@northernco/ckeditor5-anchor-drupal
Version:
Drupal CKEditor 5 integration
61 lines • 42.3 kB
JavaScript
!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{Anchor:"Anchor","Anchor name":"Anchor name","Edit anchor":"Edit anchor",Unanchor:"Unanchor"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var e={590:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=n(645),i=n.n(o)()((function(e){return e[1]}));i.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 r=i},17:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=n(645),i=n.n(o)()((function(e){return e[1]}));i.push([e.id,"",""]);const r=i},145:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=n(645),i=n.n(o)()((function(e){return e[1]}));i.push([e.id,'.ck.ck-anchor-actions{display:flex;flex-direction:row;flex-wrap:nowrap}.ck.ck-anchor-actions .ck-anchor-actions__preview{display:inline-block}.ck.ck-anchor-actions .ck-anchor-actions__preview .ck-button__label{overflow:hidden}@media screen and (max-width:600px){.ck.ck-anchor-actions{flex-wrap:wrap}.ck.ck-anchor-actions .ck-anchor-actions__preview{flex-basis:100%}.ck.ck-anchor-actions .ck-button:not(.ck-anchor-actions__preview){flex-basis:50%}}div[contenteditable=false] .ck-anchor{background-size:16px;color:#00f;cursor:auto;padding-left:18px}div[contenteditable=true] .ck-anchor{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4AsCDSEAgw7OCAAAA1lJREFUWMPdl82LHEUYxn/VPTthe5Q1SMgt7GlZRG8KXrwEsgQlmEvwkIsL2YPgvyAEIoFcAvG0Nw8hgroQiHtIRNBLIAhqAlmQfHkIHiQssjg7n131eOjqmeqPnWF24x58oJjp6n7f99dVXdVPI4mpzTmctbg0LTRZi5ybHl9snykTkiicdM5hrcVai8sTW4vt95H0tqTvJP0pyaqotRFMHdC4/9MgpgJQq3+2tvY8F+impCNuMCiOjHPIWtxwiKSPSjFjAH+3k+WcHqyu6vujR/XD8eP65exZ7dy7V77qhaT3bLeLGw5xwyFpu42kz2vyjQGstSMAQFDkeXzxom6AvgZt+PYN6Ib//+zKlTrk3yX9Fnb8uLg4rp/VxOQAcRwLIEkSBHQ7HQDunzvH1sYGCdAAIjIJcIAFBr7vjdVV3lpfh2aTUP3nz/lpeZlnnQ6fSFm8tcbEcRVgYWEBgJ2dHQC+NIbXgLmgeKgQJPUw88DrS0tEzSbbDx/SAWKgA3ycA6SpMXFMo5zQGIOC44YPrisOYILzDeCIB9p+9Ah8/yu+r18T36hLKueYVca3vGjdSNWpAuCcI4rGKQyza5aYCmwURThphhQHUwVAh1i8FuCwVQFw+3gA/18jEEXRvpbhSwM47Cmo7AOSMME+oOC3vD7CzeelAdTJMd7vre+LyLbgfBueBKPS71SAcBpSoEu2xy+vrXHszBnM3Bx/373LH1evst3p0GT8ssphwuLyedLC8BkwpgoQRRE2AOgCb66s8M6dO4Xrjp0+zdKlS7h2m1/Pn+fJrVtEHiQOIJwv3ANOXrtWBIBsztM0HTmQVqulpNUaGYefT50KPcV9SR/4tl52IE8uX9ZN0HXQV75dB22Cdp8+DS9dKTiiCkCS1DmcD22/P3bFwyG220XSu96KjWR7Pb24fVt/bW7K7u6W85xwacqsACdHQWHzVt0OBkh6VdK3E1zlF2m7TVi8FiBJEs3Pz4eBF/a024Hldt792l4vn9r3/VQt2l5vz++IiiVrtVoYY2i32/mKMKE/mKjsjrLllr9VjcHkD5ypLtR6RxS8kmd6PfuldSBDkn8RHZYqI5Cm6dQgEwzlfmHzHI1ywjKAKc3btON9jcCkOzpogWmKphX5rwH+BWxcUbVSlumsAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE2LTExLTAyVDEzOjMzOjAwKzAxOjAw1wGs7QAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0xMS0wMlQxMzozMzowMCswMTowMKZcFFEAAAAASUVORK5CYII=") no-repeat 0;background-size:16px;color:#00f;cursor:auto;padding-left:18px}',""]);const r=i},831:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=n(645),i=n.n(o)()((function(e){return e[1]}));i.push([e.id,".ck.ck-anchor-form{display:flex}.ck.ck-anchor-form .ck-label{display:none}@media screen and (max-width:600px){.ck.ck-anchor-form{flex-wrap:wrap}.ck.ck-anchor-form .ck-labeled-field-view{flex-basis:100%}.ck.ck-anchor-form .ck-button{flex-basis:50%}}.ck.ck-anchor-form_layout-vertical{display:block}.ck.ck-anchor-form_layout-vertical .ck-button.ck-button-cancel,.ck.ck-anchor-form_layout-vertical .ck-button.ck-button-save{margin-top:var(--ck-spacing-medium)}",""]);const r=i},645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,o){"string"==typeof e&&(e=[[null,e,""]]);var i={};if(o)for(var r=0;r<this.length;r++){var s=this[r][0];null!=s&&(i[s]=!0)}for(var a=0;a<e.length;a++){var c=[].concat(e[a]);o&&i[c[0]]||(n&&(c[2]?c[2]="".concat(n," and ").concat(c[2]):c[2]=n),t.push(c))}},t}},379:(e,t,n)=>{"use strict";var o,i=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},r=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),s=[];function a(e){for(var t=-1,n=0;n<s.length;n++)if(s[n].identifier===e){t=n;break}return t}function c(e,t){for(var n={},o=[],i=0;i<e.length;i++){var r=e[i],c=t.base?r[0]+t.base:r[0],l=n[c]||0,d="".concat(c," ").concat(l);n[c]=l+1;var u=a(d),h={css:r[1],media:r[2],sourceMap:r[3]};-1!==u?(s[u].references++,s[u].updater(h)):s.push({identifier:d,updater:p(h,t),references:1}),o.push(d)}return o}function l(e){var t=document.createElement("style"),o=e.attributes||{};if(void 0===o.nonce){var i=n.nc;i&&(o.nonce=i)}if(Object.keys(o).forEach((function(e){t.setAttribute(e,o[e])})),"function"==typeof e.insert)e.insert(t);else{var s=r(e.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function h(e,t,n,o){var i=n?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(e.styleSheet)e.styleSheet.cssText=u(t,i);else{var r=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}function f(e,t,n){var o=n.css,i=n.media,r=n.sourceMap;if(i?e.setAttribute("media",i):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=o;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(o))}}var m=null,g=0;function p(e,t){var n,o,i;if(t.singleton){var r=g++;n=m||(m=l(t)),o=h.bind(null,n,r,!1),i=h.bind(null,n,r,!0)}else n=l(t),o=f.bind(null,n,t),i=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else i()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=i());var n=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var o=0;o<n.length;o++){var i=a(n[o]);s[i].references--}for(var r=c(e,t),l=0;l<n.length;l++){var d=a(n[l]);0===s[d].references&&(s[d].updater(),s.splice(d,1))}n=r}}}},945:(e,t,n)=>{e.exports=n(79)("./src/clipboard.js")},704:(e,t,n)=>{e.exports=n(79)("./src/core.js")},492:(e,t,n)=>{e.exports=n(79)("./src/engine.js")},181:(e,t,n)=>{e.exports=n(79)("./src/typing.js")},273:(e,t,n)=>{e.exports=n(79)("./src/ui.js")},209:(e,t,n)=>{e.exports=n(79)("./src/utils.js")},995:(e,t,n)=>{e.exports=n(79)("./src/widget.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={id:o,exports:{}};return e[o](r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var o={};(()=>{"use strict";n.r(o),n.d(o,{Anchor:()=>je});var e=n(704),t=n(492),i=n(181),r=n(945),s=n(209);
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
class a{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:anchorId",((e,t,n)=>{if(!n.consumable.test(t.item,"attribute:anchorId"))return;const o=n.writer,i=o.document.selection;for(const e of this._definitions){const r=o.createAttributeElement("a",e.attributes,{priority:5});o.setCustomProperty("anchor",!0,r),e.callback(t.attributeNewValue)?t.item.is("selection")?o.wrap(i.getFirstRange(),r):o.wrap(n.mapper.toViewRange(t.range),r):o.unwrap(n.mapper.toViewRange(t.range),r)}}),{priority:"high"})}}getDispatcherForAnchoredImage(){return e=>{e.on("attribute:anchorId:image",((e,t,n)=>{const o=n.mapper.toViewElement(t.item),i=Array.from(o.getChildren()).find((e=>"a"===e.name));for(const e of this._definitions){const o=(0,s.toMap)(e.attributes);if(e.callback(t.attributeNewValue))for(const[e,t]of o)"class"===e?n.writer.addClass(t,i):n.writer.setAttribute(e,t,i);else for(const[e,t]of o)"class"===e?n.writer.removeClass(t,i):n.writer.removeAttribute(e,i)}}))}}}const c=function(e,t,n){var o=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var r=Array(i);++o<i;)r[o]=e[o+t];return r};const l=function(e,t,n){var o=e.length;return n=void 0===n?o:n,!t&&n>=o?e:c(e,t,n)};var d=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const u=function(e){return d.test(e)};const h=function(e){return e.split("")};var f="\\ud800-\\udfff",m="["+f+"]",g="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",p="\\ud83c[\\udffb-\\udfff]",b="[^"+f+"]",w="(?:\\ud83c[\\udde6-\\uddff]){2}",v="[\\ud800-\\udbff][\\udc00-\\udfff]",k="(?:"+g+"|"+p+")"+"?",A="[\\ufe0e\\ufe0f]?",_=A+k+("(?:\\u200d(?:"+[b,w,v].join("|")+")"+A+k+")*"),y="(?:"+[b+g+"?",g,w,v,m].join("|")+")",x=RegExp(p+"(?="+p+")|"+y+_,"g");const I=function(e){return e.match(x)||[]};const V=function(e){return u(e)?I(e):h(e)};const T="object"==typeof global&&global&&global.Object===Object&&global;var S="object"==typeof self&&self&&self.Object===Object&&self;const C=(T||S||Function("return this")()).Symbol;const E=function(e,t){for(var n=-1,o=null==e?0:e.length,i=Array(o);++n<o;)i[n]=t(e[n],n,e);return i};const B=Array.isArray;var F=Object.prototype,O=F.hasOwnProperty,P=F.toString,D=C?C.toStringTag:void 0;const R=function(e){var t=O.call(e,D),n=e[D];try{e[D]=void 0;var o=!0}catch(e){}var i=P.call(e);return o&&(t?e[D]=n:delete e[D]),i};var j=Object.prototype.toString;const M=function(e){return j.call(e)};var U=C?C.toStringTag:void 0;const H=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":U&&U in Object(e)?R(e):M(e)};const z=function(e){return null!=e&&"object"==typeof e};const L=function(e){return"symbol"==typeof e||z(e)&&"[object Symbol]"==H(e)};var N=C?C.prototype:void 0,K=N?N.toString:void 0;const Q=function e(t){if("string"==typeof t)return t;if(B(t))return E(t,e)+"";if(L(t))return K?K.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n};const Z=function(e){return null==e?"":Q(e)};const W=function(e){return function(t){t=Z(t);var n=u(t)?V(t):void 0,o=n?n[0]:t.charAt(0),i=n?l(n,1).join(""):t.slice(1);return o[e]()+i}}("toUpperCase");var q=n(995);
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
const G=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Y=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,J=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,X=/^((\w+:(\/{2,})?)|(\W))/i,$="Ctrl+M";function ee(e,{writer:t}){const n=t.createAttributeElement("a",{id:e},{priority:5});return t.addClass("ck-anchor",n),t.setCustomProperty("anchor",!0,n),n}function te(e){return function(e){const t=e.replace(G,"");return t.match(Y)}(e=String(e))?e:"#"}function ne(e,t){return!!e&&(e.is("element","image")&&t.checkAttribute("image","anchorId"))}function oe(e,t){const n=(o=e,J.test(o)?"mailto:":t);var o;const i=!!n&&!X.test(e);return e&&i?n+e:e}
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
class ie extends e.Command{constructor(e){super(e),this.manualDecorators=new s.Collection,this.automaticDecorators=new a}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document,n=(0,s.first)(t.selection.getSelectedBlocks());ne(n,e.schema)?(this.value=n.getAttribute("anchorId"),this.isEnabled=e.schema.checkAttribute(n,"anchorId")):(this.value=t.selection.getAttribute("anchorId"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"anchorId"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const n=this.editor.model,o=n.document.selection,r=[],a=[];for(const e in t)t[e]?r.push(e):a.push(e);n.change((t=>{if(o.isCollapsed){const c=o.getFirstPosition();if(o.hasAttribute("anchorId")){const s=(0,i.findAttributeRange)(c,"anchorId",o.getAttribute("anchorId"),n);t.setAttribute("anchorId",e,s),r.forEach((e=>{t.setAttribute(e,!0,s)})),a.forEach((e=>{t.removeAttribute(e,s)})),t.setSelection(t.createPositionAfter(s.end.nodeBefore))}else if(""!==e){const i=(0,s.toMap)(o.getAttributes());i.set("anchorId",e),r.forEach((e=>{i.set(e,!0)}));const{end:a}=n.insertContent(t.createElement("anchor",i),c);t.setSelection(a)}["anchorId",...r,...a].forEach((e=>{t.removeSelectionAttribute(e)}))}else if("anchor"===o.getSelectedElement()?.name){const o=t.createElement("anchor",{anchorId:e});n.insertObject(o,null,null,{setSelection:"on"})}else{const i=n.schema.getValidRanges(o.getRanges(),"anchorId"),s=[];for(const e of o.getSelectedBlocks())n.schema.checkAttribute(e,"anchorId")&&s.push(t.createRangeOn(e));const c=s.slice();for(const e of i)this._isRangeToUpdate(e,s)&&c.push(e);for(const n of c)t.setAttribute("anchorId",e,n),r.forEach((e=>{t.setAttribute(e,!0,n)})),a.forEach((e=>{t.removeAttribute(e,n)}))}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,n=t.document,o=(0,s.first)(n.selection.getSelectedBlocks());return ne(o,t.schema)?o.getAttribute(e):n.selection.getAttribute(e)}_isRangeToUpdate(e,t){for(const n of t)if(n.containsRange(e))return!1;return!0}}
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
class re extends e.Command{refresh(){const e=this.editor.model,t=e.document,n=(0,s.first)(t.selection.getSelectedBlocks());ne(n,e.schema)?this.isEnabled=e.schema.checkAttribute(n,"anchorId"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"anchorId")}execute(){const e=this.editor,t=this.editor.model,n=t.document.selection,o=e.commands.get("anchor");t.change((e=>{const r=n.isCollapsed?[(0,i.findAttributeRange)(n.getFirstPosition(),"anchorId",n.getAttribute("anchorId"),t)]:t.schema.getValidRanges(n.getRanges(),"anchorId");for(const t of r)if(e.removeAttribute("anchorId",t),o)for(const n of o.manualDecorators)e.removeAttribute(n.id,t);"anchor"===n.getSelectedElement()?.name&&t.deleteContent(n)}))}}
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
class se{constructor({id:e,label:t,attributes:n,defaultValue:o}){this.id=e,this.set("value"),this.defaultValue=o,this.label=t,this.attributes=n}}
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
function ae(e,t,n,o){return o.createRange(ce(e,t,n,!0,o),ce(e,t,n,!1,o))}function ce(e,t,n,o,i){let r=e.textNode||(o?e.nodeBefore:e.nodeAfter),s=null;for(;r&&r.getAttribute(t)==n;)s=r,r=o?r.previousSibling:r.nextSibling;return s?i.createPositionAt(s,o?"before":"after"):e}(0,s.mix)(se,s.ObservableMixin);const le=
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
function(){try{return navigator.userAgent.toLowerCase()}catch(e){return""}}();de(le),function(e){e.indexOf("windows")}(le),function(e){e.match(/gecko\/\d+/)}(le),function(e){e.indexOf(" applewebkit/")>-1&&e.indexOf("chrome")}(le),function(e){!!e.match(/iphone|ipad/i)||de(e)&&navigator.maxTouchPoints}(le),function(e){e.indexOf("android")}(le),function(e){e.indexOf("chrome/")>-1&&e.indexOf("edge/")}(le),function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}}();function de(e){return e.indexOf("macintosh")>-1}
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
const ue=function(){const e={arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++){e[String.fromCharCode(t).toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;for(const t of"`-=[];',./\\")e[t]=t.charCodeAt(0);return e}();Object.fromEntries(Object.entries(ue).map((([e,t])=>[t,e.charAt(0).toUpperCase()+e.slice(1)])));var he=n(379),fe=n.n(he),me=n(17),ge={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};fe()(me.Z,ge);me.Z.locals;const pe="automatic",be=/^(https?:)?\/\//;class we extends e.Plugin{static get pluginName(){return"AnchorEditing"}static get requires(){return[i.TwoStepCaretMovement,i.Input,r.Clipboard]}constructor(e){super(e),e.config.define("anchor",{addTargetToExternalAnchors:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"anchorId"}),e.model.schema.register("anchor",{allowContentOf:"$inlineObject",allowWhere:"$inlineObject",inheritTypesFrom:"$inlineObject",allowAttributes:["class","id","anchorId","name"]}),e.conversion.for("dataDowncast").attributeToElement({model:{name:"$text",key:"anchorId"},view:ee}),e.conversion.for("dataDowncast").elementToElement({model:"anchor",view:(e,t)=>function(e,{writer:t}){let n=null;return n=t.createEmptyElement("a",{id:e}),t.addClass("ck-anchor",n),t.setCustomProperty("anchor",!0,n),n}(e.getAttribute("anchorId"),t)}),e.conversion.for("editingDowncast").attributeToElement({model:"anchorId",view:(e,t)=>e?ee(te(e),t):null}),e.conversion.for("editingDowncast").elementToElement({model:"anchor",view:(e,t)=>function(e,{writer:t}){const n=t.createContainerElement("span",{class:"ck-anchor-placeholder"},[t.createText(`[INVISIBLE ANCHOR: ${e}]`)]);return(0,q.toWidget)(n,t)}(e.getAttribute("anchorId"),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{id:!0}},model:{key:"anchorId",value:e=>{if(!(e.childCount<1||e.hasAttribute("href")))return e.getAttribute("id")}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{name:!0}},model:{key:"anchorId",value:e=>{if(!(e.childCount<1))return e.getAttribute("name")}}}),e.conversion.for("upcast").elementToElement({view:{name:"a",attributes:{id:!0}},model:(e,{writer:t})=>{if(!(e.childCount>0))return t.createElement("anchor",{anchorId:e.getAttribute("id")})}}),e.conversion.for("upcast").elementToElement({view:{name:"a",attributes:{name:!0}},model:(e,{writer:t})=>{if(!(e.childCount>0))return t.createElement("anchor",{anchorId:e.getAttribute("name")})}}),e.commands.add("anchor",new ie(e)),e.commands.add("unanchor",new re(e));const t=function(e,t){const n={};return t.forEach((e=>(e.label&&n[e.label]&&(e.label=n[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[n,o]of Object.entries(e)){const e=Object.assign({},o,{id:`anchor${W(n)}`});t.push(e)}return t}(e.config.get("anchor.decorators")));this._enableAutomaticDecorators(t.filter((e=>e.mode===pe))),this._enableManualDecorators(t.filter((e=>"manual"===e.mode)));e.plugins.get(i.TwoStepCaretMovement).registerAttribute("anchorId"),(0,i.inlineHighlight)(e,"anchorId","a","ck-anchor_selected"),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterAnchor(),this._enableTypingOverAnchor(),this._handleDeleteContentAfterAnchor(),e.editing.mapper.on("viewToModelPosition",(0,q.viewToModelPositionOutsideModelElement)(e.model,(e=>e.hasClass("ck-anchor-placeholder"))))}_enableAutomaticDecorators(e){const t=this.editor,n=t.commands.get("anchor").automaticDecorators;t.config.get("anchor.addTargetToExternalAnchors")&&n.add({id:"anchorIsExternal",mode:pe,callback:e=>be.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(e),n.length&&t.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,n=t.commands.get("anchor").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),n.add(new se(e)),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,{writer:o})=>{if(t){const t=n.get(e.id).attributes,i=o.createAttributeElement("a",t,{priority:5});return o.setCustomProperty("anchor",!0,i),i}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:n.get(e.id).attributes},model:{key:e.id}})}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor,t=e.model,n=t.document.selection,o=e.commands.get("anchor");this.listenTo(t,"insertContent",(()=>{const e=n.anchor.nodeBefore,i=n.anchor.nodeAfter;n.hasAttribute("anchorId")&&e&&e.hasAttribute("anchorId")&&(i&&i.hasAttribute("anchorId")||t.change((e=>{ve(e,o.manualDecorators)})))}),{priority:"low"})}_enableClickingAfterAnchor(){const e=this.editor,n=e.commands.get("anchor");e.editing.view.addObserver(t.MouseObserver);let o=!1;this.listenTo(e.editing.view.document,"mousedown",(()=>{o=!0})),this.listenTo(e.editing.view.document,"selectionChange",(()=>{if(!o)return;o=!1;const t=e.model.document.selection;if(!t.isCollapsed)return;if(!t.hasAttribute("anchorId"))return;const i=t.getFirstPosition(),r=ae(i,"anchorId",t.getAttribute("anchorId"),e.model);(i.isTouching(r.start)||i.isTouching(r.end))&&e.model.change((e=>{ve(e,n.manualDecorators)}))}))}_enableTypingOverAnchor(){const e=this.editor,t=e.editing.view;let n,o;this.listenTo(t.document,"delete",(()=>{o=!0}),{priority:"high"}),this.listenTo(e.model,"deleteContent",(()=>{const t=e.model.document.selection;t.isCollapsed||(o?o=!1:ke(e)&&function(e){const t=e.document.selection,n=t.getFirstPosition(),o=t.getLastPosition(),i=n.nodeAfter;if(!i)return!1;if(!i.is("$text"))return!1;if(!i.hasAttribute("anchorId"))return!1;const r=o.textNode||o.nodeBefore;if(i===r)return!0;return ae(n,"anchorId",i.getAttribute("anchorId"),e).containsRange(e.createRange(n,o),!0)}(e.model)&&(n=t.getAttributes()))}),{priority:"high"}),this.listenTo(e.model,"insertContent",((t,[i])=>{o=!1,ke(e)&&n&&(e.model.change((e=>{for(const[t,o]of n)e.setAttribute(t,o,i)})),n=null)}),{priority:"high"})}_handleDeleteContentAfterAnchor(){const e=this.editor,t=e.model,n=t.document.selection,o=e.editing.view,i=e.commands.get("anchor");let r=!1,s=!1;this.listenTo(o.document,"delete",((e,t)=>{s=t.domEvent.keyCode===ue.backspace}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{r=!1;const e=n.getFirstPosition(),o=n.getAttribute("anchorId");if(!o)return;const i=ae(e,"anchorId",o,t);r=i.containsPosition(e)||i.end.isEqual(e)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{s&&(s=!1,r||e.model.enqueueChange((e=>{ve(e,i.manualDecorators)})))}),{priority:"low"})}}function ve(e,t){e.removeSelectionAttribute("anchorId");for(const n of t)e.removeSelectionAttribute(n.id)}function ke(e){return e.model.change((e=>e.batch)).isTyping}var Ae=n(273);var _e=n(831),ye={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};fe()(_e.Z,ye);_e.Z.locals;var xe=n(590),Ie={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};fe()(xe.Z,Ie);xe.Z.locals;
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
class Ve extends Ae.View{constructor(e,t){super(e);const n=e.t;this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.972 16.615a.997.997 0 0 1-.744-.292l-4.596-4.596a1 1 0 1 1 1.414-1.414l3.926 3.926 9.937-9.937a1 1 0 0 1 1.414 1.415L7.717 16.323a.997.997 0 0 1-.745.292z"/></svg>',"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.591 10.177 4.243 4.242a1 1 0 0 1-1.415 1.415l-4.242-4.243-4.243 4.243a1 1 0 0 1-1.414-1.415l4.243-4.242L4.52 5.934A1 1 0 0 1 5.934 4.52l4.243 4.243 4.242-4.243a1 1 0 1 1 1.415 1.414l-4.243 4.243z"/></svg>',"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusables=new Ae.ViewCollection,this._focusCycler=new Ae.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-anchor-form","ck-responsive-form"];t.manualDecorators.length&&o.push("ck-anchor-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children}),(0,Ae.injectCssTransitionDisabler)(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),(0,Ae.submitHandler)({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new Ae.LabeledFieldView(this.locale,Ae.createLabeledInputText);return t.label=e("Anchor name"),t}_createButton(e,t,n,o){const i=new Ae.ButtonView(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const n of e.manualDecorators){const o=new Ae.SwitchButtonView(this.locale);o.set({name:n.id,label:n.label,withText:!0}),o.bind("isOn").toMany([n,e],"value",((e,t)=>void 0===t&&void 0===e?n.defaultValue:e)),o.on("execute",(()=>{n.set("value",!o.isOn)})),t.add(o)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Ae.View;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}var Te=n(145),Se={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};fe()(Te.Z,Se);Te.Z.locals;
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
class Ce extends Ae.View{constructor(t){super(t);const n=t.t;this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this.unanchorButtonView=this._createButton(n("Unanchor"),'<?xml version="1.0" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"\n "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">\n<svg version="1.0"\n xmlns="http://www.w3.org/2000/svg" width="512.000000pt" height="512.000000pt" viewBox="0 0 512.000000 512.000000" preserveAspectRatio="xMidYMid meet">\n <metadata>\nCreated by potrace 1.16, written by Peter Selinger 2001-2019\n </metadata>\n <g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none">\n <path d="M4255 5006 c-204 -208 -399 -316 -686 -380 -261 -58 -568 -60 -1104\n-7 -170 17 -404 36 -519 43 -593 32 -1000 -83 -1307 -370 l-72 -68 21 -64 c12\n-36 175 -616 363 -1290 188 -674 343 -1227 344 -1228 2 -2 44 31 94 75 201\n175 418 276 711 330 79 15 149 18 410 17 267 0 354 -4 575 -27 143 -15 318\n-32 390 -37 192 -16 529 -14 666 4 349 47 616 174 843 400 95 95 124 139 132\n198 11 83 7 88 -133 163 -250 133 -497 302 -731 501 -62 53 -115 106 -118 119\n-3 12 17 114 45 226 97 396 173 780 227 1157 19 134 34 268 32 296 -3 51 -3\n51 -38 53 -32 1 -44 -7 -145 -111z"/>\n <path d="M152 4245 c-97 -30 -151 -104 -152 -204 0 -42 126 -506 541 -1990\n297 -1065 548 -1951 556 -1969 26 -54 77 -82 149 -82 159 0 274 80 274 191 0\n35 -1083 3917 -1105 3959 -21 41 -81 87 -131 99 -54 14 -78 13 -132 -4z"/>\n <path d="M3845 1352 c-16 -11 -47 -38 -67 -60 -33 -36 -38 -49 -38 -89 l0 -47\n212 -213 212 -213 -212 -213 -212 -213 0 -47 c0 -42 5 -53 42 -93 51 -55 85\n-74 134 -74 36 0 50 12 251 212 l213 212 213 -212 c201 -200 215 -212 251\n-212 49 0 83 19 134 74 37 40 42 51 42 93 l0 47 -212 213 -212 213 212 213\n212 213 0 47 c0 42 -5 53 -42 93 -51 55 -85 74 -134 74 -36 0 -50 -12 -251\n-212 l-213 -212 -213 212 c-205 204 -214 212 -253 212 -21 0 -52 -8 -69 -18z"/>\n </g>\n</svg>',"unanchor"),this.editButtonView=this._createButton(n("Edit anchor"),e.icons.pencil,"edit"),this._focusables=new Ae.ViewCollection,this._focusCycler=new Ae.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-anchor-actions","ck-responsive-form"],tabindex:"-1"},children:[this.editButtonView,this.unanchorButtonView]})}render(){super.render();[this.editButtonView,this.unanchorButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createButton(e,t,n){const o=new Ae.ButtonView(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.delegate("execute").to(this,n),o}}const Ee="anchor-ui";class Be extends e.Plugin{static get requires(){return[Ae.ContextualBalloon]}static get pluginName(){return"AnchorUI"}init(){const e=this.editor;e.editing.view.addObserver(t.ClickObserver),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=e.plugins.get(Ae.ContextualBalloon),this._createToolbarAnchorButton(),this._enableUserBalloonInteractions(),e.conversion.for("editingDowncast").markerToHighlight({model:Ee,view:{classes:["ck-fake-anchor-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Ee,view:{name:"span",classes:["ck-fake-anchor-selection","ck-fake-anchor-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const e=this.editor,t=new Ce(e.locale),n=e.commands.get("anchor"),o=e.commands.get("unanchor");return t.bind("id").to(n,"value"),t.editButtonView.bind("isEnabled").to(n),t.unanchorButtonView.bind("isEnabled").to(o),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unanchor",(()=>{e.execute("unanchor"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set($,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("anchor"),n=e.config.get("anchor.defaultProtocol"),o=new Ve(e.locale,t);return o.urlInputView.fieldView.bind("value").to(t,"value"),o.urlInputView.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),o.saveButtonView.bind("isEnabled").to(t),this.listenTo(o,"submit",(()=>{const{value:t}=o.urlInputView.fieldView.element,i=oe(t,n);e.execute("anchor",i,o.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(o,"cancel",(()=>{this._closeFormView()})),o.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),o}_createToolbarAnchorButton(){const e=this.editor,t=e.commands.get("anchor"),n=e.t;e.keystrokes.set($,((e,n)=>{n(),t.isEnabled&&this._showUI(!0)})),e.ui.componentFactory.add("anchor",(e=>{const o=new Ae.ButtonView(e);return o.isEnabled=!0,o.label=n("Anchor"),o.icon='<svg height="512" viewBox="0 0 58 58" width="512"\n xmlns="http://www.w3.org/2000/svg">\n <g id="Page-1" fill="none" fill-rule="evenodd">\n <g id="037---Waypoint-Flag" fill="rgb(0,0,0)" fill-rule="nonzero" transform="translate(0 -1)">\n <path id="Shape" d="m14.678 58.9507 1.0678-.2984c1.0270794-.287091 1.6269982-1.3523947 1.34-2.3795l-12.2083-43.6888c-.17227193-.6165569-.58242107-1.139423-1.14021438-1.4535673-.5577933-.3141444-1.21753647-.3938324-1.83408562-.2215327l-.1379.0385c-1.28397381.3587434-2.0340279 1.6904218-1.6753 2.9744l12.2086 43.6888c.2870014 1.0271063 1.3522895 1.6270863 2.3794 1.3401z"/>\n <path id="Shape" d="m57.67 28.42c-3.8715209-1.930437-7.4530885-4.3944478-10.64-7.32-.2678864-.245221-.3726619-.6216366-.27-.97 1.579074-5.9738125 2.7517572-12.04771023 3.51-18.18.12-1.02-.43-1.32-1.01-.62-11.38 13.61-31.07-2.49-42.79 9.88.14070884.2634479.25140182.5418575.33.83l7.92 28.36c11.74-12.22 31.36 3.78 42.72-9.8.58-.7.69-1.98.23-2.18z"/>\n </g>\n </g>\n</svg>',o.keystroke=$,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(t,"isEnabled"),o.bind("isOn").to(t,"value",(e=>!!e)),this.listenTo(o,"execute",(()=>this._showUI(!0))),o}))}_enableUserBalloonInteractions(){const e=this.editor.editing.view.document;this.listenTo(e,"click",(()=>{this._getSelectedAnchorElement()&&this._showUI()})),this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),(0,Ae.clickOutsideHandler)({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const e=this.editor.commands.get("anchor");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("anchor");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this._getSelectedAnchorElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let n=this._getSelectedAnchorElement(),o=r();const i=()=>{const e=this._getSelectedAnchorElement(),t=r();n&&!e||!n&&t!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=e,o=t};function r(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",i),this.listenTo(this._balloon,"change:visibleView",i)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,n=e.document;let o=null;if(t.markers.has(Ee)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(Ee)),n=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));o=e.domConverter.viewRangeToDom(n)}else{const t=this._getSelectedAnchorElement(),i=n.selection.getFirstRange();o=t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i)}return{target:o}}_getSelectedAnchorElement(){const e=this.editor.editing.view,t=e.document.selection;if(t.isCollapsed)return Fe(t.getFirstPosition());{const n=t.getFirstRange().getTrimmed(),o=Fe(n.start),i=Fe(n.end);return o&&o==i&&e.createRangeIn(o).getTrimmed().isEqual(n)?o:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const n=e.document.selection.getFirstRange();if(e.markers.has(Ee))t.updateMarker(Ee,{range:n});else if(n.start.isAtEnd){const o=Oe(n,e.document.selection.focus,t);t.addMarker(Ee,{usingOperation:!1,affectsData:!1,range:o})}else t.addMarker(Ee,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Ee)&&e.change((e=>{e.removeMarker(Ee)}))}}function Fe(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("anchor");var t}))}function Oe(e,t,n){const o=[e.start.path[0]+1,0],i=n.createPositionFromPath(e.start.root,o,"toNext"),r=n.createRange(i,e.end);return r.start.path[0]>e.end.path[0]?n.createRange(t):i.isAtStart&&i.isAtEnd?Oe(r,t,n):r}
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
const Pe=new RegExp("(^|\\s)(#\\S+)");class De extends e.Plugin{static get pluginName(){return"AutoAnchor"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new i.TextWatcher(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=Re(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,n)=>{const{batch:o,range:i,url:r}=n;if(!o.isTyping)return;const s=i.end.getShiftedBy(-1),a=s.getShiftedBy(-r.length),c=e.model.createRange(a,s);this._applyAutoAnchor(r,c)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("enter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const n=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoAnchorOnRange(n)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("shiftEnter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),n=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoAnchorOnRange(n)}))}_checkAndApplyAutoAnchorOnRange(e){const t=this.editor.model,{text:n,range:o}=(0,i.getLastTextLine)(e,t),r=Re(n);if(r){const e=t.createRange(o.end.getShiftedBy(-r.length),o.end);this._applyAutoAnchor(r,e)}}_applyAutoAnchor(e,t){const n=this.editor.model;this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"anchorId")}(t,n)&&n.enqueueChange((n=>{const o=this.editor.config.get("anchor.defaultProtocol"),i=oe(e,o);n.setAttribute("linkHref",i,t)}))}}function Re(e){const t=Pe.exec(e);return t?t[2]:null}
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
class je extends e.Plugin{static get requires(){return[we,Be,De]}static get pluginName(){return"Anchor"}}})(),(window.CKEditor5=window.CKEditor5||{}).anchorDrupal=o})();