tuikit-atomicx-vue3 4.5.1 → 4.5.2

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 (122) hide show
  1. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-jPzZ5INK.js → MessageInput.vue_vue_type_script_setup_true_lang-3RVYOdkv.js} +38 -38
  2. package/dist/{PopoverPortal-DghpKKm8.js → PopoverPortal-DV6zFXcf.js} +3 -3
  3. package/dist/{PopoverTrigger-BajjNkGO.js → PopoverTrigger-DIjW4PKa.js} +4 -4
  4. package/dist/{PopperContent-SLoFuK7k.js → PopperContent-D__dbwpA.js} +1 -1
  5. package/dist/{Teleport-DFrneqLM.js → Teleport-98QrIYDI.js} +278 -268
  6. package/dist/baseComp/Modal/Modal.js +3 -3
  7. package/dist/components/AudioSettingPanel/index.js +14 -14
  8. package/dist/components/BarrageInput/EmojiPicker/EmojiPicker.js +2 -2
  9. package/dist/components/BarrageInput/TextEditor/CharacterCountExtension.js +1 -1
  10. package/dist/components/BarrageInput/TextEditor/EditorCore.js +4 -4
  11. package/dist/components/ConversationList/ConversationActions/ConversationActions.js +53 -50
  12. package/dist/components/ConversationList/ConversationActions/ConversationActions.vue.d.ts +2 -0
  13. package/dist/components/ConversationList/ConversationCreate/ConversationCreate.js +25 -25
  14. package/dist/components/ConversationList/ConversationList.vue.d.ts +16 -0
  15. package/dist/components/ConversationList/ConversationPreview/ConversationPreview.vue.d.ts +16 -0
  16. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewAbstract.js +18 -18
  17. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewTimestamp.js +13 -13
  18. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewTitle.js +11 -11
  19. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.js +84 -75
  20. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue.d.ts +4 -0
  21. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUnread.js +14 -14
  22. package/dist/components/ConversationList/i18n/en-US.d.ts +1 -0
  23. package/dist/components/ConversationList/i18n/en-US.js +2 -1
  24. package/dist/components/ConversationList/i18n/zh-CN.d.ts +1 -0
  25. package/dist/components/ConversationList/i18n/zh-CN.js +2 -1
  26. package/dist/components/ConversationList/index.d.ts +48 -0
  27. package/dist/components/LiveScenePanel/index.js +9 -10
  28. package/dist/components/MessageInput/AttachmentPicker/index.js +2 -2
  29. package/dist/components/MessageInput/EmojiPicker/EmojiPicker.js +2 -2
  30. package/dist/components/MessageInput/MessageInput.js +1 -1
  31. package/dist/components/MessageInput/TextEditor/EditorCore.js +1 -1
  32. package/dist/components/MessageInput/TextEditor/extensions/MentionSuggestion.js +3 -3
  33. package/dist/components/MessageInput/TextEditor/extensions/characterCountExtension.js +1 -1
  34. package/dist/components/MessageInput/TextEditor/extensions/emojiExtension.js +1 -1
  35. package/dist/components/MessageInput/TextEditor/extensions/enterKeyExtension.js +1 -1
  36. package/dist/components/MessageInput/TextEditor/extensions/imageExtension.js +2 -2
  37. package/dist/components/MessageInput/TextEditor/extensions/mentionExtension.js +2 -2
  38. package/dist/components/MessageInput/TextEditor/index.js +1 -1
  39. package/dist/components/MessageInput/index.js +1 -1
  40. package/dist/components/MessageList/Message/MessageLayout/MessageActionDropdown/MessageActionDropdown.js +3 -3
  41. package/dist/components/MessageList/Message/MessageLayout/MessageMeta/MessageMeta.js +37 -28
  42. package/dist/components/MessageList/MessageList.js +77 -67
  43. package/dist/components/ScheduleRoomPanel/RoomDetail.js +22 -22
  44. package/dist/components/ScheduleRoomPanel/RoomEdit.js +1 -1
  45. package/dist/components/ScheduleRoomPanel/RoomShare.js +4 -4
  46. package/dist/components/ScheduleRoomPanel/ScheduleRoomPanel.js +1 -1
  47. package/dist/components/ScheduleRoomPanel/ScheduledRoomList.js +1 -1
  48. package/dist/components/UIKitModal/chatErrorModal/chatErrorModal.d.ts +72 -0
  49. package/dist/components/UIKitModal/chatErrorModal/chatErrorModal.js +95 -0
  50. package/dist/components/UIKitModal/chatErrorModal/i18n/en-US/index.d.ts +40 -0
  51. package/dist/components/UIKitModal/chatErrorModal/i18n/en-US/index.js +51 -0
  52. package/dist/components/UIKitModal/chatErrorModal/i18n/index.d.ts +4 -0
  53. package/dist/components/UIKitModal/chatErrorModal/i18n/index.js +6 -0
  54. package/dist/components/UIKitModal/chatErrorModal/i18n/zh-CN/index.d.ts +40 -0
  55. package/dist/components/UIKitModal/chatErrorModal/i18n/zh-CN/index.js +51 -0
  56. package/dist/components/UIKitModal/chatErrorModal/index.d.ts +3 -0
  57. package/dist/components/UIKitModal/chatErrorModal/index.js +11 -0
  58. package/dist/components/VideoSettingPanel/index.js +1 -1
  59. package/dist/hooks/useReadReceipt/useReadReceipt.js +44 -41
  60. package/dist/index-CTthrJb2.js +1461 -0
  61. package/dist/{index-CzCDLp99.js → index-DXC5bPY4.js} +32 -32
  62. package/dist/{index-C8Jw_xE4.js → index-DuAffztD.js} +1731 -1648
  63. package/dist/{index-CiYL_XsE.js → index-hHVD-MG2.js} +1 -1
  64. package/dist/index.js +59 -58
  65. package/dist/states/GroupSettingState/GroupSettingState.js +109 -102
  66. package/dist/states/LoginState.js +43 -43
  67. package/dist/states/MessageInputState/MessageInputState.js +75 -78
  68. package/dist/states/MessageListState/MessageListState.js +26 -23
  69. package/dist/states/RoomParticipantState/index.js +83 -24
  70. package/dist/states/RoomParticipantState/participantEventManager.d.ts +2 -2
  71. package/dist/states/RoomParticipantState/participantEventManager.js +217 -205
  72. package/dist/states/RoomParticipantState/participantManager.d.ts +4 -0
  73. package/dist/states/RoomParticipantState/participantManager.js +159 -127
  74. package/dist/states/RoomState/callManager.d.ts +3 -3
  75. package/dist/states/RoomState/callManager.js +20 -20
  76. package/dist/states/RoomState/common.d.ts +3 -2
  77. package/dist/states/RoomState/common.js +34 -24
  78. package/dist/states/RoomState/roomManager.d.ts +0 -1
  79. package/dist/states/RoomState/roomManager.js +21 -27
  80. package/dist/states/RoomState/scheduleManager.js +2 -2
  81. package/dist/styles/index.css +1 -1
  82. package/dist/subEntry/chat/chat.d.ts +48 -0
  83. package/dist/subEntry/live/index.js +46 -45
  84. package/dist/subEntry/room/index.js +39 -38
  85. package/dist/types/beauty.d.ts +20 -0
  86. package/dist/types/index.js +37 -36
  87. package/dist/types/participant.d.ts +2 -0
  88. package/dist/types/room.d.ts +45 -1
  89. package/dist/types/room.js +4 -3
  90. package/dist/{useId-D5WE76CM.js → useId-B1VwPJLm.js} +1 -1
  91. package/dist/utils/call.js +77 -71
  92. package/dist/{utils-CttDpxqz.js → utils-BU8IkP_V.js} +1 -1
  93. package/package.json +5 -6
  94. package/src/components/AudioSettingPanel/index.vue +4 -5
  95. package/src/components/ConversationList/ConversationActions/ConversationActions.vue +7 -1
  96. package/src/components/ConversationList/ConversationCreate/ConversationCreate.vue +5 -1
  97. package/src/components/ConversationList/ConversationList.vue +0 -1
  98. package/src/components/ConversationList/ConversationPreview/ConversationPreview.scss +2 -2
  99. package/src/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue +15 -0
  100. package/src/components/ConversationList/i18n/en-US.ts +1 -0
  101. package/src/components/ConversationList/i18n/zh-CN.ts +1 -0
  102. package/src/components/LiveScenePanel/index.vue +0 -1
  103. package/src/components/MessageInput/MessageInput.module.scss +1 -0
  104. package/src/components/MessageList/Message/MessageLayout/MessageMeta/MessageMeta.vue +12 -3
  105. package/src/components/MessageList/MessageList.vue +14 -0
  106. package/src/components/ScheduleRoomPanel/RoomDetail.vue +1 -0
  107. package/src/components/ScheduleRoomPanel/RoomEdit.vue +2 -1
  108. package/src/components/ScheduleRoomPanel/RoomShare.vue +1 -0
  109. package/src/components/ScheduleRoomPanel/ScheduleRoomPanel.vue +1 -0
  110. package/src/components/ScheduleRoomPanel/ScheduledRoomList.vue +1 -0
  111. package/src/components/UIKitModal/chatErrorModal/chatErrorModal.ts +205 -0
  112. package/src/components/UIKitModal/chatErrorModal/i18n/en-US/index.ts +56 -0
  113. package/src/components/UIKitModal/chatErrorModal/i18n/index.ts +4 -0
  114. package/src/components/UIKitModal/chatErrorModal/i18n/zh-CN/index.ts +56 -0
  115. package/src/components/UIKitModal/chatErrorModal/index.ts +16 -0
  116. package/src/components/VideoSettingPanel/index.vue +1 -0
  117. package/src/hooks/useReadReceipt/useReadReceipt.ts +5 -4
  118. package/src/types/beauty.ts +20 -0
  119. package/src/types/participant.ts +3 -0
  120. package/src/types/room.ts +49 -1
  121. package/src/utils/call.ts +8 -0
  122. package/dist/index-BvFYOUyz.js +0 -2936
@@ -1,2936 +0,0 @@
1
- import { E as Je, P as I, a as P, i as qe, b as Oe, D as Le, f as Ue, d as pe, g as V, S as L, w as Xe, h as Ye, F as j, j as fe, T as x, k as Z, s as Qe, l as Me, o as Ze, p as et, q as tt, r as nt, t as rt, A as st, u as ot, v as it, x as at, y as lt, z as ct, B as dt, C as ut, G as Pe, H as pt, I as ft, J as ht, K as mt, L as gt, M as yt, O as kt, c as Mt, Q as bt, R as ie, U as vt, V as wt, W as xt, X as Ct, Y as At } from "./index-C8Jw_xE4.js";
2
- const ts = Je.create({
3
- name: "placeholder",
4
- addOptions() {
5
- return {
6
- emptyEditorClass: "is-editor-empty",
7
- emptyNodeClass: "is-empty",
8
- placeholder: "Write something …",
9
- showOnlyWhenEditable: !0,
10
- showOnlyCurrent: !0,
11
- includeChildren: !1
12
- };
13
- },
14
- addProseMirrorPlugins() {
15
- return [
16
- new I({
17
- key: new P("placeholder"),
18
- props: {
19
- decorations: ({ doc: t, selection: e }) => {
20
- const n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: r } = e, s = [];
21
- if (!n)
22
- return null;
23
- const o = this.editor.isEmpty;
24
- return t.descendants((i, a) => {
25
- const l = r >= a && r <= a + i.nodeSize, c = !i.isLeaf && qe(i);
26
- if ((l || !this.options.showOnlyCurrent) && c) {
27
- const u = [this.options.emptyNodeClass];
28
- o && u.push(this.options.emptyEditorClass);
29
- const d = Oe.node(a, a + i.nodeSize, {
30
- class: u.join(" "),
31
- "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
32
- editor: this.editor,
33
- node: i,
34
- pos: a,
35
- hasAnchor: l
36
- }) : this.options.placeholder
37
- });
38
- s.push(d);
39
- }
40
- return this.options.includeChildren;
41
- }), Le.create(t, s);
42
- }
43
- }
44
- })
45
- ];
46
- }
47
- });
48
- function $e(t) {
49
- const { state: e, transaction: n } = t;
50
- let { selection: r } = n, { doc: s } = n, { storedMarks: o } = n;
51
- return {
52
- ...e,
53
- apply: e.apply.bind(e),
54
- applyTransaction: e.applyTransaction.bind(e),
55
- plugins: e.plugins,
56
- schema: e.schema,
57
- reconfigure: e.reconfigure.bind(e),
58
- toJSON: e.toJSON.bind(e),
59
- get storedMarks() {
60
- return o;
61
- },
62
- get selection() {
63
- return r;
64
- },
65
- get doc() {
66
- return s;
67
- },
68
- get tr() {
69
- return r = n.selection, s = n.doc, o = n.storedMarks, n;
70
- }
71
- };
72
- }
73
- class St {
74
- constructor(e) {
75
- this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
76
- }
77
- get hasCustomState() {
78
- return !!this.customState;
79
- }
80
- get state() {
81
- return this.customState || this.editor.state;
82
- }
83
- get commands() {
84
- const { rawCommands: e, editor: n, state: r } = this, { view: s } = n, { tr: o } = r, i = this.buildProps(o);
85
- return Object.fromEntries(Object.entries(e).map(([a, l]) => [a, (...u) => {
86
- const d = l(...u)(i);
87
- return !o.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(o), d;
88
- }]));
89
- }
90
- get chain() {
91
- return () => this.createChain();
92
- }
93
- get can() {
94
- return () => this.createCan();
95
- }
96
- createChain(e, n = !0) {
97
- const { rawCommands: r, editor: s, state: o } = this, { view: i } = s, a = [], l = !!e, c = e || o.tr, u = () => (!l && n && !c.getMeta("preventDispatch") && !this.hasCustomState && i.dispatch(c), a.every((p) => p === !0)), d = {
98
- ...Object.fromEntries(Object.entries(r).map(([p, f]) => [p, (...h) => {
99
- const m = this.buildProps(c, n), y = f(...h)(m);
100
- return a.push(y), d;
101
- }])),
102
- run: u
103
- };
104
- return d;
105
- }
106
- createCan(e) {
107
- const { rawCommands: n, state: r } = this, s = !1, o = e || r.tr, i = this.buildProps(o, s);
108
- return {
109
- ...Object.fromEntries(Object.entries(n).map(([l, c]) => [l, (...u) => c(...u)({ ...i, dispatch: void 0 })])),
110
- chain: () => this.createChain(o, s)
111
- };
112
- }
113
- buildProps(e, n = !0) {
114
- const { rawCommands: r, editor: s, state: o } = this, { view: i } = s, a = {
115
- tr: e,
116
- editor: s,
117
- view: i,
118
- state: $e({
119
- state: o,
120
- transaction: e
121
- }),
122
- dispatch: n ? () => {
123
- } : void 0,
124
- chain: () => this.createChain(e, n),
125
- can: () => this.createCan(e),
126
- get commands() {
127
- return Object.fromEntries(Object.entries(r).map(([l, c]) => [l, (...u) => c(...u)(a)]));
128
- }
129
- };
130
- return a;
131
- }
132
- }
133
- function w(t, e, n) {
134
- return t.config[e] === void 0 && t.parent ? w(t.parent, e, n) : typeof t.config[e] == "function" ? t.config[e].bind({
135
- ...n,
136
- parent: t.parent ? w(t.parent, e, n) : null
137
- }) : t.config[e];
138
- }
139
- function Tt(t) {
140
- const e = t.filter((s) => s.type === "extension"), n = t.filter((s) => s.type === "node"), r = t.filter((s) => s.type === "mark");
141
- return {
142
- baseExtensions: e,
143
- nodeExtensions: n,
144
- markExtensions: r
145
- };
146
- }
147
- function C(t, e) {
148
- if (typeof t == "string") {
149
- if (!e.nodes[t])
150
- throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);
151
- return e.nodes[t];
152
- }
153
- return t;
154
- }
155
- function S(...t) {
156
- return t.filter((e) => !!e).reduce((e, n) => {
157
- const r = { ...e };
158
- return Object.entries(n).forEach(([s, o]) => {
159
- if (!r[s]) {
160
- r[s] = o;
161
- return;
162
- }
163
- if (s === "class") {
164
- const a = o ? String(o).split(" ") : [], l = r[s] ? r[s].split(" ") : [], c = a.filter((u) => !l.includes(u));
165
- r[s] = [...l, ...c].join(" ");
166
- } else if (s === "style") {
167
- const a = o ? o.split(";").map((u) => u.trim()).filter(Boolean) : [], l = r[s] ? r[s].split(";").map((u) => u.trim()).filter(Boolean) : [], c = /* @__PURE__ */ new Map();
168
- l.forEach((u) => {
169
- const [d, p] = u.split(":").map((f) => f.trim());
170
- c.set(d, p);
171
- }), a.forEach((u) => {
172
- const [d, p] = u.split(":").map((f) => f.trim());
173
- c.set(d, p);
174
- }), r[s] = Array.from(c.entries()).map(([u, d]) => `${u}: ${d}`).join("; ");
175
- } else
176
- r[s] = o;
177
- }), r;
178
- }, {});
179
- }
180
- function It(t) {
181
- return typeof t == "function";
182
- }
183
- function b(t, e = void 0, ...n) {
184
- return It(t) ? e ? t.bind(e)(...n) : t(...n) : t;
185
- }
186
- function Et(t) {
187
- return Object.prototype.toString.call(t) === "[object RegExp]";
188
- }
189
- class se {
190
- constructor(e) {
191
- this.find = e.find, this.handler = e.handler;
192
- }
193
- }
194
- function Ot(t) {
195
- return Object.prototype.toString.call(t).slice(8, -1);
196
- }
197
- function X(t) {
198
- return Ot(t) !== "Object" ? !1 : t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype;
199
- }
200
- function oe(t, e) {
201
- const n = { ...t };
202
- return X(t) && X(e) && Object.keys(e).forEach((r) => {
203
- X(e[r]) && X(t[r]) ? n[r] = oe(t[r], e[r]) : n[r] = e[r];
204
- }), n;
205
- }
206
- class K {
207
- constructor(e = {}) {
208
- this.type = "mark", this.name = "mark", this.parent = null, this.child = null, this.config = {
209
- name: this.name,
210
- defaultOptions: {}
211
- }, this.config = {
212
- ...this.config,
213
- ...e
214
- }, this.name = this.config.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(w(this, "addOptions", {
215
- name: this.name
216
- }))), this.storage = b(w(this, "addStorage", {
217
- name: this.name,
218
- options: this.options
219
- })) || {};
220
- }
221
- static create(e = {}) {
222
- return new K(e);
223
- }
224
- configure(e = {}) {
225
- const n = this.extend({
226
- ...this.config,
227
- addOptions: () => oe(this.options, e)
228
- });
229
- return n.name = this.name, n.parent = this.parent, n;
230
- }
231
- extend(e = {}) {
232
- const n = new K(e);
233
- return n.parent = this, this.child = n, n.name = e.name ? e.name : n.parent.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`), n.options = b(w(n, "addOptions", {
234
- name: n.name
235
- })), n.storage = b(w(n, "addStorage", {
236
- name: n.name,
237
- options: n.options
238
- })), n;
239
- }
240
- static handleExit({ editor: e, mark: n }) {
241
- const { tr: r } = e.state, s = e.state.selection.$from;
242
- if (s.pos === s.end()) {
243
- const i = s.marks();
244
- if (!!!i.find((c) => (c == null ? void 0 : c.type.name) === n.name))
245
- return !1;
246
- const l = i.find((c) => (c == null ? void 0 : c.type.name) === n.name);
247
- return l && r.removeStoredMark(l), r.insertText(" ", s.pos), e.view.dispatch(r), !0;
248
- }
249
- return !1;
250
- }
251
- }
252
- class Lt {
253
- constructor(e) {
254
- this.find = e.find, this.handler = e.handler;
255
- }
256
- }
257
- class A {
258
- constructor(e = {}) {
259
- this.type = "extension", this.name = "extension", this.parent = null, this.child = null, this.config = {
260
- name: this.name,
261
- defaultOptions: {}
262
- }, this.config = {
263
- ...this.config,
264
- ...e
265
- }, this.name = this.config.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(w(this, "addOptions", {
266
- name: this.name
267
- }))), this.storage = b(w(this, "addStorage", {
268
- name: this.name,
269
- options: this.options
270
- })) || {};
271
- }
272
- static create(e = {}) {
273
- return new A(e);
274
- }
275
- configure(e = {}) {
276
- const n = this.extend({
277
- ...this.config,
278
- addOptions: () => oe(this.options, e)
279
- });
280
- return n.name = this.name, n.parent = this.parent, n;
281
- }
282
- extend(e = {}) {
283
- const n = new A({ ...this.config, ...e });
284
- return n.parent = this, this.child = n, n.name = e.name ? e.name : n.parent.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`), n.options = b(w(n, "addOptions", {
285
- name: n.name
286
- })), n.storage = b(w(n, "addStorage", {
287
- name: n.name,
288
- options: n.options
289
- })), n;
290
- }
291
- }
292
- function Pt(t, e, n) {
293
- const { from: r, to: s } = e, { blockSeparator: o = `
294
-
295
- `, textSerializers: i = {} } = n || {};
296
- let a = "";
297
- return t.nodesBetween(r, s, (l, c, u, d) => {
298
- var p;
299
- l.isBlock && c > r && (a += o);
300
- const f = i == null ? void 0 : i[l.type.name];
301
- if (f)
302
- return u && (a += f({
303
- node: l,
304
- pos: c,
305
- parent: u,
306
- index: d,
307
- range: e
308
- })), !1;
309
- l.isText && (a += (p = l == null ? void 0 : l.text) === null || p === void 0 ? void 0 : p.slice(Math.max(r, c) - c, s - c));
310
- }), a;
311
- }
312
- function $t(t) {
313
- return Object.fromEntries(Object.entries(t.nodes).filter(([, e]) => e.spec.toText).map(([e, n]) => [e, n.spec.toText]));
314
- }
315
- A.create({
316
- name: "clipboardTextSerializer",
317
- addOptions() {
318
- return {
319
- blockSeparator: void 0
320
- };
321
- },
322
- addProseMirrorPlugins() {
323
- return [
324
- new I({
325
- key: new P("clipboardTextSerializer"),
326
- props: {
327
- clipboardTextSerializer: () => {
328
- const { editor: t } = this, { state: e, schema: n } = t, { doc: r, selection: s } = e, { ranges: o } = s, i = Math.min(...o.map((u) => u.$from.pos)), a = Math.max(...o.map((u) => u.$to.pos)), l = $t(n);
329
- return Pt(r, { from: i, to: a }, {
330
- ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
331
- textSerializers: l
332
- });
333
- }
334
- }
335
- })
336
- ];
337
- }
338
- });
339
- const Bt = () => ({ editor: t, view: e }) => (requestAnimationFrame(() => {
340
- var n;
341
- t.isDestroyed || (e.dom.blur(), (n = window == null ? void 0 : window.getSelection()) === null || n === void 0 || n.removeAllRanges());
342
- }), !0), Nt = (t = !1) => ({ commands: e }) => e.setContent("", t), Rt = () => ({ state: t, tr: e, dispatch: n }) => {
343
- const { selection: r } = e, { ranges: s } = r;
344
- return n && s.forEach(({ $from: o, $to: i }) => {
345
- t.doc.nodesBetween(o.pos, i.pos, (a, l) => {
346
- if (a.type.isText)
347
- return;
348
- const { doc: c, mapping: u } = e, d = c.resolve(u.map(l)), p = c.resolve(u.map(l + a.nodeSize)), f = d.blockRange(p);
349
- if (!f)
350
- return;
351
- const g = kt(f);
352
- if (a.type.isTextblock) {
353
- const { defaultType: h } = d.parent.contentMatchAt(d.index());
354
- e.setNodeMarkup(f.start, h);
355
- }
356
- (g || g === 0) && e.lift(f, g);
357
- });
358
- }), !0;
359
- }, Ht = (t) => (e) => t(e), _t = () => ({ state: t, dispatch: e }) => yt(t, e), jt = (t, e) => ({ editor: n, tr: r }) => {
360
- const { state: s } = n, o = s.doc.slice(t.from, t.to);
361
- r.deleteRange(t.from, t.to);
362
- const i = r.mapping.map(e);
363
- return r.insert(i, o.content), r.setSelection(new x(r.doc.resolve(Math.max(i - 1, 0)))), !0;
364
- }, Ft = () => ({ tr: t, dispatch: e }) => {
365
- const { selection: n } = t, r = n.$anchor.node();
366
- if (r.content.size > 0)
367
- return !1;
368
- const s = t.selection.$anchor;
369
- for (let o = s.depth; o > 0; o -= 1)
370
- if (s.node(o).type === r.type) {
371
- if (e) {
372
- const a = s.before(o), l = s.after(o);
373
- t.delete(a, l).scrollIntoView();
374
- }
375
- return !0;
376
- }
377
- return !1;
378
- }, Dt = (t) => ({ tr: e, state: n, dispatch: r }) => {
379
- const s = C(t, n.schema), o = e.selection.$anchor;
380
- for (let i = o.depth; i > 0; i -= 1)
381
- if (o.node(i).type === s) {
382
- if (r) {
383
- const l = o.before(i), c = o.after(i);
384
- e.delete(l, c).scrollIntoView();
385
- }
386
- return !0;
387
- }
388
- return !1;
389
- }, zt = (t) => ({ tr: e, dispatch: n }) => {
390
- const { from: r, to: s } = t;
391
- return n && e.delete(r, s), !0;
392
- }, Kt = () => ({ state: t, dispatch: e }) => gt(t, e), Vt = () => ({ commands: t }) => t.keyboardShortcut("Enter"), Wt = () => ({ state: t, dispatch: e }) => mt(t, e);
393
- function ne(t, e, n = { strict: !0 }) {
394
- const r = Object.keys(e);
395
- return r.length ? r.every((s) => n.strict ? e[s] === t[s] : Et(e[s]) ? e[s].test(t[s]) : e[s] === t[s]) : !0;
396
- }
397
- function Be(t, e, n = {}) {
398
- return t.find((r) => r.type === e && ne(
399
- // Only check equality for the attributes that are provided
400
- Object.fromEntries(Object.keys(n).map((s) => [s, r.attrs[s]])),
401
- n
402
- ));
403
- }
404
- function be(t, e, n = {}) {
405
- return !!Be(t, e, n);
406
- }
407
- function he(t, e, n) {
408
- var r;
409
- if (!t || !e)
410
- return;
411
- let s = t.parent.childAfter(t.parentOffset);
412
- if ((!s.node || !s.node.marks.some((u) => u.type === e)) && (s = t.parent.childBefore(t.parentOffset)), !s.node || !s.node.marks.some((u) => u.type === e) || (n = n || ((r = s.node.marks[0]) === null || r === void 0 ? void 0 : r.attrs), !Be([...s.node.marks], e, n)))
413
- return;
414
- let i = s.index, a = t.start() + s.offset, l = i + 1, c = a + s.node.nodeSize;
415
- for (; i > 0 && be([...t.parent.child(i - 1).marks], e, n); )
416
- i -= 1, a -= t.parent.child(i).nodeSize;
417
- for (; l < t.parent.childCount && be([...t.parent.child(l).marks], e, n); )
418
- c += t.parent.child(l).nodeSize, l += 1;
419
- return {
420
- from: a,
421
- to: c
422
- };
423
- }
424
- function F(t, e) {
425
- if (typeof t == "string") {
426
- if (!e.marks[t])
427
- throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);
428
- return e.marks[t];
429
- }
430
- return t;
431
- }
432
- const Gt = (t, e = {}) => ({ tr: n, state: r, dispatch: s }) => {
433
- const o = F(t, r.schema), { doc: i, selection: a } = n, { $from: l, from: c, to: u } = a;
434
- if (s) {
435
- const d = he(l, o, e);
436
- if (d && d.from <= c && d.to >= u) {
437
- const p = x.create(i, d.from, d.to);
438
- n.setSelection(p);
439
- }
440
- }
441
- return !0;
442
- }, Jt = (t) => (e) => {
443
- const n = typeof t == "function" ? t(e) : t;
444
- for (let r = 0; r < n.length; r += 1)
445
- if (n[r](e))
446
- return !0;
447
- return !1;
448
- };
449
- function Ne(t) {
450
- return t instanceof x;
451
- }
452
- function D(t = 0, e = 0, n = 0) {
453
- return Math.min(Math.max(t, e), n);
454
- }
455
- function qt(t, e = null) {
456
- if (!e)
457
- return null;
458
- const n = L.atStart(t), r = L.atEnd(t);
459
- if (e === "start" || e === !0)
460
- return n;
461
- if (e === "end")
462
- return r;
463
- const s = n.from, o = r.to;
464
- return e === "all" ? x.create(t, D(0, s, o), D(t.content.size, s, o)) : x.create(t, D(e, s, o), D(e, s, o));
465
- }
466
- function Ut() {
467
- return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
468
- }
469
- function me() {
470
- return [
471
- "iPad Simulator",
472
- "iPhone Simulator",
473
- "iPod Simulator",
474
- "iPad",
475
- "iPhone",
476
- "iPod"
477
- ].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
478
- }
479
- const Xt = (t = null, e = {}) => ({ editor: n, view: r, tr: s, dispatch: o }) => {
480
- e = {
481
- scrollIntoView: !0,
482
- ...e
483
- };
484
- const i = () => {
485
- (me() || Ut()) && r.dom.focus(), requestAnimationFrame(() => {
486
- n.isDestroyed || (r.focus(), e != null && e.scrollIntoView && n.commands.scrollIntoView());
487
- });
488
- };
489
- if (r.hasFocus() && t === null || t === !1)
490
- return !0;
491
- if (o && t === null && !Ne(n.state.selection))
492
- return i(), !0;
493
- const a = qt(s.doc, t) || n.state.selection, l = n.state.selection.eq(a);
494
- return o && (l || s.setSelection(a), l && s.storedMarks && s.setStoredMarks(s.storedMarks), i()), !0;
495
- }, Yt = (t, e) => (n) => t.every((r, s) => e(r, { ...n, index: s })), Qt = (t, e) => ({ tr: n, commands: r }) => r.insertContentAt({ from: n.selection.from, to: n.selection.to }, t, e), Re = (t) => {
496
- const e = t.childNodes;
497
- for (let n = e.length - 1; n >= 0; n -= 1) {
498
- const r = e[n];
499
- r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? t.removeChild(r) : r.nodeType === 1 && Re(r);
500
- }
501
- return t;
502
- };
503
- function Y(t) {
504
- const e = `<body>${t}</body>`, n = new window.DOMParser().parseFromString(e, "text/html").body;
505
- return Re(n);
506
- }
507
- function q(t, e, n) {
508
- if (t instanceof Mt || t instanceof j)
509
- return t;
510
- n = {
511
- slice: !0,
512
- parseOptions: {},
513
- ...n
514
- };
515
- const r = typeof t == "object" && t !== null, s = typeof t == "string";
516
- if (r)
517
- try {
518
- if (Array.isArray(t) && t.length > 0)
519
- return j.fromArray(t.map((a) => e.nodeFromJSON(a)));
520
- const i = e.nodeFromJSON(t);
521
- return n.errorOnInvalidContent && i.check(), i;
522
- } catch (o) {
523
- if (n.errorOnInvalidContent)
524
- throw new Error("[tiptap error]: Invalid JSON content", { cause: o });
525
- return console.warn("[tiptap warn]: Invalid content.", "Passed value:", t, "Error:", o), q("", e, n);
526
- }
527
- if (s) {
528
- if (n.errorOnInvalidContent) {
529
- let i = !1, a = "";
530
- const l = new bt({
531
- topNode: e.spec.topNode,
532
- marks: e.spec.marks,
533
- // Prosemirror's schemas are executed such that: the last to execute, matches last
534
- // 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
535
- nodes: e.spec.nodes.append({
536
- __tiptap__private__unknown__catch__all__node: {
537
- content: "inline*",
538
- group: "block",
539
- parseDOM: [
540
- {
541
- tag: "*",
542
- getAttrs: (c) => (i = !0, a = typeof c == "string" ? c : c.outerHTML, null)
543
- }
544
- ]
545
- }
546
- })
547
- });
548
- if (n.slice ? ie.fromSchema(l).parseSlice(Y(t), n.parseOptions) : ie.fromSchema(l).parse(Y(t), n.parseOptions), n.errorOnInvalidContent && i)
549
- throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${a}`) });
550
- }
551
- const o = ie.fromSchema(e);
552
- return n.slice ? o.parseSlice(Y(t), n.parseOptions).content : o.parse(Y(t), n.parseOptions);
553
- }
554
- return q("", e, n);
555
- }
556
- function Zt(t, e, n) {
557
- const r = t.steps.length - 1;
558
- if (r < e)
559
- return;
560
- const s = t.steps[r];
561
- if (!(s instanceof vt || s instanceof wt))
562
- return;
563
- const o = t.mapping.maps[r];
564
- let i = 0;
565
- o.forEach((a, l, c, u) => {
566
- i === 0 && (i = u);
567
- }), t.setSelection(L.near(t.doc.resolve(i), n));
568
- }
569
- const en = (t) => !("type" in t), tn = (t, e, n) => ({ tr: r, dispatch: s, editor: o }) => {
570
- var i;
571
- if (s) {
572
- n = {
573
- parseOptions: o.options.parseOptions,
574
- updateSelection: !0,
575
- applyInputRules: !1,
576
- applyPasteRules: !1,
577
- ...n
578
- };
579
- let a;
580
- const l = (m) => {
581
- o.emit("contentError", {
582
- editor: o,
583
- error: m,
584
- disableCollaboration: () => {
585
- o.storage.collaboration && (o.storage.collaboration.isDisabled = !0);
586
- }
587
- });
588
- }, c = {
589
- preserveWhitespace: "full",
590
- ...n.parseOptions
591
- };
592
- if (!n.errorOnInvalidContent && !o.options.enableContentCheck && o.options.emitContentError)
593
- try {
594
- q(e, o.schema, {
595
- parseOptions: c,
596
- errorOnInvalidContent: !0
597
- });
598
- } catch (m) {
599
- l(m);
600
- }
601
- try {
602
- a = q(e, o.schema, {
603
- parseOptions: c,
604
- errorOnInvalidContent: (i = n.errorOnInvalidContent) !== null && i !== void 0 ? i : o.options.enableContentCheck
605
- });
606
- } catch (m) {
607
- return l(m), !1;
608
- }
609
- let { from: u, to: d } = typeof t == "number" ? { from: t, to: t } : { from: t.from, to: t.to }, p = !0, f = !0;
610
- if ((en(a) ? a : [a]).forEach((m) => {
611
- m.check(), p = p ? m.isText && m.marks.length === 0 : !1, f = f ? m.isBlock : !1;
612
- }), u === d && f) {
613
- const { parent: m } = r.doc.resolve(u);
614
- m.isTextblock && !m.type.spec.code && !m.childCount && (u -= 1, d += 1);
615
- }
616
- let h;
617
- if (p) {
618
- if (Array.isArray(e))
619
- h = e.map((m) => m.text || "").join("");
620
- else if (e instanceof j) {
621
- let m = "";
622
- e.forEach((y) => {
623
- y.text && (m += y.text);
624
- }), h = m;
625
- } else typeof e == "object" && e && e.text ? h = e.text : h = e;
626
- r.insertText(h, u, d);
627
- } else
628
- h = a, r.replaceWith(u, d, h);
629
- n.updateSelection && Zt(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { from: u, text: h }), n.applyPasteRules && r.setMeta("applyPasteRules", { from: u, text: h });
630
- }
631
- return !0;
632
- }, nn = () => ({ state: t, dispatch: e }) => ct(t, e), rn = () => ({ state: t, dispatch: e }) => ft(t, e), sn = () => ({ state: t, dispatch: e }) => ht(t, e), on = () => ({ state: t, dispatch: e }) => pt(t, e), an = () => ({ state: t, dispatch: e, tr: n }) => {
633
- try {
634
- const r = Pe(t.doc, t.selection.$from.pos, -1);
635
- return r == null ? !1 : (n.join(r, 2), e && e(n), !0);
636
- } catch {
637
- return !1;
638
- }
639
- }, ln = () => ({ state: t, dispatch: e, tr: n }) => {
640
- try {
641
- const r = Pe(t.doc, t.selection.$from.pos, 1);
642
- return r == null ? !1 : (n.join(r, 2), e && e(n), !0);
643
- } catch {
644
- return !1;
645
- }
646
- }, cn = () => ({ state: t, dispatch: e }) => ut(t, e), dn = () => ({ state: t, dispatch: e }) => dt(t, e);
647
- function He() {
648
- return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
649
- }
650
- function un(t) {
651
- const e = t.split(/-(?!$)/);
652
- let n = e[e.length - 1];
653
- n === "Space" && (n = " ");
654
- let r, s, o, i;
655
- for (let a = 0; a < e.length - 1; a += 1) {
656
- const l = e[a];
657
- if (/^(cmd|meta|m)$/i.test(l))
658
- i = !0;
659
- else if (/^a(lt)?$/i.test(l))
660
- r = !0;
661
- else if (/^(c|ctrl|control)$/i.test(l))
662
- s = !0;
663
- else if (/^s(hift)?$/i.test(l))
664
- o = !0;
665
- else if (/^mod$/i.test(l))
666
- me() || He() ? i = !0 : s = !0;
667
- else
668
- throw new Error(`Unrecognized modifier name: ${l}`);
669
- }
670
- return r && (n = `Alt-${n}`), s && (n = `Ctrl-${n}`), i && (n = `Meta-${n}`), o && (n = `Shift-${n}`), n;
671
- }
672
- const pn = (t) => ({ editor: e, view: n, tr: r, dispatch: s }) => {
673
- const o = un(t).split(/-(?!$)/), i = o.find((c) => !["Alt", "Ctrl", "Meta", "Shift"].includes(c)), a = new KeyboardEvent("keydown", {
674
- key: i === "Space" ? " " : i,
675
- altKey: o.includes("Alt"),
676
- ctrlKey: o.includes("Ctrl"),
677
- metaKey: o.includes("Meta"),
678
- shiftKey: o.includes("Shift"),
679
- bubbles: !0,
680
- cancelable: !0
681
- }), l = e.captureTransaction(() => {
682
- n.someProp("handleKeyDown", (c) => c(n, a));
683
- });
684
- return l == null || l.steps.forEach((c) => {
685
- const u = c.map(r.mapping);
686
- u && s && r.maybeStep(u);
687
- }), !0;
688
- };
689
- function ge(t, e, n = {}) {
690
- const { from: r, to: s, empty: o } = t.selection, i = e ? C(e, t.schema) : null, a = [];
691
- t.doc.nodesBetween(r, s, (d, p) => {
692
- if (d.isText)
693
- return;
694
- const f = Math.max(r, p), g = Math.min(s, p + d.nodeSize);
695
- a.push({
696
- node: d,
697
- from: f,
698
- to: g
699
- });
700
- });
701
- const l = s - r, c = a.filter((d) => i ? i.name === d.node.type.name : !0).filter((d) => ne(d.node.attrs, n, { strict: !1 }));
702
- return o ? !!c.length : c.reduce((d, p) => d + p.to - p.from, 0) >= l;
703
- }
704
- const fn = (t, e = {}) => ({ state: n, dispatch: r }) => {
705
- const s = C(t, n.schema);
706
- return ge(n, s, e) ? lt(n, r) : !1;
707
- }, hn = () => ({ state: t, dispatch: e }) => at(t, e), mn = (t) => ({ state: e, dispatch: n }) => {
708
- const r = C(t, e.schema);
709
- return it(r)(e, n);
710
- }, gn = () => ({ state: t, dispatch: e }) => ot(t, e);
711
- function _e(t, e) {
712
- return e.nodes[t] ? "node" : e.marks[t] ? "mark" : null;
713
- }
714
- function ve(t, e) {
715
- const n = typeof e == "string" ? [e] : e;
716
- return Object.keys(t).reduce((r, s) => (n.includes(s) || (r[s] = t[s]), r), {});
717
- }
718
- const yn = (t, e) => ({ tr: n, state: r, dispatch: s }) => {
719
- let o = null, i = null;
720
- const a = _e(typeof t == "string" ? t : t.name, r.schema);
721
- return a ? (a === "node" && (o = C(t, r.schema)), a === "mark" && (i = F(t, r.schema)), s && n.selection.ranges.forEach((l) => {
722
- r.doc.nodesBetween(l.$from.pos, l.$to.pos, (c, u) => {
723
- o && o === c.type && n.setNodeMarkup(u, void 0, ve(c.attrs, e)), i && c.marks.length && c.marks.forEach((d) => {
724
- i === d.type && n.addMark(u, u + c.nodeSize, i.create(ve(d.attrs, e)));
725
- });
726
- });
727
- }), !0) : !1;
728
- }, kn = () => ({ tr: t, dispatch: e }) => (e && t.scrollIntoView(), !0), Mn = () => ({ tr: t, dispatch: e }) => {
729
- if (e) {
730
- const n = new st(t.doc);
731
- t.setSelection(n);
732
- }
733
- return !0;
734
- }, bn = () => ({ state: t, dispatch: e }) => rt(t, e), vn = () => ({ state: t, dispatch: e }) => nt(t, e), wn = () => ({ state: t, dispatch: e }) => tt(t, e), xn = () => ({ state: t, dispatch: e }) => et(t, e), Cn = () => ({ state: t, dispatch: e }) => Ze(t, e);
735
- function An(t, e, n = {}, r = {}) {
736
- return q(t, e, {
737
- slice: !1,
738
- parseOptions: n,
739
- errorOnInvalidContent: r.errorOnInvalidContent
740
- });
741
- }
742
- const Sn = (t, e = !1, n = {}, r = {}) => ({ editor: s, tr: o, dispatch: i, commands: a }) => {
743
- var l, c;
744
- const { doc: u } = o;
745
- if (n.preserveWhitespace !== "full") {
746
- const d = An(t, s.schema, n, {
747
- errorOnInvalidContent: (l = r.errorOnInvalidContent) !== null && l !== void 0 ? l : s.options.enableContentCheck
748
- });
749
- return i && o.replaceWith(0, u.content.size, d).setMeta("preventUpdate", !e), !0;
750
- }
751
- return i && o.setMeta("preventUpdate", !e), a.insertContentAt({ from: 0, to: u.content.size }, t, {
752
- parseOptions: n,
753
- errorOnInvalidContent: (c = r.errorOnInvalidContent) !== null && c !== void 0 ? c : s.options.enableContentCheck
754
- });
755
- };
756
- function Tn(t, e) {
757
- const n = F(e, t.schema), { from: r, to: s, empty: o } = t.selection, i = [];
758
- o ? (t.storedMarks && i.push(...t.storedMarks), i.push(...t.selection.$head.marks())) : t.doc.nodesBetween(r, s, (l) => {
759
- i.push(...l.marks);
760
- });
761
- const a = i.find((l) => l.type.name === n.name);
762
- return a ? { ...a.attrs } : {};
763
- }
764
- function In(t) {
765
- for (let e = 0; e < t.edgeCount; e += 1) {
766
- const { type: n } = t.edge(e);
767
- if (n.isTextblock && !n.hasRequiredAttrs())
768
- return n;
769
- }
770
- return null;
771
- }
772
- function En(t, e) {
773
- for (let n = t.depth; n > 0; n -= 1) {
774
- const r = t.node(n);
775
- if (e(r))
776
- return {
777
- pos: n > 0 ? t.before(n) : 0,
778
- start: t.start(n),
779
- depth: n,
780
- node: r
781
- };
782
- }
783
- }
784
- function ye(t) {
785
- return (e) => En(e.$from, t);
786
- }
787
- function je(t, e, n) {
788
- const r = [];
789
- return t === e ? n.resolve(t).marks().forEach((s) => {
790
- const o = n.resolve(t), i = he(o, s.type);
791
- i && r.push({
792
- mark: s,
793
- ...i
794
- });
795
- }) : n.nodesBetween(t, e, (s, o) => {
796
- !s || (s == null ? void 0 : s.nodeSize) === void 0 || r.push(...s.marks.map((i) => ({
797
- from: o,
798
- to: o + s.nodeSize,
799
- mark: i
800
- })));
801
- }), r;
802
- }
803
- function ee(t, e, n) {
804
- return Object.fromEntries(Object.entries(n).filter(([r]) => {
805
- const s = t.find((o) => o.type === e && o.name === r);
806
- return s ? s.attribute.keepOnSplit : !1;
807
- }));
808
- }
809
- function On(t, e, n = {}) {
810
- const { empty: r, ranges: s } = t.selection, o = e ? F(e, t.schema) : null;
811
- if (r)
812
- return !!(t.storedMarks || t.selection.$from.marks()).filter((d) => o ? o.name === d.type.name : !0).find((d) => ne(d.attrs, n, { strict: !1 }));
813
- let i = 0;
814
- const a = [];
815
- if (s.forEach(({ $from: d, $to: p }) => {
816
- const f = d.pos, g = p.pos;
817
- t.doc.nodesBetween(f, g, (h, m) => {
818
- if (!h.isText && !h.marks.length)
819
- return;
820
- const y = Math.max(f, m), k = Math.min(g, m + h.nodeSize), E = k - y;
821
- i += E, a.push(...h.marks.map((N) => ({
822
- mark: N,
823
- from: y,
824
- to: k
825
- })));
826
- });
827
- }), i === 0)
828
- return !1;
829
- const l = a.filter((d) => o ? o.name === d.mark.type.name : !0).filter((d) => ne(d.mark.attrs, n, { strict: !1 })).reduce((d, p) => d + p.to - p.from, 0), c = a.filter((d) => o ? d.mark.type !== o && d.mark.type.excludes(o) : !0).reduce((d, p) => d + p.to - p.from, 0);
830
- return (l > 0 ? l + c : l) >= i;
831
- }
832
- function we(t, e) {
833
- const { nodeExtensions: n } = Tt(e), r = n.find((i) => i.name === t);
834
- if (!r)
835
- return !1;
836
- const s = {
837
- name: r.name,
838
- options: r.options,
839
- storage: r.storage
840
- }, o = b(w(r, "group", s));
841
- return typeof o != "string" ? !1 : o.split(" ").includes("list");
842
- }
843
- function Fe(t, { checkChildren: e = !0, ignoreWhitespace: n = !1 } = {}) {
844
- var r;
845
- if (n) {
846
- if (t.type.name === "hardBreak")
847
- return !0;
848
- if (t.isText)
849
- return /^\s*$/m.test((r = t.text) !== null && r !== void 0 ? r : "");
850
- }
851
- if (t.isText)
852
- return !t.text;
853
- if (t.isAtom || t.isLeaf)
854
- return !1;
855
- if (t.content.childCount === 0)
856
- return !0;
857
- if (e) {
858
- let s = !0;
859
- return t.content.forEach((o) => {
860
- s !== !1 && (Fe(o, { ignoreWhitespace: n, checkChildren: e }) || (s = !1));
861
- }), s;
862
- }
863
- return !1;
864
- }
865
- function Ln(t) {
866
- return t instanceof V;
867
- }
868
- function Pn(t, e, n) {
869
- var r;
870
- const { selection: s } = e;
871
- let o = null;
872
- if (Ne(s) && (o = s.$cursor), o) {
873
- const a = (r = t.storedMarks) !== null && r !== void 0 ? r : o.marks();
874
- return !!n.isInSet(a) || !a.some((l) => l.type.excludes(n));
875
- }
876
- const { ranges: i } = s;
877
- return i.some(({ $from: a, $to: l }) => {
878
- let c = a.depth === 0 ? t.doc.inlineContent && t.doc.type.allowsMarkType(n) : !1;
879
- return t.doc.nodesBetween(a.pos, l.pos, (u, d, p) => {
880
- if (c)
881
- return !1;
882
- if (u.isInline) {
883
- const f = !p || p.type.allowsMarkType(n), g = !!n.isInSet(u.marks) || !u.marks.some((h) => h.type.excludes(n));
884
- c = f && g;
885
- }
886
- return !c;
887
- }), c;
888
- });
889
- }
890
- const $n = (t, e = {}) => ({ tr: n, state: r, dispatch: s }) => {
891
- const { selection: o } = n, { empty: i, ranges: a } = o, l = F(t, r.schema);
892
- if (s)
893
- if (i) {
894
- const c = Tn(r, l);
895
- n.addStoredMark(l.create({
896
- ...c,
897
- ...e
898
- }));
899
- } else
900
- a.forEach((c) => {
901
- const u = c.$from.pos, d = c.$to.pos;
902
- r.doc.nodesBetween(u, d, (p, f) => {
903
- const g = Math.max(f, u), h = Math.min(f + p.nodeSize, d);
904
- p.marks.find((y) => y.type === l) ? p.marks.forEach((y) => {
905
- l === y.type && n.addMark(g, h, l.create({
906
- ...y.attrs,
907
- ...e
908
- }));
909
- }) : n.addMark(g, h, l.create(e));
910
- });
911
- });
912
- return Pn(r, n, l);
913
- }, Bn = (t, e) => ({ tr: n }) => (n.setMeta(t, e), !0), Nn = (t, e = {}) => ({ state: n, dispatch: r, chain: s }) => {
914
- const o = C(t, n.schema);
915
- let i;
916
- return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), o.isTextblock ? s().command(({ commands: a }) => Me(o, { ...i, ...e })(n) ? !0 : a.clearNodes()).command(({ state: a }) => Me(o, { ...i, ...e })(a, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
917
- }, Rn = (t) => ({ tr: e, dispatch: n }) => {
918
- if (n) {
919
- const { doc: r } = e, s = D(t, 0, r.content.size), o = V.create(r, s);
920
- e.setSelection(o);
921
- }
922
- return !0;
923
- }, Hn = (t) => ({ tr: e, dispatch: n }) => {
924
- if (n) {
925
- const { doc: r } = e, { from: s, to: o } = typeof t == "number" ? { from: t, to: t } : t, i = x.atStart(r).from, a = x.atEnd(r).to, l = D(s, i, a), c = D(o, i, a), u = x.create(r, l, c);
926
- e.setSelection(u);
927
- }
928
- return !0;
929
- }, _n = (t) => ({ state: e, dispatch: n }) => {
930
- const r = C(t, e.schema);
931
- return Qe(r)(e, n);
932
- };
933
- function xe(t, e) {
934
- const n = t.storedMarks || t.selection.$to.parentOffset && t.selection.$from.marks();
935
- if (n) {
936
- const r = n.filter((s) => e == null ? void 0 : e.includes(s.type.name));
937
- t.tr.ensureMarks(r);
938
- }
939
- }
940
- const jn = ({ keepMarks: t = !0 } = {}) => ({ tr: e, state: n, dispatch: r, editor: s }) => {
941
- const { selection: o, doc: i } = e, { $from: a, $to: l } = o, c = s.extensionManager.attributes, u = ee(c, a.node().type.name, a.node().attrs);
942
- if (o instanceof V && o.node.isBlock)
943
- return !a.parentOffset || !Z(i, a.pos) ? !1 : (r && (t && xe(n, s.extensionManager.splittableMarks), e.split(a.pos).scrollIntoView()), !0);
944
- if (!a.parent.isBlock)
945
- return !1;
946
- const d = l.parentOffset === l.parent.content.size, p = a.depth === 0 ? void 0 : In(a.node(-1).contentMatchAt(a.indexAfter(-1)));
947
- let f = d && p ? [
948
- {
949
- type: p,
950
- attrs: u
951
- }
952
- ] : void 0, g = Z(e.doc, e.mapping.map(a.pos), 1, f);
953
- if (!f && !g && Z(e.doc, e.mapping.map(a.pos), 1, p ? [{ type: p }] : void 0) && (g = !0, f = p ? [
954
- {
955
- type: p,
956
- attrs: u
957
- }
958
- ] : void 0), r) {
959
- if (g && (o instanceof x && e.deleteSelection(), e.split(e.mapping.map(a.pos), 1, f), p && !d && !a.parentOffset && a.parent.type !== p)) {
960
- const h = e.mapping.map(a.before()), m = e.doc.resolve(h);
961
- a.node(-1).canReplaceWith(m.index(), m.index() + 1, p) && e.setNodeMarkup(e.mapping.map(a.before()), p);
962
- }
963
- t && xe(n, s.extensionManager.splittableMarks), e.scrollIntoView();
964
- }
965
- return g;
966
- }, Fn = (t, e = {}) => ({ tr: n, state: r, dispatch: s, editor: o }) => {
967
- var i;
968
- const a = C(t, r.schema), { $from: l, $to: c } = r.selection, u = r.selection.node;
969
- if (u && u.isBlock || l.depth < 2 || !l.sameParent(c))
970
- return !1;
971
- const d = l.node(-1);
972
- if (d.type !== a)
973
- return !1;
974
- const p = o.extensionManager.attributes;
975
- if (l.parent.content.size === 0 && l.node(-1).childCount === l.indexAfter(-1)) {
976
- if (l.depth === 2 || l.node(-3).type !== a || l.index(-2) !== l.node(-2).childCount - 1)
977
- return !1;
978
- if (s) {
979
- let y = j.empty;
980
- const k = l.index(-1) ? 1 : l.index(-2) ? 2 : 3;
981
- for (let H = l.depth - k; H >= l.depth - 3; H -= 1)
982
- y = j.from(l.node(H).copy(y));
983
- const E = l.indexAfter(-1) < l.node(-2).childCount ? 1 : l.indexAfter(-2) < l.node(-3).childCount ? 2 : 3, N = {
984
- ...ee(p, l.node().type.name, l.node().attrs),
985
- ...e
986
- }, $ = ((i = a.contentMatch.defaultType) === null || i === void 0 ? void 0 : i.createAndFill(N)) || void 0;
987
- y = y.append(j.from(a.createAndFill(null, $) || void 0));
988
- const R = l.before(l.depth - (k - 1));
989
- n.replace(R, l.after(-E), new fe(y, 4 - k, 0));
990
- let W = -1;
991
- n.doc.nodesBetween(R, n.doc.content.size, (H, Ge) => {
992
- if (W > -1)
993
- return !1;
994
- H.isTextblock && H.content.size === 0 && (W = Ge + 1);
995
- }), W > -1 && n.setSelection(x.near(n.doc.resolve(W))), n.scrollIntoView();
996
- }
997
- return !0;
998
- }
999
- const f = c.pos === l.end() ? d.contentMatchAt(0).defaultType : null, g = {
1000
- ...ee(p, d.type.name, d.attrs),
1001
- ...e
1002
- }, h = {
1003
- ...ee(p, l.node().type.name, l.node().attrs),
1004
- ...e
1005
- };
1006
- n.delete(l.pos, c.pos);
1007
- const m = f ? [
1008
- { type: a, attrs: g },
1009
- { type: f, attrs: h }
1010
- ] : [{ type: a, attrs: g }];
1011
- if (!Z(n.doc, l.pos, 2))
1012
- return !1;
1013
- if (s) {
1014
- const { selection: y, storedMarks: k } = r, { splittableMarks: E } = o.extensionManager, N = k || y.$to.parentOffset && y.$from.marks();
1015
- if (n.split(l.pos, 2, m).scrollIntoView(), !N || !s)
1016
- return !0;
1017
- const $ = N.filter((R) => E.includes(R.type.name));
1018
- n.ensureMarks($);
1019
- }
1020
- return !0;
1021
- }, ae = (t, e) => {
1022
- const n = ye((i) => i.type === e)(t.selection);
1023
- if (!n)
1024
- return !0;
1025
- const r = t.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
1026
- if (r === void 0)
1027
- return !0;
1028
- const s = t.doc.nodeAt(r);
1029
- return n.node.type === (s == null ? void 0 : s.type) && pe(t.doc, n.pos) && t.join(n.pos), !0;
1030
- }, le = (t, e) => {
1031
- const n = ye((i) => i.type === e)(t.selection);
1032
- if (!n)
1033
- return !0;
1034
- const r = t.doc.resolve(n.start).after(n.depth);
1035
- if (r === void 0)
1036
- return !0;
1037
- const s = t.doc.nodeAt(r);
1038
- return n.node.type === (s == null ? void 0 : s.type) && pe(t.doc, r) && t.join(r), !0;
1039
- }, Dn = (t, e, n, r = {}) => ({ editor: s, tr: o, state: i, dispatch: a, chain: l, commands: c, can: u }) => {
1040
- const { extensions: d, splittableMarks: p } = s.extensionManager, f = C(t, i.schema), g = C(e, i.schema), { selection: h, storedMarks: m } = i, { $from: y, $to: k } = h, E = y.blockRange(k), N = m || h.$to.parentOffset && h.$from.marks();
1041
- if (!E)
1042
- return !1;
1043
- const $ = ye((R) => we(R.type.name, d))(h);
1044
- if (E.depth >= 1 && $ && E.depth - $.depth <= 1) {
1045
- if ($.node.type === f)
1046
- return c.liftListItem(g);
1047
- if (we($.node.type.name, d) && f.validContent($.node.content) && a)
1048
- return l().command(() => (o.setNodeMarkup($.pos, f), !0)).command(() => ae(o, f)).command(() => le(o, f)).run();
1049
- }
1050
- return !n || !N || !a ? l().command(() => u().wrapInList(f, r) ? !0 : c.clearNodes()).wrapInList(f, r).command(() => ae(o, f)).command(() => le(o, f)).run() : l().command(() => {
1051
- const R = u().wrapInList(f, r), W = N.filter((H) => p.includes(H.type.name));
1052
- return o.ensureMarks(W), R ? !0 : c.clearNodes();
1053
- }).wrapInList(f, r).command(() => ae(o, f)).command(() => le(o, f)).run();
1054
- }, zn = (t, e = {}, n = {}) => ({ state: r, commands: s }) => {
1055
- const { extendEmptyMarkRange: o = !1 } = n, i = F(t, r.schema);
1056
- return On(r, i, e) ? s.unsetMark(i, { extendEmptyMarkRange: o }) : s.setMark(i, e);
1057
- }, Kn = (t, e, n = {}) => ({ state: r, commands: s }) => {
1058
- const o = C(t, r.schema), i = C(e, r.schema), a = ge(r, o, n);
1059
- let l;
1060
- return r.selection.$anchor.sameParent(r.selection.$head) && (l = r.selection.$anchor.parent.attrs), a ? s.setNode(i, l) : s.setNode(o, { ...l, ...n });
1061
- }, Vn = (t, e = {}) => ({ state: n, commands: r }) => {
1062
- const s = C(t, n.schema);
1063
- return ge(n, s, e) ? r.lift(s) : r.wrapIn(s, e);
1064
- }, Wn = () => ({ state: t, dispatch: e }) => {
1065
- const n = t.plugins;
1066
- for (let r = 0; r < n.length; r += 1) {
1067
- const s = n[r];
1068
- let o;
1069
- if (s.spec.isInputRules && (o = s.getState(t))) {
1070
- if (e) {
1071
- const i = t.tr, a = o.transform;
1072
- for (let l = a.steps.length - 1; l >= 0; l -= 1)
1073
- i.step(a.steps[l].invert(a.docs[l]));
1074
- if (o.text) {
1075
- const l = i.doc.resolve(o.from).marks();
1076
- i.replaceWith(o.from, o.to, t.schema.text(o.text, l));
1077
- } else
1078
- i.delete(o.from, o.to);
1079
- }
1080
- return !0;
1081
- }
1082
- }
1083
- return !1;
1084
- }, Gn = () => ({ tr: t, dispatch: e }) => {
1085
- const { selection: n } = t, { empty: r, ranges: s } = n;
1086
- return r || e && s.forEach((o) => {
1087
- t.removeMark(o.$from.pos, o.$to.pos);
1088
- }), !0;
1089
- }, Jn = (t, e = {}) => ({ tr: n, state: r, dispatch: s }) => {
1090
- var o;
1091
- const { extendEmptyMarkRange: i = !1 } = e, { selection: a } = n, l = F(t, r.schema), { $from: c, empty: u, ranges: d } = a;
1092
- if (!s)
1093
- return !0;
1094
- if (u && i) {
1095
- let { from: p, to: f } = a;
1096
- const g = (o = c.marks().find((m) => m.type === l)) === null || o === void 0 ? void 0 : o.attrs, h = he(c, l, g);
1097
- h && (p = h.from, f = h.to), n.removeMark(p, f, l);
1098
- } else
1099
- d.forEach((p) => {
1100
- n.removeMark(p.$from.pos, p.$to.pos, l);
1101
- });
1102
- return n.removeStoredMark(l), !0;
1103
- }, qn = (t, e = {}) => ({ tr: n, state: r, dispatch: s }) => {
1104
- let o = null, i = null;
1105
- const a = _e(typeof t == "string" ? t : t.name, r.schema);
1106
- return a ? (a === "node" && (o = C(t, r.schema)), a === "mark" && (i = F(t, r.schema)), s && n.selection.ranges.forEach((l) => {
1107
- const c = l.$from.pos, u = l.$to.pos;
1108
- let d, p, f, g;
1109
- n.selection.empty ? r.doc.nodesBetween(c, u, (h, m) => {
1110
- o && o === h.type && (f = Math.max(m, c), g = Math.min(m + h.nodeSize, u), d = m, p = h);
1111
- }) : r.doc.nodesBetween(c, u, (h, m) => {
1112
- m < c && o && o === h.type && (f = Math.max(m, c), g = Math.min(m + h.nodeSize, u), d = m, p = h), m >= c && m <= u && (o && o === h.type && n.setNodeMarkup(m, void 0, {
1113
- ...h.attrs,
1114
- ...e
1115
- }), i && h.marks.length && h.marks.forEach((y) => {
1116
- if (i === y.type) {
1117
- const k = Math.max(m, c), E = Math.min(m + h.nodeSize, u);
1118
- n.addMark(k, E, i.create({
1119
- ...y.attrs,
1120
- ...e
1121
- }));
1122
- }
1123
- }));
1124
- }), p && (d !== void 0 && n.setNodeMarkup(d, void 0, {
1125
- ...p.attrs,
1126
- ...e
1127
- }), i && p.marks.length && p.marks.forEach((h) => {
1128
- i === h.type && n.addMark(f, g, i.create({
1129
- ...h.attrs,
1130
- ...e
1131
- }));
1132
- }));
1133
- }), !0) : !1;
1134
- }, Un = (t, e = {}) => ({ state: n, dispatch: r }) => {
1135
- const s = C(t, n.schema);
1136
- return Ye(s, e)(n, r);
1137
- }, Xn = (t, e = {}) => ({ state: n, dispatch: r }) => {
1138
- const s = C(t, n.schema);
1139
- return Xe(s, e)(n, r);
1140
- };
1141
- var Yn = /* @__PURE__ */ Object.freeze({
1142
- __proto__: null,
1143
- blur: Bt,
1144
- clearContent: Nt,
1145
- clearNodes: Rt,
1146
- command: Ht,
1147
- createParagraphNear: _t,
1148
- cut: jt,
1149
- deleteCurrentNode: Ft,
1150
- deleteNode: Dt,
1151
- deleteRange: zt,
1152
- deleteSelection: Kt,
1153
- enter: Vt,
1154
- exitCode: Wt,
1155
- extendMarkRange: Gt,
1156
- first: Jt,
1157
- focus: Xt,
1158
- forEach: Yt,
1159
- insertContent: Qt,
1160
- insertContentAt: tn,
1161
- joinBackward: sn,
1162
- joinDown: rn,
1163
- joinForward: on,
1164
- joinItemBackward: an,
1165
- joinItemForward: ln,
1166
- joinTextblockBackward: cn,
1167
- joinTextblockForward: dn,
1168
- joinUp: nn,
1169
- keyboardShortcut: pn,
1170
- lift: fn,
1171
- liftEmptyBlock: hn,
1172
- liftListItem: mn,
1173
- newlineInCode: gn,
1174
- resetAttributes: yn,
1175
- scrollIntoView: kn,
1176
- selectAll: Mn,
1177
- selectNodeBackward: bn,
1178
- selectNodeForward: vn,
1179
- selectParentNode: wn,
1180
- selectTextblockEnd: xn,
1181
- selectTextblockStart: Cn,
1182
- setContent: Sn,
1183
- setMark: $n,
1184
- setMeta: Bn,
1185
- setNode: Nn,
1186
- setNodeSelection: Rn,
1187
- setTextSelection: Hn,
1188
- sinkListItem: _n,
1189
- splitBlock: jn,
1190
- splitListItem: Fn,
1191
- toggleList: Dn,
1192
- toggleMark: zn,
1193
- toggleNode: Kn,
1194
- toggleWrap: Vn,
1195
- undoInputRule: Wn,
1196
- unsetAllMarks: Gn,
1197
- unsetMark: Jn,
1198
- updateAttributes: qn,
1199
- wrapIn: Un,
1200
- wrapInList: Xn
1201
- });
1202
- A.create({
1203
- name: "commands",
1204
- addCommands() {
1205
- return {
1206
- ...Yn
1207
- };
1208
- }
1209
- });
1210
- A.create({
1211
- name: "drop",
1212
- addProseMirrorPlugins() {
1213
- return [
1214
- new I({
1215
- key: new P("tiptapDrop"),
1216
- props: {
1217
- handleDrop: (t, e, n, r) => {
1218
- this.editor.emit("drop", {
1219
- editor: this.editor,
1220
- event: e,
1221
- slice: n,
1222
- moved: r
1223
- });
1224
- }
1225
- }
1226
- })
1227
- ];
1228
- }
1229
- });
1230
- A.create({
1231
- name: "editable",
1232
- addProseMirrorPlugins() {
1233
- return [
1234
- new I({
1235
- key: new P("editable"),
1236
- props: {
1237
- editable: () => this.editor.options.editable
1238
- }
1239
- })
1240
- ];
1241
- }
1242
- });
1243
- const Qn = new P("focusEvents");
1244
- A.create({
1245
- name: "focusEvents",
1246
- addProseMirrorPlugins() {
1247
- const { editor: t } = this;
1248
- return [
1249
- new I({
1250
- key: Qn,
1251
- props: {
1252
- handleDOMEvents: {
1253
- focus: (e, n) => {
1254
- t.isFocused = !0;
1255
- const r = t.state.tr.setMeta("focus", { event: n }).setMeta("addToHistory", !1);
1256
- return e.dispatch(r), !1;
1257
- },
1258
- blur: (e, n) => {
1259
- t.isFocused = !1;
1260
- const r = t.state.tr.setMeta("blur", { event: n }).setMeta("addToHistory", !1);
1261
- return e.dispatch(r), !1;
1262
- }
1263
- }
1264
- }
1265
- })
1266
- ];
1267
- }
1268
- });
1269
- A.create({
1270
- name: "keymap",
1271
- addKeyboardShortcuts() {
1272
- const t = () => this.editor.commands.first(({ commands: i }) => [
1273
- () => i.undoInputRule(),
1274
- // maybe convert first text block node to default node
1275
- () => i.command(({ tr: a }) => {
1276
- const { selection: l, doc: c } = a, { empty: u, $anchor: d } = l, { pos: p, parent: f } = d, g = d.parent.isTextblock && p > 0 ? a.doc.resolve(p - 1) : d, h = g.parent.type.spec.isolating, m = d.pos - d.parentOffset, y = h && g.parent.childCount === 1 ? m === d.pos : L.atStart(c).from === p;
1277
- return !u || !f.type.isTextblock || f.textContent.length || !y || y && d.parent.type.name === "paragraph" ? !1 : i.clearNodes();
1278
- }),
1279
- () => i.deleteSelection(),
1280
- () => i.joinBackward(),
1281
- () => i.selectNodeBackward()
1282
- ]), e = () => this.editor.commands.first(({ commands: i }) => [
1283
- () => i.deleteSelection(),
1284
- () => i.deleteCurrentNode(),
1285
- () => i.joinForward(),
1286
- () => i.selectNodeForward()
1287
- ]), r = {
1288
- Enter: () => this.editor.commands.first(({ commands: i }) => [
1289
- () => i.newlineInCode(),
1290
- () => i.createParagraphNear(),
1291
- () => i.liftEmptyBlock(),
1292
- () => i.splitBlock()
1293
- ]),
1294
- "Mod-Enter": () => this.editor.commands.exitCode(),
1295
- Backspace: t,
1296
- "Mod-Backspace": t,
1297
- "Shift-Backspace": t,
1298
- Delete: e,
1299
- "Mod-Delete": e,
1300
- "Mod-a": () => this.editor.commands.selectAll()
1301
- }, s = {
1302
- ...r
1303
- }, o = {
1304
- ...r,
1305
- "Ctrl-h": t,
1306
- "Alt-Backspace": t,
1307
- "Ctrl-d": e,
1308
- "Ctrl-Alt-Backspace": e,
1309
- "Alt-Delete": e,
1310
- "Alt-d": e,
1311
- "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
1312
- "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
1313
- };
1314
- return me() || He() ? o : s;
1315
- },
1316
- addProseMirrorPlugins() {
1317
- return [
1318
- // With this plugin we check if the whole document was selected and deleted.
1319
- // In this case we will additionally call `clearNodes()` to convert e.g. a heading
1320
- // to a paragraph if necessary.
1321
- // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
1322
- // with many other commands.
1323
- new I({
1324
- key: new P("clearDocument"),
1325
- appendTransaction: (t, e, n) => {
1326
- if (t.some((h) => h.getMeta("composition")))
1327
- return;
1328
- const r = t.some((h) => h.docChanged) && !e.doc.eq(n.doc), s = t.some((h) => h.getMeta("preventClearDocument"));
1329
- if (!r || s)
1330
- return;
1331
- const { empty: o, from: i, to: a } = e.selection, l = L.atStart(e.doc).from, c = L.atEnd(e.doc).to;
1332
- if (o || !(i === l && a === c) || !Fe(n.doc))
1333
- return;
1334
- const p = n.tr, f = $e({
1335
- state: n,
1336
- transaction: p
1337
- }), { commands: g } = new St({
1338
- editor: this.editor,
1339
- state: f
1340
- });
1341
- if (g.clearNodes(), !!p.steps.length)
1342
- return p;
1343
- }
1344
- })
1345
- ];
1346
- }
1347
- });
1348
- A.create({
1349
- name: "paste",
1350
- addProseMirrorPlugins() {
1351
- return [
1352
- new I({
1353
- key: new P("tiptapPaste"),
1354
- props: {
1355
- handlePaste: (t, e, n) => {
1356
- this.editor.emit("paste", {
1357
- editor: this.editor,
1358
- event: e,
1359
- slice: n
1360
- });
1361
- }
1362
- }
1363
- })
1364
- ];
1365
- }
1366
- });
1367
- A.create({
1368
- name: "tabindex",
1369
- addProseMirrorPlugins() {
1370
- return [
1371
- new I({
1372
- key: new P("tabindex"),
1373
- props: {
1374
- attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
1375
- }
1376
- })
1377
- ];
1378
- }
1379
- });
1380
- function G(t) {
1381
- return new se({
1382
- find: t.find,
1383
- handler: ({ state: e, range: n, match: r }) => {
1384
- const s = b(t.getAttributes, void 0, r);
1385
- if (s === !1 || s === null)
1386
- return null;
1387
- const { tr: o } = e, i = r[r.length - 1], a = r[0];
1388
- if (i) {
1389
- const l = a.search(/\S/), c = n.from + a.indexOf(i), u = c + i.length;
1390
- if (je(n.from, n.to, e.doc).filter((f) => f.mark.type.excluded.find((h) => h === t.type && h !== f.mark.type)).filter((f) => f.to > c).length)
1391
- return null;
1392
- u < n.to && o.delete(u, n.to), c > n.from && o.delete(n.from + l, c);
1393
- const p = n.from + l + i.length;
1394
- o.addMark(n.from + l, p, t.type.create(s || {})), o.removeStoredMark(t.type);
1395
- }
1396
- }
1397
- });
1398
- }
1399
- function Zn(t) {
1400
- return new se({
1401
- find: t.find,
1402
- handler: ({ state: e, range: n, match: r }) => {
1403
- const s = b(t.getAttributes, void 0, r) || {}, { tr: o } = e, i = n.from;
1404
- let a = n.to;
1405
- const l = t.type.create(s);
1406
- if (r[1]) {
1407
- const c = r[0].lastIndexOf(r[1]);
1408
- let u = i + c;
1409
- u > a ? u = a : a = u + r[1].length;
1410
- const d = r[0][r[0].length - 1];
1411
- o.insertText(d, i + r[0].length - 1), o.replaceWith(u, a, l);
1412
- } else if (r[0]) {
1413
- const c = t.type.isInline ? i : i - 1;
1414
- o.insert(c, t.type.create(s)).delete(o.mapping.map(i), o.mapping.map(a));
1415
- }
1416
- o.scrollIntoView();
1417
- }
1418
- });
1419
- }
1420
- function ue(t) {
1421
- return new se({
1422
- find: t.find,
1423
- handler: ({ state: e, range: n, match: r }) => {
1424
- const s = e.doc.resolve(n.from), o = b(t.getAttributes, void 0, r) || {};
1425
- if (!s.node(-1).canReplaceWith(s.index(-1), s.indexAfter(-1), t.type))
1426
- return null;
1427
- e.tr.delete(n.from, n.to).setBlockType(n.from, n.from, t.type, o);
1428
- }
1429
- });
1430
- }
1431
- function U(t) {
1432
- return new se({
1433
- find: t.find,
1434
- handler: ({ state: e, range: n, match: r, chain: s }) => {
1435
- const o = b(t.getAttributes, void 0, r) || {}, i = e.tr.delete(n.from, n.to), l = i.doc.resolve(n.from).blockRange(), c = l && Ue(l, t.type, o);
1436
- if (!c)
1437
- return null;
1438
- if (i.wrap(l, c), t.keepMarks && t.editor) {
1439
- const { selection: d, storedMarks: p } = e, { splittableMarks: f } = t.editor.extensionManager, g = p || d.$to.parentOffset && d.$from.marks();
1440
- if (g) {
1441
- const h = g.filter((m) => f.includes(m.type.name));
1442
- i.ensureMarks(h);
1443
- }
1444
- }
1445
- if (t.keepAttributes) {
1446
- const d = t.type.name === "bulletList" || t.type.name === "orderedList" ? "listItem" : "taskList";
1447
- s().updateAttributes(d, o).run();
1448
- }
1449
- const u = i.doc.resolve(n.from - 1).nodeBefore;
1450
- u && u.type === t.type && pe(i.doc, n.from - 1) && (!t.joinPredicate || t.joinPredicate(r, u)) && i.join(n.from - 1);
1451
- }
1452
- });
1453
- }
1454
- class T {
1455
- constructor(e = {}) {
1456
- this.type = "node", this.name = "node", this.parent = null, this.child = null, this.config = {
1457
- name: this.name,
1458
- defaultOptions: {}
1459
- }, this.config = {
1460
- ...this.config,
1461
- ...e
1462
- }, this.name = this.config.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(w(this, "addOptions", {
1463
- name: this.name
1464
- }))), this.storage = b(w(this, "addStorage", {
1465
- name: this.name,
1466
- options: this.options
1467
- })) || {};
1468
- }
1469
- static create(e = {}) {
1470
- return new T(e);
1471
- }
1472
- configure(e = {}) {
1473
- const n = this.extend({
1474
- ...this.config,
1475
- addOptions: () => oe(this.options, e)
1476
- });
1477
- return n.name = this.name, n.parent = this.parent, n;
1478
- }
1479
- extend(e = {}) {
1480
- const n = new T(e);
1481
- return n.parent = this, this.child = n, n.name = e.name ? e.name : n.parent.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`), n.options = b(w(n, "addOptions", {
1482
- name: n.name
1483
- })), n.storage = b(w(n, "addStorage", {
1484
- name: n.name,
1485
- options: n.options
1486
- })), n;
1487
- }
1488
- }
1489
- function J(t) {
1490
- return new Lt({
1491
- find: t.find,
1492
- handler: ({ state: e, range: n, match: r, pasteEvent: s }) => {
1493
- const o = b(t.getAttributes, void 0, r, s);
1494
- if (o === !1 || o === null)
1495
- return null;
1496
- const { tr: i } = e, a = r[r.length - 1], l = r[0];
1497
- let c = n.to;
1498
- if (a) {
1499
- const u = l.search(/\S/), d = n.from + l.indexOf(a), p = d + a.length;
1500
- if (je(n.from, n.to, e.doc).filter((g) => g.mark.type.excluded.find((m) => m === t.type && m !== g.mark.type)).filter((g) => g.to > d).length)
1501
- return null;
1502
- p < n.to && i.delete(p, n.to), d > n.from && i.delete(n.from + u, d), c = n.from + u + a.length, i.addMark(n.from + u, c, t.type.create(o || {})), i.removeStoredMark(t.type);
1503
- }
1504
- }
1505
- });
1506
- }
1507
- function er(t, e) {
1508
- const { selection: n } = t, { $from: r } = n;
1509
- if (n instanceof V) {
1510
- const o = r.index();
1511
- return r.parent.canReplaceWith(o, o + 1, e);
1512
- }
1513
- let s = r.depth;
1514
- for (; s >= 0; ) {
1515
- const o = r.index(s);
1516
- if (r.node(s).contentMatchAt(o).matchType(e))
1517
- return !0;
1518
- s -= 1;
1519
- }
1520
- return !1;
1521
- }
1522
- const tr = /^\s*>\s$/, nr = T.create({
1523
- name: "blockquote",
1524
- addOptions() {
1525
- return {
1526
- HTMLAttributes: {}
1527
- };
1528
- },
1529
- content: "block+",
1530
- group: "block",
1531
- defining: !0,
1532
- parseHTML() {
1533
- return [
1534
- { tag: "blockquote" }
1535
- ];
1536
- },
1537
- renderHTML({ HTMLAttributes: t }) {
1538
- return ["blockquote", S(this.options.HTMLAttributes, t), 0];
1539
- },
1540
- addCommands() {
1541
- return {
1542
- setBlockquote: () => ({ commands: t }) => t.wrapIn(this.name),
1543
- toggleBlockquote: () => ({ commands: t }) => t.toggleWrap(this.name),
1544
- unsetBlockquote: () => ({ commands: t }) => t.lift(this.name)
1545
- };
1546
- },
1547
- addKeyboardShortcuts() {
1548
- return {
1549
- "Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
1550
- };
1551
- },
1552
- addInputRules() {
1553
- return [
1554
- U({
1555
- find: tr,
1556
- type: this.type
1557
- })
1558
- ];
1559
- }
1560
- }), rr = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, sr = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, or = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, ir = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, ar = K.create({
1561
- name: "bold",
1562
- addOptions() {
1563
- return {
1564
- HTMLAttributes: {}
1565
- };
1566
- },
1567
- parseHTML() {
1568
- return [
1569
- {
1570
- tag: "strong"
1571
- },
1572
- {
1573
- tag: "b",
1574
- getAttrs: (t) => t.style.fontWeight !== "normal" && null
1575
- },
1576
- {
1577
- style: "font-weight=400",
1578
- clearMark: (t) => t.type.name === this.name
1579
- },
1580
- {
1581
- style: "font-weight",
1582
- getAttrs: (t) => /^(bold(er)?|[5-9]\d{2,})$/.test(t) && null
1583
- }
1584
- ];
1585
- },
1586
- renderHTML({ HTMLAttributes: t }) {
1587
- return ["strong", S(this.options.HTMLAttributes, t), 0];
1588
- },
1589
- addCommands() {
1590
- return {
1591
- setBold: () => ({ commands: t }) => t.setMark(this.name),
1592
- toggleBold: () => ({ commands: t }) => t.toggleMark(this.name),
1593
- unsetBold: () => ({ commands: t }) => t.unsetMark(this.name)
1594
- };
1595
- },
1596
- addKeyboardShortcuts() {
1597
- return {
1598
- "Mod-b": () => this.editor.commands.toggleBold(),
1599
- "Mod-B": () => this.editor.commands.toggleBold()
1600
- };
1601
- },
1602
- addInputRules() {
1603
- return [
1604
- G({
1605
- find: rr,
1606
- type: this.type
1607
- }),
1608
- G({
1609
- find: or,
1610
- type: this.type
1611
- })
1612
- ];
1613
- },
1614
- addPasteRules() {
1615
- return [
1616
- J({
1617
- find: sr,
1618
- type: this.type
1619
- }),
1620
- J({
1621
- find: ir,
1622
- type: this.type
1623
- })
1624
- ];
1625
- }
1626
- }), lr = "listItem", Ce = "textStyle", Ae = /^\s*([-+*])\s$/, cr = T.create({
1627
- name: "bulletList",
1628
- addOptions() {
1629
- return {
1630
- itemTypeName: "listItem",
1631
- HTMLAttributes: {},
1632
- keepMarks: !1,
1633
- keepAttributes: !1
1634
- };
1635
- },
1636
- group: "block list",
1637
- content() {
1638
- return `${this.options.itemTypeName}+`;
1639
- },
1640
- parseHTML() {
1641
- return [
1642
- { tag: "ul" }
1643
- ];
1644
- },
1645
- renderHTML({ HTMLAttributes: t }) {
1646
- return ["ul", S(this.options.HTMLAttributes, t), 0];
1647
- },
1648
- addCommands() {
1649
- return {
1650
- toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(lr, this.editor.getAttributes(Ce)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
1651
- };
1652
- },
1653
- addKeyboardShortcuts() {
1654
- return {
1655
- "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
1656
- };
1657
- },
1658
- addInputRules() {
1659
- let t = U({
1660
- find: Ae,
1661
- type: this.type
1662
- });
1663
- return (this.options.keepMarks || this.options.keepAttributes) && (t = U({
1664
- find: Ae,
1665
- type: this.type,
1666
- keepMarks: this.options.keepMarks,
1667
- keepAttributes: this.options.keepAttributes,
1668
- getAttributes: () => this.editor.getAttributes(Ce),
1669
- editor: this.editor
1670
- })), [
1671
- t
1672
- ];
1673
- }
1674
- }), dr = /(^|[^`])`([^`]+)`(?!`)/, ur = /(^|[^`])`([^`]+)`(?!`)/g, pr = K.create({
1675
- name: "code",
1676
- addOptions() {
1677
- return {
1678
- HTMLAttributes: {}
1679
- };
1680
- },
1681
- excludes: "_",
1682
- code: !0,
1683
- exitable: !0,
1684
- parseHTML() {
1685
- return [
1686
- { tag: "code" }
1687
- ];
1688
- },
1689
- renderHTML({ HTMLAttributes: t }) {
1690
- return ["code", S(this.options.HTMLAttributes, t), 0];
1691
- },
1692
- addCommands() {
1693
- return {
1694
- setCode: () => ({ commands: t }) => t.setMark(this.name),
1695
- toggleCode: () => ({ commands: t }) => t.toggleMark(this.name),
1696
- unsetCode: () => ({ commands: t }) => t.unsetMark(this.name)
1697
- };
1698
- },
1699
- addKeyboardShortcuts() {
1700
- return {
1701
- "Mod-e": () => this.editor.commands.toggleCode()
1702
- };
1703
- },
1704
- addInputRules() {
1705
- return [
1706
- G({
1707
- find: dr,
1708
- type: this.type
1709
- })
1710
- ];
1711
- },
1712
- addPasteRules() {
1713
- return [
1714
- J({
1715
- find: ur,
1716
- type: this.type
1717
- })
1718
- ];
1719
- }
1720
- }), fr = /^```([a-z]+)?[\s\n]$/, hr = /^~~~([a-z]+)?[\s\n]$/, mr = T.create({
1721
- name: "codeBlock",
1722
- addOptions() {
1723
- return {
1724
- languageClassPrefix: "language-",
1725
- exitOnTripleEnter: !0,
1726
- exitOnArrowDown: !0,
1727
- defaultLanguage: null,
1728
- HTMLAttributes: {}
1729
- };
1730
- },
1731
- content: "text*",
1732
- marks: "",
1733
- group: "block",
1734
- code: !0,
1735
- defining: !0,
1736
- addAttributes() {
1737
- return {
1738
- language: {
1739
- default: this.options.defaultLanguage,
1740
- parseHTML: (t) => {
1741
- var e;
1742
- const { languageClassPrefix: n } = this.options, o = [...((e = t.firstElementChild) === null || e === void 0 ? void 0 : e.classList) || []].filter((i) => i.startsWith(n)).map((i) => i.replace(n, ""))[0];
1743
- return o || null;
1744
- },
1745
- rendered: !1
1746
- }
1747
- };
1748
- },
1749
- parseHTML() {
1750
- return [
1751
- {
1752
- tag: "pre",
1753
- preserveWhitespace: "full"
1754
- }
1755
- ];
1756
- },
1757
- renderHTML({ node: t, HTMLAttributes: e }) {
1758
- return [
1759
- "pre",
1760
- S(this.options.HTMLAttributes, e),
1761
- [
1762
- "code",
1763
- {
1764
- class: t.attrs.language ? this.options.languageClassPrefix + t.attrs.language : null
1765
- },
1766
- 0
1767
- ]
1768
- ];
1769
- },
1770
- addCommands() {
1771
- return {
1772
- setCodeBlock: (t) => ({ commands: e }) => e.setNode(this.name, t),
1773
- toggleCodeBlock: (t) => ({ commands: e }) => e.toggleNode(this.name, "paragraph", t)
1774
- };
1775
- },
1776
- addKeyboardShortcuts() {
1777
- return {
1778
- "Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
1779
- // remove code block when at start of document or code block is empty
1780
- Backspace: () => {
1781
- const { empty: t, $anchor: e } = this.editor.state.selection, n = e.pos === 1;
1782
- return !t || e.parent.type.name !== this.name ? !1 : n || !e.parent.textContent.length ? this.editor.commands.clearNodes() : !1;
1783
- },
1784
- // exit node on triple enter
1785
- Enter: ({ editor: t }) => {
1786
- if (!this.options.exitOnTripleEnter)
1787
- return !1;
1788
- const { state: e } = t, { selection: n } = e, { $from: r, empty: s } = n;
1789
- if (!s || r.parent.type !== this.type)
1790
- return !1;
1791
- const o = r.parentOffset === r.parent.nodeSize - 2, i = r.parent.textContent.endsWith(`
1792
-
1793
- `);
1794
- return !o || !i ? !1 : t.chain().command(({ tr: a }) => (a.delete(r.pos - 2, r.pos), !0)).exitCode().run();
1795
- },
1796
- // exit node on arrow down
1797
- ArrowDown: ({ editor: t }) => {
1798
- if (!this.options.exitOnArrowDown)
1799
- return !1;
1800
- const { state: e } = t, { selection: n, doc: r } = e, { $from: s, empty: o } = n;
1801
- if (!o || s.parent.type !== this.type || !(s.parentOffset === s.parent.nodeSize - 2))
1802
- return !1;
1803
- const a = s.after();
1804
- return a === void 0 ? !1 : r.nodeAt(a) ? t.commands.command(({ tr: c }) => (c.setSelection(L.near(r.resolve(a))), !0)) : t.commands.exitCode();
1805
- }
1806
- };
1807
- },
1808
- addInputRules() {
1809
- return [
1810
- ue({
1811
- find: fr,
1812
- type: this.type,
1813
- getAttributes: (t) => ({
1814
- language: t[1]
1815
- })
1816
- }),
1817
- ue({
1818
- find: hr,
1819
- type: this.type,
1820
- getAttributes: (t) => ({
1821
- language: t[1]
1822
- })
1823
- })
1824
- ];
1825
- },
1826
- addProseMirrorPlugins() {
1827
- return [
1828
- // this plugin creates a code block for pasted content from VS Code
1829
- // we can also detect the copied code language
1830
- new I({
1831
- key: new P("codeBlockVSCodeHandler"),
1832
- props: {
1833
- handlePaste: (t, e) => {
1834
- if (!e.clipboardData || this.editor.isActive(this.type.name))
1835
- return !1;
1836
- const n = e.clipboardData.getData("text/plain"), r = e.clipboardData.getData("vscode-editor-data"), s = r ? JSON.parse(r) : void 0, o = s == null ? void 0 : s.mode;
1837
- if (!n || !o)
1838
- return !1;
1839
- const { tr: i, schema: a } = t.state, l = a.text(n.replace(/\r\n?/g, `
1840
- `));
1841
- return i.replaceSelectionWith(this.type.create({ language: o }, l)), i.selection.$from.parent.type !== this.type && i.setSelection(x.near(i.doc.resolve(Math.max(0, i.selection.from - 2)))), i.setMeta("paste", !0), t.dispatch(i), !0;
1842
- }
1843
- }
1844
- })
1845
- ];
1846
- }
1847
- }), gr = T.create({
1848
- name: "doc",
1849
- topNode: !0,
1850
- content: "block+"
1851
- });
1852
- function yr(t = {}) {
1853
- return new I({
1854
- view(e) {
1855
- return new kr(e, t);
1856
- }
1857
- });
1858
- }
1859
- class kr {
1860
- constructor(e, n) {
1861
- var r;
1862
- this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (r = n.width) !== null && r !== void 0 ? r : 1, this.color = n.color === !1 ? void 0 : n.color || "black", this.class = n.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((s) => {
1863
- let o = (i) => {
1864
- this[s](i);
1865
- };
1866
- return e.dom.addEventListener(s, o), { name: s, handler: o };
1867
- });
1868
- }
1869
- destroy() {
1870
- this.handlers.forEach(({ name: e, handler: n }) => this.editorView.dom.removeEventListener(e, n));
1871
- }
1872
- update(e, n) {
1873
- this.cursorPos != null && n.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
1874
- }
1875
- setCursor(e) {
1876
- e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
1877
- }
1878
- updateOverlay() {
1879
- let e = this.editorView.state.doc.resolve(this.cursorPos), n = !e.parent.inlineContent, r, s = this.editorView.dom, o = s.getBoundingClientRect(), i = o.width / s.offsetWidth, a = o.height / s.offsetHeight;
1880
- if (n) {
1881
- let d = e.nodeBefore, p = e.nodeAfter;
1882
- if (d || p) {
1883
- let f = this.editorView.nodeDOM(this.cursorPos - (d ? d.nodeSize : 0));
1884
- if (f) {
1885
- let g = f.getBoundingClientRect(), h = d ? g.bottom : g.top;
1886
- d && p && (h = (h + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
1887
- let m = this.width / 2 * a;
1888
- r = { left: g.left, right: g.right, top: h - m, bottom: h + m };
1889
- }
1890
- }
1891
- }
1892
- if (!r) {
1893
- let d = this.editorView.coordsAtPos(this.cursorPos), p = this.width / 2 * i;
1894
- r = { left: d.left - p, right: d.left + p, top: d.top, bottom: d.bottom };
1895
- }
1896
- let l = this.editorView.dom.offsetParent;
1897
- this.element || (this.element = l.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", n), this.element.classList.toggle("prosemirror-dropcursor-inline", !n);
1898
- let c, u;
1899
- if (!l || l == document.body && getComputedStyle(l).position == "static")
1900
- c = -pageXOffset, u = -pageYOffset;
1901
- else {
1902
- let d = l.getBoundingClientRect(), p = d.width / l.offsetWidth, f = d.height / l.offsetHeight;
1903
- c = d.left - l.scrollLeft * p, u = d.top - l.scrollTop * f;
1904
- }
1905
- this.element.style.left = (r.left - c) / i + "px", this.element.style.top = (r.top - u) / a + "px", this.element.style.width = (r.right - r.left) / i + "px", this.element.style.height = (r.bottom - r.top) / a + "px";
1906
- }
1907
- scheduleRemoval(e) {
1908
- clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
1909
- }
1910
- dragover(e) {
1911
- if (!this.editorView.editable)
1912
- return;
1913
- let n = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), r = n && n.inside >= 0 && this.editorView.state.doc.nodeAt(n.inside), s = r && r.type.spec.disableDropCursor, o = typeof s == "function" ? s(this.editorView, n, e) : s;
1914
- if (n && !o) {
1915
- let i = n.pos;
1916
- if (this.editorView.dragging && this.editorView.dragging.slice) {
1917
- let a = xt(this.editorView.state.doc, i, this.editorView.dragging.slice);
1918
- a != null && (i = a);
1919
- }
1920
- this.setCursor(i), this.scheduleRemoval(5e3);
1921
- }
1922
- }
1923
- dragend() {
1924
- this.scheduleRemoval(20);
1925
- }
1926
- drop() {
1927
- this.scheduleRemoval(20);
1928
- }
1929
- dragleave(e) {
1930
- this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
1931
- }
1932
- }
1933
- const Mr = A.create({
1934
- name: "dropCursor",
1935
- addOptions() {
1936
- return {
1937
- color: "currentColor",
1938
- width: 1,
1939
- class: void 0
1940
- };
1941
- },
1942
- addProseMirrorPlugins() {
1943
- return [
1944
- yr(this.options)
1945
- ];
1946
- }
1947
- });
1948
- class M extends L {
1949
- /**
1950
- Create a gap cursor.
1951
- */
1952
- constructor(e) {
1953
- super(e, e);
1954
- }
1955
- map(e, n) {
1956
- let r = e.resolve(n.map(this.head));
1957
- return M.valid(r) ? new M(r) : L.near(r);
1958
- }
1959
- content() {
1960
- return fe.empty;
1961
- }
1962
- eq(e) {
1963
- return e instanceof M && e.head == this.head;
1964
- }
1965
- toJSON() {
1966
- return { type: "gapcursor", pos: this.head };
1967
- }
1968
- /**
1969
- @internal
1970
- */
1971
- static fromJSON(e, n) {
1972
- if (typeof n.pos != "number")
1973
- throw new RangeError("Invalid input for GapCursor.fromJSON");
1974
- return new M(e.resolve(n.pos));
1975
- }
1976
- /**
1977
- @internal
1978
- */
1979
- getBookmark() {
1980
- return new ke(this.anchor);
1981
- }
1982
- /**
1983
- @internal
1984
- */
1985
- static valid(e) {
1986
- let n = e.parent;
1987
- if (n.isTextblock || !br(e) || !vr(e))
1988
- return !1;
1989
- let r = n.type.spec.allowGapCursor;
1990
- if (r != null)
1991
- return r;
1992
- let s = n.contentMatchAt(e.index()).defaultType;
1993
- return s && s.isTextblock;
1994
- }
1995
- /**
1996
- @internal
1997
- */
1998
- static findGapCursorFrom(e, n, r = !1) {
1999
- e: for (; ; ) {
2000
- if (!r && M.valid(e))
2001
- return e;
2002
- let s = e.pos, o = null;
2003
- for (let i = e.depth; ; i--) {
2004
- let a = e.node(i);
2005
- if (n > 0 ? e.indexAfter(i) < a.childCount : e.index(i) > 0) {
2006
- o = a.child(n > 0 ? e.indexAfter(i) : e.index(i) - 1);
2007
- break;
2008
- } else if (i == 0)
2009
- return null;
2010
- s += n;
2011
- let l = e.doc.resolve(s);
2012
- if (M.valid(l))
2013
- return l;
2014
- }
2015
- for (; ; ) {
2016
- let i = n > 0 ? o.firstChild : o.lastChild;
2017
- if (!i) {
2018
- if (o.isAtom && !o.isText && !V.isSelectable(o)) {
2019
- e = e.doc.resolve(s + o.nodeSize * n), r = !1;
2020
- continue e;
2021
- }
2022
- break;
2023
- }
2024
- o = i, s += n;
2025
- let a = e.doc.resolve(s);
2026
- if (M.valid(a))
2027
- return a;
2028
- }
2029
- return null;
2030
- }
2031
- }
2032
- }
2033
- M.prototype.visible = !1;
2034
- M.findFrom = M.findGapCursorFrom;
2035
- L.jsonID("gapcursor", M);
2036
- class ke {
2037
- constructor(e) {
2038
- this.pos = e;
2039
- }
2040
- map(e) {
2041
- return new ke(e.map(this.pos));
2042
- }
2043
- resolve(e) {
2044
- let n = e.resolve(this.pos);
2045
- return M.valid(n) ? new M(n) : L.near(n);
2046
- }
2047
- }
2048
- function De(t) {
2049
- return t.isAtom || t.spec.isolating || t.spec.createGapCursor;
2050
- }
2051
- function br(t) {
2052
- for (let e = t.depth; e >= 0; e--) {
2053
- let n = t.index(e), r = t.node(e);
2054
- if (n == 0) {
2055
- if (r.type.spec.isolating)
2056
- return !0;
2057
- continue;
2058
- }
2059
- for (let s = r.child(n - 1); ; s = s.lastChild) {
2060
- if (s.childCount == 0 && !s.inlineContent || De(s.type))
2061
- return !0;
2062
- if (s.inlineContent)
2063
- return !1;
2064
- }
2065
- }
2066
- return !0;
2067
- }
2068
- function vr(t) {
2069
- for (let e = t.depth; e >= 0; e--) {
2070
- let n = t.indexAfter(e), r = t.node(e);
2071
- if (n == r.childCount) {
2072
- if (r.type.spec.isolating)
2073
- return !0;
2074
- continue;
2075
- }
2076
- for (let s = r.child(n); ; s = s.firstChild) {
2077
- if (s.childCount == 0 && !s.inlineContent || De(s.type))
2078
- return !0;
2079
- if (s.inlineContent)
2080
- return !1;
2081
- }
2082
- }
2083
- return !0;
2084
- }
2085
- function wr() {
2086
- return new I({
2087
- props: {
2088
- decorations: Sr,
2089
- createSelectionBetween(t, e, n) {
2090
- return e.pos == n.pos && M.valid(n) ? new M(n) : null;
2091
- },
2092
- handleClick: Cr,
2093
- handleKeyDown: xr,
2094
- handleDOMEvents: { beforeinput: Ar }
2095
- }
2096
- });
2097
- }
2098
- const xr = Ct({
2099
- ArrowLeft: Q("horiz", -1),
2100
- ArrowRight: Q("horiz", 1),
2101
- ArrowUp: Q("vert", -1),
2102
- ArrowDown: Q("vert", 1)
2103
- });
2104
- function Q(t, e) {
2105
- const n = t == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
2106
- return function(r, s, o) {
2107
- let i = r.selection, a = e > 0 ? i.$to : i.$from, l = i.empty;
2108
- if (i instanceof x) {
2109
- if (!o.endOfTextblock(n) || a.depth == 0)
2110
- return !1;
2111
- l = !1, a = r.doc.resolve(e > 0 ? a.after() : a.before());
2112
- }
2113
- let c = M.findGapCursorFrom(a, e, l);
2114
- return c ? (s && s(r.tr.setSelection(new M(c))), !0) : !1;
2115
- };
2116
- }
2117
- function Cr(t, e, n) {
2118
- if (!t || !t.editable)
2119
- return !1;
2120
- let r = t.state.doc.resolve(e);
2121
- if (!M.valid(r))
2122
- return !1;
2123
- let s = t.posAtCoords({ left: n.clientX, top: n.clientY });
2124
- return s && s.inside > -1 && V.isSelectable(t.state.doc.nodeAt(s.inside)) ? !1 : (t.dispatch(t.state.tr.setSelection(new M(r))), !0);
2125
- }
2126
- function Ar(t, e) {
2127
- if (e.inputType != "insertCompositionText" || !(t.state.selection instanceof M))
2128
- return !1;
2129
- let { $from: n } = t.state.selection, r = n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);
2130
- if (!r)
2131
- return !1;
2132
- let s = j.empty;
2133
- for (let i = r.length - 1; i >= 0; i--)
2134
- s = j.from(r[i].createAndFill(null, s));
2135
- let o = t.state.tr.replace(n.pos, n.pos, new fe(s, 0, 0));
2136
- return o.setSelection(x.near(o.doc.resolve(n.pos + 1))), t.dispatch(o), !1;
2137
- }
2138
- function Sr(t) {
2139
- if (!(t.selection instanceof M))
2140
- return null;
2141
- let e = document.createElement("div");
2142
- return e.className = "ProseMirror-gapcursor", Le.create(t.doc, [Oe.widget(t.selection.head, e, { key: "gapcursor" })]);
2143
- }
2144
- const Tr = A.create({
2145
- name: "gapCursor",
2146
- addProseMirrorPlugins() {
2147
- return [
2148
- wr()
2149
- ];
2150
- },
2151
- extendNodeSchema(t) {
2152
- var e;
2153
- const n = {
2154
- name: t.name,
2155
- options: t.options,
2156
- storage: t.storage
2157
- };
2158
- return {
2159
- allowGapCursor: (e = b(w(t, "allowGapCursor", n))) !== null && e !== void 0 ? e : null
2160
- };
2161
- }
2162
- }), Ir = T.create({
2163
- name: "hardBreak",
2164
- addOptions() {
2165
- return {
2166
- keepMarks: !0,
2167
- HTMLAttributes: {}
2168
- };
2169
- },
2170
- inline: !0,
2171
- group: "inline",
2172
- selectable: !1,
2173
- linebreakReplacement: !0,
2174
- parseHTML() {
2175
- return [
2176
- { tag: "br" }
2177
- ];
2178
- },
2179
- renderHTML({ HTMLAttributes: t }) {
2180
- return ["br", S(this.options.HTMLAttributes, t)];
2181
- },
2182
- renderText() {
2183
- return `
2184
- `;
2185
- },
2186
- addCommands() {
2187
- return {
2188
- setHardBreak: () => ({ commands: t, chain: e, state: n, editor: r }) => t.first([
2189
- () => t.exitCode(),
2190
- () => t.command(() => {
2191
- const { selection: s, storedMarks: o } = n;
2192
- if (s.$from.parent.type.spec.isolating)
2193
- return !1;
2194
- const { keepMarks: i } = this.options, { splittableMarks: a } = r.extensionManager, l = o || s.$to.parentOffset && s.$from.marks();
2195
- return e().insertContent({ type: this.name }).command(({ tr: c, dispatch: u }) => {
2196
- if (u && l && i) {
2197
- const d = l.filter((p) => a.includes(p.type.name));
2198
- c.ensureMarks(d);
2199
- }
2200
- return !0;
2201
- }).run();
2202
- })
2203
- ])
2204
- };
2205
- },
2206
- addKeyboardShortcuts() {
2207
- return {
2208
- "Mod-Enter": () => this.editor.commands.setHardBreak(),
2209
- "Shift-Enter": () => this.editor.commands.setHardBreak()
2210
- };
2211
- }
2212
- }), Er = T.create({
2213
- name: "heading",
2214
- addOptions() {
2215
- return {
2216
- levels: [1, 2, 3, 4, 5, 6],
2217
- HTMLAttributes: {}
2218
- };
2219
- },
2220
- content: "inline*",
2221
- group: "block",
2222
- defining: !0,
2223
- addAttributes() {
2224
- return {
2225
- level: {
2226
- default: 1,
2227
- rendered: !1
2228
- }
2229
- };
2230
- },
2231
- parseHTML() {
2232
- return this.options.levels.map((t) => ({
2233
- tag: `h${t}`,
2234
- attrs: { level: t }
2235
- }));
2236
- },
2237
- renderHTML({ node: t, HTMLAttributes: e }) {
2238
- return [`h${this.options.levels.includes(t.attrs.level) ? t.attrs.level : this.options.levels[0]}`, S(this.options.HTMLAttributes, e), 0];
2239
- },
2240
- addCommands() {
2241
- return {
2242
- setHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.setNode(this.name, t) : !1,
2243
- toggleHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.toggleNode(this.name, "paragraph", t) : !1
2244
- };
2245
- },
2246
- addKeyboardShortcuts() {
2247
- return this.options.levels.reduce((t, e) => ({
2248
- ...t,
2249
- [`Mod-Alt-${e}`]: () => this.editor.commands.toggleHeading({ level: e })
2250
- }), {});
2251
- },
2252
- addInputRules() {
2253
- return this.options.levels.map((t) => ue({
2254
- find: new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),
2255
- type: this.type,
2256
- getAttributes: {
2257
- level: t
2258
- }
2259
- }));
2260
- }
2261
- });
2262
- var re = 200, v = function() {
2263
- };
2264
- v.prototype.append = function(e) {
2265
- return e.length ? (e = v.from(e), !this.length && e || e.length < re && this.leafAppend(e) || this.length < re && e.leafPrepend(this) || this.appendInner(e)) : this;
2266
- };
2267
- v.prototype.prepend = function(e) {
2268
- return e.length ? v.from(e).append(this) : this;
2269
- };
2270
- v.prototype.appendInner = function(e) {
2271
- return new Or(this, e);
2272
- };
2273
- v.prototype.slice = function(e, n) {
2274
- return e === void 0 && (e = 0), n === void 0 && (n = this.length), e >= n ? v.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, n));
2275
- };
2276
- v.prototype.get = function(e) {
2277
- if (!(e < 0 || e >= this.length))
2278
- return this.getInner(e);
2279
- };
2280
- v.prototype.forEach = function(e, n, r) {
2281
- n === void 0 && (n = 0), r === void 0 && (r = this.length), n <= r ? this.forEachInner(e, n, r, 0) : this.forEachInvertedInner(e, n, r, 0);
2282
- };
2283
- v.prototype.map = function(e, n, r) {
2284
- n === void 0 && (n = 0), r === void 0 && (r = this.length);
2285
- var s = [];
2286
- return this.forEach(function(o, i) {
2287
- return s.push(e(o, i));
2288
- }, n, r), s;
2289
- };
2290
- v.from = function(e) {
2291
- return e instanceof v ? e : e && e.length ? new ze(e) : v.empty;
2292
- };
2293
- var ze = /* @__PURE__ */ function(t) {
2294
- function e(r) {
2295
- t.call(this), this.values = r;
2296
- }
2297
- t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e;
2298
- var n = { length: { configurable: !0 }, depth: { configurable: !0 } };
2299
- return e.prototype.flatten = function() {
2300
- return this.values;
2301
- }, e.prototype.sliceInner = function(s, o) {
2302
- return s == 0 && o == this.length ? this : new e(this.values.slice(s, o));
2303
- }, e.prototype.getInner = function(s) {
2304
- return this.values[s];
2305
- }, e.prototype.forEachInner = function(s, o, i, a) {
2306
- for (var l = o; l < i; l++)
2307
- if (s(this.values[l], a + l) === !1)
2308
- return !1;
2309
- }, e.prototype.forEachInvertedInner = function(s, o, i, a) {
2310
- for (var l = o - 1; l >= i; l--)
2311
- if (s(this.values[l], a + l) === !1)
2312
- return !1;
2313
- }, e.prototype.leafAppend = function(s) {
2314
- if (this.length + s.length <= re)
2315
- return new e(this.values.concat(s.flatten()));
2316
- }, e.prototype.leafPrepend = function(s) {
2317
- if (this.length + s.length <= re)
2318
- return new e(s.flatten().concat(this.values));
2319
- }, n.length.get = function() {
2320
- return this.values.length;
2321
- }, n.depth.get = function() {
2322
- return 0;
2323
- }, Object.defineProperties(e.prototype, n), e;
2324
- }(v);
2325
- v.empty = new ze([]);
2326
- var Or = /* @__PURE__ */ function(t) {
2327
- function e(n, r) {
2328
- t.call(this), this.left = n, this.right = r, this.length = n.length + r.length, this.depth = Math.max(n.depth, r.depth) + 1;
2329
- }
2330
- return t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
2331
- return this.left.flatten().concat(this.right.flatten());
2332
- }, e.prototype.getInner = function(r) {
2333
- return r < this.left.length ? this.left.get(r) : this.right.get(r - this.left.length);
2334
- }, e.prototype.forEachInner = function(r, s, o, i) {
2335
- var a = this.left.length;
2336
- if (s < a && this.left.forEachInner(r, s, Math.min(o, a), i) === !1 || o > a && this.right.forEachInner(r, Math.max(s - a, 0), Math.min(this.length, o) - a, i + a) === !1)
2337
- return !1;
2338
- }, e.prototype.forEachInvertedInner = function(r, s, o, i) {
2339
- var a = this.left.length;
2340
- if (s > a && this.right.forEachInvertedInner(r, s - a, Math.max(o, a) - a, i + a) === !1 || o < a && this.left.forEachInvertedInner(r, Math.min(s, a), o, i) === !1)
2341
- return !1;
2342
- }, e.prototype.sliceInner = function(r, s) {
2343
- if (r == 0 && s == this.length)
2344
- return this;
2345
- var o = this.left.length;
2346
- return s <= o ? this.left.slice(r, s) : r >= o ? this.right.slice(r - o, s - o) : this.left.slice(r, o).append(this.right.slice(0, s - o));
2347
- }, e.prototype.leafAppend = function(r) {
2348
- var s = this.right.leafAppend(r);
2349
- if (s)
2350
- return new e(this.left, s);
2351
- }, e.prototype.leafPrepend = function(r) {
2352
- var s = this.left.leafPrepend(r);
2353
- if (s)
2354
- return new e(s, this.right);
2355
- }, e.prototype.appendInner = function(r) {
2356
- return this.left.depth >= Math.max(this.right.depth, r.depth) + 1 ? new e(this.left, new e(this.right, r)) : new e(this, r);
2357
- }, e;
2358
- }(v);
2359
- const Lr = 500;
2360
- class O {
2361
- constructor(e, n) {
2362
- this.items = e, this.eventCount = n;
2363
- }
2364
- // Pop the latest event off the branch's history and apply it
2365
- // to a document transform.
2366
- popEvent(e, n) {
2367
- if (this.eventCount == 0)
2368
- return null;
2369
- let r = this.items.length;
2370
- for (; ; r--)
2371
- if (this.items.get(r - 1).selection) {
2372
- --r;
2373
- break;
2374
- }
2375
- let s, o;
2376
- n && (s = this.remapping(r, this.items.length), o = s.maps.length);
2377
- let i = e.tr, a, l, c = [], u = [];
2378
- return this.items.forEach((d, p) => {
2379
- if (!d.step) {
2380
- s || (s = this.remapping(r, p + 1), o = s.maps.length), o--, u.push(d);
2381
- return;
2382
- }
2383
- if (s) {
2384
- u.push(new B(d.map));
2385
- let f = d.step.map(s.slice(o)), g;
2386
- f && i.maybeStep(f).doc && (g = i.mapping.maps[i.mapping.maps.length - 1], c.push(new B(g, void 0, void 0, c.length + u.length))), o--, g && s.appendMap(g, o);
2387
- } else
2388
- i.maybeStep(d.step);
2389
- if (d.selection)
2390
- return a = s ? d.selection.map(s.slice(o)) : d.selection, l = new O(this.items.slice(0, r).append(u.reverse().concat(c)), this.eventCount - 1), !1;
2391
- }, this.items.length, 0), { remaining: l, transform: i, selection: a };
2392
- }
2393
- // Create a new branch with the given transform added.
2394
- addTransform(e, n, r, s) {
2395
- let o = [], i = this.eventCount, a = this.items, l = !s && a.length ? a.get(a.length - 1) : null;
2396
- for (let u = 0; u < e.steps.length; u++) {
2397
- let d = e.steps[u].invert(e.docs[u]), p = new B(e.mapping.maps[u], d, n), f;
2398
- (f = l && l.merge(p)) && (p = f, u ? o.pop() : a = a.slice(0, a.length - 1)), o.push(p), n && (i++, n = void 0), s || (l = p);
2399
- }
2400
- let c = i - r.depth;
2401
- return c > $r && (a = Pr(a, c), i -= c), new O(a.append(o), i);
2402
- }
2403
- remapping(e, n) {
2404
- let r = new At();
2405
- return this.items.forEach((s, o) => {
2406
- let i = s.mirrorOffset != null && o - s.mirrorOffset >= e ? r.maps.length - s.mirrorOffset : void 0;
2407
- r.appendMap(s.map, i);
2408
- }, e, n), r;
2409
- }
2410
- addMaps(e) {
2411
- return this.eventCount == 0 ? this : new O(this.items.append(e.map((n) => new B(n))), this.eventCount);
2412
- }
2413
- // When the collab module receives remote changes, the history has
2414
- // to know about those, so that it can adjust the steps that were
2415
- // rebased on top of the remote changes, and include the position
2416
- // maps for the remote changes in its array of items.
2417
- rebased(e, n) {
2418
- if (!this.eventCount)
2419
- return this;
2420
- let r = [], s = Math.max(0, this.items.length - n), o = e.mapping, i = e.steps.length, a = this.eventCount;
2421
- this.items.forEach((p) => {
2422
- p.selection && a--;
2423
- }, s);
2424
- let l = n;
2425
- this.items.forEach((p) => {
2426
- let f = o.getMirror(--l);
2427
- if (f == null)
2428
- return;
2429
- i = Math.min(i, f);
2430
- let g = o.maps[f];
2431
- if (p.step) {
2432
- let h = e.steps[f].invert(e.docs[f]), m = p.selection && p.selection.map(o.slice(l + 1, f));
2433
- m && a++, r.push(new B(g, h, m));
2434
- } else
2435
- r.push(new B(g));
2436
- }, s);
2437
- let c = [];
2438
- for (let p = n; p < i; p++)
2439
- c.push(new B(o.maps[p]));
2440
- let u = this.items.slice(0, s).append(c).append(r), d = new O(u, a);
2441
- return d.emptyItemCount() > Lr && (d = d.compress(this.items.length - r.length)), d;
2442
- }
2443
- emptyItemCount() {
2444
- let e = 0;
2445
- return this.items.forEach((n) => {
2446
- n.step || e++;
2447
- }), e;
2448
- }
2449
- // Compressing a branch means rewriting it to push the air (map-only
2450
- // items) out. During collaboration, these naturally accumulate
2451
- // because each remote change adds one. The `upto` argument is used
2452
- // to ensure that only the items below a given level are compressed,
2453
- // because `rebased` relies on a clean, untouched set of items in
2454
- // order to associate old items with rebased steps.
2455
- compress(e = this.items.length) {
2456
- let n = this.remapping(0, e), r = n.maps.length, s = [], o = 0;
2457
- return this.items.forEach((i, a) => {
2458
- if (a >= e)
2459
- s.push(i), i.selection && o++;
2460
- else if (i.step) {
2461
- let l = i.step.map(n.slice(r)), c = l && l.getMap();
2462
- if (r--, c && n.appendMap(c, r), l) {
2463
- let u = i.selection && i.selection.map(n.slice(r));
2464
- u && o++;
2465
- let d = new B(c.invert(), l, u), p, f = s.length - 1;
2466
- (p = s.length && s[f].merge(d)) ? s[f] = p : s.push(d);
2467
- }
2468
- } else i.map && r--;
2469
- }, this.items.length, 0), new O(v.from(s.reverse()), o);
2470
- }
2471
- }
2472
- O.empty = new O(v.empty, 0);
2473
- function Pr(t, e) {
2474
- let n;
2475
- return t.forEach((r, s) => {
2476
- if (r.selection && e-- == 0)
2477
- return n = s, !1;
2478
- }), t.slice(n);
2479
- }
2480
- class B {
2481
- constructor(e, n, r, s) {
2482
- this.map = e, this.step = n, this.selection = r, this.mirrorOffset = s;
2483
- }
2484
- merge(e) {
2485
- if (this.step && e.step && !e.selection) {
2486
- let n = e.step.merge(this.step);
2487
- if (n)
2488
- return new B(n.getMap().invert(), n, this.selection);
2489
- }
2490
- }
2491
- }
2492
- class _ {
2493
- constructor(e, n, r, s, o) {
2494
- this.done = e, this.undone = n, this.prevRanges = r, this.prevTime = s, this.prevComposition = o;
2495
- }
2496
- }
2497
- const $r = 20;
2498
- function Br(t, e, n, r) {
2499
- let s = n.getMeta(z), o;
2500
- if (s)
2501
- return s.historyState;
2502
- n.getMeta(Hr) && (t = new _(t.done, t.undone, null, 0, -1));
2503
- let i = n.getMeta("appendedTransaction");
2504
- if (n.steps.length == 0)
2505
- return t;
2506
- if (i && i.getMeta(z))
2507
- return i.getMeta(z).redo ? new _(t.done.addTransform(n, void 0, r, te(e)), t.undone, Se(n.mapping.maps), t.prevTime, t.prevComposition) : new _(t.done, t.undone.addTransform(n, void 0, r, te(e)), null, t.prevTime, t.prevComposition);
2508
- if (n.getMeta("addToHistory") !== !1 && !(i && i.getMeta("addToHistory") === !1)) {
2509
- let a = n.getMeta("composition"), l = t.prevTime == 0 || !i && t.prevComposition != a && (t.prevTime < (n.time || 0) - r.newGroupDelay || !Nr(n, t.prevRanges)), c = i ? ce(t.prevRanges, n.mapping) : Se(n.mapping.maps);
2510
- return new _(t.done.addTransform(n, l ? e.selection.getBookmark() : void 0, r, te(e)), O.empty, c, n.time, a ?? t.prevComposition);
2511
- } else return (o = n.getMeta("rebased")) ? new _(t.done.rebased(n, o), t.undone.rebased(n, o), ce(t.prevRanges, n.mapping), t.prevTime, t.prevComposition) : new _(t.done.addMaps(n.mapping.maps), t.undone.addMaps(n.mapping.maps), ce(t.prevRanges, n.mapping), t.prevTime, t.prevComposition);
2512
- }
2513
- function Nr(t, e) {
2514
- if (!e)
2515
- return !1;
2516
- if (!t.docChanged)
2517
- return !0;
2518
- let n = !1;
2519
- return t.mapping.maps[0].forEach((r, s) => {
2520
- for (let o = 0; o < e.length; o += 2)
2521
- r <= e[o + 1] && s >= e[o] && (n = !0);
2522
- }), n;
2523
- }
2524
- function Se(t) {
2525
- let e = [];
2526
- for (let n = t.length - 1; n >= 0 && e.length == 0; n--)
2527
- t[n].forEach((r, s, o, i) => e.push(o, i));
2528
- return e;
2529
- }
2530
- function ce(t, e) {
2531
- if (!t)
2532
- return null;
2533
- let n = [];
2534
- for (let r = 0; r < t.length; r += 2) {
2535
- let s = e.map(t[r], 1), o = e.map(t[r + 1], -1);
2536
- s <= o && n.push(s, o);
2537
- }
2538
- return n;
2539
- }
2540
- function Rr(t, e, n) {
2541
- let r = te(e), s = z.get(e).spec.config, o = (n ? t.undone : t.done).popEvent(e, r);
2542
- if (!o)
2543
- return null;
2544
- let i = o.selection.resolve(o.transform.doc), a = (n ? t.done : t.undone).addTransform(o.transform, e.selection.getBookmark(), s, r), l = new _(n ? a : o.remaining, n ? o.remaining : a, null, 0, -1);
2545
- return o.transform.setSelection(i).setMeta(z, { redo: n, historyState: l });
2546
- }
2547
- let de = !1, Te = null;
2548
- function te(t) {
2549
- let e = t.plugins;
2550
- if (Te != e) {
2551
- de = !1, Te = e;
2552
- for (let n = 0; n < e.length; n++)
2553
- if (e[n].spec.historyPreserveItems) {
2554
- de = !0;
2555
- break;
2556
- }
2557
- }
2558
- return de;
2559
- }
2560
- const z = new P("history"), Hr = new P("closeHistory");
2561
- function _r(t = {}) {
2562
- return t = {
2563
- depth: t.depth || 100,
2564
- newGroupDelay: t.newGroupDelay || 500
2565
- }, new I({
2566
- key: z,
2567
- state: {
2568
- init() {
2569
- return new _(O.empty, O.empty, null, 0, -1);
2570
- },
2571
- apply(e, n, r) {
2572
- return Br(n, r, e, t);
2573
- }
2574
- },
2575
- config: t,
2576
- props: {
2577
- handleDOMEvents: {
2578
- beforeinput(e, n) {
2579
- let r = n.inputType, s = r == "historyUndo" ? Ve : r == "historyRedo" ? We : null;
2580
- return !s || !e.editable ? !1 : (n.preventDefault(), s(e.state, e.dispatch));
2581
- }
2582
- }
2583
- }
2584
- });
2585
- }
2586
- function Ke(t, e) {
2587
- return (n, r) => {
2588
- let s = z.getState(n);
2589
- if (!s || (t ? s.undone : s.done).eventCount == 0)
2590
- return !1;
2591
- if (r) {
2592
- let o = Rr(s, n, t);
2593
- o && r(e ? o.scrollIntoView() : o);
2594
- }
2595
- return !0;
2596
- };
2597
- }
2598
- const Ve = Ke(!1, !0), We = Ke(!0, !0), jr = A.create({
2599
- name: "history",
2600
- addOptions() {
2601
- return {
2602
- depth: 100,
2603
- newGroupDelay: 500
2604
- };
2605
- },
2606
- addCommands() {
2607
- return {
2608
- undo: () => ({ state: t, dispatch: e }) => Ve(t, e),
2609
- redo: () => ({ state: t, dispatch: e }) => We(t, e)
2610
- };
2611
- },
2612
- addProseMirrorPlugins() {
2613
- return [
2614
- _r(this.options)
2615
- ];
2616
- },
2617
- addKeyboardShortcuts() {
2618
- return {
2619
- "Mod-z": () => this.editor.commands.undo(),
2620
- "Shift-Mod-z": () => this.editor.commands.redo(),
2621
- "Mod-y": () => this.editor.commands.redo(),
2622
- // Russian keyboard layouts
2623
- "Mod-я": () => this.editor.commands.undo(),
2624
- "Shift-Mod-я": () => this.editor.commands.redo()
2625
- };
2626
- }
2627
- }), Fr = T.create({
2628
- name: "horizontalRule",
2629
- addOptions() {
2630
- return {
2631
- HTMLAttributes: {}
2632
- };
2633
- },
2634
- group: "block",
2635
- parseHTML() {
2636
- return [{ tag: "hr" }];
2637
- },
2638
- renderHTML({ HTMLAttributes: t }) {
2639
- return ["hr", S(this.options.HTMLAttributes, t)];
2640
- },
2641
- addCommands() {
2642
- return {
2643
- setHorizontalRule: () => ({ chain: t, state: e }) => {
2644
- if (!er(e, e.schema.nodes[this.name]))
2645
- return !1;
2646
- const { selection: n } = e, { $from: r, $to: s } = n, o = t();
2647
- return r.parentOffset === 0 ? o.insertContentAt({
2648
- from: Math.max(r.pos - 1, 0),
2649
- to: s.pos
2650
- }, {
2651
- type: this.name
2652
- }) : Ln(n) ? o.insertContentAt(s.pos, {
2653
- type: this.name
2654
- }) : o.insertContent({ type: this.name }), o.command(({ tr: i, dispatch: a }) => {
2655
- var l;
2656
- if (a) {
2657
- const { $to: c } = i.selection, u = c.end();
2658
- if (c.nodeAfter)
2659
- c.nodeAfter.isTextblock ? i.setSelection(x.create(i.doc, c.pos + 1)) : c.nodeAfter.isBlock ? i.setSelection(V.create(i.doc, c.pos)) : i.setSelection(x.create(i.doc, c.pos));
2660
- else {
2661
- const d = (l = c.parent.type.contentMatch.defaultType) === null || l === void 0 ? void 0 : l.create();
2662
- d && (i.insert(u, d), i.setSelection(x.create(i.doc, u + 1)));
2663
- }
2664
- i.scrollIntoView();
2665
- }
2666
- return !0;
2667
- }).run();
2668
- }
2669
- };
2670
- },
2671
- addInputRules() {
2672
- return [
2673
- Zn({
2674
- find: /^(?:---|—-|___\s|\*\*\*\s)$/,
2675
- type: this.type
2676
- })
2677
- ];
2678
- }
2679
- }), Dr = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, zr = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, Kr = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, Vr = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, Wr = K.create({
2680
- name: "italic",
2681
- addOptions() {
2682
- return {
2683
- HTMLAttributes: {}
2684
- };
2685
- },
2686
- parseHTML() {
2687
- return [
2688
- {
2689
- tag: "em"
2690
- },
2691
- {
2692
- tag: "i",
2693
- getAttrs: (t) => t.style.fontStyle !== "normal" && null
2694
- },
2695
- {
2696
- style: "font-style=normal",
2697
- clearMark: (t) => t.type.name === this.name
2698
- },
2699
- {
2700
- style: "font-style=italic"
2701
- }
2702
- ];
2703
- },
2704
- renderHTML({ HTMLAttributes: t }) {
2705
- return ["em", S(this.options.HTMLAttributes, t), 0];
2706
- },
2707
- addCommands() {
2708
- return {
2709
- setItalic: () => ({ commands: t }) => t.setMark(this.name),
2710
- toggleItalic: () => ({ commands: t }) => t.toggleMark(this.name),
2711
- unsetItalic: () => ({ commands: t }) => t.unsetMark(this.name)
2712
- };
2713
- },
2714
- addKeyboardShortcuts() {
2715
- return {
2716
- "Mod-i": () => this.editor.commands.toggleItalic(),
2717
- "Mod-I": () => this.editor.commands.toggleItalic()
2718
- };
2719
- },
2720
- addInputRules() {
2721
- return [
2722
- G({
2723
- find: Dr,
2724
- type: this.type
2725
- }),
2726
- G({
2727
- find: Kr,
2728
- type: this.type
2729
- })
2730
- ];
2731
- },
2732
- addPasteRules() {
2733
- return [
2734
- J({
2735
- find: zr,
2736
- type: this.type
2737
- }),
2738
- J({
2739
- find: Vr,
2740
- type: this.type
2741
- })
2742
- ];
2743
- }
2744
- }), Gr = T.create({
2745
- name: "listItem",
2746
- addOptions() {
2747
- return {
2748
- HTMLAttributes: {},
2749
- bulletListTypeName: "bulletList",
2750
- orderedListTypeName: "orderedList"
2751
- };
2752
- },
2753
- content: "paragraph block*",
2754
- defining: !0,
2755
- parseHTML() {
2756
- return [
2757
- {
2758
- tag: "li"
2759
- }
2760
- ];
2761
- },
2762
- renderHTML({ HTMLAttributes: t }) {
2763
- return ["li", S(this.options.HTMLAttributes, t), 0];
2764
- },
2765
- addKeyboardShortcuts() {
2766
- return {
2767
- Enter: () => this.editor.commands.splitListItem(this.name),
2768
- Tab: () => this.editor.commands.sinkListItem(this.name),
2769
- "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
2770
- };
2771
- }
2772
- }), Jr = "listItem", Ie = "textStyle", Ee = /^(\d+)\.\s$/, qr = T.create({
2773
- name: "orderedList",
2774
- addOptions() {
2775
- return {
2776
- itemTypeName: "listItem",
2777
- HTMLAttributes: {},
2778
- keepMarks: !1,
2779
- keepAttributes: !1
2780
- };
2781
- },
2782
- group: "block list",
2783
- content() {
2784
- return `${this.options.itemTypeName}+`;
2785
- },
2786
- addAttributes() {
2787
- return {
2788
- start: {
2789
- default: 1,
2790
- parseHTML: (t) => t.hasAttribute("start") ? parseInt(t.getAttribute("start") || "", 10) : 1
2791
- },
2792
- type: {
2793
- default: null,
2794
- parseHTML: (t) => t.getAttribute("type")
2795
- }
2796
- };
2797
- },
2798
- parseHTML() {
2799
- return [
2800
- {
2801
- tag: "ol"
2802
- }
2803
- ];
2804
- },
2805
- renderHTML({ HTMLAttributes: t }) {
2806
- const { start: e, ...n } = t;
2807
- return e === 1 ? ["ol", S(this.options.HTMLAttributes, n), 0] : ["ol", S(this.options.HTMLAttributes, t), 0];
2808
- },
2809
- addCommands() {
2810
- return {
2811
- toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Jr, this.editor.getAttributes(Ie)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
2812
- };
2813
- },
2814
- addKeyboardShortcuts() {
2815
- return {
2816
- "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
2817
- };
2818
- },
2819
- addInputRules() {
2820
- let t = U({
2821
- find: Ee,
2822
- type: this.type,
2823
- getAttributes: (e) => ({ start: +e[1] }),
2824
- joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1]
2825
- });
2826
- return (this.options.keepMarks || this.options.keepAttributes) && (t = U({
2827
- find: Ee,
2828
- type: this.type,
2829
- keepMarks: this.options.keepMarks,
2830
- keepAttributes: this.options.keepAttributes,
2831
- getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(Ie) }),
2832
- joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1],
2833
- editor: this.editor
2834
- })), [
2835
- t
2836
- ];
2837
- }
2838
- }), Ur = T.create({
2839
- name: "paragraph",
2840
- priority: 1e3,
2841
- addOptions() {
2842
- return {
2843
- HTMLAttributes: {}
2844
- };
2845
- },
2846
- group: "block",
2847
- content: "inline*",
2848
- parseHTML() {
2849
- return [
2850
- { tag: "p" }
2851
- ];
2852
- },
2853
- renderHTML({ HTMLAttributes: t }) {
2854
- return ["p", S(this.options.HTMLAttributes, t), 0];
2855
- },
2856
- addCommands() {
2857
- return {
2858
- setParagraph: () => ({ commands: t }) => t.setNode(this.name)
2859
- };
2860
- },
2861
- addKeyboardShortcuts() {
2862
- return {
2863
- "Mod-Alt-0": () => this.editor.commands.setParagraph()
2864
- };
2865
- }
2866
- }), Xr = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, Yr = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, Qr = K.create({
2867
- name: "strike",
2868
- addOptions() {
2869
- return {
2870
- HTMLAttributes: {}
2871
- };
2872
- },
2873
- parseHTML() {
2874
- return [
2875
- {
2876
- tag: "s"
2877
- },
2878
- {
2879
- tag: "del"
2880
- },
2881
- {
2882
- tag: "strike"
2883
- },
2884
- {
2885
- style: "text-decoration",
2886
- consuming: !1,
2887
- getAttrs: (t) => t.includes("line-through") ? {} : !1
2888
- }
2889
- ];
2890
- },
2891
- renderHTML({ HTMLAttributes: t }) {
2892
- return ["s", S(this.options.HTMLAttributes, t), 0];
2893
- },
2894
- addCommands() {
2895
- return {
2896
- setStrike: () => ({ commands: t }) => t.setMark(this.name),
2897
- toggleStrike: () => ({ commands: t }) => t.toggleMark(this.name),
2898
- unsetStrike: () => ({ commands: t }) => t.unsetMark(this.name)
2899
- };
2900
- },
2901
- addKeyboardShortcuts() {
2902
- return {
2903
- "Mod-Shift-s": () => this.editor.commands.toggleStrike()
2904
- };
2905
- },
2906
- addInputRules() {
2907
- return [
2908
- G({
2909
- find: Xr,
2910
- type: this.type
2911
- })
2912
- ];
2913
- },
2914
- addPasteRules() {
2915
- return [
2916
- J({
2917
- find: Yr,
2918
- type: this.type
2919
- })
2920
- ];
2921
- }
2922
- }), Zr = T.create({
2923
- name: "text",
2924
- group: "inline"
2925
- }), ns = A.create({
2926
- name: "starterKit",
2927
- addExtensions() {
2928
- var t, e, n, r, s, o, i, a, l, c, u, d, p, f, g, h, m, y;
2929
- const k = [];
2930
- return this.options.bold !== !1 && k.push(ar.configure((t = this.options) === null || t === void 0 ? void 0 : t.bold)), this.options.blockquote !== !1 && k.push(nr.configure((e = this.options) === null || e === void 0 ? void 0 : e.blockquote)), this.options.bulletList !== !1 && k.push(cr.configure((n = this.options) === null || n === void 0 ? void 0 : n.bulletList)), this.options.code !== !1 && k.push(pr.configure((r = this.options) === null || r === void 0 ? void 0 : r.code)), this.options.codeBlock !== !1 && k.push(mr.configure((s = this.options) === null || s === void 0 ? void 0 : s.codeBlock)), this.options.document !== !1 && k.push(gr.configure((o = this.options) === null || o === void 0 ? void 0 : o.document)), this.options.dropcursor !== !1 && k.push(Mr.configure((i = this.options) === null || i === void 0 ? void 0 : i.dropcursor)), this.options.gapcursor !== !1 && k.push(Tr.configure((a = this.options) === null || a === void 0 ? void 0 : a.gapcursor)), this.options.hardBreak !== !1 && k.push(Ir.configure((l = this.options) === null || l === void 0 ? void 0 : l.hardBreak)), this.options.heading !== !1 && k.push(Er.configure((c = this.options) === null || c === void 0 ? void 0 : c.heading)), this.options.history !== !1 && k.push(jr.configure((u = this.options) === null || u === void 0 ? void 0 : u.history)), this.options.horizontalRule !== !1 && k.push(Fr.configure((d = this.options) === null || d === void 0 ? void 0 : d.horizontalRule)), this.options.italic !== !1 && k.push(Wr.configure((p = this.options) === null || p === void 0 ? void 0 : p.italic)), this.options.listItem !== !1 && k.push(Gr.configure((f = this.options) === null || f === void 0 ? void 0 : f.listItem)), this.options.orderedList !== !1 && k.push(qr.configure((g = this.options) === null || g === void 0 ? void 0 : g.orderedList)), this.options.paragraph !== !1 && k.push(Ur.configure((h = this.options) === null || h === void 0 ? void 0 : h.paragraph)), this.options.strike !== !1 && k.push(Qr.configure((m = this.options) === null || m === void 0 ? void 0 : m.strike)), this.options.text !== !1 && k.push(Zr.configure((y = this.options) === null || y === void 0 ? void 0 : y.text)), k;
2931
- }
2932
- });
2933
- export {
2934
- ts as P,
2935
- ns as S
2936
- };