@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.
- package/dist/index.js +66 -58
- package/dist/index10.js +54 -4
- package/dist/index11.js +44 -171
- package/dist/index12.js +25 -21
- package/dist/index13.js +58 -74
- package/dist/index14.js +88 -8
- package/dist/index15.js +4 -78
- package/dist/index16.js +168 -107
- package/dist/index17.js +23 -35
- package/dist/index18.js +21 -5
- package/dist/index19.js +73 -65
- package/dist/index2.js +77 -24
- package/dist/index20.js +8 -91
- package/dist/index21.js +10 -4
- package/dist/index22.js +77 -35
- package/dist/index23.js +113 -31
- package/dist/index24.js +32 -47
- package/dist/index25.js +5 -29
- package/dist/index26.js +68 -7
- package/dist/index27.js +89 -50
- package/dist/index28.js +4 -11
- package/dist/index29.js +37 -3
- package/dist/index3.js +52 -11
- package/dist/index30.js +53 -20
- package/dist/index31.js +34 -2
- package/dist/index32.js +47 -9738
- package/dist/index33.js +29 -17015
- package/dist/index34.js +8 -2
- package/dist/index35.js +52 -7
- package/dist/index36.js +12 -2
- package/dist/index37.js +15 -2
- package/dist/index38.js +3 -222
- package/dist/index39.js +20 -224
- package/dist/index4.js +238 -54
- package/dist/index40.js +2 -2
- package/dist/index41.js +9742 -2
- package/dist/index42.js +17018 -0
- package/dist/index43.js +4 -0
- package/dist/index44.js +10 -0
- package/dist/index45.js +4 -0
- package/dist/index46.js +4 -0
- package/dist/index47.js +224 -0
- package/dist/index48.js +227 -0
- package/dist/index49.js +4 -0
- package/dist/index5.js +82 -55
- package/dist/index50.js +4 -0
- package/dist/index6.js +71 -46
- package/dist/index7.js +64 -26
- package/dist/index8.js +58 -59
- package/dist/index9.js +2 -91
- package/package.json +25 -31
package/dist/index.js
CHANGED
|
@@ -1,60 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
56
|
+
O as Vizel
|
|
7
57
|
};
|
package/dist/index11.js
CHANGED
|
@@ -1,179 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
51
|
+
S as VizelBubbleMenu
|
|
179
52
|
};
|
package/dist/index12.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
27
|
+
i as VizelBubbleMenuButton
|
|
24
28
|
};
|
package/dist/index13.js
CHANGED
|
@@ -1,79 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
62
|
+
A as VizelBubbleMenuColorPicker
|
|
79
63
|
};
|