@ckeditor/ckeditor5-word-count 41.2.0 → 41.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
package/dist/index.css ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
package/dist/index.js ADDED
@@ -0,0 +1,246 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
6
+ import { Template, View } from '@ckeditor/ckeditor5-ui/dist/index.js';
7
+ import { env } from '@ckeditor/ckeditor5-utils/dist/index.js';
8
+ import { throttle, isElement } from 'lodash-es';
9
+
10
+ /**
11
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
12
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
13
+ */
14
+ /**
15
+ * Returns a plain text representation of an element and its children.
16
+ *
17
+ * @returns Plain text representing the model's data.
18
+ */
19
+ function modelElementToPlainText(item) {
20
+ if (item.is('$text') || item.is('$textProxy')) {
21
+ return item.data;
22
+ }
23
+ const element = item;
24
+ let text = '';
25
+ let prev = null;
26
+ for (const child of element.getChildren()) {
27
+ const childText = modelElementToPlainText(child);
28
+ // If last block was finish, start from new line.
29
+ if (prev && prev.is('element')) {
30
+ text += '\n';
31
+ }
32
+ text += childText;
33
+ prev = child;
34
+ }
35
+ return text;
36
+ }
37
+
38
+ /**
39
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
40
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
41
+ */
42
+ /**
43
+ * The word count plugin.
44
+ *
45
+ * This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.
46
+ * It also provides an HTML element that updates its state whenever the editor content is changed.
47
+ *
48
+ * The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.
49
+ * The number of words and characters in your text are determined based on the created plain text. Please keep in mind
50
+ * that every block in the editor is separated with a newline character, which is included in the calculation.
51
+ *
52
+ * Here are some examples of how the word and character calculations are made:
53
+ *
54
+ * ```html
55
+ * <paragraph>foo</paragraph>
56
+ * <paragraph>bar</paragraph>
57
+ * // Words: 2, Characters: 7
58
+ *
59
+ * <paragraph><$text bold="true">foo</$text>bar</paragraph>
60
+ * // Words: 1, Characters: 6
61
+ *
62
+ * <paragraph>*&^%)</paragraph>
63
+ * // Words: 0, Characters: 5
64
+ *
65
+ * <paragraph>foo(bar)</paragraph>
66
+ * //Words: 1, Characters: 8
67
+ *
68
+ * <paragraph>12345</paragraph>
69
+ * // Words: 1, Characters: 5
70
+ * ```
71
+ */
72
+ class WordCount extends Plugin {
73
+ /**
74
+ * @inheritDoc
75
+ */
76
+ constructor(editor) {
77
+ super(editor);
78
+ this.set('characters', 0);
79
+ this.set('words', 0);
80
+ // Don't wait for the #update event to set the value of the properties but obtain it right away.
81
+ // This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.
82
+ // If not accessed directly, the properties will be refreshed upon #update anyway.
83
+ Object.defineProperties(this, {
84
+ characters: {
85
+ get() {
86
+ return (this.characters = this._getCharacters(this._getText()));
87
+ }
88
+ },
89
+ words: {
90
+ get() {
91
+ return (this.words = this._getWords(this._getText()));
92
+ }
93
+ }
94
+ });
95
+ this.set('_wordsLabel', undefined);
96
+ this.set('_charactersLabel', undefined);
97
+ this._config = editor.config.get('wordCount') || {};
98
+ this._outputView = undefined;
99
+ this._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ?
100
+ // Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).
101
+ // Groups:
102
+ // {L} - Any kind of letter from any language.
103
+ // {N} - Any kind of numeric character in any script.
104
+ new RegExp('([\\p{L}\\p{N}]+\\S?)+', 'gu') :
105
+ /([a-zA-Z0-9À-ž]+\S?)+/gu;
106
+ }
107
+ /**
108
+ * @inheritDoc
109
+ */
110
+ static get pluginName() {
111
+ return 'WordCount';
112
+ }
113
+ /**
114
+ * @inheritDoc
115
+ */
116
+ init() {
117
+ const editor = this.editor;
118
+ editor.model.document.on('change:data', throttle(this._refreshStats.bind(this), 250));
119
+ if (typeof this._config.onUpdate == 'function') {
120
+ this.on('update', (evt, data) => {
121
+ this._config.onUpdate(data);
122
+ });
123
+ }
124
+ if (isElement(this._config.container)) {
125
+ this._config.container.appendChild(this.wordCountContainer);
126
+ }
127
+ }
128
+ /**
129
+ * @inheritDoc
130
+ */
131
+ destroy() {
132
+ if (this._outputView) {
133
+ this._outputView.element.remove();
134
+ this._outputView.destroy();
135
+ }
136
+ super.destroy();
137
+ }
138
+ /**
139
+ * Creates a self-updating HTML element. Repeated executions return the same element.
140
+ * The returned element has the following HTML structure:
141
+ *
142
+ * ```html
143
+ * <div class="ck ck-word-count">
144
+ * <div class="ck-word-count__words">Words: 4</div>
145
+ * <div class="ck-word-count__characters">Characters: 28</div>
146
+ * </div>
147
+ * ```
148
+ */
149
+ get wordCountContainer() {
150
+ const editor = this.editor;
151
+ const t = editor.t;
152
+ const displayWords = editor.config.get('wordCount.displayWords');
153
+ const displayCharacters = editor.config.get('wordCount.displayCharacters');
154
+ const bind = Template.bind(this, this);
155
+ const children = [];
156
+ if (!this._outputView) {
157
+ this._outputView = new View();
158
+ if (displayWords || displayWords === undefined) {
159
+ this.bind('_wordsLabel').to(this, 'words', words => {
160
+ return t('Words: %0', words);
161
+ });
162
+ children.push({
163
+ tag: 'div',
164
+ children: [
165
+ {
166
+ text: [bind.to('_wordsLabel')]
167
+ }
168
+ ],
169
+ attributes: {
170
+ class: 'ck-word-count__words'
171
+ }
172
+ });
173
+ }
174
+ if (displayCharacters || displayCharacters === undefined) {
175
+ this.bind('_charactersLabel').to(this, 'characters', words => {
176
+ return t('Characters: %0', words);
177
+ });
178
+ children.push({
179
+ tag: 'div',
180
+ children: [
181
+ {
182
+ text: [bind.to('_charactersLabel')]
183
+ }
184
+ ],
185
+ attributes: {
186
+ class: 'ck-word-count__characters'
187
+ }
188
+ });
189
+ }
190
+ this._outputView.setTemplate({
191
+ tag: 'div',
192
+ attributes: {
193
+ class: [
194
+ 'ck',
195
+ 'ck-word-count'
196
+ ]
197
+ },
198
+ children
199
+ });
200
+ this._outputView.render();
201
+ }
202
+ return this._outputView.element;
203
+ }
204
+ _getText() {
205
+ let txt = '';
206
+ for (const root of this.editor.model.document.getRoots()) {
207
+ if (txt !== '') {
208
+ // Add a delimiter, so words from each root are treated independently.
209
+ txt += '\n';
210
+ }
211
+ txt += modelElementToPlainText(root);
212
+ }
213
+ return txt;
214
+ }
215
+ /**
216
+ * Determines the number of characters in the current editor's model.
217
+ */
218
+ _getCharacters(txt) {
219
+ return txt.replace(/\n/g, '').length;
220
+ }
221
+ /**
222
+ * Determines the number of words in the current editor's model.
223
+ */
224
+ _getWords(txt) {
225
+ const detectedWords = txt.match(this._wordsMatchRegExp) || [];
226
+ return detectedWords.length;
227
+ }
228
+ /**
229
+ * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
230
+ * It also fires the {@link #event:update}.
231
+ *
232
+ * @fires update
233
+ */
234
+ _refreshStats() {
235
+ const txt = this._getText();
236
+ const words = this.words = this._getWords(txt);
237
+ const characters = this.characters = this._getCharacters(txt);
238
+ this.fire('update', {
239
+ words,
240
+ characters
241
+ });
242
+ }
243
+ }
244
+
245
+ export { WordCount };
246
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js","../src/utils.ts","../src/wordcount.ts"],"names":[],"mappings":";;;;AAAA,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAChE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACtE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9D,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAChD;ACJA,CAAA,CAAA,CAAA;ADMA,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;AACrF,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG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rB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG","file":"index.js.map","sourcesContent":["import { Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';\nimport { Template, View } from '@ckeditor/ckeditor5-ui/dist/index.js';\nimport { env } from '@ckeditor/ckeditor5-utils/dist/index.js';\nimport { throttle, isElement } from 'lodash-es';\n\n/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n/**\n * Returns a plain text representation of an element and its children.\n *\n * @returns Plain text representing the model's data.\n */\nfunction modelElementToPlainText(item) {\n if (item.is('$text') || item.is('$textProxy')) {\n return item.data;\n }\n const element = item;\n let text = '';\n let prev = null;\n for (const child of element.getChildren()) {\n const childText = modelElementToPlainText(child);\n // If last block was finish, start from new line.\n if (prev && prev.is('element')) {\n text += '\\n';\n }\n text += childText;\n prev = child;\n }\n return text;\n}\n\n/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n/**\n * The word count plugin.\n *\n * This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.\n * It also provides an HTML element that updates its state whenever the editor content is changed.\n *\n * The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.\n * The number of words and characters in your text are determined based on the created plain text. Please keep in mind\n * that every block in the editor is separated with a newline character, which is included in the calculation.\n *\n * Here are some examples of how the word and character calculations are made:\n *\n * ```html\n * <paragraph>foo</paragraph>\n * <paragraph>bar</paragraph>\n * // Words: 2, Characters: 7\n *\n * <paragraph><$text bold=\"true\">foo</$text>bar</paragraph>\n * // Words: 1, Characters: 6\n *\n * <paragraph>*&^%)</paragraph>\n * // Words: 0, Characters: 5\n *\n * <paragraph>foo(bar)</paragraph>\n * //Words: 1, Characters: 8\n *\n * <paragraph>12345</paragraph>\n * // Words: 1, Characters: 5\n * ```\n */\nclass WordCount extends Plugin {\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n this.set('characters', 0);\n this.set('words', 0);\n // Don't wait for the #update event to set the value of the properties but obtain it right away.\n // This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.\n // If not accessed directly, the properties will be refreshed upon #update anyway.\n Object.defineProperties(this, {\n characters: {\n get() {\n return (this.characters = this._getCharacters(this._getText()));\n }\n },\n words: {\n get() {\n return (this.words = this._getWords(this._getText()));\n }\n }\n });\n this.set('_wordsLabel', undefined);\n this.set('_charactersLabel', undefined);\n this._config = editor.config.get('wordCount') || {};\n this._outputView = undefined;\n this._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ?\n // Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).\n // Groups:\n // {L} - Any kind of letter from any language.\n // {N} - Any kind of numeric character in any script.\n new RegExp('([\\\\p{L}\\\\p{N}]+\\\\S?)+', 'gu') :\n /([a-zA-Z0-9À-ž]+\\S?)+/gu;\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'WordCount';\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n editor.model.document.on('change:data', throttle(this._refreshStats.bind(this), 250));\n if (typeof this._config.onUpdate == 'function') {\n this.on('update', (evt, data) => {\n this._config.onUpdate(data);\n });\n }\n if (isElement(this._config.container)) {\n this._config.container.appendChild(this.wordCountContainer);\n }\n }\n /**\n * @inheritDoc\n */\n destroy() {\n if (this._outputView) {\n this._outputView.element.remove();\n this._outputView.destroy();\n }\n super.destroy();\n }\n /**\n * Creates a self-updating HTML element. Repeated executions return the same element.\n * The returned element has the following HTML structure:\n *\n * ```html\n * <div class=\"ck ck-word-count\">\n * \t<div class=\"ck-word-count__words\">Words: 4</div>\n * \t<div class=\"ck-word-count__characters\">Characters: 28</div>\n * </div>\n * ```\n */\n get wordCountContainer() {\n const editor = this.editor;\n const t = editor.t;\n const displayWords = editor.config.get('wordCount.displayWords');\n const displayCharacters = editor.config.get('wordCount.displayCharacters');\n const bind = Template.bind(this, this);\n const children = [];\n if (!this._outputView) {\n this._outputView = new View();\n if (displayWords || displayWords === undefined) {\n this.bind('_wordsLabel').to(this, 'words', words => {\n return t('Words: %0', words);\n });\n children.push({\n tag: 'div',\n children: [\n {\n text: [bind.to('_wordsLabel')]\n }\n ],\n attributes: {\n class: 'ck-word-count__words'\n }\n });\n }\n if (displayCharacters || displayCharacters === undefined) {\n this.bind('_charactersLabel').to(this, 'characters', words => {\n return t('Characters: %0', words);\n });\n children.push({\n tag: 'div',\n children: [\n {\n text: [bind.to('_charactersLabel')]\n }\n ],\n attributes: {\n class: 'ck-word-count__characters'\n }\n });\n }\n this._outputView.setTemplate({\n tag: 'div',\n attributes: {\n class: [\n 'ck',\n 'ck-word-count'\n ]\n },\n children\n });\n this._outputView.render();\n }\n return this._outputView.element;\n }\n _getText() {\n let txt = '';\n for (const root of this.editor.model.document.getRoots()) {\n if (txt !== '') {\n // Add a delimiter, so words from each root are treated independently.\n txt += '\\n';\n }\n txt += modelElementToPlainText(root);\n }\n return txt;\n }\n /**\n * Determines the number of characters in the current editor's model.\n */\n _getCharacters(txt) {\n return txt.replace(/\\n/g, '').length;\n }\n /**\n * Determines the number of words in the current editor's model.\n */\n _getWords(txt) {\n const detectedWords = txt.match(this._wordsMatchRegExp) || [];\n return detectedWords.length;\n }\n /**\n * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.\n * It also fires the {@link #event:update}.\n *\n * @fires update\n */\n _refreshStats() {\n const txt = this._getText();\n const words = this.words = this._getWords(txt);\n const characters = this.characters = this._getCharacters(txt);\n this.fire('update', {\n words,\n characters\n });\n }\n}\n\nexport { WordCount };\n//# sourceMappingURL=index.js.map\n","/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module word-count/utils\n */\n\nimport type { Element, Item } from 'ckeditor5/src/engine.js';\n\n/**\n * Returns a plain text representation of an element and its children.\n *\n * @returns Plain text representing the model's data.\n */\nexport function modelElementToPlainText( item: Item ): string {\n\tif ( item.is( '$text' ) || item.is( '$textProxy' ) ) {\n\t\treturn item.data;\n\t}\n\n\tconst element = item as Element;\n\tlet text = '';\n\tlet prev = null;\n\n\tfor ( const child of element.getChildren() ) {\n\t\tconst childText = modelElementToPlainText( child );\n\n\t\t// If last block was finish, start from new line.\n\t\tif ( prev && prev.is( 'element' ) ) {\n\t\t\ttext += '\\n';\n\t\t}\n\n\t\ttext += childText;\n\n\t\tprev = child;\n\t}\n\n\treturn text;\n}\n","/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module word-count/wordcount\n */\n\nimport { type DocumentChangeEvent } from 'ckeditor5/src/engine.js';\nimport { Plugin, type Editor } from 'ckeditor5/src/core.js';\nimport { Template, View } from 'ckeditor5/src/ui.js';\nimport { env } from 'ckeditor5/src/utils.js';\n\nimport { modelElementToPlainText } from './utils.js';\nimport type { WordCountConfig } from './wordcountconfig.js';\n\nimport { throttle, isElement } from 'lodash-es';\n\n/**\n * The word count plugin.\n *\n * This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.\n * It also provides an HTML element that updates its state whenever the editor content is changed.\n *\n * The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.\n * The number of words and characters in your text are determined based on the created plain text. Please keep in mind\n * that every block in the editor is separated with a newline character, which is included in the calculation.\n *\n * Here are some examples of how the word and character calculations are made:\n *\n * ```html\n * <paragraph>foo</paragraph>\n * <paragraph>bar</paragraph>\n * // Words: 2, Characters: 7\n *\n * <paragraph><$text bold=\"true\">foo</$text>bar</paragraph>\n * // Words: 1, Characters: 6\n *\n * <paragraph>*&^%)</paragraph>\n * // Words: 0, Characters: 5\n *\n * <paragraph>foo(bar)</paragraph>\n * //Words: 1, Characters: 8\n *\n * <paragraph>12345</paragraph>\n * // Words: 1, Characters: 5\n * ```\n */\nexport default class WordCount extends Plugin {\n\t/**\n\t * The number of characters in the editor.\n\t *\n\t * @observable\n\t * @readonly\n\t */\n\tdeclare public characters: number;\n\n\t/**\n\t * The number of words in the editor.\n\t *\n\t * @observable\n\t * @readonly\n\t */\n\tdeclare public words: number;\n\n\t/**\n\t * The label used to display the words value in the {@link #wordCountContainer output container}.\n\t *\n\t * @observable\n\t * @private\n\t * @readonly\n\t */\n\tdeclare public _wordsLabel: string | undefined;\n\n\t/**\n\t * The label used to display the characters value in the {@link #wordCountContainer output container}.\n\t *\n\t * @observable\n\t * @private\n\t * @readonly\n\t */\n\tdeclare public _charactersLabel: string | undefined;\n\n\t/**\n\t * The configuration of this plugin.\n\t */\n\tprivate _config: WordCountConfig;\n\n\t/**\n\t * The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.\n\t */\n\tprivate _outputView: View | undefined;\n\n\t/**\n\t * A regular expression used to recognize words in the editor's content.\n\t */\n\tprivate readonly _wordsMatchRegExp: RegExp;\n\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor: Editor ) {\n\t\tsuper( editor );\n\n\t\tthis.set( 'characters', 0 );\n\t\tthis.set( 'words', 0 );\n\n\t\t// Don't wait for the #update event to set the value of the properties but obtain it right away.\n\t\t// This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.\n\t\t// If not accessed directly, the properties will be refreshed upon #update anyway.\n\t\tObject.defineProperties( this, {\n\t\t\tcharacters: {\n\t\t\t\tget() {\n\t\t\t\t\treturn ( this.characters = this._getCharacters( this._getText() ) );\n\t\t\t\t}\n\t\t\t},\n\t\t\twords: {\n\t\t\t\tget() {\n\t\t\t\t\treturn ( this.words = this._getWords( this._getText() ) );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\n\t\tthis.set( '_wordsLabel', undefined );\n\t\tthis.set( '_charactersLabel', undefined );\n\n\t\tthis._config = editor.config.get( 'wordCount' ) || {};\n\n\t\tthis._outputView = undefined;\n\n\t\tthis._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ?\n\t\t\t// Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).\n\t\t\t// Groups:\n\t\t\t// {L} - Any kind of letter from any language.\n\t\t\t// {N} - Any kind of numeric character in any script.\n\t\t\tnew RegExp( '([\\\\p{L}\\\\p{N}]+\\\\S?)+', 'gu' ) :\n\t\t\t/([a-zA-Z0-9À-ž]+\\S?)+/gu;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get pluginName() {\n\t\treturn 'WordCount' as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic init(): void {\n\t\tconst editor = this.editor;\n\n\t\teditor.model.document.on<DocumentChangeEvent>( 'change:data', throttle( this._refreshStats.bind( this ), 250 ) );\n\n\t\tif ( typeof this._config.onUpdate == 'function' ) {\n\t\t\tthis.on<WordCountUpdateEvent>( 'update', ( evt, data ) => {\n\t\t\t\tthis._config.onUpdate!( data );\n\t\t\t} );\n\t\t}\n\n\t\tif ( isElement( this._config.container ) ) {\n\t\t\tthis._config.container!.appendChild( this.wordCountContainer );\n\t\t}\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic override destroy(): void {\n\t\tif ( this._outputView ) {\n\t\t\tthis._outputView.element!.remove();\n\t\t\tthis._outputView.destroy();\n\t\t}\n\n\t\tsuper.destroy();\n\t}\n\n\t/**\n\t * Creates a self-updating HTML element. Repeated executions return the same element.\n\t * The returned element has the following HTML structure:\n\t *\n\t * ```html\n\t * <div class=\"ck ck-word-count\">\n\t * \t<div class=\"ck-word-count__words\">Words: 4</div>\n\t * \t<div class=\"ck-word-count__characters\">Characters: 28</div>\n\t * </div>\n\t * ```\n\t */\n\tpublic get wordCountContainer(): HTMLElement {\n\t\tconst editor = this.editor;\n\t\tconst t = editor.t;\n\t\tconst displayWords = editor.config.get( 'wordCount.displayWords' );\n\t\tconst displayCharacters = editor.config.get( 'wordCount.displayCharacters' );\n\t\tconst bind = Template.bind( this, this );\n\t\tconst children = [];\n\n\t\tif ( !this._outputView ) {\n\t\t\tthis._outputView = new View();\n\n\t\t\tif ( displayWords || displayWords === undefined ) {\n\t\t\t\tthis.bind( '_wordsLabel' ).to( this, 'words', words => {\n\t\t\t\t\treturn t( 'Words: %0', words );\n\t\t\t\t} );\n\n\t\t\t\tchildren.push( {\n\t\t\t\t\ttag: 'div',\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: [ bind.to( '_wordsLabel' ) ]\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tclass: 'ck-word-count__words'\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( displayCharacters || displayCharacters === undefined ) {\n\t\t\t\tthis.bind( '_charactersLabel' ).to( this, 'characters', words => {\n\t\t\t\t\treturn t( 'Characters: %0', words );\n\t\t\t\t} );\n\n\t\t\t\tchildren.push( {\n\t\t\t\t\ttag: 'div',\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: [ bind.to( '_charactersLabel' ) ]\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tclass: 'ck-word-count__characters'\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tthis._outputView.setTemplate( {\n\t\t\t\ttag: 'div',\n\t\t\t\tattributes: {\n\t\t\t\t\tclass: [\n\t\t\t\t\t\t'ck',\n\t\t\t\t\t\t'ck-word-count'\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\tchildren\n\t\t\t} );\n\n\t\t\tthis._outputView.render();\n\t\t}\n\n\t\treturn this._outputView.element!;\n\t}\n\n\tprivate _getText(): string {\n\t\tlet txt = '';\n\n\t\tfor ( const root of this.editor.model.document.getRoots() ) {\n\t\t\tif ( txt !== '' ) {\n\t\t\t\t// Add a delimiter, so words from each root are treated independently.\n\t\t\t\ttxt += '\\n';\n\t\t\t}\n\n\t\t\ttxt += modelElementToPlainText( root );\n\t\t}\n\n\t\treturn txt;\n\t}\n\n\t/**\n\t * Determines the number of characters in the current editor's model.\n\t */\n\tprivate _getCharacters( txt: string ): number {\n\t\treturn txt.replace( /\\n/g, '' ).length;\n\t}\n\n\t/**\n\t * Determines the number of words in the current editor's model.\n\t */\n\tprivate _getWords( txt: string ): number {\n\t\tconst detectedWords = txt.match( this._wordsMatchRegExp ) || [];\n\n\t\treturn detectedWords.length;\n\t}\n\n\t/**\n\t * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.\n\t * It also fires the {@link #event:update}.\n\t *\n\t * @fires update\n\t */\n\tprivate _refreshStats(): void {\n\t\tconst txt = this._getText();\n\t\tconst words = this.words = this._getWords( txt );\n\t\tconst characters = this.characters = this._getCharacters( txt );\n\n\t\tthis.fire<WordCountUpdateEvent>( 'update', {\n\t\t\twords,\n\t\t\tcharacters\n\t\t} );\n\t}\n}\n\n/**\n * An event fired after {@link ~WordCount#words} and {@link ~WordCount#characters} are updated.\n *\n * @eventName ~WordCount#update\n */\nexport type WordCountUpdateEvent = {\n\tname: 'update';\n\targs: [ { words: number; characters: number } ];\n};\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import type { WordCount, WordCountConfig } from './index.js';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the word count feature.
10
+ * It is introduced by the {@link module:word-count/wordcount~WordCount} feature.
11
+ *
12
+ * Read more in {@link module:word-count/wordcountconfig~WordCountConfig}.
13
+ */
14
+ wordCount?: WordCountConfig;
15
+ }
16
+ interface PluginsMap {
17
+ [WordCount.pluginName]: WordCount;
18
+ }
19
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module word-count
7
+ */
8
+ export { default as WordCount, type WordCountUpdateEvent } from './wordcount.js';
9
+ export type { WordCountConfig } from './wordcountconfig.js';
10
+ import './augmentation.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module word-count/utils
7
+ */
8
+ import type { Item } from 'ckeditor5/src/engine.js';
9
+ /**
10
+ * Returns a plain text representation of an element and its children.
11
+ *
12
+ * @returns Plain text representing the model's data.
13
+ */
14
+ export declare function modelElementToPlainText(item: Item): string;
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
6
+ /**
7
+ * The word count plugin.
8
+ *
9
+ * This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.
10
+ * It also provides an HTML element that updates its state whenever the editor content is changed.
11
+ *
12
+ * The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.
13
+ * The number of words and characters in your text are determined based on the created plain text. Please keep in mind
14
+ * that every block in the editor is separated with a newline character, which is included in the calculation.
15
+ *
16
+ * Here are some examples of how the word and character calculations are made:
17
+ *
18
+ * ```html
19
+ * <paragraph>foo</paragraph>
20
+ * <paragraph>bar</paragraph>
21
+ * // Words: 2, Characters: 7
22
+ *
23
+ * <paragraph><$text bold="true">foo</$text>bar</paragraph>
24
+ * // Words: 1, Characters: 6
25
+ *
26
+ * <paragraph>*&^%)</paragraph>
27
+ * // Words: 0, Characters: 5
28
+ *
29
+ * <paragraph>foo(bar)</paragraph>
30
+ * //Words: 1, Characters: 8
31
+ *
32
+ * <paragraph>12345</paragraph>
33
+ * // Words: 1, Characters: 5
34
+ * ```
35
+ */
36
+ export default class WordCount extends Plugin {
37
+ /**
38
+ * The number of characters in the editor.
39
+ *
40
+ * @observable
41
+ * @readonly
42
+ */
43
+ characters: number;
44
+ /**
45
+ * The number of words in the editor.
46
+ *
47
+ * @observable
48
+ * @readonly
49
+ */
50
+ words: number;
51
+ /**
52
+ * The label used to display the words value in the {@link #wordCountContainer output container}.
53
+ *
54
+ * @observable
55
+ * @private
56
+ * @readonly
57
+ */
58
+ _wordsLabel: string | undefined;
59
+ /**
60
+ * The label used to display the characters value in the {@link #wordCountContainer output container}.
61
+ *
62
+ * @observable
63
+ * @private
64
+ * @readonly
65
+ */
66
+ _charactersLabel: string | undefined;
67
+ /**
68
+ * The configuration of this plugin.
69
+ */
70
+ private _config;
71
+ /**
72
+ * The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.
73
+ */
74
+ private _outputView;
75
+ /**
76
+ * A regular expression used to recognize words in the editor's content.
77
+ */
78
+ private readonly _wordsMatchRegExp;
79
+ /**
80
+ * @inheritDoc
81
+ */
82
+ constructor(editor: Editor);
83
+ /**
84
+ * @inheritDoc
85
+ */
86
+ static get pluginName(): "WordCount";
87
+ /**
88
+ * @inheritDoc
89
+ */
90
+ init(): void;
91
+ /**
92
+ * @inheritDoc
93
+ */
94
+ destroy(): void;
95
+ /**
96
+ * Creates a self-updating HTML element. Repeated executions return the same element.
97
+ * The returned element has the following HTML structure:
98
+ *
99
+ * ```html
100
+ * <div class="ck ck-word-count">
101
+ * <div class="ck-word-count__words">Words: 4</div>
102
+ * <div class="ck-word-count__characters">Characters: 28</div>
103
+ * </div>
104
+ * ```
105
+ */
106
+ get wordCountContainer(): HTMLElement;
107
+ private _getText;
108
+ /**
109
+ * Determines the number of characters in the current editor's model.
110
+ */
111
+ private _getCharacters;
112
+ /**
113
+ * Determines the number of words in the current editor's model.
114
+ */
115
+ private _getWords;
116
+ /**
117
+ * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
118
+ * It also fires the {@link #event:update}.
119
+ *
120
+ * @fires update
121
+ */
122
+ private _refreshStats;
123
+ }
124
+ /**
125
+ * An event fired after {@link ~WordCount#words} and {@link ~WordCount#characters} are updated.
126
+ *
127
+ * @eventName ~WordCount#update
128
+ */
129
+ export type WordCountUpdateEvent = {
130
+ name: 'update';
131
+ args: [{
132
+ words: number;
133
+ characters: number;
134
+ }];
135
+ };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module word-count/wordcountconfig
7
+ */
8
+ /**
9
+ * The configuration of the word count feature.
10
+ *
11
+ * ```ts
12
+ * ClassicEditor
13
+ * .create( {
14
+ * wordCount: ... // Word count feature configuration.
15
+ * } )
16
+ * .then( ... )
17
+ * .catch( ... );
18
+ * ```
19
+ *
20
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
21
+ */
22
+ export interface WordCountConfig {
23
+ /**
24
+ * This option allows for hiding the word counter. The element obtained through
25
+ * {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
26
+ * the characters part. Word counter is displayed by default when this configuration option is not defined.
27
+ *
28
+ * ```ts
29
+ * const wordCountConfig = {
30
+ * displayWords: false
31
+ * };
32
+ * ```
33
+ *
34
+ * The configuration above will result in the following container:
35
+ *
36
+ * ```html
37
+ * <div class="ck ck-word-count">
38
+ * <div class="ck-word-count__characters">Characters: 28</div>
39
+ * </div>
40
+ * ```
41
+ */
42
+ displayWords?: boolean;
43
+ /**
44
+ * This option allows for hiding the character counter. The element obtained through
45
+ * {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
46
+ * the words part. Character counter is displayed by default when this configuration option is not defined.
47
+ *
48
+ * ```ts
49
+ * const wordCountConfig = {
50
+ * displayCharacters: false
51
+ * };
52
+ * ```
53
+ *
54
+ * The configuration above will result in the following container:
55
+ *
56
+ * ```html
57
+ * <div class="ck ck-word-count">
58
+ * <div class="ck-word-count__words">Words: 4</div>
59
+ * </div>
60
+ * ```
61
+ */
62
+ displayCharacters?: boolean;
63
+ /**
64
+ * This configuration takes a function that is executed whenever the word count plugin updates its values.
65
+ * This function is called with one argument, which is an object with the `words` and `characters` keys containing
66
+ * the number of detected words and characters in the document.
67
+ *
68
+ * ```ts
69
+ * const wordCountConfig = {
70
+ * onUpdate: function( stats ) {
71
+ * doSthWithWordNumber( stats.words );
72
+ * doSthWithCharacterNumber( stats.characters );
73
+ * }
74
+ * };
75
+ * ```
76
+ */
77
+ onUpdate?: (data: {
78
+ words: number;
79
+ characters: number;
80
+ }) => void;
81
+ /**
82
+ * Allows for providing the HTML element that the
83
+ * {@link module:word-count/wordcount~WordCount#wordCountContainer word count container} will be appended to automatically.
84
+ *
85
+ * ```ts
86
+ * const wordCountConfig = {
87
+ * container: document.getElementById( 'container-for-word-count' );
88
+ * };
89
+ * ```
90
+ */
91
+ container?: HTMLElement;
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-word-count",
3
- "version": "41.2.0",
3
+ "version": "41.3.0-alpha.1",
4
4
  "description": "Word and character count feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -14,7 +14,7 @@
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
16
  "lodash-es": "4.17.21",
17
- "ckeditor5": "41.2.0"
17
+ "ckeditor5": "41.3.0-alpha.1"
18
18
  },
19
19
  "author": "CKSource (http://cksource.com/)",
20
20
  "license": "GPL-2.0-or-later",
@@ -26,6 +26,7 @@
26
26
  "directory": "packages/ckeditor5-word-count"
27
27
  },
28
28
  "files": [
29
+ "dist",
29
30
  "lang",
30
31
  "src/**/*.js",
31
32
  "src/**/*.d.ts",
package/src/index.d.ts CHANGED
@@ -6,5 +6,5 @@
6
6
  * @module word-count
7
7
  */
8
8
  export { default as WordCount, type WordCountUpdateEvent } from './wordcount.js';
9
- export { WordCountConfig } from './wordcountconfig.js';
9
+ export type { WordCountConfig } from './wordcountconfig.js';
10
10
  import './augmentation.js';