@ckeditor/ckeditor5-find-and-replace 35.4.0 → 36.0.1
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/LICENSE.md +1 -1
- package/build/find-and-replace.js +2 -2
- package/build/translations/ug.js +1 -0
- package/lang/translations/ug.po +69 -0
- package/package.json +20 -20
- package/src/findandreplace.js +1 -1
- package/src/findandreplaceediting.js +14 -5
- package/src/findandreplacestate.js +1 -1
- package/src/findandreplaceui.js +17 -10
- package/src/findandreplaceutils.js +179 -0
- package/src/findcommand.js +4 -4
- package/src/findnextcommand.js +1 -1
- package/src/findpreviouscommand.js +1 -1
- package/src/index.js +2 -1
- package/src/replaceallcommand.js +4 -4
- package/src/replacecommand.js +1 -1
- package/src/ui/findandreplaceformview.js +1 -1
- package/theme/findandreplace.css +1 -1
- package/theme/findandreplaceform.css +1 -1
- package/src/utils.js +0 -166
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 Find and Replace Feature** – https://github.com/ckeditor/ckeditor5-find-and-replace <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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{Find:"Find","Find and replace":"Find and replace","Find in text…":"Find in text…","Match case":"Match case","Next result":"Next result","Previous result":"Previous result",Replace:"Replace","Replace all":"Replace all","Replace with…":"Replace with…","Show options":"Show options","Text to find must not be empty.":"Text to find must not be empty.","Tip: Find some text first in order to replace it.":"Tip: Find some text first in order to replace it.","Whole words only":"Whole words only"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
|
|
2
2
|
/*!
|
|
3
|
-
* @license Copyright (c) 2003-
|
|
3
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
4
4
|
* For licensing, see LICENSE.md.
|
|
5
|
-
*/(()=>{var e={299:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(609),r=i.n(n)()((function(e){return e[1]}));r.push([e.id,".ck-find-result{background:var(--ck-color-highlight-background);color:var(--ck-color-text)}.ck-find-result_selected{background:#ff9633}",""]);const s=r},226:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(609),r=i.n(n)()((function(e){return e[1]}));r.push([e.id,".ck.ck-find-and-replace-form{max-width:100%}.ck.ck-find-and-replace-form fieldset{display:flex}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{position:absolute}.ck.ck-find-and-replace-form{width:400px}.ck.ck-find-and-replace-form:focus{outline:none}.ck.ck-find-and-replace-form fieldset{align-content:stretch;align-items:center;border:0;flex-direction:row;flex-wrap:nowrap;margin:0;padding:var(--ck-spacing-large)}.ck.ck-find-and-replace-form fieldset>.ck-button{flex:0 0 auto}[dir=ltr] .ck.ck-find-and-replace-form fieldset>*+*{margin-left:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-find-and-replace-form fieldset>*+*{margin-right:var(--ck-spacing-standard)}.ck.ck-find-and-replace-form fieldset .ck-labeled-field-view{flex:1 1 auto}.ck.ck-find-and-replace-form fieldset .ck-labeled-field-view .ck-input{min-width:50px;width:100%}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find{align-items:flex-start}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-find{font-weight:700}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-find .ck-button__label{padding-left:var(--ck-spacing-large);padding-right:var(--ck-spacing-large)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-prev>.ck-icon{transform:rotate(90deg)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-next>.ck-icon{transform:rotate(-90deg)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{top:50%;transform:translateY(-50%)}[dir=ltr] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{right:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{left:var(--ck-spacing-standard)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{color:var(--ck-color-base-border)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace{flex-wrap:wrap;justify-content:flex-end;margin-top:calc(var(--ck-spacing-large)*-1)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-labeled-field-view{margin-bottom:var(--ck-spacing-large)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-options-dropdown{margin-left:0;margin-right:auto}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-labeled-field-view,.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-labeled-field-view .ck-input{width:100%}@media screen and (max-width:600px){.ck.ck-find-and-replace-form{width:300px}.ck.ck-find-and-replace-form fieldset{flex-wrap:wrap}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-labeled-field-view{flex:1 0 auto;margin-bottom:var(--ck-spacing-standard);width:100%}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button{text-align:center}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type{flex:1 1 auto}[dir=ltr] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type{margin-left:0}[dir=rtl] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type{margin-right:0}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type .ck-button__label{text-align:center;width:100%}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>:not(.ck-labeled-field-view){flex:1 1 auto}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-dropdown:not(.ck-labeled-field-view){flex-grow:0}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-button:not(.ck-labeled-field-view)>.ck-button__label{text-align:center;width:100%}}",""]);const s=r},764:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(609),r=i.n(n)()((function(e){return e[1]}));r.push([e.id,'.ck-vertical-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck-vertical-form .ck-button:focus:after{display:none}@media screen and (max-width:600px){.ck.ck-responsive-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck.ck-responsive-form .ck-button:focus:after{display:none}}.ck-vertical-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form{padding:var(--ck-spacing-large)}.ck.ck-responsive-form:focus{outline:none}[dir=ltr] .ck.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-responsive-form>:not(:last-child){margin-left:var(--ck-spacing-standard)}@media screen and (max-width:600px){.ck.ck-responsive-form{padding:0;width:calc(var(--ck-input-width)*.8)}.ck.ck-responsive-form .ck-labeled-field-view{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-responsive-form .ck-labeled-field-view .ck-input-text{min-width:0;width:100%}.ck.ck-responsive-form .ck-labeled-field-view .ck-labeled-field-view__error{white-space:normal}.ck.ck-responsive-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form>.ck-button:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){border-radius:0;margin-top:var(--ck-spacing-large);padding:var(--ck-spacing-standard)}.ck.ck-responsive-form>.ck-button:last-child:not(:focus),.ck.ck-responsive-form>.ck-button:nth-last-child(2):not(:focus){border-top:1px solid var(--ck-color-base-border)}[dir=ltr] .ck.ck-responsive-form>.ck-button:last-child,[dir=ltr] .ck.ck-responsive-form>.ck-button:nth-last-child(2),[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2){margin-left:0}[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child:last-of-type,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2):last-of-type{border-right:1px solid var(--ck-color-base-border)}}',""]);const s=r},609:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=e(t);return t[2]?"@media ".concat(t[2]," {").concat(i,"}"):i})).join("")},t.i=function(e,i,n){"string"==typeof e&&(e=[[null,e,""]]);var r={};if(n)for(var s=0;s<this.length;s++){var o=this[s][0];null!=o&&(r[o]=!0)}for(var a=0;a<e.length;a++){var c=[].concat(e[a]);n&&r[c[0]]||(i&&(c[2]?c[2]="".concat(i," and ").concat(c[2]):c[2]=i),t.push(c))}},t}},62:(e,t,i)=>{"use strict";var n,r=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},s=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),o=[];function a(e){for(var t=-1,i=0;i<o.length;i++)if(o[i].identifier===e){t=i;break}return t}function c(e,t){for(var i={},n=[],r=0;r<e.length;r++){var s=e[r],c=t.base?s[0]+t.base:s[0],l=i[c]||0,d="".concat(c," ").concat(l);i[c]=l+1;var h=a(d),f={css:s[1],media:s[2],sourceMap:s[3]};-1!==h?(o[h].references++,o[h].updater(f)):o.push({identifier:d,updater:g(f,t),references:1}),n.push(d)}return n}function l(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var r=i.nc;r&&(n.nonce=r)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var o=s(e.insert||"head");if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(t)}return t}var d,h=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function f(e,t,i,n){var r=i?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=h(t,r);else{var s=document.createTextNode(r),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(s,o[t]):e.appendChild(s)}}function u(e,t,i){var n=i.css,r=i.media,s=i.sourceMap;if(r?e.setAttribute("media",r):e.removeAttribute("media"),s&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var p=null,m=0;function g(e,t){var i,n,r;if(t.singleton){var s=m++;i=p||(p=l(t)),n=f.bind(null,i,s,!1),r=f.bind(null,i,s,!0)}else i=l(t),n=u.bind(null,i,t),r=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=r());var i=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<i.length;n++){var r=a(i[n]);o[r].references--}for(var s=c(e,t),l=0;l<i.length;l++){var d=a(i[l]);0===o[d].references&&(o[d].updater(),o.splice(d,1))}i=s}}}},704:(e,t,i)=>{e.exports=i(79)("./src/core.js")},273:(e,t,i)=>{e.exports=i(79)("./src/ui.js")},209:(e,t,i)=>{e.exports=i(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={id:n,exports:{}};return e[n](s,s.exports,i),s.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{FindAndReplace:()=>Ie});var e=i(704),t=i(273),r=i(209),s=i(62),o=i.n(s),a=i(764),c={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};o()(a.Z,c);a.Z.locals;var l=i(226),d={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};o()(l.Z,d);l.Z.locals;const h='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.463 5.187a.888.888 0 1 1 1.254 1.255L9.16 10l3.557 3.557a.888.888 0 1 1-1.254 1.255L7.26 10.61a.888.888 0 0 1 .16-1.382l4.043-4.042z"/></svg>';class f extends t.View{constructor(e){super(e);const i=e.t;this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",((e,t)=>e>0&&!t)),this._findInputView=this._createInputField(i("Find in text…")),this._replaceInputView=this._createInputField(i("Replace with…")),this._findButtonView=this._createButton({label:i("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._findPrevButtonView=this._createButton({label:i("Previous result"),class:"ck-button-prev",icon:h,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:i("Next result"),class:"ck-button-next",icon:h,keystroke:"F3",tooltip:!0}),this._optionsDropdown=this._createOptionsDropdown(),this._replaceButtonView=this._createButton({label:i("Replace"),class:"ck-button-replace",withText:!0}),this._replaceAllButtonView=this._createButton({label:i("Replace all"),class:"ck-button-replaceall",withText:!0}),this._findFieldsetView=this._createFindFieldset(),this._replaceFieldsetView=this._createReplaceFieldset(),this._focusTracker=new r.FocusTracker,this._keystrokes=new r.KeystrokeHandler,this._focusables=new t.ViewCollection,this._focusCycler=new t.FocusCycler({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:[new t.FormHeaderView(e,{label:i("Find and replace")}),this._findFieldsetView,this._replaceFieldsetView]}),(0,t.injectCssTransitionDisabler)(this)}render(){super.render(),(0,t.submitHandler)({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createFindFieldset(){const e=this.locale,i=new t.View(e);return this._findInputView.fieldView.on("input",(()=>{this.isDirty=!0})),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findPrevious:e})=>e)),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findNext:e})=>e)),this._injectFindResultsCounter(),i.setTemplate({tag:"fieldset",attributes:{class:["ck","ck-find-and-replace-form__find"]},children:[this._findInputView,this._findButtonView,this._findPrevButtonView,this._findNextButtonView]}),i}_onFindButtonExecute(){if(this._textToFind)this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly});else{const e=this.t;this._findInputView.errorText=e("Text to find must not be empty.")}}_injectFindResultsCounter(){const e=this.locale,i=e.t,n=this.bindTemplate,s=new t.View(e);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",((e,t)=>i("%0 of %1",[e,t]))),s.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",n.if("isDirty","ck-hidden")]},children:[{text:n.to("_resultsCounterText")}]});const o=()=>{const t=this._findInputView.fieldView.element;if(!t||!(0,r.isVisible)(t))return;const i=new r.Rect(s.element).width,n="ltr"===e.uiLanguageDirection?"paddingRight":"paddingLeft";t.style[n]=i?`calc( 2 * var(--ck-spacing-standard) + ${i}px )`:null};this.on("change:_resultsCounterText",o,{priority:"low"}),this.on("change:isDirty",o,{priority:"low"}),this._findInputView.template.children[0].children.push(s)}_createReplaceFieldset(){const e=this.locale,i=e.t,n=new t.View(e);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replaceAll:e},t)=>e&&t)),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",((e,t)=>e||!t?"":i("Tip: Find some text first in order to replace it."))),this._replaceButtonView.on("execute",(()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})})),this._replaceAllButtonView.on("execute",(()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()})),n.setTemplate({tag:"fieldset",attributes:{class:["ck","ck-find-and-replace-form__replace"]},children:[this._replaceInputView,this._optionsDropdown,this._replaceButtonView,this._replaceAllButtonView]}),n}_createOptionsDropdown(){const i=this.locale,n=i.t,s=(0,t.createDropdown)(i);s.class="ck-options-dropdown",s.buttonView.set({withText:!1,label:n("Show options"),icon:e.icons.cog,tooltip:!0});const o=new t.Model({withText:!0,label:n("Match case"),_isMatchCaseSwitch:!0}),a=new t.Model({withText:!0,label:n("Whole words only")});return o.bind("isOn").to(this,"_matchCase"),a.bind("isOn").to(this,"_wholeWordsOnly"),s.on("execute",(e=>{e.source._isMatchCaseSwitch?this._matchCase=!this._matchCase:this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0})),(0,t.addListToDropdown)(s,new r.Collection([{type:"switchbutton",model:o},{type:"switchbutton",model:a}])),s}_initFocusCycling(){[this._findInputView,this._findButtonView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._optionsDropdown,this._replaceButtonView,this._replaceAllButtonView].forEach((e=>{this._focusables.add(e),this._focusTracker.add(e.element)}))}_initKeystrokeHandling(){const e=e=>e.stopPropagation(),t=e=>{e.stopPropagation(),e.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",(e=>{t(e),this._findNextButtonView.fire("execute")})),this._keystrokes.set("shift+f3",(e=>{t(e),this._findPrevButtonView.fire("execute")})),this._keystrokes.set("enter",(e=>{const i=e.target;i===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e)):i!==this._replaceInputView.fieldView.element||this.isDirty||(this._replaceButtonView.fire("execute"),t(e))})),this._keystrokes.set("shift+enter",(e=>{e.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e))})),this._keystrokes.set("arrowright",e),this._keystrokes.set("arrowleft",e),this._keystrokes.set("arrowup",e),this._keystrokes.set("arrowdown",e),this.listenTo(this._findInputView.element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"}),this.listenTo(this._replaceInputView.element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"})}_createButton(e){const i=new t.ButtonView(this.locale);return i.set(e),i}_createInputField(e){const i=new t.LabeledFieldView(this.locale,t.createLabeledInputText);return i.label=e,i}}class u extends e.Plugin{static get pluginName(){return"FindAndReplaceUI"}constructor(e){super(e),this.formView=null}init(){const e=this.editor;e.ui.componentFactory.add("findAndReplace",(i=>{const n=(0,t.createDropdown)(i),r=this.formView=new f(e.locale);return n.bind("isEnabled").to(e.commands.get("find")),n.panelView.children.add(r),n.on("change:isOpen",((e,t,i)=>{i?(r.disableCssTransitions(),r.reset(),r._findInputView.fieldView.select(),r.enableCssTransitions()):this.fire("searchReseted")}),{priority:"low"}),this._setupDropdownButton(n),this._setupFormView(r),n}))}_setupDropdownButton(e){const t=this.editor,i=t.locale.t;e.buttonView.set({icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.87 13.786 1.532-1.286 3.857 4.596a1 1 0 1 1-1.532 1.286l-3.857-4.596z"/><path d="M16.004 8.5a6.5 6.5 0 0 1-9.216 5.905c-1.154-.53-.863-1.415-.663-1.615.194-.194.564-.592 1.635-.141a4.5 4.5 0 0 0 5.89-5.904l-.104-.227 1.332-1.331c.045-.046.196-.041.224.007a6.47 6.47 0 0 1 .902 3.306zm-3.4-5.715c.562.305.742 1.106.354 1.494-.388.388-.995.414-1.476.178a4.5 4.5 0 0 0-6.086 5.882l.114.236-1.348 1.349c-.038.037-.17.022-.198-.023a6.5 6.5 0 0 1 5.54-9.9 6.469 6.469 0 0 1 3.1.784z"/><path d="M4.001 11.93.948 8.877a.2.2 0 0 1 .141-.341h6.106a.2.2 0 0 1 .141.341L4.283 11.93a.2.2 0 0 1-.282 0zm11.083-6.789 3.053 3.053a.2.2 0 0 1-.14.342H11.89a.2.2 0 0 1-.14-.342l3.052-3.053a.2.2 0 0 1 .282 0z"/></svg>',label:i("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),t.keystrokes.set("Ctrl+F",((t,i)=>{e.isOpen=!0,i()}))}_setupFormView(e){const t=this.editor.commands,i=this.editor.plugins.get("FindAndReplaceEditing").state,n={before:-1,same:0,after:1};e.bind("highlightOffset").to(i,"highlightedResult",(e=>e?Array.from(i.results).sort(((e,t)=>n[e.marker.getStart().compareWith(t.marker.getStart())])).indexOf(e)+1:0)),e.listenTo(i.results,"change",(()=>{e.matchCount=i.results.length})),e.bind("_areCommandsEnabled").to(t.get("findNext"),"isEnabled",t.get("findPrevious"),"isEnabled",t.get("replace"),"isEnabled",t.get("replaceAll"),"isEnabled",((e,t,i,n)=>({findNext:e,findPrevious:t,replace:i,replaceAll:n}))),e.delegate("findNext","findPrevious","replace","replaceAll").to(this),e.on("change:isDirty",((e,t,i)=>{i&&this.fire("searchReseted")}))}}const p="object"==typeof global&&global&&global.Object===Object&&global;var m="object"==typeof self&&self&&self.Object===Object&&self;const g=p||m||Function("return this")();const k=g.Symbol;const w=function(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i<n;)r[i]=t(e[i],i,e);return r};const b=Array.isArray;var _=Object.prototype,v=_.hasOwnProperty,x=_.toString,y=k?k.toStringTag:void 0;const T=function(e){var t=v.call(e,y),i=e[y];try{e[y]=void 0;var n=!0}catch(e){}var r=x.call(e);return n&&(t?e[y]=i:delete e[y]),r};var R=Object.prototype.toString;const V=function(e){return R.call(e)};var C=k?k.toStringTag:void 0;const I=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":C&&C in Object(e)?T(e):V(e)};const E=function(e){return null!=e&&"object"==typeof e};const F=function(e){return"symbol"==typeof e||E(e)&&"[object Symbol]"==I(e)};var N=k?k.prototype:void 0,B=N?N.toString:void 0;const A=function e(t){if("string"==typeof t)return t;if(b(t))return w(t,e)+"";if(F(t))return B?B.call(t):"";var i=t+"";return"0"==i&&1/t==-Infinity?"-0":i};const S=function(e){return null==e?"":A(e)};var O=/[\\^$.*+?()[\]{}|]/g,j=RegExp(O.source);const M=function(e){return(e=S(e))&&j.test(e)?e.replace(O,"\\$&"):e};function D(e,t,i,n){const s=n||new r.Collection;return t.change((n=>{[...e].forEach((({type:e,item:o})=>{if("elementStart"===e&&t.schema.checkChild(o,"$text")){const e=i({item:o,text:P(t.createRangeIn(o))});if(!e)return;e.forEach((e=>{const t=`findResult:${(0,r.uid)()}`,i=n.addMarker(t,{usingOperation:!1,affectsData:!1,range:n.createRange(n.createPositionAt(o,e.start),n.createPositionAt(o,e.end))}),a=function(e,t){const i=e.find((({marker:e})=>t.getStart().isBefore(e.getStart())));return i?e.getIndex(i):e.length}(s,i);s.add({id:t,label:e.label,marker:i},a)}))}}))})),s}function P(e){return Array.from(e.getItems()).reduce(((e,t)=>t.is("text")||t.is("textProxy")?e+t.data:`${e}\n`),"")}function W(e){const t=e.length-1;let i=e.index;return 3===e.length&&(i+=e[1].length),{label:e[t],start:i,end:i+e[t].length}}function $(e,t){let i="gu";t.matchCase||(i+="i");let n=`(${M(e)})`;if(t.wholeWords){const t="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+t).test(e)||(n=`(^|${t}|_)${n}`),new RegExp(t+"$").test(e)||(n=`${n}(?=_|${t}|$)`)}const r=new RegExp(n,i);return function({text:e}){return[...e.matchAll(r)].map(W)}}class H extends e.Command{constructor(e,t){super(e),this.isEnabled=!0,this.affectsData=!1,this._state=t}execute(e,{matchCase:t,wholeWords:i}={}){const{editor:n}=this,{model:r}=n;let s;"string"==typeof e?(s=$(e,{matchCase:t,wholeWords:i}),this._state.searchText=e):s=e;const o=r.document.getRootNames().reduce(((e,t)=>D(r.createRangeIn(r.document.getRoot(t)),r,s,e)),null);return this._state.clear(r),this._state.results.addMany(Array.from(o)),this._state.highlightedResult=o.get(0),"string"==typeof e&&(this._state.searchText=e),this._state.matchCase=!!t,this._state.matchWholeWords=!!i,{results:o,findCallback:s}}}class L extends e.Command{constructor(e,t){super(e),this.isEnabled=!0,this._state=t}execute(e,t){const{model:i}=this.editor;i.change((n=>{const r=t.marker.getRange();if("$graveyard"===r.root.rootName)return void this._state.results.remove(t);let s={};for(const e of r.getItems())if(e.is("$text")||e.is("$textProxy")){s=e.getAttributes();break}i.insertContent(n.createText(e,s),r),this._state.results.has(t)&&this._state.results.remove(t)}))}}class Z extends L{execute(e,t){const{editor:i}=this,{model:n}=i,s=t instanceof r.Collection?t:n.document.getRootNames().reduce(((e,i)=>D(n.createRangeIn(n.document.getRoot(i)),n,$(t,this._state),e)),null);s.length&&n.change((()=>{[...s].forEach((t=>{super.execute(e,t)}))}))}}class z extends e.Command{constructor(e,t){super(e),this.affectsData=!1,this._state=t,this.isEnabled=!1,this.listenTo(this._state.results,"change",(()=>{this.isEnabled=this._state.results.length>1}))}refresh(){this.isEnabled=this._state.results.length>1}execute(){const e=this._state.results,t=e.getIndex(this._state.highlightedResult),i=t+1>=e.length?0:t+1;this._state.highlightedResult=this._state.results.get(i)}}class K extends z{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),t=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(t)}}class Y{constructor(e){this.set("results",new r.Collection),this.set("highlightedResult",null),this.set("searchText",""),this.set("replaceText",""),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",((t,{removed:i,index:n})=>{if((i=Array.from(i)).length){let t=!1;if(e.change((n=>{for(const r of i)this.highlightedResult===r&&(t=!0),e.markers.has(r.marker.name)&&n.removeMarker(r.marker)})),t){const e=n>=this.results.length?0:n;this.highlightedResult=this.results.get(e)}}}))}clear(e){this.searchText="",e.change((t=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],n=e.markers.get(`findResultHighlighted:${i}`);n&&t.removeMarker(n)}[...this.results].forEach((({marker:e})=>{t.removeMarker(e)}))})),this.results.clear()}}function U(e){return"[object Range]"==Object.prototype.toString.apply(e)}function q(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}function G(e){return"[object Text]"==Object.prototype.toString.call(e)}(0,r.mix)(Y,r.ObservableMixin);const J=["top","right","bottom","left","width","height"];class X{constructor(e){const t=U(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),te(e)||t)if(t){const t=X.getDomRangeRects(e);Q(this,X.getBoundingRect(t))}else Q(this,e.getBoundingClientRect());else if(q(e)){const{innerWidth:t,innerHeight:i}=e;Q(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else Q(this,e)}clone(){return new X(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left),width:0,height:0};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new X(t)}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(!ee(e)){let i=e.parentNode||e.commonAncestorContainer;for(;i&&!ee(i);){const e=new X(i),n=t.getIntersection(e);if(!n)return null;n.getArea()<t.getArea()&&(t=n),i=i.parentNode}}return t}isEqual(e){for(const t of J)if(this[t]!==e[t])return!1;return!0}contains(e){const t=this.getIntersection(e);return!(!t||!t.isEqual(e))}excludeScrollbarsAndBorders(){const e=this._source;let t,i,n;if(q(e))t=e.innerWidth-e.document.documentElement.clientWidth,i=e.innerHeight-e.document.documentElement.clientHeight,n=e.getComputedStyle(e.document.documentElement).direction;else{const r=function(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}(e);t=e.offsetWidth-e.clientWidth-r.left-r.right,i=e.offsetHeight-e.clientHeight-r.top-r.bottom,n=e.ownerDocument.defaultView.getComputedStyle(e).direction,this.left+=r.left,this.top+=r.top,this.right-=r.right,this.bottom-=r.bottom,this.width=this.right-this.left,this.height=this.bottom-this.top}return this.width-=t,"ltr"===n?this.right-=t:this.left+=t,this.height-=i,this.bottom-=i,this}static getDomRangeRects(e){const t=[],i=Array.from(e.getClientRects());if(i.length)for(const e of i)t.push(new X(e));else{let i=e.startContainer;G(i)&&(i=i.parentNode);const n=new X(i.getBoundingClientRect());n.right=n.left,n.width=0,t.push(n)}return t}static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let i=0;for(const n of e)i++,t.left=Math.min(t.left,n.left),t.top=Math.min(t.top,n.top),t.right=Math.max(t.right,n.right),t.bottom=Math.max(t.bottom,n.bottom);return 0==i?null:(t.width=t.right-t.left,t.height=t.bottom-t.top,new X(t))}}function Q(e,t){for(const i of J)e[i]=t[i]}function ee(e){return!!te(e)&&e===e.ownerDocument.body}function te(e){return null!==e&&"object"==typeof e&&1===e.nodeType&&"function"==typeof e.getBoundingClientRect}function ie(e,t,i){const n=t.clone().moveBy(0,i),r=t.clone().moveBy(0,-i),s=new X(e).excludeScrollbarsAndBorders();if(![r,n].every((e=>s.contains(e)))){let{scrollX:o,scrollY:a}=e;se(r,s)?a-=s.top-t.top+i:re(n,s)&&(a+=t.bottom-s.bottom+i),oe(t,s)?o-=s.left-t.left+i:ae(t,s)&&(o+=t.right-s.right+i),e.scrollTo(o,a)}}function ne(e,t){const i=ce(e);let n,r;for(;e!=i.document.body;)r=t(),n=new X(e).excludeScrollbarsAndBorders(),n.contains(r)||(se(r,n)?e.scrollTop-=n.top-r.top:re(r,n)&&(e.scrollTop+=r.bottom-n.bottom),oe(r,n)?e.scrollLeft-=n.left-r.left:ae(r,n)&&(e.scrollLeft+=r.right-n.right)),e=e.parentNode}function re(e,t){return e.bottom>t.bottom}function se(e,t){return e.top<t.top}function oe(e,t){return e.left<t.left}function ae(e,t){return e.right>t.right}function ce(e){return U(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function le(e){if(U(e)){let t=e.commonAncestorContainer;return G(t)&&(t=t.parentNode),t}return e.parentNode}function de(e,t){const i=ce(e),n=new X(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new X(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const he=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const fe=function(){return g.Date.now()};var ue=/\s/;const pe=function(e){for(var t=e.length;t--&&ue.test(e.charAt(t)););return t};var me=/^\s+/;const ge=function(e){return e?e.slice(0,pe(e)+1).replace(me,""):e};var ke=/^[-+]0x[0-9a-f]+$/i,we=/^0b[01]+$/i,be=/^0o[0-7]+$/i,_e=parseInt;const ve=function(e){if("number"==typeof e)return e;if(F(e))return NaN;if(he(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=he(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=ge(e);var i=we.test(e);return i||be.test(e)?_e(e.slice(2),i?2:8):ke.test(e)?NaN:+e};var xe=Math.max,ye=Math.min;const Te=function(e,t,i){var n,r,s,o,a,c,l=0,d=!1,h=!1,f=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function u(t){var i=n,s=r;return n=r=void 0,l=t,o=e.apply(s,i)}function p(e){return l=e,a=setTimeout(g,t),d?u(e):o}function m(e){var i=e-c;return void 0===c||i>=t||i<0||h&&e-l>=s}function g(){var e=fe();if(m(e))return k(e);a=setTimeout(g,function(e){var i=t-(e-c);return h?ye(i,s-(e-l)):i}(e))}function k(e){return a=void 0,f&&n?u(e):(n=r=void 0,o)}function w(){var e=fe(),i=m(e);if(n=arguments,r=this,c=e,i){if(void 0===a)return p(c);if(h)return clearTimeout(a),a=setTimeout(g,t),u(c)}return void 0===a&&(a=setTimeout(g,t)),o}return t=ve(t)||0,he(i)&&(d=!!i.leading,s=(h="maxWait"in i)?xe(ve(i.maxWait)||0,t):s,f="trailing"in i?!!i.trailing:f),w.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=r=a=void 0},w.flush=function(){return void 0===a?o:k(fe())},w};var Re=i(299),Ve={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};o()(Re.Z,Ve);Re.Z.locals;class Ce extends e.Plugin{static get pluginName(){return"FindAndReplaceEditing"}init(){this._activeResults=null,this.state=new Y(this.editor.model),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",((e,t,i,n)=>{const{model:r}=this.editor;r.change((e=>{if(n){const t=n.marker.name.split(":")[1],i=r.markers.get(`findResultHighlighted:${t}`);i&&e.removeMarker(i)}if(i){const t=i.marker.name.split(":")[1];e.addMarker(`findResultHighlighted:${t}`,{usingOperation:!1,affectsData:!1,range:i.marker.getRange()})}}))}));const e=Te(function(e,t,i){if(i){const e=this.editor.editing.view.domConverter,t=this.editor.editing.mapper.toViewRange(i.marker.getRange());!function({target:e,viewportOffset:t=0}){const i=ce(e);let n=i,r=null;for(;n;){let s;s=le(n==i?e:r),ne(s,(()=>de(e,n)));const o=de(e,n);if(ie(n,o,t),n.parent!=n){if(r=n.frameElement,n=n.parent,!r)return}else n=null}}({target:e.viewRangeToDom(t),viewportOffset:40})}}.bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel)}find(e){const{editor:t}=this,{model:i}=t,{findCallback:n,results:r}=t.execute("find",e);return this._activeResults=r,this.listenTo(i.document,"change:data",(()=>function(e,t,i){const n=new Set,r=new Set;t.document.differ.getChanges().forEach((e=>{"$text"===e.name||t.schema.isInline(e.position.nodeAfter)?(n.add(e.position.parent),[...t.markers.getMarkersAtPosition(e.position)].forEach((e=>{r.add(e.name)}))):"insert"===e.type&&n.add(e.position.nodeAfter)})),t.document.differ.getChangedMarkers().forEach((({name:e,data:{newRange:t}})=>{t&&"$graveyard"===t.start.root.rootName&&r.add(e)})),n.forEach((e=>{[...t.markers.getMarkersIntersectingRange(t.createRangeIn(e))].forEach((e=>r.add(e.name)))})),t.change((t=>{r.forEach((i=>{e.has(i)&&e.remove(i),t.removeMarker(i)}))})),n.forEach((n=>{D(t.createRangeOn(n),t,i,e)}))}(this._activeResults,i,n))),this._activeResults}stop(){this._activeResults&&(this.stopListening(this.editor.model.document),this.state.clear(this.editor.model),this._activeResults=null)}_defineCommands(){this.editor.commands.add("find",new H(this.editor,this.state)),this.editor.commands.add("findNext",new z(this.editor,this.state)),this.editor.commands.add("findPrevious",new K(this.editor,this.state)),this.editor.commands.add("replace",new L(this.editor,this.state)),this.editor.commands.add("replaceAll",new Z(this.editor,this.state))}_defineConverters(){const{editor:e}=this;e.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":t}}}}),e.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result_selected"],attributes:{"data-find-result":t}}}})}}class Ie extends e.Plugin{static get requires(){return[Ce,u]}static get pluginName(){return"FindAndReplace"}init(){const e=this.editor.plugins.get("FindAndReplaceUI"),t=this.editor.plugins.get("FindAndReplaceEditing"),i=t.state;e.on("findNext",((e,t)=>{t?(i.searchText=t.searchText,this.editor.execute("find",t.searchText,t)):this.editor.execute("findNext")})),e.on("findPrevious",((e,t)=>{t&&i.searchText!==t.searchText?this.editor.execute("find",t.searchText):this.editor.execute("findPrevious")})),e.on("replace",((e,t)=>{i.searchText!==t.searchText&&this.editor.execute("find",t.searchText);const n=i.highlightedResult;n&&this.editor.execute("replace",t.replaceText,n)})),e.on("replaceAll",((e,t)=>{i.searchText!==t.searchText&&this.editor.execute("find",t.searchText),this.editor.execute("replaceAll",t.replaceText,i.results)})),e.on("searchReseted",(()=>{i.clear(this.editor.model),t.stop()}))}}})(),(window.CKEditor5=window.CKEditor5||{}).findAndReplace=n})();
|
|
5
|
+
*/(()=>{var e={299:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(609),r=i.n(n)()((function(e){return e[1]}));r.push([e.id,".ck-find-result{background:var(--ck-color-highlight-background);color:var(--ck-color-text)}.ck-find-result_selected{background:#ff9633}",""]);const s=r},226:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(609),r=i.n(n)()((function(e){return e[1]}));r.push([e.id,".ck.ck-find-and-replace-form{max-width:100%}.ck.ck-find-and-replace-form fieldset{display:flex}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{position:absolute}.ck.ck-find-and-replace-form{width:400px}.ck.ck-find-and-replace-form:focus{outline:none}.ck.ck-find-and-replace-form fieldset{align-content:stretch;align-items:center;border:0;flex-direction:row;flex-wrap:nowrap;margin:0;padding:var(--ck-spacing-large)}.ck.ck-find-and-replace-form fieldset>.ck-button{flex:0 0 auto}[dir=ltr] .ck.ck-find-and-replace-form fieldset>*+*{margin-left:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-find-and-replace-form fieldset>*+*{margin-right:var(--ck-spacing-standard)}.ck.ck-find-and-replace-form fieldset .ck-labeled-field-view{flex:1 1 auto}.ck.ck-find-and-replace-form fieldset .ck-labeled-field-view .ck-input{min-width:50px;width:100%}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find{align-items:flex-start}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-find{font-weight:700}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-find .ck-button__label{padding-left:var(--ck-spacing-large);padding-right:var(--ck-spacing-large)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-prev>.ck-icon{transform:rotate(90deg)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button-next>.ck-icon{transform:rotate(-90deg)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{top:50%;transform:translateY(-50%)}[dir=ltr] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{right:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{left:var(--ck-spacing-standard)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-results-counter{color:var(--ck-color-base-border)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace{flex-wrap:wrap;justify-content:flex-end;margin-top:calc(var(--ck-spacing-large)*-1)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-labeled-field-view{margin-bottom:var(--ck-spacing-large)}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-options-dropdown{margin-left:0;margin-right:auto}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-labeled-field-view,.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-labeled-field-view .ck-input{width:100%}@media screen and (max-width:600px){.ck.ck-find-and-replace-form{width:300px}.ck.ck-find-and-replace-form fieldset{flex-wrap:wrap}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find .ck-labeled-field-view{flex:1 0 auto;margin-bottom:var(--ck-spacing-standard);width:100%}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button{text-align:center}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type{flex:1 1 auto}[dir=ltr] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type{margin-left:0}[dir=rtl] .ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type{margin-right:0}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__find>.ck-button:first-of-type .ck-button__label{text-align:center;width:100%}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>:not(.ck-labeled-field-view){flex:1 1 auto}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-dropdown:not(.ck-labeled-field-view){flex-grow:0}.ck.ck-find-and-replace-form fieldset.ck-find-and-replace-form__replace>.ck-button:not(.ck-labeled-field-view)>.ck-button__label{text-align:center;width:100%}}",""]);const s=r},764:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(609),r=i.n(n)()((function(e){return e[1]}));r.push([e.id,'.ck-vertical-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck-vertical-form .ck-button:focus:after{display:none}@media screen and (max-width:600px){.ck.ck-responsive-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck.ck-responsive-form .ck-button:focus:after{display:none}}.ck-vertical-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form{padding:var(--ck-spacing-large)}.ck.ck-responsive-form:focus{outline:none}[dir=ltr] .ck.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-responsive-form>:not(:last-child){margin-left:var(--ck-spacing-standard)}@media screen and (max-width:600px){.ck.ck-responsive-form{padding:0;width:calc(var(--ck-input-width)*.8)}.ck.ck-responsive-form .ck-labeled-field-view{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-responsive-form .ck-labeled-field-view .ck-input-text{min-width:0;width:100%}.ck.ck-responsive-form .ck-labeled-field-view .ck-labeled-field-view__error{white-space:normal}.ck.ck-responsive-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form>.ck-button:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){border-radius:0;margin-top:var(--ck-spacing-large);padding:var(--ck-spacing-standard)}.ck.ck-responsive-form>.ck-button:last-child:not(:focus),.ck.ck-responsive-form>.ck-button:nth-last-child(2):not(:focus){border-top:1px solid var(--ck-color-base-border)}[dir=ltr] .ck.ck-responsive-form>.ck-button:last-child,[dir=ltr] .ck.ck-responsive-form>.ck-button:nth-last-child(2),[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2){margin-left:0}[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child:last-of-type,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2):last-of-type{border-right:1px solid var(--ck-color-base-border)}}',""]);const s=r},609:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=e(t);return t[2]?"@media ".concat(t[2]," {").concat(i,"}"):i})).join("")},t.i=function(e,i,n){"string"==typeof e&&(e=[[null,e,""]]);var r={};if(n)for(var s=0;s<this.length;s++){var o=this[s][0];null!=o&&(r[o]=!0)}for(var a=0;a<e.length;a++){var c=[].concat(e[a]);n&&r[c[0]]||(i&&(c[2]?c[2]="".concat(i," and ").concat(c[2]):c[2]=i),t.push(c))}},t}},62:(e,t,i)=>{"use strict";var n,r=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},s=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),o=[];function a(e){for(var t=-1,i=0;i<o.length;i++)if(o[i].identifier===e){t=i;break}return t}function c(e,t){for(var i={},n=[],r=0;r<e.length;r++){var s=e[r],c=t.base?s[0]+t.base:s[0],l=i[c]||0,d="".concat(c," ").concat(l);i[c]=l+1;var h=a(d),f={css:s[1],media:s[2],sourceMap:s[3]};-1!==h?(o[h].references++,o[h].updater(f)):o.push({identifier:d,updater:g(f,t),references:1}),n.push(d)}return n}function l(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var r=i.nc;r&&(n.nonce=r)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var o=s(e.insert||"head");if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(t)}return t}var d,h=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function f(e,t,i,n){var r=i?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=h(t,r);else{var s=document.createTextNode(r),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(s,o[t]):e.appendChild(s)}}function u(e,t,i){var n=i.css,r=i.media,s=i.sourceMap;if(r?e.setAttribute("media",r):e.removeAttribute("media"),s&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var p=null,m=0;function g(e,t){var i,n,r;if(t.singleton){var s=m++;i=p||(p=l(t)),n=f.bind(null,i,s,!1),r=f.bind(null,i,s,!0)}else i=l(t),n=u.bind(null,i,t),r=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=r());var i=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<i.length;n++){var r=a(i[n]);o[r].references--}for(var s=c(e,t),l=0;l<i.length;l++){var d=a(i[l]);0===o[d].references&&(o[d].updater(),o.splice(d,1))}i=s}}}},704:(e,t,i)=>{e.exports=i(79)("./src/core.js")},273:(e,t,i)=>{e.exports=i(79)("./src/ui.js")},209:(e,t,i)=>{e.exports=i(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={id:n,exports:{}};return e[n](s,s.exports,i),s.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{FindAndReplace:()=>Be,FindAndReplaceUtils:()=>Y});var e=i(704),t=i(273),r=i(209),s=i(62),o=i.n(s),a=i(764),c={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};o()(a.Z,c);a.Z.locals;var l=i(226),d={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};o()(l.Z,d);l.Z.locals;const h='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.463 5.187a.888.888 0 1 1 1.254 1.255L9.16 10l3.557 3.557a.888.888 0 1 1-1.254 1.255L7.26 10.61a.888.888 0 0 1 .16-1.382l4.043-4.042z"/></svg>';class f extends t.View{constructor(e){super(e);const i=e.t;this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",((e,t)=>e>0&&!t)),this._findInputView=this._createInputField(i("Find in text…")),this._replaceInputView=this._createInputField(i("Replace with…")),this._findButtonView=this._createButton({label:i("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._findPrevButtonView=this._createButton({label:i("Previous result"),class:"ck-button-prev",icon:h,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:i("Next result"),class:"ck-button-next",icon:h,keystroke:"F3",tooltip:!0}),this._optionsDropdown=this._createOptionsDropdown(),this._replaceButtonView=this._createButton({label:i("Replace"),class:"ck-button-replace",withText:!0}),this._replaceAllButtonView=this._createButton({label:i("Replace all"),class:"ck-button-replaceall",withText:!0}),this._findFieldsetView=this._createFindFieldset(),this._replaceFieldsetView=this._createReplaceFieldset(),this._focusTracker=new r.FocusTracker,this._keystrokes=new r.KeystrokeHandler,this._focusables=new t.ViewCollection,this._focusCycler=new t.FocusCycler({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:[new t.FormHeaderView(e,{label:i("Find and replace")}),this._findFieldsetView,this._replaceFieldsetView]}),(0,t.injectCssTransitionDisabler)(this)}render(){super.render(),(0,t.submitHandler)({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createFindFieldset(){const e=this.locale,i=new t.View(e);return this._findInputView.fieldView.on("input",(()=>{this.isDirty=!0})),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findPrevious:e})=>e)),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findNext:e})=>e)),this._injectFindResultsCounter(),i.setTemplate({tag:"fieldset",attributes:{class:["ck","ck-find-and-replace-form__find"]},children:[this._findInputView,this._findButtonView,this._findPrevButtonView,this._findNextButtonView]}),i}_onFindButtonExecute(){if(this._textToFind)this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly});else{const e=this.t;this._findInputView.errorText=e("Text to find must not be empty.")}}_injectFindResultsCounter(){const e=this.locale,i=e.t,n=this.bindTemplate,s=new t.View(e);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",((e,t)=>i("%0 of %1",[e,t]))),s.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",n.if("isDirty","ck-hidden")]},children:[{text:n.to("_resultsCounterText")}]});const o=()=>{const t=this._findInputView.fieldView.element;if(!t||!(0,r.isVisible)(t))return;const i=new r.Rect(s.element).width,n="ltr"===e.uiLanguageDirection?"paddingRight":"paddingLeft";t.style[n]=i?`calc( 2 * var(--ck-spacing-standard) + ${i}px )`:null};this.on("change:_resultsCounterText",o,{priority:"low"}),this.on("change:isDirty",o,{priority:"low"}),this._findInputView.template.children[0].children.push(s)}_createReplaceFieldset(){const e=this.locale,i=e.t,n=new t.View(e);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replaceAll:e},t)=>e&&t)),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",((e,t)=>e||!t?"":i("Tip: Find some text first in order to replace it."))),this._replaceButtonView.on("execute",(()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})})),this._replaceAllButtonView.on("execute",(()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()})),n.setTemplate({tag:"fieldset",attributes:{class:["ck","ck-find-and-replace-form__replace"]},children:[this._replaceInputView,this._optionsDropdown,this._replaceButtonView,this._replaceAllButtonView]}),n}_createOptionsDropdown(){const i=this.locale,n=i.t,s=(0,t.createDropdown)(i);s.class="ck-options-dropdown",s.buttonView.set({withText:!1,label:n("Show options"),icon:e.icons.cog,tooltip:!0});const o=new t.Model({withText:!0,label:n("Match case"),_isMatchCaseSwitch:!0}),a=new t.Model({withText:!0,label:n("Whole words only")});return o.bind("isOn").to(this,"_matchCase"),a.bind("isOn").to(this,"_wholeWordsOnly"),s.on("execute",(e=>{e.source._isMatchCaseSwitch?this._matchCase=!this._matchCase:this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0})),(0,t.addListToDropdown)(s,new r.Collection([{type:"switchbutton",model:o},{type:"switchbutton",model:a}])),s}_initFocusCycling(){[this._findInputView,this._findButtonView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._optionsDropdown,this._replaceButtonView,this._replaceAllButtonView].forEach((e=>{this._focusables.add(e),this._focusTracker.add(e.element)}))}_initKeystrokeHandling(){const e=e=>e.stopPropagation(),t=e=>{e.stopPropagation(),e.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",(e=>{t(e),this._findNextButtonView.fire("execute")})),this._keystrokes.set("shift+f3",(e=>{t(e),this._findPrevButtonView.fire("execute")})),this._keystrokes.set("enter",(e=>{const i=e.target;i===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e)):i!==this._replaceInputView.fieldView.element||this.isDirty||(this._replaceButtonView.fire("execute"),t(e))})),this._keystrokes.set("shift+enter",(e=>{e.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e))})),this._keystrokes.set("arrowright",e),this._keystrokes.set("arrowleft",e),this._keystrokes.set("arrowup",e),this._keystrokes.set("arrowdown",e),this.listenTo(this._findInputView.element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"}),this.listenTo(this._replaceInputView.element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"})}_createButton(e){const i=new t.ButtonView(this.locale);return i.set(e),i}_createInputField(e){const i=new t.LabeledFieldView(this.locale,t.createLabeledInputText);return i.label=e,i}}class u extends e.Plugin{static get pluginName(){return"FindAndReplaceUI"}constructor(e){super(e),this.formView=null}init(){const e=this.editor;e.ui.componentFactory.add("findAndReplace",(i=>{const n=(0,t.createDropdown)(i);return n.bind("isEnabled").to(e.commands.get("find")),n.once("change:isOpen",(()=>{this.formView=new f(e.locale),n.panelView.children.add(this.formView),this._setupFormView(this.formView)})),n.on("change:isOpen",((e,t,i)=>{i?(this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()):this.fire("searchReseted")}),{priority:"low"}),this._setupDropdownButton(n),n}))}_setupDropdownButton(e){const t=this.editor,i=t.locale.t;e.buttonView.set({icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.87 13.786 1.532-1.286 3.857 4.596a1 1 0 1 1-1.532 1.286l-3.857-4.596z"/><path d="M16.004 8.5a6.5 6.5 0 0 1-9.216 5.905c-1.154-.53-.863-1.415-.663-1.615.194-.194.564-.592 1.635-.141a4.5 4.5 0 0 0 5.89-5.904l-.104-.227 1.332-1.331c.045-.046.196-.041.224.007a6.47 6.47 0 0 1 .902 3.306zm-3.4-5.715c.562.305.742 1.106.354 1.494-.388.388-.995.414-1.476.178a4.5 4.5 0 0 0-6.086 5.882l.114.236-1.348 1.349c-.038.037-.17.022-.198-.023a6.5 6.5 0 0 1 5.54-9.9 6.469 6.469 0 0 1 3.1.784z"/><path d="M4.001 11.93.948 8.877a.2.2 0 0 1 .141-.341h6.106a.2.2 0 0 1 .141.341L4.283 11.93a.2.2 0 0 1-.282 0zm11.083-6.789 3.053 3.053a.2.2 0 0 1-.14.342H11.89a.2.2 0 0 1-.14-.342l3.052-3.053a.2.2 0 0 1 .282 0z"/></svg>',label:i("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),t.keystrokes.set("Ctrl+F",((t,i)=>{e.isEnabled&&(e.isOpen=!0,i())}))}_setupFormView(e){const t=this.editor.commands,i=this.editor.plugins.get("FindAndReplaceEditing").state,n={before:-1,same:0,after:1};e.bind("highlightOffset").to(i,"highlightedResult",(e=>e?Array.from(i.results).sort(((e,t)=>n[e.marker.getStart().compareWith(t.marker.getStart())])).indexOf(e)+1:0)),e.listenTo(i.results,"change",(()=>{e.matchCount=i.results.length})),e.bind("_areCommandsEnabled").to(t.get("findNext"),"isEnabled",t.get("findPrevious"),"isEnabled",t.get("replace"),"isEnabled",t.get("replaceAll"),"isEnabled",((e,t,i,n)=>({findNext:e,findPrevious:t,replace:i,replaceAll:n}))),e.delegate("findNext","findPrevious","replace","replaceAll").to(this),e.on("change:isDirty",((e,t,i)=>{i&&this.fire("searchReseted")}))}}class p extends e.Command{constructor(e,t){super(e),this.isEnabled=!0,this.affectsData=!1,this._state=t}execute(e,{matchCase:t,wholeWords:i}={}){const{editor:n}=this,{model:r}=n,s=n.plugins.get("FindAndReplaceUtils");let o;"string"==typeof e?(o=s.findByTextCallback(e,{matchCase:t,wholeWords:i}),this._state.searchText=e):o=e;const a=r.document.getRootNames().reduce(((e,t)=>s.updateFindResultFromRange(r.createRangeIn(r.document.getRoot(t)),r,o,e)),null);return this._state.clear(r),this._state.results.addMany(Array.from(a)),this._state.highlightedResult=a.get(0),"string"==typeof e&&(this._state.searchText=e),this._state.matchCase=!!t,this._state.matchWholeWords=!!i,{results:a,findCallback:o}}}class m extends e.Command{constructor(e,t){super(e),this.isEnabled=!0,this._state=t}execute(e,t){const{model:i}=this.editor;i.change((n=>{const r=t.marker.getRange();if("$graveyard"===r.root.rootName)return void this._state.results.remove(t);let s={};for(const e of r.getItems())if(e.is("$text")||e.is("$textProxy")){s=e.getAttributes();break}i.insertContent(n.createText(e,s),r),this._state.results.has(t)&&this._state.results.remove(t)}))}}class g extends m{execute(e,t){const{editor:i}=this,{model:n}=i,s=i.plugins.get("FindAndReplaceUtils"),o=t instanceof r.Collection?t:n.document.getRootNames().reduce(((e,i)=>s.updateFindResultFromRange(n.createRangeIn(n.document.getRoot(i)),n,s.findByTextCallback(t,this._state),e)),null);o.length&&n.change((()=>{[...o].forEach((t=>{super.execute(e,t)}))}))}}class k extends e.Command{constructor(e,t){super(e),this.affectsData=!1,this._state=t,this.isEnabled=!1,this.listenTo(this._state.results,"change",(()=>{this.isEnabled=this._state.results.length>1}))}refresh(){this.isEnabled=this._state.results.length>1}execute(){const e=this._state.results,t=e.getIndex(this._state.highlightedResult),i=t+1>=e.length?0:t+1;this._state.highlightedResult=this._state.results.get(i)}}class w extends k{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),t=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(t)}}class b{constructor(e){this.set("results",new r.Collection),this.set("highlightedResult",null),this.set("searchText",""),this.set("replaceText",""),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",((t,{removed:i,index:n})=>{if((i=Array.from(i)).length){let t=!1;if(e.change((n=>{for(const r of i)this.highlightedResult===r&&(t=!0),e.markers.has(r.marker.name)&&n.removeMarker(r.marker)})),t){const e=n>=this.results.length?0:n;this.highlightedResult=this.results.get(e)}}}))}clear(e){this.searchText="",e.change((t=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],n=e.markers.get(`findResultHighlighted:${i}`);n&&t.removeMarker(n)}[...this.results].forEach((({marker:e})=>{t.removeMarker(e)}))})),this.results.clear()}}(0,r.mix)(b,r.ObservableMixin);const _="object"==typeof global&&global&&global.Object===Object&&global;var v="object"==typeof self&&self&&self.Object===Object&&self;const x=_||v||Function("return this")();const y=x.Symbol;const T=function(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i<n;)r[i]=t(e[i],i,e);return r};const R=Array.isArray;var V=Object.prototype,C=V.hasOwnProperty,F=V.toString,I=y?y.toStringTag:void 0;const E=function(e){var t=C.call(e,I),i=e[I];try{e[I]=void 0;var n=!0}catch(e){}var r=F.call(e);return n&&(t?e[I]=i:delete e[I]),r};var A=Object.prototype.toString;const B=function(e){return A.call(e)};var N="[object Null]",S="[object Undefined]",O=y?y.toStringTag:void 0;const j=function(e){return null==e?void 0===e?S:N:O&&O in Object(e)?E(e):B(e)};const M=function(e){return null!=e&&"object"==typeof e};var D="[object Symbol]";const P=function(e){return"symbol"==typeof e||M(e)&&j(e)==D};var W=1/0,$=y?y.prototype:void 0,H=$?$.toString:void 0;const L=function e(t){if("string"==typeof t)return t;if(R(t))return T(t,e)+"";if(P(t))return H?H.call(t):"";var i=t+"";return"0"==i&&1/t==-W?"-0":i};const U=function(e){return null==e?"":L(e)};var Z=/[\\^$.*+?()[\]{}|]/g,z=RegExp(Z.source);const K=function(e){return(e=U(e))&&z.test(e)?e.replace(Z,"\\$&"):e};class Y extends e.Plugin{static get pluginName(){return"FindAndReplaceUtils"}updateFindResultFromRange(e,t,i,n){const s=n||new r.Collection;return t.change((n=>{[...e].forEach((({type:e,item:o})=>{if("elementStart"===e&&t.schema.checkChild(o,"$text")){const e=i({item:o,text:this.rangeToText(t.createRangeIn(o))});if(!e)return;e.forEach((e=>{const t=`findResult:${(0,r.uid)()}`,i=n.addMarker(t,{usingOperation:!1,affectsData:!1,range:n.createRange(n.createPositionAt(o,e.start),n.createPositionAt(o,e.end))}),a=function(e,t){const i=e.find((({marker:e})=>t.getStart().isBefore(e.getStart())));return i?e.getIndex(i):e.length}(s,i);s.add({id:t,label:e.label,marker:i},a)}))}}))})),s}rangeToText(e){return Array.from(e.getItems()).reduce(((e,t)=>t.is("text")||t.is("textProxy")?e+t.data:`${e}\n`),"")}findByTextCallback(e,t){let i="gu";t.matchCase||(i+="i");let n=`(${K(e)})`;if(t.wholeWords){const t="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+t).test(e)||(n=`(^|${t}|_)${n}`),new RegExp(t+"$").test(e)||(n=`${n}(?=_|${t}|$)`)}const r=new RegExp(n,i);return function({text:e}){return[...e.matchAll(r)].map(q)}}}function q(e){const t=e.length-1;let i=e.index;return 3===e.length&&(i+=e[1].length),{label:e[t],start:i,end:i+e[t].length}}function G(e){return"[object Range]"==Object.prototype.toString.apply(e)}function J(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}function X(e){return"[object Text]"==Object.prototype.toString.call(e)}const Q=["top","right","bottom","left","width","height"];class ee{constructor(e){const t=G(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),ne(e)||t)if(t){const t=ee.getDomRangeRects(e);te(this,ee.getBoundingRect(t))}else te(this,e.getBoundingClientRect());else if(J(e)){const{innerWidth:t,innerHeight:i}=e;te(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else te(this,e)}clone(){return new ee(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left),width:0,height:0};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new ee(t)}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(!ie(e)){let i=e.parentNode||e.commonAncestorContainer;for(;i&&!ie(i);){const e=new ee(i),n=t.getIntersection(e);if(!n)return null;n.getArea()<t.getArea()&&(t=n),i=i.parentNode}}return t}isEqual(e){for(const t of Q)if(this[t]!==e[t])return!1;return!0}contains(e){const t=this.getIntersection(e);return!(!t||!t.isEqual(e))}excludeScrollbarsAndBorders(){const e=this._source;let t,i,n;if(J(e))t=e.innerWidth-e.document.documentElement.clientWidth,i=e.innerHeight-e.document.documentElement.clientHeight,n=e.getComputedStyle(e.document.documentElement).direction;else{const r=function(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}(e);t=e.offsetWidth-e.clientWidth-r.left-r.right,i=e.offsetHeight-e.clientHeight-r.top-r.bottom,n=e.ownerDocument.defaultView.getComputedStyle(e).direction,this.left+=r.left,this.top+=r.top,this.right-=r.right,this.bottom-=r.bottom,this.width=this.right-this.left,this.height=this.bottom-this.top}return this.width-=t,"ltr"===n?this.right-=t:this.left+=t,this.height-=i,this.bottom-=i,this}static getDomRangeRects(e){const t=[],i=Array.from(e.getClientRects());if(i.length)for(const e of i)t.push(new ee(e));else{let i=e.startContainer;X(i)&&(i=i.parentNode);const n=new ee(i.getBoundingClientRect());n.right=n.left,n.width=0,t.push(n)}return t}static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let i=0;for(const n of e)i++,t.left=Math.min(t.left,n.left),t.top=Math.min(t.top,n.top),t.right=Math.max(t.right,n.right),t.bottom=Math.max(t.bottom,n.bottom);return 0==i?null:(t.width=t.right-t.left,t.height=t.bottom-t.top,new ee(t))}}function te(e,t){for(const i of Q)e[i]=t[i]}function ie(e){return!!ne(e)&&e===e.ownerDocument.body}function ne(e){return null!==e&&"object"==typeof e&&1===e.nodeType&&"function"==typeof e.getBoundingClientRect}function re(e,t,i){const n=t.clone().moveBy(0,i),r=t.clone().moveBy(0,-i),s=new ee(e).excludeScrollbarsAndBorders();if(![r,n].every((e=>s.contains(e)))){let{scrollX:o,scrollY:a}=e;ae(r,s)?a-=s.top-t.top+i:oe(n,s)&&(a+=t.bottom-s.bottom+i),ce(t,s)?o-=s.left-t.left+i:le(t,s)&&(o+=t.right-s.right+i),e.scrollTo(o,a)}}function se(e,t){const i=de(e);let n,r;for(;e!=i.document.body;)r=t(),n=new ee(e).excludeScrollbarsAndBorders(),n.contains(r)||(ae(r,n)?e.scrollTop-=n.top-r.top:oe(r,n)&&(e.scrollTop+=r.bottom-n.bottom),ce(r,n)?e.scrollLeft-=n.left-r.left:le(r,n)&&(e.scrollLeft+=r.right-n.right)),e=e.parentNode}function oe(e,t){return e.bottom>t.bottom}function ae(e,t){return e.top<t.top}function ce(e,t){return e.left<t.left}function le(e,t){return e.right>t.right}function de(e){return G(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function he(e){if(G(e)){let t=e.commonAncestorContainer;return X(t)&&(t=t.parentNode),t}return e.parentNode}function fe(e,t){const i=de(e),n=new ee(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new ee(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const ue=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const pe=function(){return x.Date.now()};var me=/\s/;const ge=function(e){for(var t=e.length;t--&&me.test(e.charAt(t)););return t};var ke=/^\s+/;const we=function(e){return e?e.slice(0,ge(e)+1).replace(ke,""):e};var be=NaN,_e=/^[-+]0x[0-9a-f]+$/i,ve=/^0b[01]+$/i,xe=/^0o[0-7]+$/i,ye=parseInt;const Te=function(e){if("number"==typeof e)return e;if(P(e))return be;if(ue(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ue(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=we(e);var i=ve.test(e);return i||xe.test(e)?ye(e.slice(2),i?2:8):_e.test(e)?be:+e};var Re="Expected a function",Ve=Math.max,Ce=Math.min;const Fe=function(e,t,i){var n,r,s,o,a,c,l=0,d=!1,h=!1,f=!0;if("function"!=typeof e)throw new TypeError(Re);function u(t){var i=n,s=r;return n=r=void 0,l=t,o=e.apply(s,i)}function p(e){var i=e-c;return void 0===c||i>=t||i<0||h&&e-l>=s}function m(){var e=pe();if(p(e))return g(e);a=setTimeout(m,function(e){var i=t-(e-c);return h?Ce(i,s-(e-l)):i}(e))}function g(e){return a=void 0,f&&n?u(e):(n=r=void 0,o)}function k(){var e=pe(),i=p(e);if(n=arguments,r=this,c=e,i){if(void 0===a)return function(e){return l=e,a=setTimeout(m,t),d?u(e):o}(c);if(h)return clearTimeout(a),a=setTimeout(m,t),u(c)}return void 0===a&&(a=setTimeout(m,t)),o}return t=Te(t)||0,ue(i)&&(d=!!i.leading,s=(h="maxWait"in i)?Ve(Te(i.maxWait)||0,t):s,f="trailing"in i?!!i.trailing:f),k.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=r=a=void 0},k.flush=function(){return void 0===a?o:g(pe())},k};var Ie=i(299),Ee={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};o()(Ie.Z,Ee);Ie.Z.locals;class Ae extends e.Plugin{static get requires(){return[Y]}static get pluginName(){return"FindAndReplaceEditing"}init(){this._activeResults=null,this.state=new b(this.editor.model),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",((e,t,i,n)=>{const{model:r}=this.editor;r.change((e=>{if(n){const t=n.marker.name.split(":")[1],i=r.markers.get(`findResultHighlighted:${t}`);i&&e.removeMarker(i)}if(i){const t=i.marker.name.split(":")[1];e.addMarker(`findResultHighlighted:${t}`,{usingOperation:!1,affectsData:!1,range:i.marker.getRange()})}}))}));const e=Fe(function(e,t,i){if(i){const e=this.editor.editing.view.domConverter,t=this.editor.editing.mapper.toViewRange(i.marker.getRange());!function({target:e,viewportOffset:t=0}){const i=de(e);let n=i,r=null;for(;n;){let s;s=he(n==i?e:r),se(s,(()=>fe(e,n)));const o=fe(e,n);if(re(n,o,t),n.parent!=n){if(r=n.frameElement,n=n.parent,!r)return}else n=null}}({target:e.viewRangeToDom(t),viewportOffset:40})}}.bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel)}find(e){const{editor:t}=this,{model:i}=t,{findCallback:n,results:r}=t.execute("find",e);return this._activeResults=r,this.listenTo(i.document,"change:data",(()=>function(e,t,i){const n=new Set,r=new Set,s=t.model;s.document.differ.getChanges().forEach((e=>{"$text"===e.name||s.schema.isInline(e.position.nodeAfter)?(n.add(e.position.parent),[...s.markers.getMarkersAtPosition(e.position)].forEach((e=>{r.add(e.name)}))):"insert"===e.type&&n.add(e.position.nodeAfter)})),s.document.differ.getChangedMarkers().forEach((({name:e,data:{newRange:t}})=>{t&&"$graveyard"===t.start.root.rootName&&r.add(e)})),n.forEach((e=>{[...s.markers.getMarkersIntersectingRange(s.createRangeIn(e))].forEach((e=>r.add(e.name)))})),s.change((t=>{r.forEach((i=>{e.has(i)&&e.remove(i),t.removeMarker(i)}))})),n.forEach((n=>{t.plugins.get("FindAndReplaceUtils").updateFindResultFromRange(s.createRangeOn(n),s,i,e)}))}(this._activeResults,t,n))),this._activeResults}stop(){this._activeResults&&(this.stopListening(this.editor.model.document),this.state.clear(this.editor.model),this._activeResults=null)}_defineCommands(){this.editor.commands.add("find",new p(this.editor,this.state)),this.editor.commands.add("findNext",new k(this.editor,this.state)),this.editor.commands.add("findPrevious",new w(this.editor,this.state)),this.editor.commands.add("replace",new m(this.editor,this.state)),this.editor.commands.add("replaceAll",new g(this.editor,this.state))}_defineConverters(){const{editor:e}=this;e.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":t}}}}),e.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result_selected"],attributes:{"data-find-result":t}}}})}}class Be extends e.Plugin{static get requires(){return[Ae,u]}static get pluginName(){return"FindAndReplace"}init(){const e=this.editor.plugins.get("FindAndReplaceUI"),t=this.editor.plugins.get("FindAndReplaceEditing"),i=t.state;e.on("findNext",((e,t)=>{t?(i.searchText=t.searchText,this.editor.execute("find",t.searchText,t)):this.editor.execute("findNext")})),e.on("findPrevious",((e,t)=>{t&&i.searchText!==t.searchText?this.editor.execute("find",t.searchText):this.editor.execute("findPrevious")})),e.on("replace",((e,t)=>{i.searchText!==t.searchText&&this.editor.execute("find",t.searchText);const n=i.highlightedResult;n&&this.editor.execute("replace",t.replaceText,n)})),e.on("replaceAll",((e,t)=>{i.searchText!==t.searchText&&this.editor.execute("find",t.searchText),this.editor.execute("replaceAll",t.replaceText,i.results)})),e.on("searchReseted",(()=>{i.clear(this.editor.model),t.stop()}))}}})(),(window.CKEditor5=window.CKEditor5||{}).findAndReplace=n})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e){const t=e.ug=e.ug||{};t.dictionary=Object.assign(t.dictionary||{},{Find:"ئىزدە","Find and replace":"ئىزدە ۋە ئالماشتۇر","Find in text…":"تېكىستتىن ئىزدە…","Match case":"چوڭ كىچىك ھەرپنى پەرقلەندۈر","Next result":"كېيىنكى نەتىجە","Previous result":"ئالدىنقى نەتىجە",Replace:"ئالماشتۇر","Replace all":"ھەممىنى ئالماشتۇر","Replace with…":"ئالماشتۇرۇلۇدىغىنى…","Show options":"تاللانمىلارنى كۆرسەت","Text to find must not be empty.":"ئىزدەيدىغان تېكىست بوش قالدۇرۇلمايدۇ.","Tip: Find some text first in order to replace it.":"ئەسكەرتىش: ئاۋال ئىزدەپ ئاندىن ئالماشتۇرىدۇ.","Whole words only":"سۆزلا"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Copyright (c) 2003-2022, 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://www.transifex.com/ckeditor/teams/11143/ug/)\n"
|
|
16
|
+
"Language: ug\n"
|
|
17
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
18
|
+
|
|
19
|
+
msgctxt "The tooltip of a find and replace button in the toolbar. Also, the title of the find and replace form."
|
|
20
|
+
msgid "Find and replace"
|
|
21
|
+
msgstr "ئىزدە ۋە ئالماشتۇر"
|
|
22
|
+
|
|
23
|
+
msgctxt "The label for the searched text in the find and replace dropdown."
|
|
24
|
+
msgid "Find in text…"
|
|
25
|
+
msgstr "تېكىستتىن ئىزدە…"
|
|
26
|
+
|
|
27
|
+
msgctxt "The label for the find action button in the find and replace dropdown."
|
|
28
|
+
msgid "Find"
|
|
29
|
+
msgstr "ئىزدە"
|
|
30
|
+
|
|
31
|
+
msgctxt "The label for the previous result button in the find and replace dropdown."
|
|
32
|
+
msgid "Previous result"
|
|
33
|
+
msgstr "ئالدىنقى نەتىجە"
|
|
34
|
+
|
|
35
|
+
msgctxt "The label for the previous result button in the find and replace dropdown."
|
|
36
|
+
msgid "Next result"
|
|
37
|
+
msgstr "كېيىنكى نەتىجە"
|
|
38
|
+
|
|
39
|
+
msgctxt "The label for the (single) replace action button in the find and replace dropdown."
|
|
40
|
+
msgid "Replace"
|
|
41
|
+
msgstr "ئالماشتۇر"
|
|
42
|
+
|
|
43
|
+
msgctxt "The label for the replace all action button in the find and replace dropdown."
|
|
44
|
+
msgid "Replace all"
|
|
45
|
+
msgstr "ھەممىنى ئالماشتۇر"
|
|
46
|
+
|
|
47
|
+
msgctxt "The label for the match case checkbox in the find and replace dropdown."
|
|
48
|
+
msgid "Match case"
|
|
49
|
+
msgstr "چوڭ كىچىك ھەرپنى پەرقلەندۈر"
|
|
50
|
+
|
|
51
|
+
msgctxt "The label for the whole words only checkbox in the find and replace dropdown."
|
|
52
|
+
msgid "Whole words only"
|
|
53
|
+
msgstr "سۆزلا"
|
|
54
|
+
|
|
55
|
+
msgctxt "The label for the text replacement in the find and replace dropdown."
|
|
56
|
+
msgid "Replace with…"
|
|
57
|
+
msgstr "ئالماشتۇرۇلۇدىغىنى…"
|
|
58
|
+
|
|
59
|
+
msgctxt "An error text displayed when user attempted to find an empty text."
|
|
60
|
+
msgid "Text to find must not be empty."
|
|
61
|
+
msgstr "ئىزدەيدىغان تېكىست بوش قالدۇرۇلمايدۇ."
|
|
62
|
+
|
|
63
|
+
msgctxt "A message displayed next to the replace field when disabled but user tries to use it."
|
|
64
|
+
msgid "Tip: Find some text first in order to replace it."
|
|
65
|
+
msgstr "ئەسكەرتىش: ئاۋال ئىزدەپ ئاندىن ئالماشتۇرىدۇ."
|
|
66
|
+
|
|
67
|
+
msgctxt "The label and a tooltip of the options dropdown button in the find and replace form."
|
|
68
|
+
msgid "Show options"
|
|
69
|
+
msgstr "تاللانمىلارنى كۆرسەت"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-find-and-replace",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "36.0.1",
|
|
4
4
|
"description": "Find and replace feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,28 +12,28 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ckeditor/ckeditor5-ui": "^
|
|
16
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
17
|
-
"ckeditor5": "^
|
|
15
|
+
"@ckeditor/ckeditor5-ui": "^36.0.1",
|
|
16
|
+
"@ckeditor/ckeditor5-utils": "^36.0.1",
|
|
17
|
+
"ckeditor5": "^36.0.1",
|
|
18
18
|
"lodash-es": "^4.17.15"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
22
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
23
|
-
"@ckeditor/ckeditor5-core": "^
|
|
24
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
25
|
-
"@ckeditor/ckeditor5-editor-decoupled": "^
|
|
26
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
27
|
-
"@ckeditor/ckeditor5-essentials": "^
|
|
28
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
29
|
-
"@ckeditor/ckeditor5-font": "^
|
|
30
|
-
"@ckeditor/ckeditor5-highlight": "^
|
|
31
|
-
"@ckeditor/ckeditor5-link": "^
|
|
32
|
-
"@ckeditor/ckeditor5-list": "^
|
|
33
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
34
|
-
"@ckeditor/ckeditor5-source-editing": "^
|
|
35
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
36
|
-
"@ckeditor/ckeditor5-undo": "^
|
|
21
|
+
"@ckeditor/ckeditor5-dev-utils": "^32.0.0",
|
|
22
|
+
"@ckeditor/ckeditor5-basic-styles": "^36.0.1",
|
|
23
|
+
"@ckeditor/ckeditor5-core": "^36.0.1",
|
|
24
|
+
"@ckeditor/ckeditor5-editor-classic": "^36.0.1",
|
|
25
|
+
"@ckeditor/ckeditor5-editor-decoupled": "^36.0.1",
|
|
26
|
+
"@ckeditor/ckeditor5-engine": "^36.0.1",
|
|
27
|
+
"@ckeditor/ckeditor5-essentials": "^36.0.1",
|
|
28
|
+
"@ckeditor/ckeditor5-heading": "^36.0.1",
|
|
29
|
+
"@ckeditor/ckeditor5-font": "^36.0.1",
|
|
30
|
+
"@ckeditor/ckeditor5-highlight": "^36.0.1",
|
|
31
|
+
"@ckeditor/ckeditor5-link": "^36.0.1",
|
|
32
|
+
"@ckeditor/ckeditor5-list": "^36.0.1",
|
|
33
|
+
"@ckeditor/ckeditor5-paragraph": "^36.0.1",
|
|
34
|
+
"@ckeditor/ckeditor5-source-editing": "^36.0.1",
|
|
35
|
+
"@ckeditor/ckeditor5-theme-lark": "^36.0.1",
|
|
36
|
+
"@ckeditor/ckeditor5-undo": "^36.0.1",
|
|
37
37
|
"webpack": "^5.58.1",
|
|
38
38
|
"webpack-cli": "^4.9.0"
|
|
39
39
|
},
|
package/src/findandreplace.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import { updateFindResultFromRange } from './utils';
|
|
12
11
|
import FindCommand from './findcommand';
|
|
13
12
|
import ReplaceCommand from './replacecommand';
|
|
14
13
|
import ReplaceAllCommand from './replaceallcommand';
|
|
15
14
|
import FindNextCommand from './findnextcommand';
|
|
16
15
|
import FindPreviousCommand from './findpreviouscommand';
|
|
17
16
|
import FindAndReplaceState from './findandreplacestate';
|
|
17
|
+
import FindAndReplaceUtils from './findandreplaceutils';
|
|
18
18
|
|
|
19
19
|
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
20
20
|
import { scrollViewportToShowTarget } from '@ckeditor/ckeditor5-utils/src/dom/scroll';
|
|
@@ -26,9 +26,10 @@ import '../theme/findandreplace.css';
|
|
|
26
26
|
const HIGHLIGHT_CLASS = 'ck-find-result_selected';
|
|
27
27
|
|
|
28
28
|
// Reacts to document changes in order to update search list.
|
|
29
|
-
function onDocumentChange( results,
|
|
29
|
+
function onDocumentChange( results, editor, searchCallback ) {
|
|
30
30
|
const changedNodes = new Set();
|
|
31
31
|
const removedMarkers = new Set();
|
|
32
|
+
const model = editor.model;
|
|
32
33
|
|
|
33
34
|
const changes = model.document.differ.getChanges();
|
|
34
35
|
|
|
@@ -73,7 +74,8 @@ function onDocumentChange( results, model, searchCallback ) {
|
|
|
73
74
|
|
|
74
75
|
// Run search callback again on updated nodes.
|
|
75
76
|
changedNodes.forEach( nodeToCheck => {
|
|
76
|
-
|
|
77
|
+
const findAndReplaceUtils = editor.plugins.get( 'FindAndReplaceUtils' );
|
|
78
|
+
findAndReplaceUtils.updateFindResultFromRange( model.createRangeOn( nodeToCheck ), model, searchCallback, results );
|
|
77
79
|
} );
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -83,6 +85,13 @@ function onDocumentChange( results, model, searchCallback ) {
|
|
|
83
85
|
* @extends module:core/plugin~Plugin
|
|
84
86
|
*/
|
|
85
87
|
export default class FindAndReplaceEditing extends Plugin {
|
|
88
|
+
/**
|
|
89
|
+
* @inheritDoc
|
|
90
|
+
*/
|
|
91
|
+
static get requires() {
|
|
92
|
+
return [ FindAndReplaceUtils ];
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
/**
|
|
87
96
|
* @inheritDoc
|
|
88
97
|
*/
|
|
@@ -173,7 +182,7 @@ export default class FindAndReplaceEditing extends Plugin {
|
|
|
173
182
|
this._activeResults = results;
|
|
174
183
|
|
|
175
184
|
// @todo: handle this listener, another copy is in findcommand.js file.
|
|
176
|
-
this.listenTo( model.document, 'change:data', () => onDocumentChange( this._activeResults,
|
|
185
|
+
this.listenTo( model.document, 'change:data', () => onDocumentChange( this._activeResults, editor, findCallback ) );
|
|
177
186
|
|
|
178
187
|
return this._activeResults;
|
|
179
188
|
}
|
package/src/findandreplaceui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
|
|
@@ -52,11 +52,17 @@ export default class FindAndReplaceUI extends Plugin {
|
|
|
52
52
|
// Register the toolbar dropdown component.
|
|
53
53
|
editor.ui.componentFactory.add( 'findAndReplace', locale => {
|
|
54
54
|
const dropdown = createDropdown( locale );
|
|
55
|
-
const formView = this.formView = new FindAndReplaceFormView( editor.locale );
|
|
56
55
|
|
|
57
56
|
// Dropdown should be disabled when in source editing mode. See #10001.
|
|
58
57
|
dropdown.bind( 'isEnabled' ).to( editor.commands.get( 'find' ) );
|
|
59
|
-
|
|
58
|
+
|
|
59
|
+
dropdown.once( 'change:isOpen', () => {
|
|
60
|
+
this.formView = new FindAndReplaceFormView( editor.locale );
|
|
61
|
+
|
|
62
|
+
dropdown.panelView.children.add( this.formView );
|
|
63
|
+
|
|
64
|
+
this._setupFormView( this.formView );
|
|
65
|
+
} );
|
|
60
66
|
|
|
61
67
|
// Every time a dropdown is opened, the search text field should get focused and selected for better UX.
|
|
62
68
|
// Note: Using the low priority here to make sure the following listener starts working after
|
|
@@ -68,19 +74,18 @@ export default class FindAndReplaceUI extends Plugin {
|
|
|
68
74
|
// and no longer should be marked in the content.
|
|
69
75
|
dropdown.on( 'change:isOpen', ( event, name, isOpen ) => {
|
|
70
76
|
if ( isOpen ) {
|
|
71
|
-
formView.disableCssTransitions();
|
|
77
|
+
this.formView.disableCssTransitions();
|
|
72
78
|
|
|
73
|
-
formView.reset();
|
|
74
|
-
formView._findInputView.fieldView.select();
|
|
79
|
+
this.formView.reset();
|
|
80
|
+
this.formView._findInputView.fieldView.select();
|
|
75
81
|
|
|
76
|
-
formView.enableCssTransitions();
|
|
82
|
+
this.formView.enableCssTransitions();
|
|
77
83
|
} else {
|
|
78
84
|
this.fire( 'searchReseted' );
|
|
79
85
|
}
|
|
80
86
|
}, { priority: 'low' } );
|
|
81
87
|
|
|
82
88
|
this._setupDropdownButton( dropdown );
|
|
83
|
-
this._setupFormView( formView );
|
|
84
89
|
|
|
85
90
|
return dropdown;
|
|
86
91
|
} );
|
|
@@ -104,8 +109,10 @@ export default class FindAndReplaceUI extends Plugin {
|
|
|
104
109
|
} );
|
|
105
110
|
|
|
106
111
|
editor.keystrokes.set( 'Ctrl+F', ( data, cancelEvent ) => {
|
|
107
|
-
dropdown.
|
|
108
|
-
|
|
112
|
+
if ( dropdown.isEnabled ) {
|
|
113
|
+
dropdown.isOpen = true;
|
|
114
|
+
cancelEvent();
|
|
115
|
+
}
|
|
109
116
|
} );
|
|
110
117
|
}
|
|
111
118
|
|
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* @module find-and-replace/findandreplaceutils
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
+
import { Collection, uid } from 'ckeditor5/src/utils';
|
|
12
|
+
import { escapeRegExp } from 'lodash-es';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A set of helpers related to find and replace.
|
|
16
|
+
*/
|
|
17
|
+
export default class FindAndReplaceUtils extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName() {
|
|
22
|
+
return 'FindAndReplaceUtils';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Executes findCallback and updates search results list.
|
|
27
|
+
*
|
|
28
|
+
* @param {module:engine/model/range~Range} range The model range to scan for matches.
|
|
29
|
+
* @param {module:engine/model/model~Model} model The model.
|
|
30
|
+
* @param {Function} findCallback The callback that should return `true` if provided text matches the search term.
|
|
31
|
+
* @param {module:utils/collection~Collection} [startResults] An optional collection of find matches that the function should
|
|
32
|
+
* start with. This would be a collection returned by a previous `updateFindResultFromRange()` call.
|
|
33
|
+
* @returns {module:utils/collection~Collection} A collection of objects describing find match.
|
|
34
|
+
*
|
|
35
|
+
* An example structure:
|
|
36
|
+
*
|
|
37
|
+
* ```js
|
|
38
|
+
* {
|
|
39
|
+
* id: resultId,
|
|
40
|
+
* label: foundItem.label,
|
|
41
|
+
* marker
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
updateFindResultFromRange( range, model, findCallback, startResults ) {
|
|
46
|
+
const results = startResults || new Collection();
|
|
47
|
+
|
|
48
|
+
model.change( writer => {
|
|
49
|
+
[ ...range ].forEach( ( { type, item } ) => {
|
|
50
|
+
if ( type === 'elementStart' ) {
|
|
51
|
+
if ( model.schema.checkChild( item, '$text' ) ) {
|
|
52
|
+
const foundItems = findCallback( {
|
|
53
|
+
item,
|
|
54
|
+
text: this.rangeToText( model.createRangeIn( item ) )
|
|
55
|
+
} );
|
|
56
|
+
|
|
57
|
+
if ( !foundItems ) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
foundItems.forEach( foundItem => {
|
|
62
|
+
const resultId = `findResult:${ uid() }`;
|
|
63
|
+
const marker = writer.addMarker( resultId, {
|
|
64
|
+
usingOperation: false,
|
|
65
|
+
affectsData: false,
|
|
66
|
+
range: writer.createRange(
|
|
67
|
+
writer.createPositionAt( item, foundItem.start ),
|
|
68
|
+
writer.createPositionAt( item, foundItem.end )
|
|
69
|
+
)
|
|
70
|
+
} );
|
|
71
|
+
|
|
72
|
+
const index = findInsertIndex( results, marker );
|
|
73
|
+
|
|
74
|
+
results.add(
|
|
75
|
+
{
|
|
76
|
+
id: resultId,
|
|
77
|
+
label: foundItem.label,
|
|
78
|
+
marker
|
|
79
|
+
},
|
|
80
|
+
index
|
|
81
|
+
);
|
|
82
|
+
} );
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} );
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
return results;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns text representation of a range. The returned text length should be the same as range length.
|
|
93
|
+
* In order to achieve this, this function will replace inline elements (text-line) as new line character ("\n").
|
|
94
|
+
*
|
|
95
|
+
* @param {module:engine/model/range~Range} range The model range.
|
|
96
|
+
* @returns {String} The text content of the provided range.
|
|
97
|
+
*/
|
|
98
|
+
rangeToText( range ) {
|
|
99
|
+
return Array.from( range.getItems() ).reduce( ( rangeText, node ) => {
|
|
100
|
+
// Trim text to a last occurrence of an inline element and update range start.
|
|
101
|
+
if ( !( node.is( 'text' ) || node.is( 'textProxy' ) ) ) {
|
|
102
|
+
// Editor has only one inline element defined in schema: `<softBreak>` which is treated as new line character in blocks.
|
|
103
|
+
// Special handling might be needed for other inline elements (inline widgets).
|
|
104
|
+
return `${ rangeText }\n`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return rangeText + node.data;
|
|
108
|
+
}, '' );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Creates a text matching callback for a specified search term and matching options.
|
|
113
|
+
*
|
|
114
|
+
* @param {String} searchTerm The search term.
|
|
115
|
+
* @param {Object} [options] Matching options.
|
|
116
|
+
* @param {Boolean} [options.matchCase=false] If set to `true` letter casing will be ignored.
|
|
117
|
+
* @param {Boolean} [options.wholeWords=false] If set to `true` only whole words that match `callbackOrText` will be matched.
|
|
118
|
+
* @returns {Function}
|
|
119
|
+
*/
|
|
120
|
+
findByTextCallback( searchTerm, options ) {
|
|
121
|
+
let flags = 'gu';
|
|
122
|
+
|
|
123
|
+
if ( !options.matchCase ) {
|
|
124
|
+
flags += 'i';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let regExpQuery = `(${ escapeRegExp( searchTerm ) })`;
|
|
128
|
+
|
|
129
|
+
if ( options.wholeWords ) {
|
|
130
|
+
const nonLetterGroup = '[^a-zA-Z\u00C0-\u024F\u1E00-\u1EFF]';
|
|
131
|
+
|
|
132
|
+
if ( !new RegExp( '^' + nonLetterGroup ).test( searchTerm ) ) {
|
|
133
|
+
regExpQuery = `(^|${ nonLetterGroup }|_)${ regExpQuery }`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if ( !new RegExp( nonLetterGroup + '$' ).test( searchTerm ) ) {
|
|
137
|
+
regExpQuery = `${ regExpQuery }(?=_|${ nonLetterGroup }|$)`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const regExp = new RegExp( regExpQuery, flags );
|
|
142
|
+
|
|
143
|
+
function findCallback( { text } ) {
|
|
144
|
+
const matches = [ ...text.matchAll( regExp ) ];
|
|
145
|
+
|
|
146
|
+
return matches.map( regexpMatchToFindResult );
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return findCallback;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Finds the appropriate index in the resultsList Collection.
|
|
154
|
+
function findInsertIndex( resultsList, markerToInsert ) {
|
|
155
|
+
const result = resultsList.find( ( { marker } ) => {
|
|
156
|
+
return markerToInsert.getStart().isBefore( marker.getStart() );
|
|
157
|
+
} );
|
|
158
|
+
|
|
159
|
+
return result ? resultsList.getIndex( result ) : resultsList.length;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Maps RegExp match result to find result.
|
|
163
|
+
function regexpMatchToFindResult( matchResult ) {
|
|
164
|
+
const lastGroupIndex = matchResult.length - 1;
|
|
165
|
+
|
|
166
|
+
let startOffset = matchResult.index;
|
|
167
|
+
|
|
168
|
+
// Searches with match all flag have an extra matching group with empty string or white space matched before the word.
|
|
169
|
+
// If the search term starts with the space already, there is no extra group even with match all flag on.
|
|
170
|
+
if ( matchResult.length === 3 ) {
|
|
171
|
+
startOffset += matchResult[ 1 ].length;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
label: matchResult[ lastGroupIndex ],
|
|
176
|
+
start: startOffset,
|
|
177
|
+
end: startOffset + matchResult[ lastGroupIndex ].length
|
|
178
|
+
};
|
|
179
|
+
}
|
package/src/findcommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
import { updateFindResultFromRange, findByTextCallback } from './utils';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* The find command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
|
@@ -53,12 +52,13 @@ export default class FindCommand extends Command {
|
|
|
53
52
|
execute( callbackOrText, { matchCase, wholeWords } = {} ) {
|
|
54
53
|
const { editor } = this;
|
|
55
54
|
const { model } = editor;
|
|
55
|
+
const findAndReplaceUtils = editor.plugins.get( 'FindAndReplaceUtils' );
|
|
56
56
|
|
|
57
57
|
let findCallback;
|
|
58
58
|
|
|
59
59
|
// Allow to execute `find()` on a plugin with a keyword only.
|
|
60
60
|
if ( typeof callbackOrText === 'string' ) {
|
|
61
|
-
findCallback = findByTextCallback( callbackOrText, { matchCase, wholeWords } );
|
|
61
|
+
findCallback = findAndReplaceUtils.findByTextCallback( callbackOrText, { matchCase, wholeWords } );
|
|
62
62
|
|
|
63
63
|
this._state.searchText = callbackOrText;
|
|
64
64
|
} else {
|
|
@@ -67,7 +67,7 @@ export default class FindCommand extends Command {
|
|
|
67
67
|
|
|
68
68
|
// Initial search is done on all nodes in all roots inside the content.
|
|
69
69
|
const results = model.document.getRootNames()
|
|
70
|
-
.reduce( ( ( currentResults, rootName ) => updateFindResultFromRange(
|
|
70
|
+
.reduce( ( ( currentResults, rootName ) => findAndReplaceUtils.updateFindResultFromRange(
|
|
71
71
|
model.createRangeIn( model.document.getRoot( rootName ) ),
|
|
72
72
|
model,
|
|
73
73
|
findCallback,
|
package/src/findnextcommand.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
|
|
@@ -8,3 +8,4 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export { default as FindAndReplace } from './findandreplace';
|
|
11
|
+
export { default as FindAndReplaceUtils } from './findandreplaceutils';
|
package/src/replaceallcommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* @module find-and-replace/replaceallcommand
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { updateFindResultFromRange, findByTextCallback } from './utils';
|
|
11
10
|
import { Collection } from 'ckeditor5/src/utils';
|
|
12
11
|
import ReplaceCommand from './replacecommand';
|
|
13
12
|
|
|
@@ -39,13 +38,14 @@ export default class ReplaceAllCommand extends ReplaceCommand {
|
|
|
39
38
|
execute( newText, textToReplace ) {
|
|
40
39
|
const { editor } = this;
|
|
41
40
|
const { model } = editor;
|
|
41
|
+
const findAndReplaceUtils = editor.plugins.get( 'FindAndReplaceUtils' );
|
|
42
42
|
|
|
43
43
|
const results = textToReplace instanceof Collection ?
|
|
44
44
|
textToReplace : model.document.getRootNames()
|
|
45
|
-
.reduce( ( ( currentResults, rootName ) => updateFindResultFromRange(
|
|
45
|
+
.reduce( ( ( currentResults, rootName ) => findAndReplaceUtils.updateFindResultFromRange(
|
|
46
46
|
model.createRangeIn( model.document.getRoot( rootName ) ),
|
|
47
47
|
model,
|
|
48
|
-
findByTextCallback( textToReplace, this._state ),
|
|
48
|
+
findAndReplaceUtils.findByTextCallback( textToReplace, this._state ),
|
|
49
49
|
currentResults
|
|
50
50
|
) ), null );
|
|
51
51
|
|
package/src/replacecommand.js
CHANGED
package/theme/findandreplace.css
CHANGED
package/src/utils.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2022, 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
|
-
/**
|
|
7
|
-
* @module find-and-replace/utils
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { uid, Collection } from 'ckeditor5/src/utils';
|
|
11
|
-
import { escapeRegExp } from 'lodash-es';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Executes findCallback and updates search results list.
|
|
15
|
-
*
|
|
16
|
-
* @param {module:engine/model/range~Range} range The model range to scan for matches.
|
|
17
|
-
* @param {module:engine/model/model~Model} model The model.
|
|
18
|
-
* @param {Function} findCallback The callback that should return `true` if provided text matches the search term.
|
|
19
|
-
* @param {module:utils/collection~Collection} [startResults] An optional collection of find matches that the function should
|
|
20
|
-
* start with. This would be a collection returned by a previous `updateFindResultFromRange()` call.
|
|
21
|
-
* @returns {module:utils/collection~Collection} A collection of objects describing find match.
|
|
22
|
-
*
|
|
23
|
-
* An example structure:
|
|
24
|
-
*
|
|
25
|
-
* ```js
|
|
26
|
-
* {
|
|
27
|
-
* id: resultId,
|
|
28
|
-
* label: foundItem.label,
|
|
29
|
-
* marker
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export function updateFindResultFromRange( range, model, findCallback, startResults ) {
|
|
34
|
-
const results = startResults || new Collection();
|
|
35
|
-
|
|
36
|
-
model.change( writer => {
|
|
37
|
-
[ ...range ].forEach( ( { type, item } ) => {
|
|
38
|
-
if ( type === 'elementStart' ) {
|
|
39
|
-
if ( model.schema.checkChild( item, '$text' ) ) {
|
|
40
|
-
const foundItems = findCallback( {
|
|
41
|
-
item,
|
|
42
|
-
text: rangeToText( model.createRangeIn( item ) )
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
if ( !foundItems ) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
foundItems.forEach( foundItem => {
|
|
50
|
-
const resultId = `findResult:${ uid() }`;
|
|
51
|
-
const marker = writer.addMarker( resultId, {
|
|
52
|
-
usingOperation: false,
|
|
53
|
-
affectsData: false,
|
|
54
|
-
range: writer.createRange(
|
|
55
|
-
writer.createPositionAt( item, foundItem.start ),
|
|
56
|
-
writer.createPositionAt( item, foundItem.end )
|
|
57
|
-
)
|
|
58
|
-
} );
|
|
59
|
-
|
|
60
|
-
const index = findInsertIndex( results, marker );
|
|
61
|
-
|
|
62
|
-
results.add(
|
|
63
|
-
{
|
|
64
|
-
id: resultId,
|
|
65
|
-
label: foundItem.label,
|
|
66
|
-
marker
|
|
67
|
-
},
|
|
68
|
-
index
|
|
69
|
-
);
|
|
70
|
-
} );
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} );
|
|
74
|
-
} );
|
|
75
|
-
|
|
76
|
-
return results;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Returns text representation of a range. The returned text length should be the same as range length.
|
|
81
|
-
* In order to achieve this this function will replace inline elements (text-line) as new line character ("\n").
|
|
82
|
-
*
|
|
83
|
-
* @param {module:engine/model/range~Range} range The model range.
|
|
84
|
-
* @returns {String} The text content of the provided range.
|
|
85
|
-
*/
|
|
86
|
-
export function rangeToText( range ) {
|
|
87
|
-
return Array.from( range.getItems() ).reduce( ( rangeText, node ) => {
|
|
88
|
-
// Trim text to a last occurrence of an inline element and update range start.
|
|
89
|
-
if ( !( node.is( 'text' ) || node.is( 'textProxy' ) ) ) {
|
|
90
|
-
// Editor has only one inline element defined in schema: `<softBreak>` which is treated as new line character in blocks.
|
|
91
|
-
// Special handling might be needed for other inline elements (inline widgets).
|
|
92
|
-
return `${ rangeText }\n`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return rangeText + node.data;
|
|
96
|
-
}, '' );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Finds the appropriate index in the resultsList Collection.
|
|
100
|
-
function findInsertIndex( resultsList, markerToInsert ) {
|
|
101
|
-
const result = resultsList.find( ( { marker } ) => {
|
|
102
|
-
return markerToInsert.getStart().isBefore( marker.getStart() );
|
|
103
|
-
} );
|
|
104
|
-
|
|
105
|
-
return result ? resultsList.getIndex( result ) : resultsList.length;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Maps RegExp match result to find result.
|
|
109
|
-
function regexpMatchToFindResult( matchResult ) {
|
|
110
|
-
const lastGroupIndex = matchResult.length - 1;
|
|
111
|
-
|
|
112
|
-
let startOffset = matchResult.index;
|
|
113
|
-
|
|
114
|
-
// Searches with match all flag have an extra matching group with empty string or white space matched before the word.
|
|
115
|
-
// If the search term starts with the space already, there is no extra group even with match all flag on.
|
|
116
|
-
if ( matchResult.length === 3 ) {
|
|
117
|
-
startOffset += matchResult[ 1 ].length;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
label: matchResult[ lastGroupIndex ],
|
|
122
|
-
start: startOffset,
|
|
123
|
-
end: startOffset + matchResult[ lastGroupIndex ].length
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Creates a text matching callback for a specified search term and matching options.
|
|
129
|
-
*
|
|
130
|
-
* @param {String} searchTerm The search term.
|
|
131
|
-
* @param {Object} [options] Matching options.
|
|
132
|
-
* @param {Boolean} [options.matchCase=false] If set to `true` letter casing will be ignored.
|
|
133
|
-
* @param {Boolean} [options.wholeWords=false] If set to `true` only whole words that match `callbackOrText` will be matched.
|
|
134
|
-
* @returns {Function}
|
|
135
|
-
*/
|
|
136
|
-
export function findByTextCallback( searchTerm, options ) {
|
|
137
|
-
let flags = 'gu';
|
|
138
|
-
|
|
139
|
-
if ( !options.matchCase ) {
|
|
140
|
-
flags += 'i';
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
let regExpQuery = `(${ escapeRegExp( searchTerm ) })`;
|
|
144
|
-
|
|
145
|
-
if ( options.wholeWords ) {
|
|
146
|
-
const nonLetterGroup = '[^a-zA-Z\u00C0-\u024F\u1E00-\u1EFF]';
|
|
147
|
-
|
|
148
|
-
if ( !new RegExp( '^' + nonLetterGroup ).test( searchTerm ) ) {
|
|
149
|
-
regExpQuery = `(^|${ nonLetterGroup }|_)${ regExpQuery }`;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if ( !new RegExp( nonLetterGroup + '$' ).test( searchTerm ) ) {
|
|
153
|
-
regExpQuery = `${ regExpQuery }(?=_|${ nonLetterGroup }|$)`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const regExp = new RegExp( regExpQuery, flags );
|
|
158
|
-
|
|
159
|
-
function findCallback( { text } ) {
|
|
160
|
-
const matches = [ ...text.matchAll( regExp ) ];
|
|
161
|
-
|
|
162
|
-
return matches.map( regexpMatchToFindResult );
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return findCallback;
|
|
166
|
-
}
|