【问题标题】:Configure the user's default choice on tinyMCE toolbar在 tinyMCE 工具栏上配置用户的默认选择
【发布时间】:2022-01-23 18:57:38
【问题描述】:

我正在使用 TinyMCE v5。默认情况下,选择的样式是“段落”,如下图所示: [tinyMCE toolbar, as the user sees before he mades any format configuration]

但我知道我的用户都会更喜欢使用“Div”样式。所以我希望默认选择“Div”。因此,工具栏应如下图所示: [tinyMCE toolbar, as I want it to be configured by default]

有可能吗? 我在tinyMCE documentation 中没有找到我的答案。 如果您希望默认选择“粗体”按钮等,则同样的问题。

谢谢!

【问题讨论】:

    标签: tinymce tinymce-5


    【解决方案1】:

    要将默认的<p> 块替换为<div>,请使用forced_root_block:https://www.tiny.cloud/docs-3x/reference/Configuration3x/Configuration3x@forced_root_block/

    tinymce.init({
      // ...
      forced_root_block : 'div'
    });
    

    要默认选择粗体按钮,你可以使用execCommand: https://www.tiny.cloud/docs/api/tinymce/tinymce.editor/#execcommand

    tinymce.init({
        // ...
        setup: function(editor) {
          editor.on('init', function() {
              this.execCommand('Bold');
          });
        }
    });
    

    结合两者的小提琴示例:https://fiddle.tiny.cloud/YShaab/1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 1970-01-01
      • 2012-03-05
      • 1970-01-01
      • 2019-12-30
      • 1970-01-01
      相关资源
      最近更新 更多