问题
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