@ckeditor/ckeditor5-word-count 41.3.1 → 41.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. package/dist/index-content.css +4 -0
  2. package/dist/index-editor.css +4 -0
  3. package/dist/index.css +4 -0
  4. package/dist/index.js +204 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/translations/ar.d.ts +8 -0
  7. package/dist/translations/ar.js +5 -0
  8. package/dist/translations/ar.umd.js +11 -0
  9. package/dist/translations/az.d.ts +8 -0
  10. package/dist/translations/az.js +5 -0
  11. package/dist/translations/az.umd.js +11 -0
  12. package/dist/translations/bg.d.ts +8 -0
  13. package/dist/translations/bg.js +5 -0
  14. package/dist/translations/bg.umd.js +11 -0
  15. package/dist/translations/bn.d.ts +8 -0
  16. package/dist/translations/bn.js +5 -0
  17. package/dist/translations/bn.umd.js +11 -0
  18. package/dist/translations/ca.d.ts +8 -0
  19. package/dist/translations/ca.js +5 -0
  20. package/dist/translations/ca.umd.js +11 -0
  21. package/dist/translations/cs.d.ts +8 -0
  22. package/dist/translations/cs.js +5 -0
  23. package/dist/translations/cs.umd.js +11 -0
  24. package/dist/translations/da.d.ts +8 -0
  25. package/dist/translations/da.js +5 -0
  26. package/dist/translations/da.umd.js +11 -0
  27. package/dist/translations/de-ch.d.ts +8 -0
  28. package/dist/translations/de-ch.js +5 -0
  29. package/dist/translations/de-ch.umd.js +11 -0
  30. package/dist/translations/de.d.ts +8 -0
  31. package/dist/translations/de.js +5 -0
  32. package/dist/translations/de.umd.js +11 -0
  33. package/dist/translations/el.d.ts +8 -0
  34. package/dist/translations/el.js +5 -0
  35. package/dist/translations/el.umd.js +11 -0
  36. package/dist/translations/en-au.d.ts +8 -0
  37. package/dist/translations/en-au.js +5 -0
  38. package/dist/translations/en-au.umd.js +11 -0
  39. package/dist/translations/en-gb.d.ts +8 -0
  40. package/dist/translations/en-gb.js +5 -0
  41. package/dist/translations/en-gb.umd.js +11 -0
  42. package/dist/translations/en.d.ts +8 -0
  43. package/dist/translations/en.js +5 -0
  44. package/dist/translations/en.umd.js +11 -0
  45. package/dist/translations/es-co.d.ts +8 -0
  46. package/dist/translations/es-co.js +5 -0
  47. package/dist/translations/es-co.umd.js +11 -0
  48. package/dist/translations/es.d.ts +8 -0
  49. package/dist/translations/es.js +5 -0
  50. package/dist/translations/es.umd.js +11 -0
  51. package/dist/translations/et.d.ts +8 -0
  52. package/dist/translations/et.js +5 -0
  53. package/dist/translations/et.umd.js +11 -0
  54. package/dist/translations/fa.d.ts +8 -0
  55. package/dist/translations/fa.js +5 -0
  56. package/dist/translations/fa.umd.js +11 -0
  57. package/dist/translations/fi.d.ts +8 -0
  58. package/dist/translations/fi.js +5 -0
  59. package/dist/translations/fi.umd.js +11 -0
  60. package/dist/translations/fr.d.ts +8 -0
  61. package/dist/translations/fr.js +5 -0
  62. package/dist/translations/fr.umd.js +11 -0
  63. package/dist/translations/gl.d.ts +8 -0
  64. package/dist/translations/gl.js +5 -0
  65. package/dist/translations/gl.umd.js +11 -0
  66. package/dist/translations/he.d.ts +8 -0
  67. package/dist/translations/he.js +5 -0
  68. package/dist/translations/he.umd.js +11 -0
  69. package/dist/translations/hi.d.ts +8 -0
  70. package/dist/translations/hi.js +5 -0
  71. package/dist/translations/hi.umd.js +11 -0
  72. package/dist/translations/hr.d.ts +8 -0
  73. package/dist/translations/hr.js +5 -0
  74. package/dist/translations/hr.umd.js +11 -0
  75. package/dist/translations/hu.d.ts +8 -0
  76. package/dist/translations/hu.js +5 -0
  77. package/dist/translations/hu.umd.js +11 -0
  78. package/dist/translations/hy.d.ts +8 -0
  79. package/dist/translations/hy.js +5 -0
  80. package/dist/translations/hy.umd.js +11 -0
  81. package/dist/translations/id.d.ts +8 -0
  82. package/dist/translations/id.js +5 -0
  83. package/dist/translations/id.umd.js +11 -0
  84. package/dist/translations/it.d.ts +8 -0
  85. package/dist/translations/it.js +5 -0
  86. package/dist/translations/it.umd.js +11 -0
  87. package/dist/translations/ja.d.ts +8 -0
  88. package/dist/translations/ja.js +5 -0
  89. package/dist/translations/ja.umd.js +11 -0
  90. package/dist/translations/ko.d.ts +8 -0
  91. package/dist/translations/ko.js +5 -0
  92. package/dist/translations/ko.umd.js +11 -0
  93. package/dist/translations/ku.d.ts +8 -0
  94. package/dist/translations/ku.js +5 -0
  95. package/dist/translations/ku.umd.js +11 -0
  96. package/dist/translations/lt.d.ts +8 -0
  97. package/dist/translations/lt.js +5 -0
  98. package/dist/translations/lt.umd.js +11 -0
  99. package/dist/translations/lv.d.ts +8 -0
  100. package/dist/translations/lv.js +5 -0
  101. package/dist/translations/lv.umd.js +11 -0
  102. package/dist/translations/ms.d.ts +8 -0
  103. package/dist/translations/ms.js +5 -0
  104. package/dist/translations/ms.umd.js +11 -0
  105. package/dist/translations/ne.d.ts +8 -0
  106. package/dist/translations/ne.js +5 -0
  107. package/dist/translations/ne.umd.js +11 -0
  108. package/dist/translations/nl.d.ts +8 -0
  109. package/dist/translations/nl.js +5 -0
  110. package/dist/translations/nl.umd.js +11 -0
  111. package/dist/translations/no.d.ts +8 -0
  112. package/dist/translations/no.js +5 -0
  113. package/dist/translations/no.umd.js +11 -0
  114. package/dist/translations/pl.d.ts +8 -0
  115. package/dist/translations/pl.js +5 -0
  116. package/dist/translations/pl.umd.js +11 -0
  117. package/dist/translations/pt-br.d.ts +8 -0
  118. package/dist/translations/pt-br.js +5 -0
  119. package/dist/translations/pt-br.umd.js +11 -0
  120. package/dist/translations/pt.d.ts +8 -0
  121. package/dist/translations/pt.js +5 -0
  122. package/dist/translations/pt.umd.js +11 -0
  123. package/dist/translations/ro.d.ts +8 -0
  124. package/dist/translations/ro.js +5 -0
  125. package/dist/translations/ro.umd.js +11 -0
  126. package/dist/translations/ru.d.ts +8 -0
  127. package/dist/translations/ru.js +5 -0
  128. package/dist/translations/ru.umd.js +11 -0
  129. package/dist/translations/sk.d.ts +8 -0
  130. package/dist/translations/sk.js +5 -0
  131. package/dist/translations/sk.umd.js +11 -0
  132. package/dist/translations/sq.d.ts +8 -0
  133. package/dist/translations/sq.js +5 -0
  134. package/dist/translations/sq.umd.js +11 -0
  135. package/dist/translations/sr-latn.d.ts +8 -0
  136. package/dist/translations/sr-latn.js +5 -0
  137. package/dist/translations/sr-latn.umd.js +11 -0
  138. package/dist/translations/sr.d.ts +8 -0
  139. package/dist/translations/sr.js +5 -0
  140. package/dist/translations/sr.umd.js +11 -0
  141. package/dist/translations/sv.d.ts +8 -0
  142. package/dist/translations/sv.js +5 -0
  143. package/dist/translations/sv.umd.js +11 -0
  144. package/dist/translations/th.d.ts +8 -0
  145. package/dist/translations/th.js +5 -0
  146. package/dist/translations/th.umd.js +11 -0
  147. package/dist/translations/tk.d.ts +8 -0
  148. package/dist/translations/tk.js +5 -0
  149. package/dist/translations/tk.umd.js +11 -0
  150. package/dist/translations/tr.d.ts +8 -0
  151. package/dist/translations/tr.js +5 -0
  152. package/dist/translations/tr.umd.js +11 -0
  153. package/dist/translations/ug.d.ts +8 -0
  154. package/dist/translations/ug.js +5 -0
  155. package/dist/translations/ug.umd.js +11 -0
  156. package/dist/translations/uk.d.ts +8 -0
  157. package/dist/translations/uk.js +5 -0
  158. package/dist/translations/uk.umd.js +11 -0
  159. package/dist/translations/ur.d.ts +8 -0
  160. package/dist/translations/ur.js +5 -0
  161. package/dist/translations/ur.umd.js +11 -0
  162. package/dist/translations/vi.d.ts +8 -0
  163. package/dist/translations/vi.js +5 -0
  164. package/dist/translations/vi.umd.js +11 -0
  165. package/dist/translations/zh-cn.d.ts +8 -0
  166. package/dist/translations/zh-cn.js +5 -0
  167. package/dist/translations/zh-cn.umd.js +11 -0
  168. package/dist/translations/zh.d.ts +8 -0
  169. package/dist/translations/zh.js +5 -0
  170. package/dist/translations/zh.umd.js +11 -0
  171. package/dist/types/augmentation.d.ts +23 -0
  172. package/dist/types/index.d.ts +14 -0
  173. package/dist/types/utils.d.ts +18 -0
  174. package/dist/types/wordcount.d.ts +139 -0
  175. package/dist/types/wordcountconfig.d.ts +96 -0
  176. package/package.json +3 -2
  177. package/src/index.d.ts +1 -1
@@ -0,0 +1,11 @@
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
+ ( e => {
7
+ const { [ 'uk' ]: { dictionary, getPluralForm } } = {"uk":{"dictionary":{"Words: %0":"Слова: %0","Characters: %0":"Символи: %0"},getPluralForm(n){return (n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);}}};
8
+ e[ 'uk' ] ||= { dictionary: {}, getPluralForm: null };
9
+ e[ 'uk' ].dictionary = Object.assign( e[ 'uk' ].dictionary, dictionary );
10
+ e[ 'uk' ].getPluralForm = getPluralForm;
11
+ } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"ur":{"dictionary":{"Words: %0":"الفاظ: 0%","Characters: %0":"حروف: 0%"},getPluralForm(n){return (n != 1);}}}
@@ -0,0 +1,11 @@
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
+ ( e => {
7
+ const { [ 'ur' ]: { dictionary, getPluralForm } } = {"ur":{"dictionary":{"Words: %0":"الفاظ: 0%","Characters: %0":"حروف: 0%"},getPluralForm(n){return (n != 1);}}};
8
+ e[ 'ur' ] ||= { dictionary: {}, getPluralForm: null };
9
+ e[ 'ur' ].dictionary = Object.assign( e[ 'ur' ].dictionary, dictionary );
10
+ e[ 'ur' ].getPluralForm = getPluralForm;
11
+ } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"vi":{"dictionary":{"Words: %0":"Số chữ: %0","Characters: %0":"Số ký tự: %0"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,11 @@
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
+ ( e => {
7
+ const { [ 'vi' ]: { dictionary, getPluralForm } } = {"vi":{"dictionary":{"Words: %0":"Số chữ: %0","Characters: %0":"Số ký tự: %0"},getPluralForm(n){return 0;}}};
8
+ e[ 'vi' ] ||= { dictionary: {}, getPluralForm: null };
9
+ e[ 'vi' ].dictionary = Object.assign( e[ 'vi' ].dictionary, dictionary );
10
+ e[ 'vi' ].getPluralForm = getPluralForm;
11
+ } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"zh-cn":{"dictionary":{"Words: %0":"单词数:%0","Characters: %0":"字符数:%0"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,11 @@
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
+ ( e => {
7
+ const { [ 'zh-cn' ]: { dictionary, getPluralForm } } = {"zh-cn":{"dictionary":{"Words: %0":"单词数:%0","Characters: %0":"字符数:%0"},getPluralForm(n){return 0;}}};
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;
11
+ } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"zh":{"dictionary":{"Words: %0":"字數: %0","Characters: %0":"字元數: %0"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,11 @@
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
+ ( e => {
7
+ const { [ 'zh' ]: { dictionary, getPluralForm } } = {"zh":{"dictionary":{"Words: %0":"字數: %0","Characters: %0":"字元數: %0"},getPluralForm(n){return 0;}}};
8
+ e[ 'zh' ] ||= { dictionary: {}, getPluralForm: null };
9
+ e[ 'zh' ].dictionary = Object.assign( e[ 'zh' ].dictionary, dictionary );
10
+ e[ 'zh' ].getPluralForm = getPluralForm;
11
+ } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -0,0 +1,23 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import type { WordCount, WordCountConfig } from './index.js';
10
+ declare module '@ckeditor/ckeditor5-core' {
11
+ interface EditorConfig {
12
+ /**
13
+ * The configuration of the word count feature.
14
+ * It is introduced by the {@link module:word-count/wordcount~WordCount} feature.
15
+ *
16
+ * Read more in {@link module:word-count/wordcountconfig~WordCountConfig}.
17
+ */
18
+ wordCount?: WordCountConfig;
19
+ }
20
+ interface PluginsMap {
21
+ [WordCount.pluginName]: WordCount;
22
+ }
23
+ }
@@ -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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module word-count
11
+ */
12
+ export { default as WordCount, type WordCountUpdateEvent } from './wordcount.js';
13
+ export type { WordCountConfig } from './wordcountconfig.js';
14
+ import './augmentation.js';
@@ -0,0 +1,18 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module word-count/utils
11
+ */
12
+ import type { Item } from 'ckeditor5/src/engine.js';
13
+ /**
14
+ * Returns a plain text representation of an element and its children.
15
+ *
16
+ * @returns Plain text representing the model's data.
17
+ */
18
+ export declare function modelElementToPlainText(item: Item): string;
@@ -0,0 +1,139 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
10
+ /**
11
+ * The word count plugin.
12
+ *
13
+ * This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.
14
+ * It also provides an HTML element that updates its state whenever the editor content is changed.
15
+ *
16
+ * The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.
17
+ * The number of words and characters in your text are determined based on the created plain text. Please keep in mind
18
+ * that every block in the editor is separated with a newline character, which is included in the calculation.
19
+ *
20
+ * Here are some examples of how the word and character calculations are made:
21
+ *
22
+ * ```html
23
+ * <paragraph>foo</paragraph>
24
+ * <paragraph>bar</paragraph>
25
+ * // Words: 2, Characters: 7
26
+ *
27
+ * <paragraph><$text bold="true">foo</$text>bar</paragraph>
28
+ * // Words: 1, Characters: 6
29
+ *
30
+ * <paragraph>*&^%)</paragraph>
31
+ * // Words: 0, Characters: 5
32
+ *
33
+ * <paragraph>foo(bar)</paragraph>
34
+ * //Words: 1, Characters: 8
35
+ *
36
+ * <paragraph>12345</paragraph>
37
+ * // Words: 1, Characters: 5
38
+ * ```
39
+ */
40
+ export default class WordCount extends Plugin {
41
+ /**
42
+ * The number of characters in the editor.
43
+ *
44
+ * @observable
45
+ * @readonly
46
+ */
47
+ characters: number;
48
+ /**
49
+ * The number of words in the editor.
50
+ *
51
+ * @observable
52
+ * @readonly
53
+ */
54
+ words: number;
55
+ /**
56
+ * The label used to display the words value in the {@link #wordCountContainer output container}.
57
+ *
58
+ * @observable
59
+ * @private
60
+ * @readonly
61
+ */
62
+ _wordsLabel: string | undefined;
63
+ /**
64
+ * The label used to display the characters value in the {@link #wordCountContainer output container}.
65
+ *
66
+ * @observable
67
+ * @private
68
+ * @readonly
69
+ */
70
+ _charactersLabel: string | undefined;
71
+ /**
72
+ * The configuration of this plugin.
73
+ */
74
+ private _config;
75
+ /**
76
+ * The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.
77
+ */
78
+ private _outputView;
79
+ /**
80
+ * A regular expression used to recognize words in the editor's content.
81
+ */
82
+ private readonly _wordsMatchRegExp;
83
+ /**
84
+ * @inheritDoc
85
+ */
86
+ constructor(editor: Editor);
87
+ /**
88
+ * @inheritDoc
89
+ */
90
+ static get pluginName(): "WordCount";
91
+ /**
92
+ * @inheritDoc
93
+ */
94
+ init(): void;
95
+ /**
96
+ * @inheritDoc
97
+ */
98
+ destroy(): void;
99
+ /**
100
+ * Creates a self-updating HTML element. Repeated executions return the same element.
101
+ * The returned element has the following HTML structure:
102
+ *
103
+ * ```html
104
+ * <div class="ck ck-word-count">
105
+ * <div class="ck-word-count__words">Words: 4</div>
106
+ * <div class="ck-word-count__characters">Characters: 28</div>
107
+ * </div>
108
+ * ```
109
+ */
110
+ get wordCountContainer(): HTMLElement;
111
+ private _getText;
112
+ /**
113
+ * Determines the number of characters in the current editor's model.
114
+ */
115
+ private _getCharacters;
116
+ /**
117
+ * Determines the number of words in the current editor's model.
118
+ */
119
+ private _getWords;
120
+ /**
121
+ * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
122
+ * It also fires the {@link #event:update}.
123
+ *
124
+ * @fires update
125
+ */
126
+ private _refreshStats;
127
+ }
128
+ /**
129
+ * An event fired after {@link ~WordCount#words} and {@link ~WordCount#characters} are updated.
130
+ *
131
+ * @eventName ~WordCount#update
132
+ */
133
+ export type WordCountUpdateEvent = {
134
+ name: 'update';
135
+ args: [{
136
+ words: number;
137
+ characters: number;
138
+ }];
139
+ };
@@ -0,0 +1,96 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module word-count/wordcountconfig
11
+ */
12
+ /**
13
+ * The configuration of the word count feature.
14
+ *
15
+ * ```ts
16
+ * ClassicEditor
17
+ * .create( {
18
+ * wordCount: ... // Word count feature configuration.
19
+ * } )
20
+ * .then( ... )
21
+ * .catch( ... );
22
+ * ```
23
+ *
24
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
25
+ */
26
+ export interface WordCountConfig {
27
+ /**
28
+ * This option allows for hiding the word counter. The element obtained through
29
+ * {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
30
+ * the characters part. Word counter is displayed by default when this configuration option is not defined.
31
+ *
32
+ * ```ts
33
+ * const wordCountConfig = {
34
+ * displayWords: false
35
+ * };
36
+ * ```
37
+ *
38
+ * The configuration above will result in the following container:
39
+ *
40
+ * ```html
41
+ * <div class="ck ck-word-count">
42
+ * <div class="ck-word-count__characters">Characters: 28</div>
43
+ * </div>
44
+ * ```
45
+ */
46
+ displayWords?: boolean;
47
+ /**
48
+ * This option allows for hiding the character counter. The element obtained through
49
+ * {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
50
+ * the words part. Character counter is displayed by default when this configuration option is not defined.
51
+ *
52
+ * ```ts
53
+ * const wordCountConfig = {
54
+ * displayCharacters: false
55
+ * };
56
+ * ```
57
+ *
58
+ * The configuration above will result in the following container:
59
+ *
60
+ * ```html
61
+ * <div class="ck ck-word-count">
62
+ * <div class="ck-word-count__words">Words: 4</div>
63
+ * </div>
64
+ * ```
65
+ */
66
+ displayCharacters?: boolean;
67
+ /**
68
+ * This configuration takes a function that is executed whenever the word count plugin updates its values.
69
+ * This function is called with one argument, which is an object with the `words` and `characters` keys containing
70
+ * the number of detected words and characters in the document.
71
+ *
72
+ * ```ts
73
+ * const wordCountConfig = {
74
+ * onUpdate: function( stats ) {
75
+ * doSthWithWordNumber( stats.words );
76
+ * doSthWithCharacterNumber( stats.characters );
77
+ * }
78
+ * };
79
+ * ```
80
+ */
81
+ onUpdate?: (data: {
82
+ words: number;
83
+ characters: number;
84
+ }) => void;
85
+ /**
86
+ * Allows for providing the HTML element that the
87
+ * {@link module:word-count/wordcount~WordCount#wordCountContainer word count container} will be appended to automatically.
88
+ *
89
+ * ```ts
90
+ * const wordCountConfig = {
91
+ * container: document.getElementById( 'container-for-word-count' );
92
+ * };
93
+ * ```
94
+ */
95
+ container?: HTMLElement;
96
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-word-count",
3
- "version": "41.3.1",
3
+ "version": "41.4.0",
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.3.1"
17
+ "ckeditor5": "41.4.0"
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';