@notum-cz/strapi-plugin-tiptap-editor 1.0.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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -0
  3. package/dist/_chunks/AccentCursive-CpAPpH9C.mjs +3383 -0
  4. package/dist/_chunks/AccentCursive-CpAPpH9C.mjs.map +1 -0
  5. package/dist/_chunks/AccentCursive-D6sTlhub.js +3384 -0
  6. package/dist/_chunks/AccentCursive-D6sTlhub.js.map +1 -0
  7. package/dist/_chunks/FormattedHeadingInput-DycgfIze.mjs +101 -0
  8. package/dist/_chunks/FormattedHeadingInput-DycgfIze.mjs.map +1 -0
  9. package/dist/_chunks/FormattedHeadingInput-FFjiRSEJ.js +101 -0
  10. package/dist/_chunks/FormattedHeadingInput-FFjiRSEJ.js.map +1 -0
  11. package/dist/_chunks/RichTextInput-BZQ2iVqa.mjs +4481 -0
  12. package/dist/_chunks/RichTextInput-BZQ2iVqa.mjs.map +1 -0
  13. package/dist/_chunks/RichTextInput-BbbQxPc-.js +4414 -0
  14. package/dist/_chunks/RichTextInput-BbbQxPc-.js.map +1 -0
  15. package/dist/_chunks/RichTextInput-BjLR2pi0.js +4416 -0
  16. package/dist/_chunks/RichTextInput-BjLR2pi0.js.map +1 -0
  17. package/dist/_chunks/RichTextInput-BlxoJMa2.js +4488 -0
  18. package/dist/_chunks/RichTextInput-BlxoJMa2.js.map +1 -0
  19. package/dist/_chunks/RichTextInput-Bm3X8fR2.mjs +4400 -0
  20. package/dist/_chunks/RichTextInput-Bm3X8fR2.mjs.map +1 -0
  21. package/dist/_chunks/RichTextInput-Bms-gSvK.js +4407 -0
  22. package/dist/_chunks/RichTextInput-Bms-gSvK.js.map +1 -0
  23. package/dist/_chunks/RichTextInput-BtNjPJRN.mjs +4400 -0
  24. package/dist/_chunks/RichTextInput-BtNjPJRN.mjs.map +1 -0
  25. package/dist/_chunks/RichTextInput-Bw3tcXfp.js +4407 -0
  26. package/dist/_chunks/RichTextInput-Bw3tcXfp.js.map +1 -0
  27. package/dist/_chunks/RichTextInput-CsgNpoxq.mjs +4409 -0
  28. package/dist/_chunks/RichTextInput-CsgNpoxq.mjs.map +1 -0
  29. package/dist/_chunks/RichTextInput-CwTvEMda.js +4407 -0
  30. package/dist/_chunks/RichTextInput-CwTvEMda.js.map +1 -0
  31. package/dist/_chunks/RichTextInput-DG-36krM.js +1181 -0
  32. package/dist/_chunks/RichTextInput-DG-36krM.js.map +1 -0
  33. package/dist/_chunks/RichTextInput-DLac-zNQ.mjs +4400 -0
  34. package/dist/_chunks/RichTextInput-DLac-zNQ.mjs.map +1 -0
  35. package/dist/_chunks/RichTextInput-DSXttrvi.js +4407 -0
  36. package/dist/_chunks/RichTextInput-DSXttrvi.js.map +1 -0
  37. package/dist/_chunks/RichTextInput-DeJ6Exto.mjs +4400 -0
  38. package/dist/_chunks/RichTextInput-DeJ6Exto.mjs.map +1 -0
  39. package/dist/_chunks/RichTextInput-DgT88AkO.mjs +1175 -0
  40. package/dist/_chunks/RichTextInput-DgT88AkO.mjs.map +1 -0
  41. package/dist/_chunks/RichTextInput-DlMaDJQF.mjs +4400 -0
  42. package/dist/_chunks/RichTextInput-DlMaDJQF.mjs.map +1 -0
  43. package/dist/_chunks/RichTextInput-DtaYdjCs.mjs +4400 -0
  44. package/dist/_chunks/RichTextInput-DtaYdjCs.mjs.map +1 -0
  45. package/dist/_chunks/RichTextInput-YTKXo5oq.js +4407 -0
  46. package/dist/_chunks/RichTextInput-YTKXo5oq.js.map +1 -0
  47. package/dist/_chunks/RichTextInput-tmg-oMJk.mjs +4407 -0
  48. package/dist/_chunks/RichTextInput-tmg-oMJk.mjs.map +1 -0
  49. package/dist/_chunks/RichTextInput-umhMsI5o.js +4407 -0
  50. package/dist/_chunks/RichTextInput-umhMsI5o.js.map +1 -0
  51. package/dist/_chunks/en-B4KWt_jN.js +5 -0
  52. package/dist/_chunks/en-B4KWt_jN.js.map +1 -0
  53. package/dist/_chunks/en-Byx4XI2L.mjs +5 -0
  54. package/dist/_chunks/en-Byx4XI2L.mjs.map +1 -0
  55. package/dist/admin/index.js +71 -0
  56. package/dist/admin/index.js.map +1 -0
  57. package/dist/admin/index.mjs +72 -0
  58. package/dist/admin/index.mjs.map +1 -0
  59. package/dist/admin/src/components/BaseTiptapInput.d.ts +12 -0
  60. package/dist/admin/src/components/FormattedHeadingInput.d.ts +4 -0
  61. package/dist/admin/src/components/Initializer.d.ts +5 -0
  62. package/dist/admin/src/components/LinkDialog.d.ts +14 -0
  63. package/dist/admin/src/components/RichTextInput.d.ts +4 -0
  64. package/dist/admin/src/components/Spacer.d.ts +3 -0
  65. package/dist/admin/src/components/TableSizeDialog.d.ts +10 -0
  66. package/dist/admin/src/components/TiptapInput.d.ts +7 -0
  67. package/dist/admin/src/components/TiptapInputStyles.d.ts +2 -0
  68. package/dist/admin/src/components/ToolbarButton.d.ts +11 -0
  69. package/dist/admin/src/extensions/AccentCursive.d.ts +18 -0
  70. package/dist/admin/src/extensions/Heading.d.ts +8 -0
  71. package/dist/admin/src/extensions/Link.d.ts +7 -0
  72. package/dist/admin/src/extensions/Script.d.ts +7 -0
  73. package/dist/admin/src/extensions/StarterKit.d.ts +13 -0
  74. package/dist/admin/src/extensions/Table.d.ts +11 -0
  75. package/dist/admin/src/extensions/TextAlign.d.ts +9 -0
  76. package/dist/admin/src/fields/formattedHeadingField.d.ts +20 -0
  77. package/dist/admin/src/fields/richTextField.d.ts +20 -0
  78. package/dist/admin/src/icons/TextAlignCenter.d.ts +2 -0
  79. package/dist/admin/src/icons/TextAlignJustify.d.ts +2 -0
  80. package/dist/admin/src/icons/TextAlignLeft.d.ts +2 -0
  81. package/dist/admin/src/icons/TextAlignRight.d.ts +2 -0
  82. package/dist/admin/src/index.d.ts +10 -0
  83. package/dist/admin/src/pluginId.d.ts +1 -0
  84. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  85. package/dist/admin/src/utils/tiptapUtils.d.ts +18 -0
  86. package/dist/server/index.js +44 -0
  87. package/dist/server/index.js.map +1 -0
  88. package/dist/server/index.mjs +45 -0
  89. package/dist/server/index.mjs.map +1 -0
  90. package/dist/server/src/bootstrap.d.ts +5 -0
  91. package/dist/server/src/config/index.d.ts +5 -0
  92. package/dist/server/src/content-types/index.d.ts +2 -0
  93. package/dist/server/src/controllers/index.d.ts +2 -0
  94. package/dist/server/src/destroy.d.ts +5 -0
  95. package/dist/server/src/fields/richTextField.d.ts +2 -0
  96. package/dist/server/src/index.d.ts +25 -0
  97. package/dist/server/src/middlewares/index.d.ts +2 -0
  98. package/dist/server/src/policies/index.d.ts +2 -0
  99. package/dist/server/src/register.d.ts +5 -0
  100. package/dist/server/src/routes/index.d.ts +2 -0
  101. package/dist/server/src/services/index.d.ts +2 -0
  102. package/dist/shared/fields.d.ts +1 -0
  103. package/dist/shared/pluginId.d.ts +1 -0
  104. package/package.json +80 -0
@@ -0,0 +1,3384 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const designSystem = require("@strapi/design-system");
4
+ const react = require("@tiptap/react");
5
+ const styled = require("styled-components");
6
+ const React = require("react");
7
+ const transform = require("@tiptap/pm/transform");
8
+ const commands = require("@tiptap/pm/commands");
9
+ const state = require("@tiptap/pm/state");
10
+ const model = require("@tiptap/pm/model");
11
+ const schemaList = require("@tiptap/pm/schema-list");
12
+ require("@tiptap/pm/view");
13
+ require("@tiptap/pm/keymap");
14
+ const admin = require("@strapi/strapi/admin");
15
+ const icons = require("@strapi/icons");
16
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
17
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
18
+ const TiptapInputStyles = styled__default.default.div`
19
+ .editor-toolbar {
20
+ margin-bottom: 0.25rem;
21
+ padding-bottom: 0.25rem;
22
+ }
23
+
24
+ .ProseMirror {
25
+ font-size: 1.4rem; /* Increase editor font size to match Strapi default */
26
+ outline: none;
27
+ max-height: 60vh;
28
+ overflow-y: auto;
29
+ padding: 1rem;
30
+ }
31
+
32
+ /* Remove unnecessary margin at the top of the editor */
33
+ .ProseMirror *:first-child {
34
+ margin-top: 0;
35
+ }
36
+
37
+ /* --- Basic text styles --- */
38
+
39
+ .ProseMirror p {
40
+ margin: 0 0 12px;
41
+ }
42
+
43
+ .ProseMirror p:last-child {
44
+ margin-bottom: 0;
45
+ }
46
+
47
+ .ProseMirror h1,
48
+ .ProseMirror h2,
49
+ .ProseMirror h3,
50
+ .ProseMirror h4 {
51
+ font-weight: 600;
52
+ line-height: 1.25;
53
+ margin: 1em 0 0.5em;
54
+ }
55
+
56
+ .ProseMirror h1 {
57
+ font-size: 4rem;
58
+ }
59
+
60
+ .ProseMirror h2 {
61
+ font-size: 3.2rem;
62
+ }
63
+
64
+ .ProseMirror h3 {
65
+ font-size: 2.5rem;
66
+ }
67
+
68
+ .ProseMirror h4 {
69
+ font-size: 2rem;
70
+ }
71
+
72
+ .ProseMirror ul,
73
+ .ProseMirror ol {
74
+ margin: 0.75em 0 1em;
75
+ padding-left: 1.5rem;
76
+ }
77
+
78
+ .ProseMirror ul {
79
+ list-style: disc;
80
+ }
81
+
82
+ .ProseMirror ol {
83
+ list-style: decimal;
84
+ }
85
+
86
+ .ProseMirror li {
87
+ margin: 0.25em 0;
88
+ }
89
+
90
+ .ProseMirror blockquote {
91
+ border-left: 3px solid #222;
92
+ margin: 1em 0;
93
+ padding: 0.25em 1rem;
94
+ font-style: italic;
95
+ background: #fafafa;
96
+ }
97
+
98
+ .ProseMirror code {
99
+ background: #f3f3f3;
100
+ padding: 2px 4px;
101
+ border-radius: 4px;
102
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
103
+ font-size: 0.9em;
104
+ }
105
+
106
+ .ProseMirror a {
107
+ color: #0c75af;
108
+ text-decoration: underline;
109
+ }
110
+
111
+ .ProseMirror strong {
112
+ font-weight: 600;
113
+ }
114
+
115
+ .ProseMirror em {
116
+ font-style: italic;
117
+ }
118
+
119
+ .ProseMirror u {
120
+ text-decoration: underline;
121
+ }
122
+
123
+ .ProseMirror s {
124
+ text-decoration: line-through;
125
+ }
126
+
127
+ // Source: https://tiptap.dev/docs/editor/extensions/nodes/table?gad_source=1&gad_campaignid=22014820935&gclid=Cj0KCQjwjL3HBhCgARIsAPUg7a5ZcPOMy7tBMIDShF9LCrr6JRpVHDI9vlgYCfoVjzM573ROeYQwcdMaArJMEALw_wcB
128
+
129
+ .ProseMirror {
130
+ table {
131
+ border-collapse: collapse;
132
+ margin: 0;
133
+ overflow: hidden;
134
+ table-layout: fixed;
135
+ width: 100%;
136
+
137
+ td,
138
+ th {
139
+ border: 1px solid #ddd;
140
+ box-sizing: border-box;
141
+ min-width: 1em;
142
+ padding: 6px 8px;
143
+ position: relative;
144
+ vertical-align: top;
145
+
146
+ > * {
147
+ margin-bottom: 0;
148
+ }
149
+ }
150
+
151
+ /* It is not possible to distinguish header vs body cells when rendering
152
+ content in React. So we render all as td and the user should use bold text
153
+ in cells. */
154
+ th {
155
+ background-color: inherit;
156
+ font-weight: normal;
157
+ text-align: left;
158
+ }
159
+
160
+ .selectedCell:after {
161
+ background: rgba(0, 37, 159, 0.32);
162
+ content: '';
163
+ left: 0;
164
+ right: 0;
165
+ top: 0;
166
+ bottom: 0;
167
+ pointer-events: none;
168
+ position: absolute;
169
+ z-index: 2;
170
+ }
171
+
172
+ .column-resize-handle {
173
+ background-color: purple;
174
+ bottom: -2px;
175
+ pointer-events: none;
176
+ position: absolute;
177
+ right: -2px;
178
+ top: 0;
179
+ width: 4px;
180
+ }
181
+ }
182
+
183
+ .tableWrapper {
184
+ margin: 1.5rem 0;
185
+ overflow-x: auto;
186
+ }
187
+
188
+ &.resize-cursor {
189
+ cursor: ew-resize;
190
+ cursor: col-resize;
191
+ }
192
+ }
193
+
194
+ /* --- Accent Cursive --- */
195
+ /* How the accented text looks like in editor */
196
+
197
+ .accent-cursive {
198
+ color: var(--color-accent-dark, #ae8f5b);
199
+ font-style: italic;
200
+ font-weight: bold;
201
+ }
202
+
203
+ /* --- Only Cursive --- */
204
+ /* How the only cursive text looks like in editor */
205
+
206
+ .only-cursive {
207
+ font-style: italic;
208
+ font-weight: bold;
209
+ }
210
+ `;
211
+ const BaseTiptapInput = React.forwardRef(
212
+ ({ hint, disabled = false, labelAction, label, name, required = false, editor, field, children }, forwardedRef) => {
213
+ const borderColor = field.error ? "danger600" : "neutral200";
214
+ const background = disabled ? "neutral200" : "neutral100";
215
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name, id: name, hint, error: field.error, required, children: [
216
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
217
+ /* @__PURE__ */ jsxRuntime.jsx(TiptapInputStyles, { children: /* @__PURE__ */ jsxRuntime.jsxs(
218
+ designSystem.Box,
219
+ {
220
+ className: `tiptap-editor-wrapper ${field.error ? "has-error" : ""} ${disabled ? "is-disabled" : ""}`,
221
+ hasRadius: true,
222
+ borderColor,
223
+ background,
224
+ paddingTop: 1,
225
+ paddingBottom: 0,
226
+ paddingLeft: 0,
227
+ paddingRight: 0,
228
+ children: [
229
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { className: "editor-toolbar", paddingLeft: 2, paddingRight: 2, paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, wrap: "wrap", children }) }),
230
+ /* @__PURE__ */ jsxRuntime.jsx(
231
+ designSystem.Box,
232
+ {
233
+ className: "editor-content",
234
+ background: "neutral0",
235
+ paddingTop: 2,
236
+ paddingBottom: 2,
237
+ paddingLeft: 2,
238
+ paddingRight: 2,
239
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.EditorContent, { editor, disabled, ref: forwardedRef })
240
+ }
241
+ )
242
+ ]
243
+ }
244
+ ) }),
245
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
246
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
247
+ ] });
248
+ }
249
+ );
250
+ var __defProp = Object.defineProperty;
251
+ var __export = (target, all) => {
252
+ for (var name in all)
253
+ __defProp(target, name, { get: all[name], enumerable: true });
254
+ };
255
+ function createChainableState(config) {
256
+ const { state: state2, transaction } = config;
257
+ let { selection } = transaction;
258
+ let { doc } = transaction;
259
+ let { storedMarks } = transaction;
260
+ return {
261
+ ...state2,
262
+ apply: state2.apply.bind(state2),
263
+ applyTransaction: state2.applyTransaction.bind(state2),
264
+ plugins: state2.plugins,
265
+ schema: state2.schema,
266
+ reconfigure: state2.reconfigure.bind(state2),
267
+ toJSON: state2.toJSON.bind(state2),
268
+ get storedMarks() {
269
+ return storedMarks;
270
+ },
271
+ get selection() {
272
+ return selection;
273
+ },
274
+ get doc() {
275
+ return doc;
276
+ },
277
+ get tr() {
278
+ selection = transaction.selection;
279
+ doc = transaction.doc;
280
+ storedMarks = transaction.storedMarks;
281
+ return transaction;
282
+ }
283
+ };
284
+ }
285
+ var CommandManager = class {
286
+ constructor(props) {
287
+ this.editor = props.editor;
288
+ this.rawCommands = this.editor.extensionManager.commands;
289
+ this.customState = props.state;
290
+ }
291
+ get hasCustomState() {
292
+ return !!this.customState;
293
+ }
294
+ get state() {
295
+ return this.customState || this.editor.state;
296
+ }
297
+ get commands() {
298
+ const { rawCommands, editor, state: state2 } = this;
299
+ const { view } = editor;
300
+ const { tr } = state2;
301
+ const props = this.buildProps(tr);
302
+ return Object.fromEntries(
303
+ Object.entries(rawCommands).map(([name, command2]) => {
304
+ const method = (...args) => {
305
+ const callback = command2(...args)(props);
306
+ if (!tr.getMeta("preventDispatch") && !this.hasCustomState) {
307
+ view.dispatch(tr);
308
+ }
309
+ return callback;
310
+ };
311
+ return [name, method];
312
+ })
313
+ );
314
+ }
315
+ get chain() {
316
+ return () => this.createChain();
317
+ }
318
+ get can() {
319
+ return () => this.createCan();
320
+ }
321
+ createChain(startTr, shouldDispatch = true) {
322
+ const { rawCommands, editor, state: state2 } = this;
323
+ const { view } = editor;
324
+ const callbacks = [];
325
+ const hasStartTransaction = !!startTr;
326
+ const tr = startTr || state2.tr;
327
+ const run3 = () => {
328
+ if (!hasStartTransaction && shouldDispatch && !tr.getMeta("preventDispatch") && !this.hasCustomState) {
329
+ view.dispatch(tr);
330
+ }
331
+ return callbacks.every((callback) => callback === true);
332
+ };
333
+ const chain = {
334
+ ...Object.fromEntries(
335
+ Object.entries(rawCommands).map(([name, command2]) => {
336
+ const chainedCommand = (...args) => {
337
+ const props = this.buildProps(tr, shouldDispatch);
338
+ const callback = command2(...args)(props);
339
+ callbacks.push(callback);
340
+ return chain;
341
+ };
342
+ return [name, chainedCommand];
343
+ })
344
+ ),
345
+ run: run3
346
+ };
347
+ return chain;
348
+ }
349
+ createCan(startTr) {
350
+ const { rawCommands, state: state2 } = this;
351
+ const dispatch = false;
352
+ const tr = startTr || state2.tr;
353
+ const props = this.buildProps(tr, dispatch);
354
+ const formattedCommands = Object.fromEntries(
355
+ Object.entries(rawCommands).map(([name, command2]) => {
356
+ return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
357
+ })
358
+ );
359
+ return {
360
+ ...formattedCommands,
361
+ chain: () => this.createChain(tr, dispatch)
362
+ };
363
+ }
364
+ buildProps(tr, shouldDispatch = true) {
365
+ const { rawCommands, editor, state: state2 } = this;
366
+ const { view } = editor;
367
+ const props = {
368
+ tr,
369
+ editor,
370
+ view,
371
+ state: createChainableState({
372
+ state: state2,
373
+ transaction: tr
374
+ }),
375
+ dispatch: shouldDispatch ? () => void 0 : void 0,
376
+ chain: () => this.createChain(tr, shouldDispatch),
377
+ can: () => this.createCan(tr),
378
+ get commands() {
379
+ return Object.fromEntries(
380
+ Object.entries(rawCommands).map(([name, command2]) => {
381
+ return [name, (...args) => command2(...args)(props)];
382
+ })
383
+ );
384
+ }
385
+ };
386
+ return props;
387
+ }
388
+ };
389
+ var commands_exports = {};
390
+ __export(commands_exports, {
391
+ blur: () => blur,
392
+ clearContent: () => clearContent,
393
+ clearNodes: () => clearNodes,
394
+ command: () => command,
395
+ createParagraphNear: () => createParagraphNear,
396
+ cut: () => cut,
397
+ deleteCurrentNode: () => deleteCurrentNode,
398
+ deleteNode: () => deleteNode,
399
+ deleteRange: () => deleteRange,
400
+ deleteSelection: () => deleteSelection,
401
+ enter: () => enter,
402
+ exitCode: () => exitCode,
403
+ extendMarkRange: () => extendMarkRange,
404
+ first: () => first,
405
+ focus: () => focus,
406
+ forEach: () => forEach,
407
+ insertContent: () => insertContent,
408
+ insertContentAt: () => insertContentAt,
409
+ joinBackward: () => joinBackward,
410
+ joinDown: () => joinDown,
411
+ joinForward: () => joinForward,
412
+ joinItemBackward: () => joinItemBackward,
413
+ joinItemForward: () => joinItemForward,
414
+ joinTextblockBackward: () => joinTextblockBackward,
415
+ joinTextblockForward: () => joinTextblockForward,
416
+ joinUp: () => joinUp,
417
+ keyboardShortcut: () => keyboardShortcut,
418
+ lift: () => lift,
419
+ liftEmptyBlock: () => liftEmptyBlock,
420
+ liftListItem: () => liftListItem,
421
+ newlineInCode: () => newlineInCode,
422
+ resetAttributes: () => resetAttributes,
423
+ scrollIntoView: () => scrollIntoView,
424
+ selectAll: () => selectAll,
425
+ selectNodeBackward: () => selectNodeBackward,
426
+ selectNodeForward: () => selectNodeForward,
427
+ selectParentNode: () => selectParentNode,
428
+ selectTextblockEnd: () => selectTextblockEnd,
429
+ selectTextblockStart: () => selectTextblockStart,
430
+ setContent: () => setContent,
431
+ setMark: () => setMark,
432
+ setMeta: () => setMeta,
433
+ setNode: () => setNode,
434
+ setNodeSelection: () => setNodeSelection,
435
+ setTextDirection: () => setTextDirection,
436
+ setTextSelection: () => setTextSelection,
437
+ sinkListItem: () => sinkListItem,
438
+ splitBlock: () => splitBlock,
439
+ splitListItem: () => splitListItem,
440
+ toggleList: () => toggleList,
441
+ toggleMark: () => toggleMark,
442
+ toggleNode: () => toggleNode,
443
+ toggleWrap: () => toggleWrap,
444
+ undoInputRule: () => undoInputRule,
445
+ unsetAllMarks: () => unsetAllMarks,
446
+ unsetMark: () => unsetMark,
447
+ unsetTextDirection: () => unsetTextDirection,
448
+ updateAttributes: () => updateAttributes,
449
+ wrapIn: () => wrapIn,
450
+ wrapInList: () => wrapInList
451
+ });
452
+ var blur = () => ({ editor, view }) => {
453
+ requestAnimationFrame(() => {
454
+ var _a;
455
+ if (!editor.isDestroyed) {
456
+ view.dom.blur();
457
+ (_a = window == null ? void 0 : window.getSelection()) == null ? void 0 : _a.removeAllRanges();
458
+ }
459
+ });
460
+ return true;
461
+ };
462
+ var clearContent = (emitUpdate = true) => ({ commands: commands2 }) => {
463
+ return commands2.setContent("", { emitUpdate });
464
+ };
465
+ var clearNodes = () => ({ state: state2, tr, dispatch }) => {
466
+ const { selection } = tr;
467
+ const { ranges } = selection;
468
+ if (!dispatch) {
469
+ return true;
470
+ }
471
+ ranges.forEach(({ $from, $to }) => {
472
+ state2.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
473
+ if (node.type.isText) {
474
+ return;
475
+ }
476
+ const { doc, mapping } = tr;
477
+ const $mappedFrom = doc.resolve(mapping.map(pos));
478
+ const $mappedTo = doc.resolve(mapping.map(pos + node.nodeSize));
479
+ const nodeRange = $mappedFrom.blockRange($mappedTo);
480
+ if (!nodeRange) {
481
+ return;
482
+ }
483
+ const targetLiftDepth = transform.liftTarget(nodeRange);
484
+ if (node.type.isTextblock) {
485
+ const { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index());
486
+ tr.setNodeMarkup(nodeRange.start, defaultType);
487
+ }
488
+ if (targetLiftDepth || targetLiftDepth === 0) {
489
+ tr.lift(nodeRange, targetLiftDepth);
490
+ }
491
+ });
492
+ });
493
+ return true;
494
+ };
495
+ var command = (fn) => (props) => {
496
+ return fn(props);
497
+ };
498
+ var createParagraphNear = () => ({ state: state2, dispatch }) => {
499
+ return commands.createParagraphNear(state2, dispatch);
500
+ };
501
+ var cut = (originRange, targetPos) => ({ editor, tr }) => {
502
+ const { state: state$1 } = editor;
503
+ const contentSlice = state$1.doc.slice(originRange.from, originRange.to);
504
+ tr.deleteRange(originRange.from, originRange.to);
505
+ const newPos = tr.mapping.map(targetPos);
506
+ tr.insert(newPos, contentSlice.content);
507
+ tr.setSelection(new state.TextSelection(tr.doc.resolve(Math.max(newPos - 1, 0))));
508
+ return true;
509
+ };
510
+ var deleteCurrentNode = () => ({ tr, dispatch }) => {
511
+ const { selection } = tr;
512
+ const currentNode = selection.$anchor.node();
513
+ if (currentNode.content.size > 0) {
514
+ return false;
515
+ }
516
+ const $pos = tr.selection.$anchor;
517
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
518
+ const node = $pos.node(depth);
519
+ if (node.type === currentNode.type) {
520
+ if (dispatch) {
521
+ const from = $pos.before(depth);
522
+ const to = $pos.after(depth);
523
+ tr.delete(from, to).scrollIntoView();
524
+ }
525
+ return true;
526
+ }
527
+ }
528
+ return false;
529
+ };
530
+ function getNodeType(nameOrType, schema) {
531
+ if (typeof nameOrType === "string") {
532
+ if (!schema.nodes[nameOrType]) {
533
+ throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`);
534
+ }
535
+ return schema.nodes[nameOrType];
536
+ }
537
+ return nameOrType;
538
+ }
539
+ var deleteNode = (typeOrName) => ({ tr, state: state2, dispatch }) => {
540
+ const type = getNodeType(typeOrName, state2.schema);
541
+ const $pos = tr.selection.$anchor;
542
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
543
+ const node = $pos.node(depth);
544
+ if (node.type === type) {
545
+ if (dispatch) {
546
+ const from = $pos.before(depth);
547
+ const to = $pos.after(depth);
548
+ tr.delete(from, to).scrollIntoView();
549
+ }
550
+ return true;
551
+ }
552
+ }
553
+ return false;
554
+ };
555
+ var deleteRange = (range) => ({ tr, dispatch }) => {
556
+ const { from, to } = range;
557
+ if (dispatch) {
558
+ tr.delete(from, to);
559
+ }
560
+ return true;
561
+ };
562
+ var deleteSelection = () => ({ state: state2, dispatch }) => {
563
+ return commands.deleteSelection(state2, dispatch);
564
+ };
565
+ var enter = () => ({ commands: commands2 }) => {
566
+ return commands2.keyboardShortcut("Enter");
567
+ };
568
+ var exitCode = () => ({ state: state2, dispatch }) => {
569
+ return commands.exitCode(state2, dispatch);
570
+ };
571
+ function isRegExp(value) {
572
+ return Object.prototype.toString.call(value) === "[object RegExp]";
573
+ }
574
+ function objectIncludes(object1, object2, options = { strict: true }) {
575
+ const keys = Object.keys(object2);
576
+ if (!keys.length) {
577
+ return true;
578
+ }
579
+ return keys.every((key) => {
580
+ if (options.strict) {
581
+ return object2[key] === object1[key];
582
+ }
583
+ if (isRegExp(object2[key])) {
584
+ return object2[key].test(object1[key]);
585
+ }
586
+ return object2[key] === object1[key];
587
+ });
588
+ }
589
+ function findMarkInSet(marks, type, attributes = {}) {
590
+ return marks.find((item) => {
591
+ return item.type === type && objectIncludes(
592
+ // Only check equality for the attributes that are provided
593
+ Object.fromEntries(Object.keys(attributes).map((k) => [k, item.attrs[k]])),
594
+ attributes
595
+ );
596
+ });
597
+ }
598
+ function isMarkInSet(marks, type, attributes = {}) {
599
+ return !!findMarkInSet(marks, type, attributes);
600
+ }
601
+ function getMarkRange($pos, type, attributes) {
602
+ var _a;
603
+ if (!$pos || !type) {
604
+ return;
605
+ }
606
+ let start = $pos.parent.childAfter($pos.parentOffset);
607
+ if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
608
+ start = $pos.parent.childBefore($pos.parentOffset);
609
+ }
610
+ if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
611
+ return;
612
+ }
613
+ attributes = attributes || ((_a = start.node.marks[0]) == null ? void 0 : _a.attrs);
614
+ const mark = findMarkInSet([...start.node.marks], type, attributes);
615
+ if (!mark) {
616
+ return;
617
+ }
618
+ let startIndex = start.index;
619
+ let startPos = $pos.start() + start.offset;
620
+ let endIndex = startIndex + 1;
621
+ let endPos = startPos + start.node.nodeSize;
622
+ while (startIndex > 0 && isMarkInSet([...$pos.parent.child(startIndex - 1).marks], type, attributes)) {
623
+ startIndex -= 1;
624
+ startPos -= $pos.parent.child(startIndex).nodeSize;
625
+ }
626
+ while (endIndex < $pos.parent.childCount && isMarkInSet([...$pos.parent.child(endIndex).marks], type, attributes)) {
627
+ endPos += $pos.parent.child(endIndex).nodeSize;
628
+ endIndex += 1;
629
+ }
630
+ return {
631
+ from: startPos,
632
+ to: endPos
633
+ };
634
+ }
635
+ function getMarkType(nameOrType, schema) {
636
+ if (typeof nameOrType === "string") {
637
+ if (!schema.marks[nameOrType]) {
638
+ throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`);
639
+ }
640
+ return schema.marks[nameOrType];
641
+ }
642
+ return nameOrType;
643
+ }
644
+ var extendMarkRange = (typeOrName, attributes = {}) => ({ tr, state: state$1, dispatch }) => {
645
+ const type = getMarkType(typeOrName, state$1.schema);
646
+ const { doc, selection } = tr;
647
+ const { $from, from, to } = selection;
648
+ if (dispatch) {
649
+ const range = getMarkRange($from, type, attributes);
650
+ if (range && range.from <= from && range.to >= to) {
651
+ const newSelection = state.TextSelection.create(doc, range.from, range.to);
652
+ tr.setSelection(newSelection);
653
+ }
654
+ }
655
+ return true;
656
+ };
657
+ var first = (commands2) => (props) => {
658
+ const items = typeof commands2 === "function" ? commands2(props) : commands2;
659
+ for (let i = 0; i < items.length; i += 1) {
660
+ if (items[i](props)) {
661
+ return true;
662
+ }
663
+ }
664
+ return false;
665
+ };
666
+ function isTextSelection(value) {
667
+ return value instanceof state.TextSelection;
668
+ }
669
+ function minMax(value = 0, min = 0, max = 0) {
670
+ return Math.min(Math.max(value, min), max);
671
+ }
672
+ function resolveFocusPosition(doc, position = null) {
673
+ if (!position) {
674
+ return null;
675
+ }
676
+ const selectionAtStart = state.Selection.atStart(doc);
677
+ const selectionAtEnd = state.Selection.atEnd(doc);
678
+ if (position === "start" || position === true) {
679
+ return selectionAtStart;
680
+ }
681
+ if (position === "end") {
682
+ return selectionAtEnd;
683
+ }
684
+ const minPos = selectionAtStart.from;
685
+ const maxPos = selectionAtEnd.to;
686
+ if (position === "all") {
687
+ return state.TextSelection.create(doc, minMax(0, minPos, maxPos), minMax(doc.content.size, minPos, maxPos));
688
+ }
689
+ return state.TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos));
690
+ }
691
+ function isAndroid() {
692
+ return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
693
+ }
694
+ function isiOS() {
695
+ return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || // iPad on iOS 13 detection
696
+ navigator.userAgent.includes("Mac") && "ontouchend" in document;
697
+ }
698
+ function isSafari() {
699
+ return typeof navigator !== "undefined" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
700
+ }
701
+ var focus = (position = null, options = {}) => ({ editor, view, tr, dispatch }) => {
702
+ options = {
703
+ scrollIntoView: true,
704
+ ...options
705
+ };
706
+ const delayedFocus = () => {
707
+ if (isiOS() || isAndroid()) {
708
+ view.dom.focus();
709
+ }
710
+ if (isSafari() && !isiOS() && !isAndroid()) {
711
+ view.dom.focus({ preventScroll: true });
712
+ }
713
+ requestAnimationFrame(() => {
714
+ if (!editor.isDestroyed) {
715
+ view.focus();
716
+ if (options == null ? void 0 : options.scrollIntoView) {
717
+ editor.commands.scrollIntoView();
718
+ }
719
+ }
720
+ });
721
+ };
722
+ try {
723
+ if (view.hasFocus() && position === null || position === false) {
724
+ return true;
725
+ }
726
+ } catch {
727
+ return false;
728
+ }
729
+ if (dispatch && position === null && !isTextSelection(editor.state.selection)) {
730
+ delayedFocus();
731
+ return true;
732
+ }
733
+ const selection = resolveFocusPosition(tr.doc, position) || editor.state.selection;
734
+ const isSameSelection = editor.state.selection.eq(selection);
735
+ if (dispatch) {
736
+ if (!isSameSelection) {
737
+ tr.setSelection(selection);
738
+ }
739
+ if (isSameSelection && tr.storedMarks) {
740
+ tr.setStoredMarks(tr.storedMarks);
741
+ }
742
+ delayedFocus();
743
+ }
744
+ return true;
745
+ };
746
+ var forEach = (items, fn) => (props) => {
747
+ return items.every((item, index) => fn(item, { ...props, index }));
748
+ };
749
+ var insertContent = (value, options) => ({ tr, commands: commands2 }) => {
750
+ return commands2.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options);
751
+ };
752
+ var removeWhitespaces = (node) => {
753
+ const children = node.childNodes;
754
+ for (let i = children.length - 1; i >= 0; i -= 1) {
755
+ const child = children[i];
756
+ if (child.nodeType === 3 && child.nodeValue && /^(\n\s\s|\n)$/.test(child.nodeValue)) {
757
+ node.removeChild(child);
758
+ } else if (child.nodeType === 1) {
759
+ removeWhitespaces(child);
760
+ }
761
+ }
762
+ return node;
763
+ };
764
+ function elementFromString(value) {
765
+ if (typeof window === "undefined") {
766
+ throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");
767
+ }
768
+ const wrappedValue = `<body>${value}</body>`;
769
+ const html = new window.DOMParser().parseFromString(wrappedValue, "text/html").body;
770
+ return removeWhitespaces(html);
771
+ }
772
+ function createNodeFromContent(content, schema, options) {
773
+ if (content instanceof model.Node || content instanceof model.Fragment) {
774
+ return content;
775
+ }
776
+ options = {
777
+ slice: true,
778
+ parseOptions: {},
779
+ ...options
780
+ };
781
+ const isJSONContent = typeof content === "object" && content !== null;
782
+ const isTextContent = typeof content === "string";
783
+ if (isJSONContent) {
784
+ try {
785
+ const isArrayContent = Array.isArray(content) && content.length > 0;
786
+ if (isArrayContent) {
787
+ return model.Fragment.fromArray(content.map((item) => schema.nodeFromJSON(item)));
788
+ }
789
+ const node = schema.nodeFromJSON(content);
790
+ if (options.errorOnInvalidContent) {
791
+ node.check();
792
+ }
793
+ return node;
794
+ } catch (error) {
795
+ if (options.errorOnInvalidContent) {
796
+ throw new Error("[tiptap error]: Invalid JSON content", { cause: error });
797
+ }
798
+ console.warn("[tiptap warn]: Invalid content.", "Passed value:", content, "Error:", error);
799
+ return createNodeFromContent("", schema, options);
800
+ }
801
+ }
802
+ if (isTextContent) {
803
+ if (options.errorOnInvalidContent) {
804
+ let hasInvalidContent = false;
805
+ let invalidContent = "";
806
+ const contentCheckSchema = new model.Schema({
807
+ topNode: schema.spec.topNode,
808
+ marks: schema.spec.marks,
809
+ // Prosemirror's schemas are executed such that: the last to execute, matches last
810
+ // 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
811
+ nodes: schema.spec.nodes.append({
812
+ __tiptap__private__unknown__catch__all__node: {
813
+ content: "inline*",
814
+ group: "block",
815
+ parseDOM: [
816
+ {
817
+ tag: "*",
818
+ getAttrs: (e) => {
819
+ hasInvalidContent = true;
820
+ invalidContent = typeof e === "string" ? e : e.outerHTML;
821
+ return null;
822
+ }
823
+ }
824
+ ]
825
+ }
826
+ })
827
+ });
828
+ if (options.slice) {
829
+ model.DOMParser.fromSchema(contentCheckSchema).parseSlice(elementFromString(content), options.parseOptions);
830
+ } else {
831
+ model.DOMParser.fromSchema(contentCheckSchema).parse(elementFromString(content), options.parseOptions);
832
+ }
833
+ if (options.errorOnInvalidContent && hasInvalidContent) {
834
+ throw new Error("[tiptap error]: Invalid HTML content", {
835
+ cause: new Error(`Invalid element found: ${invalidContent}`)
836
+ });
837
+ }
838
+ }
839
+ const parser = model.DOMParser.fromSchema(schema);
840
+ if (options.slice) {
841
+ return parser.parseSlice(elementFromString(content), options.parseOptions).content;
842
+ }
843
+ return parser.parse(elementFromString(content), options.parseOptions);
844
+ }
845
+ return createNodeFromContent("", schema, options);
846
+ }
847
+ function selectionToInsertionEnd(tr, startLen, bias) {
848
+ const last = tr.steps.length - 1;
849
+ if (last < startLen) {
850
+ return;
851
+ }
852
+ const step = tr.steps[last];
853
+ if (!(step instanceof transform.ReplaceStep || step instanceof transform.ReplaceAroundStep)) {
854
+ return;
855
+ }
856
+ const map = tr.mapping.maps[last];
857
+ let end = 0;
858
+ map.forEach((_from, _to, _newFrom, newTo) => {
859
+ if (end === 0) {
860
+ end = newTo;
861
+ }
862
+ });
863
+ tr.setSelection(state.Selection.near(tr.doc.resolve(end), bias));
864
+ }
865
+ var isFragment = (nodeOrFragment) => {
866
+ return !("type" in nodeOrFragment);
867
+ };
868
+ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) => {
869
+ var _a;
870
+ if (dispatch) {
871
+ options = {
872
+ parseOptions: editor.options.parseOptions,
873
+ updateSelection: true,
874
+ applyInputRules: false,
875
+ applyPasteRules: false,
876
+ ...options
877
+ };
878
+ let content;
879
+ const emitContentError = (error) => {
880
+ editor.emit("contentError", {
881
+ editor,
882
+ error,
883
+ disableCollaboration: () => {
884
+ if ("collaboration" in editor.storage && typeof editor.storage.collaboration === "object" && editor.storage.collaboration) {
885
+ editor.storage.collaboration.isDisabled = true;
886
+ }
887
+ }
888
+ });
889
+ };
890
+ const parseOptions = {
891
+ preserveWhitespace: "full",
892
+ ...options.parseOptions
893
+ };
894
+ if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {
895
+ try {
896
+ createNodeFromContent(value, editor.schema, {
897
+ parseOptions,
898
+ errorOnInvalidContent: true
899
+ });
900
+ } catch (e) {
901
+ emitContentError(e);
902
+ }
903
+ }
904
+ try {
905
+ content = createNodeFromContent(value, editor.schema, {
906
+ parseOptions,
907
+ errorOnInvalidContent: (_a = options.errorOnInvalidContent) != null ? _a : editor.options.enableContentCheck
908
+ });
909
+ } catch (e) {
910
+ emitContentError(e);
911
+ return false;
912
+ }
913
+ let { from, to } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
914
+ let isOnlyTextContent = true;
915
+ let isOnlyBlockContent = true;
916
+ const nodes = isFragment(content) ? content : [content];
917
+ nodes.forEach((node) => {
918
+ node.check();
919
+ isOnlyTextContent = isOnlyTextContent ? node.isText && node.marks.length === 0 : false;
920
+ isOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false;
921
+ });
922
+ if (from === to && isOnlyBlockContent) {
923
+ const { parent } = tr.doc.resolve(from);
924
+ const isEmptyTextBlock = parent.isTextblock && !parent.type.spec.code && !parent.childCount;
925
+ if (isEmptyTextBlock) {
926
+ from -= 1;
927
+ to += 1;
928
+ }
929
+ }
930
+ let newContent;
931
+ if (isOnlyTextContent) {
932
+ if (Array.isArray(value)) {
933
+ newContent = value.map((v) => v.text || "").join("");
934
+ } else if (value instanceof model.Fragment) {
935
+ let text = "";
936
+ value.forEach((node) => {
937
+ if (node.text) {
938
+ text += node.text;
939
+ }
940
+ });
941
+ newContent = text;
942
+ } else if (typeof value === "object" && !!value && !!value.text) {
943
+ newContent = value.text;
944
+ } else {
945
+ newContent = value;
946
+ }
947
+ tr.insertText(newContent, from, to);
948
+ } else {
949
+ newContent = content;
950
+ const $from = tr.doc.resolve(from);
951
+ const $fromNode = $from.node();
952
+ const fromSelectionAtStart = $from.parentOffset === 0;
953
+ const isTextSelection2 = $fromNode.isText || $fromNode.isTextblock;
954
+ const hasContent = $fromNode.content.size > 0;
955
+ if (fromSelectionAtStart && isTextSelection2 && hasContent) {
956
+ from = Math.max(0, from - 1);
957
+ }
958
+ tr.replaceWith(from, to, newContent);
959
+ }
960
+ if (options.updateSelection) {
961
+ selectionToInsertionEnd(tr, tr.steps.length - 1, -1);
962
+ }
963
+ if (options.applyInputRules) {
964
+ tr.setMeta("applyInputRules", { from, text: newContent });
965
+ }
966
+ if (options.applyPasteRules) {
967
+ tr.setMeta("applyPasteRules", { from, text: newContent });
968
+ }
969
+ }
970
+ return true;
971
+ };
972
+ var joinUp = () => ({ state: state2, dispatch }) => {
973
+ return commands.joinUp(state2, dispatch);
974
+ };
975
+ var joinDown = () => ({ state: state2, dispatch }) => {
976
+ return commands.joinDown(state2, dispatch);
977
+ };
978
+ var joinBackward = () => ({ state: state2, dispatch }) => {
979
+ return commands.joinBackward(state2, dispatch);
980
+ };
981
+ var joinForward = () => ({ state: state2, dispatch }) => {
982
+ return commands.joinForward(state2, dispatch);
983
+ };
984
+ var joinItemBackward = () => ({ state: state2, dispatch, tr }) => {
985
+ try {
986
+ const point = transform.joinPoint(state2.doc, state2.selection.$from.pos, -1);
987
+ if (point === null || point === void 0) {
988
+ return false;
989
+ }
990
+ tr.join(point, 2);
991
+ if (dispatch) {
992
+ dispatch(tr);
993
+ }
994
+ return true;
995
+ } catch {
996
+ return false;
997
+ }
998
+ };
999
+ var joinItemForward = () => ({ state: state2, dispatch, tr }) => {
1000
+ try {
1001
+ const point = transform.joinPoint(state2.doc, state2.selection.$from.pos, 1);
1002
+ if (point === null || point === void 0) {
1003
+ return false;
1004
+ }
1005
+ tr.join(point, 2);
1006
+ if (dispatch) {
1007
+ dispatch(tr);
1008
+ }
1009
+ return true;
1010
+ } catch {
1011
+ return false;
1012
+ }
1013
+ };
1014
+ var joinTextblockBackward = () => ({ state: state2, dispatch }) => {
1015
+ return commands.joinTextblockBackward(state2, dispatch);
1016
+ };
1017
+ var joinTextblockForward = () => ({ state: state2, dispatch }) => {
1018
+ return commands.joinTextblockForward(state2, dispatch);
1019
+ };
1020
+ function isMacOS() {
1021
+ return typeof navigator !== "undefined" ? /Mac/.test(navigator.platform) : false;
1022
+ }
1023
+ function normalizeKeyName(name) {
1024
+ const parts = name.split(/-(?!$)/);
1025
+ let result = parts[parts.length - 1];
1026
+ if (result === "Space") {
1027
+ result = " ";
1028
+ }
1029
+ let alt;
1030
+ let ctrl;
1031
+ let shift;
1032
+ let meta;
1033
+ for (let i = 0; i < parts.length - 1; i += 1) {
1034
+ const mod = parts[i];
1035
+ if (/^(cmd|meta|m)$/i.test(mod)) {
1036
+ meta = true;
1037
+ } else if (/^a(lt)?$/i.test(mod)) {
1038
+ alt = true;
1039
+ } else if (/^(c|ctrl|control)$/i.test(mod)) {
1040
+ ctrl = true;
1041
+ } else if (/^s(hift)?$/i.test(mod)) {
1042
+ shift = true;
1043
+ } else if (/^mod$/i.test(mod)) {
1044
+ if (isiOS() || isMacOS()) {
1045
+ meta = true;
1046
+ } else {
1047
+ ctrl = true;
1048
+ }
1049
+ } else {
1050
+ throw new Error(`Unrecognized modifier name: ${mod}`);
1051
+ }
1052
+ }
1053
+ if (alt) {
1054
+ result = `Alt-${result}`;
1055
+ }
1056
+ if (ctrl) {
1057
+ result = `Ctrl-${result}`;
1058
+ }
1059
+ if (meta) {
1060
+ result = `Meta-${result}`;
1061
+ }
1062
+ if (shift) {
1063
+ result = `Shift-${result}`;
1064
+ }
1065
+ return result;
1066
+ }
1067
+ var keyboardShortcut = (name) => ({ editor, view, tr, dispatch }) => {
1068
+ const keys = normalizeKeyName(name).split(/-(?!$)/);
1069
+ const key = keys.find((item) => !["Alt", "Ctrl", "Meta", "Shift"].includes(item));
1070
+ const event = new KeyboardEvent("keydown", {
1071
+ key: key === "Space" ? " " : key,
1072
+ altKey: keys.includes("Alt"),
1073
+ ctrlKey: keys.includes("Ctrl"),
1074
+ metaKey: keys.includes("Meta"),
1075
+ shiftKey: keys.includes("Shift"),
1076
+ bubbles: true,
1077
+ cancelable: true
1078
+ });
1079
+ const capturedTransaction = editor.captureTransaction(() => {
1080
+ view.someProp("handleKeyDown", (f) => f(view, event));
1081
+ });
1082
+ capturedTransaction == null ? void 0 : capturedTransaction.steps.forEach((step) => {
1083
+ const newStep = step.map(tr.mapping);
1084
+ if (newStep && dispatch) {
1085
+ tr.maybeStep(newStep);
1086
+ }
1087
+ });
1088
+ return true;
1089
+ };
1090
+ function isNodeActive(state2, typeOrName, attributes = {}) {
1091
+ const { from, to, empty } = state2.selection;
1092
+ const type = typeOrName ? getNodeType(typeOrName, state2.schema) : null;
1093
+ const nodeRanges = [];
1094
+ state2.doc.nodesBetween(from, to, (node, pos) => {
1095
+ if (node.isText) {
1096
+ return;
1097
+ }
1098
+ const relativeFrom = Math.max(from, pos);
1099
+ const relativeTo = Math.min(to, pos + node.nodeSize);
1100
+ nodeRanges.push({
1101
+ node,
1102
+ from: relativeFrom,
1103
+ to: relativeTo
1104
+ });
1105
+ });
1106
+ const selectionRange = to - from;
1107
+ const matchedNodeRanges = nodeRanges.filter((nodeRange) => {
1108
+ if (!type) {
1109
+ return true;
1110
+ }
1111
+ return type.name === nodeRange.node.type.name;
1112
+ }).filter((nodeRange) => objectIncludes(nodeRange.node.attrs, attributes, { strict: false }));
1113
+ if (empty) {
1114
+ return !!matchedNodeRanges.length;
1115
+ }
1116
+ const range = matchedNodeRanges.reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0);
1117
+ return range >= selectionRange;
1118
+ }
1119
+ var lift = (typeOrName, attributes = {}) => ({ state: state2, dispatch }) => {
1120
+ const type = getNodeType(typeOrName, state2.schema);
1121
+ const isActive2 = isNodeActive(state2, type, attributes);
1122
+ if (!isActive2) {
1123
+ return false;
1124
+ }
1125
+ return commands.lift(state2, dispatch);
1126
+ };
1127
+ var liftEmptyBlock = () => ({ state: state2, dispatch }) => {
1128
+ return commands.liftEmptyBlock(state2, dispatch);
1129
+ };
1130
+ var liftListItem = (typeOrName) => ({ state: state2, dispatch }) => {
1131
+ const type = getNodeType(typeOrName, state2.schema);
1132
+ return schemaList.liftListItem(type)(state2, dispatch);
1133
+ };
1134
+ var newlineInCode = () => ({ state: state2, dispatch }) => {
1135
+ return commands.newlineInCode(state2, dispatch);
1136
+ };
1137
+ function getSchemaTypeNameByName(name, schema) {
1138
+ if (schema.nodes[name]) {
1139
+ return "node";
1140
+ }
1141
+ if (schema.marks[name]) {
1142
+ return "mark";
1143
+ }
1144
+ return null;
1145
+ }
1146
+ function deleteProps(obj, propOrProps) {
1147
+ const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
1148
+ return Object.keys(obj).reduce((newObj, prop) => {
1149
+ if (!props.includes(prop)) {
1150
+ newObj[prop] = obj[prop];
1151
+ }
1152
+ return newObj;
1153
+ }, {});
1154
+ }
1155
+ var resetAttributes = (typeOrName, attributes) => ({ tr, state: state2, dispatch }) => {
1156
+ let nodeType = null;
1157
+ let markType = null;
1158
+ const schemaType = getSchemaTypeNameByName(
1159
+ typeof typeOrName === "string" ? typeOrName : typeOrName.name,
1160
+ state2.schema
1161
+ );
1162
+ if (!schemaType) {
1163
+ return false;
1164
+ }
1165
+ if (schemaType === "node") {
1166
+ nodeType = getNodeType(typeOrName, state2.schema);
1167
+ }
1168
+ if (schemaType === "mark") {
1169
+ markType = getMarkType(typeOrName, state2.schema);
1170
+ }
1171
+ let canReset = false;
1172
+ tr.selection.ranges.forEach((range) => {
1173
+ state2.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
1174
+ if (nodeType && nodeType === node.type) {
1175
+ canReset = true;
1176
+ if (dispatch) {
1177
+ tr.setNodeMarkup(pos, void 0, deleteProps(node.attrs, attributes));
1178
+ }
1179
+ }
1180
+ if (markType && node.marks.length) {
1181
+ node.marks.forEach((mark) => {
1182
+ if (markType === mark.type) {
1183
+ canReset = true;
1184
+ if (dispatch) {
1185
+ tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes)));
1186
+ }
1187
+ }
1188
+ });
1189
+ }
1190
+ });
1191
+ });
1192
+ return canReset;
1193
+ };
1194
+ var scrollIntoView = () => ({ tr, dispatch }) => {
1195
+ if (dispatch) {
1196
+ tr.scrollIntoView();
1197
+ }
1198
+ return true;
1199
+ };
1200
+ var selectAll = () => ({ tr, dispatch }) => {
1201
+ if (dispatch) {
1202
+ const selection = new state.AllSelection(tr.doc);
1203
+ tr.setSelection(selection);
1204
+ }
1205
+ return true;
1206
+ };
1207
+ var selectNodeBackward = () => ({ state: state2, dispatch }) => {
1208
+ return commands.selectNodeBackward(state2, dispatch);
1209
+ };
1210
+ var selectNodeForward = () => ({ state: state2, dispatch }) => {
1211
+ return commands.selectNodeForward(state2, dispatch);
1212
+ };
1213
+ var selectParentNode = () => ({ state: state2, dispatch }) => {
1214
+ return commands.selectParentNode(state2, dispatch);
1215
+ };
1216
+ var selectTextblockEnd = () => ({ state: state2, dispatch }) => {
1217
+ return commands.selectTextblockEnd(state2, dispatch);
1218
+ };
1219
+ var selectTextblockStart = () => ({ state: state2, dispatch }) => {
1220
+ return commands.selectTextblockStart(state2, dispatch);
1221
+ };
1222
+ function createDocument(content, schema, parseOptions = {}, options = {}) {
1223
+ return createNodeFromContent(content, schema, {
1224
+ slice: false,
1225
+ parseOptions,
1226
+ errorOnInvalidContent: options.errorOnInvalidContent
1227
+ });
1228
+ }
1229
+ var setContent = (content, { errorOnInvalidContent, emitUpdate = true, parseOptions = {} } = {}) => ({ editor, tr, dispatch, commands: commands2 }) => {
1230
+ const { doc } = tr;
1231
+ if (parseOptions.preserveWhitespace !== "full") {
1232
+ const document2 = createDocument(content, editor.schema, parseOptions, {
1233
+ errorOnInvalidContent: errorOnInvalidContent != null ? errorOnInvalidContent : editor.options.enableContentCheck
1234
+ });
1235
+ if (dispatch) {
1236
+ tr.replaceWith(0, doc.content.size, document2).setMeta("preventUpdate", !emitUpdate);
1237
+ }
1238
+ return true;
1239
+ }
1240
+ if (dispatch) {
1241
+ tr.setMeta("preventUpdate", !emitUpdate);
1242
+ }
1243
+ return commands2.insertContentAt({ from: 0, to: doc.content.size }, content, {
1244
+ parseOptions,
1245
+ errorOnInvalidContent: errorOnInvalidContent != null ? errorOnInvalidContent : editor.options.enableContentCheck
1246
+ });
1247
+ };
1248
+ function getMarkAttributes(state2, typeOrName) {
1249
+ const type = getMarkType(typeOrName, state2.schema);
1250
+ const { from, to, empty } = state2.selection;
1251
+ const marks = [];
1252
+ if (empty) {
1253
+ if (state2.storedMarks) {
1254
+ marks.push(...state2.storedMarks);
1255
+ }
1256
+ marks.push(...state2.selection.$head.marks());
1257
+ } else {
1258
+ state2.doc.nodesBetween(from, to, (node) => {
1259
+ marks.push(...node.marks);
1260
+ });
1261
+ }
1262
+ const mark = marks.find((markItem) => markItem.type.name === type.name);
1263
+ if (!mark) {
1264
+ return {};
1265
+ }
1266
+ return { ...mark.attrs };
1267
+ }
1268
+ function combineTransactionSteps(oldDoc, transactions) {
1269
+ const transform$1 = new transform.Transform(oldDoc);
1270
+ transactions.forEach((transaction) => {
1271
+ transaction.steps.forEach((step) => {
1272
+ transform$1.step(step);
1273
+ });
1274
+ });
1275
+ return transform$1;
1276
+ }
1277
+ function defaultBlockAt(match) {
1278
+ for (let i = 0; i < match.edgeCount; i += 1) {
1279
+ const { type } = match.edge(i);
1280
+ if (type.isTextblock && !type.hasRequiredAttrs()) {
1281
+ return type;
1282
+ }
1283
+ }
1284
+ return null;
1285
+ }
1286
+ function findParentNodeClosestToPos($pos, predicate) {
1287
+ for (let i = $pos.depth; i > 0; i -= 1) {
1288
+ const node = $pos.node(i);
1289
+ if (predicate(node)) {
1290
+ return {
1291
+ pos: i > 0 ? $pos.before(i) : 0,
1292
+ start: $pos.start(i),
1293
+ depth: i,
1294
+ node
1295
+ };
1296
+ }
1297
+ }
1298
+ }
1299
+ function findParentNode(predicate) {
1300
+ return (selection) => findParentNodeClosestToPos(selection.$from, predicate);
1301
+ }
1302
+ function getExtensionField(extension, field, context) {
1303
+ if (extension.config[field] === void 0 && extension.parent) {
1304
+ return getExtensionField(extension.parent, field, context);
1305
+ }
1306
+ if (typeof extension.config[field] === "function") {
1307
+ const value = extension.config[field].bind({
1308
+ ...context,
1309
+ parent: extension.parent ? getExtensionField(extension.parent, field, context) : null
1310
+ });
1311
+ return value;
1312
+ }
1313
+ return extension.config[field];
1314
+ }
1315
+ function isFunction(value) {
1316
+ return typeof value === "function";
1317
+ }
1318
+ function callOrReturn(value, context = void 0, ...props) {
1319
+ if (isFunction(value)) {
1320
+ if (context) {
1321
+ return value.bind(context)(...props);
1322
+ }
1323
+ return value(...props);
1324
+ }
1325
+ return value;
1326
+ }
1327
+ function splitExtensions(extensions) {
1328
+ const baseExtensions = extensions.filter((extension) => extension.type === "extension");
1329
+ const nodeExtensions = extensions.filter((extension) => extension.type === "node");
1330
+ const markExtensions = extensions.filter((extension) => extension.type === "mark");
1331
+ return {
1332
+ baseExtensions,
1333
+ nodeExtensions,
1334
+ markExtensions
1335
+ };
1336
+ }
1337
+ function mergeAttributes(...objects) {
1338
+ return objects.filter((item) => !!item).reduce((items, item) => {
1339
+ const mergedAttributes = { ...items };
1340
+ Object.entries(item).forEach(([key, value]) => {
1341
+ const exists = mergedAttributes[key];
1342
+ if (!exists) {
1343
+ mergedAttributes[key] = value;
1344
+ return;
1345
+ }
1346
+ if (key === "class") {
1347
+ const valueClasses = value ? String(value).split(" ") : [];
1348
+ const existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(" ") : [];
1349
+ const insertClasses = valueClasses.filter((valueClass) => !existingClasses.includes(valueClass));
1350
+ mergedAttributes[key] = [...existingClasses, ...insertClasses].join(" ");
1351
+ } else if (key === "style") {
1352
+ const newStyles = value ? value.split(";").map((style2) => style2.trim()).filter(Boolean) : [];
1353
+ const existingStyles = mergedAttributes[key] ? mergedAttributes[key].split(";").map((style2) => style2.trim()).filter(Boolean) : [];
1354
+ const styleMap = /* @__PURE__ */ new Map();
1355
+ existingStyles.forEach((style2) => {
1356
+ const [property, val] = style2.split(":").map((part) => part.trim());
1357
+ styleMap.set(property, val);
1358
+ });
1359
+ newStyles.forEach((style2) => {
1360
+ const [property, val] = style2.split(":").map((part) => part.trim());
1361
+ styleMap.set(property, val);
1362
+ });
1363
+ mergedAttributes[key] = Array.from(styleMap.entries()).map(([property, val]) => `${property}: ${val}`).join("; ");
1364
+ } else {
1365
+ mergedAttributes[key] = value;
1366
+ }
1367
+ });
1368
+ return mergedAttributes;
1369
+ }, {});
1370
+ }
1371
+ function getTextBetween(startNode, range, options) {
1372
+ const { from, to } = range;
1373
+ const { blockSeparator = "\n\n", textSerializers = {} } = options || {};
1374
+ let text = "";
1375
+ startNode.nodesBetween(from, to, (node, pos, parent, index) => {
1376
+ var _a;
1377
+ if (node.isBlock && pos > from) {
1378
+ text += blockSeparator;
1379
+ }
1380
+ const textSerializer = textSerializers == null ? void 0 : textSerializers[node.type.name];
1381
+ if (textSerializer) {
1382
+ if (parent) {
1383
+ text += textSerializer({
1384
+ node,
1385
+ pos,
1386
+ parent,
1387
+ index,
1388
+ range
1389
+ });
1390
+ }
1391
+ return false;
1392
+ }
1393
+ if (node.isText) {
1394
+ text += (_a = node == null ? void 0 : node.text) == null ? void 0 : _a.slice(Math.max(from, pos) - pos, to - pos);
1395
+ }
1396
+ });
1397
+ return text;
1398
+ }
1399
+ function getTextSerializersFromSchema(schema) {
1400
+ return Object.fromEntries(
1401
+ Object.entries(schema.nodes).filter(([, node]) => node.spec.toText).map(([name, node]) => [name, node.spec.toText])
1402
+ );
1403
+ }
1404
+ function removeDuplicates(array, by = JSON.stringify) {
1405
+ const seen = {};
1406
+ return array.filter((item) => {
1407
+ const key = by(item);
1408
+ return Object.prototype.hasOwnProperty.call(seen, key) ? false : seen[key] = true;
1409
+ });
1410
+ }
1411
+ function simplifyChangedRanges(changes) {
1412
+ const uniqueChanges = removeDuplicates(changes);
1413
+ return uniqueChanges.length === 1 ? uniqueChanges : uniqueChanges.filter((change, index) => {
1414
+ const rest = uniqueChanges.filter((_, i) => i !== index);
1415
+ return !rest.some((otherChange) => {
1416
+ return change.oldRange.from >= otherChange.oldRange.from && change.oldRange.to <= otherChange.oldRange.to && change.newRange.from >= otherChange.newRange.from && change.newRange.to <= otherChange.newRange.to;
1417
+ });
1418
+ });
1419
+ }
1420
+ function getChangedRanges(transform2) {
1421
+ const { mapping, steps } = transform2;
1422
+ const changes = [];
1423
+ mapping.maps.forEach((stepMap, index) => {
1424
+ const ranges = [];
1425
+ if (!stepMap.ranges.length) {
1426
+ const { from, to } = steps[index];
1427
+ if (from === void 0 || to === void 0) {
1428
+ return;
1429
+ }
1430
+ ranges.push({ from, to });
1431
+ } else {
1432
+ stepMap.forEach((from, to) => {
1433
+ ranges.push({ from, to });
1434
+ });
1435
+ }
1436
+ ranges.forEach(({ from, to }) => {
1437
+ const newStart = mapping.slice(index).map(from, -1);
1438
+ const newEnd = mapping.slice(index).map(to);
1439
+ const oldStart = mapping.invert().map(newStart, -1);
1440
+ const oldEnd = mapping.invert().map(newEnd);
1441
+ changes.push({
1442
+ oldRange: {
1443
+ from: oldStart,
1444
+ to: oldEnd
1445
+ },
1446
+ newRange: {
1447
+ from: newStart,
1448
+ to: newEnd
1449
+ }
1450
+ });
1451
+ });
1452
+ });
1453
+ return simplifyChangedRanges(changes);
1454
+ }
1455
+ function getSplittedAttributes(extensionAttributes, typeName, attributes) {
1456
+ return Object.fromEntries(
1457
+ Object.entries(attributes).filter(([name]) => {
1458
+ const extensionAttribute = extensionAttributes.find((item) => {
1459
+ return item.type === typeName && item.name === name;
1460
+ });
1461
+ if (!extensionAttribute) {
1462
+ return false;
1463
+ }
1464
+ return extensionAttribute.attribute.keepOnSplit;
1465
+ })
1466
+ );
1467
+ }
1468
+ function isMarkActive(state2, typeOrName, attributes = {}) {
1469
+ const { empty, ranges } = state2.selection;
1470
+ const type = typeOrName ? getMarkType(typeOrName, state2.schema) : null;
1471
+ if (empty) {
1472
+ return !!(state2.storedMarks || state2.selection.$from.marks()).filter((mark) => {
1473
+ if (!type) {
1474
+ return true;
1475
+ }
1476
+ return type.name === mark.type.name;
1477
+ }).find((mark) => objectIncludes(mark.attrs, attributes, { strict: false }));
1478
+ }
1479
+ let selectionRange = 0;
1480
+ const markRanges = [];
1481
+ ranges.forEach(({ $from, $to }) => {
1482
+ const from = $from.pos;
1483
+ const to = $to.pos;
1484
+ state2.doc.nodesBetween(from, to, (node, pos) => {
1485
+ if (!node.isText && !node.marks.length) {
1486
+ return;
1487
+ }
1488
+ const relativeFrom = Math.max(from, pos);
1489
+ const relativeTo = Math.min(to, pos + node.nodeSize);
1490
+ const range2 = relativeTo - relativeFrom;
1491
+ selectionRange += range2;
1492
+ markRanges.push(
1493
+ ...node.marks.map((mark) => ({
1494
+ mark,
1495
+ from: relativeFrom,
1496
+ to: relativeTo
1497
+ }))
1498
+ );
1499
+ });
1500
+ });
1501
+ if (selectionRange === 0) {
1502
+ return false;
1503
+ }
1504
+ const matchedRange = markRanges.filter((markRange) => {
1505
+ if (!type) {
1506
+ return true;
1507
+ }
1508
+ return type.name === markRange.mark.type.name;
1509
+ }).filter((markRange) => objectIncludes(markRange.mark.attrs, attributes, { strict: false })).reduce((sum, markRange) => sum + markRange.to - markRange.from, 0);
1510
+ const excludedRange = markRanges.filter((markRange) => {
1511
+ if (!type) {
1512
+ return true;
1513
+ }
1514
+ return markRange.mark.type !== type && markRange.mark.type.excludes(type);
1515
+ }).reduce((sum, markRange) => sum + markRange.to - markRange.from, 0);
1516
+ const range = matchedRange > 0 ? matchedRange + excludedRange : matchedRange;
1517
+ return range >= selectionRange;
1518
+ }
1519
+ function isList(name, extensions) {
1520
+ const { nodeExtensions } = splitExtensions(extensions);
1521
+ const extension = nodeExtensions.find((item) => item.name === name);
1522
+ if (!extension) {
1523
+ return false;
1524
+ }
1525
+ const context = {
1526
+ name: extension.name,
1527
+ options: extension.options,
1528
+ storage: extension.storage
1529
+ };
1530
+ const group = callOrReturn(getExtensionField(extension, "group", context));
1531
+ if (typeof group !== "string") {
1532
+ return false;
1533
+ }
1534
+ return group.split(" ").includes("list");
1535
+ }
1536
+ function isNodeEmpty(node, {
1537
+ checkChildren = true,
1538
+ ignoreWhitespace = false
1539
+ } = {}) {
1540
+ var _a;
1541
+ if (ignoreWhitespace) {
1542
+ if (node.type.name === "hardBreak") {
1543
+ return true;
1544
+ }
1545
+ if (node.isText) {
1546
+ return /^\s*$/m.test((_a = node.text) != null ? _a : "");
1547
+ }
1548
+ }
1549
+ if (node.isText) {
1550
+ return !node.text;
1551
+ }
1552
+ if (node.isAtom || node.isLeaf) {
1553
+ return false;
1554
+ }
1555
+ if (node.content.childCount === 0) {
1556
+ return true;
1557
+ }
1558
+ if (checkChildren) {
1559
+ let isContentEmpty = true;
1560
+ node.content.forEach((childNode) => {
1561
+ if (isContentEmpty === false) {
1562
+ return;
1563
+ }
1564
+ if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {
1565
+ isContentEmpty = false;
1566
+ }
1567
+ });
1568
+ return isContentEmpty;
1569
+ }
1570
+ return false;
1571
+ }
1572
+ function isNodeSelection(value) {
1573
+ return value instanceof state.NodeSelection;
1574
+ }
1575
+ function canSetMark(state2, tr, newMarkType) {
1576
+ var _a;
1577
+ const { selection } = tr;
1578
+ let cursor = null;
1579
+ if (isTextSelection(selection)) {
1580
+ cursor = selection.$cursor;
1581
+ }
1582
+ if (cursor) {
1583
+ const currentMarks = (_a = state2.storedMarks) != null ? _a : cursor.marks();
1584
+ const parentAllowsMarkType = cursor.parent.type.allowsMarkType(newMarkType);
1585
+ return parentAllowsMarkType && (!!newMarkType.isInSet(currentMarks) || !currentMarks.some((mark) => mark.type.excludes(newMarkType)));
1586
+ }
1587
+ const { ranges } = selection;
1588
+ return ranges.some(({ $from, $to }) => {
1589
+ let someNodeSupportsMark = $from.depth === 0 ? state2.doc.inlineContent && state2.doc.type.allowsMarkType(newMarkType) : false;
1590
+ state2.doc.nodesBetween($from.pos, $to.pos, (node, _pos, parent) => {
1591
+ if (someNodeSupportsMark) {
1592
+ return false;
1593
+ }
1594
+ if (node.isInline) {
1595
+ const parentAllowsMarkType = !parent || parent.type.allowsMarkType(newMarkType);
1596
+ const currentMarksAllowMarkType = !!newMarkType.isInSet(node.marks) || !node.marks.some((otherMark) => otherMark.type.excludes(newMarkType));
1597
+ someNodeSupportsMark = parentAllowsMarkType && currentMarksAllowMarkType;
1598
+ }
1599
+ return !someNodeSupportsMark;
1600
+ });
1601
+ return someNodeSupportsMark;
1602
+ });
1603
+ }
1604
+ var setMark = (typeOrName, attributes = {}) => ({ tr, state: state2, dispatch }) => {
1605
+ const { selection } = tr;
1606
+ const { empty, ranges } = selection;
1607
+ const type = getMarkType(typeOrName, state2.schema);
1608
+ if (dispatch) {
1609
+ if (empty) {
1610
+ const oldAttributes = getMarkAttributes(state2, type);
1611
+ tr.addStoredMark(
1612
+ type.create({
1613
+ ...oldAttributes,
1614
+ ...attributes
1615
+ })
1616
+ );
1617
+ } else {
1618
+ ranges.forEach((range) => {
1619
+ const from = range.$from.pos;
1620
+ const to = range.$to.pos;
1621
+ state2.doc.nodesBetween(from, to, (node, pos) => {
1622
+ const trimmedFrom = Math.max(pos, from);
1623
+ const trimmedTo = Math.min(pos + node.nodeSize, to);
1624
+ const someHasMark = node.marks.find((mark) => mark.type === type);
1625
+ if (someHasMark) {
1626
+ node.marks.forEach((mark) => {
1627
+ if (type === mark.type) {
1628
+ tr.addMark(
1629
+ trimmedFrom,
1630
+ trimmedTo,
1631
+ type.create({
1632
+ ...mark.attrs,
1633
+ ...attributes
1634
+ })
1635
+ );
1636
+ }
1637
+ });
1638
+ } else {
1639
+ tr.addMark(trimmedFrom, trimmedTo, type.create(attributes));
1640
+ }
1641
+ });
1642
+ });
1643
+ }
1644
+ }
1645
+ return canSetMark(state2, tr, type);
1646
+ };
1647
+ var setMeta = (key, value) => ({ tr }) => {
1648
+ tr.setMeta(key, value);
1649
+ return true;
1650
+ };
1651
+ var setNode = (typeOrName, attributes = {}) => ({ state: state2, dispatch, chain }) => {
1652
+ const type = getNodeType(typeOrName, state2.schema);
1653
+ let attributesToCopy;
1654
+ if (state2.selection.$anchor.sameParent(state2.selection.$head)) {
1655
+ attributesToCopy = state2.selection.$anchor.parent.attrs;
1656
+ }
1657
+ if (!type.isTextblock) {
1658
+ console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.');
1659
+ return false;
1660
+ }
1661
+ return chain().command(({ commands: commands$1 }) => {
1662
+ const canSetBlock = commands.setBlockType(type, { ...attributesToCopy, ...attributes })(state2);
1663
+ if (canSetBlock) {
1664
+ return true;
1665
+ }
1666
+ return commands$1.clearNodes();
1667
+ }).command(({ state: updatedState }) => {
1668
+ return commands.setBlockType(type, { ...attributesToCopy, ...attributes })(updatedState, dispatch);
1669
+ }).run();
1670
+ };
1671
+ var setNodeSelection = (position) => ({ tr, dispatch }) => {
1672
+ if (dispatch) {
1673
+ const { doc } = tr;
1674
+ const from = minMax(position, 0, doc.content.size);
1675
+ const selection = state.NodeSelection.create(doc, from);
1676
+ tr.setSelection(selection);
1677
+ }
1678
+ return true;
1679
+ };
1680
+ var setTextDirection = (direction, position) => ({ tr, state: state2, dispatch }) => {
1681
+ const { selection } = state2;
1682
+ let from;
1683
+ let to;
1684
+ if (typeof position === "number") {
1685
+ from = position;
1686
+ to = position;
1687
+ } else if (position && "from" in position && "to" in position) {
1688
+ from = position.from;
1689
+ to = position.to;
1690
+ } else {
1691
+ from = selection.from;
1692
+ to = selection.to;
1693
+ }
1694
+ if (dispatch) {
1695
+ tr.doc.nodesBetween(from, to, (node, pos) => {
1696
+ if (node.isText) {
1697
+ return;
1698
+ }
1699
+ tr.setNodeMarkup(pos, void 0, {
1700
+ ...node.attrs,
1701
+ dir: direction
1702
+ });
1703
+ });
1704
+ }
1705
+ return true;
1706
+ };
1707
+ var setTextSelection = (position) => ({ tr, dispatch }) => {
1708
+ if (dispatch) {
1709
+ const { doc } = tr;
1710
+ const { from, to } = typeof position === "number" ? { from: position, to: position } : position;
1711
+ const minPos = state.TextSelection.atStart(doc).from;
1712
+ const maxPos = state.TextSelection.atEnd(doc).to;
1713
+ const resolvedFrom = minMax(from, minPos, maxPos);
1714
+ const resolvedEnd = minMax(to, minPos, maxPos);
1715
+ const selection = state.TextSelection.create(doc, resolvedFrom, resolvedEnd);
1716
+ tr.setSelection(selection);
1717
+ }
1718
+ return true;
1719
+ };
1720
+ var sinkListItem = (typeOrName) => ({ state: state2, dispatch }) => {
1721
+ const type = getNodeType(typeOrName, state2.schema);
1722
+ return schemaList.sinkListItem(type)(state2, dispatch);
1723
+ };
1724
+ function ensureMarks(state2, splittableMarks) {
1725
+ const marks = state2.storedMarks || state2.selection.$to.parentOffset && state2.selection.$from.marks();
1726
+ if (marks) {
1727
+ const filteredMarks = marks.filter((mark) => splittableMarks == null ? void 0 : splittableMarks.includes(mark.type.name));
1728
+ state2.tr.ensureMarks(filteredMarks);
1729
+ }
1730
+ }
1731
+ var splitBlock = ({ keepMarks = true } = {}) => ({ tr, state: state$1, dispatch, editor }) => {
1732
+ const { selection, doc } = tr;
1733
+ const { $from, $to } = selection;
1734
+ const extensionAttributes = editor.extensionManager.attributes;
1735
+ const newAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);
1736
+ if (selection instanceof state.NodeSelection && selection.node.isBlock) {
1737
+ if (!$from.parentOffset || !transform.canSplit(doc, $from.pos)) {
1738
+ return false;
1739
+ }
1740
+ if (dispatch) {
1741
+ if (keepMarks) {
1742
+ ensureMarks(state$1, editor.extensionManager.splittableMarks);
1743
+ }
1744
+ tr.split($from.pos).scrollIntoView();
1745
+ }
1746
+ return true;
1747
+ }
1748
+ if (!$from.parent.isBlock) {
1749
+ return false;
1750
+ }
1751
+ const atEnd = $to.parentOffset === $to.parent.content.size;
1752
+ const deflt = $from.depth === 0 ? void 0 : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
1753
+ let types = atEnd && deflt ? [
1754
+ {
1755
+ type: deflt,
1756
+ attrs: newAttributes
1757
+ }
1758
+ ] : void 0;
1759
+ let can = transform.canSplit(tr.doc, tr.mapping.map($from.pos), 1, types);
1760
+ if (!types && !can && transform.canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : void 0)) {
1761
+ can = true;
1762
+ types = deflt ? [
1763
+ {
1764
+ type: deflt,
1765
+ attrs: newAttributes
1766
+ }
1767
+ ] : void 0;
1768
+ }
1769
+ if (dispatch) {
1770
+ if (can) {
1771
+ if (selection instanceof state.TextSelection) {
1772
+ tr.deleteSelection();
1773
+ }
1774
+ tr.split(tr.mapping.map($from.pos), 1, types);
1775
+ if (deflt && !atEnd && !$from.parentOffset && $from.parent.type !== deflt) {
1776
+ const first2 = tr.mapping.map($from.before());
1777
+ const $first = tr.doc.resolve(first2);
1778
+ if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) {
1779
+ tr.setNodeMarkup(tr.mapping.map($from.before()), deflt);
1780
+ }
1781
+ }
1782
+ }
1783
+ if (keepMarks) {
1784
+ ensureMarks(state$1, editor.extensionManager.splittableMarks);
1785
+ }
1786
+ tr.scrollIntoView();
1787
+ }
1788
+ return can;
1789
+ };
1790
+ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state: state$1, dispatch, editor }) => {
1791
+ var _a;
1792
+ const type = getNodeType(typeOrName, state$1.schema);
1793
+ const { $from, $to } = state$1.selection;
1794
+ const node = state$1.selection.node;
1795
+ if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
1796
+ return false;
1797
+ }
1798
+ const grandParent = $from.node(-1);
1799
+ if (grandParent.type !== type) {
1800
+ return false;
1801
+ }
1802
+ const extensionAttributes = editor.extensionManager.attributes;
1803
+ if ($from.parent.content.size === 0 && $from.node(-1).childCount === $from.indexAfter(-1)) {
1804
+ if ($from.depth === 2 || $from.node(-3).type !== type || $from.index(-2) !== $from.node(-2).childCount - 1) {
1805
+ return false;
1806
+ }
1807
+ if (dispatch) {
1808
+ let wrap = model.Fragment.empty;
1809
+ const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;
1810
+ for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) {
1811
+ wrap = model.Fragment.from($from.node(d).copy(wrap));
1812
+ }
1813
+ const depthAfter = (
1814
+ // eslint-disable-next-line no-nested-ternary
1815
+ $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3
1816
+ );
1817
+ const newNextTypeAttributes2 = {
1818
+ ...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
1819
+ ...overrideAttrs
1820
+ };
1821
+ const nextType2 = ((_a = type.contentMatch.defaultType) == null ? void 0 : _a.createAndFill(newNextTypeAttributes2)) || void 0;
1822
+ wrap = wrap.append(model.Fragment.from(type.createAndFill(null, nextType2) || void 0));
1823
+ const start = $from.before($from.depth - (depthBefore - 1));
1824
+ tr.replace(start, $from.after(-depthAfter), new model.Slice(wrap, 4 - depthBefore, 0));
1825
+ let sel = -1;
1826
+ tr.doc.nodesBetween(start, tr.doc.content.size, (n, pos) => {
1827
+ if (sel > -1) {
1828
+ return false;
1829
+ }
1830
+ if (n.isTextblock && n.content.size === 0) {
1831
+ sel = pos + 1;
1832
+ }
1833
+ });
1834
+ if (sel > -1) {
1835
+ tr.setSelection(state.TextSelection.near(tr.doc.resolve(sel)));
1836
+ }
1837
+ tr.scrollIntoView();
1838
+ }
1839
+ return true;
1840
+ }
1841
+ const nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null;
1842
+ const newTypeAttributes = {
1843
+ ...getSplittedAttributes(extensionAttributes, grandParent.type.name, grandParent.attrs),
1844
+ ...overrideAttrs
1845
+ };
1846
+ const newNextTypeAttributes = {
1847
+ ...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
1848
+ ...overrideAttrs
1849
+ };
1850
+ tr.delete($from.pos, $to.pos);
1851
+ const types = nextType ? [
1852
+ { type, attrs: newTypeAttributes },
1853
+ { type: nextType, attrs: newNextTypeAttributes }
1854
+ ] : [{ type, attrs: newTypeAttributes }];
1855
+ if (!transform.canSplit(tr.doc, $from.pos, 2)) {
1856
+ return false;
1857
+ }
1858
+ if (dispatch) {
1859
+ const { selection, storedMarks } = state$1;
1860
+ const { splittableMarks } = editor.extensionManager;
1861
+ const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
1862
+ tr.split($from.pos, 2, types).scrollIntoView();
1863
+ if (!marks || !dispatch) {
1864
+ return true;
1865
+ }
1866
+ const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
1867
+ tr.ensureMarks(filteredMarks);
1868
+ }
1869
+ return true;
1870
+ };
1871
+ var joinListBackwards = (tr, listType) => {
1872
+ const list = findParentNode((node) => node.type === listType)(tr.selection);
1873
+ if (!list) {
1874
+ return true;
1875
+ }
1876
+ const before = tr.doc.resolve(Math.max(0, list.pos - 1)).before(list.depth);
1877
+ if (before === void 0) {
1878
+ return true;
1879
+ }
1880
+ const nodeBefore = tr.doc.nodeAt(before);
1881
+ const canJoinBackwards = list.node.type === (nodeBefore == null ? void 0 : nodeBefore.type) && transform.canJoin(tr.doc, list.pos);
1882
+ if (!canJoinBackwards) {
1883
+ return true;
1884
+ }
1885
+ tr.join(list.pos);
1886
+ return true;
1887
+ };
1888
+ var joinListForwards = (tr, listType) => {
1889
+ const list = findParentNode((node) => node.type === listType)(tr.selection);
1890
+ if (!list) {
1891
+ return true;
1892
+ }
1893
+ const after = tr.doc.resolve(list.start).after(list.depth);
1894
+ if (after === void 0) {
1895
+ return true;
1896
+ }
1897
+ const nodeAfter = tr.doc.nodeAt(after);
1898
+ const canJoinForwards = list.node.type === (nodeAfter == null ? void 0 : nodeAfter.type) && transform.canJoin(tr.doc, after);
1899
+ if (!canJoinForwards) {
1900
+ return true;
1901
+ }
1902
+ tr.join(after);
1903
+ return true;
1904
+ };
1905
+ var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr, state: state2, dispatch, chain, commands: commands2, can }) => {
1906
+ const { extensions, splittableMarks } = editor.extensionManager;
1907
+ const listType = getNodeType(listTypeOrName, state2.schema);
1908
+ const itemType = getNodeType(itemTypeOrName, state2.schema);
1909
+ const { selection, storedMarks } = state2;
1910
+ const { $from, $to } = selection;
1911
+ const range = $from.blockRange($to);
1912
+ const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
1913
+ if (!range) {
1914
+ return false;
1915
+ }
1916
+ const parentList = findParentNode((node) => isList(node.type.name, extensions))(selection);
1917
+ if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {
1918
+ if (parentList.node.type === listType) {
1919
+ return commands2.liftListItem(itemType);
1920
+ }
1921
+ if (isList(parentList.node.type.name, extensions) && listType.validContent(parentList.node.content) && dispatch) {
1922
+ return chain().command(() => {
1923
+ tr.setNodeMarkup(parentList.pos, listType);
1924
+ return true;
1925
+ }).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();
1926
+ }
1927
+ }
1928
+ if (!keepMarks || !marks || !dispatch) {
1929
+ return chain().command(() => {
1930
+ const canWrapInList = can().wrapInList(listType, attributes);
1931
+ if (canWrapInList) {
1932
+ return true;
1933
+ }
1934
+ return commands2.clearNodes();
1935
+ }).wrapInList(listType, attributes).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();
1936
+ }
1937
+ return chain().command(() => {
1938
+ const canWrapInList = can().wrapInList(listType, attributes);
1939
+ const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
1940
+ tr.ensureMarks(filteredMarks);
1941
+ if (canWrapInList) {
1942
+ return true;
1943
+ }
1944
+ return commands2.clearNodes();
1945
+ }).wrapInList(listType, attributes).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();
1946
+ };
1947
+ var toggleMark = (typeOrName, attributes = {}, options = {}) => ({ state: state2, commands: commands2 }) => {
1948
+ const { extendEmptyMarkRange = false } = options;
1949
+ const type = getMarkType(typeOrName, state2.schema);
1950
+ const isActive2 = isMarkActive(state2, type, attributes);
1951
+ if (isActive2) {
1952
+ return commands2.unsetMark(type, { extendEmptyMarkRange });
1953
+ }
1954
+ return commands2.setMark(type, attributes);
1955
+ };
1956
+ var toggleNode = (typeOrName, toggleTypeOrName, attributes = {}) => ({ state: state2, commands: commands2 }) => {
1957
+ const type = getNodeType(typeOrName, state2.schema);
1958
+ const toggleType = getNodeType(toggleTypeOrName, state2.schema);
1959
+ const isActive2 = isNodeActive(state2, type, attributes);
1960
+ let attributesToCopy;
1961
+ if (state2.selection.$anchor.sameParent(state2.selection.$head)) {
1962
+ attributesToCopy = state2.selection.$anchor.parent.attrs;
1963
+ }
1964
+ if (isActive2) {
1965
+ return commands2.setNode(toggleType, attributesToCopy);
1966
+ }
1967
+ return commands2.setNode(type, { ...attributesToCopy, ...attributes });
1968
+ };
1969
+ var toggleWrap = (typeOrName, attributes = {}) => ({ state: state2, commands: commands2 }) => {
1970
+ const type = getNodeType(typeOrName, state2.schema);
1971
+ const isActive2 = isNodeActive(state2, type, attributes);
1972
+ if (isActive2) {
1973
+ return commands2.lift(type);
1974
+ }
1975
+ return commands2.wrapIn(type, attributes);
1976
+ };
1977
+ var undoInputRule = () => ({ state: state2, dispatch }) => {
1978
+ const plugins = state2.plugins;
1979
+ for (let i = 0; i < plugins.length; i += 1) {
1980
+ const plugin = plugins[i];
1981
+ let undoable;
1982
+ if (plugin.spec.isInputRules && (undoable = plugin.getState(state2))) {
1983
+ if (dispatch) {
1984
+ const tr = state2.tr;
1985
+ const toUndo = undoable.transform;
1986
+ for (let j = toUndo.steps.length - 1; j >= 0; j -= 1) {
1987
+ tr.step(toUndo.steps[j].invert(toUndo.docs[j]));
1988
+ }
1989
+ if (undoable.text) {
1990
+ const marks = tr.doc.resolve(undoable.from).marks();
1991
+ tr.replaceWith(undoable.from, undoable.to, state2.schema.text(undoable.text, marks));
1992
+ } else {
1993
+ tr.delete(undoable.from, undoable.to);
1994
+ }
1995
+ }
1996
+ return true;
1997
+ }
1998
+ }
1999
+ return false;
2000
+ };
2001
+ var unsetAllMarks = () => ({ tr, dispatch }) => {
2002
+ const { selection } = tr;
2003
+ const { empty, ranges } = selection;
2004
+ if (empty) {
2005
+ return true;
2006
+ }
2007
+ if (dispatch) {
2008
+ ranges.forEach((range) => {
2009
+ tr.removeMark(range.$from.pos, range.$to.pos);
2010
+ });
2011
+ }
2012
+ return true;
2013
+ };
2014
+ var unsetMark = (typeOrName, options = {}) => ({ tr, state: state2, dispatch }) => {
2015
+ var _a;
2016
+ const { extendEmptyMarkRange = false } = options;
2017
+ const { selection } = tr;
2018
+ const type = getMarkType(typeOrName, state2.schema);
2019
+ const { $from, empty, ranges } = selection;
2020
+ if (!dispatch) {
2021
+ return true;
2022
+ }
2023
+ if (empty && extendEmptyMarkRange) {
2024
+ let { from, to } = selection;
2025
+ const attrs = (_a = $from.marks().find((mark) => mark.type === type)) == null ? void 0 : _a.attrs;
2026
+ const range = getMarkRange($from, type, attrs);
2027
+ if (range) {
2028
+ from = range.from;
2029
+ to = range.to;
2030
+ }
2031
+ tr.removeMark(from, to, type);
2032
+ } else {
2033
+ ranges.forEach((range) => {
2034
+ tr.removeMark(range.$from.pos, range.$to.pos, type);
2035
+ });
2036
+ }
2037
+ tr.removeStoredMark(type);
2038
+ return true;
2039
+ };
2040
+ var unsetTextDirection = (position) => ({ tr, state: state2, dispatch }) => {
2041
+ const { selection } = state2;
2042
+ let from;
2043
+ let to;
2044
+ if (typeof position === "number") {
2045
+ from = position;
2046
+ to = position;
2047
+ } else if (position && "from" in position && "to" in position) {
2048
+ from = position.from;
2049
+ to = position.to;
2050
+ } else {
2051
+ from = selection.from;
2052
+ to = selection.to;
2053
+ }
2054
+ if (dispatch) {
2055
+ tr.doc.nodesBetween(from, to, (node, pos) => {
2056
+ if (node.isText) {
2057
+ return;
2058
+ }
2059
+ const newAttrs = { ...node.attrs };
2060
+ delete newAttrs.dir;
2061
+ tr.setNodeMarkup(pos, void 0, newAttrs);
2062
+ });
2063
+ }
2064
+ return true;
2065
+ };
2066
+ var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state: state2, dispatch }) => {
2067
+ let nodeType = null;
2068
+ let markType = null;
2069
+ const schemaType = getSchemaTypeNameByName(
2070
+ typeof typeOrName === "string" ? typeOrName : typeOrName.name,
2071
+ state2.schema
2072
+ );
2073
+ if (!schemaType) {
2074
+ return false;
2075
+ }
2076
+ if (schemaType === "node") {
2077
+ nodeType = getNodeType(typeOrName, state2.schema);
2078
+ }
2079
+ if (schemaType === "mark") {
2080
+ markType = getMarkType(typeOrName, state2.schema);
2081
+ }
2082
+ let canUpdate = false;
2083
+ tr.selection.ranges.forEach((range) => {
2084
+ const from = range.$from.pos;
2085
+ const to = range.$to.pos;
2086
+ let lastPos;
2087
+ let lastNode;
2088
+ let trimmedFrom;
2089
+ let trimmedTo;
2090
+ if (tr.selection.empty) {
2091
+ state2.doc.nodesBetween(from, to, (node, pos) => {
2092
+ if (nodeType && nodeType === node.type) {
2093
+ canUpdate = true;
2094
+ trimmedFrom = Math.max(pos, from);
2095
+ trimmedTo = Math.min(pos + node.nodeSize, to);
2096
+ lastPos = pos;
2097
+ lastNode = node;
2098
+ }
2099
+ });
2100
+ } else {
2101
+ state2.doc.nodesBetween(from, to, (node, pos) => {
2102
+ if (pos < from && nodeType && nodeType === node.type) {
2103
+ canUpdate = true;
2104
+ trimmedFrom = Math.max(pos, from);
2105
+ trimmedTo = Math.min(pos + node.nodeSize, to);
2106
+ lastPos = pos;
2107
+ lastNode = node;
2108
+ }
2109
+ if (pos >= from && pos <= to) {
2110
+ if (nodeType && nodeType === node.type) {
2111
+ canUpdate = true;
2112
+ if (dispatch) {
2113
+ tr.setNodeMarkup(pos, void 0, {
2114
+ ...node.attrs,
2115
+ ...attributes
2116
+ });
2117
+ }
2118
+ }
2119
+ if (markType && node.marks.length) {
2120
+ node.marks.forEach((mark) => {
2121
+ if (markType === mark.type) {
2122
+ canUpdate = true;
2123
+ if (dispatch) {
2124
+ const trimmedFrom2 = Math.max(pos, from);
2125
+ const trimmedTo2 = Math.min(pos + node.nodeSize, to);
2126
+ tr.addMark(
2127
+ trimmedFrom2,
2128
+ trimmedTo2,
2129
+ markType.create({
2130
+ ...mark.attrs,
2131
+ ...attributes
2132
+ })
2133
+ );
2134
+ }
2135
+ }
2136
+ });
2137
+ }
2138
+ }
2139
+ });
2140
+ }
2141
+ if (lastNode) {
2142
+ if (lastPos !== void 0 && dispatch) {
2143
+ tr.setNodeMarkup(lastPos, void 0, {
2144
+ ...lastNode.attrs,
2145
+ ...attributes
2146
+ });
2147
+ }
2148
+ if (markType && lastNode.marks.length) {
2149
+ lastNode.marks.forEach((mark) => {
2150
+ if (markType === mark.type && dispatch) {
2151
+ tr.addMark(
2152
+ trimmedFrom,
2153
+ trimmedTo,
2154
+ markType.create({
2155
+ ...mark.attrs,
2156
+ ...attributes
2157
+ })
2158
+ );
2159
+ }
2160
+ });
2161
+ }
2162
+ }
2163
+ });
2164
+ return canUpdate;
2165
+ };
2166
+ var wrapIn = (typeOrName, attributes = {}) => ({ state: state2, dispatch }) => {
2167
+ const type = getNodeType(typeOrName, state2.schema);
2168
+ return commands.wrapIn(type, attributes)(state2, dispatch);
2169
+ };
2170
+ var wrapInList = (typeOrName, attributes = {}) => ({ state: state2, dispatch }) => {
2171
+ const type = getNodeType(typeOrName, state2.schema);
2172
+ return schemaList.wrapInList(type, attributes)(state2, dispatch);
2173
+ };
2174
+ var InputRule = class {
2175
+ constructor(config) {
2176
+ var _a;
2177
+ this.find = config.find;
2178
+ this.handler = config.handler;
2179
+ this.undoable = (_a = config.undoable) != null ? _a : true;
2180
+ }
2181
+ };
2182
+ function getType(value) {
2183
+ return Object.prototype.toString.call(value).slice(8, -1);
2184
+ }
2185
+ function isPlainObject(value) {
2186
+ if (getType(value) !== "Object") {
2187
+ return false;
2188
+ }
2189
+ return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;
2190
+ }
2191
+ function mergeDeep(target, source) {
2192
+ const output = { ...target };
2193
+ if (isPlainObject(target) && isPlainObject(source)) {
2194
+ Object.keys(source).forEach((key) => {
2195
+ if (isPlainObject(source[key]) && isPlainObject(target[key])) {
2196
+ output[key] = mergeDeep(target[key], source[key]);
2197
+ } else {
2198
+ output[key] = source[key];
2199
+ }
2200
+ });
2201
+ }
2202
+ return output;
2203
+ }
2204
+ var Extendable = class {
2205
+ constructor(config = {}) {
2206
+ this.type = "extendable";
2207
+ this.parent = null;
2208
+ this.child = null;
2209
+ this.name = "";
2210
+ this.config = {
2211
+ name: this.name
2212
+ };
2213
+ this.config = {
2214
+ ...this.config,
2215
+ ...config
2216
+ };
2217
+ this.name = this.config.name;
2218
+ }
2219
+ get options() {
2220
+ return {
2221
+ ...callOrReturn(
2222
+ getExtensionField(this, "addOptions", {
2223
+ name: this.name
2224
+ })
2225
+ ) || {}
2226
+ };
2227
+ }
2228
+ get storage() {
2229
+ return {
2230
+ ...callOrReturn(
2231
+ getExtensionField(this, "addStorage", {
2232
+ name: this.name,
2233
+ options: this.options
2234
+ })
2235
+ ) || {}
2236
+ };
2237
+ }
2238
+ configure(options = {}) {
2239
+ const extension = this.extend({
2240
+ ...this.config,
2241
+ addOptions: () => {
2242
+ return mergeDeep(this.options, options);
2243
+ }
2244
+ });
2245
+ extension.name = this.name;
2246
+ extension.parent = this.parent;
2247
+ return extension;
2248
+ }
2249
+ extend(extendedConfig = {}) {
2250
+ const extension = new this.constructor({ ...this.config, ...extendedConfig });
2251
+ extension.parent = this;
2252
+ this.child = extension;
2253
+ extension.name = "name" in extendedConfig ? extendedConfig.name : extension.parent.name;
2254
+ return extension;
2255
+ }
2256
+ };
2257
+ var Mark = class _Mark extends Extendable {
2258
+ constructor() {
2259
+ super(...arguments);
2260
+ this.type = "mark";
2261
+ }
2262
+ /**
2263
+ * Create a new Mark instance
2264
+ * @param config - Mark configuration object or a function that returns a configuration object
2265
+ */
2266
+ static create(config = {}) {
2267
+ const resolvedConfig = typeof config === "function" ? config() : config;
2268
+ return new _Mark(resolvedConfig);
2269
+ }
2270
+ static handleExit({ editor, mark }) {
2271
+ const { tr } = editor.state;
2272
+ const currentPos = editor.state.selection.$from;
2273
+ const isAtEnd = currentPos.pos === currentPos.end();
2274
+ if (isAtEnd) {
2275
+ const currentMarks = currentPos.marks();
2276
+ const isInMark = !!currentMarks.find((m) => (m == null ? void 0 : m.type.name) === mark.name);
2277
+ if (!isInMark) {
2278
+ return false;
2279
+ }
2280
+ const removeMark = currentMarks.find((m) => (m == null ? void 0 : m.type.name) === mark.name);
2281
+ if (removeMark) {
2282
+ tr.removeStoredMark(removeMark);
2283
+ }
2284
+ tr.insertText(" ", currentPos.pos);
2285
+ editor.view.dispatch(tr);
2286
+ return true;
2287
+ }
2288
+ return false;
2289
+ }
2290
+ configure(options) {
2291
+ return super.configure(options);
2292
+ }
2293
+ extend(extendedConfig) {
2294
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
2295
+ return super.extend(resolvedConfig);
2296
+ }
2297
+ };
2298
+ var extensions_exports = {};
2299
+ __export(extensions_exports, {
2300
+ ClipboardTextSerializer: () => ClipboardTextSerializer,
2301
+ Commands: () => Commands,
2302
+ Delete: () => Delete,
2303
+ Drop: () => Drop,
2304
+ Editable: () => Editable,
2305
+ FocusEvents: () => FocusEvents,
2306
+ Keymap: () => Keymap,
2307
+ Paste: () => Paste,
2308
+ Tabindex: () => Tabindex,
2309
+ TextDirection: () => TextDirection,
2310
+ focusEventsPluginKey: () => focusEventsPluginKey
2311
+ });
2312
+ var Extension = class _Extension extends Extendable {
2313
+ constructor() {
2314
+ super(...arguments);
2315
+ this.type = "extension";
2316
+ }
2317
+ /**
2318
+ * Create a new Extension instance
2319
+ * @param config - Extension configuration object or a function that returns a configuration object
2320
+ */
2321
+ static create(config = {}) {
2322
+ const resolvedConfig = typeof config === "function" ? config() : config;
2323
+ return new _Extension(resolvedConfig);
2324
+ }
2325
+ configure(options) {
2326
+ return super.configure(options);
2327
+ }
2328
+ extend(extendedConfig) {
2329
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
2330
+ return super.extend(resolvedConfig);
2331
+ }
2332
+ };
2333
+ var ClipboardTextSerializer = Extension.create({
2334
+ name: "clipboardTextSerializer",
2335
+ addOptions() {
2336
+ return {
2337
+ blockSeparator: void 0
2338
+ };
2339
+ },
2340
+ addProseMirrorPlugins() {
2341
+ return [
2342
+ new state.Plugin({
2343
+ key: new state.PluginKey("clipboardTextSerializer"),
2344
+ props: {
2345
+ clipboardTextSerializer: () => {
2346
+ const { editor } = this;
2347
+ const { state: state2, schema } = editor;
2348
+ const { doc, selection } = state2;
2349
+ const { ranges } = selection;
2350
+ const from = Math.min(...ranges.map((range2) => range2.$from.pos));
2351
+ const to = Math.max(...ranges.map((range2) => range2.$to.pos));
2352
+ const textSerializers = getTextSerializersFromSchema(schema);
2353
+ const range = { from, to };
2354
+ return getTextBetween(doc, range, {
2355
+ ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
2356
+ textSerializers
2357
+ });
2358
+ }
2359
+ }
2360
+ })
2361
+ ];
2362
+ }
2363
+ });
2364
+ var Commands = Extension.create({
2365
+ name: "commands",
2366
+ addCommands() {
2367
+ return {
2368
+ ...commands_exports
2369
+ };
2370
+ }
2371
+ });
2372
+ var Delete = Extension.create({
2373
+ name: "delete",
2374
+ onUpdate({ transaction, appendedTransactions }) {
2375
+ var _a, _b, _c;
2376
+ const callback = () => {
2377
+ var _a2, _b2, _c2, _d;
2378
+ if ((_d = (_c2 = (_b2 = (_a2 = this.editor.options.coreExtensionOptions) == null ? void 0 : _a2.delete) == null ? void 0 : _b2.filterTransaction) == null ? void 0 : _c2.call(_b2, transaction)) != null ? _d : transaction.getMeta("y-sync$")) {
2379
+ return;
2380
+ }
2381
+ const nextTransaction = combineTransactionSteps(transaction.before, [transaction, ...appendedTransactions]);
2382
+ const changes = getChangedRanges(nextTransaction);
2383
+ changes.forEach((change) => {
2384
+ if (nextTransaction.mapping.mapResult(change.oldRange.from).deletedAfter && nextTransaction.mapping.mapResult(change.oldRange.to).deletedBefore) {
2385
+ nextTransaction.before.nodesBetween(change.oldRange.from, change.oldRange.to, (node, from) => {
2386
+ const to = from + node.nodeSize - 2;
2387
+ const isFullyWithinRange = change.oldRange.from <= from && to <= change.oldRange.to;
2388
+ this.editor.emit("delete", {
2389
+ type: "node",
2390
+ node,
2391
+ from,
2392
+ to,
2393
+ newFrom: nextTransaction.mapping.map(from),
2394
+ newTo: nextTransaction.mapping.map(to),
2395
+ deletedRange: change.oldRange,
2396
+ newRange: change.newRange,
2397
+ partial: !isFullyWithinRange,
2398
+ editor: this.editor,
2399
+ transaction,
2400
+ combinedTransform: nextTransaction
2401
+ });
2402
+ });
2403
+ }
2404
+ });
2405
+ const mapping = nextTransaction.mapping;
2406
+ nextTransaction.steps.forEach((step, index) => {
2407
+ var _a3, _b3;
2408
+ if (step instanceof transform.RemoveMarkStep) {
2409
+ const newStart = mapping.slice(index).map(step.from, -1);
2410
+ const newEnd = mapping.slice(index).map(step.to);
2411
+ const oldStart = mapping.invert().map(newStart, -1);
2412
+ const oldEnd = mapping.invert().map(newEnd);
2413
+ const foundBeforeMark = (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark));
2414
+ const foundAfterMark = (_b3 = nextTransaction.doc.nodeAt(newEnd)) == null ? void 0 : _b3.marks.some((mark) => mark.eq(step.mark));
2415
+ this.editor.emit("delete", {
2416
+ type: "mark",
2417
+ mark: step.mark,
2418
+ from: step.from,
2419
+ to: step.to,
2420
+ deletedRange: {
2421
+ from: oldStart,
2422
+ to: oldEnd
2423
+ },
2424
+ newRange: {
2425
+ from: newStart,
2426
+ to: newEnd
2427
+ },
2428
+ partial: Boolean(foundAfterMark || foundBeforeMark),
2429
+ editor: this.editor,
2430
+ transaction,
2431
+ combinedTransform: nextTransaction
2432
+ });
2433
+ }
2434
+ });
2435
+ };
2436
+ if ((_c = (_b = (_a = this.editor.options.coreExtensionOptions) == null ? void 0 : _a.delete) == null ? void 0 : _b.async) != null ? _c : true) {
2437
+ setTimeout(callback, 0);
2438
+ } else {
2439
+ callback();
2440
+ }
2441
+ }
2442
+ });
2443
+ var Drop = Extension.create({
2444
+ name: "drop",
2445
+ addProseMirrorPlugins() {
2446
+ return [
2447
+ new state.Plugin({
2448
+ key: new state.PluginKey("tiptapDrop"),
2449
+ props: {
2450
+ handleDrop: (_, e, slice, moved) => {
2451
+ this.editor.emit("drop", {
2452
+ editor: this.editor,
2453
+ event: e,
2454
+ slice,
2455
+ moved
2456
+ });
2457
+ }
2458
+ }
2459
+ })
2460
+ ];
2461
+ }
2462
+ });
2463
+ var Editable = Extension.create({
2464
+ name: "editable",
2465
+ addProseMirrorPlugins() {
2466
+ return [
2467
+ new state.Plugin({
2468
+ key: new state.PluginKey("editable"),
2469
+ props: {
2470
+ editable: () => this.editor.options.editable
2471
+ }
2472
+ })
2473
+ ];
2474
+ }
2475
+ });
2476
+ var focusEventsPluginKey = new state.PluginKey("focusEvents");
2477
+ var FocusEvents = Extension.create({
2478
+ name: "focusEvents",
2479
+ addProseMirrorPlugins() {
2480
+ const { editor } = this;
2481
+ return [
2482
+ new state.Plugin({
2483
+ key: focusEventsPluginKey,
2484
+ props: {
2485
+ handleDOMEvents: {
2486
+ focus: (view, event) => {
2487
+ editor.isFocused = true;
2488
+ const transaction = editor.state.tr.setMeta("focus", { event }).setMeta("addToHistory", false);
2489
+ view.dispatch(transaction);
2490
+ return false;
2491
+ },
2492
+ blur: (view, event) => {
2493
+ editor.isFocused = false;
2494
+ const transaction = editor.state.tr.setMeta("blur", { event }).setMeta("addToHistory", false);
2495
+ view.dispatch(transaction);
2496
+ return false;
2497
+ }
2498
+ }
2499
+ }
2500
+ })
2501
+ ];
2502
+ }
2503
+ });
2504
+ var Keymap = Extension.create({
2505
+ name: "keymap",
2506
+ addKeyboardShortcuts() {
2507
+ const handleBackspace = () => this.editor.commands.first(({ commands: commands2 }) => [
2508
+ () => commands2.undoInputRule(),
2509
+ // maybe convert first text block node to default node
2510
+ () => commands2.command(({ tr }) => {
2511
+ const { selection, doc } = tr;
2512
+ const { empty, $anchor } = selection;
2513
+ const { pos, parent } = $anchor;
2514
+ const $parentPos = $anchor.parent.isTextblock && pos > 0 ? tr.doc.resolve(pos - 1) : $anchor;
2515
+ const parentIsIsolating = $parentPos.parent.type.spec.isolating;
2516
+ const parentPos = $anchor.pos - $anchor.parentOffset;
2517
+ const isAtStart = parentIsIsolating && $parentPos.parent.childCount === 1 ? parentPos === $anchor.pos : state.Selection.atStart(doc).from === pos;
2518
+ if (!empty || !parent.type.isTextblock || parent.textContent.length || !isAtStart || isAtStart && $anchor.parent.type.name === "paragraph") {
2519
+ return false;
2520
+ }
2521
+ return commands2.clearNodes();
2522
+ }),
2523
+ () => commands2.deleteSelection(),
2524
+ () => commands2.joinBackward(),
2525
+ () => commands2.selectNodeBackward()
2526
+ ]);
2527
+ const handleDelete = () => this.editor.commands.first(({ commands: commands2 }) => [
2528
+ () => commands2.deleteSelection(),
2529
+ () => commands2.deleteCurrentNode(),
2530
+ () => commands2.joinForward(),
2531
+ () => commands2.selectNodeForward()
2532
+ ]);
2533
+ const handleEnter = () => this.editor.commands.first(({ commands: commands2 }) => [
2534
+ () => commands2.newlineInCode(),
2535
+ () => commands2.createParagraphNear(),
2536
+ () => commands2.liftEmptyBlock(),
2537
+ () => commands2.splitBlock()
2538
+ ]);
2539
+ const baseKeymap = {
2540
+ Enter: handleEnter,
2541
+ "Mod-Enter": () => this.editor.commands.exitCode(),
2542
+ Backspace: handleBackspace,
2543
+ "Mod-Backspace": handleBackspace,
2544
+ "Shift-Backspace": handleBackspace,
2545
+ Delete: handleDelete,
2546
+ "Mod-Delete": handleDelete,
2547
+ "Mod-a": () => this.editor.commands.selectAll()
2548
+ };
2549
+ const pcKeymap = {
2550
+ ...baseKeymap
2551
+ };
2552
+ const macKeymap = {
2553
+ ...baseKeymap,
2554
+ "Ctrl-h": handleBackspace,
2555
+ "Alt-Backspace": handleBackspace,
2556
+ "Ctrl-d": handleDelete,
2557
+ "Ctrl-Alt-Backspace": handleDelete,
2558
+ "Alt-Delete": handleDelete,
2559
+ "Alt-d": handleDelete,
2560
+ "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
2561
+ "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
2562
+ };
2563
+ if (isiOS() || isMacOS()) {
2564
+ return macKeymap;
2565
+ }
2566
+ return pcKeymap;
2567
+ },
2568
+ addProseMirrorPlugins() {
2569
+ return [
2570
+ // With this plugin we check if the whole document was selected and deleted.
2571
+ // In this case we will additionally call `clearNodes()` to convert e.g. a heading
2572
+ // to a paragraph if necessary.
2573
+ // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
2574
+ // with many other commands.
2575
+ new state.Plugin({
2576
+ key: new state.PluginKey("clearDocument"),
2577
+ appendTransaction: (transactions, oldState, newState) => {
2578
+ if (transactions.some((tr2) => tr2.getMeta("composition"))) {
2579
+ return;
2580
+ }
2581
+ const docChanges = transactions.some((transaction) => transaction.docChanged) && !oldState.doc.eq(newState.doc);
2582
+ const ignoreTr = transactions.some((transaction) => transaction.getMeta("preventClearDocument"));
2583
+ if (!docChanges || ignoreTr) {
2584
+ return;
2585
+ }
2586
+ const { empty, from, to } = oldState.selection;
2587
+ const allFrom = state.Selection.atStart(oldState.doc).from;
2588
+ const allEnd = state.Selection.atEnd(oldState.doc).to;
2589
+ const allWasSelected = from === allFrom && to === allEnd;
2590
+ if (empty || !allWasSelected) {
2591
+ return;
2592
+ }
2593
+ const isEmpty = isNodeEmpty(newState.doc);
2594
+ if (!isEmpty) {
2595
+ return;
2596
+ }
2597
+ const tr = newState.tr;
2598
+ const state$1 = createChainableState({
2599
+ state: newState,
2600
+ transaction: tr
2601
+ });
2602
+ const { commands: commands2 } = new CommandManager({
2603
+ editor: this.editor,
2604
+ state: state$1
2605
+ });
2606
+ commands2.clearNodes();
2607
+ if (!tr.steps.length) {
2608
+ return;
2609
+ }
2610
+ return tr;
2611
+ }
2612
+ })
2613
+ ];
2614
+ }
2615
+ });
2616
+ var Paste = Extension.create({
2617
+ name: "paste",
2618
+ addProseMirrorPlugins() {
2619
+ return [
2620
+ new state.Plugin({
2621
+ key: new state.PluginKey("tiptapPaste"),
2622
+ props: {
2623
+ handlePaste: (_view, e, slice) => {
2624
+ this.editor.emit("paste", {
2625
+ editor: this.editor,
2626
+ event: e,
2627
+ slice
2628
+ });
2629
+ }
2630
+ }
2631
+ })
2632
+ ];
2633
+ }
2634
+ });
2635
+ var Tabindex = Extension.create({
2636
+ name: "tabindex",
2637
+ addProseMirrorPlugins() {
2638
+ return [
2639
+ new state.Plugin({
2640
+ key: new state.PluginKey("tabindex"),
2641
+ props: {
2642
+ attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
2643
+ }
2644
+ })
2645
+ ];
2646
+ }
2647
+ });
2648
+ var TextDirection = Extension.create({
2649
+ name: "textDirection",
2650
+ addOptions() {
2651
+ return {
2652
+ direction: void 0
2653
+ };
2654
+ },
2655
+ addGlobalAttributes() {
2656
+ if (!this.options.direction) {
2657
+ return [];
2658
+ }
2659
+ const { nodeExtensions } = splitExtensions(this.extensions);
2660
+ return [
2661
+ {
2662
+ types: nodeExtensions.filter((extension) => extension.name !== "text").map((extension) => extension.name),
2663
+ attributes: {
2664
+ dir: {
2665
+ default: this.options.direction,
2666
+ parseHTML: (element) => {
2667
+ const dir = element.getAttribute("dir");
2668
+ if (dir && (dir === "ltr" || dir === "rtl" || dir === "auto")) {
2669
+ return dir;
2670
+ }
2671
+ return this.options.direction;
2672
+ },
2673
+ renderHTML: (attributes) => {
2674
+ if (!attributes.dir) {
2675
+ return {};
2676
+ }
2677
+ return {
2678
+ dir: attributes.dir
2679
+ };
2680
+ }
2681
+ }
2682
+ }
2683
+ }
2684
+ ];
2685
+ },
2686
+ addProseMirrorPlugins() {
2687
+ return [
2688
+ new state.Plugin({
2689
+ key: new state.PluginKey("textDirection"),
2690
+ props: {
2691
+ attributes: () => {
2692
+ const direction = this.options.direction;
2693
+ if (!direction) {
2694
+ return {};
2695
+ }
2696
+ return {
2697
+ dir: direction
2698
+ };
2699
+ }
2700
+ }
2701
+ })
2702
+ ];
2703
+ }
2704
+ });
2705
+ function textblockTypeInputRule(config) {
2706
+ return new InputRule({
2707
+ find: config.find,
2708
+ handler: ({ state: state2, range, match }) => {
2709
+ const $start = state2.doc.resolve(range.from);
2710
+ const attributes = callOrReturn(config.getAttributes, void 0, match) || {};
2711
+ if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), config.type)) {
2712
+ return null;
2713
+ }
2714
+ state2.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
2715
+ },
2716
+ undoable: config.undoable
2717
+ });
2718
+ }
2719
+ var markdown_exports = {};
2720
+ __export(markdown_exports, {
2721
+ createAtomBlockMarkdownSpec: () => createAtomBlockMarkdownSpec,
2722
+ createBlockMarkdownSpec: () => createBlockMarkdownSpec,
2723
+ createInlineMarkdownSpec: () => createInlineMarkdownSpec,
2724
+ parseAttributes: () => parseAttributes,
2725
+ parseIndentedBlocks: () => parseIndentedBlocks,
2726
+ renderNestedMarkdownContent: () => renderNestedMarkdownContent,
2727
+ serializeAttributes: () => serializeAttributes
2728
+ });
2729
+ function parseAttributes(attrString) {
2730
+ if (!(attrString == null ? void 0 : attrString.trim())) {
2731
+ return {};
2732
+ }
2733
+ const attributes = {};
2734
+ const quotedStrings = [];
2735
+ const tempString = attrString.replace(/["']([^"']*)["']/g, (match) => {
2736
+ quotedStrings.push(match);
2737
+ return `__QUOTED_${quotedStrings.length - 1}__`;
2738
+ });
2739
+ const classMatches = tempString.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);
2740
+ if (classMatches) {
2741
+ const classes = classMatches.map((match) => match.trim().slice(1));
2742
+ attributes.class = classes.join(" ");
2743
+ }
2744
+ const idMatch = tempString.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);
2745
+ if (idMatch) {
2746
+ attributes.id = idMatch[1];
2747
+ }
2748
+ const kvRegex = /([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;
2749
+ const kvMatches = Array.from(tempString.matchAll(kvRegex));
2750
+ kvMatches.forEach(([, key, quotedRef]) => {
2751
+ var _a;
2752
+ const quotedIndex = parseInt(((_a = quotedRef.match(/__QUOTED_(\d+)__/)) == null ? void 0 : _a[1]) || "0", 10);
2753
+ const quotedValue = quotedStrings[quotedIndex];
2754
+ if (quotedValue) {
2755
+ attributes[key] = quotedValue.slice(1, -1);
2756
+ }
2757
+ });
2758
+ const cleanString = tempString.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();
2759
+ if (cleanString) {
2760
+ const booleanAttrs = cleanString.split(/\s+/).filter(Boolean);
2761
+ booleanAttrs.forEach((attr) => {
2762
+ if (attr.match(/^[a-zA-Z][\w-]*$/)) {
2763
+ attributes[attr] = true;
2764
+ }
2765
+ });
2766
+ }
2767
+ return attributes;
2768
+ }
2769
+ function serializeAttributes(attributes) {
2770
+ if (!attributes || Object.keys(attributes).length === 0) {
2771
+ return "";
2772
+ }
2773
+ const parts = [];
2774
+ if (attributes.class) {
2775
+ const classes = String(attributes.class).split(/\s+/).filter(Boolean);
2776
+ classes.forEach((cls) => parts.push(`.${cls}`));
2777
+ }
2778
+ if (attributes.id) {
2779
+ parts.push(`#${attributes.id}`);
2780
+ }
2781
+ Object.entries(attributes).forEach(([key, value]) => {
2782
+ if (key === "class" || key === "id") {
2783
+ return;
2784
+ }
2785
+ if (value === true) {
2786
+ parts.push(key);
2787
+ } else if (value !== false && value != null) {
2788
+ parts.push(`${key}="${String(value)}"`);
2789
+ }
2790
+ });
2791
+ return parts.join(" ");
2792
+ }
2793
+ function createAtomBlockMarkdownSpec(options) {
2794
+ const {
2795
+ nodeName,
2796
+ name: markdownName,
2797
+ parseAttributes: parseAttributes2 = parseAttributes,
2798
+ serializeAttributes: serializeAttributes2 = serializeAttributes,
2799
+ defaultAttributes = {},
2800
+ requiredAttributes = [],
2801
+ allowedAttributes
2802
+ } = options;
2803
+ const blockName = markdownName || nodeName;
2804
+ const filterAttributes = (attrs) => {
2805
+ if (!allowedAttributes) {
2806
+ return attrs;
2807
+ }
2808
+ const filtered = {};
2809
+ allowedAttributes.forEach((key) => {
2810
+ if (key in attrs) {
2811
+ filtered[key] = attrs[key];
2812
+ }
2813
+ });
2814
+ return filtered;
2815
+ };
2816
+ return {
2817
+ parseMarkdown: (token, h2) => {
2818
+ const attrs = { ...defaultAttributes, ...token.attributes };
2819
+ return h2.createNode(nodeName, attrs, []);
2820
+ },
2821
+ markdownTokenizer: {
2822
+ name: nodeName,
2823
+ level: "block",
2824
+ start(src) {
2825
+ var _a;
2826
+ const regex = new RegExp(`^:::${blockName}(?:\\s|$)`, "m");
2827
+ const index = (_a = src.match(regex)) == null ? void 0 : _a.index;
2828
+ return index !== void 0 ? index : -1;
2829
+ },
2830
+ tokenize(src, _tokens, _lexer) {
2831
+ const regex = new RegExp(`^:::${blockName}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`);
2832
+ const match = src.match(regex);
2833
+ if (!match) {
2834
+ return void 0;
2835
+ }
2836
+ const attrString = match[1] || "";
2837
+ const attributes = parseAttributes2(attrString);
2838
+ const missingRequired = requiredAttributes.find((required) => !(required in attributes));
2839
+ if (missingRequired) {
2840
+ return void 0;
2841
+ }
2842
+ return {
2843
+ type: nodeName,
2844
+ raw: match[0],
2845
+ attributes
2846
+ };
2847
+ }
2848
+ },
2849
+ renderMarkdown: (node) => {
2850
+ const filteredAttrs = filterAttributes(node.attrs || {});
2851
+ const attrs = serializeAttributes2(filteredAttrs);
2852
+ const attrString = attrs ? ` {${attrs}}` : "";
2853
+ return `:::${blockName}${attrString} :::`;
2854
+ }
2855
+ };
2856
+ }
2857
+ function createBlockMarkdownSpec(options) {
2858
+ const {
2859
+ nodeName,
2860
+ name: markdownName,
2861
+ getContent,
2862
+ parseAttributes: parseAttributes2 = parseAttributes,
2863
+ serializeAttributes: serializeAttributes2 = serializeAttributes,
2864
+ defaultAttributes = {},
2865
+ content = "block",
2866
+ allowedAttributes
2867
+ } = options;
2868
+ const blockName = markdownName || nodeName;
2869
+ const filterAttributes = (attrs) => {
2870
+ if (!allowedAttributes) {
2871
+ return attrs;
2872
+ }
2873
+ const filtered = {};
2874
+ allowedAttributes.forEach((key) => {
2875
+ if (key in attrs) {
2876
+ filtered[key] = attrs[key];
2877
+ }
2878
+ });
2879
+ return filtered;
2880
+ };
2881
+ return {
2882
+ parseMarkdown: (token, h2) => {
2883
+ let nodeContent;
2884
+ if (getContent) {
2885
+ const contentResult = getContent(token);
2886
+ nodeContent = typeof contentResult === "string" ? [{ type: "text", text: contentResult }] : contentResult;
2887
+ } else if (content === "block") {
2888
+ nodeContent = h2.parseChildren(token.tokens || []);
2889
+ } else {
2890
+ nodeContent = h2.parseInline(token.tokens || []);
2891
+ }
2892
+ const attrs = { ...defaultAttributes, ...token.attributes };
2893
+ return h2.createNode(nodeName, attrs, nodeContent);
2894
+ },
2895
+ markdownTokenizer: {
2896
+ name: nodeName,
2897
+ level: "block",
2898
+ start(src) {
2899
+ var _a;
2900
+ const regex = new RegExp(`^:::${blockName}`, "m");
2901
+ const index = (_a = src.match(regex)) == null ? void 0 : _a.index;
2902
+ return index !== void 0 ? index : -1;
2903
+ },
2904
+ tokenize(src, _tokens, lexer) {
2905
+ var _a;
2906
+ const openingRegex = new RegExp(`^:::${blockName}(?:\\s+\\{([^}]*)\\})?\\s*\\n`);
2907
+ const openingMatch = src.match(openingRegex);
2908
+ if (!openingMatch) {
2909
+ return void 0;
2910
+ }
2911
+ const [openingTag, attrString = ""] = openingMatch;
2912
+ const attributes = parseAttributes2(attrString);
2913
+ let level = 1;
2914
+ const position = openingTag.length;
2915
+ let matchedContent = "";
2916
+ const blockPattern = /^:::([\w-]*)(\s.*)?/gm;
2917
+ const remaining = src.slice(position);
2918
+ blockPattern.lastIndex = 0;
2919
+ for (; ; ) {
2920
+ const match = blockPattern.exec(remaining);
2921
+ if (match === null) {
2922
+ break;
2923
+ }
2924
+ const matchPos = match.index;
2925
+ const blockType = match[1];
2926
+ if ((_a = match[2]) == null ? void 0 : _a.endsWith(":::")) {
2927
+ continue;
2928
+ }
2929
+ if (blockType) {
2930
+ level += 1;
2931
+ } else {
2932
+ level -= 1;
2933
+ if (level === 0) {
2934
+ const rawContent = remaining.slice(0, matchPos);
2935
+ matchedContent = rawContent.trim();
2936
+ const fullMatch = src.slice(0, position + matchPos + match[0].length);
2937
+ let contentTokens = [];
2938
+ if (matchedContent) {
2939
+ if (content === "block") {
2940
+ contentTokens = lexer.blockTokens(rawContent);
2941
+ contentTokens.forEach((token) => {
2942
+ if (token.text && (!token.tokens || token.tokens.length === 0)) {
2943
+ token.tokens = lexer.inlineTokens(token.text);
2944
+ }
2945
+ });
2946
+ while (contentTokens.length > 0) {
2947
+ const lastToken = contentTokens[contentTokens.length - 1];
2948
+ if (lastToken.type === "paragraph" && (!lastToken.text || lastToken.text.trim() === "")) {
2949
+ contentTokens.pop();
2950
+ } else {
2951
+ break;
2952
+ }
2953
+ }
2954
+ } else {
2955
+ contentTokens = lexer.inlineTokens(matchedContent);
2956
+ }
2957
+ }
2958
+ return {
2959
+ type: nodeName,
2960
+ raw: fullMatch,
2961
+ attributes,
2962
+ content: matchedContent,
2963
+ tokens: contentTokens
2964
+ };
2965
+ }
2966
+ }
2967
+ }
2968
+ return void 0;
2969
+ }
2970
+ },
2971
+ renderMarkdown: (node, h2) => {
2972
+ const filteredAttrs = filterAttributes(node.attrs || {});
2973
+ const attrs = serializeAttributes2(filteredAttrs);
2974
+ const attrString = attrs ? ` {${attrs}}` : "";
2975
+ const renderedContent = h2.renderChildren(node.content || [], "\n\n");
2976
+ return `:::${blockName}${attrString}
2977
+
2978
+ ${renderedContent}
2979
+
2980
+ :::`;
2981
+ }
2982
+ };
2983
+ }
2984
+ function parseShortcodeAttributes(attrString) {
2985
+ if (!attrString.trim()) {
2986
+ return {};
2987
+ }
2988
+ const attributes = {};
2989
+ const regex = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
2990
+ let match = regex.exec(attrString);
2991
+ while (match !== null) {
2992
+ const [, key, doubleQuoted, singleQuoted] = match;
2993
+ attributes[key] = doubleQuoted || singleQuoted;
2994
+ match = regex.exec(attrString);
2995
+ }
2996
+ return attributes;
2997
+ }
2998
+ function serializeShortcodeAttributes(attrs) {
2999
+ return Object.entries(attrs).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => `${key}="${value}"`).join(" ");
3000
+ }
3001
+ function createInlineMarkdownSpec(options) {
3002
+ const {
3003
+ nodeName,
3004
+ name: shortcodeName,
3005
+ getContent,
3006
+ parseAttributes: parseAttributes2 = parseShortcodeAttributes,
3007
+ serializeAttributes: serializeAttributes2 = serializeShortcodeAttributes,
3008
+ defaultAttributes = {},
3009
+ selfClosing = false,
3010
+ allowedAttributes
3011
+ } = options;
3012
+ const shortcode = shortcodeName || nodeName;
3013
+ const filterAttributes = (attrs) => {
3014
+ if (!allowedAttributes) {
3015
+ return attrs;
3016
+ }
3017
+ const filtered = {};
3018
+ allowedAttributes.forEach((attr) => {
3019
+ const attrName = typeof attr === "string" ? attr : attr.name;
3020
+ const skipIfDefault = typeof attr === "string" ? void 0 : attr.skipIfDefault;
3021
+ if (attrName in attrs) {
3022
+ const value = attrs[attrName];
3023
+ if (skipIfDefault !== void 0 && value === skipIfDefault) {
3024
+ return;
3025
+ }
3026
+ filtered[attrName] = value;
3027
+ }
3028
+ });
3029
+ return filtered;
3030
+ };
3031
+ const escapedShortcode = shortcode.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3032
+ return {
3033
+ parseMarkdown: (token, h2) => {
3034
+ const attrs = { ...defaultAttributes, ...token.attributes };
3035
+ if (selfClosing) {
3036
+ return h2.createNode(nodeName, attrs);
3037
+ }
3038
+ const content = getContent ? getContent(token) : token.content || "";
3039
+ if (content) {
3040
+ return h2.createNode(nodeName, attrs, [h2.createTextNode(content)]);
3041
+ }
3042
+ return h2.createNode(nodeName, attrs, []);
3043
+ },
3044
+ markdownTokenizer: {
3045
+ name: nodeName,
3046
+ level: "inline",
3047
+ start(src) {
3048
+ const startPattern = selfClosing ? new RegExp(`\\[${escapedShortcode}\\s*[^\\]]*\\]`) : new RegExp(`\\[${escapedShortcode}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${escapedShortcode}\\]`);
3049
+ const match = src.match(startPattern);
3050
+ const index = match == null ? void 0 : match.index;
3051
+ return index !== void 0 ? index : -1;
3052
+ },
3053
+ tokenize(src, _tokens, _lexer) {
3054
+ const tokenPattern = selfClosing ? new RegExp(`^\\[${escapedShortcode}\\s*([^\\]]*)\\]`) : new RegExp(`^\\[${escapedShortcode}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${escapedShortcode}\\]`);
3055
+ const match = src.match(tokenPattern);
3056
+ if (!match) {
3057
+ return void 0;
3058
+ }
3059
+ let content = "";
3060
+ let attrString = "";
3061
+ if (selfClosing) {
3062
+ const [, attrs] = match;
3063
+ attrString = attrs;
3064
+ } else {
3065
+ const [, attrs, contentMatch] = match;
3066
+ attrString = attrs;
3067
+ content = contentMatch || "";
3068
+ }
3069
+ const attributes = parseAttributes2(attrString.trim());
3070
+ return {
3071
+ type: nodeName,
3072
+ raw: match[0],
3073
+ content: content.trim(),
3074
+ attributes
3075
+ };
3076
+ }
3077
+ },
3078
+ renderMarkdown: (node) => {
3079
+ let content = "";
3080
+ if (getContent) {
3081
+ content = getContent(node);
3082
+ } else if (node.content && node.content.length > 0) {
3083
+ content = node.content.filter((child) => child.type === "text").map((child) => child.text).join("");
3084
+ }
3085
+ const filteredAttrs = filterAttributes(node.attrs || {});
3086
+ const attrs = serializeAttributes2(filteredAttrs);
3087
+ const attrString = attrs ? ` ${attrs}` : "";
3088
+ if (selfClosing) {
3089
+ return `[${shortcode}${attrString}]`;
3090
+ }
3091
+ return `[${shortcode}${attrString}]${content}[/${shortcode}]`;
3092
+ }
3093
+ };
3094
+ }
3095
+ function parseIndentedBlocks(src, config, lexer) {
3096
+ var _a, _b, _c, _d;
3097
+ const lines = src.split("\n");
3098
+ const items = [];
3099
+ let totalRaw = "";
3100
+ let i = 0;
3101
+ const baseIndentSize = config.baseIndentSize || 2;
3102
+ while (i < lines.length) {
3103
+ const currentLine = lines[i];
3104
+ const itemMatch = currentLine.match(config.itemPattern);
3105
+ if (!itemMatch) {
3106
+ if (items.length > 0) {
3107
+ break;
3108
+ } else if (currentLine.trim() === "") {
3109
+ i += 1;
3110
+ totalRaw = `${totalRaw}${currentLine}
3111
+ `;
3112
+ continue;
3113
+ } else {
3114
+ return void 0;
3115
+ }
3116
+ }
3117
+ const itemData = config.extractItemData(itemMatch);
3118
+ const { indentLevel, mainContent } = itemData;
3119
+ totalRaw = `${totalRaw}${currentLine}
3120
+ `;
3121
+ const itemContent = [mainContent];
3122
+ i += 1;
3123
+ while (i < lines.length) {
3124
+ const nextLine = lines[i];
3125
+ if (nextLine.trim() === "") {
3126
+ const nextNonEmptyIndex = lines.slice(i + 1).findIndex((l) => l.trim() !== "");
3127
+ if (nextNonEmptyIndex === -1) {
3128
+ break;
3129
+ }
3130
+ const nextNonEmpty = lines[i + 1 + nextNonEmptyIndex];
3131
+ const nextIndent2 = ((_b = (_a = nextNonEmpty.match(/^(\s*)/)) == null ? void 0 : _a[1]) == null ? void 0 : _b.length) || 0;
3132
+ if (nextIndent2 > indentLevel) {
3133
+ itemContent.push(nextLine);
3134
+ totalRaw = `${totalRaw}${nextLine}
3135
+ `;
3136
+ i += 1;
3137
+ continue;
3138
+ } else {
3139
+ break;
3140
+ }
3141
+ }
3142
+ const nextIndent = ((_d = (_c = nextLine.match(/^(\s*)/)) == null ? void 0 : _c[1]) == null ? void 0 : _d.length) || 0;
3143
+ if (nextIndent > indentLevel) {
3144
+ itemContent.push(nextLine);
3145
+ totalRaw = `${totalRaw}${nextLine}
3146
+ `;
3147
+ i += 1;
3148
+ } else {
3149
+ break;
3150
+ }
3151
+ }
3152
+ let nestedTokens;
3153
+ const nestedContent = itemContent.slice(1);
3154
+ if (nestedContent.length > 0) {
3155
+ const dedentedNested = nestedContent.map((nestedLine) => nestedLine.slice(indentLevel + baseIndentSize)).join("\n");
3156
+ if (dedentedNested.trim()) {
3157
+ if (config.customNestedParser) {
3158
+ nestedTokens = config.customNestedParser(dedentedNested);
3159
+ } else {
3160
+ nestedTokens = lexer.blockTokens(dedentedNested);
3161
+ }
3162
+ }
3163
+ }
3164
+ const token = config.createToken(itemData, nestedTokens);
3165
+ items.push(token);
3166
+ }
3167
+ if (items.length === 0) {
3168
+ return void 0;
3169
+ }
3170
+ return {
3171
+ items,
3172
+ raw: totalRaw
3173
+ };
3174
+ }
3175
+ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
3176
+ if (!node || !Array.isArray(node.content)) {
3177
+ return "";
3178
+ }
3179
+ const prefix = typeof prefixOrGenerator === "function" ? prefixOrGenerator(ctx) : prefixOrGenerator;
3180
+ const [content, ...children] = node.content;
3181
+ const mainContent = h2.renderChildren([content]);
3182
+ const output = [`${prefix}${mainContent}`];
3183
+ if (children && children.length > 0) {
3184
+ children.forEach((child) => {
3185
+ const childContent = h2.renderChildren([child]);
3186
+ if (childContent) {
3187
+ const indentedChild = childContent.split("\n").map((line) => line ? h2.indent(line) : "").join("\n");
3188
+ output.push(indentedChild);
3189
+ }
3190
+ });
3191
+ }
3192
+ return output.join("\n");
3193
+ }
3194
+ var Node3 = class _Node extends Extendable {
3195
+ constructor() {
3196
+ super(...arguments);
3197
+ this.type = "node";
3198
+ }
3199
+ /**
3200
+ * Create a new Node instance
3201
+ * @param config - Node configuration object or a function that returns a configuration object
3202
+ */
3203
+ static create(config = {}) {
3204
+ const resolvedConfig = typeof config === "function" ? config() : config;
3205
+ return new _Node(resolvedConfig);
3206
+ }
3207
+ configure(options) {
3208
+ return super.configure(options);
3209
+ }
3210
+ extend(extendedConfig) {
3211
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
3212
+ return super.extend(resolvedConfig);
3213
+ }
3214
+ };
3215
+ function tiptapContent(text) {
3216
+ return {
3217
+ type: "doc",
3218
+ content: [
3219
+ {
3220
+ type: "paragraph",
3221
+ content: [
3222
+ {
3223
+ type: "text",
3224
+ text
3225
+ }
3226
+ ]
3227
+ }
3228
+ ]
3229
+ };
3230
+ }
3231
+ function parseJSONContent(value, defaultValue) {
3232
+ if (!value) {
3233
+ return tiptapContent(defaultValue);
3234
+ }
3235
+ try {
3236
+ return typeof value === "string" ? JSON.parse(value) : value;
3237
+ } catch (e) {
3238
+ console.error("Failed to parse JSON content:", e);
3239
+ return tiptapContent(`
3240
+ This component's content is malformed. Please change it or remove this component.
3241
+ Original content: ${JSON.stringify(value)}
3242
+ `);
3243
+ }
3244
+ }
3245
+ function useTiptapEditor(name, defaultValue = "", extensions = []) {
3246
+ const field = admin.useField(name);
3247
+ const editor = react.useEditor({
3248
+ extensions,
3249
+ content: parseJSONContent(field.value, defaultValue),
3250
+ onUpdate: ({ editor: editor2 }) => {
3251
+ const json = editor2.getJSON();
3252
+ field.onChange(name, JSON.stringify(json));
3253
+ }
3254
+ });
3255
+ return { editor, field };
3256
+ }
3257
+ function toolbarButton(key, {
3258
+ onClick,
3259
+ icon,
3260
+ active,
3261
+ disabled,
3262
+ tooltip,
3263
+ marginLeft,
3264
+ hidden
3265
+ }) {
3266
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: tooltip, children: /* @__PURE__ */ jsxRuntime.jsx(
3267
+ designSystem.Button,
3268
+ {
3269
+ onClick,
3270
+ variant: "tertiary",
3271
+ size: "S",
3272
+ paddingLeft: 2,
3273
+ paddingRight: 2,
3274
+ marginLeft: marginLeft ?? 1,
3275
+ disabled,
3276
+ style: {
3277
+ color: active ? "black" : void 0,
3278
+ backgroundColor: active ? "#d9d8ff" : void 0,
3279
+ display: hidden ? "none" : void 0
3280
+ },
3281
+ children: icon
3282
+ }
3283
+ ) }, key);
3284
+ }
3285
+ function spacer(width) {
3286
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: width + "px" } });
3287
+ }
3288
+ const AccentCursiveMark = Mark.create({
3289
+ name: "accentCursive",
3290
+ addAttributes() {
3291
+ return {
3292
+ class: {
3293
+ default: "accent-cursive"
3294
+ }
3295
+ };
3296
+ },
3297
+ parseHTML() {
3298
+ return [
3299
+ {
3300
+ tag: "span.accent-cursive"
3301
+ }
3302
+ ];
3303
+ },
3304
+ renderHTML({ HTMLAttributes }) {
3305
+ return ["span", { ...HTMLAttributes, class: "accent-cursive" }, 0];
3306
+ }
3307
+ });
3308
+ const OnlyCursiveMark = Mark.create({
3309
+ name: "onlyCursive",
3310
+ addAttributes() {
3311
+ return {
3312
+ class: {
3313
+ default: "only-cursive"
3314
+ }
3315
+ };
3316
+ },
3317
+ parseHTML() {
3318
+ return [
3319
+ {
3320
+ tag: "span.only-cursive"
3321
+ }
3322
+ ];
3323
+ },
3324
+ renderHTML({ HTMLAttributes }) {
3325
+ return ["span", { ...HTMLAttributes, class: "only-cursive" }, 0];
3326
+ }
3327
+ });
3328
+ function useCursiveMark(editor, markName, props = { disabled: false }) {
3329
+ const editorState = react.useEditorState({
3330
+ editor,
3331
+ selector: (ctx) => {
3332
+ return {
3333
+ isActive: ctx.editor.isActive(markName) ?? false,
3334
+ canToggle: ctx.editor.can().chain().toggleMark(markName).run() ?? false
3335
+ };
3336
+ }
3337
+ });
3338
+ const toggleMark2 = () => {
3339
+ editor?.chain().focus().toggleMark(markName).run();
3340
+ };
3341
+ const getButtonConfig = () => {
3342
+ const configs = {
3343
+ accentCursive: {
3344
+ color: "var(--color-accent-dark, #ae8f5b)",
3345
+ tooltip: "Accent Cursive"
3346
+ },
3347
+ onlyCursive: {
3348
+ color: "var(--color-primary-default)",
3349
+ tooltip: "Only Cursive"
3350
+ }
3351
+ };
3352
+ return configs[markName];
3353
+ };
3354
+ const config = getButtonConfig();
3355
+ return {
3356
+ button: toolbarButton(markName, {
3357
+ onClick: toggleMark2,
3358
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Italic, { style: { color: config.color } }),
3359
+ active: editorState.isActive,
3360
+ disabled: props.disabled || !editor || !editorState.canToggle,
3361
+ tooltip: config.tooltip
3362
+ })
3363
+ };
3364
+ }
3365
+ function useAccentCursive(editor, props) {
3366
+ return useCursiveMark(editor, "accentCursive", props);
3367
+ }
3368
+ exports.AccentCursiveMark = AccentCursiveMark;
3369
+ exports.BaseTiptapInput = BaseTiptapInput;
3370
+ exports.Extension = Extension;
3371
+ exports.Node3 = Node3;
3372
+ exports.OnlyCursiveMark = OnlyCursiveMark;
3373
+ exports.callOrReturn = callOrReturn;
3374
+ exports.getExtensionField = getExtensionField;
3375
+ exports.isNodeEmpty = isNodeEmpty;
3376
+ exports.isNodeSelection = isNodeSelection;
3377
+ exports.mergeAttributes = mergeAttributes;
3378
+ exports.spacer = spacer;
3379
+ exports.textblockTypeInputRule = textblockTypeInputRule;
3380
+ exports.toolbarButton = toolbarButton;
3381
+ exports.useAccentCursive = useAccentCursive;
3382
+ exports.useCursiveMark = useCursiveMark;
3383
+ exports.useTiptapEditor = useTiptapEditor;
3384
+ //# sourceMappingURL=AccentCursive-D6sTlhub.js.map