@ckeditor/ckeditor5-word-count 47.7.0-alpha.3 → 47.7.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/word-count.js +1 -1
- package/package.json +5 -5
package/build/word-count.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
/*!
|
|
3
3
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
4
4
|
* For licensing, see LICENSE.md.
|
|
5
|
-
*/(()=>{var t={
|
|
5
|
+
*/(()=>{var t={782(t,e,r){t.exports=r(237)("./src/core.js")},311(t,e,r){t.exports=r(237)("./src/ui.js")},584(t,e,r){t.exports=r(237)("./src/utils.js")},237(t){"use strict";t.exports=CKEditor5.dll}},e={};function r(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{WordCount:()=>u,_modelElementToPlainText:()=>i});var t=r(782),e=r(311),n=r(584);function i(t){if(t.is("$text")||t.is("$textProxy"))return t.data;const e=t;let r="",o=null;for(const t of e.getChildren()){const e=i(t);o&&o.is("element")&&(r+="\n"),r+=e,o=t}return r}function s(t,e,{signal:r,edges:o}={}){let n,i=null;const s=null!=o&&o.includes("leading"),c=null==o||o.includes("trailing"),a=()=>{null!==i&&(t.apply(n,i),n=void 0,i=null)};let u=null;const l=()=>{null!=u&&clearTimeout(u),u=setTimeout(()=>{u=null,c&&a(),h()},e)},d=()=>{null!==u&&(clearTimeout(u),u=null)},h=()=>{d(),n=void 0,i=null},g=function(...t){if(r?.aborted)return;n=this,i=t;const e=null==u;l(),s&&e&&a()};return g.schedule=l,g.cancel=h,g.flush=()=>{d(),a()},r?.addEventListener("abort",h,{once:!0}),g}function c(t,e=0,r={}){"object"!=typeof r&&(r={});const{leading:o=!0,trailing:n=!0}=r;return function(t,e=0,r={}){"object"!=typeof r&&(r={});const{leading:o=!1,trailing:n=!0,maxWait:i}=r,c=Array(2);let a;o&&(c[0]="leading"),n&&(c[1]="trailing");let u=null;const l=s(function(...e){a=t.apply(this,e),u=null},e,{edges:c}),d=function(...e){return null!=i&&(null===u&&(u=Date.now()),Date.now()-u>=i)?(a=t.apply(this,e),u=Date.now(),l.cancel(),l.schedule(),a):(l.apply(this,e),a)};return d.cancel=l.cancel,d.flush=()=>(l.flush(),a),d}(t,e,{leading:o,trailing:n,maxWait:e})}function a(t){return function(t){return"object"==typeof t&&null!==t}(t)&&1===t.nodeType&&!function(t){if("object"!=typeof t)return!1;if(null==t)return!1;if(null===Object.getPrototypeOf(t))return!0;if("[object Object]"!==Object.prototype.toString.call(t)){const e=t[Symbol.toStringTag];return null!=e&&(!!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable&&t.toString()===`[object ${e}]`)}let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}(t)}class u extends t.Plugin{_config;_outputView;_wordsMatchRegExp;constructor(t){super(t),this.set("characters",0),this.set("words",0),Object.defineProperties(this,{characters:{get(){return this.characters=this._getCharacters(this._getText())}},words:{get(){return this.words=this._getWords(this._getText())}}}),this.set("_wordsLabel",void 0),this.set("_charactersLabel",void 0),this._config=t.config.get("wordCount")||{},this._outputView=void 0,this._wordsMatchRegExp=n.env.features.isRegExpUnicodePropertySupported?new RegExp("([\\p{L}\\p{N}]+\\S?)+","gu"):/([a-zA-Z0-9À-ž]+\S?)+/gu}static get pluginName(){return"WordCount"}static get licenseFeatureCode(){return"WC"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){this.editor.model.document.on("change:data",c(this._refreshStats.bind(this),250)),"function"==typeof this._config.onUpdate&&this.on("update",(t,e)=>{this._config.onUpdate(e)}),a(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})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-word-count",
|
|
3
|
-
"version": "47.7.0-alpha.
|
|
3
|
+
"version": "47.7.0-alpha.4",
|
|
4
4
|
"description": "Word and character count feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-core": "47.7.0-alpha.
|
|
17
|
-
"@ckeditor/ckeditor5-ui": "47.7.0-alpha.
|
|
18
|
-
"@ckeditor/ckeditor5-utils": "47.7.0-alpha.
|
|
16
|
+
"@ckeditor/ckeditor5-core": "47.7.0-alpha.4",
|
|
17
|
+
"@ckeditor/ckeditor5-ui": "47.7.0-alpha.4",
|
|
18
|
+
"@ckeditor/ckeditor5-utils": "47.7.0-alpha.4",
|
|
19
19
|
"es-toolkit": "1.39.5",
|
|
20
|
-
"ckeditor5": "47.7.0-alpha.
|
|
20
|
+
"ckeditor5": "47.7.0-alpha.4"
|
|
21
21
|
},
|
|
22
22
|
"author": "CKSource (http://cksource.com/)",
|
|
23
23
|
"license": "SEE LICENSE IN LICENSE.md",
|