@ncino/web-components 9.2.0-preview.4 → 9.2.0
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/dist/components/accordion/gator/base/accordion.gator.js +1 -1
- package/dist/components/accordion/gator/group/accordion-group.gator.js +1 -1
- package/dist/components/alert/gator/base/alert.gator.js +1 -1
- package/dist/components/banner/gator/banner.gator.js +1 -1
- package/dist/components/button/gator/button.gator.js +1 -1
- package/dist/components/display-card/gator/display-card.gator.js +1 -1
- package/dist/components/headline-card/gator/headline-card.gator.js +1 -1
- package/dist/components/icon/gator/icon.gator.js +2 -2
- package/dist/components/icon/gator/index.js +1 -1
- package/dist/components/icon/gator/templates/arrows-down-up.js +8 -0
- package/dist/components/icon/gator/templates/index.js +1 -1
- package/dist/components/image-card/gator/image-card.gator.js +1 -1
- package/dist/components/input/base/input-base.gator.js +1 -1
- package/dist/components/input/gator/dropdown/input-dropdown.gator.js +1 -1
- package/dist/components/input/gator/help-text/help-text.gator.js +1 -1
- package/dist/components/input/gator/input-file/file-uploaded-preview/file-upload-preview.gator.js +1 -1
- package/dist/components/input/gator/input-file/input-file.gator.js +1 -1
- package/dist/components/input/gator/input-textarea/input-textarea.gator.js +1 -1
- package/dist/components/input/gator/input-time/input-time.gator.js +1 -1
- package/dist/components/input-rich-text/ckeditor-config.js +1 -1
- package/dist/components/input-rich-text/input-rich-text.slds.js +2 -2
- package/dist/components/list/gator/list-item/list-item.gator.js +1 -1
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/selection-box/selection-box.gator.js +1 -1
- package/dist/components/table/gator/table-pagination/table-pagination.gator.js +1 -1
- package/dist/components/table/gator/table.gator.js +135 -45
- package/dist/design-tokens.source.json +1 -0
- package/dist/generated/locale-codes.js +1 -0
- package/dist/generated/locales/es-419.js +10 -0
- package/dist/generated/locales/fr-CA.js +10 -0
- package/dist/generated/locales/zh-Hans.js +11 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-alignment@47.5.0 → @ckeditor_ckeditor5-alignment@47.6.0}/node_modules/@ckeditor/ckeditor5-alignment/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-autoformat@47.5.0 → @ckeditor_ckeditor5-autoformat@47.6.0}/node_modules/@ckeditor/ckeditor5-autoformat/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-autosave@47.5.0 → @ckeditor_ckeditor5-autosave@47.6.0}/node_modules/@ckeditor/ckeditor5-autosave/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-basic-styles@47.5.0 → @ckeditor_ckeditor5-basic-styles@47.6.0}/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-block-quote@47.5.0 → @ckeditor_ckeditor5-block-quote@47.6.0}/node_modules/@ckeditor/ckeditor5-block-quote/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-clipboard@47.5.0 → @ckeditor_ckeditor5-clipboard@47.6.0}/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-cloud-services@47.5.0 → @ckeditor_ckeditor5-cloud-services@47.6.0}/node_modules/@ckeditor/ckeditor5-cloud-services/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-code-block@47.5.0 → @ckeditor_ckeditor5-code-block@47.6.0}/node_modules/@ckeditor/ckeditor5-code-block/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-core@47.5.0 → @ckeditor_ckeditor5-core@47.6.0}/node_modules/@ckeditor/ckeditor5-core/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-editor-classic@47.5.0 → @ckeditor_ckeditor5-editor-classic@47.6.0}/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-engine@47.5.0 → @ckeditor_ckeditor5-engine@47.6.0}/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-enter@47.5.0 → @ckeditor_ckeditor5-enter@47.6.0}/node_modules/@ckeditor/ckeditor5-enter/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-essentials@47.5.0 → @ckeditor_ckeditor5-essentials@47.6.0}/node_modules/@ckeditor/ckeditor5-essentials/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-find-and-replace@47.5.0 → @ckeditor_ckeditor5-find-and-replace@47.6.0}/node_modules/@ckeditor/ckeditor5-find-and-replace/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-font@47.5.0 → @ckeditor_ckeditor5-font@47.6.0}/node_modules/@ckeditor/ckeditor5-font/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-heading@47.5.0 → @ckeditor_ckeditor5-heading@47.6.0}/node_modules/@ckeditor/ckeditor5-heading/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-highlight@47.5.0 → @ckeditor_ckeditor5-highlight@47.6.0}/node_modules/@ckeditor/ckeditor5-highlight/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-horizontal-line@47.5.0 → @ckeditor_ckeditor5-horizontal-line@47.6.0}/node_modules/@ckeditor/ckeditor5-horizontal-line/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-html-embed@47.5.0 → @ckeditor_ckeditor5-html-embed@47.6.0}/node_modules/@ckeditor/ckeditor5-html-embed/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@47.6.0/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +3 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-icons@47.5.0 → @ckeditor_ckeditor5-icons@47.6.0}/node_modules/@ckeditor/ckeditor5-icons/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-image@47.5.0 → @ckeditor_ckeditor5-image@47.6.0}/node_modules/@ckeditor/ckeditor5-image/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-indent@47.6.0/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-language@47.5.0 → @ckeditor_ckeditor5-language@47.6.0}/node_modules/@ckeditor/ckeditor5-language/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@47.6.0/node_modules/@ckeditor/ckeditor5-link/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@47.6.0/node_modules/@ckeditor/ckeditor5-list/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-markdown-gfm@47.5.0 → @ckeditor_ckeditor5-markdown-gfm@47.6.0}/node_modules/@ckeditor/ckeditor5-markdown-gfm/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-media-embed@47.5.0 → @ckeditor_ckeditor5-media-embed@47.6.0}/node_modules/@ckeditor/ckeditor5-media-embed/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-mention@47.5.0 → @ckeditor_ckeditor5-mention@47.6.0}/node_modules/@ckeditor/ckeditor5-mention/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-page-break@47.5.0 → @ckeditor_ckeditor5-page-break@47.6.0}/node_modules/@ckeditor/ckeditor5-page-break/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-paragraph@47.5.0 → @ckeditor_ckeditor5-paragraph@47.6.0}/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@47.6.0/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-remove-format@47.5.0 → @ckeditor_ckeditor5-remove-format@47.6.0}/node_modules/@ckeditor/ckeditor5-remove-format/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-select-all@47.5.0 → @ckeditor_ckeditor5-select-all@47.6.0}/node_modules/@ckeditor/ckeditor5-select-all/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-show-blocks@47.5.0 → @ckeditor_ckeditor5-show-blocks@47.6.0}/node_modules/@ckeditor/ckeditor5-show-blocks/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-source-editing@47.5.0 → @ckeditor_ckeditor5-source-editing@47.6.0}/node_modules/@ckeditor/ckeditor5-source-editing/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-special-characters@47.5.0 → @ckeditor_ckeditor5-special-characters@47.6.0}/node_modules/@ckeditor/ckeditor5-special-characters/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-style@47.5.0 → @ckeditor_ckeditor5-style@47.6.0}/node_modules/@ckeditor/ckeditor5-style/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@47.6.0/node_modules/@ckeditor/ckeditor5-table/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-typing@47.5.0 → @ckeditor_ckeditor5-typing@47.6.0}/node_modules/@ckeditor/ckeditor5-typing/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-ui@47.5.0 → @ckeditor_ckeditor5-ui@47.6.0}/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-undo@47.5.0 → @ckeditor_ckeditor5-undo@47.6.0}/node_modules/@ckeditor/ckeditor5-undo/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-upload@47.5.0 → @ckeditor_ckeditor5-upload@47.6.0}/node_modules/@ckeditor/ckeditor5-upload/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +8 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-widget@47.5.0 → @ckeditor_ckeditor5-widget@47.6.0}/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/pick.js +1 -0
- package/dist/node_modules/.pnpm/es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isNil.js +1 -0
- package/dist/packages/web-components/src/components/popover/gator/popover.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/table/gator/table.gator.scss.js +1 -1
- package/dist/types/components/icon/gator/templates/arrows-down-up.d.ts +1 -0
- package/dist/types/components/icon/gator/templates/index.d.ts +1 -0
- package/dist/types/components/popover/popover.d.ts +2 -0
- package/dist/types/components/table/gator/table.gator.d.ts +27 -0
- package/dist/types/components/table/table-column-definition.d.ts +8 -0
- package/dist/types/generated/locale-codes.d.ts +13 -0
- package/dist/types/generated/locales/es-419.d.ts +65 -0
- package/dist/types/generated/locales/fr-CA.d.ts +65 -0
- package/dist/types/generated/locales/zh-Hans.d.ts +65 -0
- package/package.json +5 -5
- package/web-types.json +4 -413
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@47.5.0/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +0 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-indent@47.5.0/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@47.5.0/node_modules/@ckeditor/ckeditor5-link/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@47.5.0/node_modules/@ckeditor/ckeditor5-list/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@47.5.0/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@47.5.0/node_modules/@ckeditor/ckeditor5-table/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@47.5.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +0 -8
- /package/dist/assets/node_modules/.pnpm/{ckeditor5@47.5.0 → ckeditor5@47.6.0}/node_modules/ckeditor5/dist/ckeditor5.css +0 -0
- /package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-watchdog@47.5.0 → @ckeditor_ckeditor5-watchdog@47.6.0}/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as m,Command as E}from"../../../../../@ckeditor_ckeditor5-core@47.
|
|
1
|
+
import{Plugin as m,Command as E}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{Observer as b,BubblingEventInfo as v,ViewDocumentDomEventData as k}from"../../../../../@ckeditor_ckeditor5-engine@47.6.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{env as S}from"../../../../../@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";function*p(s,e){for(const t of e)t&&s.getAttributeProperties(t[0]).copyOnEnter&&(yield t)}class y extends E{execute(){this.editor.model.change(e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})})}enterBlock(e){const t=this.editor.model,n=t.document.selection,i=t.schema,o=n.isCollapsed,r=n.getFirstRange(),a=r.start.parent,c=r.end.parent;if(i.isLimit(a)||i.isLimit(c))return!o&&a==c&&t.deleteContent(n),!1;if(o){const l=p(e.model.schema,n.getAttributes());return f(e,r.start),e.setSelectionAttribute(l),!0}else{const l=!(r.start.isAtStart&&r.end.isAtEnd),g=a==c;if(t.deleteContent(n,{leaveUnmerged:l}),l){if(g)return f(e,n.focus),!0;e.setSelection(c,0)}}return!1}}function f(s,e){s.split(e),s.setSelection(e.parent.nextSibling,0)}const C={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class h extends b{constructor(e){super(e);const t=this.document;let n=!1;t.on("keydown",(i,o)=>{n=o.shiftKey}),t.on("beforeinput",(i,o)=>{if(!this.isEnabled)return;let r=o.inputType;S.isSafari&&n&&r=="insertParagraph"&&(r="insertLineBreak");const a=o.domEvent,c=C[r];if(!c)return;const l=new v(t,"enter",o.targetRanges[0]);t.fire(l,new k(e,a,{isSoft:c.isSoft})),l.stop.called&&i.stop()})}observe(){}stopObserving(){}}class D extends m{static get pluginName(){return"Enter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,n=t.document,i=this.editor.t;t.addObserver(h),e.commands.add("enter",new y(e)),this.listenTo(n,"enter",(o,r)=>{n.isComposing||r.preventDefault(),!r.isSoft&&(e.execute("enter"),t.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:i("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class T extends E{execute(){const e=this.editor.model,t=e.document;e.change(n=>{A(e,n,t.selection),this.fire("afterExecute",{writer:n})})}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=x(e.schema,t.selection)}}function x(s,e){if(e.rangeCount>1)return!1;const t=e.anchor;if(!t||!s.checkChild(t,"softBreak"))return!1;const n=e.getFirstRange(),i=n.start.parent,o=n.end.parent;return!((d(i,s)||d(o,s))&&i!==o)}function A(s,e,t){const n=t.isCollapsed,i=t.getFirstRange(),o=i.start.parent,r=i.end.parent,a=o==r;if(n){const c=p(s.schema,t.getAttributes());u(s,e,i.end),e.removeSelectionAttribute(t.getAttributeKeys()),e.setSelectionAttribute(c)}else{const c=!(i.start.isAtStart&&i.end.isAtEnd);s.deleteContent(t,{leaveUnmerged:c}),a?u(s,e,t.focus):c&&e.setSelection(r,0)}}function u(s,e,t){const n=e.createElement("softBreak");s.insertContent(n,t),e.setSelection(n,"after")}function d(s,e){return s.is("rootElement")?!1:e.isLimit(s)||d(s.parent,e)}class I extends m{static get pluginName(){return"ShiftEnter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,n=e.conversion,i=e.editing.view,o=i.document,r=this.editor.t;t.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(a,{writer:c})=>c.createEmptyElement("br")}),i.addObserver(h),e.commands.add("shiftEnter",new T(e)),this.listenTo(o,"enter",(a,c)=>{o.isComposing||c.preventDefault(),c.isSoft&&(e.execute("shiftEnter"),i.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:r("Insert a soft break (a <code><br></code> element)"),keystroke:"Shift+Enter"}]})}}export{D as Enter,y as EnterCommand,h as EnterObserver,I as ShiftEnter,T as ShiftEnterCommand,p as _getCopyOnEnterAttributes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as t}from"../../../../../@ckeditor_ckeditor5-core@47.
|
|
1
|
+
import{Plugin as t}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{Clipboard as r}from"../../../../../@ckeditor_ckeditor5-clipboard@47.6.0/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js";import{Enter as i,ShiftEnter as e}from"../../../../../@ckeditor_ckeditor5-enter@47.6.0/node_modules/@ckeditor/ckeditor5-enter/dist/index.js";import{SelectAll as o}from"../../../../../@ckeditor_ckeditor5-select-all@47.6.0/node_modules/@ckeditor/ckeditor5-select-all/dist/index.js";import{Typing as s}from"../../../../../@ckeditor_ckeditor5-typing@47.6.0/node_modules/@ckeditor/ckeditor5-typing/dist/index.js";import{Undo as m}from"../../../../../@ckeditor_ckeditor5-undo@47.6.0/node_modules/@ckeditor/ckeditor5-undo/dist/index.js";import{AccessibilityHelp as l}from"../../../../../@ckeditor_ckeditor5-ui@47.6.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";class d extends t{static get requires(){return[l,r,i,o,e,s,m]}static get pluginName(){return"Essentials"}static get isOfficialPlugin(){return!0}}export{d as Essentials};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Plugin as p,Command as _}from"../../../../../@ckeditor_ckeditor5-core@47.5.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{IconFindReplace as w,IconPreviousArrow as x}from"../../../../../@ckeditor_ckeditor5-icons@47.5.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";import{Dialog as F,DropdownView as T,createDropdown as v,FormHeaderView as B,ButtonView as R,MenuBarMenuListItemButtonView as A,DialogViewPosition as I,CssTransitionDisablerMixin as E,View as g,ViewCollection as D,FocusCycler as O,submitHandler as S,CollapsibleView as P,SwitchButtonView as b,LabeledFieldView as M,createLabeledInputText as N}from"../../../../../@ckeditor_ckeditor5-ui@47.5.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{scrollViewportToShowTarget as H,Collection as m,uid as W,ObservableMixin as $,FocusTracker as L,KeystrokeHandler as U,isVisible as q,Rect as G}from"../../../../../@ckeditor_ckeditor5-utils@47.5.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{debounce as K}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/function/debounce.js";import{escapeRegExp as j}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/string/escapeRegExp.js";class z extends g{children;_findInputView;_replaceInputView;_findButtonView;_findPrevButtonView;_findNextButtonView;_advancedOptionsCollapsibleView;_matchCaseSwitchView;_wholeWordsOnlySwitchView;_replaceButtonView;_replaceAllButtonView;_inputsDivView;_actionButtonsDivView;_focusTracker;_keystrokes;_focusables;focusCycler;constructor(t){super(t);const e=t.t;this.children=this.createCollection(),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",(i,s)=>i>0&&!s),this._findInputView=this._createInputField(e("Find in text…")),this._findPrevButtonView=this._createButton({label:e("Previous result"),class:"ck-button-prev",icon:x,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:e("Next result"),class:"ck-button-next",icon:x,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(e("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:e("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:e("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:e("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new L,this._keystrokes=new U,this._focusables=new D,this.focusCycler=new O({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}render(){super.render(),S({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(t){t===-1?this.focusCycler.focusLast():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}_createInputsDiv(){const t=this.locale,e=t.t,i=new g(t);return this._findInputView.fieldView.on("input",()=>{this.isDirty=!0}),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findPrevious:s})=>s),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findNext:s})=>s),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:s},n)=>s&&n),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",(s,n)=>s||!n?"":e("Tip: Find some text first in order to replace it.")),i.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),i}_onFindButtonExecute(){if(!this._textToFind){const t=this.t;this._findInputView.errorText=t("Text to find must not be empty.");return}this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly})}_injectFindResultsCounter(){const t=this.locale,e=t.t,i=this.bindTemplate,s=new g(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",(o,r)=>e("%0 of %1",[o,r])),s.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",i.if("isDirty","ck-hidden")]},children:[{text:i.to("_resultsCounterText")}]});const n=()=>{const o=this._findInputView.fieldView.element;if(!o||!q(o))return;const r=new G(s.element).width,h=t.uiLanguageDirection==="ltr"?"paddingRight":"paddingLeft";r?o.style[h]=`calc( 2 * var(--ck-spacing-standard) + ${r}px )`:o.style[h]=""};this.on("change:_resultsCounterText",n,{priority:"low"}),this.on("change:isDirty",n,{priority:"low"}),this._findInputView.template.children[0].children.push(s)}_createAdvancedOptionsCollapsible(){const t=this.locale.t,e=new P(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return e.set({label:t("Advanced options"),isCollapsed:!0}),e}_createActionButtonsDiv(){const t=new g(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:e},i)=>e&&i),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replaceAll:e},i)=>e&&i),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()}),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),t.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),t}_createMatchCaseSwitch(){const t=this.locale.t,e=new b(this.locale);return e.set({label:t("Match case"),withText:!0}),e.bind("isOn").to(this,"_matchCase"),e.on("execute",()=>{this._matchCase=!this._matchCase,this.isDirty=!0}),e}_createWholeWordsOnlySwitch(){const t=this.locale.t,e=new b(this.locale);return e.set({label:t("Whole words only"),withText:!0}),e.bind("isOn").to(this,"_wholeWordsOnly"),e.on("execute",()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0}),e}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}_initKeystrokeHandling(){const t=i=>i.stopPropagation(),e=i=>{i.stopPropagation(),i.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",i=>{e(i),this._findNextButtonView.fire("execute")}),this._keystrokes.set("shift+f3",i=>{e(i),this._findPrevButtonView.fire("execute")}),this._keystrokes.set("enter",i=>{const s=i.target;s===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),e(i)):s===this._replaceInputView.fieldView.element&&!this.isDirty&&(this._replaceButtonView.fire("execute"),e(i))}),this._keystrokes.set("shift+enter",i=>{i.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),e(i))}),this._keystrokes.set("arrowright",t),this._keystrokes.set("arrowleft",t),this._keystrokes.set("arrowup",t),this._keystrokes.set("arrowdown",t)}_createButton(t){const e=new R(this.locale);return e.set(t),e}_createInputField(t,e){const i=new M(this.locale,N);return i.label=t,i.class=e,i}}class Q extends p{static get requires(){return[F]}static get pluginName(){return"FindAndReplaceUI"}static get isOfficialPlugin(){return!0}formView;constructor(t){super(t),t.config.define("findAndReplace.uiType","dialog"),this.formView=null}init(){const t=this.editor,e=t.config.get("findAndReplace.uiType")==="dropdown",i=t.commands.get("find"),s=this.editor.t;t.ui.componentFactory.add("findAndReplace",()=>{let n;return e?(n=this._createDropdown(),n.bind("isEnabled").to(i)):n=this._createDialogButtonForToolbar(),t.keystrokes.set("Ctrl+F",(o,r)=>{if(i.isEnabled){if(n instanceof T){const h=n.buttonView;h.isOn||h.fire("execute")}else n.isOn?t.plugins.get("Dialog").view.focus():n.fire("execute");r()}}),n}),e||t.ui.componentFactory.add("menuBar:findAndReplace",()=>this._createDialogButtonForMenuBar()),t.accessibility.addKeystrokeInfos({keystrokes:[{label:s("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const t=this.editor,e=t.locale.t,i=v(t.locale);return i.once("change:isOpen",()=>{this.formView=this._createFormView(),this.formView.children.add(new B(t.locale,{label:e("Find and replace")}),0),i.panelView.children.add(this.formView)}),i.on("change:isOpen",(s,n,o)=>{o?this._setupFormView():this.fire("searchReseted")},{priority:"low"}),i.buttonView.set({icon:w,label:e("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),i}_createDialogButtonForToolbar(){const t=this.editor,e=this._createButton(R),i=t.plugins.get("Dialog");return e.set({tooltip:!0}),e.bind("isOn").to(i,"id",s=>s==="findAndReplace"),e.on("execute",()=>{e.isOn?i.hide():this._showDialog()}),e}_createDialogButtonForMenuBar(){const t=this._createButton(A),e=this.editor.plugins.get("Dialog"),i=this.editor.plugins.get("Dialog");return t.set({role:"menuitemcheckbox",isToggleable:!0}),t.bind("isOn").to(i,"id",s=>s==="findAndReplace"),t.on("execute",()=>{if(e.id==="findAndReplace"){e.hide();return}this._showDialog()}),t}_createButton(t){const e=this.editor,i=e.commands.get("find"),s=new t(e.locale),n=e.locale.t;return s.bind("isEnabled").to(i),s.set({icon:w,label:n("Find and replace"),keystroke:"CTRL+F"}),s}_showDialog(){const t=this.editor,e=t.plugins.get("Dialog"),i=t.locale.t;this.formView||(this.formView=this._createFormView()),e.show({id:"findAndReplace",title:i("Find and replace"),content:this.formView,position:I.EDITOR_TOP_SIDE,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const t=this.editor,e=new(E(z))(t.locale),i=t.commands,n=this.editor.plugins.get("FindAndReplaceEditing").state;e.bind("highlightOffset").to(n,"highlightedOffset"),e.listenTo(n.results,"change",()=>{e.matchCount=n.results.length});const o=i.get("findNext"),r=i.get("findPrevious"),h=i.get("replace"),a=i.get("replaceAll");return e.bind("_areCommandsEnabled").to(o,"isEnabled",r,"isEnabled",h,"isEnabled",a,"isEnabled",(l,d,u,f)=>({findNext:l,findPrevious:d,replace:u,replaceAll:f})),e.delegate("findNext","findPrevious","replace","replaceAll").to(this),e.on("change:isDirty",(l,d,u)=>{u&&this.fire("searchReseted")}),e}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}}class Z extends _{_state;constructor(t,e){super(t),this.isEnabled=!0,this.affectsData=!1,this._state=e}execute(t,{matchCase:e,wholeWords:i}={}){const{editor:s}=this,{model:n}=s,o=s.plugins.get("FindAndReplaceUtils");let r,h="";typeof t=="string"?r=(...d)=>({results:o.findByTextCallback(t,{matchCase:e,wholeWords:i})(...d),searchText:t}):r=t;const a=r;r=(...d)=>{const u=a(...d);return u&&"searchText"in u&&(h=u.searchText),u};const l=n.document.getRootNames().reduce((d,u)=>o.updateFindResultFromRange(n.createRangeIn(n.document.getRoot(u)),n,r,d),null);return this._state.clear(n),this._state.results.addMany(l),this._state.highlightedResult=l.get(0),this._state.searchText=h,r&&(this._state.lastSearchCallback=r),this._state.matchCase=!!e,this._state.matchWholeWords=!!i,{results:l,findCallback:r}}}class J extends $(){constructor(t){super(),this.set("results",new m),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",(e,{removed:i,index:s})=>{if(Array.from(i).length){let n=!1;if(t.change(o=>{for(const r of i)this.highlightedResult===r&&(n=!0),t.markers.has(r.marker.name)&&o.removeMarker(r.marker)}),n){const o=s>=this.results.length?0:s;this.highlightedResult=this.results.get(o)}}}),this.on("change:highlightedResult",()=>{this.refreshHighlightOffset(t)})}clear(t){this.searchText="",t.change(e=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],s=t.markers.get(`findResultHighlighted:${i}`);s&&e.removeMarker(s)}[...this.results].forEach(({marker:i})=>{e.removeMarker(i)})}),this.results.clear()}refreshHighlightOffset(t){const{highlightedResult:e,results:i}=this;e?this.highlightedOffset=V(t,[...i]).indexOf(e)+1:this.highlightedOffset=0}}function V(c,t){const e={before:-1,same:0,after:1,different:1};return c.document.getRootNames().flatMap(i=>t.filter(s=>s.marker.getStart().root.rootName===i).sort((s,n)=>e[s.marker.getStart().compareWith(n.marker.getStart())]))}class k extends _{_state;constructor(t,e){super(t),this.isEnabled=!0,this._state=e,this._isEnabledBasedOnSelection=!1}_replace(t,e){const{model:i}=this.editor,s=e.marker.getRange();i.canEditAt(s)&&i.change(n=>{if(s.root.rootName==="$graveyard"){this._state.results.remove(e);return}let o={};for(const r of s.getItems())if(r.is("$text")||r.is("$textProxy")){o=r.getAttributes();break}i.insertContent(n.createText(t,o),s),this._state.results.has(e)&&this._state.results.remove(e)})}}class X extends k{execute(t,e){const i=Math.max(this._state.highlightedOffset-1,0);if(this._replace(t,e),this._state.results.length){const s=V(this.editor.model,[...this._state.results]);this._state.highlightedResult=s[i%s.length]}}}class Y extends k{execute(t,e){const{editor:i}=this,{model:s}=i,n=i.plugins.get("FindAndReplaceUtils"),o=e instanceof m?e:s.document.getRootNames().reduce((r,h)=>n.updateFindResultFromRange(s.createRangeIn(s.document.getRoot(h)),s,n.findByTextCallback(e,this._state),r),null);o.length&&s.change(()=>{[...o].forEach(r=>{this._replace(t,r)})})}}class C extends _{_state;constructor(t,e){super(t),this.affectsData=!1,this._state=e,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 t=this._state.results,e=t.getIndex(this._state.highlightedResult),i=e+1>=t.length?0:e+1;this._state.highlightedResult=this._state.results.get(i)}}class ee extends C{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),i=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(i)}}class te extends p{static get pluginName(){return"FindAndReplaceUtils"}static get isOfficialPlugin(){return!0}updateFindResultFromRange(t,e,i,s){const n=s||new m,o=r=>n.find(h=>{const{marker:a}=h,l=a.getRange(),d=r.getRange();return l.isEqual(d)});return e.change(r=>{[...t].forEach(({type:h,item:a})=>{if(h==="elementStart"&&e.schema.checkChild(a,"$text")){let l=i({item:a,text:this.rangeToText(e.createRangeIn(a))});if(!l)return;"results"in l&&(l=l.results),l.forEach(d=>{const u=`findResult:${W()}`,f=r.addMarker(u,{usingOperation:!1,affectsData:!1,range:r.createRange(r.createPositionAt(a,d.start),r.createPositionAt(a,d.end))}),y=ie(n,f);o(f)||n.add({id:u,label:d.label,marker:f},y)})}})}),n}rangeToText(t){return Array.from(t.getItems({shallow:!0})).reduce((e,i)=>i.is("$text")||i.is("$textProxy")?e+i.data:`${e}
|
|
1
|
+
import{Plugin as p,Command as _}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{IconFindReplace as w,IconPreviousArrow as x}from"../../../../../@ckeditor_ckeditor5-icons@47.6.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";import{Dialog as F,DropdownView as T,createDropdown as v,FormHeaderView as B,ButtonView as R,MenuBarMenuListItemButtonView as A,DialogViewPosition as I,CssTransitionDisablerMixin as E,View as g,ViewCollection as D,FocusCycler as O,submitHandler as S,CollapsibleView as P,SwitchButtonView as b,LabeledFieldView as M,createLabeledInputText as N}from"../../../../../@ckeditor_ckeditor5-ui@47.6.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{scrollViewportToShowTarget as H,Collection as m,uid as W,ObservableMixin as $,FocusTracker as L,KeystrokeHandler as U,isVisible as q,Rect as G}from"../../../../../@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{debounce as K}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/function/debounce.js";import{escapeRegExp as j}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/string/escapeRegExp.js";class z extends g{children;_findInputView;_replaceInputView;_findButtonView;_findPrevButtonView;_findNextButtonView;_advancedOptionsCollapsibleView;_matchCaseSwitchView;_wholeWordsOnlySwitchView;_replaceButtonView;_replaceAllButtonView;_inputsDivView;_actionButtonsDivView;_focusTracker;_keystrokes;_focusables;focusCycler;constructor(t){super(t);const e=t.t;this.children=this.createCollection(),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",(i,s)=>i>0&&!s),this._findInputView=this._createInputField(e("Find in text…")),this._findPrevButtonView=this._createButton({label:e("Previous result"),class:"ck-button-prev",icon:x,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:e("Next result"),class:"ck-button-next",icon:x,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(e("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:e("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:e("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:e("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new L,this._keystrokes=new U,this._focusables=new D,this.focusCycler=new O({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}render(){super.render(),S({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(t){t===-1?this.focusCycler.focusLast():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}_createInputsDiv(){const t=this.locale,e=t.t,i=new g(t);return this._findInputView.fieldView.on("input",()=>{this.isDirty=!0}),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findPrevious:s})=>s),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findNext:s})=>s),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:s},n)=>s&&n),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",(s,n)=>s||!n?"":e("Tip: Find some text first in order to replace it.")),i.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),i}_onFindButtonExecute(){if(!this._textToFind){const t=this.t;this._findInputView.errorText=t("Text to find must not be empty.");return}this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly})}_injectFindResultsCounter(){const t=this.locale,e=t.t,i=this.bindTemplate,s=new g(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",(o,r)=>e("%0 of %1",[o,r])),s.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",i.if("isDirty","ck-hidden")]},children:[{text:i.to("_resultsCounterText")}]});const n=()=>{const o=this._findInputView.fieldView.element;if(!o||!q(o))return;const r=new G(s.element).width,h=t.uiLanguageDirection==="ltr"?"paddingRight":"paddingLeft";r?o.style[h]=`calc( 2 * var(--ck-spacing-standard) + ${r}px )`:o.style[h]=""};this.on("change:_resultsCounterText",n,{priority:"low"}),this.on("change:isDirty",n,{priority:"low"}),this._findInputView.template.children[0].children.push(s)}_createAdvancedOptionsCollapsible(){const t=this.locale.t,e=new P(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return e.set({label:t("Advanced options"),isCollapsed:!0}),e}_createActionButtonsDiv(){const t=new g(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:e},i)=>e&&i),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replaceAll:e},i)=>e&&i),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()}),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),t.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),t}_createMatchCaseSwitch(){const t=this.locale.t,e=new b(this.locale);return e.set({label:t("Match case"),withText:!0}),e.bind("isOn").to(this,"_matchCase"),e.on("execute",()=>{this._matchCase=!this._matchCase,this.isDirty=!0}),e}_createWholeWordsOnlySwitch(){const t=this.locale.t,e=new b(this.locale);return e.set({label:t("Whole words only"),withText:!0}),e.bind("isOn").to(this,"_wholeWordsOnly"),e.on("execute",()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0}),e}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}_initKeystrokeHandling(){const t=i=>i.stopPropagation(),e=i=>{i.stopPropagation(),i.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",i=>{e(i),this._findNextButtonView.fire("execute")}),this._keystrokes.set("shift+f3",i=>{e(i),this._findPrevButtonView.fire("execute")}),this._keystrokes.set("enter",i=>{const s=i.target;s===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),e(i)):s===this._replaceInputView.fieldView.element&&!this.isDirty&&(this._replaceButtonView.fire("execute"),e(i))}),this._keystrokes.set("shift+enter",i=>{i.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),e(i))}),this._keystrokes.set("arrowright",t),this._keystrokes.set("arrowleft",t),this._keystrokes.set("arrowup",t),this._keystrokes.set("arrowdown",t)}_createButton(t){const e=new R(this.locale);return e.set(t),e}_createInputField(t,e){const i=new M(this.locale,N);return i.label=t,i.class=e,i}}class Q extends p{static get requires(){return[F]}static get pluginName(){return"FindAndReplaceUI"}static get isOfficialPlugin(){return!0}formView;constructor(t){super(t),t.config.define("findAndReplace.uiType","dialog"),this.formView=null}init(){const t=this.editor,e=t.config.get("findAndReplace.uiType")==="dropdown",i=t.commands.get("find"),s=this.editor.t;t.ui.componentFactory.add("findAndReplace",()=>{let n;return e?(n=this._createDropdown(),n.bind("isEnabled").to(i)):n=this._createDialogButtonForToolbar(),t.keystrokes.set("Ctrl+F",(o,r)=>{if(i.isEnabled){if(n instanceof T){const h=n.buttonView;h.isOn||h.fire("execute")}else n.isOn?t.plugins.get("Dialog").view.focus():n.fire("execute");r()}}),n}),e||t.ui.componentFactory.add("menuBar:findAndReplace",()=>this._createDialogButtonForMenuBar()),t.accessibility.addKeystrokeInfos({keystrokes:[{label:s("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const t=this.editor,e=t.locale.t,i=v(t.locale);return i.once("change:isOpen",()=>{this.formView=this._createFormView(),this.formView.children.add(new B(t.locale,{label:e("Find and replace")}),0),i.panelView.children.add(this.formView)}),i.on("change:isOpen",(s,n,o)=>{o?this._setupFormView():this.fire("searchReseted")},{priority:"low"}),i.buttonView.set({icon:w,label:e("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),i}_createDialogButtonForToolbar(){const t=this.editor,e=this._createButton(R),i=t.plugins.get("Dialog");return e.set({tooltip:!0}),e.bind("isOn").to(i,"id",s=>s==="findAndReplace"),e.on("execute",()=>{e.isOn?i.hide():this._showDialog()}),e}_createDialogButtonForMenuBar(){const t=this._createButton(A),e=this.editor.plugins.get("Dialog"),i=this.editor.plugins.get("Dialog");return t.set({role:"menuitemcheckbox",isToggleable:!0}),t.bind("isOn").to(i,"id",s=>s==="findAndReplace"),t.on("execute",()=>{if(e.id==="findAndReplace"){e.hide();return}this._showDialog()}),t}_createButton(t){const e=this.editor,i=e.commands.get("find"),s=new t(e.locale),n=e.locale.t;return s.bind("isEnabled").to(i),s.set({icon:w,label:n("Find and replace"),keystroke:"CTRL+F"}),s}_showDialog(){const t=this.editor,e=t.plugins.get("Dialog"),i=t.locale.t;this.formView||(this.formView=this._createFormView()),e.show({id:"findAndReplace",title:i("Find and replace"),content:this.formView,position:I.EDITOR_TOP_SIDE,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const t=this.editor,e=new(E(z))(t.locale),i=t.commands,n=this.editor.plugins.get("FindAndReplaceEditing").state;e.bind("highlightOffset").to(n,"highlightedOffset"),e.listenTo(n.results,"change",()=>{e.matchCount=n.results.length});const o=i.get("findNext"),r=i.get("findPrevious"),h=i.get("replace"),a=i.get("replaceAll");return e.bind("_areCommandsEnabled").to(o,"isEnabled",r,"isEnabled",h,"isEnabled",a,"isEnabled",(l,d,u,f)=>({findNext:l,findPrevious:d,replace:u,replaceAll:f})),e.delegate("findNext","findPrevious","replace","replaceAll").to(this),e.on("change:isDirty",(l,d,u)=>{u&&this.fire("searchReseted")}),e}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}}class Z extends _{_state;constructor(t,e){super(t),this.isEnabled=!0,this.affectsData=!1,this._state=e}execute(t,{matchCase:e,wholeWords:i}={}){const{editor:s}=this,{model:n}=s,o=s.plugins.get("FindAndReplaceUtils");let r,h="";typeof t=="string"?r=(...d)=>({results:o.findByTextCallback(t,{matchCase:e,wholeWords:i})(...d),searchText:t}):r=t;const a=r;r=(...d)=>{const u=a(...d);return u&&"searchText"in u&&(h=u.searchText),u};const l=n.document.getRootNames().reduce((d,u)=>o.updateFindResultFromRange(n.createRangeIn(n.document.getRoot(u)),n,r,d),null);return this._state.clear(n),this._state.results.addMany(l),this._state.highlightedResult=l.get(0),this._state.searchText=h,r&&(this._state.lastSearchCallback=r),this._state.matchCase=!!e,this._state.matchWholeWords=!!i,{results:l,findCallback:r}}}class J extends $(){constructor(t){super(),this.set("results",new m),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",(e,{removed:i,index:s})=>{if(Array.from(i).length){let n=!1;if(t.change(o=>{for(const r of i)this.highlightedResult===r&&(n=!0),t.markers.has(r.marker.name)&&o.removeMarker(r.marker)}),n){const o=s>=this.results.length?0:s;this.highlightedResult=this.results.get(o)}}}),this.on("change:highlightedResult",()=>{this.refreshHighlightOffset(t)})}clear(t){this.searchText="",t.change(e=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],s=t.markers.get(`findResultHighlighted:${i}`);s&&e.removeMarker(s)}[...this.results].forEach(({marker:i})=>{e.removeMarker(i)})}),this.results.clear()}refreshHighlightOffset(t){const{highlightedResult:e,results:i}=this;e?this.highlightedOffset=V(t,[...i]).indexOf(e)+1:this.highlightedOffset=0}}function V(c,t){const e={before:-1,same:0,after:1,different:1};return c.document.getRootNames().flatMap(i=>t.filter(s=>s.marker.getStart().root.rootName===i).sort((s,n)=>e[s.marker.getStart().compareWith(n.marker.getStart())]))}class k extends _{_state;constructor(t,e){super(t),this.isEnabled=!0,this._state=e,this._isEnabledBasedOnSelection=!1}_replace(t,e){const{model:i}=this.editor,s=e.marker.getRange();i.canEditAt(s)&&i.change(n=>{if(s.root.rootName==="$graveyard"){this._state.results.remove(e);return}let o={};for(const r of s.getItems())if(r.is("$text")||r.is("$textProxy")){o=r.getAttributes();break}i.insertContent(n.createText(t,o),s),this._state.results.has(e)&&this._state.results.remove(e)})}}class X extends k{execute(t,e){const i=Math.max(this._state.highlightedOffset-1,0);if(this._replace(t,e),this._state.results.length){const s=V(this.editor.model,[...this._state.results]);this._state.highlightedResult=s[i%s.length]}}}class Y extends k{execute(t,e){const{editor:i}=this,{model:s}=i,n=i.plugins.get("FindAndReplaceUtils"),o=e instanceof m?e:s.document.getRootNames().reduce((r,h)=>n.updateFindResultFromRange(s.createRangeIn(s.document.getRoot(h)),s,n.findByTextCallback(e,this._state),r),null);o.length&&s.change(()=>{[...o].forEach(r=>{this._replace(t,r)})})}}class C extends _{_state;constructor(t,e){super(t),this.affectsData=!1,this._state=e,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 t=this._state.results,e=t.getIndex(this._state.highlightedResult),i=e+1>=t.length?0:e+1;this._state.highlightedResult=this._state.results.get(i)}}class ee extends C{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),i=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(i)}}class te extends p{static get pluginName(){return"FindAndReplaceUtils"}static get isOfficialPlugin(){return!0}updateFindResultFromRange(t,e,i,s){const n=s||new m,o=r=>n.find(h=>{const{marker:a}=h,l=a.getRange(),d=r.getRange();return l.isEqual(d)});return e.change(r=>{[...t].forEach(({type:h,item:a})=>{if(h==="elementStart"&&e.schema.checkChild(a,"$text")){let l=i({item:a,text:this.rangeToText(e.createRangeIn(a))});if(!l)return;"results"in l&&(l=l.results),l.forEach(d=>{const u=`findResult:${W()}`,f=r.addMarker(u,{usingOperation:!1,affectsData:!1,range:r.createRange(r.createPositionAt(a,d.start),r.createPositionAt(a,d.end))}),y=ie(n,f);o(f)||n.add({id:u,label:d.label,marker:f},y)})}})}),n}rangeToText(t){return Array.from(t.getItems({shallow:!0})).reduce((e,i)=>i.is("$text")||i.is("$textProxy")?e+i.data:`${e}
|
|
2
2
|
`,"")}findByTextCallback(t,e){let i="gu";e.matchCase||(i+="i");let s=`(${j(t)})`;if(e.wholeWords){const r="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+r).test(t)||(s=`(^|${r}|_)${s}`),new RegExp(r+"$").test(t)||(s=`${s}(?=_|${r}|$)`)}const n=new RegExp(s,i);function o({text:r}){return[...r.matchAll(n)].map(se)}return o}}function ie(c,t){const e=c.find(({marker:i})=>t.getStart().isBefore(i.getStart()));return e?c.getIndex(e):c.length}function se(c){const t=c.length-1;let e=c.index;return c.length===3&&(e+=c[1].length),{label:c[t],start:e,end:e+c[t].length}}const ne="ck-find-result_selected";class re extends p{static get requires(){return[te]}static get pluginName(){return"FindAndReplaceEditing"}static get licenseFeatureCode(){return"FAR"}static get isPremiumPlugin(){return!0}static get isOfficialPlugin(){return!0}state;init(){this.state=new J(this.editor.model),this.set("_isSearchActive",!1),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",(i,s,n,o)=>{const{model:r}=this.editor;r.change(h=>{if(o){const a=o.marker.name.split(":")[1],l=r.markers.get(`findResultHighlighted:${a}`);l&&h.removeMarker(l)}if(n){const a=n.marker.name.split(":")[1];h.addMarker(`findResultHighlighted:${a}`,{usingOperation:!1,affectsData:!1,range:n.marker.getRange()})}})});const e=K(((i,s,n)=>{if(n){const o=this.editor.editing.view.domConverter,r=this.editor.editing.mapper.toViewRange(n.marker.getRange());H({target:o.viewRangeToDom(r),viewportOffset:40})}}).bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel),this.on("change:_isSearchActive",(i,s,n)=>{n?this.listenTo(this.editor.model.document,"change:data",this._onDocumentChange):this.stopListening(this.editor.model.document,"change:data",this._onDocumentChange)})}find(t,e){return this._isSearchActive=!0,this.editor.execute("find",t,e),this.state.results}stop(){this.state.clear(this.editor.model),this._isSearchActive=!1}_defineCommands(){this.editor.commands.add("find",new Z(this.editor,this.state)),this.editor.commands.add("findNext",new C(this.editor,this.state)),this.editor.commands.add("findPrevious",new ee(this.editor,this.state)),this.editor.commands.add("replace",new X(this.editor,this.state)),this.editor.commands.add("replaceAll",new Y(this.editor,this.state))}_defineConverters(){const{editor:t}=this;t.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:e})=>{const[,i]=e.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":i}}}}),t.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:e})=>{const[,i]=e.split(":");return{name:"span",classes:[ne],attributes:{"data-find-result":i}}}})}_onDocumentChange=()=>{const t=new Set,e=new Set,i=this.editor.model,{results:s}=this.state,n=i.document.differ.getChanges(),o=i.document.differ.getChangedMarkers();n.forEach(a=>{a.position&&(a.name==="$text"||a.position.nodeAfter&&i.schema.isInline(a.position.nodeAfter)?(t.add(a.position.parent),[...i.markers.getMarkersAtPosition(a.position)].forEach(l=>{e.add(l.name)})):a.type==="insert"&&a.position.nodeAfter&&t.add(a.position.nodeAfter))}),o.forEach(({name:a,data:{newRange:l}})=>{l&&l.start.root.rootName==="$graveyard"&&e.add(a)}),t.forEach(a=>{[...i.markers.getMarkersIntersectingRange(i.createRangeIn(a))].forEach(d=>e.add(d.name))}),e.forEach(a=>{s.has(a)&&(s.get(a)===this.state.highlightedResult&&(this.state.highlightedResult=null),s.remove(a))});const r=[],h=this.editor.plugins.get("FindAndReplaceUtils");t.forEach(a=>{const l=h.updateFindResultFromRange(i.createRangeOn(a),i,this.state.lastSearchCallback,s);r.push(...l)}),o.forEach(a=>{if(a.data.newRange){const l=h.updateFindResultFromRange(a.data.newRange,i,this.state.lastSearchCallback,s);r.push(...l)}}),!this.state.highlightedResult&&r.length?this.state.highlightedResult=r[0]:this.state.refreshHighlightOffset(i)}}class ue extends p{static get requires(){return[re,Q]}static get pluginName(){return"FindAndReplace"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get("FindAndReplaceUI"),e=this.editor.plugins.get("FindAndReplaceEditing"),i=e.state;t.on("findNext",(s,n)=>{n?(i.searchText=n.searchText,e.find(n.searchText,n)):this.editor.execute("findNext")}),t.on("findPrevious",(s,n)=>{n&&i.searchText!==n.searchText?e.find(n.searchText):this.editor.execute("findPrevious")}),t.on("replace",(s,n)=>{i.searchText!==n.searchText&&e.find(n.searchText);const o=i.highlightedResult;o&&this.editor.execute("replace",n.replaceText,o)}),t.on("replaceAll",(s,n)=>{i.searchText!==n.searchText&&e.find(n.searchText),this.editor.execute("replaceAll",n.replaceText,i.results)}),t.on("searchReseted",()=>{i.clear(this.editor.model),e.stop()})}}export{ue as FindAndReplace,re as FindAndReplaceEditing,z as FindAndReplaceFormView,J as FindAndReplaceState,Q as FindAndReplaceUI,te as FindAndReplaceUtils,Z as FindCommand,C as FindNextCommand,ee as FindPreviousCommand,k as FindReplaceCommandBase,Y as ReplaceAllCommand,X as ReplaceCommand,V as _sortFindResultsByMarkerPositions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as h,Command as q}from"../../../../../@ckeditor_ckeditor5-core@47.5.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{addBackgroundStylesRules as j,isLengthStyleValue as H,isPercentageStyleValue as Y,ModelDocumentSelection as W}from"../../../../../@ckeditor_ckeditor5-engine@47.5.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{createDropdown as O,addListToDropdown as P,MenuBarMenuView as z,MenuBarMenuListView as L,MenuBarMenuListItemView as T,MenuBarMenuListItemButtonView as E,normalizeColorOptions as Z,getLocalizedColorOptions as J,focusChildOnDropdownOpen as Q,ColorSelectorView as _,UIModel as D}from"../../../../../@ckeditor_ckeditor5-ui@47.5.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{CKEditorError as I,Collection as $}from"../../../../../@ckeditor_ckeditor5-utils@47.5.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{IconFontBackground as X,IconFontColor as ee,IconFontFamily as V,IconFontSize as N}from"../../../../../@ckeditor_ckeditor5-icons@47.5.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";class C extends q{attributeKey;constructor(e,o){super(e),this.attributeKey=o}refresh(){const e=this.editor.model,o=e.document;this.value=o.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(o.selection,this.attributeKey)}execute(e={}){const o=this.editor.model,i=o.document.selection,s=e.value,u=e.batch,a=r=>{if(i.isCollapsed)s?r.setSelectionAttribute(this.attributeKey,s):r.removeSelectionAttribute(this.attributeKey);else{const m=o.schema.getValidRanges(i.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(const d of m){let l=d,c=this.attributeKey;d.isCollapsed&&(l=d.start.parent,c=W._getStoreAttributeKey(this.attributeKey)),s?r.setAttribute(c,s,l):r.removeAttribute(c,l)}}};u?o.enqueueChange(u,r=>{a(r)}):o.change(r=>{a(r)})}}const p="fontSize",g="fontFamily",w="fontColor",y="fontBackgroundColor";function R(t,e){const o={model:{key:t,values:[]},view:{},upcastAlso:{}};for(const n of e)o.model.values.push(n.model),o.view[n.model]=n.view,n.upcastAlso&&(o.upcastAlso[n.model]=n.upcastAlso);return o}function U(t){return e=>oe(e.getStyle(t))}function M(t){return(e,{writer:o})=>o.createAttributeElement("span",{style:`${t}:${e}`},{priority:7})}function te({dropdownView:t,colors:e,columns:o,removeButtonLabel:n,colorPickerLabel:i,documentColorsLabel:s,documentColorsCount:u,colorPickerViewConfig:a}){const r=t.locale,m=new _(r,{colors:e,columns:o,removeButtonLabel:n,colorPickerLabel:i,documentColorsLabel:s,documentColorsCount:u,colorPickerViewConfig:a});return t.colorSelectorView=m,t.panelView.children.add(m),m}function oe(t){return t.replace(/\s/g,"")}class ne extends C{constructor(e){super(e,g)}}function G(t){return t.map(ie).filter(e=>e!==void 0)}function x(t){return t.replace(/["']/g,"").split(",").map(e=>e.trim())}function ie(t){if(typeof t=="object")return t;if(t==="default")return{title:"Default",model:void 0};if(typeof t=="string")return re(t)}function re(t){const e=x(t),o=e[0],n=e.map(se).join(", ");return{title:o,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}function se(t){return t=t.trim(),t.indexOf(" ")>0&&(t=`'${t}'`),t}class le extends h{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(g,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:g}),e.model.schema.setAttributeProperties(g,{isFormatting:!0,copyOnEnter:!0});const o=G(e.config.get("fontFamily.options")).filter(i=>i.model),n=R(g,o);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(g,new ne(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:g,view:(o,{writer:n})=>n.createAttributeElement("span",{style:"font-family:"+o},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:g,value:o=>o.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:g,value:o=>o.getAttribute("face")}})}}class ae extends h{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,o=e.t,n=this._getLocalizedOptions(),i=e.commands.get(g),s=o("Font Family"),u=ce(n,i);e.ui.componentFactory.add(g,a=>{const r=O(a);return P(r,u,{role:"menu",ariaLabel:s}),r.buttonView.set({label:s,icon:V,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",m=>{e.execute(m.source.commandName,{value:m.source.commandParam}),e.editing.view.focus()}),r}),e.ui.componentFactory.add(`menuBar:${g}`,a=>{const r=new z(a);r.buttonView.set({label:s,icon:V}),r.bind("isEnabled").to(i);const m=new L(a);for(const d of u){const l=new T(a,r),c=new E(a);c.set({role:"menuitemradio",isToggleable:!0}),c.bind(...Object.keys(d.model)).to(d.model),c.delegate("execute").to(r),c.on("execute",()=>{e.execute(d.model.commandName,{value:d.model.commandParam}),e.editing.view.focus()}),l.children.add(c),m.items.add(l)}return r.panelView.children.add(m),r})}_getLocalizedOptions(){const e=this.editor,o=e.t;return G(e.config.get(g).options).map(i=>(i.title==="Default"&&(i.title=o("Default")),i))}}function ce(t,e){const o=new $;for(const n of t){const i={type:"button",model:new D({commandName:g,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};i.model.bind("isOn").to(e,"value",s=>{if(s===n.model)return!0;if(!s||!n.model)return!1;const u=x(s)[0].toLowerCase(),a=x(n.model)[0].toLowerCase();return u===a}),n.view&&typeof n.view!="string"&&n.view.styles&&i.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),o.add(i)}return o}class ke extends h{static get requires(){return[le,ae]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class ue extends C{constructor(e){super(e,p)}}function A(t){return t.map(e=>me(e)).filter(e=>e!==void 0)}const k={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function me(t){if(typeof t=="number"&&(t=String(t)),typeof t=="object"&&pe(t))return S(t);const e=fe(t);if(e)return S(e);if(t==="default")return{model:void 0,title:"Default"};if(!ge(t))return de(t)}function de(t){return typeof t=="string"&&(t={title:t,model:`${parseFloat(t)}px`}),t.view={name:"span",styles:{"font-size":t.model}},S(t)}function S(t){return t.view&&typeof t.view!="string"&&!t.view.priority&&(t.view.priority=7),t}function fe(t){return typeof t=="string"?k[t]:k[t.model]}function pe(t){return t.title&&t.model&&t.view}function ge(t){let e;if(typeof t=="object")if(t.model)e=parseFloat(t.model);else throw new I("font-size-invalid-definition",null,t);else e=parseFloat(t);return isNaN(e)}const B=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class be extends h{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(p,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:p}),e.model.schema.setAttributeProperties(p,{isFormatting:!0,copyOnEnter:!0});const o=e.config.get("fontSize.supportAllValues"),n=A(this.editor.config.get("fontSize.options")).filter(s=>s.model),i=R(p,n);o?(this._prepareAnyValueConverters(i),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(p,new ue(e))}_prepareAnyValueConverters(e){const o=this.editor,n=e.model.values.filter(i=>!H(String(i))&&!Y(String(i)));if(n.length)throw new I("font-size-invalid-use-of-named-presets",null,{presets:n});o.conversion.for("downcast").attributeToElement({model:p,view:(i,{writer:s})=>{if(i)return s.createAttributeElement("span",{style:"font-size:"+i},{priority:7})}}),o.conversion.for("upcast").elementToAttribute({model:{key:p,value:i=>i.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:p,value:o=>{const n=o.getAttribute("size"),i=n[0]==="-"||n[0]==="+";let s=parseInt(n,10);i&&(s=3+s);const u=B.length-1,a=Math.min(Math.max(s,0),u);return B[a]}}})}}class he extends h{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,o=e.t,n=this._getLocalizedOptions(),i=e.commands.get(p),s=o("Font Size"),u=we(n,i);e.ui.componentFactory.add(p,a=>{const r=O(a);return P(r,u,{role:"menu",ariaLabel:s}),r.buttonView.set({label:s,icon:N,tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",m=>{e.execute(m.source.commandName,{value:m.source.commandParam}),e.editing.view.focus()}),r}),e.ui.componentFactory.add(`menuBar:${p}`,a=>{const r=new z(a);r.buttonView.set({label:s,icon:N}),r.bind("isEnabled").to(i);const m=new L(a);for(const d of u){const l=new T(a,r),c=new E(a);c.set({role:"menuitemradio",isToggleable:!0}),c.bind(...Object.keys(d.model)).to(d.model),c.delegate("execute").to(r),c.on("execute",()=>{e.execute(d.model.commandName,{value:d.model.commandParam}),e.editing.view.focus()}),l.children.add(c),m.items.add(l)}return r.panelView.children.add(m),r})}_getLocalizedOptions(){const e=this.editor,o=e.t,n={Default:o("Default"),Tiny:o("Tiny"),Small:o("Small"),Big:o("Big"),Huge:o("Huge")};return A(e.config.get(p).options).map(s=>{const u=n[s.title];return u&&u!=s.title&&(s=Object.assign({},s,{title:u})),s})}}function we(t,e){const o=new $;for(const n of t){const i={type:"button",model:new D({commandName:p,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&typeof n.view!="string"&&(n.view.styles&&i.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&i.model.set("class",`${i.model.class} ${n.view.classes}`)),i.model.bind("isOn").to(e,"value",s=>s===n.model),o.add(i)}return o}class Be extends h{static get requires(){return[be,he]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(e){return A(e)}}class ye extends C{constructor(e){super(e,w)}}class ve extends h{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(w,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:w,value:U("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:w,value:o=>o.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:w,view:M("color")}),e.commands.add(w,new ye(e)),e.model.schema.extend("$text",{allowAttributes:w}),e.model.schema.setAttributeProperties(w,{isFormatting:!0,copyOnEnter:!0})}}class K extends h{commandName;componentName;icon;dropdownLabel;columns;constructor(e,{commandName:o,componentName:n,icon:i,dropdownLabel:s}){super(e),this.commandName=o,this.componentName=n,this.icon=i,this.dropdownLabel=s,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,o=e.locale,n=o.t,i=e.commands.get(this.commandName),s=e.config.get(this.componentName),u=Z(s.colors),a=J(o,u),r=s.documentColors,m=s.colorPicker!==!1;e.ui.componentFactory.add(this.componentName,d=>{const l=O(d);let c=!1;const f=te({dropdownView:l,colors:a.map(b=>({label:b.label,color:b.model,options:{hasBorder:b.hasBorder}})),columns:this.columns,removeButtonLabel:n("Remove color"),colorPickerLabel:n("Color picker"),documentColorsLabel:r!==0?n("Document colors"):"",documentColorsCount:r===void 0?this.columns:r,colorPickerViewConfig:m?s.colorPicker||{}:!1});return f.bind("selectedColor").to(i,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(i),f.on("execute",(b,v)=>{l.isOpen&&e.execute(this.commandName,{value:v.value,batch:this._undoStepBatch}),v.source!=="colorPicker"&&e.editing.view.focus(),v.source==="colorPickerSaveButton"&&(l.isOpen=!1)}),f.on("colorPicker:show",()=>{this._undoStepBatch=e.model.createBatch()}),f.on("colorPicker:cancel",()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()}),l.on("change:isOpen",(b,v,F)=>{c||(c=!0,l.colorSelectorView.appendUI()),F&&(r!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),Q(l,()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find(b=>b.isOn)),l}),e.ui.componentFactory.add(`menuBar:${this.componentName}`,d=>{const l=new z(d);l.buttonView.set({label:this.dropdownLabel,icon:this.icon}),l.bind("isEnabled").to(i);let c=!1;const f=new _(d,{colors:a.map(b=>({label:b.label,color:b.model,options:{hasBorder:b.hasBorder}})),columns:this.columns,removeButtonLabel:n("Remove color"),colorPickerLabel:n("Color picker"),documentColorsLabel:r!==0?n("Document colors"):"",documentColorsCount:r===void 0?this.columns:r,colorPickerViewConfig:!1});return f.bind("selectedColor").to(i,"value"),f.delegate("execute").to(l),f.on("execute",(b,v)=>{e.execute(this.commandName,{value:v.value,batch:this._undoStepBatch}),e.editing.view.focus()}),l.on("change:isOpen",(b,v,F)=>{c||(c=!0,f.appendUI()),F&&(r!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),l.panelView.children.add(f),l})}}class Ce extends K{constructor(e){const o=e.locale.t;super(e,{commandName:w,componentName:w,icon:ee,dropdownLabel:o("Font Color")})}static get pluginName(){return"FontColorUI"}}class Pe extends h{static get requires(){return[ve,Ce]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class Fe extends C{constructor(e){super(e,y)}}class xe extends h{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(y,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(j),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:y,value:U("background-color")}}),e.conversion.for("downcast").attributeToElement({model:y,view:M("background-color")}),e.commands.add(y,new Fe(e)),e.model.schema.extend("$text",{allowAttributes:y}),e.model.schema.setAttributeProperties(y,{isFormatting:!0,copyOnEnter:!0})}}class Se extends K{constructor(e){const o=e.locale.t;super(e,{commandName:y,componentName:y,icon:X,dropdownLabel:o("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Le extends h{static get requires(){return[xe,Se]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}export{Le as FontBackgroundColor,Fe as FontBackgroundColorCommand,xe as FontBackgroundColorEditing,Se as FontBackgroundColorUI,Pe as FontColor,ye as FontColorCommand,ve as FontColorEditing,Ce as FontColorUI,K as FontColorUIBase,C as FontCommand,ke as FontFamily,ne as FontFamilyCommand,le as FontFamilyEditing,ae as FontFamilyUI,Be as FontSize,ue as FontSizeCommand,be as FontSizeEditing,he as FontSizeUI,te as _addFontColorSelectorToDropdown,R as _buildFontDefinition,G as _normalizeFontFamilyOptions,A as _normalizeFontSizeOptions,M as _renderDowncastFontElement,U as _renderUpcastFontColorAttribute};
|
|
1
|
+
import{Plugin as h,Command as q}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{addBackgroundStylesRules as j,isLengthStyleValue as H,isPercentageStyleValue as Y,ModelDocumentSelection as W}from"../../../../../@ckeditor_ckeditor5-engine@47.6.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{createDropdown as O,addListToDropdown as P,MenuBarMenuView as z,MenuBarMenuListView as L,MenuBarMenuListItemView as T,MenuBarMenuListItemButtonView as E,normalizeColorOptions as Z,getLocalizedColorOptions as J,focusChildOnDropdownOpen as Q,ColorSelectorView as _,UIModel as D}from"../../../../../@ckeditor_ckeditor5-ui@47.6.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{CKEditorError as I,Collection as $}from"../../../../../@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{IconFontBackground as X,IconFontColor as ee,IconFontFamily as V,IconFontSize as N}from"../../../../../@ckeditor_ckeditor5-icons@47.6.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";class C extends q{attributeKey;constructor(e,o){super(e),this.attributeKey=o}refresh(){const e=this.editor.model,o=e.document;this.value=o.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(o.selection,this.attributeKey)}execute(e={}){const o=this.editor.model,i=o.document.selection,s=e.value,u=e.batch,a=r=>{if(i.isCollapsed)s?r.setSelectionAttribute(this.attributeKey,s):r.removeSelectionAttribute(this.attributeKey);else{const m=o.schema.getValidRanges(i.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(const d of m){let l=d,c=this.attributeKey;d.isCollapsed&&(l=d.start.parent,c=W._getStoreAttributeKey(this.attributeKey)),s?r.setAttribute(c,s,l):r.removeAttribute(c,l)}}};u?o.enqueueChange(u,r=>{a(r)}):o.change(r=>{a(r)})}}const p="fontSize",g="fontFamily",w="fontColor",y="fontBackgroundColor";function R(t,e){const o={model:{key:t,values:[]},view:{},upcastAlso:{}};for(const n of e)o.model.values.push(n.model),o.view[n.model]=n.view,n.upcastAlso&&(o.upcastAlso[n.model]=n.upcastAlso);return o}function U(t){return e=>oe(e.getStyle(t))}function M(t){return(e,{writer:o})=>o.createAttributeElement("span",{style:`${t}:${e}`},{priority:7})}function te({dropdownView:t,colors:e,columns:o,removeButtonLabel:n,colorPickerLabel:i,documentColorsLabel:s,documentColorsCount:u,colorPickerViewConfig:a}){const r=t.locale,m=new _(r,{colors:e,columns:o,removeButtonLabel:n,colorPickerLabel:i,documentColorsLabel:s,documentColorsCount:u,colorPickerViewConfig:a});return t.colorSelectorView=m,t.panelView.children.add(m),m}function oe(t){return t.replace(/\s/g,"")}class ne extends C{constructor(e){super(e,g)}}function G(t){return t.map(ie).filter(e=>e!==void 0)}function x(t){return t.replace(/["']/g,"").split(",").map(e=>e.trim())}function ie(t){if(typeof t=="object")return t;if(t==="default")return{title:"Default",model:void 0};if(typeof t=="string")return re(t)}function re(t){const e=x(t),o=e[0],n=e.map(se).join(", ");return{title:o,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}function se(t){return t=t.trim(),t.indexOf(" ")>0&&(t=`'${t}'`),t}class le extends h{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(g,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:g}),e.model.schema.setAttributeProperties(g,{isFormatting:!0,copyOnEnter:!0});const o=G(e.config.get("fontFamily.options")).filter(i=>i.model),n=R(g,o);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(g,new ne(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:g,view:(o,{writer:n})=>n.createAttributeElement("span",{style:"font-family:"+o},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:g,value:o=>o.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:g,value:o=>o.getAttribute("face")}})}}class ae extends h{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,o=e.t,n=this._getLocalizedOptions(),i=e.commands.get(g),s=o("Font Family"),u=ce(n,i);e.ui.componentFactory.add(g,a=>{const r=O(a);return P(r,u,{role:"menu",ariaLabel:s}),r.buttonView.set({label:s,icon:V,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",m=>{e.execute(m.source.commandName,{value:m.source.commandParam}),e.editing.view.focus()}),r}),e.ui.componentFactory.add(`menuBar:${g}`,a=>{const r=new z(a);r.buttonView.set({label:s,icon:V}),r.bind("isEnabled").to(i);const m=new L(a);for(const d of u){const l=new T(a,r),c=new E(a);c.set({role:"menuitemradio",isToggleable:!0}),c.bind(...Object.keys(d.model)).to(d.model),c.delegate("execute").to(r),c.on("execute",()=>{e.execute(d.model.commandName,{value:d.model.commandParam}),e.editing.view.focus()}),l.children.add(c),m.items.add(l)}return r.panelView.children.add(m),r})}_getLocalizedOptions(){const e=this.editor,o=e.t;return G(e.config.get(g).options).map(i=>(i.title==="Default"&&(i.title=o("Default")),i))}}function ce(t,e){const o=new $;for(const n of t){const i={type:"button",model:new D({commandName:g,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};i.model.bind("isOn").to(e,"value",s=>{if(s===n.model)return!0;if(!s||!n.model)return!1;const u=x(s)[0].toLowerCase(),a=x(n.model)[0].toLowerCase();return u===a}),n.view&&typeof n.view!="string"&&n.view.styles&&i.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),o.add(i)}return o}class ke extends h{static get requires(){return[le,ae]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class ue extends C{constructor(e){super(e,p)}}function A(t){return t.map(e=>me(e)).filter(e=>e!==void 0)}const k={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function me(t){if(typeof t=="number"&&(t=String(t)),typeof t=="object"&&pe(t))return S(t);const e=fe(t);if(e)return S(e);if(t==="default")return{model:void 0,title:"Default"};if(!ge(t))return de(t)}function de(t){return typeof t=="string"&&(t={title:t,model:`${parseFloat(t)}px`}),t.view={name:"span",styles:{"font-size":t.model}},S(t)}function S(t){return t.view&&typeof t.view!="string"&&!t.view.priority&&(t.view.priority=7),t}function fe(t){return typeof t=="string"?k[t]:k[t.model]}function pe(t){return t.title&&t.model&&t.view}function ge(t){let e;if(typeof t=="object")if(t.model)e=parseFloat(t.model);else throw new I("font-size-invalid-definition",null,t);else e=parseFloat(t);return isNaN(e)}const B=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class be extends h{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(p,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:p}),e.model.schema.setAttributeProperties(p,{isFormatting:!0,copyOnEnter:!0});const o=e.config.get("fontSize.supportAllValues"),n=A(this.editor.config.get("fontSize.options")).filter(s=>s.model),i=R(p,n);o?(this._prepareAnyValueConverters(i),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(p,new ue(e))}_prepareAnyValueConverters(e){const o=this.editor,n=e.model.values.filter(i=>!H(String(i))&&!Y(String(i)));if(n.length)throw new I("font-size-invalid-use-of-named-presets",null,{presets:n});o.conversion.for("downcast").attributeToElement({model:p,view:(i,{writer:s})=>{if(i)return s.createAttributeElement("span",{style:"font-size:"+i},{priority:7})}}),o.conversion.for("upcast").elementToAttribute({model:{key:p,value:i=>i.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:p,value:o=>{const n=o.getAttribute("size"),i=n[0]==="-"||n[0]==="+";let s=parseInt(n,10);i&&(s=3+s);const u=B.length-1,a=Math.min(Math.max(s,0),u);return B[a]}}})}}class he extends h{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,o=e.t,n=this._getLocalizedOptions(),i=e.commands.get(p),s=o("Font Size"),u=we(n,i);e.ui.componentFactory.add(p,a=>{const r=O(a);return P(r,u,{role:"menu",ariaLabel:s}),r.buttonView.set({label:s,icon:N,tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",m=>{e.execute(m.source.commandName,{value:m.source.commandParam}),e.editing.view.focus()}),r}),e.ui.componentFactory.add(`menuBar:${p}`,a=>{const r=new z(a);r.buttonView.set({label:s,icon:N}),r.bind("isEnabled").to(i);const m=new L(a);for(const d of u){const l=new T(a,r),c=new E(a);c.set({role:"menuitemradio",isToggleable:!0}),c.bind(...Object.keys(d.model)).to(d.model),c.delegate("execute").to(r),c.on("execute",()=>{e.execute(d.model.commandName,{value:d.model.commandParam}),e.editing.view.focus()}),l.children.add(c),m.items.add(l)}return r.panelView.children.add(m),r})}_getLocalizedOptions(){const e=this.editor,o=e.t,n={Default:o("Default"),Tiny:o("Tiny"),Small:o("Small"),Big:o("Big"),Huge:o("Huge")};return A(e.config.get(p).options).map(s=>{const u=n[s.title];return u&&u!=s.title&&(s=Object.assign({},s,{title:u})),s})}}function we(t,e){const o=new $;for(const n of t){const i={type:"button",model:new D({commandName:p,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&typeof n.view!="string"&&(n.view.styles&&i.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&i.model.set("class",`${i.model.class} ${n.view.classes}`)),i.model.bind("isOn").to(e,"value",s=>s===n.model),o.add(i)}return o}class Be extends h{static get requires(){return[be,he]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(e){return A(e)}}class ye extends C{constructor(e){super(e,w)}}class ve extends h{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(w,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:w,value:U("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:w,value:o=>o.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:w,view:M("color")}),e.commands.add(w,new ye(e)),e.model.schema.extend("$text",{allowAttributes:w}),e.model.schema.setAttributeProperties(w,{isFormatting:!0,copyOnEnter:!0})}}class K extends h{commandName;componentName;icon;dropdownLabel;columns;constructor(e,{commandName:o,componentName:n,icon:i,dropdownLabel:s}){super(e),this.commandName=o,this.componentName=n,this.icon=i,this.dropdownLabel=s,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,o=e.locale,n=o.t,i=e.commands.get(this.commandName),s=e.config.get(this.componentName),u=Z(s.colors),a=J(o,u),r=s.documentColors,m=s.colorPicker!==!1;e.ui.componentFactory.add(this.componentName,d=>{const l=O(d);let c=!1;const f=te({dropdownView:l,colors:a.map(b=>({label:b.label,color:b.model,options:{hasBorder:b.hasBorder}})),columns:this.columns,removeButtonLabel:n("Remove color"),colorPickerLabel:n("Color picker"),documentColorsLabel:r!==0?n("Document colors"):"",documentColorsCount:r===void 0?this.columns:r,colorPickerViewConfig:m?s.colorPicker||{}:!1});return f.bind("selectedColor").to(i,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(i),f.on("execute",(b,v)=>{l.isOpen&&e.execute(this.commandName,{value:v.value,batch:this._undoStepBatch}),v.source!=="colorPicker"&&e.editing.view.focus(),v.source==="colorPickerSaveButton"&&(l.isOpen=!1)}),f.on("colorPicker:show",()=>{this._undoStepBatch=e.model.createBatch()}),f.on("colorPicker:cancel",()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()}),l.on("change:isOpen",(b,v,F)=>{c||(c=!0,l.colorSelectorView.appendUI()),F&&(r!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),Q(l,()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find(b=>b.isOn)),l}),e.ui.componentFactory.add(`menuBar:${this.componentName}`,d=>{const l=new z(d);l.buttonView.set({label:this.dropdownLabel,icon:this.icon}),l.bind("isEnabled").to(i);let c=!1;const f=new _(d,{colors:a.map(b=>({label:b.label,color:b.model,options:{hasBorder:b.hasBorder}})),columns:this.columns,removeButtonLabel:n("Remove color"),colorPickerLabel:n("Color picker"),documentColorsLabel:r!==0?n("Document colors"):"",documentColorsCount:r===void 0?this.columns:r,colorPickerViewConfig:!1});return f.bind("selectedColor").to(i,"value"),f.delegate("execute").to(l),f.on("execute",(b,v)=>{e.execute(this.commandName,{value:v.value,batch:this._undoStepBatch}),e.editing.view.focus()}),l.on("change:isOpen",(b,v,F)=>{c||(c=!0,f.appendUI()),F&&(r!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),l.panelView.children.add(f),l})}}class Ce extends K{constructor(e){const o=e.locale.t;super(e,{commandName:w,componentName:w,icon:ee,dropdownLabel:o("Font Color")})}static get pluginName(){return"FontColorUI"}}class Pe extends h{static get requires(){return[ve,Ce]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class Fe extends C{constructor(e){super(e,y)}}class xe extends h{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(y,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(j),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:y,value:U("background-color")}}),e.conversion.for("downcast").attributeToElement({model:y,view:M("background-color")}),e.commands.add(y,new Fe(e)),e.model.schema.extend("$text",{allowAttributes:y}),e.model.schema.setAttributeProperties(y,{isFormatting:!0,copyOnEnter:!0})}}class Se extends K{constructor(e){const o=e.locale.t;super(e,{commandName:y,componentName:y,icon:X,dropdownLabel:o("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Le extends h{static get requires(){return[xe,Se]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}export{Le as FontBackgroundColor,Fe as FontBackgroundColorCommand,xe as FontBackgroundColorEditing,Se as FontBackgroundColorUI,Pe as FontColor,ye as FontColorCommand,ve as FontColorEditing,Ce as FontColorUI,K as FontColorUIBase,C as FontCommand,ke as FontFamily,ne as FontFamilyCommand,le as FontFamilyEditing,ae as FontFamilyUI,Be as FontSize,ue as FontSizeCommand,be as FontSizeEditing,he as FontSizeUI,te as _addFontColorSelectorToDropdown,R as _buildFontDefinition,G as _normalizeFontFamilyOptions,A as _normalizeFontSizeOptions,M as _renderDowncastFontElement,U as _renderUpcastFontColorAttribute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as f,Command as H}from"../../../../../@ckeditor_ckeditor5-core@47.
|
|
1
|
+
import{Plugin as f,Command as H}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{Paragraph as v}from"../../../../../@ckeditor_ckeditor5-paragraph@47.6.0/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js";import{priorities as E,Collection as V,first as x}from"../../../../../@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{UIModel as C,createDropdown as M,addListToDropdown as k,MenuBarMenuView as L,MenuBarMenuListView as O,MenuBarMenuListItemView as P,MenuBarMenuListItemButtonView as T}from"../../../../../@ckeditor_ckeditor5-ui@47.6.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import"../../../../../@ckeditor_ckeditor5-engine@47.6.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";class y extends H{modelElements;constructor(e,t){super(e),this.modelElements=t}refresh(){const e=x(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>b(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,r=t.document,s=e.value;t.change(c=>{const l=Array.from(r.selection.getSelectedBlocks()).filter(a=>b(a,s,t.schema));for(const a of l)a.is("element",s)||c.rename(a,s)})}}function b(m,e,t){return t.checkChild(m.parent,e)&&!t.isObject(m)}const w="paragraph";class B extends f{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[v]}init(){const e=this.editor,t=e.config.get("heading.options"),r=[];for(const s of t)s.model!=="paragraph"&&(e.model.schema.register(s.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(s),r.push(s.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new y(e,r))}afterInit(){const e=this.editor,t=e.commands.get("enter"),r=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(s,c)=>{const l=e.model.document.selection.getFirstPosition().parent;r.some(g=>l.is("element",g.model))&&!l.is("element",w)&&l.childCount===0&&c.writer.rename(l,w)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:E.low+1})}}function I(m){const e=m.t,t={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return m.config.get("heading.options").map(r=>{const s=t[r.title];return s&&s!=r.title&&(r.title=s),r})}class N extends f{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,r=I(e),s=t("Choose heading"),c=t("Heading");e.ui.componentFactory.add("heading",l=>{const a={},g=new V,u=e.commands.get("heading"),h=e.commands.get("paragraph"),p=[u];for(const n of r){const i={type:"button",model:new C({label:n.title,class:n.class,role:"menuitemradio",withText:!0})};n.model==="paragraph"?(i.model.bind("isOn").to(h,"value"),i.model.set("commandName","paragraph"),p.push(h)):(i.model.bind("isOn").to(u,"value",d=>d===n.model),i.model.set({commandName:"heading",commandValue:n.model})),g.add(i),a[n.model]=n.title}const o=M(l);return k(o,g,{ariaLabel:c,role:"menu"}),o.buttonView.set({ariaLabel:c,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:c}),o.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),o.bind("isEnabled").toMany(p,"isEnabled",(...n)=>n.some(i=>i)),o.buttonView.bind("label").to(u,"value",h,"value",(n,i)=>{const d=i?"paragraph":n;return typeof d=="boolean"||!a[d]?s:a[d]}),o.buttonView.bind("ariaLabel").to(u,"value",h,"value",(n,i)=>{const d=i?"paragraph":n;return typeof d=="boolean"||!a[d]?c:`${a[d]}, ${c}`}),this.listenTo(o,"execute",n=>{const{commandName:i,commandValue:d}=n.source;e.execute(i,d?{value:d}:void 0),e.editing.view.focus()}),o}),e.ui.componentFactory.add("menuBar:heading",l=>{const a=new L(l),g=e.commands.get("heading"),u=e.commands.get("paragraph"),h=[g],p=new O(l);a.set({class:"ck-heading-dropdown"}),p.set({ariaLabel:t("Heading"),role:"menu"}),a.buttonView.set({label:t("Heading")}),a.panelView.children.add(p);for(const o of r){const n=new P(l,a),i=new T(l);n.children.add(i),p.items.add(n),i.set({isToggleable:!0,label:o.title,role:"menuitemradio",class:o.class}),i.delegate("execute").to(a),i.on("execute",()=>{const d=o.model==="paragraph"?"paragraph":"heading";e.execute(d,{value:o.model}),e.editing.view.focus()}),o.model==="paragraph"?(i.bind("isOn").to(u,"value"),h.push(u)):i.bind("isOn").to(g,"value",d=>d===o.model)}return a.bind("isEnabled").toMany(h,"isEnabled",(...o)=>o.some(n=>n)),a})}}class $ extends f{static get requires(){return[B,N]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}}export{$ as Heading,y as HeadingCommand,B as HeadingEditing,N as HeadingUI,I as _getLocalizedHeadingOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as w,Command as V}from"../../../../../@ckeditor_ckeditor5-core@47.
|
|
1
|
+
import{Plugin as w,Command as V}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{ModelDocumentSelection as x}from"../../../../../@ckeditor_ckeditor5-engine@47.6.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{IconEraser as k,IconMarker as B,IconPen as y}from"../../../../../@ckeditor_ckeditor5-icons@47.6.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";import{ButtonView as E,createDropdown as H,addToolbarToDropdown as M,MenuBarMenuView as A,MenuBarMenuListView as T,MenuBarMenuListItemView as f,MenuBarMenuListItemButtonView as v,ListSeparatorView as I,SplitButtonView as O,ToolbarSeparatorView as P}from"../../../../../@ckeditor_ckeditor5-ui@47.6.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";class R extends V{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,s=t.document.selection,n=e.value;t.change(i=>{if(s.isCollapsed){const h=s.getFirstPosition();if(s.hasAttribute("highlight")){const l=c=>c.item.hasAttribute("highlight")&&c.item.getAttribute("highlight")===this.value,r=h.getLastMatchingPosition(l,{direction:"backward"}),o=h.getLastMatchingPosition(l),u=i.createRange(r,o);!n||this.value===n?(h.isEqual(o)||i.removeAttribute("highlight",u),i.removeSelectionAttribute("highlight")):(h.isEqual(o)||i.setAttribute("highlight",n,u),i.setSelectionAttribute("highlight",n))}else n&&i.setSelectionAttribute("highlight",n)}else{const h=t.schema.getValidRanges(s.getRanges(),"highlight",{includeEmptyRanges:!0});for(const l of h){let r=l,o="highlight";l.isCollapsed&&(r=l.start.parent,o=x._getStoreAttributeKey("highlight")),n?i.setAttribute(o,n,r):i.removeAttribute(o,r)}}})}}class _ extends w{static get pluginName(){return"HighlightEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-content-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-content-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-content-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-content-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-content-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-content-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(S(t)),e.commands.add("highlight",new R(e))}}function S(d){const e={model:{key:"highlight",values:[]},view:{}};for(const t of d)e.model.values.push(t.model),e.view[t.model]={name:"mark",classes:t.class};return e}class C extends w{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e),this._addMenuBarButton(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),k,null,g=>{g.bind("isEnabled").to(t,"isEnabled")})}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,b(e.type),e.model,g);function g(s){s.bind("isEnabled").to(t,"isEnabled"),s.bind("isOn").to(t,"value",n=>n===e.model),s.iconView.fillColor=e.color,s.isToggleable=!0}}_addButton(e,t,g,s,n){const i=this.editor;i.ui.componentFactory.add(e,h=>{const l=new E(h),r=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return l.set({label:r,icon:g,tooltip:!0}),l.on("execute",()=>{i.execute("highlight",{value:s}),i.editing.view.focus()}),n(l),l})}_addDropdown(e){const t=this.editor,g=t.t,s=t.ui.componentFactory,n=e[0],i=e.reduce((h,l)=>(h[l.model]=l,h),{});s.add("highlight",h=>{const l=t.commands.get("highlight"),r=H(h,O),o=r.buttonView;o.set({label:g("Highlight"),tooltip:!0,lastExecuted:n.model,commandValue:n.model,isToggleable:!0}),o.bind("icon").to(l,"value",a=>b(c(a,"type"))),o.bind("color").to(l,"value",a=>c(a,"color")),o.bind("commandValue").to(l,"value",a=>c(a,"model")),o.bind("isOn").to(l,"value",a=>!!a),o.delegate("execute").to(r);const u=()=>{const a=e.map(m=>{const p=s.create("highlight:"+m.model);return this.listenTo(p,"execute",()=>{r.buttonView.set({lastExecuted:m.model})}),p});return a.push(new P),a.push(s.create("removeHighlight")),a};r.bind("isEnabled").to(l,"isEnabled"),M(r,u,{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:g("Text highlight toolbar")}),D(r),o.on("execute",()=>{t.execute("highlight",{value:o.commandValue})}),this.listenTo(r,"execute",()=>{t.editing.view.focus()});function c(a,m){const p=!a||a===o.lastExecuted?o.lastExecuted:a;return i[p][m]}return r})}_addMenuBarButton(e){const t=this.editor,g=t.t,s=t.commands.get("highlight");t.ui.componentFactory.add("menuBar:highlight",n=>{const i=new A(n);i.buttonView.set({label:g("Highlight"),icon:b("marker")}),i.bind("isEnabled").to(s),i.buttonView.iconView.fillColor="transparent";const h=new T(n);for(const o of e){const u=new f(n,i),c=new v(n);c.set({label:o.title,icon:b(o.type),role:"menuitemradio",isToggleable:!0}),c.iconView.fillColor=o.color,c.delegate("execute").to(i),c.bind("isOn").to(s,"value",a=>a===o.model),c.on("execute",()=>{t.execute("highlight",{value:o.model}),t.editing.view.focus()}),u.children.add(c),h.items.add(u)}h.items.add(new I(n));const l=new f(n,i),r=new v(n);return r.set({label:g("Remove highlight"),icon:k}),r.delegate("execute").to(i),r.on("execute",()=>{t.execute("highlight",{value:null}),t.editing.view.focus()}),l.children.add(r),h.items.add(l),i.panelView.children.add(h),i})}}function D(d){d.buttonView.actionView.iconView.bind("fillColor").to(d.buttonView,"color")}function b(d){return d==="marker"?B:y}class q extends w{static get requires(){return[_,C]}static get pluginName(){return"Highlight"}static get isOfficialPlugin(){return!0}}export{q as Highlight,R as HighlightCommand,_ as HighlightEditing,C as HighlightUI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as s,Command as m}from"../../../../../@ckeditor_ckeditor5-core@47.
|
|
1
|
+
import{Plugin as s,Command as m}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{Widget as u,toWidget as d,findOptimalInsertionRange as h}from"../../../../../@ckeditor_ckeditor5-widget@47.6.0/node_modules/@ckeditor/ckeditor5-widget/dist/index.js";import{IconHorizontalLine as g}from"../../../../../@ckeditor_ckeditor5-icons@47.6.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";import{ButtonView as z,MenuBarMenuListItemButtonView as L}from"../../../../../@ckeditor_ckeditor5-ui@47.6.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";class p extends m{refresh(){const t=this.editor.model,e=t.schema,n=t.document.selection;this.isEnabled=f(n,e,t)}execute(){const t=this.editor.model;t.change(e=>{const n=e.createElement("horizontalLine");t.insertObject(n,null,null,{setSelection:"after"})})}}function f(o,t,e){const n=E(o,e);return t.checkChild(n,"horizontalLine")}function E(o,t){const n=h(o,t).start.parent;return n.isEmpty&&!n.is("element","$root")?n.parent:n}class H extends s{static get pluginName(){return"HorizontalLineEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.model.schema,n=t.t,a=t.conversion;e.register("horizontalLine",{inheritAllFrom:"$blockObject"}),a.for("dataDowncast").elementToElement({model:"horizontalLine",view:(r,{writer:i})=>i.createEmptyElement("hr")}),a.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(r,{writer:i})=>{const c=n("Horizontal line"),l=i.createContainerElement("div",null,i.createEmptyElement("hr"));return i.addClass("ck-horizontal-line",l),i.setCustomProperty("hr",!0,l),b(l,i,c)}}),a.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),t.commands.add("horizontalLine",new p(t))}}function b(o,t,e){return t.setCustomProperty("horizontalLine",!0,o),d(o,t,{label:e})}class v extends s{static get pluginName(){return"HorizontalLineUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.ui.componentFactory.add("horizontalLine",()=>{const e=this._createButton(z);return e.set({tooltip:!0}),e}),t.ui.componentFactory.add("menuBar:horizontalLine",()=>this._createButton(L))}_createButton(t){const e=this.editor,n=e.locale,a=e.commands.get("horizontalLine"),r=new t(e.locale),i=n.t;return r.set({label:i("Horizontal line"),icon:g}),r.bind("isEnabled").to(a,"isEnabled"),this.listenTo(r,"execute",()=>{e.execute("horizontalLine"),e.editing.view.focus()}),r}}class B extends s{static get requires(){return[H,v,u]}static get pluginName(){return"HorizontalLine"}static get isOfficialPlugin(){return!0}}export{B as HorizontalLine,p as HorizontalLineCommand,H as HorizontalLineEditing,v as HorizontalLineUI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Plugin as f,Command as B}from"../../../../../@ckeditor_ckeditor5-core@47.
|
|
1
|
+
import{Plugin as f,Command as B}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{Widget as V,toWidget as S,findOptimalInsertionRange as A}from"../../../../../@ckeditor_ckeditor5-widget@47.6.0/node_modules/@ckeditor/ckeditor5-widget/dist/index.js";import{ButtonView as P,MenuBarMenuListItemButtonView as T}from"../../../../../@ckeditor_ckeditor5-ui@47.6.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{logWarning as I,createElement as b}from"../../../../../@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{IconHtml as L,IconPencil as C,IconCheck as D,IconCancel as M}from"../../../../../@ckeditor_ckeditor5-icons@47.6.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";class y extends B{refresh(){const e=this.editor.model,i=e.schema,a=e.document.selection,t=H(a);this.isEnabled=O(a,i,e),this.value=t?t.getAttribute("value")||"":null}execute(e){const i=this.editor.model,a=i.document.selection;i.change(t=>{let w;this.value!==null?w=H(a):(w=t.createElement("rawHtml"),i.insertObject(w,null,null,{setSelection:"on"})),t.setAttribute("value",e,w)})}}function O(m,e,i){const a=W(m,i);return e.checkChild(a,"rawHtml")}function W(m,e){const a=A(m,e).start.parent;return a.isEmpty&&!a.is("rootElement")?a.parent:a}function H(m){const e=m.getSelectedElement();return e&&e.is("element","rawHtml")?e:null}class z extends f{_widgetButtonViewReferences=new Set;static get pluginName(){return"HtmlEmbedEditing"}static get licenseFeatureCode(){return"HE"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("htmlEmbed",{showPreviews:!1,sanitizeHtml:i=>(I("html-embed-provide-sanitize-function"),{html:i,hasChanged:!1})})}init(){const e=this.editor;e.model.schema.register("rawHtml",{inheritAllFrom:"$blockObject",allowAttributes:["value"]}),e.commands.add("htmlEmbed",new y(e)),this._setupConversion()}_setupConversion(){const e=this.editor,i=e.t,a=e.editing.view,t=this._widgetButtonViewReferences,w=e.config.get("htmlEmbed");this.editor.editing.view.on("render",()=>{for(const o of t){if(o.element&&o.element.isConnected)return;o.destroy(),t.delete(o)}},{priority:"lowest"}),e.data.registerRawContentMatcher({name:"div",classes:"raw-html-embed"}),e.conversion.for("upcast").elementToElement({view:{name:"div",classes:"raw-html-embed"},model:(o,{writer:l})=>l.createElement("rawHtml",{value:o.getCustomProperty("$rawContent")})}),e.conversion.for("dataDowncast").elementToElement({model:"rawHtml",view:(o,{writer:l})=>l.createRawElement("div",{class:"raw-html-embed"},function(s){s.innerHTML=o.getAttribute("value")||""})}),e.conversion.for("editingDowncast").elementToStructure({model:{name:"rawHtml",attributes:["value"]},view:(o,{writer:l})=>{let s,n,r;const c=l.createRawElement("div",{class:"raw-html-embed__content-wrapper"},function(u){s=u,h({editor:e,domElement:u,state:n,props:r}),s.addEventListener("mousedown",()=>{if(n.isEditable){const g=e.model;g.document.selection.getSelectedElement()!==o&&g.change(R=>R.setSelection(o,"on"))}},!0)}),p={makeEditable(){n=Object.assign({},n,{isEditable:!0}),h({domElement:s,editor:e,state:n,props:r}),a.change(u=>{u.setAttribute("data-cke-ignore-events","true",c)}),s.querySelector("textarea").focus()},save(u){u!==n.getRawHtmlValue()?(e.execute("htmlEmbed",u),e.editing.view.focus()):this.cancel()},cancel(){n=Object.assign({},n,{isEditable:!1}),h({domElement:s,editor:e,state:n,props:r}),e.editing.view.focus(),a.change(u=>{u.removeAttribute("data-cke-ignore-events",c)})}};n={showPreviews:w.showPreviews,isEditable:!1,getRawHtmlValue:()=>o.getAttribute("value")||""},r={sanitizeHtml:w.sanitizeHtml,textareaPlaceholder:i("Paste raw HTML here..."),onEditClick(){p.makeEditable()},onSaveClick(u){p.save(u)},onCancelClick(){p.cancel()}};const d=l.createContainerElement("div",{class:"raw-html-embed","data-html-embed-label":i("HTML snippet"),dir:e.locale.uiLanguageDirection},c);return l.setCustomProperty("rawHtmlApi",p,d),l.setCustomProperty("rawHtml",!0,d),S(d,l,{label:i("HTML snippet"),hasSelectionHandle:!0})}});function h({editor:o,domElement:l,state:s,props:n}){l.textContent="";const r=l.ownerDocument;let c;if(s.isEditable){const d={isDisabled:!1,placeholder:n.textareaPlaceholder};c=E({domDocument:r,state:s,props:d}),l.append(c)}else if(s.showPreviews){const d={sanitizeHtml:n.sanitizeHtml};l.append(x({domDocument:r,state:s,props:d,editor:o}))}else{const d={isDisabled:!0,placeholder:n.textareaPlaceholder};l.append(E({domDocument:r,state:s,props:d}))}const p={onEditClick:n.onEditClick,onSaveClick:()=>{n.onSaveClick(c.value)},onCancelClick:n.onCancelClick};l.prepend(k({editor:o,domDocument:r,state:s,props:p}))}function k({editor:o,domDocument:l,state:s,props:n}){const r=b(l,"div",{class:"raw-html-embed__buttons-wrapper"});if(s.isEditable){const c=v(o,"save",n.onSaveClick),p=v(o,"cancel",n.onCancelClick);r.append(c.element,p.element),t.add(c).add(p)}else{const c=v(o,"edit",n.onEditClick);r.append(c.element),t.add(c)}return r}function E({domDocument:o,state:l,props:s}){const n=b(o,"textarea",{placeholder:s.placeholder,class:"ck ck-reset ck-input ck-input-text raw-html-embed__source"});return n.disabled=s.isDisabled,n.value=l.getRawHtmlValue(),n}function x({editor:o,domDocument:l,state:s,props:n}){const r=n.sanitizeHtml(s.getRawHtmlValue()),c=s.getRawHtmlValue().length>0?i("No preview available"):i("Empty snippet content"),p=b(l,"div",{class:"ck ck-reset_all raw-html-embed__preview-placeholder"},c),d=b(l,"div",{class:"raw-html-embed__preview-content",dir:o.locale.contentLanguageDirection}),g=l.createRange().createContextualFragment(r.html);return d.appendChild(g),b(l,"div",{class:"raw-html-embed__preview"},[p,d])}}}function v(m,e,i){const{t:a}=m.locale,t=new P(m.locale),w=m.commands.get("htmlEmbed");return t.set({class:`raw-html-embed__${e}-button`,icon:C,tooltip:!0,tooltipPosition:m.locale.uiLanguageDirection==="rtl"?"e":"w"}),t.render(),e==="edit"?(t.set({icon:C,label:a("Edit source")}),t.bind("isEnabled").to(w)):e==="save"?(t.set({icon:D,label:a("Save changes")}),t.bind("isEnabled").to(w)):t.set({icon:M,label:a("Cancel")}),t.on("execute",i),t}class F extends f{static get pluginName(){return"HtmlEmbedUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,a=e.locale.t;e.ui.componentFactory.add("htmlEmbed",()=>{const t=this._createButton(P);return t.set({tooltip:!0,label:a("Insert HTML")}),t}),e.ui.componentFactory.add("menuBar:htmlEmbed",()=>{const t=this._createButton(T);return t.set({label:a("HTML snippet")}),t})}_createButton(e){const i=this.editor,a=i.commands.get("htmlEmbed"),t=new e(i.locale);return t.set({icon:L}),t.bind("isEnabled").to(a,"isEnabled"),this.listenTo(t,"execute",()=>{i.execute("htmlEmbed"),i.editing.view.focus(),i.editing.view.document.selection.getSelectedElement().getCustomProperty("rawHtmlApi").makeEditable()}),t}}class G extends f{static get requires(){return[z,F,V]}static get pluginName(){return"HtmlEmbed"}static get isOfficialPlugin(){return!0}}export{G as HtmlEmbed,y as HtmlEmbedCommand,z as HtmlEmbedEditing,F as HtmlEmbedUI};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Plugin as g}from"../../../../../@ckeditor_ckeditor5-core@47.6.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{logWarning as Q,global as R,uid as M,priorities as P,CKEditorError as Y,toArray as T,isValidAttributeName as J}from"../../../../../@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{UpcastWriter as x,HtmlDataProcessor as Z,Matcher as j,StylesMap as tt}from"../../../../../@ckeditor_ckeditor5-engine@47.6.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{Widget as et,toWidget as X}from"../../../../../@ckeditor_ckeditor5-widget@47.6.0/node_modules/@ckeditor/ckeditor5-widget/dist/index.js";import{Enter as rt}from"../../../../../@ckeditor_ckeditor5-enter@47.6.0/node_modules/@ckeditor/ckeditor5-enter/dist/index.js";import{isEqual as N}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/predicate/isEqual.js";import{mergeWith as it}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/mergeWith.js";import{startCase as ot}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/string/startCase.js";import{isPlainObject as lt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js";import{cloneDeep as nt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/cloneDeep.js";function w(s,t,r,i){t&&st(s,t,i),r&&A(s,r,i)}function A(s,t,r){if(t.attributes)for(const[i,e]of Object.entries(t.attributes))s.setAttribute(i,e,r);t.styles&&s.setStyle(t.styles,r),t.classes&&s.addClass(t.classes,r)}function st(s,t,r){if(t.attributes)for(const[i]of Object.entries(t.attributes))s.removeAttribute(i,r);if(t.styles)for(const i of Object.keys(t.styles))s.removeStyle(i,r);t.classes&&s.removeClass(t.classes,r)}function mt(s,t){const r=nt(s);let i="attributes";for(i in t)i=="classes"?r[i]=Array.from(new Set([...s[i]||[],...t[i]])):r[i]={...s[i],...t[i]};return r}function S(s,t,r,i,e){const o=t.getAttribute(r),l={};for(const n of["attributes","styles","classes"]){if(n!=i){o&&o[n]&&(l[n]=o[n]);continue}if(i=="classes"){const a=new Set(o&&o.classes||[]);e(a),a.size&&(l[n]=Array.from(a));continue}const m=new Map(Object.entries(o&&o[n]||{}));e(m),m.size&&(l[n]=Object.fromEntries(m))}Object.keys(l).length?t.is("documentSelection")?s.setSelectionAttribute(r,l):s.setAttribute(r,l,t):o&&(t.is("documentSelection")?s.removeSelectionAttribute(r):s.removeAttribute(r,t))}function at(s,t,r){for(const i of t.getItems({shallow:!0})){const e=i.getAttribute(s);e&&e.attributes&&Object.keys(e.attributes).length?Object.keys(e).length>1&&r.setAttribute(s,{attributes:e.attributes},i):r.removeAttribute(s,i)}}function ut(s){return ot(s).replace(/ /g,"")}function p(s){return`html${ut(s)}Attributes`}function B({model:s}){return(t,r)=>r.writer.createElement(s,{htmlContent:t.getCustomProperty("$rawContent")})}function ct(s,{view:t,isInline:r}){const i=s.t;return(e,{writer:o})=>{const l=i("HTML object"),n=_(t,e,o),m=e.getAttribute(p(t));o.addClass("html-object-embed__content",n),m&&A(o,m,n);const a=o.createContainerElement(r?"span":"div",{class:"html-object-embed","data-html-object-embed-label":l},n);return X(a,o,{label:l})}}function _(s,t,r){return r.createRawElement(s,null,(i,e)=>{e.setContentOf(i,t.getAttribute("htmlContent"))})}function dt({view:s,model:t,allowEmpty:r},i){return o=>{o.on(`element:${s}`,(l,n,m)=>{let a=i.processViewAttributes(n.viewItem,m);if(!(!a&&!m.consumable.test(n.viewItem,{name:!0}))){if(a=a||{},m.consumable.consume(n.viewItem,{name:!0}),n.modelRange||(n=Object.assign(n,m.convertChildren(n.viewItem,n.modelCursor))),r&&n.modelRange.isCollapsed&&Object.keys(a).length){const u=m.writer.createElement("htmlEmptyElement");if(!m.safeInsert(u,n.modelCursor))return;const c=m.getSplitParts(u);n.modelRange=m.writer.createRange(n.modelRange.start,m.writer.createPositionAfter(c[c.length-1])),m.updateConversionResult(u,n),e(u,a,m);return}for(const u of n.modelRange.getItems())e(u,a,m)}},{priority:"low"})};function e(o,l,n){if(n.schema.checkAttribute(o,t)){const m=o.getAttribute(t),a=mt(l,m||{});n.writer.setAttribute(t,a,o)}}}function L({model:s,view:t},r){return(i,{writer:e,consumable:o})=>{if(!i.hasAttribute(s))return null;const l=e.createContainerElement(t),n=i.getAttribute(s);return o.consume(i,`attribute:${s}`),A(e,n,l),l.getFillerOffset=()=>null,r?X(l,e):l}}function ht({priority:s,view:t}){return(r,i)=>{if(!r)return;const{writer:e}=i,o=e.createAttributeElement(t,null,{priority:s});return A(e,r,o),o}}function k({view:s},t){return r=>{r.on(`element:${s}`,(i,e,o)=>{if(!e.modelRange||e.modelRange.isCollapsed)return;const l=t.processViewAttributes(e.viewItem,o);l&&o.writer.setAttribute(p(e.viewItem.name),l,e.modelRange)},{priority:"low"})}}function I({view:s,model:t}){return r=>{r.on(`attribute:${p(s)}:${t}`,(i,e,o)=>{if(!o.consumable.consume(e.item,i.name))return;const{attributeOldValue:l,attributeNewValue:n}=e,m=o.writer,a=o.mapper.toViewElement(e.item);w(m,l,n,a)})}}const W={block:[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"horizontalLine",view:"hr"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6","$text"],allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowIn:["$root","$container"],allowChildren:["paragraph","htmlP","htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDiv"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",allowIn:"htmlDiv",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",allowIn:"htmlDiv",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlHr",view:"hr",isEmpty:!0,modelSchema:{inheritAllFrom:"$blockObject"}}],inline:[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref",attributeProperties:{isFormatting:!0}},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}]};class F extends g{_definitions=[];static get pluginName(){return"DataSchema"}static get isOfficialPlugin(){return!0}init(){for(const t of W.block)this.registerBlockElement(t);for(const t of W.inline)this.registerInlineElement(t)}registerBlockElement(t){this._definitions.push({...t,isBlock:!0})}registerInlineElement(t){this._definitions.push({...t,isInline:!0})}extendBlockElement(t){this._extendDefinition({...t,isBlock:!0})}extendInlineElement(t){this._extendDefinition({...t,isInline:!0})}getDefinitionsForView(t,r=!1){const i=new Set;for(const e of this._getMatchingViewDefinitions(t)){if(r)for(const o of this._getReferences(e.model))i.add(o);i.add(e)}return i}getDefinitionsForModel(t){return this._definitions.filter(r=>r.model==t)}_getMatchingViewDefinitions(t){return this._definitions.filter(r=>r.view&&ft(t,r.view))}*_getReferences(t){const r=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter(e=>e.model==t);for(const{modelSchema:e}of i)if(e)for(const o of r)for(const l of T(e[o]||[])){const n=this._definitions.filter(m=>m.model==l);for(const m of n)l!==t&&(yield*this._getReferences(m.model),yield m)}}_extendDefinition(t){const r=Array.from(this._definitions.entries()).filter(([,i])=>i.model==t.model);if(r.length==0){this._definitions.push(t);return}for(const[i,e]of r)this._definitions[i]=it({},e,t,(o,l)=>Array.isArray(o)?o.concat(l):void 0)}}function ft(s,t){return typeof s=="string"?s===t:s instanceof RegExp?s.test(t):!1}class h extends g{_dataSchema;_allowedAttributes;_disallowedAttributes;_allowedElements;_disallowedElements;_dataInitialized;_coupledAttributes;constructor(t){super(t),this._dataSchema=t.plugins.get("DataSchema"),this._allowedAttributes=new j,this._disallowedAttributes=new j,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get isOfficialPlugin(){return!0}static get requires(){return[F,et]}loadAllowedConfig(t){for(const r of t){const i=r.name||/[\s\S]+/,e=U(r);this.allowElement(i),e.forEach(o=>this.allowAttributes(o))}}loadDisallowedConfig(t){for(const r of t){const i=r.name||/[\s\S]+/,e=U(r);e.length==0?this.disallowElement(i):e.forEach(o=>this.disallowAttributes(o))}}loadAllowedEmptyElementsConfig(t){for(const r of t)this.allowEmptyElement(r)}allowElement(t){for(const r of this._dataSchema.getDefinitionsForView(t,!0))this._addAllowedElement(r),this._coupledAttributes=null}disallowElement(t){for(const r of this._dataSchema.getDefinitionsForView(t,!1))this._disallowedElements.add(r.view)}allowEmptyElement(t){for(const r of this._dataSchema.getDefinitionsForView(t,!0))r.isInline&&this._dataSchema.extendInlineElement({...r,allowEmpty:!0})}allowAttributes(t){this._allowedAttributes.add(t)}disallowAttributes(t){this._disallowedAttributes.add(t)}processViewAttributes(t,r){const{consumable:i}=r;return q(t,this._disallowedAttributes,i),gt(t,q(t,this._allowedAttributes,i))}_addAllowedElement(t){if(!this._allowedElements.has(t)){if(this._allowedElements.add(t),"appliesToBlock"in t&&typeof t.appliesToBlock=="string")for(const r of this._dataSchema.getDefinitionsForModel(t.appliesToBlock))r.isBlock&&this._addAllowedElement(r);this._dataInitialized&&this.editor.data.once("set",()=>{this._fireRegisterEvent(t)},{priority:P.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",()=>{this._dataInitialized=!0;for(const t of this._allowedElements)this._fireRegisterEvent(t)},{priority:P.highest+1})}_registerElementHandlers(){this.on("register",(t,r)=>{const i=this.editor.model.schema;if(r.isObject&&!i.isRegistered(r.model))this._registerObjectElement(r);else if(r.isBlock)this._registerBlockElement(r);else if(r.isInline)this._registerInlineElement(r);else throw new Y("data-filter-invalid-definition",null,r);t.stop()},{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const t=this.editor.model,r=t.document.selection;t.document.registerPostFixer(i=>{const e=t.document.differ.getChanges();let o=!1;const l=this._getCoupledAttributesMap();for(const n of e){if(n.type!="attribute"||n.attributeNewValue!==null)continue;const m=l.get(n.attributeKey);if(m)for(const{item:a}of n.range.getWalker())for(const u of m)a.hasAttribute(u)&&(i.removeAttribute(u,a),o=!0)}return o}),this.listenTo(r,"change:attribute",(i,{attributeKeys:e})=>{const o=new Set,l=this._getCoupledAttributesMap();for(const n of e){if(r.hasAttribute(n))continue;const m=l.get(n);if(m)for(const a of m)r.hasAttribute(a)&&o.add(a)}o.size!=0&&t.change(n=>{for(const m of o)n.removeSelectionAttribute(m)})})}_registerAssociatedHtmlAttributesPostFixer(){const t=this.editor.model;t.document.registerPostFixer(r=>{const i=t.document.differ.getChanges();let e=!1;for(const o of i)if(!(o.type!=="insert"||o.name==="$text"))for(const l of o.attributes.keys())!l.startsWith("html")||!l.endsWith("Attributes")||t.schema.checkAttribute(o.name,l)||(r.removeAttribute(l,o.position.nodeAfter),e=!0);return e})}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const t of this._allowedElements)if(t.coupledAttribute&&t.model){const r=this._coupledAttributes.get(t.coupledAttribute);r?r.push(t.model):this._coupledAttributes.set(t.coupledAttribute,[t.model])}return this._coupledAttributes}_fireRegisterEvent(t){t.view&&this._disallowedElements.has(t.view)||this.fire(t.view?`register:${t.view}`:"register",t)}_registerObjectElement(t){const r=this.editor,i=r.model.schema,e=r.conversion,{view:o,model:l}=t;i.register(l,t.modelSchema);o&&(i.extend(t.model,{allowAttributes:[p(o),"htmlContent"]}),r.data.registerRawContentMatcher({name:o}),e.for("upcast").elementToElement({view:o,model:B(t),converterPriority:P.low+2}),e.for("upcast").add(k(t,this)),e.for("editingDowncast").elementToStructure({model:{name:l,attributes:[p(o)]},view:ct(r,t)}),e.for("dataDowncast").elementToElement({model:l,view:(n,{writer:m})=>_(o,n,m)}),e.for("dataDowncast").add(I(t)))}_registerBlockElement(t){const r=this.editor,i=r.model.schema,e=r.conversion,{view:o,model:l}=t;if(!i.isRegistered(t.model)){if(!t.modelSchema||(i.register(t.model,t.modelSchema),!o))return;e.for("upcast").elementToElement({model:l,view:o,converterPriority:P.low+2}),e.for("downcast").elementToElement({model:l,view:(n,{writer:m})=>t.isEmpty?m.createEmptyElement(o):m.createContainerElement(o)})}o&&(i.extend(t.model,{allowAttributes:p(o)}),e.for("upcast").add(k(t,this)),e.for("downcast").add(I(t)))}_registerInlineElement(t){const r=this.editor,i=r.model.schema,e=r.conversion,o=t.model;if(!t.appliesToBlock&&(i.extend("$text",{allowAttributes:o}),t.attributeProperties&&i.setAttributeProperties(o,t.attributeProperties),e.for("upcast").add(dt(t,this)),e.for("downcast").attributeToElement({model:o,view:ht(t)}),!!t.allowEmpty)){if(i.setAttributeProperties(o,{copyFromObject:!1}),!i.isRegistered("htmlEmptyElement")){i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"});const l=n=>Array.from(n.getAttributeKeys()).some(m=>m.startsWith("html"));r.model.document.registerPostFixer(n=>{const m=r.model.document.differ.getChanges(),a=new Set;for(const u of m)if(u.type!=="remove"){if(u.type==="attribute"&&u.attributeNewValue===null)for(const{item:c}of u.range)c.is("element","htmlEmptyElement")&&!l(c)&&a.add(c);if(u.type==="insert"&&u.position.nodeAfter){const c=u.position.nodeAfter;for(const{item:d}of n.createRangeOn(c))d.is("element","htmlEmptyElement")&&!l(d)&&a.add(d)}}for(const u of a)n.remove(u);return a.size>0})}r.data.htmlProcessor.domConverter.registerInlineObjectMatcher(l=>l.name==t.view&&l.isEmpty&&Array.from(l.getAttributeKeys()).length?{name:!0}:null),e.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:L(t,!0)}),e.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:L(t)})}}}function q(s,t,r){const i=t.matchAll(s)||[],e=s.document.stylesProcessor;return i.reduce((o,{match:l})=>{for(const[n,m]of l.attributes||[])if(n=="style"){const a=m,u=e.getRelatedStyles(a).filter(c=>c.split("-").length>a.split("-").length).sort((c,d)=>d.split("-").length-c.split("-").length);for(const c of u)r.consume(s,{styles:[c]})&&o.styles.push(c);r.consume(s,{styles:[a]})&&o.styles.push(a)}else if(n=="class"){const a=m;r.consume(s,{classes:[a]})&&o.classes.push(a)}else r.consume(s,{attributes:[n]})&&o.attributes.push(n);return o},{attributes:[],classes:[],styles:[]})}function gt(s,{attributes:t,classes:r,styles:i}){return!t.length&&!r.length&&!i.length?null:{...t.length&&{attributes:bt(s,t)},...i.length&&{styles:pt(s,i)},...r.length&&{classes:r}}}function bt(s,t){const r={};for(const i of t){const e=s.getAttribute(i);e!==void 0&&J(i)&&(r[i]=e)}return r}function pt(s,t){const r=new tt(s.document.stylesProcessor);for(const i of t){const e=s.getStyle(i);e!==void 0&&r.set(i,e)}return Object.fromEntries(r.getStylesEntries())}function D(s,t){const{name:r}=s,i=s[t];return lt(i)?Object.entries(i).map(([e,o])=>({name:r,[t]:{[e]:o}})):Array.isArray(i)?i.map(e=>({name:r,[t]:[e]})):[s]}function U(s){const{name:t,attributes:r,classes:i,styles:e}=s,o=[];return r&&o.push(...D({name:t,attributes:r},"attributes")),i&&o.push(...D({name:t,classes:i},"classes")),e&&o.push(...D({name:t,styles:e},"styles")),o}class wt extends g{static get requires(){return[h]}static get pluginName(){return"CodeBlockElementSupport"}static get isOfficialPlugin(){return!0}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const t=this.editor.plugins.get(h);t.on("register:pre",(r,i)=>{if(i.model!=="codeBlock")return;const e=this.editor,o=e.model.schema,l=e.conversion;o.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),l.for("upcast").add(At(t)),l.for("downcast").add(vt()),r.stop()})}}function At(s){return t=>{t.on("element:code",(r,i,e)=>{const o=i.viewItem,l=o.parent;if(!l||!l.is("element","pre"))return;n(l,"htmlPreAttributes"),n(o,"htmlContentAttributes");function n(m,a){const u=s.processViewAttributes(m,e);u&&e.writer.setAttribute(a,u,i.modelRange)}},{priority:"low"})}}function vt(){return s=>{s.on("attribute:htmlPreAttributes:codeBlock",(t,r,i)=>{if(!i.consumable.consume(r.item,t.name))return;const{attributeOldValue:e,attributeNewValue:o}=r,n=i.mapper.toViewElement(r.item).parent;w(i.writer,e,o,n)}),s.on("attribute:htmlContentAttributes:codeBlock",(t,r,i)=>{if(!i.consumable.consume(r.item,t.name))return;const{attributeOldValue:e,attributeNewValue:o}=r,l=i.mapper.toViewElement(r.item);w(i.writer,e,o,l)})}}class yt extends g{static get requires(){return[h]}static get pluginName(){return"DualContentModelElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.plugins.get(h).on("register",(r,i)=>{const e=i,o=this.editor,l=o.model.schema,n=o.conversion;if(!e.paragraphLikeModel||l.isRegistered(e.model)||l.isRegistered(e.paragraphLikeModel))return;const m={model:e.paragraphLikeModel,view:e.view};l.register(e.model,e.modelSchema),l.register(m.model,{inheritAllFrom:"$block"}),n.for("upcast").elementToElement({view:e.view,model:(a,{writer:u})=>this._hasBlockContent(a)?u.createElement(e.model):u.createElement(m.model),converterPriority:P.low+.5}),n.for("downcast").elementToElement({view:e.view,model:e.model}),this._addAttributeConversion(e),n.for("downcast").elementToElement({view:m.view,model:m.model}),this._addAttributeConversion(m),r.stop()})}_hasBlockContent(t){const r=this.editor.editing.view,i=r.domConverter.blockElements;for(const e of r.createRangeIn(t).getItems())if(e.is("element")&&i.includes(e.name))return!0;return!1}_addAttributeConversion(t){const r=this.editor,i=r.conversion,e=r.plugins.get(h);r.model.schema.extend(t.model,{allowAttributes:p(t.view)}),i.for("upcast").add(k(t,e)),i.for("downcast").add(I(t))}}class Et extends g{static get requires(){return[F,rt]}static get pluginName(){return"HeadingElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("HeadingEditing"))return;const r=t.config.get("heading.options");this.registerHeadingElements(t,r)}registerHeadingElements(t,r){const i=t.plugins.get(F),e=[];for(const o of r)"model"in o&&"view"in o&&(i.registerBlockElement({view:o.view,model:o.model}),e.push(o.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:e}}),i.extendBlockElement({model:"htmlSummary",modelSchema:{allowChildren:e}})}}function $(s,t,r){const i=s.createRangeOn(t);for(const{item:e}of i.getWalker())if(e.is("element",r))return e}class St extends g{static get requires(){return[h]}static get pluginName(){return"ImageElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("ImageInlineEditing")&&!t.plugins.has("ImageBlockEditing"))return;const r=t.model.schema,i=t.conversion,e=t.plugins.get(h);e.on("register:figure",()=>{i.for("upcast").add(Ft(e))}),e.on("register:img",(o,l)=>{l.model!=="imageBlock"&&l.model!=="imageInline"||(r.isRegistered("imageBlock")&&r.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),r.isRegistered("imageInline")&&r.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(Ct(e)),i.for("downcast").add(Ot()),t.plugins.has("LinkImage")&&i.for("upcast").add(kt(e,t)),o.stop())})}}function Ct(s){return t=>{t.on("element:img",(r,i,e)=>{if(!i.modelRange)return;const o=i.viewItem,l=s.processViewAttributes(o,e);l&&e.writer.setAttribute("htmlImgAttributes",l,i.modelRange)},{priority:"low"})}}function kt(s,t){const r=t.plugins.get("ImageUtils");return i=>{i.on("element:a",(e,o,l)=>{const n=o.viewItem;if(!r.findViewImgElement(n))return;const a=o.modelCursor.parent;if(!a.is("element","imageBlock"))return;const u=s.processViewAttributes(n,l);u&&l.writer.setAttribute("htmlLinkAttributes",u,a)},{priority:"low"})}}function Ft(s){return t=>{t.on("element:figure",(r,i,e)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("image"))return;const l=s.processViewAttributes(o,e);l&&e.writer.setAttribute("htmlFigureAttributes",l,i.modelRange)},{priority:"low"})}}function Ot(){return s=>{t("htmlImgAttributes"),r("img","htmlImgAttributes"),r("figure","htmlFigureAttributes"),r("a","htmlLinkAttributes");function t(i){s.on(`attribute:${i}:imageInline`,(e,o,l)=>{if(!l.consumable.consume(o.item,e.name))return;const{attributeOldValue:n,attributeNewValue:m}=o,a=l.mapper.toViewElement(o.item);w(l.writer,n,m,a)},{priority:"low"})}function r(i,e){s.on(`attribute:${e}:imageBlock`,(o,l,n)=>{if(!n.consumable.test(l.item,o.name))return;const{attributeOldValue:m,attributeNewValue:a}=l,u=n.mapper.toViewElement(l.item),c=$(n.writer,u,i);c&&(w(n.writer,m,a,c),n.consumable.consume(l.item,o.name))},{priority:"low"}),i==="a"&&s.on("attribute:linkHref:imageBlock",(o,l,n)=>{if(!n.consumable.consume(l.item,"attribute:htmlLinkAttributes:imageBlock"))return;const m=n.mapper.toViewElement(l.item),a=$(n.writer,m,"a");A(n.writer,l.item.getAttribute("htmlLinkAttributes"),a)},{priority:"low"})}}}class Pt extends g{static get requires(){return[h]}static get pluginName(){return"MediaEmbedElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("MediaEmbed")||t.config.get("mediaEmbed.previewsInData"))return;const r=t.model.schema,i=t.conversion,e=this.editor.plugins.get(h),o=this.editor.plugins.get(F),l=t.config.get("mediaEmbed.elementName");o.registerBlockElement({model:"media",view:l}),e.on("register:figure",()=>{i.for("upcast").add(It(e))}),e.on(`register:${l}`,(n,m)=>{m.model==="media"&&(r.extend("media",{allowAttributes:[p(l),"htmlFigureAttributes"]}),i.for("upcast").add(Tt(e,l)),i.for("dataDowncast").add($t(l)),n.stop())})}}function Tt(s,t){const r=(i,e,o)=>{const l=e.viewItem;n(l,p(t));function n(m,a){const u=s.processViewAttributes(m,o);u&&o.writer.setAttribute(a,u,e.modelRange)}};return i=>{i.on(`element:${t}`,r,{priority:"low"})}}function It(s){return t=>{t.on("element:figure",(r,i,e)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("media"))return;const l=s.processViewAttributes(o,e);l&&e.writer.setAttribute("htmlFigureAttributes",l,i.modelRange)},{priority:"low"})}}function $t(s){return t=>{r(s,p(s)),r("figure","htmlFigureAttributes");function r(i,e){t.on(`attribute:${e}:media`,(o,l,n)=>{if(!n.consumable.consume(l.item,o.name))return;const{attributeOldValue:m,attributeNewValue:a}=l,u=n.mapper.toViewElement(l.item),c=$(n.writer,u,i);w(n.writer,m,a,c)})}}}class _t extends g{static get requires(){return[h]}static get pluginName(){return"ScriptElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get(h);t.on("register:script",(r,i)=>{const e=this.editor,o=e.model.schema,l=e.conversion;o.register("htmlScript",i.modelSchema),o.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),e.data.registerRawContentMatcher({name:"script"}),l.for("upcast").elementToElement({view:"script",model:B(i)}),l.for("upcast").add(k(i,t)),l.for("downcast").elementToElement({model:"htmlScript",view:(n,{writer:m})=>_("script",n,m)}),l.for("downcast").add(I(i)),r.stop()})}}const Dt=["width","max-width","min-width","height","min-height","max-height"];class Ht extends g{static get requires(){return[h]}static get pluginName(){return"TableElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("TableEditing"))return;const r=t.model.schema,i=t.conversion,e=t.plugins.get(h),o=t.plugins.get("TableUtils");e.on("register:figure",()=>{i.for("upcast").add(Vt(e))}),e.on("register:table",(l,n)=>{n.model==="table"&&(r.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(Bt(e)),i.for("downcast").add(Rt()),t.model.document.registerPostFixer(xt(t.model,o)),l.stop())})}}function xt(s,t){return r=>{const i=s.document.differ.getChanges();let e=!1;for(const o of i){if(o.type!="attribute"||o.attributeKey!="headingRows")continue;const l=o.range.start.nodeAfter,n=l.getAttribute("htmlTheadAttributes"),m=l.getAttribute("htmlTbodyAttributes");n&&!o.attributeNewValue?(r.removeAttribute("htmlTheadAttributes",l),e=!0):m&&o.attributeNewValue==t.getRows(l)&&(r.removeAttribute("htmlTbodyAttributes",l),e=!0)}return e}}function Bt(s){return t=>{t.on("element:table",(r,i,e)=>{if(!i.modelRange)return;const o=i.viewItem;e.consumable.consume(o,{classes:"table"}),l(o,"htmlTableAttributes");for(const n of o.getChildren())n.is("element","thead")&&l(n,"htmlTheadAttributes"),n.is("element","tbody")&&l(n,"htmlTbodyAttributes");function l(n,m){const a=s.processViewAttributes(n,e);a&&e.writer.setAttribute(m,a,i.modelRange)}},{priority:"low"})}}function Vt(s){return t=>{t.on("element:figure",(r,i,e)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("table"))return;const l=s.processViewAttributes(o,e);l&&e.writer.setAttribute("htmlFigureAttributes",l,i.modelRange)},{priority:"low"})}}function Rt(){return s=>{t("table","htmlTableAttributes"),t("figure","htmlFigureAttributes"),t("thead","htmlTheadAttributes"),t("tbody","htmlTbodyAttributes");function t(r,i){s.on(`attribute:${i}:table`,(e,o,l)=>{if(!l.consumable.test(o.item,e.name))return;const n=l.mapper.toViewElement(o.item),m=$(l.writer,n,r);if(m)if(l.consumable.consume(o.item,e.name),i==="htmlTableAttributes"&&n!==m){const a=z(o.attributeOldValue),u=z(o.attributeNewValue);w(l.writer,a.tableAttributes,u.tableAttributes,m),w(l.writer,a.figureAttributes,u.figureAttributes,n)}else w(l.writer,o.attributeOldValue,o.attributeNewValue,m)})}}}function z(s){const t={},r={...s};if(!s||!("styles"in s))return{figureAttributes:t,tableAttributes:r};r.styles={};for(const[i,e]of Object.entries(s.styles))Dt.includes(i)?t.styles={...t.styles,[i]:e}:r.styles={...r.styles,[i]:e};return{figureAttributes:t,tableAttributes:r}}class Mt extends g{static get requires(){return[h]}static get pluginName(){return"StyleElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get(h);t.on("register:style",(r,i)=>{const e=this.editor,o=e.model.schema,l=e.conversion;o.register("htmlStyle",i.modelSchema),o.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),e.data.registerRawContentMatcher({name:"style"}),l.for("upcast").elementToElement({view:"style",model:B(i)}),l.for("upcast").add(k(i,t)),l.for("downcast").elementToElement({model:"htmlStyle",view:(n,{writer:m})=>_("style",n,m)}),l.for("downcast").add(I(i)),r.stop()})}}class jt extends g{static get requires(){return[h]}static get pluginName(){return"ListElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("ListEditing"))return;const r=t.model.schema,i=t.conversion,e=t.plugins.get(h),o=t.plugins.get("ListEditing"),l=t.plugins.get("ListUtils"),n=["ul","ol","li"];o.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:A}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:A}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:A}),e.on("register",(m,a)=>{if(!n.includes(a.view)||(m.stop(),r.checkAttribute("$block","htmlLiAttributes")))return;const u=n.map(c=>p(c));r.extend("$listItem",{allowAttributes:u}),i.for("upcast").add(c=>{c.on("element:ul",H("htmlUlAttributes",e),{priority:"low"}),c.on("element:ol",H("htmlOlAttributes",e),{priority:"low"}),c.on("element:li",H("htmlLiAttributes",e),{priority:"low"})})}),o.on("postFixer",(m,{listNodes:a,writer:u})=>{for(const{node:c,previousNodeInList:d}of a)if(d){if(d.getAttribute("listType")==c.getAttribute("listType")){const f=G(d.getAttribute("listType")),b=d.getAttribute(f);!N(c.getAttribute(f),b)&&u.model.schema.checkAttribute(c,f)&&(u.setAttribute(f,b,c),m.return=!0)}if(d.getAttribute("listItemId")==c.getAttribute("listItemId")){const f=d.getAttribute("htmlLiAttributes");!N(c.getAttribute("htmlLiAttributes"),f)&&u.model.schema.checkAttribute(c,"htmlLiAttributes")&&(u.setAttribute("htmlLiAttributes",f,c),m.return=!0)}}}),o.on("postFixer",(m,{listNodes:a,writer:u})=>{for(const{node:c}of a){const d=c.getAttribute("listType");!l.isNumberedListType(d)&&c.getAttribute("htmlOlAttributes")&&(u.removeAttribute("htmlOlAttributes",c),m.return=!0),l.isNumberedListType(d)&&c.getAttribute("htmlUlAttributes")&&(u.removeAttribute("htmlUlAttributes",c),m.return=!0)}})}afterInit(){const t=this.editor;if(!t.commands.get("indentList"))return;const r=t.commands.get("indentList");this.listenTo(r,"afterExecute",(i,e)=>{t.model.change(o=>{for(const l of e){const n=G(l.getAttribute("listType"));t.model.schema.checkAttribute(l,n)&&o.setAttribute(n,{},l)}})})}}function H(s,t){return(r,i,e)=>{const o=i.viewItem;i.modelRange||Object.assign(i,e.convertChildren(i.viewItem,i.modelCursor));const l=t.processViewAttributes(o,e);for(const n of i.modelRange.getItems({shallow:!0}))n.hasAttribute("listItemId")&&(n.hasAttribute("htmlUlAttributes")||n.hasAttribute("htmlOlAttributes")||e.writer.model.schema.checkAttribute(n,s)&&e.writer.setAttribute(s,l||{},n))}}function G(s){return s==="numbered"||s=="customNumbered"?"htmlOlAttributes":"htmlUlAttributes"}class Nt extends g{static get requires(){return[h]}static get pluginName(){return"HorizontalLineElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("HorizontalLineEditing"))return;const r=t.model.schema,i=t.conversion,e=t.plugins.get(h);e.on("register:hr",(o,l)=>{l.model==="horizontalLine"&&(r.extend("horizontalLine",{allowAttributes:["htmlHrAttributes"]}),i.for("upcast").add(k(l,e)),i.for("downcast").add(Lt()),o.stop())})}}function Lt(){return s=>{s.on("attribute:htmlHrAttributes:horizontalLine",(t,r,i)=>{if(!i.consumable.test(r.item,t.name))return;const{attributeOldValue:e,attributeNewValue:o}=r,l=i.mapper.toViewElement(r.item),n=$(i.writer,l,"hr");n&&(w(i.writer,e,o,n),i.consumable.consume(r.item,t.name))},{priority:"low"})}}class Wt extends g{static get requires(){return[h]}static get pluginName(){return"IframeElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.config.define("htmlSupport.htmlIframeSandbox",!0),this._setupSandboxConversion()}_setupSandboxConversion(){const{plugins:t,config:r,conversion:i}=this.editor,e=t.get(h),o=r.get("htmlSupport.htmlIframeSandbox");if(o===!1)return;const l=Array.isArray(o)?Array.from(o):[];e.on("register:iframe",(n,m)=>{i.for("editingDowncast").add(a=>{a.on(`insert:${m.model}`,(u,c,d)=>{const{mapper:f,writer:b}=d,y=f.toViewElement(c.item);for(const{item:v}of b.createRangeOn(y))if(v.is("element","iframe"))if(v.hasAttribute("sandbox")){const E=new Set,O=v.getAttribute("sandbox");for(const V of O.trim().split(/\s+/))l.includes(V)&&E.add(V);b.setAttribute("sandbox",Array.from(E).join(" "),v)}else b.setAttribute("sandbox",l.join(" "),v)},{priority:"lowest"})})})}}class qt extends g{static get requires(){return[h,F]}static get pluginName(){return"CustomElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get(h),r=this.editor.plugins.get(F);t.on("register:$customElement",(i,e)=>{i.stop();const o=this.editor,l=o.model.schema,n=o.conversion,m=o.editing.view.domConverter.unsafeElements,a=o.data.htmlProcessor.domConverter.preElements;l.register(e.model,e.modelSchema),l.extend(e.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),o.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),n.for("upcast").elementToElement({view:/.*/,model:(u,c)=>{if(u.name=="$comment")return null;if(!Ut(u.name)||r.getDefinitionsForView(u.name).size)return null;m.includes(u.name)||m.push(u.name),a.includes(u.name)||a.push(u.name);const d=c.writer.createElement(e.model,{htmlElementName:u.name}),f=t.processViewAttributes(u,c);f&&c.writer.setAttribute("htmlCustomElementAttributes",f,d);let b;if(u.is("element","template")&&u.getCustomProperty("$rawContent"))b=u.getCustomProperty("$rawContent");else{const v=new x(u.document).createDocumentFragment(u),E=o.data.htmlProcessor.domConverter.viewToDom(v),O=E.firstChild;for(;O.firstChild;)E.appendChild(O.firstChild);O.remove(),b=o.data.htmlProcessor.htmlWriter.getHtml(E)}c.writer.setAttribute("htmlContent",b,d);for(const{item:y}of o.editing.view.createRangeIn(u))c.consumable.consume(y,{name:!0});return d},converterPriority:"low"}),n.for("editingDowncast").elementToElement({model:{name:e.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(u,{writer:c})=>{const d=u.getAttribute("htmlElementName"),f=c.createRawElement(d);return u.hasAttribute("htmlCustomElementAttributes")&&A(c,u.getAttribute("htmlCustomElementAttributes"),f),f}}),n.for("dataDowncast").elementToElement({model:{name:e.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(u,{writer:c})=>{const d=u.getAttribute("htmlElementName"),f=u.getAttribute("htmlContent"),b=c.createRawElement(d,null,(y,v)=>{v.setContentOf(y,f)});return u.hasAttribute("htmlCustomElementAttributes")&&A(c,u.getAttribute("htmlCustomElementAttributes"),b),b}})})}}function Ut(s){try{document.createElement(s)}catch{return!1}return!0}class oe extends g{static get pluginName(){return"GeneralHtmlSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[h,wt,yt,Et,St,Pt,_t,Ht,Mt,jt,Nt,Wt,qt]}init(){const t=this.editor,r=t.plugins.get(h);r.loadAllowedEmptyElementsConfig(t.config.get("htmlSupport.allowEmpty")||[]),r.loadAllowedConfig(t.config.get("htmlSupport.allow")||[]),r.loadDisallowedConfig(t.config.get("htmlSupport.disallow")||[])}afterInit(){this.editor.commands.get("removeFormat")?.registerCustomAttribute(r=>r.startsWith("html")&&r.endsWith("Attributes"),at)}getGhsAttributeNameForElement(t){const r=this.editor.plugins.get("DataSchema"),i=Array.from(r.getDefinitionsForView(t,!1)),e=i.find(o=>o.isInline&&!i[0].isObject);return e?e.model:p(t)}addModelHtmlClass(t,r,i){const e=this.editor.model,o=this.getGhsAttributeNameForElement(t);e.change(l=>{for(const n of C(e,i,o))S(l,n,o,"classes",m=>{for(const a of T(r))m.add(a)})})}removeModelHtmlClass(t,r,i){const e=this.editor.model,o=this.getGhsAttributeNameForElement(t);e.change(l=>{for(const n of C(e,i,o))S(l,n,o,"classes",m=>{for(const a of T(r))m.delete(a)})})}setModelHtmlAttributes(t,r,i){const e=this.editor.model,o=this.getGhsAttributeNameForElement(t);e.change(l=>{for(const n of C(e,i,o))S(l,n,o,"attributes",m=>{for(const[a,u]of Object.entries(r))m.set(a,u)})})}removeModelHtmlAttributes(t,r,i){const e=this.editor.model,o=this.getGhsAttributeNameForElement(t);e.change(l=>{for(const n of C(e,i,o))S(l,n,o,"attributes",m=>{for(const a of T(r))m.delete(a)})})}setModelHtmlStyles(t,r,i){const e=this.editor.model,o=this.getGhsAttributeNameForElement(t);e.change(l=>{for(const n of C(e,i,o))S(l,n,o,"styles",m=>{for(const[a,u]of Object.entries(r))m.set(a,u)})})}removeModelHtmlStyles(t,r,i){const e=this.editor.model,o=this.getGhsAttributeNameForElement(t);e.change(l=>{for(const n of C(e,i,o))S(l,n,o,"styles",m=>{for(const a of T(r))m.delete(a)})})}}function*C(s,t,r){if(t)if(!(Symbol.iterator in t)&&t.is("documentSelection")&&t.isCollapsed)s.schema.checkAttributeInSelection(t,r)&&(yield t);else for(const i of zt(s,t,r))yield*i.getItems({shallow:!0})}function zt(s,t,r){return!(Symbol.iterator in t)&&(t.is("node")||t.is("$text")||t.is("$textProxy"))?s.schema.checkAttribute(t,r)?[s.createRangeOn(t)]:[]:s.schema.getValidRanges(s.createSelection(t).getRanges(),r)}class le extends g{static get pluginName(){return"HtmlComment"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,r=new Map;t.data.processor.skipComments=!1,t.model.schema.addAttributeCheck((i,e)=>{if(i.endsWith("$root")&&e.startsWith("$comment"))return!0}),t.conversion.for("upcast").elementToMarker({view:"$comment",model:i=>{const o=`$comment:${M()}`,l=i.getCustomProperty("$rawContent");return r.set(o,l),o}}),t.conversion.for("dataDowncast").markerToElement({model:"$comment",view:(i,{writer:e})=>{let o;for(const a of this.editor.model.document.getRootNames())if(o=this.editor.model.document.getRoot(a),o.hasAttribute(i.markerName))break;const l=i.markerName,n=o.getAttribute(l),m=e.createUIElement("$comment");return e.setCustomProperty("$rawContent",n,m),m}}),t.model.document.registerPostFixer(i=>{let e=!1;const o=t.model.document.differ.getChangedMarkers().filter(l=>l.name.startsWith("$comment:"));for(const l of o){const{oldRange:n,newRange:m}=l.data;if(!(n&&m&&n.root==m.root)){if(n){const a=n.root;a.hasAttribute(l.name)&&(i.removeAttribute(l.name,a),e=!0)}if(m){const a=m.root;a.rootName=="$graveyard"?(i.removeMarker(l.name),e=!0):a.hasAttribute(l.name)||(i.setAttribute(l.name,r.get(l.name)||"",a),e=!0)}}}return e}),t.data.on("set",()=>{for(const i of t.model.markers.getMarkersGroup("$comment"))this.removeHtmlComment(i.name)},{priority:"high"}),t.model.on("deleteContent",(i,[e])=>{for(const o of e.getRanges()){const l=t.model.schema.getLimitElement(o),n=t.model.createPositionAt(l,0),m=t.model.createPositionAt(l,"end");let a;n.isTouching(o.start)&&m.isTouching(o.end)?a=this.getHtmlCommentsInRange(t.model.createRange(n,m)):a=this.getHtmlCommentsInRange(o,{skipBoundaries:!0});for(const u of a)this.removeHtmlComment(u)}},{priority:"high"})}createHtmlComment(t,r){const i=M(),o=this.editor.model,l=o.document.getRoot(t.root.rootName),n=`$comment:${i}`;return o.change(m=>{const a=m.createRange(t);return m.addMarker(n,{usingOperation:!0,affectsData:!0,range:a}),m.setAttribute(n,r,l),n})}removeHtmlComment(t){const r=this.editor,i=r.model.markers.get(t);return i?(r.model.change(e=>{e.removeMarker(i)}),!0):!1}getHtmlCommentData(t){const i=this.editor.model.markers.get(t);if(!i)return null;let e="";for(const o of this.editor.model.document.getRoots())if(o.hasAttribute(t)){e=o.getAttribute(t);break}return{content:e,position:i.getStart()}}getHtmlCommentsInRange(t,{skipBoundaries:r=!1}={}){const i=!r;return Array.from(this.editor.model.markers.getMarkersGroup("$comment")).filter(o=>e(o,t)).map(o=>o.name);function e(o,l){const n=o.getRange().start;return(n.isAfter(l.start)||i&&n.isEqual(l.start))&&(n.isBefore(l.end)||i&&n.isEqual(l.end))}}}class Gt extends Z{toView(t){if(!/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(t.trim().slice(0,1e4)))return super.toView(t);let r="",i="";t=t.trim().replace(/<\?xml\s[^?]*\?>/i,m=>(i=m,"")),t=t.trim().replace(/^<!DOCTYPE\s[^>]*?>/i,m=>(r=m,""));const e=this._toDom(t),o=this.domConverter.domToView(e,{skipComments:this.skipComments}),l=new x(o.document);l.setCustomProperty("$fullPageDocument",e.ownerDocument.documentElement.outerHTML,o);const n=Array.from(e.ownerDocument.querySelectorAll("head style"));return l.setCustomProperty("$fullPageHeadStyles",n,o),r&&l.setCustomProperty("$fullPageDocType",r,o),i&&l.setCustomProperty("$fullPageXmlDeclaration",i,o),o}toData(t){let r=super.toData(t);const i=t.getCustomProperty("$fullPageDocument"),e=t.getCustomProperty("$fullPageDocType"),o=t.getCustomProperty("$fullPageXmlDeclaration");return i&&(r=i.replace(/<\/body\s*>/,r+"$&"),e&&(r=e+`
|
|
2
|
+
`+r),o&&(r=o+`
|
|
3
|
+
`+r)),r}}class ne extends g{static get pluginName(){return"FullPage"}static get licenseFeatureCode(){return"FPH"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(t){super(t),t.config.define("htmlSupport.fullPage",{allowRenderStylesFromHead:!1,sanitizeCss:r=>(Q("css-full-page-provide-sanitize-function"),{css:r,hasChanged:!1})}),t.data.processor=new Gt(t.data.viewDocument)}init(){const t=this.editor,r=["$fullPageDocument","$fullPageDocType","$fullPageXmlDeclaration","$fullPageHeadStyles"];t.model.schema.extend("$root",{allowAttributes:r}),t.data.on("toModel",(i,[e])=>{const o=t.model.document.getRoot();t.model.change(l=>{for(const n of r){const m=e.getCustomProperty(n);m&&l.setAttribute(n,m,o)}}),K(t)&&this._renderStylesFromHead(o)},{priority:"low"}),t.data.on("toView",(i,[e])=>{if(!e.is("rootElement"))return;const o=e,l=i.return;if(!o.hasAttribute("$fullPageDocument"))return;const n=new x(l.document);for(const m of r){const a=o.getAttribute(m);a&&n.setCustomProperty(m,a,l)}},{priority:"low"}),t.data.on("set",()=>{const i=t.model.document.getRoot();t.model.change(e=>{for(const o of r)i.hasAttribute(o)&&e.removeAttribute(o,i)})},{priority:"high"}),t.data.on("get",(i,e)=>{e[0]||(e[0]={}),e[0].trim=!1},{priority:"high"})}destroy(){super.destroy(),K(this.editor)&&this._removeStyleElementsFromDom()}_removeStyleElementsFromDom(){const t=Array.from(R.document.querySelectorAll(`[data-full-page-style-id="${this.editor.id}"]`));for(const r of t)r.remove()}_renderStyleElementsInDom(t){const r=this.editor,i=t.getAttribute("$fullPageHeadStyles");if(!i)return;const e=r.config.get("htmlSupport.fullPage.sanitizeCss");for(const o of i){o.setAttribute("data-full-page-style-id",r.id);const l=e(o.innerText);l.hasChanged&&(o.innerText=l.css),R.document.head.append(o)}}_renderStylesFromHead(t){this._removeStyleElementsFromDom(),this._renderStyleElementsInDom(t)}}function K(s){return s.config.get("htmlSupport.fullPage.allowRenderStylesFromHead")}export{wt as CodeBlockElementSupport,qt as CustomElementSupport,h as DataFilter,F as DataSchema,yt as DualContentModelElementSupport,ne as FullPage,oe as GeneralHtmlSupport,Et as HeadingElementSupport,Nt as HorizontalLineElementSupport,le as HtmlComment,Gt as HtmlPageDataProcessor,Wt as IframeElementSupport,St as ImageElementSupport,jt as ListElementSupport,Pt as MediaEmbedElementSupport,_t as ScriptElementSupport,Mt as StyleElementSupport,Ht as TableElementSupport,W as _HTML_SUPPORT_SCHEMA_DEFINITIONS,ht as _attributeToInlineHtmlSupportConverter,_ as _createObjectHtmlSupportView,L as _emptyInlineModelElementToViewHtmlSupportConverter,p as _getHtmlSupportAttributeName,$ as _getHtmlSupportDescendantElement,mt as _mergeHtmlSupportViewElementAttributes,I as _modelToViewBlockAttributeHtmlSupportConverter,S as _modifyHtmlSupportGhsAttribute,st as _removeHtmlSupportViewAttributes,A as _setHtmlSupportViewAttributes,ut as _toHtmlSupportPascalCase,ct as _toObjectWidgetHtmlSupportConverter,w as _updateHtmlSupportViewAttributes,dt as _viewToAttributeInlineHtmlSupportConverter,k as _viewToModelBlockAttributeHtmlSupportConverter,B as _viewToModelObjectContentHtmlSupportConverter};
|