@ckeditor/ckeditor5-word-count 47.6.1 → 48.0.0-alpha.0

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 (163) hide show
  1. package/LICENSE.md +1 -1
  2. package/ckeditor5-metadata.json +1 -1
  3. package/dist/index.css +3 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/{src → dist}/utils.d.ts +1 -1
  7. package/{src → dist}/wordcount.d.ts +1 -1
  8. package/package.json +23 -45
  9. package/build/translations/af.js +0 -1
  10. package/build/translations/ar.js +0 -1
  11. package/build/translations/ast.js +0 -1
  12. package/build/translations/az.js +0 -1
  13. package/build/translations/be.js +0 -1
  14. package/build/translations/bg.js +0 -1
  15. package/build/translations/bn.js +0 -1
  16. package/build/translations/bs.js +0 -1
  17. package/build/translations/ca.js +0 -1
  18. package/build/translations/cs.js +0 -1
  19. package/build/translations/da.js +0 -1
  20. package/build/translations/de-ch.js +0 -1
  21. package/build/translations/de.js +0 -1
  22. package/build/translations/el.js +0 -1
  23. package/build/translations/en-au.js +0 -1
  24. package/build/translations/en-gb.js +0 -1
  25. package/build/translations/eo.js +0 -1
  26. package/build/translations/es-co.js +0 -1
  27. package/build/translations/es.js +0 -1
  28. package/build/translations/et.js +0 -1
  29. package/build/translations/eu.js +0 -1
  30. package/build/translations/fa.js +0 -1
  31. package/build/translations/fi.js +0 -1
  32. package/build/translations/fr.js +0 -1
  33. package/build/translations/gl.js +0 -1
  34. package/build/translations/gu.js +0 -1
  35. package/build/translations/he.js +0 -1
  36. package/build/translations/hi.js +0 -1
  37. package/build/translations/hr.js +0 -1
  38. package/build/translations/hu.js +0 -1
  39. package/build/translations/hy.js +0 -1
  40. package/build/translations/id.js +0 -1
  41. package/build/translations/it.js +0 -1
  42. package/build/translations/ja.js +0 -1
  43. package/build/translations/jv.js +0 -1
  44. package/build/translations/kk.js +0 -1
  45. package/build/translations/km.js +0 -1
  46. package/build/translations/kn.js +0 -1
  47. package/build/translations/ko.js +0 -1
  48. package/build/translations/ku.js +0 -1
  49. package/build/translations/lt.js +0 -1
  50. package/build/translations/lv.js +0 -1
  51. package/build/translations/ms.js +0 -1
  52. package/build/translations/nb.js +0 -1
  53. package/build/translations/ne.js +0 -1
  54. package/build/translations/nl.js +0 -1
  55. package/build/translations/no.js +0 -1
  56. package/build/translations/oc.js +0 -1
  57. package/build/translations/pl.js +0 -1
  58. package/build/translations/pt-br.js +0 -1
  59. package/build/translations/pt.js +0 -1
  60. package/build/translations/ro.js +0 -1
  61. package/build/translations/ru.js +0 -1
  62. package/build/translations/si.js +0 -1
  63. package/build/translations/sk.js +0 -1
  64. package/build/translations/sl.js +0 -1
  65. package/build/translations/sq.js +0 -1
  66. package/build/translations/sr-latn.js +0 -1
  67. package/build/translations/sr.js +0 -1
  68. package/build/translations/sv.js +0 -1
  69. package/build/translations/th.js +0 -1
  70. package/build/translations/ti.js +0 -1
  71. package/build/translations/tk.js +0 -1
  72. package/build/translations/tr.js +0 -1
  73. package/build/translations/tt.js +0 -1
  74. package/build/translations/ug.js +0 -1
  75. package/build/translations/uk.js +0 -1
  76. package/build/translations/ur.js +0 -1
  77. package/build/translations/uz.js +0 -1
  78. package/build/translations/vi.js +0 -1
  79. package/build/translations/zh-cn.js +0 -1
  80. package/build/translations/zh.js +0 -1
  81. package/build/word-count.js +0 -5
  82. package/lang/contexts.json +0 -4
  83. package/lang/translations/af.po +0 -20
  84. package/lang/translations/ar.po +0 -20
  85. package/lang/translations/ast.po +0 -20
  86. package/lang/translations/az.po +0 -20
  87. package/lang/translations/be.po +0 -20
  88. package/lang/translations/bg.po +0 -20
  89. package/lang/translations/bn.po +0 -20
  90. package/lang/translations/bs.po +0 -20
  91. package/lang/translations/ca.po +0 -20
  92. package/lang/translations/cs.po +0 -20
  93. package/lang/translations/da.po +0 -20
  94. package/lang/translations/de-ch.po +0 -20
  95. package/lang/translations/de.po +0 -20
  96. package/lang/translations/el.po +0 -20
  97. package/lang/translations/en-au.po +0 -20
  98. package/lang/translations/en-gb.po +0 -20
  99. package/lang/translations/en.po +0 -20
  100. package/lang/translations/eo.po +0 -20
  101. package/lang/translations/es-co.po +0 -20
  102. package/lang/translations/es.po +0 -20
  103. package/lang/translations/et.po +0 -20
  104. package/lang/translations/eu.po +0 -20
  105. package/lang/translations/fa.po +0 -20
  106. package/lang/translations/fi.po +0 -20
  107. package/lang/translations/fr.po +0 -20
  108. package/lang/translations/gl.po +0 -20
  109. package/lang/translations/gu.po +0 -20
  110. package/lang/translations/he.po +0 -20
  111. package/lang/translations/hi.po +0 -20
  112. package/lang/translations/hr.po +0 -20
  113. package/lang/translations/hu.po +0 -20
  114. package/lang/translations/hy.po +0 -20
  115. package/lang/translations/id.po +0 -20
  116. package/lang/translations/it.po +0 -20
  117. package/lang/translations/ja.po +0 -20
  118. package/lang/translations/jv.po +0 -20
  119. package/lang/translations/kk.po +0 -20
  120. package/lang/translations/km.po +0 -20
  121. package/lang/translations/kn.po +0 -20
  122. package/lang/translations/ko.po +0 -20
  123. package/lang/translations/ku.po +0 -20
  124. package/lang/translations/lt.po +0 -20
  125. package/lang/translations/lv.po +0 -20
  126. package/lang/translations/ms.po +0 -20
  127. package/lang/translations/nb.po +0 -20
  128. package/lang/translations/ne.po +0 -20
  129. package/lang/translations/nl.po +0 -20
  130. package/lang/translations/no.po +0 -20
  131. package/lang/translations/oc.po +0 -20
  132. package/lang/translations/pl.po +0 -20
  133. package/lang/translations/pt-br.po +0 -20
  134. package/lang/translations/pt.po +0 -20
  135. package/lang/translations/ro.po +0 -20
  136. package/lang/translations/ru.po +0 -20
  137. package/lang/translations/si.po +0 -20
  138. package/lang/translations/sk.po +0 -20
  139. package/lang/translations/sl.po +0 -20
  140. package/lang/translations/sq.po +0 -20
  141. package/lang/translations/sr-latn.po +0 -20
  142. package/lang/translations/sr.po +0 -20
  143. package/lang/translations/sv.po +0 -20
  144. package/lang/translations/th.po +0 -20
  145. package/lang/translations/ti.po +0 -20
  146. package/lang/translations/tk.po +0 -20
  147. package/lang/translations/tr.po +0 -20
  148. package/lang/translations/tt.po +0 -20
  149. package/lang/translations/ug.po +0 -20
  150. package/lang/translations/uk.po +0 -20
  151. package/lang/translations/ur.po +0 -20
  152. package/lang/translations/uz.po +0 -20
  153. package/lang/translations/vi.po +0 -20
  154. package/lang/translations/zh-cn.po +0 -20
  155. package/lang/translations/zh.po +0 -20
  156. package/src/augmentation.js +0 -5
  157. package/src/index.js +0 -10
  158. package/src/utils.js +0 -28
  159. package/src/wordcount.js +0 -242
  160. package/src/wordcountconfig.js +0 -5
  161. /package/{src → dist}/augmentation.d.ts +0 -0
  162. /package/{src → dist}/index.d.ts +0 -0
  163. /package/{src → dist}/wordcountconfig.d.ts +0 -0
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sq\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Fjalë: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Karaktere: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sr@latin\n"
11
- "Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Reči: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Karakteri: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sr\n"
11
- "Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Речи: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Карактери: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sv\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Ord: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Tecken: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: th\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "คำ: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "ตัวอักษร: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: ti\n"
11
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr ""
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr ""
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: tk\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Sözler: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Nyşanlar: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: tr\n"
11
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Kelimeler: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Karakterler: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: tt\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr ""
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr ""
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: ug\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "سۆز: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "ھەرپ: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: uk\n"
11
- "Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Слова: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Символи: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: ur\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "الفاظ: 0%"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "حروف: 0%"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: uz\n"
11
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr ""
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr ""
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: vi\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "Số chữ: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "Số ký tự: %0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: zh_CN\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "单词数:%0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "字符数:%0"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: zh_TW\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Label showing the number of words in the editor content."
15
- msgid "Words: %0"
16
- msgstr "字數: %0"
17
-
18
- msgctxt "Label showing the number of characters in the editor content."
19
- msgid "Characters: %0"
20
- msgstr "字元數: %0"
@@ -1,5 +0,0 @@
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
- export {};
package/src/index.js DELETED
@@ -1,10 +0,0 @@
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
- /**
6
- * @module word-count
7
- */
8
- export { WordCount } from './wordcount.js';
9
- export { modelElementToPlainText as _modelElementToPlainText } from './utils.js';
10
- import './augmentation.js';
package/src/utils.js DELETED
@@ -1,28 +0,0 @@
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
- /**
6
- * Returns a plain text representation of an element and its children.
7
- *
8
- * @internal
9
- * @returns Plain text representing the model's data.
10
- */
11
- export function modelElementToPlainText(item) {
12
- if (item.is('$text') || item.is('$textProxy')) {
13
- return item.data;
14
- }
15
- const element = item;
16
- let text = '';
17
- let prev = null;
18
- for (const child of element.getChildren()) {
19
- const childText = modelElementToPlainText(child);
20
- // If last block was finish, start from new line.
21
- if (prev && prev.is('element')) {
22
- text += '\n';
23
- }
24
- text += childText;
25
- prev = child;
26
- }
27
- return text;
28
- }
package/src/wordcount.js DELETED
@@ -1,242 +0,0 @@
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 } from 'ckeditor5/src/core.js';
6
- import { Template, View } from 'ckeditor5/src/ui.js';
7
- import { env } from 'ckeditor5/src/utils.js';
8
- import { modelElementToPlainText } from './utils.js';
9
- import { throttle, isElement } from 'es-toolkit/compat';
10
- /**
11
- * The word count plugin.
12
- *
13
- * This plugin calculates all words and characters in all {@link module:engine/model/text~ModelText 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 class WordCount extends Plugin {
41
- /**
42
- * The configuration of this plugin.
43
- */
44
- _config;
45
- /**
46
- * The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.
47
- */
48
- _outputView;
49
- /**
50
- * A regular expression used to recognize words in the editor's content.
51
- */
52
- _wordsMatchRegExp;
53
- /**
54
- * @inheritDoc
55
- */
56
- constructor(editor) {
57
- super(editor);
58
- this.set('characters', 0);
59
- this.set('words', 0);
60
- // Don't wait for the #update event to set the value of the properties but obtain it right away.
61
- // This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.
62
- // If not accessed directly, the properties will be refreshed upon #update anyway.
63
- Object.defineProperties(this, {
64
- characters: {
65
- get() {
66
- return (this.characters = this._getCharacters(this._getText()));
67
- }
68
- },
69
- words: {
70
- get() {
71
- return (this.words = this._getWords(this._getText()));
72
- }
73
- }
74
- });
75
- this.set('_wordsLabel', undefined);
76
- this.set('_charactersLabel', undefined);
77
- this._config = editor.config.get('wordCount') || {};
78
- this._outputView = undefined;
79
- this._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ?
80
- // Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).
81
- // Groups:
82
- // {L} - Any kind of letter from any language.
83
- // {N} - Any kind of numeric character in any script.
84
- new RegExp('([\\p{L}\\p{N}]+\\S?)+', 'gu') :
85
- /([a-zA-Z0-9À-ž]+\S?)+/gu;
86
- }
87
- /**
88
- * @inheritDoc
89
- */
90
- static get pluginName() {
91
- return 'WordCount';
92
- }
93
- /**
94
- * @inheritDoc
95
- * @internal
96
- */
97
- static get licenseFeatureCode() {
98
- return 'WC';
99
- }
100
- /**
101
- * @inheritDoc
102
- */
103
- static get isOfficialPlugin() {
104
- return true;
105
- }
106
- /**
107
- * @inheritDoc
108
- */
109
- static get isPremiumPlugin() {
110
- return true;
111
- }
112
- /**
113
- * @inheritDoc
114
- */
115
- init() {
116
- const editor = this.editor;
117
- editor.model.document.on('change:data', throttle(this._refreshStats.bind(this), 250));
118
- if (typeof this._config.onUpdate == 'function') {
119
- this.on('update', (evt, data) => {
120
- this._config.onUpdate(data);
121
- });
122
- }
123
- if (isElement(this._config.container)) {
124
- this._config.container.appendChild(this.wordCountContainer);
125
- }
126
- }
127
- /**
128
- * @inheritDoc
129
- */
130
- destroy() {
131
- if (this._outputView) {
132
- this._outputView.element.remove();
133
- this._outputView.destroy();
134
- }
135
- super.destroy();
136
- }
137
- /**
138
- * Creates a self-updating HTML element. Repeated executions return the same element.
139
- * The returned element has the following HTML structure:
140
- *
141
- * ```html
142
- * <div class="ck ck-word-count">
143
- * <div class="ck-word-count__words">Words: 4</div>
144
- * <div class="ck-word-count__characters">Characters: 28</div>
145
- * </div>
146
- * ```
147
- */
148
- get wordCountContainer() {
149
- const editor = this.editor;
150
- const t = editor.t;
151
- const displayWords = editor.config.get('wordCount.displayWords');
152
- const displayCharacters = editor.config.get('wordCount.displayCharacters');
153
- const bind = Template.bind(this, this);
154
- const children = [];
155
- if (!this._outputView) {
156
- this._outputView = new View();
157
- if (displayWords || displayWords === undefined) {
158
- this.bind('_wordsLabel').to(this, 'words', words => {
159
- return t('Words: %0', words);
160
- });
161
- children.push({
162
- tag: 'div',
163
- children: [
164
- {
165
- text: [bind.to('_wordsLabel')]
166
- }
167
- ],
168
- attributes: {
169
- class: 'ck-word-count__words'
170
- }
171
- });
172
- }
173
- if (displayCharacters || displayCharacters === undefined) {
174
- this.bind('_charactersLabel').to(this, 'characters', words => {
175
- return t('Characters: %0', words);
176
- });
177
- children.push({
178
- tag: 'div',
179
- children: [
180
- {
181
- text: [bind.to('_charactersLabel')]
182
- }
183
- ],
184
- attributes: {
185
- class: 'ck-word-count__characters'
186
- }
187
- });
188
- }
189
- this._outputView.setTemplate({
190
- tag: 'div',
191
- attributes: {
192
- class: [
193
- 'ck',
194
- 'ck-word-count'
195
- ]
196
- },
197
- children
198
- });
199
- this._outputView.render();
200
- }
201
- return this._outputView.element;
202
- }
203
- _getText() {
204
- let txt = '';
205
- for (const root of this.editor.model.document.getRoots()) {
206
- if (txt !== '') {
207
- // Add a delimiter, so words from each root are treated independently.
208
- txt += '\n';
209
- }
210
- txt += modelElementToPlainText(root);
211
- }
212
- return txt;
213
- }
214
- /**
215
- * Determines the number of characters in the current editor's model.
216
- */
217
- _getCharacters(txt) {
218
- return txt.replace(/\n/g, '').length;
219
- }
220
- /**
221
- * Determines the number of words in the current editor's model.
222
- */
223
- _getWords(txt) {
224
- const detectedWords = txt.match(this._wordsMatchRegExp) || [];
225
- return detectedWords.length;
226
- }
227
- /**
228
- * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
229
- * It also fires the {@link #event:update}.
230
- *
231
- * @fires update
232
- */
233
- _refreshStats() {
234
- const txt = this._getText();
235
- const words = this.words = this._getWords(txt);
236
- const characters = this.characters = this._getCharacters(txt);
237
- this.fire('update', {
238
- words,
239
- characters
240
- });
241
- }
242
- }
@@ -1,5 +0,0 @@
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
- export {};
File without changes
File without changes
File without changes