所以 TinyMCE 5.0.6 或更高版本包含一个wordcount 插件。
我想用它来计算字符并将字符数回显到屏幕上。
显然还有一个我可以监听的WordCountUpdate事件。
如何收听“WordCountUpdate”事件?
所以 TinyMCE 5.0.6 或更高版本包含一个wordcount 插件。
我想用它来计算字符并将字符数回显到屏幕上。
显然还有一个我可以监听的WordCountUpdate事件。
如何收听“WordCountUpdate”事件?
刚刚解决了,这是其他人的示例:
<script>
tinymce.init({
selector: 'textarea',
plugins: "wordcount",
toolbar: "wordcount",
init_instance_callback: function (editor) {
var charcount = document.getElementById("charcount");
editor.on('WordCountUpdate', function (e) {
charcount.innerHTML = e.wordCount.characters;
console.log(e);
});
}
});
</script>