reactjs-tiptap-editor 0.0.28 → 0.0.30
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/lib/index.d.cts +54 -529
- package/lib/index.d.ts +54 -529
- package/lib/locales-CIjswkre.cjs +1 -0
- package/lib/{locales-CReRRAlY.js → locales-D767TIQP.js} +32 -69
- package/lib/reactjs-tiptap-editor.cjs +1 -2
- package/lib/reactjs-tiptap-editor.js +50 -145
- package/lib/{tiptap-oijPpdck.js → tiptap-CK44C-2f.js} +1192 -1442
- package/lib/tiptap-Dr2jJgw-.cjs +116 -0
- package/lib/utils-DW_zDPZv.cjs +135 -0
- package/lib/{utils-B4dNn5Nv.js → utils-DrrJak96.js} +2255 -2481
- package/lib/vendor-D533qV8r.js +17535 -0
- package/lib/vendor-JmPfJfTA.cjs +17 -0
- package/package.json +3 -3
- package/lib/locales-BW5KWG4_.cjs +0 -2
- package/lib/locales-BW5KWG4_.cjs.map +0 -1
- package/lib/locales-CReRRAlY.js.map +0 -1
- package/lib/radix-BnsE5jjU.cjs +0 -2
- package/lib/radix-BnsE5jjU.cjs.map +0 -1
- package/lib/radix-DynsTgIE.js +0 -3104
- package/lib/radix-DynsTgIE.js.map +0 -1
- package/lib/reactjs-tiptap-editor.cjs.map +0 -1
- package/lib/reactjs-tiptap-editor.js.map +0 -1
- package/lib/tiptap-CMeHtctt.cjs +0 -117
- package/lib/tiptap-CMeHtctt.cjs.map +0 -1
- package/lib/tiptap-oijPpdck.js.map +0 -1
- package/lib/utils-B4dNn5Nv.js.map +0 -1
- package/lib/utils-Bvt21Jwu.cjs +0 -136
- package/lib/utils-Bvt21Jwu.cjs.map +0 -1
- package/lib/vendor-Btqs8WA3.cjs +0 -453
- package/lib/vendor-Btqs8WA3.cjs.map +0 -1
- package/lib/vendor-CCqRdwcC.js +0 -27904
- package/lib/vendor-CCqRdwcC.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactjs-tiptap-editor.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactjs-tiptap-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/lib/tiptap-CMeHtctt.cjs
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";var Re=Object.defineProperty;var He=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var et=(e,t,n)=>He(e,typeof t!="symbol"?t+"":t,n);const m=require("./vendor-Btqs8WA3.cjs"),A=require("react"),he=require("react-dom");function dt(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}class ut{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:r}=this,{view:s}=n,{tr:o}=r,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...u)=>{const d=l(...u)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a=[],l=!!t,c=t||o.tr,u=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(c),a.every(h=>h===!0)),d={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...y)=>{const g=this.buildProps(c,n),b=p(...y)(g);return a.push(b),d}])),run:u};return d}createCan(t){const{rawCommands:n,state:r}=this,s=!1,o=t||r.tr,i=this.buildProps(o,s);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,s)}}buildProps(t,n=!0){const{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a={tr:t,editor:s,view:i,state:dt({state:o,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}}class Ie{constructor(){this.callbacks={}}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),this}emit(t,...n){const r=this.callbacks[t];return r&&r.forEach(s=>s.apply(this,n)),this}off(t,n){const r=this.callbacks[t];return r&&(n?this.callbacks[t]=r.filter(s=>s!==n):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}function k(e,t,n){return e.config[t]===void 0&&e.parent?k(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?k(e.parent,t,n):null}):e.config[t]}function pt(e){const t=e.filter(s=>s.type==="extension"),n=e.filter(s=>s.type==="node"),r=e.filter(s=>s.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function fe(e){const t=[],{nodeExtensions:n,markExtensions:r}=pt(e),s=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:s},l=k(i,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([h,p])=>{t.push({type:d,name:h,attribute:{...o,...p}})})})})}),s.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},l=k(i,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,d])=>{const h={...o,...d};typeof(h==null?void 0:h.default)=="function"&&(h.default=h.default()),h!=null&&h.isRequired&&(h==null?void 0:h.default)===void 0&&delete h.default,t.push({type:i.name,name:u,attribute:h})})}),t}function I(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function O(...e){return e.filter(t=>!!t).reduce((t,n)=>{const r={...t};return Object.entries(n).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const a=o?o.split(" "):[],l=r[s]?r[s].split(" "):[],c=a.filter(u=>!l.includes(u));r[s]=[...l,...c].join(" ")}else s==="style"?r[s]=[r[s],o].join("; "):r[s]=o}),r},{})}function Ot(e,t){return t.filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>O(n,r),{})}function me(e){return typeof e=="function"}function x(e,t=void 0,...n){return me(e)?t?e.bind(t)(...n):e(...n):e}function _e(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Ne(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function Ut(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;const s=t.reduce((o,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):Ne(n.getAttribute(i.name));return a==null?o:{...o,[i.name]:a}},{});return{...r,...s}}}}function qt(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&_e(n)?!1:n!=null))}function De(e,t){var n;const r=fe(e),{nodeExtensions:s,markExtensions:o}=pt(e),i=(n=s.find(c=>k(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:t},h=e.reduce((b,w)=>{const S=k(w,"extendNodeSchema",d);return{...b,...S?S(c):{}}},{}),p=qt({...h,content:x(k(c,"content",d)),marks:x(k(c,"marks",d)),group:x(k(c,"group",d)),inline:x(k(c,"inline",d)),atom:x(k(c,"atom",d)),selectable:x(k(c,"selectable",d)),draggable:x(k(c,"draggable",d)),code:x(k(c,"code",d)),whitespace:x(k(c,"whitespace",d)),defining:x(k(c,"defining",d)),isolating:x(k(c,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var w;return[b.name,{default:(w=b==null?void 0:b.attribute)===null||w===void 0?void 0:w.default}]}))}),f=x(k(c,"parseHTML",d));f&&(p.parseDOM=f.map(b=>Ut(b,u)));const y=k(c,"renderHTML",d);y&&(p.toDOM=b=>y({node:b,HTMLAttributes:Ot(b,u)}));const g=k(c,"renderText",d);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(o.map(c=>{const u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:t},h=e.reduce((g,b)=>{const w=k(b,"extendMarkSchema",d);return{...g,...w?w(c):{}}},{}),p=qt({...h,inclusive:x(k(c,"inclusive",d)),excludes:x(k(c,"excludes",d)),group:x(k(c,"group",d)),spanning:x(k(c,"spanning",d)),code:x(k(c,"code",d)),attrs:Object.fromEntries(u.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),f=x(k(c,"parseHTML",d));f&&(p.parseDOM=f.map(g=>Ut(g,u)));const y=k(c,"renderHTML",d);return y&&(p.toDOM=g=>y({mark:g,HTMLAttributes:Ot(g,u)})),[c.name,p]}));return new m.Schema({topNode:i,nodes:a,marks:l})}function Mt(e,t){return t.nodes[e]||t.marks[e]||null}function Gt(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}const $e=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(s,o,i,a)=>{var l,c;const u=((c=(l=s.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:s,pos:o,parent:i,index:a}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),n};function $t(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class ht{constructor(t){this.find=t.find,this.handler=t.handler}}const Be=(e,t)=>{if($t(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function nt(e){var t;const{editor:n,from:r,to:s,text:o,rules:i,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((t=c.nodeBefore||c.nodeAfter)===null||t===void 0)&&t.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=$e(c)+o;return i.forEach(h=>{if(u)return;const p=Be(d,h.find);if(!p)return;const f=l.state.tr,y=dt({state:l.state,transaction:f}),g={from:r-(p[0].length-o.length),to:s},{commands:b,chain:w,can:S}=new ut({editor:n,state:y});h.handler({state:y,range:g,match:p,commands:b,chain:w,can:S})===null||!f.steps.length||(f.setMeta(a,{transform:f,from:r,to:s,text:o}),l.dispatch(f),u=!0)}),u}function je(e){const{editor:t,rules:n}=e,r=new m.Plugin({state:{init(){return null},apply(s,o){const i=s.getMeta(r);if(i)return i;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{const{from:c,text:u}=a,d=c+u.length;nt({editor:t,from:c,to:d,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,a){return nt({editor:t,from:o,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&nt({editor:t,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?nt({editor:t,from:i.pos,to:i.pos,text:`
|
|
2
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Fe(e){return typeof e=="number"}class ze{constructor(t){this.find=t.find,this.handler=t.handler}}const We=(e,t,n)=>{if($t(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=e,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function Ve(e){const{editor:t,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:a}=e,{commands:l,chain:c,can:u}=new ut({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,s,(p,f)=>{if(!p.isTextblock||p.type.spec.code)return;const y=Math.max(r,f),g=Math.min(s,f+p.content.size),b=p.textBetween(y-f,g-f,void 0,"");We(b,o.find,i).forEach(S=>{if(S.index===void 0)return;const v=y+S.index+1,E=v+S[0].length,M={from:n.tr.mapping.map(v),to:n.tr.mapping.map(E)},C=o.handler({state:n,range:M,match:S,commands:l,chain:c,can:u,pasteEvent:i,dropEvent:a});d.push(C)})}),d.every(p=>p!==null)}const Ke=e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function Ue(e){const{editor:t,rules:n}=e;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a=typeof DragEvent<"u"?new DragEvent("drop"):null;const l=({state:u,from:d,to:h,rule:p,pasteEvt:f})=>{const y=u.tr,g=dt({state:u,transaction:y});if(!(!Ve({editor:t,state:g,from:Math.max(d-1,0),to:h.b-1,rule:p,pasteEvent:f,dropEvent:a})||!y.steps.length))return a=typeof DragEvent<"u"?new DragEvent("drop"):null,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y};return n.map(u=>new m.Plugin({view(d){const h=p=>{var f;r=!((f=d.dom.parentElement)===null||f===void 0)&&f.contains(p.target)?d.dom.parentElement:null};return window.addEventListener("dragstart",h),{destroy(){window.removeEventListener("dragstart",h)}}},props:{handleDOMEvents:{drop:(d,h)=>(o=r===d.dom.parentElement,a=h,!1),paste:(d,h)=>{var p;const f=(p=h.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return i=h,s=!!(f!=null&&f.includes("data-pm-slice")),!1}}},appendTransaction:(d,h,p)=>{const f=d[0],y=f.getMeta("uiEvent")==="paste"&&!s,g=f.getMeta("uiEvent")==="drop"&&!o,b=f.getMeta("applyPasteRules"),w=!!b;if(!y&&!g&&!w)return;if(w){const{from:E,text:M}=b,C=E+M.length,L=Ke(M);return l({rule:u,state:p,from:E,to:{b:C},pasteEvt:L})}const S=h.doc.content.findDiffStart(p.doc.content),v=h.doc.content.findDiffEnd(p.doc.content);if(!(!Fe(S)||!v||S===v.b))return l({rule:u,state:p,from:S,to:v,pasteEvt:i})}}))}function qe(e){const t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}class Y{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=Y.resolve(t),this.schema=De(this.extensions,n),this.setupExtensions()}static resolve(t){const n=Y.sort(Y.flatten(t)),r=qe(n.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),n}static flatten(t){return t.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},s=k(n,"addExtensions",r);return s?[n,...this.flatten(s())]:n}).flat(10)}static sort(t){return t.sort((r,s)=>{const o=k(r,"priority")||100,i=k(s,"priority")||100;return o>i?-1:o<i?1:0})}get commands(){return this.extensions.reduce((t,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Mt(n.name,this.schema)},s=k(n,"addCommands",r);return s?{...t,...s()}:t},{})}get plugins(){const{editor:t}=this,n=Y.sort([...this.extensions].reverse()),r=[],s=[],o=n.map(i=>{const a={name:i.name,options:i.options,storage:i.storage,editor:t,type:Mt(i.name,this.schema)},l=[],c=k(i,"addKeyboardShortcuts",a);let u={};if(i.type==="mark"&&k(i,"exitable",a)&&(u.ArrowRight=()=>_.handleExit({editor:t,mark:i})),c){const y=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:t})]));u={...u,...y}}const d=m.keymap(u);l.push(d);const h=k(i,"addInputRules",a);Gt(i,t.options.enableInputRules)&&h&&r.push(...h());const p=k(i,"addPasteRules",a);Gt(i,t.options.enablePasteRules)&&p&&s.push(...p());const f=k(i,"addProseMirrorPlugins",a);if(f){const y=f();l.push(...y)}return l}).flat();return[je({editor:t,rules:r}),...Ue({editor:t,rules:s}),...o]}get attributes(){return fe(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:n}=pt(this.extensions);return Object.fromEntries(n.filter(r=>!!k(r,"addNodeView")).map(r=>{const s=this.attributes.filter(l=>l.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:t,type:I(r.name,this.schema)},i=k(r,"addNodeView",o);if(!i)return[];const a=(l,c,u,d)=>{const h=Ot(l,s);return i()({editor:t,node:l,getPos:u,decorations:d,HTMLAttributes:h,extension:r})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(t=>{var n;this.editor.extensionStorage[t.name]=t.storage;const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Mt(t.name,this.schema)};t.type==="mark"&&(!((n=x(k(t,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(t.name);const s=k(t,"onBeforeCreate",r),o=k(t,"onCreate",r),i=k(t,"onUpdate",r),a=k(t,"onSelectionUpdate",r),l=k(t,"onTransaction",r),c=k(t,"onFocus",r),u=k(t,"onBlur",r),d=k(t,"onDestroy",r);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}function Ge(e){return Object.prototype.toString.call(e).slice(8,-1)}function rt(e){return Ge(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function ft(e,t){const n={...e};return rt(e)&&rt(t)&&Object.keys(t).forEach(r=>{rt(t[r])&&rt(e[r])?n[r]=ft(e[r],t[r]):n[r]=t[r]}),n}class H{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=x(k(this,"addOptions",{name:this.name}))),this.storage=x(k(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new H(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ft(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new H({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=x(k(n,"addOptions",{name:n.name})),n.storage=x(k(n,"addStorage",{name:n.name,options:n.options})),n}}function ge(e,t,n){const{from:r,to:s}=t,{blockSeparator:o=`
|
|
3
|
-
|
|
4
|
-
`,textSerializers:i={}}=n||{};let a="";return e.nodesBetween(r,s,(l,c,u,d)=>{var h;l.isBlock&&c>r&&(a+=o);const p=i==null?void 0:i[l.type.name];if(p)return u&&(a+=p({node:l,pos:c,parent:u,index:d,range:t})),!1;l.isText&&(a+=(h=l==null?void 0:l.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,s-c))}),a}function ye(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}const Je=H.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:s}=t,{ranges:o}=s,i=Math.min(...o.map(u=>u.$from.pos)),a=Math.max(...o.map(u=>u.$to.pos)),l=ye(n);return ge(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Ye=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),Xe=(e=!1)=>({commands:t})=>t.setContent("",e),Qe=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:s}=r;return n&&s.forEach(({$from:o,$to:i})=>{e.doc.nodesBetween(o.pos,i.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=t,d=c.resolve(u.map(l)),h=c.resolve(u.map(l+a.nodeSize)),p=d.blockRange(h);if(!p)return;const f=m.liftTarget(p);if(a.type.isTextblock){const{defaultType:y}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(p.start,y)}(f||f===0)&&t.lift(p,f)})}),!0},Ze=e=>t=>e(t),tn=()=>({state:e,dispatch:t})=>m.createParagraphNear(e,t),en=(e,t)=>({editor:n,tr:r})=>{const{state:s}=n,o=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const i=r.mapping.map(t);return r.insert(i,o.content),r.setSelection(new m.TextSelection(r.doc.resolve(i-1))),!0},nn=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(t){const a=s.before(o),l=s.after(o);e.delete(a,l).scrollIntoView()}return!0}return!1},rn=e=>({tr:t,state:n,dispatch:r})=>{const s=I(e,n.schema),o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const l=o.before(i),c=o.after(i);t.delete(l,c).scrollIntoView()}return!0}return!1},sn=e=>({tr:t,dispatch:n})=>{const{from:r,to:s}=e;return n&&t.delete(r,s),!0},on=()=>({state:e,dispatch:t})=>m.deleteSelection(e,t),an=()=>({commands:e})=>e.keyboardShortcut("Enter"),ln=()=>({state:e,dispatch:t})=>m.exitCode(e,t);function lt(e,t,n={strict:!0}){const r=Object.keys(t);return r.length?r.every(s=>n.strict?t[s]===e[s]:$t(t[s])?t[s].test(e[s]):t[s]===e[s]):!0}function Lt(e,t,n={}){return e.find(r=>r.type===t&<(r.attrs,n))}function cn(e,t,n={}){return!!Lt(e,t,n)}function mt(e,t,n={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&r.offset!==0&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;const s=Lt([...r.node.marks],t,n);if(!s)return;let o=r.index,i=e.start()+r.offset,a=o+1,l=i+r.node.nodeSize;for(Lt([...r.node.marks],t,n);o>0&&s.isInSet(e.parent.child(o-1).marks);)o-=1,i-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&cn([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:i,to:l}}function z(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const dn=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const o=z(e,r.schema),{doc:i,selection:a}=n,{$from:l,from:c,to:u}=a;if(s){const d=mt(l,o,t);if(d&&d.from<=c&&d.to>=u){const h=m.TextSelection.create(i,d.from,d.to);n.setSelection(h)}}return!0},un=e=>t=>{const n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function Bt(e){return e instanceof m.TextSelection}function $(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function be(e,t=null){if(!t)return null;const n=m.Selection.atStart(e),r=m.Selection.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;const s=n.from,o=r.to;return t==="all"?m.TextSelection.create(e,$(0,s,o),$(e.content.size,s,o)):m.TextSelection.create(e,$(t,s,o),$(t,s,o))}function gt(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const pn=(e=null,t={})=>({editor:n,view:r,tr:s,dispatch:o})=>{t={scrollIntoView:!0,...t};const i=()=>{gt()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&e===null||e===!1)return!0;if(o&&e===null&&!Bt(n.state.selection))return i(),!0;const a=be(s.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},hn=(e,t)=>n=>e.every((r,s)=>t(r,{...n,index:s})),fn=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),ve=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&ve(r)}return e};function st(e){const t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return ve(n)}function ct(e,t,n){n={slice:!0,parseOptions:{},...n};const r=typeof e=="object"&&e!==null,s=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return m.Fragment.fromArray(e.map(a=>t.nodeFromJSON(a)));const i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",o),ct("",t,n)}if(s){if(n.errorOnInvalidContent){let i=!1,a="";const l=new m.Schema({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?m.DOMParser.fromSchema(l).parseSlice(st(e),n.parseOptions):m.DOMParser.fromSchema(l).parse(st(e),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=m.DOMParser.fromSchema(t);return n.slice?o.parseSlice(st(e),n.parseOptions).content:o.parse(st(e),n.parseOptions)}return ct("",t,n)}function mn(e,t,n){const r=e.steps.length-1;if(r<t)return;const s=e.steps[r];if(!(s instanceof m.ReplaceStep||s instanceof m.ReplaceAroundStep))return;const o=e.mapping.maps[r];let i=0;o.forEach((a,l,c,u)=>{i===0&&(i=u)}),e.setSelection(m.Selection.near(e.doc.resolve(i),n))}const gn=e=>!("type"in e),yn=(e,t,n)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;try{a=ct(t,o.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:o.options.enableContentCheck})}catch(f){return o.emit("contentError",{editor:o,error:f,disableCollaboration:()=>{console.error("[tiptap error]: Unable to disable collaboration at this point in time")}}),!1}let{from:l,to:c}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((gn(a)?a:[a]).forEach(f=>{f.check(),u=u?f.isText&&f.marks.length===0:!1,d=d?f.isBlock:!1}),l===c&&d){const{parent:f}=r.doc.resolve(l);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(l-=1,c+=1)}let p;u?(Array.isArray(t)?p=t.map(f=>f.text||"").join(""):typeof t=="object"&&t&&t.text?p=t.text:p=t,r.insertText(p,l,c)):(p=a,r.replaceWith(l,c,p)),n.updateSelection&&mn(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:p}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:p})}return!0},bn=()=>({state:e,dispatch:t})=>m.joinUp(e,t),vn=()=>({state:e,dispatch:t})=>m.joinDown(e,t),Sn=()=>({state:e,dispatch:t})=>m.joinBackward(e,t),Mn=()=>({state:e,dispatch:t})=>m.joinForward(e,t),kn=()=>({state:e,dispatch:t,tr:n})=>{try{const r=m.joinPoint(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},wn=()=>({state:e,dispatch:t,tr:n})=>{try{const r=m.joinPoint(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Tn=()=>({state:e,dispatch:t})=>m.joinTextblockBackward(e,t),En=()=>({state:e,dispatch:t})=>m.joinTextblockForward(e,t);function Se(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Cn(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let r,s,o,i;for(let a=0;a<t.length-1;a+=1){const l=t[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))gt()||Se()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const xn=e=>({editor:t,view:n,tr:r,dispatch:s})=>{const o=Cn(e).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function Z(e,t,n={}){const{from:r,to:s,empty:o}=e.selection,i=t?I(t,e.schema):null,a=[];e.doc.nodesBetween(r,s,(d,h)=>{if(d.isText)return;const p=Math.max(r,h),f=Math.min(s,h+d.nodeSize);a.push({node:d,from:p,to:f})});const l=s-r,c=a.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>lt(d.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=l}const An=(e,t={})=>({state:n,dispatch:r})=>{const s=I(e,n.schema);return Z(n,s,t)?m.lift(n,r):!1},On=()=>({state:e,dispatch:t})=>m.liftEmptyBlock(e,t),Ln=e=>({state:t,dispatch:n})=>{const r=I(e,t.schema);return m.liftListItem(r)(t,n)},Pn=()=>({state:e,dispatch:t})=>m.newlineInCode(e,t);function yt(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Jt(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,s)=>(n.includes(s)||(r[s]=e[s]),r),{})}const Rn=(e,t)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=yt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(o=I(e,r.schema)),a==="mark"&&(i=z(e,r.schema)),s&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{o&&o===c.type&&n.setNodeMarkup(u,void 0,Jt(c.attrs,t)),i&&c.marks.length&&c.marks.forEach(d=>{i===d.type&&n.addMark(u,u+c.nodeSize,i.create(Jt(d.attrs,t)))})})}),!0):!1},Hn=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),In=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),_n=()=>({state:e,dispatch:t})=>m.selectNodeBackward(e,t),Nn=()=>({state:e,dispatch:t})=>m.selectNodeForward(e,t),Dn=()=>({state:e,dispatch:t})=>m.selectParentNode(e,t),$n=()=>({state:e,dispatch:t})=>m.selectTextblockEnd(e,t),Bn=()=>({state:e,dispatch:t})=>m.selectTextblockStart(e,t);function Pt(e,t,n={},r={}){return ct(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const jn=(e,t=!1,n={},r={})=>({editor:s,tr:o,dispatch:i,commands:a})=>{var l,c;const{doc:u}=o;if(n.preserveWhitespace!=="full"){const d=Pt(e,s.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:s.options.enableContentCheck});return i&&o.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),!0}return i&&o.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:u.content.size},e,{parseOptions:n,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function tt(e,t){const n=z(t,e.schema),{from:r,to:s,empty:o}=e.selection,i=[];o?(e.storedMarks&&i.push(...e.storedMarks),i.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,s,l=>{i.push(...l.marks)});const a=i.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function Fn(e,t){const n=new m.Transform(e);return t.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function zn(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Wn(e,t){const n=[];return e.descendants((r,s)=>{t(r)&&n.push({node:r,pos:s})}),n}function Vn(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(s,o)=>{n(s)&&r.push({node:s,pos:o})}),r}function Me(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function bt(e){return t=>Me(t.$from,e)}function Kn(e,t){const n=m.DOMSerializer.fromSchema(t).serializeFragment(e),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Un(e,t){const n={from:0,to:e.content.size};return ge(e,n,t)}function qn(e,t){const n=I(t,e.schema),{from:r,to:s}=e.selection,o=[];e.doc.nodesBetween(r,s,a=>{o.push(a)});const i=o.reverse().find(a=>a.type.name===n.name);return i?{...i.attrs}:{}}function ke(e,t){const n=yt(typeof t=="string"?t:t.name,e.schema);return n==="node"?qn(e,t):n==="mark"?tt(e,t):{}}function Gn(e,t=JSON.stringify){const n={};return e.filter(r=>{const s=t(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function Jn(e){const t=Gn(e);return t.length===1?t:t.filter((n,r)=>!t.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Yn(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((a,l)=>{i.push({from:a,to:l})});else{const{from:a,to:l}=n[o];if(a===void 0||l===void 0)return;i.push({from:a,to:l})}i.forEach(({from:a,to:l})=>{const c=t.slice(o).map(a,-1),u=t.slice(o).map(l),d=t.invert().map(c,-1),h=t.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),Jn(r)}function jt(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(s=>{const o=n.resolve(e),i=mt(o,s.type);i&&r.push({mark:s,...i})}):n.nodesBetween(e,t,(s,o)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}function at(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=e.find(o=>o.type===t&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}function Rt(e,t,n={}){const{empty:r,ranges:s}=e.selection,o=t?z(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>lt(d.attrs,n,{strict:!1}));let i=0;const a=[];if(s.forEach(({$from:d,$to:h})=>{const p=d.pos,f=h.pos;e.doc.nodesBetween(p,f,(y,g)=>{if(!y.isText&&!y.marks.length)return;const b=Math.max(p,g),w=Math.min(f,g+y.nodeSize),S=w-b;i+=S,a.push(...y.marks.map(v=>({mark:v,from:b,to:w})))})}),i===0)return!1;const l=a.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>lt(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=a.filter(d=>o?d.mark.type!==o&&d.mark.type.excludes(o):!0).reduce((d,h)=>d+h.to-h.from,0);return(l>0?l+c:l)>=i}function we(e,t,n={}){if(!t)return Z(e,null,n)||Rt(e,null,n);const r=yt(t,e.schema);return r==="node"?Z(e,t,n):r==="mark"?Rt(e,t,n):!1}function Ht(e,t){const{nodeExtensions:n}=pt(t),r=n.find(i=>i.name===e);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=x(k(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function Ft(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(e.type.name==="hardBreak")return!0;if(e.isText)return/^\s*$/m.test((r=e.text)!==null&&r!==void 0?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let s=!0;return e.content.forEach(o=>{s!==!1&&(Ft(o,{ignoreWhitespace:n,checkChildren:t})||(s=!1))}),s}return!1}function Te(e){return e instanceof m.NodeSelection}function Xn(e,t,n){const s=e.state.doc.content.size,o=$(t,0,s),i=$(n,0,s),a=e.coordsAtPos(o),l=e.coordsAtPos(i,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),h=Math.max(a.right,l.right),p=h-d,f=u-c,b={top:c,bottom:u,left:d,right:h,width:p,height:f,x:d,y:c};return{...b,toJSON:()=>b}}function Qn(e,t,n){var r;const{selection:s}=t;let o=null;if(Bt(s)&&(o=s.$cursor),o){const a=(r=e.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:i}=s;return i.some(({$from:a,$to:l})=>{let c=a.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(a.pos,l.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const p=!h||h.type.allowsMarkType(n),f=!!n.isInSet(u.marks)||!u.marks.some(y=>y.type.excludes(n));c=p&&f}return!c}),c})}const Zn=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:a}=o,l=z(e,r.schema);if(s)if(i){const c=tt(r,l);n.addStoredMark(l.create({...c,...t}))}else a.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,p)=>{const f=Math.max(p,u),y=Math.min(p+h.nodeSize,d);h.marks.find(b=>b.type===l)?h.marks.forEach(b=>{l===b.type&&n.addMark(f,y,l.create({...b.attrs,...t}))}):n.addMark(f,y,l.create(t))})});return Qn(r,n,l)},tr=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),er=(e,t={})=>({state:n,dispatch:r,chain:s})=>{const o=I(e,n.schema);return o.isTextblock?s().command(({commands:i})=>m.setBlockType(o,t)(n)?!0:i.clearNodes()).command(({state:i})=>m.setBlockType(o,t)(i,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},nr=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,s=$(e,0,r.content.size),o=m.NodeSelection.create(r,s);t.setSelection(o)}return!0},rr=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,{from:s,to:o}=typeof e=="number"?{from:e,to:e}:e,i=m.TextSelection.atStart(r).from,a=m.TextSelection.atEnd(r).to,l=$(s,i,a),c=$(o,i,a),u=m.TextSelection.create(r,l,c);t.setSelection(u)}return!0},sr=e=>({state:t,dispatch:n})=>{const r=I(e,t.schema);return m.sinkListItem(r)(t,n)};function Yt(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(s=>t==null?void 0:t.includes(s.type.name));e.tr.ensureMarks(r)}}const or=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:s})=>{const{selection:o,doc:i}=t,{$from:a,$to:l}=o,c=s.extensionManager.attributes,u=at(c,a.node().type.name,a.node().attrs);if(o instanceof m.NodeSelection&&o.node.isBlock)return!a.parentOffset||!m.canSplit(i,a.pos)?!1:(r&&(e&&Yt(n,s.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:zn(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=d&&h?[{type:h,attrs:u}]:void 0,f=m.canSplit(t.doc,t.mapping.map(a.pos),1,p);if(!p&&!f&&m.canSplit(t.doc,t.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(f=!0,p=h?[{type:h,attrs:u}]:void 0),r){if(f&&(o instanceof m.TextSelection&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),h&&!d&&!a.parentOffset&&a.parent.type!==h)){const y=t.mapping.map(a.before()),g=t.doc.resolve(y);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&t.setNodeMarkup(t.mapping.map(a.before()),h)}e&&Yt(n,s.extensionManager.splittableMarks),t.scrollIntoView()}return f},ir=(e,t={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var i;const a=I(e,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const h=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let b=m.Fragment.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let L=l.depth-w;L>=l.depth-3;L-=1)b=m.Fragment.from(l.node(L).copy(b));const S=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,v={...at(h,l.node().type.name,l.node().attrs),...t},E=((i=a.contentMatch.defaultType)===null||i===void 0?void 0:i.createAndFill(v))||void 0;b=b.append(m.Fragment.from(a.createAndFill(null,E)||void 0));const M=l.before(l.depth-(w-1));n.replace(M,l.after(-S),new m.Slice(b,4-w,0));let C=-1;n.doc.nodesBetween(M,n.doc.content.size,(L,T)=>{if(C>-1)return!1;L.isTextblock&&L.content.size===0&&(C=T+1)}),C>-1&&n.setSelection(m.TextSelection.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const p=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,f={...at(h,d.type.name,d.attrs),...t},y={...at(h,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,c.pos);const g=p?[{type:a,attrs:f},{type:p,attrs:y}]:[{type:a,attrs:f}];if(!m.canSplit(n.doc,l.pos,2))return!1;if(s){const{selection:b,storedMarks:w}=r,{splittableMarks:S}=o.extensionManager,v=w||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!v||!s)return!0;const E=v.filter(M=>S.includes(M.type.name));n.ensureMarks(E)}return!0},kt=(e,t)=>{const n=bt(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=e.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&m.canJoin(e.doc,n.pos)&&e.join(n.pos),!0},wt=(e,t)=>{const n=bt(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=e.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&m.canJoin(e.doc,r)&&e.join(r),!0},ar=(e,t,n,r={})=>({editor:s,tr:o,state:i,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=s.extensionManager,p=I(e,i.schema),f=I(t,i.schema),{selection:y,storedMarks:g}=i,{$from:b,$to:w}=y,S=b.blockRange(w),v=g||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const E=bt(M=>Ht(M.type.name,d))(y);if(S.depth>=1&&E&&S.depth-E.depth<=1){if(E.node.type===p)return c.liftListItem(f);if(Ht(E.node.type.name,d)&&p.validContent(E.node.content)&&a)return l().command(()=>(o.setNodeMarkup(E.pos,p),!0)).command(()=>kt(o,p)).command(()=>wt(o,p)).run()}return!n||!v||!a?l().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>kt(o,p)).command(()=>wt(o,p)).run():l().command(()=>{const M=u().wrapInList(p,r),C=v.filter(L=>h.includes(L.type.name));return o.ensureMarks(C),M?!0:c.clearNodes()}).wrapInList(p,r).command(()=>kt(o,p)).command(()=>wt(o,p)).run()},lr=(e,t={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=z(e,r.schema);return Rt(r,i,t)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,t)},cr=(e,t,n={})=>({state:r,commands:s})=>{const o=I(e,r.schema),i=I(t,r.schema);return Z(r,o,n)?s.setNode(i):s.setNode(o,n)},dr=(e,t={})=>({state:n,commands:r})=>{const s=I(e,n.schema);return Z(n,s,t)?r.lift(s):r.wrapIn(s,t)},ur=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let o;if(s.spec.isInputRules&&(o=s.getState(e))){if(t){const i=e.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)i.step(a.steps[l].invert(a.docs[l]));if(o.text){const l=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,e.schema.text(o.text,l))}else i.delete(o.from,o.to)}return!0}}return!1},pr=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:s}=n;return r||t&&s.forEach(o=>{e.removeMark(o.$from.pos,o.$to.pos)}),!0},hr=(e,t={})=>({tr:n,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=t,{selection:a}=n,l=z(e,r.schema),{$from:c,empty:u,ranges:d}=a;if(!s)return!0;if(u&&i){let{from:h,to:p}=a;const f=(o=c.marks().find(g=>g.type===l))===null||o===void 0?void 0:o.attrs,y=mt(c,l,f);y&&(h=y.from,p=y.to),n.removeMark(h,p,l)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,l)});return n.removeStoredMark(l),!0},fr=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=yt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(o=I(e,r.schema)),a==="mark"&&(i=z(e,r.schema)),s&&n.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;r.doc.nodesBetween(c,u,(d,h)=>{o&&o===d.type&&n.setNodeMarkup(h,void 0,{...d.attrs,...t}),i&&d.marks.length&&d.marks.forEach(p=>{if(i===p.type){const f=Math.max(h,c),y=Math.min(h+d.nodeSize,u);n.addMark(f,y,i.create({...p.attrs,...t}))}})})}),!0):!1},mr=(e,t={})=>({state:n,dispatch:r})=>{const s=I(e,n.schema);return m.wrapIn(s,t)(n,r)},gr=(e,t={})=>({state:n,dispatch:r})=>{const s=I(e,n.schema);return m.wrapInList(s,t)(n,r)};var yr=Object.freeze({__proto__:null,blur:Ye,clearContent:Xe,clearNodes:Qe,command:Ze,createParagraphNear:tn,cut:en,deleteCurrentNode:nn,deleteNode:rn,deleteRange:sn,deleteSelection:on,enter:an,exitCode:ln,extendMarkRange:dn,first:un,focus:pn,forEach:hn,insertContent:fn,insertContentAt:yn,joinBackward:Sn,joinDown:vn,joinForward:Mn,joinItemBackward:kn,joinItemForward:wn,joinTextblockBackward:Tn,joinTextblockForward:En,joinUp:bn,keyboardShortcut:xn,lift:An,liftEmptyBlock:On,liftListItem:Ln,newlineInCode:Pn,resetAttributes:Rn,scrollIntoView:Hn,selectAll:In,selectNodeBackward:_n,selectNodeForward:Nn,selectParentNode:Dn,selectTextblockEnd:$n,selectTextblockStart:Bn,setContent:jn,setMark:Zn,setMeta:tr,setNode:er,setNodeSelection:nr,setTextSelection:rr,sinkListItem:sr,splitBlock:or,splitListItem:ir,toggleList:ar,toggleMark:lr,toggleNode:cr,toggleWrap:dr,undoInputRule:ur,unsetAllMarks:pr,unsetMark:hr,updateAttributes:fr,wrapIn:mr,wrapInList:gr});const br=H.create({name:"commands",addCommands(){return{...yr}}}),vr=H.create({name:"editable",addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Sr=H.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new m.Plugin({key:new m.PluginKey("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Mr=H.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:h,parent:p}=d,f=d.parent.isTextblock&&h>0?a.doc.resolve(h-1):d,y=f.parent.type.spec.isolating,g=d.pos-d.parentOffset,b=y&&f.parent.childCount===1?g===d.pos:m.Selection.atStart(c).from===h;return!u||!p.type.isTextblock||p.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return gt()||Se()?o:s},addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some(f=>f.docChanged)&&!t.doc.eq(n.doc)))return;const{empty:s,from:o,to:i}=t.selection,a=m.Selection.atStart(t.doc).from,l=m.Selection.atEnd(t.doc).to;if(s||!(o===a&&i===l)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const d=n.tr,h=dt({state:n,transaction:d}),{commands:p}=new ut({editor:this.editor,state:h});if(p.clearNodes(),!!d.steps.length)return d}})]}}),kr=H.create({name:"tabindex",addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class U{get name(){return this.node.type.name}constructor(t,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new U(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new U(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new U(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,o=this.pos+r+1,i=this.resolvedPos.doc.resolve(o);if(!s&&i.depth<=this.depth)return;const a=new U(i,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),t.push(new U(i,this.editor,s,s?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===t)if(Object.keys(n).length>0){const o=s.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){const l=i[a];if(o[l]!==n[l])break}}else r=s;s=s.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(n);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===t&&o.every(l=>n[l]===i.node.attrs[l])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(t,n,r))))}),s}setAttribute(t){const n=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,t).setTextSelection(n.from).run()}}const wr=`.ProseMirror {
|
|
5
|
-
position: relative;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.ProseMirror {
|
|
9
|
-
word-wrap: break-word;
|
|
10
|
-
white-space: pre-wrap;
|
|
11
|
-
white-space: break-spaces;
|
|
12
|
-
-webkit-font-variant-ligatures: none;
|
|
13
|
-
font-variant-ligatures: none;
|
|
14
|
-
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.ProseMirror [contenteditable="false"] {
|
|
18
|
-
white-space: normal;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
22
|
-
white-space: pre-wrap;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.ProseMirror pre {
|
|
26
|
-
white-space: pre-wrap;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
img.ProseMirror-separator {
|
|
30
|
-
display: inline !important;
|
|
31
|
-
border: none !important;
|
|
32
|
-
margin: 0 !important;
|
|
33
|
-
width: 0 !important;
|
|
34
|
-
height: 0 !important;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.ProseMirror-gapcursor {
|
|
38
|
-
display: none;
|
|
39
|
-
pointer-events: none;
|
|
40
|
-
position: absolute;
|
|
41
|
-
margin: 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.ProseMirror-gapcursor:after {
|
|
45
|
-
content: "";
|
|
46
|
-
display: block;
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: -2px;
|
|
49
|
-
width: 20px;
|
|
50
|
-
border-top: 1px solid black;
|
|
51
|
-
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@keyframes ProseMirror-cursor-blink {
|
|
55
|
-
to {
|
|
56
|
-
visibility: hidden;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.ProseMirror-hideselection *::selection {
|
|
61
|
-
background: transparent;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.ProseMirror-hideselection *::-moz-selection {
|
|
65
|
-
background: transparent;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.ProseMirror-hideselection * {
|
|
69
|
-
caret-color: transparent;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
73
|
-
display: block;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
77
|
-
opacity: 0
|
|
78
|
-
}`;function Tr(e,t,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return t&&s.setAttribute("nonce",t),s.setAttribute("data-tiptap-style",""),s.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(s),s}class Er extends Ie{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n}},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Tr(wr,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,n=!0){this.setOptions({editable:t}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,n){const r=me(n)?n(t,[...this.state.plugins]):[...this.state.plugins,t],s=this.state.reconfigure({plugins:r});this.view.updateState(s)}unregisterPlugin(t){if(this.isDestroyed)return;const n=typeof t=="string"?`${t}$`:t.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(s=>!s.key.startsWith(n))});this.view.updateState(r)}createExtensionManager(){var t,n;const s=[...this.options.enableCoreExtensions?[vr,Je.configure({blockSeparator:(n=(t=this.options.coreExtensionOptions)===null||t===void 0?void 0:t.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),br,Sr,Mr,kr]:[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new Y(s,this)}createCommandManager(){this.commandManager=new ut({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let t;try{t=Pt(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.options.extensions=this.options.extensions.filter(i=>i.name!=="collaboration"),this.createExtensionManager()}}),t=Pt(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=be(t,this.options.autofocus);this.view=new m.EditorView(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:m.EditorState.create({doc:t,selection:n||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(i=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(i)});return}const n=this.state.apply(t),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:t}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=t.getMeta("focus"),o=t.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:t}),o&&this.emit("blur",{editor:this,event:o.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return ke(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,s=typeof t=="string"?n:t;return we(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Kn(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:n=`
|
|
79
|
-
|
|
80
|
-
`,textSerializers:r={}}=t||{};return Un(this.state.doc,{blockSeparator:n,textSerializers:{...ye(this.schema),...r}})}get isEmpty(){return Ft(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var t;return!(!((t=this.view)===null||t===void 0)&&t.docView)}$node(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(t,n))||null}$nodes(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(t,n))||null}$pos(t){const n=this.state.doc.resolve(t);return new U(n,this)}get $doc(){return this.$pos(0)}}function q(e){return new ht({find:e.find,handler:({state:t,range:n,match:r})=>{const s=x(e.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=t,i=r[r.length-1],a=r[0];if(i){const l=a.search(/\S/),c=n.from+a.indexOf(i),u=c+i.length;if(jt(n.from,n.to,t.doc).filter(p=>p.mark.type.excluded.find(y=>y===e.type&&y!==p.mark.type)).filter(p=>p.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+l,c);const h=n.from+l+i.length;o.addMark(n.from+l,h,e.type.create(s||{})),o.removeStoredMark(e.type)}}})}function zt(e){return new ht({find:e.find,handler:({state:t,range:n,match:r})=>{const s=x(e.getAttributes,void 0,r)||{},{tr:o}=t,i=n.from;let a=n.to;const l=e.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>a?u=a:a=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,a,l)}else if(r[0]){const c=e.type.isInline?i:i-1;o.insert(c,e.type.create(s)).delete(o.mapping.map(i),o.mapping.map(a))}o.scrollIntoView()}})}function It(e){return new ht({find:e.find,handler:({state:t,range:n,match:r})=>{const s=t.doc.resolve(n.from),o=x(e.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)}})}function X(e){return new ht({find:e.find,handler:({state:t,range:n,match:r,chain:s})=>{const o=x(e.getAttributes,void 0,r)||{},i=t.tr.delete(n.from,n.to),l=i.doc.resolve(n.from).blockRange(),c=l&&m.findWrapping(l,e.type,o);if(!c)return null;if(i.wrap(l,c),e.keepMarks&&e.editor){const{selection:d,storedMarks:h}=t,{splittableMarks:p}=e.editor.extensionManager,f=h||d.$to.parentOffset&&d.$from.marks();if(f){const y=f.filter(g=>p.includes(g.type.name));i.ensureMarks(y)}}if(e.keepAttributes){const d=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(n.from-1).nodeBefore;u&&u.type===e.type&&m.canJoin(i.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&i.join(n.from-1)}})}class _{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=x(k(this,"addOptions",{name:this.name}))),this.storage=x(k(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new _(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ft(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new _(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=x(k(n,"addOptions",{name:n.name})),n.storage=x(k(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:r}=t.state,s=t.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const l=i.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",s.pos),t.view.dispatch(r),!0}return!1}}class P{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=x(k(this,"addOptions",{name:this.name}))),this.storage=x(k(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new P(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ft(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new P(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=x(k(n,"addOptions",{name:n.name})),n.storage=x(k(n,"addStorage",{name:n.name,options:n.options})),n}}function Cr(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}class xr{constructor(t,n,r){this.isDragging=!1,this.component=t,this.editor=n.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=n.extension,this.node=n.node,this.decorations=n.decorations,this.getPos=n.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var n,r,s,o,i,a,l;const{view:c}=this.editor,u=t.target,d=u.nodeType===3?(n=u.parentElement)===null||n===void 0?void 0:n.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(u)||!d)return;let h=0,p=0;if(this.dom!==d){const g=this.dom.getBoundingClientRect(),b=d.getBoundingClientRect(),w=(s=t.offsetX)!==null&&s!==void 0?s:(o=t.nativeEvent)===null||o===void 0?void 0:o.offsetX,S=(i=t.offsetY)!==null&&i!==void 0?i:(a=t.nativeEvent)===null||a===void 0?void 0:a.offsetY;h=b.x-g.x+w,p=b.y-g.y+S}(l=t.dataTransfer)===null||l===void 0||l.setDragImage(this.dom,h,p);const f=m.NodeSelection.create(c.state.doc,this.getPos()),y=c.state.tr.setSelection(f);c.dispatch(y)}stopEvent(t){var n;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const r=t.target;if(!(this.dom.contains(r)&&!(!((n=this.contentDOM)===null||n===void 0)&&n.contains(r))))return!1;const o=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!i&&!o)return!0;const{isEditable:l}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=m.NodeSelection.isSelectable(this.node),h=t.type==="copy",p=t.type==="paste",f=t.type==="cut",y=t.type==="mousedown";if(!u&&d&&o&&t.preventDefault(),u&&o&&!c)return t.preventDefault(),!1;if(u&&l&&!c&&y){const g=r.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||i||h||p||f||y&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(gt()||Cr())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:n})=>{const r=this.getPos();return n.setNodeMarkup(r,void 0,{...this.node.attrs,...t}),!0})}deleteNode(){const t=this.getPos(),n=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:n})}}function F(e){return new ze({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:s})=>{const o=x(e.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=t,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),d=n.from+l.indexOf(a),h=d+a.length;if(jt(n.from,n.to,t.doc).filter(f=>f.mark.type.excluded.find(g=>g===e.type&&g!==f.mark.type)).filter(f=>f.to>d).length)return null;h<n.to&&i.delete(h,n.to),d>n.from&&i.delete(n.from+u,d),c=n.from+u+a.length,i.addMark(n.from+u,c,e.type.create(o||{})),i.removeStoredMark(e.type)}}})}function Ar(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const Or=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Lr=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Pr=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Rr=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Hr=_.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[q({find:Or,type:this.type}),q({find:Pr,type:this.type})]},addPasteRules(){return[F({find:Lr,type:this.type}),F({find:Rr,type:this.type})]}});class Ir{constructor({editor:t,element:n,view:r,tippyOptions:s={},updateDelay:o=250,shouldShow:i}){this.preventHide=!1,this.shouldShow=({view:a,state:l,from:c,to:u})=>{const{doc:d,selection:h}=l,{empty:p}=h,f=!d.textBetween(c,u).length&&Bt(l.selection),y=this.element.contains(document.activeElement);return!(!(a.hasFocus()||y)||p||f||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:a})=>{var l;if(this.preventHide){this.preventHide=!1;return}a!=null&&a.relatedTarget&&(!((l=this.element.parentNode)===null||l===void 0)&&l.contains(a.relatedTarget))||this.hide()},this.tippyBlurHandler=a=>{this.blurHandler({event:a})},this.handleDebouncedUpdate=(a,l)=>{const c=!(l!=null&&l.selection.eq(a.state.selection)),u=!(l!=null&&l.doc.eq(a.state.doc));!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(a,c,u,l)},this.updateDelay))},this.updateHandler=(a,l,c,u)=>{var d,h,p;const{state:f,composing:y}=a,{selection:g}=f;if(y||!l&&!c)return;this.createTooltip();const{ranges:w}=g,S=Math.min(...w.map(M=>M.$from.pos)),v=Math.max(...w.map(M=>M.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,view:a,state:f,oldState:u,from:S,to:v}))){this.hide();return}(h=this.tippy)===null||h===void 0||h.setProps({getReferenceClientRect:((p=this.tippyOptions)===null||p===void 0?void 0:p.getReferenceClientRect)||(()=>{if(Te(f.selection)){let M=a.nodeDOM(S);const C=M.dataset.nodeViewWrapper?M:M.querySelector("[data-node-view-wrapper]");if(C&&(M=C.firstChild),M)return M.getBoundingClientRect()}return Xn(a,S,v)})}),this.show()},this.editor=t,this.element=n,this.view=r,this.updateDelay=o,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=s,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:t}=this.editor.options,n=!!t.parentElement;this.tippy||!n||(this.tippy=m.tippy(t,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(t,n){const{state:r}=t,s=r.selection.from!==r.selection.to;if(this.updateDelay>0&&s){this.handleDebouncedUpdate(t,n);return}const o=!(n!=null&&n.selection.eq(t.state.selection)),i=!(n!=null&&n.doc.eq(t.state.doc));this.updateHandler(t,o,i,n)}show(){var t;(t=this.tippy)===null||t===void 0||t.show()}hide(){var t;(t=this.tippy)===null||t===void 0||t.hide()}destroy(){var t,n;!((t=this.tippy)===null||t===void 0)&&t.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(n=this.tippy)===null||n===void 0||n.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Ee=e=>new m.Plugin({key:typeof e.pluginKey=="string"?new m.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Ir({view:t,...e})});H.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Ee({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});var _t={exports:{}},Tt={};/**
|
|
81
|
-
* @license React
|
|
82
|
-
* use-sync-external-store-shim.production.min.js
|
|
83
|
-
*
|
|
84
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
85
|
-
*
|
|
86
|
-
* This source code is licensed under the MIT license found in the
|
|
87
|
-
* LICENSE file in the root directory of this source tree.
|
|
88
|
-
*/var Xt;function _r(){if(Xt)return Tt;Xt=1;var e=A;function t(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function a(d,h){var p=h(),f=r({inst:{value:p,getSnapshot:h}}),y=f[0].inst,g=f[1];return o(function(){y.value=p,y.getSnapshot=h,l(y)&&g({inst:y})},[d,p,h]),s(function(){return l(y)&&g({inst:y}),d(function(){l(y)&&g({inst:y})})},[d]),i(p),p}function l(d){var h=d.getSnapshot;d=d.value;try{var p=h();return!n(d,p)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Tt.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Tt}var Et={};/**
|
|
89
|
-
* @license React
|
|
90
|
-
* use-sync-external-store-shim.development.js
|
|
91
|
-
*
|
|
92
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
93
|
-
*
|
|
94
|
-
* This source code is licensed under the MIT license found in the
|
|
95
|
-
* LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/var Qt;function Nr(){return Qt||(Qt=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=A,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(S){{for(var v=arguments.length,E=new Array(v>1?v-1:0),M=1;M<v;M++)E[M-1]=arguments[M];r("error",S,E)}}function r(S,v,E){{var M=t.ReactDebugCurrentFrame,C=M.getStackAddendum();C!==""&&(v+="%s",E=E.concat([C]));var L=E.map(function(T){return String(T)});L.unshift("Warning: "+v),Function.prototype.apply.call(console[S],console,L)}}function s(S,v){return S===v&&(S!==0||1/S===1/v)||S!==S&&v!==v}var o=typeof Object.is=="function"?Object.is:s,i=e.useState,a=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue,u=!1,d=!1;function h(S,v,E){u||e.startTransition!==void 0&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var M=v();if(!d){var C=v();o(M,C)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}var L=i({inst:{value:M,getSnapshot:v}}),T=L[0].inst,R=L[1];return l(function(){T.value=M,T.getSnapshot=v,p(T)&&R({inst:T})},[S,M,v]),a(function(){p(T)&&R({inst:T});var D=function(){p(T)&&R({inst:T})};return S(D)},[S]),c(M),M}function p(S){var v=S.getSnapshot,E=S.value;try{var M=v();return!o(E,M)}catch{return!0}}function f(S,v,E){return v()}var y=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",g=!y,b=g?f:h,w=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:b;Et.useSyncExternalStore=w,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Et}process.env.NODE_ENV==="production"?_t.exports=_r():_t.exports=Nr();var vt=_t.exports;const Dr=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},$r=({contentComponent:e})=>{const t=vt.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return A.createElement(A.Fragment,null,Object.values(t))};function Br(){const e=new Set;let t={};return{subscribe(n){return e.add(n),()=>{e.delete(n)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:he.createPortal(r.reactElement,r.element,n)},e.forEach(s=>s())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(s=>s())}}}class jr extends A.Component{constructor(t){var n;super(t),this.editorContentRef=A.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((n=t.editor)===null||n===void 0)&&n.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const n=this.editorContentRef.current;n.append(...t.options.element.childNodes),t.setOptions({element:n}),t.contentComponent=Br(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t||(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild))return;const n=document.createElement("div");n.append(...t.options.element.childNodes),t.setOptions({element:n})}render(){const{editor:t,innerRef:n,...r}=this.props;return A.createElement(A.Fragment,null,A.createElement("div",{ref:Dr(n,this.editorContentRef),...r}),(t==null?void 0:t.contentComponent)&&A.createElement($r,{contentComponent:t.contentComponent}))}}const Fr=A.forwardRef((e,t)=>{const n=A.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return A.createElement(jr,{key:n,innerRef:t,...e})}),zr=A.memo(Fr);var Nt={exports:{}},Ct={};/**
|
|
97
|
-
* @license React
|
|
98
|
-
* use-sync-external-store-shim/with-selector.production.min.js
|
|
99
|
-
*
|
|
100
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
101
|
-
*
|
|
102
|
-
* This source code is licensed under the MIT license found in the
|
|
103
|
-
* LICENSE file in the root directory of this source tree.
|
|
104
|
-
*/var Zt;function Wr(){if(Zt)return Ct;Zt=1;var e=A,t=vt;function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;return Ct.useSyncExternalStoreWithSelector=function(c,u,d,h,p){var f=o(null);if(f.current===null){var y={hasValue:!1,value:null};f.current=y}else y=f.current;f=a(function(){function b(M){if(!w){if(w=!0,S=M,M=h(M),p!==void 0&&y.hasValue){var C=y.value;if(p(C,M))return v=C}return v=M}if(C=v,r(S,M))return C;var L=h(M);return p!==void 0&&p(C,L)?C:(S=M,v=L)}var w=!1,S,v,E=d===void 0?null:d;return[function(){return b(u())},E===null?void 0:function(){return b(E())}]},[u,d,h,p]);var g=s(c,f[0],f[1]);return i(function(){y.hasValue=!0,y.value=g},[g]),l(g),g},Ct}var xt={};/**
|
|
105
|
-
* @license React
|
|
106
|
-
* use-sync-external-store-shim/with-selector.development.js
|
|
107
|
-
*
|
|
108
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
109
|
-
*
|
|
110
|
-
* This source code is licensed under the MIT license found in the
|
|
111
|
-
* LICENSE file in the root directory of this source tree.
|
|
112
|
-
*/var te;function Vr(){return te||(te=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=A,t=vt;function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;function c(u,d,h,p,f){var y=o(null),g;y.current===null?(g={hasValue:!1,value:null},y.current=g):g=y.current;var b=a(function(){var E=!1,M,C,L=function(B){if(!E){E=!0,M=B;var G=p(B);if(f!==void 0&&g.hasValue){var W=g.value;if(f(W,G))return C=W,W}return C=G,G}var V=M,j=C;if(r(V,B))return j;var K=p(B);return f!==void 0&&f(j,K)?j:(M=B,C=K,K)},T=h===void 0?null:h,R=function(){return L(d())},D=T===null?void 0:function(){return L(T())};return[R,D]},[d,h,p,f]),w=b[0],S=b[1],v=s(u,w,S);return i(function(){g.hasValue=!0,g.value=v},[v]),l(v),v}xt.useSyncExternalStoreWithSelector=c,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),xt}process.env.NODE_ENV==="production"?Nt.exports=Wr():Nt.exports=Vr();var Kr=Nt.exports;class Ur{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function qr(e){const[t]=A.useState(()=>new Ur(e.editor)),n=Kr.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn);return A.useEffect(()=>t.watch(e.editor),[e.editor,t]),A.useDebugValue(n),n}const ee=process.env.NODE_ENV!=="production",Dt=typeof window>"u",Gr=Dt||!!(typeof window<"u"&&window.next);class Jr{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Dt||Gr?(ee&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Dt&&ee)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const t={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)===null||o===void 0?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)===null||o===void 0?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)===null||o===void 0?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)===null||o===void 0?void 0:o.call(s,...r)}};return new Er(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?this.editor.setOptions(this.options.current):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((r,s)=>r===t[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===t&&this.setEditor(null))},1)}}function Yr(e={},t=[]){const n=A.useRef(e);n.current=e;const[r]=A.useState(()=>new Jr(n)),s=vt.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return A.useDebugValue(s),A.useEffect(r.onRender(t)),qr({editor:s,selector:({transactionNumber:o})=>e.shouldRerenderOnTransaction===!1?null:e.immediatelyRender&&o===0?0:o+1}),s}const Ce=A.createContext({editor:null});Ce.Consumer;const Xr=()=>A.useContext(Ce),Qr=e=>{const[t,n]=A.useState(null),{editor:r}=Xr();return A.useEffect(()=>{var s;if(!t||!((s=e.editor)===null||s===void 0)&&s.isDestroyed||r!=null&&r.isDestroyed)return;const{pluginKey:o="bubbleMenu",editor:i,tippyOptions:a={},updateDelay:l,shouldShow:c=null}=e,u=i||r;if(!u){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=Ee({updateDelay:l,editor:u,element:t,pluginKey:o,shouldShow:c,tippyOptions:a});return u.registerPlugin(d),()=>u.unregisterPlugin(o)},[e.editor,r,t]),A.createElement("div",{ref:n,className:e.className,style:{visibility:"hidden"}},e.children)},xe=A.createContext({onDragStart:void 0}),Zr=()=>A.useContext(xe),ts=A.forwardRef((e,t)=>{const{onDragStart:n}=Zr(),r=e.as||"div";return A.createElement(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function es(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function ns(e){var t;return typeof e=="object"&&((t=e.$$typeof)===null||t===void 0?void 0:t.toString())==="Symbol(react.forward_ref)"}class Ae{constructor(t,{editor:n,props:r={},as:s="div",className:o="",attrs:i}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=n,this.props=r,this.element=document.createElement(s),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),i&&Object.keys(i).forEach(a=>{this.element.setAttribute(a,i[a])}),this.editor.isInitialized?he.flushSync(()=>{this.render()}):this.render()}render(){var t;const n=this.component,r=this.props,s=this.editor;(es(n)||ns(n))&&(r.ref=o=>{this.ref=o}),this.reactElement=A.createElement(n,r),(t=s==null?void 0:s.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const n=this.editor;(t=n==null?void 0:n.contentComponent)===null||t===void 0||t.removeRenderer(this.id)}}class rs extends xr{mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,selected:!1,extension:this.extension,getPos:()=>this.getPos(),updateAttributes:(c={})=>this.updateAttributes(c),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const c=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=c(this.extension.name)}const s={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&c.appendChild(this.contentDOMElement)}},o=this.component,i=A.memo(c=>A.createElement(xe.Provider,{value:s},A.createElement(o,c)));i.displayName="ReactNodeView",this.node.isLeaf?this.contentDOMElement=null:this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.style.whiteSpace="inherit");let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.renderer=new Ae(i,{editor:this.editor,props:t,as:a,className:`node-${this.node.type.name} ${l}`.trim(),attrs:this.options.attrs})}get dom(){var t;if(this.renderer.element.firstElementChild&&!(!((t=this.renderer.element.firstElementChild)===null||t===void 0)&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:t,to:n}=this.editor.state.selection;if(t<=this.getPos()&&n>=this.getPos()+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,n){const r=s=>{this.renderer.updateProps(s)};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations;return this.node=t,this.decorations=n,this.options.update({oldNode:s,oldDecorations:o,newNode:t,newDecorations:n,updateProps:()=>r({node:t,decorations:n})})}return t===this.node&&this.decorations===n||(this.node=t,this.decorations=n,r({node:t,decorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}}function ss(e,t){return n=>n.editor.contentComponent?new rs(e,n,t):{}}function Wt(e,t,n){const r=[],s=e.node(0);n=typeof n=="number"&&n>=0?n:e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos);const o=new m.NodeRange(e,t,n),i=o.depth===0?0:s.resolve(o.start).posAtIndex(0);return o.parent.forEach((a,l)=>{const c=i+l,u=c+a.nodeSize;if(c<o.start||c>=o.end)return;const d=new m.SelectionRange(s.resolve(c),s.resolve(u));r.push(d)}),r}class Vt{constructor(t,n){et(this,"anchor");et(this,"head");this.anchor=t,this.head=n}map(t){return new Vt(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return new N(n,r)}}class N extends m.Selection{constructor(n,r,s,o=1){const{doc:i}=n,a=n===r,l=n.pos===i.content.size&&r.pos===i.content.size,c=a&&!l?i.resolve(r.pos+(o>0?1:-1)):r,u=a&&l?i.resolve(n.pos-(o>0?1:-1)):n,d=Wt(u.min(c),u.max(c),s);super(c.pos>=n.pos?d[0].$from:d[d.length-1].$to,c.pos>=n.pos?d[d.length-1].$to:d[0].$from,d);et(this,"depth");this.depth=s}get $to(){return this.ranges[this.ranges.length-1].$to}eq(n){return n instanceof N&&n.$from.pos===this.$from.pos&&n.$to.pos===this.$to.pos}map(n,r){const s=n.resolve(r.map(this.anchor)),o=n.resolve(r.map(this.head));return new N(s,o)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:n}=this.$from;if(this.isForwards&&this.ranges.length>1){const o=this.ranges.slice(0,-1),i=o[0].$from,a=o[o.length-1].$to;return new N(i,a,this.depth)}const r=this.ranges[0],s=n.resolve(Math.max(0,r.$from.pos-1));return new N(this.$anchor,s,this.depth)}extendForwards(){const{doc:n}=this.$from;if(this.isBackwards&&this.ranges.length>1){const o=this.ranges.slice(1),i=o[0].$from,a=o[o.length-1].$to;return new N(a,i,this.depth)}const r=this.ranges[this.ranges.length-1],s=n.resolve(Math.min(n.content.size,r.$to.pos+1));return new N(this.$anchor,s,this.depth)}static fromJSON(n,r){return new N(n.resolve(r.anchor),n.resolve(r.head))}static create(n,r,s,o,i=1){return new this(n.resolve(r),n.resolve(s),o,i)}getBookmark(){return new Vt(this.anchor,this.head)}}function os(e){const t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName("*"))],r=[t,...Array.from(t.getElementsByTagName("*"))];return n.forEach((s,o)=>{r[o].style.cssText=function(i){let a="";const l=getComputedStyle(i);for(let c=0;c<l.length;c+=1)a+=`${l[c]}:${l.getPropertyValue(l[c])};`;return a}(s)}),t}function ot(e,t){return window.getComputedStyle(e)[t]}function is(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function ne(e){e.parentNode!==null&&e.parentNode!==void 0&&e.parentNode.removeChild(e)}const Oe=e=>{const{x:t,y:n,direction:r,editor:s}=e;let o=null,i=null,a=null,l=t;for(;i===null&&l<window.innerWidth&&l>0;){const c=document.elementsFromPoint(l,n),u=c.findIndex(h=>h.classList.contains("ProseMirror")),d=c.slice(0,u);if(d.length>0){const h=d[0];if(o=h,a=s.view.posAtDOM(h,0),a>=0){i=s.state.doc.nodeAt(Math.max(a-1,0)),(i===null||i.isText)&&(i=s.state.doc.nodeAt(Math.max(a-1,0))),i||(i=s.state.doc.nodeAt(Math.max(a,0)));break}}r==="left"?l-=1:l+=1}return{resultElement:o,resultNode:i,pos:a!==null?a:null}};function as(e,t){const{doc:n}=t.view.state,r=Oe({editor:t,x:e.clientX,y:e.clientY,direction:"right"});if(!r.resultNode||r.pos===null)return[];const s=e.clientX,o=function(u,d,h){const p=parseInt(ot(u.dom,"paddingLeft"),10),f=parseInt(ot(u.dom,"paddingRight"),10),y=parseInt(ot(u.dom,"borderLeftWidth"),10),g=parseInt(ot(u.dom,"borderLeftWidth"),10),b=u.dom.getBoundingClientRect();return{left:is(d,b.left+p+y,b.right-f-g),top:h}}(t.view,s,e.clientY),i=t.view.posAtCoords(o);if(!i)return[];const{pos:a}=i;if(!n.resolve(a).parent)return[];const l=n.resolve(r.pos),c=n.resolve(r.pos+1);return Wt(l,c,0)}const re=(e,t)=>{const n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},se=(e,t)=>{const n=e.nodeAt(t),r=e.resolve(t);let{depth:s}=r,o=n;for(;s>0;){const i=r.node(s);s-=1,s===0&&(o=i)}return o},At=(e,t)=>{const n=m.ySyncPluginKey.getState(e);return n?m.absolutePositionToRelativePosition(t,n.type,n.binding.mapping):null},oe=(e,t)=>{let n=t;for(;n&&n.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},Le=new m.PluginKey("dragHandle"),ls=({pluginKey:e=Le,element:t,editor:n,tippyOptions:r,onNodeChange:s})=>{const o=document.createElement("div");let i=null,a=!1,l=null,c=-1;return t.addEventListener("dragstart",u=>{const{view:d}=n;if(!u.dataTransfer)return;const{empty:h,$from:p,$to:f}=d.state.selection,y=as(u,n),g=Wt(p,f,0),b=g.some(T=>y.find(R=>R.$from===T.$from&&R.$to===T.$to)),w=h||!b?y:g;if(!w.length)return;const{tr:S}=d.state,v=document.createElement("div"),E=w[0].$from.pos,M=w[w.length-1].$to.pos,C=N.create(d.state.doc,E,M),L=C.content();w.forEach(T=>{const R=os(d.nodeDOM(T.$from.pos));v.append(R)}),v.style.position="absolute",v.style.top="-10000px",document.body.append(v),u.dataTransfer.clearData(),u.dataTransfer.setDragImage(v,0,0),d.dragging={slice:L,move:!0},S.setSelection(C),d.dispatch(S),document.addEventListener("drop",()=>ne(v),{once:!0}),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}),t.addEventListener("dragend",()=>{t&&(t.style.pointerEvents="auto")}),new m.Plugin({key:typeof e=="string"?new m.PluginKey(e):e,state:{init:()=>({locked:!1}),apply(u,d,h,p){const f=u.getMeta("lockDragHandle"),y=u.getMeta("hideDragHandle");if(f!==void 0&&(a=f),y&&i)return i.hide(),a=!1,l=null,c=-1,s==null||s({editor:n,node:null,pos:-1}),d;if(u.docChanged&&c!==-1&&t&&i){const g=u.mapping.map(c);g!==c&&(c=g,At(p,c))}return d}},view:u=>{var d;return t.draggable=!0,t.style.pointerEvents="auto",(d=n.view.dom.parentElement)===null||d===void 0||d.appendChild(o),o.appendChild(t),o.style.pointerEvents="none",o.style.position="absolute",o.style.top="0",o.style.left="0",i=m.tippy(u.dom,{getReferenceClientRect:null,interactive:!0,trigger:"manual",placement:"left-start",hideOnClick:!1,duration:100,zIndex:10,popperOptions:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",options:{rootBoundary:"document",mainAxis:!1}}]},...r,appendTo:o,content:t}),{update(h,p){if(!t||!i||(t.draggable=!a,u.state.doc.eq(p.doc)||c===-1))return;let f=u.nodeDOM(c);if(f=oe(u,f),f===u.dom||(f==null?void 0:f.nodeType)!==1)return;const y=u.posAtDOM(f,0),g=se(n.state.doc,y);if(g!==l){const b=re(n.state.doc,y);l=g,c=b,At(u.state,c),s==null||s({editor:n,node:l,pos:c}),i.setProps({getReferenceClientRect:()=>f.getBoundingClientRect()}),i.show()}},destroy(){i==null||i.destroy(),t&&ne(o)}}},props:{handleDOMEvents:{mouseleave:(u,d)=>(a||d.target&&!o.contains(d.relatedTarget)&&(i==null||i.hide(),l=null,c=-1,s==null||s({editor:n,node:null,pos:-1})),!1),mousemove(u,d){if(!t||!i||a)return!1;const h=Oe({x:d.clientX,y:d.clientY,direction:"right",editor:n});if(!h.resultElement)return!1;let p=h.resultElement;if(p=oe(u,p),p===u.dom||(p==null?void 0:p.nodeType)!==1)return!1;const f=u.posAtDOM(p,0),y=se(n.state.doc,f);if(y!==l){const g=re(n.state.doc,f);l=y,c=g,At(u.state,c),s==null||s({editor:n,node:l,pos:c}),i.setProps({getReferenceClientRect:()=>p.getBoundingClientRect()}),i.show()}return!1}}}})},cs=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ds=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,us=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ps=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,hs=_.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[q({find:cs,type:this.type}),q({find:us,type:this.type})]},addPasteRules(){return[F({find:ds,type:this.type}),F({find:ps,type:this.type})]}}),fs=_.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),ms=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,gs=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ys=_.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[q({find:ms,type:this.type})]},addPasteRules(){return[F({find:gs,type:this.type})]}}),bs=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,vs=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,Ss=_.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[q({find:bs,type:this.type})]},addPasteRules(){return[F({find:vs,type:this.type})]}}),Ms=/^```([a-z]+)?[\s\n]$/,ks=/^~~~([a-z]+)?[\s\n]$/,ws=P.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,o=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",O(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
|
|
113
|
-
|
|
114
|
-
`);return!o||!i?!1:e.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:o}=n;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?e.commands.command(({tr:c})=>(c.setSelection(m.Selection.near(r.resolve(a))),!0)):e.commands.exitCode()}}},addInputRules(){return[It({find:Ms,type:this.type,getAttributes:e=>({language:e[1]})}),It({find:ks,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s==null?void 0:s.mode;if(!n||!o)return!1;const{tr:i,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,`
|
|
115
|
-
`));return i.replaceSelectionWith(this.type.create({language:o},l)),i.selection.$from.parent.type!==this.type&&i.setSelection(m.TextSelection.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),e.dispatch(i),!0}}})]}}),Ts=_.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",O(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=tt(e,this.type);return Object.entries(n).some(([,s])=>!!s)?!0:t.unsetMark(this.name)}}}}),Es=H.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>{var t;return(t=e.style.fontFamily)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),Cs=P.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,O(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>It({find:new RegExp(`^(#{1,${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),xs=H.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{const t=e.style.textAlign||this.options.defaultAlignment;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).every(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).every(t=>t)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),As=H.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Os=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Ls=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Ps=_.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[q({find:Os,type:this.type})]},addPasteRules(){return[F({find:Ls,type:this.type})]}}),Rs=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",O(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ie=_.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",O(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=tt(e,this.type);return Object.entries(n).some(([,s])=>!!s)?!0:t.unsetMark(this.name)}}}}),ae=/^\s*([-+*])\s$/,Hs=P.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",O(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Rs.name,this.editor.getAttributes(ie.name)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=X({find:ae,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=X({find:ae,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ie.name),editor:this.editor})),[e]}}),Is=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",O(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),le=_.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",O(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=tt(e,this.type);return Object.entries(n).some(([,s])=>!!s)?!0:t.unsetMark(this.name)}}}}),ce=/^(\d+)\.\s$/,_s=P.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",O(this.options.HTMLAttributes,n),0]:["ol",O(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Is.name,this.editor.getAttributes(le.name)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=X({find:ce,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=X({find:ce,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(le.name)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Ns=/^\s*(\[([( |x])?\])\s$/,Ds=P.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",O(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");return o.contentEditable="false",a.type="checkbox",a.addEventListener("change",c=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=c.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const h=n(),p=d.doc.nodeAt(h);return d.setNodeMarkup(h,void 0,{...p==null?void 0:p.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{s.setAttribute(c,u)}),s.dataset.checked=e.attrs.checked,e.attrs.checked&&a.setAttribute("checked","checked"),o.append(a,i),s.append(o,l),Object.entries(t).forEach(([c,u])=>{s.setAttribute(c,u)}),{dom:s,contentDOM:l,update:c=>c.type!==this.type?!1:(s.dataset.checked=c.attrs.checked,c.attrs.checked?a.setAttribute("checked","checked"):a.removeAttribute("checked"),!0)}}},addInputRules(){return[X({find:Ns,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),$s=P.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",O(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),Bs=/^\s*>\s$/,js=P.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[X({find:Bs,type:this.type})]}});function Fs(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function zs(e){return new m.Plugin({key:new m.PluginKey("autolink"),appendTransaction:(t,n,r)=>{const s=t.some(c=>c.docChanged)&&!n.doc.eq(r.doc),o=t.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,a=Fn(n.doc,[...t]);if(Yn(a).forEach(({newRange:c})=>{const u=Vn(r.doc,c,p=>p.isTextblock);let d,h;if(u.length>1?(d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&h){const p=h.split(" ").filter(b=>b!=="");if(p.length<=0)return!1;const f=p[p.length-1],y=d.pos+h.lastIndexOf(f);if(!f)return!1;const g=m.tokenize(f).map(b=>b.toObject(e.defaultProtocol));if(!Fs(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:y+b.start+1,to:y+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>e.validate(b.value)).forEach(b=>{jt(b.from,b.to,r.doc).some(w=>w.mark.type===e.type)||i.addMark(b.from,b.to,e.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function Ws(e){return new m.Plugin({key:new m.PluginKey("handleClickLink"),props:{handleClick:(t,n,r)=>{var s,o;if(r.button!==0||!t.editable)return!1;let i=r.target;const a=[];for(;i.nodeName!=="DIV";)a.push(i),i=i.parentNode;if(!a.find(h=>h.nodeName==="A"))return!1;const l=ke(t.state,e.type.name),c=r.target,u=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:l.href,d=(o=c==null?void 0:c.target)!==null&&o!==void 0?o:l.target;return c&&u?(window.open(u,d),!0):!1}}})}function Vs(e){return new m.Plugin({key:new m.PluginKey("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:s}=t,{selection:o}=s,{empty:i}=o;if(i)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=m.find(a,{defaultProtocol:e.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:(e.editor.commands.setMark(e.type,{href:l.href}),!0)}}})}const Ks=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function de(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!e||e.replace(Ks,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Us=_.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach(e=>{if(typeof e=="string"){m.registerCustomProtocol(e);return}m.registerCustomProtocol(e.scheme,e.optionalSlashes)})},onDestroy(){m.reset()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!t||!de(t,this.options.protocols)?!1:null}}]},renderHTML({HTMLAttributes:e}){return de(e.href,this.options.protocols)?["a",O(this.options.HTMLAttributes,e),0]:["a",O(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>t().setMark(this.name,e).setMeta("preventAutolink",!0).run(),toggleLink:e=>({chain:t})=>t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[F({find:e=>{const t=[];if(e){const{validate:n}=this.options,r=m.find(e).filter(s=>s.isLink&&n(s.value));r.length&&r.forEach(s=>t.push({text:s.value,data:{href:s.href},index:s.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[];return this.options.autolink&&e.push(zs({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),this.options.openOnClick===!0&&e.push(Ws({type:this.type})),this.options.linkOnPaste&&e.push(Vs({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),qs=P.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",O(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{const{selection:n}=t,{$from:r,$to:s}=n,o=e();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):Te(n)?o.insertContentAt(s.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:i,dispatch:a})=>{var l;if(a){const{$to:c}=i.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?i.setSelection(m.TextSelection.create(i.doc,c.pos+1)):c.nodeAfter.isBlock?i.setSelection(m.NodeSelection.create(i.doc,c.pos)):i.setSelection(m.TextSelection.create(i.doc,c.pos));else{const d=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();d&&(i.insert(u,d),i.setSelection(m.TextSelection.create(i.doc,u+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[zt({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Gs=H.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>m.undo(e,t),redo:()=>({state:e,dispatch:t})=>m.redo(e,t)}},addProseMirrorPlugins(){return[m.history(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()}}}),Js=H.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize"}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const t=(e==null?void 0:e.node)||this.editor.state.doc;return((e==null?void 0:e.mode)||this.options.mode)==="textSize"?t.textBetween(0,t.content.size,void 0," ").length:t.nodeSize},this.storage.words=e=>{const t=(e==null?void 0:e.node)||this.editor.state.doc;return t.textBetween(0,t.content.size," "," ").split(" ").filter(s=>s!=="").length}},addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("characterCount"),filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||n===0||n===null||n===void 0)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=n||r>n&&s>n&&s<=r)return!0;if(r>n&&s>n&&s>r||!e.getMeta("paste"))return!1;const i=e.selection.$head.pos,a=s-n,l=i-a,c=i;return e.deleteRange(l,c),!(this.storage.characters({node:e.doc})>n)}})]}}),Ys=H.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[m.dropCursor(this.options)]}}),Xs=H.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=t,o=[];if(!n||!r)return m.DecorationSet.create(e,[]);let i=0;this.options.mode==="deepest"&&e.descendants((l,c)=>{if(l.isText)return;if(!(s>=c&&s<=c+l.nodeSize-1))return!1;i+=1});let a=0;return e.descendants((l,c)=>{if(l.isText||!(s>=c&&s<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";o.push(m.Decoration.node(c,c+l.nodeSize,{class:this.options.className}))}),m.DecorationSet.create(e,o)}}})]}}),Qs=H.create({name:"gapCursor",addProseMirrorPlugins(){return[m.gapCursor()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=x(k(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Zs=P.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",O(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
116
|
-
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:o}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,l=o||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&i){const d=l.filter(h=>a.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),to=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",O(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),eo=P.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),no=H.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!n)return null;const o=this.editor.isEmpty;return e.descendants((i,a)=>{const l=r>=a&&r<=a+i.nodeSize,c=!i.isLeaf&&Ft(i);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const d=m.Decoration.node(a,a+i.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:l}):this.options.placeholder});s.push(d)}return this.options.includeChildren}),m.DecorationSet.create(e,s)}}})]}}),ro=P.create({name:"text",group:"inline"}),so=P.create({name:"doc",topNode:!0,content:"block+"}),oo=_.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),io=_.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",O(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function ao(e){var t;const{char:n,allowSpaces:r,allowedPrefixes:s,startOfLine:o,$position:i}=e,a=Ar(n),l=new RegExp(`\\s${a}$`),c=o?"^":"",u=r?new RegExp(`${c}${a}.*?(?=\\s${a}|$)`,"gm"):new RegExp(`${c}(?:^)?${a}[^\\s${a}]*`,"gm"),d=((t=i.nodeBefore)===null||t===void 0?void 0:t.isText)&&i.nodeBefore.text;if(!d)return null;const h=i.pos-d.length,p=Array.from(d.matchAll(u)).pop();if(!p||p.input===void 0||p.index===void 0)return null;const f=p.input.slice(Math.max(0,p.index-1),p.index),y=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(f);if(s!==null&&!y)return null;const g=h+p.index;let b=g+p[0].length;return r&&l.test(d.slice(b-1,b+1))&&(p[0]+=" ",b+=1),g<i.pos&&b>=i.pos?{range:{from:g,to:b},query:p[0].slice(n.length),text:p[0]}:null}const lo=new m.PluginKey("suggestion");function co({pluginKey:e=lo,editor:t,char:n="@",allowSpaces:r=!1,allowedPrefixes:s=[" "],startOfLine:o=!1,decorationTag:i="span",decorationClass:a="suggestion",command:l=()=>null,items:c=()=>[],render:u=()=>({}),allow:d=()=>!0,findSuggestionMatch:h=ao}){let p;const f=u==null?void 0:u(),y=new m.Plugin({key:e,view(){return{update:async(g,b)=>{var w,S,v,E,M,C,L;const T=(w=this.key)===null||w===void 0?void 0:w.getState(b),R=(S=this.key)===null||S===void 0?void 0:S.getState(g.state),D=T.active&&R.active&&T.range.from!==R.range.from,B=!T.active&&R.active,G=T.active&&!R.active,W=!B&&!G&&T.query!==R.query,V=B||D&&W,j=W||D,K=G||D&&W;if(!V&&!j&&!K)return;const J=K&&!V?T:R,Kt=g.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);p={editor:t,range:J.range,query:J.query,text:J.text,items:[],command:Q=>l({editor:t,range:J.range,props:Q}),decorationNode:Kt,clientRect:Kt?()=>{var Q;const{decorationId:Pe}=(Q=this.key)===null||Q===void 0?void 0:Q.getState(t.state),St=g.dom.querySelector(`[data-decoration-id="${Pe}"]`);return(St==null?void 0:St.getBoundingClientRect())||null}:null},V&&((v=f==null?void 0:f.onBeforeStart)===null||v===void 0||v.call(f,p)),j&&((E=f==null?void 0:f.onBeforeUpdate)===null||E===void 0||E.call(f,p)),(j||V)&&(p.items=await c({editor:t,query:J.query})),K&&((M=f==null?void 0:f.onExit)===null||M===void 0||M.call(f,p)),j&&((C=f==null?void 0:f.onUpdate)===null||C===void 0||C.call(f,p)),V&&((L=f==null?void 0:f.onStart)===null||L===void 0||L.call(f,p))},destroy:()=>{var g;p&&((g=f==null?void 0:f.onExit)===null||g===void 0||g.call(f,p))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(g,b,w,S){const{isEditable:v}=t,{composing:E}=t.view,{selection:M}=g,{empty:C,from:L}=M,T={...b};if(T.composing=E,v&&(C||t.view.composing)){(L<b.range.from||L>b.range.to)&&!E&&!b.composing&&(T.active=!1);const R=h({char:n,allowSpaces:r,allowedPrefixes:s,startOfLine:o,$position:M.$from}),D=`id_${Math.floor(Math.random()*4294967295)}`;R&&d({editor:t,state:S,range:R.range,isActive:b.active})?(T.active=!0,T.decorationId=b.decorationId?b.decorationId:D,T.range=R.range,T.query=R.query,T.text=R.text):T.active=!1}else T.active=!1;return T.active||(T.decorationId=null,T.range={from:0,to:0},T.query=null,T.text=null),T}},props:{handleKeyDown(g,b){var w;const{active:S,range:v}=y.getState(g.state);return S&&((w=f==null?void 0:f.onKeyDown)===null||w===void 0?void 0:w.call(f,{view:g,event:b,range:v}))||!1},decorations(g){const{active:b,range:w,decorationId:S}=y.getState(g);return b?m.DecorationSet.create(g.doc,[m.Decoration.inline(w.from,w.to,{nodeName:i,class:a,"data-decoration-id":S})]):null}}});return y}const uo=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,po=P.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",O(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[zt({find:uo,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),ho=P.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",O(this.options.HTMLAttributes,e),0]}});function ue(e,t,n,r,s,o){let i=0,a=!0,l=t.firstChild;const c=e.firstChild;for(let u=0,d=0;u<c.childCount;u+=1){const{colspan:h,colwidth:p}=c.child(u).attrs;for(let f=0;f<h;f+=1,d+=1){const y=s===d?o:p&&p[f],g=y?`${y}px`:"";i+=y||r,y||(a=!1),l?(l.style.width!==g&&(l.style.width=g),l=l.nextSibling):t.appendChild(document.createElement("col")).style.width=g}}for(;l;){const u=l.nextSibling;l.parentNode.removeChild(l),l=u}a?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}class fo{constructor(t,n){this.node=t,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ue(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,ue(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type==="attributes"&&(t.target===this.table||this.colgroup.contains(t.target))}}function mo(e,t,n,r){let s=0,o=!0;const i=[],a=e.firstChild;if(!a)return{};for(let d=0,h=0;d<a.childCount;d+=1){const{colspan:p,colwidth:f}=a.child(d).attrs;for(let y=0;y<p;y+=1,h+=1){const g=n===h?r:f&&f[y],b=g?`${g}px`:"";s+=g||t,g||(o=!1),i.push(["col",b?{style:`width: ${b}`}:{}])}}const l=o?`${s}px`:"",c=o?"":`${s}px`;return{colgroup:["colgroup",{},...i],tableWidth:l,tableMinWidth:c}}function pe(e,t){return e.createAndFill()}function go(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function yo(e,t,n,r,s){const o=go(e),i=[],a=[];for(let c=0;c<n;c+=1){const u=pe(o.cell);if(u&&a.push(u),r){const d=pe(o.header_cell);d&&i.push(d)}}const l=[];for(let c=0;c<t;c+=1)l.push(o.row.createChecked(null,r&&c===0?i:a));return o.table.createChecked(null,l)}function bo(e){return e instanceof m.CellSelection}const it=({editor:e})=>{const{selection:t}=e.state;if(!bo(t))return!1;let n=0;const r=Me(t.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},vo=P.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:fo,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=mo(e,this.options.cellMinWidth);return["table",O(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${s}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:o})=>{const i=yo(o.schema,e,t,n);if(s){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(m.TextSelection.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>m.addColumnBefore(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>m.addColumnAfter(e,t),deleteColumn:()=>({state:e,dispatch:t})=>m.deleteColumn(e,t),addRowBefore:()=>({state:e,dispatch:t})=>m.addRowBefore(e,t),addRowAfter:()=>({state:e,dispatch:t})=>m.addRowAfter(e,t),deleteRow:()=>({state:e,dispatch:t})=>m.deleteRow(e,t),deleteTable:()=>({state:e,dispatch:t})=>m.deleteTable(e,t),mergeCells:()=>({state:e,dispatch:t})=>m.mergeCells(e,t),splitCell:()=>({state:e,dispatch:t})=>m.splitCell(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>m.toggleHeader("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>m.toggleHeader("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>m.toggleHeaderCell(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>m.mergeCells(e,t)?!0:m.splitCell(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>m.setCellAttr(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>m.goToNextCell(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>m.goToNextCell(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&m.fixTables(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=m.CellSelection.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:it,"Mod-Backspace":it,Delete:it,"Mod-Delete":it}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[m.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],m.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:x(k(e,"tableRole",t))}}}),So=P.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?[parseInt(t,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",O(this.options.HTMLAttributes,e),0]}}),Mo=P.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?[parseInt(t,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",O(this.options.HTMLAttributes,e),0]}});exports.Blockquote=js;exports.Bold=Hr;exports.BubbleMenu=Qr;exports.BulletList=Hs;exports.CharacterCount=Js;exports.Code=Ss;exports.CodeBlock=ws;exports.Color=As;exports.Document=so;exports.DragHandlePlugin=ls;exports.Dropcursor=Ys;exports.EditorContent=zr;exports.Extension=H;exports.FocusClasses=Xs;exports.FontFamily=Es;exports.Gapcursor=Qs;exports.HardBreak=Zs;exports.Heading=Cs;exports.Highlight=Ps;exports.History=Gs;exports.HorizontalRule=qs;exports.Image=po;exports.Italic=hs;exports.Link=Us;exports.ListItem=to;exports.Node=P;exports.NodeViewWrapper=ts;exports.OrderedList=_s;exports.Paragraph=eo;exports.Placeholder=no;exports.ReactNodeViewRenderer=ss;exports.ReactRenderer=Ae;exports.Strike=ys;exports.Subscript=oo;exports.Suggestion=co;exports.Superscript=io;exports.Table=vo;exports.TableCell=So;exports.TableHeader=Mo;exports.TableRow=ho;exports.TaskItem=Ds;exports.TaskList=$s;exports.Text=ro;exports.TextAlign=xs;exports.TextStyle=Ts;exports.Underline=fs;exports.dragHandlePluginDefaultKey=Le;exports.findChildren=Wn;exports.findParentNode=bt;exports.getMarkRange=mt;exports.isActive=we;exports.isList=Ht;exports.mergeAttributes=O;exports.nodeInputRule=zt;exports.useEditor=Yr;
|
|
117
|
-
//# sourceMappingURL=tiptap-CMeHtctt.cjs.map
|