Word count integration

This commit is contained in:
yflory
2019-11-22 15:50:32 +01:00
parent 9f903b645a
commit a573255072
3 changed files with 28 additions and 274 deletions

View File

@@ -616,6 +616,8 @@ define([
var patch = (DD).diff(inner, userDocStateDom);
(DD).apply(inner, patch);
editor.fire('cp-wc'); // Update word count
// Restore cursor position
var newText = inner.outerHTML;
var ops = ChainPad.Diff.diff(oldText, newText);
@@ -835,9 +837,20 @@ define([
inner.addEventListener('input', function () {
framework.localChange();
updateCursor();
editor.fire('cp-wc'); // Update word count
});
editor.on('change', framework.localChange);
var wordCount = h('span.cp-app-pad-wordCount');
$('.cke_toolbox_main').append(wordCount);
editor.on('cp-wc-update', function (event) {
if (!editor.wordCount || typeof (editor.wordCount.wordCount) === "undefined") {
wordCount.innerText = '';
return;
}
wordCount.innerText = Messages._getKey('pad_wordCount', [editor.wordCount.wordCount]);
});
// export the typing tests to the window.
// call like `test = easyTest()`
// terminate the test like `test.cancel()`