@ckeditor/ckeditor5-word-count 0.0.0-internal-20241017.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.
- package/CHANGELOG.md +4 -0
- package/LICENSE.md +21 -0
- package/README.md +26 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/hy.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/build/word-count.js +5 -0
- package/ckeditor5-metadata.json +11 -0
- package/dist/augmentation.d.ts +23 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +4 -0
- package/dist/index.css +4 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +249 -0
- package/dist/index.js.map +1 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es-co.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/hy.d.ts +8 -0
- package/dist/translations/hy.js +5 -0
- package/dist/translations/hy.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/dist/utils.d.ts +18 -0
- package/dist/wordcount.d.ts +143 -0
- package/dist/wordcountconfig.d.ts +96 -0
- package/lang/contexts.json +4 -0
- package/lang/translations/ar.po +26 -0
- package/lang/translations/az.po +26 -0
- package/lang/translations/bg.po +26 -0
- package/lang/translations/bn.po +26 -0
- package/lang/translations/ca.po +26 -0
- package/lang/translations/cs.po +26 -0
- package/lang/translations/da.po +26 -0
- package/lang/translations/de-ch.po +26 -0
- package/lang/translations/de.po +26 -0
- package/lang/translations/el.po +26 -0
- package/lang/translations/en-au.po +26 -0
- package/lang/translations/en-gb.po +26 -0
- package/lang/translations/en.po +26 -0
- package/lang/translations/es-co.po +26 -0
- package/lang/translations/es.po +26 -0
- package/lang/translations/et.po +26 -0
- package/lang/translations/fa.po +26 -0
- package/lang/translations/fi.po +26 -0
- package/lang/translations/fr.po +26 -0
- package/lang/translations/gl.po +26 -0
- package/lang/translations/he.po +26 -0
- package/lang/translations/hi.po +26 -0
- package/lang/translations/hr.po +26 -0
- package/lang/translations/hu.po +26 -0
- package/lang/translations/hy.po +26 -0
- package/lang/translations/id.po +26 -0
- package/lang/translations/it.po +26 -0
- package/lang/translations/ja.po +26 -0
- package/lang/translations/ko.po +26 -0
- package/lang/translations/ku.po +26 -0
- package/lang/translations/lt.po +26 -0
- package/lang/translations/lv.po +26 -0
- package/lang/translations/ms.po +26 -0
- package/lang/translations/ne.po +26 -0
- package/lang/translations/nl.po +26 -0
- package/lang/translations/no.po +26 -0
- package/lang/translations/pl.po +26 -0
- package/lang/translations/pt-br.po +26 -0
- package/lang/translations/pt.po +26 -0
- package/lang/translations/ro.po +26 -0
- package/lang/translations/ru.po +26 -0
- package/lang/translations/sk.po +26 -0
- package/lang/translations/sq.po +26 -0
- package/lang/translations/sr-latn.po +26 -0
- package/lang/translations/sr.po +26 -0
- package/lang/translations/sv.po +26 -0
- package/lang/translations/th.po +26 -0
- package/lang/translations/tk.po +26 -0
- package/lang/translations/tr.po +26 -0
- package/lang/translations/ug.po +26 -0
- package/lang/translations/uk.po +26 -0
- package/lang/translations/ur.po +26 -0
- package/lang/translations/vi.po +26 -0
- package/lang/translations/zh-cn.po +26 -0
- package/lang/translations/zh.po +26 -0
- package/package.json +42 -0
- package/src/augmentation.d.ts +19 -0
- package/src/augmentation.js +5 -0
- package/src/index.d.ts +10 -0
- package/src/index.js +9 -0
- package/src/utils.d.ts +14 -0
- package/src/utils.js +27 -0
- package/src/wordcount.d.ts +139 -0
- package/src/wordcount.js +217 -0
- package/src/wordcountconfig.d.ts +92 -0
- package/src/wordcountconfig.js +5 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Software License Agreement
|
|
2
|
+
==========================
|
|
3
|
+
|
|
4
|
+
**CKEditor 5 word and character count feature** – https://github.com/ckeditor/ckeditor5-word-count <br>
|
|
5
|
+
Copyright (c) 2003–2024, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
|
6
|
+
|
|
7
|
+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
|
+
|
|
9
|
+
Sources of Intellectual Property Included in CKEditor
|
|
10
|
+
-----------------------------------------------------
|
|
11
|
+
|
|
12
|
+
Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.
|
|
13
|
+
|
|
14
|
+
The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):
|
|
15
|
+
|
|
16
|
+
* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
|
|
17
|
+
|
|
18
|
+
Trademarks
|
|
19
|
+
----------
|
|
20
|
+
|
|
21
|
+
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
CKEditor 5 word and character count feature
|
|
2
|
+
===========================
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/@ckeditor/ckeditor5-word-count)
|
|
5
|
+
[](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
|
6
|
+
[](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
|
7
|
+
|
|
8
|
+
This package implements word count and character count support for CKEditor 5.
|
|
9
|
+
|
|
10
|
+
## Demo
|
|
11
|
+
|
|
12
|
+
Check out the demo in the [word count and character count feature guide](https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html#demo).
|
|
13
|
+
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
See the [`@ckeditor/ckeditor5-word-count` package](https://ckeditor.com/docs/ckeditor5/latest/api/word-count.html) page in [CKEditor 5 documentation](https://ckeditor.com/docs/ckeditor5/latest/).
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install ckeditor5
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file or [https://ckeditor.com/legal/ckeditor-oss-license](https://ckeditor.com/legal/ckeditor-oss-license).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.ar=i.ar||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"الأحرف: %0","Words: %0":"الكلمات: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const a=i.az=i.az||{};a.dictionary=Object.assign(a.dictionary||{},{"Characters: %0":"Simvolar: %0","Words: %0":"Sözlər: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.bg=i.bg||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Знаци: %0","Words: %0":"Думи: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const i=n.bn=n.bn||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"অক্ষরসমূহঃ %0","Words: %0":"শব্দগুলোঃ %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const c=a.ca=a.ca||{};c.dictionary=Object.assign(c.dictionary||{},{"Characters: %0":"Caràcters: %0","Words: %0":"Paraules: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(o){const n=o.cs=o.cs||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Počet znaků: %0","Words: %0":"Počet slov: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const r=a.da=a.da||{};r.dictionary=Object.assign(r.dictionary||{},{"Characters: %0":"Karakterer: %0","Words: %0":"Ord: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(c){const i=c["de-ch"]=c["de-ch"]||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Zeichen: %0","Words: %0":"Wörter: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.de=i.de||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Zeichen: %0 ","Words: %0":"Wörter: %0 "})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.el=i.el||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Χαρακτήρες: %0","Words: %0":"Λέξεις: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const a=n["en-au"]=n["en-au"]||{};a.dictionary=Object.assign(a.dictionary||{},{"Characters: %0":"Characters: %0","Words: %0":"Words: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const i=n["en-gb"]=n["en-gb"]||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Characters: %0","Words: %0":"Words: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const c=a["es-co"]=a["es-co"]||{};c.dictionary=Object.assign(c.dictionary||{},{"Characters: %0":"Caracteres: %0","Words: %0":"Palabras: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const s=a.es=a.es||{};s.dictionary=Object.assign(s.dictionary||{},{"Characters: %0":"Caracteres: %0","Words: %0":"Palabras: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const i=n.et=n.et||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Märke: %0","Words: %0":"Sõnu: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.fa=i.fa||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"تعداد حروف : %0","Words: %0":"تعداد لغات : %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.fi=i.fi||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Merkkejä: %0","Words: %0":"Sanoja: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(r){const i=r.fr=r.fr||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Caractères : %0","Words: %0":"Mots : %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const i=a.gl=a.gl||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Caracteres: %0","Words: %0":"Palabras: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.he=i.he||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"מס' תווים: %0","Words: %0":"מס' מילים: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.hi=i.hi||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Characters: %0","Words: %0":"Words: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.hr=i.hr||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Znakova: %0","Words: %0":"Riječi: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const i=a.hu=a.hu||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Karakterek: %0","Words: %0":"Szavak: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.hy=i.hy||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"%0 նիշեր","Words: %0":"%0 բառեր"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const a=i.id=i.id||{};a.dictionary=Object.assign(a.dictionary||{},{"Characters: %0":"Karakter: %0","Words: %0":"Kata: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const t=i.it=i.it||{};t.dictionary=Object.assign(t.dictionary||{},{"Characters: %0":"Caratteri: %0","Words: %0":"Parole: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.ja=i.ja||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"文字数: %0","Words: %0":"単語数: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(o){const i=o.ko=o.ko||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"문자 수: %0","Words: %0":"단어 수: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.ku=i.ku||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"نووسەکان: %0","Words: %0":"وشەکان: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const o=i.lt=i.lt||{};o.dictionary=Object.assign(o.dictionary||{},{"Characters: %0":"Simbolių: %0","Words: %0":"Žodžių: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.lv=i.lv||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Rakstzīmes: %0","Words: %0":"Vārdi: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const n=a.ms=a.ms||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Aksara: %0","Words: %0":"Perkataan: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const i=n.ne=n.ne||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"क्यारेक्टरहरू: %0","Words: %0":"शब्दहरू: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const o=n.nl=n.nl||{};o.dictionary=Object.assign(o.dictionary||{},{"Characters: %0":"Tekens: %0","Words: %0":"Woorden: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const o=n.no=n.no||{};o.dictionary=Object.assign(o.dictionary||{},{"Characters: %0":"Tegn: %0","Words: %0":"Ord: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.pl=i.pl||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Znaki: %0","Words: %0":"Słowa: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const r=a["pt-br"]=a["pt-br"]||{};r.dictionary=Object.assign(r.dictionary||{},{"Characters: %0":"Caracteres: %0","Words: %0":"Palavras: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const t=a.pt=a.pt||{};t.dictionary=Object.assign(t.dictionary||{},{"Characters: %0":"Caracteres: %0","Words: %0":"Palavras: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.ro=i.ro||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Caractere: %0","Words: %0":"Cuvinte: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.ru=i.ru||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Символов: %0","Words: %0":"Слов: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const o=n.sk=n.sk||{};o.dictionary=Object.assign(o.dictionary||{},{"Characters: %0":"Znakov: %0","Words: %0":"Slov: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(a){const i=a.sq=a.sq||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Karaktere: %0","Words: %0":"Fjalë: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i["sr-latn"]=i["sr-latn"]||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Karakteri: %0","Words: %0":"Reči: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.sr=i.sr||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Карактери: %0","Words: %0":"Речи: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const i=n.sv=n.sv||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Tecken: %0","Words: %0":"Ord: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.th=i.th||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"ตัวอักษร: %0","Words: %0":"คำ: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const i=n.tk=n.tk||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Nyşanlar: %0","Words: %0":"Sözler: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(r){const i=r.tr=r.tr||{};i.dictionary=Object.assign(i.dictionary||{},{"Characters: %0":"Karakterler: %0","Words: %0":"Kelimeler: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.ug=i.ug||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"ھەرپ: %0","Words: %0":"سۆز: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.uk=i.uk||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Символи: %0","Words: %0":"Слова: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.ur=i.ur||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"حروف: 0%","Words: %0":"الفاظ: 0%"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.vi=i.vi||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"Số ký tự: %0","Words: %0":"Số chữ: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(n){const c=n["zh-cn"]=n["zh-cn"]||{};c.dictionary=Object.assign(c.dictionary||{},{"Characters: %0":"字符数:%0","Words: %0":"单词数:%0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(i){const n=i.zh=i.zh||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"字元數: %0","Words: %0":"字數: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
!function(t){const e=t.en=t.en||{};e.dictionary=Object.assign(e.dictionary||{},{"Characters: %0":"Characters: %0","Words: %0":"Words: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
|
|
2
|
+
/*!
|
|
3
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
4
|
+
* For licensing, see LICENSE.md.
|
|
5
|
+
*/(()=>{var t={782:(t,e,r)=>{t.exports=r(237)("./src/core.js")},311:(t,e,r)=>{t.exports=r(237)("./src/ui.js")},584:(t,e,r)=>{t.exports=r(237)("./src/utils.js")},237:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function r(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{WordCount:()=>z});var t=r(782),e=r(311),n=r(584);function i(t){if(t.is("$text")||t.is("$textProxy"))return t.data;const e=t;let r="",o=null;for(const t of e.getChildren()){const e=i(t);o&&o.is("element")&&(r+="\n"),r+=e,o=t}return r}const s=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const c="object"==typeof global&&global&&global.Object===Object&&global;var a="object"==typeof self&&self&&self.Object===Object&&self;const u=c||a||Function("return this")();const d=function(){return u.Date.now()};var l=/\s/;const f=function(t){for(var e=t.length;e--&&l.test(t.charAt(e)););return e};var h=/^\s+/;const p=function(t){return t?t.slice(0,f(t)+1).replace(h,""):t};const g=u.Symbol;var v=Object.prototype,b=v.hasOwnProperty,w=v.toString,y=g?g.toStringTag:void 0;const _=function(t){var e=b.call(t,y),r=t[y];try{t[y]=void 0;var o=!0}catch(t){}var n=w.call(t);return o&&(e?t[y]=r:delete t[y]),n};var m=Object.prototype.toString;const j=function(t){return m.call(t)};var x=g?g.toStringTag:void 0;const O=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":x&&x in Object(t)?_(t):j(t)};const T=function(t){return null!=t&&"object"==typeof t};const C=function(t){return"symbol"==typeof t||T(t)&&"[object Symbol]"==O(t)};var S=/^[-+]0x[0-9a-f]+$/i,E=/^0b[01]+$/i,P=/^0o[0-7]+$/i,W=parseInt;const N=function(t){if("number"==typeof t)return t;if(C(t))return NaN;if(s(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=s(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=p(t);var r=E.test(t);return r||P.test(t)?W(t.slice(2),r?2:8):S.test(t)?NaN:+t};var V=Math.max,L=Math.min;const R=function(t,e,r){var o,n,i,c,a,u,l=0,f=!1,h=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function g(e){var r=o,i=n;return o=n=void 0,l=e,c=t.apply(i,r)}function v(t){var r=t-u;return void 0===u||r>=e||r<0||h&&t-l>=i}function b(){var t=d();if(v(t))return w(t);a=setTimeout(b,function(t){var r=e-(t-u);return h?L(r,i-(t-l)):r}(t))}function w(t){return a=void 0,p&&o?g(t):(o=n=void 0,c)}function y(){var t=d(),r=v(t);if(o=arguments,n=this,u=t,r){if(void 0===a)return function(t){return l=t,a=setTimeout(b,e),f?g(t):c}(u);if(h)return clearTimeout(a),a=setTimeout(b,e),g(u)}return void 0===a&&(a=setTimeout(b,e)),c}return e=N(e)||0,s(r)&&(f=!!r.leading,i=(h="maxWait"in r)?V(N(r.maxWait)||0,e):i,p="trailing"in r?!!r.trailing:p),y.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=u=n=a=void 0},y.flush=function(){return void 0===a?c:w(d())},y};const A=function(t,e,r){var o=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return s(r)&&(o="leading"in r?!!r.leading:o,n="trailing"in r?!!r.trailing:n),R(t,e,{leading:o,maxWait:e,trailing:n})};const M=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);var I=Function.prototype,K=Object.prototype,$=I.toString,k=K.hasOwnProperty,U=$.call(Object);const D=function(t){if(!T(t)||"[object Object]"!=O(t))return!1;var e=M(t);if(null===e)return!0;var r=k.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&$.call(r)==U};const F=function(t){return T(t)&&1===t.nodeType&&!D(t)};class z extends t.Plugin{constructor(t){super(t),this.set("characters",0),this.set("words",0),Object.defineProperties(this,{characters:{get(){return this.characters=this._getCharacters(this._getText())}},words:{get(){return this.words=this._getWords(this._getText())}}}),this.set("_wordsLabel",void 0),this.set("_charactersLabel",void 0),this._config=t.config.get("wordCount")||{},this._outputView=void 0,this._wordsMatchRegExp=n.env.features.isRegExpUnicodePropertySupported?new RegExp("([\\p{L}\\p{N}]+\\S?)+","gu"):/([a-zA-Z0-9À-ž]+\S?)+/gu}static get pluginName(){return"WordCount"}static get isOfficialPlugin(){return!0}init(){this.editor.model.document.on("change:data",A(this._refreshStats.bind(this),250)),"function"==typeof this._config.onUpdate&&this.on("update",((t,e)=>{this._config.onUpdate(e)})),F(this._config.container)&&this._config.container.appendChild(this.wordCountContainer)}destroy(){this._outputView&&(this._outputView.element.remove(),this._outputView.destroy()),super.destroy()}get wordCountContainer(){const t=this.editor,r=t.t,o=t.config.get("wordCount.displayWords"),n=t.config.get("wordCount.displayCharacters"),i=e.Template.bind(this,this),s=[];return this._outputView||(this._outputView=new e.View,(o||void 0===o)&&(this.bind("_wordsLabel").to(this,"words",(t=>r("Words: %0",t))),s.push({tag:"div",children:[{text:[i.to("_wordsLabel")]}],attributes:{class:"ck-word-count__words"}})),(n||void 0===n)&&(this.bind("_charactersLabel").to(this,"characters",(t=>r("Characters: %0",t))),s.push({tag:"div",children:[{text:[i.to("_charactersLabel")]}],attributes:{class:"ck-word-count__characters"}})),this._outputView.setTemplate({tag:"div",attributes:{class:["ck","ck-word-count"]},children:s}),this._outputView.render()),this._outputView.element}_getText(){let t="";for(const e of this.editor.model.document.getRoots())""!==t&&(t+="\n"),t+=i(e);return t}_getCharacters(t){return t.replace(/\n/g,"").length}_getWords(t){return(t.match(this._wordsMatchRegExp)||[]).length}_refreshStats(){const t=this._getText(),e=this.words=this._getWords(t),r=this.characters=this._getCharacters(t);this.fire("update",{words:e,characters:r})}}})(),(window.CKEditor5=window.CKEditor5||{}).wordCount=o})();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": [
|
|
3
|
+
{
|
|
4
|
+
"name": "Word count",
|
|
5
|
+
"className": "WordCount",
|
|
6
|
+
"description": "Provides the possibility to track the number of words and characters written in the rich-text editor.",
|
|
7
|
+
"docs": "features/word-count.html",
|
|
8
|
+
"path": "src/wordcount.js"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -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
|
+
}
|
package/dist/index.css
ADDED
package/dist/index.d.ts
ADDED
|
@@ -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';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
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
|
+
* @module word-count/utils
|
|
15
|
+
*/ /**
|
|
16
|
+
* Returns a plain text representation of an element and its children.
|
|
17
|
+
*
|
|
18
|
+
* @returns Plain text representing the model's data.
|
|
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
|
+
* The word count plugin.
|
|
40
|
+
*
|
|
41
|
+
* This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.
|
|
42
|
+
* It also provides an HTML element that updates its state whenever the editor content is changed.
|
|
43
|
+
*
|
|
44
|
+
* The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.
|
|
45
|
+
* The number of words and characters in your text are determined based on the created plain text. Please keep in mind
|
|
46
|
+
* that every block in the editor is separated with a newline character, which is included in the calculation.
|
|
47
|
+
*
|
|
48
|
+
* Here are some examples of how the word and character calculations are made:
|
|
49
|
+
*
|
|
50
|
+
* ```html
|
|
51
|
+
* <paragraph>foo</paragraph>
|
|
52
|
+
* <paragraph>bar</paragraph>
|
|
53
|
+
* // Words: 2, Characters: 7
|
|
54
|
+
*
|
|
55
|
+
* <paragraph><$text bold="true">foo</$text>bar</paragraph>
|
|
56
|
+
* // Words: 1, Characters: 6
|
|
57
|
+
*
|
|
58
|
+
* <paragraph>*&^%)</paragraph>
|
|
59
|
+
* // Words: 0, Characters: 5
|
|
60
|
+
*
|
|
61
|
+
* <paragraph>foo(bar)</paragraph>
|
|
62
|
+
* //Words: 1, Characters: 8
|
|
63
|
+
*
|
|
64
|
+
* <paragraph>12345</paragraph>
|
|
65
|
+
* // Words: 1, Characters: 5
|
|
66
|
+
* ```
|
|
67
|
+
*/ class WordCount extends Plugin {
|
|
68
|
+
/**
|
|
69
|
+
* The configuration of this plugin.
|
|
70
|
+
*/ _config;
|
|
71
|
+
/**
|
|
72
|
+
* The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.
|
|
73
|
+
*/ _outputView;
|
|
74
|
+
/**
|
|
75
|
+
* A regular expression used to recognize words in the editor's content.
|
|
76
|
+
*/ _wordsMatchRegExp;
|
|
77
|
+
/**
|
|
78
|
+
* @inheritDoc
|
|
79
|
+
*/ constructor(editor){
|
|
80
|
+
super(editor);
|
|
81
|
+
this.set('characters', 0);
|
|
82
|
+
this.set('words', 0);
|
|
83
|
+
// Don't wait for the #update event to set the value of the properties but obtain it right away.
|
|
84
|
+
// This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.
|
|
85
|
+
// If not accessed directly, the properties will be refreshed upon #update anyway.
|
|
86
|
+
Object.defineProperties(this, {
|
|
87
|
+
characters: {
|
|
88
|
+
get () {
|
|
89
|
+
return this.characters = this._getCharacters(this._getText());
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
words: {
|
|
93
|
+
get () {
|
|
94
|
+
return this.words = this._getWords(this._getText());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
this.set('_wordsLabel', undefined);
|
|
99
|
+
this.set('_charactersLabel', undefined);
|
|
100
|
+
this._config = editor.config.get('wordCount') || {};
|
|
101
|
+
this._outputView = undefined;
|
|
102
|
+
this._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ? // Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).
|
|
103
|
+
// Groups:
|
|
104
|
+
// {L} - Any kind of letter from any language.
|
|
105
|
+
// {N} - Any kind of numeric character in any script.
|
|
106
|
+
new RegExp('([\\p{L}\\p{N}]+\\S?)+', 'gu') : /([a-zA-Z0-9À-ž]+\S?)+/gu;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @inheritDoc
|
|
110
|
+
*/ static get pluginName() {
|
|
111
|
+
return 'WordCount';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @inheritDoc
|
|
115
|
+
*/ static get isOfficialPlugin() {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @inheritDoc
|
|
120
|
+
*/ init() {
|
|
121
|
+
const editor = this.editor;
|
|
122
|
+
editor.model.document.on('change:data', throttle(this._refreshStats.bind(this), 250));
|
|
123
|
+
if (typeof this._config.onUpdate == 'function') {
|
|
124
|
+
this.on('update', (evt, data)=>{
|
|
125
|
+
this._config.onUpdate(data);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (isElement(this._config.container)) {
|
|
129
|
+
this._config.container.appendChild(this.wordCountContainer);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @inheritDoc
|
|
134
|
+
*/ destroy() {
|
|
135
|
+
if (this._outputView) {
|
|
136
|
+
this._outputView.element.remove();
|
|
137
|
+
this._outputView.destroy();
|
|
138
|
+
}
|
|
139
|
+
super.destroy();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Creates a self-updating HTML element. Repeated executions return the same element.
|
|
143
|
+
* The returned element has the following HTML structure:
|
|
144
|
+
*
|
|
145
|
+
* ```html
|
|
146
|
+
* <div class="ck ck-word-count">
|
|
147
|
+
* <div class="ck-word-count__words">Words: 4</div>
|
|
148
|
+
* <div class="ck-word-count__characters">Characters: 28</div>
|
|
149
|
+
* </div>
|
|
150
|
+
* ```
|
|
151
|
+
*/ get wordCountContainer() {
|
|
152
|
+
const editor = this.editor;
|
|
153
|
+
const t = editor.t;
|
|
154
|
+
const displayWords = editor.config.get('wordCount.displayWords');
|
|
155
|
+
const displayCharacters = editor.config.get('wordCount.displayCharacters');
|
|
156
|
+
const bind = Template.bind(this, this);
|
|
157
|
+
const children = [];
|
|
158
|
+
if (!this._outputView) {
|
|
159
|
+
this._outputView = new View();
|
|
160
|
+
if (displayWords || displayWords === undefined) {
|
|
161
|
+
this.bind('_wordsLabel').to(this, 'words', (words)=>{
|
|
162
|
+
return t('Words: %0', words);
|
|
163
|
+
});
|
|
164
|
+
children.push({
|
|
165
|
+
tag: 'div',
|
|
166
|
+
children: [
|
|
167
|
+
{
|
|
168
|
+
text: [
|
|
169
|
+
bind.to('_wordsLabel')
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
attributes: {
|
|
174
|
+
class: 'ck-word-count__words'
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (displayCharacters || displayCharacters === undefined) {
|
|
179
|
+
this.bind('_charactersLabel').to(this, 'characters', (words)=>{
|
|
180
|
+
return t('Characters: %0', words);
|
|
181
|
+
});
|
|
182
|
+
children.push({
|
|
183
|
+
tag: 'div',
|
|
184
|
+
children: [
|
|
185
|
+
{
|
|
186
|
+
text: [
|
|
187
|
+
bind.to('_charactersLabel')
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
attributes: {
|
|
192
|
+
class: 'ck-word-count__characters'
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
this._outputView.setTemplate({
|
|
197
|
+
tag: 'div',
|
|
198
|
+
attributes: {
|
|
199
|
+
class: [
|
|
200
|
+
'ck',
|
|
201
|
+
'ck-word-count'
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
children
|
|
205
|
+
});
|
|
206
|
+
this._outputView.render();
|
|
207
|
+
}
|
|
208
|
+
return this._outputView.element;
|
|
209
|
+
}
|
|
210
|
+
_getText() {
|
|
211
|
+
let txt = '';
|
|
212
|
+
for (const root of this.editor.model.document.getRoots()){
|
|
213
|
+
if (txt !== '') {
|
|
214
|
+
// Add a delimiter, so words from each root are treated independently.
|
|
215
|
+
txt += '\n';
|
|
216
|
+
}
|
|
217
|
+
txt += modelElementToPlainText(root);
|
|
218
|
+
}
|
|
219
|
+
return txt;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Determines the number of characters in the current editor's model.
|
|
223
|
+
*/ _getCharacters(txt) {
|
|
224
|
+
return txt.replace(/\n/g, '').length;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Determines the number of words in the current editor's model.
|
|
228
|
+
*/ _getWords(txt) {
|
|
229
|
+
const detectedWords = txt.match(this._wordsMatchRegExp) || [];
|
|
230
|
+
return detectedWords.length;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
|
|
234
|
+
* It also fires the {@link #event:update}.
|
|
235
|
+
*
|
|
236
|
+
* @fires update
|
|
237
|
+
*/ _refreshStats() {
|
|
238
|
+
const txt = this._getText();
|
|
239
|
+
const words = this.words = this._getWords(txt);
|
|
240
|
+
const characters = this.characters = this._getCharacters(txt);
|
|
241
|
+
this.fire('update', {
|
|
242
|
+
words,
|
|
243
|
+
characters
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export { WordCount };
|
|
249
|
+
//# sourceMappingURL=index.js.map
|