@vizel/react 0.0.1-alpha.6 → 1.1.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 (49) hide show
  1. package/README.md +41 -17
  2. package/dist/index.d.ts +331 -1
  3. package/dist/index.js +63 -47
  4. package/dist/index10.js +52 -45
  5. package/dist/index13.js +1 -1
  6. package/dist/index14.js +55 -51
  7. package/dist/index16.js +1 -1
  8. package/dist/index19.js +1 -1
  9. package/dist/index2.js +1 -1
  10. package/dist/index20.js +152 -8
  11. package/dist/index21.js +8 -10
  12. package/dist/index22.js +10 -78
  13. package/dist/index23.js +75 -112
  14. package/dist/index24.js +112 -32
  15. package/dist/index25.js +35 -5
  16. package/dist/index26.js +5 -68
  17. package/dist/index27.js +65 -88
  18. package/dist/index28.js +91 -4
  19. package/dist/index29.js +4 -36
  20. package/dist/index30.js +34 -51
  21. package/dist/index31.js +53 -33
  22. package/dist/index32.js +12 -50
  23. package/dist/index33.js +25 -29
  24. package/dist/index34.js +30 -7
  25. package/dist/index35.js +4 -52
  26. package/dist/index36.js +32 -10
  27. package/dist/index37.js +51 -15
  28. package/dist/index38.js +49 -3
  29. package/dist/index39.js +71 -20
  30. package/dist/index40.js +46 -2
  31. package/dist/index41.js +7 -9741
  32. package/dist/index42.js +52 -17015
  33. package/dist/index43.js +12 -2
  34. package/dist/index44.js +53 -7
  35. package/dist/index45.js +15 -2
  36. package/dist/index46.js +3 -2
  37. package/dist/index47.js +18 -219
  38. package/dist/index48.js +2 -225
  39. package/dist/index49.js +9742 -2
  40. package/dist/index50.js +17016 -2
  41. package/dist/index51.js +4 -0
  42. package/dist/index52.js +10 -0
  43. package/dist/index53.js +4 -0
  44. package/dist/index54.js +4 -0
  45. package/dist/index55.js +224 -0
  46. package/dist/index56.js +227 -0
  47. package/dist/index57.js +4 -0
  48. package/dist/index58.js +4 -0
  49. package/package.json +36 -16
package/dist/index10.js CHANGED
@@ -1,57 +1,64 @@
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({
1
+ import { jsxs as G, jsx as r } from "react/jsx-runtime";
2
+ import { useImperativeHandle as J } from "react";
3
+ import { useVizelEditor as K } from "./index40.js";
4
+ import { VizelBubbleMenu as N } from "./index11.js";
5
+ import { VizelEditor as L } from "./index18.js";
6
+ import { VizelToolbar as $ } from "./index32.js";
7
+ function X({
7
8
  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
9
+ initialContent: m,
10
+ initialMarkdown: o,
11
+ transformDiagramsOnImport: g = !0,
12
+ placeholder: f,
13
+ editable: h = !0,
14
+ autofocus: q = !1,
15
+ features: z,
16
+ extensions: p,
17
+ className: u,
18
+ showToolbar: V = !1,
19
+ toolbarContent: d,
20
+ showBubbleMenu: l = !0,
21
+ enableEmbed: s = !1,
22
+ bubbleMenuContent: v,
23
+ children: A,
24
+ onUpdate: c,
25
+ onCreate: j,
26
+ onDestroy: x,
27
+ onSelectionUpdate: E,
28
+ onFocus: H,
29
+ onBlur: I
26
30
  }) {
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 }
31
+ const i = K({
32
+ ...m !== void 0 && { initialContent: m },
33
+ ...o !== void 0 && { initialMarkdown: o },
34
+ transformDiagramsOnImport: g,
35
+ ...f !== void 0 && { placeholder: f },
36
+ editable: h,
37
+ autofocus: q,
38
+ ...z !== void 0 && { features: z },
39
+ ...p !== void 0 && { extensions: p },
40
+ ...c !== void 0 && { onUpdate: c },
41
+ ...j !== void 0 && { onCreate: j },
42
+ ...x !== void 0 && { onDestroy: x },
43
+ ...E !== void 0 && { onSelectionUpdate: E },
44
+ ...H !== void 0 && { onFocus: H },
45
+ ...I !== void 0 && { onBlur: I }
41
46
  });
42
- return h(
47
+ return J(
43
48
  e,
44
49
  () => ({
45
50
  editor: i
46
51
  }),
47
52
  [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
- $
53
+ ), /* @__PURE__ */ G("div", { className: `vizel-root ${u ?? ""}`, "data-vizel-root": "", children: [
54
+ V && i && d && /* @__PURE__ */ r($, { editor: i, children: d }),
55
+ V && i && !d && /* @__PURE__ */ r($, { editor: i }),
56
+ /* @__PURE__ */ r(L, { editor: i }),
57
+ l && i && v && /* @__PURE__ */ r(N, { editor: i, enableEmbed: s, children: v }),
58
+ l && i && !v && /* @__PURE__ */ r(N, { editor: i, enableEmbed: s }),
59
+ A
53
60
  ] });
54
61
  }
55
62
  export {
56
- O as Vizel
63
+ X as Vizel
57
64
  };
package/dist/index13.js CHANGED
@@ -2,7 +2,7 @@ import { jsxs as V, jsx as l } from "react/jsx-runtime";
2
2
  import { getVizelRecentColors as H, addVizelRecentColor as u, VIZEL_TEXT_COLORS as L, VIZEL_HIGHLIGHT_COLORS as O } from "@vizel/core";
3
3
  import { useState as h, useRef as E, useEffect as g, useCallback as I } from "react";
4
4
  import { VizelColorPicker as T } from "./index16.js";
5
- import { VizelIcon as C } from "./index20.js";
5
+ import { VizelIcon as C } from "./index21.js";
6
6
  function A({
7
7
  editor: o,
8
8
  type: e,
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";
8
- import { VizelNodeSelector as k } from "./index23.js";
9
- function z({
10
- editor: i,
11
- className: r,
12
- enableEmbed: n
3
+ import { useVizelState as h } from "./index43.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 "./index21.js";
8
+ import { VizelLinkEditor as f } from "./index23.js";
9
+ import { VizelNodeSelector as k } from "./index24.js";
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/index16.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsxs as z, jsx as l } from "react/jsx-runtime";
2
2
  import { normalizeVizelHexColor as N, isVizelValidHexColor as I } from "@vizel/core";
3
3
  import { useState as K, useRef as L, useMemo as $, useEffect as y, useCallback as b } from "react";
4
- import { VizelIcon as w } from "./index20.js";
4
+ import { VizelIcon as w } from "./index21.js";
5
5
  const S = 4, j = ["transparent", "inherit"];
6
6
  function q({
7
7
  colors: f,
package/dist/index19.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as i, jsxs as s } from "react/jsx-runtime";
2
2
  import { useRef as a, useEffect as v } from "react";
3
- import { VizelIcon as p } from "./index20.js";
3
+ import { VizelIcon as p } from "./index21.js";
4
4
  const b = (r, e, n) => `vizel-embed ${r ? "is-loading" : ""} ${e ? "ProseMirror-selectednode" : ""} ${n ?? ""}`, h = (r, e) => /* @__PURE__ */ i("div", { className: r, "data-embed-type": "loading", "data-embed-provider": e, children: /* @__PURE__ */ s("div", { className: "vizel-embed-loading", children: [
5
5
  /* @__PURE__ */ i("div", { className: "vizel-embed-loading-spinner" }),
6
6
  /* @__PURE__ */ i("span", { children: "Loading embed..." })
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 "./index45.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/index20.js CHANGED
@@ -1,11 +1,155 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { Icon as s } from "@iconify/react";
3
- import { vizelDefaultIconIds as I } from "@vizel/core";
4
- import { useVizelIconContext as m } from "./index21.js";
5
- function x({ name: o, customIcons: t, style: n, ...c }) {
6
- const { customIcons: r } = m(), e = t?.[o] ?? r?.[o] ?? I[o];
7
- return /* @__PURE__ */ i(s, { icon: e, style: { pointerEvents: "none", ...n }, ...c });
1
+ import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
+ import { getVizelFindReplaceState as D } from "@vizel/core";
3
+ import { useState as d, useRef as I, useEffect as C, useCallback as l } from "react";
4
+ function O({ editor: e, className: N, onClose: h }) {
5
+ const [p, v] = d(""), [s, b] = d(""), [R, z] = d(!1), [t, F] = d(null), r = I(null);
6
+ C(() => {
7
+ if (!e) return;
8
+ const n = () => {
9
+ const c = D(e.state);
10
+ F(c);
11
+ };
12
+ return n(), e.on("transaction", n), () => {
13
+ e.off("transaction", n);
14
+ };
15
+ }, [e]), C(() => {
16
+ t?.isOpen && (r.current?.focus(), r.current?.select());
17
+ }, [t?.isOpen]);
18
+ const y = l(
19
+ (n) => {
20
+ const c = n.target.value;
21
+ v(c), e && e.commands.find(c);
22
+ },
23
+ [e]
24
+ ), u = l(() => {
25
+ e?.commands.findNext();
26
+ }, [e]), f = l(() => {
27
+ e?.commands.findPrevious();
28
+ }, [e]), k = l(() => {
29
+ e && (e.commands.replace(s), e.commands.findNext());
30
+ }, [e, s]), g = l(() => {
31
+ e && e.commands.replaceAll(s);
32
+ }, [e, s]), m = l(() => {
33
+ e && (e.commands.clearFind(), e.commands.closeFindReplace()), v(""), b(""), h?.();
34
+ }, [e, h]), S = l(
35
+ (n) => {
36
+ const c = n.target.checked;
37
+ z(c), e?.commands.setFindCaseSensitive(c), p && e?.commands.find(p);
38
+ },
39
+ [e, p]
40
+ ), x = l(
41
+ (n) => {
42
+ n.key === "Enter" ? (n.preventDefault(), n.shiftKey ? f() : u()) : n.key === "Escape" && (n.preventDefault(), m());
43
+ },
44
+ [u, f, m]
45
+ );
46
+ if (!t?.isOpen)
47
+ return null;
48
+ const i = t.matches.length, w = t.activeIndex >= 0 ? t.activeIndex + 1 : 0, E = t.mode === "replace";
49
+ return /* @__PURE__ */ o(
50
+ "div",
51
+ {
52
+ className: `vizel-find-replace-panel ${N || ""}`,
53
+ role: "dialog",
54
+ "aria-label": "Find and Replace",
55
+ children: [
56
+ /* @__PURE__ */ o("div", { className: "vizel-find-replace-row", children: [
57
+ /* @__PURE__ */ a(
58
+ "input",
59
+ {
60
+ ref: r,
61
+ type: "text",
62
+ className: "vizel-find-replace-input",
63
+ placeholder: "Find...",
64
+ value: p,
65
+ onChange: y,
66
+ onKeyDown: x,
67
+ "aria-label": "Find text"
68
+ }
69
+ ),
70
+ /* @__PURE__ */ a("span", { className: "vizel-find-replace-count", children: i > 0 ? `${w}/${i}` : "No results" }),
71
+ /* @__PURE__ */ a(
72
+ "button",
73
+ {
74
+ type: "button",
75
+ className: "vizel-find-replace-button",
76
+ onClick: f,
77
+ disabled: i === 0,
78
+ "aria-label": "Find previous",
79
+ title: "Find previous (Shift+Enter)",
80
+ children: "↑"
81
+ }
82
+ ),
83
+ /* @__PURE__ */ a(
84
+ "button",
85
+ {
86
+ type: "button",
87
+ className: "vizel-find-replace-button",
88
+ onClick: u,
89
+ disabled: i === 0,
90
+ "aria-label": "Find next",
91
+ title: "Find next (Enter)",
92
+ children: "↓"
93
+ }
94
+ ),
95
+ /* @__PURE__ */ a(
96
+ "button",
97
+ {
98
+ type: "button",
99
+ className: "vizel-find-replace-button",
100
+ onClick: m,
101
+ "aria-label": "Close",
102
+ title: "Close (Escape)",
103
+ children: "✕"
104
+ }
105
+ )
106
+ ] }),
107
+ E && /* @__PURE__ */ o("div", { className: "vizel-find-replace-row", children: [
108
+ /* @__PURE__ */ a(
109
+ "input",
110
+ {
111
+ type: "text",
112
+ className: "vizel-find-replace-input",
113
+ placeholder: "Replace with...",
114
+ value: s,
115
+ onChange: (n) => b(n.target.value),
116
+ onKeyDown: x,
117
+ "aria-label": "Replace text"
118
+ }
119
+ ),
120
+ /* @__PURE__ */ a(
121
+ "button",
122
+ {
123
+ type: "button",
124
+ className: "vizel-find-replace-button",
125
+ onClick: k,
126
+ disabled: i === 0,
127
+ "aria-label": "Replace",
128
+ title: "Replace current match",
129
+ children: "Replace"
130
+ }
131
+ ),
132
+ /* @__PURE__ */ a(
133
+ "button",
134
+ {
135
+ type: "button",
136
+ className: "vizel-find-replace-button vizel-find-replace-button--primary",
137
+ onClick: g,
138
+ disabled: i === 0,
139
+ "aria-label": "Replace all",
140
+ title: "Replace all matches",
141
+ children: "All"
142
+ }
143
+ )
144
+ ] }),
145
+ /* @__PURE__ */ a("div", { className: "vizel-find-replace-options", children: /* @__PURE__ */ o("label", { className: "vizel-find-replace-checkbox", children: [
146
+ /* @__PURE__ */ a("input", { type: "checkbox", checked: R, onChange: S }),
147
+ "Case sensitive"
148
+ ] }) })
149
+ ]
150
+ }
151
+ );
8
152
  }
9
153
  export {
10
- x as VizelIcon
154
+ O as VizelFindReplace
11
155
  };
package/dist/index21.js CHANGED
@@ -1,13 +1,11 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { createContext as r, useContext as c } from "react";
3
- const o = r({});
4
- function s({ icons: t, children: e }) {
5
- return /* @__PURE__ */ n(o.Provider, { value: { customIcons: t }, children: e });
6
- }
7
- function x() {
8
- return c(o);
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { Icon as s } from "@iconify/react";
3
+ import { vizelDefaultIconIds as I } from "@vizel/core";
4
+ import { useVizelIconContext as m } from "./index22.js";
5
+ function x({ name: o, customIcons: t, style: n, ...c }) {
6
+ const { customIcons: r } = m(), e = t?.[o] ?? r?.[o] ?? I[o];
7
+ return /* @__PURE__ */ i(s, { icon: e, style: { pointerEvents: "none", ...n }, ...c });
9
8
  }
10
9
  export {
11
- s as VizelIconProvider,
12
- x as useVizelIconContext
10
+ x as VizelIcon
13
11
  };
package/dist/index22.js CHANGED
@@ -1,81 +1,13 @@
1
- import { jsxs as a, jsx as i } from "react/jsx-runtime";
2
- import { detectVizelEmbedProvider as R } from "@vizel/core";
3
- import { useState as h, useRef as k, useMemo as v, useEffect as b, useCallback as p } from "react";
4
- import { VizelIcon as g } from "./index20.js";
5
- function P({
6
- editor: e,
7
- onClose: n,
8
- className: E,
9
- enableEmbed: m = !1
10
- }) {
11
- const d = e.getAttributes("link").href || "", [s, z] = h(d), [l, L] = h(!1), u = k(null), f = k(null), o = v(() => m ? e.extensionManager.extensions.some((r) => r.name === "embed") : !1, [e, m]), x = v(() => s.trim() ? R(s.trim()) !== null : !1, [s]);
12
- b(() => {
13
- f.current?.focus();
14
- }, []), b(() => {
15
- const t = (c) => {
16
- u.current && !u.current.contains(c.target) && n();
17
- }, r = (c) => {
18
- c.key === "Escape" && (c.preventDefault(), c.stopImmediatePropagation(), n());
19
- }, N = setTimeout(() => {
20
- document.addEventListener("mousedown", t);
21
- }, 0);
22
- return document.addEventListener("keydown", r, !0), () => {
23
- clearTimeout(N), document.removeEventListener("mousedown", t), document.removeEventListener("keydown", r, !0);
24
- };
25
- }, [n]);
26
- const y = p(
27
- (t) => {
28
- t.preventDefault();
29
- const r = s.trim();
30
- if (!r) {
31
- e.chain().focus().unsetLink().run(), n();
32
- return;
33
- }
34
- l && o ? e.chain().focus().unsetLink().setEmbed({ url: r }).run() : e.chain().focus().setLink({ href: r }).run(), n();
35
- },
36
- [e, s, l, o, n]
37
- ), w = p(() => {
38
- e.chain().focus().unsetLink().run(), n();
39
- }, [e, n]);
40
- return /* @__PURE__ */ a("form", { ref: u, onSubmit: y, className: `vizel-link-editor ${E ?? ""}`, children: [
41
- /* @__PURE__ */ a("div", { className: "vizel-link-editor-row", children: [
42
- /* @__PURE__ */ i(
43
- "input",
44
- {
45
- ref: f,
46
- type: "url",
47
- value: s,
48
- onChange: (t) => z(t.target.value),
49
- placeholder: "Enter URL...",
50
- className: "vizel-link-input"
51
- }
52
- ),
53
- /* @__PURE__ */ i("button", { type: "submit", className: "vizel-link-button", title: "Apply", children: /* @__PURE__ */ i(g, { name: "check" }) }),
54
- d && /* @__PURE__ */ i(
55
- "button",
56
- {
57
- type: "button",
58
- onClick: w,
59
- className: "vizel-link-button vizel-link-remove",
60
- title: "Remove link",
61
- children: /* @__PURE__ */ i(g, { name: "x" })
62
- }
63
- )
64
- ] }),
65
- o && x && /* @__PURE__ */ a("div", { className: "vizel-link-editor-embed-toggle", children: [
66
- /* @__PURE__ */ i(
67
- "input",
68
- {
69
- type: "checkbox",
70
- id: "vizel-embed-toggle",
71
- checked: l,
72
- onChange: (t) => L(t.target.checked)
73
- }
74
- ),
75
- /* @__PURE__ */ i("label", { htmlFor: "vizel-embed-toggle", children: "Embed as rich content" })
76
- ] })
77
- ] });
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { createContext as r, useContext as c } from "react";
3
+ const o = r({});
4
+ function s({ icons: t, children: e }) {
5
+ return /* @__PURE__ */ n(o.Provider, { value: { customIcons: t }, children: e });
6
+ }
7
+ function x() {
8
+ return c(o);
78
9
  }
79
10
  export {
80
- P as VizelLinkEditor
11
+ s as VizelIconProvider,
12
+ x as useVizelIconContext
81
13
  };