繁体   English   中英

TinyMCE getContent 返回 Null

[英]TinyMCE getContent Returns Null

我正在尝试从 TinyMCE 编辑器中获取原始 HTML。 这是我正在使用的代码

      tinymce.init({
          selector: 'textarea',
          plugins: 'a11ychecker advcode casechange export formatpainter image editimage linkchecker autolink lists checklist media mediaembed pageembed permanentpen powerpaste table advtable tableofcontents tinycomments tinymcespellchecker',
          toolbar: 'a11ycheck addcomment showcomments casechange checklist code export formatpainter image editimage pageembed permanentpen table tableofcontents',
          toolbar_mode: 'floating',
          tinycomments_mode: 'embedded',
          tinycomments_author: 'Author name',

         
        });

        console.log (tinymce.get('content-text'))


在控制台中它显示为空。 我还使用了活动编辑器功能。

console.log (tinymce.activeEditor.getContent())

这样做会给我一个错误

Uncaught TypeError: Cannot read properties of null (reading 'getContent')
    at contact-us.html:62:43

我正在使用 TinyMCE 6.1 版

<script>放在<textarea>下方,然后重试。

或者尝试将 ID 添加到textarea标签上,例如

<textarea id="tinyarea">
...
</textarea>

并将js中的选择器更改为

selector: 'textarea#tinyarea',

tinyMCE

[英]tinyMCE turning <i> into <em> on getContent

暂无
暂无

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

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