@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.
Files changed (75) hide show
  1. package/dist/components.css +1 -1
  2. package/dist/components.css.map +1 -1
  3. package/dist/index.d.ts +230 -15
  4. package/dist/index.js +78 -75
  5. package/dist/index10.js +1 -1
  6. package/dist/index11.js +4 -4
  7. package/dist/index14.js +1 -1
  8. package/dist/index15.js +134 -127
  9. package/dist/index17.js +2 -2
  10. package/dist/index18.js +1 -1
  11. package/dist/index19.js +86 -86
  12. package/dist/index20.js +2 -2
  13. package/dist/index21.js +2 -2
  14. package/dist/index22.js +16 -13
  15. package/dist/index24.js +164 -11
  16. package/dist/index25.js +12 -53
  17. package/dist/index26.js +49 -136
  18. package/dist/index27.js +132 -59
  19. package/dist/index28.js +66 -32
  20. package/dist/index29.js +35 -21
  21. package/dist/index3.js +91 -90
  22. package/dist/index30.js +23 -9
  23. package/dist/index31.js +9 -147
  24. package/dist/index32.js +138 -256
  25. package/dist/index33.js +258 -85
  26. package/dist/index34.js +91 -15
  27. package/dist/index35.js +63 -57
  28. package/dist/index36.js +4 -15
  29. package/dist/index37.js +115 -56
  30. package/dist/index38.js +327 -4
  31. package/dist/index39.js +11 -121
  32. package/dist/index4.js +1 -1
  33. package/dist/index40.js +481 -321
  34. package/dist/index41.js +42 -481
  35. package/dist/index42.js +683 -37
  36. package/dist/index43.js +4 -679
  37. package/dist/index44.js +4 -4
  38. package/dist/index45.js +238 -4
  39. package/dist/index46.js +54 -210
  40. package/dist/index47.js +16 -81
  41. package/dist/index48.js +57 -285
  42. package/dist/index49.js +14 -1501
  43. package/dist/index5.js +78 -68
  44. package/dist/index50.js +286 -5
  45. package/dist/index51.js +4 -4
  46. package/dist/index52.js +1408 -1467
  47. package/dist/index53.js +5 -723
  48. package/dist/index54.js +1112 -21
  49. package/dist/index55.js +722 -9
  50. package/dist/index56.js +83 -6
  51. package/dist/index57.js +245 -7
  52. package/dist/index58.js +3 -14
  53. package/dist/index59.js +1230 -17
  54. package/dist/index6.js +1 -1
  55. package/dist/index60.js +733 -24
  56. package/dist/index61.js +21 -84
  57. package/dist/index62.js +10 -246
  58. package/dist/index63.js +7 -3
  59. package/dist/index64.js +7 -1231
  60. package/dist/index65.js +11 -731
  61. package/dist/index66.js +17 -1059
  62. package/dist/index67.js +21 -51
  63. package/dist/index68.js +54 -3
  64. package/dist/index69.js +1061 -98
  65. package/dist/index7.js +108 -96
  66. package/dist/index70.js +98 -91
  67. package/dist/index71.js +93 -0
  68. package/dist/index72.js +6 -0
  69. package/dist/index8.js +1 -1
  70. package/dist/index9.js +75 -65
  71. package/dist/mathematics.css +1 -0
  72. package/dist/mathematics.css.map +1 -0
  73. package/dist/styles.css +1 -1
  74. package/dist/styles.css.map +1 -1
  75. package/package.json +90 -52
package/dist/index15.js CHANGED
@@ -1,38 +1,39 @@
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) {
1
+ import { Node as b, mergeAttributes as g, InputRule as $ } from "@tiptap/core";
2
+ import { createLazyLoader as M } from "./index39.js";
3
+ const T = M("katex", async () => (await import("katex")).default);
4
+ async function x(e, r, o) {
5
5
  try {
6
- return { html: L.renderToString(t, {
6
+ return { html: (await T()).renderToString(e, {
7
7
  displayMode: r,
8
8
  throwOnError: !1,
9
9
  strict: !1,
10
- trust: !1,
11
- ...o
10
+ ...o,
11
+ trust: !1
12
+ // Enforced: prevents external URL access via \url, \href commands
12
13
  }), error: null };
13
- } catch (a) {
14
- const l = a instanceof Error ? a.message : "Invalid LaTeX";
14
+ } catch (t) {
15
+ const i = t instanceof Error ? t.message : "Invalid LaTeX";
15
16
  return {
16
- html: `<span class="vizel-math-error">${l}</span>`,
17
- error: l
17
+ html: `<span class="vizel-math-error">${i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")}</span>`,
18
+ error: i
18
19
  };
19
20
  }
20
21
  }
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);
22
+ const w = /\$([^$\n]+)\$$/, I = /\$\$([^$]+)\$\$$/;
23
+ function z(e) {
24
+ return new $({
25
+ find: e.find,
26
+ handler: ({ state: r, range: o, match: t }) => {
27
+ const i = e.getAttributes?.(t) ?? {}, { tr: n } = r, s = e.type.create(i);
27
28
  n.replaceWith(o.from, o.to, s);
28
29
  }
29
30
  });
30
31
  }
31
- const z = {
32
+ const C = {
32
33
  name: "mathInline",
33
34
  start: "$",
34
- tokenize(t) {
35
- const r = t.match(/^\$([^$\n]+?)\$/);
35
+ tokenize(e) {
36
+ const r = e.match(/^\$([^$\n]+?)\$/);
36
37
  if (r?.[1])
37
38
  return {
38
39
  type: "mathInline",
@@ -40,11 +41,11 @@ const z = {
40
41
  latex: r[1]
41
42
  };
42
43
  }
43
- }, g = {
44
+ }, A = {
44
45
  name: "mathBlock",
45
46
  start: "$$",
46
- tokenize(t) {
47
- const r = t.match(/^\$\$([\s\S]+?)\$\$/);
47
+ tokenize(e) {
48
+ const r = e.match(/^\$\$([\s\S]+?)\$\$/);
48
49
  if (r?.[1])
49
50
  return {
50
51
  type: "mathBlock",
@@ -52,7 +53,7 @@ const z = {
52
53
  latex: r[1].trim()
53
54
  };
54
55
  }
55
- }, $ = v.create({
56
+ }, B = b.create({
56
57
  name: "mathInline",
57
58
  group: "inline",
58
59
  inline: !0,
@@ -70,9 +71,9 @@ const z = {
70
71
  return {
71
72
  latex: {
72
73
  default: "",
73
- parseHTML: (t) => t.getAttribute("data-latex") || "",
74
- renderHTML: (t) => ({
75
- "data-latex": t.latex
74
+ parseHTML: (e) => e.getAttribute("data-latex") || "",
75
+ renderHTML: (e) => ({
76
+ "data-latex": e.latex
76
77
  })
77
78
  }
78
79
  };
@@ -84,87 +85,88 @@ const z = {
84
85
  }
85
86
  ];
86
87
  },
87
- renderHTML({ HTMLAttributes: t }) {
88
+ renderHTML({ HTMLAttributes: e }) {
88
89
  return [
89
90
  "span",
90
- y(t, {
91
+ g(e, {
91
92
  "data-type": "math-inline",
92
93
  class: "vizel-math vizel-math-inline"
93
94
  })
94
95
  ];
95
96
  },
96
97
  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);
98
+ return ({ node: e, getPos: r, editor: o }) => {
99
+ const t = document.createElement("span");
100
+ t.classList.add("vizel-math", "vizel-math-inline"), t.setAttribute("data-type", "math-inline"), t.setAttribute("contenteditable", "false");
101
+ const i = document.createElement("span");
102
+ i.classList.add("vizel-math-render"), t.appendChild(i);
102
103
  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
+ n.type = "text", n.classList.add("vizel-math-input"), n.value = e.attrs.latex, n.style.display = "none", t.appendChild(n);
104
105
  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 = () => {
106
+ const h = this.options.katexOptions, u = (l) => {
107
+ x(l, !1, h).then(({ html: c }) => {
108
+ i.innerHTML = c;
109
+ });
110
+ }, y = () => {
111
+ o.isEditable && (s = !0, t.classList.add("vizel-math-editing"), i.style.display = "none", n.style.display = "inline", n.value = e.attrs.latex, n.focus(), n.select());
112
+ }, p = () => {
111
113
  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());
114
+ s = !1, t.classList.remove("vizel-math-editing"), i.style.display = "", n.style.display = "none";
115
+ const l = n.value.trim(), c = typeof r == "function" ? r() : null;
116
+ c != null && (l === "" ? o.chain().focus().deleteRange({ from: c, to: c + e.nodeSize }).run() : l !== e.attrs.latex && o.chain().focus().updateAttributes("mathInline", { latex: l }).run());
117
+ }, v = (l) => {
118
+ s || (l.preventDefault(), l.stopPropagation(), y());
119
+ }, f = () => p(), m = (l) => {
120
+ l.key === "Enter" ? (l.preventDefault(), p()) : l.key === "Escape" && (l.preventDefault(), n.value = e.attrs.latex, p());
119
121
  };
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);
122
+ return t.addEventListener("click", v), n.addEventListener("blur", f), n.addEventListener("keydown", m), u(e.attrs.latex), {
123
+ dom: t,
124
+ update(l) {
125
+ return l.type.name !== "mathInline" ? !1 : (s || u(l.attrs.latex), !0);
124
126
  },
125
127
  selectNode() {
126
- a.classList.add("vizel-math-selected");
128
+ t.classList.add("vizel-math-selected");
127
129
  },
128
130
  deselectNode() {
129
- a.classList.remove("vizel-math-selected");
131
+ t.classList.remove("vizel-math-selected");
130
132
  },
131
133
  destroy() {
132
- a.removeEventListener("click", m), n.removeEventListener("blur", h), n.removeEventListener("keydown", p);
134
+ t.removeEventListener("click", v), n.removeEventListener("blur", f), n.removeEventListener("keydown", m);
133
135
  }
134
136
  };
135
137
  };
136
138
  },
137
139
  addInputRules() {
138
140
  return this.options.inlineInputRules ? [
139
- x({
140
- find: E,
141
+ z({
142
+ find: w,
141
143
  type: this.type,
142
- getAttributes: (t) => ({ latex: t[1] })
144
+ getAttributes: (e) => ({ latex: e[1] })
143
145
  })
144
146
  ] : [];
145
147
  },
146
148
  addCommands() {
147
149
  return {
148
- insertMath: ({ latex: t }) => ({ commands: r }) => r.insertContent({
150
+ insertMath: ({ latex: e }) => ({ commands: r }) => r.insertContent({
149
151
  type: this.name,
150
- attrs: { latex: t }
152
+ attrs: { latex: e }
151
153
  })
152
154
  };
153
155
  },
154
156
  // Markdown support (GitHub compatible)
155
- markdownTokenizer: z,
156
- parseMarkdown(t) {
157
+ markdownTokenizer: C,
158
+ parseMarkdown(e) {
157
159
  return {
158
160
  type: "mathInline",
159
161
  attrs: {
160
- latex: t.latex || ""
162
+ latex: e.latex || ""
161
163
  }
162
164
  };
163
165
  },
164
- renderMarkdown(t) {
165
- return `$${t.attrs?.latex || ""}$`;
166
+ renderMarkdown(e) {
167
+ return `$${e.attrs?.latex || ""}$`;
166
168
  }
167
- }), M = v.create({
169
+ }), R = b.create({
168
170
  name: "mathBlock",
169
171
  group: "block",
170
172
  atom: !0,
@@ -181,9 +183,9 @@ const z = {
181
183
  return {
182
184
  latex: {
183
185
  default: "",
184
- parseHTML: (t) => t.getAttribute("data-latex") || "",
185
- renderHTML: (t) => ({
186
- "data-latex": t.latex
186
+ parseHTML: (e) => e.getAttribute("data-latex") || "",
187
+ renderHTML: (e) => ({
188
+ "data-latex": e.latex
187
189
  })
188
190
  }
189
191
  };
@@ -195,114 +197,119 @@ const z = {
195
197
  }
196
198
  ];
197
199
  },
198
- renderHTML({ HTMLAttributes: t }) {
200
+ renderHTML({ HTMLAttributes: e }) {
199
201
  return [
200
202
  "div",
201
- y(t, {
203
+ g(e, {
202
204
  "data-type": "math-block",
203
205
  class: "vizel-math vizel-math-block"
204
206
  })
205
207
  ];
206
208
  },
207
209
  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);
210
+ return ({ node: e, getPos: r, editor: o }) => {
211
+ const t = document.createElement("div");
212
+ t.classList.add("vizel-math", "vizel-math-block"), t.setAttribute("data-type", "math-block"), t.setAttribute("contenteditable", "false");
213
+ const i = document.createElement("div");
214
+ i.classList.add("vizel-math-render"), t.appendChild(i);
213
215
  const n = document.createElement("div");
214
216
  n.classList.add("vizel-math-edit-container"), n.style.display = "none";
215
217
  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());
218
+ s.classList.add("vizel-math-textarea"), s.value = e.attrs.latex, s.placeholder = "Enter LaTeX expression...", n.appendChild(s);
219
+ const h = document.createElement("div");
220
+ h.classList.add("vizel-math-preview"), n.appendChild(h), t.appendChild(n);
221
+ let u = !1;
222
+ const y = this.options.katexOptions, p = (a) => {
223
+ x(a, !0, y).then(({ html: d }) => {
224
+ i.innerHTML = d;
225
+ });
226
+ }, v = (a) => {
227
+ x(a, !0, y).then(({ html: d }) => {
228
+ h.innerHTML = d;
229
+ });
230
+ }, f = () => {
231
+ o.isEditable && (u = !0, t.classList.add("vizel-math-editing"), i.style.display = "none", n.style.display = "", s.value = e.attrs.latex, v(e.attrs.latex), s.focus());
232
+ }, m = () => {
233
+ if (!u) return;
234
+ u = !1, t.classList.remove("vizel-math-editing"), i.style.display = "", n.style.display = "none";
235
+ const a = s.value.trim(), d = typeof r == "function" ? r() : null;
236
+ d != null && (a === "" ? o.chain().focus().deleteRange({ from: d, to: d + e.nodeSize }).run() : a !== e.attrs.latex && o.chain().focus().updateAttributes("mathBlock", { latex: a }).run());
237
+ }, l = (a) => {
238
+ !u && a.target === t && (a.preventDefault(), a.stopPropagation(), f());
239
+ }, c = (a) => {
240
+ a.preventDefault(), a.stopPropagation(), f();
241
+ }, k = (a) => {
242
+ const d = a.relatedTarget;
243
+ d instanceof HTMLElement && n.contains(d) || m();
244
+ }, L = (a) => {
245
+ a.key === "Escape" && (a.preventDefault(), s.value = e.attrs.latex, m()), a.key === "Enter" && (a.ctrlKey || a.metaKey) && (a.preventDefault(), m());
246
+ }, E = () => {
247
+ v(s.value);
233
248
  };
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
+ return t.addEventListener("click", l), i.addEventListener("click", c), s.addEventListener("blur", k), s.addEventListener("keydown", L), s.addEventListener("input", E), p(e.attrs.latex), {
250
+ dom: t,
251
+ update(a) {
252
+ return a.type.name !== "mathBlock" ? !1 : (u || p(a.attrs.latex), !0);
249
253
  },
250
254
  selectNode() {
251
- a.classList.add("vizel-math-selected");
255
+ t.classList.add("vizel-math-selected");
252
256
  },
253
257
  deselectNode() {
254
- a.classList.remove("vizel-math-selected");
258
+ t.classList.remove("vizel-math-selected");
259
+ },
260
+ destroy() {
261
+ t.removeEventListener("click", l), i.removeEventListener("click", c), s.removeEventListener("blur", k), s.removeEventListener("keydown", L), s.removeEventListener("input", E);
255
262
  }
256
263
  };
257
264
  };
258
265
  },
259
266
  addInputRules() {
260
267
  return this.options.blockInputRules ? [
261
- x({
262
- find: b,
268
+ z({
269
+ find: I,
263
270
  type: this.type,
264
- getAttributes: (t) => ({ latex: t[1]?.trim() })
271
+ getAttributes: (e) => ({ latex: e[1]?.trim() })
265
272
  })
266
273
  ] : [];
267
274
  },
268
275
  addCommands() {
269
276
  return {
270
- insertMathBlock: ({ latex: t }) => ({ commands: r }) => r.insertContent({
277
+ insertMathBlock: ({ latex: e }) => ({ commands: r }) => r.insertContent({
271
278
  type: this.name,
272
- attrs: { latex: t }
279
+ attrs: { latex: e }
273
280
  })
274
281
  };
275
282
  },
276
283
  addKeyboardShortcuts() {
277
284
  return {
278
285
  Backspace: () => {
279
- const { selection: t } = this.editor.state, { $anchor: r } = t;
286
+ const { selection: e } = this.editor.state, { $anchor: r } = e;
280
287
  return r.node().type.name === "mathBlock" ? this.editor.commands.deleteSelection() : !1;
281
288
  }
282
289
  };
283
290
  },
284
291
  // Markdown support (GitHub compatible)
285
- markdownTokenizer: g,
286
- parseMarkdown(t) {
292
+ markdownTokenizer: A,
293
+ parseMarkdown(e) {
287
294
  return {
288
295
  type: "mathBlock",
289
296
  attrs: {
290
- latex: t.latex || ""
297
+ latex: e.latex || ""
291
298
  }
292
299
  };
293
300
  },
294
- renderMarkdown(t) {
301
+ renderMarkdown(e) {
295
302
  return `$$
296
- ${t.attrs?.latex || ""}
303
+ ${e.attrs?.latex || ""}
297
304
  $$`;
298
305
  }
299
306
  });
300
- function w(t = {}) {
301
- return [$.configure(t), M.configure(t)];
307
+ function D(e = {}) {
308
+ return [B.configure(e), R.configure(e)];
302
309
  }
303
310
  export {
304
- M as VizelMathBlock,
305
- $ as VizelMathInline,
306
- w as createVizelMathematicsExtensions,
307
- H as katex
311
+ R as VizelMathBlock,
312
+ B as VizelMathInline,
313
+ D as createVizelMathematicsExtensions,
314
+ T as loadKatex
308
315
  };
package/dist/index17.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Extension as a } from "@tiptap/core";
2
2
  import e from "@tiptap/suggestion";
3
- import { filterSlashCommands as i, defaultSlashCommands as m } from "./index32.js";
4
- import { flattenSlashCommandGroups as p, groupSlashCommands as g, searchSlashCommands as C, defaultGroupOrder as S } from "./index32.js";
3
+ import { filterSlashCommands as i, defaultSlashCommands as m } from "./index33.js";
4
+ import { flattenSlashCommandGroups as p, groupSlashCommands as g, searchSlashCommands as C, defaultGroupOrder as S } from "./index33.js";
5
5
  const n = (s) => typeof s == "object" && s !== null && "title" in s && "command" in s, h = a.create({
6
6
  name: "slashCommand",
7
7
  addOptions() {
package/dist/index18.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TableRow as s } from "@tiptap/extension-table";
2
- import { VizelTable as i, VizelTableHeader as o, VizelTableCell as r } from "./index33.js";
2
+ import { VizelTable as i, VizelTableHeader as o, VizelTableCell as r } from "./index34.js";
3
3
  import { VizelTableWithControls as a } from "./index19.js";
4
4
  function z(l = {}) {
5
5
  const { controls: t = !0, ...e } = l;