Set default font/text size in RTF Control

2019-06-06 07:50发布

I found this answer Default font for Rich Text field but it doesn't help me. I need to be able to set it in the application as this is an XPiNC (Xpages in Notes Client for those reading this in the CKEditor forum) app and I have no control over what is on the system beyond IBM Notes 8.5.3FP4. Because the config.js is server side for the CKEditor, I need to do this in the code or css somehow.

Is this even possible?

2条回答
劫难
2楼-- · 2019-06-06 08:27

Knut's solutions works great except you have to use ​ instead of ­ as you lose the font styling when clicking into the field and start typing.

查看更多
在下西门庆
3楼-- · 2019-06-06 08:41

Add the following script block to your XPage. It will set the initial font and text size in CKEditor field.

<xp:scriptBlock
    id="scriptBlock1">
    <xp:this.value>
        <![CDATA[XSP.addOnLoad(function() {
                    try{
                        CKEDITOR.on( 'instanceReady', function( ev ) {
                            if (ev.editor.getData() === "") {
                                ev.editor.setData('<span style="font-family: Comic Sans MS, cursive; font-size:36px;">&shy;</span>');
                            }
                        });
                    }catch(e){
                        console.log(e);
                    }
    })]]></xp:this.value>
</xp:scriptBlock>

The trick is to set an initial value to field with a style when field is empty.

(Unfortunately, all attempts to set config.font_defaultLabel and config.fontSize_defaultLabel don't work like:

CKEDITOR.editorConfig = function( config ) {
        config.font_defaultLabel = 'Comic Sans MS, cursive';
        config.fontSize_defaultLabel = '36px';
};

)

查看更多
登录 后发表回答