@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.
- package/dist/components.css +1 -1
- package/dist/components.css.map +1 -1
- package/dist/index.d.ts +230 -15
- package/dist/index.js +78 -75
- package/dist/index10.js +1 -1
- package/dist/index11.js +4 -4
- package/dist/index14.js +1 -1
- package/dist/index15.js +134 -127
- package/dist/index17.js +2 -2
- package/dist/index18.js +1 -1
- package/dist/index19.js +86 -86
- package/dist/index20.js +2 -2
- package/dist/index21.js +2 -2
- package/dist/index22.js +16 -13
- package/dist/index24.js +164 -11
- package/dist/index25.js +12 -53
- package/dist/index26.js +49 -136
- package/dist/index27.js +132 -59
- package/dist/index28.js +66 -32
- package/dist/index29.js +35 -21
- package/dist/index3.js +91 -90
- package/dist/index30.js +23 -9
- package/dist/index31.js +9 -147
- package/dist/index32.js +138 -256
- package/dist/index33.js +258 -85
- package/dist/index34.js +91 -15
- package/dist/index35.js +63 -57
- package/dist/index36.js +4 -15
- package/dist/index37.js +115 -56
- package/dist/index38.js +327 -4
- package/dist/index39.js +11 -121
- package/dist/index4.js +1 -1
- package/dist/index40.js +481 -321
- package/dist/index41.js +42 -481
- package/dist/index42.js +683 -37
- package/dist/index43.js +4 -679
- package/dist/index44.js +4 -4
- package/dist/index45.js +238 -4
- package/dist/index46.js +54 -210
- package/dist/index47.js +16 -81
- package/dist/index48.js +57 -285
- package/dist/index49.js +14 -1501
- package/dist/index5.js +78 -68
- package/dist/index50.js +286 -5
- package/dist/index51.js +4 -4
- package/dist/index52.js +1408 -1467
- package/dist/index53.js +5 -723
- package/dist/index54.js +1112 -21
- package/dist/index55.js +722 -9
- package/dist/index56.js +83 -6
- package/dist/index57.js +245 -7
- package/dist/index58.js +3 -14
- package/dist/index59.js +1230 -17
- package/dist/index6.js +1 -1
- package/dist/index60.js +733 -24
- package/dist/index61.js +21 -84
- package/dist/index62.js +10 -246
- package/dist/index63.js +7 -3
- package/dist/index64.js +7 -1231
- package/dist/index65.js +11 -731
- package/dist/index66.js +17 -1059
- package/dist/index67.js +21 -51
- package/dist/index68.js +54 -3
- package/dist/index69.js +1061 -98
- package/dist/index7.js +108 -96
- package/dist/index70.js +98 -91
- package/dist/index71.js +93 -0
- package/dist/index72.js +6 -0
- package/dist/index8.js +1 -1
- package/dist/index9.js +75 -65
- package/dist/mathematics.css +1 -0
- package/dist/mathematics.css.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +90 -52
package/dist/index32.js
CHANGED
|
@@ -1,268 +1,150 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
icon: "heading3",
|
|
30
|
-
group: "Text",
|
|
31
|
-
keywords: ["h3", "header", "section"],
|
|
32
|
-
shortcut: "⌘⌥3",
|
|
33
|
-
command: ({ editor: e, range: t }) => {
|
|
34
|
-
e.chain().focus().deleteRange(t).setNode("heading", { level: 3 }).run();
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
// Lists group
|
|
38
|
-
{
|
|
39
|
-
title: "Bullet List",
|
|
40
|
-
description: "Create a simple bullet list",
|
|
41
|
-
icon: "bulletList",
|
|
42
|
-
group: "Lists",
|
|
43
|
-
keywords: ["ul", "unordered", "bullets", "points"],
|
|
44
|
-
shortcut: "⌘⇧8",
|
|
45
|
-
command: ({ editor: e, range: t }) => {
|
|
46
|
-
e.chain().focus().deleteRange(t).toggleBulletList().run();
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
title: "Numbered List",
|
|
51
|
-
description: "Create a numbered list",
|
|
52
|
-
icon: "orderedList",
|
|
53
|
-
group: "Lists",
|
|
54
|
-
keywords: ["ol", "ordered", "numbers", "steps"],
|
|
55
|
-
shortcut: "⌘⇧7",
|
|
56
|
-
command: ({ editor: e, range: t }) => {
|
|
57
|
-
e.chain().focus().deleteRange(t).toggleOrderedList().run();
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
title: "Task List",
|
|
62
|
-
description: "Create a task list with checkboxes",
|
|
63
|
-
icon: "taskList",
|
|
64
|
-
group: "Lists",
|
|
65
|
-
keywords: ["todo", "checkbox", "checklist", "tasks"],
|
|
66
|
-
command: ({ editor: e, range: t }) => {
|
|
67
|
-
e.chain().focus().deleteRange(t).toggleTaskList().run();
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
// Blocks group
|
|
71
|
-
{
|
|
72
|
-
title: "Quote",
|
|
73
|
-
description: "Capture a quote",
|
|
74
|
-
icon: "blockquote",
|
|
75
|
-
group: "Blocks",
|
|
76
|
-
keywords: ["blockquote", "citation", "cite"],
|
|
77
|
-
shortcut: "⌘⇧B",
|
|
78
|
-
command: ({ editor: e, range: t }) => {
|
|
79
|
-
e.chain().focus().deleteRange(t).toggleBlockquote().run();
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
title: "Divider",
|
|
84
|
-
description: "Insert a horizontal divider",
|
|
85
|
-
icon: "horizontalRule",
|
|
86
|
-
group: "Blocks",
|
|
87
|
-
keywords: ["hr", "horizontal", "line", "separator", "break"],
|
|
88
|
-
command: ({ editor: e, range: t }) => {
|
|
89
|
-
e.chain().focus().deleteRange(t).setHorizontalRule().run();
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
title: "Details",
|
|
94
|
-
description: "Collapsible content block",
|
|
95
|
-
icon: "details",
|
|
96
|
-
group: "Blocks",
|
|
97
|
-
keywords: ["accordion", "toggle", "collapse", "expand", "summary", "details"],
|
|
98
|
-
command: ({ editor: e, range: t }) => {
|
|
99
|
-
e.can().setDetails?.() && e.chain().focus().deleteRange(t).setDetails().run();
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
title: "Code Block",
|
|
104
|
-
description: "Insert a code snippet",
|
|
105
|
-
icon: "codeBlock",
|
|
106
|
-
group: "Blocks",
|
|
107
|
-
keywords: ["pre", "code", "programming", "syntax", "snippet"],
|
|
108
|
-
shortcut: "⌘⌥C",
|
|
109
|
-
command: ({ editor: e, range: t }) => {
|
|
110
|
-
e.chain().focus().deleteRange(t).toggleCodeBlock().run();
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
title: "Table",
|
|
115
|
-
description: "Insert a table",
|
|
116
|
-
icon: "table",
|
|
117
|
-
group: "Blocks",
|
|
118
|
-
keywords: ["grid", "spreadsheet", "columns", "rows"],
|
|
119
|
-
command: ({ editor: e, range: t }) => {
|
|
120
|
-
e.chain().focus().deleteRange(t).insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run();
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
// Media group
|
|
124
|
-
{
|
|
125
|
-
title: "Image",
|
|
126
|
-
description: "Insert an image from URL",
|
|
127
|
-
icon: "image",
|
|
128
|
-
group: "Media",
|
|
129
|
-
keywords: ["picture", "photo", "img", "url"],
|
|
130
|
-
command: ({ editor: e, range: t }) => {
|
|
131
|
-
const o = window.prompt("Enter image URL:");
|
|
132
|
-
o && e.chain().focus().deleteRange(t).setImage({ src: o }).run();
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
title: "Upload Image",
|
|
137
|
-
description: "Upload an image from your device",
|
|
138
|
-
icon: "imageUpload",
|
|
139
|
-
group: "Media",
|
|
140
|
-
keywords: ["picture", "photo", "upload", "file"],
|
|
141
|
-
command: ({ editor: e, range: t }) => {
|
|
142
|
-
try {
|
|
143
|
-
e.chain().focus().deleteRange(t).run();
|
|
144
|
-
} catch {
|
|
1
|
+
import { PluginKey as S, Plugin as A } from "./index40.js";
|
|
2
|
+
import { DecorationSet as E, Decoration as M } from "./index52.js";
|
|
3
|
+
import { VIZEL_DEFAULT_IMAGE_MAX_FILE_SIZE as _, VIZEL_DEFAULT_FILE_MIME_TYPES as P } from "./index10.js";
|
|
4
|
+
const d = new S("vizel-image-upload"), U = (e) => typeof e == "object" && e !== null && "type" in e && (e.type === "add" || e.type === "remove");
|
|
5
|
+
function T(e) {
|
|
6
|
+
const { placeholderClass: o = "vizel-image-placeholder", imageClass: r = "vizel-image-uploading" } = e;
|
|
7
|
+
return new A({
|
|
8
|
+
key: d,
|
|
9
|
+
state: {
|
|
10
|
+
init() {
|
|
11
|
+
return E.empty;
|
|
12
|
+
},
|
|
13
|
+
apply(t, i) {
|
|
14
|
+
let a = i.map(t.mapping, t.doc);
|
|
15
|
+
const s = t.getMeta(d), n = U(s) ? s : void 0;
|
|
16
|
+
if (n?.type === "add") {
|
|
17
|
+
const { id: l, pos: g, previewSrc: p } = n, c = document.createElement("div");
|
|
18
|
+
c.setAttribute("class", o);
|
|
19
|
+
const u = document.createElement("img");
|
|
20
|
+
u.setAttribute("class", r), u.src = p, c.appendChild(u);
|
|
21
|
+
const m = document.createElement("div");
|
|
22
|
+
m.setAttribute("class", "vizel-image-spinner"), c.appendChild(m);
|
|
23
|
+
const f = M.widget(g, c, { id: l });
|
|
24
|
+
a = a.add(t.doc, [f]);
|
|
25
|
+
} else n?.type === "remove" && (a = a.remove(
|
|
26
|
+
a.find(void 0, void 0, (l) => l.id === n.id)
|
|
27
|
+
));
|
|
28
|
+
return a;
|
|
145
29
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const n = new CustomEvent("vizel:upload-image", {
|
|
151
|
-
detail: { file: i, editor: e }
|
|
152
|
-
});
|
|
153
|
-
document.dispatchEvent(n);
|
|
154
|
-
}
|
|
155
|
-
}, o.click();
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
title: "Embed",
|
|
160
|
-
description: "Embed a URL (YouTube, Twitter, etc.)",
|
|
161
|
-
icon: "embed",
|
|
162
|
-
group: "Media",
|
|
163
|
-
keywords: ["link", "url", "youtube", "video", "twitter", "embed", "iframe", "oembed"],
|
|
164
|
-
command: ({ editor: e, range: t }) => {
|
|
165
|
-
if (!(typeof e.commands.setEmbed == "function")) {
|
|
166
|
-
const n = window.prompt("Enter URL:");
|
|
167
|
-
n && e.chain().focus().deleteRange(t).setLink({ href: n }).run();
|
|
168
|
-
return;
|
|
30
|
+
},
|
|
31
|
+
props: {
|
|
32
|
+
decorations(t) {
|
|
33
|
+
return d.getState(t) ?? E.empty;
|
|
169
34
|
}
|
|
170
|
-
const i = window.prompt("Enter URL to embed:");
|
|
171
|
-
i && e.chain().focus().deleteRange(t).setEmbed({ url: i }).run();
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
// Advanced group
|
|
175
|
-
{
|
|
176
|
-
title: "Math Equation",
|
|
177
|
-
description: "Insert a mathematical expression",
|
|
178
|
-
icon: "mathBlock",
|
|
179
|
-
group: "Advanced",
|
|
180
|
-
keywords: ["latex", "formula", "equation", "katex", "math"],
|
|
181
|
-
command: ({ editor: e, range: t }) => {
|
|
182
|
-
e.can().insertMathBlock?.({ latex: "" }) && e.chain().focus().deleteRange(t).insertMathBlock({ latex: "" }).run();
|
|
183
35
|
}
|
|
184
|
-
}
|
|
185
|
-
{
|
|
186
|
-
title: "Inline Math",
|
|
187
|
-
description: "Insert an inline math expression",
|
|
188
|
-
icon: "mathInline",
|
|
189
|
-
group: "Advanced",
|
|
190
|
-
keywords: ["latex", "formula", "inline", "katex", "math"],
|
|
191
|
-
command: ({ editor: e, range: t }) => {
|
|
192
|
-
e.can().insertMath?.({ latex: "" }) && e.chain().focus().deleteRange(t).insertMath({ latex: "" }).run();
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
title: "Mermaid Diagram",
|
|
197
|
-
description: "Insert a Mermaid diagram",
|
|
198
|
-
icon: "mermaid",
|
|
199
|
-
group: "Advanced",
|
|
200
|
-
keywords: ["diagram", "chart", "flowchart", "mermaid", "sequence", "graph", "uml"],
|
|
201
|
-
command: ({ editor: e, range: t }) => {
|
|
202
|
-
e.can().insertDiagram?.({ code: "" }) && e.chain().focus().deleteRange(t).insertDiagram({ code: "", type: "mermaid" }).run();
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
title: "GraphViz Diagram",
|
|
207
|
-
description: "Insert a GraphViz (DOT) diagram",
|
|
208
|
-
icon: "graphviz",
|
|
209
|
-
group: "Advanced",
|
|
210
|
-
keywords: ["diagram", "graphviz", "dot", "graph", "network", "nodes", "edges"],
|
|
211
|
-
command: ({ editor: e, range: t }) => {
|
|
212
|
-
e.can().insertDiagram?.({ code: "" }) && e.chain().focus().deleteRange(t).insertDiagram({ code: "", type: "graphviz" }).run();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
], u = ["Text", "Lists", "Blocks", "Media", "Advanced"], m = {
|
|
216
|
-
keys: [
|
|
217
|
-
{ name: "title", weight: 0.4 },
|
|
218
|
-
{ name: "description", weight: 0.2 },
|
|
219
|
-
{ name: "keywords", weight: 0.4 }
|
|
220
|
-
],
|
|
221
|
-
threshold: 0.4,
|
|
222
|
-
includeScore: !0,
|
|
223
|
-
includeMatches: !0,
|
|
224
|
-
minMatchCharLength: 1
|
|
225
|
-
}, s = /* @__PURE__ */ new WeakMap();
|
|
226
|
-
function c(e) {
|
|
227
|
-
let t = s.get(e);
|
|
228
|
-
return t || (t = new l(e, m), s.set(e, t)), t;
|
|
36
|
+
});
|
|
229
37
|
}
|
|
230
|
-
function
|
|
231
|
-
|
|
38
|
+
function F(e, o) {
|
|
39
|
+
const r = d.getState(e);
|
|
40
|
+
if (!r)
|
|
41
|
+
return null;
|
|
42
|
+
const t = r.find(void 0, void 0, (i) => i.id === o);
|
|
43
|
+
return t.length > 0 ? t[0]?.from ?? null : null;
|
|
232
44
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
|
|
45
|
+
function x(e, o) {
|
|
46
|
+
const r = o.maxFileSize ?? _, t = o.allowedTypes ?? P;
|
|
47
|
+
if (!t.includes(e.type))
|
|
236
48
|
return {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
49
|
+
type: "invalid_type",
|
|
50
|
+
message: `File type "${e.type}" is not allowed. Allowed types: ${t.join(", ")}`,
|
|
51
|
+
file: e
|
|
52
|
+
};
|
|
53
|
+
if (e.size > r) {
|
|
54
|
+
const i = (r / 1048576).toFixed(1);
|
|
55
|
+
return {
|
|
56
|
+
type: "file_too_large",
|
|
57
|
+
message: `File size (${(e.size / (1024 * 1024)).toFixed(1)}MB) exceeds maximum allowed size (${i}MB)`,
|
|
58
|
+
file: e
|
|
240
59
|
};
|
|
241
|
-
}) : e.map((n) => ({ item: n, score: 0 }));
|
|
242
|
-
}
|
|
243
|
-
function k(e, t = u) {
|
|
244
|
-
const o = /* @__PURE__ */ new Map();
|
|
245
|
-
for (const n of e) {
|
|
246
|
-
const a = n.group ?? "Other", r = o.get(a) ?? [];
|
|
247
|
-
r.push(n), o.set(a, r);
|
|
248
|
-
}
|
|
249
|
-
const i = [];
|
|
250
|
-
for (const n of t) {
|
|
251
|
-
const a = o.get(n);
|
|
252
|
-
a && a.length > 0 && (i.push({ name: n, items: a }), o.delete(n));
|
|
253
60
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function v(e) {
|
|
64
|
+
const { onUpload: o, maxFileSize: r, allowedTypes: t, onValidationError: i, onUploadError: a } = e;
|
|
65
|
+
return (s, n, l) => {
|
|
66
|
+
const g = x(s, {
|
|
67
|
+
...r !== void 0 && { maxFileSize: r },
|
|
68
|
+
...t !== void 0 && { allowedTypes: t }
|
|
69
|
+
});
|
|
70
|
+
if (g) {
|
|
71
|
+
i?.(g);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const p = {}, c = new FileReader();
|
|
75
|
+
c.readAsDataURL(s), c.onload = () => {
|
|
76
|
+
if (typeof c.result != "string") return;
|
|
77
|
+
const u = c.result, m = n.state.tr;
|
|
78
|
+
m.selection.empty || m.deleteSelection(), m.setMeta(d, {
|
|
79
|
+
type: "add",
|
|
80
|
+
id: p,
|
|
81
|
+
pos: l,
|
|
82
|
+
previewSrc: u
|
|
83
|
+
}), n.dispatch(m), o(s).then((f) => {
|
|
84
|
+
const y = F(n.state, p);
|
|
85
|
+
if (y === null)
|
|
86
|
+
return;
|
|
87
|
+
const { schema: h } = n.state, z = h.nodes.image?.create({ src: f });
|
|
88
|
+
if (!z) {
|
|
89
|
+
console.warn("Image node type not found in schema");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const I = n.state.tr.replaceWith(y, y, z).setMeta(d, {
|
|
93
|
+
type: "remove",
|
|
94
|
+
id: p
|
|
95
|
+
});
|
|
96
|
+
n.dispatch(I);
|
|
97
|
+
}).catch((f) => {
|
|
98
|
+
if (a?.(f, s), F(n.state, p) !== null) {
|
|
99
|
+
const h = n.state.tr.setMeta(d, {
|
|
100
|
+
type: "remove",
|
|
101
|
+
id: p
|
|
102
|
+
});
|
|
103
|
+
n.dispatch(h);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function b(e, o, r) {
|
|
110
|
+
const t = o.clipboardData?.files;
|
|
111
|
+
if (!t || t.length === 0)
|
|
112
|
+
return !1;
|
|
113
|
+
const i = Array.from(t).filter((s) => s.type.startsWith("image/"));
|
|
114
|
+
if (i.length === 0)
|
|
115
|
+
return !1;
|
|
116
|
+
o.preventDefault();
|
|
117
|
+
const a = e.state.selection.from;
|
|
118
|
+
for (const s of i)
|
|
119
|
+
r(s, e, a);
|
|
120
|
+
return !0;
|
|
121
|
+
}
|
|
122
|
+
function B(e, o, r, t) {
|
|
123
|
+
if (r)
|
|
124
|
+
return !1;
|
|
125
|
+
const i = o.dataTransfer?.files;
|
|
126
|
+
if (!i || i.length === 0)
|
|
127
|
+
return !1;
|
|
128
|
+
const a = Array.from(i).filter((l) => l.type.startsWith("image/"));
|
|
129
|
+
if (a.length === 0)
|
|
130
|
+
return !1;
|
|
131
|
+
o.preventDefault();
|
|
132
|
+
const n = e.posAtCoords({
|
|
133
|
+
left: o.clientX,
|
|
134
|
+
top: o.clientY
|
|
135
|
+
})?.pos ?? e.state.selection.from;
|
|
136
|
+
for (const l of a)
|
|
137
|
+
t(l, e, n);
|
|
138
|
+
return !0;
|
|
257
139
|
}
|
|
258
|
-
function
|
|
259
|
-
return
|
|
140
|
+
function C() {
|
|
141
|
+
return d;
|
|
260
142
|
}
|
|
261
143
|
export {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
144
|
+
T as createVizelImageUploadPlugin,
|
|
145
|
+
v as createVizelImageUploader,
|
|
146
|
+
C as getVizelImageUploadPluginKey,
|
|
147
|
+
B as handleVizelImageDrop,
|
|
148
|
+
b as handleVizelImagePaste,
|
|
149
|
+
x as validateVizelImageFile
|
|
268
150
|
};
|