@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.
Files changed (77) hide show
  1. package/README.md +44 -0
  2. package/dist/components.css +1 -0
  3. package/dist/components.css.map +1 -0
  4. package/dist/index.d.ts +2642 -0
  5. package/dist/index.js +150 -0
  6. package/dist/index10.js +118 -0
  7. package/dist/index11.js +174 -0
  8. package/dist/index12.js +78 -0
  9. package/dist/index13.js +141 -0
  10. package/dist/index14.js +150 -0
  11. package/dist/index15.js +20 -0
  12. package/dist/index16.js +17 -0
  13. package/dist/index17.js +308 -0
  14. package/dist/index18.js +52 -0
  15. package/dist/index19.js +29 -0
  16. package/dist/index2.js +93 -0
  17. package/dist/index20.js +268 -0
  18. package/dist/index21.js +72 -0
  19. package/dist/index22.js +360 -0
  20. package/dist/index23.js +87 -0
  21. package/dist/index24.js +39 -0
  22. package/dist/index25.js +95 -0
  23. package/dist/index26.js +104 -0
  24. package/dist/index27.js +136 -0
  25. package/dist/index28.js +56 -0
  26. package/dist/index29.js +69 -0
  27. package/dist/index3.js +69 -0
  28. package/dist/index30.js +40 -0
  29. package/dist/index31.js +26 -0
  30. package/dist/index32.js +15 -0
  31. package/dist/index33.js +12 -0
  32. package/dist/index34.js +19 -0
  33. package/dist/index35.js +60 -0
  34. package/dist/index36.js +17 -0
  35. package/dist/index37.js +66 -0
  36. package/dist/index38.js +6 -0
  37. package/dist/index39.js +125 -0
  38. package/dist/index4.js +89 -0
  39. package/dist/index40.js +329 -0
  40. package/dist/index41.js +489 -0
  41. package/dist/index42.js +50 -0
  42. package/dist/index43.js +676 -0
  43. package/dist/index44.js +6 -0
  44. package/dist/index45.js +6 -0
  45. package/dist/index46.js +240 -0
  46. package/dist/index47.js +84 -0
  47. package/dist/index48.js +288 -0
  48. package/dist/index49.js +1504 -0
  49. package/dist/index5.js +13 -0
  50. package/dist/index50.js +7 -0
  51. package/dist/index51.js +1563 -0
  52. package/dist/index52.js +204 -0
  53. package/dist/index53.js +725 -0
  54. package/dist/index54.js +23 -0
  55. package/dist/index55.js +12 -0
  56. package/dist/index56.js +9 -0
  57. package/dist/index57.js +10 -0
  58. package/dist/index58.js +16 -0
  59. package/dist/index59.js +21 -0
  60. package/dist/index6.js +135 -0
  61. package/dist/index60.js +27 -0
  62. package/dist/index61.js +86 -0
  63. package/dist/index62.js +248 -0
  64. package/dist/index63.js +1234 -0
  65. package/dist/index64.js +736 -0
  66. package/dist/index65.js +5 -0
  67. package/dist/index66.js +1063 -0
  68. package/dist/index67.js +57 -0
  69. package/dist/index68.js +100 -0
  70. package/dist/index69.js +6 -0
  71. package/dist/index7.js +456 -0
  72. package/dist/index70.js +93 -0
  73. package/dist/index8.js +52 -0
  74. package/dist/index9.js +275 -0
  75. package/dist/styles.css +1 -0
  76. package/dist/styles.css.map +1 -0
  77. package/package.json +109 -0
@@ -0,0 +1,87 @@
1
+ import x from "@tiptap/extension-image";
2
+ const T = x.extend({
3
+ name: "image",
4
+ addOptions() {
5
+ return {
6
+ ...this.parent?.(),
7
+ minWidth: 100,
8
+ minHeight: 100,
9
+ inline: !1,
10
+ allowBase64: !0,
11
+ HTMLAttributes: {
12
+ class: "vizel-image"
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
+ };
82
+ }
83
+ });
84
+ export {
85
+ T as VizelImageResize,
86
+ T as VizelResizableImage
87
+ };
@@ -0,0 +1,39 @@
1
+ import { Extension as a } from "@tiptap/core";
2
+ import e from "@tiptap/suggestion";
3
+ import { filterSlashCommands as i, defaultSlashCommands as m } from "./index20.js";
4
+ import { flattenSlashCommandGroups as p, groupSlashCommands as g, searchSlashCommands as C, defaultGroupOrder as S } from "./index20.js";
5
+ const n = (s) => typeof s == "object" && s !== null && "title" in s && "command" in s, h = a.create({
6
+ name: "slashCommand",
7
+ addOptions() {
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
+ ];
29
+ }
30
+ });
31
+ export {
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
39
+ };
@@ -0,0 +1,95 @@
1
+ import { Table as w, TableCell as A, TableHeader as T } from "@tiptap/extension-table";
2
+ function g(t, e) {
3
+ return t.tokens ? e.parseInline(t.tokens) : t.text ? [e.createTextNode(t.text)] : [];
4
+ }
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
+ export {
92
+ C as VizelTable,
93
+ M as VizelTableCell,
94
+ N as VizelTableHeader
95
+ };
@@ -0,0 +1,104 @@
1
+ import { getIconData as g } from "./index34.js";
2
+ import { iconToSVG as h } from "./index35.js";
3
+ import s from "./index36.js";
4
+ const u = {
5
+ // Text/Headings
6
+ heading1: "lucide:heading-1",
7
+ heading2: "lucide:heading-2",
8
+ heading3: "lucide:heading-3",
9
+ // Lists
10
+ bulletList: "lucide:list",
11
+ orderedList: "lucide:list-ordered",
12
+ taskList: "lucide:list-checks",
13
+ // Blocks
14
+ paragraph: "lucide:pilcrow",
15
+ blockquote: "lucide:quote",
16
+ horizontalRule: "lucide:minus",
17
+ details: "lucide:chevron-right",
18
+ codeBlock: "lucide:code",
19
+ table: "lucide:table",
20
+ // Media
21
+ image: "lucide:image",
22
+ imageUpload: "lucide:image-up",
23
+ embed: "lucide:link",
24
+ // Advanced
25
+ mathBlock: "lucide:sigma",
26
+ mathInline: "lucide:superscript",
27
+ mermaid: "lucide:git-graph",
28
+ graphviz: "lucide:workflow",
29
+ // Table controls
30
+ arrowUp: "lucide:arrow-up",
31
+ arrowDown: "lucide:arrow-down",
32
+ arrowLeft: "lucide:arrow-left",
33
+ arrowRight: "lucide:arrow-right",
34
+ alignLeft: "lucide:align-left",
35
+ alignCenter: "lucide:align-center",
36
+ alignRight: "lucide:align-right",
37
+ plus: "lucide:plus",
38
+ gripVertical: "lucide:grip-vertical",
39
+ gripHorizontal: "lucide:grip-horizontal",
40
+ // UI
41
+ check: "lucide:check",
42
+ loader: "lucide:loader-2",
43
+ circle: "lucide:circle",
44
+ warning: "lucide:alert-triangle",
45
+ chevronDown: "lucide:chevron-down",
46
+ x: "lucide:x",
47
+ // BubbleMenu toolbar
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];
63
+ }
64
+ let t = null;
65
+ function w(e) {
66
+ t = e;
67
+ }
68
+ function z(e, i) {
69
+ return t ? t(e, i) : (process.env.NODE_ENV === "development" && console.warn(
70
+ "[Vizel] Icon renderer not set. Call setVizelIconRenderer() from your framework package (@vizel/react, @vizel/vue, or @vizel/svelte)."
71
+ ), "");
72
+ }
73
+ function p(e, i) {
74
+ const c = u[e];
75
+ if (!c) return "";
76
+ const [, d] = c.split(":");
77
+ if (!d) return "";
78
+ const l = g(s, d);
79
+ if (!l) return "";
80
+ const r = h(l, {
81
+ height: i?.height ?? 24,
82
+ width: i?.width ?? 24
83
+ }), n = [
84
+ 'xmlns="http://www.w3.org/2000/svg"',
85
+ `width="${i?.width ?? 24}"`,
86
+ `height="${i?.height ?? 24}"`,
87
+ `viewBox="0 0 ${l.width ?? 24} ${l.height ?? 24}"`
88
+ ];
89
+ if (r.attributes)
90
+ for (const [o, a] of Object.entries(r.attributes))
91
+ ["width", "height", "viewBox"].includes(o) || n.push(`${o}="${a}"`);
92
+ return `<svg ${n.join(" ")}>${r.body}</svg>`;
93
+ }
94
+ function I() {
95
+ w(p);
96
+ }
97
+ export {
98
+ k as getVizelIconId,
99
+ I as initVizelIconRenderer,
100
+ z as renderVizelIcon,
101
+ p as renderVizelIconSvg,
102
+ w as setVizelIconRenderer,
103
+ u as vizelDefaultIconIds
104
+ };
@@ -0,0 +1,136 @@
1
+ import { createVizelImageUploader as p } from "./index14.js";
2
+ function y(e) {
3
+ const { features: t, createSlashMenuRenderer: a } = e;
4
+ if (!t)
5
+ return {
6
+ slashCommand: {
7
+ suggestion: a()
8
+ }
9
+ };
10
+ if (t.slashCommand === !1)
11
+ return t;
12
+ const o = typeof t.slashCommand == "object" ? t.slashCommand : {};
13
+ return o.suggestion ? t : {
14
+ ...t,
15
+ slashCommand: {
16
+ ...o,
17
+ suggestion: a()
18
+ }
19
+ };
20
+ }
21
+ const f = (e) => e instanceof CustomEvent && typeof e.detail == "object" && e.detail !== null && "file" in e.detail && "editor" in e.detail;
22
+ function g(e) {
23
+ return (t) => {
24
+ const a = e.getEditor();
25
+ if (!a || !f(t)) return;
26
+ const { file: o } = t.detail, n = a.state.selection.from, r = e.getImageOptions();
27
+ p({
28
+ onUpload: r.onUpload ?? ((i) => new Promise((l) => {
29
+ const s = new FileReader();
30
+ s.onload = () => {
31
+ typeof s.result == "string" && l(s.result);
32
+ }, s.readAsDataURL(i);
33
+ })),
34
+ ...r.maxFileSize !== void 0 && { maxFileSize: r.maxFileSize },
35
+ ...r.allowedTypes !== void 0 && { allowedTypes: r.allowedTypes },
36
+ ...r.onValidationError !== void 0 && {
37
+ onValidationError: r.onValidationError
38
+ },
39
+ ...r.onUploadError !== void 0 && {
40
+ onUploadError: r.onUploadError
41
+ }
42
+ })(o, a.view, n);
43
+ };
44
+ }
45
+ const u = "vizel:upload-image";
46
+ function z(e) {
47
+ const t = g(e);
48
+ return document.addEventListener(u, t), () => {
49
+ document.removeEventListener(u, t);
50
+ };
51
+ }
52
+ const v = {
53
+ attributes: {
54
+ class: "vizel-editor"
55
+ }
56
+ };
57
+ function h(e) {
58
+ return "characterCount" in e && typeof e.characterCount == "object" && e.characterCount !== null && "characters" in e.characterCount && "words" in e.characterCount;
59
+ }
60
+ function U(e) {
61
+ if (!e)
62
+ return {
63
+ isFocused: !1,
64
+ isEmpty: !0,
65
+ canUndo: !1,
66
+ canRedo: !1,
67
+ characterCount: 0,
68
+ wordCount: 0
69
+ };
70
+ const t = e.storage;
71
+ let a = 0, o = 0;
72
+ return h(t) && (a = t.characterCount.characters(), o = t.characterCount.words()), {
73
+ isFocused: e.isFocused,
74
+ isEmpty: e.isEmpty,
75
+ canUndo: e.can().undo(),
76
+ canRedo: e.can().redo(),
77
+ characterCount: a,
78
+ wordCount: o
79
+ };
80
+ }
81
+ const d = {
82
+ mermaid: "mermaid",
83
+ dot: "graphviz",
84
+ graphviz: "graphviz"
85
+ };
86
+ function E(e) {
87
+ if (!e) return e;
88
+ const t = e.attrs?.language;
89
+ return e.type === "codeBlock" && t && t in d ? {
90
+ type: "diagram",
91
+ attrs: {
92
+ code: e.content?.map((o) => o.text || "").join("").trim() || "",
93
+ type: d[t]
94
+ }
95
+ } : e.content && Array.isArray(e.content) ? {
96
+ ...e,
97
+ content: e.content.map(E)
98
+ } : e;
99
+ }
100
+ function V(e) {
101
+ const t = e.schema.nodes.diagram;
102
+ if (!t) return;
103
+ const a = [];
104
+ if (e.state.doc.descendants((n, r) => {
105
+ if (n.type.name === "codeBlock") {
106
+ const c = n.attrs.language, i = c ? d[c] : void 0;
107
+ i && a.push({
108
+ from: r,
109
+ to: r + n.nodeSize,
110
+ code: n.textContent.trim(),
111
+ type: i
112
+ });
113
+ }
114
+ }), a.length === 0) return;
115
+ let { tr: o } = e.state;
116
+ for (let n = a.length - 1; n >= 0; n--) {
117
+ const r = a[n];
118
+ if (!r) continue;
119
+ const { from: c, to: i, code: l, type: s } = r, m = t.create({
120
+ code: l,
121
+ type: s
122
+ });
123
+ o = o.replaceWith(c, i, m);
124
+ }
125
+ e.view.dispatch(o);
126
+ }
127
+ export {
128
+ u as VIZEL_UPLOAD_IMAGE_EVENT,
129
+ V as convertVizelCodeBlocksToDiagrams,
130
+ g as createVizelUploadEventHandler,
131
+ U as getVizelEditorState,
132
+ z as registerVizelUploadEventHandler,
133
+ y as resolveVizelFeatures,
134
+ E as transformVizelDiagramCodeBlocks,
135
+ v as vizelDefaultEditorProps
136
+ };
@@ -0,0 +1,56 @@
1
+ import { Editor as E } from "@tiptap/core";
2
+ import { createVizelExtensions as w } from "./index11.js";
3
+ import { resolveVizelFeatures as D, vizelDefaultEditorProps as V } from "./index27.js";
4
+ import { initializeVizelMarkdownContent as F } from "./index29.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
+ };
53
+ }
54
+ export {
55
+ y as createVizelEditorInstance
56
+ };
@@ -0,0 +1,69 @@
1
+ import { transformVizelDiagramCodeBlocks as c, convertVizelCodeBlocksToDiagrams as d } from "./index27.js";
2
+ const m = 300;
3
+ function u(n) {
4
+ return typeof n.getMarkdown == "function";
5
+ }
6
+ function s(n) {
7
+ return n ? u(n) ? n.getMarkdown() : (console.warn(
8
+ "[Vizel] Markdown extension is not enabled. Enable it via features.markdown option."
9
+ ), "") : "";
10
+ }
11
+ function f(n, r, a = {}) {
12
+ if (!n) return;
13
+ const { transformDiagrams: t = !0 } = a;
14
+ if (!u(n)) {
15
+ console.warn(
16
+ "[Vizel] Markdown extension is not enabled. Enable it via features.markdown option."
17
+ );
18
+ return;
19
+ }
20
+ n.commands.setContent(r, { contentType: "markdown" }), t && d(n);
21
+ }
22
+ function g(n, r, a = {}) {
23
+ if (!n) return null;
24
+ const { transformDiagrams: t = !0 } = a, o = n.markdown;
25
+ if (!o?.parse)
26
+ return console.warn(
27
+ "[Vizel] Markdown extension is not enabled. Enable it via features.markdown option."
28
+ ), null;
29
+ const e = o.parse(r);
30
+ return t && e?.type ? c(e) : e;
31
+ }
32
+ function z(n, r, a = {}) {
33
+ const { transformDiagrams: t = !0 } = a;
34
+ f(n, r, { transformDiagrams: t });
35
+ }
36
+ function V(n = {}) {
37
+ const { debounceMs: r = m, transformDiagrams: a = !0 } = n;
38
+ let t = "", o = !1, e = null;
39
+ return {
40
+ handleUpdate: (i) => {
41
+ if (r === 0) {
42
+ t = s(i);
43
+ return;
44
+ }
45
+ o = !0, e && clearTimeout(e), e = setTimeout(() => {
46
+ t = s(i), o = !1, e = null;
47
+ }, r);
48
+ },
49
+ getMarkdown: () => t,
50
+ setMarkdown: (i, l) => {
51
+ e && (clearTimeout(e), e = null), o = !1, f(i, l, { transformDiagrams: a }), t = l;
52
+ },
53
+ isPending: () => o,
54
+ flush: (i) => {
55
+ e && (clearTimeout(e), e = null), t = s(i), o = !1;
56
+ },
57
+ destroy: () => {
58
+ e && (clearTimeout(e), e = null);
59
+ }
60
+ };
61
+ }
62
+ export {
63
+ m as VIZEL_DEFAULT_MARKDOWN_DEBOUNCE_MS,
64
+ V as createVizelMarkdownSyncHandlers,
65
+ s as getVizelMarkdown,
66
+ z as initializeVizelMarkdownContent,
67
+ g as parseVizelMarkdown,
68
+ f as setVizelMarkdown
69
+ };
package/dist/index3.js ADDED
@@ -0,0 +1,69 @@
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 {
16
+ }
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
+ }
58
+ export {
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
69
+ };
@@ -0,0 +1,40 @@
1
+ const o = "vizel-portal-root", i = {
2
+ /** Base layer for dropdowns and menus */
3
+ dropdown: 50,
4
+ /** Layer for modals and dialogs */
5
+ modal: 100,
6
+ /** Layer for tooltips (highest priority) */
7
+ tooltip: 150
8
+ };
9
+ function a() {
10
+ let e = document.getElementById(o);
11
+ return e || (e = document.createElement("div"), e.id = o, e.setAttribute("data-vizel-portal", ""), document.body.appendChild(e)), e;
12
+ }
13
+ function c() {
14
+ return document.getElementById(o) !== null;
15
+ }
16
+ function u() {
17
+ const e = document.getElementById(o);
18
+ e?.parentNode && e.parentNode.removeChild(e);
19
+ }
20
+ function d(e = "dropdown") {
21
+ const t = document.createElement("div");
22
+ return t.setAttribute("data-vizel-portal-layer", e), t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.zIndex = String(i[e]), t;
23
+ }
24
+ function m(e, t = {}) {
25
+ const { layer: r = "dropdown", className: l } = t, n = d(r);
26
+ return l && (n.className = l), n.appendChild(e), a().appendChild(n), n;
27
+ }
28
+ function s(e) {
29
+ e.parentNode && e.parentNode.removeChild(e);
30
+ }
31
+ export {
32
+ o as VIZEL_PORTAL_ID,
33
+ i as VIZEL_PORTAL_Z_INDEX,
34
+ d as createVizelPortalElement,
35
+ a as getVizelPortalContainer,
36
+ c as hasVizelPortalContainer,
37
+ m as mountToVizelPortal,
38
+ u as removeVizelPortalContainer,
39
+ s as unmountFromVizelPortal
40
+ };