【问题标题】:TinyMCE: when selecting Bold, how to use different font instead of applying normal bold style?Tinymce:选择粗体时,如何使用不同的字体而不是应用正常的粗体样式?
【发布时间】:2019-05-01 04:14:35
【问题描述】:

当我在 TinyMCE 中选择粗体时,我想让它使用不同的字体,而不是仅使用当前字体的粗体变体 - 我该怎么做?

【问题讨论】:

  • 您需要创建自己的自定义工具栏按钮来执行此操作......粗体按钮就是这样做的(粗体文本)......您要求的不是粗体文本。下面是一个如何添加自定义工具栏按钮的简单示例:tinymce.com/docs/demo/custom-toolbar-button

标签: fonts tinymce tinymce-4


【解决方案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】:

    看你的粗体文字的源代码,它可以被标记

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

    取决于您的 Tiny Instance 的设置。

    当您知道这一点后,您应该可以在编辑器样式表中设置字体了。

    例如

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

    【讨论】:

      猜你喜欢
      • 2015-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 2011-08-21
      • 2019-06-18
      相关资源
      最近更新 更多