@quoreadmin/ui 1.10.23 → 1.10.25

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