@caspeco/casper-ui-library 12.0.0 → 12.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/_virtual/builtin_esm-external-require-react.js +1 -1
- package/dist/components/accordion/accordion-item.js +1 -1
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +4 -4
- package/dist/components/alert/helper.d.ts +3 -3
- package/dist/components/alert/helper.d.ts.map +1 -1
- package/dist/components/alert/helper.js +1 -1
- package/dist/components/badge/badge.js +1 -1
- package/dist/components/badge/helper.d.ts +3 -3
- package/dist/components/badge/helper.d.ts.map +1 -1
- package/dist/components/badge/helper.js +1 -1
- package/dist/components/box/box.composition.d.ts.map +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.js +4 -4
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +1 -1
- package/dist/components/checkbox/checkbox.js +1 -1
- package/dist/components/collapsible/collapsible.js +1 -1
- package/dist/components/combobox/combobox-button.js +1 -1
- package/dist/components/combobox/combobox-item.js +1 -1
- package/dist/components/combobox/combobox-menu.js +1 -1
- package/dist/components/combobox/combobox-recipe.js +1 -1
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/combobox.js +88 -93
- package/dist/components/date-picker/base-date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/base-date-picker.js +3 -3
- package/dist/components/date-picker/date-picker-date-cell.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker-date-cell.js +1 -1
- package/dist/components/date-picker/date-picker-header.js +3 -3
- package/dist/components/date-picker/date-picker-week-cell.js +1 -1
- package/dist/components/divider/divider.d.ts.map +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/inline-drawer.js +1 -1
- package/dist/components/form-control/form-label.d.ts.map +1 -1
- package/dist/components/form-control/form-label.js +1 -1
- package/dist/components/heading/heading.d.ts.map +1 -1
- package/dist/components/heading/heading.js +2 -2
- package/dist/components/highlight/highlight.js +1 -1
- package/dist/components/icon/create-icon.d.ts +2 -2
- package/dist/components/icon/create-icon.d.ts.map +1 -1
- package/dist/components/icon/create-icon.js +1 -1
- package/dist/components/icon/icon.composition.d.ts.map +1 -1
- package/dist/components/icon-button/icon-button.d.ts.map +1 -1
- package/dist/components/icon-button/icon-button.js +1 -1
- package/dist/components/image-upload/image-cropper.js +1 -1
- package/dist/components/image-upload/image-upload-dropzone.js +3 -7
- package/dist/components/image-upload/image-upload-modal.d.ts.map +1 -1
- package/dist/components/image-upload/image-upload-modal.js +3 -3
- package/dist/components/image-upload/image-upload.js +1 -1
- package/dist/components/input/helper.js +1 -1
- package/dist/components/input/input-recipe.js +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/list/list.d.ts.map +1 -1
- package/dist/components/list/list.js +1 -1
- package/dist/components/menu/menu-divider.js +1 -1
- package/dist/components/menu/menu-group.d.ts.map +1 -1
- package/dist/components/menu/menu-group.js +1 -2
- package/dist/components/menu/menu-item.d.ts.map +1 -1
- package/dist/components/menu/menu-item.js +1 -1
- package/dist/components/menu/menu-recipe.d.ts.map +1 -1
- package/dist/components/menu/menu-recipe.js +1 -1
- package/dist/components/message/message.js +1 -1
- package/dist/components/modal/modal-close-button.js +1 -1
- package/dist/components/modal/modal.composition.d.ts.map +1 -1
- package/dist/components/navigation-list/navigation-list-item.js +3 -3
- package/dist/components/paginator/paginator-recipe.d.ts.map +1 -1
- package/dist/components/paginator/paginator-recipe.js +3 -3
- package/dist/components/phone-input/country-selector.d.ts.map +1 -1
- package/dist/components/phone-input/country-selector.js +1 -1
- package/dist/components/quantity-button/quantity-button.composition.d.ts.map +1 -1
- package/dist/components/quantity-button/quantity-button.d.ts.map +1 -1
- package/dist/components/quantity-button/quantity-button.js +1 -1
- package/dist/components/radio/hover-styles.js +1 -1
- package/dist/components/radio/radio-group-recipe.js +1 -1
- package/dist/components/radio/radio.d.ts.map +1 -1
- package/dist/components/radio/radio.js +1 -1
- package/dist/components/radio-card/hover-styles.js +1 -1
- package/dist/components/radio-card/radio-card-group.d.ts.map +1 -1
- package/dist/components/radio-card/radio-card-group.js +1 -1
- package/dist/components/radio-card/radio-card.js +3 -3
- package/dist/components/rich-text-editor/rich-text-editor-control.d.ts.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor-control.js +3 -7
- package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor-recipe.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/components/segmented-control/segmented-control.d.ts.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +1 -1
- package/dist/components/select/select-recipe.js +1 -1
- package/dist/components/select/select.js +1 -1
- package/dist/components/skeleton/skeleton-text.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton-text.js +1 -1
- package/dist/components/skeleton/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton.js +1 -1
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/stepper/step-context.d.ts +4 -4
- package/dist/components/stepper/step-context.d.ts.map +1 -1
- package/dist/components/stepper/step.d.ts.map +1 -1
- package/dist/components/stepper/step.js +3 -3
- package/dist/components/stepper/stepper.js +1 -1
- package/dist/components/stepper/types.d.ts +4 -4
- package/dist/components/stepper/types.d.ts.map +1 -1
- package/dist/components/switch/hover-styles.js +1 -1
- package/dist/components/table/table-cell.js +1 -1
- package/dist/components/table/table-column-resize-handle.js +1 -1
- package/dist/components/table/table-content.d.ts.map +1 -1
- package/dist/components/table/table-content.js +1 -1
- package/dist/components/table/table-filter.js +1 -1
- package/dist/components/table/table-header-dropdown.d.ts.map +1 -1
- package/dist/components/table/table-header-dropdown.js +1 -1
- package/dist/components/table/table-header-row.js +3 -3
- package/dist/components/table/table-recipe.js +1 -1
- package/dist/components/table/table-row-drag-handle.js +1 -1
- package/dist/components/table/table-row-expand-toggle-button.js +1 -1
- package/dist/components/table/table-sorted-reorder-prompt.js +3 -3
- package/dist/components/table/table-toolbar-settings.d.ts.map +1 -1
- package/dist/components/table/table-toolbar-settings.js +1 -1
- package/dist/components/table/table-toolbar.d.ts.map +1 -1
- package/dist/components/table/table-toolbar.js +3 -3
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +1 -1
- package/dist/components/tabs/tab-with-image.js +1 -1
- package/dist/components/tabs/tabs-recipe.js +1 -1
- package/dist/components/tabs/types.d.ts +2 -2
- package/dist/components/tabs/types.d.ts.map +1 -1
- package/dist/components/tag/tag-recipe.js +5 -5
- package/dist/components/text/text.d.ts.map +1 -1
- package/dist/components/text/text.js +2 -2
- package/dist/components/textarea/textarea-recipe.js +1 -1
- package/dist/components/toaster/toast-store.d.ts +2 -2
- package/dist/components/toaster/toast-store.d.ts.map +1 -1
- package/dist/components/toaster/toaster.js +1 -1
- package/dist/components/toggle-button/use-button-children.js +1 -1
- package/dist/components/tooltip/tooltip.js +2 -2
- package/dist/index.js +402 -402
- package/dist/node_modules/@dnd-kit/abstract/index.js +1 -1
- package/dist/node_modules/@dnd-kit/dom/index.js +11 -16
- package/dist/node_modules/@dnd-kit/dom/sortable.js +4 -4
- package/dist/node_modules/@dnd-kit/dom/utilities.js +2 -6
- package/dist/node_modules/@dnd-kit/react/hooks.js +2 -5
- package/dist/node_modules/@dnd-kit/react/sortable.js +4 -4
- package/dist/node_modules/@tanstack/table-core/build/lib/index.js +16 -30
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +9 -18
- package/dist/node_modules/@tiptap/core/dist/index.js +838 -790
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +14 -3
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +114 -97
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +133 -120
- package/dist/node_modules/@tiptap/extensions/dist/index.js +33 -33
- package/dist/node_modules/country-flag-icons/modules/react/3x2/index.js +1 -2
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +1 -1
- package/dist/node_modules/date-fns/getISOWeek.js +1 -1
- package/dist/node_modules/date-fns/getWeek.js +1 -1
- package/dist/node_modules/libphonenumber-js/es6-modern/metadata.js +1 -1
- package/dist/node_modules/prosemirror-commands/dist/index.js +1 -1
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +2 -6
- package/dist/node_modules/prosemirror-history/dist/index.js +27 -22
- package/dist/node_modules/prosemirror-model/dist/index.js +32 -35
- package/dist/node_modules/prosemirror-view/dist/index.js +10 -11
- package/dist/packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js +74 -57
- package/dist/theme/theme-casper-ui.d.ts.map +1 -1
- package/dist/theme/theme-casper-ui.js +1 -1
- package/dist/theme/theme-style-props.d.ts +25 -25
- package/dist/theme/theme-style-props.d.ts.map +1 -1
- package/dist/theme/theme-types.d.ts +46 -10
- package/dist/theme/theme-types.d.ts.map +1 -1
- package/dist/theme/theme-types.js +2 -2
- package/dist/theme/theme-types.spec.d.ts +2 -0
- package/dist/theme/theme-types.spec.d.ts.map +1 -0
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +1 -1
- package/package.json +13 -13
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createParagraphNear as ee, exitCode as
|
|
6
|
-
import { liftListItem as
|
|
7
|
-
import { DecorationSet as
|
|
8
|
-
import { keymap as
|
|
1
|
+
import { DOMParser as e, DOMSerializer as t, Fragment as n, Node as r, Schema as i, Slice as a } from "../../../prosemirror-model/dist/index.js";
|
|
2
|
+
import { RemoveMarkStep as o, ReplaceAroundStep as s, ReplaceStep as c, Transform as l, canJoin as u, canSplit as d, findWrapping as f, joinPoint as p, liftTarget as m } from "../../../prosemirror-transform/dist/index.js";
|
|
3
|
+
import { AllSelection as h, EditorState as g, NodeSelection as _, Plugin as v, PluginKey as y, Selection as b, TextSelection as x } from "../../../prosemirror-state/dist/index.js";
|
|
4
|
+
import { t as S } from "./rolldown-runtime-D7D4PA-g.js";
|
|
5
|
+
import { createParagraphNear as ee, exitCode as te, joinBackward as ne, joinDown as C, joinForward as re, joinTextblockBackward as ie, joinTextblockForward as ae, joinUp as oe, lift as se, liftEmptyBlock as ce, newlineInCode as le, selectNodeBackward as ue, selectNodeForward as de, selectParentNode as fe, selectTextblockEnd as pe, selectTextblockStart as me, setBlockType as he, wrapIn as ge } from "../../../prosemirror-commands/dist/index.js";
|
|
6
|
+
import { liftListItem as _e, sinkListItem as ve, wrapInList as ye } from "../../../prosemirror-schema-list/dist/index.js";
|
|
7
|
+
import { DecorationSet as w, EditorView as be } from "../../../prosemirror-view/dist/index.js";
|
|
8
|
+
import { keymap as xe } from "../../../prosemirror-keymap/dist/index.js";
|
|
9
|
+
import { closeHistory as Se } from "../../../prosemirror-history/dist/index.js";
|
|
9
10
|
//#region ../../node_modules/@tiptap/core/dist/index.js
|
|
10
|
-
function
|
|
11
|
+
function T(e) {
|
|
11
12
|
let { state: t, transaction: n } = e, { selection: r } = n, { doc: i } = n, { storedMarks: a } = n;
|
|
12
13
|
return {
|
|
13
14
|
...t,
|
|
@@ -31,7 +32,7 @@ function E(e) {
|
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
var
|
|
35
|
+
var E = class e {
|
|
35
36
|
constructor(e) {
|
|
36
37
|
this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
|
|
37
38
|
}
|
|
@@ -91,7 +92,7 @@ var D = class e {
|
|
|
91
92
|
tr: e,
|
|
92
93
|
editor: r,
|
|
93
94
|
view: a,
|
|
94
|
-
state:
|
|
95
|
+
state: T({
|
|
95
96
|
state: i,
|
|
96
97
|
transaction: e
|
|
97
98
|
}),
|
|
@@ -104,19 +105,19 @@ var D = class e {
|
|
|
104
105
|
};
|
|
105
106
|
return o;
|
|
106
107
|
}
|
|
107
|
-
},
|
|
108
|
+
}, Ce = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
|
|
108
109
|
if (!e.isDestroyed) {
|
|
109
110
|
var n;
|
|
110
111
|
t.dom.blur(), (n = window) == null || (n = n.getSelection()) == null || n.removeAllRanges();
|
|
111
112
|
}
|
|
112
|
-
}), !0),
|
|
113
|
+
}), !0), we = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), Te = () => ({ state: e, tr: t, dispatch: n }) => {
|
|
113
114
|
let { selection: r } = t, { ranges: i } = r;
|
|
114
115
|
return n && i.forEach(({ $from: n, $to: r }) => {
|
|
115
116
|
e.doc.nodesBetween(n.pos, r.pos, (e, n) => {
|
|
116
117
|
if (e.type.isText) return;
|
|
117
118
|
let { doc: r, mapping: i } = t, a = r.resolve(i.map(n)), o = r.resolve(i.map(n + e.nodeSize)), s = a.blockRange(o);
|
|
118
119
|
if (!s) return;
|
|
119
|
-
let c =
|
|
120
|
+
let c = m(s);
|
|
120
121
|
if (e.type.isTextblock) {
|
|
121
122
|
let { defaultType: e } = a.parent.contentMatchAt(a.index());
|
|
122
123
|
t.setNodeMarkup(s.start, e);
|
|
@@ -124,12 +125,12 @@ var D = class e {
|
|
|
124
125
|
(c || c === 0) && t.lift(s, c);
|
|
125
126
|
});
|
|
126
127
|
}), !0;
|
|
127
|
-
},
|
|
128
|
+
}, Ee = (e) => (t) => e(t), De = () => ({ state: e, dispatch: t }) => ee(e, t), Oe = (e, t) => ({ editor: n, tr: r }) => {
|
|
128
129
|
let { state: i } = n, a = i.doc.slice(e.from, e.to);
|
|
129
130
|
r.deleteRange(e.from, e.to);
|
|
130
131
|
let o = r.mapping.map(t);
|
|
131
|
-
return r.insert(o, a.content), r.setSelection(new
|
|
132
|
-
},
|
|
132
|
+
return r.insert(o, a.content), r.setSelection(new x(r.doc.resolve(Math.max(o - 1, 0)))), !0;
|
|
133
|
+
}, ke = () => ({ tr: e, dispatch: t }) => {
|
|
133
134
|
let { selection: n } = e, r = n.$anchor.node();
|
|
134
135
|
if (r.content.size > 0) return !1;
|
|
135
136
|
let i = e.selection.$anchor;
|
|
@@ -142,15 +143,15 @@ var D = class e {
|
|
|
142
143
|
}
|
|
143
144
|
return !1;
|
|
144
145
|
};
|
|
145
|
-
function
|
|
146
|
+
function D(e, t) {
|
|
146
147
|
if (typeof e == "string") {
|
|
147
148
|
if (!t.nodes[e]) throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
|
|
148
149
|
return t.nodes[e];
|
|
149
150
|
}
|
|
150
151
|
return e;
|
|
151
152
|
}
|
|
152
|
-
var
|
|
153
|
-
let i =
|
|
153
|
+
var Ae = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
154
|
+
let i = D(e, n.schema), a = t.selection.$anchor;
|
|
154
155
|
for (let e = a.depth; e > 0; --e) if (a.node(e).type === i) {
|
|
155
156
|
if (r) {
|
|
156
157
|
let n = a.before(e), r = a.after(e);
|
|
@@ -159,41 +160,41 @@ var Oe = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
|
159
160
|
return !0;
|
|
160
161
|
}
|
|
161
162
|
return !1;
|
|
162
|
-
},
|
|
163
|
+
}, je = (e) => ({ tr: t, dispatch: n }) => {
|
|
163
164
|
let { from: r, to: i } = e;
|
|
164
165
|
return n && t.delete(r, i), !0;
|
|
165
|
-
},
|
|
166
|
+
}, Me = (e) => e.content ? /^text(\*|\+)/.test(e.content) : !1, Ne = (e, t, n) => {
|
|
166
167
|
if (!e.parent.isInline || n === "left" && e.pos > e.start() || n === "right" && e.pos < e.end()) return e.pos;
|
|
167
168
|
let r = t.nodes[e.parent.type.name].spec;
|
|
168
|
-
return
|
|
169
|
-
},
|
|
170
|
-
from:
|
|
171
|
-
to:
|
|
172
|
-
}),
|
|
169
|
+
return Me(r) ? n === "left" ? e.start() - 1 : e.end() + 1 : e.pos;
|
|
170
|
+
}, Pe = (e, t, n) => ({
|
|
171
|
+
from: Ne(e, n, "left"),
|
|
172
|
+
to: Ne(t, n, "right")
|
|
173
|
+
}), Fe = () => ({ state: e, dispatch: t }) => {
|
|
173
174
|
if (e.selection.empty) return !1;
|
|
174
175
|
if (t) {
|
|
175
176
|
let n = e.tr, { ranges: r } = e.selection, i = n.steps.length;
|
|
176
177
|
r.forEach((t) => {
|
|
177
|
-
let r = n.mapping.slice(i), { from: a, to: o } =
|
|
178
|
+
let r = n.mapping.slice(i), { from: a, to: o } = Pe(n.doc.resolve(r.map(t.$from.pos)), n.doc.resolve(r.map(t.$to.pos)), e.schema);
|
|
178
179
|
n.deleteRange(a, o);
|
|
179
|
-
}), n.selection.empty || n.setSelection(
|
|
180
|
+
}), n.selection.empty || n.setSelection(x.near(n.doc.resolve(n.selection.from))), n.scrollIntoView(), t(n);
|
|
180
181
|
}
|
|
181
182
|
return !0;
|
|
182
|
-
},
|
|
183
|
-
function
|
|
183
|
+
}, Ie = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Le = () => ({ state: e, dispatch: t }) => te(e, t);
|
|
184
|
+
function O(e) {
|
|
184
185
|
return Object.prototype.toString.call(e) === "[object RegExp]";
|
|
185
186
|
}
|
|
186
|
-
function
|
|
187
|
+
function k(e, t, n = { strict: !0 }) {
|
|
187
188
|
let r = Object.keys(t);
|
|
188
|
-
return !r.length || r.every((r) => n.strict ? t[r] === e[r] :
|
|
189
|
+
return !r.length || r.every((r) => n.strict ? t[r] === e[r] : O(t[r]) ? t[r].test(e[r]) : t[r] === e[r]);
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
-
return e.find((e) => e.type === t &&
|
|
191
|
+
function Re(e, t, n = {}) {
|
|
192
|
+
return e.find((e) => e.type === t && k(Object.fromEntries(Object.keys(n).map((t) => [t, e.attrs[t]])), n));
|
|
192
193
|
}
|
|
193
|
-
function
|
|
194
|
-
return !!
|
|
194
|
+
function ze(e, t, n = {}) {
|
|
195
|
+
return !!Re(e, t, n);
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
+
function Be(e, t, n) {
|
|
197
198
|
if (!e || !t) return;
|
|
198
199
|
let r = e.parent.childAfter(e.parentOffset);
|
|
199
200
|
if ((!r.node || !r.node.marks.some((e) => e.type === t)) && (r = e.parent.childBefore(e.parentOffset)), !r.node || !r.node.marks.some((e) => e.type === t)) return;
|
|
@@ -201,55 +202,55 @@ function Re(e, t, n) {
|
|
|
201
202
|
let e = r.node.marks.find((e) => e.type === t);
|
|
202
203
|
e && (n = e.attrs);
|
|
203
204
|
}
|
|
204
|
-
if (!
|
|
205
|
+
if (!Re([...r.node.marks], t, n)) return;
|
|
205
206
|
let i = r.index, a = e.start() + r.offset, o = i + 1, s = a + r.node.nodeSize;
|
|
206
|
-
for (; i > 0 &&
|
|
207
|
-
for (; o < e.parent.childCount &&
|
|
207
|
+
for (; i > 0 && ze([...e.parent.child(i - 1).marks], t, n);) --i, a -= e.parent.child(i).nodeSize;
|
|
208
|
+
for (; o < e.parent.childCount && ze([...e.parent.child(o).marks], t, n);) s += e.parent.child(o).nodeSize, o += 1;
|
|
208
209
|
return {
|
|
209
210
|
from: a,
|
|
210
211
|
to: s
|
|
211
212
|
};
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
+
function A(e, t) {
|
|
214
215
|
if (typeof e == "string") {
|
|
215
216
|
if (!t.marks[e]) throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
|
|
216
217
|
return t.marks[e];
|
|
217
218
|
}
|
|
218
219
|
return e;
|
|
219
220
|
}
|
|
220
|
-
var
|
|
221
|
-
let a =
|
|
221
|
+
var Ve = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
222
|
+
let a = A(e, r.schema), { doc: o, selection: s } = n, { $from: c, from: l, to: u } = s;
|
|
222
223
|
if (i) {
|
|
223
|
-
let e =
|
|
224
|
+
let e = Be(c, a, t);
|
|
224
225
|
if (e && e.from <= l && e.to >= u) {
|
|
225
|
-
let t =
|
|
226
|
+
let t = x.create(o, e.from, e.to);
|
|
226
227
|
n.setSelection(t);
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
return !0;
|
|
230
|
-
},
|
|
231
|
+
}, He = (e) => (t) => {
|
|
231
232
|
let n = typeof e == "function" ? e(t) : e;
|
|
232
233
|
for (let e = 0; e < n.length; e += 1) if (n[e](t)) return !0;
|
|
233
234
|
return !1;
|
|
234
235
|
};
|
|
235
|
-
function
|
|
236
|
-
return e instanceof
|
|
236
|
+
function Ue(e) {
|
|
237
|
+
return e instanceof x;
|
|
237
238
|
}
|
|
238
|
-
function
|
|
239
|
+
function j(e = 0, t = 0, n = 0) {
|
|
239
240
|
return Math.min(Math.max(e, t), n);
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
+
function We(e, t = null) {
|
|
242
243
|
if (!t) return null;
|
|
243
|
-
let n =
|
|
244
|
+
let n = b.atStart(e), r = b.atEnd(e);
|
|
244
245
|
if (t === "start" || t === !0) return n;
|
|
245
246
|
if (t === "end") return r;
|
|
246
247
|
let i = n.from, a = r.to;
|
|
247
|
-
return t === "all" ?
|
|
248
|
+
return t === "all" ? x.create(e, j(0, i, a), j(e.content.size, i, a)) : x.create(e, j(t, i, a), j(t, i, a));
|
|
248
249
|
}
|
|
249
|
-
function
|
|
250
|
+
function Ge() {
|
|
250
251
|
return ["Android"].includes(navigator.platform) || /android/i.test(navigator.userAgent);
|
|
251
252
|
}
|
|
252
|
-
function
|
|
253
|
+
function M() {
|
|
253
254
|
return [
|
|
254
255
|
"iPad Simulator",
|
|
255
256
|
"iPhone Simulator",
|
|
@@ -259,16 +260,16 @@ function N() {
|
|
|
259
260
|
"iPod"
|
|
260
261
|
].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
261
262
|
}
|
|
262
|
-
function
|
|
263
|
+
function Ke() {
|
|
263
264
|
return typeof navigator < "u" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
264
265
|
}
|
|
265
|
-
var
|
|
266
|
+
var qe = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
266
267
|
t = {
|
|
267
268
|
scrollIntoView: !0,
|
|
268
269
|
...t
|
|
269
270
|
};
|
|
270
271
|
let o = () => {
|
|
271
|
-
(
|
|
272
|
+
(M() || Ge()) && r.dom.focus(), Ke() && !M() && !Ge() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
|
|
272
273
|
n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
|
|
273
274
|
});
|
|
274
275
|
};
|
|
@@ -277,90 +278,90 @@ var Ge = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
|
277
278
|
} catch {
|
|
278
279
|
return !1;
|
|
279
280
|
}
|
|
280
|
-
if (a && e === null && !
|
|
281
|
-
let s =
|
|
281
|
+
if (a && e === null && !Ue(n.state.selection)) return o(), !0;
|
|
282
|
+
let s = We(i.doc, e) || n.state.selection, c = n.state.selection.eq(s);
|
|
282
283
|
return a && (c || i.setSelection(s), c && i.storedMarks && i.setStoredMarks(i.storedMarks), o()), !0;
|
|
283
|
-
},
|
|
284
|
+
}, Je = (e, t) => (n) => e.every((e, r) => t(e, {
|
|
284
285
|
...n,
|
|
285
286
|
index: r
|
|
286
|
-
})),
|
|
287
|
+
})), Ye = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({
|
|
287
288
|
from: n.selection.from,
|
|
288
289
|
to: n.selection.to
|
|
289
|
-
}, e, t),
|
|
290
|
+
}, e, t), Xe = (e) => {
|
|
290
291
|
let t = e.childNodes;
|
|
291
292
|
for (let n = t.length - 1; n >= 0; --n) {
|
|
292
293
|
let r = t[n];
|
|
293
|
-
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 &&
|
|
294
|
+
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && Xe(r);
|
|
294
295
|
}
|
|
295
296
|
return e;
|
|
296
297
|
};
|
|
297
|
-
function
|
|
298
|
+
function N(e) {
|
|
298
299
|
if (typeof window > "u") throw Error("[tiptap error]: there is no window object available, so this function cannot be used");
|
|
299
300
|
let t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
|
|
300
|
-
return
|
|
301
|
+
return Xe(n);
|
|
301
302
|
}
|
|
302
|
-
function
|
|
303
|
+
function Ze(e) {
|
|
303
304
|
return typeof e?.nodesBetween == "function";
|
|
304
305
|
}
|
|
305
|
-
function
|
|
306
|
-
if (
|
|
307
|
-
let o = typeof
|
|
308
|
-
|
|
306
|
+
function P(t, r, a) {
|
|
307
|
+
if (Ze(t)) return t;
|
|
308
|
+
let o = typeof t == "object" && !!t;
|
|
309
|
+
a = {
|
|
309
310
|
slice: !0,
|
|
310
311
|
parseOptions: {},
|
|
311
|
-
...
|
|
312
|
+
...a
|
|
312
313
|
};
|
|
313
|
-
let s = typeof
|
|
314
|
+
let s = typeof t == "string";
|
|
314
315
|
if (o) try {
|
|
315
|
-
if (Array.isArray(
|
|
316
|
-
let
|
|
317
|
-
return
|
|
318
|
-
} catch (
|
|
319
|
-
if (
|
|
320
|
-
return console.warn("[tiptap warn]: Invalid content.", "Passed value:",
|
|
316
|
+
if (Array.isArray(t) && t.length > 0) return n.fromArray(t.map((e) => r.nodeFromJSON(e)));
|
|
317
|
+
let e = r.nodeFromJSON(t);
|
|
318
|
+
return a.errorOnInvalidContent && e.check(), e;
|
|
319
|
+
} catch (e) {
|
|
320
|
+
if (a.errorOnInvalidContent) throw Error("[tiptap error]: Invalid JSON content", { cause: e });
|
|
321
|
+
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", t, "Error:", e), P("", r, a);
|
|
321
322
|
}
|
|
322
323
|
if (s) {
|
|
323
|
-
if (
|
|
324
|
-
let
|
|
325
|
-
topNode:
|
|
326
|
-
marks:
|
|
327
|
-
nodes:
|
|
324
|
+
if (a.errorOnInvalidContent) {
|
|
325
|
+
let n = !1, o = "", s = new i({
|
|
326
|
+
topNode: r.spec.topNode,
|
|
327
|
+
marks: r.spec.marks,
|
|
328
|
+
nodes: r.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: {
|
|
328
329
|
content: "inline*",
|
|
329
330
|
group: "block",
|
|
330
331
|
parseDOM: [{
|
|
331
332
|
tag: "*",
|
|
332
|
-
getAttrs: (e) => (
|
|
333
|
+
getAttrs: (e) => (n = !0, o = typeof e == "string" ? e : e.outerHTML, null)
|
|
333
334
|
}]
|
|
334
335
|
} })
|
|
335
336
|
});
|
|
336
|
-
if (
|
|
337
|
+
if (a.slice ? e.fromSchema(s).parseSlice(N(t), a.parseOptions) : e.fromSchema(s).parse(N(t), a.parseOptions), a.errorOnInvalidContent && n) throw Error("[tiptap error]: Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${o}`) });
|
|
337
338
|
}
|
|
338
|
-
let
|
|
339
|
-
return
|
|
339
|
+
let n = e.fromSchema(r);
|
|
340
|
+
return a.slice ? n.parseSlice(N(t), a.parseOptions).content : n.parse(N(t), a.parseOptions);
|
|
340
341
|
}
|
|
341
|
-
return
|
|
342
|
+
return P("", r, a);
|
|
342
343
|
}
|
|
343
|
-
function
|
|
344
|
+
function Qe(e) {
|
|
344
345
|
return !("type" in e);
|
|
345
346
|
}
|
|
346
|
-
function
|
|
347
|
+
function $e(e, t, n) {
|
|
347
348
|
let r = e.steps.length - 1;
|
|
348
349
|
if (r < t) return;
|
|
349
350
|
let i = e.steps[r];
|
|
350
|
-
if (!(i instanceof
|
|
351
|
+
if (!(i instanceof c || i instanceof s)) return;
|
|
351
352
|
let a = e.mapping.maps[r], o = 0;
|
|
352
353
|
a.forEach((e, t, n, r) => {
|
|
353
354
|
o === 0 && (o = r);
|
|
354
|
-
}), e.setSelection(
|
|
355
|
+
}), e.setSelection(b.near(e.doc.resolve(o), n));
|
|
355
356
|
}
|
|
356
|
-
var
|
|
357
|
+
var et = (e, t, r) => ({ tr: i, dispatch: a, editor: o }) => {
|
|
357
358
|
if (a) {
|
|
358
|
-
|
|
359
|
+
r = {
|
|
359
360
|
parseOptions: o.options.parseOptions,
|
|
360
361
|
updateSelection: !0,
|
|
361
362
|
applyInputRules: !1,
|
|
362
363
|
applyPasteRules: !1,
|
|
363
|
-
...
|
|
364
|
+
...r
|
|
364
365
|
};
|
|
365
366
|
let a, s = (e) => {
|
|
366
367
|
o.emit("contentError", {
|
|
@@ -372,10 +373,10 @@ var Qe = (e, t, n) => ({ tr: i, dispatch: a, editor: o }) => {
|
|
|
372
373
|
});
|
|
373
374
|
}, c = {
|
|
374
375
|
preserveWhitespace: "full",
|
|
375
|
-
...
|
|
376
|
+
...r.parseOptions
|
|
376
377
|
};
|
|
377
|
-
if (!
|
|
378
|
-
|
|
378
|
+
if (!r.errorOnInvalidContent && !o.options.enableContentCheck && o.options.emitContentError) try {
|
|
379
|
+
P(t, o.schema, {
|
|
379
380
|
parseOptions: c,
|
|
380
381
|
errorOnInvalidContent: !0
|
|
381
382
|
});
|
|
@@ -383,9 +384,9 @@ var Qe = (e, t, n) => ({ tr: i, dispatch: a, editor: o }) => {
|
|
|
383
384
|
s(e);
|
|
384
385
|
}
|
|
385
386
|
try {
|
|
386
|
-
a =
|
|
387
|
+
a = P(t, o.schema, {
|
|
387
388
|
parseOptions: c,
|
|
388
|
-
errorOnInvalidContent:
|
|
389
|
+
errorOnInvalidContent: r.errorOnInvalidContent ?? o.options.enableContentCheck
|
|
389
390
|
});
|
|
390
391
|
} catch (e) {
|
|
391
392
|
return s(e), !1;
|
|
@@ -396,7 +397,7 @@ var Qe = (e, t, n) => ({ tr: i, dispatch: a, editor: o }) => {
|
|
|
396
397
|
} : {
|
|
397
398
|
from: e.from,
|
|
398
399
|
to: e.to
|
|
399
|
-
}, d = !0, f = !0, p =
|
|
400
|
+
}, d = !0, f = !0, p = Qe(a) ? a.content : [a];
|
|
400
401
|
if (p.forEach((e) => {
|
|
401
402
|
e.check(), d = d ? e.isText && e.marks.length === 0 : !1, f = f ? e.isBlock : !1;
|
|
402
403
|
}), l === u && f) {
|
|
@@ -404,59 +405,62 @@ var Qe = (e, t, n) => ({ tr: i, dispatch: a, editor: o }) => {
|
|
|
404
405
|
e.isTextblock && !e.type.spec.code && !e.childCount && (--l, u += 1);
|
|
405
406
|
}
|
|
406
407
|
let m;
|
|
407
|
-
if (d) m = Array.isArray(t) ? t.map((e) => e.text || "").join("") :
|
|
408
|
+
if (d) m = Array.isArray(t) ? t.map((e) => e.text || "").join("") : Ze(t) ? p.map((e) => e.text ?? "").join("") : typeof t == "object" && t && t.text ? t.text : t, i.insertText(m, l, u);
|
|
408
409
|
else {
|
|
409
|
-
m =
|
|
410
|
-
let e = i.doc.resolve(l), t = e.node(),
|
|
411
|
-
|
|
410
|
+
m = n.from(p);
|
|
411
|
+
let e = i.doc.resolve(l), t = e.node(), r = e.parentOffset === 0, a = t.isText || t.isTextblock, o = t.content.size > 0;
|
|
412
|
+
r && a && o && f && (l = Math.max(0, l - 1)), i.replaceWith(l, u, p);
|
|
412
413
|
}
|
|
413
|
-
|
|
414
|
+
r.updateSelection && $e(i, i.steps.length - 1, -1), r.applyInputRules && i.setMeta("applyInputRules", {
|
|
414
415
|
from: l,
|
|
415
416
|
text: m
|
|
416
|
-
}),
|
|
417
|
+
}), r.applyPasteRules && i.setMeta("applyPasteRules", {
|
|
417
418
|
from: l,
|
|
418
419
|
text: m
|
|
419
420
|
});
|
|
420
421
|
}
|
|
421
422
|
return !0;
|
|
422
423
|
};
|
|
423
|
-
function
|
|
424
|
+
function tt(e) {
|
|
424
425
|
for (let t = 0; t < e.edgeCount; t += 1) {
|
|
425
426
|
let { type: n } = e.edge(t);
|
|
426
427
|
if (n.isTextblock && !n.hasRequiredAttrs()) return n;
|
|
427
428
|
}
|
|
428
429
|
return null;
|
|
429
430
|
}
|
|
430
|
-
var
|
|
431
|
+
var nt = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
431
432
|
let { pos: i, attrs: a, content: o, updateSelection: s = !0 } = e, c;
|
|
432
433
|
c = typeof i == "number" ? t.doc.resolve(i) : i || t.selection.$from;
|
|
433
|
-
let l =
|
|
434
|
+
let l = tt(c.parent.contentMatchAt(c.index()));
|
|
434
435
|
if (!l) return !1;
|
|
435
436
|
let u = Object.keys(l.spec.attrs || {}), d = a ? Object.fromEntries(Object.entries(a).filter(([e]) => u.includes(e))) : {}, f;
|
|
436
437
|
if (o) {
|
|
437
|
-
let e =
|
|
438
|
+
let e = P(o, r.schema);
|
|
438
439
|
f = l.createAndFill(d, e);
|
|
439
440
|
} else f = l.createAndFill(d);
|
|
440
|
-
return f ? (n && (t.insert(c.pos, f), s &&
|
|
441
|
-
},
|
|
441
|
+
return f ? (n && (t.insert(c.pos, f), s && $e(t, t.steps.length - 1, -1)), !0) : !1;
|
|
442
|
+
}, rt = () => ({ state: e, dispatch: t }) => oe(e, t), it = () => ({ state: e, dispatch: t }) => C(e, t), at = () => ({ state: e, dispatch: t }) => ne(e, t), ot = () => ({ state: e, dispatch: t }) => re(e, t), st = (e, t) => {
|
|
443
|
+
let n = e.resolve(t), r = n.nodeBefore, i = n.nodeAfter;
|
|
444
|
+
return !r || !i ? !1 : !r.type.spec.isolating && !i.type.spec.isolating;
|
|
445
|
+
}, ct = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
442
446
|
try {
|
|
443
|
-
let r =
|
|
444
|
-
return r
|
|
447
|
+
let r = p(e.doc, e.selection.$from.pos, -1);
|
|
448
|
+
return r == null || !st(e.doc, r) ? !1 : (n.join(r, 2), t && t(n), !0);
|
|
445
449
|
} catch {
|
|
446
450
|
return !1;
|
|
447
451
|
}
|
|
448
|
-
},
|
|
452
|
+
}, lt = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
449
453
|
try {
|
|
450
|
-
let r =
|
|
451
|
-
return r
|
|
454
|
+
let r = p(e.doc, e.selection.$from.pos, 1);
|
|
455
|
+
return r == null || !st(e.doc, r) ? !1 : (n.join(r, 2), t && t(n), !0);
|
|
452
456
|
} catch {
|
|
453
457
|
return !1;
|
|
454
458
|
}
|
|
455
|
-
},
|
|
456
|
-
function
|
|
459
|
+
}, ut = () => ({ state: e, dispatch: t }) => ie(e, t), dt = () => ({ state: e, dispatch: t }) => ae(e, t);
|
|
460
|
+
function ft() {
|
|
457
461
|
return typeof navigator < "u" && /Mac/.test(navigator.platform);
|
|
458
462
|
}
|
|
459
|
-
function
|
|
463
|
+
function pt(e) {
|
|
460
464
|
let t = e.split(/-(?!$)/), n = t[t.length - 1];
|
|
461
465
|
n === "Space" && (n = " ");
|
|
462
466
|
let r, i, a, o;
|
|
@@ -466,13 +470,13 @@ function ut(e) {
|
|
|
466
470
|
else if (/^a(lt)?$/i.test(n)) r = !0;
|
|
467
471
|
else if (/^(c|ctrl|control)$/i.test(n)) i = !0;
|
|
468
472
|
else if (/^s(hift)?$/i.test(n)) a = !0;
|
|
469
|
-
else if (/^mod$/i.test(n))
|
|
473
|
+
else if (/^mod$/i.test(n)) M() || ft() ? o = !0 : i = !0;
|
|
470
474
|
else throw Error(`Unrecognized modifier name: ${n}`);
|
|
471
475
|
}
|
|
472
476
|
return r && (n = `Alt-${n}`), i && (n = `Ctrl-${n}`), o && (n = `Meta-${n}`), a && (n = `Shift-${n}`), n;
|
|
473
477
|
}
|
|
474
|
-
var
|
|
475
|
-
let a =
|
|
478
|
+
var mt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
479
|
+
let a = pt(e).split(/-(?!$)/), o = a.find((e) => ![
|
|
476
480
|
"Alt",
|
|
477
481
|
"Ctrl",
|
|
478
482
|
"Meta",
|
|
@@ -493,8 +497,8 @@ var dt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
|
493
497
|
t && i && r.maybeStep(t);
|
|
494
498
|
}), !0;
|
|
495
499
|
};
|
|
496
|
-
function
|
|
497
|
-
let { from: r, to: i, empty: a } = e.selection, o = t ?
|
|
500
|
+
function F(e, t, n = {}) {
|
|
501
|
+
let { from: r, to: i, empty: a } = e.selection, o = t ? D(t, e.schema) : null, s = [];
|
|
498
502
|
e.doc.nodesBetween(r, i, (e, t) => {
|
|
499
503
|
if (e.isText) return;
|
|
500
504
|
let n = Math.max(r, t), a = Math.min(i, t + e.nodeSize);
|
|
@@ -504,52 +508,52 @@ function I(e, t, n = {}) {
|
|
|
504
508
|
to: a
|
|
505
509
|
});
|
|
506
510
|
});
|
|
507
|
-
let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) =>
|
|
511
|
+
let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) => k(e.node.attrs, n, { strict: !1 }));
|
|
508
512
|
return a ? !!l.length : l.reduce((e, t) => e + t.to - t.from, 0) >= c;
|
|
509
513
|
}
|
|
510
|
-
var
|
|
511
|
-
let r =
|
|
512
|
-
return
|
|
513
|
-
},
|
|
514
|
-
function
|
|
514
|
+
var ht = (e, t = {}) => ({ state: n, dispatch: r }) => F(n, D(e, n.schema), t) ? se(n, r) : !1, gt = () => ({ state: e, dispatch: t }) => ce(e, t), _t = (e) => ({ state: t, dispatch: n }) => {
|
|
515
|
+
let r = D(e, t.schema);
|
|
516
|
+
return _e(r)(t, n);
|
|
517
|
+
}, vt = () => ({ state: e, dispatch: t }) => le(e, t);
|
|
518
|
+
function I(e, t) {
|
|
515
519
|
return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
|
|
516
520
|
}
|
|
517
|
-
function
|
|
521
|
+
function yt(e, t) {
|
|
518
522
|
let n = typeof t == "string" ? [t] : t;
|
|
519
523
|
return Object.keys(e).reduce((t, r) => (n.includes(r) || (t[r] = e[r]), t), {});
|
|
520
524
|
}
|
|
521
|
-
var
|
|
522
|
-
let a = null, o = null, s =
|
|
525
|
+
var bt = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
526
|
+
let a = null, o = null, s = I(typeof e == "string" ? e : e.name, r.schema);
|
|
523
527
|
if (!s) return !1;
|
|
524
|
-
s === "node" && (a =
|
|
528
|
+
s === "node" && (a = D(e, r.schema)), s === "mark" && (o = A(e, r.schema));
|
|
525
529
|
let c = !1;
|
|
526
530
|
return n.selection.ranges.forEach((e) => {
|
|
527
531
|
r.doc.nodesBetween(e.$from.pos, e.$to.pos, (e, r) => {
|
|
528
|
-
a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0,
|
|
529
|
-
o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(
|
|
532
|
+
a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0, yt(e.attrs, t))), o && e.marks.length && e.marks.forEach((a) => {
|
|
533
|
+
o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(yt(a.attrs, t))));
|
|
530
534
|
});
|
|
531
535
|
});
|
|
532
536
|
}), c;
|
|
533
|
-
},
|
|
537
|
+
}, xt = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), St = () => ({ tr: e, dispatch: t }) => {
|
|
534
538
|
if (t) {
|
|
535
|
-
let t = new
|
|
539
|
+
let t = new h(e.doc);
|
|
536
540
|
e.setSelection(t);
|
|
537
541
|
}
|
|
538
542
|
return !0;
|
|
539
|
-
},
|
|
540
|
-
function
|
|
541
|
-
return
|
|
543
|
+
}, Ct = () => ({ state: e, dispatch: t }) => ue(e, t), wt = () => ({ state: e, dispatch: t }) => de(e, t), Tt = () => ({ state: e, dispatch: t }) => fe(e, t), Et = () => ({ state: e, dispatch: t }) => pe(e, t), Dt = () => ({ state: e, dispatch: t }) => me(e, t);
|
|
544
|
+
function Ot(e, t, n = {}, r = {}) {
|
|
545
|
+
return P(e, t, {
|
|
542
546
|
slice: !1,
|
|
543
547
|
parseOptions: n,
|
|
544
548
|
errorOnInvalidContent: r.errorOnInvalidContent
|
|
545
549
|
});
|
|
546
550
|
}
|
|
547
|
-
var
|
|
551
|
+
var kt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: i, tr: a, dispatch: o, commands: s }) => {
|
|
548
552
|
let { doc: c } = a;
|
|
549
553
|
if (r.preserveWhitespace !== "full") {
|
|
550
|
-
let s =
|
|
554
|
+
let s = Ot(e, i.schema, r, { errorOnInvalidContent: t ?? i.options.enableContentCheck });
|
|
551
555
|
if (o) {
|
|
552
|
-
let e =
|
|
556
|
+
let e = Qe(s) ? s.content : [s];
|
|
553
557
|
a.replaceWith(0, c.content.size, e).setMeta("preventUpdate", !n);
|
|
554
558
|
}
|
|
555
559
|
return !0;
|
|
@@ -562,23 +566,23 @@ var Tt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {
|
|
|
562
566
|
errorOnInvalidContent: t ?? i.options.enableContentCheck
|
|
563
567
|
});
|
|
564
568
|
};
|
|
565
|
-
function
|
|
566
|
-
let n =
|
|
569
|
+
function At(e, t) {
|
|
570
|
+
let n = A(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = [];
|
|
567
571
|
a ? (e.storedMarks && o.push(...e.storedMarks), o.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, i, (e) => {
|
|
568
572
|
o.push(...e.marks);
|
|
569
573
|
});
|
|
570
574
|
let s = o.find((e) => e.type.name === n.name);
|
|
571
575
|
return s ? { ...s.attrs } : {};
|
|
572
576
|
}
|
|
573
|
-
function
|
|
574
|
-
let n = new
|
|
577
|
+
function jt(e, t) {
|
|
578
|
+
let n = new l(e);
|
|
575
579
|
return t.forEach((e) => {
|
|
576
580
|
e.steps.forEach((e) => {
|
|
577
581
|
n.step(e);
|
|
578
582
|
});
|
|
579
583
|
}), n;
|
|
580
584
|
}
|
|
581
|
-
function
|
|
585
|
+
function Mt(e, t, n) {
|
|
582
586
|
let r = [];
|
|
583
587
|
return e.nodesBetween(t.from, t.to, (e, t) => {
|
|
584
588
|
n(e) && r.push({
|
|
@@ -587,7 +591,7 @@ function Ot(e, t, n) {
|
|
|
587
591
|
});
|
|
588
592
|
}), r;
|
|
589
593
|
}
|
|
590
|
-
function
|
|
594
|
+
function Nt(e, t) {
|
|
591
595
|
for (let n = e.depth; n > 0; --n) {
|
|
592
596
|
let r = e.node(n);
|
|
593
597
|
if (t(r)) return {
|
|
@@ -598,47 +602,47 @@ function kt(e, t) {
|
|
|
598
602
|
};
|
|
599
603
|
}
|
|
600
604
|
}
|
|
601
|
-
function
|
|
602
|
-
return (t) =>
|
|
605
|
+
function L(e) {
|
|
606
|
+
return (t) => Nt(t.$from, e);
|
|
603
607
|
}
|
|
604
|
-
function
|
|
605
|
-
return e.config[t] === void 0 && e.parent ?
|
|
608
|
+
function R(e, t, n) {
|
|
609
|
+
return e.config[t] === void 0 && e.parent ? R(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
|
|
606
610
|
...n,
|
|
607
|
-
parent: e.parent ?
|
|
611
|
+
parent: e.parent ? R(e.parent, t, n) : null
|
|
608
612
|
}) : e.config[t];
|
|
609
613
|
}
|
|
610
|
-
function
|
|
614
|
+
function z(e) {
|
|
611
615
|
return e.map((e) => {
|
|
612
|
-
let t =
|
|
616
|
+
let t = R(e, "addExtensions", {
|
|
613
617
|
name: e.name,
|
|
614
618
|
options: e.options,
|
|
615
619
|
storage: e.storage
|
|
616
620
|
});
|
|
617
|
-
return t ? [e, ...
|
|
621
|
+
return t ? [e, ...z(t())] : e;
|
|
618
622
|
}).flat(10);
|
|
619
623
|
}
|
|
620
|
-
function
|
|
621
|
-
let r =
|
|
624
|
+
function B(e, n) {
|
|
625
|
+
let r = t.fromSchema(n).serializeFragment(e), i = document.implementation.createHTMLDocument().createElement("div");
|
|
622
626
|
return i.appendChild(r), i.innerHTML;
|
|
623
627
|
}
|
|
624
|
-
function
|
|
628
|
+
function V(e) {
|
|
625
629
|
return typeof e == "function";
|
|
626
630
|
}
|
|
627
|
-
function
|
|
628
|
-
return
|
|
631
|
+
function H(e, t = void 0, ...n) {
|
|
632
|
+
return V(e) ? t ? e.bind(t)(...n) : e(...n) : e;
|
|
629
633
|
}
|
|
630
|
-
function
|
|
634
|
+
function Pt(e = {}) {
|
|
631
635
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
632
636
|
}
|
|
633
|
-
function
|
|
637
|
+
function U(e) {
|
|
634
638
|
return {
|
|
635
639
|
baseExtensions: e.filter((e) => e.type === "extension"),
|
|
636
640
|
nodeExtensions: e.filter((e) => e.type === "node"),
|
|
637
641
|
markExtensions: e.filter((e) => e.type === "mark")
|
|
638
642
|
};
|
|
639
643
|
}
|
|
640
|
-
function
|
|
641
|
-
let t = [], { nodeExtensions: n, markExtensions: r } =
|
|
644
|
+
function Ft(e) {
|
|
645
|
+
let t = [], { nodeExtensions: n, markExtensions: r } = U(e), i = [...n, ...r], a = {
|
|
642
646
|
default: null,
|
|
643
647
|
validate: void 0,
|
|
644
648
|
rendered: !0,
|
|
@@ -648,7 +652,7 @@ function Mt(e) {
|
|
|
648
652
|
isRequired: !1
|
|
649
653
|
}, o = n.filter((e) => e.name !== "text").map((e) => e.name), s = r.map((e) => e.name), c = [...o, ...s];
|
|
650
654
|
return e.forEach((e) => {
|
|
651
|
-
let n =
|
|
655
|
+
let n = R(e, "addGlobalAttributes", {
|
|
652
656
|
name: e.name,
|
|
653
657
|
options: e.options,
|
|
654
658
|
storage: e.storage,
|
|
@@ -670,7 +674,7 @@ function Mt(e) {
|
|
|
670
674
|
});
|
|
671
675
|
});
|
|
672
676
|
}), i.forEach((e) => {
|
|
673
|
-
let n =
|
|
677
|
+
let n = R(e, "addAttributes", {
|
|
674
678
|
name: e.name,
|
|
675
679
|
options: e.options,
|
|
676
680
|
storage: e.storage
|
|
@@ -690,38 +694,34 @@ function Mt(e) {
|
|
|
690
694
|
});
|
|
691
695
|
}), t;
|
|
692
696
|
}
|
|
693
|
-
function
|
|
697
|
+
function It(e) {
|
|
694
698
|
let t = [], n = "", r = !1, i = !1, a = 0, o = e.length;
|
|
695
699
|
for (let s = 0; s < o; s += 1) {
|
|
696
700
|
let o = e[s];
|
|
697
|
-
if (o === "'" && !i)
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
if (o === ";" && a === 0) {
|
|
715
|
-
t.push(n), n = "";
|
|
716
|
-
continue;
|
|
701
|
+
if (o === "'" && !i) r = !r, n += o;
|
|
702
|
+
else if (o === "\"" && !r) i = !i, n += o;
|
|
703
|
+
else {
|
|
704
|
+
if (!r && !i) {
|
|
705
|
+
if (o === "(") {
|
|
706
|
+
a += 1, n += o;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (o === ")" && a > 0) {
|
|
710
|
+
--a, n += o;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (o === ";" && a === 0) {
|
|
714
|
+
t.push(n), n = "";
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
717
|
}
|
|
718
|
+
n += o;
|
|
718
719
|
}
|
|
719
|
-
n += o;
|
|
720
720
|
}
|
|
721
721
|
return n && t.push(n), t;
|
|
722
722
|
}
|
|
723
|
-
function
|
|
724
|
-
let t = [], n =
|
|
723
|
+
function Lt(e) {
|
|
724
|
+
let t = [], n = It(e || ""), r = n.length;
|
|
725
725
|
for (let e = 0; e < r; e += 1) {
|
|
726
726
|
let r = n[e], i = r.indexOf(":");
|
|
727
727
|
if (i === -1) continue;
|
|
@@ -730,47 +730,41 @@ function Pt(e) {
|
|
|
730
730
|
}
|
|
731
731
|
return t;
|
|
732
732
|
}
|
|
733
|
-
function
|
|
733
|
+
function Rt(...e) {
|
|
734
734
|
return e.filter((e) => !!e).reduce((e, t) => {
|
|
735
735
|
let n = { ...e };
|
|
736
736
|
return Object.entries(t).forEach(([e, t]) => {
|
|
737
|
-
if (e === "__proto__") {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
if (!n[e]) {
|
|
747
|
-
n[e] = t;
|
|
748
|
-
return;
|
|
749
|
-
}
|
|
750
|
-
if (e === "class") {
|
|
737
|
+
if (e === "__proto__") Object.defineProperty(n, e, {
|
|
738
|
+
configurable: !0,
|
|
739
|
+
enumerable: !0,
|
|
740
|
+
value: t,
|
|
741
|
+
writable: !0
|
|
742
|
+
});
|
|
743
|
+
else if (!n[e]) n[e] = t;
|
|
744
|
+
else if (e === "class") {
|
|
751
745
|
let r = t ? String(t).split(" ") : [], i = n[e] ? n[e].split(" ") : [], a = r.filter((e) => !i.includes(e));
|
|
752
746
|
n[e] = [...i, ...a].join(" ");
|
|
753
747
|
} else if (e === "style") {
|
|
754
|
-
let r = new Map([...
|
|
748
|
+
let r = new Map([...Lt(n[e]), ...Lt(t)]);
|
|
755
749
|
n[e] = Array.from(r.entries()).map(([e, t]) => `${e}: ${t}`).join("; ");
|
|
756
750
|
} else n[e] = t;
|
|
757
751
|
}), n;
|
|
758
752
|
}, {});
|
|
759
753
|
}
|
|
760
|
-
function
|
|
761
|
-
return t.filter((t) => t.type === e.type.name).filter((e) => e.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(e.attrs) || {} : { [t.name]: e.attrs[t.name] }).reduce((e, t) =>
|
|
754
|
+
function W(e, t) {
|
|
755
|
+
return t.filter((t) => t.type === e.type.name).filter((e) => e.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(e.attrs) || {} : { [t.name]: e.attrs[t.name] }).reduce((e, t) => Rt(e, t), {});
|
|
762
756
|
}
|
|
763
|
-
function
|
|
757
|
+
function zt(e) {
|
|
764
758
|
return typeof e == "string" ? e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" || e !== "false" && e : e;
|
|
765
759
|
}
|
|
766
|
-
function
|
|
760
|
+
function Bt(e, t) {
|
|
767
761
|
return "style" in e ? e : {
|
|
768
762
|
...e,
|
|
769
763
|
getAttrs: (n) => {
|
|
770
764
|
let r = e.getAttrs ? e.getAttrs(n) : e.attrs;
|
|
771
765
|
if (r === !1) return !1;
|
|
772
766
|
let i = t.reduce((e, t) => {
|
|
773
|
-
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) :
|
|
767
|
+
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) : zt(n.getAttribute(t.name));
|
|
774
768
|
return r == null ? e : {
|
|
775
769
|
...e,
|
|
776
770
|
[t.name]: r
|
|
@@ -783,111 +777,111 @@ function Lt(e, t) {
|
|
|
783
777
|
}
|
|
784
778
|
};
|
|
785
779
|
}
|
|
786
|
-
function
|
|
787
|
-
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" &&
|
|
780
|
+
function Vt(e) {
|
|
781
|
+
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && Pt(t) ? !1 : t != null));
|
|
788
782
|
}
|
|
789
|
-
function
|
|
783
|
+
function Ht(e) {
|
|
790
784
|
var t, n;
|
|
791
785
|
let r = {};
|
|
792
786
|
return !(e != null && (t = e.attribute) != null && t.isRequired) && "default" in (e?.attribute || {}) && (r.default = e.attribute.default), (e == null || (n = e.attribute) == null ? void 0 : n.validate) !== void 0 && (r.validate = e.attribute.validate), [e.name, r];
|
|
793
787
|
}
|
|
794
|
-
function
|
|
795
|
-
let n =
|
|
788
|
+
function Ut(e, t) {
|
|
789
|
+
let n = Ft(e), { nodeExtensions: r, markExtensions: a } = U(e), o = r.find((e) => R(e, "topNode"))?.name, s = Object.fromEntries(r.map((r) => {
|
|
796
790
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
797
791
|
name: r.name,
|
|
798
792
|
options: r.options,
|
|
799
793
|
storage: r.storage,
|
|
800
794
|
editor: t
|
|
801
|
-
}, o =
|
|
795
|
+
}, o = Vt({
|
|
802
796
|
...e.reduce((e, t) => {
|
|
803
|
-
let n =
|
|
797
|
+
let n = R(t, "extendNodeSchema", a);
|
|
804
798
|
return {
|
|
805
799
|
...e,
|
|
806
800
|
...n ? n(r) : {}
|
|
807
801
|
};
|
|
808
802
|
}, {}),
|
|
809
|
-
content:
|
|
810
|
-
marks:
|
|
811
|
-
group:
|
|
812
|
-
inline:
|
|
813
|
-
atom:
|
|
814
|
-
selectable:
|
|
815
|
-
draggable:
|
|
816
|
-
code:
|
|
817
|
-
whitespace:
|
|
818
|
-
linebreakReplacement:
|
|
819
|
-
defining:
|
|
820
|
-
isolating:
|
|
821
|
-
attrs: Object.fromEntries(i.map(
|
|
822
|
-
}), s =
|
|
823
|
-
s && (o.parseDOM = s.map((e) =>
|
|
824
|
-
let c =
|
|
803
|
+
content: H(R(r, "content", a)),
|
|
804
|
+
marks: H(R(r, "marks", a)),
|
|
805
|
+
group: H(R(r, "group", a)),
|
|
806
|
+
inline: H(R(r, "inline", a)),
|
|
807
|
+
atom: H(R(r, "atom", a)),
|
|
808
|
+
selectable: H(R(r, "selectable", a)),
|
|
809
|
+
draggable: H(R(r, "draggable", a)),
|
|
810
|
+
code: H(R(r, "code", a)),
|
|
811
|
+
whitespace: H(R(r, "whitespace", a)),
|
|
812
|
+
linebreakReplacement: H(R(r, "linebreakReplacement", a)),
|
|
813
|
+
defining: H(R(r, "defining", a)),
|
|
814
|
+
isolating: H(R(r, "isolating", a)),
|
|
815
|
+
attrs: Object.fromEntries(i.map(Ht))
|
|
816
|
+
}), s = H(R(r, "parseHTML", a));
|
|
817
|
+
s && (o.parseDOM = s.map((e) => Bt(e, i)));
|
|
818
|
+
let c = R(r, "renderHTML", a);
|
|
825
819
|
c && (o.toDOM = (e) => c({
|
|
826
820
|
node: e,
|
|
827
|
-
HTMLAttributes:
|
|
821
|
+
HTMLAttributes: W(e, i)
|
|
828
822
|
}));
|
|
829
|
-
let l =
|
|
823
|
+
let l = R(r, "renderText", a);
|
|
830
824
|
return l && (o.toText = l), [r.name, o];
|
|
831
|
-
})), c = Object.fromEntries(
|
|
825
|
+
})), c = Object.fromEntries(a.map((r) => {
|
|
832
826
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
833
827
|
name: r.name,
|
|
834
828
|
options: r.options,
|
|
835
829
|
storage: r.storage,
|
|
836
830
|
editor: t
|
|
837
|
-
}, o =
|
|
831
|
+
}, o = Vt({
|
|
838
832
|
...e.reduce((e, t) => {
|
|
839
|
-
let n =
|
|
833
|
+
let n = R(t, "extendMarkSchema", a);
|
|
840
834
|
return {
|
|
841
835
|
...e,
|
|
842
836
|
...n ? n(r) : {}
|
|
843
837
|
};
|
|
844
838
|
}, {}),
|
|
845
|
-
inclusive:
|
|
846
|
-
excludes:
|
|
847
|
-
group:
|
|
848
|
-
spanning:
|
|
849
|
-
code:
|
|
850
|
-
attrs: Object.fromEntries(i.map(
|
|
851
|
-
}), s =
|
|
852
|
-
s && (o.parseDOM = s.map((e) =>
|
|
853
|
-
let c =
|
|
839
|
+
inclusive: H(R(r, "inclusive", a)),
|
|
840
|
+
excludes: H(R(r, "excludes", a)),
|
|
841
|
+
group: H(R(r, "group", a)),
|
|
842
|
+
spanning: H(R(r, "spanning", a)),
|
|
843
|
+
code: H(R(r, "code", a)),
|
|
844
|
+
attrs: Object.fromEntries(i.map(Ht))
|
|
845
|
+
}), s = H(R(r, "parseHTML", a));
|
|
846
|
+
s && (o.parseDOM = s.map((e) => Bt(e, i)));
|
|
847
|
+
let c = R(r, "renderHTML", a);
|
|
854
848
|
return c && (o.toDOM = (e) => c({
|
|
855
849
|
mark: e,
|
|
856
|
-
HTMLAttributes:
|
|
850
|
+
HTMLAttributes: W(e, i)
|
|
857
851
|
})), [r.name, o];
|
|
858
852
|
}));
|
|
859
|
-
return new
|
|
853
|
+
return new i({
|
|
860
854
|
topNode: o,
|
|
861
855
|
nodes: s,
|
|
862
856
|
marks: c
|
|
863
857
|
});
|
|
864
858
|
}
|
|
865
|
-
function
|
|
859
|
+
function Wt(e) {
|
|
866
860
|
let t = e.filter((t, n) => e.indexOf(t) !== n);
|
|
867
861
|
return Array.from(new Set(t));
|
|
868
862
|
}
|
|
869
|
-
function
|
|
863
|
+
function G(e) {
|
|
870
864
|
return e.sort((e, t) => {
|
|
871
|
-
let n =
|
|
865
|
+
let n = R(e, "priority") || 100, r = R(t, "priority") || 100;
|
|
872
866
|
return n > r ? -1 : +(n < r);
|
|
873
867
|
});
|
|
874
868
|
}
|
|
875
|
-
function
|
|
876
|
-
let t =
|
|
869
|
+
function Gt(e) {
|
|
870
|
+
let t = G(z(e)), n = Wt(t.map((e) => e.name));
|
|
877
871
|
return n.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e) => `'${e}'`).join(", ")}]. This can lead to issues.`), t;
|
|
878
872
|
}
|
|
879
|
-
function
|
|
880
|
-
return
|
|
873
|
+
function Kt(e, t) {
|
|
874
|
+
return Ut(Gt(e), t);
|
|
881
875
|
}
|
|
882
|
-
function
|
|
883
|
-
let n =
|
|
884
|
-
return
|
|
876
|
+
function qt(e, t) {
|
|
877
|
+
let n = Kt(t);
|
|
878
|
+
return B(r.fromJSON(n, e).content, n);
|
|
885
879
|
}
|
|
886
|
-
function
|
|
887
|
-
let r =
|
|
888
|
-
return
|
|
880
|
+
function Jt(t, n) {
|
|
881
|
+
let r = Kt(n), i = N(t);
|
|
882
|
+
return e.fromSchema(r).parse(i).toJSON();
|
|
889
883
|
}
|
|
890
|
-
function
|
|
884
|
+
function Yt(e, t, n) {
|
|
891
885
|
let { from: r, to: i } = t, { blockSeparator: a = "\n\n", textSerializers: o = {} } = n || {}, s = "";
|
|
892
886
|
return e.nodesBetween(r, i, (e, n, c, l) => {
|
|
893
887
|
e.isBlock && n > r && (s += a);
|
|
@@ -905,39 +899,39 @@ function Kt(e, t, n) {
|
|
|
905
899
|
}
|
|
906
900
|
}), s;
|
|
907
901
|
}
|
|
908
|
-
function
|
|
909
|
-
return
|
|
902
|
+
function Xt(e, t) {
|
|
903
|
+
return Yt(e, {
|
|
910
904
|
from: 0,
|
|
911
905
|
to: e.content.size
|
|
912
906
|
}, t);
|
|
913
907
|
}
|
|
914
|
-
function
|
|
908
|
+
function Zt(e) {
|
|
915
909
|
return Object.fromEntries(Object.entries(e.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText]));
|
|
916
910
|
}
|
|
917
|
-
function
|
|
918
|
-
let n =
|
|
911
|
+
function Qt(e, t) {
|
|
912
|
+
let n = D(t, e.schema), { from: r, to: i } = e.selection, a = [];
|
|
919
913
|
e.doc.nodesBetween(r, i, (e) => {
|
|
920
914
|
a.push(e);
|
|
921
915
|
});
|
|
922
916
|
let o = a.reverse().find((e) => e.type.name === n.name);
|
|
923
917
|
return o ? { ...o.attrs } : {};
|
|
924
918
|
}
|
|
925
|
-
function
|
|
926
|
-
let n =
|
|
927
|
-
return n === "node" ?
|
|
919
|
+
function $t(e, t) {
|
|
920
|
+
let n = I(typeof t == "string" ? t : t.name, e.schema);
|
|
921
|
+
return n === "node" ? Qt(e, t) : n === "mark" ? At(e, t) : {};
|
|
928
922
|
}
|
|
929
|
-
function
|
|
923
|
+
function en(e, t = JSON.stringify) {
|
|
930
924
|
let n = {};
|
|
931
925
|
return e.filter((e) => {
|
|
932
926
|
let r = t(e);
|
|
933
927
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
934
928
|
});
|
|
935
929
|
}
|
|
936
|
-
function
|
|
937
|
-
let t =
|
|
930
|
+
function tn(e) {
|
|
931
|
+
let t = en(e);
|
|
938
932
|
return t.length === 1 ? t : t.filter((e, n) => !t.filter((e, t) => t !== n).some((t) => e.oldRange.from >= t.oldRange.from && e.oldRange.to <= t.oldRange.to && e.newRange.from >= t.newRange.from && e.newRange.to <= t.newRange.to));
|
|
939
933
|
}
|
|
940
|
-
function
|
|
934
|
+
function nn(e) {
|
|
941
935
|
let { mapping: t, steps: n } = e, r = [];
|
|
942
936
|
return t.maps.forEach((e, i) => {
|
|
943
937
|
let a = [];
|
|
@@ -968,47 +962,47 @@ function $t(e) {
|
|
|
968
962
|
}
|
|
969
963
|
});
|
|
970
964
|
});
|
|
971
|
-
}),
|
|
965
|
+
}), tn(r);
|
|
972
966
|
}
|
|
973
|
-
function
|
|
967
|
+
function rn(e, t, n) {
|
|
974
968
|
let r = [];
|
|
975
969
|
return e === t ? n.resolve(e).marks().forEach((t) => {
|
|
976
|
-
let i =
|
|
970
|
+
let i = Be(n.resolve(e), t.type);
|
|
977
971
|
i && r.push({
|
|
978
972
|
mark: t,
|
|
979
973
|
...i
|
|
980
974
|
});
|
|
981
975
|
}) : n.nodesBetween(e, t, (e, t) => {
|
|
982
|
-
|
|
976
|
+
e && e?.nodeSize !== void 0 && r.push(...e.marks.map((n) => ({
|
|
983
977
|
from: t,
|
|
984
978
|
to: t + e.nodeSize,
|
|
985
979
|
mark: n
|
|
986
980
|
})));
|
|
987
981
|
}), r;
|
|
988
982
|
}
|
|
989
|
-
var
|
|
983
|
+
var an = (e, t, n, r = 20) => {
|
|
990
984
|
let i = e.doc.resolve(n), a = r, o = null;
|
|
991
985
|
for (; a > 0 && o === null;) {
|
|
992
986
|
let e = i.node(a);
|
|
993
987
|
e?.type.name === t ? o = e : --a;
|
|
994
988
|
}
|
|
995
989
|
return [o, a];
|
|
996
|
-
},
|
|
990
|
+
}, on = (e) => {
|
|
997
991
|
let t = e.depth - 1;
|
|
998
992
|
if (t < 0) return null;
|
|
999
993
|
let n = e.index(t);
|
|
1000
994
|
return n === 0 ? null : e.node(t).child(n - 1);
|
|
1001
995
|
};
|
|
1002
|
-
function
|
|
996
|
+
function K(e, t) {
|
|
1003
997
|
return t.nodes[e] || t.marks[e] || null;
|
|
1004
998
|
}
|
|
1005
|
-
function
|
|
999
|
+
function q(e, t, n) {
|
|
1006
1000
|
return Object.fromEntries(Object.entries(n).filter(([n]) => {
|
|
1007
1001
|
let r = e.find((e) => e.type === t && e.name === n);
|
|
1008
1002
|
return r ? r.attribute.keepOnSplit : !1;
|
|
1009
1003
|
}));
|
|
1010
1004
|
}
|
|
1011
|
-
var
|
|
1005
|
+
var sn = (e, t = 500) => {
|
|
1012
1006
|
let n = "", r = e.parentOffset;
|
|
1013
1007
|
return e.parent.nodesBetween(Math.max(0, r - t), r, (e, t, i, a) => {
|
|
1014
1008
|
var o;
|
|
@@ -1021,9 +1015,9 @@ var rn = (e, t = 500) => {
|
|
|
1021
1015
|
n += e.isAtom && !e.isText ? s : s.slice(0, Math.max(0, r - t));
|
|
1022
1016
|
}), n;
|
|
1023
1017
|
};
|
|
1024
|
-
function
|
|
1025
|
-
let { empty: r, ranges: i } = e.selection, a = t ?
|
|
1026
|
-
if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) =>
|
|
1018
|
+
function cn(e, t, n = {}) {
|
|
1019
|
+
let { empty: r, ranges: i } = e.selection, a = t ? A(t, e.schema) : null;
|
|
1020
|
+
if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) => k(e.attrs, n, { strict: !1 }));
|
|
1027
1021
|
let o = 0, s = [];
|
|
1028
1022
|
if (i.forEach(({ $from: t, $to: n }) => {
|
|
1029
1023
|
let r = t.pos, i = n.pos;
|
|
@@ -1038,41 +1032,41 @@ function an(e, t, n = {}) {
|
|
|
1038
1032
|
})));
|
|
1039
1033
|
});
|
|
1040
1034
|
}), o === 0) return !1;
|
|
1041
|
-
let c = s.filter((e) => !a || a.name === e.mark.type.name).filter((e) =>
|
|
1035
|
+
let c = s.filter((e) => !a || a.name === e.mark.type.name).filter((e) => k(e.mark.attrs, n, { strict: !1 })).reduce((e, t) => e + t.to - t.from, 0), l = s.filter((e) => !a || e.mark.type !== a && e.mark.type.excludes(a)).reduce((e, t) => e + t.to - t.from, 0);
|
|
1042
1036
|
return (c > 0 ? c + l : c) >= o;
|
|
1043
1037
|
}
|
|
1044
|
-
function
|
|
1045
|
-
if (!t) return
|
|
1046
|
-
let r =
|
|
1047
|
-
return r === "node" ?
|
|
1038
|
+
function ln(e, t, n = {}) {
|
|
1039
|
+
if (!t) return F(e, null, n) || cn(e, null, n);
|
|
1040
|
+
let r = I(t, e.schema);
|
|
1041
|
+
return r === "node" ? F(e, t, n) : r === "mark" && cn(e, t, n);
|
|
1048
1042
|
}
|
|
1049
|
-
var
|
|
1043
|
+
var un = (e, t) => {
|
|
1050
1044
|
let { $from: n, $to: r, $anchor: i } = e.selection;
|
|
1051
1045
|
if (t) {
|
|
1052
|
-
let n =
|
|
1046
|
+
let n = L((e) => e.type.name === t)(e.selection);
|
|
1053
1047
|
if (!n) return !1;
|
|
1054
1048
|
let r = e.doc.resolve(n.pos + 1);
|
|
1055
1049
|
return i.pos + 1 === r.end();
|
|
1056
1050
|
}
|
|
1057
1051
|
return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
|
|
1058
|
-
},
|
|
1052
|
+
}, dn = (e) => {
|
|
1059
1053
|
let { $from: t, $to: n } = e.selection;
|
|
1060
1054
|
return !(t.parentOffset > 0 || t.pos !== n.pos);
|
|
1061
1055
|
};
|
|
1062
|
-
function
|
|
1056
|
+
function fn(e, t) {
|
|
1063
1057
|
return Array.isArray(t) ? t.some((t) => (typeof t == "string" ? t : t.name) === e.name) : t;
|
|
1064
1058
|
}
|
|
1065
|
-
function
|
|
1066
|
-
let { nodeExtensions: n } =
|
|
1059
|
+
function pn(e, t) {
|
|
1060
|
+
let { nodeExtensions: n } = U(t), r = n.find((t) => t.name === e);
|
|
1067
1061
|
if (!r) return !1;
|
|
1068
|
-
let i =
|
|
1062
|
+
let i = H(R(r, "group", {
|
|
1069
1063
|
name: r.name,
|
|
1070
1064
|
options: r.options,
|
|
1071
1065
|
storage: r.storage
|
|
1072
1066
|
}));
|
|
1073
1067
|
return typeof i == "string" && i.split(" ").includes("list");
|
|
1074
1068
|
}
|
|
1075
|
-
function
|
|
1069
|
+
function mn(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
1076
1070
|
if (n) {
|
|
1077
1071
|
if (e.type.name === "hardBreak") return !0;
|
|
1078
1072
|
if (e.isText) return !/\S/.test(e.text ?? "");
|
|
@@ -1083,7 +1077,7 @@ function dn(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1083
1077
|
if (t) {
|
|
1084
1078
|
let r = !0;
|
|
1085
1079
|
return e.content.forEach((e) => {
|
|
1086
|
-
r !== !1 && (
|
|
1080
|
+
r !== !1 && (mn(e, {
|
|
1087
1081
|
ignoreWhitespace: n,
|
|
1088
1082
|
checkChildren: t
|
|
1089
1083
|
}) || (r = !1));
|
|
@@ -1091,10 +1085,10 @@ function dn(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1091
1085
|
}
|
|
1092
1086
|
return !1;
|
|
1093
1087
|
}
|
|
1094
|
-
function
|
|
1095
|
-
return e instanceof
|
|
1088
|
+
function hn(e) {
|
|
1089
|
+
return e instanceof _;
|
|
1096
1090
|
}
|
|
1097
|
-
var
|
|
1091
|
+
var gn = class e {
|
|
1098
1092
|
constructor(e) {
|
|
1099
1093
|
this.position = e;
|
|
1100
1094
|
}
|
|
@@ -1105,19 +1099,19 @@ var pn = class e {
|
|
|
1105
1099
|
return { position: this.position };
|
|
1106
1100
|
}
|
|
1107
1101
|
};
|
|
1108
|
-
function
|
|
1102
|
+
function _n(e, t) {
|
|
1109
1103
|
let n = t.mapping.mapResult(e.position);
|
|
1110
1104
|
return {
|
|
1111
|
-
position: new
|
|
1105
|
+
position: new gn(n.pos),
|
|
1112
1106
|
mapResult: n
|
|
1113
1107
|
};
|
|
1114
1108
|
}
|
|
1115
|
-
function
|
|
1116
|
-
return new
|
|
1109
|
+
function vn(e) {
|
|
1110
|
+
return new gn(e);
|
|
1117
1111
|
}
|
|
1118
|
-
function
|
|
1112
|
+
function yn(e, t, n) {
|
|
1119
1113
|
let { selection: r } = t, i = null;
|
|
1120
|
-
if (
|
|
1114
|
+
if (Ue(r) && (i = r.$cursor), i) {
|
|
1121
1115
|
let t = e.storedMarks ?? i.marks();
|
|
1122
1116
|
return i.parent.type.allowsMarkType(n) && (!!n.isInSet(t) || !t.some((e) => e.type.excludes(n)));
|
|
1123
1117
|
}
|
|
@@ -1134,11 +1128,11 @@ function gn(e, t, n) {
|
|
|
1134
1128
|
}), i;
|
|
1135
1129
|
});
|
|
1136
1130
|
}
|
|
1137
|
-
var
|
|
1138
|
-
let { selection: a } = n, { empty: o, ranges: s } = a, c =
|
|
1131
|
+
var bn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1132
|
+
let { selection: a } = n, { empty: o, ranges: s } = a, c = A(e, r.schema);
|
|
1139
1133
|
if (i) {
|
|
1140
1134
|
if (o) {
|
|
1141
|
-
let e =
|
|
1135
|
+
let e = At(r, c);
|
|
1142
1136
|
n.addStoredMark(c.create({
|
|
1143
1137
|
...e,
|
|
1144
1138
|
...t
|
|
@@ -1156,23 +1150,23 @@ var _n = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1156
1150
|
});
|
|
1157
1151
|
});
|
|
1158
1152
|
}
|
|
1159
|
-
return
|
|
1160
|
-
},
|
|
1161
|
-
let a =
|
|
1162
|
-
return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) =>
|
|
1153
|
+
return yn(r, n, c);
|
|
1154
|
+
}, xn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), Sn = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
|
|
1155
|
+
let a = D(e, n.schema), o;
|
|
1156
|
+
return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) => he(a, {
|
|
1163
1157
|
...o,
|
|
1164
1158
|
...t
|
|
1165
|
-
})(n) ? !0 : e.clearNodes()).command(({ state: e }) =>
|
|
1159
|
+
})(n) ? !0 : e.clearNodes()).command(({ state: e }) => he(a, {
|
|
1166
1160
|
...o,
|
|
1167
1161
|
...t
|
|
1168
1162
|
})(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1);
|
|
1169
|
-
},
|
|
1163
|
+
}, Cn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1170
1164
|
if (n) {
|
|
1171
|
-
let { doc: n } = t, r =
|
|
1165
|
+
let { doc: n } = t, r = j(e, 0, n.content.size), i = _.create(n, r);
|
|
1172
1166
|
t.setSelection(i);
|
|
1173
1167
|
}
|
|
1174
1168
|
return !0;
|
|
1175
|
-
},
|
|
1169
|
+
}, wn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1176
1170
|
let { selection: a } = r, o, s;
|
|
1177
1171
|
return typeof t == "number" ? (o = t, s = t) : t && "from" in t && "to" in t ? (o = t.from, s = t.to) : (o = a.from, s = a.to), i && n.doc.nodesBetween(o, s, (t, r) => {
|
|
1178
1172
|
t.isText || n.setNodeMarkup(r, void 0, {
|
|
@@ -1180,157 +1174,163 @@ var _n = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1180
1174
|
dir: e
|
|
1181
1175
|
});
|
|
1182
1176
|
}), !0;
|
|
1183
|
-
},
|
|
1177
|
+
}, Tn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1184
1178
|
if (n) {
|
|
1185
1179
|
let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? {
|
|
1186
1180
|
from: e,
|
|
1187
1181
|
to: e
|
|
1188
|
-
} : e, a =
|
|
1182
|
+
} : e, a = x.atStart(n).from, o = x.atEnd(n).to, s = j(r, a, o), c = j(i, a, o), l = x.create(n, s, c);
|
|
1189
1183
|
t.setSelection(l);
|
|
1190
1184
|
}
|
|
1191
1185
|
return !0;
|
|
1192
|
-
},
|
|
1193
|
-
let r =
|
|
1194
|
-
return
|
|
1186
|
+
}, En = (e) => ({ state: t, dispatch: n }) => {
|
|
1187
|
+
let r = D(e, t.schema);
|
|
1188
|
+
return ve(r)(t, n);
|
|
1195
1189
|
};
|
|
1196
|
-
function
|
|
1190
|
+
function Dn(e, t) {
|
|
1197
1191
|
let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
|
|
1198
1192
|
if (n) {
|
|
1199
1193
|
let r = n.filter((e) => t?.includes(e.type.name));
|
|
1200
1194
|
e.tr.ensureMarks(r);
|
|
1201
1195
|
}
|
|
1202
1196
|
}
|
|
1203
|
-
var
|
|
1204
|
-
let { selection: a, doc: o } = t, { $from: s, $to: c } = a, l = i.extensionManager.attributes, u =
|
|
1205
|
-
if (a instanceof
|
|
1197
|
+
var On = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: i }) => {
|
|
1198
|
+
let { selection: a, doc: o } = t, { $from: s, $to: c } = a, l = i.extensionManager.attributes, u = q(l, s.node().type.name, s.node().attrs);
|
|
1199
|
+
if (a instanceof _ && a.node.isBlock) return !s.parentOffset || !d(o, s.pos) ? !1 : (r && (e && Dn(n, i.extensionManager.splittableMarks), t.split(s.pos).scrollIntoView()), !0);
|
|
1206
1200
|
if (!s.parent.isBlock) return !1;
|
|
1207
|
-
let
|
|
1201
|
+
let f = c.parentOffset === c.parent.content.size, p = s.depth === 0 ? void 0 : tt(s.node(-1).contentMatchAt(s.indexAfter(-1))), m = f && p ? [{
|
|
1208
1202
|
type: p,
|
|
1209
1203
|
attrs: u
|
|
1210
|
-
}] : void 0, h =
|
|
1211
|
-
|
|
1204
|
+
}] : void 0, h = a instanceof x && !a.empty ? g.create({
|
|
1205
|
+
doc: t.doc,
|
|
1206
|
+
selection: a
|
|
1207
|
+
}).tr.deleteSelection() : null, v = h ? h.doc : t.doc, y = h ? h.mapping.map(s.pos) : s.pos, b = d(v, y, 1, m);
|
|
1208
|
+
if (!m && !b && d(v, y, 1, p ? [{ type: p }] : void 0) && (b = !0, m = p ? [{
|
|
1212
1209
|
type: p,
|
|
1213
1210
|
attrs: u
|
|
1214
1211
|
}] : void 0), r) {
|
|
1215
|
-
if (
|
|
1216
|
-
let e = t.
|
|
1217
|
-
|
|
1212
|
+
if (b) {
|
|
1213
|
+
let e = t.steps.length;
|
|
1214
|
+
if (a instanceof x && t.deleteSelection(), t.split(t.mapping.slice(e).map(s.pos), 1, m), p && !f && !s.parentOffset && s.parent.type !== p) {
|
|
1215
|
+
let n = t.mapping.slice(e).map(s.before()), r = t.doc.resolve(n);
|
|
1216
|
+
s.node(-1).canReplaceWith(r.index(), r.index() + 1, p) && t.setNodeMarkup(t.mapping.slice(e).map(s.before()), p);
|
|
1217
|
+
}
|
|
1218
1218
|
}
|
|
1219
|
-
e &&
|
|
1219
|
+
e && Dn(n, i.extensionManager.splittableMarks), t.scrollIntoView();
|
|
1220
1220
|
}
|
|
1221
|
-
return
|
|
1222
|
-
},
|
|
1223
|
-
let c =
|
|
1224
|
-
if (
|
|
1221
|
+
return b;
|
|
1222
|
+
}, kn = (e, t = {}) => ({ tr: r, state: i, dispatch: o, editor: s }) => {
|
|
1223
|
+
let c = D(e, i.schema), { $from: l, $to: u } = i.selection, f = i.selection.node;
|
|
1224
|
+
if (f && f.isBlock || l.depth < 2 || !l.sameParent(u)) return !1;
|
|
1225
1225
|
let p = l.node(-1);
|
|
1226
1226
|
if (p.type !== c) return !1;
|
|
1227
1227
|
let m = s.extensionManager.attributes;
|
|
1228
1228
|
if (l.parent.content.size === 0 && l.node(-1).childCount === l.indexAfter(-1)) {
|
|
1229
1229
|
if (l.depth === 2 || l.node(-3).type !== c || l.index(-2) !== l.node(-2).childCount - 1) return !1;
|
|
1230
|
-
if (
|
|
1231
|
-
let e =
|
|
1232
|
-
for (let t = l.depth - i; t >= l.depth - 3; --t) e =
|
|
1233
|
-
let
|
|
1234
|
-
...
|
|
1230
|
+
if (o) {
|
|
1231
|
+
let e = n.empty, i = l.index(-1) ? 1 : l.index(-2) ? 2 : 3;
|
|
1232
|
+
for (let t = l.depth - i; t >= l.depth - 3; --t) e = n.from(l.node(t).copy(e));
|
|
1233
|
+
let o = l.indexAfter(-1) < l.node(-2).childCount ? 1 : l.indexAfter(-2) < l.node(-3).childCount ? 2 : 3, s = {
|
|
1234
|
+
...q(m, l.node().type.name, l.node().attrs),
|
|
1235
1235
|
...t
|
|
1236
1236
|
}, u = c.contentMatch.defaultType?.createAndFill(s) || void 0;
|
|
1237
|
-
e = e.append(
|
|
1237
|
+
e = e.append(n.from(c.createAndFill(null, u) || void 0));
|
|
1238
1238
|
let d = l.before(l.depth - (i - 1));
|
|
1239
|
-
|
|
1239
|
+
r.replace(d, l.after(-o), new a(e, 4 - i, 0));
|
|
1240
1240
|
let f = -1;
|
|
1241
|
-
|
|
1241
|
+
r.doc.nodesBetween(d, r.doc.content.size, (e, t) => {
|
|
1242
1242
|
if (f > -1) return !1;
|
|
1243
1243
|
e.isTextblock && e.content.size === 0 && (f = t + 1);
|
|
1244
|
-
}), f > -1 &&
|
|
1244
|
+
}), f > -1 && r.setSelection(x.near(r.doc.resolve(f))), r.scrollIntoView();
|
|
1245
1245
|
}
|
|
1246
1246
|
return !0;
|
|
1247
1247
|
}
|
|
1248
1248
|
let h = u.pos === l.end() ? p.contentMatchAt(0).defaultType : null, g = {
|
|
1249
|
-
...
|
|
1249
|
+
...q(m, p.type.name, p.attrs),
|
|
1250
1250
|
...t
|
|
1251
1251
|
}, _ = {
|
|
1252
|
-
...
|
|
1252
|
+
...q(m, l.node().type.name, l.node().attrs),
|
|
1253
1253
|
...t
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
let v = h ? [{
|
|
1254
|
+
}, v = l.parentOffset === 0 && l.index(-1) === 0, y = l.before(-1);
|
|
1255
|
+
r.delete(l.pos, u.pos);
|
|
1256
|
+
let b = v ? p.attrs : g, S = h ? [{
|
|
1257
1257
|
type: c,
|
|
1258
|
-
attrs:
|
|
1258
|
+
attrs: b
|
|
1259
1259
|
}, {
|
|
1260
1260
|
type: h,
|
|
1261
1261
|
attrs: _
|
|
1262
1262
|
}] : [{
|
|
1263
1263
|
type: c,
|
|
1264
|
-
attrs:
|
|
1264
|
+
attrs: b
|
|
1265
1265
|
}];
|
|
1266
|
-
if (!
|
|
1267
|
-
if (
|
|
1268
|
-
let { selection: e, storedMarks: t } = i, { splittableMarks:
|
|
1269
|
-
if (
|
|
1270
|
-
let c =
|
|
1271
|
-
|
|
1266
|
+
if (!d(r.doc, l.pos, 2)) return !1;
|
|
1267
|
+
if (o) {
|
|
1268
|
+
let { selection: e, storedMarks: t } = i, { splittableMarks: n } = s.extensionManager, a = t || e.$to.parentOffset && e.$from.marks();
|
|
1269
|
+
if (r.split(l.pos, 2, S).scrollIntoView(), v && r.setNodeMarkup(y, void 0, g), !a || !o) return !0;
|
|
1270
|
+
let c = a.filter((e) => n.includes(e.type.name));
|
|
1271
|
+
r.ensureMarks(c);
|
|
1272
1272
|
}
|
|
1273
1273
|
return !0;
|
|
1274
1274
|
};
|
|
1275
|
-
function
|
|
1275
|
+
function An(e) {
|
|
1276
1276
|
return !e || e === "1" ? null : e;
|
|
1277
1277
|
}
|
|
1278
|
-
function
|
|
1279
|
-
return
|
|
1278
|
+
function jn(e, t) {
|
|
1279
|
+
return An(e) === An(t);
|
|
1280
1280
|
}
|
|
1281
|
-
var
|
|
1282
|
-
let n =
|
|
1281
|
+
var Mn = (e, t) => {
|
|
1282
|
+
let n = L((e) => e.type === t)(e.selection);
|
|
1283
1283
|
if (!n) return !0;
|
|
1284
1284
|
let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
|
|
1285
1285
|
if (r === void 0) return !0;
|
|
1286
1286
|
let i = e.doc.nodeAt(r);
|
|
1287
|
-
return !(n.node.type === i?.type &&
|
|
1288
|
-
},
|
|
1289
|
-
let n =
|
|
1287
|
+
return !(n.node.type === i?.type && u(e.doc, n.pos)) || !jn(n.node.attrs.type, i?.attrs.type) || e.join(n.pos), !0;
|
|
1288
|
+
}, Nn = (e, t) => {
|
|
1289
|
+
let n = L((e) => e.type === t)(e.selection);
|
|
1290
1290
|
if (!n) return !0;
|
|
1291
1291
|
let r = e.doc.resolve(n.start).after(n.depth);
|
|
1292
1292
|
if (r === void 0) return !0;
|
|
1293
1293
|
let i = e.doc.nodeAt(r);
|
|
1294
|
-
return !(n.node.type === i?.type &&
|
|
1294
|
+
return !(n.node.type === i?.type && u(e.doc, r)) || !jn(n.node.attrs.type, i?.attrs.type) || e.join(r), !0;
|
|
1295
1295
|
};
|
|
1296
|
-
function
|
|
1296
|
+
function Pn(e) {
|
|
1297
1297
|
let t = e.doc, n = t.firstChild;
|
|
1298
1298
|
if (!n) return null;
|
|
1299
1299
|
let r = t.resolve(1), i = t.resolve(n.nodeSize - 1);
|
|
1300
|
-
return
|
|
1300
|
+
return x.between(r, i);
|
|
1301
1301
|
}
|
|
1302
|
-
var
|
|
1303
|
-
let { extensions: d, splittableMarks: f } = i.extensionManager, p =
|
|
1302
|
+
var Fn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
|
|
1303
|
+
let { extensions: d, splittableMarks: f } = i.extensionManager, p = D(e, o.schema), m = D(t, o.schema), { selection: h, storedMarks: g } = o, { $from: _, $to: v } = h, y = _.blockRange(v), b = g || h.$to.parentOffset && h.$from.marks();
|
|
1304
1304
|
if (!y) return !1;
|
|
1305
|
-
let x =
|
|
1306
|
-
node:
|
|
1305
|
+
let x = L((e) => pn(e.type.name, d))(h), S = h.from === 0 && h.to === o.doc.content.size, ee = o.doc.content.content, te = ee.length === 1 ? ee[0] : null, ne = S && te && pn(te.type.name, d) ? {
|
|
1306
|
+
node: te,
|
|
1307
1307
|
pos: 0,
|
|
1308
1308
|
depth: 0
|
|
1309
|
-
} : null,
|
|
1310
|
-
if ((
|
|
1311
|
-
if (
|
|
1312
|
-
let n =
|
|
1309
|
+
} : null, C = x ?? ne, re = !!x && y.depth >= 1 && y.depth - x.depth <= 1, ie = !!ne;
|
|
1310
|
+
if ((re || ie) && C) {
|
|
1311
|
+
if (C.node.type === p) return S && ie ? c().command(({ tr: e, dispatch: t }) => {
|
|
1312
|
+
let n = Pn(e);
|
|
1313
1313
|
return n ? (e.setSelection(n), t && t(e), !0) : !1;
|
|
1314
1314
|
}).liftListItem(m).run() : l.liftListItem(m);
|
|
1315
|
-
if (
|
|
1315
|
+
if (pn(C.node.type.name, d) && p.validContent(C.node.content)) return c().command(() => (a.setNodeMarkup(C.pos, p), !0)).command(() => Mn(a, p)).command(() => Nn(a, p)).run();
|
|
1316
1316
|
}
|
|
1317
|
-
return !n || !b || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() =>
|
|
1317
|
+
return !n || !b || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => Mn(a, p)).command(() => Nn(a, p)).run() : c().command(() => {
|
|
1318
1318
|
let e = u().wrapInList(p, r), t = b.filter((e) => f.includes(e.type.name));
|
|
1319
1319
|
return a.ensureMarks(t), e ? !0 : l.clearNodes();
|
|
1320
|
-
}).wrapInList(p, r).command(() =>
|
|
1321
|
-
},
|
|
1322
|
-
let { extendEmptyMarkRange: a = !1 } = n, o =
|
|
1323
|
-
return
|
|
1324
|
-
},
|
|
1325
|
-
let a =
|
|
1320
|
+
}).wrapInList(p, r).command(() => Mn(a, p)).command(() => Nn(a, p)).run();
|
|
1321
|
+
}, In = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
|
|
1322
|
+
let { extendEmptyMarkRange: a = !1 } = n, o = A(e, r.schema);
|
|
1323
|
+
return cn(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
|
|
1324
|
+
}, Ln = (e, t, n = {}) => ({ state: r, commands: i }) => {
|
|
1325
|
+
let a = D(e, r.schema), o = D(t, r.schema), s = F(r, a, n), c;
|
|
1326
1326
|
return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, {
|
|
1327
1327
|
...c,
|
|
1328
1328
|
...n
|
|
1329
1329
|
});
|
|
1330
|
-
},
|
|
1331
|
-
let i =
|
|
1332
|
-
return
|
|
1333
|
-
},
|
|
1330
|
+
}, Rn = (e, t = {}) => ({ state: n, commands: r }) => {
|
|
1331
|
+
let i = D(e, n.schema);
|
|
1332
|
+
return F(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
|
|
1333
|
+
}, zn = () => ({ state: e, dispatch: t }) => {
|
|
1334
1334
|
let n = e.plugins;
|
|
1335
1335
|
for (let r = 0; r < n.length; r += 1) {
|
|
1336
1336
|
let i = n[r], a;
|
|
@@ -1347,7 +1347,7 @@ var Mn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1347
1347
|
}
|
|
1348
1348
|
}
|
|
1349
1349
|
return !1;
|
|
1350
|
-
},
|
|
1350
|
+
}, Bn = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
1351
1351
|
let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a;
|
|
1352
1352
|
if (o) return !0;
|
|
1353
1353
|
let { nonClearableMarks: c } = r.extensionManager;
|
|
@@ -1358,27 +1358,27 @@ var Mn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1358
1358
|
});
|
|
1359
1359
|
}
|
|
1360
1360
|
return !0;
|
|
1361
|
-
},
|
|
1362
|
-
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s =
|
|
1361
|
+
}, Vn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1362
|
+
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = A(e, r.schema), { $from: c, empty: l, ranges: u } = o;
|
|
1363
1363
|
if (!i) return !0;
|
|
1364
1364
|
if (l && a) {
|
|
1365
|
-
let { from: e, to: t } = o, r =
|
|
1365
|
+
let { from: e, to: t } = o, r = Be(c, s, c.marks().find((e) => e.type === s)?.attrs);
|
|
1366
1366
|
r && (e = r.from, t = r.to), n.removeMark(e, t, s);
|
|
1367
1367
|
} else u.forEach((e) => {
|
|
1368
1368
|
n.removeMark(e.$from.pos, e.$to.pos, s);
|
|
1369
1369
|
});
|
|
1370
1370
|
return n.removeStoredMark(s), !0;
|
|
1371
|
-
},
|
|
1371
|
+
}, Hn = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
1372
1372
|
let { selection: i } = n, a, o;
|
|
1373
1373
|
return typeof e == "number" ? (a = e, o = e) : e && "from" in e && "to" in e ? (a = e.from, o = e.to) : (a = i.from, o = i.to), r && t.doc.nodesBetween(a, o, (e, n) => {
|
|
1374
1374
|
if (e.isText) return;
|
|
1375
1375
|
let r = { ...e.attrs };
|
|
1376
1376
|
delete r.dir, t.setNodeMarkup(n, void 0, r);
|
|
1377
1377
|
}), !0;
|
|
1378
|
-
},
|
|
1379
|
-
let a = null, o = null, s =
|
|
1378
|
+
}, Un = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1379
|
+
let a = null, o = null, s = I(typeof e == "string" ? e : e.name, r.schema);
|
|
1380
1380
|
if (!s) return !1;
|
|
1381
|
-
s === "node" && (a =
|
|
1381
|
+
s === "node" && (a = D(e, r.schema)), s === "mark" && (o = A(e, r.schema));
|
|
1382
1382
|
let c = !1;
|
|
1383
1383
|
return n.selection.ranges.forEach((e) => {
|
|
1384
1384
|
let s = e.$from.pos, l = e.$to.pos, u, d, f, p;
|
|
@@ -1407,92 +1407,92 @@ var Mn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1407
1407
|
}));
|
|
1408
1408
|
}));
|
|
1409
1409
|
}), c;
|
|
1410
|
-
},
|
|
1410
|
+
}, J = new y("__tiptap_decorations__"), Wn = (e) => ({ tr: t, dispatch: n }) => (n && t.setMeta(J, {
|
|
1411
1411
|
type: "force",
|
|
1412
1412
|
name: e
|
|
1413
|
-
}), !0),
|
|
1414
|
-
let i =
|
|
1415
|
-
return
|
|
1416
|
-
},
|
|
1417
|
-
let i =
|
|
1418
|
-
return
|
|
1419
|
-
},
|
|
1420
|
-
blur: () =>
|
|
1421
|
-
clearContent: () =>
|
|
1422
|
-
clearNodes: () =>
|
|
1423
|
-
command: () =>
|
|
1424
|
-
createParagraphNear: () =>
|
|
1425
|
-
cut: () =>
|
|
1426
|
-
deleteCurrentNode: () =>
|
|
1427
|
-
deleteNode: () =>
|
|
1428
|
-
deleteRange: () =>
|
|
1429
|
-
deleteSelection: () =>
|
|
1430
|
-
enter: () =>
|
|
1431
|
-
exitCode: () =>
|
|
1432
|
-
extendMarkRange: () =>
|
|
1433
|
-
first: () =>
|
|
1434
|
-
focus: () =>
|
|
1435
|
-
forEach: () =>
|
|
1436
|
-
insertContent: () =>
|
|
1437
|
-
insertContentAt: () =>
|
|
1438
|
-
insertDefaultBlock: () =>
|
|
1439
|
-
joinBackward: () =>
|
|
1440
|
-
joinDown: () =>
|
|
1441
|
-
joinForward: () =>
|
|
1442
|
-
joinItemBackward: () =>
|
|
1443
|
-
joinItemForward: () =>
|
|
1444
|
-
joinTextblockBackward: () =>
|
|
1445
|
-
joinTextblockForward: () =>
|
|
1446
|
-
joinUp: () =>
|
|
1447
|
-
keyboardShortcut: () =>
|
|
1448
|
-
lift: () =>
|
|
1449
|
-
liftEmptyBlock: () =>
|
|
1450
|
-
liftListItem: () =>
|
|
1451
|
-
newlineInCode: () =>
|
|
1452
|
-
resetAttributes: () =>
|
|
1453
|
-
scrollIntoView: () =>
|
|
1454
|
-
selectAll: () =>
|
|
1455
|
-
selectNodeBackward: () =>
|
|
1456
|
-
selectNodeForward: () =>
|
|
1457
|
-
selectParentNode: () =>
|
|
1458
|
-
selectTextblockEnd: () =>
|
|
1459
|
-
selectTextblockStart: () =>
|
|
1460
|
-
setContent: () =>
|
|
1461
|
-
setMark: () =>
|
|
1462
|
-
setMeta: () =>
|
|
1463
|
-
setNode: () =>
|
|
1464
|
-
setNodeSelection: () =>
|
|
1465
|
-
setTextDirection: () =>
|
|
1466
|
-
setTextSelection: () =>
|
|
1467
|
-
sinkListItem: () =>
|
|
1468
|
-
splitBlock: () =>
|
|
1469
|
-
splitListItem: () =>
|
|
1470
|
-
toggleList: () =>
|
|
1471
|
-
toggleMark: () =>
|
|
1472
|
-
toggleNode: () =>
|
|
1473
|
-
toggleWrap: () =>
|
|
1474
|
-
undoInputRule: () =>
|
|
1475
|
-
unsetAllMarks: () =>
|
|
1476
|
-
unsetMark: () =>
|
|
1477
|
-
unsetTextDirection: () =>
|
|
1478
|
-
updateAttributes: () =>
|
|
1479
|
-
updateDecorations: () =>
|
|
1480
|
-
wrapIn: () =>
|
|
1481
|
-
wrapInList: () =>
|
|
1482
|
-
}),
|
|
1483
|
-
function
|
|
1484
|
-
|
|
1413
|
+
}), !0), Gn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1414
|
+
let i = D(e, n.schema);
|
|
1415
|
+
return ge(i, t)(n, r);
|
|
1416
|
+
}, Kn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1417
|
+
let i = D(e, n.schema);
|
|
1418
|
+
return ye(i, t)(n, r);
|
|
1419
|
+
}, qn = /* @__PURE__ */ S({
|
|
1420
|
+
blur: () => Ce,
|
|
1421
|
+
clearContent: () => we,
|
|
1422
|
+
clearNodes: () => Te,
|
|
1423
|
+
command: () => Ee,
|
|
1424
|
+
createParagraphNear: () => De,
|
|
1425
|
+
cut: () => Oe,
|
|
1426
|
+
deleteCurrentNode: () => ke,
|
|
1427
|
+
deleteNode: () => Ae,
|
|
1428
|
+
deleteRange: () => je,
|
|
1429
|
+
deleteSelection: () => Fe,
|
|
1430
|
+
enter: () => Ie,
|
|
1431
|
+
exitCode: () => Le,
|
|
1432
|
+
extendMarkRange: () => Ve,
|
|
1433
|
+
first: () => He,
|
|
1434
|
+
focus: () => qe,
|
|
1435
|
+
forEach: () => Je,
|
|
1436
|
+
insertContent: () => Ye,
|
|
1437
|
+
insertContentAt: () => et,
|
|
1438
|
+
insertDefaultBlock: () => nt,
|
|
1439
|
+
joinBackward: () => at,
|
|
1440
|
+
joinDown: () => it,
|
|
1441
|
+
joinForward: () => ot,
|
|
1442
|
+
joinItemBackward: () => ct,
|
|
1443
|
+
joinItemForward: () => lt,
|
|
1444
|
+
joinTextblockBackward: () => ut,
|
|
1445
|
+
joinTextblockForward: () => dt,
|
|
1446
|
+
joinUp: () => rt,
|
|
1447
|
+
keyboardShortcut: () => mt,
|
|
1448
|
+
lift: () => ht,
|
|
1449
|
+
liftEmptyBlock: () => gt,
|
|
1450
|
+
liftListItem: () => _t,
|
|
1451
|
+
newlineInCode: () => vt,
|
|
1452
|
+
resetAttributes: () => bt,
|
|
1453
|
+
scrollIntoView: () => xt,
|
|
1454
|
+
selectAll: () => St,
|
|
1455
|
+
selectNodeBackward: () => Ct,
|
|
1456
|
+
selectNodeForward: () => wt,
|
|
1457
|
+
selectParentNode: () => Tt,
|
|
1458
|
+
selectTextblockEnd: () => Et,
|
|
1459
|
+
selectTextblockStart: () => Dt,
|
|
1460
|
+
setContent: () => kt,
|
|
1461
|
+
setMark: () => bn,
|
|
1462
|
+
setMeta: () => xn,
|
|
1463
|
+
setNode: () => Sn,
|
|
1464
|
+
setNodeSelection: () => Cn,
|
|
1465
|
+
setTextDirection: () => wn,
|
|
1466
|
+
setTextSelection: () => Tn,
|
|
1467
|
+
sinkListItem: () => En,
|
|
1468
|
+
splitBlock: () => On,
|
|
1469
|
+
splitListItem: () => kn,
|
|
1470
|
+
toggleList: () => Fn,
|
|
1471
|
+
toggleMark: () => In,
|
|
1472
|
+
toggleNode: () => Ln,
|
|
1473
|
+
toggleWrap: () => Rn,
|
|
1474
|
+
undoInputRule: () => zn,
|
|
1475
|
+
unsetAllMarks: () => Bn,
|
|
1476
|
+
unsetMark: () => Vn,
|
|
1477
|
+
unsetTextDirection: () => Hn,
|
|
1478
|
+
updateAttributes: () => Un,
|
|
1479
|
+
updateDecorations: () => Wn,
|
|
1480
|
+
wrapIn: () => Gn,
|
|
1481
|
+
wrapInList: () => Kn
|
|
1482
|
+
}), Y = /* @__PURE__ */ new WeakMap();
|
|
1483
|
+
function Jn(e, t) {
|
|
1484
|
+
Y.set(e, (Y.get(e) ?? 0) + 1);
|
|
1485
1485
|
try {
|
|
1486
1486
|
return t();
|
|
1487
1487
|
} finally {
|
|
1488
|
-
let t = (
|
|
1489
|
-
t > 0 ?
|
|
1488
|
+
let t = (Y.get(e) ?? 1) - 1;
|
|
1489
|
+
t > 0 ? Y.set(e, t) : Y.delete(e);
|
|
1490
1490
|
}
|
|
1491
1491
|
}
|
|
1492
|
-
function
|
|
1493
|
-
return
|
|
1492
|
+
function Yn(e) {
|
|
1493
|
+
return Y.has(e);
|
|
1494
1494
|
}
|
|
1495
|
-
var
|
|
1495
|
+
var Xn = class {
|
|
1496
1496
|
constructor() {
|
|
1497
1497
|
this.callbacks = {};
|
|
1498
1498
|
}
|
|
@@ -1516,44 +1516,44 @@ var qn = class {
|
|
|
1516
1516
|
removeAllListeners() {
|
|
1517
1517
|
this.callbacks = {};
|
|
1518
1518
|
}
|
|
1519
|
-
},
|
|
1520
|
-
function
|
|
1519
|
+
}, Zn = typeof process < "u" && process.env.NODE_ENV !== "production";
|
|
1520
|
+
function Qn(e) {
|
|
1521
1521
|
return e.kind === "widget";
|
|
1522
1522
|
}
|
|
1523
|
-
function
|
|
1523
|
+
function $n(e, t) {
|
|
1524
1524
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
1525
|
-
for (let i of e) i.kind === "widget" &&
|
|
1525
|
+
for (let i of e) i.kind === "widget" && Qn(i) && r.add(i.key), n.push(i.toPMDecoration(t));
|
|
1526
1526
|
return {
|
|
1527
1527
|
decorations: n,
|
|
1528
1528
|
widgetKeys: r
|
|
1529
1529
|
};
|
|
1530
1530
|
}
|
|
1531
|
-
function
|
|
1532
|
-
let { decorations: r, widgetKeys: i } =
|
|
1531
|
+
function er(e, t, n) {
|
|
1532
|
+
let { decorations: r, widgetKeys: i } = $n(t, n);
|
|
1533
1533
|
return {
|
|
1534
|
-
set:
|
|
1534
|
+
set: w.create(e, r),
|
|
1535
1535
|
widgetKeys: i
|
|
1536
1536
|
};
|
|
1537
1537
|
}
|
|
1538
|
-
function
|
|
1538
|
+
function tr({ position: e, from: t, to: n, docSize: r }) {
|
|
1539
1539
|
return e < t ? !1 : e < n || e === n && n === r;
|
|
1540
1540
|
}
|
|
1541
|
-
function
|
|
1542
|
-
return e.filter((e) =>
|
|
1541
|
+
function nr({ decorations: e, from: t, to: n, docSize: r, extensionName: i, warnedExtensions: a }) {
|
|
1542
|
+
return e.filter((e) => tr({
|
|
1543
1543
|
position: e.anchor,
|
|
1544
1544
|
from: t,
|
|
1545
1545
|
to: n,
|
|
1546
1546
|
docSize: r
|
|
1547
1547
|
}) ? !0 : (e.anchor === n || a.has(i) || (a.add(i), console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)), !1));
|
|
1548
1548
|
}
|
|
1549
|
-
function
|
|
1549
|
+
function rr(e) {
|
|
1550
1550
|
let t = e.spec?.key;
|
|
1551
1551
|
return typeof t == "string" ? t : void 0;
|
|
1552
1552
|
}
|
|
1553
|
-
function
|
|
1553
|
+
function ir(e) {
|
|
1554
1554
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
1555
1555
|
for (let r of e.find()) {
|
|
1556
|
-
let e =
|
|
1556
|
+
let e = rr(r);
|
|
1557
1557
|
if (!e) continue;
|
|
1558
1558
|
let i = r.spec.extensionName ?? "unknown", a = t.get(e) ?? /* @__PURE__ */ new Set();
|
|
1559
1559
|
a.add(i), t.set(e, a), n.set(e, (n.get(e) ?? 0) + 1);
|
|
@@ -1563,18 +1563,18 @@ function tr(e) {
|
|
|
1563
1563
|
extensions: t
|
|
1564
1564
|
})).filter(({ key: e }) => (n.get(e) ?? 0) > 1);
|
|
1565
1565
|
}
|
|
1566
|
-
function
|
|
1566
|
+
function ar(e) {
|
|
1567
1567
|
return e.jsonID === "attr";
|
|
1568
1568
|
}
|
|
1569
|
-
function
|
|
1569
|
+
function or(e) {
|
|
1570
1570
|
let t = !1;
|
|
1571
1571
|
if (e.getMap().forEach(() => {
|
|
1572
1572
|
t = !0;
|
|
1573
|
-
}), t ||
|
|
1573
|
+
}), t || ar(e)) return !0;
|
|
1574
1574
|
let n = e;
|
|
1575
1575
|
return typeof n.from == "number" && typeof n.to == "number";
|
|
1576
1576
|
}
|
|
1577
|
-
function
|
|
1577
|
+
function sr(e, t) {
|
|
1578
1578
|
let n = null, r = 0, i = 0;
|
|
1579
1579
|
for (let a = 0; a < e.childCount && !(i > t.to); a += 1) {
|
|
1580
1580
|
let o = i + e.child(a).nodeSize;
|
|
@@ -1585,11 +1585,11 @@ function ir(e, t) {
|
|
|
1585
1585
|
to: r
|
|
1586
1586
|
};
|
|
1587
1587
|
}
|
|
1588
|
-
function
|
|
1589
|
-
if (e.steps.some((e) => !
|
|
1590
|
-
let n =
|
|
1588
|
+
function cr(e, t) {
|
|
1589
|
+
if (e.steps.some((e) => !or(e))) return { type: "full" };
|
|
1590
|
+
let n = nn(e).map(({ newRange: e }) => e);
|
|
1591
1591
|
e.steps.forEach((t, r) => {
|
|
1592
|
-
if (!
|
|
1592
|
+
if (!ar(t)) return;
|
|
1593
1593
|
let i = e.mapping.slice(r);
|
|
1594
1594
|
n.push({
|
|
1595
1595
|
from: i.map(t.pos, -1),
|
|
@@ -1598,7 +1598,7 @@ function ar(e, t) {
|
|
|
1598
1598
|
});
|
|
1599
1599
|
let r = [];
|
|
1600
1600
|
for (let e of n) {
|
|
1601
|
-
let n =
|
|
1601
|
+
let n = sr(t, e);
|
|
1602
1602
|
n && r.push(n);
|
|
1603
1603
|
}
|
|
1604
1604
|
r.sort((e, t) => e.from - t.from);
|
|
@@ -1612,29 +1612,29 @@ function ar(e, t) {
|
|
|
1612
1612
|
ranges: i
|
|
1613
1613
|
};
|
|
1614
1614
|
}
|
|
1615
|
-
function
|
|
1615
|
+
function lr(e, t, n, r) {
|
|
1616
1616
|
return e.map(t, n, { onRemove: (e) => {
|
|
1617
1617
|
let t = e?.key;
|
|
1618
1618
|
typeof t == "string" && r.delete(t);
|
|
1619
1619
|
} });
|
|
1620
1620
|
}
|
|
1621
|
-
function
|
|
1622
|
-
let r = t.decorationSetsByExtension[e] ??
|
|
1621
|
+
function ur(e, t, n) {
|
|
1622
|
+
let r = t.decorationSetsByExtension[e] ?? w.empty, i = new Set(t.widgetKeysByExtension[e] ?? []);
|
|
1623
1623
|
return {
|
|
1624
|
-
set:
|
|
1624
|
+
set: lr(r, n.mapping, n.doc, i),
|
|
1625
1625
|
widgetKeys: i
|
|
1626
1626
|
};
|
|
1627
1627
|
}
|
|
1628
|
-
function
|
|
1628
|
+
function dr(e, t) {
|
|
1629
1629
|
let n = Object.values(t).flatMap((e) => e.find());
|
|
1630
|
-
return
|
|
1630
|
+
return w.create(e, n);
|
|
1631
1631
|
}
|
|
1632
|
-
function
|
|
1632
|
+
function fr(e) {
|
|
1633
1633
|
let t = /* @__PURE__ */ new Set();
|
|
1634
1634
|
for (let n of Object.values(e)) for (let e of n) t.add(e);
|
|
1635
1635
|
return t;
|
|
1636
1636
|
}
|
|
1637
|
-
function
|
|
1637
|
+
function pr(e, t) {
|
|
1638
1638
|
switch (t.update ?? "document") {
|
|
1639
1639
|
case "document":
|
|
1640
1640
|
if (t.createInRange) throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);
|
|
@@ -1649,21 +1649,21 @@ function ur(e, t) {
|
|
|
1649
1649
|
default: throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`);
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
|
-
function
|
|
1652
|
+
function mr(e, t, n) {
|
|
1653
1653
|
return n ? !0 : e.update === "manual" ? !1 : e.shouldUpdate ? e.shouldUpdate(t) : t.tr.docChanged;
|
|
1654
1654
|
}
|
|
1655
|
-
var
|
|
1655
|
+
var hr = /* @__PURE__ */ new Set(), gr = class {
|
|
1656
1656
|
constructor(e) {
|
|
1657
1657
|
this.warnedWidgetKeys = /* @__PURE__ */ new Set(), this.warnedOutOfRangeExtensions = /* @__PURE__ */ new Set(), this.handleBeforeTransaction = ({ nextState: e }) => {
|
|
1658
|
-
let t =
|
|
1658
|
+
let t = J.getState(e);
|
|
1659
1659
|
t && this.warnDuplicateWidgetKeys(t);
|
|
1660
|
-
}, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) =>
|
|
1660
|
+
}, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) => pr(e, t)), this.plugin = this.entries.length > 0 ? this.createPlugin() : null, this.editor.on("beforeTransaction", this.handleBeforeTransaction);
|
|
1661
1661
|
}
|
|
1662
1662
|
destroy() {
|
|
1663
1663
|
this.editor.off("beforeTransaction", this.handleBeforeTransaction);
|
|
1664
1664
|
}
|
|
1665
1665
|
liveWidgetKeys() {
|
|
1666
|
-
return
|
|
1666
|
+
return J.getState(this.editor.state)?.widgetKeys ?? hr;
|
|
1667
1667
|
}
|
|
1668
1668
|
get mountedView() {
|
|
1669
1669
|
return this.editor.isDestroyed ? null : this.editor.view;
|
|
@@ -1681,8 +1681,8 @@ var fr = /* @__PURE__ */ new Set(), pr = class {
|
|
|
1681
1681
|
}
|
|
1682
1682
|
createPlugin() {
|
|
1683
1683
|
let { editor: e, entries: t } = this;
|
|
1684
|
-
return new
|
|
1685
|
-
key:
|
|
1684
|
+
return new v({
|
|
1685
|
+
key: J,
|
|
1686
1686
|
state: {
|
|
1687
1687
|
init: (e, n) => {
|
|
1688
1688
|
let r = {}, i = {};
|
|
@@ -1694,22 +1694,22 @@ var fr = /* @__PURE__ */ new Set(), pr = class {
|
|
|
1694
1694
|
decorationSetsByExtension: r,
|
|
1695
1695
|
widgetKeysByExtension: i,
|
|
1696
1696
|
mergedDecorationSet: this.buildMergedSet(n.doc, r),
|
|
1697
|
-
widgetKeys:
|
|
1697
|
+
widgetKeys: fr(i)
|
|
1698
1698
|
};
|
|
1699
1699
|
return this.warnDuplicateWidgetKeys(a), a;
|
|
1700
1700
|
},
|
|
1701
1701
|
apply: (n, r, i, a) => {
|
|
1702
|
-
let o = n.getMeta(
|
|
1703
|
-
return
|
|
1702
|
+
let o = n.getMeta(J), s = o?.type === "force" && !o.name, c = o?.type === "force" ? o.name : void 0, l = {}, u = {}, d = /* @__PURE__ */ new Set();
|
|
1703
|
+
return Jn(e, () => {
|
|
1704
1704
|
for (let { name: o, spec: f } of t) {
|
|
1705
1705
|
let t = s || c === o;
|
|
1706
|
-
if (!
|
|
1706
|
+
if (!mr(f, {
|
|
1707
1707
|
editor: e,
|
|
1708
1708
|
tr: n,
|
|
1709
1709
|
oldState: i,
|
|
1710
1710
|
newState: a
|
|
1711
1711
|
}, t)) {
|
|
1712
|
-
let e =
|
|
1712
|
+
let e = ur(o, r, n);
|
|
1713
1713
|
l[o] = e.set, u[o] = e.widgetKeys;
|
|
1714
1714
|
} else if (f.update === "changedRanges" && n.docChanged && !t) {
|
|
1715
1715
|
let e = this.applyChangedRangesRecompute(o, f, r, n, a);
|
|
@@ -1729,34 +1729,34 @@ var fr = /* @__PURE__ */ new Set(), pr = class {
|
|
|
1729
1729
|
decorationSetsByExtension: l,
|
|
1730
1730
|
recomputedNames: d
|
|
1731
1731
|
}),
|
|
1732
|
-
widgetKeys:
|
|
1732
|
+
widgetKeys: fr(u)
|
|
1733
1733
|
};
|
|
1734
1734
|
}
|
|
1735
1735
|
},
|
|
1736
1736
|
props: { decorations(e) {
|
|
1737
|
-
return
|
|
1737
|
+
return J.getState(e)?.mergedDecorationSet ?? w.empty;
|
|
1738
1738
|
} }
|
|
1739
1739
|
});
|
|
1740
1740
|
}
|
|
1741
1741
|
applyChangedRangesRecompute(e, t, n, r, i) {
|
|
1742
|
-
let a =
|
|
1742
|
+
let a = cr(r, i.doc);
|
|
1743
1743
|
return a.type === "full" ? this.buildFullSet(e, t, i) : this.rebuildRanges(e, t, n, r, i, a.ranges);
|
|
1744
1744
|
}
|
|
1745
1745
|
rebuildRanges(e, t, n, r, i, a) {
|
|
1746
|
-
let o = n.decorationSetsByExtension[e] ??
|
|
1746
|
+
let o = n.decorationSetsByExtension[e] ?? w.empty, s = new Set(n.widgetKeysByExtension[e] ?? []), c = lr(o, r.mapping, r.doc, s), l = i.doc.content.size;
|
|
1747
1747
|
for (let { from: n, to: r } of a) {
|
|
1748
|
-
let a = c.find(n, r).filter((e) =>
|
|
1748
|
+
let a = c.find(n, r).filter((e) => tr({
|
|
1749
1749
|
position: e.from,
|
|
1750
1750
|
from: n,
|
|
1751
1751
|
to: r,
|
|
1752
1752
|
docSize: l
|
|
1753
1753
|
}));
|
|
1754
1754
|
for (let e of a) {
|
|
1755
|
-
let t =
|
|
1755
|
+
let t = rr(e);
|
|
1756
1756
|
t && s.delete(t);
|
|
1757
1757
|
}
|
|
1758
1758
|
c = c.remove(a);
|
|
1759
|
-
let { decorations: o, widgetKeys: u } =
|
|
1759
|
+
let { decorations: o, widgetKeys: u } = $n(nr({
|
|
1760
1760
|
decorations: this.runCreate(e, "createInRange", () => t.createInRange({
|
|
1761
1761
|
editor: this.editor,
|
|
1762
1762
|
state: i,
|
|
@@ -1784,7 +1784,7 @@ var fr = /* @__PURE__ */ new Set(), pr = class {
|
|
|
1784
1784
|
state: n,
|
|
1785
1785
|
view: this.mountedView
|
|
1786
1786
|
}));
|
|
1787
|
-
return
|
|
1787
|
+
return er(n.doc, r, e);
|
|
1788
1788
|
}
|
|
1789
1789
|
runCreate(e, t, n) {
|
|
1790
1790
|
try {
|
|
@@ -1794,12 +1794,12 @@ var fr = /* @__PURE__ */ new Set(), pr = class {
|
|
|
1794
1794
|
}
|
|
1795
1795
|
}
|
|
1796
1796
|
warnDuplicateWidgetKeys(e) {
|
|
1797
|
-
if (!
|
|
1797
|
+
if (!Zn) return;
|
|
1798
1798
|
if (e.widgetKeys.size === 0) {
|
|
1799
1799
|
this.warnedWidgetKeys.clear();
|
|
1800
1800
|
return;
|
|
1801
1801
|
}
|
|
1802
|
-
let t =
|
|
1802
|
+
let t = ir(e.mergedDecorationSet), n = new Set(t.map(({ key: e }) => e));
|
|
1803
1803
|
for (let { key: e, extensions: n } of t) {
|
|
1804
1804
|
if (this.warnedWidgetKeys.has(e)) continue;
|
|
1805
1805
|
let t = Array.from(n).map((e) => `"${e}"`).join(", ");
|
|
@@ -1809,15 +1809,15 @@ var fr = /* @__PURE__ */ new Set(), pr = class {
|
|
|
1809
1809
|
}
|
|
1810
1810
|
buildMergedSet(e, t) {
|
|
1811
1811
|
let n = Object.keys(t);
|
|
1812
|
-
return n.length === 1 ? t[n[0]] :
|
|
1812
|
+
return n.length === 1 ? t[n[0]] : dr(e, t);
|
|
1813
1813
|
}
|
|
1814
1814
|
mergeAfterApply({ entries: e, previous: t, tr: n, decorationSetsByExtension: r, recomputedNames: i }) {
|
|
1815
|
-
return e.length === 1 ? r[e[0].name] : i.size === 0 ? t.mergedDecorationSet.map(n.mapping, n.doc) :
|
|
1815
|
+
return e.length === 1 ? r[e[0].name] : i.size === 0 ? t.mergedDecorationSet.map(n.mapping, n.doc) : dr(n.doc, r);
|
|
1816
1816
|
}
|
|
1817
1817
|
};
|
|
1818
|
-
function
|
|
1818
|
+
function _r(e, t) {
|
|
1819
1819
|
let { selection: n } = e, { $from: r } = n;
|
|
1820
|
-
if (n instanceof
|
|
1820
|
+
if (n instanceof _) {
|
|
1821
1821
|
let e = r.index();
|
|
1822
1822
|
return r.parent.canReplaceWith(e, e + 1, t);
|
|
1823
1823
|
}
|
|
@@ -1829,22 +1829,22 @@ function mr(e, t) {
|
|
|
1829
1829
|
}
|
|
1830
1830
|
return !1;
|
|
1831
1831
|
}
|
|
1832
|
-
function
|
|
1832
|
+
function vr(e, t, n) {
|
|
1833
1833
|
let r = document.querySelector(`style[data-tiptap-style${n ? `-${n}` : ""}]`);
|
|
1834
1834
|
if (r !== null) return r;
|
|
1835
1835
|
let i = document.createElement("style");
|
|
1836
1836
|
return t && i.setAttribute("nonce", t), i.setAttribute(`data-tiptap-style${n ? `-${n}` : ""}`, ""), i.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(i), i;
|
|
1837
1837
|
}
|
|
1838
|
-
function
|
|
1838
|
+
function yr(e) {
|
|
1839
1839
|
return typeof e == "number";
|
|
1840
1840
|
}
|
|
1841
|
-
function
|
|
1841
|
+
function br(e) {
|
|
1842
1842
|
return Object.prototype.toString.call(e).slice(8, -1);
|
|
1843
1843
|
}
|
|
1844
|
-
function
|
|
1845
|
-
return
|
|
1844
|
+
function X(e) {
|
|
1845
|
+
return br(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
|
|
1846
1846
|
}
|
|
1847
|
-
function
|
|
1847
|
+
function xr(e, t, n) {
|
|
1848
1848
|
let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2;
|
|
1849
1849
|
for (; o < r.length;) {
|
|
1850
1850
|
let e = r[o], u = e.match(t.itemPattern);
|
|
@@ -1888,13 +1888,13 @@ function vr(e, t, n) {
|
|
|
1888
1888
|
raw: a
|
|
1889
1889
|
};
|
|
1890
1890
|
}
|
|
1891
|
-
var
|
|
1892
|
-
function
|
|
1891
|
+
var Sr = 4;
|
|
1892
|
+
function Cr(e) {
|
|
1893
1893
|
let t = 0;
|
|
1894
|
-
for (let n of e) t = n === " " ? t +
|
|
1894
|
+
for (let n of e) t = n === " " ? t + Sr - t % Sr : t + 1;
|
|
1895
1895
|
return t;
|
|
1896
1896
|
}
|
|
1897
|
-
function
|
|
1897
|
+
function wr(e, t, n, r, i) {
|
|
1898
1898
|
if (!e || !Array.isArray(e.content)) return "";
|
|
1899
1899
|
let a = typeof n == "function" ? n(r) : n, [o, ...s] = e.content, c = `${a}${t.renderChildren([o])}`;
|
|
1900
1900
|
return s && s.length > 0 && s.forEach((e, n) => {
|
|
@@ -1902,20 +1902,20 @@ function xr(e, t, n, r, i) {
|
|
|
1902
1902
|
if (r != null) {
|
|
1903
1903
|
let n = (e) => {
|
|
1904
1904
|
if (!i?.alignNestedToPrefix) return t.indent(e);
|
|
1905
|
-
let n = t.indent(""), r =
|
|
1906
|
-
return (
|
|
1905
|
+
let n = t.indent(""), r = Cr(a);
|
|
1906
|
+
return (Cr(n) >= r ? n : " ".repeat(r)) + e;
|
|
1907
1907
|
}, o = r.split("\n").map((e) => n(e || "")).join("\n");
|
|
1908
1908
|
c += e.type === "paragraph" ? `\n\n${o}` : `\n${o}`;
|
|
1909
1909
|
}
|
|
1910
1910
|
}), c;
|
|
1911
1911
|
}
|
|
1912
|
-
function
|
|
1912
|
+
function Tr(e, t) {
|
|
1913
1913
|
let n = { ...e };
|
|
1914
|
-
return
|
|
1915
|
-
|
|
1914
|
+
return X(e) && X(t) && Object.keys(t).forEach((r) => {
|
|
1915
|
+
X(t[r]) && X(e[r]) ? n[r] = Tr(e[r], t[r]) : n[r] = t[r];
|
|
1916
1916
|
}), n;
|
|
1917
1917
|
}
|
|
1918
|
-
function
|
|
1918
|
+
function Er(e, t, n = {}) {
|
|
1919
1919
|
let { state: r } = t, { doc: i, tr: a } = r, o = e;
|
|
1920
1920
|
i.descendants((t, r) => {
|
|
1921
1921
|
let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null;
|
|
@@ -1935,59 +1935,93 @@ function Cr(e, t, n = {}) {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
}), a.docChanged && t.view.dispatch(a);
|
|
1937
1937
|
}
|
|
1938
|
-
var
|
|
1938
|
+
var Z = class {
|
|
1939
1939
|
constructor(e) {
|
|
1940
1940
|
this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0;
|
|
1941
1941
|
}
|
|
1942
|
-
},
|
|
1943
|
-
if (
|
|
1942
|
+
}, Dr = (e, t) => {
|
|
1943
|
+
if (O(t)) return t.exec(e);
|
|
1944
1944
|
let n = t(e);
|
|
1945
1945
|
if (!n) return null;
|
|
1946
1946
|
let r = [n.text];
|
|
1947
1947
|
return r.index = n.index, r.input = e, r.data = n.data, n.replaceWith && (n.text.includes(n.replaceWith) || console.warn("[tiptap warn]: \"inputRuleMatch.replaceWith\" must be part of \"inputRuleMatch.text\"."), r.push(n.replaceWith)), r;
|
|
1948
1948
|
};
|
|
1949
|
-
function
|
|
1950
|
-
let { editor: t, from: n, to: r, text: i,
|
|
1951
|
-
if (
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1949
|
+
function Or(e) {
|
|
1950
|
+
let { editor: t, from: n, to: r, text: i, insertText: a } = e;
|
|
1951
|
+
if (!a) return {
|
|
1952
|
+
inputTransaction: null,
|
|
1953
|
+
tr: t.view.state.tr
|
|
1954
|
+
};
|
|
1955
|
+
let o = t.view.state.tr.insertText(i, n, r);
|
|
1956
|
+
return {
|
|
1957
|
+
inputTransaction: o,
|
|
1958
|
+
tr: g.create({
|
|
1959
|
+
doc: o.doc,
|
|
1960
|
+
selection: o.selection,
|
|
1961
|
+
storedMarks: o.storedMarks
|
|
1962
|
+
}).tr
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
function kr(e) {
|
|
1966
|
+
let { editor: t, from: n, to: r, text: i, rule: a, match: o, plugin: s, insertText: c } = e, { view: l } = t, { inputTransaction: u, tr: d } = Or({
|
|
1967
|
+
editor: t,
|
|
1968
|
+
from: n,
|
|
1969
|
+
to: r,
|
|
1970
|
+
text: i,
|
|
1971
|
+
insertText: c
|
|
1972
|
+
}), f = u ? n + i.length : r, p = T({
|
|
1973
|
+
state: l.state,
|
|
1974
|
+
transaction: d
|
|
1975
|
+
}), m = {
|
|
1976
|
+
from: n - (o[0].length - i.length),
|
|
1977
|
+
to: f
|
|
1978
|
+
}, { commands: h, chain: g, can: _ } = new E({
|
|
1979
|
+
editor: t,
|
|
1980
|
+
state: p
|
|
1981
|
+
});
|
|
1982
|
+
return a.handler({
|
|
1983
|
+
state: p,
|
|
1984
|
+
range: m,
|
|
1985
|
+
match: o,
|
|
1986
|
+
commands: h,
|
|
1987
|
+
chain: g,
|
|
1988
|
+
can: _
|
|
1989
|
+
}) === null || !d.steps.length ? !1 : (u && (l.dispatch(u), !l.state.doc.eq(u.doc)) || (Se(d), d.setMeta("inputRule", !0), a.undoable && d.setMeta(s, {
|
|
1990
|
+
transform: d,
|
|
1991
|
+
from: n,
|
|
1992
|
+
to: f,
|
|
1993
|
+
text: i
|
|
1994
|
+
}), l.dispatch(d)), !0);
|
|
1995
|
+
}
|
|
1996
|
+
function Ar(e, t, n) {
|
|
1997
|
+
let r = t[0].length - n.length;
|
|
1998
|
+
if (r <= 0) return !0;
|
|
1999
|
+
let i = e.parentOffset - r;
|
|
2000
|
+
return i >= 0 && e.parent.textBetween(i, e.parentOffset) === t[0].slice(0, r);
|
|
2001
|
+
}
|
|
2002
|
+
function jr(e) {
|
|
2003
|
+
let { editor: t, from: n, to: r, text: i, rules: a, plugin: o, insertText: s } = e, { view: c } = t;
|
|
2004
|
+
if (c.composing) return !1;
|
|
2005
|
+
let l = c.state.doc.resolve(n);
|
|
2006
|
+
if (l.parent.type.spec.code || (l.nodeBefore || l.nodeAfter)?.marks.find((e) => e.type.spec.code)) return !1;
|
|
2007
|
+
let u = sn(l) + i;
|
|
2008
|
+
for (let e of a) {
|
|
2009
|
+
let a = Dr(u, e.find);
|
|
2010
|
+
if (a && Ar(l, a, i) && kr({
|
|
1971
2011
|
editor: t,
|
|
1972
|
-
state: p
|
|
1973
|
-
});
|
|
1974
|
-
e.handler({
|
|
1975
|
-
state: p,
|
|
1976
|
-
range: m,
|
|
1977
|
-
match: a,
|
|
1978
|
-
commands: h,
|
|
1979
|
-
chain: g,
|
|
1980
|
-
can: _
|
|
1981
|
-
}) === null || !f.steps.length || (e.undoable && f.setMeta(o, {
|
|
1982
|
-
transform: f,
|
|
1983
2012
|
from: n,
|
|
1984
2013
|
to: r,
|
|
1985
|
-
text: i
|
|
1986
|
-
|
|
1987
|
-
|
|
2014
|
+
text: i,
|
|
2015
|
+
rule: e,
|
|
2016
|
+
match: a,
|
|
2017
|
+
plugin: o,
|
|
2018
|
+
insertText: s
|
|
2019
|
+
})) return !0;
|
|
2020
|
+
}
|
|
2021
|
+
return !1;
|
|
1988
2022
|
}
|
|
1989
|
-
function
|
|
1990
|
-
let { editor: t, rules:
|
|
2023
|
+
function Mr(e) {
|
|
2024
|
+
let { editor: t, rules: r } = e, i = new v({
|
|
1991
2025
|
state: {
|
|
1992
2026
|
init() {
|
|
1993
2027
|
return null;
|
|
@@ -1998,50 +2032,51 @@ function Er(e) {
|
|
|
1998
2032
|
let c = e.getMeta("applyInputRules");
|
|
1999
2033
|
return c && setTimeout(() => {
|
|
2000
2034
|
let { text: e } = c;
|
|
2001
|
-
e = typeof e == "string" ? e :
|
|
2035
|
+
e = typeof e == "string" ? e : B(n.from(e), o.schema);
|
|
2002
2036
|
let { from: a } = c, s = a + e.length;
|
|
2003
|
-
|
|
2037
|
+
jr({
|
|
2004
2038
|
editor: t,
|
|
2005
2039
|
from: a,
|
|
2006
2040
|
to: s,
|
|
2007
2041
|
text: e,
|
|
2008
|
-
rules:
|
|
2042
|
+
rules: r,
|
|
2009
2043
|
plugin: i
|
|
2010
2044
|
});
|
|
2011
2045
|
}), e.selectionSet || e.docChanged ? null : a;
|
|
2012
2046
|
}
|
|
2013
2047
|
},
|
|
2014
2048
|
props: {
|
|
2015
|
-
handleTextInput(e,
|
|
2016
|
-
return
|
|
2049
|
+
handleTextInput(e, n, a, o) {
|
|
2050
|
+
return jr({
|
|
2017
2051
|
editor: t,
|
|
2018
|
-
from:
|
|
2052
|
+
from: n,
|
|
2019
2053
|
to: a,
|
|
2020
2054
|
text: o,
|
|
2021
|
-
rules:
|
|
2022
|
-
plugin: i
|
|
2055
|
+
rules: r,
|
|
2056
|
+
plugin: i,
|
|
2057
|
+
insertText: !0
|
|
2023
2058
|
});
|
|
2024
2059
|
},
|
|
2025
2060
|
handleDOMEvents: { compositionend: (e) => (setTimeout(() => {
|
|
2026
|
-
let { $cursor:
|
|
2027
|
-
|
|
2061
|
+
let { $cursor: n } = e.state.selection;
|
|
2062
|
+
n && jr({
|
|
2028
2063
|
editor: t,
|
|
2029
|
-
from:
|
|
2030
|
-
to:
|
|
2064
|
+
from: n.pos,
|
|
2065
|
+
to: n.pos,
|
|
2031
2066
|
text: "",
|
|
2032
|
-
rules:
|
|
2067
|
+
rules: r,
|
|
2033
2068
|
plugin: i
|
|
2034
2069
|
});
|
|
2035
2070
|
}), !1) },
|
|
2036
|
-
handleKeyDown(e,
|
|
2037
|
-
if (
|
|
2071
|
+
handleKeyDown(e, n) {
|
|
2072
|
+
if (n.key !== "Enter") return !1;
|
|
2038
2073
|
let { $cursor: a } = e.state.selection;
|
|
2039
|
-
return a ?
|
|
2074
|
+
return a ? jr({
|
|
2040
2075
|
editor: t,
|
|
2041
2076
|
from: a.pos,
|
|
2042
2077
|
to: a.pos,
|
|
2043
2078
|
text: "\n",
|
|
2044
|
-
rules:
|
|
2079
|
+
rules: r,
|
|
2045
2080
|
plugin: i
|
|
2046
2081
|
}) : !1;
|
|
2047
2082
|
}
|
|
@@ -2050,7 +2085,7 @@ function Er(e) {
|
|
|
2050
2085
|
});
|
|
2051
2086
|
return i;
|
|
2052
2087
|
}
|
|
2053
|
-
var
|
|
2088
|
+
var Nr = class {
|
|
2054
2089
|
constructor(e = {}) {
|
|
2055
2090
|
this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = {
|
|
2056
2091
|
...this.config,
|
|
@@ -2058,10 +2093,10 @@ var Dr = class {
|
|
|
2058
2093
|
}, this.name = this.config.name;
|
|
2059
2094
|
}
|
|
2060
2095
|
get options() {
|
|
2061
|
-
return { ...
|
|
2096
|
+
return { ...H(R(this, "addOptions", { name: this.name })) };
|
|
2062
2097
|
}
|
|
2063
2098
|
get storage() {
|
|
2064
|
-
return { ...
|
|
2099
|
+
return { ...H(R(this, "addStorage", {
|
|
2065
2100
|
name: this.name,
|
|
2066
2101
|
options: this.options
|
|
2067
2102
|
})) };
|
|
@@ -2069,7 +2104,7 @@ var Dr = class {
|
|
|
2069
2104
|
configure(e = {}) {
|
|
2070
2105
|
let t = this.extend({
|
|
2071
2106
|
...this.config,
|
|
2072
|
-
addOptions: () =>
|
|
2107
|
+
addOptions: () => Tr(this.options, e)
|
|
2073
2108
|
});
|
|
2074
2109
|
return t.name = this.name, t.parent = this.parent, this.child = null, t;
|
|
2075
2110
|
}
|
|
@@ -2080,7 +2115,7 @@ var Dr = class {
|
|
|
2080
2115
|
});
|
|
2081
2116
|
return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
|
|
2082
2117
|
}
|
|
2083
|
-
},
|
|
2118
|
+
}, Pr = class e extends Nr {
|
|
2084
2119
|
constructor(...e) {
|
|
2085
2120
|
super(...e), this.type = "mark";
|
|
2086
2121
|
}
|
|
@@ -2105,20 +2140,20 @@ var Dr = class {
|
|
|
2105
2140
|
let t = typeof e == "function" ? e() : e;
|
|
2106
2141
|
return super.extend(t);
|
|
2107
2142
|
}
|
|
2108
|
-
},
|
|
2143
|
+
}, Fr = class {
|
|
2109
2144
|
constructor(e) {
|
|
2110
2145
|
this.find = e.find, this.handler = e.handler;
|
|
2111
2146
|
}
|
|
2112
|
-
},
|
|
2113
|
-
if (
|
|
2147
|
+
}, Ir = (e, t, n) => {
|
|
2148
|
+
if (O(t)) return [...e.matchAll(t)];
|
|
2114
2149
|
let r = t(e, n);
|
|
2115
2150
|
return r ? r.map((t) => {
|
|
2116
2151
|
let n = [t.text];
|
|
2117
2152
|
return n.index = t.index, n.input = e, n.data = t.data, t.replaceWith && (t.text.includes(t.replaceWith) || console.warn("[tiptap warn]: \"pasteRuleMatch.replaceWith\" must be part of \"pasteRuleMatch.text\"."), n.push(t.replaceWith)), n;
|
|
2118
2153
|
}) : [];
|
|
2119
2154
|
};
|
|
2120
|
-
function
|
|
2121
|
-
let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new
|
|
2155
|
+
function Lr(e) {
|
|
2156
|
+
let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new E({
|
|
2122
2157
|
editor: t,
|
|
2123
2158
|
state: n
|
|
2124
2159
|
}), d = [];
|
|
@@ -2126,7 +2161,7 @@ function jr(e) {
|
|
|
2126
2161
|
var f;
|
|
2127
2162
|
if ((f = e.type) != null && (f = f.spec) != null && f.code || !(e.isText || e.isTextblock || e.isInline)) return;
|
|
2128
2163
|
let p = e.content?.size ?? e.nodeSize ?? 0, m = Math.max(r, t), h = Math.min(i, t + p);
|
|
2129
|
-
m >= h ||
|
|
2164
|
+
m >= h || Ir(e.isText ? e.text || "" : e.textBetween(m - t, h - t, void 0, ""), a.find, o).forEach((e) => {
|
|
2130
2165
|
if (e.index === void 0) return;
|
|
2131
2166
|
let t = m + e.index + 1, r = t + e[0].length, i = {
|
|
2132
2167
|
from: n.tr.mapping.map(t),
|
|
@@ -2145,24 +2180,24 @@ function jr(e) {
|
|
|
2145
2180
|
});
|
|
2146
2181
|
}), d.every((e) => e !== null);
|
|
2147
2182
|
}
|
|
2148
|
-
var
|
|
2183
|
+
var Q = null, Rr = (e) => {
|
|
2149
2184
|
var t;
|
|
2150
2185
|
let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
|
|
2151
2186
|
return (t = n.clipboardData) == null || t.setData("text/html", e), n;
|
|
2152
2187
|
};
|
|
2153
|
-
function
|
|
2154
|
-
let { editor: t, rules:
|
|
2188
|
+
function zr(e) {
|
|
2189
|
+
let { editor: t, rules: r } = e, i = null, a = !1, o = !1, s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
2155
2190
|
try {
|
|
2156
2191
|
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
2157
2192
|
} catch {
|
|
2158
2193
|
c = null;
|
|
2159
2194
|
}
|
|
2160
2195
|
let l = ({ state: e, from: n, to: r, rule: i, pasteEvt: a }) => {
|
|
2161
|
-
let o = e.tr, l =
|
|
2196
|
+
let o = e.tr, l = T({
|
|
2162
2197
|
state: e,
|
|
2163
2198
|
transaction: o
|
|
2164
2199
|
});
|
|
2165
|
-
if (
|
|
2200
|
+
if (Lr({
|
|
2166
2201
|
editor: t,
|
|
2167
2202
|
state: l,
|
|
2168
2203
|
from: Math.max(n - 1, 0),
|
|
@@ -2170,7 +2205,7 @@ function Pr(e) {
|
|
|
2170
2205
|
rule: i,
|
|
2171
2206
|
pasteEvent: a,
|
|
2172
2207
|
dropEvent: c
|
|
2173
|
-
})
|
|
2208
|
+
}) && o.steps.length) {
|
|
2174
2209
|
try {
|
|
2175
2210
|
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
2176
2211
|
} catch {
|
|
@@ -2179,12 +2214,14 @@ function Pr(e) {
|
|
|
2179
2214
|
return s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, o;
|
|
2180
2215
|
}
|
|
2181
2216
|
};
|
|
2182
|
-
return
|
|
2217
|
+
return t.on("destroy", () => {
|
|
2218
|
+
Q === t && (Q = null);
|
|
2219
|
+
}), r.map((e) => new v({
|
|
2183
2220
|
view(e) {
|
|
2184
2221
|
let n = (n) => {
|
|
2185
|
-
i = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, i && (
|
|
2222
|
+
i = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, i && (Q = t);
|
|
2186
2223
|
}, r = () => {
|
|
2187
|
-
|
|
2224
|
+
Q &&= null;
|
|
2188
2225
|
};
|
|
2189
2226
|
return window.addEventListener("dragstart", n), window.addEventListener("dragend", r), { destroy() {
|
|
2190
2227
|
window.removeEventListener("dragstart", n), window.removeEventListener("dragend", r);
|
|
@@ -2193,8 +2230,9 @@ function Pr(e) {
|
|
|
2193
2230
|
props: { handleDOMEvents: {
|
|
2194
2231
|
drop: (e, t) => {
|
|
2195
2232
|
if (o = i === e.dom.parentElement, c = t, !o) {
|
|
2196
|
-
let e =
|
|
2233
|
+
let e = Q;
|
|
2197
2234
|
e?.isEditable && setTimeout(() => {
|
|
2235
|
+
if (e.isDestroyed) return;
|
|
2198
2236
|
let t = e.state.selection;
|
|
2199
2237
|
t && e.commands.deleteRange({
|
|
2200
2238
|
from: t.from,
|
|
@@ -2209,23 +2247,23 @@ function Pr(e) {
|
|
|
2209
2247
|
return s = t, a = !!n?.includes("data-pm-slice"), !1;
|
|
2210
2248
|
}
|
|
2211
2249
|
} },
|
|
2212
|
-
appendTransaction: (t,
|
|
2250
|
+
appendTransaction: (t, r, i) => {
|
|
2213
2251
|
let c = t[0], u = c.getMeta("uiEvent") === "paste" && !a, d = c.getMeta("uiEvent") === "drop" && !o, f = c.getMeta("applyPasteRules"), p = !!f;
|
|
2214
2252
|
if (!u && !d && !p) return;
|
|
2215
2253
|
if (p) {
|
|
2216
2254
|
let { text: t } = f;
|
|
2217
|
-
t = typeof t == "string" ? t :
|
|
2218
|
-
let { from:
|
|
2255
|
+
t = typeof t == "string" ? t : B(n.from(t), i.schema);
|
|
2256
|
+
let { from: r } = f, a = r + t.length, o = Rr(t);
|
|
2219
2257
|
return l({
|
|
2220
2258
|
rule: e,
|
|
2221
2259
|
state: i,
|
|
2222
|
-
from:
|
|
2260
|
+
from: r,
|
|
2223
2261
|
to: { b: a },
|
|
2224
2262
|
pasteEvt: o
|
|
2225
2263
|
});
|
|
2226
2264
|
}
|
|
2227
|
-
let m =
|
|
2228
|
-
if (
|
|
2265
|
+
let m = r.doc.content.findDiffStart(i.doc.content), h = r.doc.content.findDiffEnd(i.doc.content);
|
|
2266
|
+
if (yr(m) && h && m !== h.b) return l({
|
|
2229
2267
|
rule: e,
|
|
2230
2268
|
state: i,
|
|
2231
2269
|
from: m,
|
|
@@ -2235,18 +2273,18 @@ function Pr(e) {
|
|
|
2235
2273
|
}
|
|
2236
2274
|
}));
|
|
2237
2275
|
}
|
|
2238
|
-
var
|
|
2276
|
+
var Br = class {
|
|
2239
2277
|
constructor(e, t) {
|
|
2240
|
-
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions =
|
|
2278
|
+
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions = Gt(e), this.schema = Ut(this.extensions, t), this.setupExtensions();
|
|
2241
2279
|
}
|
|
2242
2280
|
get commands() {
|
|
2243
2281
|
return this.extensions.reduce((e, t) => {
|
|
2244
|
-
let n =
|
|
2282
|
+
let n = R(t, "addCommands", {
|
|
2245
2283
|
name: t.name,
|
|
2246
2284
|
options: t.options,
|
|
2247
2285
|
storage: this.editor.extensionStorage[t.name],
|
|
2248
2286
|
editor: this.editor,
|
|
2249
|
-
type:
|
|
2287
|
+
type: K(t.name, this.schema)
|
|
2250
2288
|
});
|
|
2251
2289
|
return n ? {
|
|
2252
2290
|
...e,
|
|
@@ -2255,15 +2293,15 @@ var Fr = class {
|
|
|
2255
2293
|
}, {});
|
|
2256
2294
|
}
|
|
2257
2295
|
get plugins() {
|
|
2258
|
-
let { editor: e } = this, t =
|
|
2296
|
+
let { editor: e } = this, t = G([...this.extensions].reverse()).flatMap((t) => {
|
|
2259
2297
|
let n = {
|
|
2260
2298
|
name: t.name,
|
|
2261
2299
|
options: t.options,
|
|
2262
2300
|
storage: this.editor.extensionStorage[t.name],
|
|
2263
2301
|
editor: e,
|
|
2264
|
-
type:
|
|
2265
|
-
}, r = [], i =
|
|
2266
|
-
if (t.type === "mark" &&
|
|
2302
|
+
type: K(t.name, this.schema)
|
|
2303
|
+
}, r = [], i = R(t, "addKeyboardShortcuts", n), a = {};
|
|
2304
|
+
if (t.type === "mark" && R(t, "exitable", n) && (a.ArrowRight = () => Pr.handleExit({
|
|
2267
2305
|
editor: e,
|
|
2268
2306
|
mark: t
|
|
2269
2307
|
})), i) {
|
|
@@ -2273,31 +2311,31 @@ var Fr = class {
|
|
|
2273
2311
|
...t
|
|
2274
2312
|
};
|
|
2275
2313
|
}
|
|
2276
|
-
let o =
|
|
2314
|
+
let o = xe(a);
|
|
2277
2315
|
r.push(o);
|
|
2278
|
-
let s =
|
|
2279
|
-
if (
|
|
2316
|
+
let s = R(t, "addInputRules", n);
|
|
2317
|
+
if (fn(t, e.options.enableInputRules) && s) {
|
|
2280
2318
|
let t = s();
|
|
2281
2319
|
if (t && t.length) {
|
|
2282
|
-
let n =
|
|
2320
|
+
let n = Mr({
|
|
2283
2321
|
editor: e,
|
|
2284
2322
|
rules: t
|
|
2285
2323
|
}), i = Array.isArray(n) ? n : [n];
|
|
2286
2324
|
r.push(...i);
|
|
2287
2325
|
}
|
|
2288
2326
|
}
|
|
2289
|
-
let c =
|
|
2290
|
-
if (
|
|
2327
|
+
let c = R(t, "addPasteRules", n);
|
|
2328
|
+
if (fn(t, e.options.enablePasteRules) && c) {
|
|
2291
2329
|
let t = c();
|
|
2292
2330
|
if (t && t.length) {
|
|
2293
|
-
let n =
|
|
2331
|
+
let n = zr({
|
|
2294
2332
|
editor: e,
|
|
2295
2333
|
rules: t
|
|
2296
2334
|
});
|
|
2297
2335
|
r.push(...n);
|
|
2298
2336
|
}
|
|
2299
2337
|
}
|
|
2300
|
-
let l =
|
|
2338
|
+
let l = R(t, "addProseMirrorPlugins", n);
|
|
2301
2339
|
if (l) {
|
|
2302
2340
|
let e = l();
|
|
2303
2341
|
r.push(...e);
|
|
@@ -2312,39 +2350,39 @@ var Fr = class {
|
|
|
2312
2350
|
(e = this.decorationManager) == null || e.destroy();
|
|
2313
2351
|
let n = [];
|
|
2314
2352
|
return this.extensions.forEach((e) => {
|
|
2315
|
-
let r =
|
|
2353
|
+
let r = R(e, "addDecorations", {
|
|
2316
2354
|
name: e.name,
|
|
2317
2355
|
options: e.options,
|
|
2318
2356
|
storage: this.editor.extensionStorage[e.name],
|
|
2319
2357
|
editor: t,
|
|
2320
|
-
type:
|
|
2358
|
+
type: K(e.name, this.schema)
|
|
2321
2359
|
});
|
|
2322
2360
|
r && n.push({
|
|
2323
2361
|
name: e.name,
|
|
2324
2362
|
addDecorations: r
|
|
2325
2363
|
});
|
|
2326
|
-
}), this.decorationManager = new
|
|
2364
|
+
}), this.decorationManager = new gr({
|
|
2327
2365
|
editor: t,
|
|
2328
2366
|
entries: n
|
|
2329
2367
|
}), this.decorationManager.plugin;
|
|
2330
2368
|
}
|
|
2331
2369
|
get attributes() {
|
|
2332
|
-
return
|
|
2370
|
+
return Ft(this.extensions);
|
|
2333
2371
|
}
|
|
2334
2372
|
get nodeViews() {
|
|
2335
|
-
let { editor: e } = this, { nodeExtensions: t } =
|
|
2336
|
-
return Object.fromEntries(t.filter((e) => !!
|
|
2337
|
-
let n = this.attributes.filter((e) => e.type === t.name), r =
|
|
2373
|
+
let { editor: e } = this, { nodeExtensions: t } = U(this.extensions);
|
|
2374
|
+
return Object.fromEntries(t.filter((e) => !!R(e, "addNodeView")).map((t) => {
|
|
2375
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = R(t, "addNodeView", {
|
|
2338
2376
|
name: t.name,
|
|
2339
2377
|
options: t.options,
|
|
2340
2378
|
storage: this.editor.extensionStorage[t.name],
|
|
2341
2379
|
editor: e,
|
|
2342
|
-
type:
|
|
2380
|
+
type: D(t.name, this.schema)
|
|
2343
2381
|
});
|
|
2344
2382
|
if (!r) return [];
|
|
2345
2383
|
let i = r();
|
|
2346
2384
|
return i ? [t.name, (r, a, o, s, c) => {
|
|
2347
|
-
let l =
|
|
2385
|
+
let l = W(r, n);
|
|
2348
2386
|
return i({
|
|
2349
2387
|
node: r,
|
|
2350
2388
|
view: a,
|
|
@@ -2360,14 +2398,14 @@ var Fr = class {
|
|
|
2360
2398
|
}
|
|
2361
2399
|
dispatchTransaction(e) {
|
|
2362
2400
|
let { editor: t } = this;
|
|
2363
|
-
return
|
|
2401
|
+
return G([...this.extensions].reverse()).reduceRight((e, n) => {
|
|
2364
2402
|
let r = {
|
|
2365
2403
|
name: n.name,
|
|
2366
2404
|
options: n.options,
|
|
2367
2405
|
storage: this.editor.extensionStorage[n.name],
|
|
2368
2406
|
editor: t,
|
|
2369
|
-
type:
|
|
2370
|
-
}, i =
|
|
2407
|
+
type: K(n.name, this.schema)
|
|
2408
|
+
}, i = R(n, "dispatchTransaction", r);
|
|
2371
2409
|
return i ? (t) => {
|
|
2372
2410
|
i.call(r, {
|
|
2373
2411
|
transaction: t,
|
|
@@ -2378,14 +2416,14 @@ var Fr = class {
|
|
|
2378
2416
|
}
|
|
2379
2417
|
transformPastedHTML(e) {
|
|
2380
2418
|
let { editor: t } = this;
|
|
2381
|
-
return
|
|
2419
|
+
return G([...this.extensions]).reduce((e, n) => {
|
|
2382
2420
|
let r = {
|
|
2383
2421
|
name: n.name,
|
|
2384
2422
|
options: n.options,
|
|
2385
2423
|
storage: this.editor.extensionStorage[n.name],
|
|
2386
2424
|
editor: t,
|
|
2387
|
-
type:
|
|
2388
|
-
}, i =
|
|
2425
|
+
type: K(n.name, this.schema)
|
|
2426
|
+
}, i = R(n, "transformPastedHTML", r);
|
|
2389
2427
|
return i ? (t, n) => {
|
|
2390
2428
|
let a = e(t, n);
|
|
2391
2429
|
return i.call(r, a);
|
|
@@ -2393,17 +2431,17 @@ var Fr = class {
|
|
|
2393
2431
|
}, e || ((e) => e));
|
|
2394
2432
|
}
|
|
2395
2433
|
get markViews() {
|
|
2396
|
-
let { editor: e } = this, { markExtensions: t } =
|
|
2397
|
-
return Object.fromEntries(t.filter((e) => !!
|
|
2398
|
-
let n = this.attributes.filter((e) => e.type === t.name), r =
|
|
2434
|
+
let { editor: e } = this, { markExtensions: t } = U(this.extensions);
|
|
2435
|
+
return Object.fromEntries(t.filter((e) => !!R(e, "addMarkView")).map((t) => {
|
|
2436
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = R(t, "addMarkView", {
|
|
2399
2437
|
name: t.name,
|
|
2400
2438
|
options: t.options,
|
|
2401
2439
|
storage: this.editor.extensionStorage[t.name],
|
|
2402
2440
|
editor: e,
|
|
2403
|
-
type:
|
|
2441
|
+
type: A(t.name, this.schema)
|
|
2404
2442
|
});
|
|
2405
2443
|
return r ? [t.name, (i, a, o) => {
|
|
2406
|
-
let s =
|
|
2444
|
+
let s = W(i, n);
|
|
2407
2445
|
return r()({
|
|
2408
2446
|
mark: i,
|
|
2409
2447
|
view: a,
|
|
@@ -2412,7 +2450,7 @@ var Fr = class {
|
|
|
2412
2450
|
extension: t,
|
|
2413
2451
|
HTMLAttributes: s,
|
|
2414
2452
|
updateAttributes: (t) => {
|
|
2415
|
-
|
|
2453
|
+
Er(i, e, t);
|
|
2416
2454
|
}
|
|
2417
2455
|
});
|
|
2418
2456
|
}] : [];
|
|
@@ -2436,16 +2474,16 @@ var Fr = class {
|
|
|
2436
2474
|
options: e.options,
|
|
2437
2475
|
storage: this.editor.extensionStorage[e.name],
|
|
2438
2476
|
editor: this.editor,
|
|
2439
|
-
type:
|
|
2477
|
+
type: K(e.name, this.schema)
|
|
2440
2478
|
};
|
|
2441
|
-
e.type === "mark" && ((
|
|
2442
|
-
let n =
|
|
2479
|
+
e.type === "mark" && ((H(R(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (H(R(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name));
|
|
2480
|
+
let n = R(e, "onBeforeCreate", t), r = R(e, "onCreate", t), i = R(e, "onUpdate", t), a = R(e, "onSelectionUpdate", t), o = R(e, "onTransaction", t), s = R(e, "onFocus", t), c = R(e, "onBlur", t), l = R(e, "onDestroy", t);
|
|
2443
2481
|
n && this.editor.on("beforeCreate", n), r && this.editor.on("create", r), i && this.editor.on("update", i), a && this.editor.on("selectionUpdate", a), o && this.editor.on("transaction", o), s && this.editor.on("focus", s), c && this.editor.on("blur", c), l && this.editor.on("destroy", l);
|
|
2444
2482
|
});
|
|
2445
2483
|
}
|
|
2446
2484
|
};
|
|
2447
|
-
|
|
2448
|
-
var $ = class e extends
|
|
2485
|
+
Br.resolve = Gt, Br.sort = G, Br.flatten = z;
|
|
2486
|
+
var $ = class e extends Nr {
|
|
2449
2487
|
constructor(...e) {
|
|
2450
2488
|
super(...e), this.type = "extension";
|
|
2451
2489
|
}
|
|
@@ -2460,40 +2498,40 @@ var $ = class e extends Dr {
|
|
|
2460
2498
|
let t = typeof e == "function" ? e() : e;
|
|
2461
2499
|
return super.extend(t);
|
|
2462
2500
|
}
|
|
2463
|
-
},
|
|
2501
|
+
}, Vr = $.create({
|
|
2464
2502
|
name: "clipboardTextSerializer",
|
|
2465
2503
|
addOptions() {
|
|
2466
2504
|
return { blockSeparator: void 0 };
|
|
2467
2505
|
},
|
|
2468
2506
|
addProseMirrorPlugins() {
|
|
2469
|
-
return [new
|
|
2470
|
-
key: new
|
|
2507
|
+
return [new v({
|
|
2508
|
+
key: new y("clipboardTextSerializer"),
|
|
2471
2509
|
props: { clipboardTextSerializer: () => {
|
|
2472
|
-
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a =
|
|
2510
|
+
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Zt(n), { blockSeparator: o } = this.options, s = {
|
|
2473
2511
|
...o === void 0 ? {} : { blockSeparator: o },
|
|
2474
2512
|
textSerializers: a
|
|
2475
2513
|
};
|
|
2476
|
-
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) =>
|
|
2514
|
+
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) => Yt(r, {
|
|
2477
2515
|
from: e.pos,
|
|
2478
2516
|
to: t.pos
|
|
2479
2517
|
}, s)).join(o ?? "\n\n");
|
|
2480
2518
|
} }
|
|
2481
2519
|
})];
|
|
2482
2520
|
}
|
|
2483
|
-
}),
|
|
2521
|
+
}), Hr = $.create({
|
|
2484
2522
|
name: "commands",
|
|
2485
2523
|
addCommands() {
|
|
2486
|
-
return { ...
|
|
2524
|
+
return { ...qn };
|
|
2487
2525
|
}
|
|
2488
|
-
}),
|
|
2526
|
+
}), Ur = $.create({
|
|
2489
2527
|
name: "delete",
|
|
2490
2528
|
onUpdate({ transaction: e, appendedTransactions: t }) {
|
|
2491
2529
|
var n;
|
|
2492
2530
|
let r = () => {
|
|
2493
2531
|
var n, r;
|
|
2494
2532
|
if (((n = this.editor.options.coreExtensionOptions) == null || (n = n.delete) == null || (r = n.filterTransaction) == null ? void 0 : r.call(n, e)) ?? e.getMeta("y-sync$")) return;
|
|
2495
|
-
let i =
|
|
2496
|
-
|
|
2533
|
+
let i = jt(e.before, [e, ...t]);
|
|
2534
|
+
nn(i).forEach((t) => {
|
|
2497
2535
|
i.mapping.mapResult(t.oldRange.from).deletedAfter && i.mapping.mapResult(t.oldRange.to).deletedBefore && i.before.nodesBetween(t.oldRange.from, t.oldRange.to, (n, r) => {
|
|
2498
2536
|
let a = r + n.nodeSize - 2, o = t.oldRange.from <= r && a <= t.oldRange.to;
|
|
2499
2537
|
this.editor.emit("delete", {
|
|
@@ -2514,7 +2552,7 @@ var $ = class e extends Dr {
|
|
|
2514
2552
|
});
|
|
2515
2553
|
let a = i.mapping;
|
|
2516
2554
|
i.steps.forEach((t, n) => {
|
|
2517
|
-
if (t instanceof
|
|
2555
|
+
if (t instanceof o) {
|
|
2518
2556
|
let r = a.slice(n).map(t.from, -1), o = a.slice(n).map(t.to), s = a.invert().map(r, -1), c = a.invert().map(o), l = r > 0 && i.doc.nodeAt(r - 1)?.marks.some((e) => e.eq(t.mark)), u = i.doc.nodeAt(o)?.marks.some((e) => e.eq(t.mark));
|
|
2519
2557
|
this.editor.emit("delete", {
|
|
2520
2558
|
type: "mark",
|
|
@@ -2539,11 +2577,11 @@ var $ = class e extends Dr {
|
|
|
2539
2577
|
};
|
|
2540
2578
|
((n = this.editor.options.coreExtensionOptions) == null || (n = n.delete) == null ? void 0 : n.async) ?? !0 ? setTimeout(r, 0) : r();
|
|
2541
2579
|
}
|
|
2542
|
-
}),
|
|
2580
|
+
}), Wr = $.create({
|
|
2543
2581
|
name: "drop",
|
|
2544
2582
|
addProseMirrorPlugins() {
|
|
2545
|
-
return [new
|
|
2546
|
-
key: new
|
|
2583
|
+
return [new v({
|
|
2584
|
+
key: new y("tiptapDrop"),
|
|
2547
2585
|
props: { handleDrop: (e, t, n, r) => {
|
|
2548
2586
|
this.editor.emit("drop", {
|
|
2549
2587
|
editor: this.editor,
|
|
@@ -2554,20 +2592,20 @@ var $ = class e extends Dr {
|
|
|
2554
2592
|
} }
|
|
2555
2593
|
})];
|
|
2556
2594
|
}
|
|
2557
|
-
}),
|
|
2595
|
+
}), Gr = $.create({
|
|
2558
2596
|
name: "editable",
|
|
2559
2597
|
addProseMirrorPlugins() {
|
|
2560
|
-
return [new
|
|
2561
|
-
key: new
|
|
2598
|
+
return [new v({
|
|
2599
|
+
key: new y("editable"),
|
|
2562
2600
|
props: { editable: () => this.editor.options.editable }
|
|
2563
2601
|
})];
|
|
2564
2602
|
}
|
|
2565
|
-
}),
|
|
2603
|
+
}), Kr = new y("focusEvents"), qr = $.create({
|
|
2566
2604
|
name: "focusEvents",
|
|
2567
2605
|
addProseMirrorPlugins() {
|
|
2568
2606
|
let { editor: e } = this;
|
|
2569
|
-
return [new
|
|
2570
|
-
key:
|
|
2607
|
+
return [new v({
|
|
2608
|
+
key: Kr,
|
|
2571
2609
|
props: { handleDOMEvents: {
|
|
2572
2610
|
focus: (t, n) => {
|
|
2573
2611
|
e.isFocused = !0;
|
|
@@ -2582,13 +2620,13 @@ var $ = class e extends Dr {
|
|
|
2582
2620
|
} }
|
|
2583
2621
|
})];
|
|
2584
2622
|
}
|
|
2585
|
-
}),
|
|
2623
|
+
}), Jr = $.create({
|
|
2586
2624
|
name: "keymap",
|
|
2587
2625
|
addKeyboardShortcuts() {
|
|
2588
2626
|
let e = () => this.editor.commands.first(({ commands: e }) => [
|
|
2589
2627
|
() => e.undoInputRule(),
|
|
2590
2628
|
() => e.command(({ tr: t }) => {
|
|
2591
|
-
let { selection: n, doc: r } = t, { empty: i, $anchor: a } = n, { pos: o, parent: s } = a, c = a.parent.isTextblock && o > 0 ? t.doc.resolve(o - 1) : a, l = c.parent.type.spec.isolating, u = a.pos - a.parentOffset, d = l && c.parent.childCount === 1 ? u === a.pos :
|
|
2629
|
+
let { selection: n, doc: r } = t, { empty: i, $anchor: a } = n, { pos: o, parent: s } = a, c = a.parent.isTextblock && o > 0 ? t.doc.resolve(o - 1) : a, l = c.parent.type.spec.isolating, u = a.pos - a.parentOffset, d = l && c.parent.childCount === 1 ? u === a.pos : b.atStart(r).from === o;
|
|
2592
2630
|
return !i || !s.type.isTextblock || s.textContent.length || !d || d && a.parent.type.name === "paragraph" ? !1 : e.clearNodes();
|
|
2593
2631
|
}),
|
|
2594
2632
|
() => e.deleteSelection(),
|
|
@@ -2624,21 +2662,21 @@ var $ = class e extends Dr {
|
|
|
2624
2662
|
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2625
2663
|
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2626
2664
|
};
|
|
2627
|
-
return
|
|
2665
|
+
return M() || ft() ? i : r;
|
|
2628
2666
|
},
|
|
2629
2667
|
addProseMirrorPlugins() {
|
|
2630
|
-
return [new
|
|
2631
|
-
key: new
|
|
2668
|
+
return [new v({
|
|
2669
|
+
key: new y("clearDocument"),
|
|
2632
2670
|
appendTransaction: (e, t, n) => {
|
|
2633
2671
|
if (e.some((e) => e.getMeta("composition"))) return;
|
|
2634
2672
|
let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = e.some((e) => e.getMeta("preventClearDocument"));
|
|
2635
2673
|
if (!r || i) return;
|
|
2636
|
-
let { empty: a, from: o, to: s } = t.selection, c =
|
|
2637
|
-
if (a || o !== c || s !== l || !
|
|
2638
|
-
let u = n.tr, d =
|
|
2674
|
+
let { empty: a, from: o, to: s } = t.selection, c = b.atStart(t.doc).from, l = b.atEnd(t.doc).to;
|
|
2675
|
+
if (a || o !== c || s !== l || !mn(n.doc)) return;
|
|
2676
|
+
let u = n.tr, d = T({
|
|
2639
2677
|
state: n,
|
|
2640
2678
|
transaction: u
|
|
2641
|
-
}), { commands: f } = new
|
|
2679
|
+
}), { commands: f } = new E({
|
|
2642
2680
|
editor: this.editor,
|
|
2643
2681
|
state: d
|
|
2644
2682
|
});
|
|
@@ -2646,11 +2684,11 @@ var $ = class e extends Dr {
|
|
|
2646
2684
|
}
|
|
2647
2685
|
})];
|
|
2648
2686
|
}
|
|
2649
|
-
}),
|
|
2687
|
+
}), Yr = $.create({
|
|
2650
2688
|
name: "paste",
|
|
2651
2689
|
addProseMirrorPlugins() {
|
|
2652
|
-
return [new
|
|
2653
|
-
key: new
|
|
2690
|
+
return [new v({
|
|
2691
|
+
key: new y("tiptapPaste"),
|
|
2654
2692
|
props: { handlePaste: (e, t, n) => {
|
|
2655
2693
|
this.editor.emit("paste", {
|
|
2656
2694
|
editor: this.editor,
|
|
@@ -2660,25 +2698,25 @@ var $ = class e extends Dr {
|
|
|
2660
2698
|
} }
|
|
2661
2699
|
})];
|
|
2662
2700
|
}
|
|
2663
|
-
}),
|
|
2701
|
+
}), Xr = $.create({
|
|
2664
2702
|
name: "tabindex",
|
|
2665
2703
|
addOptions() {
|
|
2666
2704
|
return { value: void 0 };
|
|
2667
2705
|
},
|
|
2668
2706
|
addProseMirrorPlugins() {
|
|
2669
|
-
return [new
|
|
2670
|
-
key: new
|
|
2707
|
+
return [new v({
|
|
2708
|
+
key: new y("tabindex"),
|
|
2671
2709
|
props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } }
|
|
2672
2710
|
})];
|
|
2673
2711
|
}
|
|
2674
|
-
}),
|
|
2712
|
+
}), Zr = $.create({
|
|
2675
2713
|
name: "textDirection",
|
|
2676
2714
|
addOptions() {
|
|
2677
2715
|
return { direction: void 0 };
|
|
2678
2716
|
},
|
|
2679
2717
|
addGlobalAttributes() {
|
|
2680
2718
|
if (!this.options.direction) return [];
|
|
2681
|
-
let { nodeExtensions: e } =
|
|
2719
|
+
let { nodeExtensions: e } = U(this.extensions);
|
|
2682
2720
|
return [{
|
|
2683
2721
|
types: e.filter((e) => e.name !== "text").map((e) => e.name),
|
|
2684
2722
|
attributes: { dir: {
|
|
@@ -2692,30 +2730,30 @@ var $ = class e extends Dr {
|
|
|
2692
2730
|
}];
|
|
2693
2731
|
},
|
|
2694
2732
|
addProseMirrorPlugins() {
|
|
2695
|
-
return [new
|
|
2696
|
-
key: new
|
|
2733
|
+
return [new v({
|
|
2734
|
+
key: new y("textDirection"),
|
|
2697
2735
|
props: { attributes: () => {
|
|
2698
2736
|
let e = this.options.direction;
|
|
2699
2737
|
return e ? { dir: e } : {};
|
|
2700
2738
|
} }
|
|
2701
2739
|
})];
|
|
2702
2740
|
}
|
|
2703
|
-
}),
|
|
2704
|
-
function
|
|
2705
|
-
if (
|
|
2706
|
-
|
|
2741
|
+
}), Qr = !1;
|
|
2742
|
+
function $r(e) {
|
|
2743
|
+
if (Qr) return;
|
|
2744
|
+
Qr = !0;
|
|
2707
2745
|
let t;
|
|
2708
2746
|
try {
|
|
2709
|
-
t =
|
|
2747
|
+
t = c.fromJSON(e, {
|
|
2710
2748
|
from: 0,
|
|
2711
2749
|
to: 0
|
|
2712
2750
|
}).slice.content;
|
|
2713
2751
|
} catch {
|
|
2714
2752
|
return;
|
|
2715
2753
|
}
|
|
2716
|
-
t instanceof
|
|
2754
|
+
t instanceof n || console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.");
|
|
2717
2755
|
}
|
|
2718
|
-
var
|
|
2756
|
+
var ei = class e {
|
|
2719
2757
|
get name() {
|
|
2720
2758
|
return this.node.type.name;
|
|
2721
2759
|
}
|
|
@@ -2837,7 +2875,7 @@ var Yr = class e {
|
|
|
2837
2875
|
...e
|
|
2838
2876
|
}), this.editor.view.dispatch(t);
|
|
2839
2877
|
}
|
|
2840
|
-
},
|
|
2878
|
+
}, ti = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}", ni = class extends Xn {
|
|
2841
2879
|
constructor(e = {}) {
|
|
2842
2880
|
super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.destroyed = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.hasWarnedStaleDecorationRead = !1, this.options = {
|
|
2843
2881
|
element: typeof document < "u" ? document.createElement("div") : null,
|
|
@@ -2874,19 +2912,19 @@ var Yr = class e {
|
|
|
2874
2912
|
onDelete: () => null,
|
|
2875
2913
|
enableExtensionDispatchTransaction: !0
|
|
2876
2914
|
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
|
|
2877
|
-
getUpdatedPosition:
|
|
2878
|
-
createMappablePosition:
|
|
2915
|
+
getUpdatedPosition: _n,
|
|
2916
|
+
createMappablePosition: vn
|
|
2879
2917
|
}, this.setOptions(e), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("mount", this.options.onMount), this.on("unmount", this.options.onUnmount), this.on("contentError", this.options.onContentError), this.on("create", this.options.onCreate), this.on("update", this.options.onUpdate), this.on("selectionUpdate", this.options.onSelectionUpdate), this.on("transaction", this.options.onTransaction), this.on("focus", this.options.onFocus), this.on("blur", this.options.onBlur), this.on("destroy", this.options.onDestroy), this.on("drop", ({ event: e, slice: t, moved: n }) => this.options.onDrop(e, t, n)), this.on("paste", ({ event: e, slice: t }) => this.options.onPaste(e, t)), this.on("delete", this.options.onDelete);
|
|
2880
2918
|
let t = this.createDoc();
|
|
2881
2919
|
if (!this.editorState) {
|
|
2882
|
-
let e =
|
|
2883
|
-
this.editorState =
|
|
2920
|
+
let e = We(t, this.options.autofocus);
|
|
2921
|
+
this.editorState = g.create({
|
|
2884
2922
|
doc: t,
|
|
2885
2923
|
schema: this.schema,
|
|
2886
2924
|
selection: e || void 0
|
|
2887
2925
|
});
|
|
2888
2926
|
}
|
|
2889
|
-
|
|
2927
|
+
$r(this.schema), this.options.element && this.mount(this.options.element);
|
|
2890
2928
|
}
|
|
2891
2929
|
mount(e) {
|
|
2892
2930
|
if (typeof document > "u") throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
|
|
@@ -2914,19 +2952,22 @@ var Yr = class e {
|
|
|
2914
2952
|
return this.commandManager.commands;
|
|
2915
2953
|
}
|
|
2916
2954
|
chain() {
|
|
2917
|
-
return this.commandManager ? this.commandManager.chain() :
|
|
2955
|
+
return this.commandManager ? this.commandManager.chain() : E.createFakeChain();
|
|
2918
2956
|
}
|
|
2919
2957
|
can() {
|
|
2920
|
-
return this.commandManager ? this.commandManager.can() :
|
|
2958
|
+
return this.commandManager ? this.commandManager.can() : E.createFallbackCan();
|
|
2921
2959
|
}
|
|
2922
2960
|
injectCSS() {
|
|
2923
|
-
this.options.injectCSS && typeof document < "u" && (this.css =
|
|
2961
|
+
this.options.injectCSS && typeof document < "u" && (this.css = vr(ti, this.options.injectNonce));
|
|
2924
2962
|
}
|
|
2925
2963
|
setOptions(e = {}) {
|
|
2926
2964
|
this.options = {
|
|
2927
2965
|
...this.options,
|
|
2928
2966
|
...e
|
|
2929
|
-
},
|
|
2967
|
+
}, this.editorView && this.state && !this.isDestroyed && (this.options.editorProps && this.view.setProps({
|
|
2968
|
+
...this.options.editorProps,
|
|
2969
|
+
attributes: this.getEditorViewAttributes()
|
|
2970
|
+
}), this.view.updateState(this.state));
|
|
2930
2971
|
}
|
|
2931
2972
|
setEditable(e, t = !0) {
|
|
2932
2973
|
this.setOptions({ editable: e }), t && this.emit("update", {
|
|
@@ -2959,10 +3000,10 @@ var Yr = class e {
|
|
|
2959
3000
|
} });
|
|
2960
3001
|
}
|
|
2961
3002
|
get state() {
|
|
2962
|
-
return
|
|
3003
|
+
return Zn && !this.hasWarnedStaleDecorationRead && Yn(this) && (this.hasWarnedStaleDecorationRead = !0, console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")), this.editorView && (this.editorState = this.view.state), this.editorState;
|
|
2963
3004
|
}
|
|
2964
3005
|
registerPlugin(e, t) {
|
|
2965
|
-
let n =
|
|
3006
|
+
let n = V(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n });
|
|
2966
3007
|
return this.view.updateState(r), r;
|
|
2967
3008
|
}
|
|
2968
3009
|
unregisterPlugin(e) {
|
|
@@ -2978,25 +3019,25 @@ var Yr = class e {
|
|
|
2978
3019
|
createExtensionManager() {
|
|
2979
3020
|
var e, t;
|
|
2980
3021
|
let n = [...this.options.enableCoreExtensions ? [
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
Lr,
|
|
3022
|
+
Gr,
|
|
3023
|
+
Vr.configure({ blockSeparator: (e = this.options.coreExtensionOptions) == null || (e = e.clipboardTextSerializer) == null ? void 0 : e.blockSeparator }),
|
|
2984
3024
|
Hr,
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
3025
|
+
qr,
|
|
3026
|
+
Jr,
|
|
3027
|
+
Xr.configure({ value: (t = this.options.coreExtensionOptions) == null || (t = t.tabindex) == null ? void 0 : t.value }),
|
|
2988
3028
|
Wr,
|
|
2989
|
-
|
|
2990
|
-
|
|
3029
|
+
Yr,
|
|
3030
|
+
Ur,
|
|
3031
|
+
Zr.configure({ direction: this.options.textDirection })
|
|
2991
3032
|
].filter((e) => typeof this.options.enableCoreExtensions != "object" || this.options.enableCoreExtensions[e.name] !== !1) : [], ...this.options.extensions].filter((e) => [
|
|
2992
3033
|
"extension",
|
|
2993
3034
|
"node",
|
|
2994
3035
|
"mark"
|
|
2995
3036
|
].includes(e?.type));
|
|
2996
|
-
this.extensionManager = new
|
|
3037
|
+
this.extensionManager = new Br(n, this);
|
|
2997
3038
|
}
|
|
2998
3039
|
createCommandManager() {
|
|
2999
|
-
this.commandManager = new
|
|
3040
|
+
this.commandManager = new E({ editor: this });
|
|
3000
3041
|
}
|
|
3001
3042
|
createSchema() {
|
|
3002
3043
|
this.schema = this.extensionManager.schema;
|
|
@@ -3004,14 +3045,14 @@ var Yr = class e {
|
|
|
3004
3045
|
createDoc() {
|
|
3005
3046
|
let e;
|
|
3006
3047
|
try {
|
|
3007
|
-
e =
|
|
3048
|
+
e = Ot(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
|
|
3008
3049
|
} catch (e) {
|
|
3009
3050
|
if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) throw e;
|
|
3010
|
-
let t =
|
|
3011
|
-
return this.editorState =
|
|
3051
|
+
let t = Ot(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
|
|
3052
|
+
return this.editorState = g.create({
|
|
3012
3053
|
doc: t,
|
|
3013
3054
|
schema: this.schema,
|
|
3014
|
-
selection:
|
|
3055
|
+
selection: We(t, this.options.autofocus) || void 0
|
|
3015
3056
|
}), this.emit("contentError", {
|
|
3016
3057
|
editor: this,
|
|
3017
3058
|
error: e,
|
|
@@ -3022,14 +3063,21 @@ var Yr = class e {
|
|
|
3022
3063
|
}
|
|
3023
3064
|
return e;
|
|
3024
3065
|
}
|
|
3066
|
+
getEditorViewAttributes() {
|
|
3067
|
+
let e = this.options.editorProps?.attributes;
|
|
3068
|
+
return V(e) ? (t) => ({
|
|
3069
|
+
role: "textbox",
|
|
3070
|
+
...e(t)
|
|
3071
|
+
}) : {
|
|
3072
|
+
role: "textbox",
|
|
3073
|
+
...e
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3025
3076
|
createView(e) {
|
|
3026
3077
|
let { editorProps: t, enableExtensionDispatchTransaction: n } = this.options, r = t.dispatchTransaction || this.dispatchTransaction.bind(this), i = n ? this.extensionManager.dispatchTransaction(r) : r, a = t.transformPastedHTML, o = this.extensionManager.transformPastedHTML(a);
|
|
3027
|
-
this.editorView = new
|
|
3078
|
+
this.editorView = new be(e, {
|
|
3028
3079
|
...t,
|
|
3029
|
-
attributes:
|
|
3030
|
-
role: "textbox",
|
|
3031
|
-
...t?.attributes
|
|
3032
|
-
},
|
|
3080
|
+
attributes: this.getEditorViewAttributes(),
|
|
3033
3081
|
dispatchTransaction: i,
|
|
3034
3082
|
transformPastedHTML: o,
|
|
3035
3083
|
state: this.editorState,
|
|
@@ -3095,30 +3143,30 @@ var Yr = class e {
|
|
|
3095
3143
|
});
|
|
3096
3144
|
}
|
|
3097
3145
|
getAttributes(e) {
|
|
3098
|
-
return
|
|
3146
|
+
return $t(this.state, e);
|
|
3099
3147
|
}
|
|
3100
3148
|
isActive(e, t) {
|
|
3101
3149
|
let n = typeof e == "string" ? e : null, r = typeof e == "string" ? t : e;
|
|
3102
|
-
return
|
|
3150
|
+
return ln(this.state, n, r);
|
|
3103
3151
|
}
|
|
3104
3152
|
getJSON() {
|
|
3105
3153
|
return this.state.doc.toJSON();
|
|
3106
3154
|
}
|
|
3107
3155
|
getHTML() {
|
|
3108
|
-
return
|
|
3156
|
+
return B(this.state.doc.content, this.schema);
|
|
3109
3157
|
}
|
|
3110
3158
|
getText(e) {
|
|
3111
3159
|
let { blockSeparator: t = "\n\n", textSerializers: n = {} } = e || {};
|
|
3112
|
-
return
|
|
3160
|
+
return Xt(this.state.doc, {
|
|
3113
3161
|
blockSeparator: t,
|
|
3114
3162
|
textSerializers: {
|
|
3115
|
-
...
|
|
3163
|
+
...Zt(this.schema),
|
|
3116
3164
|
...n
|
|
3117
3165
|
}
|
|
3118
3166
|
});
|
|
3119
3167
|
}
|
|
3120
3168
|
get isEmpty() {
|
|
3121
|
-
return
|
|
3169
|
+
return mn(this.state.doc);
|
|
3122
3170
|
}
|
|
3123
3171
|
destroy() {
|
|
3124
3172
|
this.destroyed || (this.destroyed = !0, this.emit("destroy"), this.unmount(), this.removeAllListeners(), this.extensionManager.destroy(), this.extensionManager = null, this.schema = null, this.commandManager = null, this.extensionStorage = {});
|
|
@@ -3134,22 +3182,22 @@ var Yr = class e {
|
|
|
3134
3182
|
}
|
|
3135
3183
|
$pos(e) {
|
|
3136
3184
|
let t = this.state.doc.resolve(e), n = e > 0 && t.nodeAfter && !t.nodeAfter.isText && t.nodeAfter.isAtom ? t.nodeAfter : null;
|
|
3137
|
-
return new
|
|
3185
|
+
return new ei(t, this, !1, n);
|
|
3138
3186
|
}
|
|
3139
3187
|
get $doc() {
|
|
3140
3188
|
return this.$pos(0);
|
|
3141
3189
|
}
|
|
3142
3190
|
};
|
|
3143
|
-
function
|
|
3144
|
-
return new
|
|
3191
|
+
function ri(e) {
|
|
3192
|
+
return new Z({
|
|
3145
3193
|
find: e.find,
|
|
3146
3194
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3147
|
-
let i =
|
|
3195
|
+
let i = H(e.getAttributes, void 0, r);
|
|
3148
3196
|
if (i === !1 || i === null) return null;
|
|
3149
3197
|
let { tr: a } = t, o = r[r.length - 1], s = r[0];
|
|
3150
3198
|
if (o) {
|
|
3151
3199
|
let r = s.search(/\S/), c = n.from + s.indexOf(o), l = c + o.length;
|
|
3152
|
-
if (
|
|
3200
|
+
if (rn(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > c).length) return null;
|
|
3153
3201
|
l < n.to && a.delete(l, n.to), c > n.from && a.delete(n.from + r, c);
|
|
3154
3202
|
let u = n.from + r + o.length;
|
|
3155
3203
|
a.addMark(n.from + r, u, e.type.create(i || {})), a.removeStoredMark(e.type);
|
|
@@ -3158,11 +3206,11 @@ function Qr(e) {
|
|
|
3158
3206
|
undoable: e.undoable
|
|
3159
3207
|
});
|
|
3160
3208
|
}
|
|
3161
|
-
function
|
|
3162
|
-
return new
|
|
3209
|
+
function ii(e) {
|
|
3210
|
+
return new Z({
|
|
3163
3211
|
find: e.find,
|
|
3164
3212
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3165
|
-
let i =
|
|
3213
|
+
let i = H(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i);
|
|
3166
3214
|
if (r[1]) {
|
|
3167
3215
|
let e = o + r[0].lastIndexOf(r[1]);
|
|
3168
3216
|
e > s ? e = s : s = e + r[1].length;
|
|
@@ -3177,22 +3225,22 @@ function $r(e) {
|
|
|
3177
3225
|
undoable: e.undoable
|
|
3178
3226
|
});
|
|
3179
3227
|
}
|
|
3180
|
-
function
|
|
3181
|
-
return new
|
|
3228
|
+
function ai(e) {
|
|
3229
|
+
return new Z({
|
|
3182
3230
|
find: e.find,
|
|
3183
3231
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3184
|
-
let i = t.doc.resolve(n.from), a =
|
|
3232
|
+
let i = t.doc.resolve(n.from), a = H(e.getAttributes, void 0, r) || {};
|
|
3185
3233
|
if (!i.node(-1).canReplaceWith(i.index(-1), i.indexAfter(-1), e.type)) return null;
|
|
3186
3234
|
t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, a);
|
|
3187
3235
|
},
|
|
3188
3236
|
undoable: e.undoable
|
|
3189
3237
|
});
|
|
3190
3238
|
}
|
|
3191
|
-
function
|
|
3192
|
-
return new
|
|
3239
|
+
function oi(e) {
|
|
3240
|
+
return new Z({
|
|
3193
3241
|
find: e.find,
|
|
3194
3242
|
handler: ({ state: t, range: n, match: r, chain: i }) => {
|
|
3195
|
-
let a =
|
|
3243
|
+
let a = H(e.getAttributes, void 0, r) || {}, o = t.tr.delete(n.from, n.to), s = o.doc.resolve(n.from).blockRange(), c = s && f(s, e.type, a);
|
|
3196
3244
|
if (!c) return null;
|
|
3197
3245
|
if (o.wrap(s, c), e.keepMarks && e.editor) {
|
|
3198
3246
|
let { selection: n, storedMarks: r } = t, { splittableMarks: i } = e.editor.extensionManager, a = r || n.$to.parentOffset && n.$from.marks();
|
|
@@ -3206,12 +3254,12 @@ function ti(e) {
|
|
|
3206
3254
|
i().updateAttributes(t, a).run();
|
|
3207
3255
|
}
|
|
3208
3256
|
let l = o.doc.resolve(n.from - 1).nodeBefore;
|
|
3209
|
-
l && l.type === e.type &&
|
|
3257
|
+
l && l.type === e.type && u(o.doc, n.from - 1) && (!e.joinPredicate || e.joinPredicate(r, l)) && o.join(n.from - 1);
|
|
3210
3258
|
},
|
|
3211
3259
|
undoable: e.undoable
|
|
3212
3260
|
});
|
|
3213
3261
|
}
|
|
3214
|
-
var
|
|
3262
|
+
var si = class e extends Nr {
|
|
3215
3263
|
constructor(...e) {
|
|
3216
3264
|
super(...e), this.type = "node";
|
|
3217
3265
|
}
|
|
@@ -3227,20 +3275,20 @@ var ni = class e extends Dr {
|
|
|
3227
3275
|
return super.extend(t);
|
|
3228
3276
|
}
|
|
3229
3277
|
};
|
|
3230
|
-
function
|
|
3231
|
-
return new
|
|
3278
|
+
function ci(e) {
|
|
3279
|
+
return new Fr({
|
|
3232
3280
|
find: e.find,
|
|
3233
3281
|
handler: ({ state: t, range: n, match: r, pasteEvent: i }) => {
|
|
3234
|
-
let a =
|
|
3282
|
+
let a = H(e.getAttributes, void 0, r, i);
|
|
3235
3283
|
if (a === !1 || a === null) return null;
|
|
3236
3284
|
let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to;
|
|
3237
3285
|
if (s) {
|
|
3238
3286
|
let i = c.search(/\S/), u = n.from + c.indexOf(s), d = u + s.length;
|
|
3239
|
-
if (
|
|
3287
|
+
if (rn(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > u).length) return null;
|
|
3240
3288
|
d < n.to && o.delete(d, n.to), u > n.from && o.delete(n.from + i, u), l = n.from + i + s.length, o.addMark(n.from + i, l, e.type.create(a || {})), r.index !== void 0 && r.input !== void 0 && r.index + r[0].length >= r.input.length || o.removeStoredMark(e.type);
|
|
3241
3289
|
}
|
|
3242
3290
|
}
|
|
3243
3291
|
});
|
|
3244
3292
|
}
|
|
3245
3293
|
//#endregion
|
|
3246
|
-
export {
|
|
3294
|
+
export { E as CommandManager, J as DECORATION_MANAGER_PLUGIN_KEY, gr as DecorationManager, ni as Editor, Nr as Extendable, $ as Extension, Z as InputRule, gn as MappablePosition, Pr as Mark, si as Node, ei as NodePos, Fr as PasteRule, H as callOrReturn, _r as canInsertNode, jt as combineTransactionSteps, qn as commands, T as createChainableState, Ot as createDocument, vn as createMappablePosition, P as createNodeFromContent, vr as createStyleTag, tt as defaultBlockAt, yt as deleteProps, N as elementFromString, Mt as findChildrenInRange, Wt as findDuplicates, L as findParentNode, Nt as findParentNodeClosestToPos, z as flattenExtensions, zt as fromString, qt as generateHTML, Jt as generateJSON, $t as getAttributes, Ft as getAttributesFromExtensions, nn as getChangedRanges, R as getExtensionField, B as getHTMLFromFragment, At as getMarkAttributes, Be as getMarkRange, A as getMarkType, rn as getMarksBetween, an as getNodeAtPosition, Qt as getNodeAttributes, D as getNodeType, on as getPreviousBlockSibling, W as getRenderedAttributes, Kt as getSchema, Ut as getSchemaByResolvedExtensions, K as getSchemaTypeByName, I as getSchemaTypeNameByName, q as getSplittedAttributes, Xt as getText, Yt as getTextBetween, sn as getTextContentFromNodes, Zt as getTextSerializersFromSchema, _n as getUpdatedPosition, Bt as injectExtensionAttributesToParseRule, Mr as inputRulesPlugin, ln as isActive, Ge as isAndroid, un as isAtEndOfNode, dn as isAtStartOfNode, Pt as isEmptyObject, fn as isExtensionRulesEnabled, V as isFunction, pn as isList, ft as isMacOS, cn as isMarkActive, F as isNodeActive, mn as isNodeEmpty, hn as isNodeSelection, yr as isNumber, X as isPlainObject, O as isRegExp, Ke as isSafari, Ue as isTextSelection, M as isiOS, ri as markInputRule, ci as markPasteRule, Rt as mergeAttributes, Tr as mergeDeep, j as minMax, ii as nodeInputRule, k as objectIncludes, xr as parseIndentedBlocks, zr as pasteRulesPlugin, en as removeDuplicates, wr as renderNestedMarkdownContent, Gt as resolveExtensions, We as resolveFocusPosition, $e as selectionToInsertionEnd, G as sortExtensions, U as splitExtensions, ai as textblockTypeInputRule, Er as updateMarkViewAttributes, oi as wrappingInputRule };
|