reactjs-tiptap-editor-pro 0.2.22 → 0.2.24

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.
@@ -920,13 +920,19 @@ declare module '@tiptap/core' {
920
920
 
921
921
  declare module '@tiptap/core' {
922
922
  interface Commands<ReturnType> {
923
- columns: {
924
- insertColumns: (attrs?: {
925
- cols: number;
926
- }) => ReturnType;
927
- addColBefore: () => ReturnType;
928
- addColAfter: () => ReturnType;
929
- deleteCol: () => ReturnType;
923
+ imageUpload: {
924
+ /**
925
+ * Add an image
926
+ */
927
+ setImageInline: (options: Partial<SetImageAttrsOptions>) => ReturnType;
928
+ /**
929
+ * Update an image
930
+ */
931
+ updateImage: (options: Partial<SetImageAttrsOptions>) => ReturnType;
932
+ /**
933
+ * Set image alignment
934
+ */
935
+ setAlignImage: (align: 'left' | 'center' | 'right') => ReturnType;
930
936
  };
931
937
  }
932
938
  }
@@ -934,8 +940,14 @@ declare module '@tiptap/core' {
934
940
 
935
941
  declare module '@tiptap/core' {
936
942
  interface Commands<ReturnType> {
937
- painter: {
938
- setPainter: (marks: Mark[]) => ReturnType;
943
+ iframe: {
944
+ /**
945
+ * Add an iframe
946
+ */
947
+ setIframe: (options: {
948
+ src: string;
949
+ service: string;
950
+ }) => ReturnType;
939
951
  };
940
952
  }
941
953
  }
@@ -943,9 +955,14 @@ declare module '@tiptap/core' {
943
955
 
944
956
  declare module '@tiptap/core' {
945
957
  interface Commands<ReturnType> {
946
- lineHeight: {
947
- setLineHeight: (lineHeight: string) => ReturnType;
948
- unsetLineHeight: () => ReturnType;
958
+ search: {
959
+ setSearchTerm: (searchTerm: string) => ReturnType;
960
+ setReplaceTerm: (replaceTerm: string) => ReturnType;
961
+ replace: () => ReturnType;
962
+ replaceAll: () => ReturnType;
963
+ goToPrevSearchResult: () => void;
964
+ goToNextSearchResult: () => void;
965
+ setCaseSensitive: (caseSensitive: boolean) => ReturnType;
949
966
  };
950
967
  }
951
968
  }
@@ -953,15 +970,8 @@ declare module '@tiptap/core' {
953
970
 
954
971
  declare module '@tiptap/core' {
955
972
  interface Commands<ReturnType> {
956
- indent: {
957
- /**
958
- * Set the indent attribute
959
- */
960
- indent: () => ReturnType;
961
- /**
962
- * Set the outdent attribute
963
- */
964
- outdent: () => ReturnType;
973
+ painter: {
974
+ setPainter: (marks: Mark[]) => ReturnType;
965
975
  };
966
976
  }
967
977
  }
@@ -969,19 +979,9 @@ declare module '@tiptap/core' {
969
979
 
970
980
  declare module '@tiptap/core' {
971
981
  interface Commands<ReturnType> {
972
- imageUpload: {
973
- /**
974
- * Add an image
975
- */
976
- setImageInline: (options: Partial<SetImageAttrsOptions>) => ReturnType;
977
- /**
978
- * Update an image
979
- */
980
- updateImage: (options: Partial<SetImageAttrsOptions>) => ReturnType;
981
- /**
982
- * Set image alignment
983
- */
984
- setAlignImage: (align: 'left' | 'center' | 'right') => ReturnType;
982
+ tableCellBackground: {
983
+ setTableCellBackground: (color: string) => ReturnType;
984
+ unsetTableCellBackground: () => ReturnType;
985
985
  };
986
986
  }
987
987
  }
@@ -989,9 +989,15 @@ declare module '@tiptap/core' {
989
989
 
990
990
  declare module '@tiptap/core' {
991
991
  interface Commands<ReturnType> {
992
- tableCellBackground: {
993
- setTableCellBackground: (color: string) => ReturnType;
994
- unsetTableCellBackground: () => ReturnType;
992
+ indent: {
993
+ /**
994
+ * Set the indent attribute
995
+ */
996
+ indent: () => ReturnType;
997
+ /**
998
+ * Set the outdent attribute
999
+ */
1000
+ outdent: () => ReturnType;
995
1001
  };
996
1002
  }
997
1003
  }
@@ -999,8 +1005,11 @@ declare module '@tiptap/core' {
999
1005
 
1000
1006
  declare module '@tiptap/core' {
1001
1007
  interface Commands<ReturnType> {
1002
- katex: {
1003
- setKatex: (arg?: IKatexAttrs) => ReturnType;
1008
+ emoji: {
1009
+ setEmoji: (emoji: {
1010
+ name: string;
1011
+ emoji: string;
1012
+ }) => ReturnType;
1004
1013
  };
1005
1014
  }
1006
1015
  }
@@ -1008,9 +1017,13 @@ declare module '@tiptap/core' {
1008
1017
 
1009
1018
  declare module '@tiptap/core' {
1010
1019
  interface Commands<ReturnType> {
1011
- tableOfContents: {
1012
- setTableOfContents: () => ReturnType;
1013
- removeTableOfContents: () => ReturnType;
1020
+ columns: {
1021
+ insertColumns: (attrs?: {
1022
+ cols: number;
1023
+ }) => ReturnType;
1024
+ addColBefore: () => ReturnType;
1025
+ addColAfter: () => ReturnType;
1026
+ deleteCol: () => ReturnType;
1014
1027
  };
1015
1028
  }
1016
1029
  }
@@ -1018,8 +1031,9 @@ declare module '@tiptap/core' {
1018
1031
 
1019
1032
  declare module '@tiptap/core' {
1020
1033
  interface Commands<ReturnType> {
1021
- excalidraw: {
1022
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
1034
+ lineHeight: {
1035
+ setLineHeight: (lineHeight: string) => ReturnType;
1036
+ unsetLineHeight: () => ReturnType;
1023
1037
  };
1024
1038
  }
1025
1039
  }
@@ -1027,11 +1041,8 @@ declare module '@tiptap/core' {
1027
1041
 
1028
1042
  declare module '@tiptap/core' {
1029
1043
  interface Commands<ReturnType> {
1030
- emoji: {
1031
- setEmoji: (emoji: {
1032
- name: string;
1033
- emoji: string;
1034
- }) => ReturnType;
1044
+ katex: {
1045
+ setKatex: (arg?: IKatexAttrs) => ReturnType;
1035
1046
  };
1036
1047
  }
1037
1048
  }
@@ -1039,14 +1050,14 @@ declare module '@tiptap/core' {
1039
1050
 
1040
1051
  declare module '@tiptap/core' {
1041
1052
  interface Commands<ReturnType> {
1042
- iframe: {
1053
+ twitter: {
1043
1054
  /**
1044
- * Add an iframe
1055
+ * Insert a tweet
1056
+ * @param options The tweet attributes
1057
+ * @example editor.commands.setTweet({ src: 'https://x.com/seanpk/status/1800145949580517852' })
1045
1058
  */
1046
- setIframe: (options: {
1047
- src: string;
1048
- service: string;
1049
- }) => ReturnType;
1059
+ setTweet: (options: SetTweetOptions) => ReturnType;
1060
+ updateTweet: (options: SetTweetOptions) => ReturnType;
1050
1061
  };
1051
1062
  }
1052
1063
  }
@@ -1063,14 +1074,9 @@ declare module '@tiptap/core' {
1063
1074
 
1064
1075
  declare module '@tiptap/core' {
1065
1076
  interface Commands<ReturnType> {
1066
- search: {
1067
- setSearchTerm: (searchTerm: string) => ReturnType;
1068
- setReplaceTerm: (replaceTerm: string) => ReturnType;
1069
- replace: () => ReturnType;
1070
- replaceAll: () => ReturnType;
1071
- goToPrevSearchResult: () => void;
1072
- goToNextSearchResult: () => void;
1073
- setCaseSensitive: (caseSensitive: boolean) => ReturnType;
1077
+ mermaid: {
1078
+ setMermaid: (options: any, replace?: any) => ReturnType;
1079
+ setAlignImageMermaid: (align: 'left' | 'center' | 'right') => ReturnType;
1074
1080
  };
1075
1081
  }
1076
1082
  }
@@ -1098,9 +1104,8 @@ declare module '@tiptap/core' {
1098
1104
 
1099
1105
  declare module '@tiptap/core' {
1100
1106
  interface Commands<ReturnType> {
1101
- mermaid: {
1102
- setMermaid: (options: any, replace?: any) => ReturnType;
1103
- setAlignImageMermaid: (align: 'left' | 'center' | 'right') => ReturnType;
1107
+ attachment: {
1108
+ setAttachment: (attrs?: unknown) => ReturnType;
1104
1109
  };
1105
1110
  }
1106
1111
  }
@@ -1108,8 +1113,9 @@ declare module '@tiptap/core' {
1108
1113
 
1109
1114
  declare module '@tiptap/core' {
1110
1115
  interface Commands<ReturnType> {
1111
- attachment: {
1112
- setAttachment: (attrs?: unknown) => ReturnType;
1116
+ tableOfContents: {
1117
+ setTableOfContents: () => ReturnType;
1118
+ removeTableOfContents: () => ReturnType;
1113
1119
  };
1114
1120
  }
1115
1121
  }
@@ -1117,14 +1123,9 @@ declare module '@tiptap/core' {
1117
1123
 
1118
1124
  declare module '@tiptap/core' {
1119
1125
  interface Commands<ReturnType> {
1120
- twitter: {
1121
- /**
1122
- * Insert a tweet
1123
- * @param options The tweet attributes
1124
- * @example editor.commands.setTweet({ src: 'https://x.com/seanpk/status/1800145949580517852' })
1125
- */
1126
- setTweet: (options: SetTweetOptions) => ReturnType;
1127
- updateTweet: (options: SetTweetOptions) => ReturnType;
1126
+ drawer: {
1127
+ setDrawer: (options: any, replace?: any) => ReturnType;
1128
+ setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
1128
1129
  };
1129
1130
  }
1130
1131
  }
@@ -1132,9 +1133,8 @@ declare module '@tiptap/core' {
1132
1133
 
1133
1134
  declare module '@tiptap/core' {
1134
1135
  interface Commands<ReturnType> {
1135
- drawer: {
1136
- setDrawer: (options: any, replace?: any) => ReturnType;
1137
- setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
1136
+ excalidraw: {
1137
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
1138
1138
  };
1139
1139
  }
1140
1140
  }
@@ -1,4 +1,4 @@
1
- import { a as e, b as l, l as o, e as _, c, d as h } from "./index-8id9bPv5.js";
1
+ import { a as e, b as l, l as o, e as _, c, d as h } from "./index-PJxla8pp.js";
2
2
  export {
3
3
  e as en,
4
4
  l as hu_HU,
@@ -1,4 +1,4 @@
1
- "use strict";const Pe=require("tippy.js"),m=require("./vendor-CRmKyn1B.cjs"),x=require("react"),ae=require("react-dom");function ct(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:o}=n,{storedMarks:s}=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 s},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,s=n.storedMarks,n}}}class dt{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:o}=n,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>{const d=c(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a=[],c=!!t,l=t||s.tr,u=()=>(!c&&n&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),a.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(r).map(([p,h])=>[p,(...f)=>{const y=this.buildProps(l,n),b=h(...f)(y);return a.push(b),d}])),run:u};return d}createCan(t){const{rawCommands:n,state:r}=this,o=!1,s=t||r.tr,i=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(n).map(([c,l])=>[c,(...u)=>l(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}buildProps(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a={tr:t,editor:o,view:i,state:ct({state:s,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([c,l])=>[c,(...u)=>l(...u)(a)]))}};return a}}class Re{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(o=>o.apply(this,n)),this}off(t,n){const r=this.callbacks[t];return r&&(n?this.callbacks[t]=r.filter(o=>o!==n):delete this.callbacks[t]),this}once(t,n){const r=(...o)=>{this.off(t,r),n.apply(this,o)};return this.on(t,r)}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 ut(e){const t=e.filter(o=>o.type==="extension"),n=e.filter(o=>o.type==="node"),r=e.filter(o=>o.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function le(e){const t=[],{nodeExtensions:n,markExtensions:r}=ut(e),o=[...n,...r],s={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:o},c=k(i,"addGlobalAttributes",a);if(!c)return;c().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([p,h])=>{t.push({type:d,name:p,attribute:{...s,...h}})})})})}),o.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},c=k(i,"addAttributes",a);if(!c)return;const l=c();Object.entries(l).forEach(([u,d])=>{const p={...s,...d};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,t.push({type:i.name,name:u,attribute:p})})}),t}function H(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 A(...e){return e.filter(t=>!!t).reduce((t,n)=>{const r={...t};return Object.entries(n).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const a=s?String(s).split(" "):[],c=r[o]?r[o].split(" "):[],l=a.filter(u=>!c.includes(u));r[o]=[...c,...l].join(" ")}else if(o==="style"){const a=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],c=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],l=new Map;c.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),a.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),r[o]=Array.from(l.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[o]=s}),r},{})}function it(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>A(n,r),{})}function ce(e){return typeof e=="function"}function E(e,t=void 0,...n){return ce(e)?t?e.bind(t)(...n):e(...n):e}function _e(e={}){return Object.keys(e).length===0&&e.constructor===Object}function He(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function Wt(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 o=t.reduce((s,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):He(n.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function Kt(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&_e(n)?!1:n!=null))}function Ne(e,t){var n;const r=le(e),{nodeExtensions:o,markExtensions:s}=ut(e),i=(n=o.find(l=>k(l,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(o.map(l=>{const u=r.filter(b=>b.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((b,M)=>{const v=k(M,"extendNodeSchema",d);return{...b,...v?v(l):{}}},{}),h=Kt({...p,content:E(k(l,"content",d)),marks:E(k(l,"marks",d)),group:E(k(l,"group",d)),inline:E(k(l,"inline",d)),atom:E(k(l,"atom",d)),selectable:E(k(l,"selectable",d)),draggable:E(k(l,"draggable",d)),code:E(k(l,"code",d)),whitespace:E(k(l,"whitespace",d)),linebreakReplacement:E(k(l,"linebreakReplacement",d)),defining:E(k(l,"defining",d)),isolating:E(k(l,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var M;return[b.name,{default:(M=b==null?void 0:b.attribute)===null||M===void 0?void 0:M.default}]}))}),g=E(k(l,"parseHTML",d));g&&(h.parseDOM=g.map(b=>Wt(b,u)));const f=k(l,"renderHTML",d);f&&(h.toDOM=b=>f({node:b,HTMLAttributes:it(b,u)}));const y=k(l,"renderText",d);return y&&(h.toText=y),[l.name,h]})),c=Object.fromEntries(s.map(l=>{const u=r.filter(y=>y.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((y,b)=>{const M=k(b,"extendMarkSchema",d);return{...y,...M?M(l):{}}},{}),h=Kt({...p,inclusive:E(k(l,"inclusive",d)),excludes:E(k(l,"excludes",d)),group:E(k(l,"group",d)),spanning:E(k(l,"spanning",d)),code:E(k(l,"code",d)),attrs:Object.fromEntries(u.map(y=>{var b;return[y.name,{default:(b=y==null?void 0:y.attribute)===null||b===void 0?void 0:b.default}]}))}),g=E(k(l,"parseHTML",d));g&&(h.parseDOM=g.map(y=>Wt(y,u)));const f=k(l,"renderHTML",d);return f&&(h.toDOM=y=>f({mark:y,HTMLAttributes:it(y,u)})),[l.name,h]}));return new m.Schema({topNode:i,nodes:a,marks:c})}function kt(e,t){return t.nodes[e]||t.marks[e]||null}function Ut(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function It(e,t){const n=m.DOMSerializer.fromSchema(t).serializeFragment(e),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}const De=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(o,s,i,a)=>{var c,l;const u=((l=(c=o.type.spec).toText)===null||l===void 0?void 0:l.call(c,{node:o,pos:s,parent:i,index:a}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-s))}),n};function $t(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class pt{constructor(t){this.find=t.find,this.handler=t.handler}}const Ie=(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 tt(e){var t;const{editor:n,from:r,to:o,text:s,rules:i,plugin:a}=e,{view:c}=n;if(c.composing)return!1;const l=c.state.doc.resolve(r);if(l.parent.type.spec.code||!((t=l.nodeBefore||l.nodeAfter)===null||t===void 0)&&t.marks.find(p=>p.type.spec.code))return!1;let u=!1;const d=De(l)+s;return i.forEach(p=>{if(u)return;const h=Ie(d,p.find);if(!h)return;const g=c.state.tr,f=ct({state:c.state,transaction:g}),y={from:r-(h[0].length-s.length),to:o},{commands:b,chain:M,can:v}=new dt({editor:n,state:f});p.handler({state:f,range:y,match:h,commands:b,chain:M,can:v})===null||!g.steps.length||(g.setMeta(a,{transform:g,from:r,to:o,text:s}),c.dispatch(g),u=!0)}),u}function $e(e){const{editor:t,rules:n}=e,r=new m.Plugin({state:{init(){return null},apply(o,s,i){const a=o.getMeta(r);if(a)return a;const c=o.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=It(m.Fragment.from(u),i.schema);const{from:d}=c,p=d+u.length;tt({editor:t,from:d,to:p,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,a){return tt({editor:t,from:s,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&tt({editor:t,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;const{$cursor:i}=o.state.selection;return i?tt({editor:t,from:i.pos,to:i.pos,text:`
1
+ "use strict";const Pe=require("tippy.js"),m=require("./vendor-LvbrNFNL.cjs"),x=require("react"),ae=require("react-dom");function ct(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:o}=n,{storedMarks:s}=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 s},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,s=n.storedMarks,n}}}class dt{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:o}=n,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>{const d=c(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a=[],c=!!t,l=t||s.tr,u=()=>(!c&&n&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),a.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(r).map(([p,h])=>[p,(...f)=>{const y=this.buildProps(l,n),b=h(...f)(y);return a.push(b),d}])),run:u};return d}createCan(t){const{rawCommands:n,state:r}=this,o=!1,s=t||r.tr,i=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(n).map(([c,l])=>[c,(...u)=>l(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}buildProps(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a={tr:t,editor:o,view:i,state:ct({state:s,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([c,l])=>[c,(...u)=>l(...u)(a)]))}};return a}}class Re{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(o=>o.apply(this,n)),this}off(t,n){const r=this.callbacks[t];return r&&(n?this.callbacks[t]=r.filter(o=>o!==n):delete this.callbacks[t]),this}once(t,n){const r=(...o)=>{this.off(t,r),n.apply(this,o)};return this.on(t,r)}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 ut(e){const t=e.filter(o=>o.type==="extension"),n=e.filter(o=>o.type==="node"),r=e.filter(o=>o.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function le(e){const t=[],{nodeExtensions:n,markExtensions:r}=ut(e),o=[...n,...r],s={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:o},c=k(i,"addGlobalAttributes",a);if(!c)return;c().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([p,h])=>{t.push({type:d,name:p,attribute:{...s,...h}})})})})}),o.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},c=k(i,"addAttributes",a);if(!c)return;const l=c();Object.entries(l).forEach(([u,d])=>{const p={...s,...d};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,t.push({type:i.name,name:u,attribute:p})})}),t}function H(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 A(...e){return e.filter(t=>!!t).reduce((t,n)=>{const r={...t};return Object.entries(n).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const a=s?String(s).split(" "):[],c=r[o]?r[o].split(" "):[],l=a.filter(u=>!c.includes(u));r[o]=[...c,...l].join(" ")}else if(o==="style"){const a=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],c=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],l=new Map;c.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),a.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),r[o]=Array.from(l.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[o]=s}),r},{})}function it(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>A(n,r),{})}function ce(e){return typeof e=="function"}function E(e,t=void 0,...n){return ce(e)?t?e.bind(t)(...n):e(...n):e}function _e(e={}){return Object.keys(e).length===0&&e.constructor===Object}function He(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function Wt(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 o=t.reduce((s,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):He(n.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function Kt(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&_e(n)?!1:n!=null))}function Ne(e,t){var n;const r=le(e),{nodeExtensions:o,markExtensions:s}=ut(e),i=(n=o.find(l=>k(l,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(o.map(l=>{const u=r.filter(b=>b.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((b,M)=>{const v=k(M,"extendNodeSchema",d);return{...b,...v?v(l):{}}},{}),h=Kt({...p,content:E(k(l,"content",d)),marks:E(k(l,"marks",d)),group:E(k(l,"group",d)),inline:E(k(l,"inline",d)),atom:E(k(l,"atom",d)),selectable:E(k(l,"selectable",d)),draggable:E(k(l,"draggable",d)),code:E(k(l,"code",d)),whitespace:E(k(l,"whitespace",d)),linebreakReplacement:E(k(l,"linebreakReplacement",d)),defining:E(k(l,"defining",d)),isolating:E(k(l,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var M;return[b.name,{default:(M=b==null?void 0:b.attribute)===null||M===void 0?void 0:M.default}]}))}),g=E(k(l,"parseHTML",d));g&&(h.parseDOM=g.map(b=>Wt(b,u)));const f=k(l,"renderHTML",d);f&&(h.toDOM=b=>f({node:b,HTMLAttributes:it(b,u)}));const y=k(l,"renderText",d);return y&&(h.toText=y),[l.name,h]})),c=Object.fromEntries(s.map(l=>{const u=r.filter(y=>y.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((y,b)=>{const M=k(b,"extendMarkSchema",d);return{...y,...M?M(l):{}}},{}),h=Kt({...p,inclusive:E(k(l,"inclusive",d)),excludes:E(k(l,"excludes",d)),group:E(k(l,"group",d)),spanning:E(k(l,"spanning",d)),code:E(k(l,"code",d)),attrs:Object.fromEntries(u.map(y=>{var b;return[y.name,{default:(b=y==null?void 0:y.attribute)===null||b===void 0?void 0:b.default}]}))}),g=E(k(l,"parseHTML",d));g&&(h.parseDOM=g.map(y=>Wt(y,u)));const f=k(l,"renderHTML",d);return f&&(h.toDOM=y=>f({mark:y,HTMLAttributes:it(y,u)})),[l.name,h]}));return new m.Schema({topNode:i,nodes:a,marks:c})}function kt(e,t){return t.nodes[e]||t.marks[e]||null}function Ut(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function It(e,t){const n=m.DOMSerializer.fromSchema(t).serializeFragment(e),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}const De=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(o,s,i,a)=>{var c,l;const u=((l=(c=o.type.spec).toText)===null||l===void 0?void 0:l.call(c,{node:o,pos:s,parent:i,index:a}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-s))}),n};function $t(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class pt{constructor(t){this.find=t.find,this.handler=t.handler}}const Ie=(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 tt(e){var t;const{editor:n,from:r,to:o,text:s,rules:i,plugin:a}=e,{view:c}=n;if(c.composing)return!1;const l=c.state.doc.resolve(r);if(l.parent.type.spec.code||!((t=l.nodeBefore||l.nodeAfter)===null||t===void 0)&&t.marks.find(p=>p.type.spec.code))return!1;let u=!1;const d=De(l)+s;return i.forEach(p=>{if(u)return;const h=Ie(d,p.find);if(!h)return;const g=c.state.tr,f=ct({state:c.state,transaction:g}),y={from:r-(h[0].length-s.length),to:o},{commands:b,chain:M,can:v}=new dt({editor:n,state:f});p.handler({state:f,range:y,match:h,commands:b,chain:M,can:v})===null||!g.steps.length||(g.setMeta(a,{transform:g,from:r,to:o,text:s}),c.dispatch(g),u=!0)}),u}function $e(e){const{editor:t,rules:n}=e,r=new m.Plugin({state:{init(){return null},apply(o,s,i){const a=o.getMeta(r);if(a)return a;const c=o.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=It(m.Fragment.from(u),i.schema);const{from:d}=c,p=d+u.length;tt({editor:t,from:d,to:p,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,a){return tt({editor:t,from:s,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&tt({editor:t,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;const{$cursor:i}=o.state.selection;return i?tt({editor:t,from:i.pos,to:i.pos,text:`
2
2
  `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Be(e){return Object.prototype.toString.call(e).slice(8,-1)}function et(e){return Be(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function ht(e,t){const n={...e};return et(e)&&et(t)&&Object.keys(t).forEach(r=>{et(t[r])&&et(e[r])?n[r]=ht(e[r],t[r]):n[r]=t[r]}),n}class D{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=E(k(this,"addOptions",{name:this.name}))),this.storage=E(k(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new D(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ht(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new D(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=E(k(n,"addOptions",{name:n.name})),n.storage=E(k(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:r}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const i=o.marks();if(!!!i.find(l=>(l==null?void 0:l.type.name)===n.name))return!1;const c=i.find(l=>(l==null?void 0:l.type.name)===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}}function de(e){return typeof e=="number"}class ue{constructor(t){this.find=t.find,this.handler=t.handler}}const je=(e,t,n)=>{if($t(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(o=>{const s=[o.text];return s.index=o.index,s.input=e,s.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(o.replaceWith)),s}):[]};function Fe(e){const{editor:t,state:n,from:r,to:o,rule:s,pasteEvent:i,dropEvent:a}=e,{commands:c,chain:l,can:u}=new dt({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,o,(h,g)=>{if(!h.isTextblock||h.type.spec.code)return;const f=Math.max(r,g),y=Math.min(o,g+h.content.size),b=h.textBetween(f-g,y-g,void 0,"");je(b,s.find,i).forEach(v=>{if(v.index===void 0)return;const S=f+v.index+1,T=S+v[0].length,w={from:n.tr.mapping.map(S),to:n.tr.mapping.map(T)},C=s.handler({state:n,range:w,match:v,commands:c,chain:l,can:u,pasteEvent:i,dropEvent:a});d.push(C)})}),d.every(h=>h!==null)}let nt=null;const ze=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 Ve(e){const{editor:t,rules:n}=e;let r=null,o=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const c=({state:u,from:d,to:p,rule:h,pasteEvt:g})=>{const f=u.tr,y=ct({state:u,transaction:f});if(!(!Fe({editor:t,state:y,from:Math.max(d-1,0),to:p.b-1,rule:h,pasteEvent:g,dropEvent:a})||!f.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,f}};return n.map(u=>new m.Plugin({view(d){const p=g=>{var f;r=!((f=d.dom.parentElement)===null||f===void 0)&&f.contains(g.target)?d.dom.parentElement:null,r&&(nt=t)},h=()=>{nt&&(nt=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,p)=>{if(s=r===d.dom.parentElement,a=p,!s){const h=nt;h&&setTimeout(()=>{const g=h.state.selection;g&&h.commands.deleteRange({from:g.from,to:g.to})},10)}return!1},paste:(d,p)=>{var h;const g=(h=p.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return i=p,o=!!(g!=null&&g.includes("data-pm-slice")),!1}}},appendTransaction:(d,p,h)=>{const g=d[0],f=g.getMeta("uiEvent")==="paste"&&!o,y=g.getMeta("uiEvent")==="drop"&&!s,b=g.getMeta("applyPasteRules"),M=!!b;if(!f&&!y&&!M)return;if(M){let{text:T}=b;typeof T=="string"?T=T:T=It(m.Fragment.from(T),h.schema);const{from:w}=b,C=w+T.length,O=ze(T);return c({rule:u,state:h,from:w,to:{b:C},pasteEvt:O})}const v=p.doc.content.findDiffStart(h.doc.content),S=p.doc.content.findDiffEnd(h.doc.content);if(!(!de(v)||!S||v===S.b))return c({rule:u,state:h,from:v,to:S,pasteEvt:i})}}))}function We(e){const t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}class J{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=J.resolve(t),this.schema=Ne(this.extensions,n),this.setupExtensions()}static resolve(t){const n=J.sort(J.flatten(t)),r=We(n.map(o=>o.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(o=>`'${o}'`).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},o=k(n,"addExtensions",r);return o?[n,...this.flatten(o())]:n}).flat(10)}static sort(t){return t.sort((r,o)=>{const s=k(r,"priority")||100,i=k(o,"priority")||100;return s>i?-1:s<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:kt(n.name,this.schema)},o=k(n,"addCommands",r);return o?{...t,...o()}:t},{})}get plugins(){const{editor:t}=this,n=J.sort([...this.extensions].reverse()),r=[],o=[],s=n.map(i=>{const a={name:i.name,options:i.options,storage:i.storage,editor:t,type:kt(i.name,this.schema)},c=[],l=k(i,"addKeyboardShortcuts",a);let u={};if(i.type==="mark"&&k(i,"exitable",a)&&(u.ArrowRight=()=>D.handleExit({editor:t,mark:i})),l){const f=Object.fromEntries(Object.entries(l()).map(([y,b])=>[y,()=>b({editor:t})]));u={...u,...f}}const d=m.keymap(u);c.push(d);const p=k(i,"addInputRules",a);Ut(i,t.options.enableInputRules)&&p&&r.push(...p());const h=k(i,"addPasteRules",a);Ut(i,t.options.enablePasteRules)&&h&&o.push(...h());const g=k(i,"addProseMirrorPlugins",a);if(g){const f=g();c.push(...f)}return c}).flat();return[$e({editor:t,rules:r}),...Ve({editor:t,rules:o}),...s]}get attributes(){return le(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:n}=ut(this.extensions);return Object.fromEntries(n.filter(r=>!!k(r,"addNodeView")).map(r=>{const o=this.attributes.filter(c=>c.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:t,type:H(r.name,this.schema)},i=k(r,"addNodeView",s);if(!i)return[];const a=(c,l,u,d,p)=>{const h=it(c,o);return i()({node:c,view:l,getPos:u,decorations:d,innerDecorations:p,editor:t,extension:r,HTMLAttributes:h})};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:kt(t.name,this.schema)};t.type==="mark"&&(!((n=E(k(t,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(t.name);const o=k(t,"onBeforeCreate",r),s=k(t,"onCreate",r),i=k(t,"onUpdate",r),a=k(t,"onSelectionUpdate",r),c=k(t,"onTransaction",r),l=k(t,"onFocus",r),u=k(t,"onBlur",r),d=k(t,"onDestroy",r);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),l&&this.editor.on("focus",l),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}class _{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=E(k(this,"addOptions",{name:this.name}))),this.storage=E(k(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new _(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ht(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new _({...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=E(k(n,"addOptions",{name:n.name})),n.storage=E(k(n,"addStorage",{name:n.name,options:n.options})),n}}function pe(e,t,n){const{from:r,to:o}=t,{blockSeparator:s=`
3
3
 
4
4
  `,textSerializers:i={}}=n||{};let a="";return e.nodesBetween(r,o,(c,l,u,d)=>{var p;c.isBlock&&l>r&&(a+=s);const h=i==null?void 0:i[c.type.name];if(h)return u&&(a+=h({node:c,pos:l,parent:u,index:d,range:t})),!1;c.isText&&(a+=(p=c==null?void 0:c.text)===null||p===void 0?void 0:p.slice(Math.max(r,l)-l,o-l))}),a}function he(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}const Ke=_.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:o}=t,{ranges:s}=o,i=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),c=he(n);return pe(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Ue=()=>({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),qe=(e=!1)=>({commands:t})=>t.setContent("",e),Ge=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:o}=r;return n&&o.forEach(({$from:s,$to:i})=>{e.doc.nodesBetween(s.pos,i.pos,(a,c)=>{if(a.type.isText)return;const{doc:l,mapping:u}=t,d=l.resolve(u.map(c)),p=l.resolve(u.map(c+a.nodeSize)),h=d.blockRange(p);if(!h)return;const g=m.liftTarget(h);if(a.type.isTextblock){const{defaultType:f}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(h.start,f)}(g||g===0)&&t.lift(h,g)})}),!0},Je=e=>t=>e(t),Ye=()=>({state:e,dispatch:t})=>m.createParagraphNear(e,t),Xe=(e,t)=>({editor:n,tr:r})=>{const{state:o}=n,s=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const i=r.mapping.map(t);return r.insert(i,s.content),r.setSelection(new m.TextSelection(r.doc.resolve(i-1))),!0},Qe=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(t){const a=o.before(s),c=o.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Ze=e=>({tr:t,state:n,dispatch:r})=>{const o=H(e,n.schema),s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const c=s.before(i),l=s.after(i);t.delete(c,l).scrollIntoView()}return!0}return!1},tn=e=>({tr:t,dispatch:n})=>{const{from:r,to:o}=e;return n&&t.delete(r,o),!0},en=()=>({state:e,dispatch:t})=>m.deleteSelection(e,t),nn=()=>({commands:e})=>e.keyboardShortcut("Enter"),rn=()=>({state:e,dispatch:t})=>m.exitCode(e,t);function at(e,t,n={strict:!0}){const r=Object.keys(t);return r.length?r.every(o=>n.strict?t[o]===e[o]:$t(t[o])?t[o].test(e[o]):t[o]===e[o]):!0}function fe(e,t,n={}){return e.find(r=>r.type===t&&at(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function qt(e,t,n={}){return!!fe(e,t,n)}function ft(e,t,n){var r;if(!e||!t)return;let o=e.parent.childAfter(e.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===t))&&(o=e.parent.childBefore(e.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===t)||(n=n||((r=o.node.marks[0])===null||r===void 0?void 0:r.attrs),!fe([...o.node.marks],t,n)))return;let i=o.index,a=e.start()+o.offset,c=i+1,l=a+o.node.nodeSize;for(;i>0&&qt([...e.parent.child(i-1).marks],t,n);)i-=1,a-=e.parent.child(i).nodeSize;for(;c<e.parent.childCount&&qt([...e.parent.child(c).marks],t,n);)l+=e.parent.child(c).nodeSize,c+=1;return{from:a,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 on=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const s=z(e,r.schema),{doc:i,selection:a}=n,{$from:c,from:l,to:u}=a;if(o){const d=ft(c,s,t);if(d&&d.from<=l&&d.to>=u){const p=m.TextSelection.create(i,d.from,d.to);n.setSelection(p)}}return!0},sn=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 B(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function me(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 o=n.from,s=r.to;return t==="all"?m.TextSelection.create(e,B(0,o,s),B(e.content.size,o,s)):m.TextSelection.create(e,B(t,o,s),B(t,o,s))}function ge(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function mt(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const an=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:s})=>{t={scrollIntoView:!0,...t};const i=()=>{(mt()||ge())&&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(s&&e===null&&!Bt(n.state.selection))return i(),!0;const a=me(o.doc,e)||n.state.selection,c=n.state.selection.eq(a);return s&&(c||o.setSelection(a),c&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},ln=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),cn=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),ye=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&&ye(r)}return e};function rt(e){const t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return ye(n)}function lt(e,t,n){if(e instanceof m.Node||e instanceof m.Fragment)return e;n={slice:!0,parseOptions:{},...n};const r=typeof e=="object"&&e!==null,o=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(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),lt("",t,n)}if(o){if(n.errorOnInvalidContent){let i=!1,a="";const c=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:l=>(i=!0,a=typeof l=="string"?l:l.outerHTML,null)}]}})});if(n.slice?m.DOMParser.fromSchema(c).parseSlice(rt(e),n.parseOptions):m.DOMParser.fromSchema(c).parse(rt(e),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=m.DOMParser.fromSchema(t);return n.slice?s.parseSlice(rt(e),n.parseOptions).content:s.parse(rt(e),n.parseOptions)}return lt("",t,n)}function dn(e,t,n){const r=e.steps.length-1;if(r<t)return;const o=e.steps[r];if(!(o instanceof m.ReplaceStep||o instanceof m.ReplaceAroundStep))return;const s=e.mapping.maps[r];let i=0;s.forEach((a,c,l,u)=>{i===0&&(i=u)}),e.setSelection(m.Selection.near(e.doc.resolve(i),n))}const un=e=>!("type"in e),pn=(e,t,n)=>({tr:r,dispatch:o,editor:s})=>{var i;if(o){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;try{a=lt(t,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:s.options.enableContentCheck})}catch(g){return s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}}),!1}let{from:c,to:l}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((un(a)?a:[a]).forEach(g=>{g.check(),u=u?g.isText&&g.marks.length===0:!1,d=d?g.isBlock:!1}),c===l&&d){const{parent:g}=r.doc.resolve(c);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(c-=1,l+=1)}let h;if(u){if(Array.isArray(t))h=t.map(g=>g.text||"").join("");else if(t instanceof m.Fragment){let g="";t.forEach(f=>{f.text&&(g+=f.text)}),h=g}else typeof t=="object"&&t&&t.text?h=t.text:h=t;r.insertText(h,c,l)}else h=a,r.replaceWith(c,l,h);n.updateSelection&&dn(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:h}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:h})}return!0},hn=()=>({state:e,dispatch:t})=>m.joinUp(e,t),fn=()=>({state:e,dispatch:t})=>m.joinDown(e,t),mn=()=>({state:e,dispatch:t})=>m.joinBackward(e,t),gn=()=>({state:e,dispatch:t})=>m.joinForward(e,t),yn=()=>({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}},bn=()=>({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}},vn=()=>({state:e,dispatch:t})=>m.joinTextblockBackward(e,t),Sn=()=>({state:e,dispatch:t})=>m.joinTextblockForward(e,t);function be(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Mn(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let r,o,s,i;for(let a=0;a<t.length-1;a+=1){const c=t[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))mt()||be()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}const kn=e=>({editor:t,view:n,tr:r,dispatch:o})=>{const s=Mn(e).split(/-(?!$)/),i=s.find(l=>!["Alt","Ctrl","Meta","Shift"].includes(l)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=t.captureTransaction(()=>{n.someProp("handleKeyDown",l=>l(n,a))});return c==null||c.steps.forEach(l=>{const u=l.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function Z(e,t,n={}){const{from:r,to:o,empty:s}=e.selection,i=t?H(t,e.schema):null,a=[];e.doc.nodesBetween(r,o,(d,p)=>{if(d.isText)return;const h=Math.max(r,p),g=Math.min(o,p+d.nodeSize);a.push({node:d,from:h,to:g})});const c=o-r,l=a.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>at(d.node.attrs,n,{strict:!1}));return s?!!l.length:l.reduce((d,p)=>d+p.to-p.from,0)>=c}const wn=(e,t={})=>({state:n,dispatch:r})=>{const o=H(e,n.schema);return Z(n,o,t)?m.lift(n,r):!1},Tn=()=>({state:e,dispatch:t})=>m.liftEmptyBlock(e,t),En=e=>({state:t,dispatch:n})=>{const r=H(e,t.schema);return m.liftListItem(r)(t,n)},Cn=()=>({state:e,dispatch:t})=>m.newlineInCode(e,t);function gt(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Gt(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,o)=>(n.includes(o)||(r[o]=e[o]),r),{})}const xn=(e,t)=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=gt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(s=H(e,r.schema)),a==="mark"&&(i=z(e,r.schema)),o&&n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(l,u)=>{s&&s===l.type&&n.setNodeMarkup(u,void 0,Gt(l.attrs,t)),i&&l.marks.length&&l.marks.forEach(d=>{i===d.type&&n.addMark(u,u+l.nodeSize,i.create(Gt(d.attrs,t)))})})}),!0):!1},An=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),On=()=>({tr:e,dispatch:t})=>{if(t){const n=new m.AllSelection(e.doc);e.setSelection(n)}return!0},Ln=()=>({state:e,dispatch:t})=>m.selectNodeBackward(e,t),Pn=()=>({state:e,dispatch:t})=>m.selectNodeForward(e,t),Rn=()=>({state:e,dispatch:t})=>m.selectParentNode(e,t),_n=()=>({state:e,dispatch:t})=>m.selectTextblockEnd(e,t),Hn=()=>({state:e,dispatch:t})=>m.selectTextblockStart(e,t);function Ot(e,t,n={},r={}){return lt(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const Nn=(e,t=!1,n={},r={})=>({editor:o,tr:s,dispatch:i,commands:a})=>{var c,l;const{doc:u}=s;if(n.preserveWhitespace!=="full"){const d=Ot(e,o.schema,n,{errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:o.options.enableContentCheck});return i&&s.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),!0}return i&&s.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:u.content.size},e,{parseOptions:n,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})};function ve(e,t){const n=z(t,e.schema),{from:r,to:o,empty:s}=e.selection,i=[];s?(e.storedMarks&&i.push(...e.storedMarks),i.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,c=>{i.push(...c.marks)});const a=i.find(c=>c.type.name===n.name);return a?{...a.attrs}:{}}function Dn(e,t){const n=new m.Transform(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function In(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 $n(e,t){const n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function Bn(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(o,s)=>{n(o)&&r.push({node:o,pos:s})}),r}function Se(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 yt(e){return t=>Se(t.$from,e)}function jn(e,t){const n={from:0,to:e.content.size};return pe(e,n,t)}function Fn(e,t){const n=H(t,e.schema),{from:r,to:o}=e.selection,s=[];e.doc.nodesBetween(r,o,a=>{s.push(a)});const i=s.reverse().find(a=>a.type.name===n.name);return i?{...i.attrs}:{}}function Me(e,t){const n=gt(typeof t=="string"?t:t.name,e.schema);return n==="node"?Fn(e,t):n==="mark"?ve(e,t):{}}function zn(e,t=JSON.stringify){const n={};return e.filter(r=>{const o=t(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Vn(e){const t=zn(e);return t.length===1?t:t.filter((n,r)=>!t.filter((s,i)=>i!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function Wn(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((a,c)=>{i.push({from:a,to:c})});else{const{from:a,to:c}=n[s];if(a===void 0||c===void 0)return;i.push({from:a,to:c})}i.forEach(({from:a,to:c})=>{const l=t.slice(s).map(a,-1),u=t.slice(s).map(c),d=t.invert().map(l,-1),p=t.invert().map(u);r.push({oldRange:{from:d,to:p},newRange:{from:l,to:u}})})}),Vn(r)}function jt(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(o=>{const s=n.resolve(e),i=ft(s,o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(e,t,(o,s)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}function st(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const o=e.find(s=>s.type===t&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}function Lt(e,t,n={}){const{empty:r,ranges:o}=e.selection,s=t?z(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>at(d.attrs,n,{strict:!1}));let i=0;const a=[];if(o.forEach(({$from:d,$to:p})=>{const h=d.pos,g=p.pos;e.doc.nodesBetween(h,g,(f,y)=>{if(!f.isText&&!f.marks.length)return;const b=Math.max(h,y),M=Math.min(g,y+f.nodeSize),v=M-b;i+=v,a.push(...f.marks.map(S=>({mark:S,from:b,to:M})))})}),i===0)return!1;const c=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>at(d.mark.attrs,n,{strict:!1})).reduce((d,p)=>d+p.to-p.from,0),l=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,p)=>d+p.to-p.from,0);return(c>0?c+l:c)>=i}function ke(e,t,n={}){if(!t)return Z(e,null,n)||Lt(e,null,n);const r=gt(t,e.schema);return r==="node"?Z(e,t,n):r==="mark"?Lt(e,t,n):!1}function Pt(e,t){const{nodeExtensions:n}=ut(t),r=n.find(i=>i.name===e);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=E(k(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function bt(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 o=!0;return e.content.forEach(s=>{o!==!1&&(bt(s,{ignoreWhitespace:n,checkChildren:t})||(o=!1))}),o}return!1}function we(e){return e instanceof m.NodeSelection}function Kn(e,t,n){const o=e.state.doc.content.size,s=B(t,0,o),i=B(n,0,o),a=e.coordsAtPos(s),c=e.coordsAtPos(i,-1),l=Math.min(a.top,c.top),u=Math.max(a.bottom,c.bottom),d=Math.min(a.left,c.left),p=Math.max(a.right,c.right),h=p-d,g=u-l,b={top:l,bottom:u,left:d,right:p,width:h,height:g,x:d,y:l};return{...b,toJSON:()=>b}}function Un(e,t,n){var r;const{selection:o}=t;let s=null;if(Bt(o)&&(s=o.$cursor),s){const a=(r=e.storedMarks)!==null&&r!==void 0?r:s.marks();return!!n.isInSet(a)||!a.some(c=>c.type.excludes(n))}const{ranges:i}=o;return i.some(({$from:a,$to:c})=>{let l=a.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(a.pos,c.pos,(u,d,p)=>{if(l)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(n),g=!!n.isInSet(u.marks)||!u.marks.some(f=>f.type.excludes(n));l=h&&g}return!l}),l})}const qn=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const{selection:s}=n,{empty:i,ranges:a}=s,c=z(e,r.schema);if(o)if(i){const l=ve(r,c);n.addStoredMark(c.create({...l,...t}))}else a.forEach(l=>{const u=l.$from.pos,d=l.$to.pos;r.doc.nodesBetween(u,d,(p,h)=>{const g=Math.max(h,u),f=Math.min(h+p.nodeSize,d);p.marks.find(b=>b.type===c)?p.marks.forEach(b=>{c===b.type&&n.addMark(g,f,c.create({...b.attrs,...t}))}):n.addMark(g,f,c.create(t))})});return Un(r,n,c)},Gn=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Jn=(e,t={})=>({state:n,dispatch:r,chain:o})=>{const s=H(e,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),s.isTextblock?o().command(({commands:a})=>m.setBlockType(s,{...i,...t})(n)?!0:a.clearNodes()).command(({state:a})=>m.setBlockType(s,{...i,...t})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Yn=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,o=B(e,0,r.content.size),s=m.NodeSelection.create(r,o);t.setSelection(s)}return!0},Xn=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,{from:o,to:s}=typeof e=="number"?{from:e,to:e}:e,i=m.TextSelection.atStart(r).from,a=m.TextSelection.atEnd(r).to,c=B(o,i,a),l=B(s,i,a),u=m.TextSelection.create(r,c,l);t.setSelection(u)}return!0},Qn=e=>({state:t,dispatch:n})=>{const r=H(e,t.schema);return m.sinkListItem(r)(t,n)};function Jt(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(o=>t==null?void 0:t.includes(o.type.name));e.tr.ensureMarks(r)}}const Zn=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{const{selection:s,doc:i}=t,{$from:a,$to:c}=s,l=o.extensionManager.attributes,u=st(l,a.node().type.name,a.node().attrs);if(s instanceof m.NodeSelection&&s.node.isBlock)return!a.parentOffset||!m.canSplit(i,a.pos)?!1:(r&&(e&&Jt(n,o.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=c.parentOffset===c.parent.content.size,p=a.depth===0?void 0:In(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&p?[{type:p,attrs:u}]:void 0,g=m.canSplit(t.doc,t.mapping.map(a.pos),1,h);if(!h&&!g&&m.canSplit(t.doc,t.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(g=!0,h=p?[{type:p,attrs:u}]:void 0),r){if(g&&(s instanceof m.TextSelection&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,h),p&&!d&&!a.parentOffset&&a.parent.type!==p)){const f=t.mapping.map(a.before()),y=t.doc.resolve(f);a.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&t.setNodeMarkup(t.mapping.map(a.before()),p)}e&&Jt(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return g},tr=(e,t={})=>({tr:n,state:r,dispatch:o,editor:s})=>{var i;const a=H(e,r.schema),{$from:c,$to:l}=r.selection,u=r.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(l))return!1;const d=c.node(-1);if(d.type!==a)return!1;const p=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(o){let b=m.Fragment.empty;const M=c.index(-1)?1:c.index(-2)?2:3;for(let O=c.depth-M;O>=c.depth-3;O-=1)b=m.Fragment.from(c.node(O).copy(b));const v=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,S={...st(p,c.node().type.name,c.node().attrs),...t},T=((i=a.contentMatch.defaultType)===null||i===void 0?void 0:i.createAndFill(S))||void 0;b=b.append(m.Fragment.from(a.createAndFill(null,T)||void 0));const w=c.before(c.depth-(M-1));n.replace(w,c.after(-v),new m.Slice(b,4-M,0));let C=-1;n.doc.nodesBetween(w,n.doc.content.size,(O,R)=>{if(C>-1)return!1;O.isTextblock&&O.content.size===0&&(C=R+1)}),C>-1&&n.setSelection(m.TextSelection.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const h=l.pos===c.end()?d.contentMatchAt(0).defaultType:null,g={...st(p,d.type.name,d.attrs),...t},f={...st(p,c.node().type.name,c.node().attrs),...t};n.delete(c.pos,l.pos);const y=h?[{type:a,attrs:g},{type:h,attrs:f}]:[{type:a,attrs:g}];if(!m.canSplit(n.doc,c.pos,2))return!1;if(o){const{selection:b,storedMarks:M}=r,{splittableMarks:v}=s.extensionManager,S=M||b.$to.parentOffset&&b.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!S||!o)return!0;const T=S.filter(w=>v.includes(w.type.name));n.ensureMarks(T)}return!0},wt=(e,t)=>{const n=yt(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 o=e.doc.nodeAt(r);return n.node.type===(o==null?void 0:o.type)&&m.canJoin(e.doc,n.pos)&&e.join(n.pos),!0},Tt=(e,t)=>{const n=yt(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 o=e.doc.nodeAt(r);return n.node.type===(o==null?void 0:o.type)&&m.canJoin(e.doc,r)&&e.join(r),!0},er=(e,t,n,r={})=>({editor:o,tr:s,state:i,dispatch:a,chain:c,commands:l,can:u})=>{const{extensions:d,splittableMarks:p}=o.extensionManager,h=H(e,i.schema),g=H(t,i.schema),{selection:f,storedMarks:y}=i,{$from:b,$to:M}=f,v=b.blockRange(M),S=y||f.$to.parentOffset&&f.$from.marks();if(!v)return!1;const T=yt(w=>Pt(w.type.name,d))(f);if(v.depth>=1&&T&&v.depth-T.depth<=1){if(T.node.type===h)return l.liftListItem(g);if(Pt(T.node.type.name,d)&&h.validContent(T.node.content)&&a)return c().command(()=>(s.setNodeMarkup(T.pos,h),!0)).command(()=>wt(s,h)).command(()=>Tt(s,h)).run()}return!n||!S||!a?c().command(()=>u().wrapInList(h,r)?!0:l.clearNodes()).wrapInList(h,r).command(()=>wt(s,h)).command(()=>Tt(s,h)).run():c().command(()=>{const w=u().wrapInList(h,r),C=S.filter(O=>p.includes(O.type.name));return s.ensureMarks(C),w?!0:l.clearNodes()}).wrapInList(h,r).command(()=>wt(s,h)).command(()=>Tt(s,h)).run()},nr=(e,t={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=n,i=z(e,r.schema);return Lt(r,i,t)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,t)},rr=(e,t,n={})=>({state:r,commands:o})=>{const s=H(e,r.schema),i=H(t,r.schema),a=Z(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),a?o.setNode(i,c):o.setNode(s,{...c,...n})},or=(e,t={})=>({state:n,commands:r})=>{const o=H(e,n.schema);return Z(n,o,t)?r.lift(o):r.wrapIn(o,t)},sr=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let s;if(o.spec.isInputRules&&(s=o.getState(e))){if(t){const i=e.tr,a=s.transform;for(let c=a.steps.length-1;c>=0;c-=1)i.step(a.steps[c].invert(a.docs[c]));if(s.text){const c=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,e.schema.text(s.text,c))}else i.delete(s.from,s.to)}return!0}}return!1},ir=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:o}=n;return r||t&&o.forEach(s=>{e.removeMark(s.$from.pos,s.$to.pos)}),!0},ar=(e,t={})=>({tr:n,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=t,{selection:a}=n,c=z(e,r.schema),{$from:l,empty:u,ranges:d}=a;if(!o)return!0;if(u&&i){let{from:p,to:h}=a;const g=(s=l.marks().find(y=>y.type===c))===null||s===void 0?void 0:s.attrs,f=ft(l,c,g);f&&(p=f.from,h=f.to),n.removeMark(p,h,c)}else d.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},lr=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=gt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(s=H(e,r.schema)),a==="mark"&&(i=z(e,r.schema)),o&&n.selection.ranges.forEach(c=>{const l=c.$from.pos,u=c.$to.pos;let d,p,h,g;n.selection.empty?r.doc.nodesBetween(l,u,(f,y)=>{s&&s===f.type&&(h=Math.max(y,l),g=Math.min(y+f.nodeSize,u),d=y,p=f)}):r.doc.nodesBetween(l,u,(f,y)=>{y<l&&s&&s===f.type&&(h=Math.max(y,l),g=Math.min(y+f.nodeSize,u),d=y,p=f),y>=l&&y<=u&&(s&&s===f.type&&n.setNodeMarkup(y,void 0,{...f.attrs,...t}),i&&f.marks.length&&f.marks.forEach(b=>{if(i===b.type){const M=Math.max(y,l),v=Math.min(y+f.nodeSize,u);n.addMark(M,v,i.create({...b.attrs,...t}))}}))}),p&&(d!==void 0&&n.setNodeMarkup(d,void 0,{...p.attrs,...t}),i&&p.marks.length&&p.marks.forEach(f=>{i===f.type&&n.addMark(h,g,i.create({...f.attrs,...t}))}))}),!0):!1},cr=(e,t={})=>({state:n,dispatch:r})=>{const o=H(e,n.schema);return m.wrapIn(o,t)(n,r)},dr=(e,t={})=>({state:n,dispatch:r})=>{const o=H(e,n.schema);return m.wrapInList(o,t)(n,r)};var ur=Object.freeze({__proto__:null,blur:Ue,clearContent:qe,clearNodes:Ge,command:Je,createParagraphNear:Ye,cut:Xe,deleteCurrentNode:Qe,deleteNode:Ze,deleteRange:tn,deleteSelection:en,enter:nn,exitCode:rn,extendMarkRange:on,first:sn,focus:an,forEach:ln,insertContent:cn,insertContentAt:pn,joinBackward:mn,joinDown:fn,joinForward:gn,joinItemBackward:yn,joinItemForward:bn,joinTextblockBackward:vn,joinTextblockForward:Sn,joinUp:hn,keyboardShortcut:kn,lift:wn,liftEmptyBlock:Tn,liftListItem:En,newlineInCode:Cn,resetAttributes:xn,scrollIntoView:An,selectAll:On,selectNodeBackward:Ln,selectNodeForward:Pn,selectParentNode:Rn,selectTextblockEnd:_n,selectTextblockStart:Hn,setContent:Nn,setMark:qn,setMeta:Gn,setNode:Jn,setNodeSelection:Yn,setTextSelection:Xn,sinkListItem:Qn,splitBlock:Zn,splitListItem:tr,toggleList:er,toggleMark:nr,toggleNode:rr,toggleWrap:or,undoInputRule:sr,unsetAllMarks:ir,unsetMark:ar,updateAttributes:lr,wrapIn:cr,wrapInList:dr});const pr=_.create({name:"commands",addCommands(){return{...ur}}}),hr=_.create({name:"drop",addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),fr=_.create({name:"editable",addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),mr=new m.PluginKey("focusEvents"),gr=_.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new m.Plugin({key:mr,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}}}})]}}),yr=_.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:c,doc:l}=a,{empty:u,$anchor:d}=c,{pos:p,parent:h}=d,g=d.parent.isTextblock&&p>0?a.doc.resolve(p-1):d,f=g.parent.type.spec.isolating,y=d.pos-d.parentOffset,b=f&&g.parent.childCount===1?y===d.pos:m.Selection.atStart(l).from===p;return!u||!h.type.isTextblock||h.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()},o={...r},s={...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 mt()||be()?s:o},addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(f=>f.getMeta("composition")))return;const r=e.some(f=>f.docChanged)&&!t.doc.eq(n.doc),o=e.some(f=>f.getMeta("preventClearDocument"));if(!r||o)return;const{empty:s,from:i,to:a}=t.selection,c=m.Selection.atStart(t.doc).from,l=m.Selection.atEnd(t.doc).to;if(s||!(i===c&&a===l)||!bt(n.doc))return;const p=n.tr,h=ct({state:n,transaction:p}),{commands:g}=new dt({editor:this.editor,state:h});if(g.clearNodes(),!!p.steps.length)return p}})]}}),br=_.create({name:"paste",addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),vr=_.create({name:"tabindex",addProseMirrorPlugins(){return[new m.Plugin({key:new m.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class W{get name(){return this.node.type.name}constructor(t,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=o}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 W(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 W(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 W(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,i=this.pos+r+(s?0:1),a=this.resolvedPos.doc.resolve(i);if(!o&&a.depth<=this.depth)return;const c=new W(a,this.editor,o,o?n:null);o&&(c.actualDepth=this.depth+1),t.push(new W(a,this.editor,o,o?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,o=this.parent;for(;o&&!r;){if(o.node.type.name===t)if(Object.keys(n).length>0){const s=o.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){const c=i[a];if(s[c]!==n[c])break}}else r=o;o=o.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const s=Object.keys(n);return this.children.forEach(i=>{r&&o.length>0||(i.node.type.name===t&&s.every(c=>n[c]===i.node.attrs[c])&&o.push(i),!(r&&o.length>0)&&(o=o.concat(i.querySelectorAll(t,n,r))))}),o}setAttribute(t){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(n)}}const Sr=`.ProseMirror {
@@ -1,5 +1,5 @@
1
1
  import Xe from "tippy.js";
2
- import { E as Qe, a as Ze, P as H, b as $, S as G, k as tn, T as D, D as en, c as Ee, F as V, N as nn, d as xt, w as rn, e as sn, f as on, g as dt, h as tt, s as an, i as te, j as ln, l as cn, m as dn, n as un, o as pn, A as hn, p as fn, q as mn, r as gn, t as yn, u as vn, v as bn, x as Mn, y as Te, z as Sn, B as kn, C as wn, G as En, H as Tn, I as Cn, J as xn, K as zt, R as An, L as On, M as Ln, O as _n, Q as ee, U as Pn, V as Ce, W as Rn, X as Hn, Y as $n, Z as In, _ as Dn, $ as pt, a0 as Vt, a1 as Nn, a2 as Bn, a3 as jn, a4 as xe, a5 as Fn, a6 as ne, a7 as zn, a8 as re, a9 as se, aa as Vn, ab as oe, ac as Wn, ad as Kn, ae as Un, af as qn, ag as Gn, ah as Jn, ai as Yn } from "./vendor-DyAqAGVt.js";
2
+ import { E as Qe, a as Ze, P as H, b as $, S as G, k as tn, T as D, D as en, c as Ee, F as V, N as nn, d as xt, w as rn, e as sn, f as on, g as dt, h as tt, s as an, i as te, j as ln, l as cn, m as dn, n as un, o as pn, A as hn, p as fn, q as mn, r as gn, t as yn, u as vn, v as bn, x as Mn, y as Te, z as Sn, B as kn, C as wn, G as En, H as Tn, I as Cn, J as xn, K as zt, R as An, L as On, M as Ln, O as _n, Q as ee, U as Pn, V as Ce, W as Rn, X as Hn, Y as $n, Z as In, _ as Dn, $ as pt, a0 as Vt, a1 as Nn, a2 as Bn, a3 as jn, a4 as xe, a5 as Fn, a6 as ne, a7 as zn, a8 as re, a9 as se, aa as Vn, ab as oe, ac as Wn, ad as Kn, ae as Un, af as qn, ag as Gn, ah as Jn, ai as Yn } from "./vendor-tDefVoN_.js";
3
3
  import O, { useRef as Xn, useState as Wt, useDebugValue as Ae, useEffect as Kt, forwardRef as Qn, useLayoutEffect as Zn, useContext as Oe, createContext as Le } from "react";
4
4
  import tr, { flushSync as er } from "react-dom";
5
5
  function gt(e) {