【发布时间】:2010-05-04 17:26:30
【问题描述】:
var wgetFrame = window.frames[0] wframeDoc = wgetFrame.document;
editor.focus();
editor.execCommand('bold');
wframeDoc.execCommand('forecolor',false,'#00ff00');
wframeDoc.execCommand('JustifyCenter', false, null);
wframeDoc.execCommand('fontsize', false, 15);
(我在CKEditor中使用上面的代码作为插件)
bold、forecolor 和 JustifyCenter,它们都正确显示,选中的文本被 span 元素包裹
但是当应用 fontsize 命令时,被选中的会进入字体元素内部, 我知道这是正确的,但它需要在 span 元素内
我需要知道为什么粗体、前景色和 JustifyCenter 被 span 和 fontsize 包裹而不是!!
如果还有其他方法可以应用这种样式
(ps:我在初始化ckeditor时运行这些命令,即使editort不包含任何文本,当你编写时应用定义的样式)
CKEDITOR.editorConfig = function(config) {
CKEDITOR.addStylesSet('customStyles',
[
{ name: 'Header 1', element: 'h1' },
{ name: 'Header 2', element: 'h2' },
{ name: 'Header 3', element: 'h3' },
{ name: 'Text', element: 'p' },
{ name: 'Left Align', element: 'img', attributes: { 'class': 'ImageLeft'} },
{ name: 'Right Align', element: 'img', attributes: { 'class': 'ImageRight'} }
]);
};
我可以应用 editor.execCommand("Header 1"); ??
【问题讨论】: