Set default font/text size in RTF Control

≯℡__Kan透↙ 提交于 2019-12-23 03:13:06

问题


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?


回答1:


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';
};

)




回答2:


Knut's solutions works great except you have to use &#8203; instead of &shy; as you lose the font styling when clicking into the field and start typing.



来源:https://stackoverflow.com/questions/18156462/set-default-font-text-size-in-rtf-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!