@vizel/react 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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ React components for Vizel block-based Markdown editor.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @vizel/react @vizel/core
8
+ npm install @vizel/react
9
9
  ```
10
10
 
11
11
  ## Requirements
@@ -37,8 +37,8 @@ function App() {
37
37
 
38
38
  return (
39
39
  <>
40
- <VizelEditor editor={editor.current} />
41
- <VizelBubbleMenu editor={editor.current} />
40
+ <VizelEditor editor={editor} />
41
+ <VizelBubbleMenu editor={editor} />
42
42
  </>
43
43
  );
44
44
  }
@@ -51,14 +51,14 @@ import { useVizelEditor, useVizelMarkdown } from "@vizel/react";
51
51
 
52
52
  function App() {
53
53
  const editor = useVizelEditor();
54
- const { getMarkdown, setMarkdown } = useVizelMarkdown(() => editor.current);
54
+ const { getMarkdown, setMarkdown } = useVizelMarkdown(() => editor);
55
55
 
56
56
  const handleExport = () => {
57
57
  const markdown = getMarkdown();
58
58
  console.log(markdown);
59
59
  };
60
60
 
61
- return <VizelEditor editor={editor.current} />;
61
+ return <VizelEditor editor={editor} />;
62
62
  }
63
63
  ```
64
64
 
package/dist/index.d.ts CHANGED
@@ -24,6 +24,7 @@ import { VizelSlashCommandItem } from '@vizel/core';
24
24
  import { VizelSlashMenuRendererOptions } from '@vizel/core';
25
25
  import { VizelThemeProviderOptions } from '@vizel/core';
26
26
  import { VizelThemeState } from '@vizel/core';
27
+ import { VizelToolbarAction } from '@vizel/core';
27
28
 
28
29
  /**
29
30
  * Creates a suggestion render configuration for the SlashCommand extension.
@@ -333,7 +334,7 @@ export declare function useVizelThemeSafe(): VizelThemeState | null;
333
334
  * }
334
335
  * ```
335
336
  */
336
- export declare function Vizel({ ref, initialContent, initialMarkdown, transformDiagramsOnImport, placeholder, editable, autofocus, features, className, showBubbleMenu, enableEmbed, bubbleMenuContent, children, onUpdate, onCreate, onDestroy, onSelectionUpdate, onFocus, onBlur, }: VizelProps): ReactNode;
337
+ export declare function Vizel({ ref, initialContent, initialMarkdown, transformDiagramsOnImport, placeholder, editable, autofocus, features, className, showToolbar, toolbarContent, showBubbleMenu, enableEmbed, bubbleMenuContent, children, onUpdate, onCreate, onDestroy, onSelectionUpdate, onFocus, onBlur, }: VizelProps): ReactNode;
337
338
 
338
339
  /**
339
340
  * A floating menu that appears when text is selected.
@@ -766,6 +767,10 @@ export declare interface VizelProps {
766
767
  features?: VizelFeatureOptions;
767
768
  /** Custom class name for the editor container */
768
769
  className?: string;
770
+ /** Whether to show the toolbar (default: false) */
771
+ showToolbar?: boolean;
772
+ /** Custom toolbar content */
773
+ toolbarContent?: ReactNode;
769
774
  /** Whether to show the bubble menu (default: true) */
770
775
  showBubbleMenu?: boolean;
771
776
  /** Enable embed option in bubble menu link editor (requires Embed extension) */
@@ -962,4 +967,105 @@ export declare interface VizelThemeProviderProps extends VizelThemeProviderOptio
962
967
  children: ReactNode;
963
968
  }
964
969
 
970
+ /**
971
+ * Fixed toolbar component for the Vizel editor.
972
+ * Displays formatting buttons above the editor content area.
973
+ *
974
+ * @example
975
+ * ```tsx
976
+ * // Default toolbar with all formatting buttons
977
+ * <VizelToolbar editor={editor} />
978
+ *
979
+ * // Custom toolbar content
980
+ * <VizelToolbar editor={editor}>
981
+ * <VizelToolbarButton onClick={() => editor.chain().focus().toggleBold().run()}>
982
+ * <strong>B</strong>
983
+ * </VizelToolbarButton>
984
+ * </VizelToolbar>
985
+ * ```
986
+ */
987
+ export declare function VizelToolbar({ editor: editorProp, className, showDefaultToolbar, children, }: VizelToolbarProps): JSX.Element | null;
988
+
989
+ /**
990
+ * A button component for use in the VizelToolbar.
991
+ *
992
+ * @example
993
+ * ```tsx
994
+ * <VizelToolbarButton
995
+ * onClick={() => editor.chain().focus().toggleBold().run()}
996
+ * isActive={editor.isActive("bold")}
997
+ * title="Bold (Cmd+B)"
998
+ * >
999
+ * <VizelIcon name="bold" />
1000
+ * </VizelToolbarButton>
1001
+ * ```
1002
+ */
1003
+ export declare function VizelToolbarButton({ onClick, isActive, disabled, children, title, className, action, }: VizelToolbarButtonProps): JSX.Element;
1004
+
1005
+ export declare interface VizelToolbarButtonProps {
1006
+ /** Click handler */
1007
+ onClick?: () => void;
1008
+ /** Whether the action is currently active */
1009
+ isActive?: boolean;
1010
+ /** Whether the button is disabled */
1011
+ disabled?: boolean;
1012
+ /** Button content (typically an icon) */
1013
+ children: ReactNode;
1014
+ /** Tooltip text */
1015
+ title?: string;
1016
+ /** Additional CSS class name */
1017
+ className?: string;
1018
+ /** Action identifier for testing */
1019
+ action?: string;
1020
+ }
1021
+
1022
+ /**
1023
+ * The default toolbar content for VizelToolbar.
1024
+ * Provides formatting buttons grouped by category with dividers between groups.
1025
+ *
1026
+ * @example
1027
+ * ```tsx
1028
+ * <VizelToolbar>
1029
+ * <VizelToolbarDefault editor={editor} />
1030
+ * </VizelToolbar>
1031
+ * ```
1032
+ */
1033
+ export declare function VizelToolbarDefault({ editor, className, actions, }: VizelToolbarDefaultProps): JSX.Element;
1034
+
1035
+ export declare interface VizelToolbarDefaultProps {
1036
+ editor: Editor;
1037
+ className?: string;
1038
+ /** Custom toolbar actions (defaults to vizelDefaultToolbarActions) */
1039
+ actions?: VizelToolbarAction[];
1040
+ }
1041
+
1042
+ /**
1043
+ * A divider component for separating groups of buttons in the VizelToolbar.
1044
+ *
1045
+ * @example
1046
+ * ```tsx
1047
+ * <VizelToolbar>
1048
+ * <VizelToolbarButton>B</VizelToolbarButton>
1049
+ * <VizelToolbarDivider />
1050
+ * <VizelToolbarButton>H1</VizelToolbarButton>
1051
+ * </VizelToolbar>
1052
+ * ```
1053
+ */
1054
+ export declare function VizelToolbarDivider({ className }: VizelToolbarDividerProps): JSX.Element;
1055
+
1056
+ export declare interface VizelToolbarDividerProps {
1057
+ className?: string;
1058
+ }
1059
+
1060
+ export declare interface VizelToolbarProps {
1061
+ /** Editor instance. Falls back to context if not provided. */
1062
+ editor?: Editor | null;
1063
+ /** Additional CSS class name */
1064
+ className?: string;
1065
+ /** Whether to show the default toolbar (default: true). Set to false when using custom children. */
1066
+ showDefaultToolbar?: boolean;
1067
+ /** Custom toolbar content. When provided, replaces the default toolbar. */
1068
+ children?: ReactNode;
1069
+ }
1070
+
965
1071
  export { }
package/dist/index.js CHANGED
@@ -6,17 +6,17 @@ import "./index6.js";
6
6
  import "./index7.js";
7
7
  import "./index8.js";
8
8
  import "./index9.js";
9
- import { Vizel as f } from "./index10.js";
9
+ import { Vizel as z } from "./index10.js";
10
10
  import { VizelBubbleMenu as u } from "./index11.js";
11
11
  import { VizelBubbleMenuButton as a } from "./index12.js";
12
12
  import { VizelBubbleMenuColorPicker as d } from "./index13.js";
13
13
  import { VizelBubbleMenuDefault as S } from "./index14.js";
14
14
  import { VizelBubbleMenuDivider as c } from "./index15.js";
15
15
  import { VizelColorPicker as v } from "./index16.js";
16
- import { useVizelContext as E, useVizelContextSafe as P } from "./index17.js";
17
- import { VizelEditor as I } from "./index18.js";
18
- import { VizelEmbedView as T } from "./index19.js";
19
- import { VizelIcon as D } from "./index20.js";
16
+ import { useVizelContext as T, useVizelContextSafe as E } from "./index17.js";
17
+ import { VizelEditor as C } from "./index18.js";
18
+ import { VizelEmbedView as k } from "./index19.js";
19
+ import { VizelIcon as w } from "./index20.js";
20
20
  import { VizelIconProvider as A, useVizelIconContext as L } from "./index21.js";
21
21
  import { VizelLinkEditor as R } from "./index22.js";
22
22
  import { VizelNodeSelector as j } from "./index23.js";
@@ -27,23 +27,27 @@ import { VizelSlashMenu as Q } from "./index27.js";
27
27
  import { VizelSlashMenuEmpty as W } from "./index28.js";
28
28
  import { VizelSlashMenuItem as Y } from "./index29.js";
29
29
  import { VizelThemeProvider as _, useVizelTheme as $, useVizelThemeSafe as ee } from "./index30.js";
30
- import { createVizelSlashMenuRenderer as re } from "./index31.js";
31
- import { useVizelAutoSave as ie } from "./index32.js";
32
- import { useVizelEditor as me } from "./index33.js";
33
- import { useVizelEditorState as Ve } from "./index34.js";
34
- import { useVizelMarkdown as fe } from "./index35.js";
35
- import { useVizelState as ue } from "./index36.js";
30
+ import { VizelToolbar as re } from "./index31.js";
31
+ import { VizelToolbarButton as ie } from "./index32.js";
32
+ import { VizelToolbarDefault as me } from "./index33.js";
33
+ import { VizelToolbarDivider as Ve } from "./index34.js";
34
+ import { createVizelSlashMenuRenderer as ze } from "./index35.js";
35
+ import { useVizelAutoSave as ue } from "./index36.js";
36
+ import { useVizelEditor as ae } from "./index37.js";
37
+ import { useVizelEditorState as de } from "./index38.js";
38
+ import { useVizelMarkdown as Se } from "./index39.js";
39
+ import { useVizelState as ce } from "./index40.js";
36
40
  export {
37
- f as Vizel,
41
+ z as Vizel,
38
42
  u as VizelBubbleMenu,
39
43
  a as VizelBubbleMenuButton,
40
44
  d as VizelBubbleMenuColorPicker,
41
45
  S as VizelBubbleMenuDefault,
42
46
  c as VizelBubbleMenuDivider,
43
47
  v as VizelColorPicker,
44
- I as VizelEditor,
45
- T as VizelEmbedView,
46
- D as VizelIcon,
48
+ C as VizelEditor,
49
+ k as VizelEmbedView,
50
+ w as VizelIcon,
47
51
  A as VizelIconProvider,
48
52
  R as VizelLinkEditor,
49
53
  j as VizelNodeSelector,
@@ -54,15 +58,19 @@ export {
54
58
  W as VizelSlashMenuEmpty,
55
59
  Y as VizelSlashMenuItem,
56
60
  _ as VizelThemeProvider,
57
- re as createVizelSlashMenuRenderer,
58
- ie as useVizelAutoSave,
59
- E as useVizelContext,
60
- P as useVizelContextSafe,
61
- me as useVizelEditor,
62
- Ve as useVizelEditorState,
61
+ re as VizelToolbar,
62
+ ie as VizelToolbarButton,
63
+ me as VizelToolbarDefault,
64
+ Ve as VizelToolbarDivider,
65
+ ze as createVizelSlashMenuRenderer,
66
+ ue as useVizelAutoSave,
67
+ T as useVizelContext,
68
+ E as useVizelContextSafe,
69
+ ae as useVizelEditor,
70
+ de as useVizelEditorState,
63
71
  L as useVizelIconContext,
64
- fe as useVizelMarkdown,
65
- ue as useVizelState,
72
+ Se as useVizelMarkdown,
73
+ ce as useVizelState,
66
74
  $ as useVizelTheme,
67
75
  ee as useVizelThemeSafe
68
76
  };
package/dist/index10.js CHANGED
@@ -1,57 +1,62 @@
1
- import { jsxs as g, jsx as o } from "react/jsx-runtime";
2
- import { useImperativeHandle as h } from "react";
3
- import { useVizelEditor as q } from "./index33.js";
4
- import { VizelBubbleMenu as j } from "./index11.js";
5
- import { VizelEditor as u } from "./index18.js";
6
- function O({
7
- ref: e,
8
- initialContent: v,
9
- initialMarkdown: d,
10
- transformDiagramsOnImport: E = !0,
11
- placeholder: m,
12
- editable: H = !0,
13
- autofocus: I = !1,
14
- features: f,
15
- className: N,
16
- showBubbleMenu: s = !0,
17
- enableEmbed: z = !1,
18
- bubbleMenuContent: r,
19
- children: $,
20
- onUpdate: t,
21
- onCreate: p,
22
- onDestroy: V,
23
- onSelectionUpdate: l,
24
- onFocus: x,
25
- onBlur: c
1
+ import { jsxs as u, jsx as r } from "react/jsx-runtime";
2
+ import { useImperativeHandle as A } from "react";
3
+ import { useVizelEditor as G } from "./index37.js";
4
+ import { VizelBubbleMenu as H } from "./index11.js";
5
+ import { VizelEditor as J } from "./index18.js";
6
+ import { VizelToolbar as I } from "./index31.js";
7
+ function T({
8
+ ref: N,
9
+ initialContent: m,
10
+ initialMarkdown: o,
11
+ transformDiagramsOnImport: $ = !0,
12
+ placeholder: f,
13
+ editable: g = !0,
14
+ autofocus: h = !1,
15
+ features: z,
16
+ className: q,
17
+ showToolbar: s = !1,
18
+ toolbarContent: d,
19
+ showBubbleMenu: p = !0,
20
+ enableEmbed: V = !1,
21
+ bubbleMenuContent: v,
22
+ children: t,
23
+ onUpdate: l,
24
+ onCreate: c,
25
+ onDestroy: x,
26
+ onSelectionUpdate: e,
27
+ onFocus: j,
28
+ onBlur: E
26
29
  }) {
27
- const i = q({
28
- ...v !== void 0 && { initialContent: v },
29
- ...d !== void 0 && { initialMarkdown: d },
30
- transformDiagramsOnImport: E,
31
- ...m !== void 0 && { placeholder: m },
32
- editable: H,
33
- autofocus: I,
34
- ...f !== void 0 && { features: f },
35
- ...t !== void 0 && { onUpdate: t },
36
- ...p !== void 0 && { onCreate: p },
37
- ...V !== void 0 && { onDestroy: V },
38
- ...l !== void 0 && { onSelectionUpdate: l },
39
- ...x !== void 0 && { onFocus: x },
40
- ...c !== void 0 && { onBlur: c }
30
+ const i = G({
31
+ ...m !== void 0 && { initialContent: m },
32
+ ...o !== void 0 && { initialMarkdown: o },
33
+ transformDiagramsOnImport: $,
34
+ ...f !== void 0 && { placeholder: f },
35
+ editable: g,
36
+ autofocus: h,
37
+ ...z !== void 0 && { features: z },
38
+ ...l !== void 0 && { onUpdate: l },
39
+ ...c !== void 0 && { onCreate: c },
40
+ ...x !== void 0 && { onDestroy: x },
41
+ ...e !== void 0 && { onSelectionUpdate: e },
42
+ ...j !== void 0 && { onFocus: j },
43
+ ...E !== void 0 && { onBlur: E }
41
44
  });
42
- return h(
43
- e,
45
+ return A(
46
+ N,
44
47
  () => ({
45
48
  editor: i
46
49
  }),
47
50
  [i]
48
- ), /* @__PURE__ */ g("div", { className: `vizel-root ${N ?? ""}`, "data-vizel-root": "", children: [
49
- /* @__PURE__ */ o(u, { editor: i }),
50
- s && i && r && /* @__PURE__ */ o(j, { editor: i, enableEmbed: z, children: r }),
51
- s && i && !r && /* @__PURE__ */ o(j, { editor: i, enableEmbed: z }),
52
- $
51
+ ), /* @__PURE__ */ u("div", { className: `vizel-root ${q ?? ""}`, "data-vizel-root": "", children: [
52
+ s && i && d && /* @__PURE__ */ r(I, { editor: i, children: d }),
53
+ s && i && !d && /* @__PURE__ */ r(I, { editor: i }),
54
+ /* @__PURE__ */ r(J, { editor: i }),
55
+ p && i && v && /* @__PURE__ */ r(H, { editor: i, enableEmbed: V, children: v }),
56
+ p && i && !v && /* @__PURE__ */ r(H, { editor: i, enableEmbed: V }),
57
+ t
53
58
  ] });
54
59
  }
55
60
  export {
56
- O as Vizel
61
+ T as Vizel
57
62
  };
package/dist/index14.js CHANGED
@@ -1,91 +1,95 @@
1
- import { jsx as e, jsxs as u } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as m } from "react/jsx-runtime";
2
2
  import { useState as a } from "react";
3
- import { useVizelState as m } from "./index36.js";
4
- import { VizelBubbleMenuButton as t } from "./index12.js";
5
- import { VizelBubbleMenuColorPicker as o } from "./index13.js";
6
- import { VizelIcon as l } from "./index20.js";
7
- import { VizelLinkEditor as h } from "./index22.js";
3
+ import { useVizelState as h } from "./index40.js";
4
+ import { VizelBubbleMenuButton as l } from "./index12.js";
5
+ import { VizelBubbleMenuColorPicker as r } from "./index13.js";
6
+ import { VizelBubbleMenuDivider as n } from "./index15.js";
7
+ import { VizelIcon as t } from "./index20.js";
8
+ import { VizelLinkEditor as f } from "./index22.js";
8
9
  import { VizelNodeSelector as k } from "./index23.js";
9
- function z({
10
- editor: i,
11
- className: r,
12
- enableEmbed: n
10
+ function V({
11
+ editor: e,
12
+ className: s,
13
+ enableEmbed: o
13
14
  }) {
14
- m(() => i);
15
- const [s, c] = a(!1);
16
- return s ? /* @__PURE__ */ e(
17
- h,
15
+ h(() => e);
16
+ const [u, c] = a(!1);
17
+ return u ? /* @__PURE__ */ i(
18
+ f,
18
19
  {
19
- editor: i,
20
+ editor: e,
20
21
  onClose: () => c(!1),
21
- ...n ? { enableEmbed: n } : {}
22
+ ...o ? { enableEmbed: o } : {}
22
23
  }
23
- ) : /* @__PURE__ */ u("div", { className: `vizel-bubble-menu-toolbar ${r ?? ""}`, children: [
24
- /* @__PURE__ */ e(k, { editor: i }),
25
- /* @__PURE__ */ e(
26
- t,
24
+ ) : /* @__PURE__ */ m("div", { className: `vizel-bubble-menu-toolbar ${s ?? ""}`, children: [
25
+ /* @__PURE__ */ i(k, { editor: e }),
26
+ /* @__PURE__ */ i(n, {}),
27
+ /* @__PURE__ */ i(
28
+ l,
27
29
  {
28
30
  action: "bold",
29
- onClick: () => i.chain().focus().toggleBold().run(),
30
- isActive: i.isActive("bold"),
31
+ onClick: () => e.chain().focus().toggleBold().run(),
32
+ isActive: e.isActive("bold"),
31
33
  title: "Bold (Cmd+B)",
32
- children: /* @__PURE__ */ e(l, { name: "bold" })
34
+ children: /* @__PURE__ */ i(t, { name: "bold" })
33
35
  }
34
36
  ),
35
- /* @__PURE__ */ e(
36
- t,
37
+ /* @__PURE__ */ i(
38
+ l,
37
39
  {
38
40
  action: "italic",
39
- onClick: () => i.chain().focus().toggleItalic().run(),
40
- isActive: i.isActive("italic"),
41
+ onClick: () => e.chain().focus().toggleItalic().run(),
42
+ isActive: e.isActive("italic"),
41
43
  title: "Italic (Cmd+I)",
42
- children: /* @__PURE__ */ e(l, { name: "italic" })
44
+ children: /* @__PURE__ */ i(t, { name: "italic" })
43
45
  }
44
46
  ),
45
- /* @__PURE__ */ e(
46
- t,
47
+ /* @__PURE__ */ i(
48
+ l,
47
49
  {
48
50
  action: "strike",
49
- onClick: () => i.chain().focus().toggleStrike().run(),
50
- isActive: i.isActive("strike"),
51
+ onClick: () => e.chain().focus().toggleStrike().run(),
52
+ isActive: e.isActive("strike"),
51
53
  title: "Strikethrough",
52
- children: /* @__PURE__ */ e(l, { name: "strikethrough" })
54
+ children: /* @__PURE__ */ i(t, { name: "strikethrough" })
53
55
  }
54
56
  ),
55
- /* @__PURE__ */ e(
56
- t,
57
+ /* @__PURE__ */ i(
58
+ l,
57
59
  {
58
60
  action: "underline",
59
- onClick: () => i.chain().focus().toggleUnderline().run(),
60
- isActive: i.isActive("underline"),
61
+ onClick: () => e.chain().focus().toggleUnderline().run(),
62
+ isActive: e.isActive("underline"),
61
63
  title: "Underline (Cmd+U)",
62
- children: /* @__PURE__ */ e(l, { name: "underline" })
64
+ children: /* @__PURE__ */ i(t, { name: "underline" })
63
65
  }
64
66
  ),
65
- /* @__PURE__ */ e(
66
- t,
67
+ /* @__PURE__ */ i(
68
+ l,
67
69
  {
68
70
  action: "code",
69
- onClick: () => i.chain().focus().toggleCode().run(),
70
- isActive: i.isActive("code"),
71
+ onClick: () => e.chain().focus().toggleCode().run(),
72
+ isActive: e.isActive("code"),
71
73
  title: "Code (Cmd+E)",
72
- children: /* @__PURE__ */ e(l, { name: "code" })
74
+ children: /* @__PURE__ */ i(t, { name: "code" })
73
75
  }
74
76
  ),
75
- /* @__PURE__ */ e(
76
- t,
77
+ /* @__PURE__ */ i(n, {}),
78
+ /* @__PURE__ */ i(
79
+ l,
77
80
  {
78
81
  action: "link",
79
82
  onClick: () => c(!0),
80
- isActive: i.isActive("link"),
83
+ isActive: e.isActive("link"),
81
84
  title: "Link (Cmd+K)",
82
- children: /* @__PURE__ */ e(l, { name: "link" })
85
+ children: /* @__PURE__ */ i(t, { name: "link" })
83
86
  }
84
87
  ),
85
- /* @__PURE__ */ e(o, { editor: i, type: "textColor" }),
86
- /* @__PURE__ */ e(o, { editor: i, type: "highlight" })
88
+ /* @__PURE__ */ i(n, {}),
89
+ /* @__PURE__ */ i(r, { editor: e, type: "textColor" }),
90
+ /* @__PURE__ */ i(r, { editor: e, type: "highlight" })
87
91
  ] });
88
92
  }
89
93
  export {
90
- z as VizelBubbleMenuDefault
94
+ V as VizelBubbleMenuDefault
91
95
  };
package/dist/index2.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Mark as a, markPasteRule as r, markInputRule as s, mergeAttributes as o } from "@tiptap/core";
2
- import { createElement as n } from "./index37.js";
2
+ import { createElement as n } from "./index41.js";
3
3
  var d = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, i = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, l = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, u = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;
4
4
  a.create({
5
5
  name: "bold",
package/dist/index23.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsxs as p, jsx as n } from "react/jsx-runtime";
2
2
  import { getVizelActiveNodeType as x, vizelDefaultNodeTypes as E } from "@vizel/core";
3
3
  import { useState as z, useRef as N, useEffect as w } from "react";
4
- import { useVizelState as y } from "./index36.js";
4
+ import { useVizelState as y } from "./index40.js";
5
5
  import { VizelIcon as s } from "./index20.js";
6
6
  function $({
7
7
  editor: c,
package/dist/index31.js CHANGED
@@ -1,36 +1,15 @@
1
- import { handleVizelSuggestionEscape as u, createVizelSuggestionContainer as m } from "@vizel/core";
2
- import { createElement as c } from "react";
3
- import { c as s } from "./index38.js";
4
- import { VizelSlashMenu as d } from "./index27.js";
5
- function z(l = {}) {
6
- return {
7
- render: () => {
8
- let t = null, n = null, o = [], r = null;
9
- const i = { current: null }, a = () => {
10
- t && r && t.render(
11
- c(d, {
12
- items: o,
13
- command: r,
14
- ...l.className !== void 0 && { className: l.className },
15
- ref: i
16
- })
17
- );
18
- };
19
- return {
20
- onStart: (e) => {
21
- o = e.items, r = e.command, n = m(), t = s.createRoot(n.menuContainer), a(), n.updatePosition(e.clientRect);
22
- },
23
- onUpdate: (e) => {
24
- o = e.items, r = e.command, a(), n?.updatePosition(e.clientRect);
25
- },
26
- onKeyDown: (e) => u(e.event) ? !0 : i.current?.onKeyDown(e) ?? !1,
27
- onExit: () => {
28
- t?.unmount(), n?.destroy(), t = null, n = null;
29
- }
30
- };
31
- }
32
- };
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useVizelContextSafe as n } from "./index17.js";
3
+ import { VizelToolbarDefault as m } from "./index33.js";
4
+ function s({
5
+ editor: t,
6
+ className: e,
7
+ showDefaultToolbar: l = !0,
8
+ children: i
9
+ }) {
10
+ const a = n(), o = t ?? a?.editor ?? null;
11
+ return o ? /* @__PURE__ */ r("div", { className: `vizel-toolbar ${e ?? ""}`, role: "toolbar", "aria-label": "Formatting", children: i ?? (l && /* @__PURE__ */ r(m, { editor: o })) }) : null;
33
12
  }
34
13
  export {
35
- z as createVizelSlashMenuRenderer
14
+ s as VizelToolbar
36
15
  };
package/dist/index32.js CHANGED
@@ -1,53 +1,28 @@
1
- import { VIZEL_DEFAULT_AUTO_SAVE_OPTIONS as c, createVizelAutoSaveHandlers as y } from "@vizel/core";
2
- import { useRef as h, useState as A, useCallback as u, useMemo as C, useEffect as R } from "react";
3
- function M(s, t = {}) {
4
- const r = h(t);
5
- r.current = t;
6
- const n = t.enabled ?? c.enabled, d = t.debounceMs ?? c.debounceMs, l = t.storage ?? c.storage, v = t.key ?? c.key, [o, b] = A({
7
- status: "saved",
8
- hasUnsavedChanges: !1,
9
- lastSaved: null,
10
- error: null
11
- }), f = h(s);
12
- f.current = s;
13
- const S = u((e) => {
14
- b((m) => ({ ...m, ...e }));
15
- }, []), a = C(
16
- () => y(
17
- () => f.current(),
18
- {
19
- enabled: n,
20
- debounceMs: d,
21
- storage: l,
22
- key: v,
23
- // Access callbacks through ref to avoid dependency on them
24
- onSave: (e) => r.current.onSave?.(e),
25
- onError: (e) => r.current.onError?.(e),
26
- onRestore: (e) => r.current.onRestore?.(e)
27
- },
28
- S
29
- ),
30
- [n, d, l, v, S]
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ function u({
3
+ onClick: a,
4
+ isActive: t = !1,
5
+ disabled: o = !1,
6
+ children: e,
7
+ title: r,
8
+ className: n,
9
+ action: l
10
+ }) {
11
+ return /* @__PURE__ */ i(
12
+ "button",
13
+ {
14
+ type: "button",
15
+ onClick: a,
16
+ disabled: o,
17
+ "aria-pressed": t,
18
+ className: `vizel-toolbar-button ${t ? "is-active" : ""} ${n ?? ""}`,
19
+ title: r,
20
+ "data-active": t || void 0,
21
+ "data-action": l,
22
+ children: e
23
+ }
31
24
  );
32
- R(() => {
33
- const e = s();
34
- if (e && n)
35
- return e.on("update", a.handleUpdate), () => {
36
- e.off("update", a.handleUpdate), a.cancel();
37
- };
38
- }, [s, n, a]);
39
- const U = u(async () => {
40
- await a.saveNow();
41
- }, [a]), g = u(async () => await a.restore(), [a]);
42
- return {
43
- status: o.status,
44
- hasUnsavedChanges: o.hasUnsavedChanges,
45
- lastSaved: o.lastSaved,
46
- error: o.error,
47
- save: U,
48
- restore: g
49
- };
50
25
  }
51
26
  export {
52
- M as useVizelAutoSave
27
+ u as VizelToolbarButton
53
28
  };