@vizel/react 1.0.0 → 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.
- package/README.md +38 -14
- package/dist/index.d.ts +225 -1
- package/dist/index.js +59 -51
- package/dist/index10.js +42 -40
- package/dist/index13.js +1 -1
- package/dist/index14.js +4 -4
- package/dist/index16.js +1 -1
- package/dist/index19.js +1 -1
- package/dist/index2.js +1 -1
- package/dist/index20.js +152 -8
- package/dist/index21.js +8 -10
- package/dist/index22.js +10 -78
- package/dist/index23.js +75 -112
- package/dist/index24.js +112 -32
- package/dist/index25.js +35 -5
- package/dist/index26.js +5 -68
- package/dist/index27.js +65 -88
- package/dist/index28.js +91 -4
- package/dist/index29.js +4 -36
- package/dist/index30.js +34 -51
- package/dist/index31.js +52 -11
- package/dist/index32.js +11 -24
- package/dist/index33.js +24 -29
- package/dist/index34.js +30 -4
- package/dist/index35.js +4 -33
- package/dist/index36.js +31 -48
- package/dist/index37.js +50 -37
- package/dist/index38.js +48 -7
- package/dist/index39.js +69 -50
- package/dist/index40.js +45 -11
- package/dist/index41.js +8 -15
- package/dist/index42.js +53 -3
- package/dist/index43.js +11 -20
- package/dist/index44.js +54 -2
- package/dist/index45.js +15 -9742
- package/dist/index46.js +3 -17016
- package/dist/index47.js +21 -2
- package/dist/index48.js +2 -8
- package/dist/index49.js +9742 -2
- package/dist/index50.js +17016 -2
- package/dist/index51.js +2 -222
- package/dist/index52.js +7 -224
- package/dist/index53.js +2 -2
- package/dist/index54.js +2 -2
- package/dist/index55.js +224 -0
- package/dist/index56.js +227 -0
- package/dist/index57.js +4 -0
- package/dist/index58.js +4 -0
- package/package.json +12 -12
package/dist/index20.js
CHANGED
|
@@ -1,11 +1,155 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
154
|
+
O as VizelFindReplace
|
|
11
155
|
};
|
package/dist/index21.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
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
|
-
|
|
12
|
-
x as useVizelIconContext
|
|
10
|
+
x as VizelIcon
|
|
13
11
|
};
|
package/dist/index22.js
CHANGED
|
@@ -1,81 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
+
s as VizelIconProvider,
|
|
12
|
+
x as useVizelIconContext
|
|
81
13
|
};
|
package/dist/index23.js
CHANGED
|
@@ -1,118 +1,81 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { useState as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 "./index21.js";
|
|
5
|
+
function P({
|
|
6
|
+
editor: e,
|
|
7
|
+
onClose: n,
|
|
8
|
+
className: E,
|
|
9
|
+
enableEmbed: m = !1
|
|
10
10
|
}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
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);
|
|
17
24
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
switch (e.key) {
|
|
28
|
-
case "Escape":
|
|
29
|
-
e.preventDefault(), l(!1);
|
|
30
|
-
break;
|
|
31
|
-
case "ArrowDown":
|
|
32
|
-
e.preventDefault(), a((t) => (t + 1) % r.length);
|
|
33
|
-
break;
|
|
34
|
-
case "ArrowUp":
|
|
35
|
-
e.preventDefault(), a((t) => (t - 1 + r.length) % r.length);
|
|
36
|
-
break;
|
|
37
|
-
case "Enter":
|
|
38
|
-
case " ": {
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
const t = r[f];
|
|
41
|
-
t && v(t);
|
|
42
|
-
break;
|
|
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;
|
|
43
33
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
onKeyDown: b,
|
|
89
|
-
children: r.map((e, t) => {
|
|
90
|
-
const u = e.isActive(c), k = t === f;
|
|
91
|
-
return /* @__PURE__ */ p(
|
|
92
|
-
"button",
|
|
93
|
-
{
|
|
94
|
-
type: "button",
|
|
95
|
-
role: "option",
|
|
96
|
-
"aria-selected": u,
|
|
97
|
-
className: `vizel-node-selector-option ${u ? "is-active" : ""} ${k ? "is-focused" : ""}`,
|
|
98
|
-
onClick: () => v(e),
|
|
99
|
-
onMouseEnter: () => a(t),
|
|
100
|
-
tabIndex: k ? 0 : -1,
|
|
101
|
-
children: [
|
|
102
|
-
/* @__PURE__ */ n("span", { className: "vizel-node-selector-option-icon", children: /* @__PURE__ */ n(s, { name: e.icon }) }),
|
|
103
|
-
/* @__PURE__ */ n("span", { className: "vizel-node-selector-option-label", children: e.label }),
|
|
104
|
-
u && /* @__PURE__ */ n("span", { className: "vizel-node-selector-check", "aria-hidden": "true", children: /* @__PURE__ */ n(s, { name: "check" }) })
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
e.name
|
|
108
|
-
);
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
)
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
);
|
|
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
|
+
] });
|
|
115
78
|
}
|
|
116
79
|
export {
|
|
117
|
-
|
|
80
|
+
P as VizelLinkEditor
|
|
118
81
|
};
|
package/dist/index24.js
CHANGED
|
@@ -1,38 +1,118 @@
|
|
|
1
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useState as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsxs as p, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { getVizelActiveNodeType as x, vizelDefaultNodeTypes as E } from "@vizel/core";
|
|
3
|
+
import { useState as z, useRef as N, useEffect as w } from "react";
|
|
4
|
+
import { useVizelState as y } from "./index43.js";
|
|
5
|
+
import { VizelIcon as s } from "./index21.js";
|
|
6
|
+
function $({
|
|
7
|
+
editor: c,
|
|
8
|
+
nodeTypes: r = E,
|
|
9
|
+
className: D
|
|
10
10
|
}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
y(() => c);
|
|
12
|
+
const [o, l] = z(!1), [f, a] = z(0), i = N(null), d = N(null), m = x(c, r), h = m?.label ?? "Text", g = m?.icon ?? "paragraph";
|
|
13
|
+
w(() => {
|
|
14
|
+
if (!o) return;
|
|
15
|
+
const e = (t) => {
|
|
16
|
+
i.current && !i.current.contains(t.target) && l(!1);
|
|
17
|
+
};
|
|
18
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
19
|
+
}, [o]), w(() => {
|
|
20
|
+
o && d.current && d.current.focus();
|
|
21
|
+
}, [o]);
|
|
22
|
+
const b = (e) => {
|
|
23
|
+
if (!o) {
|
|
24
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), l(!0), a(0));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
switch (e.key) {
|
|
28
|
+
case "Escape":
|
|
29
|
+
e.preventDefault(), l(!1);
|
|
30
|
+
break;
|
|
31
|
+
case "ArrowDown":
|
|
32
|
+
e.preventDefault(), a((t) => (t + 1) % r.length);
|
|
33
|
+
break;
|
|
34
|
+
case "ArrowUp":
|
|
35
|
+
e.preventDefault(), a((t) => (t - 1 + r.length) % r.length);
|
|
36
|
+
break;
|
|
37
|
+
case "Enter":
|
|
38
|
+
case " ": {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
const t = r[f];
|
|
41
|
+
t && v(t);
|
|
42
|
+
break;
|
|
30
43
|
}
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
case "Home":
|
|
45
|
+
e.preventDefault(), a(0);
|
|
46
|
+
break;
|
|
47
|
+
case "End":
|
|
48
|
+
e.preventDefault(), a(r.length - 1);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}, v = (e) => {
|
|
52
|
+
e.command(c), l(!1);
|
|
53
|
+
};
|
|
54
|
+
return /* @__PURE__ */ p(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
ref: i,
|
|
58
|
+
className: `vizel-node-selector ${D ?? ""}`,
|
|
59
|
+
"data-vizel-node-selector": !0,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ p(
|
|
62
|
+
"button",
|
|
63
|
+
{
|
|
64
|
+
type: "button",
|
|
65
|
+
className: "vizel-node-selector-trigger",
|
|
66
|
+
onClick: () => l(!o),
|
|
67
|
+
onKeyDown: b,
|
|
68
|
+
"aria-haspopup": "listbox",
|
|
69
|
+
"aria-expanded": o,
|
|
70
|
+
"aria-label": `Current block type: ${h}`,
|
|
71
|
+
title: "Change block type",
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ n("span", { className: "vizel-node-selector-icon", children: /* @__PURE__ */ n(s, { name: g }) }),
|
|
74
|
+
/* @__PURE__ */ n("span", { className: "vizel-node-selector-label", children: h }),
|
|
75
|
+
/* @__PURE__ */ n("span", { className: "vizel-node-selector-chevron", "aria-hidden": "true", children: /* @__PURE__ */ n(s, { name: "chevronDown" }) })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
o && /* @__PURE__ */ n(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
ref: d,
|
|
83
|
+
className: "vizel-node-selector-dropdown",
|
|
84
|
+
role: "listbox",
|
|
85
|
+
"aria-label": "Block types",
|
|
86
|
+
"data-vizel-node-selector-dropdown": !0,
|
|
87
|
+
tabIndex: -1,
|
|
88
|
+
onKeyDown: b,
|
|
89
|
+
children: r.map((e, t) => {
|
|
90
|
+
const u = e.isActive(c), k = t === f;
|
|
91
|
+
return /* @__PURE__ */ p(
|
|
92
|
+
"button",
|
|
93
|
+
{
|
|
94
|
+
type: "button",
|
|
95
|
+
role: "option",
|
|
96
|
+
"aria-selected": u,
|
|
97
|
+
className: `vizel-node-selector-option ${u ? "is-active" : ""} ${k ? "is-focused" : ""}`,
|
|
98
|
+
onClick: () => v(e),
|
|
99
|
+
onMouseEnter: () => a(t),
|
|
100
|
+
tabIndex: k ? 0 : -1,
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ n("span", { className: "vizel-node-selector-option-icon", children: /* @__PURE__ */ n(s, { name: e.icon }) }),
|
|
103
|
+
/* @__PURE__ */ n("span", { className: "vizel-node-selector-option-label", children: e.label }),
|
|
104
|
+
u && /* @__PURE__ */ n("span", { className: "vizel-node-selector-check", "aria-hidden": "true", children: /* @__PURE__ */ n(s, { name: "check" }) })
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
e.name
|
|
108
|
+
);
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
]
|
|
113
|
+
}
|
|
33
114
|
);
|
|
34
115
|
}
|
|
35
|
-
d.displayName = "VizelPortal";
|
|
36
116
|
export {
|
|
37
|
-
|
|
117
|
+
$ as VizelNodeSelector
|
|
38
118
|
};
|