@vizel/core 0.0.1-alpha.2 → 0.0.1-alpha.4
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/dist/index.d.ts +13 -13
- package/dist/index10.js +1 -1
- package/dist/index11.js +2 -2
- package/dist/index14.js +1 -1
- package/dist/index20.js +2 -2
- package/dist/index21.js +2 -2
- package/dist/index22.js +3 -3
- package/dist/index26.js +1 -1
- package/dist/index3.js +1 -1
- package/dist/index31.js +2 -2
- package/dist/index34.js +63 -16
- package/dist/index35.js +4 -58
- package/dist/index36.js +123 -15
- package/dist/index37.js +316 -37
- package/dist/index38.js +481 -58
- package/dist/index39.js +48 -4
- package/dist/index4.js +1 -1
- package/dist/index40.js +664 -108
- package/dist/index41.js +4 -327
- package/dist/index42.js +4 -487
- package/dist/index43.js +206 -647
- package/dist/index44.js +82 -4
- package/dist/index45.js +17 -4
- package/dist/index46.js +57 -237
- package/dist/index47.js +15 -82
- package/dist/index48.js +4 -4
- package/dist/index49.js +3 -3
- package/dist/index5.js +1 -1
- package/dist/index50.js +1408 -1467
- package/dist/index51.js +5 -1502
- package/dist/index52.js +1533 -695
- package/dist/index53.js +723 -5
- package/dist/index54.js +84 -21
- package/dist/index55.js +246 -10
- package/dist/index56.js +3 -7
- package/dist/index57.js +1231 -7
- package/dist/index58.js +731 -11
- package/dist/index59.js +21 -19
- package/dist/index6.js +1 -1
- package/dist/index60.js +10 -25
- package/dist/index61.js +6 -83
- package/dist/index62.js +7 -245
- package/dist/index63.js +11 -1229
- package/dist/index64.js +17 -732
- package/dist/index65.js +25 -3
- package/dist/index66.js +1 -1
- package/dist/index68.js +91 -98
- package/dist/index69.js +3 -90
- package/dist/index70.js +98 -4
- package/dist/index8.js +1 -1
- package/dist/index9.js +1 -1
- package/package.json +27 -15
- package/LICENSE +0 -21
package/dist/index41.js
CHANGED
|
@@ -1,329 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { GapCursor as H } from "./index49.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
|
-
});
|
|
1
|
+
import { TaskItem as a } from "./index53.js";
|
|
2
|
+
var t = a;
|
|
325
3
|
export {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
_ as DetailsSummary
|
|
4
|
+
a as TaskItem,
|
|
5
|
+
t as default
|
|
329
6
|
};
|