@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.
- package/README.md +44 -0
- package/dist/components.css +1 -0
- package/dist/components.css.map +1 -0
- package/dist/index.d.ts +2642 -0
- package/dist/index.js +150 -0
- package/dist/index10.js +118 -0
- package/dist/index11.js +174 -0
- package/dist/index12.js +78 -0
- package/dist/index13.js +141 -0
- package/dist/index14.js +150 -0
- package/dist/index15.js +20 -0
- package/dist/index16.js +17 -0
- package/dist/index17.js +308 -0
- package/dist/index18.js +52 -0
- package/dist/index19.js +29 -0
- package/dist/index2.js +93 -0
- package/dist/index20.js +268 -0
- package/dist/index21.js +72 -0
- package/dist/index22.js +360 -0
- package/dist/index23.js +87 -0
- package/dist/index24.js +39 -0
- package/dist/index25.js +95 -0
- package/dist/index26.js +104 -0
- package/dist/index27.js +136 -0
- package/dist/index28.js +56 -0
- package/dist/index29.js +69 -0
- package/dist/index3.js +69 -0
- package/dist/index30.js +40 -0
- package/dist/index31.js +26 -0
- package/dist/index32.js +15 -0
- package/dist/index33.js +12 -0
- package/dist/index34.js +19 -0
- package/dist/index35.js +60 -0
- package/dist/index36.js +17 -0
- package/dist/index37.js +66 -0
- package/dist/index38.js +6 -0
- package/dist/index39.js +125 -0
- package/dist/index4.js +89 -0
- package/dist/index40.js +329 -0
- package/dist/index41.js +489 -0
- package/dist/index42.js +50 -0
- package/dist/index43.js +676 -0
- package/dist/index44.js +6 -0
- package/dist/index45.js +6 -0
- package/dist/index46.js +240 -0
- package/dist/index47.js +84 -0
- package/dist/index48.js +288 -0
- package/dist/index49.js +1504 -0
- package/dist/index5.js +13 -0
- package/dist/index50.js +7 -0
- package/dist/index51.js +1563 -0
- package/dist/index52.js +204 -0
- package/dist/index53.js +725 -0
- package/dist/index54.js +23 -0
- package/dist/index55.js +12 -0
- package/dist/index56.js +9 -0
- package/dist/index57.js +10 -0
- package/dist/index58.js +16 -0
- package/dist/index59.js +21 -0
- package/dist/index6.js +135 -0
- package/dist/index60.js +27 -0
- package/dist/index61.js +86 -0
- package/dist/index62.js +248 -0
- package/dist/index63.js +1234 -0
- package/dist/index64.js +736 -0
- package/dist/index65.js +5 -0
- package/dist/index66.js +1063 -0
- package/dist/index67.js +57 -0
- package/dist/index68.js +100 -0
- package/dist/index69.js +6 -0
- package/dist/index7.js +456 -0
- package/dist/index70.js +93 -0
- package/dist/index8.js +52 -0
- package/dist/index9.js +275 -0
- package/dist/styles.css +1 -0
- package/dist/styles.css.map +1 -0
- package/package.json +109 -0
package/dist/index14.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { PluginKey as S, Plugin as A } from "./index41.js";
|
|
2
|
+
import { DecorationSet as E, Decoration as M } from "./index49.js";
|
|
3
|
+
import { VIZEL_DEFAULT_IMAGE_MAX_FILE_SIZE as _, VIZEL_DEFAULT_FILE_MIME_TYPES as P } from "./index12.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;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
props: {
|
|
32
|
+
decorations(t) {
|
|
33
|
+
return d.getState(t) ?? E.empty;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
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;
|
|
44
|
+
}
|
|
45
|
+
function x(e, o) {
|
|
46
|
+
const r = o.maxFileSize ?? _, t = o.allowedTypes ?? P;
|
|
47
|
+
if (!t.includes(e.type))
|
|
48
|
+
return {
|
|
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
|
|
59
|
+
};
|
|
60
|
+
}
|
|
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;
|
|
139
|
+
}
|
|
140
|
+
function C() {
|
|
141
|
+
return d;
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
T as createVizelImageUploadPlugin,
|
|
145
|
+
v as createVizelImageUploader,
|
|
146
|
+
C as getVizelImageUploadPluginKey,
|
|
147
|
+
B as handleVizelImageDrop,
|
|
148
|
+
b as handleVizelImagePaste,
|
|
149
|
+
x as validateVizelImageFile
|
|
150
|
+
};
|
package/dist/index15.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import t from "@tiptap/extension-link";
|
|
2
|
+
import { default as i } from "@tiptap/extension-link";
|
|
3
|
+
function n(e = {}) {
|
|
4
|
+
return t.configure({
|
|
5
|
+
openOnClick: e.openOnClick ?? !0,
|
|
6
|
+
autolink: e.autolink ?? !0,
|
|
7
|
+
linkOnPaste: e.linkOnPaste ?? !0,
|
|
8
|
+
defaultProtocol: e.defaultProtocol ?? "https",
|
|
9
|
+
HTMLAttributes: {
|
|
10
|
+
class: "vizel-link",
|
|
11
|
+
rel: "noopener noreferrer nofollow",
|
|
12
|
+
target: "_blank",
|
|
13
|
+
...e.HTMLAttributes
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
i as Link,
|
|
19
|
+
n as createVizelLinkExtension
|
|
20
|
+
};
|
package/dist/index16.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Markdown as a } from "./index43.js";
|
|
2
|
+
function i(n = {}) {
|
|
3
|
+
const { indentation: e = { style: "space", size: 2 }, gfm: o = !0, breaks: t = !1 } = n, r = {
|
|
4
|
+
gfm: o,
|
|
5
|
+
breaks: t
|
|
6
|
+
};
|
|
7
|
+
return a.configure({
|
|
8
|
+
indentation: e,
|
|
9
|
+
markedOptions: r
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const c = i();
|
|
13
|
+
export {
|
|
14
|
+
a as TiptapMarkdown,
|
|
15
|
+
c as VizelMarkdown,
|
|
16
|
+
i as createVizelMarkdownExtension
|
|
17
|
+
};
|
package/dist/index17.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { Node as v, mergeAttributes as y, InputRule as k } from "@tiptap/core";
|
|
2
|
+
import L from "katex";
|
|
3
|
+
import { default as H } from "katex";
|
|
4
|
+
function f(t, r, o) {
|
|
5
|
+
try {
|
|
6
|
+
return { html: L.renderToString(t, {
|
|
7
|
+
displayMode: r,
|
|
8
|
+
throwOnError: !1,
|
|
9
|
+
strict: !1,
|
|
10
|
+
trust: !1,
|
|
11
|
+
...o
|
|
12
|
+
}), error: null };
|
|
13
|
+
} catch (a) {
|
|
14
|
+
const l = a instanceof Error ? a.message : "Invalid LaTeX";
|
|
15
|
+
return {
|
|
16
|
+
html: `<span class="vizel-math-error">${l}</span>`,
|
|
17
|
+
error: l
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const E = /\$([^$\n]+)\$$/, b = /\$\$([^$]+)\$\$$/;
|
|
22
|
+
function x(t) {
|
|
23
|
+
return new k({
|
|
24
|
+
find: t.find,
|
|
25
|
+
handler: ({ state: r, range: o, match: a }) => {
|
|
26
|
+
const l = t.getAttributes?.(a) ?? {}, { tr: n } = r, s = t.type.create(l);
|
|
27
|
+
n.replaceWith(o.from, o.to, s);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const z = {
|
|
32
|
+
name: "mathInline",
|
|
33
|
+
start: "$",
|
|
34
|
+
tokenize(t) {
|
|
35
|
+
const r = t.match(/^\$([^$\n]+?)\$/);
|
|
36
|
+
if (r?.[1])
|
|
37
|
+
return {
|
|
38
|
+
type: "mathInline",
|
|
39
|
+
raw: r[0],
|
|
40
|
+
latex: r[1]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}, g = {
|
|
44
|
+
name: "mathBlock",
|
|
45
|
+
start: "$$",
|
|
46
|
+
tokenize(t) {
|
|
47
|
+
const r = t.match(/^\$\$([\s\S]+?)\$\$/);
|
|
48
|
+
if (r?.[1])
|
|
49
|
+
return {
|
|
50
|
+
type: "mathBlock",
|
|
51
|
+
raw: r[0],
|
|
52
|
+
latex: r[1].trim()
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, $ = v.create({
|
|
56
|
+
name: "mathInline",
|
|
57
|
+
group: "inline",
|
|
58
|
+
inline: !0,
|
|
59
|
+
atom: !0,
|
|
60
|
+
selectable: !0,
|
|
61
|
+
draggable: !1,
|
|
62
|
+
addOptions() {
|
|
63
|
+
return {
|
|
64
|
+
katexOptions: {},
|
|
65
|
+
inlineInputRules: !0,
|
|
66
|
+
blockInputRules: !0
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
addAttributes() {
|
|
70
|
+
return {
|
|
71
|
+
latex: {
|
|
72
|
+
default: "",
|
|
73
|
+
parseHTML: (t) => t.getAttribute("data-latex") || "",
|
|
74
|
+
renderHTML: (t) => ({
|
|
75
|
+
"data-latex": t.latex
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
parseHTML() {
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
tag: 'span[data-type="math-inline"]'
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
},
|
|
87
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
88
|
+
return [
|
|
89
|
+
"span",
|
|
90
|
+
y(t, {
|
|
91
|
+
"data-type": "math-inline",
|
|
92
|
+
class: "vizel-math vizel-math-inline"
|
|
93
|
+
})
|
|
94
|
+
];
|
|
95
|
+
},
|
|
96
|
+
addNodeView() {
|
|
97
|
+
return ({ node: t, getPos: r, editor: o }) => {
|
|
98
|
+
const a = document.createElement("span");
|
|
99
|
+
a.classList.add("vizel-math", "vizel-math-inline"), a.setAttribute("data-type", "math-inline"), a.setAttribute("contenteditable", "false");
|
|
100
|
+
const l = document.createElement("span");
|
|
101
|
+
l.classList.add("vizel-math-render"), a.appendChild(l);
|
|
102
|
+
const n = document.createElement("input");
|
|
103
|
+
n.type = "text", n.classList.add("vizel-math-input"), n.value = t.attrs.latex, n.style.display = "none", a.appendChild(n);
|
|
104
|
+
let s = !1;
|
|
105
|
+
const c = (e) => {
|
|
106
|
+
const { html: i } = f(e, !1, this.options.katexOptions);
|
|
107
|
+
l.innerHTML = i;
|
|
108
|
+
}, d = () => {
|
|
109
|
+
o.isEditable && (s = !0, a.classList.add("vizel-math-editing"), l.style.display = "none", n.style.display = "inline", n.value = t.attrs.latex, n.focus(), n.select());
|
|
110
|
+
}, u = () => {
|
|
111
|
+
if (!s) return;
|
|
112
|
+
s = !1, a.classList.remove("vizel-math-editing"), l.style.display = "", n.style.display = "none";
|
|
113
|
+
const e = n.value.trim(), i = typeof r == "function" ? r() : null;
|
|
114
|
+
i != null && (e === "" ? o.chain().focus().deleteRange({ from: i, to: i + t.nodeSize }).run() : e !== t.attrs.latex && o.chain().focus().updateAttributes("mathInline", { latex: e }).run());
|
|
115
|
+
}, m = (e) => {
|
|
116
|
+
s || (e.preventDefault(), e.stopPropagation(), d());
|
|
117
|
+
}, h = () => u(), p = (e) => {
|
|
118
|
+
e.key === "Enter" ? (e.preventDefault(), u()) : e.key === "Escape" && (e.preventDefault(), n.value = t.attrs.latex, u());
|
|
119
|
+
};
|
|
120
|
+
return a.addEventListener("click", m), n.addEventListener("blur", h), n.addEventListener("keydown", p), c(t.attrs.latex), {
|
|
121
|
+
dom: a,
|
|
122
|
+
update(e) {
|
|
123
|
+
return e.type.name !== "mathInline" ? !1 : (s || c(e.attrs.latex), !0);
|
|
124
|
+
},
|
|
125
|
+
selectNode() {
|
|
126
|
+
a.classList.add("vizel-math-selected");
|
|
127
|
+
},
|
|
128
|
+
deselectNode() {
|
|
129
|
+
a.classList.remove("vizel-math-selected");
|
|
130
|
+
},
|
|
131
|
+
destroy() {
|
|
132
|
+
a.removeEventListener("click", m), n.removeEventListener("blur", h), n.removeEventListener("keydown", p);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
addInputRules() {
|
|
138
|
+
return this.options.inlineInputRules ? [
|
|
139
|
+
x({
|
|
140
|
+
find: E,
|
|
141
|
+
type: this.type,
|
|
142
|
+
getAttributes: (t) => ({ latex: t[1] })
|
|
143
|
+
})
|
|
144
|
+
] : [];
|
|
145
|
+
},
|
|
146
|
+
addCommands() {
|
|
147
|
+
return {
|
|
148
|
+
insertMath: ({ latex: t }) => ({ commands: r }) => r.insertContent({
|
|
149
|
+
type: this.name,
|
|
150
|
+
attrs: { latex: t }
|
|
151
|
+
})
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
// Markdown support (GitHub compatible)
|
|
155
|
+
markdownTokenizer: z,
|
|
156
|
+
parseMarkdown(t) {
|
|
157
|
+
return {
|
|
158
|
+
type: "mathInline",
|
|
159
|
+
attrs: {
|
|
160
|
+
latex: t.latex || ""
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
renderMarkdown(t) {
|
|
165
|
+
return `$${t.attrs?.latex || ""}$`;
|
|
166
|
+
}
|
|
167
|
+
}), M = v.create({
|
|
168
|
+
name: "mathBlock",
|
|
169
|
+
group: "block",
|
|
170
|
+
atom: !0,
|
|
171
|
+
selectable: !0,
|
|
172
|
+
draggable: !0,
|
|
173
|
+
addOptions() {
|
|
174
|
+
return {
|
|
175
|
+
katexOptions: {},
|
|
176
|
+
inlineInputRules: !0,
|
|
177
|
+
blockInputRules: !0
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
addAttributes() {
|
|
181
|
+
return {
|
|
182
|
+
latex: {
|
|
183
|
+
default: "",
|
|
184
|
+
parseHTML: (t) => t.getAttribute("data-latex") || "",
|
|
185
|
+
renderHTML: (t) => ({
|
|
186
|
+
"data-latex": t.latex
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
parseHTML() {
|
|
192
|
+
return [
|
|
193
|
+
{
|
|
194
|
+
tag: 'div[data-type="math-block"]'
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
},
|
|
198
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
199
|
+
return [
|
|
200
|
+
"div",
|
|
201
|
+
y(t, {
|
|
202
|
+
"data-type": "math-block",
|
|
203
|
+
class: "vizel-math vizel-math-block"
|
|
204
|
+
})
|
|
205
|
+
];
|
|
206
|
+
},
|
|
207
|
+
addNodeView() {
|
|
208
|
+
return ({ node: t, getPos: r, editor: o }) => {
|
|
209
|
+
const a = document.createElement("div");
|
|
210
|
+
a.classList.add("vizel-math", "vizel-math-block"), a.setAttribute("data-type", "math-block"), a.setAttribute("contenteditable", "false");
|
|
211
|
+
const l = document.createElement("div");
|
|
212
|
+
l.classList.add("vizel-math-render"), a.appendChild(l);
|
|
213
|
+
const n = document.createElement("div");
|
|
214
|
+
n.classList.add("vizel-math-edit-container"), n.style.display = "none";
|
|
215
|
+
const s = document.createElement("textarea");
|
|
216
|
+
s.classList.add("vizel-math-textarea"), s.value = t.attrs.latex, s.placeholder = "Enter LaTeX expression...", n.appendChild(s);
|
|
217
|
+
const c = document.createElement("div");
|
|
218
|
+
c.classList.add("vizel-math-preview"), n.appendChild(c), a.appendChild(n);
|
|
219
|
+
let d = !1;
|
|
220
|
+
const u = (e) => {
|
|
221
|
+
const { html: i } = f(e, !0, this.options.katexOptions);
|
|
222
|
+
l.innerHTML = i;
|
|
223
|
+
}, m = (e) => {
|
|
224
|
+
const { html: i } = f(e, !0, this.options.katexOptions);
|
|
225
|
+
c.innerHTML = i;
|
|
226
|
+
}, h = () => {
|
|
227
|
+
o.isEditable && (d = !0, a.classList.add("vizel-math-editing"), l.style.display = "none", n.style.display = "", s.value = t.attrs.latex, m(t.attrs.latex), s.focus());
|
|
228
|
+
}, p = () => {
|
|
229
|
+
if (!d) return;
|
|
230
|
+
d = !1, a.classList.remove("vizel-math-editing"), l.style.display = "", n.style.display = "none";
|
|
231
|
+
const e = s.value.trim(), i = typeof r == "function" ? r() : null;
|
|
232
|
+
i != null && (e === "" ? o.chain().focus().deleteRange({ from: i, to: i + t.nodeSize }).run() : e !== t.attrs.latex && o.chain().focus().updateAttributes("mathBlock", { latex: e }).run());
|
|
233
|
+
};
|
|
234
|
+
return a.addEventListener("click", (e) => {
|
|
235
|
+
!d && e.target === a && (e.preventDefault(), e.stopPropagation(), h());
|
|
236
|
+
}), l.addEventListener("click", (e) => {
|
|
237
|
+
e.preventDefault(), e.stopPropagation(), h();
|
|
238
|
+
}), s.addEventListener("blur", (e) => {
|
|
239
|
+
const i = e.relatedTarget;
|
|
240
|
+
i instanceof HTMLElement && n.contains(i) || p();
|
|
241
|
+
}), s.addEventListener("keydown", (e) => {
|
|
242
|
+
e.key === "Escape" && (e.preventDefault(), s.value = t.attrs.latex, p()), e.key === "Enter" && (e.ctrlKey || e.metaKey) && (e.preventDefault(), p());
|
|
243
|
+
}), s.addEventListener("input", () => {
|
|
244
|
+
m(s.value);
|
|
245
|
+
}), u(t.attrs.latex), {
|
|
246
|
+
dom: a,
|
|
247
|
+
update(e) {
|
|
248
|
+
return e.type.name !== "mathBlock" ? !1 : (d || u(e.attrs.latex), !0);
|
|
249
|
+
},
|
|
250
|
+
selectNode() {
|
|
251
|
+
a.classList.add("vizel-math-selected");
|
|
252
|
+
},
|
|
253
|
+
deselectNode() {
|
|
254
|
+
a.classList.remove("vizel-math-selected");
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
},
|
|
259
|
+
addInputRules() {
|
|
260
|
+
return this.options.blockInputRules ? [
|
|
261
|
+
x({
|
|
262
|
+
find: b,
|
|
263
|
+
type: this.type,
|
|
264
|
+
getAttributes: (t) => ({ latex: t[1]?.trim() })
|
|
265
|
+
})
|
|
266
|
+
] : [];
|
|
267
|
+
},
|
|
268
|
+
addCommands() {
|
|
269
|
+
return {
|
|
270
|
+
insertMathBlock: ({ latex: t }) => ({ commands: r }) => r.insertContent({
|
|
271
|
+
type: this.name,
|
|
272
|
+
attrs: { latex: t }
|
|
273
|
+
})
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
addKeyboardShortcuts() {
|
|
277
|
+
return {
|
|
278
|
+
Backspace: () => {
|
|
279
|
+
const { selection: t } = this.editor.state, { $anchor: r } = t;
|
|
280
|
+
return r.node().type.name === "mathBlock" ? this.editor.commands.deleteSelection() : !1;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
// Markdown support (GitHub compatible)
|
|
285
|
+
markdownTokenizer: g,
|
|
286
|
+
parseMarkdown(t) {
|
|
287
|
+
return {
|
|
288
|
+
type: "mathBlock",
|
|
289
|
+
attrs: {
|
|
290
|
+
latex: t.latex || ""
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
renderMarkdown(t) {
|
|
295
|
+
return `$$
|
|
296
|
+
${t.attrs?.latex || ""}
|
|
297
|
+
$$`;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
function w(t = {}) {
|
|
301
|
+
return [$.configure(t), M.configure(t)];
|
|
302
|
+
}
|
|
303
|
+
export {
|
|
304
|
+
M as VizelMathBlock,
|
|
305
|
+
$ as VizelMathInline,
|
|
306
|
+
w as createVizelMathematicsExtensions,
|
|
307
|
+
H as katex
|
|
308
|
+
};
|
package/dist/index18.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TableRow as s } from "@tiptap/extension-table";
|
|
2
|
+
import { VizelTable as i, VizelTableHeader as o, VizelTableCell as r } from "./index25.js";
|
|
3
|
+
import { VizelTableWithControls as a } from "./index22.js";
|
|
4
|
+
function z(l = {}) {
|
|
5
|
+
const { controls: t = !0, ...e } = l;
|
|
6
|
+
return [
|
|
7
|
+
t ? a.configure({
|
|
8
|
+
resizable: e.resizable ?? !1,
|
|
9
|
+
cellMinWidth: e.cellMinWidth ?? 50,
|
|
10
|
+
lastColumnResizable: e.lastColumnResizable ?? !0,
|
|
11
|
+
HTMLAttributes: {
|
|
12
|
+
class: "vizel-table",
|
|
13
|
+
...e.tableHTMLAttributes
|
|
14
|
+
},
|
|
15
|
+
// Pass control options (default to true if not explicitly set)
|
|
16
|
+
showColumnInsert: typeof t == "object" ? t.showColumnInsert ?? !0 : !0,
|
|
17
|
+
showRowInsert: typeof t == "object" ? t.showRowInsert ?? !0 : !0,
|
|
18
|
+
showRowHandle: typeof t == "object" ? t.showRowHandle ?? !0 : !0
|
|
19
|
+
}) : i.configure({
|
|
20
|
+
resizable: e.resizable ?? !1,
|
|
21
|
+
cellMinWidth: e.cellMinWidth ?? 50,
|
|
22
|
+
lastColumnResizable: e.lastColumnResizable ?? !0,
|
|
23
|
+
HTMLAttributes: {
|
|
24
|
+
class: "vizel-table",
|
|
25
|
+
...e.tableHTMLAttributes
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
s.configure({
|
|
29
|
+
HTMLAttributes: {
|
|
30
|
+
class: "vizel-table-row"
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
o.configure({
|
|
34
|
+
HTMLAttributes: {
|
|
35
|
+
class: "vizel-table-header",
|
|
36
|
+
...e.headerHTMLAttributes
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
r.configure({
|
|
40
|
+
HTMLAttributes: {
|
|
41
|
+
class: "vizel-table-cell",
|
|
42
|
+
...e.cellHTMLAttributes
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
i as VizelTable,
|
|
49
|
+
r as VizelTableCell,
|
|
50
|
+
o as VizelTableHeader,
|
|
51
|
+
z as createVizelTableExtensions
|
|
52
|
+
};
|
package/dist/index19.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import i from "./index44.js";
|
|
2
|
+
import a from "./index45.js";
|
|
3
|
+
function o(s = {}) {
|
|
4
|
+
const { taskList: t = {}, taskItem: e = {} } = s;
|
|
5
|
+
return [
|
|
6
|
+
a.configure({
|
|
7
|
+
HTMLAttributes: {
|
|
8
|
+
class: "vizel-task-list",
|
|
9
|
+
...t.HTMLAttributes
|
|
10
|
+
},
|
|
11
|
+
itemTypeName: t.itemTypeName ?? "taskItem"
|
|
12
|
+
}),
|
|
13
|
+
i.configure({
|
|
14
|
+
HTMLAttributes: {
|
|
15
|
+
class: "vizel-task-item",
|
|
16
|
+
...e.HTMLAttributes
|
|
17
|
+
},
|
|
18
|
+
nested: e.nested ?? !0,
|
|
19
|
+
...e.onReadOnlyChecked !== void 0 && {
|
|
20
|
+
onReadOnlyChecked: e.onReadOnlyChecked
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
i as TaskItem,
|
|
27
|
+
a as TaskList,
|
|
28
|
+
o as createVizelTaskListExtensions
|
|
29
|
+
};
|
package/dist/index2.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const i = {
|
|
2
|
+
enabled: !0,
|
|
3
|
+
debounceMs: 1e3,
|
|
4
|
+
storage: "localStorage",
|
|
5
|
+
key: "vizel-content"
|
|
6
|
+
};
|
|
7
|
+
function d(n, r) {
|
|
8
|
+
let t = null;
|
|
9
|
+
const e = (...o) => {
|
|
10
|
+
t && clearTimeout(t), t = setTimeout(() => {
|
|
11
|
+
n(...o), t = null;
|
|
12
|
+
}, r);
|
|
13
|
+
};
|
|
14
|
+
return e.cancel = () => {
|
|
15
|
+
t && (clearTimeout(t), t = null);
|
|
16
|
+
}, e;
|
|
17
|
+
}
|
|
18
|
+
function f(n, r) {
|
|
19
|
+
if (n === "localStorage" || n === "sessionStorage") {
|
|
20
|
+
const t = n === "localStorage" ? localStorage : sessionStorage;
|
|
21
|
+
return {
|
|
22
|
+
save: (e) => (t.setItem(r, JSON.stringify(e)), Promise.resolve()),
|
|
23
|
+
load: () => {
|
|
24
|
+
const e = t.getItem(r);
|
|
25
|
+
if (e)
|
|
26
|
+
try {
|
|
27
|
+
return Promise.resolve(JSON.parse(e));
|
|
28
|
+
} catch {
|
|
29
|
+
return Promise.resolve(null);
|
|
30
|
+
}
|
|
31
|
+
return Promise.resolve(null);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
save: async (t) => {
|
|
37
|
+
await n.save(t);
|
|
38
|
+
},
|
|
39
|
+
load: async () => n.load ? await n.load() : null
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function m(n, r, t) {
|
|
43
|
+
const e = { ...i, ...r }, o = f(e.storage, e.key), a = async () => {
|
|
44
|
+
const l = n();
|
|
45
|
+
if (l) {
|
|
46
|
+
t({ status: "saving" });
|
|
47
|
+
try {
|
|
48
|
+
const s = l.getJSON();
|
|
49
|
+
await o.save(s), t({
|
|
50
|
+
status: "saved",
|
|
51
|
+
hasUnsavedChanges: !1,
|
|
52
|
+
lastSaved: /* @__PURE__ */ new Date(),
|
|
53
|
+
error: null
|
|
54
|
+
}), e.onSave?.(s);
|
|
55
|
+
} catch (s) {
|
|
56
|
+
const u = s instanceof Error ? s : new Error(String(s));
|
|
57
|
+
t({
|
|
58
|
+
status: "error",
|
|
59
|
+
error: u
|
|
60
|
+
}), e.onError?.(u);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, c = d(a, e.debounceMs);
|
|
64
|
+
return {
|
|
65
|
+
save: c,
|
|
66
|
+
saveNow: a,
|
|
67
|
+
restore: async () => {
|
|
68
|
+
try {
|
|
69
|
+
const l = await o.load();
|
|
70
|
+
return e.onRestore?.(l), l;
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
handleUpdate: () => {
|
|
76
|
+
e.enabled && (t({
|
|
77
|
+
status: "unsaved",
|
|
78
|
+
hasUnsavedChanges: !0
|
|
79
|
+
}), c());
|
|
80
|
+
},
|
|
81
|
+
cancel: c.cancel
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function S(n) {
|
|
85
|
+
const t = (/* @__PURE__ */ new Date()).getTime() - n.getTime(), e = Math.floor(t / 1e3), o = Math.floor(e / 60), a = Math.floor(o / 60), c = Math.floor(a / 24);
|
|
86
|
+
return e < 5 ? "Just now" : e < 60 ? `${e}s ago` : o < 60 ? `${o}m ago` : a < 24 ? `${a}h ago` : `${c}d ago`;
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
i as VIZEL_DEFAULT_AUTO_SAVE_OPTIONS,
|
|
90
|
+
m as createVizelAutoSaveHandlers,
|
|
91
|
+
S as formatVizelRelativeTime,
|
|
92
|
+
f as getVizelStorageBackend
|
|
93
|
+
};
|