【问题标题】:tinyMCE in angular6 application not making font boldangular6应用程序中的tinyMCE没有使字体变粗
【发布时间】:2020-01-17 05:19:35
【问题描述】:

我是 StackOverflow 的新手,如有错别字,请见谅。

好吧,我正在开发 Angular 6 应用程序,我的 tinyMCE 版本 5 编辑器配置如下:

  tinymce.init({
      selector: '.TinyMCE',
      mode: 'exact',
      height: 150,
      menubar: false,
      theme: 'silver',
      statusbar: false,
      plugins: 'placeholder',
      content_style:
        '#tinymce-body { min-height: 0px; } .mce-content-body { color: rgba(101, 99, 93, 1); overflow-x: hidden !important; }',
      body_id: 'tinymce-body',
      toolbar: 'bold underline italic addAttachment',
      valid_elements: 'strong/b,i/italic,p,br',
      inline_styles: false,
      formats: {
        underline: { inline: 'u', exact: true },
        italic: { inline: 'i', exact: true },
        bold: { inline: 'b', exact: true }
        },
      elements: this.elementID,
      setup: this.tinyMCESetup.bind(this),
      //  setup: this.getSetup,
    });

关于设置功能...

 tinyMCESetup(ed) {
    ed.on('keyup', this.tinyMCEOnKeyup.bind(this));
    this.editor = ed;
    //starts  here
    ed.ui.registry.addButton('Bold', {
      text: '',
      onAction: () => {
        ed.execCommand('Bold');
        return false;
      }
    });

  }

但是,当我在编辑器中选择文本并将其设置为粗体后将内容发送到时不起作用,我的意思是当我调试我的应用程序时,它只是将文本发送为。

<p>Hello</p>

但我希望它有

<p><strong>Hello</strong></p>

附件是我嵌入到 Angular 6 聊天应用程序中的 tinyMCE 编辑器的屏幕截图。

tinyMCE picture

【问题讨论】:

    标签: angular tinymce


    【解决方案1】:

    我通过更改以下 tinymce 的 init 属性来解决它。

     schema:'html5',
    formats: {
    
            underline: { inline: 'u', exact: true },
            italic: { inline: 'em', exact: true },
            bold: { inline: 'b', exact: true }
            }
    

    这帮助我创建了粗体、斜体和下划线。

    希望这对需要它的人有所帮助。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-10
      • 1970-01-01
      • 2013-08-29
      • 1970-01-01
      • 2019-10-28
      • 2018-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多