@vc-shell/framework 1.1.99-alpha.2 → 1.2.1

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