@vizel/core 0.0.1-alpha.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/components.css +1 -1
  2. package/dist/components.css.map +1 -1
  3. package/dist/index.d.ts +230 -15
  4. package/dist/index.js +78 -75
  5. package/dist/index10.js +1 -1
  6. package/dist/index11.js +4 -4
  7. package/dist/index14.js +1 -1
  8. package/dist/index15.js +134 -127
  9. package/dist/index17.js +2 -2
  10. package/dist/index18.js +1 -1
  11. package/dist/index19.js +86 -86
  12. package/dist/index20.js +2 -2
  13. package/dist/index21.js +2 -2
  14. package/dist/index22.js +16 -13
  15. package/dist/index24.js +164 -11
  16. package/dist/index25.js +12 -53
  17. package/dist/index26.js +49 -136
  18. package/dist/index27.js +132 -59
  19. package/dist/index28.js +66 -32
  20. package/dist/index29.js +35 -21
  21. package/dist/index3.js +91 -90
  22. package/dist/index30.js +23 -9
  23. package/dist/index31.js +9 -147
  24. package/dist/index32.js +138 -256
  25. package/dist/index33.js +258 -85
  26. package/dist/index34.js +91 -15
  27. package/dist/index35.js +63 -57
  28. package/dist/index36.js +4 -15
  29. package/dist/index37.js +115 -56
  30. package/dist/index38.js +327 -4
  31. package/dist/index39.js +11 -121
  32. package/dist/index4.js +1 -1
  33. package/dist/index40.js +481 -321
  34. package/dist/index41.js +42 -481
  35. package/dist/index42.js +683 -37
  36. package/dist/index43.js +4 -679
  37. package/dist/index44.js +4 -4
  38. package/dist/index45.js +238 -4
  39. package/dist/index46.js +54 -210
  40. package/dist/index47.js +16 -81
  41. package/dist/index48.js +57 -285
  42. package/dist/index49.js +14 -1501
  43. package/dist/index5.js +78 -68
  44. package/dist/index50.js +286 -5
  45. package/dist/index51.js +4 -4
  46. package/dist/index52.js +1408 -1467
  47. package/dist/index53.js +5 -723
  48. package/dist/index54.js +1112 -21
  49. package/dist/index55.js +722 -9
  50. package/dist/index56.js +83 -6
  51. package/dist/index57.js +245 -7
  52. package/dist/index58.js +3 -14
  53. package/dist/index59.js +1230 -17
  54. package/dist/index6.js +1 -1
  55. package/dist/index60.js +733 -24
  56. package/dist/index61.js +21 -84
  57. package/dist/index62.js +10 -246
  58. package/dist/index63.js +7 -3
  59. package/dist/index64.js +7 -1231
  60. package/dist/index65.js +11 -731
  61. package/dist/index66.js +17 -1059
  62. package/dist/index67.js +21 -51
  63. package/dist/index68.js +54 -3
  64. package/dist/index69.js +1061 -98
  65. package/dist/index7.js +108 -96
  66. package/dist/index70.js +98 -91
  67. package/dist/index71.js +93 -0
  68. package/dist/index72.js +6 -0
  69. package/dist/index8.js +1 -1
  70. package/dist/index9.js +75 -65
  71. package/dist/mathematics.css +1 -0
  72. package/dist/mathematics.css.map +1 -0
  73. package/dist/styles.css +1 -1
  74. package/dist/styles.css.map +1 -1
  75. package/package.json +90 -52
package/dist/index40.js CHANGED
@@ -1,329 +1,489 @@
1
- import { Node as L, createBlockMarkdownSpec as N, isActive as F, findChildren as b, defaultBlockAt as x, findParentNode as w, mergeAttributes as v } from "@tiptap/core";
2
- import { Plugin as z, PluginKey as G, TextSelection as R, Selection as D } from "./index41.js";
3
- import { GapCursor as H } from "./index51.js";
4
- var S = (t, s) => s.view.domAtPos(t).node.offsetParent !== null, W = (t, s, o) => {
5
- for (let e = t.depth; e > 0; e -= 1) {
6
- const n = t.node(e), c = s(n), r = S(t.start(e), o);
7
- if (c && r)
8
- return {
9
- pos: e > 0 ? t.before(e) : 0,
10
- start: t.start(e),
11
- depth: e,
12
- node: n
13
- };
14
- }
15
- }, O = (t, s) => {
16
- const { state: o, view: e, extensionManager: n } = t, { schema: c, selection: r } = o, { empty: d, $anchor: l } = r, i = !!n.extensions.find((u) => u.name === "gapCursor");
17
- if (!d || l.parent.type !== c.nodes.detailsSummary || !i || s === "right" && l.parentOffset !== l.parent.nodeSize - 2)
18
- return !1;
19
- const a = w((u) => u.type === c.nodes.details)(r);
20
- if (!a)
21
- return !1;
22
- const p = b(a.node, (u) => u.type === c.nodes.detailsContent);
23
- if (!p.length || S(a.start + p[0].pos + 1, t))
24
- return !1;
25
- const m = o.doc.resolve(a.pos + a.node.nodeSize), h = H.findFrom(m, 1, !1);
26
- if (!h)
27
- return !1;
28
- const { tr: y } = o, C = new H(h);
29
- return y.setSelection(C), y.scrollIntoView(), e.dispatch(y), !0;
30
- }, j = L.create({
31
- name: "details",
32
- content: "detailsSummary detailsContent",
33
- group: "block",
34
- defining: !0,
35
- isolating: !0,
36
- // @ts-ignore reason: `allowGapCursor` is not a valid property by default, but the `GapCursor` extension adds it to the Nodeconfig type
37
- allowGapCursor: !1,
38
- addOptions() {
39
- return {
40
- persist: !1,
41
- openClassName: "is-open",
42
- HTMLAttributes: {}
43
- };
44
- },
45
- addAttributes() {
46
- return this.options.persist ? {
47
- open: {
48
- default: !1,
49
- parseHTML: (t) => t.hasAttribute("open"),
50
- renderHTML: ({ open: t }) => t ? { open: "" } : {}
51
- }
52
- } : [];
53
- },
54
- parseHTML() {
55
- return [
56
- {
57
- tag: "details"
58
- }
59
- ];
60
- },
61
- renderHTML({ HTMLAttributes: t }) {
62
- return ["details", v(this.options.HTMLAttributes, t), 0];
63
- },
64
- ...N({
65
- nodeName: "details",
66
- content: "block"
67
- }),
68
- addNodeView() {
69
- return ({ editor: t, getPos: s, node: o, HTMLAttributes: e }) => {
70
- const n = document.createElement("div"), c = v(this.options.HTMLAttributes, e, {
71
- "data-type": this.name
72
- });
73
- Object.entries(c).forEach(([i, a]) => n.setAttribute(i, a));
74
- const r = document.createElement("button");
75
- r.type = "button", n.append(r);
76
- const d = document.createElement("div");
77
- n.append(d);
78
- const l = (i) => {
79
- if (i !== void 0)
80
- if (i) {
81
- if (n.classList.contains(this.options.openClassName))
82
- return;
83
- n.classList.add(this.options.openClassName);
84
- } else {
85
- if (!n.classList.contains(this.options.openClassName))
86
- return;
87
- n.classList.remove(this.options.openClassName);
88
- }
89
- else
90
- n.classList.toggle(this.options.openClassName);
91
- const a = new Event("toggleDetailsContent"), p = d.querySelector(':scope > div[data-type="detailsContent"]');
92
- p?.dispatchEvent(a);
93
- };
94
- return o.attrs.open && setTimeout(() => l()), r.addEventListener("click", () => {
95
- if (l(), !this.options.persist) {
96
- t.commands.focus(void 0, { scrollIntoView: !1 });
97
- return;
98
- }
99
- if (t.isEditable && typeof s == "function") {
100
- const { from: i, to: a } = t.state.selection;
101
- t.chain().command(({ tr: p }) => {
102
- const f = s();
103
- if (!f)
104
- return !1;
105
- const m = p.doc.nodeAt(f);
106
- return m?.type !== this.type ? !1 : (p.setNodeMarkup(f, void 0, {
107
- open: !m.attrs.open
108
- }), !0);
109
- }).setTextSelection({
110
- from: i,
111
- to: a
112
- }).focus(void 0, { scrollIntoView: !1 }).run();
113
- }
114
- }), {
115
- dom: n,
116
- contentDOM: d,
117
- ignoreMutation(i) {
118
- return i.type === "selection" ? !1 : !n.contains(i.target) || n === i.target;
119
- },
120
- update: (i) => i.type !== this.type ? !1 : (i.attrs.open !== void 0 && l(i.attrs.open), !0)
121
- };
122
- };
123
- },
124
- addCommands() {
125
- return {
126
- setDetails: () => ({ state: t, chain: s }) => {
127
- var o;
128
- const { schema: e, selection: n } = t, { $from: c, $to: r } = n, d = c.blockRange(r);
129
- if (!d)
130
- return !1;
131
- const l = t.doc.slice(d.start, d.end);
132
- if (!e.nodes.detailsContent.contentMatch.matchFragment(l.content))
133
- return !1;
134
- const a = ((o = l.toJSON()) == null ? void 0 : o.content) || [];
135
- return s().insertContentAt(
136
- { from: d.start, to: d.end },
137
- {
138
- type: this.name,
139
- content: [
140
- {
141
- type: "detailsSummary"
142
- },
143
- {
144
- type: "detailsContent",
145
- content: a
146
- }
147
- ]
148
- }
149
- ).setTextSelection(d.start + 2).run();
150
- },
151
- unsetDetails: () => ({ state: t, chain: s }) => {
152
- const { selection: o, schema: e } = t, n = w((u) => u.type === this.type)(o);
153
- if (!n)
154
- return !1;
155
- const c = b(n.node, (u) => u.type === e.nodes.detailsSummary), r = b(n.node, (u) => u.type === e.nodes.detailsContent);
156
- if (!c.length || !r.length)
157
- return !1;
158
- const d = c[0], l = r[0], i = n.pos, a = t.doc.resolve(i), p = i + n.node.nodeSize, f = { from: i, to: p }, m = l.node.content.toJSON() || [], h = a.parent.type.contentMatch.defaultType, C = [h?.create(null, d.node.content).toJSON(), ...m];
159
- return s().insertContentAt(f, C).setTextSelection(i + 1).run();
160
- }
161
- };
162
- },
163
- addKeyboardShortcuts() {
164
- return {
165
- Backspace: () => {
166
- const { schema: t, selection: s } = this.editor.state, { empty: o, $anchor: e } = s;
167
- return !o || e.parent.type !== t.nodes.detailsSummary ? !1 : e.parentOffset !== 0 ? this.editor.commands.command(({ tr: n }) => {
168
- const c = e.pos - 1, r = e.pos;
169
- return n.delete(c, r), !0;
170
- }) : this.editor.commands.unsetDetails();
171
- },
172
- // Creates a new node below it if it is closed.
173
- // Otherwise inside `DetailsContent`.
174
- Enter: ({ editor: t }) => {
175
- const { state: s, view: o } = t, { schema: e, selection: n } = s, { $head: c } = n;
176
- if (c.parent.type !== e.nodes.detailsSummary)
177
- return !1;
178
- const r = S(c.after() + 1, t), d = r ? s.doc.nodeAt(c.after()) : c.node(-2);
179
- if (!d)
180
- return !1;
181
- const l = r ? 0 : c.indexAfter(-1), i = x(d.contentMatchAt(l));
182
- if (!i || !d.canReplaceWith(l, l, i))
183
- return !1;
184
- const a = i.createAndFill();
185
- if (!a)
186
- return !1;
187
- const p = r ? c.after() + 1 : c.after(-1), f = s.tr.replaceWith(p, p, a), m = f.doc.resolve(p), h = D.near(m, 1);
188
- return f.setSelection(h), f.scrollIntoView(), o.dispatch(f), !0;
189
- },
190
- // The default gapcursor implementation can’t handle hidden content, so we need to fix this.
191
- ArrowRight: ({ editor: t }) => O(t, "right"),
192
- // The default gapcursor implementation can’t handle hidden content, so we need to fix this.
193
- ArrowDown: ({ editor: t }) => O(t, "down")
194
- };
195
- },
196
- addProseMirrorPlugins() {
197
- return [
198
- // This plugin prevents text selections within the hidden content in `DetailsContent`.
199
- // The cursor is moved to the next visible position.
200
- new z({
201
- key: new G("detailsSelection"),
202
- appendTransaction: (t, s, o) => {
203
- const { editor: e, type: n } = this;
204
- if (e.view.composing || !t.some((u) => u.selectionSet) || !s.selection.empty || !o.selection.empty || !F(o, n.name))
205
- return;
206
- const { $from: l } = o.selection;
207
- if (S(l.pos, e))
208
- return;
209
- const a = W(l, (u) => u.type === n, e);
210
- if (!a)
211
- return;
212
- const p = b(
213
- a.node,
214
- (u) => u.type === o.schema.nodes.detailsSummary
215
- );
216
- if (!p.length)
217
- return;
218
- const f = p[0], h = (s.selection.from < o.selection.from ? "forward" : "backward") === "forward" ? a.start + f.pos : a.pos + f.pos + f.node.nodeSize, y = R.create(o.doc, h);
219
- return o.tr.setSelection(y);
220
- }
221
- })
222
- ];
223
- }
224
- }), q = L.create({
225
- name: "detailsContent",
226
- content: "block+",
227
- defining: !0,
228
- selectable: !1,
229
- addOptions() {
230
- return {
231
- HTMLAttributes: {}
232
- };
233
- },
234
- parseHTML() {
235
- return [
236
- {
237
- tag: `div[data-type="${this.name}"]`
238
- }
239
- ];
240
- },
241
- renderHTML({ HTMLAttributes: t }) {
242
- return ["div", v(this.options.HTMLAttributes, t, { "data-type": this.name }), 0];
243
- },
244
- addNodeView() {
245
- return ({ HTMLAttributes: t }) => {
246
- const s = document.createElement("div"), o = v(this.options.HTMLAttributes, t, {
247
- "data-type": this.name,
248
- hidden: "hidden"
249
- });
250
- return Object.entries(o).forEach(([e, n]) => s.setAttribute(e, n)), s.addEventListener("toggleDetailsContent", () => {
251
- s.toggleAttribute("hidden");
252
- }), {
253
- dom: s,
254
- contentDOM: s,
255
- ignoreMutation(e) {
256
- return e.type === "selection" ? !1 : !s.contains(e.target) || s === e.target;
257
- },
258
- update: (e) => e.type === this.type
259
- };
260
- };
1
+ import { Slice as m, Fragment as J } from "./index59.js";
2
+ import { ReplaceStep as x, ReplaceAroundStep as C } from "./index60.js";
3
+ const k = /* @__PURE__ */ Object.create(null);
4
+ class l {
5
+ /**
6
+ Initialize a selection with the head and anchor and ranges. If no
7
+ ranges are given, constructs a single range across `$anchor` and
8
+ `$head`.
9
+ */
10
+ constructor(e, t, n) {
11
+ this.$anchor = e, this.$head = t, this.ranges = n || [new E(e.min(t), e.max(t))];
12
+ }
13
+ /**
14
+ The selection's anchor, as an unresolved position.
15
+ */
16
+ get anchor() {
17
+ return this.$anchor.pos;
18
+ }
19
+ /**
20
+ The selection's head.
21
+ */
22
+ get head() {
23
+ return this.$head.pos;
24
+ }
25
+ /**
26
+ The lower bound of the selection's main range.
27
+ */
28
+ get from() {
29
+ return this.$from.pos;
30
+ }
31
+ /**
32
+ The upper bound of the selection's main range.
33
+ */
34
+ get to() {
35
+ return this.$to.pos;
36
+ }
37
+ /**
38
+ The resolved lower bound of the selection's main range.
39
+ */
40
+ get $from() {
41
+ return this.ranges[0].$from;
42
+ }
43
+ /**
44
+ The resolved upper bound of the selection's main range.
45
+ */
46
+ get $to() {
47
+ return this.ranges[0].$to;
48
+ }
49
+ /**
50
+ Indicates whether the selection contains any content.
51
+ */
52
+ get empty() {
53
+ let e = this.ranges;
54
+ for (let t = 0; t < e.length; t++)
55
+ if (e[t].$from.pos != e[t].$to.pos)
56
+ return !1;
57
+ return !0;
58
+ }
59
+ /**
60
+ Get the content of this selection as a slice.
61
+ */
62
+ content() {
63
+ return this.$from.doc.slice(this.from, this.to, !0);
64
+ }
65
+ /**
66
+ Replace the selection with a slice or, if no slice is given,
67
+ delete the selection. Will append to the given transaction.
68
+ */
69
+ replace(e, t = m.empty) {
70
+ let n = t.content.lastChild, i = null;
71
+ for (let s = 0; s < t.openEnd; s++)
72
+ i = n, n = n.lastChild;
73
+ let o = e.steps.length, a = this.ranges;
74
+ for (let s = 0; s < a.length; s++) {
75
+ let { $from: h, $to: g } = a[s], f = e.mapping.slice(o);
76
+ e.replaceRange(f.map(h.pos), f.map(g.pos), s ? m.empty : t), s == 0 && b(e, o, (n ? n.isInline : i && i.isTextblock) ? -1 : 1);
77
+ }
78
+ }
79
+ /**
80
+ Replace the selection with the given node, appending the changes
81
+ to the given transaction.
82
+ */
83
+ replaceWith(e, t) {
84
+ let n = e.steps.length, i = this.ranges;
85
+ for (let o = 0; o < i.length; o++) {
86
+ let { $from: a, $to: s } = i[o], h = e.mapping.slice(n), g = h.map(a.pos), f = h.map(s.pos);
87
+ o ? e.deleteRange(g, f) : (e.replaceRangeWith(g, f, t), b(e, n, t.isInline ? -1 : 1));
88
+ }
89
+ }
90
+ /**
91
+ Find a valid cursor or leaf node selection starting at the given
92
+ position and searching back if `dir` is negative, and forward if
93
+ positive. When `textOnly` is true, only consider cursor
94
+ selections. Will return null when no valid selection position is
95
+ found.
96
+ */
97
+ static findFrom(e, t, n = !1) {
98
+ let i = e.parent.inlineContent ? new c(e) : d(e.node(0), e.parent, e.pos, e.index(), t, n);
99
+ if (i)
100
+ return i;
101
+ for (let o = e.depth - 1; o >= 0; o--) {
102
+ let a = t < 0 ? d(e.node(0), e.node(o), e.before(o + 1), e.index(o), t, n) : d(e.node(0), e.node(o), e.after(o + 1), e.index(o) + 1, t, n);
103
+ if (a)
104
+ return a;
105
+ }
106
+ return null;
107
+ }
108
+ /**
109
+ Find a valid cursor or leaf node selection near the given
110
+ position. Searches forward first by default, but if `bias` is
111
+ negative, it will search backwards first.
112
+ */
113
+ static near(e, t = 1) {
114
+ return this.findFrom(e, t) || this.findFrom(e, -t) || new p(e.node(0));
115
+ }
116
+ /**
117
+ Find the cursor or leaf node selection closest to the start of
118
+ the given document. Will return an
119
+ [`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
120
+ exists.
121
+ */
122
+ static atStart(e) {
123
+ return d(e, e, 0, 0, 1) || new p(e);
124
+ }
125
+ /**
126
+ Find the cursor or leaf node selection closest to the end of the
127
+ given document.
128
+ */
129
+ static atEnd(e) {
130
+ return d(e, e, e.content.size, e.childCount, -1) || new p(e);
131
+ }
132
+ /**
133
+ Deserialize the JSON representation of a selection. Must be
134
+ implemented for custom classes (as a static class method).
135
+ */
136
+ static fromJSON(e, t) {
137
+ if (!t || !t.type)
138
+ throw new RangeError("Invalid input for Selection.fromJSON");
139
+ let n = k[t.type];
140
+ if (!n)
141
+ throw new RangeError(`No selection type ${t.type} defined`);
142
+ return n.fromJSON(e, t);
143
+ }
144
+ /**
145
+ To be able to deserialize selections from JSON, custom selection
146
+ classes must register themselves with an ID string, so that they
147
+ can be disambiguated. Try to pick something that's unlikely to
148
+ clash with classes from other modules.
149
+ */
150
+ static jsonID(e, t) {
151
+ if (e in k)
152
+ throw new RangeError("Duplicate use of selection JSON ID " + e);
153
+ return k[e] = t, t.prototype.jsonID = e, t;
154
+ }
155
+ /**
156
+ Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
157
+ which is a value that can be mapped without having access to a
158
+ current document, and later resolved to a real selection for a
159
+ given document again. (This is used mostly by the history to
160
+ track and restore old selections.) The default implementation of
161
+ this method just converts the selection to a text selection and
162
+ returns the bookmark for that.
163
+ */
164
+ getBookmark() {
165
+ return c.between(this.$anchor, this.$head).getBookmark();
166
+ }
167
+ }
168
+ l.prototype.visible = !0;
169
+ class E {
170
+ /**
171
+ Create a range.
172
+ */
173
+ constructor(e, t) {
174
+ this.$from = e, this.$to = t;
175
+ }
176
+ }
177
+ let I = !1;
178
+ function F(r) {
179
+ !I && !r.parent.inlineContent && (I = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + r.parent.type.name + ")"));
180
+ }
181
+ class c extends l {
182
+ /**
183
+ Construct a text selection between the given points.
184
+ */
185
+ constructor(e, t = e) {
186
+ F(e), F(t), super(e, t);
187
+ }
188
+ /**
189
+ Returns a resolved position if this is a cursor selection (an
190
+ empty text selection), and null otherwise.
191
+ */
192
+ get $cursor() {
193
+ return this.$anchor.pos == this.$head.pos ? this.$head : null;
194
+ }
195
+ map(e, t) {
196
+ let n = e.resolve(t.map(this.head));
197
+ if (!n.parent.inlineContent)
198
+ return l.near(n);
199
+ let i = e.resolve(t.map(this.anchor));
200
+ return new c(i.parent.inlineContent ? i : n, n);
201
+ }
202
+ replace(e, t = m.empty) {
203
+ if (super.replace(e, t), t == m.empty) {
204
+ let n = this.$from.marksAcross(this.$to);
205
+ n && e.ensureMarks(n);
206
+ }
207
+ }
208
+ eq(e) {
209
+ return e instanceof c && e.anchor == this.anchor && e.head == this.head;
210
+ }
211
+ getBookmark() {
212
+ return new y(this.anchor, this.head);
213
+ }
214
+ toJSON() {
215
+ return { type: "text", anchor: this.anchor, head: this.head };
216
+ }
217
+ /**
218
+ @internal
219
+ */
220
+ static fromJSON(e, t) {
221
+ if (typeof t.anchor != "number" || typeof t.head != "number")
222
+ throw new RangeError("Invalid input for TextSelection.fromJSON");
223
+ return new c(e.resolve(t.anchor), e.resolve(t.head));
224
+ }
225
+ /**
226
+ Create a text selection from non-resolved positions.
227
+ */
228
+ static create(e, t, n = t) {
229
+ let i = e.resolve(t);
230
+ return new this(i, n == t ? i : e.resolve(n));
231
+ }
232
+ /**
233
+ Return a text selection that spans the given positions or, if
234
+ they aren't text positions, find a text selection near them.
235
+ `bias` determines whether the method searches forward (default)
236
+ or backwards (negative number) first. Will fall back to calling
237
+ [`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
238
+ doesn't contain a valid text position.
239
+ */
240
+ static between(e, t, n) {
241
+ let i = e.pos - t.pos;
242
+ if ((!n || i) && (n = i >= 0 ? 1 : -1), !t.parent.inlineContent) {
243
+ let o = l.findFrom(t, n, !0) || l.findFrom(t, -n, !0);
244
+ if (o)
245
+ t = o.$head;
246
+ else
247
+ return l.near(t, n);
248
+ }
249
+ return e.parent.inlineContent || (i == 0 ? e = t : (e = (l.findFrom(e, -n, !0) || l.findFrom(e, n, !0)).$anchor, e.pos < t.pos != i < 0 && (e = t))), new c(e, t);
250
+ }
251
+ }
252
+ l.jsonID("text", c);
253
+ class y {
254
+ constructor(e, t) {
255
+ this.anchor = e, this.head = t;
256
+ }
257
+ map(e) {
258
+ return new y(e.map(this.anchor), e.map(this.head));
259
+ }
260
+ resolve(e) {
261
+ return c.between(e.resolve(this.anchor), e.resolve(this.head));
262
+ }
263
+ }
264
+ class u extends l {
265
+ /**
266
+ Create a node selection. Does not verify the validity of its
267
+ argument.
268
+ */
269
+ constructor(e) {
270
+ let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
271
+ super(e, n), this.node = t;
272
+ }
273
+ map(e, t) {
274
+ let { deleted: n, pos: i } = t.mapResult(this.anchor), o = e.resolve(i);
275
+ return n ? l.near(o) : new u(o);
276
+ }
277
+ content() {
278
+ return new m(J.from(this.node), 0, 0);
279
+ }
280
+ eq(e) {
281
+ return e instanceof u && e.anchor == this.anchor;
282
+ }
283
+ toJSON() {
284
+ return { type: "node", anchor: this.anchor };
285
+ }
286
+ getBookmark() {
287
+ return new v(this.anchor);
288
+ }
289
+ /**
290
+ @internal
291
+ */
292
+ static fromJSON(e, t) {
293
+ if (typeof t.anchor != "number")
294
+ throw new RangeError("Invalid input for NodeSelection.fromJSON");
295
+ return new u(e.resolve(t.anchor));
296
+ }
297
+ /**
298
+ Create a node selection from non-resolved positions.
299
+ */
300
+ static create(e, t) {
301
+ return new u(e.resolve(t));
302
+ }
303
+ /**
304
+ Determines whether the given node may be selected as a node
305
+ selection.
306
+ */
307
+ static isSelectable(e) {
308
+ return !e.isText && e.type.spec.selectable !== !1;
309
+ }
310
+ }
311
+ u.prototype.visible = !1;
312
+ l.jsonID("node", u);
313
+ class v {
314
+ constructor(e) {
315
+ this.anchor = e;
316
+ }
317
+ map(e) {
318
+ let { deleted: t, pos: n } = e.mapResult(this.anchor);
319
+ return t ? new y(n, n) : new v(n);
320
+ }
321
+ resolve(e) {
322
+ let t = e.resolve(this.anchor), n = t.nodeAfter;
323
+ return n && u.isSelectable(n) ? new u(t) : l.near(t);
324
+ }
325
+ }
326
+ class p extends l {
327
+ /**
328
+ Create an all-selection over the given document.
329
+ */
330
+ constructor(e) {
331
+ super(e.resolve(0), e.resolve(e.content.size));
332
+ }
333
+ replace(e, t = m.empty) {
334
+ if (t == m.empty) {
335
+ e.delete(0, e.doc.content.size);
336
+ let n = l.atStart(e.doc);
337
+ n.eq(e.selection) || e.setSelection(n);
338
+ } else
339
+ super.replace(e, t);
340
+ }
341
+ toJSON() {
342
+ return { type: "all" };
343
+ }
344
+ /**
345
+ @internal
346
+ */
347
+ static fromJSON(e) {
348
+ return new p(e);
349
+ }
350
+ map(e) {
351
+ return new p(e);
352
+ }
353
+ eq(e) {
354
+ return e instanceof p;
355
+ }
356
+ getBookmark() {
357
+ return D;
358
+ }
359
+ }
360
+ l.jsonID("all", p);
361
+ const D = {
362
+ map() {
363
+ return this;
261
364
  },
262
- addKeyboardShortcuts() {
263
- return {
264
- // Escape node on double enter
265
- Enter: ({ editor: t }) => {
266
- const { state: s, view: o } = t, { selection: e } = s, { $from: n, empty: c } = e, r = w(($) => $.type === this.type)(e);
267
- if (!c || !r || !r.node.childCount)
268
- return !1;
269
- const d = n.index(r.depth), { childCount: l } = r.node;
270
- if (!(l === d + 1))
271
- return !1;
272
- const a = r.node.type.contentMatch.defaultType, p = a?.createAndFill();
273
- if (!p)
274
- return !1;
275
- const f = s.doc.resolve(r.pos + 1), m = l - 1, h = r.node.child(m), y = f.posAtIndex(m, r.depth);
276
- if (!h.eq(p))
277
- return !1;
278
- const u = n.node(-3);
279
- if (!u)
280
- return !1;
281
- const A = n.indexAfter(-3), M = x(u.contentMatchAt(A));
282
- if (!M || !u.canReplaceWith(A, A, M))
283
- return !1;
284
- const E = M.createAndFill();
285
- if (!E)
286
- return !1;
287
- const { tr: g } = s, T = n.after(-2);
288
- g.replaceWith(T, T, E);
289
- const k = g.doc.resolve(T), I = D.near(k, 1);
290
- g.setSelection(I);
291
- const V = y, P = y + h.nodeSize;
292
- return g.delete(V, P), g.scrollIntoView(), o.dispatch(g), !0;
293
- }
294
- };
365
+ resolve(r) {
366
+ return new p(r);
367
+ }
368
+ };
369
+ function d(r, e, t, n, i, o = !1) {
370
+ if (e.inlineContent)
371
+ return c.create(r, t);
372
+ for (let a = n - (i > 0 ? 0 : 1); i > 0 ? a < e.childCount : a >= 0; a += i) {
373
+ let s = e.child(a);
374
+ if (s.isAtom) {
375
+ if (!o && u.isSelectable(s))
376
+ return u.create(r, t - (i < 0 ? s.nodeSize : 0));
377
+ } else {
378
+ let h = d(r, s, t + i, i < 0 ? s.childCount : 0, i, o);
379
+ if (h)
380
+ return h;
381
+ }
382
+ t += s.nodeSize * i;
383
+ }
384
+ return null;
385
+ }
386
+ function b(r, e, t) {
387
+ let n = r.steps.length - 1;
388
+ if (n < e)
389
+ return;
390
+ let i = r.steps[n];
391
+ if (!(i instanceof x || i instanceof C))
392
+ return;
393
+ let o = r.mapping.maps[n], a;
394
+ o.forEach((s, h, g, f) => {
395
+ a == null && (a = f);
396
+ }), r.setSelection(l.near(r.doc.resolve(a), t));
397
+ }
398
+ function N(r, e) {
399
+ return !e || !r ? r : r.bind(e);
400
+ }
401
+ class w {
402
+ constructor(e, t, n) {
403
+ this.name = e, this.init = N(t.init, n), this.apply = N(t.apply, n);
404
+ }
405
+ }
406
+ new w("doc", {
407
+ init(r) {
408
+ return r.doc || r.schema.topNodeType.createAndFill();
295
409
  },
296
- ...N({
297
- nodeName: "detailsContent"
298
- })
299
- }), _ = L.create({
300
- name: "detailsSummary",
301
- content: "text*",
302
- defining: !0,
303
- selectable: !1,
304
- isolating: !0,
305
- addOptions() {
306
- return {
307
- HTMLAttributes: {}
308
- };
410
+ apply(r) {
411
+ return r.doc;
412
+ }
413
+ }), new w("selection", {
414
+ init(r, e) {
415
+ return r.selection || l.atStart(e.doc);
309
416
  },
310
- parseHTML() {
311
- return [
312
- {
313
- tag: "summary"
314
- }
315
- ];
417
+ apply(r) {
418
+ return r.selection;
419
+ }
420
+ }), new w("storedMarks", {
421
+ init(r) {
422
+ return r.storedMarks || null;
316
423
  },
317
- renderHTML({ HTMLAttributes: t }) {
318
- return ["summary", v(this.options.HTMLAttributes, t), 0];
424
+ apply(r, e, t, n) {
425
+ return n.selection.$cursor ? r.storedMarks : null;
426
+ }
427
+ }), new w("scrollToSelection", {
428
+ init() {
429
+ return 0;
319
430
  },
320
- ...N({
321
- nodeName: "detailsSummary",
322
- content: "inline"
323
- })
431
+ apply(r, e) {
432
+ return r.scrolledIntoView ? e + 1 : e;
433
+ }
324
434
  });
435
+ function O(r, e, t) {
436
+ for (let n in r) {
437
+ let i = r[n];
438
+ i instanceof Function ? i = i.bind(e) : n == "handleDOMEvents" && (i = O(i, e, {})), t[n] = i;
439
+ }
440
+ return t;
441
+ }
442
+ class A {
443
+ /**
444
+ Create a plugin.
445
+ */
446
+ constructor(e) {
447
+ this.spec = e, this.props = {}, e.props && O(e.props, this, this.props), this.key = e.key ? e.key.key : R("plugin");
448
+ }
449
+ /**
450
+ Extract the plugin's state field from an editor state.
451
+ */
452
+ getState(e) {
453
+ return e[this.key];
454
+ }
455
+ }
456
+ const S = /* @__PURE__ */ Object.create(null);
457
+ function R(r) {
458
+ return r in S ? r + "$" + ++S[r] : (S[r] = 0, r + "$");
459
+ }
460
+ class T {
461
+ /**
462
+ Create a plugin key.
463
+ */
464
+ constructor(e = "key") {
465
+ this.key = R(e);
466
+ }
467
+ /**
468
+ Get the active plugin with this key, if any, from an editor
469
+ state.
470
+ */
471
+ get(e) {
472
+ return e.config.pluginsByKey[this.key];
473
+ }
474
+ /**
475
+ Get the plugin's state from an editor state.
476
+ */
477
+ getState(e) {
478
+ return e[this.key];
479
+ }
480
+ }
325
481
  export {
326
- j as Details,
327
- q as DetailsContent,
328
- _ as DetailsSummary
482
+ p as AllSelection,
483
+ u as NodeSelection,
484
+ A as Plugin,
485
+ T as PluginKey,
486
+ l as Selection,
487
+ E as SelectionRange,
488
+ c as TextSelection
329
489
  };