我定义了多个工具栏,默认工具栏目前为MyToolbar
config.toolbar = 'MyToolbar';
但是如何在页面加载中选择任何这些配置?
我试过$('#TextBox1').ckeditor(function () { }, { toolbar: 'Basic' });
正如Configure the toolbar when the editor is configured through jQuery
但是这不会覆盖默认的MyToolbar。我也尝试删除config.toolbar = 'MyToolbar';
,但没有运气。
我在控制台中收到Uncaught TypeError: undefined is not a function
,但我不知道为什么。
我目前有此代码显示默认的CKEditor实例:
<script src="/ckeditor/ckeditor.js"></script>
<asp:TextBox ID="TextBox1" ClientIDMode="Static" CssClass="ckeditor" TextMode="MultiLine" runat="server"></asp:TextBox>
config.js
CKEDITOR.editorConfig = function (config) {
config.toolbar = 'MyToolbar';
config.toolbar_MyToolbar =
[
{ name: 'document', items: ['NewPage', 'Preview'] },
{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
{ name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'Scayt'] },
{
name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'
, 'Iframe']
},
'/',
{ name: 'styles', items: ['Styles', 'Format'] },
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', '-', 'RemoveFormat'] },
{ name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote'] },
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
{ name: 'tools', items: ['Maximize', '-', 'About'] }
];
config.toolbar_Full =
[
{ name: 'document', items: ['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'] },
{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
{ name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'] },
{
name: 'forms', items: ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
'HiddenField']
},
'/',
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
{
name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv',
'-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl']
},
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
{ name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe'] },
'/',
{ name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] },
{ name: 'colors', items: ['TextColor', 'BGColor'] },
{ name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'About'] }
];
config.toolbar_Basic =
[
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', '-', 'About']
];
};
更新
我忘记了<script src="adapters/jquery.js"></script>
。如下所述:http://docs.ckeditor.com/#!/guide/dev_jquery
它现在有效。