Ckeditor 自定义编辑器插件按钮未显示
感觉我应该已经能找到这个了。我需要为CKEditor创建一个自定义插件(我使用的是4.3.1)。为了开始,我使用了这里的指南()。我下载了代码并将其放在我的ckeditor\plugins文件夹中。所以,现在我有了ckeditor\plugins\abbr。我不确定我在做什么,但是按钮没有显示在工具栏中。代码如下。我的问题是,我应该在哪里定义“abbr”额外插件?我是否在定义样式表解析器的_Edit.cshtml页面中执行此操作?或者把它放在config.js中?鉴于下面的设置,按钮不应该显示在源按钮旁边吗?我需要将它包含在config.js中吗?还是插件代码会处理这个问题 一直在做一些游戏,如果我使用完整的工具栏,它会显示出来,但当我自定义它时,它不会显示出来 config.jsCkeditor 自定义编辑器插件按钮未显示,ckeditor,Ckeditor,感觉我应该已经能找到这个了。我需要为CKEditor创建一个自定义插件(我使用的是4.3.1)。为了开始,我使用了这里的指南()。我下载了代码并将其放在我的ckeditor\plugins文件夹中。所以,现在我有了ckeditor\plugins\abbr。我不确定我在做什么,但是按钮没有显示在工具栏中。代码如下。我的问题是,我应该在哪里定义“abbr”额外插件?我是否在定义样式表解析器的_Edit.cshtml页面中执行此操作?或者把它放在config.js中?鉴于下面的设置,按钮不应该显示在
CKEDITOR.editorConfig = function (config) {
config.toolbar = 'MyToolbar';
config.forcePasteAsPlainText = true;
//config.extraPlugins = 'abbr';
config.ignoreEmptyParagraph = 'true'
config.toolbar_MyToolbar =
[
{ name: 'document', items: ['Preview', 'Print'] },
{ name: 'clipboard', items: ['Cut', 'Copy', 'PasteText', '-', 'Undo', 'Redo'] },
{ name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'] },
{ name: 'basicstyles', items : [ 'Bold','Italic','Subscript','Superscript','-','RemoveFormat' ] },
'/',
{ name: 'insert', items: ['Table', 'SpecialChar'] },
{ name: 'styles', items : [ 'Styles'] }
, { name: 'source', items: ['Source', '-', 'abbr'] }
];
};
_Edit.cshtml
@Html.TextAreaFor(e => e.Narrative, 10, 10, null)
<script type="text/javascript">
CKEDITOR.replace('Narrative', {
extraPlugins: 'stylesheetparser,abbr',
// Stylesheet for the contents.
contentsCss: '@Href("~/content/"+@Model.CssFile)',
stylesheetParser_skipSelectors: '',
disableNativeSpellChecker: false,
// Do not load the default Styles configuration.
stylesSet: [],
height: '600px',
width: '100%'
});
</script>
发现问题(在CKEditor支持的帮助下)。我本来打算删除我的问题,但万一将来有人碰到这个问题,我就不提了。我使用的是“逐项”配置(),这意味着我必须定义按钮在配置中的位置。插件名为“abbr”,但按钮本身名为“abbr”-大写a。当我将配置文件中的行更改为“{name:'source',items:['source','-','abbr']}”时,它工作了。案件很重要。吸取的教训。在这里也吸取了教训。谢谢你的研究!这对我有帮助。它需要添加到文档状态。
CKEDITOR.plugins.add( 'abbr', {
// Register the icons.
icons: 'abbr',
// The plugin initialization logic goes inside this method.
init: function( editor ) {
// Define an editor command that opens our dialog.
editor.addCommand( 'abbr', new CKEDITOR.dialogCommand( 'abbrDialog' ) );
// Create a toolbar button that executes the above command.
editor.ui.addButton( 'Abbr', {
// The text part of the button (if available) and tooptip.
label: 'Insert Abbreviation',
// The command to execute on click.
command: 'abbr',
// The button placement in the toolbar (toolbar group name).
toolbar: 'source'
});
// Register our dialog file. this.path is the plugin folder path.
CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' );
}
});