@quoreadmin/ui 1.10.20 → 1.10.22

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.
Files changed (211) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index131.js +168 -147
  3. package/dist/index149.js +78 -68
  4. package/dist/index157.js +30 -29
  5. package/dist/index183.js +3 -3
  6. package/dist/index186.js +4 -4
  7. package/dist/index193.js +10 -10
  8. package/dist/index195.js +10 -10
  9. package/dist/index198.js +17 -17
  10. package/dist/index201.js +28 -28
  11. package/dist/index202.js +2 -2
  12. package/dist/index203.js +2 -2
  13. package/dist/index204.js +1 -1
  14. package/dist/index206.js +2 -2
  15. package/dist/index208.js +14 -14
  16. package/dist/index209.js +1 -1
  17. package/dist/index210.js +1 -1
  18. package/dist/index211.js +3 -3
  19. package/dist/index212.js +6 -6
  20. package/dist/index216.js +2 -2
  21. package/dist/index217.js +1 -1
  22. package/dist/index219.js +4 -4
  23. package/dist/index221.js +1 -1
  24. package/dist/index222.js +1 -1
  25. package/dist/index223.js +1 -1
  26. package/dist/index224.js +4 -4
  27. package/dist/index226.js +1 -1
  28. package/dist/index227.js +106 -67
  29. package/dist/index228.js +26 -395
  30. package/dist/index229.js +406 -21
  31. package/dist/index230.js +76 -123
  32. package/dist/index231.js +19 -37
  33. package/dist/index232.js +85 -77
  34. package/dist/index233.js +12 -12
  35. package/dist/index234.js +3 -3
  36. package/dist/index235.js +3 -3
  37. package/dist/index236.js +11 -11
  38. package/dist/index237.js +22 -20
  39. package/dist/index238.js +159 -159
  40. package/dist/index239.js +20 -228
  41. package/dist/index240.js +21 -36
  42. package/dist/index241.js +198 -9
  43. package/dist/index242.js +49 -140
  44. package/dist/index243.js +34 -20
  45. package/dist/index244.js +39 -21
  46. package/dist/index245.js +21 -198
  47. package/dist/index246.js +21 -69
  48. package/dist/index247.js +20 -34
  49. package/dist/index248.js +823 -27
  50. package/dist/index249.js +701 -21
  51. package/dist/index250.js +176 -22
  52. package/dist/index251.js +15 -13
  53. package/dist/index252.js +20 -836
  54. package/dist/index253.js +19 -701
  55. package/dist/index254.js +3 -176
  56. package/dist/index255.js +186 -21
  57. package/dist/index256.js +132 -19
  58. package/dist/index257.js +1223 -20
  59. package/dist/index258.js +20 -3
  60. package/dist/index259.js +21 -186
  61. package/dist/index260.js +21 -132
  62. package/dist/index261.js +29 -1223
  63. package/dist/index262.js +12 -12
  64. package/dist/index263.js +13 -15
  65. package/dist/index264.js +2 -22
  66. package/dist/index265.js +2 -29
  67. package/dist/index266.js +3636 -20
  68. package/dist/index267.js +55 -20
  69. package/dist/index268.js +77 -2
  70. package/dist/index269.js +52 -2
  71. package/dist/index270.js +182 -3603
  72. package/dist/index271.js +8 -53
  73. package/dist/index272.js +40 -60
  74. package/dist/index273.js +44 -35
  75. package/dist/index274.js +32 -193
  76. package/dist/index275.js +74 -9
  77. package/dist/index276.js +707 -38
  78. package/dist/index277.js +25 -44
  79. package/dist/index278.js +46 -36
  80. package/dist/index279.js +10 -74
  81. package/dist/index280.js +679 -700
  82. package/dist/index281.js +817 -39
  83. package/dist/index282.js +160 -63
  84. package/dist/index283.js +227 -10
  85. package/dist/index284.js +36 -704
  86. package/dist/index285.js +9 -819
  87. package/dist/index286.js +253 -3
  88. package/dist/index287.js +2 -27
  89. package/dist/index288.js +104 -219
  90. package/dist/index289.js +83 -8
  91. package/dist/index290.js +59 -118
  92. package/dist/index291.js +8 -83
  93. package/dist/index292.js +3 -262
  94. package/dist/index293.js +25 -4
  95. package/dist/index294.js +51 -137
  96. package/dist/index295.js +25 -72
  97. package/dist/index296.js +20 -85
  98. package/dist/index297.js +21 -28
  99. package/dist/index298.js +16 -16
  100. package/dist/index299.js +17 -75
  101. package/dist/index300.js +23 -4
  102. package/dist/index301.js +79 -2
  103. package/dist/index302.js +21 -82
  104. package/dist/index303.js +929 -47
  105. package/dist/index304.js +21 -5
  106. package/dist/index305.js +19 -4
  107. package/dist/index306.js +19 -178
  108. package/dist/index307.js +67 -61
  109. package/dist/index308.js +18 -74
  110. package/dist/index309.js +19 -2
  111. package/dist/index310.js +21 -78
  112. package/dist/index311.js +21 -53
  113. package/dist/index312.js +63 -26
  114. package/dist/index313.js +1534 -22
  115. package/dist/index314.js +386 -22
  116. package/dist/index315.js +2731 -16
  117. package/dist/index316.js +86 -17
  118. package/dist/index317.js +3792 -23
  119. package/dist/index318.js +55 -1529
  120. package/dist/index319.js +14 -385
  121. package/dist/index320.js +67 -2714
  122. package/dist/index321.js +189 -73
  123. package/dist/index322.js +222 -3768
  124. package/dist/index323.js +254 -52
  125. package/dist/index324.js +6 -15
  126. package/dist/index325.js +130 -74
  127. package/dist/index326.js +66 -195
  128. package/dist/index327.js +81 -240
  129. package/dist/index328.js +25 -75
  130. package/dist/index329.js +14 -20
  131. package/dist/index330.js +66 -926
  132. package/dist/index331.js +3 -21
  133. package/dist/index332.js +2 -20
  134. package/dist/index333.js +82 -19
  135. package/dist/index334.js +52 -68
  136. package/dist/index335.js +6 -19
  137. package/dist/index336.js +5 -19
  138. package/dist/index337.js +178 -21
  139. package/dist/index338.js +62 -21
  140. package/dist/index339.js +74 -62
  141. package/dist/index340.js +36 -9
  142. package/dist/index341.js +9 -10
  143. package/dist/index342.js +13 -14
  144. package/dist/index343.js +55 -10
  145. package/dist/index344.js +11 -16
  146. package/dist/index345.js +13 -8
  147. package/dist/index346.js +57 -12
  148. package/dist/index347.js +48 -51
  149. package/dist/index348.js +28 -9
  150. package/dist/index349.js +2 -14
  151. package/dist/index350.js +5 -58
  152. package/dist/index351.js +2 -52
  153. package/dist/index352.js +22 -30
  154. package/dist/index353.js +41 -2
  155. package/dist/index354.js +2 -5
  156. package/dist/index355.js +11 -2
  157. package/dist/index356.js +19 -22
  158. package/dist/index357.js +9 -40
  159. package/dist/index358.js +10 -2
  160. package/dist/index359.js +16 -10
  161. package/dist/index360.js +2 -20
  162. package/dist/index361.js +9 -2
  163. package/dist/index362.js +10 -9
  164. package/dist/index363.js +14 -19
  165. package/dist/index364.js +19 -56
  166. package/dist/index365.js +19 -28
  167. package/dist/index366.js +63 -6
  168. package/dist/index367.js +36 -51
  169. package/dist/index368.js +19 -7
  170. package/dist/index369.js +56 -11
  171. package/dist/index370.js +29 -7
  172. package/dist/index371.js +6 -27
  173. package/dist/index372.js +52 -2
  174. package/dist/index373.js +6 -69
  175. package/dist/index374.js +11 -166
  176. package/dist/index375.js +7 -37
  177. package/dist/index376.js +28 -20
  178. package/dist/index377.js +2 -20
  179. package/dist/index378.js +67 -61
  180. package/dist/index379.js +166 -36
  181. package/dist/index38.js +2 -2
  182. package/dist/index380.js +17 -31
  183. package/dist/index381.js +100 -10
  184. package/dist/index382.js +90 -3
  185. package/dist/index383.js +98 -4
  186. package/dist/index384.js +30 -12
  187. package/dist/index385.js +11 -7
  188. package/dist/index386.js +3 -11
  189. package/dist/index387.js +3 -4
  190. package/dist/index388.js +13 -33
  191. package/dist/index389.js +7 -31
  192. package/dist/index390.js +12 -28
  193. package/dist/index391.js +5 -61
  194. package/dist/index392.js +33 -101
  195. package/dist/index393.js +31 -91
  196. package/dist/index394.js +27 -97
  197. package/dist/index395.js +60 -16
  198. package/dist/index396.js +1 -1
  199. package/dist/index401.js +1 -1
  200. package/dist/index402.js +2 -2
  201. package/dist/index46.js +6 -3
  202. package/dist/index50.js +1 -1
  203. package/dist/src/components/grid/grid.stories.d.ts +2 -0
  204. package/dist/src/components/list/list.stories.d.ts +1 -0
  205. package/dist/src/components/modal/modal.stories.d.ts +1 -0
  206. package/dist/src/components/page-layout/page-layout.vue.d.ts +4 -0
  207. package/dist/src/components/room-details-popover/room-details-popover.d.ts +3 -0
  208. package/dist/src/components/select/select.d.ts +1 -0
  209. package/dist/src/components/select/select.stories.d.ts +3 -0
  210. package/dist/src/components/time-picker/time-picker.vue.d.ts +3 -0
  211. package/package.json +1 -1
package/dist/index266.js CHANGED
@@ -1,22 +1,3638 @@
1
- import t from "./index310.js";
2
- import { openBlock as C, createElementBlock as r, mergeProps as o, createElementVNode as n } from "vue";
3
- var i = {
4
- name: "SortAmountDownIcon",
5
- extends: t
6
- }, p = /* @__PURE__ */ n("path", {
7
- d: "M4.93953 10.5858L3.83759 11.6877V0.677419C3.83759 0.307097 3.53049 0 3.16017 0C2.78985 0 2.48275 0.307097 2.48275 0.677419V11.6877L1.38082 10.5858C1.11888 10.3239 0.685331 10.3239 0.423396 10.5858C0.16146 10.8477 0.16146 11.2813 0.423396 11.5432L2.68146 13.8013C2.74469 13.8645 2.81694 13.9097 2.89823 13.9458C2.97952 13.9819 3.06985 14 3.16017 14C3.25049 14 3.33178 13.9819 3.42211 13.9458C3.5034 13.9097 3.57565 13.8645 3.63888 13.8013L5.89694 11.5432C6.15888 11.2813 6.15888 10.8477 5.89694 10.5858C5.63501 10.3239 5.20146 10.3239 4.93953 10.5858ZM13.0957 0H7.22468C6.85436 0 6.54726 0.307097 6.54726 0.677419C6.54726 1.04774 6.85436 1.35484 7.22468 1.35484H13.0957C13.466 1.35484 13.7731 1.04774 13.7731 0.677419C13.7731 0.307097 13.466 0 13.0957 0ZM7.22468 5.41935H9.48275C9.85307 5.41935 10.1602 5.72645 10.1602 6.09677C10.1602 6.4671 9.85307 6.77419 9.48275 6.77419H7.22468C6.85436 6.77419 6.54726 6.4671 6.54726 6.09677C6.54726 5.72645 6.85436 5.41935 7.22468 5.41935ZM7.6763 8.12903H7.22468C6.85436 8.12903 6.54726 8.43613 6.54726 8.80645C6.54726 9.17677 6.85436 9.48387 7.22468 9.48387H7.6763C8.04662 9.48387 8.35372 9.17677 8.35372 8.80645C8.35372 8.43613 8.04662 8.12903 7.6763 8.12903ZM7.22468 2.70968H11.2892C11.6595 2.70968 11.9666 3.01677 11.9666 3.3871C11.9666 3.75742 11.6595 4.06452 11.2892 4.06452H7.22468C6.85436 4.06452 6.54726 3.75742 6.54726 3.3871C6.54726 3.01677 6.85436 2.70968 7.22468 2.70968Z",
8
- fill: "currentColor"
9
- }, null, -1), l = [p];
10
- function s(e, a, c, d, m, h) {
11
- return C(), r("svg", o({
12
- width: "14",
13
- height: "14",
14
- viewBox: "0 0 14 14",
15
- fill: "none",
16
- xmlns: "http://www.w3.org/2000/svg"
17
- }, e.pti()), l, 16);
18
- }
19
- i.render = s;
1
+ import { findWrapping as me, canJoin as gt, Transform as he, RemoveMarkStep as ge, liftTarget as ve, joinPoint as Ot, canSplit as Q, ReplaceStep as be, ReplaceAroundStep as ke } from "./index313.js";
2
+ import { createParagraphNear as ye, deleteSelection as we, exitCode as Me, joinUp as xe, joinDown as Se, joinBackward as Ee, joinForward as Te, joinTextblockBackward as Ae, joinTextblockForward as Ce, lift as $e, liftEmptyBlock as Pe, newlineInCode as Ne, selectNodeBackward as Ie, selectNodeForward as Re, selectParentNode as Be, selectTextblockEnd as je, selectTextblockStart as Oe, setBlockType as Tt, wrapIn as De } from "./index314.js";
3
+ import { EditorState as _e, NodeSelection as nt, Selection as z, TextSelection as $, Plugin as P, PluginKey as O, AllSelection as ze } from "./index281.js";
4
+ import { DOMSerializer as Fe, Schema as Dt, Fragment as j, Node as Le, DOMParser as ut, Slice as Ve } from "./index315.js";
5
+ import { liftListItem as He, sinkListItem as Ue, wrapInList as We } from "./index316.js";
6
+ import { EditorView as qe } from "./index317.js";
7
+ import { keymap as Ke } from "./index318.js";
8
+ var Je = Object.defineProperty, vt = (e, t) => {
9
+ for (var n in t)
10
+ Je(e, n, { get: t[n], enumerable: !0 });
11
+ };
12
+ function rt(e) {
13
+ const { state: t, transaction: n } = e;
14
+ let { selection: r } = n, { doc: o } = n, { storedMarks: s } = n;
15
+ return {
16
+ ...t,
17
+ apply: t.apply.bind(t),
18
+ applyTransaction: t.applyTransaction.bind(t),
19
+ plugins: t.plugins,
20
+ schema: t.schema,
21
+ reconfigure: t.reconfigure.bind(t),
22
+ toJSON: t.toJSON.bind(t),
23
+ get storedMarks() {
24
+ return s;
25
+ },
26
+ get selection() {
27
+ return r;
28
+ },
29
+ get doc() {
30
+ return o;
31
+ },
32
+ get tr() {
33
+ return r = n.selection, o = n.doc, s = n.storedMarks, n;
34
+ }
35
+ };
36
+ }
37
+ var ot = class {
38
+ constructor(e) {
39
+ this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
40
+ }
41
+ get hasCustomState() {
42
+ return !!this.customState;
43
+ }
44
+ get state() {
45
+ return this.customState || this.editor.state;
46
+ }
47
+ get commands() {
48
+ const { rawCommands: e, editor: t, state: n } = this, { view: r } = t, { tr: o } = n, s = this.buildProps(o);
49
+ return Object.fromEntries(
50
+ Object.entries(e).map(([i, a]) => [i, (...l) => {
51
+ const u = a(...l)(s);
52
+ return !o.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(o), u;
53
+ }])
54
+ );
55
+ }
56
+ get chain() {
57
+ return () => this.createChain();
58
+ }
59
+ get can() {
60
+ return () => this.createCan();
61
+ }
62
+ createChain(e, t = !0) {
63
+ const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = [], a = !!e, c = e || o.tr, l = () => (!a && t && !c.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(c), i.every((d) => d === !0)), u = {
64
+ ...Object.fromEntries(
65
+ Object.entries(n).map(([d, f]) => [d, (...m) => {
66
+ const h = this.buildProps(c, t), g = f(...m)(h);
67
+ return i.push(g), u;
68
+ }])
69
+ ),
70
+ run: l
71
+ };
72
+ return u;
73
+ }
74
+ createCan(e) {
75
+ const { rawCommands: t, state: n } = this, r = !1, o = e || n.tr, s = this.buildProps(o, r);
76
+ return {
77
+ ...Object.fromEntries(
78
+ Object.entries(t).map(([a, c]) => [a, (...l) => c(...l)({ ...s, dispatch: void 0 })])
79
+ ),
80
+ chain: () => this.createChain(o, r)
81
+ };
82
+ }
83
+ buildProps(e, t = !0) {
84
+ const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = {
85
+ tr: e,
86
+ editor: r,
87
+ view: s,
88
+ state: rt({
89
+ state: o,
90
+ transaction: e
91
+ }),
92
+ dispatch: t ? () => {
93
+ } : void 0,
94
+ chain: () => this.createChain(e, t),
95
+ can: () => this.createCan(e),
96
+ get commands() {
97
+ return Object.fromEntries(
98
+ Object.entries(n).map(([a, c]) => [a, (...l) => c(...l)(i)])
99
+ );
100
+ }
101
+ };
102
+ return i;
103
+ }
104
+ }, _t = {};
105
+ vt(_t, {
106
+ blur: () => Ze,
107
+ clearContent: () => Qe,
108
+ clearNodes: () => Ge,
109
+ command: () => Ye,
110
+ createParagraphNear: () => Xe,
111
+ cut: () => tn,
112
+ deleteCurrentNode: () => en,
113
+ deleteNode: () => nn,
114
+ deleteRange: () => rn,
115
+ deleteSelection: () => on,
116
+ enter: () => sn,
117
+ exitCode: () => an,
118
+ extendMarkRange: () => cn,
119
+ first: () => ln,
120
+ focus: () => un,
121
+ forEach: () => fn,
122
+ insertContent: () => pn,
123
+ insertContentAt: () => gn,
124
+ joinBackward: () => kn,
125
+ joinDown: () => bn,
126
+ joinForward: () => yn,
127
+ joinItemBackward: () => wn,
128
+ joinItemForward: () => Mn,
129
+ joinTextblockBackward: () => xn,
130
+ joinTextblockForward: () => Sn,
131
+ joinUp: () => vn,
132
+ keyboardShortcut: () => Tn,
133
+ lift: () => An,
134
+ liftEmptyBlock: () => Cn,
135
+ liftListItem: () => $n,
136
+ newlineInCode: () => Pn,
137
+ resetAttributes: () => Nn,
138
+ scrollIntoView: () => In,
139
+ selectAll: () => Rn,
140
+ selectNodeBackward: () => Bn,
141
+ selectNodeForward: () => jn,
142
+ selectParentNode: () => On,
143
+ selectTextblockEnd: () => Dn,
144
+ selectTextblockStart: () => _n,
145
+ setContent: () => zn,
146
+ setMark: () => sr,
147
+ setMeta: () => ir,
148
+ setNode: () => ar,
149
+ setNodeSelection: () => cr,
150
+ setTextDirection: () => lr,
151
+ setTextSelection: () => dr,
152
+ sinkListItem: () => ur,
153
+ splitBlock: () => fr,
154
+ splitListItem: () => pr,
155
+ toggleList: () => mr,
156
+ toggleMark: () => hr,
157
+ toggleNode: () => gr,
158
+ toggleWrap: () => vr,
159
+ undoInputRule: () => br,
160
+ unsetAllMarks: () => kr,
161
+ unsetMark: () => yr,
162
+ unsetTextDirection: () => wr,
163
+ updateAttributes: () => Mr,
164
+ wrapIn: () => xr,
165
+ wrapInList: () => Sr
166
+ });
167
+ var Ze = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
168
+ var n;
169
+ e.isDestroyed || (t.dom.blur(), (n = window?.getSelection()) == null || n.removeAllRanges());
170
+ }), !0), Qe = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), Ge = () => ({ state: e, tr: t, dispatch: n }) => {
171
+ const { selection: r } = t, { ranges: o } = r;
172
+ return n && o.forEach(({ $from: s, $to: i }) => {
173
+ e.doc.nodesBetween(s.pos, i.pos, (a, c) => {
174
+ if (a.type.isText)
175
+ return;
176
+ const { doc: l, mapping: u } = t, d = l.resolve(u.map(c)), f = l.resolve(u.map(c + a.nodeSize)), p = d.blockRange(f);
177
+ if (!p)
178
+ return;
179
+ const m = ve(p);
180
+ if (a.type.isTextblock) {
181
+ const { defaultType: h } = d.parent.contentMatchAt(d.index());
182
+ t.setNodeMarkup(p.start, h);
183
+ }
184
+ (m || m === 0) && t.lift(p, m);
185
+ });
186
+ }), !0;
187
+ }, Ye = (e) => (t) => e(t), Xe = () => ({ state: e, dispatch: t }) => ye(e, t), tn = (e, t) => ({ editor: n, tr: r }) => {
188
+ const { state: o } = n, s = o.doc.slice(e.from, e.to);
189
+ r.deleteRange(e.from, e.to);
190
+ const i = r.mapping.map(t);
191
+ return r.insert(i, s.content), r.setSelection(new $(r.doc.resolve(Math.max(i - 1, 0)))), !0;
192
+ }, en = () => ({ tr: e, dispatch: t }) => {
193
+ const { selection: n } = e, r = n.$anchor.node();
194
+ if (r.content.size > 0)
195
+ return !1;
196
+ const o = e.selection.$anchor;
197
+ for (let s = o.depth; s > 0; s -= 1)
198
+ if (o.node(s).type === r.type) {
199
+ if (t) {
200
+ const a = o.before(s), c = o.after(s);
201
+ e.delete(a, c).scrollIntoView();
202
+ }
203
+ return !0;
204
+ }
205
+ return !1;
206
+ };
207
+ function T(e, t) {
208
+ if (typeof e == "string") {
209
+ if (!t.nodes[e])
210
+ throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
211
+ return t.nodes[e];
212
+ }
213
+ return e;
214
+ }
215
+ var nn = (e) => ({ tr: t, state: n, dispatch: r }) => {
216
+ const o = T(e, n.schema), s = t.selection.$anchor;
217
+ for (let i = s.depth; i > 0; i -= 1)
218
+ if (s.node(i).type === o) {
219
+ if (r) {
220
+ const c = s.before(i), l = s.after(i);
221
+ t.delete(c, l).scrollIntoView();
222
+ }
223
+ return !0;
224
+ }
225
+ return !1;
226
+ }, rn = (e) => ({ tr: t, dispatch: n }) => {
227
+ const { from: r, to: o } = e;
228
+ return n && t.delete(r, o), !0;
229
+ }, on = () => ({ state: e, dispatch: t }) => we(e, t), sn = () => ({ commands: e }) => e.keyboardShortcut("Enter"), an = () => ({ state: e, dispatch: t }) => Me(e, t);
230
+ function bt(e) {
231
+ return Object.prototype.toString.call(e) === "[object RegExp]";
232
+ }
233
+ function Y(e, t, n = { strict: !0 }) {
234
+ const r = Object.keys(t);
235
+ return r.length ? r.every((o) => n.strict ? t[o] === e[o] : bt(t[o]) ? t[o].test(e[o]) : t[o] === e[o]) : !0;
236
+ }
237
+ function zt(e, t, n = {}) {
238
+ return e.find((r) => r.type === t && Y(
239
+ // Only check equality for the attributes that are provided
240
+ Object.fromEntries(Object.keys(n).map((o) => [o, r.attrs[o]])),
241
+ n
242
+ ));
243
+ }
244
+ function At(e, t, n = {}) {
245
+ return !!zt(e, t, n);
246
+ }
247
+ function kt(e, t, n) {
248
+ var r;
249
+ if (!e || !t)
250
+ return;
251
+ let o = e.parent.childAfter(e.parentOffset);
252
+ 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 ? void 0 : r.attrs), !zt([...o.node.marks], t, n)))
253
+ return;
254
+ let i = o.index, a = e.start() + o.offset, c = i + 1, l = a + o.node.nodeSize;
255
+ for (; i > 0 && At([...e.parent.child(i - 1).marks], t, n); )
256
+ i -= 1, a -= e.parent.child(i).nodeSize;
257
+ for (; c < e.parent.childCount && At([...e.parent.child(c).marks], t, n); )
258
+ l += e.parent.child(c).nodeSize, c += 1;
259
+ return {
260
+ from: a,
261
+ to: l
262
+ };
263
+ }
264
+ function R(e, t) {
265
+ if (typeof e == "string") {
266
+ if (!t.marks[e])
267
+ throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
268
+ return t.marks[e];
269
+ }
270
+ return e;
271
+ }
272
+ var cn = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
273
+ const s = R(e, r.schema), { doc: i, selection: a } = n, { $from: c, from: l, to: u } = a;
274
+ if (o) {
275
+ const d = kt(c, s, t);
276
+ if (d && d.from <= l && d.to >= u) {
277
+ const f = $.create(i, d.from, d.to);
278
+ n.setSelection(f);
279
+ }
280
+ }
281
+ return !0;
282
+ }, ln = (e) => (t) => {
283
+ const n = typeof e == "function" ? e(t) : e;
284
+ for (let r = 0; r < n.length; r += 1)
285
+ if (n[r](t))
286
+ return !0;
287
+ return !1;
288
+ };
289
+ function Ft(e) {
290
+ return e instanceof $;
291
+ }
292
+ function _(e = 0, t = 0, n = 0) {
293
+ return Math.min(Math.max(e, t), n);
294
+ }
295
+ function Lt(e, t = null) {
296
+ if (!t)
297
+ return null;
298
+ const n = z.atStart(e), r = z.atEnd(e);
299
+ if (t === "start" || t === !0)
300
+ return n;
301
+ if (t === "end")
302
+ return r;
303
+ const o = n.from, s = r.to;
304
+ return t === "all" ? $.create(e, _(0, o, s), _(e.content.size, o, s)) : $.create(e, _(t, o, s), _(t, o, s));
305
+ }
306
+ function Ct() {
307
+ return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
308
+ }
309
+ function X() {
310
+ return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || // iPad on iOS 13 detection
311
+ navigator.userAgent.includes("Mac") && "ontouchend" in document;
312
+ }
313
+ function dn() {
314
+ return typeof navigator < "u" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1;
315
+ }
316
+ var un = (e = null, t = {}) => ({ editor: n, view: r, tr: o, dispatch: s }) => {
317
+ t = {
318
+ scrollIntoView: !0,
319
+ ...t
320
+ };
321
+ const i = () => {
322
+ (X() || Ct()) && r.dom.focus(), dn() && !X() && !Ct() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
323
+ n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
324
+ });
325
+ };
326
+ try {
327
+ if (r.hasFocus() && e === null || e === !1)
328
+ return !0;
329
+ } catch {
330
+ return !1;
331
+ }
332
+ if (s && e === null && !Ft(n.state.selection))
333
+ return i(), !0;
334
+ const a = Lt(o.doc, e) || n.state.selection, c = n.state.selection.eq(a);
335
+ return s && (c || o.setSelection(a), c && o.storedMarks && o.setStoredMarks(o.storedMarks), i()), !0;
336
+ }, fn = (e, t) => (n) => e.every((r, o) => t(r, { ...n, index: o })), pn = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({ from: n.selection.from, to: n.selection.to }, e, t), Vt = (e) => {
337
+ const t = e.childNodes;
338
+ for (let n = t.length - 1; n >= 0; n -= 1) {
339
+ const r = t[n];
340
+ r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && Vt(r);
341
+ }
342
+ return e;
343
+ };
344
+ function W(e) {
345
+ if (typeof window > "u")
346
+ throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");
347
+ const t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
348
+ return Vt(n);
349
+ }
350
+ function V(e, t, n) {
351
+ if (e instanceof Le || e instanceof j)
352
+ return e;
353
+ n = {
354
+ slice: !0,
355
+ parseOptions: {},
356
+ ...n
357
+ };
358
+ const r = typeof e == "object" && e !== null, o = typeof e == "string";
359
+ if (r)
360
+ try {
361
+ if (Array.isArray(e) && e.length > 0)
362
+ return j.fromArray(e.map((a) => t.nodeFromJSON(a)));
363
+ const i = t.nodeFromJSON(e);
364
+ return n.errorOnInvalidContent && i.check(), i;
365
+ } catch (s) {
366
+ if (n.errorOnInvalidContent)
367
+ throw new Error("[tiptap error]: Invalid JSON content", { cause: s });
368
+ return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", s), V("", t, n);
369
+ }
370
+ if (o) {
371
+ if (n.errorOnInvalidContent) {
372
+ let i = !1, a = "";
373
+ const c = new Dt({
374
+ topNode: t.spec.topNode,
375
+ marks: t.spec.marks,
376
+ // Prosemirror's schemas are executed such that: the last to execute, matches last
377
+ // This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
378
+ nodes: t.spec.nodes.append({
379
+ __tiptap__private__unknown__catch__all__node: {
380
+ content: "inline*",
381
+ group: "block",
382
+ parseDOM: [
383
+ {
384
+ tag: "*",
385
+ getAttrs: (l) => (i = !0, a = typeof l == "string" ? l : l.outerHTML, null)
386
+ }
387
+ ]
388
+ }
389
+ })
390
+ });
391
+ if (n.slice ? ut.fromSchema(c).parseSlice(W(e), n.parseOptions) : ut.fromSchema(c).parse(W(e), n.parseOptions), n.errorOnInvalidContent && i)
392
+ throw new Error("[tiptap error]: Invalid HTML content", {
393
+ cause: new Error(`Invalid element found: ${a}`)
394
+ });
395
+ }
396
+ const s = ut.fromSchema(t);
397
+ return n.slice ? s.parseSlice(W(e), n.parseOptions).content : s.parse(W(e), n.parseOptions);
398
+ }
399
+ return V("", t, n);
400
+ }
401
+ function mn(e, t, n) {
402
+ const r = e.steps.length - 1;
403
+ if (r < t)
404
+ return;
405
+ const o = e.steps[r];
406
+ if (!(o instanceof be || o instanceof ke))
407
+ return;
408
+ const s = e.mapping.maps[r];
409
+ let i = 0;
410
+ s.forEach((a, c, l, u) => {
411
+ i === 0 && (i = u);
412
+ }), e.setSelection(z.near(e.doc.resolve(i), n));
413
+ }
414
+ var hn = (e) => !("type" in e), gn = (e, t, n) => ({ tr: r, dispatch: o, editor: s }) => {
415
+ var i;
416
+ if (o) {
417
+ n = {
418
+ parseOptions: s.options.parseOptions,
419
+ updateSelection: !0,
420
+ applyInputRules: !1,
421
+ applyPasteRules: !1,
422
+ ...n
423
+ };
424
+ let a;
425
+ const c = (g) => {
426
+ s.emit("contentError", {
427
+ editor: s,
428
+ error: g,
429
+ disableCollaboration: () => {
430
+ "collaboration" in s.storage && typeof s.storage.collaboration == "object" && s.storage.collaboration && (s.storage.collaboration.isDisabled = !0);
431
+ }
432
+ });
433
+ }, l = {
434
+ preserveWhitespace: "full",
435
+ ...n.parseOptions
436
+ };
437
+ if (!n.errorOnInvalidContent && !s.options.enableContentCheck && s.options.emitContentError)
438
+ try {
439
+ V(t, s.schema, {
440
+ parseOptions: l,
441
+ errorOnInvalidContent: !0
442
+ });
443
+ } catch (g) {
444
+ c(g);
445
+ }
446
+ try {
447
+ a = V(t, s.schema, {
448
+ parseOptions: l,
449
+ errorOnInvalidContent: (i = n.errorOnInvalidContent) != null ? i : s.options.enableContentCheck
450
+ });
451
+ } catch (g) {
452
+ return c(g), !1;
453
+ }
454
+ let { from: u, to: d } = typeof e == "number" ? { from: e, to: e } : { from: e.from, to: e.to }, f = !0, p = !0;
455
+ if ((hn(a) ? a : [a]).forEach((g) => {
456
+ g.check(), f = f ? g.isText && g.marks.length === 0 : !1, p = p ? g.isBlock : !1;
457
+ }), u === d && p) {
458
+ const { parent: g } = r.doc.resolve(u);
459
+ g.isTextblock && !g.type.spec.code && !g.childCount && (u -= 1, d += 1);
460
+ }
461
+ let h;
462
+ if (f) {
463
+ if (Array.isArray(t))
464
+ h = t.map((g) => g.text || "").join("");
465
+ else if (t instanceof j) {
466
+ let g = "";
467
+ t.forEach((v) => {
468
+ v.text && (g += v.text);
469
+ }), h = g;
470
+ } else typeof t == "object" && t && t.text ? h = t.text : h = t;
471
+ r.insertText(h, u, d);
472
+ } else {
473
+ h = a;
474
+ const g = r.doc.resolve(u), v = g.node(), k = g.parentOffset === 0, w = v.isText || v.isTextblock, M = v.content.size > 0;
475
+ k && w && M && (u = Math.max(0, u - 1)), r.replaceWith(u, d, h);
476
+ }
477
+ n.updateSelection && mn(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { from: u, text: h }), n.applyPasteRules && r.setMeta("applyPasteRules", { from: u, text: h });
478
+ }
479
+ return !0;
480
+ }, vn = () => ({ state: e, dispatch: t }) => xe(e, t), bn = () => ({ state: e, dispatch: t }) => Se(e, t), kn = () => ({ state: e, dispatch: t }) => Ee(e, t), yn = () => ({ state: e, dispatch: t }) => Te(e, t), wn = () => ({ state: e, dispatch: t, tr: n }) => {
481
+ try {
482
+ const r = Ot(e.doc, e.selection.$from.pos, -1);
483
+ return r == null ? !1 : (n.join(r, 2), t && t(n), !0);
484
+ } catch {
485
+ return !1;
486
+ }
487
+ }, Mn = () => ({ state: e, dispatch: t, tr: n }) => {
488
+ try {
489
+ const r = Ot(e.doc, e.selection.$from.pos, 1);
490
+ return r == null ? !1 : (n.join(r, 2), t && t(n), !0);
491
+ } catch {
492
+ return !1;
493
+ }
494
+ }, xn = () => ({ state: e, dispatch: t }) => Ae(e, t), Sn = () => ({ state: e, dispatch: t }) => Ce(e, t);
495
+ function Ht() {
496
+ return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
497
+ }
498
+ function En(e) {
499
+ const t = e.split(/-(?!$)/);
500
+ let n = t[t.length - 1];
501
+ n === "Space" && (n = " ");
502
+ let r, o, s, i;
503
+ for (let a = 0; a < t.length - 1; a += 1) {
504
+ const c = t[a];
505
+ if (/^(cmd|meta|m)$/i.test(c))
506
+ i = !0;
507
+ else if (/^a(lt)?$/i.test(c))
508
+ r = !0;
509
+ else if (/^(c|ctrl|control)$/i.test(c))
510
+ o = !0;
511
+ else if (/^s(hift)?$/i.test(c))
512
+ s = !0;
513
+ else if (/^mod$/i.test(c))
514
+ X() || Ht() ? i = !0 : o = !0;
515
+ else
516
+ throw new Error(`Unrecognized modifier name: ${c}`);
517
+ }
518
+ return r && (n = `Alt-${n}`), o && (n = `Ctrl-${n}`), i && (n = `Meta-${n}`), s && (n = `Shift-${n}`), n;
519
+ }
520
+ var Tn = (e) => ({ editor: t, view: n, tr: r, dispatch: o }) => {
521
+ const s = En(e).split(/-(?!$)/), i = s.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), a = new KeyboardEvent("keydown", {
522
+ key: i === "Space" ? " " : i,
523
+ altKey: s.includes("Alt"),
524
+ ctrlKey: s.includes("Ctrl"),
525
+ metaKey: s.includes("Meta"),
526
+ shiftKey: s.includes("Shift"),
527
+ bubbles: !0,
528
+ cancelable: !0
529
+ }), c = t.captureTransaction(() => {
530
+ n.someProp("handleKeyDown", (l) => l(n, a));
531
+ });
532
+ return c?.steps.forEach((l) => {
533
+ const u = l.map(r.mapping);
534
+ u && o && r.maybeStep(u);
535
+ }), !0;
536
+ };
537
+ function H(e, t, n = {}) {
538
+ const { from: r, to: o, empty: s } = e.selection, i = t ? T(t, e.schema) : null, a = [];
539
+ e.doc.nodesBetween(r, o, (d, f) => {
540
+ if (d.isText)
541
+ return;
542
+ const p = Math.max(r, f), m = Math.min(o, f + d.nodeSize);
543
+ a.push({
544
+ node: d,
545
+ from: p,
546
+ to: m
547
+ });
548
+ });
549
+ const c = o - r, l = a.filter((d) => i ? i.name === d.node.type.name : !0).filter((d) => Y(d.node.attrs, n, { strict: !1 }));
550
+ return s ? !!l.length : l.reduce((d, f) => d + f.to - f.from, 0) >= c;
551
+ }
552
+ var An = (e, t = {}) => ({ state: n, dispatch: r }) => {
553
+ const o = T(e, n.schema);
554
+ return H(n, o, t) ? $e(n, r) : !1;
555
+ }, Cn = () => ({ state: e, dispatch: t }) => Pe(e, t), $n = (e) => ({ state: t, dispatch: n }) => {
556
+ const r = T(e, t.schema);
557
+ return He(r)(t, n);
558
+ }, Pn = () => ({ state: e, dispatch: t }) => Ne(e, t);
559
+ function st(e, t) {
560
+ return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
561
+ }
562
+ function $t(e, t) {
563
+ const n = typeof t == "string" ? [t] : t;
564
+ return Object.keys(e).reduce((r, o) => (n.includes(o) || (r[o] = e[o]), r), {});
565
+ }
566
+ var Nn = (e, t) => ({ tr: n, state: r, dispatch: o }) => {
567
+ let s = null, i = null;
568
+ const a = st(
569
+ typeof e == "string" ? e : e.name,
570
+ r.schema
571
+ );
572
+ if (!a)
573
+ return !1;
574
+ a === "node" && (s = T(e, r.schema)), a === "mark" && (i = R(e, r.schema));
575
+ let c = !1;
576
+ return n.selection.ranges.forEach((l) => {
577
+ r.doc.nodesBetween(l.$from.pos, l.$to.pos, (u, d) => {
578
+ s && s === u.type && (c = !0, o && n.setNodeMarkup(d, void 0, $t(u.attrs, t))), i && u.marks.length && u.marks.forEach((f) => {
579
+ i === f.type && (c = !0, o && n.addMark(d, d + u.nodeSize, i.create($t(f.attrs, t))));
580
+ });
581
+ });
582
+ }), c;
583
+ }, In = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), Rn = () => ({ tr: e, dispatch: t }) => {
584
+ if (t) {
585
+ const n = new ze(e.doc);
586
+ e.setSelection(n);
587
+ }
588
+ return !0;
589
+ }, Bn = () => ({ state: e, dispatch: t }) => Ie(e, t), jn = () => ({ state: e, dispatch: t }) => Re(e, t), On = () => ({ state: e, dispatch: t }) => Be(e, t), Dn = () => ({ state: e, dispatch: t }) => je(e, t), _n = () => ({ state: e, dispatch: t }) => Oe(e, t);
590
+ function mt(e, t, n = {}, r = {}) {
591
+ return V(e, t, {
592
+ slice: !1,
593
+ parseOptions: n,
594
+ errorOnInvalidContent: r.errorOnInvalidContent
595
+ });
596
+ }
597
+ var zn = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: o, tr: s, dispatch: i, commands: a }) => {
598
+ const { doc: c } = s;
599
+ if (r.preserveWhitespace !== "full") {
600
+ const l = mt(e, o.schema, r, {
601
+ errorOnInvalidContent: t ?? o.options.enableContentCheck
602
+ });
603
+ return i && s.replaceWith(0, c.content.size, l).setMeta("preventUpdate", !n), !0;
604
+ }
605
+ return i && s.setMeta("preventUpdate", !n), a.insertContentAt({ from: 0, to: c.content.size }, e, {
606
+ parseOptions: r,
607
+ errorOnInvalidContent: t ?? o.options.enableContentCheck
608
+ });
609
+ };
610
+ function Ut(e, t) {
611
+ const n = R(t, e.schema), { from: r, to: o, empty: s } = e.selection, i = [];
612
+ s ? (e.storedMarks && i.push(...e.storedMarks), i.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, o, (c) => {
613
+ i.push(...c.marks);
614
+ });
615
+ const a = i.find((c) => c.type.name === n.name);
616
+ return a ? { ...a.attrs } : {};
617
+ }
618
+ function Fn(e, t) {
619
+ const n = new he(e);
620
+ return t.forEach((r) => {
621
+ r.steps.forEach((o) => {
622
+ n.step(o);
623
+ });
624
+ }), n;
625
+ }
626
+ function Ln(e) {
627
+ for (let t = 0; t < e.edgeCount; t += 1) {
628
+ const { type: n } = e.edge(t);
629
+ if (n.isTextblock && !n.hasRequiredAttrs())
630
+ return n;
631
+ }
632
+ return null;
633
+ }
634
+ function no(e, t, n) {
635
+ const r = [];
636
+ return e.nodesBetween(t.from, t.to, (o, s) => {
637
+ n(o) && r.push({
638
+ node: o,
639
+ pos: s
640
+ });
641
+ }), r;
642
+ }
643
+ function Vn(e, t) {
644
+ for (let n = e.depth; n > 0; n -= 1) {
645
+ const r = e.node(n);
646
+ if (t(r))
647
+ return {
648
+ pos: n > 0 ? e.before(n) : 0,
649
+ start: e.start(n),
650
+ depth: n,
651
+ node: r
652
+ };
653
+ }
654
+ }
655
+ function it(e) {
656
+ return (t) => Vn(t.$from, e);
657
+ }
658
+ function b(e, t, n) {
659
+ return e.config[t] === void 0 && e.parent ? b(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
660
+ ...n,
661
+ parent: e.parent ? b(e.parent, t, n) : null
662
+ }) : e.config[t];
663
+ }
664
+ function yt(e) {
665
+ return e.map((t) => {
666
+ const n = {
667
+ name: t.name,
668
+ options: t.options,
669
+ storage: t.storage
670
+ }, r = b(t, "addExtensions", n);
671
+ return r ? [t, ...yt(r())] : t;
672
+ }).flat(10);
673
+ }
674
+ function wt(e, t) {
675
+ const n = Fe.fromSchema(t).serializeFragment(e), o = document.implementation.createHTMLDocument().createElement("div");
676
+ return o.appendChild(n), o.innerHTML;
677
+ }
678
+ function Wt(e) {
679
+ return typeof e == "function";
680
+ }
681
+ function x(e, t = void 0, ...n) {
682
+ return Wt(e) ? t ? e.bind(t)(...n) : e(...n) : e;
683
+ }
684
+ function Hn(e = {}) {
685
+ return Object.keys(e).length === 0 && e.constructor === Object;
686
+ }
687
+ function F(e) {
688
+ const t = e.filter((o) => o.type === "extension"), n = e.filter((o) => o.type === "node"), r = e.filter((o) => o.type === "mark");
689
+ return {
690
+ baseExtensions: t,
691
+ nodeExtensions: n,
692
+ markExtensions: r
693
+ };
694
+ }
695
+ function qt(e) {
696
+ const t = [], { nodeExtensions: n, markExtensions: r } = F(e), o = [...n, ...r], s = {
697
+ default: null,
698
+ validate: void 0,
699
+ rendered: !0,
700
+ renderHTML: null,
701
+ parseHTML: null,
702
+ keepOnSplit: !0,
703
+ isRequired: !1
704
+ };
705
+ return e.forEach((i) => {
706
+ const a = {
707
+ name: i.name,
708
+ options: i.options,
709
+ storage: i.storage,
710
+ extensions: o
711
+ }, c = b(
712
+ i,
713
+ "addGlobalAttributes",
714
+ a
715
+ );
716
+ if (!c)
717
+ return;
718
+ c().forEach((u) => {
719
+ u.types.forEach((d) => {
720
+ Object.entries(u.attributes).forEach(([f, p]) => {
721
+ t.push({
722
+ type: d,
723
+ name: f,
724
+ attribute: {
725
+ ...s,
726
+ ...p
727
+ }
728
+ });
729
+ });
730
+ });
731
+ });
732
+ }), o.forEach((i) => {
733
+ const a = {
734
+ name: i.name,
735
+ options: i.options,
736
+ storage: i.storage
737
+ }, c = b(
738
+ i,
739
+ "addAttributes",
740
+ a
741
+ );
742
+ if (!c)
743
+ return;
744
+ const l = c();
745
+ Object.entries(l).forEach(([u, d]) => {
746
+ const f = {
747
+ ...s,
748
+ ...d
749
+ };
750
+ typeof f?.default == "function" && (f.default = f.default()), f?.isRequired && f?.default === void 0 && delete f.default, t.push({
751
+ type: i.name,
752
+ name: u,
753
+ attribute: f
754
+ });
755
+ });
756
+ }), t;
757
+ }
758
+ function Un(...e) {
759
+ return e.filter((t) => !!t).reduce((t, n) => {
760
+ const r = { ...t };
761
+ return Object.entries(n).forEach(([o, s]) => {
762
+ if (!r[o]) {
763
+ r[o] = s;
764
+ return;
765
+ }
766
+ if (o === "class") {
767
+ const a = s ? String(s).split(" ") : [], c = r[o] ? r[o].split(" ") : [], l = a.filter((u) => !c.includes(u));
768
+ r[o] = [...c, ...l].join(" ");
769
+ } else if (o === "style") {
770
+ const a = s ? s.split(";").map((u) => u.trim()).filter(Boolean) : [], c = r[o] ? r[o].split(";").map((u) => u.trim()).filter(Boolean) : [], l = /* @__PURE__ */ new Map();
771
+ c.forEach((u) => {
772
+ const [d, f] = u.split(":").map((p) => p.trim());
773
+ l.set(d, f);
774
+ }), a.forEach((u) => {
775
+ const [d, f] = u.split(":").map((p) => p.trim());
776
+ l.set(d, f);
777
+ }), r[o] = Array.from(l.entries()).map(([u, d]) => `${u}: ${d}`).join("; ");
778
+ } else
779
+ r[o] = s;
780
+ }), r;
781
+ }, {});
782
+ }
783
+ function tt(e, t) {
784
+ return t.filter((n) => n.type === e.type.name).filter((n) => n.attribute.rendered).map((n) => n.attribute.renderHTML ? n.attribute.renderHTML(e.attrs) || {} : {
785
+ [n.name]: e.attrs[n.name]
786
+ }).reduce((n, r) => Un(n, r), {});
787
+ }
788
+ function Wn(e) {
789
+ return typeof e != "string" ? e : e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" ? !0 : e === "false" ? !1 : e;
790
+ }
791
+ function Pt(e, t) {
792
+ return "style" in e ? e : {
793
+ ...e,
794
+ getAttrs: (n) => {
795
+ const r = e.getAttrs ? e.getAttrs(n) : e.attrs;
796
+ if (r === !1)
797
+ return !1;
798
+ const o = t.reduce((s, i) => {
799
+ const a = i.attribute.parseHTML ? i.attribute.parseHTML(n) : Wn(n.getAttribute(i.name));
800
+ return a == null ? s : {
801
+ ...s,
802
+ [i.name]: a
803
+ };
804
+ }, {});
805
+ return { ...r, ...o };
806
+ }
807
+ };
808
+ }
809
+ function Nt(e) {
810
+ return Object.fromEntries(
811
+ // @ts-ignore
812
+ Object.entries(e).filter(([t, n]) => t === "attrs" && Hn(n) ? !1 : n != null)
813
+ );
814
+ }
815
+ function It(e) {
816
+ var t, n;
817
+ const r = {};
818
+ return !((t = e?.attribute) != null && t.isRequired) && "default" in (e?.attribute || {}) && (r.default = e.attribute.default), ((n = e?.attribute) == null ? void 0 : n.validate) !== void 0 && (r.validate = e.attribute.validate), [e.name, r];
819
+ }
820
+ function qn(e, t) {
821
+ var n;
822
+ const r = qt(e), { nodeExtensions: o, markExtensions: s } = F(e), i = (n = o.find((l) => b(l, "topNode"))) == null ? void 0 : n.name, a = Object.fromEntries(
823
+ o.map((l) => {
824
+ const u = r.filter((v) => v.type === l.name), d = {
825
+ name: l.name,
826
+ options: l.options,
827
+ storage: l.storage,
828
+ editor: t
829
+ }, f = e.reduce((v, k) => {
830
+ const w = b(k, "extendNodeSchema", d);
831
+ return {
832
+ ...v,
833
+ ...w ? w(l) : {}
834
+ };
835
+ }, {}), p = Nt({
836
+ ...f,
837
+ content: x(b(l, "content", d)),
838
+ marks: x(b(l, "marks", d)),
839
+ group: x(b(l, "group", d)),
840
+ inline: x(b(l, "inline", d)),
841
+ atom: x(b(l, "atom", d)),
842
+ selectable: x(b(l, "selectable", d)),
843
+ draggable: x(b(l, "draggable", d)),
844
+ code: x(b(l, "code", d)),
845
+ whitespace: x(b(l, "whitespace", d)),
846
+ linebreakReplacement: x(
847
+ b(l, "linebreakReplacement", d)
848
+ ),
849
+ defining: x(b(l, "defining", d)),
850
+ isolating: x(b(l, "isolating", d)),
851
+ attrs: Object.fromEntries(u.map(It))
852
+ }), m = x(b(l, "parseHTML", d));
853
+ m && (p.parseDOM = m.map(
854
+ (v) => Pt(v, u)
855
+ ));
856
+ const h = b(l, "renderHTML", d);
857
+ h && (p.toDOM = (v) => h({
858
+ node: v,
859
+ HTMLAttributes: tt(v, u)
860
+ }));
861
+ const g = b(l, "renderText", d);
862
+ return g && (p.toText = g), [l.name, p];
863
+ })
864
+ ), c = Object.fromEntries(
865
+ s.map((l) => {
866
+ const u = r.filter((g) => g.type === l.name), d = {
867
+ name: l.name,
868
+ options: l.options,
869
+ storage: l.storage,
870
+ editor: t
871
+ }, f = e.reduce((g, v) => {
872
+ const k = b(v, "extendMarkSchema", d);
873
+ return {
874
+ ...g,
875
+ ...k ? k(l) : {}
876
+ };
877
+ }, {}), p = Nt({
878
+ ...f,
879
+ inclusive: x(b(l, "inclusive", d)),
880
+ excludes: x(b(l, "excludes", d)),
881
+ group: x(b(l, "group", d)),
882
+ spanning: x(b(l, "spanning", d)),
883
+ code: x(b(l, "code", d)),
884
+ attrs: Object.fromEntries(u.map(It))
885
+ }), m = x(b(l, "parseHTML", d));
886
+ m && (p.parseDOM = m.map(
887
+ (g) => Pt(g, u)
888
+ ));
889
+ const h = b(l, "renderHTML", d);
890
+ return h && (p.toDOM = (g) => h({
891
+ mark: g,
892
+ HTMLAttributes: tt(g, u)
893
+ })), [l.name, p];
894
+ })
895
+ );
896
+ return new Dt({
897
+ topNode: i,
898
+ nodes: a,
899
+ marks: c
900
+ });
901
+ }
902
+ function Kn(e) {
903
+ const t = e.filter((n, r) => e.indexOf(n) !== r);
904
+ return Array.from(new Set(t));
905
+ }
906
+ function et(e) {
907
+ return e.sort((n, r) => {
908
+ const o = b(n, "priority") || 100, s = b(r, "priority") || 100;
909
+ return o > s ? -1 : o < s ? 1 : 0;
910
+ });
911
+ }
912
+ function Kt(e) {
913
+ const t = et(yt(e)), n = Kn(t.map((r) => r.name));
914
+ return n.length && console.warn(
915
+ `[tiptap warn]: Duplicate extension names found: [${n.map((r) => `'${r}'`).join(", ")}]. This can lead to issues.`
916
+ ), t;
917
+ }
918
+ function Jt(e, t, n) {
919
+ const { from: r, to: o } = t, { blockSeparator: s = `
920
+
921
+ `, textSerializers: i = {} } = n || {};
922
+ let a = "";
923
+ return e.nodesBetween(r, o, (c, l, u, d) => {
924
+ var f;
925
+ c.isBlock && l > r && (a += s);
926
+ const p = i?.[c.type.name];
927
+ if (p)
928
+ return u && (a += p({
929
+ node: c,
930
+ pos: l,
931
+ parent: u,
932
+ index: d,
933
+ range: t
934
+ })), !1;
935
+ c.isText && (a += (f = c?.text) == null ? void 0 : f.slice(Math.max(r, l) - l, o - l));
936
+ }), a;
937
+ }
938
+ function Jn(e, t) {
939
+ const n = {
940
+ from: 0,
941
+ to: e.content.size
942
+ };
943
+ return Jt(e, n, t);
944
+ }
945
+ function Zt(e) {
946
+ return Object.fromEntries(
947
+ Object.entries(e.nodes).filter(([, t]) => t.spec.toText).map(([t, n]) => [t, n.spec.toText])
948
+ );
949
+ }
950
+ function Zn(e, t) {
951
+ const n = T(t, e.schema), { from: r, to: o } = e.selection, s = [];
952
+ e.doc.nodesBetween(r, o, (a) => {
953
+ s.push(a);
954
+ });
955
+ const i = s.reverse().find((a) => a.type.name === n.name);
956
+ return i ? { ...i.attrs } : {};
957
+ }
958
+ function Qn(e, t) {
959
+ const n = st(
960
+ typeof t == "string" ? t : t.name,
961
+ e.schema
962
+ );
963
+ return n === "node" ? Zn(e, t) : n === "mark" ? Ut(e, t) : {};
964
+ }
965
+ function Gn(e, t = JSON.stringify) {
966
+ const n = {};
967
+ return e.filter((r) => {
968
+ const o = t(r);
969
+ return Object.prototype.hasOwnProperty.call(n, o) ? !1 : n[o] = !0;
970
+ });
971
+ }
972
+ function Yn(e) {
973
+ const t = Gn(e);
974
+ 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));
975
+ }
976
+ function Xn(e) {
977
+ const { mapping: t, steps: n } = e, r = [];
978
+ return t.maps.forEach((o, s) => {
979
+ const i = [];
980
+ if (o.ranges.length)
981
+ o.forEach((a, c) => {
982
+ i.push({ from: a, to: c });
983
+ });
984
+ else {
985
+ const { from: a, to: c } = n[s];
986
+ if (a === void 0 || c === void 0)
987
+ return;
988
+ i.push({ from: a, to: c });
989
+ }
990
+ i.forEach(({ from: a, to: c }) => {
991
+ const l = t.slice(s).map(a, -1), u = t.slice(s).map(c), d = t.invert().map(l, -1), f = t.invert().map(u);
992
+ r.push({
993
+ oldRange: {
994
+ from: d,
995
+ to: f
996
+ },
997
+ newRange: {
998
+ from: l,
999
+ to: u
1000
+ }
1001
+ });
1002
+ });
1003
+ }), Yn(r);
1004
+ }
1005
+ function Qt(e, t, n) {
1006
+ const r = [];
1007
+ return e === t ? n.resolve(e).marks().forEach((o) => {
1008
+ const s = n.resolve(e), i = kt(s, o.type);
1009
+ i && r.push({
1010
+ mark: o,
1011
+ ...i
1012
+ });
1013
+ }) : n.nodesBetween(e, t, (o, s) => {
1014
+ !o || o?.nodeSize === void 0 || r.push(
1015
+ ...o.marks.map((i) => ({
1016
+ from: s,
1017
+ to: s + o.nodeSize,
1018
+ mark: i
1019
+ }))
1020
+ );
1021
+ }), r;
1022
+ }
1023
+ var ro = (e, t, n, r = 20) => {
1024
+ const o = e.doc.resolve(n);
1025
+ let s = r, i = null;
1026
+ for (; s > 0 && i === null; ) {
1027
+ const a = o.node(s);
1028
+ a?.type.name === t ? i = a : s -= 1;
1029
+ }
1030
+ return [i, s];
1031
+ };
1032
+ function q(e, t) {
1033
+ return t.nodes[e] || t.marks[e] || null;
1034
+ }
1035
+ function G(e, t, n) {
1036
+ return Object.fromEntries(
1037
+ Object.entries(n).filter(([r]) => {
1038
+ const o = e.find((s) => s.type === t && s.name === r);
1039
+ return o ? o.attribute.keepOnSplit : !1;
1040
+ })
1041
+ );
1042
+ }
1043
+ var tr = (e, t = 500) => {
1044
+ let n = "";
1045
+ const r = e.parentOffset;
1046
+ return e.parent.nodesBetween(Math.max(0, r - t), r, (o, s, i, a) => {
1047
+ var c, l;
1048
+ const u = ((l = (c = o.type.spec).toText) == null ? void 0 : l.call(c, {
1049
+ node: o,
1050
+ pos: s,
1051
+ parent: i,
1052
+ index: a
1053
+ })) || o.textContent || "%leaf%";
1054
+ n += o.isAtom && !o.isText ? u : u.slice(0, Math.max(0, r - s));
1055
+ }), n;
1056
+ };
1057
+ function ht(e, t, n = {}) {
1058
+ const { empty: r, ranges: o } = e.selection, s = t ? R(t, e.schema) : null;
1059
+ if (r)
1060
+ return !!(e.storedMarks || e.selection.$from.marks()).filter((d) => s ? s.name === d.type.name : !0).find((d) => Y(d.attrs, n, { strict: !1 }));
1061
+ let i = 0;
1062
+ const a = [];
1063
+ if (o.forEach(({ $from: d, $to: f }) => {
1064
+ const p = d.pos, m = f.pos;
1065
+ e.doc.nodesBetween(p, m, (h, g) => {
1066
+ if (!h.isText && !h.marks.length)
1067
+ return;
1068
+ const v = Math.max(p, g), k = Math.min(m, g + h.nodeSize), w = k - v;
1069
+ i += w, a.push(
1070
+ ...h.marks.map((M) => ({
1071
+ mark: M,
1072
+ from: v,
1073
+ to: k
1074
+ }))
1075
+ );
1076
+ });
1077
+ }), i === 0)
1078
+ return !1;
1079
+ const c = a.filter((d) => s ? s.name === d.mark.type.name : !0).filter((d) => Y(d.mark.attrs, n, { strict: !1 })).reduce((d, f) => d + f.to - f.from, 0), l = a.filter((d) => s ? d.mark.type !== s && d.mark.type.excludes(s) : !0).reduce((d, f) => d + f.to - f.from, 0);
1080
+ return (c > 0 ? c + l : c) >= i;
1081
+ }
1082
+ function er(e, t, n = {}) {
1083
+ if (!t)
1084
+ return H(e, null, n) || ht(e, null, n);
1085
+ const r = st(t, e.schema);
1086
+ return r === "node" ? H(e, t, n) : r === "mark" ? ht(e, t, n) : !1;
1087
+ }
1088
+ var oo = (e, t) => {
1089
+ const { $from: n, $to: r, $anchor: o } = e.selection;
1090
+ if (t) {
1091
+ const s = it((a) => a.type.name === t)(e.selection);
1092
+ if (!s)
1093
+ return !1;
1094
+ const i = e.doc.resolve(s.pos + 1);
1095
+ return o.pos + 1 === i.end();
1096
+ }
1097
+ return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
1098
+ }, so = (e) => {
1099
+ const { $from: t, $to: n } = e.selection;
1100
+ return !(t.parentOffset > 0 || t.pos !== n.pos);
1101
+ };
1102
+ function Rt(e, t) {
1103
+ return Array.isArray(t) ? t.some((n) => (typeof n == "string" ? n : n.name) === e.name) : t;
1104
+ }
1105
+ function Bt(e, t) {
1106
+ const { nodeExtensions: n } = F(t), r = n.find((i) => i.name === e);
1107
+ if (!r)
1108
+ return !1;
1109
+ const o = {
1110
+ name: r.name,
1111
+ options: r.options,
1112
+ storage: r.storage
1113
+ }, s = x(b(r, "group", o));
1114
+ return typeof s != "string" ? !1 : s.split(" ").includes("list");
1115
+ }
1116
+ function Mt(e, {
1117
+ checkChildren: t = !0,
1118
+ ignoreWhitespace: n = !1
1119
+ } = {}) {
1120
+ var r;
1121
+ if (n) {
1122
+ if (e.type.name === "hardBreak")
1123
+ return !0;
1124
+ if (e.isText)
1125
+ return /^\s*$/m.test((r = e.text) != null ? r : "");
1126
+ }
1127
+ if (e.isText)
1128
+ return !e.text;
1129
+ if (e.isAtom || e.isLeaf)
1130
+ return !1;
1131
+ if (e.content.childCount === 0)
1132
+ return !0;
1133
+ if (t) {
1134
+ let o = !0;
1135
+ return e.content.forEach((s) => {
1136
+ o !== !1 && (Mt(s, { ignoreWhitespace: n, checkChildren: t }) || (o = !1));
1137
+ }), o;
1138
+ }
1139
+ return !1;
1140
+ }
1141
+ function io(e) {
1142
+ return e instanceof nt;
1143
+ }
1144
+ var Gt = class Yt {
1145
+ constructor(t) {
1146
+ this.position = t;
1147
+ }
1148
+ /**
1149
+ * Creates a MappablePosition from a JSON object.
1150
+ */
1151
+ static fromJSON(t) {
1152
+ return new Yt(t.position);
1153
+ }
1154
+ /**
1155
+ * Converts the MappablePosition to a JSON object.
1156
+ */
1157
+ toJSON() {
1158
+ return {
1159
+ position: this.position
1160
+ };
1161
+ }
1162
+ };
1163
+ function nr(e, t) {
1164
+ const n = t.mapping.mapResult(e.position);
1165
+ return {
1166
+ position: new Gt(n.pos),
1167
+ mapResult: n
1168
+ };
1169
+ }
1170
+ function rr(e) {
1171
+ return new Gt(e);
1172
+ }
1173
+ function or(e, t, n) {
1174
+ var r;
1175
+ const { selection: o } = t;
1176
+ let s = null;
1177
+ if (Ft(o) && (s = o.$cursor), s) {
1178
+ const a = (r = e.storedMarks) != null ? r : s.marks();
1179
+ return s.parent.type.allowsMarkType(n) && (!!n.isInSet(a) || !a.some((l) => l.type.excludes(n)));
1180
+ }
1181
+ const { ranges: i } = o;
1182
+ return i.some(({ $from: a, $to: c }) => {
1183
+ let l = a.depth === 0 ? e.doc.inlineContent && e.doc.type.allowsMarkType(n) : !1;
1184
+ return e.doc.nodesBetween(a.pos, c.pos, (u, d, f) => {
1185
+ if (l)
1186
+ return !1;
1187
+ if (u.isInline) {
1188
+ const p = !f || f.type.allowsMarkType(n), m = !!n.isInSet(u.marks) || !u.marks.some((h) => h.type.excludes(n));
1189
+ l = p && m;
1190
+ }
1191
+ return !l;
1192
+ }), l;
1193
+ });
1194
+ }
1195
+ var sr = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
1196
+ const { selection: s } = n, { empty: i, ranges: a } = s, c = R(e, r.schema);
1197
+ if (o)
1198
+ if (i) {
1199
+ const l = Ut(r, c);
1200
+ n.addStoredMark(
1201
+ c.create({
1202
+ ...l,
1203
+ ...t
1204
+ })
1205
+ );
1206
+ } else
1207
+ a.forEach((l) => {
1208
+ const u = l.$from.pos, d = l.$to.pos;
1209
+ r.doc.nodesBetween(u, d, (f, p) => {
1210
+ const m = Math.max(p, u), h = Math.min(p + f.nodeSize, d);
1211
+ f.marks.find((v) => v.type === c) ? f.marks.forEach((v) => {
1212
+ c === v.type && n.addMark(
1213
+ m,
1214
+ h,
1215
+ c.create({
1216
+ ...v.attrs,
1217
+ ...t
1218
+ })
1219
+ );
1220
+ }) : n.addMark(m, h, c.create(t));
1221
+ });
1222
+ });
1223
+ return or(r, n, c);
1224
+ }, ir = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), ar = (e, t = {}) => ({ state: n, dispatch: r, chain: o }) => {
1225
+ const s = T(e, n.schema);
1226
+ let i;
1227
+ return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), s.isTextblock ? o().command(({ commands: a }) => Tt(s, { ...i, ...t })(n) ? !0 : a.clearNodes()).command(({ state: a }) => Tt(s, { ...i, ...t })(a, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
1228
+ }, cr = (e) => ({ tr: t, dispatch: n }) => {
1229
+ if (n) {
1230
+ const { doc: r } = t, o = _(e, 0, r.content.size), s = nt.create(r, o);
1231
+ t.setSelection(s);
1232
+ }
1233
+ return !0;
1234
+ }, lr = (e, t) => ({ tr: n, state: r, dispatch: o }) => {
1235
+ const { selection: s } = r;
1236
+ let i, a;
1237
+ return typeof t == "number" ? (i = t, a = t) : t && "from" in t && "to" in t ? (i = t.from, a = t.to) : (i = s.from, a = s.to), o && n.doc.nodesBetween(i, a, (c, l) => {
1238
+ c.isText || n.setNodeMarkup(l, void 0, {
1239
+ ...c.attrs,
1240
+ dir: e
1241
+ });
1242
+ }), !0;
1243
+ }, dr = (e) => ({ tr: t, dispatch: n }) => {
1244
+ if (n) {
1245
+ const { doc: r } = t, { from: o, to: s } = typeof e == "number" ? { from: e, to: e } : e, i = $.atStart(r).from, a = $.atEnd(r).to, c = _(o, i, a), l = _(s, i, a), u = $.create(r, c, l);
1246
+ t.setSelection(u);
1247
+ }
1248
+ return !0;
1249
+ }, ur = (e) => ({ state: t, dispatch: n }) => {
1250
+ const r = T(e, t.schema);
1251
+ return Ue(r)(t, n);
1252
+ };
1253
+ function jt(e, t) {
1254
+ const n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
1255
+ if (n) {
1256
+ const r = n.filter((o) => t?.includes(o.type.name));
1257
+ e.tr.ensureMarks(r);
1258
+ }
1259
+ }
1260
+ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: o }) => {
1261
+ const { selection: s, doc: i } = t, { $from: a, $to: c } = s, l = o.extensionManager.attributes, u = G(l, a.node().type.name, a.node().attrs);
1262
+ if (s instanceof nt && s.node.isBlock)
1263
+ return !a.parentOffset || !Q(i, a.pos) ? !1 : (r && (e && jt(n, o.extensionManager.splittableMarks), t.split(a.pos).scrollIntoView()), !0);
1264
+ if (!a.parent.isBlock)
1265
+ return !1;
1266
+ const d = c.parentOffset === c.parent.content.size, f = a.depth === 0 ? void 0 : Ln(a.node(-1).contentMatchAt(a.indexAfter(-1)));
1267
+ let p = d && f ? [
1268
+ {
1269
+ type: f,
1270
+ attrs: u
1271
+ }
1272
+ ] : void 0, m = Q(t.doc, t.mapping.map(a.pos), 1, p);
1273
+ if (!p && !m && Q(t.doc, t.mapping.map(a.pos), 1, f ? [{ type: f }] : void 0) && (m = !0, p = f ? [
1274
+ {
1275
+ type: f,
1276
+ attrs: u
1277
+ }
1278
+ ] : void 0), r) {
1279
+ if (m && (s instanceof $ && t.deleteSelection(), t.split(t.mapping.map(a.pos), 1, p), f && !d && !a.parentOffset && a.parent.type !== f)) {
1280
+ const h = t.mapping.map(a.before()), g = t.doc.resolve(h);
1281
+ a.node(-1).canReplaceWith(g.index(), g.index() + 1, f) && t.setNodeMarkup(t.mapping.map(a.before()), f);
1282
+ }
1283
+ e && jt(n, o.extensionManager.splittableMarks), t.scrollIntoView();
1284
+ }
1285
+ return m;
1286
+ }, pr = (e, t = {}) => ({ tr: n, state: r, dispatch: o, editor: s }) => {
1287
+ var i;
1288
+ const a = T(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
1289
+ if (u && u.isBlock || c.depth < 2 || !c.sameParent(l))
1290
+ return !1;
1291
+ const d = c.node(-1);
1292
+ if (d.type !== a)
1293
+ return !1;
1294
+ const f = s.extensionManager.attributes;
1295
+ if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
1296
+ if (c.depth === 2 || c.node(-3).type !== a || c.index(-2) !== c.node(-2).childCount - 1)
1297
+ return !1;
1298
+ if (o) {
1299
+ let v = j.empty;
1300
+ const k = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
1301
+ for (let A = c.depth - k; A >= c.depth - 3; A -= 1)
1302
+ v = j.from(c.node(A).copy(v));
1303
+ const w = (
1304
+ // eslint-disable-next-line no-nested-ternary
1305
+ c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3
1306
+ ), M = {
1307
+ ...G(f, c.node().type.name, c.node().attrs),
1308
+ ...t
1309
+ }, y = ((i = a.contentMatch.defaultType) == null ? void 0 : i.createAndFill(M)) || void 0;
1310
+ v = v.append(j.from(a.createAndFill(null, y) || void 0));
1311
+ const S = c.before(c.depth - (k - 1));
1312
+ n.replace(S, c.after(-w), new Ve(v, 4 - k, 0));
1313
+ let E = -1;
1314
+ n.doc.nodesBetween(S, n.doc.content.size, (A, C) => {
1315
+ if (E > -1)
1316
+ return !1;
1317
+ A.isTextblock && A.content.size === 0 && (E = C + 1);
1318
+ }), E > -1 && n.setSelection($.near(n.doc.resolve(E))), n.scrollIntoView();
1319
+ }
1320
+ return !0;
1321
+ }
1322
+ const p = l.pos === c.end() ? d.contentMatchAt(0).defaultType : null, m = {
1323
+ ...G(f, d.type.name, d.attrs),
1324
+ ...t
1325
+ }, h = {
1326
+ ...G(f, c.node().type.name, c.node().attrs),
1327
+ ...t
1328
+ };
1329
+ n.delete(c.pos, l.pos);
1330
+ const g = p ? [
1331
+ { type: a, attrs: m },
1332
+ { type: p, attrs: h }
1333
+ ] : [{ type: a, attrs: m }];
1334
+ if (!Q(n.doc, c.pos, 2))
1335
+ return !1;
1336
+ if (o) {
1337
+ const { selection: v, storedMarks: k } = r, { splittableMarks: w } = s.extensionManager, M = k || v.$to.parentOffset && v.$from.marks();
1338
+ if (n.split(c.pos, 2, g).scrollIntoView(), !M || !o)
1339
+ return !0;
1340
+ const y = M.filter((S) => w.includes(S.type.name));
1341
+ n.ensureMarks(y);
1342
+ }
1343
+ return !0;
1344
+ }, ft = (e, t) => {
1345
+ const n = it((i) => i.type === t)(e.selection);
1346
+ if (!n)
1347
+ return !0;
1348
+ const r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
1349
+ if (r === void 0)
1350
+ return !0;
1351
+ const o = e.doc.nodeAt(r);
1352
+ return n.node.type === o?.type && gt(e.doc, n.pos) && e.join(n.pos), !0;
1353
+ }, pt = (e, t) => {
1354
+ const n = it((i) => i.type === t)(e.selection);
1355
+ if (!n)
1356
+ return !0;
1357
+ const r = e.doc.resolve(n.start).after(n.depth);
1358
+ if (r === void 0)
1359
+ return !0;
1360
+ const o = e.doc.nodeAt(r);
1361
+ return n.node.type === o?.type && gt(e.doc, r) && e.join(r), !0;
1362
+ }, mr = (e, t, n, r = {}) => ({ editor: o, tr: s, state: i, dispatch: a, chain: c, commands: l, can: u }) => {
1363
+ const { extensions: d, splittableMarks: f } = o.extensionManager, p = T(e, i.schema), m = T(t, i.schema), { selection: h, storedMarks: g } = i, { $from: v, $to: k } = h, w = v.blockRange(k), M = g || h.$to.parentOffset && h.$from.marks();
1364
+ if (!w)
1365
+ return !1;
1366
+ const y = it((S) => Bt(S.type.name, d))(h);
1367
+ if (w.depth >= 1 && y && w.depth - y.depth <= 1) {
1368
+ if (y.node.type === p)
1369
+ return l.liftListItem(m);
1370
+ if (Bt(y.node.type.name, d) && p.validContent(y.node.content) && a)
1371
+ return c().command(() => (s.setNodeMarkup(y.pos, p), !0)).command(() => ft(s, p)).command(() => pt(s, p)).run();
1372
+ }
1373
+ return !n || !M || !a ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => ft(s, p)).command(() => pt(s, p)).run() : c().command(() => {
1374
+ const S = u().wrapInList(p, r), E = M.filter((A) => f.includes(A.type.name));
1375
+ return s.ensureMarks(E), S ? !0 : l.clearNodes();
1376
+ }).wrapInList(p, r).command(() => ft(s, p)).command(() => pt(s, p)).run();
1377
+ }, hr = (e, t = {}, n = {}) => ({ state: r, commands: o }) => {
1378
+ const { extendEmptyMarkRange: s = !1 } = n, i = R(e, r.schema);
1379
+ return ht(r, i, t) ? o.unsetMark(i, { extendEmptyMarkRange: s }) : o.setMark(i, t);
1380
+ }, gr = (e, t, n = {}) => ({ state: r, commands: o }) => {
1381
+ const s = T(e, r.schema), i = T(t, r.schema), a = H(r, s, n);
1382
+ let c;
1383
+ return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), a ? o.setNode(i, c) : o.setNode(s, { ...c, ...n });
1384
+ }, vr = (e, t = {}) => ({ state: n, commands: r }) => {
1385
+ const o = T(e, n.schema);
1386
+ return H(n, o, t) ? r.lift(o) : r.wrapIn(o, t);
1387
+ }, br = () => ({ state: e, dispatch: t }) => {
1388
+ const n = e.plugins;
1389
+ for (let r = 0; r < n.length; r += 1) {
1390
+ const o = n[r];
1391
+ let s;
1392
+ if (o.spec.isInputRules && (s = o.getState(e))) {
1393
+ if (t) {
1394
+ const i = e.tr, a = s.transform;
1395
+ for (let c = a.steps.length - 1; c >= 0; c -= 1)
1396
+ i.step(a.steps[c].invert(a.docs[c]));
1397
+ if (s.text) {
1398
+ const c = i.doc.resolve(s.from).marks();
1399
+ i.replaceWith(s.from, s.to, e.schema.text(s.text, c));
1400
+ } else
1401
+ i.delete(s.from, s.to);
1402
+ }
1403
+ return !0;
1404
+ }
1405
+ }
1406
+ return !1;
1407
+ }, kr = () => ({ tr: e, dispatch: t }) => {
1408
+ const { selection: n } = e, { empty: r, ranges: o } = n;
1409
+ return r || t && o.forEach((s) => {
1410
+ e.removeMark(s.$from.pos, s.$to.pos);
1411
+ }), !0;
1412
+ }, yr = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
1413
+ var s;
1414
+ const { extendEmptyMarkRange: i = !1 } = t, { selection: a } = n, c = R(e, r.schema), { $from: l, empty: u, ranges: d } = a;
1415
+ if (!o)
1416
+ return !0;
1417
+ if (u && i) {
1418
+ let { from: f, to: p } = a;
1419
+ const m = (s = l.marks().find((g) => g.type === c)) == null ? void 0 : s.attrs, h = kt(l, c, m);
1420
+ h && (f = h.from, p = h.to), n.removeMark(f, p, c);
1421
+ } else
1422
+ d.forEach((f) => {
1423
+ n.removeMark(f.$from.pos, f.$to.pos, c);
1424
+ });
1425
+ return n.removeStoredMark(c), !0;
1426
+ }, wr = (e) => ({ tr: t, state: n, dispatch: r }) => {
1427
+ const { selection: o } = n;
1428
+ let s, i;
1429
+ return typeof e == "number" ? (s = e, i = e) : e && "from" in e && "to" in e ? (s = e.from, i = e.to) : (s = o.from, i = o.to), r && t.doc.nodesBetween(s, i, (a, c) => {
1430
+ if (a.isText)
1431
+ return;
1432
+ const l = { ...a.attrs };
1433
+ delete l.dir, t.setNodeMarkup(c, void 0, l);
1434
+ }), !0;
1435
+ }, Mr = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
1436
+ let s = null, i = null;
1437
+ const a = st(
1438
+ typeof e == "string" ? e : e.name,
1439
+ r.schema
1440
+ );
1441
+ if (!a)
1442
+ return !1;
1443
+ a === "node" && (s = T(e, r.schema)), a === "mark" && (i = R(e, r.schema));
1444
+ let c = !1;
1445
+ return n.selection.ranges.forEach((l) => {
1446
+ const u = l.$from.pos, d = l.$to.pos;
1447
+ let f, p, m, h;
1448
+ n.selection.empty ? r.doc.nodesBetween(u, d, (g, v) => {
1449
+ s && s === g.type && (c = !0, m = Math.max(v, u), h = Math.min(v + g.nodeSize, d), f = v, p = g);
1450
+ }) : r.doc.nodesBetween(u, d, (g, v) => {
1451
+ v < u && s && s === g.type && (c = !0, m = Math.max(v, u), h = Math.min(v + g.nodeSize, d), f = v, p = g), v >= u && v <= d && (s && s === g.type && (c = !0, o && n.setNodeMarkup(v, void 0, {
1452
+ ...g.attrs,
1453
+ ...t
1454
+ })), i && g.marks.length && g.marks.forEach((k) => {
1455
+ if (i === k.type && (c = !0, o)) {
1456
+ const w = Math.max(v, u), M = Math.min(v + g.nodeSize, d);
1457
+ n.addMark(
1458
+ w,
1459
+ M,
1460
+ i.create({
1461
+ ...k.attrs,
1462
+ ...t
1463
+ })
1464
+ );
1465
+ }
1466
+ }));
1467
+ }), p && (f !== void 0 && o && n.setNodeMarkup(f, void 0, {
1468
+ ...p.attrs,
1469
+ ...t
1470
+ }), i && p.marks.length && p.marks.forEach((g) => {
1471
+ i === g.type && o && n.addMark(
1472
+ m,
1473
+ h,
1474
+ i.create({
1475
+ ...g.attrs,
1476
+ ...t
1477
+ })
1478
+ );
1479
+ }));
1480
+ }), c;
1481
+ }, xr = (e, t = {}) => ({ state: n, dispatch: r }) => {
1482
+ const o = T(e, n.schema);
1483
+ return De(o, t)(n, r);
1484
+ }, Sr = (e, t = {}) => ({ state: n, dispatch: r }) => {
1485
+ const o = T(e, n.schema);
1486
+ return We(o, t)(n, r);
1487
+ }, Er = class {
1488
+ constructor() {
1489
+ this.callbacks = {};
1490
+ }
1491
+ on(e, t) {
1492
+ return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), this;
1493
+ }
1494
+ emit(e, ...t) {
1495
+ const n = this.callbacks[e];
1496
+ return n && n.forEach((r) => r.apply(this, t)), this;
1497
+ }
1498
+ off(e, t) {
1499
+ const n = this.callbacks[e];
1500
+ return n && (t ? this.callbacks[e] = n.filter((r) => r !== t) : delete this.callbacks[e]), this;
1501
+ }
1502
+ once(e, t) {
1503
+ const n = (...r) => {
1504
+ this.off(e, n), t.apply(this, r);
1505
+ };
1506
+ return this.on(e, n);
1507
+ }
1508
+ removeAllListeners() {
1509
+ this.callbacks = {};
1510
+ }
1511
+ }, at = class {
1512
+ constructor(e) {
1513
+ var t;
1514
+ this.find = e.find, this.handler = e.handler, this.undoable = (t = e.undoable) != null ? t : !0;
1515
+ }
1516
+ }, Tr = (e, t) => {
1517
+ if (bt(t))
1518
+ return t.exec(e);
1519
+ const n = t(e);
1520
+ if (!n)
1521
+ return null;
1522
+ const r = [n.text];
1523
+ 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;
1524
+ };
1525
+ function K(e) {
1526
+ var t;
1527
+ const { editor: n, from: r, to: o, text: s, rules: i, plugin: a } = e, { view: c } = n;
1528
+ if (c.composing)
1529
+ return !1;
1530
+ const l = c.state.doc.resolve(r);
1531
+ if (
1532
+ // check for code node
1533
+ l.parent.type.spec.code || (t = l.nodeBefore || l.nodeAfter) != null && t.marks.find((f) => f.type.spec.code)
1534
+ )
1535
+ return !1;
1536
+ let u = !1;
1537
+ const d = tr(l) + s;
1538
+ return i.forEach((f) => {
1539
+ if (u)
1540
+ return;
1541
+ const p = Tr(d, f.find);
1542
+ if (!p)
1543
+ return;
1544
+ const m = c.state.tr, h = rt({
1545
+ state: c.state,
1546
+ transaction: m
1547
+ }), g = {
1548
+ from: r - (p[0].length - s.length),
1549
+ to: o
1550
+ }, { commands: v, chain: k, can: w } = new ot({
1551
+ editor: n,
1552
+ state: h
1553
+ });
1554
+ f.handler({
1555
+ state: h,
1556
+ range: g,
1557
+ match: p,
1558
+ commands: v,
1559
+ chain: k,
1560
+ can: w
1561
+ }) === null || !m.steps.length || (f.undoable && m.setMeta(a, {
1562
+ transform: m,
1563
+ from: r,
1564
+ to: o,
1565
+ text: s
1566
+ }), c.dispatch(m), u = !0);
1567
+ }), u;
1568
+ }
1569
+ function Ar(e) {
1570
+ const { editor: t, rules: n } = e, r = new P({
1571
+ state: {
1572
+ init() {
1573
+ return null;
1574
+ },
1575
+ apply(o, s, i) {
1576
+ const a = o.getMeta(r);
1577
+ if (a)
1578
+ return a;
1579
+ const c = o.getMeta("applyInputRules");
1580
+ return c && setTimeout(() => {
1581
+ let { text: u } = c;
1582
+ typeof u == "string" ? u = u : u = wt(j.from(u), i.schema);
1583
+ const { from: d } = c, f = d + u.length;
1584
+ K({
1585
+ editor: t,
1586
+ from: d,
1587
+ to: f,
1588
+ text: u,
1589
+ rules: n,
1590
+ plugin: r
1591
+ });
1592
+ }), o.selectionSet || o.docChanged ? null : s;
1593
+ }
1594
+ },
1595
+ props: {
1596
+ handleTextInput(o, s, i, a) {
1597
+ return K({
1598
+ editor: t,
1599
+ from: s,
1600
+ to: i,
1601
+ text: a,
1602
+ rules: n,
1603
+ plugin: r
1604
+ });
1605
+ },
1606
+ handleDOMEvents: {
1607
+ compositionend: (o) => (setTimeout(() => {
1608
+ const { $cursor: s } = o.state.selection;
1609
+ s && K({
1610
+ editor: t,
1611
+ from: s.pos,
1612
+ to: s.pos,
1613
+ text: "",
1614
+ rules: n,
1615
+ plugin: r
1616
+ });
1617
+ }), !1)
1618
+ },
1619
+ // add support for input rules to trigger on enter
1620
+ // this is useful for example for code blocks
1621
+ handleKeyDown(o, s) {
1622
+ if (s.key !== "Enter")
1623
+ return !1;
1624
+ const { $cursor: i } = o.state.selection;
1625
+ return i ? K({
1626
+ editor: t,
1627
+ from: i.pos,
1628
+ to: i.pos,
1629
+ text: `
1630
+ `,
1631
+ rules: n,
1632
+ plugin: r
1633
+ }) : !1;
1634
+ }
1635
+ },
1636
+ // @ts-ignore
1637
+ isInputRules: !0
1638
+ });
1639
+ return r;
1640
+ }
1641
+ function Cr(e) {
1642
+ return Object.prototype.toString.call(e).slice(8, -1);
1643
+ }
1644
+ function J(e) {
1645
+ return Cr(e) !== "Object" ? !1 : e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
1646
+ }
1647
+ function Xt(e, t) {
1648
+ const n = { ...e };
1649
+ return J(e) && J(t) && Object.keys(t).forEach((r) => {
1650
+ J(t[r]) && J(e[r]) ? n[r] = Xt(e[r], t[r]) : n[r] = t[r];
1651
+ }), n;
1652
+ }
1653
+ var xt = class {
1654
+ constructor(e = {}) {
1655
+ this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = {
1656
+ name: this.name
1657
+ }, this.config = {
1658
+ ...this.config,
1659
+ ...e
1660
+ }, this.name = this.config.name;
1661
+ }
1662
+ get options() {
1663
+ return {
1664
+ ...x(
1665
+ b(this, "addOptions", {
1666
+ name: this.name
1667
+ })
1668
+ ) || {}
1669
+ };
1670
+ }
1671
+ get storage() {
1672
+ return {
1673
+ ...x(
1674
+ b(this, "addStorage", {
1675
+ name: this.name,
1676
+ options: this.options
1677
+ })
1678
+ ) || {}
1679
+ };
1680
+ }
1681
+ configure(e = {}) {
1682
+ const t = this.extend({
1683
+ ...this.config,
1684
+ addOptions: () => Xt(this.options, e)
1685
+ });
1686
+ return t.name = this.name, t.parent = this.parent, t;
1687
+ }
1688
+ extend(e = {}) {
1689
+ const t = new this.constructor({ ...this.config, ...e });
1690
+ return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
1691
+ }
1692
+ }, $r = class te extends xt {
1693
+ constructor() {
1694
+ super(...arguments), this.type = "mark";
1695
+ }
1696
+ /**
1697
+ * Create a new Mark instance
1698
+ * @param config - Mark configuration object or a function that returns a configuration object
1699
+ */
1700
+ static create(t = {}) {
1701
+ const n = typeof t == "function" ? t() : t;
1702
+ return new te(n);
1703
+ }
1704
+ static handleExit({ editor: t, mark: n }) {
1705
+ const { tr: r } = t.state, o = t.state.selection.$from;
1706
+ if (o.pos === o.end()) {
1707
+ const i = o.marks();
1708
+ if (!!!i.find((l) => l?.type.name === n.name))
1709
+ return !1;
1710
+ const c = i.find((l) => l?.type.name === n.name);
1711
+ return c && r.removeStoredMark(c), r.insertText(" ", o.pos), t.view.dispatch(r), !0;
1712
+ }
1713
+ return !1;
1714
+ }
1715
+ configure(t) {
1716
+ return super.configure(t);
1717
+ }
1718
+ extend(t) {
1719
+ const n = typeof t == "function" ? t() : t;
1720
+ return super.extend(n);
1721
+ }
1722
+ };
1723
+ function Pr(e) {
1724
+ return typeof e == "number";
1725
+ }
1726
+ var Nr = class {
1727
+ constructor(e) {
1728
+ this.find = e.find, this.handler = e.handler;
1729
+ }
1730
+ }, Ir = (e, t, n) => {
1731
+ if (bt(t))
1732
+ return [...e.matchAll(t)];
1733
+ const r = t(e, n);
1734
+ return r ? r.map((o) => {
1735
+ const s = [o.text];
1736
+ 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;
1737
+ }) : [];
1738
+ };
1739
+ function Rr(e) {
1740
+ const { editor: t, state: n, from: r, to: o, rule: s, pasteEvent: i, dropEvent: a } = e, { commands: c, chain: l, can: u } = new ot({
1741
+ editor: t,
1742
+ state: n
1743
+ }), d = [];
1744
+ return n.doc.nodesBetween(r, o, (p, m) => {
1745
+ var h, g, v, k, w;
1746
+ if ((g = (h = p.type) == null ? void 0 : h.spec) != null && g.code || !(p.isText || p.isTextblock || p.isInline))
1747
+ return;
1748
+ const M = (w = (k = (v = p.content) == null ? void 0 : v.size) != null ? k : p.nodeSize) != null ? w : 0, y = Math.max(r, m), S = Math.min(o, m + M);
1749
+ if (y >= S)
1750
+ return;
1751
+ const E = p.isText ? p.text || "" : p.textBetween(y - m, S - m, void 0, "");
1752
+ Ir(E, s.find, i).forEach((C) => {
1753
+ if (C.index === void 0)
1754
+ return;
1755
+ const D = y + C.index + 1, lt = D + C[0].length, U = {
1756
+ from: n.tr.mapping.map(D),
1757
+ to: n.tr.mapping.map(lt)
1758
+ }, dt = s.handler({
1759
+ state: n,
1760
+ range: U,
1761
+ match: C,
1762
+ commands: c,
1763
+ chain: l,
1764
+ can: u,
1765
+ pasteEvent: i,
1766
+ dropEvent: a
1767
+ });
1768
+ d.push(dt);
1769
+ });
1770
+ }), d.every((p) => p !== null);
1771
+ }
1772
+ var Z = null, Br = (e) => {
1773
+ var t;
1774
+ const n = new ClipboardEvent("paste", {
1775
+ clipboardData: new DataTransfer()
1776
+ });
1777
+ return (t = n.clipboardData) == null || t.setData("text/html", e), n;
1778
+ };
1779
+ function jr(e) {
1780
+ const { editor: t, rules: n } = e;
1781
+ let r = null, o = !1, s = !1, i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, a;
1782
+ try {
1783
+ a = typeof DragEvent < "u" ? new DragEvent("drop") : null;
1784
+ } catch {
1785
+ a = null;
1786
+ }
1787
+ const c = ({
1788
+ state: u,
1789
+ from: d,
1790
+ to: f,
1791
+ rule: p,
1792
+ pasteEvt: m
1793
+ }) => {
1794
+ const h = u.tr, g = rt({
1795
+ state: u,
1796
+ transaction: h
1797
+ });
1798
+ if (!(!Rr({
1799
+ editor: t,
1800
+ state: g,
1801
+ from: Math.max(d - 1, 0),
1802
+ to: f.b - 1,
1803
+ rule: p,
1804
+ pasteEvent: m,
1805
+ dropEvent: a
1806
+ }) || !h.steps.length)) {
1807
+ try {
1808
+ a = typeof DragEvent < "u" ? new DragEvent("drop") : null;
1809
+ } catch {
1810
+ a = null;
1811
+ }
1812
+ return i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, h;
1813
+ }
1814
+ };
1815
+ return n.map((u) => new P({
1816
+ // we register a global drag handler to track the current drag source element
1817
+ view(d) {
1818
+ const f = (m) => {
1819
+ var h;
1820
+ r = (h = d.dom.parentElement) != null && h.contains(m.target) ? d.dom.parentElement : null, r && (Z = t);
1821
+ }, p = () => {
1822
+ Z && (Z = null);
1823
+ };
1824
+ return window.addEventListener("dragstart", f), window.addEventListener("dragend", p), {
1825
+ destroy() {
1826
+ window.removeEventListener("dragstart", f), window.removeEventListener("dragend", p);
1827
+ }
1828
+ };
1829
+ },
1830
+ props: {
1831
+ handleDOMEvents: {
1832
+ drop: (d, f) => {
1833
+ if (s = r === d.dom.parentElement, a = f, !s) {
1834
+ const p = Z;
1835
+ p?.isEditable && setTimeout(() => {
1836
+ const m = p.state.selection;
1837
+ m && p.commands.deleteRange({ from: m.from, to: m.to });
1838
+ }, 10);
1839
+ }
1840
+ return !1;
1841
+ },
1842
+ paste: (d, f) => {
1843
+ var p;
1844
+ const m = (p = f.clipboardData) == null ? void 0 : p.getData("text/html");
1845
+ return i = f, o = !!m?.includes("data-pm-slice"), !1;
1846
+ }
1847
+ }
1848
+ },
1849
+ appendTransaction: (d, f, p) => {
1850
+ const m = d[0], h = m.getMeta("uiEvent") === "paste" && !o, g = m.getMeta("uiEvent") === "drop" && !s, v = m.getMeta("applyPasteRules"), k = !!v;
1851
+ if (!h && !g && !k)
1852
+ return;
1853
+ if (k) {
1854
+ let { text: y } = v;
1855
+ typeof y == "string" ? y = y : y = wt(j.from(y), p.schema);
1856
+ const { from: S } = v, E = S + y.length, A = Br(y);
1857
+ return c({
1858
+ rule: u,
1859
+ state: p,
1860
+ from: S,
1861
+ to: { b: E },
1862
+ pasteEvt: A
1863
+ });
1864
+ }
1865
+ const w = f.doc.content.findDiffStart(p.doc.content), M = f.doc.content.findDiffEnd(p.doc.content);
1866
+ if (!(!Pr(w) || !M || w === M.b))
1867
+ return c({
1868
+ rule: u,
1869
+ state: p,
1870
+ from: w,
1871
+ to: M,
1872
+ pasteEvt: i
1873
+ });
1874
+ }
1875
+ }));
1876
+ }
1877
+ var ct = class {
1878
+ constructor(e, t) {
1879
+ this.splittableMarks = [], this.editor = t, this.baseExtensions = e, this.extensions = Kt(e), this.schema = qn(this.extensions, t), this.setupExtensions();
1880
+ }
1881
+ /**
1882
+ * Get all commands from the extensions.
1883
+ * @returns An object with all commands where the key is the command name and the value is the command function
1884
+ */
1885
+ get commands() {
1886
+ return this.extensions.reduce((e, t) => {
1887
+ const n = {
1888
+ name: t.name,
1889
+ options: t.options,
1890
+ storage: this.editor.extensionStorage[t.name],
1891
+ editor: this.editor,
1892
+ type: q(t.name, this.schema)
1893
+ }, r = b(t, "addCommands", n);
1894
+ return r ? {
1895
+ ...e,
1896
+ ...r()
1897
+ } : e;
1898
+ }, {});
1899
+ }
1900
+ /**
1901
+ * Get all registered Prosemirror plugins from the extensions.
1902
+ * @returns An array of Prosemirror plugins
1903
+ */
1904
+ get plugins() {
1905
+ const { editor: e } = this;
1906
+ return et([...this.extensions].reverse()).flatMap((r) => {
1907
+ const o = {
1908
+ name: r.name,
1909
+ options: r.options,
1910
+ storage: this.editor.extensionStorage[r.name],
1911
+ editor: e,
1912
+ type: q(r.name, this.schema)
1913
+ }, s = [], i = b(
1914
+ r,
1915
+ "addKeyboardShortcuts",
1916
+ o
1917
+ );
1918
+ let a = {};
1919
+ if (r.type === "mark" && b(r, "exitable", o) && (a.ArrowRight = () => $r.handleExit({ editor: e, mark: r })), i) {
1920
+ const f = Object.fromEntries(
1921
+ Object.entries(i()).map(([p, m]) => [p, () => m({ editor: e })])
1922
+ );
1923
+ a = { ...a, ...f };
1924
+ }
1925
+ const c = Ke(a);
1926
+ s.push(c);
1927
+ const l = b(r, "addInputRules", o);
1928
+ if (Rt(r, e.options.enableInputRules) && l) {
1929
+ const f = l();
1930
+ if (f && f.length) {
1931
+ const p = Ar({
1932
+ editor: e,
1933
+ rules: f
1934
+ }), m = Array.isArray(p) ? p : [p];
1935
+ s.push(...m);
1936
+ }
1937
+ }
1938
+ const u = b(r, "addPasteRules", o);
1939
+ if (Rt(r, e.options.enablePasteRules) && u) {
1940
+ const f = u();
1941
+ if (f && f.length) {
1942
+ const p = jr({ editor: e, rules: f });
1943
+ s.push(...p);
1944
+ }
1945
+ }
1946
+ const d = b(
1947
+ r,
1948
+ "addProseMirrorPlugins",
1949
+ o
1950
+ );
1951
+ if (d) {
1952
+ const f = d();
1953
+ s.push(...f);
1954
+ }
1955
+ return s;
1956
+ });
1957
+ }
1958
+ /**
1959
+ * Get all attributes from the extensions.
1960
+ * @returns An array of attributes
1961
+ */
1962
+ get attributes() {
1963
+ return qt(this.extensions);
1964
+ }
1965
+ /**
1966
+ * Get all node views from the extensions.
1967
+ * @returns An object with all node views where the key is the node name and the value is the node view function
1968
+ */
1969
+ get nodeViews() {
1970
+ const { editor: e } = this, { nodeExtensions: t } = F(this.extensions);
1971
+ return Object.fromEntries(
1972
+ t.filter((n) => !!b(n, "addNodeView")).map((n) => {
1973
+ const r = this.attributes.filter((c) => c.type === n.name), o = {
1974
+ name: n.name,
1975
+ options: n.options,
1976
+ storage: this.editor.extensionStorage[n.name],
1977
+ editor: e,
1978
+ type: T(n.name, this.schema)
1979
+ }, s = b(n, "addNodeView", o);
1980
+ if (!s)
1981
+ return [];
1982
+ const i = s();
1983
+ if (!i)
1984
+ return [];
1985
+ const a = (c, l, u, d, f) => {
1986
+ const p = tt(c, r);
1987
+ return i({
1988
+ // pass-through
1989
+ node: c,
1990
+ view: l,
1991
+ getPos: u,
1992
+ decorations: d,
1993
+ innerDecorations: f,
1994
+ // tiptap-specific
1995
+ editor: e,
1996
+ extension: n,
1997
+ HTMLAttributes: p
1998
+ });
1999
+ };
2000
+ return [n.name, a];
2001
+ })
2002
+ );
2003
+ }
2004
+ /**
2005
+ * Get the composed dispatchTransaction function from all extensions.
2006
+ * @param baseDispatch The base dispatch function (e.g. from the editor or user props)
2007
+ * @returns A composed dispatch function
2008
+ */
2009
+ dispatchTransaction(e) {
2010
+ const { editor: t } = this;
2011
+ return et([...this.extensions].reverse()).reduceRight((r, o) => {
2012
+ const s = {
2013
+ name: o.name,
2014
+ options: o.options,
2015
+ storage: this.editor.extensionStorage[o.name],
2016
+ editor: t,
2017
+ type: q(o.name, this.schema)
2018
+ }, i = b(
2019
+ o,
2020
+ "dispatchTransaction",
2021
+ s
2022
+ );
2023
+ return i ? (a) => {
2024
+ i.call(s, { transaction: a, next: r });
2025
+ } : r;
2026
+ }, e);
2027
+ }
2028
+ get markViews() {
2029
+ const { editor: e } = this, { markExtensions: t } = F(this.extensions);
2030
+ return Object.fromEntries(
2031
+ t.filter((n) => !!b(n, "addMarkView")).map((n) => {
2032
+ const r = this.attributes.filter((a) => a.type === n.name), o = {
2033
+ name: n.name,
2034
+ options: n.options,
2035
+ storage: this.editor.extensionStorage[n.name],
2036
+ editor: e,
2037
+ type: R(n.name, this.schema)
2038
+ }, s = b(n, "addMarkView", o);
2039
+ if (!s)
2040
+ return [];
2041
+ const i = (a, c, l) => {
2042
+ const u = tt(a, r);
2043
+ return s()({
2044
+ // pass-through
2045
+ mark: a,
2046
+ view: c,
2047
+ inline: l,
2048
+ // tiptap-specific
2049
+ editor: e,
2050
+ extension: n,
2051
+ HTMLAttributes: u,
2052
+ updateAttributes: (d) => {
2053
+ Jr(a, e, d);
2054
+ }
2055
+ });
2056
+ };
2057
+ return [n.name, i];
2058
+ })
2059
+ );
2060
+ }
2061
+ /**
2062
+ * Go through all extensions, create extension storages & setup marks
2063
+ * & bind editor event listener.
2064
+ */
2065
+ setupExtensions() {
2066
+ const e = this.extensions;
2067
+ this.editor.extensionStorage = Object.fromEntries(
2068
+ e.map((t) => [t.name, t.storage])
2069
+ ), e.forEach((t) => {
2070
+ var n;
2071
+ const r = {
2072
+ name: t.name,
2073
+ options: t.options,
2074
+ storage: this.editor.extensionStorage[t.name],
2075
+ editor: this.editor,
2076
+ type: q(t.name, this.schema)
2077
+ };
2078
+ t.type === "mark" && ((n = x(b(t, "keepOnSplit", r))) == null || n) && this.splittableMarks.push(t.name);
2079
+ const o = b(t, "onBeforeCreate", r), s = b(t, "onCreate", r), i = b(t, "onUpdate", r), a = b(
2080
+ t,
2081
+ "onSelectionUpdate",
2082
+ r
2083
+ ), c = b(t, "onTransaction", r), l = b(t, "onFocus", r), u = b(t, "onBlur", r), d = b(t, "onDestroy", r);
2084
+ 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);
2085
+ });
2086
+ }
2087
+ };
2088
+ ct.resolve = Kt;
2089
+ ct.sort = et;
2090
+ ct.flatten = yt;
2091
+ var Or = {};
2092
+ vt(Or, {
2093
+ ClipboardTextSerializer: () => ne,
2094
+ Commands: () => re,
2095
+ Delete: () => oe,
2096
+ Drop: () => se,
2097
+ Editable: () => ie,
2098
+ FocusEvents: () => ce,
2099
+ Keymap: () => le,
2100
+ Paste: () => de,
2101
+ Tabindex: () => ue,
2102
+ TextDirection: () => fe,
2103
+ focusEventsPluginKey: () => ae
2104
+ });
2105
+ var N = class ee extends xt {
2106
+ constructor() {
2107
+ super(...arguments), this.type = "extension";
2108
+ }
2109
+ /**
2110
+ * Create a new Extension instance
2111
+ * @param config - Extension configuration object or a function that returns a configuration object
2112
+ */
2113
+ static create(t = {}) {
2114
+ const n = typeof t == "function" ? t() : t;
2115
+ return new ee(n);
2116
+ }
2117
+ configure(t) {
2118
+ return super.configure(t);
2119
+ }
2120
+ extend(t) {
2121
+ const n = typeof t == "function" ? t() : t;
2122
+ return super.extend(n);
2123
+ }
2124
+ }, ne = N.create({
2125
+ name: "clipboardTextSerializer",
2126
+ addOptions() {
2127
+ return {
2128
+ blockSeparator: void 0
2129
+ };
2130
+ },
2131
+ addProseMirrorPlugins() {
2132
+ return [
2133
+ new P({
2134
+ key: new O("clipboardTextSerializer"),
2135
+ props: {
2136
+ clipboardTextSerializer: () => {
2137
+ 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 = Zt(n);
2138
+ return Jt(r, { from: i, to: a }, {
2139
+ ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
2140
+ textSerializers: c
2141
+ });
2142
+ }
2143
+ }
2144
+ })
2145
+ ];
2146
+ }
2147
+ }), re = N.create({
2148
+ name: "commands",
2149
+ addCommands() {
2150
+ return {
2151
+ ..._t
2152
+ };
2153
+ }
2154
+ }), oe = N.create({
2155
+ name: "delete",
2156
+ onUpdate({ transaction: e, appendedTransactions: t }) {
2157
+ var n, r, o;
2158
+ const s = () => {
2159
+ var i, a, c, l;
2160
+ if ((l = (c = (a = (i = this.editor.options.coreExtensionOptions) == null ? void 0 : i.delete) == null ? void 0 : a.filterTransaction) == null ? void 0 : c.call(a, e)) != null ? l : e.getMeta("y-sync$"))
2161
+ return;
2162
+ const u = Fn(e.before, [e, ...t]);
2163
+ Xn(u).forEach((p) => {
2164
+ u.mapping.mapResult(p.oldRange.from).deletedAfter && u.mapping.mapResult(p.oldRange.to).deletedBefore && u.before.nodesBetween(p.oldRange.from, p.oldRange.to, (m, h) => {
2165
+ const g = h + m.nodeSize - 2, v = p.oldRange.from <= h && g <= p.oldRange.to;
2166
+ this.editor.emit("delete", {
2167
+ type: "node",
2168
+ node: m,
2169
+ from: h,
2170
+ to: g,
2171
+ newFrom: u.mapping.map(h),
2172
+ newTo: u.mapping.map(g),
2173
+ deletedRange: p.oldRange,
2174
+ newRange: p.newRange,
2175
+ partial: !v,
2176
+ editor: this.editor,
2177
+ transaction: e,
2178
+ combinedTransform: u
2179
+ });
2180
+ });
2181
+ });
2182
+ const f = u.mapping;
2183
+ u.steps.forEach((p, m) => {
2184
+ var h, g;
2185
+ if (p instanceof ge) {
2186
+ const v = f.slice(m).map(p.from, -1), k = f.slice(m).map(p.to), w = f.invert().map(v, -1), M = f.invert().map(k), y = (h = u.doc.nodeAt(v - 1)) == null ? void 0 : h.marks.some((E) => E.eq(p.mark)), S = (g = u.doc.nodeAt(k)) == null ? void 0 : g.marks.some((E) => E.eq(p.mark));
2187
+ this.editor.emit("delete", {
2188
+ type: "mark",
2189
+ mark: p.mark,
2190
+ from: p.from,
2191
+ to: p.to,
2192
+ deletedRange: {
2193
+ from: w,
2194
+ to: M
2195
+ },
2196
+ newRange: {
2197
+ from: v,
2198
+ to: k
2199
+ },
2200
+ partial: !!(S || y),
2201
+ editor: this.editor,
2202
+ transaction: e,
2203
+ combinedTransform: u
2204
+ });
2205
+ }
2206
+ });
2207
+ };
2208
+ (o = (r = (n = this.editor.options.coreExtensionOptions) == null ? void 0 : n.delete) == null ? void 0 : r.async) == null || o ? setTimeout(s, 0) : s();
2209
+ }
2210
+ }), se = N.create({
2211
+ name: "drop",
2212
+ addProseMirrorPlugins() {
2213
+ return [
2214
+ new P({
2215
+ key: new O("tiptapDrop"),
2216
+ props: {
2217
+ handleDrop: (e, t, n, r) => {
2218
+ this.editor.emit("drop", {
2219
+ editor: this.editor,
2220
+ event: t,
2221
+ slice: n,
2222
+ moved: r
2223
+ });
2224
+ }
2225
+ }
2226
+ })
2227
+ ];
2228
+ }
2229
+ }), ie = N.create({
2230
+ name: "editable",
2231
+ addProseMirrorPlugins() {
2232
+ return [
2233
+ new P({
2234
+ key: new O("editable"),
2235
+ props: {
2236
+ editable: () => this.editor.options.editable
2237
+ }
2238
+ })
2239
+ ];
2240
+ }
2241
+ }), ae = new O("focusEvents"), ce = N.create({
2242
+ name: "focusEvents",
2243
+ addProseMirrorPlugins() {
2244
+ const { editor: e } = this;
2245
+ return [
2246
+ new P({
2247
+ key: ae,
2248
+ props: {
2249
+ handleDOMEvents: {
2250
+ focus: (t, n) => {
2251
+ e.isFocused = !0;
2252
+ const r = e.state.tr.setMeta("focus", { event: n }).setMeta("addToHistory", !1);
2253
+ return t.dispatch(r), !1;
2254
+ },
2255
+ blur: (t, n) => {
2256
+ e.isFocused = !1;
2257
+ const r = e.state.tr.setMeta("blur", { event: n }).setMeta("addToHistory", !1);
2258
+ return t.dispatch(r), !1;
2259
+ }
2260
+ }
2261
+ }
2262
+ })
2263
+ ];
2264
+ }
2265
+ }), le = N.create({
2266
+ name: "keymap",
2267
+ addKeyboardShortcuts() {
2268
+ const e = () => this.editor.commands.first(({ commands: i }) => [
2269
+ () => i.undoInputRule(),
2270
+ // maybe convert first text block node to default node
2271
+ () => i.command(({ tr: a }) => {
2272
+ const { selection: c, doc: l } = a, { empty: u, $anchor: d } = c, { pos: f, parent: p } = d, m = d.parent.isTextblock && f > 0 ? a.doc.resolve(f - 1) : d, h = m.parent.type.spec.isolating, g = d.pos - d.parentOffset, v = h && m.parent.childCount === 1 ? g === d.pos : z.atStart(l).from === f;
2273
+ return !u || !p.type.isTextblock || p.textContent.length || !v || v && d.parent.type.name === "paragraph" ? !1 : i.clearNodes();
2274
+ }),
2275
+ () => i.deleteSelection(),
2276
+ () => i.joinBackward(),
2277
+ () => i.selectNodeBackward()
2278
+ ]), t = () => this.editor.commands.first(({ commands: i }) => [
2279
+ () => i.deleteSelection(),
2280
+ () => i.deleteCurrentNode(),
2281
+ () => i.joinForward(),
2282
+ () => i.selectNodeForward()
2283
+ ]), r = {
2284
+ Enter: () => this.editor.commands.first(({ commands: i }) => [
2285
+ () => i.newlineInCode(),
2286
+ () => i.createParagraphNear(),
2287
+ () => i.liftEmptyBlock(),
2288
+ () => i.splitBlock()
2289
+ ]),
2290
+ "Mod-Enter": () => this.editor.commands.exitCode(),
2291
+ Backspace: e,
2292
+ "Mod-Backspace": e,
2293
+ "Shift-Backspace": e,
2294
+ Delete: t,
2295
+ "Mod-Delete": t,
2296
+ "Mod-a": () => this.editor.commands.selectAll()
2297
+ }, o = {
2298
+ ...r
2299
+ }, s = {
2300
+ ...r,
2301
+ "Ctrl-h": e,
2302
+ "Alt-Backspace": e,
2303
+ "Ctrl-d": t,
2304
+ "Ctrl-Alt-Backspace": t,
2305
+ "Alt-Delete": t,
2306
+ "Alt-d": t,
2307
+ "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
2308
+ "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
2309
+ };
2310
+ return X() || Ht() ? s : o;
2311
+ },
2312
+ addProseMirrorPlugins() {
2313
+ return [
2314
+ // With this plugin we check if the whole document was selected and deleted.
2315
+ // In this case we will additionally call `clearNodes()` to convert e.g. a heading
2316
+ // to a paragraph if necessary.
2317
+ // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
2318
+ // with many other commands.
2319
+ new P({
2320
+ key: new O("clearDocument"),
2321
+ appendTransaction: (e, t, n) => {
2322
+ if (e.some((h) => h.getMeta("composition")))
2323
+ return;
2324
+ const r = e.some((h) => h.docChanged) && !t.doc.eq(n.doc), o = e.some((h) => h.getMeta("preventClearDocument"));
2325
+ if (!r || o)
2326
+ return;
2327
+ const { empty: s, from: i, to: a } = t.selection, c = z.atStart(t.doc).from, l = z.atEnd(t.doc).to;
2328
+ if (s || !(i === c && a === l) || !Mt(n.doc))
2329
+ return;
2330
+ const f = n.tr, p = rt({
2331
+ state: n,
2332
+ transaction: f
2333
+ }), { commands: m } = new ot({
2334
+ editor: this.editor,
2335
+ state: p
2336
+ });
2337
+ if (m.clearNodes(), !!f.steps.length)
2338
+ return f;
2339
+ }
2340
+ })
2341
+ ];
2342
+ }
2343
+ }), de = N.create({
2344
+ name: "paste",
2345
+ addProseMirrorPlugins() {
2346
+ return [
2347
+ new P({
2348
+ key: new O("tiptapPaste"),
2349
+ props: {
2350
+ handlePaste: (e, t, n) => {
2351
+ this.editor.emit("paste", {
2352
+ editor: this.editor,
2353
+ event: t,
2354
+ slice: n
2355
+ });
2356
+ }
2357
+ }
2358
+ })
2359
+ ];
2360
+ }
2361
+ }), ue = N.create({
2362
+ name: "tabindex",
2363
+ addProseMirrorPlugins() {
2364
+ return [
2365
+ new P({
2366
+ key: new O("tabindex"),
2367
+ props: {
2368
+ attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
2369
+ }
2370
+ })
2371
+ ];
2372
+ }
2373
+ }), fe = N.create({
2374
+ name: "textDirection",
2375
+ addOptions() {
2376
+ return {
2377
+ direction: void 0
2378
+ };
2379
+ },
2380
+ addGlobalAttributes() {
2381
+ if (!this.options.direction)
2382
+ return [];
2383
+ const { nodeExtensions: e } = F(this.extensions);
2384
+ return [
2385
+ {
2386
+ types: e.filter((t) => t.name !== "text").map((t) => t.name),
2387
+ attributes: {
2388
+ dir: {
2389
+ default: this.options.direction,
2390
+ parseHTML: (t) => {
2391
+ const n = t.getAttribute("dir");
2392
+ return n && (n === "ltr" || n === "rtl" || n === "auto") ? n : this.options.direction;
2393
+ },
2394
+ renderHTML: (t) => t.dir ? {
2395
+ dir: t.dir
2396
+ } : {}
2397
+ }
2398
+ }
2399
+ }
2400
+ ];
2401
+ },
2402
+ addProseMirrorPlugins() {
2403
+ return [
2404
+ new P({
2405
+ key: new O("textDirection"),
2406
+ props: {
2407
+ attributes: () => {
2408
+ const e = this.options.direction;
2409
+ return e ? {
2410
+ dir: e
2411
+ } : {};
2412
+ }
2413
+ }
2414
+ })
2415
+ ];
2416
+ }
2417
+ }), Dr = class L {
2418
+ constructor(t, n, r = !1, o = null) {
2419
+ this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = t, this.editor = n, this.currentNode = o;
2420
+ }
2421
+ get name() {
2422
+ return this.node.type.name;
2423
+ }
2424
+ get node() {
2425
+ return this.currentNode || this.resolvedPos.node();
2426
+ }
2427
+ get element() {
2428
+ return this.editor.view.domAtPos(this.pos).node;
2429
+ }
2430
+ get depth() {
2431
+ var t;
2432
+ return (t = this.actualDepth) != null ? t : this.resolvedPos.depth;
2433
+ }
2434
+ get pos() {
2435
+ return this.resolvedPos.pos;
2436
+ }
2437
+ get content() {
2438
+ return this.node.content;
2439
+ }
2440
+ set content(t) {
2441
+ let n = this.from, r = this.to;
2442
+ if (this.isBlock) {
2443
+ if (this.content.size === 0) {
2444
+ console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
2445
+ return;
2446
+ }
2447
+ n = this.from + 1, r = this.to - 1;
2448
+ }
2449
+ this.editor.commands.insertContentAt({ from: n, to: r }, t);
2450
+ }
2451
+ get attributes() {
2452
+ return this.node.attrs;
2453
+ }
2454
+ get textContent() {
2455
+ return this.node.textContent;
2456
+ }
2457
+ get size() {
2458
+ return this.node.nodeSize;
2459
+ }
2460
+ get from() {
2461
+ return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth);
2462
+ }
2463
+ get range() {
2464
+ return {
2465
+ from: this.from,
2466
+ to: this.to
2467
+ };
2468
+ }
2469
+ get to() {
2470
+ return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
2471
+ }
2472
+ get parent() {
2473
+ if (this.depth === 0)
2474
+ return null;
2475
+ const t = this.resolvedPos.start(this.resolvedPos.depth - 1), n = this.resolvedPos.doc.resolve(t);
2476
+ return new L(n, this.editor);
2477
+ }
2478
+ get before() {
2479
+ let t = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
2480
+ return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.from - 3)), new L(t, this.editor);
2481
+ }
2482
+ get after() {
2483
+ let t = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
2484
+ return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.to + 3)), new L(t, this.editor);
2485
+ }
2486
+ get children() {
2487
+ const t = [];
2488
+ return this.node.content.forEach((n, r) => {
2489
+ const o = n.isBlock && !n.isTextblock, s = n.isAtom && !n.isText, i = n.isInline, a = this.pos + r + (s ? 0 : 1);
2490
+ if (a < 0 || a > this.resolvedPos.doc.nodeSize - 2)
2491
+ return;
2492
+ const c = this.resolvedPos.doc.resolve(a);
2493
+ if (!o && !i && c.depth <= this.depth)
2494
+ return;
2495
+ const l = new L(c, this.editor, o, o || i ? n : null);
2496
+ o && (l.actualDepth = this.depth + 1), t.push(l);
2497
+ }), t;
2498
+ }
2499
+ get firstChild() {
2500
+ return this.children[0] || null;
2501
+ }
2502
+ get lastChild() {
2503
+ const t = this.children;
2504
+ return t[t.length - 1] || null;
2505
+ }
2506
+ closest(t, n = {}) {
2507
+ let r = null, o = this.parent;
2508
+ for (; o && !r; ) {
2509
+ if (o.node.type.name === t)
2510
+ if (Object.keys(n).length > 0) {
2511
+ const s = o.node.attrs, i = Object.keys(n);
2512
+ for (let a = 0; a < i.length; a += 1) {
2513
+ const c = i[a];
2514
+ if (s[c] !== n[c])
2515
+ break;
2516
+ }
2517
+ } else
2518
+ r = o;
2519
+ o = o.parent;
2520
+ }
2521
+ return r;
2522
+ }
2523
+ querySelector(t, n = {}) {
2524
+ return this.querySelectorAll(t, n, !0)[0] || null;
2525
+ }
2526
+ querySelectorAll(t, n = {}, r = !1) {
2527
+ let o = [];
2528
+ if (!this.children || this.children.length === 0)
2529
+ return o;
2530
+ const s = Object.keys(n);
2531
+ return this.children.forEach((i) => {
2532
+ 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))));
2533
+ }), o;
2534
+ }
2535
+ setAttribute(t) {
2536
+ const { tr: n } = this.editor.state;
2537
+ n.setNodeMarkup(this.from, void 0, {
2538
+ ...this.node.attrs,
2539
+ ...t
2540
+ }), this.editor.view.dispatch(n);
2541
+ }
2542
+ }, _r = `.ProseMirror {
2543
+ position: relative;
2544
+ }
2545
+
2546
+ .ProseMirror {
2547
+ word-wrap: break-word;
2548
+ white-space: pre-wrap;
2549
+ white-space: break-spaces;
2550
+ -webkit-font-variant-ligatures: none;
2551
+ font-variant-ligatures: none;
2552
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
2553
+ }
2554
+
2555
+ .ProseMirror [contenteditable="false"] {
2556
+ white-space: normal;
2557
+ }
2558
+
2559
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
2560
+ white-space: pre-wrap;
2561
+ }
2562
+
2563
+ .ProseMirror pre {
2564
+ white-space: pre-wrap;
2565
+ }
2566
+
2567
+ img.ProseMirror-separator {
2568
+ display: inline !important;
2569
+ border: none !important;
2570
+ margin: 0 !important;
2571
+ width: 0 !important;
2572
+ height: 0 !important;
2573
+ }
2574
+
2575
+ .ProseMirror-gapcursor {
2576
+ display: none;
2577
+ pointer-events: none;
2578
+ position: absolute;
2579
+ margin: 0;
2580
+ }
2581
+
2582
+ .ProseMirror-gapcursor:after {
2583
+ content: "";
2584
+ display: block;
2585
+ position: absolute;
2586
+ top: -2px;
2587
+ width: 20px;
2588
+ border-top: 1px solid black;
2589
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
2590
+ }
2591
+
2592
+ @keyframes ProseMirror-cursor-blink {
2593
+ to {
2594
+ visibility: hidden;
2595
+ }
2596
+ }
2597
+
2598
+ .ProseMirror-hideselection *::selection {
2599
+ background: transparent;
2600
+ }
2601
+
2602
+ .ProseMirror-hideselection *::-moz-selection {
2603
+ background: transparent;
2604
+ }
2605
+
2606
+ .ProseMirror-hideselection * {
2607
+ caret-color: transparent;
2608
+ }
2609
+
2610
+ .ProseMirror-focused .ProseMirror-gapcursor {
2611
+ display: block;
2612
+ }`;
2613
+ function zr(e, t, n) {
2614
+ const r = document.querySelector("style[data-tiptap-style]");
2615
+ if (r !== null)
2616
+ return r;
2617
+ const o = document.createElement("style");
2618
+ return t && o.setAttribute("nonce", t), o.setAttribute("data-tiptap-style", ""), o.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(o), o;
2619
+ }
2620
+ var ao = class extends Er {
2621
+ constructor(t = {}) {
2622
+ super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = {
2623
+ element: typeof document < "u" ? document.createElement("div") : null,
2624
+ content: "",
2625
+ injectCSS: !0,
2626
+ injectNonce: void 0,
2627
+ extensions: [],
2628
+ autofocus: !1,
2629
+ editable: !0,
2630
+ textDirection: void 0,
2631
+ editorProps: {},
2632
+ parseOptions: {},
2633
+ coreExtensionOptions: {},
2634
+ enableInputRules: !0,
2635
+ enablePasteRules: !0,
2636
+ enableCoreExtensions: !0,
2637
+ enableContentCheck: !1,
2638
+ emitContentError: !1,
2639
+ onBeforeCreate: () => null,
2640
+ onCreate: () => null,
2641
+ onMount: () => null,
2642
+ onUnmount: () => null,
2643
+ onUpdate: () => null,
2644
+ onSelectionUpdate: () => null,
2645
+ onTransaction: () => null,
2646
+ onFocus: () => null,
2647
+ onBlur: () => null,
2648
+ onDestroy: () => null,
2649
+ onContentError: ({ error: o }) => {
2650
+ throw o;
2651
+ },
2652
+ onPaste: () => null,
2653
+ onDrop: () => null,
2654
+ onDelete: () => null,
2655
+ enableExtensionDispatchTransaction: !0
2656
+ }, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
2657
+ getUpdatedPosition: nr,
2658
+ createMappablePosition: rr
2659
+ }, this.setOptions(t), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("mount", this.options.onMount), this.on("unmount", this.options.onUnmount), this.on("contentError", this.options.onContentError), 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), this.on("drop", ({ event: o, slice: s, moved: i }) => this.options.onDrop(o, s, i)), this.on("paste", ({ event: o, slice: s }) => this.options.onPaste(o, s)), this.on("delete", this.options.onDelete);
2660
+ const n = this.createDoc(), r = Lt(n, this.options.autofocus);
2661
+ this.editorState = _e.create({
2662
+ doc: n,
2663
+ schema: this.schema,
2664
+ selection: r || void 0
2665
+ }), this.options.element && this.mount(this.options.element);
2666
+ }
2667
+ /**
2668
+ * Attach the editor to the DOM, creating a new editor view.
2669
+ */
2670
+ mount(t) {
2671
+ if (typeof document > "u")
2672
+ throw new Error(
2673
+ "[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment."
2674
+ );
2675
+ this.createView(t), this.emit("mount", { editor: this }), this.css && !document.head.contains(this.css) && document.head.appendChild(this.css), window.setTimeout(() => {
2676
+ this.isDestroyed || (this.options.autofocus !== !1 && this.options.autofocus !== null && this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0);
2677
+ }, 0);
2678
+ }
2679
+ /**
2680
+ * Remove the editor from the DOM, but still allow remounting at a different point in time
2681
+ */
2682
+ unmount() {
2683
+ if (this.editorView) {
2684
+ const t = this.editorView.dom;
2685
+ t?.editor && delete t.editor, this.editorView.destroy();
2686
+ }
2687
+ if (this.editorView = null, this.isInitialized = !1, this.css && !document.querySelectorAll(`.${this.className}`).length)
2688
+ try {
2689
+ typeof this.css.remove == "function" ? this.css.remove() : this.css.parentNode && this.css.parentNode.removeChild(this.css);
2690
+ } catch (t) {
2691
+ console.warn("Failed to remove CSS element:", t);
2692
+ }
2693
+ this.css = null, this.emit("unmount", { editor: this });
2694
+ }
2695
+ /**
2696
+ * Returns the editor storage.
2697
+ */
2698
+ get storage() {
2699
+ return this.extensionStorage;
2700
+ }
2701
+ /**
2702
+ * An object of all registered commands.
2703
+ */
2704
+ get commands() {
2705
+ return this.commandManager.commands;
2706
+ }
2707
+ /**
2708
+ * Create a command chain to call multiple commands at once.
2709
+ */
2710
+ chain() {
2711
+ return this.commandManager.chain();
2712
+ }
2713
+ /**
2714
+ * Check if a command or a command chain can be executed. Without executing it.
2715
+ */
2716
+ can() {
2717
+ return this.commandManager.can();
2718
+ }
2719
+ /**
2720
+ * Inject CSS styles.
2721
+ */
2722
+ injectCSS() {
2723
+ this.options.injectCSS && typeof document < "u" && (this.css = zr(_r, this.options.injectNonce));
2724
+ }
2725
+ /**
2726
+ * Update editor options.
2727
+ *
2728
+ * @param options A list of options
2729
+ */
2730
+ setOptions(t = {}) {
2731
+ this.options = {
2732
+ ...this.options,
2733
+ ...t
2734
+ }, !(!this.editorView || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
2735
+ }
2736
+ /**
2737
+ * Update editable state of the editor.
2738
+ */
2739
+ setEditable(t, n = !0) {
2740
+ this.setOptions({ editable: t }), n && this.emit("update", { editor: this, transaction: this.state.tr, appendedTransactions: [] });
2741
+ }
2742
+ /**
2743
+ * Returns whether the editor is editable.
2744
+ */
2745
+ get isEditable() {
2746
+ return this.options.editable && this.view && this.view.editable;
2747
+ }
2748
+ /**
2749
+ * Returns the editor state.
2750
+ */
2751
+ get view() {
2752
+ return this.editorView ? this.editorView : new Proxy(
2753
+ {
2754
+ state: this.editorState,
2755
+ updateState: (t) => {
2756
+ this.editorState = t;
2757
+ },
2758
+ dispatch: (t) => {
2759
+ this.dispatchTransaction(t);
2760
+ },
2761
+ // Stub some commonly accessed properties to prevent errors
2762
+ composing: !1,
2763
+ dragging: null,
2764
+ editable: !0,
2765
+ isDestroyed: !1
2766
+ },
2767
+ {
2768
+ get: (t, n) => {
2769
+ if (this.editorView)
2770
+ return this.editorView[n];
2771
+ if (n === "state")
2772
+ return this.editorState;
2773
+ if (n in t)
2774
+ return Reflect.get(t, n);
2775
+ throw new Error(
2776
+ `[tiptap error]: The editor view is not available. Cannot access view['${n}']. The editor may not be mounted yet.`
2777
+ );
2778
+ }
2779
+ }
2780
+ );
2781
+ }
2782
+ /**
2783
+ * Returns the editor state.
2784
+ */
2785
+ get state() {
2786
+ return this.editorView && (this.editorState = this.view.state), this.editorState;
2787
+ }
2788
+ /**
2789
+ * Register a ProseMirror plugin.
2790
+ *
2791
+ * @param plugin A ProseMirror plugin
2792
+ * @param handlePlugins Control how to merge the plugin into the existing plugins.
2793
+ * @returns The new editor state
2794
+ */
2795
+ registerPlugin(t, n) {
2796
+ const r = Wt(n) ? n(t, [...this.state.plugins]) : [...this.state.plugins, t], o = this.state.reconfigure({ plugins: r });
2797
+ return this.view.updateState(o), o;
2798
+ }
2799
+ /**
2800
+ * Unregister a ProseMirror plugin.
2801
+ *
2802
+ * @param nameOrPluginKeyToRemove The plugins name
2803
+ * @returns The new editor state or undefined if the editor is destroyed
2804
+ */
2805
+ unregisterPlugin(t) {
2806
+ if (this.isDestroyed)
2807
+ return;
2808
+ const n = this.state.plugins;
2809
+ let r = n;
2810
+ if ([].concat(t).forEach((s) => {
2811
+ const i = typeof s == "string" ? `${s}$` : s.key;
2812
+ r = r.filter((a) => !a.key.startsWith(i));
2813
+ }), n.length === r.length)
2814
+ return;
2815
+ const o = this.state.reconfigure({
2816
+ plugins: r
2817
+ });
2818
+ return this.view.updateState(o), o;
2819
+ }
2820
+ /**
2821
+ * Creates an extension manager.
2822
+ */
2823
+ createExtensionManager() {
2824
+ var t, n;
2825
+ const o = [...this.options.enableCoreExtensions ? [
2826
+ ie,
2827
+ ne.configure({
2828
+ blockSeparator: (n = (t = this.options.coreExtensionOptions) == null ? void 0 : t.clipboardTextSerializer) == null ? void 0 : n.blockSeparator
2829
+ }),
2830
+ re,
2831
+ ce,
2832
+ le,
2833
+ ue,
2834
+ se,
2835
+ de,
2836
+ oe,
2837
+ fe.configure({
2838
+ direction: this.options.textDirection
2839
+ })
2840
+ ].filter((s) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[s.name] !== !1 : !0) : [], ...this.options.extensions].filter((s) => ["extension", "node", "mark"].includes(s?.type));
2841
+ this.extensionManager = new ct(o, this);
2842
+ }
2843
+ /**
2844
+ * Creates an command manager.
2845
+ */
2846
+ createCommandManager() {
2847
+ this.commandManager = new ot({
2848
+ editor: this
2849
+ });
2850
+ }
2851
+ /**
2852
+ * Creates a ProseMirror schema.
2853
+ */
2854
+ createSchema() {
2855
+ this.schema = this.extensionManager.schema;
2856
+ }
2857
+ /**
2858
+ * Creates the initial document.
2859
+ */
2860
+ createDoc() {
2861
+ let t;
2862
+ try {
2863
+ t = mt(this.options.content, this.schema, this.options.parseOptions, {
2864
+ errorOnInvalidContent: this.options.enableContentCheck
2865
+ });
2866
+ } catch (n) {
2867
+ if (!(n instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(n.message))
2868
+ throw n;
2869
+ this.emit("contentError", {
2870
+ editor: this,
2871
+ error: n,
2872
+ disableCollaboration: () => {
2873
+ "collaboration" in this.storage && typeof this.storage.collaboration == "object" && this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((r) => r.name !== "collaboration"), this.createExtensionManager();
2874
+ }
2875
+ }), t = mt(this.options.content, this.schema, this.options.parseOptions, {
2876
+ errorOnInvalidContent: !1
2877
+ });
2878
+ }
2879
+ return t;
2880
+ }
2881
+ /**
2882
+ * Creates a ProseMirror view.
2883
+ */
2884
+ createView(t) {
2885
+ const { editorProps: n, enableExtensionDispatchTransaction: r } = this.options, o = n.dispatchTransaction || this.dispatchTransaction.bind(this), s = r ? this.extensionManager.dispatchTransaction(o) : o;
2886
+ this.editorView = new qe(t, {
2887
+ ...n,
2888
+ attributes: {
2889
+ // add `role="textbox"` to the editor element
2890
+ role: "textbox",
2891
+ ...n?.attributes
2892
+ },
2893
+ dispatchTransaction: s,
2894
+ state: this.editorState,
2895
+ markViews: this.extensionManager.markViews,
2896
+ nodeViews: this.extensionManager.nodeViews
2897
+ });
2898
+ const i = this.state.reconfigure({
2899
+ plugins: this.extensionManager.plugins
2900
+ });
2901
+ this.view.updateState(i), this.prependClass(), this.injectCSS();
2902
+ const a = this.view.dom;
2903
+ a.editor = this;
2904
+ }
2905
+ /**
2906
+ * Creates all node and mark views.
2907
+ */
2908
+ createNodeViews() {
2909
+ this.view.isDestroyed || this.view.setProps({
2910
+ markViews: this.extensionManager.markViews,
2911
+ nodeViews: this.extensionManager.nodeViews
2912
+ });
2913
+ }
2914
+ /**
2915
+ * Prepend class name to element.
2916
+ */
2917
+ prependClass() {
2918
+ this.view.dom.className = `${this.className} ${this.view.dom.className}`;
2919
+ }
2920
+ captureTransaction(t) {
2921
+ this.isCapturingTransaction = !0, t(), this.isCapturingTransaction = !1;
2922
+ const n = this.capturedTransaction;
2923
+ return this.capturedTransaction = null, n;
2924
+ }
2925
+ /**
2926
+ * The callback over which to send transactions (state updates) produced by the view.
2927
+ *
2928
+ * @param transaction An editor state transaction
2929
+ */
2930
+ dispatchTransaction(t) {
2931
+ if (this.view.isDestroyed)
2932
+ return;
2933
+ if (this.isCapturingTransaction) {
2934
+ if (!this.capturedTransaction) {
2935
+ this.capturedTransaction = t;
2936
+ return;
2937
+ }
2938
+ t.steps.forEach((u) => {
2939
+ var d;
2940
+ return (d = this.capturedTransaction) == null ? void 0 : d.step(u);
2941
+ });
2942
+ return;
2943
+ }
2944
+ const { state: n, transactions: r } = this.state.applyTransaction(t), o = !this.state.selection.eq(n.selection), s = r.includes(t), i = this.state;
2945
+ if (this.emit("beforeTransaction", {
2946
+ editor: this,
2947
+ transaction: t,
2948
+ nextState: n
2949
+ }), !s)
2950
+ return;
2951
+ this.view.updateState(n), this.emit("transaction", {
2952
+ editor: this,
2953
+ transaction: t,
2954
+ appendedTransactions: r.slice(1)
2955
+ }), o && this.emit("selectionUpdate", {
2956
+ editor: this,
2957
+ transaction: t
2958
+ });
2959
+ const a = r.findLast((u) => u.getMeta("focus") || u.getMeta("blur")), c = a?.getMeta("focus"), l = a?.getMeta("blur");
2960
+ c && this.emit("focus", {
2961
+ editor: this,
2962
+ event: c.event,
2963
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2964
+ transaction: a
2965
+ }), l && this.emit("blur", {
2966
+ editor: this,
2967
+ event: l.event,
2968
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2969
+ transaction: a
2970
+ }), !(t.getMeta("preventUpdate") || !r.some((u) => u.docChanged) || i.doc.eq(n.doc)) && this.emit("update", {
2971
+ editor: this,
2972
+ transaction: t,
2973
+ appendedTransactions: r.slice(1)
2974
+ });
2975
+ }
2976
+ /**
2977
+ * Get attributes of the currently selected node or mark.
2978
+ */
2979
+ getAttributes(t) {
2980
+ return Qn(this.state, t);
2981
+ }
2982
+ isActive(t, n) {
2983
+ const r = typeof t == "string" ? t : null, o = typeof t == "string" ? n : t;
2984
+ return er(this.state, r, o);
2985
+ }
2986
+ /**
2987
+ * Get the document as JSON.
2988
+ */
2989
+ getJSON() {
2990
+ return this.state.doc.toJSON();
2991
+ }
2992
+ /**
2993
+ * Get the document as HTML.
2994
+ */
2995
+ getHTML() {
2996
+ return wt(this.state.doc.content, this.schema);
2997
+ }
2998
+ /**
2999
+ * Get the document as text.
3000
+ */
3001
+ getText(t) {
3002
+ const { blockSeparator: n = `
3003
+
3004
+ `, textSerializers: r = {} } = t || {};
3005
+ return Jn(this.state.doc, {
3006
+ blockSeparator: n,
3007
+ textSerializers: {
3008
+ ...Zt(this.schema),
3009
+ ...r
3010
+ }
3011
+ });
3012
+ }
3013
+ /**
3014
+ * Check if there is no content.
3015
+ */
3016
+ get isEmpty() {
3017
+ return Mt(this.state.doc);
3018
+ }
3019
+ /**
3020
+ * Destroy the editor.
3021
+ */
3022
+ destroy() {
3023
+ this.emit("destroy"), this.unmount(), this.removeAllListeners();
3024
+ }
3025
+ /**
3026
+ * Check if the editor is already destroyed.
3027
+ */
3028
+ get isDestroyed() {
3029
+ var t, n;
3030
+ return (n = (t = this.editorView) == null ? void 0 : t.isDestroyed) != null ? n : !0;
3031
+ }
3032
+ $node(t, n) {
3033
+ var r;
3034
+ return ((r = this.$doc) == null ? void 0 : r.querySelector(t, n)) || null;
3035
+ }
3036
+ $nodes(t, n) {
3037
+ var r;
3038
+ return ((r = this.$doc) == null ? void 0 : r.querySelectorAll(t, n)) || null;
3039
+ }
3040
+ $pos(t) {
3041
+ const n = this.state.doc.resolve(t);
3042
+ return new Dr(n, this);
3043
+ }
3044
+ get $doc() {
3045
+ return this.$pos(0);
3046
+ }
3047
+ };
3048
+ function lo(e) {
3049
+ return new at({
3050
+ find: e.find,
3051
+ handler: ({ state: t, range: n, match: r }) => {
3052
+ const o = x(e.getAttributes, void 0, r);
3053
+ if (o === !1 || o === null)
3054
+ return null;
3055
+ const { tr: s } = t, i = r[r.length - 1], a = r[0];
3056
+ if (i) {
3057
+ const c = a.search(/\S/), l = n.from + a.indexOf(i), u = l + i.length;
3058
+ if (Qt(n.from, n.to, t.doc).filter((p) => p.mark.type.excluded.find((h) => h === e.type && h !== p.mark.type)).filter((p) => p.to > l).length)
3059
+ return null;
3060
+ u < n.to && s.delete(u, n.to), l > n.from && s.delete(n.from + c, l);
3061
+ const f = n.from + c + i.length;
3062
+ s.addMark(n.from + c, f, e.type.create(o || {})), s.removeStoredMark(e.type);
3063
+ }
3064
+ },
3065
+ undoable: e.undoable
3066
+ });
3067
+ }
3068
+ function uo(e) {
3069
+ return new at({
3070
+ find: e.find,
3071
+ handler: ({ state: t, range: n, match: r }) => {
3072
+ const o = x(e.getAttributes, void 0, r) || {}, { tr: s } = t, i = n.from;
3073
+ let a = n.to;
3074
+ const c = e.type.create(o);
3075
+ if (r[1]) {
3076
+ const l = r[0].lastIndexOf(r[1]);
3077
+ let u = i + l;
3078
+ u > a ? u = a : a = u + r[1].length;
3079
+ const d = r[0][r[0].length - 1];
3080
+ s.insertText(d, i + r[0].length - 1), s.replaceWith(u, a, c);
3081
+ } else if (r[0]) {
3082
+ const l = e.type.isInline ? i : i - 1;
3083
+ s.insert(l, e.type.create(o)).delete(s.mapping.map(i), s.mapping.map(a));
3084
+ }
3085
+ s.scrollIntoView();
3086
+ },
3087
+ undoable: e.undoable
3088
+ });
3089
+ }
3090
+ function fo(e) {
3091
+ return new at({
3092
+ find: e.find,
3093
+ handler: ({ state: t, range: n, match: r }) => {
3094
+ const o = t.doc.resolve(n.from), s = x(e.getAttributes, void 0, r) || {};
3095
+ if (!o.node(-1).canReplaceWith(o.index(-1), o.indexAfter(-1), e.type))
3096
+ return null;
3097
+ t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, s);
3098
+ },
3099
+ undoable: e.undoable
3100
+ });
3101
+ }
3102
+ function po(e) {
3103
+ return new at({
3104
+ find: e.find,
3105
+ handler: ({ state: t, range: n, match: r, chain: o }) => {
3106
+ const s = x(e.getAttributes, void 0, r) || {}, i = t.tr.delete(n.from, n.to), c = i.doc.resolve(n.from).blockRange(), l = c && me(c, e.type, s);
3107
+ if (!l)
3108
+ return null;
3109
+ if (i.wrap(c, l), e.keepMarks && e.editor) {
3110
+ const { selection: d, storedMarks: f } = t, { splittableMarks: p } = e.editor.extensionManager, m = f || d.$to.parentOffset && d.$from.marks();
3111
+ if (m) {
3112
+ const h = m.filter((g) => p.includes(g.type.name));
3113
+ i.ensureMarks(h);
3114
+ }
3115
+ }
3116
+ if (e.keepAttributes) {
3117
+ const d = e.type.name === "bulletList" || e.type.name === "orderedList" ? "listItem" : "taskList";
3118
+ o().updateAttributes(d, s).run();
3119
+ }
3120
+ const u = i.doc.resolve(n.from - 1).nodeBefore;
3121
+ u && u.type === e.type && gt(i.doc, n.from - 1) && (!e.joinPredicate || e.joinPredicate(r, u)) && i.join(n.from - 1);
3122
+ },
3123
+ undoable: e.undoable
3124
+ });
3125
+ }
3126
+ function mo(e, t) {
3127
+ const { selection: n } = e, { $from: r } = n;
3128
+ if (n instanceof nt) {
3129
+ const s = r.index();
3130
+ return r.parent.canReplaceWith(s, s + 1, t);
3131
+ }
3132
+ let o = r.depth;
3133
+ for (; o >= 0; ) {
3134
+ const s = r.index(o);
3135
+ if (r.node(o).contentMatchAt(s).matchType(t))
3136
+ return !0;
3137
+ o -= 1;
3138
+ }
3139
+ return !1;
3140
+ }
3141
+ var Fr = {};
3142
+ vt(Fr, {
3143
+ createAtomBlockMarkdownSpec: () => Lr,
3144
+ createBlockMarkdownSpec: () => Vr,
3145
+ createInlineMarkdownSpec: () => Wr,
3146
+ parseAttributes: () => St,
3147
+ parseIndentedBlocks: () => qr,
3148
+ renderNestedMarkdownContent: () => Kr,
3149
+ serializeAttributes: () => Et
3150
+ });
3151
+ function St(e) {
3152
+ if (!e?.trim())
3153
+ return {};
3154
+ const t = {}, n = [], r = e.replace(/["']([^"']*)["']/g, (l) => (n.push(l), `__QUOTED_${n.length - 1}__`)), o = r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);
3155
+ if (o) {
3156
+ const l = o.map((u) => u.trim().slice(1));
3157
+ t.class = l.join(" ");
3158
+ }
3159
+ const s = r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);
3160
+ s && (t.id = s[1]);
3161
+ const i = /([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;
3162
+ Array.from(r.matchAll(i)).forEach(([, l, u]) => {
3163
+ var d;
3164
+ const f = parseInt(((d = u.match(/__QUOTED_(\d+)__/)) == null ? void 0 : d[1]) || "0", 10), p = n[f];
3165
+ p && (t[l] = p.slice(1, -1));
3166
+ });
3167
+ const c = r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g, "").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g, "").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g, "").trim();
3168
+ return c && c.split(/\s+/).filter(Boolean).forEach((u) => {
3169
+ u.match(/^[a-zA-Z][\w-]*$/) && (t[u] = !0);
3170
+ }), t;
3171
+ }
3172
+ function Et(e) {
3173
+ if (!e || Object.keys(e).length === 0)
3174
+ return "";
3175
+ const t = [];
3176
+ return e.class && String(e.class).split(/\s+/).filter(Boolean).forEach((r) => t.push(`.${r}`)), e.id && t.push(`#${e.id}`), Object.entries(e).forEach(([n, r]) => {
3177
+ n === "class" || n === "id" || (r === !0 ? t.push(n) : r !== !1 && r != null && t.push(`${n}="${String(r)}"`));
3178
+ }), t.join(" ");
3179
+ }
3180
+ function Lr(e) {
3181
+ const {
3182
+ nodeName: t,
3183
+ name: n,
3184
+ parseAttributes: r = St,
3185
+ serializeAttributes: o = Et,
3186
+ defaultAttributes: s = {},
3187
+ requiredAttributes: i = [],
3188
+ allowedAttributes: a
3189
+ } = e, c = n || t, l = (u) => {
3190
+ if (!a)
3191
+ return u;
3192
+ const d = {};
3193
+ return a.forEach((f) => {
3194
+ f in u && (d[f] = u[f]);
3195
+ }), d;
3196
+ };
3197
+ return {
3198
+ parseMarkdown: (u, d) => {
3199
+ const f = { ...s, ...u.attributes };
3200
+ return d.createNode(t, f, []);
3201
+ },
3202
+ markdownTokenizer: {
3203
+ name: t,
3204
+ level: "block",
3205
+ start(u) {
3206
+ var d;
3207
+ const f = new RegExp(`^:::${c}(?:\\s|$)`, "m"), p = (d = u.match(f)) == null ? void 0 : d.index;
3208
+ return p !== void 0 ? p : -1;
3209
+ },
3210
+ tokenize(u, d, f) {
3211
+ const p = new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`), m = u.match(p);
3212
+ if (!m)
3213
+ return;
3214
+ const h = m[1] || "", g = r(h);
3215
+ if (!i.find((k) => !(k in g)))
3216
+ return {
3217
+ type: t,
3218
+ raw: m[0],
3219
+ attributes: g
3220
+ };
3221
+ }
3222
+ },
3223
+ renderMarkdown: (u) => {
3224
+ const d = l(u.attrs || {}), f = o(d), p = f ? ` {${f}}` : "";
3225
+ return `:::${c}${p} :::`;
3226
+ }
3227
+ };
3228
+ }
3229
+ function Vr(e) {
3230
+ const {
3231
+ nodeName: t,
3232
+ name: n,
3233
+ getContent: r,
3234
+ parseAttributes: o = St,
3235
+ serializeAttributes: s = Et,
3236
+ defaultAttributes: i = {},
3237
+ content: a = "block",
3238
+ allowedAttributes: c
3239
+ } = e, l = n || t, u = (d) => {
3240
+ if (!c)
3241
+ return d;
3242
+ const f = {};
3243
+ return c.forEach((p) => {
3244
+ p in d && (f[p] = d[p]);
3245
+ }), f;
3246
+ };
3247
+ return {
3248
+ parseMarkdown: (d, f) => {
3249
+ let p;
3250
+ if (r) {
3251
+ const h = r(d);
3252
+ p = typeof h == "string" ? [{ type: "text", text: h }] : h;
3253
+ } else a === "block" ? p = f.parseChildren(d.tokens || []) : p = f.parseInline(d.tokens || []);
3254
+ const m = { ...i, ...d.attributes };
3255
+ return f.createNode(t, m, p);
3256
+ },
3257
+ markdownTokenizer: {
3258
+ name: t,
3259
+ level: "block",
3260
+ start(d) {
3261
+ var f;
3262
+ const p = new RegExp(`^:::${l}`, "m"), m = (f = d.match(p)) == null ? void 0 : f.index;
3263
+ return m !== void 0 ? m : -1;
3264
+ },
3265
+ tokenize(d, f, p) {
3266
+ var m;
3267
+ const h = new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`), g = d.match(h);
3268
+ if (!g)
3269
+ return;
3270
+ const [v, k = ""] = g, w = o(k);
3271
+ let M = 1;
3272
+ const y = v.length;
3273
+ let S = "";
3274
+ const E = /^:::([\w-]*)(\s.*)?/gm, A = d.slice(y);
3275
+ for (E.lastIndex = 0; ; ) {
3276
+ const C = E.exec(A);
3277
+ if (C === null)
3278
+ break;
3279
+ const D = C.index, lt = C[1];
3280
+ if (!((m = C[2]) != null && m.endsWith(":::"))) {
3281
+ if (lt)
3282
+ M += 1;
3283
+ else if (M -= 1, M === 0) {
3284
+ const U = A.slice(0, D);
3285
+ S = U.trim();
3286
+ const dt = d.slice(0, y + D + C[0].length);
3287
+ let B = [];
3288
+ if (S)
3289
+ if (a === "block")
3290
+ for (B = p.blockTokens(U), B.forEach((I) => {
3291
+ I.text && (!I.tokens || I.tokens.length === 0) && (I.tokens = p.inlineTokens(I.text));
3292
+ }); B.length > 0; ) {
3293
+ const I = B[B.length - 1];
3294
+ if (I.type === "paragraph" && (!I.text || I.text.trim() === ""))
3295
+ B.pop();
3296
+ else
3297
+ break;
3298
+ }
3299
+ else
3300
+ B = p.inlineTokens(S);
3301
+ return {
3302
+ type: t,
3303
+ raw: dt,
3304
+ attributes: w,
3305
+ content: S,
3306
+ tokens: B
3307
+ };
3308
+ }
3309
+ }
3310
+ }
3311
+ }
3312
+ },
3313
+ renderMarkdown: (d, f) => {
3314
+ const p = u(d.attrs || {}), m = s(p), h = m ? ` {${m}}` : "", g = f.renderChildren(d.content || [], `
3315
+
3316
+ `);
3317
+ return `:::${l}${h}
3318
+
3319
+ ${g}
3320
+
3321
+ :::`;
3322
+ }
3323
+ };
3324
+ }
3325
+ function Hr(e) {
3326
+ if (!e.trim())
3327
+ return {};
3328
+ const t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
3329
+ let r = n.exec(e);
3330
+ for (; r !== null; ) {
3331
+ const [, o, s, i] = r;
3332
+ t[o] = s || i, r = n.exec(e);
3333
+ }
3334
+ return t;
3335
+ }
3336
+ function Ur(e) {
3337
+ return Object.entries(e).filter(([, t]) => t != null).map(([t, n]) => `${t}="${n}"`).join(" ");
3338
+ }
3339
+ function Wr(e) {
3340
+ const {
3341
+ nodeName: t,
3342
+ name: n,
3343
+ getContent: r,
3344
+ parseAttributes: o = Hr,
3345
+ serializeAttributes: s = Ur,
3346
+ defaultAttributes: i = {},
3347
+ selfClosing: a = !1,
3348
+ allowedAttributes: c
3349
+ } = e, l = n || t, u = (f) => {
3350
+ if (!c)
3351
+ return f;
3352
+ const p = {};
3353
+ return c.forEach((m) => {
3354
+ const h = typeof m == "string" ? m : m.name, g = typeof m == "string" ? void 0 : m.skipIfDefault;
3355
+ if (h in f) {
3356
+ const v = f[h];
3357
+ if (g !== void 0 && v === g)
3358
+ return;
3359
+ p[h] = v;
3360
+ }
3361
+ }), p;
3362
+ }, d = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3363
+ return {
3364
+ parseMarkdown: (f, p) => {
3365
+ const m = { ...i, ...f.attributes };
3366
+ if (a)
3367
+ return p.createNode(t, m);
3368
+ const h = r ? r(f) : f.content || "";
3369
+ return h ? p.createNode(t, m, [p.createTextNode(h)]) : p.createNode(t, m, []);
3370
+ },
3371
+ markdownTokenizer: {
3372
+ name: t,
3373
+ level: "inline",
3374
+ start(f) {
3375
+ const p = a ? new RegExp(`\\[${d}\\s*[^\\]]*\\]`) : new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`), m = f.match(p), h = m?.index;
3376
+ return h !== void 0 ? h : -1;
3377
+ },
3378
+ tokenize(f, p, m) {
3379
+ const h = a ? new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`) : new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`), g = f.match(h);
3380
+ if (!g)
3381
+ return;
3382
+ let v = "", k = "";
3383
+ if (a) {
3384
+ const [, M] = g;
3385
+ k = M;
3386
+ } else {
3387
+ const [, M, y] = g;
3388
+ k = M, v = y || "";
3389
+ }
3390
+ const w = o(k.trim());
3391
+ return {
3392
+ type: t,
3393
+ raw: g[0],
3394
+ content: v.trim(),
3395
+ attributes: w
3396
+ };
3397
+ }
3398
+ },
3399
+ renderMarkdown: (f) => {
3400
+ let p = "";
3401
+ r ? p = r(f) : f.content && f.content.length > 0 && (p = f.content.filter((v) => v.type === "text").map((v) => v.text).join(""));
3402
+ const m = u(f.attrs || {}), h = s(m), g = h ? ` ${h}` : "";
3403
+ return a ? `[${l}${g}]` : `[${l}${g}]${p}[/${l}]`;
3404
+ }
3405
+ };
3406
+ }
3407
+ function qr(e, t, n) {
3408
+ var r, o, s, i;
3409
+ const a = e.split(`
3410
+ `), c = [];
3411
+ let l = "", u = 0;
3412
+ const d = t.baseIndentSize || 2;
3413
+ for (; u < a.length; ) {
3414
+ const f = a[u], p = f.match(t.itemPattern);
3415
+ if (!p) {
3416
+ if (c.length > 0)
3417
+ break;
3418
+ if (f.trim() === "") {
3419
+ u += 1, l = `${l}${f}
3420
+ `;
3421
+ continue;
3422
+ } else
3423
+ return;
3424
+ }
3425
+ const m = t.extractItemData(p), { indentLevel: h, mainContent: g } = m;
3426
+ l = `${l}${f}
3427
+ `;
3428
+ const v = [g];
3429
+ for (u += 1; u < a.length; ) {
3430
+ const y = a[u];
3431
+ if (y.trim() === "") {
3432
+ const E = a.slice(u + 1).findIndex((D) => D.trim() !== "");
3433
+ if (E === -1)
3434
+ break;
3435
+ if ((((o = (r = a[u + 1 + E].match(/^(\s*)/)) == null ? void 0 : r[1]) == null ? void 0 : o.length) || 0) > h) {
3436
+ v.push(y), l = `${l}${y}
3437
+ `, u += 1;
3438
+ continue;
3439
+ } else
3440
+ break;
3441
+ }
3442
+ if ((((i = (s = y.match(/^(\s*)/)) == null ? void 0 : s[1]) == null ? void 0 : i.length) || 0) > h)
3443
+ v.push(y), l = `${l}${y}
3444
+ `, u += 1;
3445
+ else
3446
+ break;
3447
+ }
3448
+ let k;
3449
+ const w = v.slice(1);
3450
+ if (w.length > 0) {
3451
+ const y = w.map((S) => S.slice(h + d)).join(`
3452
+ `);
3453
+ y.trim() && (t.customNestedParser ? k = t.customNestedParser(y) : k = n.blockTokens(y));
3454
+ }
3455
+ const M = t.createToken(m, k);
3456
+ c.push(M);
3457
+ }
3458
+ if (c.length !== 0)
3459
+ return {
3460
+ items: c,
3461
+ raw: l
3462
+ };
3463
+ }
3464
+ function Kr(e, t, n, r) {
3465
+ if (!e || !Array.isArray(e.content))
3466
+ return "";
3467
+ const o = typeof n == "function" ? n(r) : n, [s, ...i] = e.content, a = t.renderChildren([s]), c = [`${o}${a}`];
3468
+ return i && i.length > 0 && i.forEach((l) => {
3469
+ const u = t.renderChildren([l]);
3470
+ if (u) {
3471
+ const d = u.split(`
3472
+ `).map((f) => f ? t.indent(f) : "").join(`
3473
+ `);
3474
+ c.push(d);
3475
+ }
3476
+ }), c.join(`
3477
+ `);
3478
+ }
3479
+ function Jr(e, t, n = {}) {
3480
+ const { state: r } = t, { doc: o, tr: s } = r, i = e;
3481
+ o.descendants((a, c) => {
3482
+ const l = s.mapping.map(c), u = s.mapping.map(c) + a.nodeSize;
3483
+ let d = null;
3484
+ if (a.marks.forEach((p) => {
3485
+ if (p !== i)
3486
+ return !1;
3487
+ d = p;
3488
+ }), !d)
3489
+ return;
3490
+ let f = !1;
3491
+ if (Object.keys(n).forEach((p) => {
3492
+ n[p] !== d.attrs[p] && (f = !0);
3493
+ }), f) {
3494
+ const p = e.type.create({
3495
+ ...e.attrs,
3496
+ ...n
3497
+ });
3498
+ s.removeMark(l, u, e.type), s.addMark(l, u, p);
3499
+ }
3500
+ }), s.docChanged && t.view.dispatch(s);
3501
+ }
3502
+ var ho = class pe extends xt {
3503
+ constructor() {
3504
+ super(...arguments), this.type = "node";
3505
+ }
3506
+ /**
3507
+ * Create a new Node instance
3508
+ * @param config - Node configuration object or a function that returns a configuration object
3509
+ */
3510
+ static create(t = {}) {
3511
+ const n = typeof t == "function" ? t() : t;
3512
+ return new pe(n);
3513
+ }
3514
+ configure(t) {
3515
+ return super.configure(t);
3516
+ }
3517
+ extend(t) {
3518
+ const n = typeof t == "function" ? t() : t;
3519
+ return super.extend(n);
3520
+ }
3521
+ };
3522
+ function go(e) {
3523
+ return new Nr({
3524
+ find: e.find,
3525
+ handler: ({ state: t, range: n, match: r, pasteEvent: o }) => {
3526
+ const s = x(e.getAttributes, void 0, r, o);
3527
+ if (s === !1 || s === null)
3528
+ return null;
3529
+ const { tr: i } = t, a = r[r.length - 1], c = r[0];
3530
+ let l = n.to;
3531
+ if (a) {
3532
+ const u = c.search(/\S/), d = n.from + c.indexOf(a), f = d + a.length;
3533
+ if (Qt(n.from, n.to, t.doc).filter((m) => m.mark.type.excluded.find((g) => g === e.type && g !== m.mark.type)).filter((m) => m.to > d).length)
3534
+ return null;
3535
+ f < n.to && i.delete(f, n.to), d > n.from && i.delete(n.from + u, d), l = n.from + u + a.length, i.addMark(n.from + u, l, e.type.create(s || {})), i.removeStoredMark(e.type);
3536
+ }
3537
+ }
3538
+ });
3539
+ }
20
3540
  export {
21
- i as default
3541
+ ot as CommandManager,
3542
+ ao as Editor,
3543
+ xt as Extendable,
3544
+ N as Extension,
3545
+ at as InputRule,
3546
+ Gt as MappablePosition,
3547
+ $r as Mark,
3548
+ ho as Node,
3549
+ Dr as NodePos,
3550
+ Nr as PasteRule,
3551
+ x as callOrReturn,
3552
+ mo as canInsertNode,
3553
+ Fn as combineTransactionSteps,
3554
+ _t as commands,
3555
+ Lr as createAtomBlockMarkdownSpec,
3556
+ Vr as createBlockMarkdownSpec,
3557
+ rt as createChainableState,
3558
+ mt as createDocument,
3559
+ Wr as createInlineMarkdownSpec,
3560
+ rr as createMappablePosition,
3561
+ V as createNodeFromContent,
3562
+ zr as createStyleTag,
3563
+ Ln as defaultBlockAt,
3564
+ $t as deleteProps,
3565
+ W as elementFromString,
3566
+ Or as extensions,
3567
+ no as findChildrenInRange,
3568
+ Kn as findDuplicates,
3569
+ it as findParentNode,
3570
+ Vn as findParentNodeClosestToPos,
3571
+ yt as flattenExtensions,
3572
+ Wn as fromString,
3573
+ Qn as getAttributes,
3574
+ qt as getAttributesFromExtensions,
3575
+ Xn as getChangedRanges,
3576
+ b as getExtensionField,
3577
+ wt as getHTMLFromFragment,
3578
+ Ut as getMarkAttributes,
3579
+ kt as getMarkRange,
3580
+ R as getMarkType,
3581
+ Qt as getMarksBetween,
3582
+ ro as getNodeAtPosition,
3583
+ Zn as getNodeAttributes,
3584
+ T as getNodeType,
3585
+ tt as getRenderedAttributes,
3586
+ qn as getSchemaByResolvedExtensions,
3587
+ q as getSchemaTypeByName,
3588
+ st as getSchemaTypeNameByName,
3589
+ G as getSplittedAttributes,
3590
+ Jn as getText,
3591
+ Jt as getTextBetween,
3592
+ tr as getTextContentFromNodes,
3593
+ Zt as getTextSerializersFromSchema,
3594
+ nr as getUpdatedPosition,
3595
+ Pt as injectExtensionAttributesToParseRule,
3596
+ Ar as inputRulesPlugin,
3597
+ er as isActive,
3598
+ Ct as isAndroid,
3599
+ oo as isAtEndOfNode,
3600
+ so as isAtStartOfNode,
3601
+ Hn as isEmptyObject,
3602
+ Rt as isExtensionRulesEnabled,
3603
+ Wt as isFunction,
3604
+ Bt as isList,
3605
+ Ht as isMacOS,
3606
+ ht as isMarkActive,
3607
+ H as isNodeActive,
3608
+ Mt as isNodeEmpty,
3609
+ io as isNodeSelection,
3610
+ Pr as isNumber,
3611
+ J as isPlainObject,
3612
+ bt as isRegExp,
3613
+ dn as isSafari,
3614
+ Ft as isTextSelection,
3615
+ X as isiOS,
3616
+ lo as markInputRule,
3617
+ go as markPasteRule,
3618
+ Fr as markdown,
3619
+ Un as mergeAttributes,
3620
+ Xt as mergeDeep,
3621
+ _ as minMax,
3622
+ uo as nodeInputRule,
3623
+ Y as objectIncludes,
3624
+ St as parseAttributes,
3625
+ qr as parseIndentedBlocks,
3626
+ jr as pasteRulesPlugin,
3627
+ Gn as removeDuplicates,
3628
+ Kr as renderNestedMarkdownContent,
3629
+ Kt as resolveExtensions,
3630
+ Lt as resolveFocusPosition,
3631
+ mn as selectionToInsertionEnd,
3632
+ Et as serializeAttributes,
3633
+ et as sortExtensions,
3634
+ F as splitExtensions,
3635
+ fo as textblockTypeInputRule,
3636
+ Jr as updateMarkViewAttributes,
3637
+ po as wrappingInputRule
22
3638
  };