pagemaster-editor 0.3.6 → 0.3.8
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/README.md +2 -0
- package/dist/{html2canvas-DclbxxWD.js → html2canvas-eTwj5M2H.js} +1 -1
- package/dist/{index-B3VYvTi2.js → index-BwtZTr7g.js} +3 -3
- package/dist/{index.es-CAlgpoA0.js → index.es-Dyje8t3s.js} +1 -1
- package/dist/pagemaster-editor.js +1 -1
- package/dist/pagemaster-editor.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ A powerful, DOCX-style rich text editor and PDF viewer for React applications. B
|
|
|
5
5
|
[](https://www.npmjs.com/package/pagemaster-editor)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
+
**[🔥 Live Demo](https://pagemaster-demo-app.vercel.app/)**
|
|
9
|
+
|
|
8
10
|
## Features
|
|
9
11
|
|
|
10
12
|
### 📝 Advanced Document Editor
|
|
@@ -14031,7 +14031,7 @@ var Sae = ir.create({
|
|
|
14031
14031
|
},
|
|
14032
14032
|
addProseMirrorPlugins() {
|
|
14033
14033
|
var n;
|
|
14034
|
-
const e = new oi(this.name), t = ((n = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : n.name) ||
|
|
14034
|
+
const e = new oi(this.name), t = this.options.node || ((n = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : n.name) || "paragraph", r = Object.entries(this.editor.schema.nodes).map(([, i]) => i).filter((i) => (this.options.notAfter || []).concat(t).includes(i.name));
|
|
14035
14035
|
return [
|
|
14036
14036
|
new Mr({
|
|
14037
14037
|
key: e,
|
|
@@ -53882,7 +53882,7 @@ function(n) {
|
|
|
53882
53882
|
}, n.loadImageFile = n.loadFile;
|
|
53883
53883
|
}(Gt.API), function(n) {
|
|
53884
53884
|
function e() {
|
|
53885
|
-
return (dn.html2canvas ? Promise.resolve(dn.html2canvas) : import("./html2canvas-
|
|
53885
|
+
return (dn.html2canvas ? Promise.resolve(dn.html2canvas) : import("./html2canvas-eTwj5M2H.js").then((a) => a.h)).catch(function(a) {
|
|
53886
53886
|
return Promise.reject(new Error("Could not load html2canvas: " + a));
|
|
53887
53887
|
}).then(function(a) {
|
|
53888
53888
|
return a.default ? a.default : a;
|
|
@@ -54587,7 +54587,7 @@ function(n) {
|
|
|
54587
54587
|
var u = l.getContext("2d");
|
|
54588
54588
|
u.fillStyle = "#fff", u.fillRect(0, 0, l.width, l.height);
|
|
54589
54589
|
var c = { ignoreMouse: !0, ignoreAnimation: !0, ignoreDimensions: !0 }, A = this;
|
|
54590
|
-
return (dn.canvg ? Promise.resolve(dn.canvg) : import("./index.es-
|
|
54590
|
+
return (dn.canvg ? Promise.resolve(dn.canvg) : import("./index.es-Dyje8t3s.js")).catch(function(h) {
|
|
54591
54591
|
return Promise.reject(new Error("Could not load canvg: " + h));
|
|
54592
54592
|
}).then(function(h) {
|
|
54593
54593
|
return h.default ? h.default : h;
|
|
@@ -97,7 +97,7 @@ ${m}
|
|
|
97
97
|
`);x.trim()&&(e.customNestedParser?v=e.customNestedParser(x):v=t.blockTokens(x))}const b=e.createToken(p,v);l.push(b)}if(l.length!==0)return{items:l,raw:u}}function Hk(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const i=typeof t=="function"?t(r):t,[s,...o]=n.content,a=e.renderChildren([s]),l=[`${i}${a}`];return o&&o.length>0&&o.forEach(u=>{const c=e.renderChildren([u]);if(c){const d=c.split(`
|
|
98
98
|
`).map(f=>f?e.indent(f):"").join(`
|
|
99
99
|
`);l.push(d)}}),l.join(`
|
|
100
|
-
`)}function A2e(n,e,t={}){const{state:r}=e,{doc:i,tr:s}=r,o=n;i.descendants((a,l)=>{const u=s.mapping.map(l),c=s.mapping.map(l)+a.nodeSize;let d=null;if(a.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});s.removeMark(u,c,n.type),s.addMark(u,c,h)}}),s.docChanged&&e.view.dispatch(s)}var ro=class Ege extends Lk{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Ege(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function up(n){return new qbe({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=Sr(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let u=t.to;if(a){const c=l.search(/\S/),d=t.from+l.indexOf(a),f=d+a.length;if(Ik(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===n.type&&m!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+c,d),u=t.from+c+a.length,o.addMark(t.from+c,u,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function p2e(n={}){return new Xr({view(e){return new g2e(e,n)}})}class g2e{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,a=s.height/i.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),A=d?p.bottom:p.top;d&&f&&(A=(A+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*a;r={left:p.left,right:p.right,top:A-m,bottom:A+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let u,c;if(!l||l==document.body&&getComputedStyle(l).position=="static")u=-pageXOffset,c=-pageYOffset;else{let d=l.getBoundingClientRect(),f=d.width/l.offsetWidth,h=d.height/l.offsetHeight;u=d.left-l.scrollLeft*f,c=d.top-l.scrollTop*h}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-c)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=iz(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class $i extends vn{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return $i.valid(r)?new $i(r):vn.near(r)}content(){return kt.empty}eq(e){return e instanceof $i&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new $i(e.resolve(t.pos))}getBookmark(){return new Qk(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!m2e(e)||!v2e(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&$i.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(t>0?e.indexAfter(o)<a.childCount:e.index(o)>0){s=a.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let l=e.doc.resolve(i);if($i.valid(l))return l}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!un.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let a=e.doc.resolve(i);if($i.valid(a))return a}return null}}}$i.prototype.visible=!1,$i.findFrom=$i.findGapCursorFrom,vn.jsonID("gapcursor",$i);class Qk{constructor(e){this.pos=e}map(e){return new Qk(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $i.valid(t)?new $i(t):vn.near(t)}}function EV(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function m2e(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||EV(i.type))return!0;if(i.inlineContent)return!1}}return!0}function v2e(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||EV(i.type))return!0;if(i.inlineContent)return!1}}return!0}function y2e(){return new Xr({props:{decorations:E2e,createSelectionBetween(n,e,t){return e.pos==t.pos&&$i.valid(t)?new $i(t):null},handleClick:w2e,handleKeyDown:b2e,handleDOMEvents:{beforeinput:x2e}}})}const b2e=xk({ArrowLeft:bT("horiz",-1),ArrowRight:bT("horiz",1),ArrowUp:bT("vert",-1),ArrowDown:bT("vert",1)});function bT(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof hn){if(!s.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let u=$i.findGapCursorFrom(a,e,l);return u?(i&&i(r.tr.setSelection(new $i(u))),!0):!1}}function w2e(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!$i.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&un.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new $i(r))),!0)}function x2e(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof $i))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=ht.empty;for(let o=r.length-1;o>=0;o--)i=ht.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new kt(i,0,0));return s.setSelection(hn.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function E2e(n){if(!(n.selection instanceof $i))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Yr.create(n.doc,[js.widget(n.selection.head,e,{key:"gapcursor"})])}var wT=200,io=function(){};io.prototype.append=function(e){return e.length?(e=io.from(e),!this.length&&e||e.length<wT&&this.leafAppend(e)||this.length<wT&&e.leafPrepend(this)||this.appendInner(e)):this},io.prototype.prepend=function(e){return e.length?io.from(e).append(this):this},io.prototype.appendInner=function(e){return new C2e(this,e)},io.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?io.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},io.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},io.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},io.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i},io.from=function(e){return e instanceof io?e:e&&e.length?new CV(e):io.empty};var CV=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l<o;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,a){for(var l=s-1;l>=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=wT)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=wT)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(io);io.empty=new CV([]);var C2e=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(s,a),o)===!1||s>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(i,a),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(io);const S2e=500;class Cu{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,u=[],c=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,c.push(d);return}if(i){c.push(new dp(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],u.push(new dp(p,void 0,void 0,u.length+c.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(s)):d.selection,l=new Cu(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,t,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let c=0;c<e.steps.length;c++){let d=e.steps[c].invert(e.docs[c]),f=new dp(e.mapping.maps[c],d,t),h;(h=l&&l.merge(f))&&(f=h,c?s.pop():a=a.slice(0,a.length-1)),s.push(f),t&&(o++,t=void 0),i||(l=f)}let u=o-r.depth;return u>T2e&&(a=B2e(a,u),o-=u),new Cu(a.append(s),o)}remapping(e,t){let r=new ix;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new Cu(this.items.append(e.map(t=>new dp(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=t;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let A=e.steps[h].invert(e.docs[h]),m=f.selection&&f.selection.map(s.slice(l+1,h));m&&a++,r.push(new dp(p,A,m))}else r.push(new dp(p))},i);let u=[];for(let f=t;f<o;f++)u.push(new dp(s.maps[f]));let c=this.items.slice(0,i).append(u).append(r),d=new Cu(c,a);return d.emptyItemCount()>S2e&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(t.slice(r)),u=l&&l.getMap();if(r--,u&&t.appendMap(u,r),l){let c=o.selection&&o.selection.map(t.slice(r));c&&s++;let d=new dp(u.invert(),l,c),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new Cu(io.from(i.reverse()),s)}}Cu.empty=new Cu(io.empty,0);function B2e(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}let dp=class Cge{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Cge(t.getMap().invert(),t,this.selection)}}};class hp{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const T2e=20;function D2e(n,e,t,r){let i=t.getMeta(Hm),s;if(i)return i.historyState;t.getMeta(I2e)&&(n=new hp(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Hm))return o.getMeta(Hm).redo?new hp(n.done.addTransform(t,void 0,r,xT(e)),n.undone,SV(t.mapping.maps),n.prevTime,n.prevComposition):new hp(n.done,n.undone.addTransform(t,void 0,r,xT(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!_2e(t,n.prevRanges)),u=o?Wk(n.prevRanges,t.mapping):SV(t.mapping.maps);return new hp(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,xT(e)),Cu.empty,u,t.time,a??n.prevComposition)}else return(s=t.getMeta("rebased"))?new hp(n.done.rebased(t,s),n.undone.rebased(t,s),Wk(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new hp(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Wk(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function _2e(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function SV(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function Wk(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function F2e(n,e,t){let r=xT(e),i=Hm.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),a=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),l=new hp(t?a:s.remaining,t?s.remaining:a,null,0,-1);return s.transform.setSelection(o).setMeta(Hm,{redo:t,historyState:l})}let zk=!1,BV=null;function xT(n){let e=n.plugins;if(BV!=e){zk=!1,BV=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zk=!0;break}}return zk}const Hm=new wi("history"),I2e=new wi("closeHistory");function k2e(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Xr({key:Hm,state:{init(){return new hp(Cu.empty,Cu.empty,null,0,-1)},apply(e,t,r){return D2e(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?DV:r=="historyRedo"?_V:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function TV(n,e){return(t,r)=>{let i=Hm.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=F2e(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const DV=TV(!1,!0),_V=TV(!0,!0);yr.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new Xr({key:new wi("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit;if(i==null||i===0){n=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,a=0,l=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(a,l);return n=!0,u}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,u=a-l,c=a;return e.deleteRange(u,c),!(this.storage.characters({node:e.doc})>r)}})]}});var U2e=yr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[p2e(this.options)]}});yr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Xr({key:new wi("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return Yr.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((l,u)=>{if(l.isText)return;if(!(i>=u&&i<=u+l.nodeSize-1))return!1;o+=1});let a=0;return n.descendants((l,u)=>{if(l.isText||!(i>=u&&i<=u+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&o-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(js.node(u,u+l.nodeSize,{class:this.options.className}))}),Yr.create(n,s)}}})]}});var N2e=yr.create({name:"gapCursor",addProseMirrorPlugins(){return[y2e()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Sr(an(n,"allowGapCursor",t)))!=null?e:null}}}),O2e=yr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Xr({key:new wi("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;const s=this.editor.isEmpty;return n.descendants((o,a)=>{const l=r>=a&&r<=a+o.nodeSize,u=!o.isLeaf&&AT(o);if((l||!this.options.showOnlyCurrent)&&u){const c=[this.options.emptyNodeClass];s&&c.push(this.options.emptyEditorClass);const d=js.node(a,a+o.nodeSize,{class:c.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:a,hasAnchor:l}):this.options.placeholder});i.push(d)}return this.options.includeChildren}),Yr.create(n,i)}}})]}});yr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new Xr({key:new wi("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||aV(t.selection)||n.view.dragging?null:Yr.create(t.doc,[js.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function FV({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}var L2e=yr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new wi(this.name),t=((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new Xr({key:e,appendTransaction:(i,s,o)=>{const{doc:a,tr:l,schema:u}=o,c=e.getState(o),d=a.content.size,f=u.nodes[t];if(c)return l.insert(d,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!FV({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!FV({node:o,types:r})}}})]}}),R2e=yr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>DV(n,e),redo:()=>({state:n,dispatch:e})=>_V(n,e)}},addProseMirrorPlugins(){return[k2e(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Bn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function IV(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var $k={exports:{}},Vk={};/**
|
|
100
|
+
`)}function A2e(n,e,t={}){const{state:r}=e,{doc:i,tr:s}=r,o=n;i.descendants((a,l)=>{const u=s.mapping.map(l),c=s.mapping.map(l)+a.nodeSize;let d=null;if(a.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});s.removeMark(u,c,n.type),s.addMark(u,c,h)}}),s.docChanged&&e.view.dispatch(s)}var ro=class Ege extends Lk{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Ege(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function up(n){return new qbe({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=Sr(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let u=t.to;if(a){const c=l.search(/\S/),d=t.from+l.indexOf(a),f=d+a.length;if(Ik(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===n.type&&m!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+c,d),u=t.from+c+a.length,o.addMark(t.from+c,u,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function p2e(n={}){return new Xr({view(e){return new g2e(e,n)}})}class g2e{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,a=s.height/i.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),A=d?p.bottom:p.top;d&&f&&(A=(A+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*a;r={left:p.left,right:p.right,top:A-m,bottom:A+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let u,c;if(!l||l==document.body&&getComputedStyle(l).position=="static")u=-pageXOffset,c=-pageYOffset;else{let d=l.getBoundingClientRect(),f=d.width/l.offsetWidth,h=d.height/l.offsetHeight;u=d.left-l.scrollLeft*f,c=d.top-l.scrollTop*h}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-c)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=iz(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class $i extends vn{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return $i.valid(r)?new $i(r):vn.near(r)}content(){return kt.empty}eq(e){return e instanceof $i&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new $i(e.resolve(t.pos))}getBookmark(){return new Qk(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!m2e(e)||!v2e(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&$i.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(t>0?e.indexAfter(o)<a.childCount:e.index(o)>0){s=a.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let l=e.doc.resolve(i);if($i.valid(l))return l}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!un.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let a=e.doc.resolve(i);if($i.valid(a))return a}return null}}}$i.prototype.visible=!1,$i.findFrom=$i.findGapCursorFrom,vn.jsonID("gapcursor",$i);class Qk{constructor(e){this.pos=e}map(e){return new Qk(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $i.valid(t)?new $i(t):vn.near(t)}}function EV(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function m2e(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||EV(i.type))return!0;if(i.inlineContent)return!1}}return!0}function v2e(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||EV(i.type))return!0;if(i.inlineContent)return!1}}return!0}function y2e(){return new Xr({props:{decorations:E2e,createSelectionBetween(n,e,t){return e.pos==t.pos&&$i.valid(t)?new $i(t):null},handleClick:w2e,handleKeyDown:b2e,handleDOMEvents:{beforeinput:x2e}}})}const b2e=xk({ArrowLeft:bT("horiz",-1),ArrowRight:bT("horiz",1),ArrowUp:bT("vert",-1),ArrowDown:bT("vert",1)});function bT(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof hn){if(!s.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let u=$i.findGapCursorFrom(a,e,l);return u?(i&&i(r.tr.setSelection(new $i(u))),!0):!1}}function w2e(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!$i.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&un.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new $i(r))),!0)}function x2e(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof $i))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=ht.empty;for(let o=r.length-1;o>=0;o--)i=ht.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new kt(i,0,0));return s.setSelection(hn.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function E2e(n){if(!(n.selection instanceof $i))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Yr.create(n.doc,[js.widget(n.selection.head,e,{key:"gapcursor"})])}var wT=200,io=function(){};io.prototype.append=function(e){return e.length?(e=io.from(e),!this.length&&e||e.length<wT&&this.leafAppend(e)||this.length<wT&&e.leafPrepend(this)||this.appendInner(e)):this},io.prototype.prepend=function(e){return e.length?io.from(e).append(this):this},io.prototype.appendInner=function(e){return new C2e(this,e)},io.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?io.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},io.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},io.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},io.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i},io.from=function(e){return e instanceof io?e:e&&e.length?new CV(e):io.empty};var CV=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l<o;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,a){for(var l=s-1;l>=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=wT)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=wT)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(io);io.empty=new CV([]);var C2e=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(s,a),o)===!1||s>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(i,a),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(io);const S2e=500;class Cu{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,u=[],c=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,c.push(d);return}if(i){c.push(new dp(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],u.push(new dp(p,void 0,void 0,u.length+c.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(s)):d.selection,l=new Cu(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,t,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let c=0;c<e.steps.length;c++){let d=e.steps[c].invert(e.docs[c]),f=new dp(e.mapping.maps[c],d,t),h;(h=l&&l.merge(f))&&(f=h,c?s.pop():a=a.slice(0,a.length-1)),s.push(f),t&&(o++,t=void 0),i||(l=f)}let u=o-r.depth;return u>T2e&&(a=B2e(a,u),o-=u),new Cu(a.append(s),o)}remapping(e,t){let r=new ix;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new Cu(this.items.append(e.map(t=>new dp(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=t;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let A=e.steps[h].invert(e.docs[h]),m=f.selection&&f.selection.map(s.slice(l+1,h));m&&a++,r.push(new dp(p,A,m))}else r.push(new dp(p))},i);let u=[];for(let f=t;f<o;f++)u.push(new dp(s.maps[f]));let c=this.items.slice(0,i).append(u).append(r),d=new Cu(c,a);return d.emptyItemCount()>S2e&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(t.slice(r)),u=l&&l.getMap();if(r--,u&&t.appendMap(u,r),l){let c=o.selection&&o.selection.map(t.slice(r));c&&s++;let d=new dp(u.invert(),l,c),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new Cu(io.from(i.reverse()),s)}}Cu.empty=new Cu(io.empty,0);function B2e(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}let dp=class Cge{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Cge(t.getMap().invert(),t,this.selection)}}};class hp{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const T2e=20;function D2e(n,e,t,r){let i=t.getMeta(Hm),s;if(i)return i.historyState;t.getMeta(I2e)&&(n=new hp(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Hm))return o.getMeta(Hm).redo?new hp(n.done.addTransform(t,void 0,r,xT(e)),n.undone,SV(t.mapping.maps),n.prevTime,n.prevComposition):new hp(n.done,n.undone.addTransform(t,void 0,r,xT(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!_2e(t,n.prevRanges)),u=o?Wk(n.prevRanges,t.mapping):SV(t.mapping.maps);return new hp(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,xT(e)),Cu.empty,u,t.time,a??n.prevComposition)}else return(s=t.getMeta("rebased"))?new hp(n.done.rebased(t,s),n.undone.rebased(t,s),Wk(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new hp(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Wk(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function _2e(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function SV(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function Wk(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function F2e(n,e,t){let r=xT(e),i=Hm.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),a=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),l=new hp(t?a:s.remaining,t?s.remaining:a,null,0,-1);return s.transform.setSelection(o).setMeta(Hm,{redo:t,historyState:l})}let zk=!1,BV=null;function xT(n){let e=n.plugins;if(BV!=e){zk=!1,BV=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zk=!0;break}}return zk}const Hm=new wi("history"),I2e=new wi("closeHistory");function k2e(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Xr({key:Hm,state:{init(){return new hp(Cu.empty,Cu.empty,null,0,-1)},apply(e,t,r){return D2e(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?DV:r=="historyRedo"?_V:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function TV(n,e){return(t,r)=>{let i=Hm.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=F2e(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const DV=TV(!1,!0),_V=TV(!0,!0);yr.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new Xr({key:new wi("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit;if(i==null||i===0){n=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,a=0,l=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(a,l);return n=!0,u}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,u=a-l,c=a;return e.deleteRange(u,c),!(this.storage.characters({node:e.doc})>r)}})]}});var U2e=yr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[p2e(this.options)]}});yr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Xr({key:new wi("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return Yr.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((l,u)=>{if(l.isText)return;if(!(i>=u&&i<=u+l.nodeSize-1))return!1;o+=1});let a=0;return n.descendants((l,u)=>{if(l.isText||!(i>=u&&i<=u+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&o-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(js.node(u,u+l.nodeSize,{class:this.options.className}))}),Yr.create(n,s)}}})]}});var N2e=yr.create({name:"gapCursor",addProseMirrorPlugins(){return[y2e()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Sr(an(n,"allowGapCursor",t)))!=null?e:null}}}),O2e=yr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Xr({key:new wi("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;const s=this.editor.isEmpty;return n.descendants((o,a)=>{const l=r>=a&&r<=a+o.nodeSize,u=!o.isLeaf&&AT(o);if((l||!this.options.showOnlyCurrent)&&u){const c=[this.options.emptyNodeClass];s&&c.push(this.options.emptyEditorClass);const d=js.node(a,a+o.nodeSize,{class:c.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:a,hasAnchor:l}):this.options.placeholder});i.push(d)}return this.options.includeChildren}),Yr.create(n,i)}}})]}});yr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new Xr({key:new wi("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||aV(t.selection)||n.view.dragging?null:Yr.create(t.doc,[js.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function FV({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}var L2e=yr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new wi(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new Xr({key:e,appendTransaction:(i,s,o)=>{const{doc:a,tr:l,schema:u}=o,c=e.getState(o),d=a.content.size,f=u.nodes[t];if(c)return l.insert(d,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!FV({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!FV({node:o,types:r})}}})]}}),R2e=yr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>DV(n,e),redo:()=>({state:n,dispatch:e})=>_V(n,e)}},addProseMirrorPlugins(){return[k2e(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Bn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function IV(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),t}var $k={exports:{}},Vk={};/**
|
|
101
101
|
* @license React
|
|
102
102
|
* use-sync-external-store-shim.production.js
|
|
103
103
|
*
|