@vizel/core 0.0.1-alpha.1 → 0.0.1-alpha.2
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/LICENSE +21 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +141 -141
- package/dist/index10.js +70 -110
- package/dist/index11.js +135 -168
- package/dist/index12.js +83 -74
- package/dist/index13.js +13 -134
- package/dist/index14.js +13 -146
- package/dist/index15.js +303 -15
- package/dist/index16.js +69 -14
- package/dist/index17.js +26 -295
- package/dist/index18.js +2 -2
- package/dist/index19.js +355 -24
- package/dist/index20.js +25 -264
- package/dist/index21.js +85 -68
- package/dist/index22.js +97 -353
- package/dist/index23.js +66 -84
- package/dist/index24.js +12 -36
- package/dist/index25.js +53 -92
- package/dist/index26.js +132 -96
- package/dist/index27.js +59 -126
- package/dist/index28.js +37 -53
- package/dist/index29.js +19 -62
- package/dist/index3.js +165 -60
- package/dist/index30.js +9 -37
- package/dist/index31.js +143 -19
- package/dist/index32.js +264 -11
- package/dist/index33.js +92 -9
- package/dist/index36.js +1 -1
- package/dist/index37.js +41 -57
- package/dist/index38.js +64 -4
- package/dist/index39.js +4 -123
- package/dist/index4.js +10 -86
- package/dist/index40.js +111 -315
- package/dist/index41.js +321 -481
- package/dist/index42.js +481 -42
- package/dist/index43.js +143 -138
- package/dist/index44.js +1 -1
- package/dist/index45.js +1 -1
- package/dist/index46.js +1 -1
- package/dist/index48.js +3 -3
- package/dist/index49.js +158 -1458
- package/dist/index5.js +132 -10
- package/dist/index50.js +1561 -5
- package/dist/index51.js +1408 -1467
- package/dist/index52.js +704 -183
- package/dist/index53.js +5 -723
- package/dist/index6.js +48 -131
- package/dist/index61.js +1 -1
- package/dist/index62.js +1 -1
- package/dist/index65.js +1 -1
- package/dist/index66.js +53 -1059
- package/dist/index67.js +1059 -53
- package/dist/index69.js +90 -3
- package/dist/index7.js +228 -409
- package/dist/index70.js +3 -90
- package/dist/index8.js +111 -45
- package/dist/index9.js +409 -228
- package/package.json +54 -80
package/dist/index23.js
CHANGED
|
@@ -1,87 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
addAttributes() {
|
|
17
|
-
return {
|
|
18
|
-
...this.parent?.(),
|
|
19
|
-
width: {
|
|
20
|
-
default: null,
|
|
21
|
-
parseHTML: (n) => {
|
|
22
|
-
const s = n.getAttribute("width") || n.style.width;
|
|
23
|
-
return s ? Number.parseInt(s, 10) : null;
|
|
24
|
-
},
|
|
25
|
-
renderHTML: (n) => n.width ? { width: n.width } : {}
|
|
26
|
-
},
|
|
27
|
-
height: {
|
|
28
|
-
default: null,
|
|
29
|
-
parseHTML: (n) => {
|
|
30
|
-
const s = n.getAttribute("height") || n.style.height;
|
|
31
|
-
return s ? Number.parseInt(s, 10) : null;
|
|
32
|
-
},
|
|
33
|
-
renderHTML: (n) => n.height ? { height: n.height } : {}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
addNodeView() {
|
|
38
|
-
return ({ node: n, editor: s, getPos: m }) => {
|
|
39
|
-
const { minWidth: b = 100, maxWidth: E } = this.options, r = document.createElement("div");
|
|
40
|
-
r.setAttribute("data-resize-wrapper", "true");
|
|
41
|
-
const t = document.createElement("img");
|
|
42
|
-
t.src = n.attrs.src, t.alt = n.attrs.alt || "", t.title = n.attrs.title || "", t.className = "vizel-image", t.draggable = !1, n.attrs.width && (t.style.width = `${n.attrs.width}px`, t.style.height = "auto"), r.appendChild(t);
|
|
43
|
-
const i = document.createElement("div");
|
|
44
|
-
i.setAttribute("data-resize-handle", "left"), i.contentEditable = "false", i.style.position = "absolute", i.style.left = "4px", i.style.top = "50%", i.style.transform = "translateY(-50%)";
|
|
45
|
-
const o = document.createElement("div");
|
|
46
|
-
o.setAttribute("data-resize-handle", "right"), o.contentEditable = "false", o.style.position = "absolute", o.style.right = "4px", o.style.top = "50%", o.style.transform = "translateY(-50%)";
|
|
47
|
-
const l = document.createElement("div");
|
|
48
|
-
l.setAttribute("data-resize-tooltip", "true"), l.style.position = "absolute", l.style.display = "none", r.appendChild(i), r.appendChild(o), r.appendChild(l);
|
|
49
|
-
let u = 0, p = 0, d = !1, f = "right";
|
|
50
|
-
const g = (e, a) => {
|
|
51
|
-
l.textContent = `${Math.round(e)} × ${Math.round(a)}`;
|
|
52
|
-
}, M = () => {
|
|
53
|
-
l.style.display = "block", g(t.offsetWidth, t.offsetHeight);
|
|
54
|
-
}, L = () => {
|
|
55
|
-
l.style.display = "none";
|
|
56
|
-
}, y = (e, a) => {
|
|
57
|
-
e.preventDefault(), e.stopPropagation(), s.isEditable && (d = !0, f = a, u = e.clientX, p = t.offsetWidth, M(), document.addEventListener("mousemove", h), document.addEventListener("mouseup", c), document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none");
|
|
58
|
-
}, h = (e) => {
|
|
59
|
-
if (!d) return;
|
|
60
|
-
const a = f === "right" ? e.clientX - u : u - e.clientX, W = r.parentElement?.clientWidth ?? Number.POSITIVE_INFINITY, z = Math.min(E ?? W, Math.max(b, p + a));
|
|
61
|
-
t.style.width = `${z}px`, t.style.height = "auto", g(t.offsetWidth, t.offsetHeight);
|
|
62
|
-
}, c = () => {
|
|
63
|
-
if (!d) return;
|
|
64
|
-
if (d = !1, L(), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c), document.body.style.cursor = "", document.body.style.userSelect = "", (typeof m == "function" ? m() : null) != null && s.isEditable) {
|
|
65
|
-
const a = Math.round(t.offsetWidth);
|
|
66
|
-
s.commands.updateAttributes("image", {
|
|
67
|
-
width: a,
|
|
68
|
-
height: null
|
|
69
|
-
// Clear height to use auto
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}, w = (e) => y(e, "left"), v = (e) => y(e, "right");
|
|
73
|
-
return i.addEventListener("mousedown", w), o.addEventListener("mousedown", v), {
|
|
74
|
-
dom: r,
|
|
75
|
-
contentDOM: null,
|
|
76
|
-
update: (e) => e.type.name !== "image" ? !1 : (t.src = e.attrs.src, t.alt = e.attrs.alt || "", t.title = e.attrs.title || "", e.attrs.width ? (t.style.width = `${e.attrs.width}px`, t.style.height = "auto") : (t.style.width = "", t.style.height = ""), !0),
|
|
77
|
-
destroy: () => {
|
|
78
|
-
i.removeEventListener("mousedown", w), o.removeEventListener("mousedown", v), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
};
|
|
1
|
+
const a = "system", d = "vizel-theme", i = "data-vizel-theme";
|
|
2
|
+
function c() {
|
|
3
|
+
return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
4
|
+
}
|
|
5
|
+
function m(t, e) {
|
|
6
|
+
return t === "system" ? e : t;
|
|
7
|
+
}
|
|
8
|
+
function s(t) {
|
|
9
|
+
if (typeof window > "u")
|
|
10
|
+
return null;
|
|
11
|
+
try {
|
|
12
|
+
const e = localStorage.getItem(t);
|
|
13
|
+
if (e === "light" || e === "dark" || e === "system")
|
|
14
|
+
return e;
|
|
15
|
+
} catch {
|
|
82
16
|
}
|
|
83
|
-
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
function u(t, e) {
|
|
20
|
+
if (!(typeof window > "u"))
|
|
21
|
+
try {
|
|
22
|
+
localStorage.setItem(t, e);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function l(t, e, n) {
|
|
27
|
+
if (typeof document > "u")
|
|
28
|
+
return;
|
|
29
|
+
const r = e ? document.querySelector(e) : document.documentElement;
|
|
30
|
+
if (r) {
|
|
31
|
+
if (n) {
|
|
32
|
+
const o = document.createElement("style");
|
|
33
|
+
o.appendChild(
|
|
34
|
+
document.createTextNode(
|
|
35
|
+
"*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"
|
|
36
|
+
)
|
|
37
|
+
), document.head.appendChild(o), window.getComputedStyle(document.body), setTimeout(() => {
|
|
38
|
+
document.head.removeChild(o);
|
|
39
|
+
}, 1);
|
|
40
|
+
}
|
|
41
|
+
r.setAttribute(i, t);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function h(t) {
|
|
45
|
+
if (typeof window > "u")
|
|
46
|
+
return () => {
|
|
47
|
+
};
|
|
48
|
+
const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (r) => {
|
|
49
|
+
t(r.matches ? "dark" : "light");
|
|
50
|
+
};
|
|
51
|
+
return e.addEventListener("change", n), () => {
|
|
52
|
+
e.removeEventListener("change", n);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function f(t = d) {
|
|
56
|
+
return `(function(){try{var s=localStorage.getItem('${t}');var d=window.matchMedia('(prefers-color-scheme: dark)').matches;var t=s==='dark'?'dark':s==='light'?'light':d?'dark':'light';document.documentElement.setAttribute('${i}',t)}catch(e){}})()`;
|
|
57
|
+
}
|
|
84
58
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
59
|
+
a as VIZEL_DEFAULT_THEME,
|
|
60
|
+
d as VIZEL_DEFAULT_THEME_STORAGE_KEY,
|
|
61
|
+
i as VIZEL_THEME_DATA_ATTRIBUTE,
|
|
62
|
+
l as applyVizelTheme,
|
|
63
|
+
h as createVizelSystemThemeListener,
|
|
64
|
+
s as getStoredVizelTheme,
|
|
65
|
+
c as getVizelSystemTheme,
|
|
66
|
+
f as getVizelThemeInitScript,
|
|
67
|
+
m as resolveVizelTheme,
|
|
68
|
+
u as storeVizelTheme
|
|
87
69
|
};
|
package/dist/index24.js
CHANGED
|
@@ -1,39 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
items: m,
|
|
10
|
-
suggestion: {
|
|
11
|
-
char: "/",
|
|
12
|
-
startOfLine: !1
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
addProseMirrorPlugins() {
|
|
17
|
-
return [
|
|
18
|
-
e({
|
|
19
|
-
editor: this.editor,
|
|
20
|
-
char: this.options.suggestion?.char ?? "/",
|
|
21
|
-
startOfLine: this.options.suggestion?.startOfLine ?? !1,
|
|
22
|
-
items: ({ query: s }) => i(this.options.items ?? [], s),
|
|
23
|
-
command: ({ editor: s, range: t, props: o }) => {
|
|
24
|
-
n(o) && o.command({ editor: s, range: t });
|
|
25
|
-
},
|
|
26
|
-
...this.options.suggestion
|
|
27
|
-
})
|
|
28
|
-
];
|
|
1
|
+
function s(t) {
|
|
2
|
+
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t);
|
|
3
|
+
}
|
|
4
|
+
function a(t) {
|
|
5
|
+
const e = t.trim(), r = e.startsWith("#") ? e : `#${e}`;
|
|
6
|
+
if (r.length === 4) {
|
|
7
|
+
const [, o, i, n] = r;
|
|
8
|
+
return `#${o}${o}${i}${i}${n}${n}`.toUpperCase();
|
|
29
9
|
}
|
|
30
|
-
|
|
10
|
+
return r.toUpperCase();
|
|
11
|
+
}
|
|
31
12
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
p as flattenVizelSlashCommandGroups,
|
|
35
|
-
g as groupVizelSlashCommands,
|
|
36
|
-
C as searchVizelSlashCommands,
|
|
37
|
-
S as vizelDefaultGroupOrder,
|
|
38
|
-
m as vizelDefaultSlashCommands
|
|
13
|
+
s as isVizelValidHexColor,
|
|
14
|
+
a as normalizeVizelHexColor
|
|
39
15
|
};
|
package/dist/index25.js
CHANGED
|
@@ -1,95 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Editor as E } from "@tiptap/core";
|
|
2
|
+
import { createVizelExtensions as w } from "./index3.js";
|
|
3
|
+
import { resolveVizelFeatures as D, vizelDefaultEditorProps as V } from "./index26.js";
|
|
4
|
+
import { initializeVizelMarkdownContent as F } from "./index27.js";
|
|
5
|
+
function y(f) {
|
|
6
|
+
const {
|
|
7
|
+
initialContent: o,
|
|
8
|
+
initialMarkdown: t,
|
|
9
|
+
transformDiagramsOnImport: p = !0,
|
|
10
|
+
placeholder: r,
|
|
11
|
+
editable: v = !0,
|
|
12
|
+
autofocus: z = !1,
|
|
13
|
+
features: e,
|
|
14
|
+
extensions: g = [],
|
|
15
|
+
createSlashMenuRenderer: x,
|
|
16
|
+
onUpdate: n,
|
|
17
|
+
onCreate: i,
|
|
18
|
+
onDestroy: a,
|
|
19
|
+
onSelectionUpdate: s,
|
|
20
|
+
onFocus: d,
|
|
21
|
+
onBlur: l
|
|
22
|
+
} = f, c = D({
|
|
23
|
+
...e !== void 0 && { features: e },
|
|
24
|
+
createSlashMenuRenderer: x
|
|
25
|
+
}), C = typeof e?.image == "object" ? e.image : {}, m = t ? (u) => {
|
|
26
|
+
F(u.editor, t, {
|
|
27
|
+
transformDiagrams: p
|
|
28
|
+
}), i?.(u);
|
|
29
|
+
} : i;
|
|
30
|
+
return {
|
|
31
|
+
editor: new E({
|
|
32
|
+
extensions: [
|
|
33
|
+
...w({
|
|
34
|
+
...r !== void 0 && { placeholder: r },
|
|
35
|
+
...c !== void 0 && { features: c }
|
|
36
|
+
}),
|
|
37
|
+
...g
|
|
38
|
+
],
|
|
39
|
+
// Only set initialContent if initialMarkdown is not provided
|
|
40
|
+
...!t && o !== void 0 && { content: o },
|
|
41
|
+
editable: v,
|
|
42
|
+
autofocus: z,
|
|
43
|
+
editorProps: V,
|
|
44
|
+
...n && { onUpdate: n },
|
|
45
|
+
...m && { onCreate: m },
|
|
46
|
+
...a && { onDestroy: a },
|
|
47
|
+
...s && { onSelectionUpdate: s },
|
|
48
|
+
...d && { onFocus: d },
|
|
49
|
+
...l && { onBlur: l }
|
|
50
|
+
}),
|
|
51
|
+
imageOptions: C
|
|
52
|
+
};
|
|
4
53
|
}
|
|
5
|
-
function f(t, e) {
|
|
6
|
-
return t.length > 0 ? [e.createNode("paragraph", void 0, t)] : [e.createNode("paragraph")];
|
|
7
|
-
}
|
|
8
|
-
function x(t, e) {
|
|
9
|
-
const { header: l, align: r, rows: s } = t, a = l.map((n, i) => {
|
|
10
|
-
const o = g(n, e), c = r[i] ? { textAlign: r[i] } : void 0;
|
|
11
|
-
return e.createNode("tableHeader", c, f(o, e));
|
|
12
|
-
}), d = e.createNode("tableRow", void 0, a), u = s.map((n) => {
|
|
13
|
-
const i = n.map((o, c) => {
|
|
14
|
-
const m = g(o, e), p = r[c] ? { textAlign: r[c] } : void 0;
|
|
15
|
-
return e.createNode("tableCell", p, f(m, e));
|
|
16
|
-
});
|
|
17
|
-
return e.createNode("tableRow", void 0, i);
|
|
18
|
-
});
|
|
19
|
-
return e.createNode("table", void 0, [d, ...u]);
|
|
20
|
-
}
|
|
21
|
-
function b(t, e) {
|
|
22
|
-
if (!t.content || t.content.length === 0)
|
|
23
|
-
return "";
|
|
24
|
-
const l = t.content, r = l[0];
|
|
25
|
-
if (!r?.content)
|
|
26
|
-
return "";
|
|
27
|
-
const s = r.content.map(
|
|
28
|
-
(n) => n.attrs?.textAlign || null
|
|
29
|
-
), a = l.map((n) => n.content ? `| ${n.content.map((o) => (o.content ? e.renderChildren(o.content, "") : "").replace(/\n/g, " ").trim()).join(" | ")} |` : "|"), u = `| ${s.map((n) => {
|
|
30
|
-
switch (n) {
|
|
31
|
-
case "left":
|
|
32
|
-
return ":---";
|
|
33
|
-
case "center":
|
|
34
|
-
return ":---:";
|
|
35
|
-
case "right":
|
|
36
|
-
return "---:";
|
|
37
|
-
default:
|
|
38
|
-
return "---";
|
|
39
|
-
}
|
|
40
|
-
}).join(" | ")} |`;
|
|
41
|
-
return a.length > 0 ? [a[0], u, ...a.slice(1)].join(`
|
|
42
|
-
`) : a.join(`
|
|
43
|
-
`);
|
|
44
|
-
}
|
|
45
|
-
const C = w.extend({
|
|
46
|
-
// Register markdown name for token matching
|
|
47
|
-
name: "table",
|
|
48
|
-
addStorage() {
|
|
49
|
-
return {
|
|
50
|
-
...this.parent?.(),
|
|
51
|
-
// Mark this extension as markdown-aware
|
|
52
|
-
markdown: {
|
|
53
|
-
parse: x,
|
|
54
|
-
serialize: b
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
// Add markdown parsing support
|
|
59
|
-
// @ts-expect-error - parseMarkdown is a @tiptap/markdown extension point
|
|
60
|
-
parseMarkdown(t, e) {
|
|
61
|
-
return t.type !== "table" ? null : x(t, e);
|
|
62
|
-
},
|
|
63
|
-
// Add markdown rendering support
|
|
64
|
-
// @ts-expect-error - renderMarkdown is a @tiptap/markdown extension point
|
|
65
|
-
renderMarkdown(t, e, l) {
|
|
66
|
-
return b(t, e);
|
|
67
|
-
}
|
|
68
|
-
}), M = A.extend({
|
|
69
|
-
addAttributes() {
|
|
70
|
-
return {
|
|
71
|
-
...this.parent?.(),
|
|
72
|
-
textAlign: {
|
|
73
|
-
default: null,
|
|
74
|
-
parseHTML: (t) => t.style.textAlign || null,
|
|
75
|
-
renderHTML: (t) => t.textAlign ? { style: `text-align: ${t.textAlign}` } : {}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}), N = T.extend({
|
|
80
|
-
addAttributes() {
|
|
81
|
-
return {
|
|
82
|
-
...this.parent?.(),
|
|
83
|
-
textAlign: {
|
|
84
|
-
default: null,
|
|
85
|
-
parseHTML: (t) => t.style.textAlign || null,
|
|
86
|
-
renderHTML: (t) => t.textAlign ? { style: `text-align: ${t.textAlign}` } : {}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
54
|
export {
|
|
92
|
-
|
|
93
|
-
M as VizelTableCell,
|
|
94
|
-
N as VizelTableHeader
|
|
55
|
+
y as createVizelEditorInstance
|
|
95
56
|
};
|
package/dist/index26.js
CHANGED
|
@@ -1,104 +1,140 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
bold: "lucide:bold",
|
|
49
|
-
italic: "lucide:italic",
|
|
50
|
-
strikethrough: "lucide:strikethrough",
|
|
51
|
-
underline: "lucide:underline",
|
|
52
|
-
code: "lucide:code",
|
|
53
|
-
link: "lucide:link",
|
|
54
|
-
textColor: "lucide:baseline",
|
|
55
|
-
highlighter: "lucide:highlighter",
|
|
56
|
-
// Internal (NodeView rendering)
|
|
57
|
-
grip: "lucide:grip-vertical",
|
|
58
|
-
plusSmall: "lucide:plus",
|
|
59
|
-
listOrdered: "lucide:list-ordered"
|
|
60
|
-
};
|
|
61
|
-
function k(e, i) {
|
|
62
|
-
return i?.[e] ?? u[e];
|
|
1
|
+
import "@tiptap/core";
|
|
2
|
+
import "./index37.js";
|
|
3
|
+
import "@tiptap/extension-image";
|
|
4
|
+
import { createVizelImageUploader as p } from "./index31.js";
|
|
5
|
+
import "./index12.js";
|
|
6
|
+
function V(e) {
|
|
7
|
+
const { features: t, createSlashMenuRenderer: a } = e;
|
|
8
|
+
if (!t)
|
|
9
|
+
return {
|
|
10
|
+
slashCommand: {
|
|
11
|
+
suggestion: a()
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
if (t.slashCommand === !1)
|
|
15
|
+
return t;
|
|
16
|
+
const o = typeof t.slashCommand == "object" ? t.slashCommand : {};
|
|
17
|
+
return o.suggestion ? t : {
|
|
18
|
+
...t,
|
|
19
|
+
slashCommand: {
|
|
20
|
+
...o,
|
|
21
|
+
suggestion: a()
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const f = (e) => e instanceof CustomEvent && typeof e.detail == "object" && e.detail !== null && "file" in e.detail && "editor" in e.detail;
|
|
26
|
+
function g(e) {
|
|
27
|
+
return (t) => {
|
|
28
|
+
const a = e.getEditor();
|
|
29
|
+
if (!a || !f(t)) return;
|
|
30
|
+
const { file: o } = t.detail, n = a.state.selection.from, r = e.getImageOptions();
|
|
31
|
+
p({
|
|
32
|
+
onUpload: r.onUpload ?? ((i) => new Promise((l) => {
|
|
33
|
+
const s = new FileReader();
|
|
34
|
+
s.onload = () => {
|
|
35
|
+
typeof s.result == "string" && l(s.result);
|
|
36
|
+
}, s.readAsDataURL(i);
|
|
37
|
+
})),
|
|
38
|
+
...r.maxFileSize !== void 0 && { maxFileSize: r.maxFileSize },
|
|
39
|
+
...r.allowedTypes !== void 0 && { allowedTypes: r.allowedTypes },
|
|
40
|
+
...r.onValidationError !== void 0 && {
|
|
41
|
+
onValidationError: r.onValidationError
|
|
42
|
+
},
|
|
43
|
+
...r.onUploadError !== void 0 && {
|
|
44
|
+
onUploadError: r.onUploadError
|
|
45
|
+
}
|
|
46
|
+
})(o, a.view, n);
|
|
47
|
+
};
|
|
63
48
|
}
|
|
64
|
-
|
|
49
|
+
const u = "vizel:upload-image";
|
|
65
50
|
function w(e) {
|
|
66
|
-
t = e;
|
|
51
|
+
const t = g(e);
|
|
52
|
+
return document.addEventListener(u, t), () => {
|
|
53
|
+
document.removeEventListener(u, t);
|
|
54
|
+
};
|
|
67
55
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
56
|
+
const F = {
|
|
57
|
+
attributes: {
|
|
58
|
+
class: "vizel-editor"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function h(e) {
|
|
62
|
+
return "characterCount" in e && typeof e.characterCount == "object" && e.characterCount !== null && "characters" in e.characterCount && "words" in e.characterCount;
|
|
72
63
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
64
|
+
function A(e) {
|
|
65
|
+
if (!e)
|
|
66
|
+
return {
|
|
67
|
+
isFocused: !1,
|
|
68
|
+
isEmpty: !0,
|
|
69
|
+
canUndo: !1,
|
|
70
|
+
canRedo: !1,
|
|
71
|
+
characterCount: 0,
|
|
72
|
+
wordCount: 0
|
|
73
|
+
};
|
|
74
|
+
const t = e.storage;
|
|
75
|
+
let a = 0, o = 0;
|
|
76
|
+
return h(t) && (a = t.characterCount.characters(), o = t.characterCount.words()), {
|
|
77
|
+
isFocused: e.isFocused,
|
|
78
|
+
isEmpty: e.isEmpty,
|
|
79
|
+
canUndo: e.can().undo(),
|
|
80
|
+
canRedo: e.can().redo(),
|
|
81
|
+
characterCount: a,
|
|
82
|
+
wordCount: o
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const d = {
|
|
86
|
+
mermaid: "mermaid",
|
|
87
|
+
dot: "graphviz",
|
|
88
|
+
graphviz: "graphviz"
|
|
89
|
+
};
|
|
90
|
+
function E(e) {
|
|
91
|
+
if (!e) return e;
|
|
92
|
+
const t = e.attrs?.language;
|
|
93
|
+
return e.type === "codeBlock" && t && t in d ? {
|
|
94
|
+
type: "diagram",
|
|
95
|
+
attrs: {
|
|
96
|
+
code: e.content?.map((o) => o.text || "").join("").trim() || "",
|
|
97
|
+
type: d[t]
|
|
98
|
+
}
|
|
99
|
+
} : e.content && Array.isArray(e.content) ? {
|
|
100
|
+
...e,
|
|
101
|
+
content: e.content.map(E)
|
|
102
|
+
} : e;
|
|
93
103
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
104
|
+
function S(e) {
|
|
105
|
+
const t = e.schema.nodes.diagram;
|
|
106
|
+
if (!t) return;
|
|
107
|
+
const a = [];
|
|
108
|
+
if (e.state.doc.descendants((n, r) => {
|
|
109
|
+
if (n.type.name === "codeBlock") {
|
|
110
|
+
const c = n.attrs.language, i = c ? d[c] : void 0;
|
|
111
|
+
i && a.push({
|
|
112
|
+
from: r,
|
|
113
|
+
to: r + n.nodeSize,
|
|
114
|
+
code: n.textContent.trim(),
|
|
115
|
+
type: i
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}), a.length === 0) return;
|
|
119
|
+
let { tr: o } = e.state;
|
|
120
|
+
for (let n = a.length - 1; n >= 0; n--) {
|
|
121
|
+
const r = a[n];
|
|
122
|
+
if (!r) continue;
|
|
123
|
+
const { from: c, to: i, code: l, type: s } = r, m = t.create({
|
|
124
|
+
code: l,
|
|
125
|
+
type: s
|
|
126
|
+
});
|
|
127
|
+
o = o.replaceWith(c, i, m);
|
|
128
|
+
}
|
|
129
|
+
e.view.dispatch(o);
|
|
96
130
|
}
|
|
97
131
|
export {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
w as
|
|
103
|
-
|
|
132
|
+
u as VIZEL_UPLOAD_IMAGE_EVENT,
|
|
133
|
+
S as convertVizelCodeBlocksToDiagrams,
|
|
134
|
+
g as createVizelUploadEventHandler,
|
|
135
|
+
A as getVizelEditorState,
|
|
136
|
+
w as registerVizelUploadEventHandler,
|
|
137
|
+
V as resolveVizelFeatures,
|
|
138
|
+
E as transformVizelDiagramCodeBlocks,
|
|
139
|
+
F as vizelDefaultEditorProps
|
|
104
140
|
};
|