@ckeditor/ckeditor5-word-count 38.2.0-alpha.1 → 39.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -1
- package/build/translations/sq.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/word-count.js +1 -1
- package/lang/translations/sq.po +25 -0
- package/lang/translations/ug.po +25 -0
- package/package.json +3 -4
- package/src/augmentation.d.ts +1 -1
- package/src/index.d.ts +3 -3
- package/src/index.js +2 -2
- package/src/utils.d.ts +1 -1
- package/src/wordcount.d.ts +1 -1
- package/src/wordcount.js +6 -6
package/README.md
CHANGED
@@ -4,7 +4,6 @@ CKEditor 5 word and character count feature
|
|
4
4
|
[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-word-count.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-word-count)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
6
6
|
[![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
7
|
-
![Dependency Status](https://img.shields.io/librariesio/release/npm/@ckeditor/ckeditor5-word-count)
|
8
7
|
|
9
8
|
This package implements word count and character count support for CKEditor 5.
|
10
9
|
|
@@ -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.ug=i.ug||{};n.dictionary=Object.assign(n.dictionary||{},{"Characters: %0":"ھەرپ: %0","Words: %0":"سۆز: %0"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
package/build/word-count.js
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
/*!
|
3
3
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
4
4
|
* For licensing, see LICENSE.md.
|
5
|
-
*/(()=>{var t={704:(t,e,r)=>{t.exports=r(79)("./src/core.js")},273:(t,e,r)=>{t.exports=r(79)("./src/ui.js")},209:(t,e,r)=>{t.exports=r(79)("./src/utils.js")},79: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(704),e=r(273),n=r(209);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,
|
5
|
+
*/(()=>{var t={704:(t,e,r)=>{t.exports=r(79)("./src/core.js")},273:(t,e,r)=>{t.exports=r(79)("./src/ui.js")},209:(t,e,r)=>{t.exports=r(79)("./src/utils.js")},79: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(704),e=r(273),n=r(209);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,W=/^0o[0-7]+$/i,N=parseInt;const P=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||W.test(t)?N(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=P(e)||0,s(r)&&(f=!!r.leading,i=(h="maxWait"in r)?V(P(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"}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,25 @@
|
|
1
|
+
# Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
2
|
+
#
|
3
|
+
# !!! IMPORTANT !!!
|
4
|
+
#
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
7
|
+
#
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
9
|
+
#
|
10
|
+
# To learn more, check out the official contributor's guide:
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
12
|
+
#
|
13
|
+
msgid ""
|
14
|
+
msgstr ""
|
15
|
+
"Language-Team: Albanian (https://app.transifex.com/ckeditor/teams/11143/sq/)\n"
|
16
|
+
"Language: sq\n"
|
17
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
18
|
+
|
19
|
+
msgctxt "Label showing the number of words in the editor content."
|
20
|
+
msgid "Words: %0"
|
21
|
+
msgstr "Fjalë: %0"
|
22
|
+
|
23
|
+
msgctxt "Label showing the number of characters in the editor content."
|
24
|
+
msgid "Characters: %0"
|
25
|
+
msgstr "Karaktere: %0"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
2
|
+
#
|
3
|
+
# !!! IMPORTANT !!!
|
4
|
+
#
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
7
|
+
#
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
9
|
+
#
|
10
|
+
# To learn more, check out the official contributor's guide:
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
12
|
+
#
|
13
|
+
msgid ""
|
14
|
+
msgstr ""
|
15
|
+
"Language-Team: Uyghur (https://app.transifex.com/ckeditor/teams/11143/ug/)\n"
|
16
|
+
"Language: ug\n"
|
17
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
18
|
+
|
19
|
+
msgctxt "Label showing the number of words in the editor content."
|
20
|
+
msgid "Words: %0"
|
21
|
+
msgstr "سۆز: %0"
|
22
|
+
|
23
|
+
msgctxt "Label showing the number of characters in the editor content."
|
24
|
+
msgid "Characters: %0"
|
25
|
+
msgstr "ھەرپ: %0"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-word-count",
|
3
|
-
"version": "
|
3
|
+
"version": "39.0.0",
|
4
4
|
"description": "Word and character count feature for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -11,10 +11,9 @@
|
|
11
11
|
"ckeditor5-dll"
|
12
12
|
],
|
13
13
|
"main": "src/index.js",
|
14
|
-
"type": "module",
|
15
14
|
"dependencies": {
|
16
|
-
"lodash-es": "
|
17
|
-
"ckeditor5": "
|
15
|
+
"lodash-es": "4.17.21",
|
16
|
+
"ckeditor5": "39.0.0"
|
18
17
|
},
|
19
18
|
"engines": {
|
20
19
|
"node": ">=16.0.0",
|
package/src/augmentation.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
4
|
*/
|
5
|
-
import type { WordCount, WordCountConfig } from './index
|
5
|
+
import type { WordCount, WordCountConfig } from './index';
|
6
6
|
declare module '@ckeditor/ckeditor5-core' {
|
7
7
|
interface EditorConfig {
|
8
8
|
/**
|
package/src/index.d.ts
CHANGED
@@ -5,6 +5,6 @@
|
|
5
5
|
/**
|
6
6
|
* @module word-count
|
7
7
|
*/
|
8
|
-
export { default as WordCount, type WordCountUpdateEvent } from './wordcount
|
9
|
-
export { WordCountConfig } from './wordcountconfig
|
10
|
-
import './augmentation
|
8
|
+
export { default as WordCount, type WordCountUpdateEvent } from './wordcount';
|
9
|
+
export { WordCountConfig } from './wordcountconfig';
|
10
|
+
import './augmentation';
|
package/src/index.js
CHANGED
package/src/utils.d.ts
CHANGED
package/src/wordcount.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
4
|
*/
|
5
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core
|
5
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
6
6
|
/**
|
7
7
|
* The word count plugin.
|
8
8
|
*
|
package/src/wordcount.js
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
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
|
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
9
|
import { throttle, isElement } from 'lodash-es';
|
10
10
|
/**
|
11
11
|
* The word count plugin.
|
@@ -171,12 +171,12 @@ export default class WordCount extends Plugin {
|
|
171
171
|
}
|
172
172
|
_getText() {
|
173
173
|
let txt = '';
|
174
|
-
for (const
|
174
|
+
for (const root of this.editor.model.document.getRoots()) {
|
175
175
|
if (txt !== '') {
|
176
176
|
// Add a delimiter, so words from each root are treated independently.
|
177
177
|
txt += '\n';
|
178
178
|
}
|
179
|
-
txt += modelElementToPlainText(
|
179
|
+
txt += modelElementToPlainText(root);
|
180
180
|
}
|
181
181
|
return txt;
|
182
182
|
}
|