统计tinymce中的字符数

bɪˈ*_*ɪnə 4 javascript jquery tinymce tinymce-4

有什么方法可以计算在tinymce编辑器中输入的字符数。我只是想设置最低字符要求。或者如何tinyMCE.activeEditor.getContent()正确使用此目的。

rop*_*rzh 7

我相信更好的方法是使用getContent api:

// Get the HTML contents of the currently active editor
tinymce.activeEditor.getContent().length

// Get the raw text of the currently active editor
tinymce.activeEditor.getContent({format: 'text'}).length;

// Get content of a specific editor:
tinymce.get('content id').getContent().length
Run Code Online (Sandbox Code Playgroud)

请注意第二个示例中参数的用法format,以便获取原始文本而不是带有 HTML 标记的解析文本。