【发布时间】:2019-05-01 04:14:35
【问题描述】:
当我在 TinyMCE 中选择粗体时,我想让它使用不同的字体,而不是仅使用当前字体的粗体变体 - 我该怎么做?
【问题讨论】:
-
您需要创建自己的自定义工具栏按钮来执行此操作......粗体按钮就是这样做的(粗体文本)......您要求的不是粗体文本。下面是一个如何添加自定义工具栏按钮的简单示例:tinymce.com/docs/demo/custom-toolbar-button
当我在 TinyMCE 中选择粗体时,我想让它使用不同的字体,而不是仅使用当前字体的粗体变体 - 我该怎么做?
【问题讨论】:
// 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
});
【讨论】:
看你的粗体文字的源代码,它可以被标记
<strong>, <b>, <span style="*"> or else
取决于您的 Tiny Instance 的设置。
当您知道这一点后,您应该可以在编辑器样式表中设置字体了。
例如
p strong{
font-weight:400;
font-family: ...;
}
【讨论】: