简体   繁体   English

angular6 应用程序中的 tinyMCE 没有使字体变粗

[英]tinyMCE in angular6 application not making font bold

I am new to StackOverflow, please excuse me for any typos.我是 StackOverflow 的新手,如有错别字请见谅。

Well, I am developing angular 6 application therein I am having tinyMCE version 5 editor confgured as below:好吧,我正在开发 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,
    });

On setup function...在设置功能...

 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;
      }
    });

  }

However, when I send content to the after selecting text inside editor and making them bold does not work, I mean when I debug my application it simply sends the text as.但是,当我将内容发送到在编辑器中选择文本并使其加粗后不起作用时,我的意思是当我调试我的应用程序时,它只是将文本发送为。

<p>Hello</p>

However I am expecting it to have但是我期待它有

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

Attachced is the screenshot of my tinyMCE editor embedded in angular 6 chat application.附件是我的 tinyMCE 编辑器嵌入 angular 6 聊天应用程序的屏幕截图。

tinyMCE picture tinyMCE 图片

I solved it by changing below init property of tinymce.我通过更改tinymce的init属性来解决它。

 schema:'html5',
formats: {

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

this helped me to create bold , italic and underline.这帮助我创建了粗体、斜体和下划线。

Hope this helps to someone who needs it.希望这对需要它的人有所帮助。

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM