Fonts 使用execk命令应用字体大小

Fonts 使用execk命令应用字体大小,fonts,ckeditor,Fonts,Ckeditor,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,

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中的插件)

粗体、前景色和JustifyCenter,它们都正确地呈现,所选文本由span元素包装

但是当应用fontsize命令时,所选的字符会进入font元素中, 我知道这是正确的,但它需要在跨度元素内

我需要知道为什么粗体、前景色和JustifyCenter被span和fontsize包裹,而不是

还有,如果有其他方法来应用这种风格

(请注意:我在初始化ckeditor时运行这些命令,即使editort不包含任何文本,当您写入应用了定义的样式时)


})

我可以应用editor.execCommand(“头1”)

来自

onClick : function( value ) {
    editor.focus();
    editor.fire( 'saveSnapshot' );

    var style = styles[ value ];

    if ( this.getValue() == value )
        style.remove( editor.document );
    else
        style.apply( editor.document );

    editor.fire( 'saveSnapshot' );
}
在_source\plugins\font\plugin.js中,我找到了一种方法,但似乎有点长

editor.focus();
editor.fire('saveSnapshot');

var styles = new CKEDITOR.style({
    element     : 'span',
    styles      : { 'font-size' : '#(size)' },
    overrides   : [ { element : 'font', attributes : { 'size' : null } } ]
}, {size: '72px'});

styles.apply( editor.document );
editor.fire('saveSnapshot');
我现在遇到的问题是编辑器焦点问题,当你使用编辑器时,你会看到应用的字体大小,但是如果你点击编辑器外的元素并返回,光标会离开span style=“72px”并从中创建一个新的p元素

onClick : function( value ) {
    editor.focus();
    editor.fire( 'saveSnapshot' );

    var style = styles[ value ];

    if ( this.getValue() == value )
        style.remove( editor.document );
    else
        style.apply( editor.document );

    editor.fire( 'saveSnapshot' );
}
在_source\plugins\font\plugin.js中,我找到了一种方法,但似乎有点长

editor.focus();
editor.fire('saveSnapshot');

var styles = new CKEDITOR.style({
    element     : 'span',
    styles      : { 'font-size' : '#(size)' },
    overrides   : [ { element : 'font', attributes : { 'size' : null } } ]
}, {size: '72px'});

styles.apply( editor.document );
editor.fire('saveSnapshot');
我现在遇到的问题是编辑器焦点问题,当你使用编辑器时,你会看到应用的字体大小,但是如果你点击编辑器外的一个元素并返回,光标会离开span style=“72px”并创建一个新的p元素