@vizel/core 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +44 -0
  2. package/dist/components.css +1 -0
  3. package/dist/components.css.map +1 -0
  4. package/dist/index.d.ts +2642 -0
  5. package/dist/index.js +150 -0
  6. package/dist/index10.js +118 -0
  7. package/dist/index11.js +174 -0
  8. package/dist/index12.js +78 -0
  9. package/dist/index13.js +141 -0
  10. package/dist/index14.js +150 -0
  11. package/dist/index15.js +20 -0
  12. package/dist/index16.js +17 -0
  13. package/dist/index17.js +308 -0
  14. package/dist/index18.js +52 -0
  15. package/dist/index19.js +29 -0
  16. package/dist/index2.js +93 -0
  17. package/dist/index20.js +268 -0
  18. package/dist/index21.js +72 -0
  19. package/dist/index22.js +360 -0
  20. package/dist/index23.js +87 -0
  21. package/dist/index24.js +39 -0
  22. package/dist/index25.js +95 -0
  23. package/dist/index26.js +104 -0
  24. package/dist/index27.js +136 -0
  25. package/dist/index28.js +56 -0
  26. package/dist/index29.js +69 -0
  27. package/dist/index3.js +69 -0
  28. package/dist/index30.js +40 -0
  29. package/dist/index31.js +26 -0
  30. package/dist/index32.js +15 -0
  31. package/dist/index33.js +12 -0
  32. package/dist/index34.js +19 -0
  33. package/dist/index35.js +60 -0
  34. package/dist/index36.js +17 -0
  35. package/dist/index37.js +66 -0
  36. package/dist/index38.js +6 -0
  37. package/dist/index39.js +125 -0
  38. package/dist/index4.js +89 -0
  39. package/dist/index40.js +329 -0
  40. package/dist/index41.js +489 -0
  41. package/dist/index42.js +50 -0
  42. package/dist/index43.js +676 -0
  43. package/dist/index44.js +6 -0
  44. package/dist/index45.js +6 -0
  45. package/dist/index46.js +240 -0
  46. package/dist/index47.js +84 -0
  47. package/dist/index48.js +288 -0
  48. package/dist/index49.js +1504 -0
  49. package/dist/index5.js +13 -0
  50. package/dist/index50.js +7 -0
  51. package/dist/index51.js +1563 -0
  52. package/dist/index52.js +204 -0
  53. package/dist/index53.js +725 -0
  54. package/dist/index54.js +23 -0
  55. package/dist/index55.js +12 -0
  56. package/dist/index56.js +9 -0
  57. package/dist/index57.js +10 -0
  58. package/dist/index58.js +16 -0
  59. package/dist/index59.js +21 -0
  60. package/dist/index6.js +135 -0
  61. package/dist/index60.js +27 -0
  62. package/dist/index61.js +86 -0
  63. package/dist/index62.js +248 -0
  64. package/dist/index63.js +1234 -0
  65. package/dist/index64.js +736 -0
  66. package/dist/index65.js +5 -0
  67. package/dist/index66.js +1063 -0
  68. package/dist/index67.js +57 -0
  69. package/dist/index68.js +100 -0
  70. package/dist/index69.js +6 -0
  71. package/dist/index7.js +456 -0
  72. package/dist/index70.js +93 -0
  73. package/dist/index8.js +52 -0
  74. package/dist/index9.js +275 -0
  75. package/dist/styles.css +1 -0
  76. package/dist/styles.css.map +1 -0
  77. package/package.json +109 -0
@@ -0,0 +1,66 @@
1
+ import { Mark as d, mergeAttributes as a } from "@tiptap/core";
2
+ var s = d.create({
3
+ name: "underline",
4
+ addOptions() {
5
+ return {
6
+ HTMLAttributes: {}
7
+ };
8
+ },
9
+ parseHTML() {
10
+ return [
11
+ {
12
+ tag: "u"
13
+ },
14
+ {
15
+ style: "text-decoration",
16
+ consuming: !1,
17
+ getAttrs: (e) => e.includes("underline") ? {} : !1
18
+ }
19
+ ];
20
+ },
21
+ renderHTML({ HTMLAttributes: e }) {
22
+ return ["u", a(this.options.HTMLAttributes, e), 0];
23
+ },
24
+ parseMarkdown(e, n) {
25
+ return n.applyMark(this.name || "underline", n.parseInline(e.tokens || []));
26
+ },
27
+ renderMarkdown(e, n) {
28
+ return `++${n.renderChildren(e)}++`;
29
+ },
30
+ markdownTokenizer: {
31
+ name: "underline",
32
+ level: "inline",
33
+ start(e) {
34
+ return e.indexOf("++");
35
+ },
36
+ tokenize(e, n, i) {
37
+ const r = /^(\+\+)([\s\S]+?)(\+\+)/.exec(e);
38
+ if (!r)
39
+ return;
40
+ const t = r[2].trim();
41
+ return {
42
+ type: "underline",
43
+ raw: r[0],
44
+ text: t,
45
+ tokens: i.inlineTokens(t)
46
+ };
47
+ }
48
+ },
49
+ addCommands() {
50
+ return {
51
+ setUnderline: () => ({ commands: e }) => e.setMark(this.name),
52
+ toggleUnderline: () => ({ commands: e }) => e.toggleMark(this.name),
53
+ unsetUnderline: () => ({ commands: e }) => e.unsetMark(this.name)
54
+ };
55
+ },
56
+ addKeyboardShortcuts() {
57
+ return {
58
+ "Mod-u": () => this.editor.commands.toggleUnderline(),
59
+ "Mod-U": () => this.editor.commands.toggleUnderline()
60
+ };
61
+ }
62
+ }), l = s;
63
+ export {
64
+ s as Underline,
65
+ l as default
66
+ };
@@ -0,0 +1,6 @@
1
+ import { CharacterCount as a } from "./index48.js";
2
+ var t = a;
3
+ export {
4
+ a as CharacterCount,
5
+ t as default
6
+ };
@@ -0,0 +1,125 @@
1
+ import x from "@tiptap/extension-code-block";
2
+ import { findChildren as p } from "@tiptap/core";
3
+ import { Plugin as y, PluginKey as w } from "./index41.js";
4
+ import { Decoration as N, DecorationSet as L } from "./index49.js";
5
+ import C from "./index50.js";
6
+ function v(e, i = []) {
7
+ return e.flatMap((t) => {
8
+ const a = [...i, ...t.properties ? t.properties.className : []];
9
+ return t.children ? v(t.children, a) : {
10
+ text: t.value,
11
+ classes: a
12
+ };
13
+ });
14
+ }
15
+ function f(e) {
16
+ return e.value || e.children || [];
17
+ }
18
+ function P(e) {
19
+ return !!C.getLanguage(e);
20
+ }
21
+ function m({
22
+ doc: e,
23
+ name: i,
24
+ lowlight: t,
25
+ defaultLanguage: a
26
+ }) {
27
+ const n = [];
28
+ return p(e, (r) => r.type.name === i).forEach((r) => {
29
+ var u;
30
+ let l = r.pos + 1;
31
+ const s = r.node.attrs.language || a, h = t.listLanguages(), d = s && (h.includes(s) || P(s) || (u = t.registered) != null && u.call(t, s)) ? f(t.highlight(s, r.node.textContent)) : f(t.highlightAuto(r.node.textContent));
32
+ v(d).forEach((g) => {
33
+ const o = l + g.text.length;
34
+ if (g.classes.length) {
35
+ const c = N.inline(l, o, {
36
+ class: g.classes.join(" ")
37
+ });
38
+ n.push(c);
39
+ }
40
+ l = o;
41
+ });
42
+ }), L.create(e, n);
43
+ }
44
+ function _(e) {
45
+ return typeof e == "function";
46
+ }
47
+ function A({
48
+ name: e,
49
+ lowlight: i,
50
+ defaultLanguage: t
51
+ }) {
52
+ if (!["highlight", "highlightAuto", "listLanguages"].every((n) => _(i[n])))
53
+ throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");
54
+ const a = new y({
55
+ key: new w("lowlight"),
56
+ state: {
57
+ init: (n, { doc: r }) => m({
58
+ doc: r,
59
+ name: e,
60
+ lowlight: i,
61
+ defaultLanguage: t
62
+ }),
63
+ apply: (n, r, u, l) => {
64
+ const s = u.selection.$head.parent.type.name, h = l.selection.$head.parent.type.name, d = p(u.doc, (o) => o.type.name === e), g = p(l.doc, (o) => o.type.name === e);
65
+ return n.docChanged && // Apply decorations if:
66
+ // selection includes named node,
67
+ ([s, h].includes(e) || // OR transaction adds/removes named node,
68
+ g.length !== d.length || // OR transaction has changes that completely encapsulte a node
69
+ // (for example, a transaction that affects the entire document).
70
+ // Such transactions can happen during collab syncing via y-prosemirror, for example.
71
+ n.steps.some((o) => (
72
+ // @ts-ignore
73
+ o.from !== void 0 && // @ts-ignore
74
+ o.to !== void 0 && d.some((c) => (
75
+ // @ts-ignore
76
+ c.pos >= o.from && // @ts-ignore
77
+ c.pos + c.node.nodeSize <= o.to
78
+ ))
79
+ ))) ? m({
80
+ doc: n.doc,
81
+ name: e,
82
+ lowlight: i,
83
+ defaultLanguage: t
84
+ }) : r.map(n.mapping, n.doc);
85
+ }
86
+ },
87
+ props: {
88
+ decorations(n) {
89
+ return a.getState(n);
90
+ }
91
+ }
92
+ });
93
+ return a;
94
+ }
95
+ var D = x.extend({
96
+ addOptions() {
97
+ var e;
98
+ return {
99
+ ...(e = this.parent) == null ? void 0 : e.call(this),
100
+ lowlight: {},
101
+ languageClassPrefix: "language-",
102
+ exitOnTripleEnter: !0,
103
+ exitOnArrowDown: !0,
104
+ defaultLanguage: null,
105
+ enableTabIndentation: !1,
106
+ tabSize: 4,
107
+ HTMLAttributes: {}
108
+ };
109
+ },
110
+ addProseMirrorPlugins() {
111
+ var e;
112
+ return [
113
+ ...((e = this.parent) == null ? void 0 : e.call(this)) || [],
114
+ A({
115
+ name: this.name,
116
+ lowlight: this.options.lowlight,
117
+ defaultLanguage: this.options.defaultLanguage
118
+ })
119
+ ];
120
+ }
121
+ }), S = D;
122
+ export {
123
+ D as CodeBlockLowlight,
124
+ S as default
125
+ };
package/dist/index4.js ADDED
@@ -0,0 +1,89 @@
1
+ import { TextStyle as t, Color as l } from "./index46.js";
2
+ import { Highlight as i } from "./index47.js";
3
+ const h = [
4
+ // Row 1: Grayscale
5
+ { name: "Default", color: "inherit" },
6
+ { name: "Dark Gray", color: "#374151" },
7
+ { name: "Gray", color: "#6b7280" },
8
+ { name: "Light Gray", color: "#9ca3af" },
9
+ // Row 2: Warm colors
10
+ { name: "Dark Red", color: "#b91c1c" },
11
+ { name: "Red", color: "#ef4444" },
12
+ { name: "Orange", color: "#f97316" },
13
+ { name: "Amber", color: "#f59e0b" },
14
+ // Row 3: Cool colors
15
+ { name: "Yellow", color: "#eab308" },
16
+ { name: "Lime", color: "#84cc16" },
17
+ { name: "Green", color: "#22c55e" },
18
+ { name: "Emerald", color: "#10b981" },
19
+ // Row 4: Blue spectrum
20
+ { name: "Teal", color: "#14b8a6" },
21
+ { name: "Cyan", color: "#06b6d4" },
22
+ { name: "Blue", color: "#3b82f6" },
23
+ { name: "Indigo", color: "#6366f1" },
24
+ // Row 5: Purple/Pink spectrum
25
+ { name: "Violet", color: "#8b5cf6" },
26
+ { name: "Purple", color: "#a855f7" },
27
+ { name: "Fuchsia", color: "#d946ef" },
28
+ { name: "Pink", color: "#ec4899" }
29
+ ], s = [
30
+ // Row 1: Basics
31
+ { name: "None", color: "transparent" },
32
+ { name: "Light Gray", color: "#e5e7eb" },
33
+ { name: "Warm Gray", color: "#e7e5e4" },
34
+ { name: "Cool Gray", color: "#e2e8f0" },
35
+ // Row 2: Warm highlights
36
+ { name: "Light Red", color: "#fecaca" },
37
+ { name: "Light Orange", color: "#fed7aa" },
38
+ { name: "Light Amber", color: "#fde68a" },
39
+ { name: "Yellow", color: "#fef08a" },
40
+ // Row 3: Green highlights
41
+ { name: "Light Lime", color: "#d9f99d" },
42
+ { name: "Light Green", color: "#bbf7d0" },
43
+ { name: "Light Emerald", color: "#a7f3d0" },
44
+ { name: "Light Teal", color: "#99f6e4" },
45
+ // Row 4: Blue highlights
46
+ { name: "Light Cyan", color: "#a5f3fc" },
47
+ { name: "Light Blue", color: "#bfdbfe" },
48
+ { name: "Light Indigo", color: "#c7d2fe" },
49
+ { name: "Light Violet", color: "#ddd6fe" },
50
+ // Row 5: Purple/Pink highlights
51
+ { name: "Light Purple", color: "#e9d5ff" },
52
+ { name: "Light Fuchsia", color: "#f5d0fe" },
53
+ { name: "Light Pink", color: "#fbcfe8" },
54
+ { name: "Light Rose", color: "#fecdd3" }
55
+ ], r = "vizel-recent-colors", m = 8;
56
+ function f(o) {
57
+ if (typeof window > "u") return [];
58
+ try {
59
+ const e = localStorage.getItem(`${r}-${o}`);
60
+ return e ? JSON.parse(e) : [];
61
+ } catch {
62
+ return [];
63
+ }
64
+ }
65
+ function u(o, e) {
66
+ if (!(typeof window > "u") && !(e === "inherit" || e === "transparent"))
67
+ try {
68
+ const n = f(o).filter((c) => c !== e), a = [e, ...n].slice(0, m);
69
+ localStorage.setItem(`${r}-${o}`, JSON.stringify(a));
70
+ } catch {
71
+ }
72
+ }
73
+ function b(o = {}) {
74
+ const { multicolor: e = !0 } = o;
75
+ return [
76
+ t,
77
+ l,
78
+ i.configure({
79
+ multicolor: e
80
+ })
81
+ ];
82
+ }
83
+ export {
84
+ s as VIZEL_HIGHLIGHT_COLORS,
85
+ h as VIZEL_TEXT_COLORS,
86
+ u as addVizelRecentColor,
87
+ b as createVizelTextColorExtensions,
88
+ f as getVizelRecentColors
89
+ };
@@ -0,0 +1,329 @@
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 "./index52.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
+ };
261
+ },
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
+ };
295
+ },
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
+ };
309
+ },
310
+ parseHTML() {
311
+ return [
312
+ {
313
+ tag: "summary"
314
+ }
315
+ ];
316
+ },
317
+ renderHTML({ HTMLAttributes: t }) {
318
+ return ["summary", v(this.options.HTMLAttributes, t), 0];
319
+ },
320
+ ...N({
321
+ nodeName: "detailsSummary",
322
+ content: "inline"
323
+ })
324
+ });
325
+ export {
326
+ j as Details,
327
+ q as DetailsContent,
328
+ _ as DetailsSummary
329
+ };