✏️ 正在编辑: plugin.js
路径:
/srv/systems_dir/yuppiecred/public/components/tinymce/plugins/charactercount/plugin.js
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
tinymce.PluginManager.add('charactercount', function (editor) { var self = this; function update() { editor.theme.panel.find('#charactercount').text(['Characters: {0}', self.getCount()]); } editor.on('init', function () { var statusbar = editor.theme.panel && editor.theme.panel.find('#statusbar')[0]; if (statusbar) { window.setTimeout(function () { statusbar.insert({ type: 'label', name: 'charactercount', text: ['Characters: {0}', self.getCount()], classes: 'charactercount', disabled: editor.settings.readonly }, 0); editor.on('setcontent beforeaddundo', update); editor.on('keyup', function (e) { update(); }); }, 0); } }); self.getCount = function () { var tx = editor.getContent({ format: 'raw' }); var decoded = decodeHtml(tx); // here we strip all HTML tags var decodedStripped = decoded.replace(/(<([^>]+)>)/ig, "").trim(); var tc = decodedStripped.length; return tc; }; function decodeHtml(html) { var txt = document.createElement("textarea"); txt.innerHTML = html; return txt.value; } });
💾 保存文件
← 返回文件管理器