@vizel/react 0.0.1-alpha.1 → 0.0.1-alpha.6

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 (51) hide show
  1. package/dist/index.js +66 -58
  2. package/dist/index10.js +54 -4
  3. package/dist/index11.js +44 -171
  4. package/dist/index12.js +25 -21
  5. package/dist/index13.js +58 -74
  6. package/dist/index14.js +88 -8
  7. package/dist/index15.js +4 -78
  8. package/dist/index16.js +168 -107
  9. package/dist/index17.js +23 -35
  10. package/dist/index18.js +21 -5
  11. package/dist/index19.js +73 -65
  12. package/dist/index2.js +77 -24
  13. package/dist/index20.js +8 -91
  14. package/dist/index21.js +10 -4
  15. package/dist/index22.js +77 -35
  16. package/dist/index23.js +113 -31
  17. package/dist/index24.js +32 -47
  18. package/dist/index25.js +5 -29
  19. package/dist/index26.js +68 -7
  20. package/dist/index27.js +89 -50
  21. package/dist/index28.js +4 -11
  22. package/dist/index29.js +37 -3
  23. package/dist/index3.js +52 -11
  24. package/dist/index30.js +53 -20
  25. package/dist/index31.js +34 -2
  26. package/dist/index32.js +47 -9738
  27. package/dist/index33.js +29 -17015
  28. package/dist/index34.js +8 -2
  29. package/dist/index35.js +52 -7
  30. package/dist/index36.js +12 -2
  31. package/dist/index37.js +15 -2
  32. package/dist/index38.js +3 -222
  33. package/dist/index39.js +20 -224
  34. package/dist/index4.js +238 -54
  35. package/dist/index40.js +2 -2
  36. package/dist/index41.js +9742 -2
  37. package/dist/index42.js +17018 -0
  38. package/dist/index43.js +4 -0
  39. package/dist/index44.js +10 -0
  40. package/dist/index45.js +4 -0
  41. package/dist/index46.js +4 -0
  42. package/dist/index47.js +224 -0
  43. package/dist/index48.js +227 -0
  44. package/dist/index49.js +4 -0
  45. package/dist/index5.js +82 -55
  46. package/dist/index50.js +4 -0
  47. package/dist/index6.js +71 -46
  48. package/dist/index7.js +64 -26
  49. package/dist/index8.js +58 -59
  50. package/dist/index9.js +2 -91
  51. package/package.json +25 -31
package/dist/index.js CHANGED
@@ -1,60 +1,68 @@
1
- import { useVizelContext as r, useVizelContextSafe as t } from "./index2.js";
2
- import { VizelIconProvider as l, useVizelIconContext as m } from "./index3.js";
3
- import { VizelThemeProvider as z, useVizelTheme as f, useVizelThemeSafe as x } from "./index4.js";
4
- import { Vizel as u } from "./index5.js";
5
- import { VizelBubbleMenu as a } from "./index6.js";
6
- import { VizelBubbleMenuButton as d } from "./index7.js";
7
- import { VizelBubbleMenuColorPicker as S } from "./index8.js";
8
- import { VizelBubbleMenuDefault as c } from "./index9.js";
9
- import { VizelBubbleMenuDivider as v } from "./index10.js";
10
- import { VizelColorPicker as E } from "./index11.js";
11
- import { VizelEditor as C } from "./index12.js";
12
- import { VizelEmbedView as k } from "./index13.js";
13
- import { VizelIcon as w } from "./index14.js";
14
- import { VizelLinkEditor as y } from "./index15.js";
15
- import { VizelNodeSelector as L } from "./index16.js";
16
- import { VizelPortal as R } from "./index17.js";
17
- import { VizelProvider as j } from "./index18.js";
18
- import { VizelSaveIndicator as F } from "./index19.js";
19
- import { VizelSlashMenu as H } from "./index20.js";
20
- import { VizelSlashMenuEmpty as K } from "./index21.js";
21
- import { VizelSlashMenuItem as Q } from "./index22.js";
22
- import { createVizelSlashMenuRenderer as W } from "./index23.js";
23
- import { useVizelAutoSave as Y } from "./index24.js";
24
- import { useVizelEditor as _ } from "./index25.js";
25
- import { useVizelEditorState as ee } from "./index26.js";
26
- import { useVizelMarkdown as re } from "./index27.js";
27
- import { useVizelState as ie } from "./index28.js";
1
+ import "./index2.js";
2
+ import "./index3.js";
3
+ import "./index4.js";
4
+ import "./index5.js";
5
+ import "./index6.js";
6
+ import "./index7.js";
7
+ import "./index8.js";
8
+ import "./index9.js";
9
+ import { Vizel as f } from "./index10.js";
10
+ import { VizelBubbleMenu as u } from "./index11.js";
11
+ import { VizelBubbleMenuButton as a } from "./index12.js";
12
+ import { VizelBubbleMenuColorPicker as d } from "./index13.js";
13
+ import { VizelBubbleMenuDefault as S } from "./index14.js";
14
+ import { VizelBubbleMenuDivider as c } from "./index15.js";
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";
20
+ import { VizelIconProvider as A, useVizelIconContext as L } from "./index21.js";
21
+ import { VizelLinkEditor as R } from "./index22.js";
22
+ import { VizelNodeSelector as j } from "./index23.js";
23
+ import { VizelPortal as F } from "./index24.js";
24
+ import { VizelProvider as H } from "./index25.js";
25
+ import { VizelSaveIndicator as K } from "./index26.js";
26
+ import { VizelSlashMenu as Q } from "./index27.js";
27
+ import { VizelSlashMenuEmpty as W } from "./index28.js";
28
+ import { VizelSlashMenuItem as Y } from "./index29.js";
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";
28
36
  export {
29
- u as Vizel,
30
- a as VizelBubbleMenu,
31
- d as VizelBubbleMenuButton,
32
- S as VizelBubbleMenuColorPicker,
33
- c as VizelBubbleMenuDefault,
34
- v as VizelBubbleMenuDivider,
35
- E as VizelColorPicker,
36
- C as VizelEditor,
37
- k as VizelEmbedView,
38
- w as VizelIcon,
39
- l as VizelIconProvider,
40
- y as VizelLinkEditor,
41
- L as VizelNodeSelector,
42
- R as VizelPortal,
43
- j as VizelProvider,
44
- F as VizelSaveIndicator,
45
- H as VizelSlashMenu,
46
- K as VizelSlashMenuEmpty,
47
- Q as VizelSlashMenuItem,
48
- z as VizelThemeProvider,
49
- W as createVizelSlashMenuRenderer,
50
- Y as useVizelAutoSave,
51
- r as useVizelContext,
52
- t as useVizelContextSafe,
53
- _ as useVizelEditor,
54
- ee as useVizelEditorState,
55
- m as useVizelIconContext,
56
- re as useVizelMarkdown,
57
- ie as useVizelState,
58
- f as useVizelTheme,
59
- x as useVizelThemeSafe
37
+ f as Vizel,
38
+ u as VizelBubbleMenu,
39
+ a as VizelBubbleMenuButton,
40
+ d as VizelBubbleMenuColorPicker,
41
+ S as VizelBubbleMenuDefault,
42
+ c as VizelBubbleMenuDivider,
43
+ v as VizelColorPicker,
44
+ I as VizelEditor,
45
+ T as VizelEmbedView,
46
+ D as VizelIcon,
47
+ A as VizelIconProvider,
48
+ R as VizelLinkEditor,
49
+ j as VizelNodeSelector,
50
+ F as VizelPortal,
51
+ H as VizelProvider,
52
+ K as VizelSaveIndicator,
53
+ Q as VizelSlashMenu,
54
+ W as VizelSlashMenuEmpty,
55
+ Y as VizelSlashMenuItem,
56
+ _ 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,
63
+ L as useVizelIconContext,
64
+ fe as useVizelMarkdown,
65
+ ue as useVizelState,
66
+ $ as useVizelTheme,
67
+ ee as useVizelThemeSafe
60
68
  };
package/dist/index10.js CHANGED
@@ -1,7 +1,57 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- function n({ className: e }) {
3
- return /* @__PURE__ */ i("span", { className: `vizel-bubble-menu-divider ${e ?? ""}` });
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
26
+ }) {
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 }
41
+ });
42
+ return h(
43
+ e,
44
+ () => ({
45
+ editor: i
46
+ }),
47
+ [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
+ ] });
4
54
  }
5
55
  export {
6
- n as VizelBubbleMenuDivider
56
+ O as Vizel
7
57
  };
package/dist/index11.js CHANGED
@@ -1,179 +1,52 @@
1
- import { jsxs as z, jsx as l } from "react/jsx-runtime";
2
- import { normalizeVizelHexColor as N, isVizelValidHexColor as I } from "@vizel/core";
3
- import { useState as K, useRef as L, useMemo as $, useEffect as y, useCallback as b } from "react";
4
- import { VizelIcon as w } from "./index14.js";
5
- const S = 4, j = ["transparent", "inherit"];
6
- function q({
7
- colors: f,
8
- value: a,
9
- onChange: m,
10
- label: M = "Color palette",
11
- className: O,
12
- allowCustomColor: U = !0,
13
- recentColors: s = [],
14
- showRecentColors: h = !0,
15
- noneValues: g = j
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { BubbleMenuPlugin as x } from "@vizel/core";
3
+ import { useRef as f, useEffect as g } from "react";
4
+ import { VizelBubbleMenuDefault as y } from "./index14.js";
5
+ import { useVizelContextSafe as B } from "./index17.js";
6
+ function S({
7
+ editor: d,
8
+ className: b,
9
+ children: a,
10
+ showDefaultMenu: p = !0,
11
+ pluginKey: n = "vizelBubbleMenu",
12
+ updateDelay: u = 100,
13
+ shouldShow: l,
14
+ enableEmbed: s
16
15
  }) {
17
- const [p, d] = K(""), [x, v] = K(-1), u = L([]), D = L(null), i = $(
18
- () => [...h ? s : [], ...f.map((e) => e.color)],
19
- [h, s, f]
20
- );
21
- y(() => {
22
- u.current.length > i.length && (u.current.length = i.length);
23
- }, [i.length]);
24
- const H = h ? s.length : 0, o = b(
25
- (e) => g.includes(e),
26
- [g]
27
- ), k = b(
28
- (e) => {
29
- m(e), d("");
30
- },
31
- [m]
32
- ), V = b(() => {
33
- const e = N(p);
34
- I(e) && (m(e), d(""));
35
- }, [p, m]), R = (e) => {
36
- e.key === "Enter" && (e.preventDefault(), V());
37
- }, A = b(
38
- (e, r) => {
39
- const t = i.length;
40
- if (t === 0) return;
41
- let n = r, c = !1;
42
- switch (e.key) {
43
- case "ArrowRight":
44
- n = (r + 1) % t, c = !0;
45
- break;
46
- case "ArrowLeft":
47
- n = (r - 1 + t) % t, c = !0;
48
- break;
49
- case "ArrowDown":
50
- n = Math.min(r + S, t - 1), c = !0;
51
- break;
52
- case "ArrowUp":
53
- n = Math.max(r - S, 0), c = !0;
54
- break;
55
- case "Home":
56
- n = 0, c = !0;
57
- break;
58
- case "End":
59
- n = t - 1, c = !0;
60
- break;
61
- case "Enter":
62
- case " ": {
63
- e.preventDefault();
64
- const E = i[r];
65
- E && k(E);
66
- return;
67
- }
16
+ const v = B(), e = d ?? v?.editor ?? null, r = f(null), o = f(l);
17
+ return o.current = l, g(() => {
18
+ if (!(e && r.current))
19
+ return;
20
+ const w = x({
21
+ pluginKey: n,
22
+ editor: e,
23
+ element: r.current,
24
+ updateDelay: u,
25
+ ...o.current && {
26
+ shouldShow: ({ editor: t, from: z, to: h }) => o.current?.({ editor: t, from: z, to: h }) ?? !1
27
+ },
28
+ options: {
29
+ placement: "top"
68
30
  }
69
- c && (e.preventDefault(), v(n), u.current[n]?.focus());
70
- },
71
- [i, k]
72
- );
73
- y(() => {
74
- a && !o(a) ? d(a) : d("");
75
- }, [a, o]), y(() => {
76
- const e = a ? i.indexOf(a) : -1;
77
- e >= 0 ? v(e) : i.length > 0 && v(0);
78
- }, [i, a]);
79
- const C = I(N(p)), _ = C ? N(p) : void 0;
80
- return /* @__PURE__ */ z(
31
+ });
32
+ e.registerPlugin(w);
33
+ const i = e, c = (t) => {
34
+ t.key === "Escape" && !i.view.state.selection.empty && (t.preventDefault(), i.commands.setTextSelection(i.view.state.selection.to));
35
+ };
36
+ return document.addEventListener("keydown", c), () => {
37
+ e.unregisterPlugin(n), document.removeEventListener("keydown", c);
38
+ };
39
+ }, [e, n, u]), e ? /* @__PURE__ */ m(
81
40
  "div",
82
41
  {
83
- className: `vizel-color-picker-content ${O ?? ""}`,
84
- role: "listbox",
85
- "aria-label": M,
86
- children: [
87
- h && s.length > 0 && /* @__PURE__ */ z("div", { className: "vizel-color-picker-section", children: [
88
- /* @__PURE__ */ l("div", { className: "vizel-color-picker-label", children: "Recent" }),
89
- /* @__PURE__ */ l("div", { className: "vizel-color-picker-recent", children: s.map((e, r) => /* @__PURE__ */ l(
90
- "button",
91
- {
92
- ref: (t) => {
93
- u.current[r] = t;
94
- },
95
- type: "button",
96
- role: "option",
97
- "aria-selected": a === e,
98
- "aria-label": e,
99
- tabIndex: x === r ? 0 : -1,
100
- className: `vizel-color-picker-swatch ${a === e ? "is-active" : ""}`,
101
- onClick: () => k(e),
102
- onKeyDown: (t) => A(t, r),
103
- style: {
104
- backgroundColor: o(e) ? "transparent" : e
105
- },
106
- "data-color": e,
107
- children: o(e) ? /* @__PURE__ */ l("span", { className: "vizel-color-picker-none", children: /* @__PURE__ */ l(w, { name: "x" }) }) : null
108
- },
109
- e
110
- )) })
111
- ] }),
112
- /* @__PURE__ */ l("div", { className: "vizel-color-picker-section", children: /* @__PURE__ */ l("div", { className: "vizel-color-picker-grid", children: f.map((e, r) => {
113
- const t = H + r;
114
- return /* @__PURE__ */ l(
115
- "button",
116
- {
117
- ref: (n) => {
118
- u.current[t] = n;
119
- },
120
- type: "button",
121
- role: "option",
122
- "aria-selected": a === e.color,
123
- "aria-label": e.name,
124
- tabIndex: x === t ? 0 : -1,
125
- className: `vizel-color-picker-swatch ${a === e.color ? "is-active" : ""}`,
126
- onClick: () => k(e.color),
127
- onKeyDown: (n) => A(n, t),
128
- style: {
129
- backgroundColor: o(e.color) ? "transparent" : e.color
130
- },
131
- "data-color": e.color,
132
- children: o(e.color) ? /* @__PURE__ */ l("span", { className: "vizel-color-picker-none", children: /* @__PURE__ */ l(w, { name: "x" }) }) : null
133
- },
134
- e.color
135
- );
136
- }) }) }),
137
- U && /* @__PURE__ */ z("div", { className: "vizel-color-picker-input-row", children: [
138
- /* @__PURE__ */ l(
139
- "span",
140
- {
141
- className: "vizel-color-picker-preview",
142
- style: { backgroundColor: _ || "transparent" },
143
- "aria-hidden": "true"
144
- }
145
- ),
146
- /* @__PURE__ */ l(
147
- "input",
148
- {
149
- ref: D,
150
- type: "text",
151
- className: "vizel-color-picker-input",
152
- placeholder: "#000000",
153
- value: p,
154
- onChange: (e) => d(e.target.value),
155
- onKeyDown: R,
156
- maxLength: 7,
157
- "aria-label": "Custom color hex value"
158
- }
159
- ),
160
- /* @__PURE__ */ l(
161
- "button",
162
- {
163
- type: "button",
164
- className: "vizel-color-picker-apply",
165
- onClick: V,
166
- disabled: !C,
167
- title: "Apply",
168
- "aria-label": "Apply custom color",
169
- children: /* @__PURE__ */ l(w, { name: "check" })
170
- }
171
- )
172
- ] })
173
- ]
42
+ ref: r,
43
+ className: `vizel-bubble-menu ${b ?? ""}`,
44
+ "data-vizel-bubble-menu": "",
45
+ style: { visibility: "hidden" },
46
+ children: a ?? (p && /* @__PURE__ */ m(y, { editor: e, ...s ? { enableEmbed: s } : {} }))
174
47
  }
175
- );
48
+ ) : null;
176
49
  }
177
50
  export {
178
- q as VizelColorPicker
51
+ S as VizelBubbleMenu
179
52
  };
package/dist/index12.js CHANGED
@@ -1,24 +1,28 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useRef as a, useImperativeHandle as c, useEffect as l } from "react";
3
- import { useVizelContextSafe as s } from "./index2.js";
4
- function v({ ref: i, editor: o, className: n }) {
5
- const d = s(), e = o ?? d?.editor, r = a(null);
6
- return c(
7
- i,
8
- () => ({
9
- container: r.current
10
- }),
11
- []
12
- ), l(() => {
13
- const t = r.current;
14
- if (e && t)
15
- return t.appendChild(e.view.dom), e.view.setProps({
16
- editable: () => e?.isEditable ?? !1
17
- }), () => {
18
- e.view.dom.parentNode === t && t.removeChild(e.view.dom);
19
- };
20
- }, [e]), e ? /* @__PURE__ */ f("div", { ref: r, className: n, "data-vizel-content": "" }) : null;
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ function i({
3
+ onClick: e,
4
+ isActive: t = !1,
5
+ disabled: a = !1,
6
+ children: n,
7
+ title: o,
8
+ className: u,
9
+ action: b
10
+ }) {
11
+ return /* @__PURE__ */ l(
12
+ "button",
13
+ {
14
+ type: "button",
15
+ onClick: e,
16
+ disabled: a,
17
+ "aria-pressed": t,
18
+ className: `vizel-bubble-menu-button ${t ? "is-active" : ""} ${u ?? ""}`,
19
+ title: o,
20
+ "data-active": t || void 0,
21
+ "data-action": b,
22
+ children: n
23
+ }
24
+ );
21
25
  }
22
26
  export {
23
- v as VizelEditor
27
+ i as VizelBubbleMenuButton
24
28
  };
package/dist/index13.js CHANGED
@@ -1,79 +1,63 @@
1
- import { jsx as i, jsxs as s } from "react/jsx-runtime";
2
- import { useRef as a, useEffect as v } from "react";
3
- import { VizelIcon as p } from "./index14.js";
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
- /* @__PURE__ */ i("div", { className: "vizel-embed-loading-spinner" }),
6
- /* @__PURE__ */ i("span", { children: "Loading embed..." })
7
- ] }) }), f = (r, e, n) => {
8
- const l = ["youtube", "vimeo", "loom", "tiktok"].includes(e.provider ?? "");
9
- return /* @__PURE__ */ i(
10
- "div",
11
- {
12
- ref: n,
13
- className: r,
14
- "data-embed-type": "oembed",
15
- "data-embed-provider": e.provider,
16
- children: /* @__PURE__ */ i(
17
- "div",
18
- {
19
- className: l ? "vizel-embed-video" : "vizel-embed-oembed",
20
- dangerouslySetInnerHTML: { __html: e.html ?? "" }
21
- }
22
- )
23
- }
1
+ import { jsxs as V, jsx as l } from "react/jsx-runtime";
2
+ import { getVizelRecentColors as H, addVizelRecentColor as u, VIZEL_TEXT_COLORS as L, VIZEL_HIGHLIGHT_COLORS as O } from "@vizel/core";
3
+ import { useState as h, useRef as E, useEffect as g, useCallback as I } from "react";
4
+ import { VizelColorPicker as T } from "./index16.js";
5
+ import { VizelIcon as C } from "./index20.js";
6
+ function A({
7
+ editor: o,
8
+ type: e,
9
+ colors: f,
10
+ className: m,
11
+ allowCustomColor: d = !0,
12
+ showRecentColors: s = !0
13
+ }) {
14
+ const [r, c] = h(!1), [b, x] = h([]), a = E(null), v = f ?? (e === "textColor" ? L : O), i = e === "textColor" ? o.getAttributes("textStyle").color : o.getAttributes("highlight").color;
15
+ g(() => {
16
+ r && s && x(H(e));
17
+ }, [r, s, e]);
18
+ const p = I(
19
+ (t) => {
20
+ e === "textColor" ? t === "inherit" ? o.chain().focus().unsetColor().run() : (o.chain().focus().setColor(t).run(), u(e, t)) : t === "transparent" ? o.chain().focus().unsetHighlight().run() : (o.chain().focus().toggleHighlight({ color: t }).run(), u(e, t)), c(!1);
21
+ },
22
+ [o, e]
24
23
  );
25
- }, u = (r, e) => {
26
- const n = !!e.image, l = n ? "vizel-embed-card-horizontal" : "";
27
- return /* @__PURE__ */ i("div", { className: r, "data-embed-type": "ogp", "data-embed-provider": e.provider, children: /* @__PURE__ */ s(
28
- "a",
29
- {
30
- href: e.url,
31
- target: "_blank",
32
- rel: "noopener noreferrer",
33
- className: `vizel-embed-card ${l}`,
34
- children: [
35
- n && /* @__PURE__ */ i("img", { src: e.image, alt: "", className: "vizel-embed-card-image", loading: "lazy" }),
36
- /* @__PURE__ */ s("div", { className: "vizel-embed-card-content", children: [
37
- (e.siteName || e.favicon) && /* @__PURE__ */ s("div", { className: "vizel-embed-card-site", children: [
38
- e.favicon && /* @__PURE__ */ i("img", { src: e.favicon, alt: "", className: "vizel-embed-card-favicon" }),
39
- e.siteName && /* @__PURE__ */ i("span", { children: e.siteName })
40
- ] }),
41
- e.title && /* @__PURE__ */ i("div", { className: "vizel-embed-card-title", children: e.title }),
42
- e.description && /* @__PURE__ */ i("div", { className: "vizel-embed-card-description", children: e.description }),
43
- /* @__PURE__ */ i("div", { className: "vizel-embed-card-url", children: new URL(e.url).hostname })
44
- ] })
45
- ]
46
- }
47
- ) });
48
- }, N = (r, e, n) => /* @__PURE__ */ i("div", { className: r, "data-embed-type": "title", "data-embed-provider": e.provider, children: /* @__PURE__ */ s("a", { href: e.url, target: "_blank", rel: "noopener noreferrer", className: "vizel-embed-link", children: [
49
- /* @__PURE__ */ i("span", { className: "vizel-embed-link-icon", children: n }),
50
- /* @__PURE__ */ i("span", { className: "vizel-embed-link-text", children: e.title })
51
- ] }) }), z = (r, e, n) => /* @__PURE__ */ i("div", { className: r, "data-embed-type": "link", "data-embed-provider": e.provider, children: /* @__PURE__ */ s("a", { href: e.url, target: "_blank", rel: "noopener noreferrer", className: "vizel-embed-link", children: [
52
- /* @__PURE__ */ i("span", { className: "vizel-embed-link-icon", children: n }),
53
- /* @__PURE__ */ i("span", { className: "vizel-embed-link-text", children: e.url })
54
- ] }) });
55
- function w({ data: r, className: e, selected: n }) {
56
- const l = a(null);
57
- v(() => {
58
- if (r.type === "oembed" && r.html && l.current) {
59
- const m = l.current.querySelectorAll("script");
60
- for (const o of m) {
61
- const d = document.createElement("script");
62
- o.src ? d.src = o.src : d.textContent = o.textContent, o.parentNode?.replaceChild(d, o);
24
+ g(() => {
25
+ const t = (k) => {
26
+ a.current && !a.current.contains(k.target) && c(!1);
27
+ };
28
+ return r && document.addEventListener("mousedown", t), () => {
29
+ document.removeEventListener("mousedown", t);
30
+ };
31
+ }, [r]);
32
+ const n = e === "textColor", z = n ? /* @__PURE__ */ l(C, { name: "textColor" }) : /* @__PURE__ */ l(C, { name: "highlighter" });
33
+ return /* @__PURE__ */ V("div", { ref: a, className: `vizel-color-picker ${m ?? ""}`, "data-type": e, children: [
34
+ /* @__PURE__ */ l(
35
+ "button",
36
+ {
37
+ type: "button",
38
+ className: `vizel-bubble-menu-button vizel-color-picker-trigger ${i ? "has-color" : ""}`,
39
+ onClick: () => c(!r),
40
+ title: n ? "Text Color" : "Highlight",
41
+ "data-action": e,
42
+ style: n ? { color: i || "inherit" } : { "--highlight-color": i || "transparent" },
43
+ children: z
63
44
  }
64
- r.provider === "twitter" && "twttr" in window && window.twttr?.widgets?.load?.();
65
- }
66
- }, [r.type, r.html, r.provider]);
67
- const c = b(r.loading, n, e);
68
- if (r.loading)
69
- return h(c, r.provider);
70
- if (r.type === "oembed" && r.html)
71
- return f(c, r, l);
72
- if (r.type === "ogp")
73
- return u(c, r);
74
- const t = /* @__PURE__ */ i(p, { name: "link" });
75
- return r.type === "title" && r.title ? N(c, r, t) : z(c, r, t);
45
+ ),
46
+ r && /* @__PURE__ */ l("div", { className: "vizel-color-picker-dropdown", children: /* @__PURE__ */ l(
47
+ T,
48
+ {
49
+ colors: v,
50
+ value: i,
51
+ onChange: p,
52
+ label: n ? "Text color palette" : "Highlight color palette",
53
+ allowCustomColor: d,
54
+ recentColors: b,
55
+ showRecentColors: s,
56
+ noneValues: n ? ["inherit"] : ["transparent"]
57
+ }
58
+ ) })
59
+ ] });
76
60
  }
77
61
  export {
78
- w as VizelEmbedView
62
+ A as VizelBubbleMenuColorPicker
79
63
  };