ckeditor character count on multiple textareas with wordcount 插件

ckeditor character count on multiple textareas with wordcount plugin

我在单个页面上有多个 ckeditor textareas,我需要限制所有它们的组合字符数。 是否可以使用 ckeditor 来完成,或者是否可以将该值赋给 javascript 变量,以便我可以添加它们并以这种方式创建警报?

如果您知道每个 CKEditor 实例的 ID,那么您可以使用 getData 方法,或者您可以使用 CKEDITOR.instances 获取页面上的所有实例并根据需要设置逻辑。

for (var id in CKEDITOR.instances) {
     console.log(CKEDITOR.instances[id].getData().replace(/<[^>]*>|\s/g, '').length);
}