TinyMCE: when selecting Bold, how to use different font instead of applying normal bold style?

社会主义新天地 提交于 2019-12-12 00:38:02

问题


When I select Bold in TinyMCE I want to make it use a different font instead of just using the bold variant of current font - how can I do that?


回答1:


// get the current editor
var editor = tinyMce.activeEditor;

// get the editor formatter
var f = editor.formatter;

f.register('customBold', {
    inline: 'span',
    selector: 'span,p',
    styles: { fontWeight: 'bold',fontFamily: 'arial'.....your custom style },
});

editor.addCommand('customBold',function(){
    editor.applyFormat(name)
});

// add a button in the toolbar
editor.addButton(customBtn, {
    tooltip: 'My custom bold',
    icon: 'bold',
    cmd: customBold
});



回答2:


Look at the source code of your bold text, it could be marked

<strong>, <b>, <span style="*"> or else

depending on the settings of your Tiny Instance.

When you know this, you should be able to set the font in the editor stylesheet.

For example

p strong{
  font-weight:400;
  font-family: ...;
}


来源:https://stackoverflow.com/questions/41739352/tinymce-when-selecting-bold-how-to-use-different-font-instead-of-applying-norm

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