在RTF控件中设置默认字体/文本大小 [英] Set default font/text size in RTF Control
问题描述
我发现此答案 Rich Text字段的默认字体,但它不不帮我。我需要能够在应用程序中设置它,因为这是一个XPiNC(对于那些在CKEditor论坛中阅读此文档的人来说,是Xpages的Notes客户端)应用程序,我不能控制超出IBM Notes 8.5.3FP4的系统上的内容。因为config.js是CKEditor的服务器端,我需要在代码或css中这样做。
这是可能吗?
到你的XPage。它将在CKEditor字段中设置初始字体和文本大小。
< xp:scriptBlock
id =scriptBlock1 >
< xp:this.value>
<![CDATA [XSP.addOnLoad(function(){
try {
CKEDITOR.on('instanceReady',function(ev){
if .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>
窍门是当字段为空时将初始值设置为字段。 >
(不幸的是,所有尝试设置 config.font_defaultLabel
和 config.fontSize_defaultLabel
不要工作方式:
CKEDITOR.editorConfig = function(config){
config.font_defaultLabel ='Comic Sans MS,cursive';
config.fontSize_defaultLabel ='36px';
};
)
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?
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;">­</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';
};
)
这篇关于在RTF控件中设置默认字体/文本大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!