@ckeditor/ckeditor5-word-count 48.8.1-alpha.4 → 49.0.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.
Files changed (161) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/augmentation.d.ts +17 -17
  3. package/dist/index-content.css +3 -0
  4. package/dist/index-content.css.map +1 -0
  5. package/dist/index-editor.css +9 -0
  6. package/dist/index-editor.css.map +1 -0
  7. package/dist/index.css +6 -0
  8. package/dist/index.css.map +1 -1
  9. package/dist/index.d.ts +11 -9
  10. package/dist/index.js +228 -250
  11. package/dist/index.js.map +1 -1
  12. package/dist/translations/af.js +1 -1
  13. package/dist/translations/af.umd.js +5 -3
  14. package/dist/translations/ar.js +1 -1
  15. package/dist/translations/ar.umd.js +5 -3
  16. package/dist/translations/ast.js +1 -1
  17. package/dist/translations/ast.umd.js +5 -3
  18. package/dist/translations/az.js +1 -1
  19. package/dist/translations/az.umd.js +5 -3
  20. package/dist/translations/be.js +1 -1
  21. package/dist/translations/be.umd.js +5 -3
  22. package/dist/translations/bg.js +1 -1
  23. package/dist/translations/bg.umd.js +5 -3
  24. package/dist/translations/bn.js +1 -1
  25. package/dist/translations/bn.umd.js +5 -3
  26. package/dist/translations/bs.js +1 -1
  27. package/dist/translations/bs.umd.js +5 -3
  28. package/dist/translations/ca.js +1 -1
  29. package/dist/translations/ca.umd.js +5 -3
  30. package/dist/translations/cs.js +1 -1
  31. package/dist/translations/cs.umd.js +5 -3
  32. package/dist/translations/da.js +1 -1
  33. package/dist/translations/da.umd.js +5 -3
  34. package/dist/translations/de-ch.js +1 -1
  35. package/dist/translations/de-ch.umd.js +5 -3
  36. package/dist/translations/de.js +1 -1
  37. package/dist/translations/de.umd.js +5 -3
  38. package/dist/translations/el.js +1 -1
  39. package/dist/translations/el.umd.js +5 -3
  40. package/dist/translations/en-au.js +1 -1
  41. package/dist/translations/en-au.umd.js +5 -3
  42. package/dist/translations/en-gb.js +1 -1
  43. package/dist/translations/en-gb.umd.js +5 -3
  44. package/dist/translations/en.js +1 -1
  45. package/dist/translations/en.umd.js +5 -3
  46. package/dist/translations/eo.js +1 -1
  47. package/dist/translations/eo.umd.js +5 -3
  48. package/dist/translations/es-co.js +1 -1
  49. package/dist/translations/es-co.umd.js +5 -3
  50. package/dist/translations/es.js +1 -1
  51. package/dist/translations/es.umd.js +5 -3
  52. package/dist/translations/et.js +1 -1
  53. package/dist/translations/et.umd.js +5 -3
  54. package/dist/translations/eu.js +1 -1
  55. package/dist/translations/eu.umd.js +5 -3
  56. package/dist/translations/fa.js +1 -1
  57. package/dist/translations/fa.umd.js +5 -3
  58. package/dist/translations/fi.js +1 -1
  59. package/dist/translations/fi.umd.js +5 -3
  60. package/dist/translations/fr.js +1 -1
  61. package/dist/translations/fr.umd.js +5 -3
  62. package/dist/translations/gl.js +1 -1
  63. package/dist/translations/gl.umd.js +5 -3
  64. package/dist/translations/gu.js +1 -1
  65. package/dist/translations/gu.umd.js +5 -3
  66. package/dist/translations/he.js +1 -1
  67. package/dist/translations/he.umd.js +5 -3
  68. package/dist/translations/hi.js +1 -1
  69. package/dist/translations/hi.umd.js +5 -3
  70. package/dist/translations/hr.js +1 -1
  71. package/dist/translations/hr.umd.js +5 -3
  72. package/dist/translations/hu.js +1 -1
  73. package/dist/translations/hu.umd.js +5 -3
  74. package/dist/translations/hy.js +1 -1
  75. package/dist/translations/hy.umd.js +5 -3
  76. package/dist/translations/id.js +1 -1
  77. package/dist/translations/id.umd.js +5 -3
  78. package/dist/translations/it.js +1 -1
  79. package/dist/translations/it.umd.js +5 -3
  80. package/dist/translations/ja.js +1 -1
  81. package/dist/translations/ja.umd.js +5 -3
  82. package/dist/translations/jv.js +1 -1
  83. package/dist/translations/jv.umd.js +5 -3
  84. package/dist/translations/kk.js +1 -1
  85. package/dist/translations/kk.umd.js +5 -3
  86. package/dist/translations/km.js +1 -1
  87. package/dist/translations/km.umd.js +5 -3
  88. package/dist/translations/kn.js +1 -1
  89. package/dist/translations/kn.umd.js +5 -3
  90. package/dist/translations/ko.js +1 -1
  91. package/dist/translations/ko.umd.js +5 -3
  92. package/dist/translations/ku.js +1 -1
  93. package/dist/translations/ku.umd.js +5 -3
  94. package/dist/translations/lt.js +1 -1
  95. package/dist/translations/lt.umd.js +5 -3
  96. package/dist/translations/lv.js +1 -1
  97. package/dist/translations/lv.umd.js +5 -3
  98. package/dist/translations/ms.js +1 -1
  99. package/dist/translations/ms.umd.js +5 -3
  100. package/dist/translations/nb.js +1 -1
  101. package/dist/translations/nb.umd.js +5 -3
  102. package/dist/translations/ne.js +1 -1
  103. package/dist/translations/ne.umd.js +5 -3
  104. package/dist/translations/nl.js +1 -1
  105. package/dist/translations/nl.umd.js +5 -3
  106. package/dist/translations/no.js +1 -1
  107. package/dist/translations/no.umd.js +5 -3
  108. package/dist/translations/oc.js +1 -1
  109. package/dist/translations/oc.umd.js +5 -3
  110. package/dist/translations/pl.js +1 -1
  111. package/dist/translations/pl.umd.js +5 -3
  112. package/dist/translations/pt-br.js +1 -1
  113. package/dist/translations/pt-br.umd.js +5 -3
  114. package/dist/translations/pt.js +1 -1
  115. package/dist/translations/pt.umd.js +5 -3
  116. package/dist/translations/ro.js +1 -1
  117. package/dist/translations/ro.umd.js +5 -3
  118. package/dist/translations/ru.js +1 -1
  119. package/dist/translations/ru.umd.js +5 -3
  120. package/dist/translations/si.js +1 -1
  121. package/dist/translations/si.umd.js +5 -3
  122. package/dist/translations/sk.js +1 -1
  123. package/dist/translations/sk.umd.js +5 -3
  124. package/dist/translations/sl.js +1 -1
  125. package/dist/translations/sl.umd.js +5 -3
  126. package/dist/translations/sq.js +1 -1
  127. package/dist/translations/sq.umd.js +5 -3
  128. package/dist/translations/sr-latn.js +1 -1
  129. package/dist/translations/sr-latn.umd.js +5 -3
  130. package/dist/translations/sr.js +1 -1
  131. package/dist/translations/sr.umd.js +5 -3
  132. package/dist/translations/sv.js +1 -1
  133. package/dist/translations/sv.umd.js +5 -3
  134. package/dist/translations/th.js +1 -1
  135. package/dist/translations/th.umd.js +5 -3
  136. package/dist/translations/ti.js +1 -1
  137. package/dist/translations/ti.umd.js +5 -3
  138. package/dist/translations/tk.js +1 -1
  139. package/dist/translations/tk.umd.js +5 -3
  140. package/dist/translations/tr.js +1 -1
  141. package/dist/translations/tr.umd.js +5 -3
  142. package/dist/translations/tt.js +1 -1
  143. package/dist/translations/tt.umd.js +5 -3
  144. package/dist/translations/ug.js +1 -1
  145. package/dist/translations/ug.umd.js +5 -3
  146. package/dist/translations/uk.js +1 -1
  147. package/dist/translations/uk.umd.js +5 -3
  148. package/dist/translations/ur.js +1 -1
  149. package/dist/translations/ur.umd.js +5 -3
  150. package/dist/translations/uz.js +1 -1
  151. package/dist/translations/uz.umd.js +5 -3
  152. package/dist/translations/vi.js +1 -1
  153. package/dist/translations/vi.umd.js +5 -3
  154. package/dist/translations/zh-cn.js +1 -1
  155. package/dist/translations/zh-cn.umd.js +5 -3
  156. package/dist/translations/zh.js +1 -1
  157. package/dist/translations/zh.umd.js +5 -3
  158. package/dist/utils.d.ts +11 -11
  159. package/dist/wordcount.d.ts +141 -141
  160. package/dist/wordcountconfig.d.ts +87 -87
  161. package/package.json +6 -6
@@ -4,8 +4,10 @@
4
4
  */
5
5
 
6
6
  ( e => {
7
- const { [ 'ur' ]: { dictionary, getPluralForm } } = {"ur":{"dictionary":{"Words: %0":"الفاظ: 0%","Characters: %0":"حروف: 0%"},getPluralForm(n){return (n != 1);}}};
7
+ const { [ 'ur' ]: translations } = {"ur":{"dictionary":{"Words: %0":"الفاظ: 0%","Characters: %0":"حروف: 0%"}}};
8
8
  e[ 'ur' ] ||= { dictionary: {}, getPluralForm: null };
9
- e[ 'ur' ].dictionary = Object.assign( e[ 'ur' ].dictionary, dictionary );
10
- e[ 'ur' ].getPluralForm = getPluralForm;
9
+ e[ 'ur' ].dictionary = Object.assign( e[ 'ur' ].dictionary, translations.dictionary );
10
+ if ( translations.getPluralForm ) {
11
+ e[ 'ur' ].getPluralForm = translations.getPluralForm;
12
+ }
11
13
  } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -2,4 +2,4 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- export default {"uz":{"dictionary":{"Words: %0":"","Characters: %0":""},getPluralForm(n){return (n > 1);}}}
5
+ export default {"uz":{"dictionary":{"Words: %0":"","Characters: %0":""}}}
@@ -4,8 +4,10 @@
4
4
  */
5
5
 
6
6
  ( e => {
7
- const { [ 'uz' ]: { dictionary, getPluralForm } } = {"uz":{"dictionary":{"Words: %0":"","Characters: %0":""},getPluralForm(n){return (n > 1);}}};
7
+ const { [ 'uz' ]: translations } = {"uz":{"dictionary":{"Words: %0":"","Characters: %0":""}}};
8
8
  e[ 'uz' ] ||= { dictionary: {}, getPluralForm: null };
9
- e[ 'uz' ].dictionary = Object.assign( e[ 'uz' ].dictionary, dictionary );
10
- e[ 'uz' ].getPluralForm = getPluralForm;
9
+ e[ 'uz' ].dictionary = Object.assign( e[ 'uz' ].dictionary, translations.dictionary );
10
+ if ( translations.getPluralForm ) {
11
+ e[ 'uz' ].getPluralForm = translations.getPluralForm;
12
+ }
11
13
  } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -2,4 +2,4 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- export default {"vi":{"dictionary":{"Words: %0":"Số chữ: %0","Characters: %0":"Số ký tự: %0"},getPluralForm(n){return 0;}}}
5
+ export default {"vi":{"dictionary":{"Words: %0":"Số chữ: %0","Characters: %0":"Số ký tự: %0"}}}
@@ -4,8 +4,10 @@
4
4
  */
5
5
 
6
6
  ( e => {
7
- const { [ 'vi' ]: { dictionary, getPluralForm } } = {"vi":{"dictionary":{"Words: %0":"Số chữ: %0","Characters: %0":"Số ký tự: %0"},getPluralForm(n){return 0;}}};
7
+ const { [ 'vi' ]: translations } = {"vi":{"dictionary":{"Words: %0":"Số chữ: %0","Characters: %0":"Số ký tự: %0"}}};
8
8
  e[ 'vi' ] ||= { dictionary: {}, getPluralForm: null };
9
- e[ 'vi' ].dictionary = Object.assign( e[ 'vi' ].dictionary, dictionary );
10
- e[ 'vi' ].getPluralForm = getPluralForm;
9
+ e[ 'vi' ].dictionary = Object.assign( e[ 'vi' ].dictionary, translations.dictionary );
10
+ if ( translations.getPluralForm ) {
11
+ e[ 'vi' ].getPluralForm = translations.getPluralForm;
12
+ }
11
13
  } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -2,4 +2,4 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- export default {"zh-cn":{"dictionary":{"Words: %0":"单词数:%0","Characters: %0":"字符数:%0"},getPluralForm(n){return 0;}}}
5
+ export default {"zh-cn":{"dictionary":{"Words: %0":"单词数:%0","Characters: %0":"字符数:%0"}}}
@@ -4,8 +4,10 @@
4
4
  */
5
5
 
6
6
  ( e => {
7
- const { [ 'zh-cn' ]: { dictionary, getPluralForm } } = {"zh-cn":{"dictionary":{"Words: %0":"单词数:%0","Characters: %0":"字符数:%0"},getPluralForm(n){return 0;}}};
7
+ const { [ 'zh-cn' ]: translations } = {"zh-cn":{"dictionary":{"Words: %0":"单词数:%0","Characters: %0":"字符数:%0"}}};
8
8
  e[ 'zh-cn' ] ||= { dictionary: {}, getPluralForm: null };
9
- e[ 'zh-cn' ].dictionary = Object.assign( e[ 'zh-cn' ].dictionary, dictionary );
10
- e[ 'zh-cn' ].getPluralForm = getPluralForm;
9
+ e[ 'zh-cn' ].dictionary = Object.assign( e[ 'zh-cn' ].dictionary, translations.dictionary );
10
+ if ( translations.getPluralForm ) {
11
+ e[ 'zh-cn' ].getPluralForm = translations.getPluralForm;
12
+ }
11
13
  } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -2,4 +2,4 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- export default {"zh":{"dictionary":{"Words: %0":"字數: %0","Characters: %0":"字元數: %0"},getPluralForm(n){return 0;}}}
5
+ export default {"zh":{"dictionary":{"Words: %0":"字數: %0","Characters: %0":"字元數: %0"}}}
@@ -4,8 +4,10 @@
4
4
  */
5
5
 
6
6
  ( e => {
7
- const { [ 'zh' ]: { dictionary, getPluralForm } } = {"zh":{"dictionary":{"Words: %0":"字數: %0","Characters: %0":"字元數: %0"},getPluralForm(n){return 0;}}};
7
+ const { [ 'zh' ]: translations } = {"zh":{"dictionary":{"Words: %0":"字數: %0","Characters: %0":"字元數: %0"}}};
8
8
  e[ 'zh' ] ||= { dictionary: {}, getPluralForm: null };
9
- e[ 'zh' ].dictionary = Object.assign( e[ 'zh' ].dictionary, dictionary );
10
- e[ 'zh' ].getPluralForm = getPluralForm;
9
+ e[ 'zh' ].dictionary = Object.assign( e[ 'zh' ].dictionary, translations.dictionary );
10
+ if ( translations.getPluralForm ) {
11
+ e[ 'zh' ].getPluralForm = translations.getPluralForm;
12
+ }
11
13
  } )( window.CKEDITOR_TRANSLATIONS ||= {} );
package/dist/utils.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module word-count/utils
7
- */
8
- import type { ModelItem } from '@ckeditor/ckeditor5-engine';
6
+ * @module word-count/utils
7
+ */
8
+ import type { ModelItem } from "@ckeditor/ckeditor5-engine";
9
9
  /**
10
- * Returns a plain text representation of an element and its children.
11
- *
12
- * @internal
13
- * @returns Plain text representing the model's data.
14
- */
10
+ * Returns a plain text representation of an element and its children.
11
+ *
12
+ * @internal
13
+ * @returns Plain text representing the model's data.
14
+ */
15
15
  export declare function modelElementToPlainText(item: ModelItem): string;
@@ -1,148 +1,148 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- import { Plugin, type Editor } from '@ckeditor/ckeditor5-core';
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ import { Plugin, type Editor } from "@ckeditor/ckeditor5-core";
6
6
  /**
7
- * The word count plugin.
8
- *
9
- * This plugin calculates all words and characters in all {@link module:engine/model/text~ModelText 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
- */
7
+ * The word count plugin.
8
+ *
9
+ * This plugin calculates all words and characters in all {@link module:engine/model/text~ModelText 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
36
  export declare 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
- * @internal
90
- */
91
- static get licenseFeatureCode(): string;
92
- /**
93
- * @inheritDoc
94
- */
95
- static get isOfficialPlugin(): true;
96
- /**
97
- * @inheritDoc
98
- */
99
- static get isPremiumPlugin(): true;
100
- /**
101
- * @inheritDoc
102
- */
103
- init(): void;
104
- /**
105
- * @inheritDoc
106
- */
107
- destroy(): void;
108
- /**
109
- * Creates a self-updating HTML element. Repeated executions return the same element.
110
- * The returned element has the following HTML structure:
111
- *
112
- * ```html
113
- * <div class="ck ck-word-count">
114
- * <div class="ck-word-count__words">Words: 4</div>
115
- * <div class="ck-word-count__characters">Characters: 28</div>
116
- * </div>
117
- * ```
118
- */
119
- get wordCountContainer(): HTMLElement;
120
- private _getText;
121
- /**
122
- * Determines the number of characters in the current editor's model.
123
- */
124
- private _getCharacters;
125
- /**
126
- * Determines the number of words in the current editor's model.
127
- */
128
- private _getWords;
129
- /**
130
- * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
131
- * It also fires the {@link #event:update}.
132
- *
133
- * @fires update
134
- */
135
- private _refreshStats;
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
+ * @internal
90
+ */
91
+ static get licenseFeatureCode(): string;
92
+ /**
93
+ * @inheritDoc
94
+ */
95
+ static override get isOfficialPlugin(): true;
96
+ /**
97
+ * @inheritDoc
98
+ */
99
+ static override get isPremiumPlugin(): true;
100
+ /**
101
+ * @inheritDoc
102
+ */
103
+ init(): void;
104
+ /**
105
+ * @inheritDoc
106
+ */
107
+ override destroy(): void;
108
+ /**
109
+ * Creates a self-updating HTML element. Repeated executions return the same element.
110
+ * The returned element has the following HTML structure:
111
+ *
112
+ * ```html
113
+ * <div class="ck ck-word-count">
114
+ * <div class="ck-word-count__words">Words: 4</div>
115
+ * <div class="ck-word-count__characters">Characters: 28</div>
116
+ * </div>
117
+ * ```
118
+ */
119
+ get wordCountContainer(): HTMLElement;
120
+ private _getText;
121
+ /**
122
+ * Determines the number of characters in the current editor's model.
123
+ */
124
+ private _getCharacters;
125
+ /**
126
+ * Determines the number of words in the current editor's model.
127
+ */
128
+ private _getWords;
129
+ /**
130
+ * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
131
+ * It also fires the {@link #event:update}.
132
+ *
133
+ * @fires update
134
+ */
135
+ private _refreshStats;
136
136
  }
137
137
  /**
138
- * An event fired after {@link ~WordCount#words} and {@link ~WordCount#characters} are updated.
139
- *
140
- * @eventName ~WordCount#update
141
- */
138
+ * An event fired after {@link ~WordCount#words} and {@link ~WordCount#characters} are updated.
139
+ *
140
+ * @eventName ~WordCount#update
141
+ */
142
142
  export type WordCountUpdateEvent = {
143
- name: 'update';
144
- args: [{
145
- words: number;
146
- characters: number;
147
- }];
143
+ name: "update";
144
+ args: [{
145
+ words: number;
146
+ characters: number;
147
+ }];
148
148
  };
@@ -1,92 +1,92 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module word-count/wordcountconfig
7
- */
6
+ * @module word-count/wordcountconfig
7
+ */
8
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
- */
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
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;
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
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-word-count",
3
- "version": "48.8.1-alpha.4",
3
+ "version": "49.0.0-alpha.1",
4
4
  "description": "Word and character count feature for CKEditor 5.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -26,11 +26,11 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@ckeditor/ckeditor5-core": "48.8.1-alpha.4",
30
- "@ckeditor/ckeditor5-engine": "48.8.1-alpha.4",
31
- "@ckeditor/ckeditor5-ui": "48.8.1-alpha.4",
32
- "@ckeditor/ckeditor5-utils": "48.8.1-alpha.4",
33
- "es-toolkit": "1.45.1"
29
+ "@ckeditor/ckeditor5-core": "49.0.0-alpha.1",
30
+ "@ckeditor/ckeditor5-engine": "49.0.0-alpha.1",
31
+ "@ckeditor/ckeditor5-ui": "49.0.0-alpha.1",
32
+ "@ckeditor/ckeditor5-utils": "49.0.0-alpha.1",
33
+ "es-toolkit": "1.52.0"
34
34
  },
35
35
  "files": [
36
36
  "dist",