@ckeditor/ckeditor5-word-count 40.0.0 → 40.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -8
- package/LICENSE.md +3 -3
- package/package.json +2 -2
- package/src/augmentation.d.ts +19 -19
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +10 -10
- package/src/index.js +9 -9
- package/src/utils.d.ts +14 -14
- package/src/utils.js +27 -27
- package/src/wordcount.d.ts +135 -135
- package/src/wordcount.js +211 -211
- package/src/wordcountconfig.d.ts +92 -92
- package/src/wordcountconfig.js +5 -5
- package/build/word-count.js.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -5,40 +5,40 @@ All changes in the package are documented in the main repository. See: https://g
|
|
5
5
|
|
6
6
|
Changes for the past releases are available below.
|
7
7
|
|
8
|
-
## [19.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v18.0.0...v19.0.0) (2020
|
8
|
+
## [19.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v18.0.0...v19.0.0) (April 29, 2020)
|
9
9
|
|
10
10
|
### Other changes
|
11
11
|
|
12
12
|
* Updated translations. ([091f2e7](https://github.com/ckeditor/ckeditor5-word-count/commit/091f2e7))
|
13
13
|
|
14
14
|
|
15
|
-
## [18.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v17.0.0...v18.0.0) (2020
|
15
|
+
## [18.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v17.0.0...v18.0.0) (March 19, 2020)
|
16
16
|
|
17
17
|
Internal changes only (updated dependencies, documentation, etc.).
|
18
18
|
|
19
19
|
|
20
|
-
## [17.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v16.0.0...v17.0.0) (2020
|
20
|
+
## [17.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v16.0.0...v17.0.0) (February 19, 2020)
|
21
21
|
|
22
22
|
### Other changes
|
23
23
|
|
24
24
|
* Updated translations. ([d8e40e5](https://github.com/ckeditor/ckeditor5-word-count/commit/d8e40e5))
|
25
25
|
|
26
26
|
|
27
|
-
## [16.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v15.0.0...v16.0.0) (2019
|
27
|
+
## [16.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v15.0.0...v16.0.0) (December 4, 2019)
|
28
28
|
|
29
29
|
### Other changes
|
30
30
|
|
31
31
|
* Updated translations. ([ffa4b14](https://github.com/ckeditor/ckeditor5-word-count/commit/ffa4b14))
|
32
32
|
|
33
33
|
|
34
|
-
## [15.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v10.0.2...v15.0.0) (2019
|
34
|
+
## [15.0.0](https://github.com/ckeditor/ckeditor5-word-count/compare/v10.0.2...v15.0.0) (October 23, 2019)
|
35
35
|
|
36
36
|
### Other changes
|
37
37
|
|
38
38
|
* Updated translations. ([ff823db](https://github.com/ckeditor/ckeditor5-word-count/commit/ff823db)) ([6d2cc2b](https://github.com/ckeditor/ckeditor5-word-count/commit/6d2cc2b))
|
39
39
|
|
40
40
|
|
41
|
-
## [10.0.2](https://github.com/ckeditor/ckeditor5-word-count/compare/v10.0.1...v10.0.2) (2019
|
41
|
+
## [10.0.2](https://github.com/ckeditor/ckeditor5-word-count/compare/v10.0.1...v10.0.2) (August 26, 2019)
|
42
42
|
|
43
43
|
### Bug fixes
|
44
44
|
|
@@ -52,11 +52,11 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
52
52
|
* Updated translations. ([9aab7fb](https://github.com/ckeditor/ckeditor5-word-count/commit/9aab7fb))
|
53
53
|
|
54
54
|
|
55
|
-
## [10.0.1](https://github.com/ckeditor/ckeditor5-word-count/compare/v10.0.0...v10.0.1) (2019
|
55
|
+
## [10.0.1](https://github.com/ckeditor/ckeditor5-word-count/compare/v10.0.0...v10.0.1) (July 10, 2019)
|
56
56
|
|
57
57
|
Internal changes only (updated dependencies, documentation, etc.).
|
58
58
|
|
59
59
|
|
60
|
-
## [10.0.0](https://github.com/ckeditor/ckeditor5-word-count/tree/v10.0.0) (2019
|
60
|
+
## [10.0.0](https://github.com/ckeditor/ckeditor5-word-count/tree/v10.0.0) (July 4, 2019)
|
61
61
|
|
62
62
|
The initial font feature implementation.
|
package/LICENSE.md
CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
|
|
2
2
|
==========================
|
3
3
|
|
4
4
|
**CKEditor 5 word and character count feature** – https://github.com/ckeditor/ckeditor5-word-count <br>
|
5
|
-
Copyright (c) 2003
|
5
|
+
Copyright (c) 2003–2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
6
6
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
8
8
|
|
@@ -13,9 +13,9 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
|
|
13
13
|
|
14
14
|
The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):
|
15
15
|
|
16
|
-
*
|
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
17
|
|
18
18
|
Trademarks
|
19
19
|
----------
|
20
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.
|
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-word-count",
|
3
|
-
"version": "40.
|
3
|
+
"version": "40.2.0",
|
4
4
|
"description": "Word and character count feature for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"main": "src/index.js",
|
14
14
|
"dependencies": {
|
15
15
|
"lodash-es": "4.17.21",
|
16
|
-
"ckeditor5": "40.
|
16
|
+
"ckeditor5": "40.2.0"
|
17
17
|
},
|
18
18
|
"author": "CKSource (http://cksource.com/)",
|
19
19
|
"license": "GPL-2.0-or-later",
|
package/src/augmentation.d.ts
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
import type { WordCount, WordCountConfig } from './index';
|
6
|
-
declare module '@ckeditor/ckeditor5-core' {
|
7
|
-
interface EditorConfig {
|
8
|
-
/**
|
9
|
-
* The configuration of the word count feature.
|
10
|
-
* It is introduced by the {@link module:word-count/wordcount~WordCount} feature.
|
11
|
-
*
|
12
|
-
* Read more in {@link module:word-count/wordcountconfig~WordCountConfig}.
|
13
|
-
*/
|
14
|
-
wordCount?: WordCountConfig;
|
15
|
-
}
|
16
|
-
interface PluginsMap {
|
17
|
-
[WordCount.pluginName]: WordCount;
|
18
|
-
}
|
19
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
import type { WordCount, WordCountConfig } from './index';
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
7
|
+
interface EditorConfig {
|
8
|
+
/**
|
9
|
+
* The configuration of the word count feature.
|
10
|
+
* It is introduced by the {@link module:word-count/wordcount~WordCount} feature.
|
11
|
+
*
|
12
|
+
* Read more in {@link module:word-count/wordcountconfig~WordCountConfig}.
|
13
|
+
*/
|
14
|
+
wordCount?: WordCountConfig;
|
15
|
+
}
|
16
|
+
interface PluginsMap {
|
17
|
+
[WordCount.pluginName]: WordCount;
|
18
|
+
}
|
19
|
+
}
|
package/src/augmentation.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, 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 {};
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, 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 {};
|
package/src/index.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module word-count
|
7
|
-
*/
|
8
|
-
export { default as WordCount, type WordCountUpdateEvent } from './wordcount';
|
9
|
-
export { WordCountConfig } from './wordcountconfig';
|
10
|
-
import './augmentation';
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module word-count
|
7
|
+
*/
|
8
|
+
export { default as WordCount, type WordCountUpdateEvent } from './wordcount';
|
9
|
+
export { WordCountConfig } from './wordcountconfig';
|
10
|
+
import './augmentation';
|
package/src/index.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module word-count
|
7
|
-
*/
|
8
|
-
export { default as WordCount } from './wordcount';
|
9
|
-
import './augmentation';
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module word-count
|
7
|
+
*/
|
8
|
+
export { default as WordCount } from './wordcount';
|
9
|
+
import './augmentation';
|
package/src/utils.d.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module word-count/utils
|
7
|
-
*/
|
8
|
-
import type { Item } from 'ckeditor5/src/engine';
|
9
|
-
/**
|
10
|
-
* Returns a plain text representation of an element and its children.
|
11
|
-
*
|
12
|
-
* @returns Plain text representing the model's data.
|
13
|
-
*/
|
14
|
-
export declare function modelElementToPlainText(item: Item): string;
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module word-count/utils
|
7
|
+
*/
|
8
|
+
import type { Item } from 'ckeditor5/src/engine';
|
9
|
+
/**
|
10
|
+
* Returns a plain text representation of an element and its children.
|
11
|
+
*
|
12
|
+
* @returns Plain text representing the model's data.
|
13
|
+
*/
|
14
|
+
export declare function modelElementToPlainText(item: Item): string;
|
package/src/utils.js
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, 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
|
-
* Returns a plain text representation of an element and its children.
|
7
|
-
*
|
8
|
-
* @returns Plain text representing the model's data.
|
9
|
-
*/
|
10
|
-
export function modelElementToPlainText(item) {
|
11
|
-
if (item.is('$text') || item.is('$textProxy')) {
|
12
|
-
return item.data;
|
13
|
-
}
|
14
|
-
const element = item;
|
15
|
-
let text = '';
|
16
|
-
let prev = null;
|
17
|
-
for (const child of element.getChildren()) {
|
18
|
-
const childText = modelElementToPlainText(child);
|
19
|
-
// If last block was finish, start from new line.
|
20
|
-
if (prev && prev.is('element')) {
|
21
|
-
text += '\n';
|
22
|
-
}
|
23
|
-
text += childText;
|
24
|
-
prev = child;
|
25
|
-
}
|
26
|
-
return text;
|
27
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, 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
|
+
* Returns a plain text representation of an element and its children.
|
7
|
+
*
|
8
|
+
* @returns Plain text representing the model's data.
|
9
|
+
*/
|
10
|
+
export function modelElementToPlainText(item) {
|
11
|
+
if (item.is('$text') || item.is('$textProxy')) {
|
12
|
+
return item.data;
|
13
|
+
}
|
14
|
+
const element = item;
|
15
|
+
let text = '';
|
16
|
+
let prev = null;
|
17
|
+
for (const child of element.getChildren()) {
|
18
|
+
const childText = modelElementToPlainText(child);
|
19
|
+
// If last block was finish, start from new line.
|
20
|
+
if (prev && prev.is('element')) {
|
21
|
+
text += '\n';
|
22
|
+
}
|
23
|
+
text += childText;
|
24
|
+
prev = child;
|
25
|
+
}
|
26
|
+
return text;
|
27
|
+
}
|
package/src/wordcount.d.ts
CHANGED
@@ -1,135 +1,135 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
6
|
-
/**
|
7
|
-
* The word count plugin.
|
8
|
-
*
|
9
|
-
* This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.
|
10
|
-
* It also provides an HTML element that updates its state whenever the editor content is changed.
|
11
|
-
*
|
12
|
-
* The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.
|
13
|
-
* The number of words and characters in your text are determined based on the created plain text. Please keep in mind
|
14
|
-
* that every block in the editor is separated with a newline character, which is included in the calculation.
|
15
|
-
*
|
16
|
-
* Here are some examples of how the word and character calculations are made:
|
17
|
-
*
|
18
|
-
* ```html
|
19
|
-
* <paragraph>foo</paragraph>
|
20
|
-
* <paragraph>bar</paragraph>
|
21
|
-
* // Words: 2, Characters: 7
|
22
|
-
*
|
23
|
-
* <paragraph><$text bold="true">foo</$text>bar</paragraph>
|
24
|
-
* // Words: 1, Characters: 6
|
25
|
-
*
|
26
|
-
* <paragraph>*&^%)</paragraph>
|
27
|
-
* // Words: 0, Characters: 5
|
28
|
-
*
|
29
|
-
* <paragraph>foo(bar)</paragraph>
|
30
|
-
* //Words: 1, Characters: 8
|
31
|
-
*
|
32
|
-
* <paragraph>12345</paragraph>
|
33
|
-
* // Words: 1, Characters: 5
|
34
|
-
* ```
|
35
|
-
*/
|
36
|
-
export default class WordCount extends Plugin {
|
37
|
-
/**
|
38
|
-
* The number of characters in the editor.
|
39
|
-
*
|
40
|
-
* @observable
|
41
|
-
* @readonly
|
42
|
-
*/
|
43
|
-
characters: number;
|
44
|
-
/**
|
45
|
-
* The number of words in the editor.
|
46
|
-
*
|
47
|
-
* @observable
|
48
|
-
* @readonly
|
49
|
-
*/
|
50
|
-
words: number;
|
51
|
-
/**
|
52
|
-
* The label used to display the words value in the {@link #wordCountContainer output container}.
|
53
|
-
*
|
54
|
-
* @observable
|
55
|
-
* @private
|
56
|
-
* @readonly
|
57
|
-
*/
|
58
|
-
_wordsLabel: string | undefined;
|
59
|
-
/**
|
60
|
-
* The label used to display the characters value in the {@link #wordCountContainer output container}.
|
61
|
-
*
|
62
|
-
* @observable
|
63
|
-
* @private
|
64
|
-
* @readonly
|
65
|
-
*/
|
66
|
-
_charactersLabel: string | undefined;
|
67
|
-
/**
|
68
|
-
* The configuration of this plugin.
|
69
|
-
*/
|
70
|
-
private _config;
|
71
|
-
/**
|
72
|
-
* The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.
|
73
|
-
*/
|
74
|
-
private _outputView;
|
75
|
-
/**
|
76
|
-
* A regular expression used to recognize words in the editor's content.
|
77
|
-
*/
|
78
|
-
private readonly _wordsMatchRegExp;
|
79
|
-
/**
|
80
|
-
* @inheritDoc
|
81
|
-
*/
|
82
|
-
constructor(editor: Editor);
|
83
|
-
/**
|
84
|
-
* @inheritDoc
|
85
|
-
*/
|
86
|
-
static get pluginName(): "WordCount";
|
87
|
-
/**
|
88
|
-
* @inheritDoc
|
89
|
-
*/
|
90
|
-
init(): void;
|
91
|
-
/**
|
92
|
-
* @inheritDoc
|
93
|
-
*/
|
94
|
-
destroy(): void;
|
95
|
-
/**
|
96
|
-
* Creates a self-updating HTML element. Repeated executions return the same element.
|
97
|
-
* The returned element has the following HTML structure:
|
98
|
-
*
|
99
|
-
* ```html
|
100
|
-
* <div class="ck ck-word-count">
|
101
|
-
* <div class="ck-word-count__words">Words: 4</div>
|
102
|
-
* <div class="ck-word-count__characters">Characters: 28</div>
|
103
|
-
* </div>
|
104
|
-
* ```
|
105
|
-
*/
|
106
|
-
get wordCountContainer(): HTMLElement;
|
107
|
-
private _getText;
|
108
|
-
/**
|
109
|
-
* Determines the number of characters in the current editor's model.
|
110
|
-
*/
|
111
|
-
private _getCharacters;
|
112
|
-
/**
|
113
|
-
* Determines the number of words in the current editor's model.
|
114
|
-
*/
|
115
|
-
private _getWords;
|
116
|
-
/**
|
117
|
-
* Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
|
118
|
-
* It also fires the {@link #event:update}.
|
119
|
-
*
|
120
|
-
* @fires update
|
121
|
-
*/
|
122
|
-
private _refreshStats;
|
123
|
-
}
|
124
|
-
/**
|
125
|
-
* An event fired after {@link ~WordCount#words} and {@link ~WordCount#characters} are updated.
|
126
|
-
*
|
127
|
-
* @eventName ~WordCount#update
|
128
|
-
*/
|
129
|
-
export type WordCountUpdateEvent = {
|
130
|
-
name: 'update';
|
131
|
-
args: [{
|
132
|
-
words: number;
|
133
|
-
characters: number;
|
134
|
-
}];
|
135
|
-
};
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
6
|
+
/**
|
7
|
+
* The word count plugin.
|
8
|
+
*
|
9
|
+
* This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.
|
10
|
+
* It also provides an HTML element that updates its state whenever the editor content is changed.
|
11
|
+
*
|
12
|
+
* The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.
|
13
|
+
* The number of words and characters in your text are determined based on the created plain text. Please keep in mind
|
14
|
+
* that every block in the editor is separated with a newline character, which is included in the calculation.
|
15
|
+
*
|
16
|
+
* Here are some examples of how the word and character calculations are made:
|
17
|
+
*
|
18
|
+
* ```html
|
19
|
+
* <paragraph>foo</paragraph>
|
20
|
+
* <paragraph>bar</paragraph>
|
21
|
+
* // Words: 2, Characters: 7
|
22
|
+
*
|
23
|
+
* <paragraph><$text bold="true">foo</$text>bar</paragraph>
|
24
|
+
* // Words: 1, Characters: 6
|
25
|
+
*
|
26
|
+
* <paragraph>*&^%)</paragraph>
|
27
|
+
* // Words: 0, Characters: 5
|
28
|
+
*
|
29
|
+
* <paragraph>foo(bar)</paragraph>
|
30
|
+
* //Words: 1, Characters: 8
|
31
|
+
*
|
32
|
+
* <paragraph>12345</paragraph>
|
33
|
+
* // Words: 1, Characters: 5
|
34
|
+
* ```
|
35
|
+
*/
|
36
|
+
export default class WordCount extends Plugin {
|
37
|
+
/**
|
38
|
+
* The number of characters in the editor.
|
39
|
+
*
|
40
|
+
* @observable
|
41
|
+
* @readonly
|
42
|
+
*/
|
43
|
+
characters: number;
|
44
|
+
/**
|
45
|
+
* The number of words in the editor.
|
46
|
+
*
|
47
|
+
* @observable
|
48
|
+
* @readonly
|
49
|
+
*/
|
50
|
+
words: number;
|
51
|
+
/**
|
52
|
+
* The label used to display the words value in the {@link #wordCountContainer output container}.
|
53
|
+
*
|
54
|
+
* @observable
|
55
|
+
* @private
|
56
|
+
* @readonly
|
57
|
+
*/
|
58
|
+
_wordsLabel: string | undefined;
|
59
|
+
/**
|
60
|
+
* The label used to display the characters value in the {@link #wordCountContainer output container}.
|
61
|
+
*
|
62
|
+
* @observable
|
63
|
+
* @private
|
64
|
+
* @readonly
|
65
|
+
*/
|
66
|
+
_charactersLabel: string | undefined;
|
67
|
+
/**
|
68
|
+
* The configuration of this plugin.
|
69
|
+
*/
|
70
|
+
private _config;
|
71
|
+
/**
|
72
|
+
* The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.
|
73
|
+
*/
|
74
|
+
private _outputView;
|
75
|
+
/**
|
76
|
+
* A regular expression used to recognize words in the editor's content.
|
77
|
+
*/
|
78
|
+
private readonly _wordsMatchRegExp;
|
79
|
+
/**
|
80
|
+
* @inheritDoc
|
81
|
+
*/
|
82
|
+
constructor(editor: Editor);
|
83
|
+
/**
|
84
|
+
* @inheritDoc
|
85
|
+
*/
|
86
|
+
static get pluginName(): "WordCount";
|
87
|
+
/**
|
88
|
+
* @inheritDoc
|
89
|
+
*/
|
90
|
+
init(): void;
|
91
|
+
/**
|
92
|
+
* @inheritDoc
|
93
|
+
*/
|
94
|
+
destroy(): void;
|
95
|
+
/**
|
96
|
+
* Creates a self-updating HTML element. Repeated executions return the same element.
|
97
|
+
* The returned element has the following HTML structure:
|
98
|
+
*
|
99
|
+
* ```html
|
100
|
+
* <div class="ck ck-word-count">
|
101
|
+
* <div class="ck-word-count__words">Words: 4</div>
|
102
|
+
* <div class="ck-word-count__characters">Characters: 28</div>
|
103
|
+
* </div>
|
104
|
+
* ```
|
105
|
+
*/
|
106
|
+
get wordCountContainer(): HTMLElement;
|
107
|
+
private _getText;
|
108
|
+
/**
|
109
|
+
* Determines the number of characters in the current editor's model.
|
110
|
+
*/
|
111
|
+
private _getCharacters;
|
112
|
+
/**
|
113
|
+
* Determines the number of words in the current editor's model.
|
114
|
+
*/
|
115
|
+
private _getWords;
|
116
|
+
/**
|
117
|
+
* Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
|
118
|
+
* It also fires the {@link #event:update}.
|
119
|
+
*
|
120
|
+
* @fires update
|
121
|
+
*/
|
122
|
+
private _refreshStats;
|
123
|
+
}
|
124
|
+
/**
|
125
|
+
* An event fired after {@link ~WordCount#words} and {@link ~WordCount#characters} are updated.
|
126
|
+
*
|
127
|
+
* @eventName ~WordCount#update
|
128
|
+
*/
|
129
|
+
export type WordCountUpdateEvent = {
|
130
|
+
name: 'update';
|
131
|
+
args: [{
|
132
|
+
words: number;
|
133
|
+
characters: number;
|
134
|
+
}];
|
135
|
+
};
|
package/src/wordcount.js
CHANGED
@@ -1,211 +1,211 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, 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 'ckeditor5/src/core';
|
6
|
-
import { Template, View } from 'ckeditor5/src/ui';
|
7
|
-
import { env } from 'ckeditor5/src/utils';
|
8
|
-
import { modelElementToPlainText } from './utils';
|
9
|
-
import { throttle, isElement } from 'lodash-es';
|
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
|
-
* @inheritDoc
|
43
|
-
*/
|
44
|
-
constructor(editor) {
|
45
|
-
super(editor);
|
46
|
-
this.set('characters', 0);
|
47
|
-
this.set('words', 0);
|
48
|
-
// Don't wait for the #update event to set the value of the properties but obtain it right away.
|
49
|
-
// This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.
|
50
|
-
// If not accessed directly, the properties will be refreshed upon #update anyway.
|
51
|
-
Object.defineProperties(this, {
|
52
|
-
characters: {
|
53
|
-
get() {
|
54
|
-
return (this.characters = this._getCharacters(this._getText()));
|
55
|
-
}
|
56
|
-
},
|
57
|
-
words: {
|
58
|
-
get() {
|
59
|
-
return (this.words = this._getWords(this._getText()));
|
60
|
-
}
|
61
|
-
}
|
62
|
-
});
|
63
|
-
this.set('_wordsLabel', undefined);
|
64
|
-
this.set('_charactersLabel', undefined);
|
65
|
-
this._config = editor.config.get('wordCount') || {};
|
66
|
-
this._outputView = undefined;
|
67
|
-
this._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ?
|
68
|
-
// Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).
|
69
|
-
// Groups:
|
70
|
-
// {L} - Any kind of letter from any language.
|
71
|
-
// {N} - Any kind of numeric character in any script.
|
72
|
-
new RegExp('([\\p{L}\\p{N}]+\\S?)+', 'gu') :
|
73
|
-
/([a-zA-Z0-9À-ž]+\S?)+/gu;
|
74
|
-
}
|
75
|
-
/**
|
76
|
-
* @inheritDoc
|
77
|
-
*/
|
78
|
-
static get pluginName() {
|
79
|
-
return 'WordCount';
|
80
|
-
}
|
81
|
-
/**
|
82
|
-
* @inheritDoc
|
83
|
-
*/
|
84
|
-
init() {
|
85
|
-
const editor = this.editor;
|
86
|
-
editor.model.document.on('change:data', throttle(this._refreshStats.bind(this), 250));
|
87
|
-
if (typeof this._config.onUpdate == 'function') {
|
88
|
-
this.on('update', (evt, data) => {
|
89
|
-
this._config.onUpdate(data);
|
90
|
-
});
|
91
|
-
}
|
92
|
-
if (isElement(this._config.container)) {
|
93
|
-
this._config.container.appendChild(this.wordCountContainer);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
/**
|
97
|
-
* @inheritDoc
|
98
|
-
*/
|
99
|
-
destroy() {
|
100
|
-
if (this._outputView) {
|
101
|
-
this._outputView.element.remove();
|
102
|
-
this._outputView.destroy();
|
103
|
-
}
|
104
|
-
super.destroy();
|
105
|
-
}
|
106
|
-
/**
|
107
|
-
* Creates a self-updating HTML element. Repeated executions return the same element.
|
108
|
-
* The returned element has the following HTML structure:
|
109
|
-
*
|
110
|
-
* ```html
|
111
|
-
* <div class="ck ck-word-count">
|
112
|
-
* <div class="ck-word-count__words">Words: 4</div>
|
113
|
-
* <div class="ck-word-count__characters">Characters: 28</div>
|
114
|
-
* </div>
|
115
|
-
* ```
|
116
|
-
*/
|
117
|
-
get wordCountContainer() {
|
118
|
-
const editor = this.editor;
|
119
|
-
const t = editor.t;
|
120
|
-
const displayWords = editor.config.get('wordCount.displayWords');
|
121
|
-
const displayCharacters = editor.config.get('wordCount.displayCharacters');
|
122
|
-
const bind = Template.bind(this, this);
|
123
|
-
const children = [];
|
124
|
-
if (!this._outputView) {
|
125
|
-
this._outputView = new View();
|
126
|
-
if (displayWords || displayWords === undefined) {
|
127
|
-
this.bind('_wordsLabel').to(this, 'words', words => {
|
128
|
-
return t('Words: %0', words);
|
129
|
-
});
|
130
|
-
children.push({
|
131
|
-
tag: 'div',
|
132
|
-
children: [
|
133
|
-
{
|
134
|
-
text: [bind.to('_wordsLabel')]
|
135
|
-
}
|
136
|
-
],
|
137
|
-
attributes: {
|
138
|
-
class: 'ck-word-count__words'
|
139
|
-
}
|
140
|
-
});
|
141
|
-
}
|
142
|
-
if (displayCharacters || displayCharacters === undefined) {
|
143
|
-
this.bind('_charactersLabel').to(this, 'characters', words => {
|
144
|
-
return t('Characters: %0', words);
|
145
|
-
});
|
146
|
-
children.push({
|
147
|
-
tag: 'div',
|
148
|
-
children: [
|
149
|
-
{
|
150
|
-
text: [bind.to('_charactersLabel')]
|
151
|
-
}
|
152
|
-
],
|
153
|
-
attributes: {
|
154
|
-
class: 'ck-word-count__characters'
|
155
|
-
}
|
156
|
-
});
|
157
|
-
}
|
158
|
-
this._outputView.setTemplate({
|
159
|
-
tag: 'div',
|
160
|
-
attributes: {
|
161
|
-
class: [
|
162
|
-
'ck',
|
163
|
-
'ck-word-count'
|
164
|
-
]
|
165
|
-
},
|
166
|
-
children
|
167
|
-
});
|
168
|
-
this._outputView.render();
|
169
|
-
}
|
170
|
-
return this._outputView.element;
|
171
|
-
}
|
172
|
-
_getText() {
|
173
|
-
let txt = '';
|
174
|
-
for (const root of this.editor.model.document.getRoots()) {
|
175
|
-
if (txt !== '') {
|
176
|
-
// Add a delimiter, so words from each root are treated independently.
|
177
|
-
txt += '\n';
|
178
|
-
}
|
179
|
-
txt += modelElementToPlainText(root);
|
180
|
-
}
|
181
|
-
return txt;
|
182
|
-
}
|
183
|
-
/**
|
184
|
-
* Determines the number of characters in the current editor's model.
|
185
|
-
*/
|
186
|
-
_getCharacters(txt) {
|
187
|
-
return txt.replace(/\n/g, '').length;
|
188
|
-
}
|
189
|
-
/**
|
190
|
-
* Determines the number of words in the current editor's model.
|
191
|
-
*/
|
192
|
-
_getWords(txt) {
|
193
|
-
const detectedWords = txt.match(this._wordsMatchRegExp) || [];
|
194
|
-
return detectedWords.length;
|
195
|
-
}
|
196
|
-
/**
|
197
|
-
* Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
|
198
|
-
* It also fires the {@link #event:update}.
|
199
|
-
*
|
200
|
-
* @fires update
|
201
|
-
*/
|
202
|
-
_refreshStats() {
|
203
|
-
const txt = this._getText();
|
204
|
-
const words = this.words = this._getWords(txt);
|
205
|
-
const characters = this.characters = this._getCharacters(txt);
|
206
|
-
this.fire('update', {
|
207
|
-
words,
|
208
|
-
characters
|
209
|
-
});
|
210
|
-
}
|
211
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, 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 'ckeditor5/src/core';
|
6
|
+
import { Template, View } from 'ckeditor5/src/ui';
|
7
|
+
import { env } from 'ckeditor5/src/utils';
|
8
|
+
import { modelElementToPlainText } from './utils';
|
9
|
+
import { throttle, isElement } from 'lodash-es';
|
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
|
+
* @inheritDoc
|
43
|
+
*/
|
44
|
+
constructor(editor) {
|
45
|
+
super(editor);
|
46
|
+
this.set('characters', 0);
|
47
|
+
this.set('words', 0);
|
48
|
+
// Don't wait for the #update event to set the value of the properties but obtain it right away.
|
49
|
+
// This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.
|
50
|
+
// If not accessed directly, the properties will be refreshed upon #update anyway.
|
51
|
+
Object.defineProperties(this, {
|
52
|
+
characters: {
|
53
|
+
get() {
|
54
|
+
return (this.characters = this._getCharacters(this._getText()));
|
55
|
+
}
|
56
|
+
},
|
57
|
+
words: {
|
58
|
+
get() {
|
59
|
+
return (this.words = this._getWords(this._getText()));
|
60
|
+
}
|
61
|
+
}
|
62
|
+
});
|
63
|
+
this.set('_wordsLabel', undefined);
|
64
|
+
this.set('_charactersLabel', undefined);
|
65
|
+
this._config = editor.config.get('wordCount') || {};
|
66
|
+
this._outputView = undefined;
|
67
|
+
this._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ?
|
68
|
+
// Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).
|
69
|
+
// Groups:
|
70
|
+
// {L} - Any kind of letter from any language.
|
71
|
+
// {N} - Any kind of numeric character in any script.
|
72
|
+
new RegExp('([\\p{L}\\p{N}]+\\S?)+', 'gu') :
|
73
|
+
/([a-zA-Z0-9À-ž]+\S?)+/gu;
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* @inheritDoc
|
77
|
+
*/
|
78
|
+
static get pluginName() {
|
79
|
+
return 'WordCount';
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* @inheritDoc
|
83
|
+
*/
|
84
|
+
init() {
|
85
|
+
const editor = this.editor;
|
86
|
+
editor.model.document.on('change:data', throttle(this._refreshStats.bind(this), 250));
|
87
|
+
if (typeof this._config.onUpdate == 'function') {
|
88
|
+
this.on('update', (evt, data) => {
|
89
|
+
this._config.onUpdate(data);
|
90
|
+
});
|
91
|
+
}
|
92
|
+
if (isElement(this._config.container)) {
|
93
|
+
this._config.container.appendChild(this.wordCountContainer);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
/**
|
97
|
+
* @inheritDoc
|
98
|
+
*/
|
99
|
+
destroy() {
|
100
|
+
if (this._outputView) {
|
101
|
+
this._outputView.element.remove();
|
102
|
+
this._outputView.destroy();
|
103
|
+
}
|
104
|
+
super.destroy();
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Creates a self-updating HTML element. Repeated executions return the same element.
|
108
|
+
* The returned element has the following HTML structure:
|
109
|
+
*
|
110
|
+
* ```html
|
111
|
+
* <div class="ck ck-word-count">
|
112
|
+
* <div class="ck-word-count__words">Words: 4</div>
|
113
|
+
* <div class="ck-word-count__characters">Characters: 28</div>
|
114
|
+
* </div>
|
115
|
+
* ```
|
116
|
+
*/
|
117
|
+
get wordCountContainer() {
|
118
|
+
const editor = this.editor;
|
119
|
+
const t = editor.t;
|
120
|
+
const displayWords = editor.config.get('wordCount.displayWords');
|
121
|
+
const displayCharacters = editor.config.get('wordCount.displayCharacters');
|
122
|
+
const bind = Template.bind(this, this);
|
123
|
+
const children = [];
|
124
|
+
if (!this._outputView) {
|
125
|
+
this._outputView = new View();
|
126
|
+
if (displayWords || displayWords === undefined) {
|
127
|
+
this.bind('_wordsLabel').to(this, 'words', words => {
|
128
|
+
return t('Words: %0', words);
|
129
|
+
});
|
130
|
+
children.push({
|
131
|
+
tag: 'div',
|
132
|
+
children: [
|
133
|
+
{
|
134
|
+
text: [bind.to('_wordsLabel')]
|
135
|
+
}
|
136
|
+
],
|
137
|
+
attributes: {
|
138
|
+
class: 'ck-word-count__words'
|
139
|
+
}
|
140
|
+
});
|
141
|
+
}
|
142
|
+
if (displayCharacters || displayCharacters === undefined) {
|
143
|
+
this.bind('_charactersLabel').to(this, 'characters', words => {
|
144
|
+
return t('Characters: %0', words);
|
145
|
+
});
|
146
|
+
children.push({
|
147
|
+
tag: 'div',
|
148
|
+
children: [
|
149
|
+
{
|
150
|
+
text: [bind.to('_charactersLabel')]
|
151
|
+
}
|
152
|
+
],
|
153
|
+
attributes: {
|
154
|
+
class: 'ck-word-count__characters'
|
155
|
+
}
|
156
|
+
});
|
157
|
+
}
|
158
|
+
this._outputView.setTemplate({
|
159
|
+
tag: 'div',
|
160
|
+
attributes: {
|
161
|
+
class: [
|
162
|
+
'ck',
|
163
|
+
'ck-word-count'
|
164
|
+
]
|
165
|
+
},
|
166
|
+
children
|
167
|
+
});
|
168
|
+
this._outputView.render();
|
169
|
+
}
|
170
|
+
return this._outputView.element;
|
171
|
+
}
|
172
|
+
_getText() {
|
173
|
+
let txt = '';
|
174
|
+
for (const root of this.editor.model.document.getRoots()) {
|
175
|
+
if (txt !== '') {
|
176
|
+
// Add a delimiter, so words from each root are treated independently.
|
177
|
+
txt += '\n';
|
178
|
+
}
|
179
|
+
txt += modelElementToPlainText(root);
|
180
|
+
}
|
181
|
+
return txt;
|
182
|
+
}
|
183
|
+
/**
|
184
|
+
* Determines the number of characters in the current editor's model.
|
185
|
+
*/
|
186
|
+
_getCharacters(txt) {
|
187
|
+
return txt.replace(/\n/g, '').length;
|
188
|
+
}
|
189
|
+
/**
|
190
|
+
* Determines the number of words in the current editor's model.
|
191
|
+
*/
|
192
|
+
_getWords(txt) {
|
193
|
+
const detectedWords = txt.match(this._wordsMatchRegExp) || [];
|
194
|
+
return detectedWords.length;
|
195
|
+
}
|
196
|
+
/**
|
197
|
+
* Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.
|
198
|
+
* It also fires the {@link #event:update}.
|
199
|
+
*
|
200
|
+
* @fires update
|
201
|
+
*/
|
202
|
+
_refreshStats() {
|
203
|
+
const txt = this._getText();
|
204
|
+
const words = this.words = this._getWords(txt);
|
205
|
+
const characters = this.characters = this._getCharacters(txt);
|
206
|
+
this.fire('update', {
|
207
|
+
words,
|
208
|
+
characters
|
209
|
+
});
|
210
|
+
}
|
211
|
+
}
|
package/src/wordcountconfig.d.ts
CHANGED
@@ -1,92 +1,92 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module word-count/wordcountconfig
|
7
|
-
*/
|
8
|
-
/**
|
9
|
-
* The configuration of the word count feature.
|
10
|
-
*
|
11
|
-
* ```ts
|
12
|
-
* ClassicEditor
|
13
|
-
* .create( {
|
14
|
-
* wordCount: ... // Word count feature configuration.
|
15
|
-
* } )
|
16
|
-
* .then( ... )
|
17
|
-
* .catch( ... );
|
18
|
-
* ```
|
19
|
-
*
|
20
|
-
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
21
|
-
*/
|
22
|
-
export interface WordCountConfig {
|
23
|
-
/**
|
24
|
-
* This option allows for hiding the word counter. The element obtained through
|
25
|
-
* {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
|
26
|
-
* the characters part. Word counter is displayed by default when this configuration option is not defined.
|
27
|
-
*
|
28
|
-
* ```ts
|
29
|
-
* const wordCountConfig = {
|
30
|
-
* displayWords: false
|
31
|
-
* };
|
32
|
-
* ```
|
33
|
-
*
|
34
|
-
* The configuration above will result in the following container:
|
35
|
-
*
|
36
|
-
* ```html
|
37
|
-
* <div class="ck ck-word-count">
|
38
|
-
* <div class="ck-word-count__characters">Characters: 28</div>
|
39
|
-
* </div>
|
40
|
-
* ```
|
41
|
-
*/
|
42
|
-
displayWords?: boolean;
|
43
|
-
/**
|
44
|
-
* This option allows for hiding the character counter. The element obtained through
|
45
|
-
* {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
|
46
|
-
* the words part. Character counter is displayed by default when this configuration option is not defined.
|
47
|
-
*
|
48
|
-
* ```ts
|
49
|
-
* const wordCountConfig = {
|
50
|
-
* displayCharacters: false
|
51
|
-
* };
|
52
|
-
* ```
|
53
|
-
*
|
54
|
-
* The configuration above will result in the following container:
|
55
|
-
*
|
56
|
-
* ```html
|
57
|
-
* <div class="ck ck-word-count">
|
58
|
-
* <div class="ck-word-count__words">Words: 4</div>
|
59
|
-
* </div>
|
60
|
-
* ```
|
61
|
-
*/
|
62
|
-
displayCharacters?: boolean;
|
63
|
-
/**
|
64
|
-
* This configuration takes a function that is executed whenever the word count plugin updates its values.
|
65
|
-
* This function is called with one argument, which is an object with the `words` and `characters` keys containing
|
66
|
-
* the number of detected words and characters in the document.
|
67
|
-
*
|
68
|
-
* ```ts
|
69
|
-
* const wordCountConfig = {
|
70
|
-
* onUpdate: function( stats ) {
|
71
|
-
* doSthWithWordNumber( stats.words );
|
72
|
-
* doSthWithCharacterNumber( stats.characters );
|
73
|
-
* }
|
74
|
-
* };
|
75
|
-
* ```
|
76
|
-
*/
|
77
|
-
onUpdate?: (data: {
|
78
|
-
words: number;
|
79
|
-
characters: number;
|
80
|
-
}) => void;
|
81
|
-
/**
|
82
|
-
* Allows for providing the HTML element that the
|
83
|
-
* {@link module:word-count/wordcount~WordCount#wordCountContainer word count container} will be appended to automatically.
|
84
|
-
*
|
85
|
-
* ```ts
|
86
|
-
* const wordCountConfig = {
|
87
|
-
* container: document.getElementById( 'container-for-word-count' );
|
88
|
-
* };
|
89
|
-
* ```
|
90
|
-
*/
|
91
|
-
container?: HTMLElement;
|
92
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module word-count/wordcountconfig
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* The configuration of the word count feature.
|
10
|
+
*
|
11
|
+
* ```ts
|
12
|
+
* ClassicEditor
|
13
|
+
* .create( {
|
14
|
+
* wordCount: ... // Word count feature configuration.
|
15
|
+
* } )
|
16
|
+
* .then( ... )
|
17
|
+
* .catch( ... );
|
18
|
+
* ```
|
19
|
+
*
|
20
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
21
|
+
*/
|
22
|
+
export interface WordCountConfig {
|
23
|
+
/**
|
24
|
+
* This option allows for hiding the word counter. The element obtained through
|
25
|
+
* {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
|
26
|
+
* the characters part. Word counter is displayed by default when this configuration option is not defined.
|
27
|
+
*
|
28
|
+
* ```ts
|
29
|
+
* const wordCountConfig = {
|
30
|
+
* displayWords: false
|
31
|
+
* };
|
32
|
+
* ```
|
33
|
+
*
|
34
|
+
* The configuration above will result in the following container:
|
35
|
+
*
|
36
|
+
* ```html
|
37
|
+
* <div class="ck ck-word-count">
|
38
|
+
* <div class="ck-word-count__characters">Characters: 28</div>
|
39
|
+
* </div>
|
40
|
+
* ```
|
41
|
+
*/
|
42
|
+
displayWords?: boolean;
|
43
|
+
/**
|
44
|
+
* This option allows for hiding the character counter. The element obtained through
|
45
|
+
* {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve
|
46
|
+
* the words part. Character counter is displayed by default when this configuration option is not defined.
|
47
|
+
*
|
48
|
+
* ```ts
|
49
|
+
* const wordCountConfig = {
|
50
|
+
* displayCharacters: false
|
51
|
+
* };
|
52
|
+
* ```
|
53
|
+
*
|
54
|
+
* The configuration above will result in the following container:
|
55
|
+
*
|
56
|
+
* ```html
|
57
|
+
* <div class="ck ck-word-count">
|
58
|
+
* <div class="ck-word-count__words">Words: 4</div>
|
59
|
+
* </div>
|
60
|
+
* ```
|
61
|
+
*/
|
62
|
+
displayCharacters?: boolean;
|
63
|
+
/**
|
64
|
+
* This configuration takes a function that is executed whenever the word count plugin updates its values.
|
65
|
+
* This function is called with one argument, which is an object with the `words` and `characters` keys containing
|
66
|
+
* the number of detected words and characters in the document.
|
67
|
+
*
|
68
|
+
* ```ts
|
69
|
+
* const wordCountConfig = {
|
70
|
+
* onUpdate: function( stats ) {
|
71
|
+
* doSthWithWordNumber( stats.words );
|
72
|
+
* doSthWithCharacterNumber( stats.characters );
|
73
|
+
* }
|
74
|
+
* };
|
75
|
+
* ```
|
76
|
+
*/
|
77
|
+
onUpdate?: (data: {
|
78
|
+
words: number;
|
79
|
+
characters: number;
|
80
|
+
}) => void;
|
81
|
+
/**
|
82
|
+
* Allows for providing the HTML element that the
|
83
|
+
* {@link module:word-count/wordcount~WordCount#wordCountContainer word count container} will be appended to automatically.
|
84
|
+
*
|
85
|
+
* ```ts
|
86
|
+
* const wordCountConfig = {
|
87
|
+
* container: document.getElementById( 'container-for-word-count' );
|
88
|
+
* };
|
89
|
+
* ```
|
90
|
+
*/
|
91
|
+
container?: HTMLElement;
|
92
|
+
}
|
package/src/wordcountconfig.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, 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 {};
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, 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 {};
|
package/build/word-count.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["webpack://CKEditor5.wordCount/./src/utils.js","webpack://CKEditor5.wordCount/./src/wordcount.js","webpack://CKEditor5.wordCount/delegated \"./src/core.js\" from dll-reference CKEditor5.dll","webpack://CKEditor5.wordCount/delegated \"./src/ui.js\" from dll-reference CKEditor5.dll","webpack://CKEditor5.wordCount/delegated \"./src/utils.js\" from dll-reference CKEditor5.dll","webpack://CKEditor5.wordCount/external var \"CKEditor5.dll\"","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_Symbol.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_baseGetTag.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_baseTrim.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_freeGlobal.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_getPrototype.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_getRawTag.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_objectToString.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_overArg.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_root.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/_trimmedEndIndex.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/debounce.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/isElement.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/isObject.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/isObjectLike.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/isPlainObject.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/isSymbol.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/now.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/throttle.js","webpack://CKEditor5.wordCount/javascript/node_modules/lodash-es/toNumber.js","webpack://CKEditor5.wordCount/webpack/bootstrap","webpack://CKEditor5.wordCount/webpack/runtime/define property getters","webpack://CKEditor5.wordCount/webpack/runtime/hasOwnProperty shorthand","webpack://CKEditor5.wordCount/webpack/runtime/make namespace object","webpack://CKEditor5.wordCount/./src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,qCAAqC;AAChD,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;ACrCA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAE4C;AACM;AACR;AACM;AACE;;AAElD;AACA;AACA;AACA,2DAA2D,gDAAgD;AAC3G;AACA;AACA,4DAA4D,sDAAsD;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,wBAAwB,sDAAM;AAC7C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,IAAI;;AAEJ;AACA,uDAAuD,2CAA2C;AAClG;AACA;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;;AAEA;AACA,4DAA4D,2CAA2C;AACvG;AACA;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA,yBAAyB,uCAAuC;AAChE;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA,2BAA2B,8FAA6C;AACxE;AACA;AACA,OAAO,GAAG;AACV,OAAO,GAAG;AACV,sBAAsB,EAAE,IAAI,EAAE;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,2CAA2C,qDAAQ;;AAEnD;AACA;AACA;AACA,KAAK;AACL;;AAEA,OAAO,qDAAS;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,2DAAa;AAC5B;;AAEA;AACA,0BAA0B,kDAAI;;AAE9B;AACA;AACA;AACA,MAAM;;AAEN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;;AAEA;AACA;AACA;AACA,MAAM;;AAEN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA,cAAc,+DAAuB;;AAErC;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA,cAAc,+DAAuB;AACrC;;AAEA;AACA;;AAEA;AACA,mGAAmG,mBAAmB,KAAK,aAAa;AACxI,uBAAuB,oBAAoB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA,yBAAyB,cAAc,KAAK,mBAAmB;AAC/D;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,QAAQ,sEAAsE;AAC9E;AACA;AACA;;AAEA;AACA;AACA,4BAA4B,6CAA6C;AACzE;AACA,iBAAiB,kDAAkD;AACnE;AACA,YAAY,6CAA6C;AACzD;;AAEA;AACA;AACA,IAAI,gEAAgE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;;AAEA;AACA;AACA,IAAI,gEAAgE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,UAAU;AACtB;;AAEA;AACA;AACA,IAAI,qFAAqF;AACzF;AACA;AACA;AACA;AACA;AACA,YAAY,aAAa;AACzB;;;;;;;;;;;ACpYA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;;;;;;ACA8B;;AAE9B;AACA,aAAa,uDAAW;;AAExB,iEAAe,MAAM,EAAC;;;;;;;;;;;;;;;;;;;ACLY;AACM;AACU;;AAElD;AACA;AACA;;AAEA;AACA,qBAAqB,kDAAM,GAAG,8DAAkB;;AAEhD;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,yDAAS;AACf,MAAM,8DAAc;AACpB;;AAEA,iEAAe,UAAU,EAAC;;;;;;;;;;;;;;;;;AC3B0B;;AAEpD;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,aAAa,QAAQ;AACrB;AACA;AACA;AACA,sBAAsB,+DAAe;AACrC;AACA;;AAEA,iEAAe,QAAQ,EAAC;;;;;;;;;;;;;;;;AClBxB;AACA;;AAEA,iEAAe,UAAU,EAAC;;;;;;;;;;;;;;;;;ACHU;;AAEpC;AACA,mBAAmB,uDAAO;;AAE1B,iEAAe,YAAY,EAAC;;;;;;;;;;;;;;;;;ACLM;;AAElC;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qBAAqB,kDAAM,GAAG,8DAAkB;;AAEhD;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;;AAEJ;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA,iEAAe,SAAS,EAAC;;;;;;;;;;;;;;;;AC7CzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA,iEAAe,cAAc,EAAC;;;;;;;;;;;;;;;;ACrB9B;AACA;AACA;AACA;AACA,WAAW,UAAU;AACrB,WAAW,UAAU;AACrB,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,OAAO,EAAC;;;;;;;;;;;;;;;;;ACdmB;;AAE1C;AACA;;AAEA;AACA,WAAW,sDAAU;;AAErB,iEAAe,IAAI,EAAC;;;;;;;;;;;;;;;;ACRpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iEAAe,eAAe,EAAC;;;;;;;;;;;;;;;;;;;AClBM;AACV;AACU;;AAErC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,UAAU;AACrB,WAAW,QAAQ;AACnB,WAAW,QAAQ,WAAW;AAC9B,WAAW,SAAS;AACpB;AACA,WAAW,QAAQ;AACnB;AACA,WAAW,SAAS;AACpB;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,+CAA+C,iBAAiB;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS,wDAAQ;AACjB,MAAM,wDAAQ;AACd;AACA;AACA,iCAAiC,wDAAQ;AACzC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,mDAAG;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yDAAyD,mDAAG;AAC5D;;AAEA;AACA,eAAe,mDAAG;AAClB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,QAAQ,EAAC;;;;;;;;;;;;;;;;;;AC9LqB;AACE;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4DAAY,oCAAoC,6DAAa;AACtE;;AAEA,iEAAe,SAAS,EAAC;;;;;;;;;;;;;;;;ACxBzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,SAAS;AACtB;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,QAAQ,EAAC;;;;;;;;;;;;;;;;AC9BxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,SAAS;AACtB;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,YAAY,EAAC;;;;;;;;;;;;;;;;;;;AC5Bc;AACI;AACD;;AAE7C;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,gBAAgB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,4DAAY,WAAW,0DAAU;AACxC;AACA;AACA,cAAc,4DAAY;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,aAAa,EAAC;;;;;;;;;;;;;;;;;;AC7Da;AACG;;AAE7C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,4DAAY,WAAW,0DAAU;AACtC;;AAEA,iEAAe,QAAQ,EAAC;;;;;;;;;;;;;;;;;AC5BM;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,SAAS,yDAAa;AACtB;;AAEA,iEAAe,GAAG,EAAC;;;;;;;;;;;;;;;;;;ACtBkB;AACA;;AAErC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,UAAU;AACrB,WAAW,QAAQ;AACnB,WAAW,QAAQ,WAAW;AAC9B,WAAW,SAAS;AACpB;AACA,WAAW,SAAS;AACpB;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,mBAAmB;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM,wDAAQ;AACd;AACA;AACA;AACA,SAAS,wDAAQ;AACjB;AACA;AACA;AACA,GAAG;AACH;;AAEA,iEAAe,QAAQ,EAAC;;;;;;;;;;;;;;;;;;;ACpEc;AACD;AACA;;AAErC;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,GAAG;AACd,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,wDAAQ;AACd;AACA;AACA,MAAM,wDAAQ;AACd;AACA,YAAY,wDAAQ;AACpB;AACA;AACA;AACA;AACA,UAAU,wDAAQ;AAClB;AACA;AACA;AACA;AACA;;AAEA,iEAAe,QAAQ,EAAC;;;;;;;UC/DxB;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;ACNA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEmD","file":"word-count.js","sourcesContent":["/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module word-count/utils\n */\n\n/**\n * Returns a plain text representation of an element and its children.\n *\n * @param {module:engine/model/element~Element} element\n * @returns {String} Plain text representing the model's data.\n */\nexport function modelElementToPlainText( element ) {\n\tif ( element.is( '$text' ) || element.is( '$textProxy' ) ) {\n\t\treturn element.data;\n\t}\n\n\tlet text = '';\n\tlet prev = null;\n\n\tfor ( const child of element.getChildren() ) {\n\t\tconst childText = modelElementToPlainText( child );\n\n\t\t// If last block was finish, start from new line.\n\t\tif ( prev && prev.is( 'element' ) ) {\n\t\t\ttext += '\\n';\n\t\t}\n\n\t\ttext += childText;\n\n\t\tprev = child;\n\t}\n\n\treturn text;\n}\n","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module word-count/wordcount\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\nimport { View, Template } from 'ckeditor5/src/ui';\nimport { env } from 'ckeditor5/src/utils';\nimport { throttle, isElement } from 'lodash-es';\nimport { modelElementToPlainText } from './utils';\n\n/**\n * The word count plugin.\n *\n * This plugin calculates all words and characters in all {@link module:engine/model/text~Text text nodes} available in the model.\n * It also provides an HTML element that updates its state whenever the editor content is changed.\n *\n * The model's data is first converted to plain text using {@link module:word-count/utils~modelElementToPlainText}.\n * The number of words and characters in your text are determined based on the created plain text. Please keep in mind\n * that every block in the editor is separated with a newline character, which is included in the calculation.\n *\n * Here are some examples of how the word and character calculations are made:\n *\n * \t\t<paragraph>foo</paragraph>\n * \t\t<paragraph>bar</paragraph>\n * \t\t// Words: 2, Characters: 7\n *\n * \t\t<paragraph><$text bold=\"true\">foo</$text>bar</paragraph>\n * \t\t// Words: 1, Characters: 6\n *\n * \t\t<paragraph>*&^%)</paragraph>\n * \t\t// Words: 0, Characters: 5\n *\n * \t\t<paragraph>foo(bar)</paragraph>\n * \t\t//Words: 1, Characters: 8\n *\n * \t\t<paragraph>12345</paragraph>\n * \t\t// Words: 1, Characters: 5\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class WordCount extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor ) {\n\t\tsuper( editor );\n\n\t\t/**\n\t\t * The number of characters in the editor.\n\t\t *\n\t\t * @observable\n\t\t * @readonly\n\t\t * @member {Number} module:word-count/wordcount~WordCount#characters\n\t\t */\n\t\tthis.set( 'characters', 0 );\n\n\t\t/**\n\t\t * The number of words in the editor.\n\t\t *\n\t\t * @observable\n\t\t * @readonly\n\t\t * @member {Number} module:word-count/wordcount~WordCount#words\n\t\t */\n\t\tthis.set( 'words', 0 );\n\n\t\t// Don't wait for the #update event to set the value of the properties but obtain it right away.\n\t\t// This way, accessing the properties directly returns precise numbers, e.g. for validation, etc.\n\t\t// If not accessed directly, the properties will be refreshed upon #update anyway.\n\t\tObject.defineProperties( this, {\n\t\t\tcharacters: {\n\t\t\t\tget() {\n\t\t\t\t\treturn ( this.characters = this._getCharacters() );\n\t\t\t\t}\n\t\t\t},\n\t\t\twords: {\n\t\t\t\tget() {\n\t\t\t\t\treturn ( this.words = this._getWords() );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\n\t\t/**\n\t\t * The label used to display the words value in the {@link #wordCountContainer output container}.\n\t\t *\n\t\t * @observable\n\t\t * @private\n\t\t * @readonly\n\t\t * @member {String} module:word-count/wordcount~WordCount#_wordsLabel\n\t\t */\n\t\tthis.set( '_wordsLabel' );\n\n\t\t/**\n\t\t * The label used to display the characters value in the {@link #wordCountContainer output container}.\n\t\t *\n\t\t * @observable\n\t\t * @private\n\t\t * @readonly\n\t\t * @member {String} module:word-count/wordcount~WordCount#_charactersLabel\n\t\t */\n\t\tthis.set( '_charactersLabel' );\n\n\t\t/**\n\t\t * The configuration of this plugin.\n\t\t *\n\t\t * @private\n\t\t * @type {Object}\n\t\t */\n\t\tthis._config = editor.config.get( 'wordCount' ) || {};\n\n\t\t/**\n\t\t * The reference to a {@link module:ui/view~View view object} that contains the self-updating HTML container.\n\t\t *\n\t\t * @private\n\t\t * @readonly\n\t\t * @type {module:ui/view~View}\n\t\t */\n\t\tthis._outputView = undefined;\n\n\t\t/**\n\t\t * A regular expression used to recognize words in the editor's content.\n\t\t *\n\t\t * @readonly\n\t\t * @private\n\t\t * @type {RegExp}\n\t\t */\n\t\tthis._wordsMatchRegExp = env.features.isRegExpUnicodePropertySupported ?\n\t\t\t// Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).\n\t\t\t// Groups:\n\t\t\t// {L} - Any kind of letter from any language.\n\t\t\t// {N} - Any kind of numeric character in any script.\n\t\t\tnew RegExp( '([\\\\p{L}\\\\p{N}]+\\\\S?)+', 'gu' ) :\n\t\t\t/([a-zA-Z0-9À-ž]+\\S?)+/gu;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'WordCount';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tinit() {\n\t\tconst editor = this.editor;\n\n\t\teditor.model.document.on( 'change:data', throttle( this._refreshStats.bind( this ), 250 ) );\n\n\t\tif ( typeof this._config.onUpdate == 'function' ) {\n\t\t\tthis.on( 'update', ( evt, data ) => {\n\t\t\t\tthis._config.onUpdate( data );\n\t\t\t} );\n\t\t}\n\n\t\tif ( isElement( this._config.container ) ) {\n\t\t\tthis._config.container.appendChild( this.wordCountContainer );\n\t\t}\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tdestroy() {\n\t\tif ( this._outputView ) {\n\t\t\tthis._outputView.element.remove();\n\t\t\tthis._outputView.destroy();\n\t\t}\n\n\t\tsuper.destroy();\n\t}\n\n\t/**\n\t * Creates a self-updating HTML element. Repeated executions return the same element.\n\t * The returned element has the following HTML structure:\n\t *\n\t * \t\t<div class=\"ck ck-word-count\">\n\t * \t\t\t<div class=\"ck-word-count__words\">Words: 4</div>\n\t * \t\t\t<div class=\"ck-word-count__characters\">Characters: 28</div>\n\t * \t\t</div>\n\t *\n\t * @type {HTMLElement}\n\t */\n\tget wordCountContainer() {\n\t\tconst editor = this.editor;\n\t\tconst t = editor.t;\n\t\tconst displayWords = editor.config.get( 'wordCount.displayWords' );\n\t\tconst displayCharacters = editor.config.get( 'wordCount.displayCharacters' );\n\t\tconst bind = Template.bind( this, this );\n\t\tconst children = [];\n\n\t\tif ( !this._outputView ) {\n\t\t\tthis._outputView = new View();\n\n\t\t\tif ( displayWords || displayWords === undefined ) {\n\t\t\t\tthis.bind( '_wordsLabel' ).to( this, 'words', words => {\n\t\t\t\t\treturn t( 'Words: %0', words );\n\t\t\t\t} );\n\n\t\t\t\tchildren.push( {\n\t\t\t\t\ttag: 'div',\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: [ bind.to( '_wordsLabel' ) ]\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tclass: 'ck-word-count__words'\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( displayCharacters || displayCharacters === undefined ) {\n\t\t\t\tthis.bind( '_charactersLabel' ).to( this, 'characters', words => {\n\t\t\t\t\treturn t( 'Characters: %0', words );\n\t\t\t\t} );\n\n\t\t\t\tchildren.push( {\n\t\t\t\t\ttag: 'div',\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: [ bind.to( '_charactersLabel' ) ]\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tclass: 'ck-word-count__characters'\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tthis._outputView.setTemplate( {\n\t\t\t\ttag: 'div',\n\t\t\t\tattributes: {\n\t\t\t\t\tclass: [\n\t\t\t\t\t\t'ck',\n\t\t\t\t\t\t'ck-word-count'\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\tchildren\n\t\t\t} );\n\n\t\t\tthis._outputView.render();\n\t\t}\n\n\t\treturn this._outputView.element;\n\t}\n\n\t/**\n\t * Determines the number of characters in the current editor's model.\n\t *\n\t * @private\n\t * @returns {Number}\n\t */\n\t_getCharacters() {\n\t\tconst txt = modelElementToPlainText( this.editor.model.document.getRoot() );\n\n\t\treturn txt.replace( /\\n/g, '' ).length;\n\t}\n\n\t/**\n\t * Determines the number of words in the current editor's model.\n\t *\n\t * @private\n\t * @returns {Number}\n\t */\n\t_getWords() {\n\t\tconst txt = modelElementToPlainText( this.editor.model.document.getRoot() );\n\t\tconst detectedWords = txt.match( this._wordsMatchRegExp ) || [];\n\n\t\treturn detectedWords.length;\n\t}\n\n\t/**\n\t * Determines the number of words and characters in the current editor's model and assigns it to {@link #characters} and {@link #words}.\n\t * It also fires the {@link #event:update}.\n\t *\n\t * @private\n\t * @fires update\n\t */\n\t_refreshStats() {\n\t\tconst words = this.words = this._getWords();\n\t\tconst characters = this.characters = this._getCharacters();\n\n\t\tthis.fire( 'update', {\n\t\t\twords,\n\t\t\tcharacters\n\t\t} );\n\t}\n}\n\n/**\n * An event fired after {@link #words} and {@link #characters} are updated.\n *\n * @event update\n * @param {Object} data\n * @param {Number} data.words The number of words in the current model.\n * @param {Number} data.characters The number of characters in the current model.\n */\n\n/**\n * The configuration of the word count feature.\n *\n *\t\tClassicEditor\n *\t\t\t.create( {\n *\t\t\t\twordCount: ... // Word count feature configuration.\n *\t\t\t} )\n *\t\t\t.then( ... )\n *\t\t\t.catch( ... );\n *\n * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.\n *\n * @interface module:word-count/wordcount~WordCountConfig\n */\n\n/**\n * The configuration of the word count feature.\n * It is introduced by the {@link module:word-count/wordcount~WordCount} feature.\n *\n * Read more in {@link module:word-count/wordcount~WordCountConfig}.\n *\n * @member {module:word-count/wordcount~WordCountConfig} module:core/editor/editorconfig~EditorConfig#wordCount\n */\n\n/**\n * This option allows for hiding the word counter. The element obtained through\n * {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve\n * the characters part. Word counter is displayed by default when this configuration option is not defined.\n *\n *\t\tconst wordCountConfig = {\n *\t\t\tdisplayWords: false\n *\t\t};\n *\n * The configuration above will result in the following container:\n *\n *\t\t<div class=\"ck ck-word-count\">\n *\t\t\t<div class=\"ck-word-count__characters\">Characters: 28</div>\n *\t\t</div>\n *\n * @member {Boolean} module:word-count/wordcount~WordCountConfig#displayWords\n */\n\n/**\n * This option allows for hiding the character counter. The element obtained through\n * {@link module:word-count/wordcount~WordCount#wordCountContainer} will only preserve\n * the words part. Character counter is displayed by default when this configuration option is not defined.\n *\n *\t\tconst wordCountConfig = {\n *\t\t\tdisplayCharacters: false\n *\t\t};\n *\n * The configuration above will result in the following container:\n *\n *\t\t<div class=\"ck ck-word-count\">\n *\t\t\t<div class=\"ck-word-count__words\">Words: 4</div>\n *\t\t</div>\n *\n * @member {Boolean} module:word-count/wordcount~WordCountConfig#displayCharacters\n */\n\n/**\n * This configuration takes a function that is executed whenever the word count plugin updates its values.\n * This function is called with one argument, which is an object with the `words` and `characters` keys containing\n * the number of detected words and characters in the document.\n *\n *\t\tconst wordCountConfig = {\n *\t\t\tonUpdate: function( stats ) {\n *\t\t\t\tdoSthWithWordNumber( stats.words );\n *\t\t\t\tdoSthWithCharacterNumber( stats.characters );\n *\t\t\t}\n *\t\t};\n *\n * @member {Function} module:word-count/wordcount~WordCountConfig#onUpdate\n */\n\n/**\n * Allows for providing the HTML element that the\n * {@link module:word-count/wordcount~WordCount#wordCountContainer word count container} will be appended to automatically.\n *\n *\t\tconst wordCountConfig = {\n *\t\t\tcontainer: document.getElementById( 'container-for-word-count' );\n *\t\t};\n *\n * @member {HTMLElement} module:word-count/wordcount~WordCountConfig#container\n */\n","module.exports = (__webpack_require__(/*! dll-reference CKEditor5.dll */ \"dll-reference CKEditor5.dll\"))(\"./src/core.js\");","module.exports = (__webpack_require__(/*! dll-reference CKEditor5.dll */ \"dll-reference CKEditor5.dll\"))(\"./src/ui.js\");","module.exports = (__webpack_require__(/*! dll-reference CKEditor5.dll */ \"dll-reference CKEditor5.dll\"))(\"./src/utils.js\");","module.exports = CKEditor5.dll;","import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n","import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nexport default baseGetTag;\n","import trimmedEndIndex from './_trimmedEndIndex.js';\n\n/** Used to match leading whitespace. */\nvar reTrimStart = /^\\s+/;\n\n/**\n * The base implementation of `_.trim`.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} Returns the trimmed string.\n */\nfunction baseTrim(string) {\n return string\n ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')\n : string;\n}\n\nexport default baseTrim;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n","import overArg from './_overArg.js';\n\n/** Built-in value references. */\nvar getPrototype = overArg(Object.getPrototypeOf, Object);\n\nexport default getPrototype;\n","import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nexport default getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n","/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nexport default overArg;\n","import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n","/** Used to match a single whitespace character. */\nvar reWhitespace = /\\s/;\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\nfunction trimmedEndIndex(string) {\n var index = string.length;\n\n while (index-- && reWhitespace.test(string.charAt(index))) {}\n return index;\n}\n\nexport default trimmedEndIndex;\n","import isObject from './isObject.js';\nimport now from './now.js';\nimport toNumber from './toNumber.js';\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\nexport default debounce;\n","import isObjectLike from './isObjectLike.js';\nimport isPlainObject from './isPlainObject.js';\n\n/**\n * Checks if `value` is likely a DOM element.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.\n * @example\n *\n * _.isElement(document.body);\n * // => true\n *\n * _.isElement('<body>');\n * // => false\n */\nfunction isElement(value) {\n return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);\n}\n\nexport default isElement;\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n","import baseGetTag from './_baseGetTag.js';\nimport getPrototype from './_getPrototype.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to infer the `Object` constructor. */\nvar objectCtorString = funcToString.call(Object);\n\n/**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n}\n\nexport default isPlainObject;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nexport default isSymbol;\n","import root from './_root.js';\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\nexport default now;\n","import debounce from './debounce.js';\nimport isObject from './isObject.js';\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\nfunction throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n 'leading': leading,\n 'maxWait': wait,\n 'trailing': trailing\n });\n}\n\nexport default throttle;\n","import baseTrim from './_baseTrim.js';\nimport isObject from './isObject.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = baseTrim(value);\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nexport default toNumber;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module word-count\n */\n\nexport { default as WordCount } from './wordcount';\n"],"sourceRoot":""}
|