@progress/kendo-editor-common 1.11.9-develop.1 → 1.11.9-develop.2
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/cdn/main.js +1 -1
- package/dist/es/main.js +1 -1
- package/dist/es2015/main.js +1 -1
- package/dist/npm/main.d.ts +2 -2
- package/dist/npm/main.js +1 -0
- package/dist/npm/utils.d.ts +6 -2
- package/package.json +2 -2
package/dist/cdn/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("prosemirror-model"),require("prosemirror-state"),require("@progress/kendo-common"),require("prosemirror-transform"),require("prosemirror-schema-list"),require("prosemirror-commands"),require("prosemirror-tables"),require("prosemirror-history"),require("prosemirror-inputrules"),require("prosemirror-view"),require("prosemirror-dropcursor"),require("prosemirror-gapcursor"),require("prosemirror-keymap")):"function"==typeof define&&define.amd?define(["exports","prosemirror-model","prosemirror-state","@progress/kendo-common","prosemirror-transform","prosemirror-schema-list","prosemirror-commands","prosemirror-tables","prosemirror-history","prosemirror-inputrules","prosemirror-view","prosemirror-dropcursor","prosemirror-gapcursor","prosemirror-keymap"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoEditorCommon={},e.prosemirrorModel,e.prosemirrorState,e.KendoCommon,e.prosemirrorTransform,e.prosemirrorSchemaList,e.prosemirrorCommands,e.prosemirrorTables,e.prosemirrorHistory,e.prosemirrorInputrules,e.prosemirrorView,e.prosemirrorDropcursor,e.prosemirrorGapcursor,e.prosemirrorKeymap)}(this,(function(e,t,n,r,o,s,i,a,l,c,d,u,p,h){"use strict";const f="k-parent-node",m="k-colgroup-data",g="k-resizable-node",y="k-editor-resize-handle",b="data-dir-table-resize",w="data-dir-image-resize",v=(e,t)=>{const n=t.style,r=t.value,o=t.newValue;if(!e)return{changed:!1,style:null};const s=$(e),i=Object.keys(s),a=[];for(let e=0;e<i.length;e++){const t=i[e];t.toLowerCase()===n&&r.test(s[t])||a.push(`${t}: ${s[t]}`)}return o&&a.push(`${n}: ${o}`),{style:a.join("; ")+(a.length?";":""),changed:Boolean(o)||a.length!==i.length}},k=/^.+$/;function M(e,t,n){let r;if(new RegExp("[^-]?"+t+":").test(e.style||"")){const{style:o}=v(e.style||"",{style:t,value:k,newValue:n});r={...e,style:o}}else r=e.style?{...e,style:e.style.replace(/;$/,"")+"; "+t+": "+n+";"}:{...e,style:t+": "+n+";"};return r}const x=e=>e instanceof t.Node?e.type.name:e.name,S=(e,t=1)=>n=>((e,t=1)=>n=>{const{$from:r}=n;for(let n=r.depth;n>0;n--){const o=r.node(n);if(e(o)&&0==(t-=1))return{depth:n,node:o}}})((t=>x(t)===x(e)),t)(n);function O(e,t){for(let n=e.depth;n>0;n--){const r=e.node(n);if(t(r))return{node:r,depth:n}}return null}const C=e=>{const t={};for(const n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t},A=(e,t)=>(r,o)=>{const{selection:s,tr:i}=r;s instanceof n.NodeSelection&&s.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(i.setNodeMarkup(s.from,null,{...C(s.node.attrs),...C(e.attrs)}),i.setSelection(n.NodeSelection.create(i.doc,s.from))):i.replaceSelectionWith(e),t&&i.scrollIntoView(),o(i)},T=e=>{const t=e.selection;if(t instanceof n.TextSelection||t instanceof n.AllSelection){const e=t.content().content;return e.textBetween(0,e.size)}return""},E={before:/[^ !,?.\[\]{}()]+$/i,after:/^[^ !,?.\[\]{}()]+/i},N=(e,t,r)=>{if(!r.applyToWord||!e.selection.empty)return{state:e,dispatch:t};const o=!0===r.applyToWord?E:r.applyToWord;let s=null;const i=e.tr,a=e.selection,l=a.$head.nodeBefore,c=a.$head.nodeAfter;if(l&&"text"===l.type.name&&l.text&&c&&"text"===c.type.name&&c.text){const r=[];a.$head.parent.descendants(((e,t)=>(r.push({node:e,pos:t}),!1)));let l=a.$head.parentOffset;const c=r.findIndex((({node:e,pos:t})=>t<=l&&t+e.nodeSize>=l));let d=r[c].node.text,u=!1;for(let e=c-1;e>=0;e--){const t=r[e];!u&&t&&"text"===t.node.type.name?d=t.node.text+d:(u=!0,l-=t.node.nodeSize)}for(let e=c+1;e<r.length;e++){const t=r[e];if(!t||"text"!==t.node.type.name)break;d+=t.node.text}const p=d.substring(0,l),h=d.substring(l),f=o.before.exec(p),m=o.after.exec(h);if(f&&m){const r=f[0].length,o=m[0].length,l=s=a.from;i.setSelection(n.TextSelection.create(e.doc,l-r,l+o));return{state:{tr:i,selection:i.selection,doc:i.doc,storedMarks:null,schema:i.doc.type.schema},dispatch:e=>{e.setSelection(n.TextSelection.create(e.doc,s)),t(e)}}}}return{state:e,dispatch:t}},D=(e,t)=>(n,r)=>{const{state:o,dispatch:s}=N(n,r,t);return e(t)(o,s)},$=e=>r.parseInlineStyles(e),P=(e,t,n)=>{const r=$(e);r[t]=n;const o=Object.keys(r).map((e=>r[e]?`${e}: ${r[e]}`:null)).filter(Boolean).join("; ");return o?o+";":null},H=(e,t)=>{const n=$(t);for(const t in n)t&&void 0!==e.style[t]&&(e.style[t]=n[t])},I=(e,t,n)=>{const r=e.getAttribute(t);void 0!==n&&n!==r?"style"===t?(e.removeAttribute(t),H(e,n)):e.setAttribute(t,n):void 0===n&&e.removeAttribute(t)};class L{static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,o=t[0],s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));const i=n?e.createElementNS(n,o):e.createElement(o);let a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(const e in a)null!=a[e]&&(s=e.indexOf(" "),s>0?i.setAttributeNS(e.slice(0,s),e.slice(s+1),a[e]):I(i,e,a[e]))}for(let o=l;o<t.length;o++){const s=t[o];if(0===s){if(o<t.length-1||o>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:i,contentDOM:i}}{const{dom:t,contentDOM:o}=L.renderSpec(e,s,n);if(i.appendChild(t),o){if(r)throw new RangeError("Multiple content holes");r=o}}}return{dom:i,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new L(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){const t=z(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return z(e.marks)}constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=j(t).createDocumentFragment());let r=n,o=[];return e.forEach((e=>{if(o.length||e.marks.length){let n=0,s=0;for(;n<o.length&&s<e.marks.length;){const t=e.marks[s];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,s++}else s++}for(;n<o.length;)r=o.pop()[1];for(;s<e.marks.length;){const n=e.marks[s++],i=this.serializeMark(n,e.isInline,t);i&&(o.push([n,r]),r.appendChild(i.dom),r=i.contentDOM||i.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){const o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){const r=this.marks[e.type.name];return r&&L.renderSpec(j(n),r(e,t))}serializeNodeInner(e,t){const{dom:n,contentDOM:r}=L.renderSpec(j(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}}function z(e){const t={};for(const n in e)if(e[n]){const r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function j(e){return e.document||window.document}const R=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],B=(e,t)=>{const n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((e=>e.getAttribute(f)===t)).forEach((e=>{e.removeAttribute(f),n.appendChild(e)})),n.children.length&&e.appendChild(n)},_=(e,t)=>{const n=t.toUpperCase();e.filter((e=>e.nodeName===n)).forEach((e=>{Array.from(e.children).forEach((n=>{n.setAttribute(f,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))},F="data-style",q=" "+F+"=",W=/<[^>]+>/gm,V=/\sstyle=/gm,K=e=>e.replace(V,q),Y=e=>{const t=document.createElement("template");var n;return t.innerHTML=(e=>e.replace(W,K))(e),n=t.content,Array.from(n.querySelectorAll("["+F+"]")).forEach((e=>{const t=e.getAttribute(F);e.removeAttribute(F),H(e,t)})),t.content},X=e=>Array.from(e.childNodes).reduce(((e,t)=>e+(t.outerHTML||t.textContent||"")),""),G=e=>{const t=L.fromSchema(e.type.schema).serializeFragment(e.content);return(e=>{Array.from(e.querySelectorAll("table")).forEach((e=>{B(e,"thead"),B(e,"tbody"),B(e,"tfoot");const t=Array.from(e.children).find((e=>0===e.children.length));t&&t.remove();const n=e.parentNode instanceof HTMLDivElement?e.parentNode:null;if(n&&n.matches("div[table]")){e.style.marginLeft=n.style.marginLeft,e.style.marginRight=n.style.marginRight;const t=Array.from(n.children).find((e=>e.matches("div[caption]")));if(t&&"<img>"!==t.innerHTML){const n=e.createCaption();for(t.id&&(n.id=t.id),t.className&&(n.className=t.className),Array.from(t.style).forEach((e=>{n.style[e]=t.style[e]}));t.firstChild;)n.appendChild(t.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))})(t),t},U=(e,n,r)=>t.DOMParser.fromSchema(n).parse(e,r),Z=(e,t,n)=>{const r=Y(e);var o;return o=r,Array.from(o.querySelectorAll("table")).forEach((e=>{const t=Array.from(e.children);t.some((e=>"THEAD"===e.nodeName||"TFOOT"===e.nodeName))&&(_(t,"thead"),_(t,"tbody"),_(t,"tfoot"));const n=t.find((e=>"COLGROUP"===e.nodeName));if(n&&(e.setAttribute(m,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){const t=document.createElement("div");if(t.setAttribute("table",""),t.style.display="table",t.style.marginLeft=e.style.marginLeft,t.style.marginRight=e.style.marginRight,e.caption){const n=document.createElement("div");for(n.setAttribute("caption",""),e.caption.id&&(n.id=e.caption.id),e.caption.className&&(n.className=e.caption.className),Array.from(e.caption.style).forEach((t=>{n.style[t]=e.caption.style[t]}));e.caption.firstChild;)n.appendChild(e.caption.firstChild);e.removeChild(e.caption),t.appendChild(n)}e.parentNode.insertBefore(t,e),t.appendChild(e),/%/.test(e.style.width)&&(t.style.width=e.style.width,e.style.width="")}})),U(r,t,n)},J=(e,t,n)=>{const r=r=>{const o=t[r],s=o.$from,i=o.$to;let a=0===s.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(s.pos,i.pos,(e=>{if(a)return!1;a=e.inlineContent&&e.type.allowsMarkType(n)})),a)return{v:!0}};for(let e=0;e<t.length;e++){const t=r(e);if(t)return t.v}return!1},Q=(e,t,n)=>(r,o)=>{const{empty:s,$cursor:i,ranges:a}=r.selection;if(s&&!i||!J(r.doc,a,e))return!1;if(o)if(i)e.isInSet(r.storedMarks||i.marks())?o(n.removeStoredMark(e)):o(n.addStoredMark(e.create(t)));else{let s=!1;for(let t=0;!s&&t<a.length;t++){const{$from:n,$to:o}=a[t];s=r.doc.rangeHasMark(n.pos,o.pos,e)}for(let r=0;r<a.length;r++){const{$from:o,$to:i}=a[r];s?n.removeMark(o.pos,i.pos,e):n.addMark(o.pos,i.pos,e.create(t))}o(n.scrollIntoView())}return!0},ee=(e,n,r,s)=>{void 0===s&&(s=null);let i=[],a=0;return e.doc.nodesBetween(n,r,((e,o)=>{if(!e.isInline)return;a++;let l=null;if(s instanceof t.MarkType){const t=s.isInSet(e.marks);t&&(l=[t])}else s?s.isInSet(e.marks)&&(l=[s]):l=e.marks;if(l&&l.length){const t=Math.min(o+e.nodeSize,r);for(let e=0;e<l.length;e++){let r,s=l[e];for(let e=0;e<i.length;e++){const t=i[e];t.step===a-1&&s.eq(t.style)&&(r=t)}r?(r.to=t,r.step=a):i.push({style:s,from:Math.max(o,n),to:t,step:a})}}})),i.forEach((t=>e.step(new o.RemoveMarkStep(t.from,t.to,t.style)))),e},te=(e,{except:t})=>{const{doc:n,selection:r}=e,o=n.type.schema,{empty:s,ranges:i}=r,a=(t||[]).map((e=>e.name));if(!s){const t=Object.keys(o.marks).map((e=>o.marks[e])).filter((e=>-1===a.indexOf(e.name)));i.forEach((({$from:n,$to:r})=>{t.forEach((t=>e.removeMark(n.pos,r.pos,t)))}))}},ne=(e,t)=>{const n=e.schema.marks,r=(t.altMarks||[]).filter((e=>n[e])),o=t.altStyle,{from:s,$from:i,to:a,empty:l}=e.selection,c=n[t.mark],d=e.doc;let u,p=!1;return l?(u=e.storedMarks||i.marks(),p=c&&c.isInSet(u)||r.some((e=>n[e].isInSet(u)))):p=c&&d.rangeHasMark(s,a,c)||r.some((e=>d.rangeHasMark(s,a,n[e]))),!p&&o&&n.style?oe(e,n.style).some((e=>null!==re(e,o))):Boolean(p)},re=(e,t)=>{const n=e&&e.attrs.style||"",r=$(n),o=Object.keys(r);for(let e=0;e<o.length;e++){const n=o[e];if(n.toLowerCase()===t.name&&t.value.test(r[n]))return r[n]}return null},oe=(e,t)=>{const{from:n,$from:r,to:o,empty:s}=e.selection,i=[];return s?i.push(t.isInSet(e.storedMarks||r.marks())):e.doc.nodesBetween(n,o,(e=>{e.isInline&&i.push(t.isInSet(e.marks))})),i},se=(e,t)=>{const n=e.find((e=>"style"===e.type.name)),r=n&&n.attrs.style;return v(r,t)},ie=(e,t,n,r,s)=>{const i=s.create({style:r.style});let a=[],l=[],c=null,d=null;return e.doc.nodesBetween(t,n,((e,u,p)=>{if(!e.isInline)return;const h=e.marks;if(!i.isInSet(h)&&p.type.allowsMarkType(i.type)){const i=Math.max(u,t),p=Math.min(u+e.nodeSize,n),f=se(h,r);if(f.changed||r.newValue){const e=f.changed?{style:f.style||null}:{style:`${[r.style]}: ${r.newValue};`},t=s.isInSet(h)?h.find((e=>"style"===e.type.name)):null,n=t?{...t.attrs,...e}:e,u=s.create(n),m=u.addToSet(h);for(let e=0;e<h.length;e++)h[e].isInSet(m)||(c&&c.to===i&&c.mark.eq(h[e])?c.to=p:(c=new o.RemoveMarkStep(i,p,h[e]),a.push(c)));const g=d&&d.to===i,y=g&&u.attrs.style===d.mark.attrs.style;g&&y?d.to=p:Object.keys(n).some((e=>null!==n[e]))&&(d=new o.AddMarkStep(i,p,u),l.push(d))}}})),a.forEach((t=>e.step(t))),l.forEach((t=>e.step(t))),a.length+l.length>0},ae=(e,t)=>function(r,o,s){const{empty:i,ranges:a}=r.selection,l=r.selection instanceof n.TextSelection&&r.selection.$cursor;if(i&&!l||!J(r.doc,a,e))return!1;let c=!1;if(o){const n=s||r.tr;if(l){const s=r.storedMarks||l.marks();if(e.isInSet(s)){const r=se(s,t),i=s.find((e=>"style"===e.type.name)),a={...i?i.attrs:{},style:r.style||null};if(((e,t)=>{const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((n=>e[n]===t[n]))})(i.attrs,a))return!1;o(n.removeStoredMark(e)),Object.keys(a).some((e=>null!==a[e]))&&o(n.addStoredMark(e.create(a))),c=!0}}else{for(let r=0;r<a.length;r++){const{$from:o,$to:s}=a[r];c=ie(n,o.pos,s.pos,t,e)||c}c&&(n.scrollIntoView(),o(n))}}return c},le=(e,t,n)=>(r,o)=>{const s=r.schema.marks,{altStyle:i,altMarks:a=[],mark:l}=e,c=t||r.tr;let d=!1,u=!1;const p=()=>u=!0;if(i&&s.style){d=ae(s.style,{style:i.name,value:i.value})(r,p,c)}const h=[l,...a].filter((e=>s[e])).map((e=>ne(r,{mark:e})&&s[e])).filter((e=>e));return h.length?((e,t,n,r)=>{const{$cursor:o,ranges:s}=t.selection;if(r=r||t.tr,o)e.forEach((e=>{e.isInSet(t.storedMarks||o.marks())&&n(r.removeStoredMark(e))}));else{for(let t=0;t<s.length;t++){const{$from:n,$to:o}=s[t];e.forEach((e=>{ee(r,n.pos,o.pos,e)}))}n(r.scrollIntoView())}})(h,r,p,c):d||Q(s[l],n,c)(r,p),u&&o(c),u},ce=(e,t)=>(n,r)=>{const{$cursor:o}=n.selection;if(o){const s=o.parent,i=o.index(),a=n.schema.marks[e.mark],l=s.child(i).marks.find((e=>e.type===a)),c=s.childCount;let d,u,p=o.pos-o.textOffset,h=s.child(i).nodeSize;for(d=i-1;d>=0&&l.isInSet(s.child(d).marks);)u=s.child(d).nodeSize,h+=u,p-=u,d-=1;for(d=i+1;d<c&&l.isInSet(s.child(d).marks);)h+=s.child(d).nodeSize,d+=1;r(ee(t||n.tr,p,p+h,l))}else le(e,t)(n,r)},de=(e,n,r,s)=>{if(!r.isTextblock)return!1;const{ranges:i}=e.selection;i.forEach((i=>{const a=e.steps.length,l=i.$from.pos,c=i.$to.pos;e.doc.nodesBetween(l,c,((i,l)=>{if(i.eq(n)&&i.isTextblock&&!i.hasMarkup(r,s)&&((e,t,n)=>{const r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)})(e.doc,e.mapping.slice(a).map(l),r)){e.clearIncompatible(e.mapping.slice(a).map(l,1),r);const n=e.mapping.slice(a),c=n.map(l,1),d=n.map(l+i.nodeSize,1),u=new t.Slice(t.Fragment.from(r.create(s,null,i.marks)),0,0);return e.step(new o.ReplaceAroundStep(c,d,c+1,d-1,u,1,!0)),!1}}))}))},ue=(e,t={blocksInSelection:!1})=>{const{doc:r,selection:o}=e,{$from:s,ranges:i}=o,{blocksInSelection:a}=t,l=[],c=o instanceof n.NodeSelection?o.node:void 0;return c?c.isBlock?(l.push(c),c.nodesBetween(0,c.content.size,(e=>{e.isBlock&&l.push(e)}))):!a&&s.parent&&s.parent.isBlock&&l.push(s.parent):i.forEach((e=>{const t=e.$from.pos,n=e.$to.pos;r.nodesBetween(t,n,((e,r)=>{e.isBlock&&(!a||r>=t&&r+e.content.size+2<=n)&&l.push(e)}))})),l},pe=(e,t={blocksInSelection:!0})=>{const{doc:n,selection:r}=e,{blocksInSelection:o,blockNodeType:s}=t;ue({doc:n,selection:r},{blocksInSelection:o}).filter((e=>e.isTextblock)).forEach((t=>{const{style:n="",class:r="",...o}=t.attrs||{},i=s||t.type;(n||r||i!==t.type)&&de(e,t,i,o)}))},he=e=>{const t=ue(e),n=e.schema.nodes,r=[];return t.forEach((e=>{e.type===n.paragraph?r.push("p"):e.type===n.heading?r.push(`h${e.attrs.level}`):e.type===n.blockquote&&n.blockquote.isTextblock&&r.push("blockquote")})),r},fe=(e,t)=>{let n,r,o=e.attrs.style;o&&t.forEach((e=>{r={style:e.name,value:/^.+$/,newValue:e.value},n=v(o,r),o=n.changed?n.style:o}));return o=o||t.reduce(((e,t)=>(e&&t.value?e+" ":"")+t.value?`${t.name}: ${t.value};`:""),""),Object.assign({},e.attrs,{style:o||null})},me=(e,t)=>{const{from:n,to:r}=e.selection;let o=!1;return e.doc.nodesBetween(n,r,(e=>(o=o||e.type===t,!o))),o},ge=e=>{const t=he(e);return 1===new Set(t).size?t[0]:null},ye={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},be={listType:ye.orderedList,types:{...ye}},we={listType:ye.bulletList,types:{...ye}},ve={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"}],listsTypes:{...ye}},ke={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"}],listsTypes:{...ye}},Me=(e,t)=>{const{$from:n,$to:r}=e.selection,o=e.schema.nodes.blockquote,s=e.doc;let i=-1;const a=n.blockRange(r);a&&s.nodesBetween(a.start,a.end,((e,t)=>{e.type===o&&(i=t)}));const l=-1!==i;return t&&l&&t(e.tr.lift(a,s.resolve(i).depth)),l},xe=(e,t,n)=>(r,o)=>{const s=ue(r),i=r.tr;i.setMeta("commandName",t),s.forEach((t=>{if(t.type.isTextblock){let r;const o=e.find((e=>e.node===t.type.name));if(o){const e="rtl"===n?o.rtlStyle:o.style,s={name:e,value:o.step>0?`${o.step}${o.unit}`:""};if(t.attrs.style){const n=new RegExp(`${e}:\\s?(\\d+)${o.unit}`,"i"),r=t.attrs.style.match(n);if(r){let e=parseFloat(r[1])+o.step;e=e<=0?"":e,s.value=`${e}${e?o.unit:""}`}}r=fe(t,[s])}r&&de(i,t,t.type,r)}}));const a=i.docChanged;return a&&o(i.scrollIntoView()),a},Se=(e,t,n)=>{const r=ue(e);let o=!1;return r.forEach((e=>{if(!o&&e.type.isTextblock&&e.attrs.style){const r=t.find((t=>t.node===e.type.name));if(r){const t="rtl"===n?r.rtlStyle:r.style,s=new RegExp(`${t}:\\s?\\d+${r.unit}`,"i");o=s.test(e.attrs.style)}}})),o},Oe=(e,t)=>s.sinkListItem(t)(e),Ce=(e,t)=>{const n=e.schema.nodes[t.listsTypes.listItem],r=e.schema.nodes[t.listsTypes.orderedList],o=e.schema.nodes[t.listsTypes.bulletList],i=!!S(r,2)(e.selection),a=!!S(o,2)(e.selection);return(i||a)&&s.liftListItem(n)(e)},Ae=(e,t)=>{const n=e.schema.nodes,r=n[ve.listsTypes.listItem];return(Se(e,t.nodes)||ve.nodes.some((t=>n[t.node]&&me(e,n[t.node]))))&&!me(e,r)},Te=(e,t,n)=>{let r=t.depth;const o=e.nodes[n.bulletList],s=e.nodes[n.orderedList],i=e.nodes[n.listItem];for(let e=t.depth;e>0;e--){const n=t.node(e);if(n.type!==o&&n.type!==s||(r=e),n.type!==o&&n.type!==s&&n.type!==i)break}return r-1};function Ee(e){return function(t,n,r){if(!r)return!1;const o=(t=r.state).schema.nodes[e.listType],{$from:a,$to:l}=t.selection,c=a.node(-2),d=a.node(-3),u=function(e,t,n,r){return 0===function(e,t,n){const r=[],o=function(e,t){const n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;let r=t.node(t.depth),o=t;for(;t.depth>=1;)r=(t=e.resolve(t.before(t.depth))).node(t.depth),r&&-1!==n.indexOf(r.type.name)&&(o=t);return o}(e,t).depth;let s=e.resolve(t.start(o));for(;s.pos<=n.start(n.depth);){const t=Math.min(s.depth,o),n=s.node(t);if(n&&r.push(n),0===t)break;let i=e.resolve(s.after(t));if(i.start(t)>=e.nodeSize-2)break;i.depth!==s.depth&&(i=e.resolve(i.pos+2)),s=i.depth?e.resolve(i.start(i.depth)):e.resolve(i.end(i.depth))}return r}(e,t,n).filter((e=>e.type!==r)).length}(t.doc,a,l,o);return(c&&c.type===o||d&&d.type===o)&&u?De(e)(t,n):(u||(De(e)(t,n),t=r.state),function(e,t={}){return i.autoJoin(s.wrapInList(e,t),((t,n)=>t.type===n.type&&t.type===e))}(o,e.listAttrs)(t,n))}}function Ne(e,n,r,s){const i=s||e.schema.nodes.listItem,{$from:a,$to:l}=n;let c=a.blockRange(l,(e=>e.childCount&&e.firstChild.type===i));if(!c||c.depth<2||a.node(c.depth-1).type!==i)return r;const d=c.end,u=l.end(c.depth);return d<u&&(r.step(new o.ReplaceAroundStep(d-1,u,d,u,new t.Slice(t.Fragment.from(i.create(void 0,c.parent.copy())),1,0),1,!0)),c=new t.NodeRange(r.doc.resolve(a.pos),r.doc.resolve(u),c.depth)),r.lift(c,o.liftTarget(c)).scrollIntoView()}function De(e){return function(t,r){const{tr:s}=t,{$from:i,$to:a}=t.selection;return s.doc.nodesBetween(i.pos,a.pos,((r,i)=>{if(r.isTextblock||"blockquote"===r.type.name||"div"===r.type.name){const r=new n.NodeSelection(s.doc.resolve(s.mapping.map(i))),a=r.$from.blockRange(r.$to);if(!a||r.$from.parent.type!==t.schema.nodes[e.listItem])return;const l=a&&o.liftTarget(a);if(null==l)return!1;s.lift(a,l)}})),r&&r(s),!0}}const $e=/list\-style\-type:\s?([\w-]+)/,Pe=e=>{const t=e.style||"",n=$e.exec(t);return n&&n[1]||""},He=(e,t,r,o,s)=>{const{listType:i,listAttrs:a={style:null}}=o,{selection:l}=e,c=l.$from.node(l.$from.depth-2),d=l.$to.node(l.$to.depth-2);if(c&&c.type.name===i&&Pe(c.attrs)===Pe(a)&&d&&d.type.name===i&&Pe(d.attrs)===Pe(a)){const i=r.state.schema.nodes,a={bulletList:i[o.bulletList],orderedList:i[o.orderedList],listItem:i[o.listItem]},c=((e,t)=>{const{bulletList:n,orderedList:r,listItem:o}=t;let s;for(let t=e.depth-1;t>0;t--){const i=e.node(t);if(i.type!==n&&i.type!==r||(s=t),i.type!==n&&i.type!==r&&i.type!==o)break}return s})(l.$to,a);let d=function(e,t,r,o,s,i){i||(i=e.schema.nodes.listItem);let a=!1;return s.doc.nodesBetween(t,r,((r,l)=>{if(!a&&r.type===i&&l>t){a=!0;let t=o+3;for(;t>o+2;){const o=s.doc.resolve(s.mapping.map(l));t=o.depth;const a=s.doc.resolve(s.mapping.map(l+r.textContent.length)),c=new n.TextSelection(o,a);s=Ne(e,c,s,i)}}})),s}(e,l.$to.pos,l.$to.end(c),c,r.state.tr,a.listItem);return d=function(e,t,n){const{from:r,to:o}=e.selection,{paragraph:s,heading:i}=e.schema.nodes,a=[];t.doc.nodesBetween(r,o,((e,t)=>{e.type!==s&&e.type!==i||a.push({node:e,pos:t})}));for(let r=a.length-1;r>=0;r--){const o=a[r],s=t.doc.resolve(t.mapping.map(o.pos));if(s.depth>0){let r;r=o.node.textContent&&o.node.textContent.length>0?t.doc.resolve(t.mapping.map(o.pos+o.node.textContent.length)):t.doc.resolve(t.mapping.map(o.pos+1));const i=s.blockRange(r);i&&t.lift(i,Te(e.schema,s,n))}}return t}(e,d,o),d.setMeta("commandName",s),t(d),!0}return Ee(o)(e,t,r)};const Ie=(e,t)=>({name:e,value:t}),Le=[{node:"paragraph",style:[Ie("text-align","left")]},{node:"heading",style:[Ie("text-align","left")]},{node:"table_caption_external",style:[Ie("text-align","left")]}],ze=[{node:"paragraph",style:[Ie("text-align","right")]},{node:"heading",style:[Ie("text-align","right")]},{node:"table_caption_external",style:[Ie("text-align","right")]}],je=[{node:"paragraph",style:[Ie("text-align","center")]},{node:"heading",style:[Ie("text-align","center")]},{node:"table_caption_external",style:[Ie("text-align","center")]}],Re=[{node:"paragraph",style:[Ie("text-align","justify")]},{node:"heading",style:[Ie("text-align","justify")]},{node:"table_caption_external",style:[Ie("text-align","justify")]}],Be=[{node:"paragraph",style:[Ie("text-align","")]},{node:"heading",style:[Ie("text-align","")]},{node:"table_caption_external",style:[Ie("text-align","")]}],_e=["blockquote",0],Fe=["hr"],qe=["pre",["code",0]],We=["ol",0],Ve=["ul",0],Ke=["li",0],Ye=e=>{const t={},n=e.attributes;let r;for(let e=0;e<n.length;e++)r=n[e],t[r.name]=r.value;return t},Xe=e=>{const t={};return e.forEach((e=>{t[e]={default:null}})),t},Ge=()=>Xe(["style","class","id"]),Ue=(e,t)=>{for(const n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},Ze=(e,t=[])=>{const n={};for(const r in e)r&&null!==e[r]&&!t.find((e=>e===r))&&(n[r]=e[r]);return n},Je=e=>({[e]:{name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:()=>[e,0]}}),Qe={link:{attrs:{...Ge(),href:{default:null},target:{default:null},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a",getAttrs:Ye}],toDOM:e=>["a",Ze(e.attrs),0]},...Je("strong"),...Je("b"),...Je("em"),...Je("i"),...Je("del"),...Je("sub"),...Je("sup"),...Je("code"),style:{attrs:{...Ge()},parseDOM:[{tag:"span",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["span",Ze(e.attrs),0]:["span",0]},...Je("u")},et=e=>({[e]:{default:null,getFromDOM:t=>t.getAttribute(e),setDOMAttr:(t,n)=>{n[e]=t}}}),tt={...et("style"),...et("class"),...et("id"),...et("headers"),...et("scope")},nt={doc:{content:"colgroup*"},col:{attrs:Xe(["id","class","style","span"]),parseDOM:[{getAttrs:Ye,tag:"col"}],toDOM:e=>["col",e.attrs]},colgroup:{attrs:Xe(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:Ye,tag:"colgroup"}],toDOM:e=>["colgroup",e.attrs,0]},text:{inline:!0,group:"inline"}},rt=new t.Schema({nodes:nt,marks:{}}),ot=e=>{const t=U(Y(e),rt,{preserveWhitespace:!1});return G(t).firstChild},st=a.tableNodes({tableGroup:"block",cellContent:"block+",cellAttributes:tt});st.table_row.attrs={...st.table_row.attrs,...Xe([f,"style","class","id"])},st.table_row.toDOM=e=>["tr",Ze(e.attrs),0],st.table_row.parseDOM=[{tag:"tr",getAttrs:Ye}],st.table.attrs={...st.table.attrs,...Xe(["style","class","id",m,g])},st.table.toDOM=e=>{const t=Ue(e.attrs)?Ze(e.attrs,[m,g]):{};let n=null;if(e.attrs[m]&&!(e=>{let t=!1;const n=e.child(0);for(let e=0;e<n.childCount;e++)if(n.child(e).attrs.colwidth){t=!0;break}return t})(e)){const t=ot(e.attrs[m]);if(t){const e=Array.from(t.children).map((e=>["col",Ye(e)]));n=["colgroup",Ye(t)].concat(e)}}return n?["table",t,n,["tbody",0]]:["table",t,["tbody",0]]},st.table.parseDOM=[{tag:"table",getAttrs:e=>{const t=Ye(e),n=Array.from(e.childNodes).find((e=>"COLGROUP"===e.nodeName));return n&&(t[m]=n.outerHTML),t}}];const it={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:{...Ge()},parseDOM:[{tag:"p",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["p",Ze(e.attrs),0]:["p",0]},table_wrapper:{content:"(table_caption_external | table)+",group:"block",defining:!0,attrs:{table:{default:null},style:{default:null}},parseDOM:[{tag:"div[table]",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["div",Ze(e.attrs),0]:["div",0]},table_caption_external:{content:"inline+",group:"block",attrs:{caption:{default:null},...Ge()},parseDOM:[{tag:"div[caption]",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["div",Ze(e.attrs),0]:["div",0]},div:{content:"block*",group:"block",attrs:{...Ge()},parseDOM:[{tag:"div",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["div",Ze(e.attrs),0]:["div",0]},blockquote:{attrs:{...Ge()},content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["blockquote",Ze(e.attrs),0]:_e},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>Fe},heading:{attrs:{...Ge(),level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:e=>({...Ye(e),level:1})},{tag:"h2",getAttrs:e=>({...Ye(e),level:2})},{tag:"h3",getAttrs:e=>({...Ye(e),level:3})},{tag:"h4",getAttrs:e=>({...Ye(e),level:4})},{tag:"h5",getAttrs:e=>({...Ye(e),level:5})},{tag:"h6",getAttrs:e=>({...Ye(e),level:6})}],toDOM:e=>Ue(e.attrs,"level")?["h"+e.attrs.level,Ze(e.attrs,["level"]),0]:["h"+e.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>qe},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},...Ge()},group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["img",Ze(e.attrs)]:["img"]},hard_break:{inline:!0,attrs:{...Ge()},group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["br",Ze(e.attrs)]:["br"]},ordered_list:{content:"list_item+",group:"block",attrs:{...Ge(),type:{default:null},order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({...Ye(e),order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}],toDOM:e=>1===e.attrs.order?Ue(e.attrs,"order")?["ol",Ze(e.attrs,["order"]),0]:We:["ol",{...Ze(e.attrs,["order"]),start:e.attrs.order},0]},bullet_list:{content:"list_item+",group:"block",attrs:{...Ge()},parseDOM:[{tag:"ul",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["ul",Ze(e.attrs),0]:Ve},list_item:{content:"(paragraph | heading) block*",attrs:{...Ge()},parseDOM:[{tag:"li",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["li",Ze(e.attrs),0]:Ke,defining:!0},...st},at={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},lt={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},ct={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},dt="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ut=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,pt=e=>/^MsoListParagraph/.test(e.className),ht=e=>{let t=e.innerHTML;return t=t.replace(/<!--(.|\s)*?-->/gi,""),t=t.replace(/<\/?[^>]+?\/?>/gm,""),t},ft=(e,t)=>{const n=document.createElement(e);return n.style.listStyleType=t,n},mt=e=>{let t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},gt=(e,t)=>{let n=[];Array.from(e).forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const r=e;r.getAttribute("datalist")?(n.push(e),t.add(n)):pt(r)&&n.length?n.push(e):(n=[],"DIV"===r.nodeName?gt(r.children,t):"TABLE"===r.nodeName&&Array.from(r.querySelectorAll("td,th")).forEach((e=>{gt(e.children,t)})))}))},yt=e=>{let t=e.innerHTML;const n=e=>e.replace(/^(?: |[\u00a0\n\r\s])+/,"");return t=t.replace(/<\/?\w+[^>]*>/g,"").replace(/ /g," "),/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(t)?{tag:"ul",style:(r=n(ht(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(r)?null:/^o/.test(r)?"circle":"square")}:/^\s*\w+[\.\)][\u00a0 ]{2,}/.test(t)?{tag:"ol",style:mt(n(ht(e)))}:void 0;var r},bt=e=>{let t,n=e.nodeName.toLowerCase();e.firstChild&&e.firstChild.nodeType===Node.COMMENT_NODE&&e.removeChild(e.firstChild),1===e.childNodes.length?t=e.firstChild.nodeType===Node.TEXT_NODE?ht(e):e.firstChild.innerHTML.replace(/^\w+[\.\)]( )+ /,""):(e.removeChild(e.firstChild),3===e.firstChild.nodeType&&/^[ivxlcdm]+\.$/i.test(e.firstChild.nodeValue)&&e.removeChild(e.firstChild),/^( |\s)+$/i.test(e.firstChild.innerHTML)&&e.removeChild(e.firstChild),t="p"!==n?"<"+n+">"+e.innerHTML+"</"+n+">":e.innerHTML),e.parentNode.removeChild(e);const r=document.createElement("li");return r.appendChild(Y(t)),r},wt=e=>{const t=Y((e=>e.replace(ut,((e,t,n)=>`datalist="${t}" datalevel="${n}" ${e}`)))(e)),n=new Set;return gt(t.children,n),n.forEach((e=>(e=>{let t,n,r,o,s,i,a,l,c,d,u,p,h,f=-1,m={};for(l=0;l<e.length;l++){c=e[l],h={datalist:c.getAttribute("datalist"),datalevel:c.getAttribute("datalevel")};const g=h.datalist,y=yt(c);if(d=y&&y.tag,!d){!t||s&&!pt(c)||(c.style.marginLeft&&(c.style.marginLeft=""),c.style.marginLeft&&(c.style.margin=""),t.appendChild(c));continue}if(u=h.datalevel||parseFloat(c.style.marginLeft||0),!h.datalevel&&!c.style.marginLeft)continue;const b=d+g;m[u]||(m[u]={}),(!n||n<0)&&(n=u,r=g,a=e.filter((e=>e.getAttribute("datalist")===String(r))),o=a[a.length-1],i=ft(d,y&&y.style),c.parentNode.insertBefore(i,c),f=u,m[u][b]=i),s=o===c,p=m[u][b],(u>f||!p)&&(p=ft(d,y&&y.style),m[u][b]=p,t.appendChild(p)),t=bt(c),p.appendChild(t),s?n=f=-1:f=u}})(e))),X(t)},vt=(e,t)=>e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),""),kt=e=>{e.ownerElement&&e.ownerElement.removeAttribute(e.name)};function Mt(e){const t=e.length,n=new Array(t/2);for(let r=0;r<t;r+=2)n[r]=String.fromCharCode(parseInt(e.substring(r,r+2),16));return btoa(n.join(""))}const xt=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,St=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,Ot=new RegExp("(?:("+St.source+"))([\\da-fA-F\\s]+)\\}","g"),Ct=/[^\da-fA-F]/g,At=/file:\/[^'"]+\.(jpg|png|gif)/i,Tt=/\\(png|jpeg)blip\\/,Et="text/rtf",Nt=(e,t,r,o,s)=>{let i,a,l,c,d,u,p=[];const h=[],{matchCase:f,matchWord:m,useRegExp:g}=t;let y=t.text;if(g&&(/^\\$/.test(y)||/[^\\]\\$/.test(y))&&(y=y.substring(0,y.length-1)),!y)return p;const b=f?"g":"gi",w=g?new RegExp(y,b):Ht(y,b);return e.nodesBetween(r,o,((t,f)=>{if(s(p))return!1;t.inlineContent&&f+t.content.size>=r&&(h.length=0,t.nodesBetween(0,t.content.size,((t,g,y,b)=>{if(s(p))return!1;const v=1+f+g;if(t.isText&&v+t.nodeSize>=r){if(d=t.text||"",u=y.childCount-1>=b+1&&y.child(b+1),h.push(r<=v?{text:d,start:v}:{text:d.slice(r-v),start:r}),u&&u.isText)return;for(a=h.map((e=>e.text)).join(""),i=w.exec(a);null!==i&&(l=h[0].start+i.index,c=l+i[0].length,r<=l&&o>=c&&Pt(i,m)&&p.push(n.TextSelection.create(e,l,c)),!s(p));)i=w.exec(a)}else h.length=0})))})),p},Dt=(e,t)=>Nt(e,t,0,e.content.size,(()=>!1)),$t=/^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/,Pt=(e,t)=>{if(t){if(!0===t){const t=e.input,n=t.charAt(e.index-1),r=t.charAt(e.index+e[0].length);return $t.test(n)&&$t.test(r)}return t(e)}return!0},Ht=(e,t)=>{const n=e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(/\s/g,"\\s");return new RegExp(n,t)};const It=/\s+/g,Lt=/text-align/,zt=(e,t)=>{for(const n in t)n&&I(e,n,t[n])};class jt{constructor(e,t,n,r=!1){this.node=e,this.view=t,this.dom=document.createElement(n),zt(this.dom,e.attrs),this.contentDOM=r?void 0:this.dom}}class Rt{constructor(e,t){this.mark=e,this.view=t,this.dom=document.createElement("span"),zt(this.dom,e.attrs),this.contentDOM=this.dom}}const Bt=new n.PluginKey("highlight");const _t={southeast:{x:1,y:1},east:{x:1,y:0},south:{x:0,y:1},north:{x:0,y:-1},west:{x:-1,y:0},southwest:{x:-1,y:1},northwest:{x:-1,y:-1},northeast:{x:1,y:-1}},Ft=Object.keys(_t),qt=new n.PluginKey("image-resize"),Wt=(e,t,n)=>{e.style[t]=n+"px"},Vt=/[^\-]width:|[^\-]height:/,Kt=/^.+$/;let Yt=class e{constructor(e,t,n,r){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=r}apply(t){const n=t.getMeta(qt);return n?new e(n.activeHandle,n.setDragging,n.rect,n.nodePosition):this}};const Xt=(e,t,r)=>{const o=t.target.getAttribute(w);if(!o)return!1;const s=qt.getState(e.state);t.preventDefault();const i=e.state.tr;function a(t){((e,t,n)=>{const r=qt.getState(e.state),{rect:o,dragging:s,nodePosition:i,activeHandle:a}=r;if(!s||!o)return;const l=e.nodeDOM(i),c=_t[a],d=(t.clientX-s.startX)*c.x,u=(t.clientY-s.startY)*c.y;let p=c.x?d+l.width:o.width,h=c.y?u+l.height:o.height;if(n.lockRatio&&c.x&&c.y){const e=Math.min(p/l.width,h/l.height),n=l.width*e,r=l.height*e;s.startX=t.clientX-(p-n)*c.x,s.startY=t.clientY-(h-r)*c.y,p=n,h=r}else s.startX=c.x?t.clientX:s.startX,s.startY=c.y?t.clientY:s.startY;Wt(l,"width",p),Wt(l,"height",h),o.top=l.offsetTop,o.left=l.offsetLeft,o.width=l.offsetWidth,o.height=l.offsetHeight;const f=l.nextElementSibling;f.style.width=o.width+"px",f.style.height=o.height+"px",f.style.top=o.top+"px",f.style.left=o.left+"px"})(e,t,r)}return i.setMeta(qt,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:o,rect:s.rect,nodePosition:s.nodePosition}),i.setMeta("addToHistory",!1),e.dispatch(i),t.view.addEventListener("mouseup",(function t(r){r.view.removeEventListener("mouseup",t),r.view.removeEventListener("mousemove",a),(e=>{const{rect:t,dragging:r,nodePosition:o}=qt.getState(e.state);if(r&&t){const r=e.state.selection;if(r instanceof n.NodeSelection){const s=r.node.attrs,i=t.width,a=t.height;let l;if(Vt.test(s.style||"")){const e=v(s.style,{style:"width",value:Kt,newValue:i+"px"}),{style:t}=v(e.style||"",{style:"height",value:Kt,newValue:a+"px"});l={...s,style:t}}else l={...s,width:i,height:a};const c=r.node.type.createAndFill(l);if(c){const r=e.state.tr;r.replaceWith(o,o+1,c),r.setSelection(n.NodeSelection.create(r.doc,o)),r.setMeta("commandName","image-resize"),r.setMeta("args",l),r.setMeta(qt,{setDragging:null,activeHandle:null,rect:t,nodePosition:o}),e.dispatch(r)}}}})(e)})),t.view.addEventListener("mousemove",a),!0},Gt=new n.PluginKey("caret-color");class Ut{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className="k-editor-resize-wrap-element",this.table=this.dom.appendChild(document.createElement("table")),e.attrs[m]&&this.renderColgroup(e.attrs[m]);const n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=Ft.map((e=>{const t=document.createElement("span");return t.className=y+" "+e,t.setAttribute(b,e),t})),this.contentDOM=n}update(e){if(e.type!==this.node.type)return!1;const t=this.node;return this.node=e,e.attrs[g]?this.resizeHandles.forEach((e=>{this.dom.appendChild(e)})):Array.from(this.dom.children).filter((e=>e.classList.contains(y))).forEach((e=>e.remove())),this.setAttributes(this.table,e.attrs),t.attrs[m]!==e.attrs[m]&&this.renderColgroup(e.attrs[m]),!0}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))}destroy(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0}renderColgroup(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=ot(e),this.table.insertBefore(this.colgroup,this.table.firstChild))}setAttributes(e,t){const n=[m,g];for(const r in t)r&&-1===n.indexOf(r)&&I(e,r,t[r]);/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""}}class Zt{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}update(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)}ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName}destroy(){this.node=void 0,this.view=void 0}setAttributes(e,t){for(const n in t)n&&I(e,n,t[n]);if(e.setAttribute("table",""),/%/.test(e.style.width)){const t=this.node&&this.node.lastChild,n=(t?$(t.attrs.style):{}).width||"";n&&!/%/.test(n)&&(e.style.width="")}}}const Jt=new n.PluginKey("table-resize"),Qt=new n.PluginKey("table-column-resizing"),en=new n.PluginKey("table-row-resizing");function tn(e,t){let n=!1;return n=n||e!==Jt&&Boolean(Jt.get(t))&&Jt.getState(t).dragging,n=n||e!==Qt&&Boolean(Qt.get(t))&&Qt.getState(t).dragging,n=n||e!==en&&Boolean(en.get(t))&&en.getState(t).dragging,n}function nn(e,t){let n=!1;return n=n||e!==Qt&&Boolean(Qt.get(t))&&Qt.getState(t).activeHandle>-1,n=n||e!==en&&Boolean(en.get(t))&&en.getState(t).activeHandle>-1,n}function rn(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e}function on(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}function sn(e){const t=function(e){const t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((e=>e.colSpan)).reduce(((e,t)=>e+t),0),r=t.map((()=>new Array(n)));return t.forEach(((e,t)=>{let n=0;Array.from(e.cells).forEach((e=>{for(let o=0;o<e.colSpan;o++){for(let o=0;o<e.rowSpan;o++){const s=r[t+o].findIndex(((e,t)=>t>=n&&!e));r[t+o][s]=e}n++}}))})),r}(e.closest("table"));let n=null;for(let r=0;r<t.length;r++){if(t[r].forEach(((t,o)=>{e===t&&(n={rowIndex:r,cellIndex:o})})),n)break}return n||{rowIndex:-1,cellIndex:-1}}function an(e,t,n){const r=e.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return-1;const o=e.state.doc.resolve(r.pos),s=O(o,(e=>"table"===e.type.spec.tableRole));if(null===s)return-1;const i=o.start(s.depth),l=s.node,c=a.TableMap.get(l);return i+c.map[c.width*n.rowIndex+n.cellIndex]}function ln(){const e=new n.Plugin({key:Qt,state:{init:()=>new cn(-1,null),apply:(e,t)=>t.apply(e)},props:{attributes(e){if(nn(Qt,e))return null;return Qt.getState(e).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:(e,t)=>(tn(Qt,e.state)||function(e,t,n){const r=Qt.getState(e.state);if(!r.dragging){const o=on(t.target);let s=-1;if(o){const r=sn(o),{left:i,right:a}=o.getBoundingClientRect();Math.abs(t.clientX-i)<=n&&r.cellIndex>0?(r.cellIndex-=o.colSpan,s=an(e,t,r)):a-t.clientX>0&&a-t.clientX<=n&&(s=an(e,t,r))}s!==r.activeHandle&&dn(e,s)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=Qt.getState(e.state);t.activeHandle>-1&&!t.dragging&&dn(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t,n){const r=Qt.getState(e.state);if(-1===r.activeHandle||r.dragging)return!1;const o=e.state.doc.resolve(r.activeHandle),s=o.parent,i=o.index();let l=0;for(let e=0;e<=i;e++)l+=s.child(e).attrs.colspan;const c=o.node(o.depth-1),d=e.domAtPos(r.activeHandle),u=d.node.childNodes[d.offset].closest("table");let p,h;if(c.attrs[m]){p=u.firstChild.children[l-1],p.style.width||(p.style.width=p.offsetWidth+"px")}else{let e=0;for(let t=0;t<s.childCount;t++)e+=s.child(t).attrs.colspan;const t=document.createElement("colgroup"),n=new Array(e);for(let r=0;r<e;r++)n[r]=document.createElement("col"),t.appendChild(n[r]);u.insertBefore(t,u.firstChild),p=n[i],p.style.width=p.offsetWidth+"px",h={...c.attrs,[m]:"<colgroup>"+n.reduce(((e,t)=>e+t.outerHTML),"")+"</colgroup>"}}const f=parseFloat(p.style.width),g=e.state.tr.setMeta(Qt,{setDragging:{startX:t.clientX,startWidth:f}});if(!u.style.width){const e=Array.from(p.parentNode.children).map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);h=M(h||c.attrs,"width",t+"px")}}if(h){const e=o.posAtIndex(0,o.depth-1)-1;g.setNodeMarkup(e,null,h)}function y(t){t.view.removeEventListener("mouseup",y),t.view.removeEventListener("mousemove",b);const n=Qt.getState(e.state);if(n.dragging){const t=e.state.tr;!function(e,t,n){const r=e.state.doc.resolve(n),o=r.node(-1),s=r.start(-1),i=r.posAtIndex(0,r.depth-1)-1,a=e.nodeDOM(s).closest("table");let l=o.attrs;if(o&&l[m]){const e=a.firstChild;l={...l,[m]:e.outerHTML}}const c=a.style.width;a&&c&&$(l.style).width!==c&&(l=M(l,"width",c));t.setNodeMarkup(i,null,l)}(e,t,n.activeHandle),e.dispatch(t.setMeta(Qt,{setDragging:null}))}}function b(t){if(!t.which)return y(t);const r=Qt.getState(e.state),o=function(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}(r.dragging,t,n);!function(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),s=r.start(-1),i=a.TableMap.get(o).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let l=e.domAtPos(r.start(-1)).node;"TABLE"!==l.nodeName&&(l=l.closest("table"));const c=l,d=c.firstChild,u=Array.from(d.children);if(u[i].style.width=n+"px",c.style.width){const e=u.map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);c.style.width=t+"px"}}}(e,r.activeHandle,o)}return e.dispatch(g),t.view.addEventListener("mouseup",y),t.view.addEventListener("mousemove",b),t.preventDefault(),!0}(e,t,25)},decorations(e){if(!tn(Qt,e)){const t=Qt.getState(e);if(t.activeHandle>-1)return function(e,t){const n=[],r=e.doc.resolve(t),o=r.node(-1),s=a.TableMap.get(o),i=r.start(-1),l=[],c=t-i;let u=-1;for(let e=0;e<s.height;e++)l.push(s.map.slice(e*s.width,e*s.width+s.width)),-1===u&&(u=l[e].lastIndexOf(c));const p=[];return l.forEach((e=>{const t=e[u];e[u]!==e[u+1]&&p.push(t)})),p.forEach((e=>{const t=i+e+o.nodeAt(e).nodeSize-1,r=document.createElement("div");r.className="column-resize-handle",n.push(d.Decoration.widget(t,r))})),d.DecorationSet.create(e.doc,n)}(e,t.activeHandle)}return d.DecorationSet.empty},nodeViews:{table_wrapper:(e,t)=>new Zt(e,t),table:(e,t)=>new Ut(e,t)}}});return e}let cn=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n;const r=t.getMeta(Qt);if(r&&null!=r.setHandle)return new e(r.setHandle,null);if(r&&void 0!==r.setDragging)return new e(this.activeHandle,r.setDragging);if(this.activeHandle>-1&&t.docChanged){let r=t.mapping.map(this.activeHandle,-1);o=t.doc.resolve(r),Boolean("row"===o.parent.type.spec.tableRole&&o.nodeAfter)||(r=-1),n=new e(r,this.dragging)}var o;return n||this}};function dn(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(Qt,{setHandle:t}),e.dispatch(n)}const un={southeast:!0,southwest:!0,northwest:!0,northeast:!0},pn={east:!0,west:!0,...un},hn={south:!0,north:!0,...un};let fn=class e{constructor(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}apply(t){const n=t.getMeta(Jt);if(n){return new e(n.activeHandle,n.setDragging,n.nodePosition)}return this}};const mn=e=>{const t=Array.from(e.firstChild.children).map((e=>e.offsetWidth)),n=Array.from(e.rows).map((e=>e.offsetHeight)),r=t.reduce(((e,t)=>e+t),0),o=n.reduce(((e,t)=>e+t),0),s=e.offsetHeight;return{width:r,height:o,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:s}},gn=e=>{const{dragging:t,nodePosition:n,activeHandle:r}=Jt.getState(e.state);if(t){const t=e.state.doc.nodeAt(n),o=rn(e.nodeDOM(n)),s=mn(o);if(t){const i=s.offsetWidth+"px",a=s.offsetHeight+"px",l=e.state.tr;let c=t.attrs;const d=$(c.style);if(pn[r]&&o.style.width&&d.width!==i&&(c=M(c,"width",i)),hn[r]&&o.style.height&&d.height!==a&&(c=M(c,"height",a)),c=((e,t,n,r)=>{const o=e.state.doc.nodeAt(n),s=rn(e.nodeDOM(n)),i=(s.ownerDocument&&s.ownerDocument.defaultView||window).getComputedStyle,a=Array.from(s.rows);o.forEach(((e,r,o)=>{const s=$(e.attrs.style).height;s&&!/px$/.test(s)&&t.setNodeMarkup(n+r+1,null,M(e.attrs,"height",i(a[o]).height))}));const l=s.firstChild,c=Array.from(l&&l.children||[]);let d=!1;c.forEach(((e,t)=>{e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=i(c[t]).width,d=!0)}));const u={...r};return d&&(u[m]=l.outerHTML),u})(e,l,n,c),l.setNodeMarkup(n,null,c),l.setMeta("commandName","node-resize"),l.setMeta("args",c),l.setMeta(Jt,{setDragging:null,activeHandle:null,nodePosition:n}),!/%/.test($(c.style).width||"")){const e=l.doc.resolve(n),t=O(e,(e=>"table_wrapper"===e.type.name));if(t&&/%/.test($(t.node.attrs.style).width||"")){const n=M(t.node.attrs,"width",""),r=e.start(t.depth)-1;l.setNodeMarkup(r,null,n)}}e.dispatch(l)}}},yn=(e,t)=>{const n=t.target.getAttribute(b);if(!n)return!1;const r=Jt.getState(e.state);t.preventDefault();const o=e.state.tr;o.setMeta(Jt,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:r.nodePosition}),o.setMeta("addToHistory",!1),((e,t,n)=>{const r=e.state.doc.nodeAt(n),o=rn(e.nodeDOM(n)),{width:s,height:i,colsWidth:a,rowsHeight:l,offsetWidth:c,offsetHeight:d}=mn(o),u=o.firstChild,p=Array.from(u&&u.children||[]);let h=!1;p.forEach(((e,t)=>{e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*a[t]/s+"%",h=!0)}));let f=!1;r.forEach(((e,r,o)=>{const s=$(e.attrs.style).height;s&&!/%$/.test(s)&&(t.setNodeMarkup(n+r+1,null,M(e.attrs,"height",100*l[o]/i+"%")),f=!0)}));let g=r.attrs;$(g.style).width!==c+"px"&&(g=M(g,"width",c+"px")),h&&(g[m]=u.outerHTML),f&&(g=M(g,"height",d+"px")),(h||f)&&t.setNodeMarkup(n,null,g)})(e,o,r.nodePosition),e.dispatch(o);const s=t.view||window;function i(t){((e,t)=>{var n;const r=Jt.getState(e.state),{dragging:o,nodePosition:s,activeHandle:i}=r;if(s<0||!o)return;const a=rn(e.nodeDOM(s)),l=a.getBoundingClientRect(),c=_t[i],d=(t.clientX-o.startX)*c.x,u=(t.clientY-o.startY)*c.y,p=(a.ownerDocument&&a.ownerDocument.defaultView||window).getComputedStyle(a),h=/px/.test(p.width)?parseFloat(p.width):a.offsetWidth,f=/px/.test(p.height)?parseFloat(p.height):a.offsetHeight,m=c.x?d+h:l.width,g=c.y?u+f:l.height;if(o.startX=c.x?t.clientX:o.startX,o.startY=c.y?t.clientY:o.startY,pn[i]&&(a.style.width=m+"px"),hn[i]&&(a.style.height=g+"px"),/px/.test(a.style.width)){const e=null===(n=a.parentNode)||void 0===n?void 0:n.parentNode;e instanceof HTMLDivElement&&e.matches("div[table]")&&/%/.test(e.style.width)&&(e.style.width="")}})(e,t)}return s.addEventListener("mouseup",(function t(){s.removeEventListener("mouseup",t),s.removeEventListener("mousemove",i),gn(e)})),s.addEventListener("mousemove",i),!0},bn=(e={node:"table"})=>new n.Plugin({key:Jt,view:()=>({selectedNode(e,t){const r=e.selection;if(r instanceof n.NodeSelection&&t===r.node.type&&r instanceof n.NodeSelection)return{node:r.node,pos:r.from};const o=O(r.$from,(e=>e.type===t)),s=o&&o.node;if(s){return{node:s,pos:r.$from.start(o.depth)-1}}return null},update(t,n){const r=t.state,o=r.schema.nodes[e.node],s=this.selectedNode(r,o),i=this.selectedNode(n,o);if((s||!i||n.doc.eq(t.state.doc))&&(s||i)){const e=r.tr;if(e.setMeta("addToHistory",!1),s&&i&&s.pos!==i.pos){e.setMeta(Jt,{nodePosition:s.pos});const n=e.doc.nodeAt(i.pos);n&&n.type.name===o.name&&e.setNodeMarkup(i.pos,o,{...i.node.attrs,[g]:!1}),e.setNodeMarkup(s.pos,o,{...s.node.attrs,[g]:!0}),t.dispatch(e)}else s&&i&&s.pos===i.pos&&!s.node.attrs[g]&&!r.selection.eq(n.selection)?(e.setMeta(Jt,{nodePosition:s.pos}),t.dispatch(e.setNodeMarkup(s.pos,o,{...s.node.attrs,[g]:!0}))):s&&!i?(e.setMeta(Jt,{nodePosition:s.pos}),t.dispatch(e.setNodeMarkup(s.pos,o,{...s.node.attrs,[g]:!0}))):!s&&i&&(e.setMeta(Jt,{nodePosition:-1}),t.dispatch(e.setNodeMarkup(i.pos,o,{...i.node.attrs,[g]:!1})))}}}),state:{init:()=>new fn("",null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(e,t)=>yn(e,t)}}});class wn{ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName}}function vn(){const e=new n.Plugin({key:en,state:{init(e,t){return this.spec.props.nodeViews[a.tableNodeTypes(t.schema).row.name]=()=>new wn,new kn(-1,null)},apply:(e,t)=>t.apply(e)},props:{attributes(e){if(nn(en,e))return null;return en.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null},handleDOMEvents:{mousemove:(e,t)=>(tn(en,e.state)||function(e,t,n){const r=en.getState(e.state);if(!r.dragging){let o=on(t.target),s=-1;if(o){const r=sn(o),{top:i,bottom:a}=o.getBoundingClientRect();Math.abs(t.clientY-i)<=n&&r.rowIndex>0?(r.rowIndex-=o.rowSpan,s=an(e,t,r)):a-t.clientY>0&&a-t.clientY<=n&&(s=an(e,t,r))}s!==r.activeHandle&&Mn(e,s)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=en.getState(e.state);t.activeHandle>-1&&!t.dragging&&Mn(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=en.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const r=e.state.doc,o=r.resolve(n.activeHandle),s=o.parent,i=o.node(-1),a=$(s.attrs.style).height,l=$(i.attrs.style).height;let c=a?parseFloat(a):0;if(!a){c=e.nodeDOM(n.activeHandle).offsetHeight}function d(t){t.view.removeEventListener("mouseup",d),t.view.removeEventListener("mousemove",u);const n=en.getState(e.state);if(n.dragging){const t=e.state.tr.setMeta(en,{setDragging:null});!function(e,t,n){const r=e.state.doc,o=r.resolve(n),s=o.parent,i=o.posAtIndex(0)-1,a=e.nodeDOM(i),l=a.ownerDocument&&a.ownerDocument.defaultView||window;a.style.height=l.getComputedStyle(a).height,t.setNodeMarkup(i,null,M(s.attrs,"height",a.style.height));const c=a&&a.closest("table"),d=c&&c.style.height;if(d){const e=r.resolve(i),n=e.start(e.depth)-1;t.setNodeMarkup(n,null,M(e.parent.attrs,"height",d))}}(e,t,n.activeHandle),e.dispatch(t)}}function u(t){if(!t.which)return d(t);const n=en.getState(e.state),r=function(e,t){const n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),o=t.clientY-n.dragging.startY;!function(e,t,n,r,o){const s=e.nodeDOM(t),i=s&&s.parentNode;if(i){i.style.height=n+"px";const e=i.ownerDocument&&i.ownerDocument.defaultView||window;i.style.height=e.getComputedStyle(i).height;const t=i.closest("table"),s=parseFloat(o)+r+"px",a=t&&t.style.height;a&&a!==s&&(t.style.height=parseFloat(o)+r+"px",t.style.height=e.getComputedStyle(t).height)}}(e,n.activeHandle,r,o,l)}return e.dispatch(e.state.tr.setMeta(en,{setDragging:{startY:t.clientY,startHeight:{rowHeight:c,tableHeight:l}}})),t.view.addEventListener("mouseup",d),t.view.addEventListener("mousemove",u),t.preventDefault(),!0}(e,t)},decorations(e){if(tn(en,e))return d.DecorationSet.empty;const t=en.getState(e);return t.activeHandle>-1?function(e,t){const n=[];if("number"!=typeof t)return d.DecorationSet.empty;const r=e.doc.resolve(t),o=r.node(-1),s=a.TableMap.get(o),i=r.start(-1),l=[],c=t-i;let u=-1;for(let e=0;e<s.height;e++)l.push(s.map.slice(e*s.width,e*s.width+s.width)),-1!==l[e].indexOf(c)&&(u=e);const p=[];return l[u].forEach(((e,t)=>{l[u+1]&&e===l[u+1][t]||p.push(e)})),p.forEach((e=>{const t=o.nodeAt(e),r=i+e+(t?t.nodeSize:0)-1,s=document.createElement("div");s.className="row-resize-handle",n.push(d.Decoration.widget(r,s))})),d.DecorationSet.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}});return e}class kn{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t,n=e.getMeta(en);if(n&&null!=n.setHandle)return new kn(n.setHandle,null);if(n&&void 0!==n.setDragging)return new kn(this.activeHandle,n.setDragging);if(this.activeHandle>-1){let n=e.mapping.map(this.activeHandle,-1);"row"===(r=e.doc.resolve(n)).parent.type.spec.tableRole&&r.nodeAfter||(n=null),t=new kn(n,this.dragging)}var r;return t||this}}function Mn(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(en,{setHandle:t}),e.dispatch(n)}const xn=(e,t,n,r,o)=>{const s=o.resolve(e),i=o.resolve(t),a=r.type.name;let l,c;return!s.nodeBefore&&(l=s.node(s.depth),c=s.node(s.depth-1),l&&c&&c.firstChild===l&&c.type.name===a)?n+r.content.size<=t:!i.nodeAfter&&(l=i.node(i.depth),c=i.node(i.depth-1),l&&c&&c.lastChild===l&&c.type.name===a)?e<=n:e<=n&&n+r.content.size<=t},Sn={listItem:"list_item",resetValues:{"font-size":"","font-family":"",color:""}};const On=/^table$/,Cn=/^table_row$/,An=/^table_cell|table_header$/,Tn=(e,t)=>{const n=e.$head;for(let e=n.depth;e>0;e--){const r=n.node(e);if(t.test(r.type.name))return{pos:n.before(e),node:r}}return null},En=(e,t)=>{if(!e)return-1;const n=a.TableMap.get(e.node),r=Tn(t,An),o=n.map.indexOf(r.pos-e.pos-1);let s=-1;return-1!==o&&(s=o%n.width),s},Nn=(e,t,n)=>{const r=En(t,e.selection),o=ot(t.node.attrs[m]);o.insertBefore(o.ownerDocument.createElement("col"),o.children[r+n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[m]:o.outerHTML})};Object.defineProperty(e,"CellSelection",{enumerable:!0,get:function(){return a.CellSelection}}),Object.defineProperty(e,"TableMap",{enumerable:!0,get:function(){return a.TableMap}}),Object.defineProperty(e,"addColSpan",{enumerable:!0,get:function(){return a.addColSpan}}),Object.defineProperty(e,"addColumn",{enumerable:!0,get:function(){return a.addColumn}}),Object.defineProperty(e,"addRow",{enumerable:!0,get:function(){return a.addRow}}),Object.defineProperty(e,"cellAround",{enumerable:!0,get:function(){return a.cellAround}}),Object.defineProperty(e,"colCount",{enumerable:!0,get:function(){return a.colCount}}),Object.defineProperty(e,"columnIsHeader",{enumerable:!0,get:function(){return a.columnIsHeader}}),Object.defineProperty(e,"columnResizing",{enumerable:!0,get:function(){return a.columnResizing}}),Object.defineProperty(e,"columnResizingPluginKey",{enumerable:!0,get:function(){return a.columnResizingPluginKey}}),Object.defineProperty(e,"deleteRow",{enumerable:!0,get:function(){return a.deleteRow}}),Object.defineProperty(e,"deleteTable",{enumerable:!0,get:function(){return a.deleteTable}}),Object.defineProperty(e,"findCell",{enumerable:!0,get:function(){return a.findCell}}),Object.defineProperty(e,"fixTables",{enumerable:!0,get:function(){return a.fixTables}}),Object.defineProperty(e,"fixTablesKey",{enumerable:!0,get:function(){return a.fixTablesKey}}),Object.defineProperty(e,"goToNextCell",{enumerable:!0,get:function(){return a.goToNextCell}}),Object.defineProperty(e,"inSameTable",{enumerable:!0,get:function(){return a.inSameTable}}),Object.defineProperty(e,"isInTable",{enumerable:!0,get:function(){return a.isInTable}}),Object.defineProperty(e,"mergeCells",{enumerable:!0,get:function(){return a.mergeCells}}),Object.defineProperty(e,"moveCellForward",{enumerable:!0,get:function(){return a.moveCellForward}}),Object.defineProperty(e,"nextCell",{enumerable:!0,get:function(){return a.nextCell}}),Object.defineProperty(e,"pmAddColumnAfter",{enumerable:!0,get:function(){return a.addColumnAfter}}),Object.defineProperty(e,"pmAddColumnBefore",{enumerable:!0,get:function(){return a.addColumnBefore}}),Object.defineProperty(e,"pmAddRowAfter",{enumerable:!0,get:function(){return a.addRowAfter}}),Object.defineProperty(e,"pmAddRowBefore",{enumerable:!0,get:function(){return a.addRowBefore}}),Object.defineProperty(e,"pmDeleteColumn",{enumerable:!0,get:function(){return a.deleteColumn}}),Object.defineProperty(e,"removeColSpan",{enumerable:!0,get:function(){return a.removeColSpan}}),Object.defineProperty(e,"rowIsHeader",{enumerable:!0,get:function(){return a.rowIsHeader}}),Object.defineProperty(e,"selectedRect",{enumerable:!0,get:function(){return a.selectedRect}}),Object.defineProperty(e,"selectionCell",{enumerable:!0,get:function(){return a.selectionCell}}),Object.defineProperty(e,"setCellAttr",{enumerable:!0,get:function(){return a.setCellAttr}}),Object.defineProperty(e,"splitCell",{enumerable:!0,get:function(){return a.splitCell}}),Object.defineProperty(e,"splitCellWithType",{enumerable:!0,get:function(){return a.splitCellWithType}}),Object.defineProperty(e,"tableEditing",{enumerable:!0,get:function(){return a.tableEditing}}),Object.defineProperty(e,"tableEditingKey",{enumerable:!0,get:function(){return a.tableEditingKey}}),Object.defineProperty(e,"tableNodeTypes",{enumerable:!0,get:function(){return a.tableNodeTypes}}),Object.defineProperty(e,"tableNodes",{enumerable:!0,get:function(){return a.tableNodes}}),Object.defineProperty(e,"toggleHeader",{enumerable:!0,get:function(){return a.toggleHeader}}),Object.defineProperty(e,"toggleHeaderCell",{enumerable:!0,get:function(){return a.toggleHeaderCell}}),Object.defineProperty(e,"toggleHeaderColumn",{enumerable:!0,get:function(){return a.toggleHeaderColumn}}),Object.defineProperty(e,"toggleHeaderRow",{enumerable:!0,get:function(){return a.toggleHeaderRow}}),Object.defineProperty(e,"updateColumnsOnResize",{enumerable:!0,get:function(){return a.updateColumnsOnResize}}),e.activeNode=e=>({tag:ge(e)||""}),e.addColumnAfter=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,On);return n.node.attrs[m]?(Nn(e,n,1),t(e)):t(e)});return a.addColumnAfter(e,n)},e.addColumnBefore=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,On);return n.node.attrs[m]?(Nn(e,n,-1),t(e)):t(e)});return a.addColumnBefore(e,n)},e.addRowAfter=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,Cn);if(n&&n.node.attrs[f]){const t=n.pos+n.node.nodeSize;e.setNodeMarkup(t,void 0,{[f]:n.node.attrs[f]})}return t(e)});return a.addRowAfter(e,n)},e.addRowBefore=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,Cn),r=Tn(e.selection,On);if(n&&r&&n.node.attrs[f]){let t=0;for(let e=0;e<r.node.nodeSize;e++)if(r.node.child(e).eq(n.node)){t=e;break}const o=r.node.child(t-1),s=n.pos-o.nodeSize;e.setNodeMarkup(s,void 0,{[f]:n.node.attrs[f]})}return t(e)});return a.addRowBefore(e,n)},e.alignBlocks=(e,t)=>(n,r)=>{const o=ue(n),s=n.tr;s.setMeta("commandName",t),o.forEach((t=>{if(t.type.isTextblock){const n=e.find((e=>e.node===t.type.name));if(n){const e=fe(t,n.style);de(s,t,t.type,e)}}}));const i=s.docChanged;return i&&r(s.scrollIntoView()),i},e.alignCenterRules=je,e.alignJustifyRules=Re,e.alignLeftRules=Le,e.alignRemoveRules=Be,e.alignRightRules=ze,e.applyInlineStyle=(e,t)=>(n,r)=>{const o=n.schema.marks.style,s={style:e.style,value:/^.+$/,newValue:e.value},i=n.tr;t&&i.setMeta("commandName",t),i.setMeta("args",e);const{empty:a,$cursor:l,ranges:c}=n.selection;if(a&&!l||!o||!J(n.doc,c,o))return!1;if(l){const e=n.storedMarks||l.marks(),t=o.isInSet(e)?e.find((e=>"style"===e.type.name)):null,a={style:null};if(t&&t.attrs.style){const e=v(t.attrs.style,s);e.changed&&e.style&&(a.style=e.style)}else s.newValue&&(a.style=`${[s.style]}: ${s.newValue};`);const c=t?{...t.attrs,...a}:a;return Object.keys(c).some((e=>null!==c[e]))?r(i.addStoredMark(o.create(c))):r(i.removeStoredMark(o)),!0}return ae(o,s)(n,r,i)},e.applyLink=({mark:e,attrs:t},r="link")=>(o,s)=>{const i=o.schema.marks,a=o.tr;r&&(a.setMeta("commandName",r),a.setMeta("args",t));let l=!1;const c=()=>l=!0;if(((e,t)=>{const n=oe(e,t);return 1===n.length&&n[0]?n[0]:null})(o,i[e]))((e,t)=>(n,r)=>{const{$cursor:o,from:s,to:i}=n.selection,a=n.schema.marks[e.mark];if(o){const n=o.parent,s=o.index(),i=n.child(s).marks.find((e=>e.type===a)),l=n.childCount;let c,d,u=o.pos-o.textOffset,p=n.child(s).nodeSize;for(c=s-1;c>=0&&i.isInSet(n.child(c).marks);)d=n.child(c).nodeSize,p+=d,u-=d,c-=1;for(c=s+1;c<l&&i.isInSet(n.child(c).marks);)p+=n.child(c).nodeSize,c+=1;t.removeMark(u,u+p,a),t.addMark(u,u+p,a.create(e.attrs)),r(t)}else t.doc.nodesBetween(s,i,((n,o)=>{n.isInline&&a.isInSet(n.marks)&&(t.removeMark(o,o+n.nodeSize,a),t.addMark(o,o+n.nodeSize,a.create(e.attrs)),r(t))}))})({mark:e,attrs:t},a)(o,c);else{let r=o;ne(o,{mark:e})&&(ce({mark:e,attrs:t},a)(o,c),r=n.EditorState.create({doc:a.doc,selection:a.selection})),l?Q(i[e],t,a)(r,c):le({mark:e},a,t)(r,c)}return l&&s(a),l},e.blockNodes=ue,e.blockquote=(e,t)=>i.wrapIn(e.schema.nodes.blockquote)(e,t),e.bold=at,e.buildKeymap=(e,t)=>{const n={},r=t&&t.applyToWord||!1;if(n["Mod-z"]=l.undo,n["Shift-Mod-z"]=l.redo,n.Backspace=i.chainCommands(c.undoInputRule,i.deleteSelection,i.joinBackward,i.selectNodeBackward),n.Enter=i.chainCommands(i.newlineInCode,i.createParagraphNear,i.liftEmptyBlock,i.splitBlockKeepMarks),dt||(n["Mod-y"]=l.redo),e.marks.strong&&(n["Mod-b"]=D(le,{...at,applyToWord:r})),e.marks.em&&(n["Mod-i"]=D(le,{...lt,applyToWord:r})),e.marks.u&&(n["Mod-u"]=D(le,{...ct,applyToWord:r})),e.nodes.hard_break){const t=e.nodes.hard_break,r=i.chainCommands(i.exitCode,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n["Shift-Enter"]=r}return n},e.buildListKeymap=e=>{const t={};var n;return e.nodes.list_item&&(t.Enter=(n=e.nodes.list_item,(e,t)=>s.splitListItem(n)(e,(n=>{const r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)})))),t},e.canBeIndented=Ae,e.canIndentAsListItem=Oe,e.canInsert=(e,t)=>{const n=e.selection.$from;for(let e=n.depth;e>=0;e--){const r=n.index(e);if(n.node(e).canReplaceWith(r,r,t))return!0}return!1},e.canOutdentAsListItem=Ce,e.caretColor=function(){return new n.Plugin({key:Gt,props:{decorations:e=>{const{doc:t,selection:n,storedMarks:r}=e;if(!n.empty||!r)return d.DecorationSet.empty;const o=re((r||[]).find((e=>"style"===e.type.name)),{name:"color",value:/^.+$/});if(!o)return d.DecorationSet.empty;const s=n.$anchor.parent,i=[];return t.descendants(((e,t)=>{e.eq(s)&&i.push(d.Decoration.node(t,t+e.nodeSize,{style:"caret-color: "+o}))})),d.DecorationSet.create(t,i)}}})},e.caretColorKey=Gt,e.changeTextBlock=de,e.cleanFormatting=(e={blocksInSelection:!0})=>(t,n)=>{const r=t.tr,{blocksInSelection:o,blockNodeType:s,exceptMarks:i}=e,a=(i||[t.schema.marks.link]).filter(Boolean);te(r,{except:a}),pe(r,{blocksInSelection:o,blockNodeType:s});const l=r.docChanged;return l&&n&&n(r),l},e.cleanMarks=te,e.cleanTextBlockFormatting=pe,e.convertMsLists=wt,e.createTable=(e,t,n)=>{const{table:r,table_row:o,table_cell:s}=e,i=[];let a;for(let e=0;e<t+1;e++){a=[];for(let e=0;e<n+1;e++)a.push(s.createAndFill());i.push(o.createAndFill(void 0,a))}return r.createAndFill(void 0,i)},e.cspFix=()=>new n.Plugin({key:new n.PluginKey("csp-fix"),props:{nodeViews:{paragraph:(e,t)=>new jt(e,t,"p"),div:(e,t)=>new jt(e,t,"div"),table_wrapper:(e,t)=>new jt(e,t,"div"),table_caption_external:(e,t)=>new jt(e,t,"div"),table:(e,t)=>new jt(e,t,"table"),table_row:(e,t)=>new jt(e,t,"tr"),table_cell:(e,t)=>new jt(e,t,"td"),table_header:(e,t)=>new jt(e,t,"th"),image:(e,t)=>new jt(e,t,"img",!0)},markViews:{style:(e,t)=>new Rt(e,t)}}}),e.deleteColumn=(e,t)=>{const n=Tn(e.selection,On),r=n&&n.node.attrs[m],o=En(n,e.selection),s=t&&(e=>{if(!r)return t(e);const s=e.doc.nodeAt(n.pos);return((e,t,n)=>{const r=ot(t.node.attrs[m]);r.removeChild(r.children[n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[m]:r.outerHTML})})(e,{node:s,pos:n.pos},o),t(e)});return a.deleteColumn(e,s)},e.domToPmDoc=U,e.expandSelection=N,e.expandToWordWrap=D,e.find=(e,t)=>{const{backward:n,matchCyclic:r,...o}=t,s=n?()=>!1:e=>e.length>0,{doc:i,selection:a}=e;let l=[];return n?(l=Nt(i,o,0,a.from,s),!l.length&&r&&(l=Nt(i,o,a.from,i.content.size,s))):(l=Nt(i,o,a.to,i.content.size,s),!l.length&&r&&(l=Nt(i,o,0,a.to,s))),l.length?l[l.length-1]:null},e.findAll=Dt,e.findAt=Nt,e.formatBlockElements=(e,t)=>(n,r)=>{const o=ue(n),s=n.schema.nodes,i=n.tr;i.setMeta("commandName",t),i.setMeta("args",{value:e}),o.forEach((t=>{if(t.type.isTextblock)if("p"===e)de(i,t,s.paragraph,t.attrs);else if(/^h[1-6]$/i.test(e)){const n=parseInt(e.substr(1),10);de(i,t,s.heading,{...t.attrs,level:n})}else"blockquote"===e&&de(i,t,s.blockquote,t.attrs)}));const a=i.docChanged;return a&&r(i.scrollIntoView()),a},e.fragmentToHtml=X,e.getActiveMarks=(e,t)=>{const n=oe(e,t),r=n.filter((e=>Boolean(e)));return{hasNodesWithoutMarks:n.length!==r.length,marks:r}},e.getBlockFormats=he,e.getHtml=e=>{const t=G(e.doc);return X(t)},e.getInlineStyles=(e,t)=>{const n=e.schema.marks.style;return(n?oe(e,n):[]).map((e=>re(e,t))).filter((e=>null!==e))},e.getMark=(e,t)=>{const n=oe(e,t),r=n.filter((e=>Boolean(e)));return n.length===r.length?n[0]:void 0},e.getNodeFromSelection=e=>{if(e.selection instanceof n.NodeSelection)return e.selection.node},e.getSelectionText=T,e.hasMark=ne,e.hasNode=me,e.hasSameMarkup=(e,n,r,o)=>{const s=t.Fragment.from(Z(e,r,o)),i=t.Fragment.from(Z(n,r,o));return s.eq(i)},e.htmlToFragment=Y,e.imageResizeKey=qt,e.imageResizing=(e={node:"image",lockRatio:!0})=>new n.Plugin({key:qt,view:t=>({resize(){qt.getState(t.state).rect&&t.dispatch(t.state.tr.setMeta("resize",!0))},get window(){return t.dom.ownerDocument&&t.dom.ownerDocument.defaultView},attachResize(){const e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize(){const e=this.window;e&&e.removeEventListener("resize",this.resize)},update(t,r){const o=t.state,s=o.selection,i=o.schema.nodes[e.node],a=qt.getState(o),l=a.rect;if(s instanceof n.NodeSelection&&i===s.node.type){const e=t.nodeDOM(s.from),n={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight};if(!r.selection.eq(s)||l&&(l.width!==n.width||l.height!==n.height||l.top!==n.top||l.left!==n.left)){const e=o.tr;e.setMeta(qt,{rect:n,nodePosition:s.from}),t.dispatch(e),this.attachResize()}}else l&&(a.rect=null,a.nodePosition=-1)},destroy(){this.removeResize()}}),state:{init:()=>new Yt("",null,null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(t,n)=>Xt(t,n,e)},decorations(t){const r=t.selection,o=t.schema.nodes[e.node],s=qt.getState(t).rect;if(s&&r instanceof n.NodeSelection&&o===r.node.type){const e=document.createElement("div");e.className="k-editor-resize-handles-wrapper",e.style.width=s.width+"px",e.style.height=s.height+"px",e.style.top=s.top+"px",e.style.left=s.left+"px";for(let t=0;t<Ft.length;t++){const n=document.createElement("div");n.className=y+" "+Ft[t],n.setAttribute(w,Ft[t]),e.appendChild(n)}return d.DecorationSet.create(t.doc,[d.Decoration.widget(t.selection.from+1,e)])}return d.DecorationSet.empty}}}),e.indent=(e,t)=>{const n=e.schema.nodes[ve.listsTypes.listItem],r=Ae(e,ve);Oe(e,n)?s.sinkListItem(n)(e,t):r&&xe(ve.nodes)(e,t)},e.indentBlocks=xe,e.indentHtml=e=>e.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/gi,"</$1>\n").replace(/<(ul|ol)([^>]*)><li/gi,"<$1$2>\n<li").replace(/<br \/>/gi,"<br />\n").replace(/\n$/,""),e.indentRules=ve,e.insertImage=e=>(t,n)=>{const{image:r}=t.schema.nodes,o=r.createAndFill(e);A(o)(t,(t=>n(t.setMeta("commandName","insertImage").setMeta("args",e))))},e.insertNode=A,e.insertText=e=>(t,n)=>{n(t.tr.insertText(e.text,e.from,e.to))},e.isAligned=(e,t)=>{const n=ue(e);let r=!1;return n.forEach((e=>{if(!r&&e.type.isTextblock&&e.attrs.style){const n=t.find((t=>t.node===e.type.name));n&&(r=n.style.every((t=>!!t.value&&new RegExp(`${t.name}:\\s?${t.value}`,"i").test(e.attrs.style))))}})),r},e.isIndented=Se,e.italic=lt,e.liftBlockquote=Me,e.link={mark:"link"},e.listMarkersStyles=function(e=Sn){return new n.Plugin({key:new n.PluginKey("list-markers-styles"),appendTransaction:(t,n,r)=>{const s=t.slice().pop(),i=s.getMeta("commandName");let a;return"FontSize"===i||"FontName"===i||"ForeColor"===i?a=((e,t,n)=>{const{tr:r,doc:o,selection:{from:s,to:i}}=t,a=e.getMeta("args");return o.nodesBetween(s,i,((e,t)=>{e.type.name===n.listItem&&xn(s,i,t,e,o)&&r.setNodeMarkup(t,null,{...e.attrs,style:P(e.attrs.style,a.style,a.value)})})),r.docChanged?r:void 0})(s,r,e):"CleanFormatting"===i&&(a=((e,t,n)=>{const r=Object.keys(n.resetValues),{tr:s,doc:i,selection:{from:a,to:l}}=t;return i.nodesBetween(a,l,((e,t)=>{if(e.type.name===n.listItem&&xn(a,l,t,e,i)){let n=e.attrs;const o=$(e.attrs.style);r.forEach((e=>{o[e]&&(n={...n,style:P(n.style,e,"")})})),n!==e.attrs&&s.setNodeMarkup(t,null,n)}})),e.steps.forEach((e=>{if(e instanceof o.RemoveMarkStep){const t=e.mark;if("style"===t.type.name&&t.attrs.style){const[r]=t.attrs.style.split(/\s*:\s*/),o=O(s.doc.resolve(e.from),(e=>e.type.name===n.listItem));if(o&&$(o.node.attrs.style)[r]&&n.resetValues[r]){const o=t.type.create({style:`${r}: ${n.resetValues[r]};`});s.addMark(e.from,e.to,o)}}}})),s.docChanged?s:void 0})(s,r,e)),a&&a.setMeta("addToHistory",!0),a}})},e.listStyle=Pe,e.marks=Qe,e.nodes=it,e.outdent=(e,t)=>{const n=e.schema.nodes,r=n[ke.listsTypes.listItem],o=Ae(e,ke);me(e,n.blockquote)?Me(e,t):Ce(e,ke)?s.liftListItem(r)(e,t):o&&xe(ke.nodes)(e,t)},e.outdentRules=ke,e.parentBlockFormat=ge,e.parseContent=Z,e.pasteCleanup=(e,t)=>{let n=e;if(t.convertMsLists&&(n=wt(n)),t.stripTags&&(n=vt(n,t.stripTags)),t.attributes){const e=Y(n);Array.from(e.querySelectorAll("*")).forEach((e=>((e,t)=>{if(e.nodeType===Node.ELEMENT_NODE){for(let n=e.attributes.length-1;n>=0;n--){const r=e.attributes[n];t[r.name]?t[r.name](r):t["*"]&&t["*"](r)}"SPAN"===e.nodeName&&0===e.attributes.length&&(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}})(e)}})(e,t.attributes))),n=X(e)}return n},e.placeholder=function(e){const t={class:"k-placeholder","data-placeholder":e};return new n.Plugin({key:new n.PluginKey("placeholder"),props:{decorations:e=>{const{doc:n}=e,r=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&r.inlineContent&&0===r.childCount))return d.DecorationSet.empty;const o=[];return n.descendants(((e,n)=>{o.push(d.Decoration.node(n,n+e.nodeSize,t))})),d.DecorationSet.create(n,o)}}})},e.pmDocToFragment=G,e.removeAllMarks=({except:e=[]}={})=>(t,n)=>{const r=t.tr;var o;te(r,{except:(o=e,o instanceof Array?o:[o])}),r.docChanged&&n(r)},e.removeAttribute=kt,e.removeComments=e=>e.replace(/<!--[\s\S]+?-->/g,""),e.removeLink=ce,e.removeTag=vt,e.replace=(e,t,r)=>{const{from:o,to:s}=e;return r.insertText(t,o,s).setSelection(n.TextSelection.create(r.doc,o,o+t.length)),r},e.replaceAll=(e,t,n)=>{const r=Dt(e.doc,n);if(0===r.length)return null;const o=e.tr;for(let e=r.length-1;e>=0;e--)o.insertText(t,r[e].from,r[e].to);return o},e.replaceImageSourcesFromRtf=(e,t)=>{const n=e.match(xt);if(!n||-1===t.types.indexOf(Et))return e;const r=t.getData(Et),o=[],s=r.match(Ot);if(!r||!s)return e;for(const e of s){const t=Tt.exec(e);if(t){const n=e.replace(St,"").replace(Ct,"");o.push(`data:image/${t[1]};base64,${Mt(n)}`)}}return n.length!==o.length?e:e.replace(xt,(e=>{const t=o.shift()||"";return e.replace(At,t)}))},e.sanitize=e=>e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/,"$1")).replace(/<\/?[ovw]:[^>]*?>/gi,"")).replace(/<\\?\??xml[^>]*>/gi,"")).replace(/<(?:link|meta) [^>]+?>/gi,"")).replace(/<style[^>]*?>\s*<\/style>/gi,"")).replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,""),e.sanitizeClassAttr=e=>{/^Mso/.test(e.value)&&kt(e)},e.sanitizeStyleAttr=e=>{const t=$(e.value),n=e.ownerElement.style;let r="";Object.keys(t).forEach((e=>{void 0!==n[e]&&(r+=`${e}: ${t[e]}; `)})),r=r.trim(),r?e.value=r:kt(e)},e.selectedLineTextOnly=e=>{let t="",n=!1;const{selection:r,doc:o}=e,{$from:s,$to:i,from:a,to:l}=r;return s.sameParent(i)&&(o.nodesBetween(a,l,(e=>{n=n||e.isLeaf&&!e.isText})),n||(t=T(e))),t},e.selectionMarks=oe,e.setHtml=(e,t="setHTML",r={preserveWhitespace:"full"})=>(o,s)=>s(o.tr.setSelection(new n.AllSelection(o.doc)).replaceSelectionWith(Z(e,o.schema,r)).setMeta("commandName",t)),e.spacesFix=()=>new n.Plugin({key:new n.PluginKey("spaces-fix"),props:{decorations:e=>{const t=[],n=e.doc;let r,o,s,i;return n.nodesBetween(0,n.content.size,((e,n,a)=>{if(e.type.isText&&(e=>Lt.test(e&&e.attrs&&e.attrs.style||""))(a))for(o=It.exec(e.text||"");null!==o;){if(r=n+o.index,s=o[0].length,o.index+s<o.input.length)for(i=0;i<=s-1;i+=2)t.push(d.Decoration.inline(r+i,r+i+1,{style:"white-space: normal"}));o=It.exec(e.text||"")}})),d.DecorationSet.create(n,t)}}}),e.strikethrough={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},e.subscript={mark:"sub"},e.superscript={mark:"sup"},e.tableColumnResizeKey=Qt,e.tableResizeKey=Jt,e.tableResizing=()=>[bn(),ln(),vn()],e.tableRowResizeKey=en,e.textHighlight=function(e=Bt){return new n.Plugin({key:e,state:{init:()=>null,apply(e){return e.getMeta(this.spec.key)}},props:{decorations(e){const t=(this.spec.key.getState(e)||[]).map((e=>d.Decoration.inline(e.from,e.to,e.attrs)));return d.DecorationSet.create(e.doc,t)}}})},e.textHighlightKey=Bt,e.toggleInlineFormat=le,e.toggleList=He,e.toggleOrderedList=function(e,t,n){return He(e,t,n,{listType:be.listType,...be.types})},e.toggleUnorderedList=function(e,t,n){return He(e,t,n,{listType:we.listType,...we.types})},e.trimWhitespace=(e,t=R)=>{const n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")},e.underline=ct,Object.keys(t).forEach((function(n){"default"===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.keys(o).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})),Object.keys(s).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})),Object.keys(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return i[t]}})})),Object.keys(l).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return l[t]}})})),Object.keys(c).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})})),Object.keys(d).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return d[t]}})})),Object.keys(u).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return u[t]}})})),Object.keys(p).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return p[t]}})})),Object.keys(h).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return h[t]}})}))}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("prosemirror-model"),require("prosemirror-state"),require("@progress/kendo-common"),require("prosemirror-transform"),require("prosemirror-schema-list"),require("prosemirror-commands"),require("prosemirror-tables"),require("prosemirror-history"),require("prosemirror-inputrules"),require("prosemirror-view"),require("prosemirror-dropcursor"),require("prosemirror-gapcursor"),require("prosemirror-keymap")):"function"==typeof define&&define.amd?define(["exports","prosemirror-model","prosemirror-state","@progress/kendo-common","prosemirror-transform","prosemirror-schema-list","prosemirror-commands","prosemirror-tables","prosemirror-history","prosemirror-inputrules","prosemirror-view","prosemirror-dropcursor","prosemirror-gapcursor","prosemirror-keymap"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoEditorCommon={},e.prosemirrorModel,e.prosemirrorState,e.KendoCommon,e.prosemirrorTransform,e.prosemirrorSchemaList,e.prosemirrorCommands,e.prosemirrorTables,e.prosemirrorHistory,e.prosemirrorInputrules,e.prosemirrorView,e.prosemirrorDropcursor,e.prosemirrorGapcursor,e.prosemirrorKeymap)}(this,(function(e,t,n,r,o,s,i,a,l,c,d,u,p,h){"use strict";const f="k-parent-node",m="k-colgroup-data",g="k-resizable-node",y="k-editor-resize-handle",b="data-dir-table-resize",w="data-dir-image-resize",v=(e,t)=>{const n=t.style,r=t.value,o=t.newValue;if(!e)return{changed:!1,style:null};const s=$(e),i=Object.keys(s),a=[];for(let e=0;e<i.length;e++){const t=i[e];t.toLowerCase()===n&&r.test(s[t])||a.push(`${t}: ${s[t]}`)}return o&&a.push(`${n}: ${o}`),{style:a.join("; ")+(a.length?";":""),changed:Boolean(o)||a.length!==i.length}},k=/^.+$/;function M(e,t,n){let r;if(new RegExp("[^-]?"+t+":").test(e.style||"")){const{style:o}=v(e.style||"",{style:t,value:k,newValue:n});r={...e,style:o}}else r=e.style?{...e,style:e.style.replace(/;$/,"")+"; "+t+": "+n+";"}:{...e,style:t+": "+n+";"};return r}const x=e=>e instanceof t.Node?e.type.name:e.name,S=(e,t=1)=>n=>((e,t=1)=>n=>{const{$from:r}=n;for(let n=r.depth;n>0;n--){const o=r.node(n);if(e(o)&&0==(t-=1))return{depth:n,node:o}}})((t=>x(t)===x(e)),t)(n);function O(e,t){for(let n=e.depth;n>0;n--){const r=e.node(n);if(t(r))return{node:r,depth:n}}return null}const C=e=>{const t={};for(const n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t},A=(e,t)=>(r,o)=>{const{selection:s,tr:i}=r;s instanceof n.NodeSelection&&s.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(i.setNodeMarkup(s.from,null,{...C(s.node.attrs),...C(e.attrs)}),i.setSelection(n.NodeSelection.create(i.doc,s.from))):i.replaceSelectionWith(e),t&&i.scrollIntoView(),o(i)},T=e=>{const t=e.selection;if(t instanceof n.TextSelection||t instanceof n.AllSelection){const e=t.content().content;return e.textBetween(0,e.size)}return""},E={before:/[^ !,?.\[\]{}()]+$/i,after:/^[^ !,?.\[\]{}()]+/i},N=(e,t,r)=>{if(!r.applyToWord||!e.selection.empty)return{state:e,dispatch:t};const o=!0===r.applyToWord?E:r.applyToWord;let s=null;const i=e.tr,a=e.selection,l=a.$head.nodeBefore,c=a.$head.nodeAfter;if(l&&"text"===l.type.name&&l.text&&c&&"text"===c.type.name&&c.text){const r=[];a.$head.parent.descendants(((e,t)=>(r.push({node:e,pos:t}),!1)));let l=a.$head.parentOffset;const c=r.findIndex((({node:e,pos:t})=>t<=l&&t+e.nodeSize>=l));let d=r[c].node.text,u=!1;for(let e=c-1;e>=0;e--){const t=r[e];!u&&t&&"text"===t.node.type.name?d=t.node.text+d:(u=!0,l-=t.node.nodeSize)}for(let e=c+1;e<r.length;e++){const t=r[e];if(!t||"text"!==t.node.type.name)break;d+=t.node.text}const p=d.substring(0,l),h=d.substring(l),f=o.before.exec(p),m=o.after.exec(h);if(f&&m){const r=f[0].length,o=m[0].length,l=s=a.from;i.setSelection(n.TextSelection.create(e.doc,l-r,l+o));return{state:{tr:i,selection:i.selection,doc:i.doc,storedMarks:null,schema:i.doc.type.schema},dispatch:e=>{e.setSelection(n.TextSelection.create(e.doc,s)),t(e)}}}}return{state:e,dispatch:t}},D=(e,t)=>(n,r)=>{const{state:o,dispatch:s}=N(n,r,t);return e(t)(o,s)},$=e=>r.parseInlineStyles(e),P=(e,t,n)=>{const r=$(e);r[t]=n;const o=Object.keys(r).map((e=>r[e]?`${e}: ${r[e]}`:null)).filter(Boolean).join("; ");return o?o+";":null},H=(e,t)=>{const n=$(t);for(const t in n)t&&void 0!==e.style[t]&&(e.style[t]=n[t])},I=(e,t,n)=>{const r=e.getAttribute(t);void 0!==n&&n!==r?"style"===t?(e.removeAttribute(t),H(e,n)):e.setAttribute(t,n):void 0===n&&e.removeAttribute(t)};class L{static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,o=t[0],s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));const i=n?e.createElementNS(n,o):e.createElement(o);let a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(const e in a)null!=a[e]&&(s=e.indexOf(" "),s>0?i.setAttributeNS(e.slice(0,s),e.slice(s+1),a[e]):I(i,e,a[e]))}for(let o=l;o<t.length;o++){const s=t[o];if(0===s){if(o<t.length-1||o>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:i,contentDOM:i}}{const{dom:t,contentDOM:o}=L.renderSpec(e,s,n);if(i.appendChild(t),o){if(r)throw new RangeError("Multiple content holes");r=o}}}return{dom:i,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new L(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){const t=z(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return z(e.marks)}constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=j(t).createDocumentFragment());let r=n,o=[];return e.forEach((e=>{if(o.length||e.marks.length){let n=0,s=0;for(;n<o.length&&s<e.marks.length;){const t=e.marks[s];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,s++}else s++}for(;n<o.length;)r=o.pop()[1];for(;s<e.marks.length;){const n=e.marks[s++],i=this.serializeMark(n,e.isInline,t);i&&(o.push([n,r]),r.appendChild(i.dom),r=i.contentDOM||i.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){const o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){const r=this.marks[e.type.name];return r&&L.renderSpec(j(n),r(e,t))}serializeNodeInner(e,t){const{dom:n,contentDOM:r}=L.renderSpec(j(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}}function z(e){const t={};for(const n in e)if(e[n]){const r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function j(e){return e.document||window.document}const R=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],B=(e,t)=>{const n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((e=>e.getAttribute(f)===t)).forEach((e=>{e.removeAttribute(f),n.appendChild(e)})),n.children.length&&e.appendChild(n)},_=(e,t)=>{const n=t.toUpperCase();e.filter((e=>e.nodeName===n)).forEach((e=>{Array.from(e.children).forEach((n=>{n.setAttribute(f,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))},F="data-style",q=" "+F+"=",W=/<[^>]+>/gm,V=/\sstyle=/gm,K=e=>e.replace(V,q),Y=e=>{const t=document.createElement("template");var n;return t.innerHTML=(e=>e.replace(W,K))(e),n=t.content,Array.from(n.querySelectorAll("["+F+"]")).forEach((e=>{const t=e.getAttribute(F);e.removeAttribute(F),H(e,t)})),t.content},X=e=>Array.from(e.childNodes).reduce(((e,t)=>e+(t.outerHTML||t.textContent||"")),""),G=e=>{const t=L.fromSchema(e.type.schema).serializeFragment(e.content);return(e=>{Array.from(e.querySelectorAll("table")).forEach((e=>{B(e,"thead"),B(e,"tbody"),B(e,"tfoot");const t=Array.from(e.children).find((e=>0===e.children.length));t&&t.remove();const n=e.parentNode instanceof HTMLDivElement?e.parentNode:null;if(n&&n.matches("div[table]")){e.style.marginLeft=n.style.marginLeft,e.style.marginRight=n.style.marginRight;const t=Array.from(n.children).find((e=>e.matches("div[caption]")));if(t&&"<img>"!==t.innerHTML){const n=e.createCaption();for(t.id&&(n.id=t.id),t.className&&(n.className=t.className),Array.from(t.style).forEach((e=>{n.style[e]=t.style[e]}));t.firstChild;)n.appendChild(t.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))})(t),t},U=(e,n,r)=>t.DOMParser.fromSchema(n).parse(e,r),Z=(e,t,n)=>{const r=Y(e);var o;return o=r,Array.from(o.querySelectorAll("table")).forEach((e=>{const t=Array.from(e.children);t.some((e=>"THEAD"===e.nodeName||"TFOOT"===e.nodeName))&&(_(t,"thead"),_(t,"tbody"),_(t,"tfoot"));const n=t.find((e=>"COLGROUP"===e.nodeName));if(n&&(e.setAttribute(m,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){const t=document.createElement("div");if(t.setAttribute("table",""),t.style.display="table",t.style.marginLeft=e.style.marginLeft,t.style.marginRight=e.style.marginRight,e.caption){const n=document.createElement("div");for(n.setAttribute("caption",""),e.caption.id&&(n.id=e.caption.id),e.caption.className&&(n.className=e.caption.className),Array.from(e.caption.style).forEach((t=>{n.style[t]=e.caption.style[t]}));e.caption.firstChild;)n.appendChild(e.caption.firstChild);e.removeChild(e.caption),t.appendChild(n)}e.parentNode.insertBefore(t,e),t.appendChild(e),/%/.test(e.style.width)&&(t.style.width=e.style.width,e.style.width="")}})),U(r,t,n)},J=(e,t,n)=>{const r=r=>{const o=t[r],s=o.$from,i=o.$to;let a=0===s.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(s.pos,i.pos,(e=>{if(a)return!1;a=e.inlineContent&&e.type.allowsMarkType(n)})),a)return{v:!0}};for(let e=0;e<t.length;e++){const t=r(e);if(t)return t.v}return!1},Q=(e,t,n)=>(r,o)=>{const{empty:s,$cursor:i,ranges:a}=r.selection;if(s&&!i||!J(r.doc,a,e))return!1;if(o)if(i)e.isInSet(r.storedMarks||i.marks())?o(n.removeStoredMark(e)):o(n.addStoredMark(e.create(t)));else{let s=!1;for(let t=0;!s&&t<a.length;t++){const{$from:n,$to:o}=a[t];s=r.doc.rangeHasMark(n.pos,o.pos,e)}for(let r=0;r<a.length;r++){const{$from:o,$to:i}=a[r];s?n.removeMark(o.pos,i.pos,e):n.addMark(o.pos,i.pos,e.create(t))}o(n.scrollIntoView())}return!0},ee=(e,n,r,s)=>{void 0===s&&(s=null);let i=[],a=0;return e.doc.nodesBetween(n,r,((e,o)=>{if(!e.isInline)return;a++;let l=null;if(s instanceof t.MarkType){const t=s.isInSet(e.marks);t&&(l=[t])}else s?s.isInSet(e.marks)&&(l=[s]):l=e.marks;if(l&&l.length){const t=Math.min(o+e.nodeSize,r);for(let e=0;e<l.length;e++){let r,s=l[e];for(let e=0;e<i.length;e++){const t=i[e];t.step===a-1&&s.eq(t.style)&&(r=t)}r?(r.to=t,r.step=a):i.push({style:s,from:Math.max(o,n),to:t,step:a})}}})),i.forEach((t=>e.step(new o.RemoveMarkStep(t.from,t.to,t.style)))),e},te=(e,{except:t})=>{const{doc:n,selection:r}=e,o=n.type.schema,{empty:s,ranges:i}=r,a=(t||[]).map((e=>e.name));if(!s){const t=Object.keys(o.marks).map((e=>o.marks[e])).filter((e=>-1===a.indexOf(e.name)));i.forEach((({$from:n,$to:r})=>{t.forEach((t=>e.removeMark(n.pos,r.pos,t)))}))}},ne=(e,t)=>{const n=e.schema.marks,r=(t.altMarks||[]).filter((e=>n[e])),o=t.altStyle,{from:s,$from:i,to:a,empty:l}=e.selection,c=n[t.mark],d=e.doc;let u,p=!1;return l?(u=e.storedMarks||i.marks(),p=c&&c.isInSet(u)||r.some((e=>n[e].isInSet(u)))):p=c&&d.rangeHasMark(s,a,c)||r.some((e=>d.rangeHasMark(s,a,n[e]))),!p&&o&&n.style?oe(e,n.style).some((e=>null!==re(e,o))):Boolean(p)},re=(e,t)=>{const n=e&&e.attrs.style||"",r=$(n),o=Object.keys(r);for(let e=0;e<o.length;e++){const n=o[e];if(n.toLowerCase()===t.name&&t.value.test(r[n]))return r[n]}return null},oe=(e,t)=>{const{from:n,$from:r,to:o,empty:s}=e.selection,i=[];return s?i.push(t.isInSet(e.storedMarks||r.marks())):e.doc.nodesBetween(n,o,(e=>{e.isInline&&i.push(t.isInSet(e.marks))})),i},se=(e,t)=>{const n=e.find((e=>"style"===e.type.name)),r=n&&n.attrs.style;return v(r,t)},ie=(e,t,n,r,s)=>{const i=s.create({style:r.style});let a=[],l=[],c=null,d=null;return e.doc.nodesBetween(t,n,((e,u,p)=>{if(!e.isInline)return;const h=e.marks;if(!i.isInSet(h)&&p.type.allowsMarkType(i.type)){const i=Math.max(u,t),p=Math.min(u+e.nodeSize,n),f=se(h,r);if(f.changed||r.newValue){const e=f.changed?{style:f.style||null}:{style:`${[r.style]}: ${r.newValue};`},t=s.isInSet(h)?h.find((e=>"style"===e.type.name)):null,n=t?{...t.attrs,...e}:e,u=s.create(n),m=u.addToSet(h);for(let e=0;e<h.length;e++)h[e].isInSet(m)||(c&&c.to===i&&c.mark.eq(h[e])?c.to=p:(c=new o.RemoveMarkStep(i,p,h[e]),a.push(c)));const g=d&&d.to===i,y=g&&u.attrs.style===d.mark.attrs.style;g&&y?d.to=p:Object.keys(n).some((e=>null!==n[e]))&&(d=new o.AddMarkStep(i,p,u),l.push(d))}}})),a.forEach((t=>e.step(t))),l.forEach((t=>e.step(t))),a.length+l.length>0},ae=(e,t)=>function(r,o,s){const{empty:i,ranges:a}=r.selection,l=r.selection instanceof n.TextSelection&&r.selection.$cursor;if(i&&!l||!J(r.doc,a,e))return!1;let c=!1;if(o){const n=s||r.tr;if(l){const s=r.storedMarks||l.marks();if(e.isInSet(s)){const r=se(s,t),i=s.find((e=>"style"===e.type.name)),a={...i?i.attrs:{},style:r.style||null};if(((e,t)=>{const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((n=>e[n]===t[n]))})(i.attrs,a))return!1;o(n.removeStoredMark(e)),Object.keys(a).some((e=>null!==a[e]))&&o(n.addStoredMark(e.create(a))),c=!0}}else{for(let r=0;r<a.length;r++){const{$from:o,$to:s}=a[r];c=ie(n,o.pos,s.pos,t,e)||c}c&&(n.scrollIntoView(),o(n))}}return c},le=(e,t,n)=>(r,o)=>{const s=r.schema.marks,{altStyle:i,altMarks:a=[],mark:l}=e,c=t||r.tr;let d=!1,u=!1;const p=()=>u=!0;if(i&&s.style){d=ae(s.style,{style:i.name,value:i.value})(r,p,c)}const h=[l,...a].filter((e=>s[e])).map((e=>ne(r,{mark:e})&&s[e])).filter((e=>e));return h.length?((e,t,n,r)=>{const{$cursor:o,ranges:s}=t.selection;if(r=r||t.tr,o)e.forEach((e=>{e.isInSet(t.storedMarks||o.marks())&&n(r.removeStoredMark(e))}));else{for(let t=0;t<s.length;t++){const{$from:n,$to:o}=s[t];e.forEach((e=>{ee(r,n.pos,o.pos,e)}))}n(r.scrollIntoView())}})(h,r,p,c):d||Q(s[l],n,c)(r,p),u&&o(c),u},ce=(e,t)=>(n,r)=>{const{$cursor:o}=n.selection;if(o){const s=o.parent,i=o.index(),a=n.schema.marks[e.mark],l=s.child(i).marks.find((e=>e.type===a)),c=s.childCount;let d,u,p=o.pos-o.textOffset,h=s.child(i).nodeSize;for(d=i-1;d>=0&&l.isInSet(s.child(d).marks);)u=s.child(d).nodeSize,h+=u,p-=u,d-=1;for(d=i+1;d<c&&l.isInSet(s.child(d).marks);)h+=s.child(d).nodeSize,d+=1;r(ee(t||n.tr,p,p+h,l))}else le(e,t)(n,r)},de=(e,n,r,s)=>{if(!r.isTextblock)return!1;const{ranges:i}=e.selection;i.forEach((i=>{const a=e.steps.length,l=i.$from.pos,c=i.$to.pos;e.doc.nodesBetween(l,c,((i,l)=>{if(i.eq(n)&&i.isTextblock&&!i.hasMarkup(r,s)&&((e,t,n)=>{const r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)})(e.doc,e.mapping.slice(a).map(l),r)){e.clearIncompatible(e.mapping.slice(a).map(l,1),r);const n=e.mapping.slice(a),c=n.map(l,1),d=n.map(l+i.nodeSize,1),u=new t.Slice(t.Fragment.from(r.create(s,null,i.marks)),0,0);return e.step(new o.ReplaceAroundStep(c,d,c+1,d-1,u,1,!0)),!1}}))}))},ue=(e,t={blocksInSelection:!1})=>{const{doc:r,selection:o}=e,{$from:s,ranges:i}=o,{blocksInSelection:a}=t,l=[],c=o instanceof n.NodeSelection?o.node:void 0;return c?c.isBlock?(l.push(c),c.nodesBetween(0,c.content.size,(e=>{e.isBlock&&l.push(e)}))):!a&&s.parent&&s.parent.isBlock&&l.push(s.parent):i.forEach((e=>{const t=e.$from.pos,n=e.$to.pos;r.nodesBetween(t,n,((e,r)=>{e.isBlock&&(!a||r>=t&&r+e.content.size+2<=n)&&l.push(e)}))})),l},pe=(e,t={blocksInSelection:!0})=>{const{doc:n,selection:r}=e,{blocksInSelection:o,blockNodeType:s}=t;ue({doc:n,selection:r},{blocksInSelection:o}).filter((e=>e.isTextblock)).forEach((t=>{const{style:n="",class:r="",...o}=t.attrs||{},i=s||t.type;(n||r||i!==t.type)&&de(e,t,i,o)}))},he=e=>{const t=ue(e),n=e.schema.nodes,r=[];return t.forEach((e=>{e.type===n.paragraph?r.push("p"):e.type===n.heading?r.push(`h${e.attrs.level}`):e.type===n.blockquote&&n.blockquote.isTextblock&&r.push("blockquote")})),r},fe=(e,t)=>{let n,r,o=e.attrs.style;o&&t.forEach((e=>{r={style:e.name,value:/^.+$/,newValue:e.value},n=v(o,r),o=n.changed?n.style:o}));return o=o||t.reduce(((e,t)=>(e&&t.value?e+" ":"")+t.value?`${t.name}: ${t.value};`:""),""),Object.assign({},e.attrs,{style:o||null})},me=(e,t)=>{const{from:n,to:r}=e.selection;let o=!1;return e.doc.nodesBetween(n,r,(e=>(o=o||e.type===t,!o))),o},ge=e=>{const t=he(e);return 1===new Set(t).size?t[0]:null},ye={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},be={listType:ye.orderedList,types:{...ye}},we={listType:ye.bulletList,types:{...ye}},ve={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"}],listsTypes:{...ye}},ke={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"}],listsTypes:{...ye}},Me=(e,t)=>{const{$from:n,$to:r}=e.selection,o=e.schema.nodes.blockquote,s=e.doc;let i=-1;const a=n.blockRange(r);a&&s.nodesBetween(a.start,a.end,((e,t)=>{e.type===o&&(i=t)}));const l=-1!==i;return t&&l&&t(e.tr.lift(a,s.resolve(i).depth)),l},xe=(e,t,n)=>(r,o)=>{const s=ue(r),i=r.tr;i.setMeta("commandName",t),s.forEach((t=>{if(t.type.isTextblock){let r;const o=e.find((e=>e.node===t.type.name));if(o){const e="rtl"===n?o.rtlStyle:o.style,s={name:e,value:o.step>0?`${o.step}${o.unit}`:""};if(t.attrs.style){const n=new RegExp(`${e}:\\s?(\\d+)${o.unit}`,"i"),r=t.attrs.style.match(n);if(r){let e=parseFloat(r[1])+o.step;e=e<=0?"":e,s.value=`${e}${e?o.unit:""}`}}r=fe(t,[s])}r&&de(i,t,t.type,r)}}));const a=i.docChanged;return a&&o(i.scrollIntoView()),a},Se=(e,t,n)=>{const r=ue(e);let o=!1;return r.forEach((e=>{if(!o&&e.type.isTextblock&&e.attrs.style){const r=t.find((t=>t.node===e.type.name));if(r){const t="rtl"===n?r.rtlStyle:r.style,s=new RegExp(`${t}:\\s?\\d+${r.unit}`,"i");o=s.test(e.attrs.style)}}})),o},Oe=(e,t)=>s.sinkListItem(t)(e),Ce=(e,t)=>{const n=e.schema.nodes[t.listsTypes.listItem],r=e.schema.nodes[t.listsTypes.orderedList],o=e.schema.nodes[t.listsTypes.bulletList],i=!!S(r,2)(e.selection),a=!!S(o,2)(e.selection);return(i||a)&&s.liftListItem(n)(e)},Ae=(e,t)=>{const n=e.schema.nodes,r=n[ve.listsTypes.listItem];return(Se(e,t.nodes)||ve.nodes.some((t=>n[t.node]&&me(e,n[t.node]))))&&!me(e,r)},Te=(e,t,n)=>{let r=t.depth;const o=e.nodes[n.bulletList],s=e.nodes[n.orderedList],i=e.nodes[n.listItem];for(let e=t.depth;e>0;e--){const n=t.node(e);if(n.type!==o&&n.type!==s||(r=e),n.type!==o&&n.type!==s&&n.type!==i)break}return r-1};function Ee(e){return function(t,n,r){if(!r)return!1;const o=(t=r.state).schema.nodes[e.listType],{$from:a,$to:l}=t.selection,c=a.node(-2),d=a.node(-3),u=function(e,t,n,r){return 0===function(e,t,n){const r=[],o=function(e,t){const n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;let r=t.node(t.depth),o=t;for(;t.depth>=1;)r=(t=e.resolve(t.before(t.depth))).node(t.depth),r&&-1!==n.indexOf(r.type.name)&&(o=t);return o}(e,t).depth;let s=e.resolve(t.start(o));for(;s.pos<=n.start(n.depth);){const t=Math.min(s.depth,o),n=s.node(t);if(n&&r.push(n),0===t)break;let i=e.resolve(s.after(t));if(i.start(t)>=e.nodeSize-2)break;i.depth!==s.depth&&(i=e.resolve(i.pos+2)),s=i.depth?e.resolve(i.start(i.depth)):e.resolve(i.end(i.depth))}return r}(e,t,n).filter((e=>e.type!==r)).length}(t.doc,a,l,o);return(c&&c.type===o||d&&d.type===o)&&u?De(e)(t,n):(u||(De(e)(t,n),t=r.state),function(e,t={}){return i.autoJoin(s.wrapInList(e,t),((t,n)=>t.type===n.type&&t.type===e))}(o,e.listAttrs)(t,n))}}function Ne(e,n,r,s){const i=s||e.schema.nodes.listItem,{$from:a,$to:l}=n;let c=a.blockRange(l,(e=>e.childCount&&e.firstChild.type===i));if(!c||c.depth<2||a.node(c.depth-1).type!==i)return r;const d=c.end,u=l.end(c.depth);return d<u&&(r.step(new o.ReplaceAroundStep(d-1,u,d,u,new t.Slice(t.Fragment.from(i.create(void 0,c.parent.copy())),1,0),1,!0)),c=new t.NodeRange(r.doc.resolve(a.pos),r.doc.resolve(u),c.depth)),r.lift(c,o.liftTarget(c)).scrollIntoView()}function De(e){return function(t,r){const{tr:s}=t,{$from:i,$to:a}=t.selection;return s.doc.nodesBetween(i.pos,a.pos,((r,i)=>{if(r.isTextblock||"blockquote"===r.type.name||"div"===r.type.name){const r=new n.NodeSelection(s.doc.resolve(s.mapping.map(i))),a=r.$from.blockRange(r.$to);if(!a||r.$from.parent.type!==t.schema.nodes[e.listItem])return;const l=a&&o.liftTarget(a);if(null==l)return!1;s.lift(a,l)}})),r&&r(s),!0}}const $e=/list\-style\-type:\s?([\w-]+)/,Pe=e=>{const t=e.style||"",n=$e.exec(t);return n&&n[1]||""},He=(e,t,r,o,s)=>{const{listType:i,listAttrs:a={style:null}}=o,{selection:l}=e,c=l.$from.node(l.$from.depth-2),d=l.$to.node(l.$to.depth-2);if(c&&c.type.name===i&&Pe(c.attrs)===Pe(a)&&d&&d.type.name===i&&Pe(d.attrs)===Pe(a)){const i=r.state.schema.nodes,a={bulletList:i[o.bulletList],orderedList:i[o.orderedList],listItem:i[o.listItem]},c=((e,t)=>{const{bulletList:n,orderedList:r,listItem:o}=t;let s;for(let t=e.depth-1;t>0;t--){const i=e.node(t);if(i.type!==n&&i.type!==r||(s=t),i.type!==n&&i.type!==r&&i.type!==o)break}return s})(l.$to,a);let d=function(e,t,r,o,s,i){i||(i=e.schema.nodes.listItem);let a=!1;return s.doc.nodesBetween(t,r,((r,l)=>{if(!a&&r.type===i&&l>t){a=!0;let t=o+3;for(;t>o+2;){const o=s.doc.resolve(s.mapping.map(l));t=o.depth;const a=s.doc.resolve(s.mapping.map(l+r.textContent.length)),c=new n.TextSelection(o,a);s=Ne(e,c,s,i)}}})),s}(e,l.$to.pos,l.$to.end(c),c,r.state.tr,a.listItem);return d=function(e,t,n){const{from:r,to:o}=e.selection,{paragraph:s,heading:i}=e.schema.nodes,a=[];t.doc.nodesBetween(r,o,((e,t)=>{e.type!==s&&e.type!==i||a.push({node:e,pos:t})}));for(let r=a.length-1;r>=0;r--){const o=a[r],s=t.doc.resolve(t.mapping.map(o.pos));if(s.depth>0){let r;r=o.node.textContent&&o.node.textContent.length>0?t.doc.resolve(t.mapping.map(o.pos+o.node.textContent.length)):t.doc.resolve(t.mapping.map(o.pos+1));const i=s.blockRange(r);i&&t.lift(i,Te(e.schema,s,n))}}return t}(e,d,o),d.setMeta("commandName",s),t(d),!0}return Ee(o)(e,t,r)};const Ie=(e,t)=>({name:e,value:t}),Le=[{node:"paragraph",style:[Ie("text-align","left")]},{node:"heading",style:[Ie("text-align","left")]},{node:"table_caption_external",style:[Ie("text-align","left")]}],ze=[{node:"paragraph",style:[Ie("text-align","right")]},{node:"heading",style:[Ie("text-align","right")]},{node:"table_caption_external",style:[Ie("text-align","right")]}],je=[{node:"paragraph",style:[Ie("text-align","center")]},{node:"heading",style:[Ie("text-align","center")]},{node:"table_caption_external",style:[Ie("text-align","center")]}],Re=[{node:"paragraph",style:[Ie("text-align","justify")]},{node:"heading",style:[Ie("text-align","justify")]},{node:"table_caption_external",style:[Ie("text-align","justify")]}],Be=[{node:"paragraph",style:[Ie("text-align","")]},{node:"heading",style:[Ie("text-align","")]},{node:"table_caption_external",style:[Ie("text-align","")]}],_e=["blockquote",0],Fe=["hr"],qe=["pre",["code",0]],We=["ol",0],Ve=["ul",0],Ke=["li",0],Ye=e=>{const t={},n=e.attributes;let r;for(let e=0;e<n.length;e++)r=n[e],t[r.name]=r.value;return t},Xe=e=>{const t={};return e.forEach((e=>{t[e]={default:null}})),t},Ge=()=>Xe(["style","class","id"]),Ue=(e,t)=>{for(const n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},Ze=(e,t=[])=>{const n={};for(const r in e)r&&null!==e[r]&&!t.find((e=>e===r))&&(n[r]=e[r]);return n},Je=e=>({[e]:{name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:()=>[e,0]}}),Qe={link:{attrs:{...Ge(),href:{default:null},target:{default:null},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a",getAttrs:Ye}],toDOM:e=>["a",Ze(e.attrs),0]},...Je("strong"),...Je("b"),...Je("em"),...Je("i"),...Je("del"),...Je("sub"),...Je("sup"),...Je("code"),style:{attrs:{...Ge()},parseDOM:[{tag:"span",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["span",Ze(e.attrs),0]:["span",0]},...Je("u")},et=e=>({[e]:{default:null,getFromDOM:t=>t.getAttribute(e),setDOMAttr:(t,n)=>{n[e]=t}}}),tt={...et("style"),...et("class"),...et("id"),...et("headers"),...et("scope")},nt={doc:{content:"colgroup*"},col:{attrs:Xe(["id","class","style","span"]),parseDOM:[{getAttrs:Ye,tag:"col"}],toDOM:e=>["col",e.attrs]},colgroup:{attrs:Xe(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:Ye,tag:"colgroup"}],toDOM:e=>["colgroup",e.attrs,0]},text:{inline:!0,group:"inline"}},rt=new t.Schema({nodes:nt,marks:{}}),ot=e=>{const t=U(Y(e),rt,{preserveWhitespace:!1});return G(t).firstChild},st=a.tableNodes({tableGroup:"block",cellContent:"block+",cellAttributes:tt});st.table_row.attrs={...st.table_row.attrs,...Xe([f,"style","class","id"])},st.table_row.toDOM=e=>["tr",Ze(e.attrs),0],st.table_row.parseDOM=[{tag:"tr",getAttrs:Ye}],st.table.attrs={...st.table.attrs,...Xe(["style","class","id",m,g])},st.table.toDOM=e=>{const t=Ue(e.attrs)?Ze(e.attrs,[m,g]):{};let n=null;if(e.attrs[m]&&!(e=>{let t=!1;const n=e.child(0);for(let e=0;e<n.childCount;e++)if(n.child(e).attrs.colwidth){t=!0;break}return t})(e)){const t=ot(e.attrs[m]);if(t){const e=Array.from(t.children).map((e=>["col",Ye(e)]));n=["colgroup",Ye(t)].concat(e)}}return n?["table",t,n,["tbody",0]]:["table",t,["tbody",0]]},st.table.parseDOM=[{tag:"table",getAttrs:e=>{const t=Ye(e),n=Array.from(e.childNodes).find((e=>"COLGROUP"===e.nodeName));return n&&(t[m]=n.outerHTML),t}}];const it={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:{...Ge()},parseDOM:[{tag:"p",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["p",Ze(e.attrs),0]:["p",0]},table_wrapper:{content:"(table_caption_external | table)+",group:"block",defining:!0,attrs:{table:{default:null},style:{default:null}},parseDOM:[{tag:"div[table]",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["div",Ze(e.attrs),0]:["div",0]},table_caption_external:{content:"inline+",group:"block",attrs:{caption:{default:null},...Ge()},parseDOM:[{tag:"div[caption]",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["div",Ze(e.attrs),0]:["div",0]},div:{content:"block*",group:"block",attrs:{...Ge()},parseDOM:[{tag:"div",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["div",Ze(e.attrs),0]:["div",0]},blockquote:{attrs:{...Ge()},content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["blockquote",Ze(e.attrs),0]:_e},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>Fe},heading:{attrs:{...Ge(),level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:e=>({...Ye(e),level:1})},{tag:"h2",getAttrs:e=>({...Ye(e),level:2})},{tag:"h3",getAttrs:e=>({...Ye(e),level:3})},{tag:"h4",getAttrs:e=>({...Ye(e),level:4})},{tag:"h5",getAttrs:e=>({...Ye(e),level:5})},{tag:"h6",getAttrs:e=>({...Ye(e),level:6})}],toDOM:e=>Ue(e.attrs,"level")?["h"+e.attrs.level,Ze(e.attrs,["level"]),0]:["h"+e.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>qe},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},...Ge()},group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["img",Ze(e.attrs)]:["img"]},hard_break:{inline:!0,attrs:{...Ge()},group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["br",Ze(e.attrs)]:["br"]},ordered_list:{content:"list_item+",group:"block",attrs:{...Ge(),type:{default:null},order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({...Ye(e),order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}],toDOM:e=>1===e.attrs.order?Ue(e.attrs,"order")?["ol",Ze(e.attrs,["order"]),0]:We:["ol",{...Ze(e.attrs,["order"]),start:e.attrs.order},0]},bullet_list:{content:"list_item+",group:"block",attrs:{...Ge()},parseDOM:[{tag:"ul",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["ul",Ze(e.attrs),0]:Ve},list_item:{content:"(paragraph | heading) block*",attrs:{...Ge()},parseDOM:[{tag:"li",getAttrs:Ye}],toDOM:e=>Ue(e.attrs)?["li",Ze(e.attrs),0]:Ke,defining:!0},...st},at={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},lt={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},ct={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},dt="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ut=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,pt=e=>/^MsoListParagraph/.test(e.className),ht=e=>{let t=e.innerHTML;return t=t.replace(/<!--(.|\s)*?-->/gi,""),t=t.replace(/<\/?[^>]+?\/?>/gm,""),t},ft=(e,t)=>{const n=document.createElement(e);return n.style.listStyleType=t,n},mt=e=>{let t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},gt=(e,t)=>{let n=[];Array.from(e).forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const r=e;r.getAttribute("datalist")?(n.push(e),t.add(n)):pt(r)&&n.length?n.push(e):(n=[],"DIV"===r.nodeName?gt(r.children,t):"TABLE"===r.nodeName&&Array.from(r.querySelectorAll("td,th")).forEach((e=>{gt(e.children,t)})))}))},yt=e=>{let t=e.innerHTML;const n=e=>e.replace(/^(?: |[\u00a0\n\r\s])+/,"");return t=t.replace(/<\/?\w+[^>]*>/g,"").replace(/ /g," "),/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(t)?{tag:"ul",style:(r=n(ht(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(r)?null:/^o/.test(r)?"circle":"square")}:/^\s*\w+[\.\)][\u00a0 ]{2,}/.test(t)?{tag:"ol",style:mt(n(ht(e)))}:void 0;var r},bt=e=>{let t,n=e.nodeName.toLowerCase();e.firstChild&&e.firstChild.nodeType===Node.COMMENT_NODE&&e.removeChild(e.firstChild),1===e.childNodes.length?t=e.firstChild.nodeType===Node.TEXT_NODE?ht(e):e.firstChild.innerHTML.replace(/^\w+[\.\)]( )+ /,""):(e.removeChild(e.firstChild),3===e.firstChild.nodeType&&/^[ivxlcdm]+\.$/i.test(e.firstChild.nodeValue)&&e.removeChild(e.firstChild),/^( |\s)+$/i.test(e.firstChild.innerHTML)&&e.removeChild(e.firstChild),t="p"!==n?"<"+n+">"+e.innerHTML+"</"+n+">":e.innerHTML),e.parentNode.removeChild(e);const r=document.createElement("li");return r.appendChild(Y(t)),r},wt=e=>{const t=Y((e=>e.replace(ut,((e,t,n)=>`datalist="${t}" datalevel="${n}" ${e}`)))(e)),n=new Set;return gt(t.children,n),n.forEach((e=>(e=>{let t,n,r,o,s,i,a,l,c,d,u,p,h,f=-1,m={};for(l=0;l<e.length;l++){c=e[l],h={datalist:c.getAttribute("datalist"),datalevel:c.getAttribute("datalevel")};const g=h.datalist,y=yt(c);if(d=y&&y.tag,!d){!t||s&&!pt(c)||(c.style.marginLeft&&(c.style.marginLeft=""),c.style.marginLeft&&(c.style.margin=""),t.appendChild(c));continue}if(u=h.datalevel||parseFloat(c.style.marginLeft||0),!h.datalevel&&!c.style.marginLeft)continue;const b=d+g;m[u]||(m[u]={}),(!n||n<0)&&(n=u,r=g,a=e.filter((e=>e.getAttribute("datalist")===String(r))),o=a[a.length-1],i=ft(d,y&&y.style),c.parentNode.insertBefore(i,c),f=u,m[u][b]=i),s=o===c,p=m[u][b],(u>f||!p)&&(p=ft(d,y&&y.style),m[u][b]=p,t.appendChild(p)),t=bt(c),p.appendChild(t),s?n=f=-1:f=u}})(e))),X(t)},vt=(e,t)=>e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),""),kt=e=>{e.ownerElement&&e.ownerElement.removeAttribute(e.name)};function Mt(e){const t=e.length,n=new Array(t/2);for(let r=0;r<t;r+=2)n[r]=String.fromCharCode(parseInt(e.substring(r,r+2),16));return btoa(n.join(""))}const xt=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,St=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,Ot=new RegExp("(?:("+St.source+"))([\\da-fA-F\\s]+)\\}","g"),Ct=/[^\da-fA-F]/g,At=/file:\/[^'"]+\.(jpg|png|gif)/i,Tt=/\\(png|jpeg)blip\\/,Et="text/rtf",Nt=(e,t,r,o,s)=>{let i,a,l,c,d,u,p=[];const h=[],{matchCase:f,matchWord:m,useRegExp:g}=t;let y=t.text;if(g&&(/^\\$/.test(y)||/[^\\]\\$/.test(y))&&(y=y.substring(0,y.length-1)),!y)return p;const b=f?"g":"gi",w=g?new RegExp(y,b):Ht(y,b);return e.nodesBetween(r,o,((t,f)=>{if(s(p))return!1;t.inlineContent&&f+t.content.size>=r&&(h.length=0,t.nodesBetween(0,t.content.size,((t,g,y,b)=>{if(s(p))return!1;const v=1+f+g;if(t.isText&&v+t.nodeSize>=r){if(d=t.text||"",u=y.childCount-1>=b+1&&y.child(b+1),h.push(r<=v?{text:d,start:v}:{text:d.slice(r-v),start:r}),u&&u.isText)return;for(a=h.map((e=>e.text)).join(""),i=w.exec(a);null!==i&&(l=h[0].start+i.index,c=l+i[0].length,r<=l&&o>=c&&Pt(i,m)&&p.push(n.TextSelection.create(e,l,c)),!s(p));)i=w.exec(a)}else h.length=0})))})),p},Dt=(e,t)=>Nt(e,t,0,e.content.size,(()=>!1)),$t=/^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/,Pt=(e,t)=>{if(t){if(!0===t){const t=e.input,n=t.charAt(e.index-1),r=t.charAt(e.index+e[0].length);return $t.test(n)&&$t.test(r)}return t(e)}return!0},Ht=(e,t)=>{const n=e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(/\s/g,"\\s");return new RegExp(n,t)};const It=/\s+/g,Lt=/text-align/,zt=(e,t)=>{for(const n in t)n&&I(e,n,t[n])};class jt{constructor(e,t,n,r=!1){this.node=e,this.view=t,this.dom=document.createElement(n),zt(this.dom,e.attrs),this.contentDOM=r?void 0:this.dom}}class Rt{constructor(e,t){this.mark=e,this.view=t,this.dom=document.createElement("span"),zt(this.dom,e.attrs),this.contentDOM=this.dom}}const Bt=new n.PluginKey("highlight");const _t={southeast:{x:1,y:1},east:{x:1,y:0},south:{x:0,y:1},north:{x:0,y:-1},west:{x:-1,y:0},southwest:{x:-1,y:1},northwest:{x:-1,y:-1},northeast:{x:1,y:-1}},Ft=Object.keys(_t),qt=new n.PluginKey("image-resize"),Wt=(e,t,n)=>{e.style[t]=n+"px"},Vt=/[^\-]width:|[^\-]height:/,Kt=/^.+$/;let Yt=class e{constructor(e,t,n,r){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=r}apply(t){const n=t.getMeta(qt);return n?new e(n.activeHandle,n.setDragging,n.rect,n.nodePosition):this}};const Xt=(e,t,r)=>{const o=t.target.getAttribute(w);if(!o)return!1;const s=qt.getState(e.state);t.preventDefault();const i=e.state.tr;function a(t){((e,t,n)=>{const r=qt.getState(e.state),{rect:o,dragging:s,nodePosition:i,activeHandle:a}=r;if(!s||!o)return;const l=e.nodeDOM(i),c=_t[a],d=(t.clientX-s.startX)*c.x,u=(t.clientY-s.startY)*c.y;let p=c.x?d+l.width:o.width,h=c.y?u+l.height:o.height;if(n.lockRatio&&c.x&&c.y){const e=Math.min(p/l.width,h/l.height),n=l.width*e,r=l.height*e;s.startX=t.clientX-(p-n)*c.x,s.startY=t.clientY-(h-r)*c.y,p=n,h=r}else s.startX=c.x?t.clientX:s.startX,s.startY=c.y?t.clientY:s.startY;Wt(l,"width",p),Wt(l,"height",h),o.top=l.offsetTop,o.left=l.offsetLeft,o.width=l.offsetWidth,o.height=l.offsetHeight;const f=l.nextElementSibling;f.style.width=o.width+"px",f.style.height=o.height+"px",f.style.top=o.top+"px",f.style.left=o.left+"px"})(e,t,r)}return i.setMeta(qt,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:o,rect:s.rect,nodePosition:s.nodePosition}),i.setMeta("addToHistory",!1),e.dispatch(i),t.view.addEventListener("mouseup",(function t(r){r.view.removeEventListener("mouseup",t),r.view.removeEventListener("mousemove",a),(e=>{const{rect:t,dragging:r,nodePosition:o}=qt.getState(e.state);if(r&&t){const r=e.state.selection;if(r instanceof n.NodeSelection){const s=r.node.attrs,i=t.width,a=t.height;let l;if(Vt.test(s.style||"")){const e=v(s.style,{style:"width",value:Kt,newValue:i+"px"}),{style:t}=v(e.style||"",{style:"height",value:Kt,newValue:a+"px"});l={...s,style:t}}else l={...s,width:i,height:a};const c=r.node.type.createAndFill(l);if(c){const r=e.state.tr;r.replaceWith(o,o+1,c),r.setSelection(n.NodeSelection.create(r.doc,o)),r.setMeta("commandName","image-resize"),r.setMeta("args",l),r.setMeta(qt,{setDragging:null,activeHandle:null,rect:t,nodePosition:o}),e.dispatch(r)}}}})(e)})),t.view.addEventListener("mousemove",a),!0},Gt=new n.PluginKey("caret-color");class Ut{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className="k-editor-resize-wrap-element",this.table=this.dom.appendChild(document.createElement("table")),e.attrs[m]&&this.renderColgroup(e.attrs[m]);const n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=Ft.map((e=>{const t=document.createElement("span");return t.className=y+" "+e,t.setAttribute(b,e),t})),this.contentDOM=n}update(e){if(e.type!==this.node.type)return!1;const t=this.node;return this.node=e,e.attrs[g]?this.resizeHandles.forEach((e=>{this.dom.appendChild(e)})):Array.from(this.dom.children).filter((e=>e.classList.contains(y))).forEach((e=>e.remove())),this.setAttributes(this.table,e.attrs),t.attrs[m]!==e.attrs[m]&&this.renderColgroup(e.attrs[m]),!0}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))}destroy(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0}renderColgroup(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=ot(e),this.table.insertBefore(this.colgroup,this.table.firstChild))}setAttributes(e,t){const n=[m,g];for(const r in t)r&&-1===n.indexOf(r)&&I(e,r,t[r]);/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""}}class Zt{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}update(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)}ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName}destroy(){this.node=void 0,this.view=void 0}setAttributes(e,t){for(const n in t)n&&I(e,n,t[n]);if(e.setAttribute("table",""),/%/.test(e.style.width)){const t=this.node&&this.node.lastChild,n=(t?$(t.attrs.style):{}).width||"";n&&!/%/.test(n)&&(e.style.width="")}}}const Jt=new n.PluginKey("table-resize"),Qt=new n.PluginKey("table-column-resizing"),en=new n.PluginKey("table-row-resizing");function tn(e,t){let n=!1;return n=n||e!==Jt&&Boolean(Jt.get(t))&&Jt.getState(t).dragging,n=n||e!==Qt&&Boolean(Qt.get(t))&&Qt.getState(t).dragging,n=n||e!==en&&Boolean(en.get(t))&&en.getState(t).dragging,n}function nn(e,t){let n=!1;return n=n||e!==Qt&&Boolean(Qt.get(t))&&Qt.getState(t).activeHandle>-1,n=n||e!==en&&Boolean(en.get(t))&&en.getState(t).activeHandle>-1,n}function rn(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e}function on(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}function sn(e){const t=function(e){const t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((e=>e.colSpan)).reduce(((e,t)=>e+t),0),r=t.map((()=>new Array(n)));return t.forEach(((e,t)=>{let n=0;Array.from(e.cells).forEach((e=>{for(let o=0;o<e.colSpan;o++){for(let o=0;o<e.rowSpan;o++){const s=r[t+o].findIndex(((e,t)=>t>=n&&!e));r[t+o][s]=e}n++}}))})),r}(e.closest("table"));let n=null;for(let r=0;r<t.length;r++){if(t[r].forEach(((t,o)=>{e===t&&(n={rowIndex:r,cellIndex:o})})),n)break}return n||{rowIndex:-1,cellIndex:-1}}function an(e,t,n){const r=e.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return-1;const o=e.state.doc.resolve(r.pos),s=O(o,(e=>"table"===e.type.spec.tableRole));if(null===s)return-1;const i=o.start(s.depth),l=s.node,c=a.TableMap.get(l);return i+c.map[c.width*n.rowIndex+n.cellIndex]}function ln(){const e=new n.Plugin({key:Qt,state:{init:()=>new cn(-1,null),apply:(e,t)=>t.apply(e)},props:{attributes(e){if(nn(Qt,e))return null;return Qt.getState(e).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:(e,t)=>(tn(Qt,e.state)||function(e,t,n){const r=Qt.getState(e.state);if(!r.dragging){const o=on(t.target);let s=-1;if(o){const r=sn(o),{left:i,right:a}=o.getBoundingClientRect();Math.abs(t.clientX-i)<=n&&r.cellIndex>0?(r.cellIndex-=o.colSpan,s=an(e,t,r)):a-t.clientX>0&&a-t.clientX<=n&&(s=an(e,t,r))}s!==r.activeHandle&&dn(e,s)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=Qt.getState(e.state);t.activeHandle>-1&&!t.dragging&&dn(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t,n){const r=Qt.getState(e.state);if(-1===r.activeHandle||r.dragging)return!1;const o=e.state.doc.resolve(r.activeHandle),s=o.parent,i=o.index();let l=0;for(let e=0;e<=i;e++)l+=s.child(e).attrs.colspan;const c=o.node(o.depth-1),d=e.domAtPos(r.activeHandle),u=d.node.childNodes[d.offset].closest("table");let p,h;if(c.attrs[m]){p=u.firstChild.children[l-1],p.style.width||(p.style.width=p.offsetWidth+"px")}else{let e=0;for(let t=0;t<s.childCount;t++)e+=s.child(t).attrs.colspan;const t=document.createElement("colgroup"),n=new Array(e);for(let r=0;r<e;r++)n[r]=document.createElement("col"),t.appendChild(n[r]);u.insertBefore(t,u.firstChild),p=n[i],p.style.width=p.offsetWidth+"px",h={...c.attrs,[m]:"<colgroup>"+n.reduce(((e,t)=>e+t.outerHTML),"")+"</colgroup>"}}const f=parseFloat(p.style.width),g=e.state.tr.setMeta(Qt,{setDragging:{startX:t.clientX,startWidth:f}});if(!u.style.width){const e=Array.from(p.parentNode.children).map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);h=M(h||c.attrs,"width",t+"px")}}if(h){const e=o.posAtIndex(0,o.depth-1)-1;g.setNodeMarkup(e,null,h)}function y(t){t.view.removeEventListener("mouseup",y),t.view.removeEventListener("mousemove",b);const n=Qt.getState(e.state);if(n.dragging){const t=e.state.tr;!function(e,t,n){const r=e.state.doc.resolve(n),o=r.node(-1),s=r.start(-1),i=r.posAtIndex(0,r.depth-1)-1,a=e.nodeDOM(s).closest("table");let l=o.attrs;if(o&&l[m]){const e=a.firstChild;l={...l,[m]:e.outerHTML}}const c=a.style.width;a&&c&&$(l.style).width!==c&&(l=M(l,"width",c));t.setNodeMarkup(i,null,l)}(e,t,n.activeHandle),e.dispatch(t.setMeta(Qt,{setDragging:null}))}}function b(t){if(!t.which)return y(t);const r=Qt.getState(e.state),o=function(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}(r.dragging,t,n);!function(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),s=r.start(-1),i=a.TableMap.get(o).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let l=e.domAtPos(r.start(-1)).node;"TABLE"!==l.nodeName&&(l=l.closest("table"));const c=l,d=c.firstChild,u=Array.from(d.children);if(u[i].style.width=n+"px",c.style.width){const e=u.map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);c.style.width=t+"px"}}}(e,r.activeHandle,o)}return e.dispatch(g),t.view.addEventListener("mouseup",y),t.view.addEventListener("mousemove",b),t.preventDefault(),!0}(e,t,25)},decorations(e){if(!tn(Qt,e)){const t=Qt.getState(e);if(t.activeHandle>-1)return function(e,t){const n=[],r=e.doc.resolve(t),o=r.node(-1),s=a.TableMap.get(o),i=r.start(-1),l=[],c=t-i;let u=-1;for(let e=0;e<s.height;e++)l.push(s.map.slice(e*s.width,e*s.width+s.width)),-1===u&&(u=l[e].lastIndexOf(c));const p=[];return l.forEach((e=>{const t=e[u];e[u]!==e[u+1]&&p.push(t)})),p.forEach((e=>{const t=i+e+o.nodeAt(e).nodeSize-1,r=document.createElement("div");r.className="column-resize-handle",n.push(d.Decoration.widget(t,r))})),d.DecorationSet.create(e.doc,n)}(e,t.activeHandle)}return d.DecorationSet.empty},nodeViews:{table_wrapper:(e,t)=>new Zt(e,t),table:(e,t)=>new Ut(e,t)}}});return e}let cn=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n;const r=t.getMeta(Qt);if(r&&null!=r.setHandle)return new e(r.setHandle,null);if(r&&void 0!==r.setDragging)return new e(this.activeHandle,r.setDragging);if(this.activeHandle>-1&&t.docChanged){let r=t.mapping.map(this.activeHandle,-1);o=t.doc.resolve(r),Boolean("row"===o.parent.type.spec.tableRole&&o.nodeAfter)||(r=-1),n=new e(r,this.dragging)}var o;return n||this}};function dn(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(Qt,{setHandle:t}),e.dispatch(n)}const un={southeast:!0,southwest:!0,northwest:!0,northeast:!0},pn={east:!0,west:!0,...un},hn={south:!0,north:!0,...un};let fn=class e{constructor(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}apply(t){const n=t.getMeta(Jt);if(n){return new e(n.activeHandle,n.setDragging,n.nodePosition)}return this}};const mn=e=>{const t=Array.from(e.firstChild.children).map((e=>e.offsetWidth)),n=Array.from(e.rows).map((e=>e.offsetHeight)),r=t.reduce(((e,t)=>e+t),0),o=n.reduce(((e,t)=>e+t),0),s=e.offsetHeight;return{width:r,height:o,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:s}},gn=e=>{const{dragging:t,nodePosition:n,activeHandle:r}=Jt.getState(e.state);if(t){const t=e.state.doc.nodeAt(n),o=rn(e.nodeDOM(n)),s=mn(o);if(t){const i=s.offsetWidth+"px",a=s.offsetHeight+"px",l=e.state.tr;let c=t.attrs;const d=$(c.style);if(pn[r]&&o.style.width&&d.width!==i&&(c=M(c,"width",i)),hn[r]&&o.style.height&&d.height!==a&&(c=M(c,"height",a)),c=((e,t,n,r)=>{const o=e.state.doc.nodeAt(n),s=rn(e.nodeDOM(n)),i=(s.ownerDocument&&s.ownerDocument.defaultView||window).getComputedStyle,a=Array.from(s.rows);o.forEach(((e,r,o)=>{const s=$(e.attrs.style).height;s&&!/px$/.test(s)&&t.setNodeMarkup(n+r+1,null,M(e.attrs,"height",i(a[o]).height))}));const l=s.firstChild,c=Array.from(l&&l.children||[]);let d=!1;c.forEach(((e,t)=>{e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=i(c[t]).width,d=!0)}));const u={...r};return d&&(u[m]=l.outerHTML),u})(e,l,n,c),l.setNodeMarkup(n,null,c),l.setMeta("commandName","node-resize"),l.setMeta("args",c),l.setMeta(Jt,{setDragging:null,activeHandle:null,nodePosition:n}),!/%/.test($(c.style).width||"")){const e=l.doc.resolve(n),t=O(e,(e=>"table_wrapper"===e.type.name));if(t&&/%/.test($(t.node.attrs.style).width||"")){const n=M(t.node.attrs,"width",""),r=e.start(t.depth)-1;l.setNodeMarkup(r,null,n)}}e.dispatch(l)}}},yn=(e,t)=>{const n=t.target.getAttribute(b);if(!n)return!1;const r=Jt.getState(e.state);t.preventDefault();const o=e.state.tr;o.setMeta(Jt,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:r.nodePosition}),o.setMeta("addToHistory",!1),((e,t,n)=>{const r=e.state.doc.nodeAt(n),o=rn(e.nodeDOM(n)),{width:s,height:i,colsWidth:a,rowsHeight:l,offsetWidth:c,offsetHeight:d}=mn(o),u=o.firstChild,p=Array.from(u&&u.children||[]);let h=!1;p.forEach(((e,t)=>{e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*a[t]/s+"%",h=!0)}));let f=!1;r.forEach(((e,r,o)=>{const s=$(e.attrs.style).height;s&&!/%$/.test(s)&&(t.setNodeMarkup(n+r+1,null,M(e.attrs,"height",100*l[o]/i+"%")),f=!0)}));let g=r.attrs;$(g.style).width!==c+"px"&&(g=M(g,"width",c+"px")),h&&(g[m]=u.outerHTML),f&&(g=M(g,"height",d+"px")),(h||f)&&t.setNodeMarkup(n,null,g)})(e,o,r.nodePosition),e.dispatch(o);const s=t.view||window;function i(t){((e,t)=>{var n;const r=Jt.getState(e.state),{dragging:o,nodePosition:s,activeHandle:i}=r;if(s<0||!o)return;const a=rn(e.nodeDOM(s)),l=a.getBoundingClientRect(),c=_t[i],d=(t.clientX-o.startX)*c.x,u=(t.clientY-o.startY)*c.y,p=(a.ownerDocument&&a.ownerDocument.defaultView||window).getComputedStyle(a),h=/px/.test(p.width)?parseFloat(p.width):a.offsetWidth,f=/px/.test(p.height)?parseFloat(p.height):a.offsetHeight,m=c.x?d+h:l.width,g=c.y?u+f:l.height;if(o.startX=c.x?t.clientX:o.startX,o.startY=c.y?t.clientY:o.startY,pn[i]&&(a.style.width=m+"px"),hn[i]&&(a.style.height=g+"px"),/px/.test(a.style.width)){const e=null===(n=a.parentNode)||void 0===n?void 0:n.parentNode;e instanceof HTMLDivElement&&e.matches("div[table]")&&/%/.test(e.style.width)&&(e.style.width="")}})(e,t)}return s.addEventListener("mouseup",(function t(){s.removeEventListener("mouseup",t),s.removeEventListener("mousemove",i),gn(e)})),s.addEventListener("mousemove",i),!0},bn=(e={node:"table"})=>new n.Plugin({key:Jt,view:()=>({selectedNode(e,t){const r=e.selection;if(r instanceof n.NodeSelection&&t===r.node.type&&r instanceof n.NodeSelection)return{node:r.node,pos:r.from};const o=O(r.$from,(e=>e.type===t)),s=o&&o.node;if(s){return{node:s,pos:r.$from.start(o.depth)-1}}return null},update(t,n){const r=t.state,o=r.schema.nodes[e.node],s=this.selectedNode(r,o),i=this.selectedNode(n,o);if((s||!i||n.doc.eq(t.state.doc))&&(s||i)){const e=r.tr;if(e.setMeta("addToHistory",!1),s&&i&&s.pos!==i.pos){e.setMeta(Jt,{nodePosition:s.pos});const n=e.doc.nodeAt(i.pos);n&&n.type.name===o.name&&e.setNodeMarkup(i.pos,o,{...i.node.attrs,[g]:!1}),e.setNodeMarkup(s.pos,o,{...s.node.attrs,[g]:!0}),t.dispatch(e)}else s&&i&&s.pos===i.pos&&!s.node.attrs[g]&&!r.selection.eq(n.selection)?(e.setMeta(Jt,{nodePosition:s.pos}),t.dispatch(e.setNodeMarkup(s.pos,o,{...s.node.attrs,[g]:!0}))):s&&!i?(e.setMeta(Jt,{nodePosition:s.pos}),t.dispatch(e.setNodeMarkup(s.pos,o,{...s.node.attrs,[g]:!0}))):!s&&i&&(e.setMeta(Jt,{nodePosition:-1}),t.dispatch(e.setNodeMarkup(i.pos,o,{...i.node.attrs,[g]:!1})))}}}),state:{init:()=>new fn("",null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(e,t)=>yn(e,t)}}});class wn{ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName}}function vn(){const e=new n.Plugin({key:en,state:{init(e,t){return this.spec.props.nodeViews[a.tableNodeTypes(t.schema).row.name]=()=>new wn,new kn(-1,null)},apply:(e,t)=>t.apply(e)},props:{attributes(e){if(nn(en,e))return null;return en.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null},handleDOMEvents:{mousemove:(e,t)=>(tn(en,e.state)||function(e,t,n){const r=en.getState(e.state);if(!r.dragging){let o=on(t.target),s=-1;if(o){const r=sn(o),{top:i,bottom:a}=o.getBoundingClientRect();Math.abs(t.clientY-i)<=n&&r.rowIndex>0?(r.rowIndex-=o.rowSpan,s=an(e,t,r)):a-t.clientY>0&&a-t.clientY<=n&&(s=an(e,t,r))}s!==r.activeHandle&&Mn(e,s)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=en.getState(e.state);t.activeHandle>-1&&!t.dragging&&Mn(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=en.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const r=e.state.doc,o=r.resolve(n.activeHandle),s=o.parent,i=o.node(-1),a=$(s.attrs.style).height,l=$(i.attrs.style).height;let c=a?parseFloat(a):0;if(!a){c=e.nodeDOM(n.activeHandle).offsetHeight}function d(t){t.view.removeEventListener("mouseup",d),t.view.removeEventListener("mousemove",u);const n=en.getState(e.state);if(n.dragging){const t=e.state.tr.setMeta(en,{setDragging:null});!function(e,t,n){const r=e.state.doc,o=r.resolve(n),s=o.parent,i=o.posAtIndex(0)-1,a=e.nodeDOM(i),l=a.ownerDocument&&a.ownerDocument.defaultView||window;a.style.height=l.getComputedStyle(a).height,t.setNodeMarkup(i,null,M(s.attrs,"height",a.style.height));const c=a&&a.closest("table"),d=c&&c.style.height;if(d){const e=r.resolve(i),n=e.start(e.depth)-1;t.setNodeMarkup(n,null,M(e.parent.attrs,"height",d))}}(e,t,n.activeHandle),e.dispatch(t)}}function u(t){if(!t.which)return d(t);const n=en.getState(e.state),r=function(e,t){const n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),o=t.clientY-n.dragging.startY;!function(e,t,n,r,o){const s=e.nodeDOM(t),i=s&&s.parentNode;if(i){i.style.height=n+"px";const e=i.ownerDocument&&i.ownerDocument.defaultView||window;i.style.height=e.getComputedStyle(i).height;const t=i.closest("table"),s=parseFloat(o)+r+"px",a=t&&t.style.height;a&&a!==s&&(t.style.height=parseFloat(o)+r+"px",t.style.height=e.getComputedStyle(t).height)}}(e,n.activeHandle,r,o,l)}return e.dispatch(e.state.tr.setMeta(en,{setDragging:{startY:t.clientY,startHeight:{rowHeight:c,tableHeight:l}}})),t.view.addEventListener("mouseup",d),t.view.addEventListener("mousemove",u),t.preventDefault(),!0}(e,t)},decorations(e){if(tn(en,e))return d.DecorationSet.empty;const t=en.getState(e);return t.activeHandle>-1?function(e,t){const n=[];if("number"!=typeof t)return d.DecorationSet.empty;const r=e.doc.resolve(t),o=r.node(-1),s=a.TableMap.get(o),i=r.start(-1),l=[],c=t-i;let u=-1;for(let e=0;e<s.height;e++)l.push(s.map.slice(e*s.width,e*s.width+s.width)),-1!==l[e].indexOf(c)&&(u=e);const p=[];return l[u].forEach(((e,t)=>{l[u+1]&&e===l[u+1][t]||p.push(e)})),p.forEach((e=>{const t=o.nodeAt(e),r=i+e+(t?t.nodeSize:0)-1,s=document.createElement("div");s.className="row-resize-handle",n.push(d.Decoration.widget(r,s))})),d.DecorationSet.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}});return e}class kn{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t,n=e.getMeta(en);if(n&&null!=n.setHandle)return new kn(n.setHandle,null);if(n&&void 0!==n.setDragging)return new kn(this.activeHandle,n.setDragging);if(this.activeHandle>-1){let n=e.mapping.map(this.activeHandle,-1);"row"===(r=e.doc.resolve(n)).parent.type.spec.tableRole&&r.nodeAfter||(n=null),t=new kn(n,this.dragging)}var r;return t||this}}function Mn(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(en,{setHandle:t}),e.dispatch(n)}const xn=(e,t,n,r,o)=>{const s=o.resolve(e),i=o.resolve(t),a=r.type.name;let l,c;return!s.nodeBefore&&(l=s.node(s.depth),c=s.node(s.depth-1),l&&c&&c.firstChild===l&&c.type.name===a)?n+r.content.size<=t:!i.nodeAfter&&(l=i.node(i.depth),c=i.node(i.depth-1),l&&c&&c.lastChild===l&&c.type.name===a)?e<=n:e<=n&&n+r.content.size<=t},Sn={listItem:"list_item",resetValues:{"font-size":"","font-family":"",color:""}};const On=/^table$/,Cn=/^table_row$/,An=/^table_cell|table_header$/,Tn=(e,t)=>{const n=e.$head;for(let e=n.depth;e>0;e--){const r=n.node(e);if(t.test(r.type.name))return{pos:n.before(e),node:r}}return null},En=(e,t)=>{if(!e)return-1;const n=a.TableMap.get(e.node),r=Tn(t,An),o=n.map.indexOf(r.pos-e.pos-1);let s=-1;return-1!==o&&(s=o%n.width),s},Nn=(e,t,n)=>{const r=En(t,e.selection),o=ot(t.node.attrs[m]);o.insertBefore(o.ownerDocument.createElement("col"),o.children[r+n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[m]:o.outerHTML})};Object.defineProperty(e,"CellSelection",{enumerable:!0,get:function(){return a.CellSelection}}),Object.defineProperty(e,"TableMap",{enumerable:!0,get:function(){return a.TableMap}}),Object.defineProperty(e,"addColSpan",{enumerable:!0,get:function(){return a.addColSpan}}),Object.defineProperty(e,"addColumn",{enumerable:!0,get:function(){return a.addColumn}}),Object.defineProperty(e,"addRow",{enumerable:!0,get:function(){return a.addRow}}),Object.defineProperty(e,"cellAround",{enumerable:!0,get:function(){return a.cellAround}}),Object.defineProperty(e,"colCount",{enumerable:!0,get:function(){return a.colCount}}),Object.defineProperty(e,"columnIsHeader",{enumerable:!0,get:function(){return a.columnIsHeader}}),Object.defineProperty(e,"columnResizing",{enumerable:!0,get:function(){return a.columnResizing}}),Object.defineProperty(e,"columnResizingPluginKey",{enumerable:!0,get:function(){return a.columnResizingPluginKey}}),Object.defineProperty(e,"deleteRow",{enumerable:!0,get:function(){return a.deleteRow}}),Object.defineProperty(e,"deleteTable",{enumerable:!0,get:function(){return a.deleteTable}}),Object.defineProperty(e,"findCell",{enumerable:!0,get:function(){return a.findCell}}),Object.defineProperty(e,"fixTables",{enumerable:!0,get:function(){return a.fixTables}}),Object.defineProperty(e,"fixTablesKey",{enumerable:!0,get:function(){return a.fixTablesKey}}),Object.defineProperty(e,"goToNextCell",{enumerable:!0,get:function(){return a.goToNextCell}}),Object.defineProperty(e,"inSameTable",{enumerable:!0,get:function(){return a.inSameTable}}),Object.defineProperty(e,"isInTable",{enumerable:!0,get:function(){return a.isInTable}}),Object.defineProperty(e,"mergeCells",{enumerable:!0,get:function(){return a.mergeCells}}),Object.defineProperty(e,"moveCellForward",{enumerable:!0,get:function(){return a.moveCellForward}}),Object.defineProperty(e,"nextCell",{enumerable:!0,get:function(){return a.nextCell}}),Object.defineProperty(e,"pmAddColumnAfter",{enumerable:!0,get:function(){return a.addColumnAfter}}),Object.defineProperty(e,"pmAddColumnBefore",{enumerable:!0,get:function(){return a.addColumnBefore}}),Object.defineProperty(e,"pmAddRowAfter",{enumerable:!0,get:function(){return a.addRowAfter}}),Object.defineProperty(e,"pmAddRowBefore",{enumerable:!0,get:function(){return a.addRowBefore}}),Object.defineProperty(e,"pmDeleteColumn",{enumerable:!0,get:function(){return a.deleteColumn}}),Object.defineProperty(e,"removeColSpan",{enumerable:!0,get:function(){return a.removeColSpan}}),Object.defineProperty(e,"rowIsHeader",{enumerable:!0,get:function(){return a.rowIsHeader}}),Object.defineProperty(e,"selectedRect",{enumerable:!0,get:function(){return a.selectedRect}}),Object.defineProperty(e,"selectionCell",{enumerable:!0,get:function(){return a.selectionCell}}),Object.defineProperty(e,"setCellAttr",{enumerable:!0,get:function(){return a.setCellAttr}}),Object.defineProperty(e,"splitCell",{enumerable:!0,get:function(){return a.splitCell}}),Object.defineProperty(e,"splitCellWithType",{enumerable:!0,get:function(){return a.splitCellWithType}}),Object.defineProperty(e,"tableEditing",{enumerable:!0,get:function(){return a.tableEditing}}),Object.defineProperty(e,"tableEditingKey",{enumerable:!0,get:function(){return a.tableEditingKey}}),Object.defineProperty(e,"tableNodeTypes",{enumerable:!0,get:function(){return a.tableNodeTypes}}),Object.defineProperty(e,"tableNodes",{enumerable:!0,get:function(){return a.tableNodes}}),Object.defineProperty(e,"toggleHeader",{enumerable:!0,get:function(){return a.toggleHeader}}),Object.defineProperty(e,"toggleHeaderCell",{enumerable:!0,get:function(){return a.toggleHeaderCell}}),Object.defineProperty(e,"toggleHeaderColumn",{enumerable:!0,get:function(){return a.toggleHeaderColumn}}),Object.defineProperty(e,"toggleHeaderRow",{enumerable:!0,get:function(){return a.toggleHeaderRow}}),Object.defineProperty(e,"updateColumnsOnResize",{enumerable:!0,get:function(){return a.updateColumnsOnResize}}),e.activeNode=e=>({tag:ge(e)||""}),e.addColumnAfter=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,On);return n.node.attrs[m]?(Nn(e,n,1),t(e)):t(e)});return a.addColumnAfter(e,n)},e.addColumnBefore=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,On);return n.node.attrs[m]?(Nn(e,n,-1),t(e)):t(e)});return a.addColumnBefore(e,n)},e.addRowAfter=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,Cn);if(n&&n.node.attrs[f]){const t=n.pos+n.node.nodeSize;e.setNodeMarkup(t,void 0,{[f]:n.node.attrs[f]})}return t(e)});return a.addRowAfter(e,n)},e.addRowBefore=(e,t)=>{const n=t&&(e=>{const n=Tn(e.selection,Cn),r=Tn(e.selection,On);if(n&&r&&n.node.attrs[f]){let t=0;for(let e=0;e<r.node.nodeSize;e++)if(r.node.child(e).eq(n.node)){t=e;break}const o=r.node.child(t-1),s=n.pos-o.nodeSize;e.setNodeMarkup(s,void 0,{[f]:n.node.attrs[f]})}return t(e)});return a.addRowBefore(e,n)},e.alignBlocks=(e,t)=>(n,r)=>{const o=ue(n),s=n.tr;s.setMeta("commandName",t),o.forEach((t=>{if(t.type.isTextblock){const n=e.find((e=>e.node===t.type.name));if(n){const e=fe(t,n.style);de(s,t,t.type,e)}}}));const i=s.docChanged;return i&&r(s.scrollIntoView()),i},e.alignCenterRules=je,e.alignJustifyRules=Re,e.alignLeftRules=Le,e.alignRemoveRules=Be,e.alignRightRules=ze,e.applyInlineStyle=(e,t)=>(n,r)=>{const o=n.schema.marks.style,s={style:e.style,value:/^.+$/,newValue:e.value},i=n.tr;t&&i.setMeta("commandName",t),i.setMeta("args",e);const{empty:a,$cursor:l,ranges:c}=n.selection;if(a&&!l||!o||!J(n.doc,c,o))return!1;if(l){const e=n.storedMarks||l.marks(),t=o.isInSet(e)?e.find((e=>"style"===e.type.name)):null,a={style:null};if(t&&t.attrs.style){const e=v(t.attrs.style,s);e.changed&&e.style&&(a.style=e.style)}else s.newValue&&(a.style=`${[s.style]}: ${s.newValue};`);const c=t?{...t.attrs,...a}:a;return Object.keys(c).some((e=>null!==c[e]))?r(i.addStoredMark(o.create(c))):r(i.removeStoredMark(o)),!0}return ae(o,s)(n,r,i)},e.applyLink=({mark:e,attrs:t},r="link")=>(o,s)=>{const i=o.schema.marks,a=o.tr;r&&(a.setMeta("commandName",r),a.setMeta("args",t));let l=!1;const c=()=>l=!0;if(((e,t)=>{const n=oe(e,t);return 1===n.length&&n[0]?n[0]:null})(o,i[e]))((e,t)=>(n,r)=>{const{$cursor:o,from:s,to:i}=n.selection,a=n.schema.marks[e.mark];if(o){const n=o.parent,s=o.index(),i=n.child(s).marks.find((e=>e.type===a)),l=n.childCount;let c,d,u=o.pos-o.textOffset,p=n.child(s).nodeSize;for(c=s-1;c>=0&&i.isInSet(n.child(c).marks);)d=n.child(c).nodeSize,p+=d,u-=d,c-=1;for(c=s+1;c<l&&i.isInSet(n.child(c).marks);)p+=n.child(c).nodeSize,c+=1;t.removeMark(u,u+p,a),t.addMark(u,u+p,a.create(e.attrs)),r(t)}else t.doc.nodesBetween(s,i,((n,o)=>{n.isInline&&a.isInSet(n.marks)&&(t.removeMark(o,o+n.nodeSize,a),t.addMark(o,o+n.nodeSize,a.create(e.attrs)),r(t))}))})({mark:e,attrs:t},a)(o,c);else{let r=o;ne(o,{mark:e})&&(ce({mark:e,attrs:t},a)(o,c),r=n.EditorState.create({doc:a.doc,selection:a.selection})),l?Q(i[e],t,a)(r,c):le({mark:e},a,t)(r,c)}return l&&s(a),l},e.blockNodes=ue,e.blockquote=(e,t)=>i.wrapIn(e.schema.nodes.blockquote)(e,t),e.bold=at,e.buildKeymap=(e,t)=>{const n={},r=t&&t.applyToWord||!1;if(n["Mod-z"]=l.undo,n["Shift-Mod-z"]=l.redo,n.Backspace=i.chainCommands(c.undoInputRule,i.deleteSelection,i.joinBackward,i.selectNodeBackward),n.Enter=i.chainCommands(i.newlineInCode,i.createParagraphNear,i.liftEmptyBlock,i.splitBlockKeepMarks),dt||(n["Mod-y"]=l.redo),e.marks.strong&&(n["Mod-b"]=D(le,{...at,applyToWord:r})),e.marks.em&&(n["Mod-i"]=D(le,{...lt,applyToWord:r})),e.marks.u&&(n["Mod-u"]=D(le,{...ct,applyToWord:r})),e.nodes.hard_break){const t=e.nodes.hard_break,r=i.chainCommands(i.exitCode,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n["Shift-Enter"]=r}return n},e.buildListKeymap=e=>{const t={};var n;return e.nodes.list_item&&(t.Enter=(n=e.nodes.list_item,(e,t)=>s.splitListItem(n)(e,(n=>{const r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)})))),t},e.canBeIndented=Ae,e.canIndentAsListItem=Oe,e.canInsert=(e,t)=>{const n=e.selection.$from;for(let e=n.depth;e>=0;e--){const r=n.index(e);if(n.node(e).canReplaceWith(r,r,t))return!0}return!1},e.canOutdentAsListItem=Ce,e.caretColor=function(){return new n.Plugin({key:Gt,props:{decorations:e=>{const{doc:t,selection:n,storedMarks:r}=e;if(!n.empty||!r)return d.DecorationSet.empty;const o=re((r||[]).find((e=>"style"===e.type.name)),{name:"color",value:/^.+$/});if(!o)return d.DecorationSet.empty;const s=n.$anchor.parent,i=[];return t.descendants(((e,t)=>{e.eq(s)&&i.push(d.Decoration.node(t,t+e.nodeSize,{style:"caret-color: "+o}))})),d.DecorationSet.create(t,i)}}})},e.caretColorKey=Gt,e.changeTextBlock=de,e.cleanFormatting=(e={blocksInSelection:!0})=>(t,n)=>{const r=t.tr,{blocksInSelection:o,blockNodeType:s,exceptMarks:i}=e,a=(i||[t.schema.marks.link]).filter(Boolean);te(r,{except:a}),pe(r,{blocksInSelection:o,blockNodeType:s});const l=r.docChanged;return l&&n&&n(r),l},e.cleanMarks=te,e.cleanTextBlockFormatting=pe,e.convertMsLists=wt,e.createTable=(e,t,n)=>{const{table:r,table_row:o,table_cell:s}=e,i=[];let a;for(let e=0;e<t+1;e++){a=[];for(let e=0;e<n+1;e++)a.push(s.createAndFill());i.push(o.createAndFill(void 0,a))}return r.createAndFill(void 0,i)},e.cspFix=()=>new n.Plugin({key:new n.PluginKey("csp-fix"),props:{nodeViews:{paragraph:(e,t)=>new jt(e,t,"p"),div:(e,t)=>new jt(e,t,"div"),table_wrapper:(e,t)=>new jt(e,t,"div"),table_caption_external:(e,t)=>new jt(e,t,"div"),table:(e,t)=>new jt(e,t,"table"),table_row:(e,t)=>new jt(e,t,"tr"),table_cell:(e,t)=>new jt(e,t,"td"),table_header:(e,t)=>new jt(e,t,"th"),image:(e,t)=>new jt(e,t,"img",!0)},markViews:{style:(e,t)=>new Rt(e,t)}}}),e.deleteColumn=(e,t)=>{const n=Tn(e.selection,On),r=n&&n.node.attrs[m],o=En(n,e.selection),s=t&&(e=>{if(!r)return t(e);const s=e.doc.nodeAt(n.pos);return((e,t,n)=>{const r=ot(t.node.attrs[m]);r.removeChild(r.children[n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[m]:r.outerHTML})})(e,{node:s,pos:n.pos},o),t(e)});return a.deleteColumn(e,s)},e.domToPmDoc=U,e.expandSelection=N,e.expandToWordWrap=D,e.find=(e,t)=>{const{backward:n,matchCyclic:r,...o}=t,s=n?()=>!1:e=>e.length>0,{doc:i,selection:a}=e;let l=[];return n?(l=Nt(i,o,0,a.from,s),!l.length&&r&&(l=Nt(i,o,a.from,i.content.size,s))):(l=Nt(i,o,a.to,i.content.size,s),!l.length&&r&&(l=Nt(i,o,0,a.to,s))),l.length?l[l.length-1]:null},e.findAll=Dt,e.findAt=Nt,e.formatBlockElements=(e,t)=>(n,r)=>{const o=ue(n),s=n.schema.nodes,i=n.tr;i.setMeta("commandName",t),i.setMeta("args",{value:e}),o.forEach((t=>{if(t.type.isTextblock)if("p"===e)de(i,t,s.paragraph,t.attrs);else if(/^h[1-6]$/i.test(e)){const n=parseInt(e.substr(1),10);de(i,t,s.heading,{...t.attrs,level:n})}else"blockquote"===e&&de(i,t,s.blockquote,t.attrs)}));const a=i.docChanged;return a&&r(i.scrollIntoView()),a},e.fragmentToHtml=X,e.getActiveMarks=(e,t)=>{const n=oe(e,t),r=n.filter((e=>Boolean(e)));return{hasNodesWithoutMarks:n.length!==r.length,marks:r}},e.getBlockFormats=he,e.getHtml=e=>{const t=G(e.doc);return X(t)},e.getInlineStyles=(e,t)=>{const n=e.schema.marks.style;return(n?oe(e,n):[]).map((e=>re(e,t))).filter((e=>null!==e))},e.getMark=(e,t)=>{const n=oe(e,t),r=n.filter((e=>Boolean(e)));return n.length===r.length?n[0]:void 0},e.getNodeFromSelection=e=>{if(e.selection instanceof n.NodeSelection)return e.selection.node},e.getSelectionText=T,e.hasMark=ne,e.hasNode=me,e.hasSameMarkup=(e,n,r,o)=>{const s=t.Fragment.from(Z(e,r,o)),i=t.Fragment.from(Z(n,r,o));return s.eq(i)},e.htmlToFragment=Y,e.imageResizeKey=qt,e.imageResizing=(e={node:"image",lockRatio:!0})=>new n.Plugin({key:qt,view:t=>({resize(){qt.getState(t.state).rect&&t.dispatch(t.state.tr.setMeta("resize",!0))},get window(){return t.dom.ownerDocument&&t.dom.ownerDocument.defaultView},attachResize(){const e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize(){const e=this.window;e&&e.removeEventListener("resize",this.resize)},update(t,r){const o=t.state,s=o.selection,i=o.schema.nodes[e.node],a=qt.getState(o),l=a.rect;if(s instanceof n.NodeSelection&&i===s.node.type){const e=t.nodeDOM(s.from),n={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight};if(!r.selection.eq(s)||l&&(l.width!==n.width||l.height!==n.height||l.top!==n.top||l.left!==n.left)){const e=o.tr;e.setMeta(qt,{rect:n,nodePosition:s.from}),t.dispatch(e),this.attachResize()}}else l&&(a.rect=null,a.nodePosition=-1)},destroy(){this.removeResize()}}),state:{init:()=>new Yt("",null,null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(t,n)=>Xt(t,n,e)},decorations(t){const r=t.selection,o=t.schema.nodes[e.node],s=qt.getState(t).rect;if(s&&r instanceof n.NodeSelection&&o===r.node.type){const e=document.createElement("div");e.className="k-editor-resize-handles-wrapper",e.style.width=s.width+"px",e.style.height=s.height+"px",e.style.top=s.top+"px",e.style.left=s.left+"px";for(let t=0;t<Ft.length;t++){const n=document.createElement("div");n.className=y+" "+Ft[t],n.setAttribute(w,Ft[t]),e.appendChild(n)}return d.DecorationSet.create(t.doc,[d.Decoration.widget(t.selection.from+1,e)])}return d.DecorationSet.empty}}}),e.indent=(e,t)=>{const n=e.schema.nodes[ve.listsTypes.listItem],r=Ae(e,ve);Oe(e,n)?s.sinkListItem(n)(e,t):r&&xe(ve.nodes)(e,t)},e.indentBlocks=xe,e.indentHtml=e=>e.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/gi,"</$1>\n").replace(/<(ul|ol)([^>]*)><li/gi,"<$1$2>\n<li").replace(/<br \/>/gi,"<br />\n").replace(/\n$/,""),e.indentRules=ve,e.insertImage=e=>(t,n)=>{const{image:r}=t.schema.nodes,o=r.createAndFill(e);A(o)(t,(t=>n(t.setMeta("commandName","insertImage").setMeta("args",e))))},e.insertNode=A,e.insertText=e=>(t,n)=>{n(t.tr.insertText(e.text,e.from,e.to))},e.isAligned=(e,t)=>{const n=ue(e);let r=!1;return n.forEach((e=>{if(!r&&e.type.isTextblock&&e.attrs.style){const n=t.find((t=>t.node===e.type.name));n&&(r=n.style.every((t=>!!t.value&&new RegExp(`${t.name}:\\s?${t.value}`,"i").test(e.attrs.style))))}})),r},e.isIndented=Se,e.italic=lt,e.liftBlockquote=Me,e.link={mark:"link"},e.listMarkersStyles=function(e=Sn){return new n.Plugin({key:new n.PluginKey("list-markers-styles"),appendTransaction:(t,n,r)=>{const s=t.slice().pop(),i=s.getMeta("commandName");let a;return"FontSize"===i||"FontName"===i||"ForeColor"===i?a=((e,t,n)=>{const{tr:r,doc:o,selection:{from:s,to:i}}=t,a=e.getMeta("args");return o.nodesBetween(s,i,((e,t)=>{e.type.name===n.listItem&&xn(s,i,t,e,o)&&r.setNodeMarkup(t,null,{...e.attrs,style:P(e.attrs.style,a.style,a.value)})})),r.docChanged?r:void 0})(s,r,e):"CleanFormatting"===i&&(a=((e,t,n)=>{const r=Object.keys(n.resetValues),{tr:s,doc:i,selection:{from:a,to:l}}=t;return i.nodesBetween(a,l,((e,t)=>{if(e.type.name===n.listItem&&xn(a,l,t,e,i)){let n=e.attrs;const o=$(e.attrs.style);r.forEach((e=>{o[e]&&(n={...n,style:P(n.style,e,"")})})),n!==e.attrs&&s.setNodeMarkup(t,null,n)}})),e.steps.forEach((e=>{if(e instanceof o.RemoveMarkStep){const t=e.mark;if("style"===t.type.name&&t.attrs.style){const[r]=t.attrs.style.split(/\s*:\s*/),o=O(s.doc.resolve(e.from),(e=>e.type.name===n.listItem));if(o&&$(o.node.attrs.style)[r]&&n.resetValues[r]){const o=t.type.create({style:`${r}: ${n.resetValues[r]};`});s.addMark(e.from,e.to,o)}}}})),s.docChanged?s:void 0})(s,r,e)),a&&a.setMeta("addToHistory",!0),a}})},e.listStyle=Pe,e.marks=Qe,e.nodes=it,e.outdent=(e,t)=>{const n=e.schema.nodes,r=n[ke.listsTypes.listItem],o=Ae(e,ke);me(e,n.blockquote)?Me(e,t):Ce(e,ke)?s.liftListItem(r)(e,t):o&&xe(ke.nodes)(e,t)},e.outdentRules=ke,e.parentBlockFormat=ge,e.parentNode=O,e.parseContent=Z,e.pasteCleanup=(e,t)=>{let n=e;if(t.convertMsLists&&(n=wt(n)),t.stripTags&&(n=vt(n,t.stripTags)),t.attributes){const e=Y(n);Array.from(e.querySelectorAll("*")).forEach((e=>((e,t)=>{if(e.nodeType===Node.ELEMENT_NODE){for(let n=e.attributes.length-1;n>=0;n--){const r=e.attributes[n];t[r.name]?t[r.name](r):t["*"]&&t["*"](r)}"SPAN"===e.nodeName&&0===e.attributes.length&&(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}})(e)}})(e,t.attributes))),n=X(e)}return n},e.placeholder=function(e){const t={class:"k-placeholder","data-placeholder":e};return new n.Plugin({key:new n.PluginKey("placeholder"),props:{decorations:e=>{const{doc:n}=e,r=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&r.inlineContent&&0===r.childCount))return d.DecorationSet.empty;const o=[];return n.descendants(((e,n)=>{o.push(d.Decoration.node(n,n+e.nodeSize,t))})),d.DecorationSet.create(n,o)}}})},e.pmDocToFragment=G,e.removeAllMarks=({except:e=[]}={})=>(t,n)=>{const r=t.tr;var o;te(r,{except:(o=e,o instanceof Array?o:[o])}),r.docChanged&&n(r)},e.removeAttribute=kt,e.removeComments=e=>e.replace(/<!--[\s\S]+?-->/g,""),e.removeLink=ce,e.removeTag=vt,e.replace=(e,t,r)=>{const{from:o,to:s}=e;return r.insertText(t,o,s).setSelection(n.TextSelection.create(r.doc,o,o+t.length)),r},e.replaceAll=(e,t,n)=>{const r=Dt(e.doc,n);if(0===r.length)return null;const o=e.tr;for(let e=r.length-1;e>=0;e--)o.insertText(t,r[e].from,r[e].to);return o},e.replaceImageSourcesFromRtf=(e,t)=>{const n=e.match(xt);if(!n||-1===t.types.indexOf(Et))return e;const r=t.getData(Et),o=[],s=r.match(Ot);if(!r||!s)return e;for(const e of s){const t=Tt.exec(e);if(t){const n=e.replace(St,"").replace(Ct,"");o.push(`data:image/${t[1]};base64,${Mt(n)}`)}}return n.length!==o.length?e:e.replace(xt,(e=>{const t=o.shift()||"";return e.replace(At,t)}))},e.sanitize=e=>e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/,"$1")).replace(/<\/?[ovw]:[^>]*?>/gi,"")).replace(/<\\?\??xml[^>]*>/gi,"")).replace(/<(?:link|meta) [^>]+?>/gi,"")).replace(/<style[^>]*?>\s*<\/style>/gi,"")).replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,""),e.sanitizeClassAttr=e=>{/^Mso/.test(e.value)&&kt(e)},e.sanitizeStyleAttr=e=>{const t=$(e.value),n=e.ownerElement.style;let r="";Object.keys(t).forEach((e=>{void 0!==n[e]&&(r+=`${e}: ${t[e]}; `)})),r=r.trim(),r?e.value=r:kt(e)},e.selectedLineTextOnly=e=>{let t="",n=!1;const{selection:r,doc:o}=e,{$from:s,$to:i,from:a,to:l}=r;return s.sameParent(i)&&(o.nodesBetween(a,l,(e=>{n=n||e.isLeaf&&!e.isText})),n||(t=T(e))),t},e.selectionMarks=oe,e.setHtml=(e,t="setHTML",r={preserveWhitespace:"full"})=>(o,s)=>s(o.tr.setSelection(new n.AllSelection(o.doc)).replaceSelectionWith(Z(e,o.schema,r)).setMeta("commandName",t)),e.spacesFix=()=>new n.Plugin({key:new n.PluginKey("spaces-fix"),props:{decorations:e=>{const t=[],n=e.doc;let r,o,s,i;return n.nodesBetween(0,n.content.size,((e,n,a)=>{if(e.type.isText&&(e=>Lt.test(e&&e.attrs&&e.attrs.style||""))(a))for(o=It.exec(e.text||"");null!==o;){if(r=n+o.index,s=o[0].length,o.index+s<o.input.length)for(i=0;i<=s-1;i+=2)t.push(d.Decoration.inline(r+i,r+i+1,{style:"white-space: normal"}));o=It.exec(e.text||"")}})),d.DecorationSet.create(n,t)}}}),e.strikethrough={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},e.subscript={mark:"sub"},e.superscript={mark:"sup"},e.tableColumnResizeKey=Qt,e.tableResizeKey=Jt,e.tableResizing=()=>[bn(),ln(),vn()],e.tableRowResizeKey=en,e.textHighlight=function(e=Bt){return new n.Plugin({key:e,state:{init:()=>null,apply(e){return e.getMeta(this.spec.key)}},props:{decorations(e){const t=(this.spec.key.getState(e)||[]).map((e=>d.Decoration.inline(e.from,e.to,e.attrs)));return d.DecorationSet.create(e.doc,t)}}})},e.textHighlightKey=Bt,e.toggleInlineFormat=le,e.toggleList=He,e.toggleOrderedList=function(e,t,n){return He(e,t,n,{listType:be.listType,...be.types})},e.toggleUnorderedList=function(e,t,n){return He(e,t,n,{listType:we.listType,...we.types})},e.trimWhitespace=(e,t=R)=>{const n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")},e.underline=ct,Object.keys(t).forEach((function(n){"default"===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.keys(o).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})),Object.keys(s).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})),Object.keys(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return i[t]}})})),Object.keys(l).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return l[t]}})})),Object.keys(c).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})})),Object.keys(d).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return d[t]}})})),Object.keys(u).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return u[t]}})})),Object.keys(p).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return p[t]}})})),Object.keys(h).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return h[t]}})}))}));
|
package/dist/es/main.js
CHANGED
|
@@ -10,7 +10,7 @@ export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selection
|
|
|
10
10
|
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent } from './indent.js';
|
|
11
11
|
export { listStyle, toggleList, toggleOrderedList, toggleUnorderedList } from './lists.js';
|
|
12
12
|
export { blockquote, liftBlockquote } from './blockquote.js';
|
|
13
|
-
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, selectedLineTextOnly } from './utils.js';
|
|
13
|
+
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, selectedLineTextOnly } from './utils.js';
|
|
14
14
|
export { alignCenterRules, alignJustifyRules, alignLeftRules, alignRemoveRules, alignRightRules } from './config/align-rules.js';
|
|
15
15
|
export { indentRules, outdentRules } from './config/indent-rules.js';
|
|
16
16
|
export { marks, nodes } from './config/schema.js';
|
package/dist/es2015/main.js
CHANGED
|
@@ -10,7 +10,7 @@ export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selection
|
|
|
10
10
|
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent } from './indent.js';
|
|
11
11
|
export { listStyle, toggleList, toggleOrderedList, toggleUnorderedList } from './lists.js';
|
|
12
12
|
export { blockquote, liftBlockquote } from './blockquote.js';
|
|
13
|
-
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, selectedLineTextOnly } from './utils.js';
|
|
13
|
+
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, selectedLineTextOnly } from './utils.js';
|
|
14
14
|
export { alignCenterRules, alignJustifyRules, alignLeftRules, alignRemoveRules, alignRightRules } from './config/align-rules.js';
|
|
15
15
|
export { indentRules, outdentRules } from './config/indent-rules.js';
|
|
16
16
|
export { marks, nodes } from './config/schema.js';
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -10,14 +10,14 @@ export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selection
|
|
|
10
10
|
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent } from './indent.js';
|
|
11
11
|
export { listStyle, toggleList, toggleOrderedList, toggleUnorderedList } from './lists.js';
|
|
12
12
|
export { blockquote, liftBlockquote } from './blockquote.js';
|
|
13
|
-
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, selectedLineTextOnly } from './utils.js';
|
|
13
|
+
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, selectedLineTextOnly } from './utils.js';
|
|
14
14
|
export { Command } from './types/command.js';
|
|
15
15
|
export { alignCenterRules, alignJustifyRules, alignLeftRules, alignRemoveRules, alignRightRules } from './config/align-rules.js';
|
|
16
16
|
export { indentRules, outdentRules } from './config/indent-rules.js';
|
|
17
17
|
export { PasteCleanupSettings } from './types/paste-cleanup-settings.js';
|
|
18
18
|
export { marks, nodes } from './config/schema.js';
|
|
19
19
|
export { buildKeymap, buildListKeymap } from './config/keymap.js';
|
|
20
|
-
export { bold, italic, link, strikethrough, subscript, superscript, underline } from './config/commands.js';
|
|
20
|
+
export { InlineFormatOptions, bold, italic, link, strikethrough, subscript, superscript, underline } from './config/commands.js';
|
|
21
21
|
export { pasteCleanup, removeAttribute, removeComments, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr } from './paste.js';
|
|
22
22
|
export { convertMsLists } from './listConvert.js';
|
|
23
23
|
export { SearchOptions, find, findAll, findAt, replace, replaceAll } from './find-replace.js';
|
package/dist/npm/main.js
CHANGED
|
@@ -99,6 +99,7 @@ exports.getNodeFromSelection = utils.getNodeFromSelection;
|
|
|
99
99
|
exports.getSelectionText = utils.getSelectionText;
|
|
100
100
|
exports.indentHtml = utils.indentHtml;
|
|
101
101
|
exports.insertNode = utils.insertNode;
|
|
102
|
+
exports.parentNode = utils.parentNode;
|
|
102
103
|
exports.selectedLineTextOnly = utils.selectedLineTextOnly;
|
|
103
104
|
exports.alignCenterRules = alignRules.alignCenterRules;
|
|
104
105
|
exports.alignJustifyRules = alignRules.alignJustifyRules;
|
package/dist/npm/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeType, Node } from 'prosemirror-model';
|
|
1
|
+
import { NodeType, ResolvedPos, Node } from 'prosemirror-model';
|
|
2
2
|
import { EditorState } from 'prosemirror-state';
|
|
3
3
|
import { Command } from './types/command.js';
|
|
4
4
|
|
|
@@ -6,6 +6,10 @@ import { Command } from './types/command.js';
|
|
|
6
6
|
* Determines if a given node type can be inserted at the current cursor position.
|
|
7
7
|
*/
|
|
8
8
|
declare const canInsert: (state: EditorState, nodeType: NodeType) => boolean;
|
|
9
|
+
declare function parentNode(pos: ResolvedPos, predicate: (node: Node) => boolean): {
|
|
10
|
+
node: Node;
|
|
11
|
+
depth: number;
|
|
12
|
+
} | null;
|
|
9
13
|
/**
|
|
10
14
|
* Inserts the given node at the place of current selection.
|
|
11
15
|
*/
|
|
@@ -47,4 +51,4 @@ declare const expandSelection: (state: any, dispatch: any, options: any) => {
|
|
|
47
51
|
*/
|
|
48
52
|
declare const expandToWordWrap: (command: any, options: any) => (state: any, dispatch: any) => any;
|
|
49
53
|
|
|
50
|
-
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, selectedLineTextOnly };
|
|
54
|
+
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, selectedLineTextOnly };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-editor-common",
|
|
3
3
|
"description": "Kendo UI TypeScript package exporting functions for Editor component",
|
|
4
|
-
"version": "1.11.9-develop.
|
|
4
|
+
"version": "1.11.9-develop.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Kendo UI"
|
|
7
7
|
],
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prosemirror-inputrules": "1.4.0",
|
|
33
33
|
"prosemirror-keymap": "1.2.2",
|
|
34
34
|
"prosemirror-model": "1.24.0",
|
|
35
|
-
"prosemirror-schema-list": "1.
|
|
35
|
+
"prosemirror-schema-list": "1.5.0",
|
|
36
36
|
"prosemirror-state": "1.4.3",
|
|
37
37
|
"prosemirror-tables": "1.6.1",
|
|
38
38
|
"prosemirror-transform": "1.10.2",
|