@vizel/core 0.0.1-alpha.1 → 0.0.1-alpha.3

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +13 -13
  3. package/dist/index.js +141 -141
  4. package/dist/index10.js +70 -110
  5. package/dist/index11.js +135 -168
  6. package/dist/index12.js +83 -74
  7. package/dist/index13.js +13 -134
  8. package/dist/index14.js +13 -146
  9. package/dist/index15.js +303 -15
  10. package/dist/index16.js +69 -14
  11. package/dist/index17.js +26 -295
  12. package/dist/index18.js +2 -2
  13. package/dist/index19.js +355 -24
  14. package/dist/index20.js +25 -264
  15. package/dist/index21.js +85 -68
  16. package/dist/index22.js +97 -353
  17. package/dist/index23.js +66 -84
  18. package/dist/index24.js +12 -36
  19. package/dist/index25.js +53 -92
  20. package/dist/index26.js +132 -96
  21. package/dist/index27.js +59 -126
  22. package/dist/index28.js +37 -53
  23. package/dist/index29.js +19 -62
  24. package/dist/index3.js +165 -60
  25. package/dist/index30.js +9 -37
  26. package/dist/index31.js +143 -19
  27. package/dist/index32.js +264 -11
  28. package/dist/index33.js +92 -9
  29. package/dist/index34.js +63 -16
  30. package/dist/index35.js +4 -58
  31. package/dist/index36.js +123 -15
  32. package/dist/index37.js +305 -42
  33. package/dist/index38.js +487 -4
  34. package/dist/index39.js +37 -112
  35. package/dist/index4.js +10 -86
  36. package/dist/index40.js +653 -301
  37. package/dist/index41.js +4 -487
  38. package/dist/index42.js +4 -48
  39. package/dist/index43.js +206 -642
  40. package/dist/index44.js +82 -4
  41. package/dist/index45.js +17 -4
  42. package/dist/index46.js +57 -237
  43. package/dist/index47.js +15 -82
  44. package/dist/index48.js +190 -274
  45. package/dist/index49.js +281 -1497
  46. package/dist/index5.js +132 -10
  47. package/dist/index50.js +1502 -5
  48. package/dist/index51.js +5 -1561
  49. package/dist/index52.js +1551 -192
  50. package/dist/index53.js +1 -1
  51. package/dist/index54.js +84 -21
  52. package/dist/index55.js +246 -10
  53. package/dist/index56.js +3 -7
  54. package/dist/index57.js +1231 -7
  55. package/dist/index58.js +731 -11
  56. package/dist/index59.js +21 -19
  57. package/dist/index6.js +48 -131
  58. package/dist/index60.js +10 -25
  59. package/dist/index61.js +6 -83
  60. package/dist/index62.js +7 -245
  61. package/dist/index63.js +11 -1229
  62. package/dist/index64.js +17 -732
  63. package/dist/index65.js +25 -3
  64. package/dist/index66.js +53 -1059
  65. package/dist/index67.js +1059 -53
  66. package/dist/index69.js +90 -3
  67. package/dist/index7.js +228 -409
  68. package/dist/index70.js +3 -90
  69. package/dist/index8.js +111 -45
  70. package/dist/index9.js +409 -228
  71. package/package.json +54 -80
package/dist/index17.js CHANGED
@@ -1,308 +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) {
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,
1
+ import { Extension as a } from "@tiptap/core";
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";
5
+ const n = (s) => typeof s == "object" && s !== null && "title" in s && "command" in s, h = a.create({
6
+ name: "slashCommand",
62
7
  addOptions() {
63
8
  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
- })
9
+ items: m,
10
+ suggestion: {
11
+ char: "/",
12
+ startOfLine: !1
77
13
  }
78
14
  };
79
15
  },
80
- parseHTML() {
16
+ addProseMirrorPlugins() {
81
17
  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");
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 });
127
25
  },
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"
26
+ ...this.options.suggestion
204
27
  })
205
28
  ];
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
29
  }
299
30
  });
300
- function w(t = {}) {
301
- return [$.configure(t), M.configure(t)];
302
- }
303
31
  export {
304
- M as VizelMathBlock,
305
- $ as VizelMathInline,
306
- w as createVizelMathematicsExtensions,
307
- H as katex
32
+ h as VizelSlashCommand,
33
+ i as filterVizelSlashCommands,
34
+ p as flattenVizelSlashCommandGroups,
35
+ g as groupVizelSlashCommands,
36
+ C as searchVizelSlashCommands,
37
+ S as vizelDefaultGroupOrder,
38
+ m as vizelDefaultSlashCommands
308
39
  };
package/dist/index18.js CHANGED
@@ -1,6 +1,6 @@
1
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";
2
+ import { VizelTable as i, VizelTableHeader as o, VizelTableCell as r } from "./index33.js";
3
+ import { VizelTableWithControls as a } from "./index19.js";
4
4
  function z(l = {}) {
5
5
  const { controls: t = !0, ...e } = l;
6
6
  return [