@forgedevstack/bear 1.0.6 → 1.0.7
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/components/BottomSheet/BottomSheet.cjs +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/dist/components/BottomSheet/BottomSheet.js +102 -0
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +13 -0
- package/dist/components/BottomSheet/index.d.ts +2 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.js +40 -38
- package/dist/components/Button/Button.types.d.ts +4 -0
- package/dist/components/EmojiPicker/EmojiPicker.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.d.ts +5 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.js +10 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts +3 -0
- package/dist/components/EmojiPicker/EmojiPicker.js +63 -0
- package/dist/components/EmojiPicker/EmojiPicker.types.d.ts +6 -0
- package/dist/components/EmojiPicker/index.d.ts +3 -0
- package/dist/components/Kanban/Kanban.cjs +1 -0
- package/dist/components/Kanban/Kanban.d.ts +3 -0
- package/dist/components/Kanban/Kanban.js +90 -0
- package/dist/components/Kanban/Kanban.types.d.ts +21 -0
- package/dist/components/Kanban/index.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -0
- package/dist/components/MentionsInput/MentionsInput.d.ts +3 -0
- package/dist/components/MentionsInput/MentionsInput.js +140 -0
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +21 -0
- package/dist/components/MentionsInput/index.d.ts +2 -0
- package/dist/components/RichEditor/RichEditor.cjs +1 -1
- package/dist/components/RichEditor/RichEditor.const.cjs +2 -2
- package/dist/components/RichEditor/RichEditor.const.d.ts +4 -1
- package/dist/components/RichEditor/RichEditor.const.js +51 -18
- package/dist/components/RichEditor/RichEditor.js +106 -105
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +105 -95
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +2 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +47 -29
- package/dist/components/SegmentedControl/SegmentedControl.cjs +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +58 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +16 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +98 -90
- package/dist/components/SliderRange/SliderRange.cjs +1 -0
- package/dist/components/SliderRange/SliderRange.d.ts +3 -0
- package/dist/components/SliderRange/SliderRange.js +142 -0
- package/dist/components/SliderRange/SliderRange.types.d.ts +17 -0
- package/dist/components/SliderRange/index.d.ts +2 -0
- package/dist/components/TagsInput/TagsInput.cjs +1 -0
- package/dist/components/TagsInput/TagsInput.d.ts +3 -0
- package/dist/components/TagsInput/TagsInput.js +100 -0
- package/dist/components/TagsInput/TagsInput.types.d.ts +16 -0
- package/dist/components/TagsInput/index.d.ts +2 -0
- package/dist/components/VirtualList/VirtualList.cjs +1 -0
- package/dist/components/VirtualList/VirtualList.d.ts +3 -0
- package/dist/components/VirtualList/VirtualList.js +68 -0
- package/dist/components/VirtualList/VirtualList.types.d.ts +10 -0
- package/dist/components/VirtualList/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +124 -106
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +36 -32
- package/dist/hooks/useDragDrop/index.d.ts +2 -0
- package/dist/hooks/useDragDrop/useDragDrop.cjs +1 -0
- package/dist/hooks/useDragDrop/useDragDrop.d.ts +22 -0
- package/dist/hooks/useDragDrop/useDragDrop.js +56 -0
- package/dist/hooks/useDragDrop/useDragDrop.types.d.ts +55 -0
- package/dist/hooks/useLazyLoad/index.d.ts +2 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.cjs +1 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.d.ts +26 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.js +27 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.types.d.ts +25 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +179 -157
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,84 +1,85 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { getActiveFormats as be, queryCommandValue as
|
|
5
|
-
import { RICH_EDITOR_MIN_HEIGHT as ye, RICH_EDITOR_DEFAULT_TOOLBAR as
|
|
1
|
+
import { jsxs as Re, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Te, useState as I, useEffect as y, useCallback as d } from "react";
|
|
3
|
+
import { cn as R } from "../../utils/cn.js";
|
|
4
|
+
import { getActiveFormats as be, queryCommandValue as _e, execCommand as u, insertLink as Ee, setTextColor as x, setHighlightColor as A, fileToDataUrl as S, insertImage as v } from "./helpers/formatHelpers.js";
|
|
5
|
+
import { RICH_EDITOR_MIN_HEIGHT as ye, RICH_EDITOR_DEFAULT_TOOLBAR as Le, RICH_EDITOR_CONTENT_STYLES as He, RICH_EDITOR_BUTTON_CONFIG as B, RICH_EDITOR_MOBILE_TOOLBAR as Oe, RICH_EDITOR_TOOLBAR_CLASSES as ze, RICH_EDITOR_CONTENT_CLASSES as ke, RICH_EDITOR_ROOT_CLASSES as xe, RICH_EDITOR_DIVIDER_CLASSES as Ae, RICH_EDITOR_HEADING_OPTIONS as Se, RICH_EDITOR_MOBILE_MORE_ITEMS as ve, RICH_EDITOR_MOBILE_BREAKPOINT as Be } from "./RichEditor.const.js";
|
|
6
|
+
import { useMediaQuery as De } from "../../hooks/useMediaQuery.js";
|
|
6
7
|
import { ToolbarButton as f } from "./components/ToolbarButton/ToolbarButton.js";
|
|
7
|
-
import { ToolbarDropdown as
|
|
8
|
+
import { ToolbarDropdown as Ne } from "./components/ToolbarDropdown/ToolbarDropdown.js";
|
|
8
9
|
import { ToolbarColorPicker as D } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
|
|
9
|
-
import { ToolbarMore as
|
|
10
|
-
import { TextIcon as
|
|
11
|
-
const
|
|
10
|
+
import { ToolbarMore as Fe } from "./components/ToolbarMore/ToolbarMore.js";
|
|
11
|
+
import { TextIcon as Me, InsertLinkIcon as N, InsertPhotoIcon as F, AlignLeftIcon as M, AlignCenterIcon as w, AlignRightIcon as U, AlignJustifyIcon as V, IndentIncreaseIcon as P, IndentDecreaseIcon as j, FormatClearIcon as J, TableIcon as we, CodeIcon as Ue, QuoteIcon as Ve, ListNumberedIcon as Pe, ListBulletIcon as je, Heading3Icon as Je, Heading2Icon as $e, Heading1Icon as qe, StrikethroughIcon as Ge, UnderlineIcon as Ke, ItalicIcon as Qe, BoldIcon as Ye } from "../Icon/icons/editor.js";
|
|
12
|
+
const We = 6, ct = ($) => {
|
|
12
13
|
const {
|
|
13
|
-
value:
|
|
14
|
-
defaultValue:
|
|
15
|
-
onChange:
|
|
14
|
+
value: C,
|
|
15
|
+
defaultValue: L = "",
|
|
16
|
+
onChange: T,
|
|
16
17
|
placeholder: q = "Start typing...",
|
|
17
18
|
disabled: i = !1,
|
|
18
19
|
readOnly: o = !1,
|
|
19
|
-
minHeight:
|
|
20
|
+
minHeight: b = ye,
|
|
20
21
|
maxHeight: m,
|
|
21
|
-
toolbar:
|
|
22
|
-
className:
|
|
23
|
-
testId:
|
|
22
|
+
toolbar: G = Le,
|
|
23
|
+
className: K = "",
|
|
24
|
+
testId: Q,
|
|
24
25
|
id: Y,
|
|
25
|
-
allowImagePaste:
|
|
26
|
-
...
|
|
27
|
-
} =
|
|
28
|
-
|
|
26
|
+
allowImagePaste: H = !0,
|
|
27
|
+
...W
|
|
28
|
+
} = $, a = Te(null), _ = De(`(max-width: ${Be}px)`), O = _ ? Oe : G, [X, Z] = I(/* @__PURE__ */ new Set()), [ee, z] = I("p"), [te, ne] = I("#000000"), [ie, oe] = I("#fef08a"), [re, le] = I([]), [ae, se] = I([]);
|
|
29
|
+
y(() => {
|
|
29
30
|
const e = "bear-rich-editor-styles";
|
|
30
31
|
if (!document.getElementById(e)) {
|
|
31
32
|
const n = document.createElement("style");
|
|
32
|
-
n.id = e, n.textContent =
|
|
33
|
+
n.id = e, n.textContent = He, document.head.appendChild(n);
|
|
33
34
|
}
|
|
34
|
-
}, []),
|
|
35
|
-
a.current &&
|
|
36
|
-
}, [
|
|
37
|
-
a.current &&
|
|
35
|
+
}, []), y(() => {
|
|
36
|
+
a.current && C !== void 0 && a.current.innerHTML !== C && (a.current.innerHTML = C);
|
|
37
|
+
}, [C]), y(() => {
|
|
38
|
+
a.current && L && !C && (a.current.innerHTML = L);
|
|
38
39
|
}, []);
|
|
39
40
|
const h = d(() => {
|
|
40
|
-
|
|
41
|
-
const e =
|
|
42
|
-
e &&
|
|
41
|
+
Z(be());
|
|
42
|
+
const e = _e("formatBlock");
|
|
43
|
+
e && z(e.toLowerCase().replace(/[<>]/g, ""));
|
|
43
44
|
}, []), l = d(() => {
|
|
44
|
-
a.current &&
|
|
45
|
-
}, [
|
|
45
|
+
a.current && T && T(a.current.innerHTML), h();
|
|
46
|
+
}, [T, h]), ce = d((e) => {
|
|
46
47
|
var s;
|
|
47
48
|
if (i || o) return;
|
|
48
49
|
(s = a.current) == null || s.focus();
|
|
49
|
-
const n =
|
|
50
|
+
const n = B[e];
|
|
50
51
|
if (!n) return;
|
|
51
52
|
const c = "value" in n ? n.value : void 0;
|
|
52
53
|
c ? u(n.command, c) : u(n.command), h(), l();
|
|
53
|
-
}, [i, o, h, l]),
|
|
54
|
+
}, [i, o, h, l]), de = d((e) => {
|
|
54
55
|
var n;
|
|
55
|
-
i || o || ((n = a.current) == null || n.focus(), u("formatBlock", e),
|
|
56
|
-
}, [i, o, l]),
|
|
56
|
+
i || o || ((n = a.current) == null || n.focus(), u("formatBlock", e), z(e), l());
|
|
57
|
+
}, [i, o, l]), ue = d(() => {
|
|
57
58
|
var s;
|
|
58
59
|
if (i || o) return;
|
|
59
60
|
const e = window.getSelection(), n = e && e.toString().length > 0, c = prompt("Enter URL:", n ? "" : "https://");
|
|
60
|
-
c && ((s = a.current) == null || s.focus(),
|
|
61
|
+
c && ((s = a.current) == null || s.focus(), Ee(c), l());
|
|
61
62
|
}, [i, o, l]), p = d((e, n) => {
|
|
62
63
|
if (!e) return;
|
|
63
|
-
(n === "text" ?
|
|
64
|
+
(n === "text" ? le : se)((s) => {
|
|
64
65
|
const r = s.filter((g) => g !== e);
|
|
65
|
-
return [e, ...r].slice(0,
|
|
66
|
+
return [e, ...r].slice(0, We);
|
|
66
67
|
});
|
|
67
|
-
}, []),
|
|
68
|
+
}, []), fe = d((e) => {
|
|
68
69
|
var n;
|
|
69
|
-
i || o || ((n = a.current) == null || n.focus(), x(e),
|
|
70
|
-
}, [i, o, l, p]),
|
|
70
|
+
i || o || ((n = a.current) == null || n.focus(), x(e), ne(e), p(e, "text"), l());
|
|
71
|
+
}, [i, o, l, p]), ge = d((e) => {
|
|
71
72
|
var n;
|
|
72
|
-
i || o || ((n = a.current) == null || n.focus(),
|
|
73
|
-
}, [i, o, l, p]),
|
|
73
|
+
i || o || ((n = a.current) == null || n.focus(), A(e), oe(e), p(e, "highlight"), l());
|
|
74
|
+
}, [i, o, l, p]), he = d((e) => {
|
|
74
75
|
var n;
|
|
75
76
|
i || o || ((n = a.current) == null || n.focus(), x(e), l());
|
|
76
|
-
}, [i, o, l]),
|
|
77
|
+
}, [i, o, l]), Ie = d((e) => {
|
|
77
78
|
var n;
|
|
78
|
-
i || o || ((n = a.current) == null || n.focus(),
|
|
79
|
-
}, [i, o, l]),
|
|
79
|
+
i || o || ((n = a.current) == null || n.focus(), A(e), l());
|
|
80
|
+
}, [i, o, l]), Ce = d(async (e) => {
|
|
80
81
|
var c;
|
|
81
|
-
if (!
|
|
82
|
+
if (!H) return;
|
|
82
83
|
const n = (c = e.clipboardData) == null ? void 0 : c.items;
|
|
83
84
|
if (n)
|
|
84
85
|
for (let s = 0; s < n.length; s++) {
|
|
@@ -87,58 +88,58 @@ const qe = 6, nt = (P) => {
|
|
|
87
88
|
e.preventDefault();
|
|
88
89
|
const g = r.getAsFile();
|
|
89
90
|
if (g) {
|
|
90
|
-
const
|
|
91
|
-
|
|
91
|
+
const E = await S(g);
|
|
92
|
+
v(E), l();
|
|
92
93
|
}
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
|
-
}, [
|
|
97
|
+
}, [H, l]), me = d(() => {
|
|
97
98
|
if (i || o) return;
|
|
98
99
|
const e = document.createElement("input");
|
|
99
100
|
e.type = "file", e.accept = "image/*", e.onchange = async (n) => {
|
|
100
101
|
var s, r;
|
|
101
102
|
const c = (s = n.target.files) == null ? void 0 : s[0];
|
|
102
103
|
if (c) {
|
|
103
|
-
const g = await
|
|
104
|
-
(r = a.current) == null || r.focus(),
|
|
104
|
+
const g = await S(c);
|
|
105
|
+
(r = a.current) == null || r.focus(), v(g), l();
|
|
105
106
|
}
|
|
106
107
|
}, e.click();
|
|
107
|
-
}, [i, o, l]),
|
|
108
|
-
bold: /* @__PURE__ */ t(
|
|
109
|
-
italic: /* @__PURE__ */ t(
|
|
110
|
-
underline: /* @__PURE__ */ t(
|
|
111
|
-
strikethrough: /* @__PURE__ */ t(
|
|
112
|
-
heading1: /* @__PURE__ */ t(
|
|
113
|
-
heading2: /* @__PURE__ */ t(
|
|
114
|
-
heading3: /* @__PURE__ */ t(
|
|
115
|
-
bulletList: /* @__PURE__ */ t(
|
|
116
|
-
orderedList: /* @__PURE__ */ t(
|
|
117
|
-
blockquote: /* @__PURE__ */ t(
|
|
118
|
-
code: /* @__PURE__ */ t(
|
|
119
|
-
link: /* @__PURE__ */ t(
|
|
120
|
-
alignLeft: /* @__PURE__ */ t(
|
|
108
|
+
}, [i, o, l]), pe = {
|
|
109
|
+
bold: /* @__PURE__ */ t(Ye, { size: 16 }),
|
|
110
|
+
italic: /* @__PURE__ */ t(Qe, { size: 16 }),
|
|
111
|
+
underline: /* @__PURE__ */ t(Ke, { size: 16 }),
|
|
112
|
+
strikethrough: /* @__PURE__ */ t(Ge, { size: 16 }),
|
|
113
|
+
heading1: /* @__PURE__ */ t(qe, { size: 16 }),
|
|
114
|
+
heading2: /* @__PURE__ */ t($e, { size: 16 }),
|
|
115
|
+
heading3: /* @__PURE__ */ t(Je, { size: 16 }),
|
|
116
|
+
bulletList: /* @__PURE__ */ t(je, { size: 16 }),
|
|
117
|
+
orderedList: /* @__PURE__ */ t(Pe, { size: 16 }),
|
|
118
|
+
blockquote: /* @__PURE__ */ t(Ve, { size: 16 }),
|
|
119
|
+
code: /* @__PURE__ */ t(Ue, { size: 16 }),
|
|
120
|
+
link: /* @__PURE__ */ t(N, { size: 16 }),
|
|
121
|
+
alignLeft: /* @__PURE__ */ t(M, { size: 16 }),
|
|
121
122
|
alignCenter: /* @__PURE__ */ t(w, { size: 16 }),
|
|
122
123
|
alignRight: /* @__PURE__ */ t(U, { size: 16 }),
|
|
123
|
-
alignJustify: /* @__PURE__ */ t(
|
|
124
|
+
alignJustify: /* @__PURE__ */ t(V, { size: 16 }),
|
|
124
125
|
image: /* @__PURE__ */ t(F, { size: 16 }),
|
|
125
|
-
indent: /* @__PURE__ */ t(
|
|
126
|
+
indent: /* @__PURE__ */ t(P, { size: 16 }),
|
|
126
127
|
outdent: /* @__PURE__ */ t(j, { size: 16 }),
|
|
127
128
|
clearFormat: /* @__PURE__ */ t(J, { size: 16 }),
|
|
128
|
-
table: /* @__PURE__ */ t(
|
|
129
|
+
table: /* @__PURE__ */ t(we, { size: 16 })
|
|
129
130
|
}, k = (e, n) => {
|
|
130
131
|
if (e === "divider")
|
|
131
|
-
return /* @__PURE__ */ t("div", { className:
|
|
132
|
+
return /* @__PURE__ */ t("div", { className: R("Bear-RichEditor__divider", Ae) }, `divider-${n}`);
|
|
132
133
|
if (e === "headingDropdown")
|
|
133
134
|
return /* @__PURE__ */ t(
|
|
134
|
-
|
|
135
|
+
Ne,
|
|
135
136
|
{
|
|
136
|
-
options:
|
|
137
|
-
value:
|
|
138
|
-
onChange:
|
|
137
|
+
options: Se,
|
|
138
|
+
value: ee,
|
|
139
|
+
onChange: de,
|
|
139
140
|
title: "Text Style",
|
|
140
141
|
disabled: i || o,
|
|
141
|
-
icon: /* @__PURE__ */ t(
|
|
142
|
+
icon: /* @__PURE__ */ t(Me, { size: 16 })
|
|
142
143
|
},
|
|
143
144
|
"heading-dropdown"
|
|
144
145
|
);
|
|
@@ -146,13 +147,13 @@ const qe = 6, nt = (P) => {
|
|
|
146
147
|
return /* @__PURE__ */ t(
|
|
147
148
|
D,
|
|
148
149
|
{
|
|
149
|
-
value:
|
|
150
|
-
onChange:
|
|
150
|
+
value: te,
|
|
151
|
+
onChange: fe,
|
|
151
152
|
title: "Text Color",
|
|
152
153
|
disabled: i || o,
|
|
153
154
|
type: "text",
|
|
154
|
-
recentColors:
|
|
155
|
-
onApplyLast:
|
|
155
|
+
recentColors: re,
|
|
156
|
+
onApplyLast: he
|
|
156
157
|
},
|
|
157
158
|
"text-color"
|
|
158
159
|
);
|
|
@@ -160,13 +161,13 @@ const qe = 6, nt = (P) => {
|
|
|
160
161
|
return /* @__PURE__ */ t(
|
|
161
162
|
D,
|
|
162
163
|
{
|
|
163
|
-
value:
|
|
164
|
-
onChange:
|
|
164
|
+
value: ie,
|
|
165
|
+
onChange: ge,
|
|
165
166
|
title: "Highlight Color",
|
|
166
167
|
disabled: i || o,
|
|
167
168
|
type: "highlight",
|
|
168
|
-
recentColors:
|
|
169
|
-
onApplyLast:
|
|
169
|
+
recentColors: ae,
|
|
170
|
+
onApplyLast: Ie
|
|
170
171
|
},
|
|
171
172
|
"highlight-color"
|
|
172
173
|
);
|
|
@@ -174,9 +175,9 @@ const qe = 6, nt = (P) => {
|
|
|
174
175
|
return /* @__PURE__ */ t(
|
|
175
176
|
f,
|
|
176
177
|
{
|
|
177
|
-
icon: /* @__PURE__ */ t(
|
|
178
|
+
icon: /* @__PURE__ */ t(N, { size: 16 }),
|
|
178
179
|
title: "Insert Link",
|
|
179
|
-
onClick:
|
|
180
|
+
onClick: ue,
|
|
180
181
|
disabled: i || o
|
|
181
182
|
},
|
|
182
183
|
"link"
|
|
@@ -187,7 +188,7 @@ const qe = 6, nt = (P) => {
|
|
|
187
188
|
{
|
|
188
189
|
icon: /* @__PURE__ */ t(F, { size: 16 }),
|
|
189
190
|
title: "Insert Image",
|
|
190
|
-
onClick:
|
|
191
|
+
onClick: me,
|
|
191
192
|
disabled: i || o
|
|
192
193
|
},
|
|
193
194
|
"image"
|
|
@@ -196,7 +197,7 @@ const qe = 6, nt = (P) => {
|
|
|
196
197
|
return /* @__PURE__ */ t(
|
|
197
198
|
f,
|
|
198
199
|
{
|
|
199
|
-
icon: /* @__PURE__ */ t(
|
|
200
|
+
icon: /* @__PURE__ */ t(M, { size: 16 }),
|
|
200
201
|
title: "Align Left",
|
|
201
202
|
onClick: () => {
|
|
202
203
|
var r;
|
|
@@ -238,7 +239,7 @@ const qe = 6, nt = (P) => {
|
|
|
238
239
|
return /* @__PURE__ */ t(
|
|
239
240
|
f,
|
|
240
241
|
{
|
|
241
|
-
icon: /* @__PURE__ */ t(
|
|
242
|
+
icon: /* @__PURE__ */ t(V, { size: 16 }),
|
|
242
243
|
title: "Justify",
|
|
243
244
|
onClick: () => {
|
|
244
245
|
var r;
|
|
@@ -252,7 +253,7 @@ const qe = 6, nt = (P) => {
|
|
|
252
253
|
return /* @__PURE__ */ t(
|
|
253
254
|
f,
|
|
254
255
|
{
|
|
255
|
-
icon: /* @__PURE__ */ t(
|
|
256
|
+
icon: /* @__PURE__ */ t(P, { size: 16 }),
|
|
256
257
|
title: "Increase Indent",
|
|
257
258
|
onClick: () => {
|
|
258
259
|
var r;
|
|
@@ -291,7 +292,7 @@ const qe = 6, nt = (P) => {
|
|
|
291
292
|
"clearFormat"
|
|
292
293
|
);
|
|
293
294
|
if (e === "more")
|
|
294
|
-
return /* @__PURE__ */ t(
|
|
295
|
+
return /* @__PURE__ */ t(Fe, { disabled: i || o, isMobile: _, children: (_ ? ve : [
|
|
295
296
|
"alignLeft",
|
|
296
297
|
"alignCenter",
|
|
297
298
|
"alignRight",
|
|
@@ -301,35 +302,35 @@ const qe = 6, nt = (P) => {
|
|
|
301
302
|
"blockquote",
|
|
302
303
|
"code",
|
|
303
304
|
"clearFormat"
|
|
304
|
-
].map((g,
|
|
305
|
-
const c =
|
|
305
|
+
]).map((g, E) => k(g, E + 1e3)) }, "more");
|
|
306
|
+
const c = B[e], s = pe[e];
|
|
306
307
|
return !c || !s ? null : /* @__PURE__ */ t(
|
|
307
308
|
f,
|
|
308
309
|
{
|
|
309
310
|
icon: s,
|
|
310
311
|
title: c.title,
|
|
311
|
-
active:
|
|
312
|
-
onClick: () =>
|
|
312
|
+
active: X.has(e),
|
|
313
|
+
onClick: () => ce(e),
|
|
313
314
|
disabled: i || o
|
|
314
315
|
},
|
|
315
316
|
e
|
|
316
317
|
);
|
|
317
318
|
};
|
|
318
|
-
return /* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ Re(
|
|
319
320
|
"div",
|
|
320
321
|
{
|
|
321
322
|
id: Y,
|
|
322
|
-
"data-testid":
|
|
323
|
-
className:
|
|
323
|
+
"data-testid": Q,
|
|
324
|
+
className: R(
|
|
324
325
|
"Bear-RichEditor",
|
|
325
|
-
|
|
326
|
+
xe,
|
|
326
327
|
i && "Bear-RichEditor--disabled",
|
|
327
328
|
o && "Bear-RichEditor--readonly",
|
|
328
|
-
|
|
329
|
+
K
|
|
329
330
|
),
|
|
330
|
-
...
|
|
331
|
+
...W,
|
|
331
332
|
children: [
|
|
332
|
-
|
|
333
|
+
O.length > 0 && /* @__PURE__ */ t("div", { className: R("Bear-RichEditor__toolbar", ze), children: O.map((e, n) => k(e, n)) }),
|
|
333
334
|
/* @__PURE__ */ t(
|
|
334
335
|
"div",
|
|
335
336
|
{
|
|
@@ -339,16 +340,16 @@ const qe = 6, nt = (P) => {
|
|
|
339
340
|
onSelect: h,
|
|
340
341
|
onKeyUp: h,
|
|
341
342
|
onMouseUp: h,
|
|
342
|
-
onPaste:
|
|
343
|
+
onPaste: Ce,
|
|
343
344
|
"data-placeholder": q,
|
|
344
|
-
className:
|
|
345
|
+
className: R(
|
|
345
346
|
"Bear-RichEditor__content",
|
|
346
|
-
|
|
347
|
+
ke,
|
|
347
348
|
"[&:empty]:before:bear-content-[attr(data-placeholder)] [&:empty]:before:bear-text-gray-400 [&:empty]:before:bear-pointer-events-none",
|
|
348
349
|
i && "Bear-RichEditor__content--disabled bear-opacity-50 bear-cursor-not-allowed"
|
|
349
350
|
),
|
|
350
351
|
style: {
|
|
351
|
-
minHeight: typeof
|
|
352
|
+
minHeight: typeof b == "number" ? `${b}px` : b,
|
|
352
353
|
maxHeight: m ? typeof m == "number" ? `${m}px` : m : void 0,
|
|
353
354
|
overflowY: m ? "auto" : void 0
|
|
354
355
|
}
|
|
@@ -359,5 +360,5 @@ const qe = 6, nt = (P) => {
|
|
|
359
360
|
);
|
|
360
361
|
};
|
|
361
362
|
export {
|
|
362
|
-
|
|
363
|
+
ct as RichEditor
|
|
363
364
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),S=require("react-dom"),i=require("../../../../utils/cn.cjs"),d=require("../../RichEditor.const.cjs"),j=require("../../../../hooks/useMediaQuery.cjs"),_=require("../../../Icon/icons/editor.cjs"),I=require("../../../Icon/icons/status.cjs"),N=R=>{const{value:s,onChange:w,title:v,disabled:c,type:a="text",recentColors:u=[],onApplyLast:p}=R,[l,g]=r.useState(!1),[x,b]=r.useState({top:0,left:0}),m=r.useRef(null),h=r.useRef(null),o=j.useMediaQuery("(max-width: 640px)");r.useEffect(()=>{if(l&&o&&h.current&&typeof document<"u"){const e=h.current.getBoundingClientRect(),n=e.top,C=window.innerHeight-e.bottom;C>=240||C>=n?b({top:e.bottom+4,left:Math.max(8,Math.min(e.left,window.innerWidth-220))}):b({top:e.top-244,left:Math.max(8,Math.min(e.left,window.innerWidth-220))})}},[l,o]),r.useEffect(()=>{const e=n=>{m.current&&!m.current.contains(n.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const f=e=>{w(e),g(!1)},E=a==="text"?_.FormatColorTextIcon:_.HighlightIcon,y=u[0]||s,k=t.jsxs("div",{className:i.cn("Bear-RichEditor__color-menu p-3 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px] max-w-[min(90vw,240px)]",o?"fixed z-[9999]":"absolute bottom-full left-0 mb-1"),style:o?{top:x.top,left:x.left}:void 0,children:[u.length>0&&t.jsxs("div",{className:"mb-3",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1.5",children:"Recent"}),t.jsx("div",{className:"flex gap-1 flex-wrap",children:u.slice(0,6).map((e,n)=>t.jsx("button",{type:"button",onClick:()=>f(e),className:i.cn("w-6 h-6 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110 touch-manipulation",s===e&&"ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"),style:{backgroundColor:e},title:e},`recent-${n}`))})]}),t.jsx("div",{className:"grid grid-cols-8 gap-1",children:d.RICH_EDITOR_COLORS.map(e=>t.jsx("button",{type:"button",onClick:()=>f(e),className:i.cn("Bear-RichEditor__color-swatch w-5 h-5 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110 touch-manipulation",s===e&&"ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"),style:{backgroundColor:e},title:e},e))}),t.jsxs("button",{type:"button",onClick:()=>f(""),className:"w-full mt-2 px-2 py-1.5 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors touch-manipulation",children:["Remove ",a==="text"?"color":"highlight"]})]});return t.jsxs("div",{ref:m,className:"Bear-RichEditor__color-picker relative flex items-center",children:[t.jsxs("button",{ref:h,type:"button",title:v,disabled:c,onClick:()=>g(!l),className:i.cn("Bear-RichEditor__color-trigger",d.RICH_EDITOR_BUTTON_BASE_CLASSES,d.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,"flex items-center gap-0.5",c&&`Bear-RichEditor__color-trigger--disabled ${d.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:[t.jsx(E,{size:16}),t.jsx("span",{className:"w-3 h-1 rounded-sm mt-0.5",style:{backgroundColor:s||(a==="text"?"#000000":"#fef08a")}})]}),y&&p&&t.jsx("button",{type:"button",title:`Apply ${a==="text"?"text":"highlight"} color`,disabled:c,onClick:()=>p(y),className:i.cn("Bear-RichEditor__color-apply","p-0.5 rounded transition-colors","text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700",c&&"opacity-50 cursor-not-allowed"),children:t.jsx(I.CheckIcon,{size:12})}),l&&(o&&typeof document<"u"?S.createPortal(k,document.body):k)]})};exports.ToolbarColorPicker=N;
|
|
@@ -1,126 +1,136 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as C, useRef as _, useEffect as w } from "react";
|
|
3
|
+
import { createPortal as N } from "react-dom";
|
|
4
|
+
import { cn as i } from "../../../../utils/cn.js";
|
|
5
|
+
import { RICH_EDITOR_COLORS as S, RICH_EDITOR_BUTTON_DISABLED_CLASSES as B, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as T, RICH_EDITOR_BUTTON_BASE_CLASSES as O } from "../../RichEditor.const.js";
|
|
6
|
+
import { useMediaQuery as z } from "../../../../hooks/useMediaQuery.js";
|
|
7
|
+
import { FormatColorTextIcon as A, HighlightIcon as L } from "../../../Icon/icons/editor.js";
|
|
8
|
+
import { CheckIcon as M } from "../../../Icon/icons/status.js";
|
|
9
|
+
const Q = (R) => {
|
|
8
10
|
const {
|
|
9
|
-
value:
|
|
10
|
-
onChange:
|
|
11
|
-
title:
|
|
12
|
-
disabled:
|
|
13
|
-
type:
|
|
14
|
-
recentColors:
|
|
15
|
-
onApplyLast:
|
|
16
|
-
} =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
value: a,
|
|
12
|
+
onChange: v,
|
|
13
|
+
title: E,
|
|
14
|
+
disabled: l,
|
|
15
|
+
type: c = "text",
|
|
16
|
+
recentColors: d = [],
|
|
17
|
+
onApplyLast: g
|
|
18
|
+
} = R, [s, m] = C(!1), [h, b] = C({ top: 0, left: 0 }), u = _(null), p = _(null), o = z("(max-width: 640px)");
|
|
19
|
+
w(() => {
|
|
20
|
+
if (s && o && p.current && typeof document < "u") {
|
|
21
|
+
const t = p.current.getBoundingClientRect(), r = t.top, k = window.innerHeight - t.bottom;
|
|
22
|
+
k >= 240 || k >= r ? b({ top: t.bottom + 4, left: Math.max(8, Math.min(t.left, window.innerWidth - 220)) }) : b({ top: t.top - 244, left: Math.max(8, Math.min(t.left, window.innerWidth - 220)) });
|
|
23
|
+
}
|
|
24
|
+
}, [s, o]), w(() => {
|
|
25
|
+
const t = (r) => {
|
|
26
|
+
u.current && !u.current.contains(r.target) && m(!1);
|
|
20
27
|
};
|
|
21
|
-
return document.addEventListener("mousedown",
|
|
28
|
+
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
|
22
29
|
}, []);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
const f = (t) => {
|
|
31
|
+
v(t), m(!1);
|
|
32
|
+
}, I = c === "text" ? A : L, x = d[0] || a, y = /* @__PURE__ */ n(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
className: i(
|
|
36
|
+
"Bear-RichEditor__color-menu p-3 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px] max-w-[min(90vw,240px)]",
|
|
37
|
+
o ? "fixed z-[9999]" : "absolute bottom-full left-0 mb-1"
|
|
38
|
+
),
|
|
39
|
+
style: o ? { top: h.top, left: h.left } : void 0,
|
|
40
|
+
children: [
|
|
41
|
+
d.length > 0 && /* @__PURE__ */ n("div", { className: "mb-3", children: [
|
|
42
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1.5", children: "Recent" }),
|
|
43
|
+
/* @__PURE__ */ e("div", { className: "flex gap-1 flex-wrap", children: d.slice(0, 6).map((t, r) => /* @__PURE__ */ e(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
type: "button",
|
|
47
|
+
onClick: () => f(t),
|
|
48
|
+
className: i(
|
|
49
|
+
"w-6 h-6 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110 touch-manipulation",
|
|
50
|
+
a === t && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
|
|
51
|
+
),
|
|
52
|
+
style: { backgroundColor: t },
|
|
53
|
+
title: t
|
|
54
|
+
},
|
|
55
|
+
`recent-${r}`
|
|
56
|
+
)) })
|
|
57
|
+
] }),
|
|
58
|
+
/* @__PURE__ */ e("div", { className: "grid grid-cols-8 gap-1", children: S.map((t) => /* @__PURE__ */ e(
|
|
59
|
+
"button",
|
|
60
|
+
{
|
|
61
|
+
type: "button",
|
|
62
|
+
onClick: () => f(t),
|
|
63
|
+
className: i(
|
|
64
|
+
"Bear-RichEditor__color-swatch w-5 h-5 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110 touch-manipulation",
|
|
65
|
+
a === t && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
|
|
66
|
+
),
|
|
67
|
+
style: { backgroundColor: t },
|
|
68
|
+
title: t
|
|
69
|
+
},
|
|
70
|
+
t
|
|
71
|
+
)) }),
|
|
72
|
+
/* @__PURE__ */ n(
|
|
73
|
+
"button",
|
|
74
|
+
{
|
|
75
|
+
type: "button",
|
|
76
|
+
onClick: () => f(""),
|
|
77
|
+
className: "w-full mt-2 px-2 py-1.5 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors touch-manipulation",
|
|
78
|
+
children: [
|
|
79
|
+
"Remove ",
|
|
80
|
+
c === "text" ? "color" : "highlight"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
return /* @__PURE__ */ n("div", { ref: u, className: "Bear-RichEditor__color-picker relative flex items-center", children: [
|
|
88
|
+
/* @__PURE__ */ n(
|
|
28
89
|
"button",
|
|
29
90
|
{
|
|
91
|
+
ref: p,
|
|
30
92
|
type: "button",
|
|
31
|
-
title:
|
|
32
|
-
disabled:
|
|
33
|
-
onClick: () =>
|
|
34
|
-
className:
|
|
93
|
+
title: E,
|
|
94
|
+
disabled: l,
|
|
95
|
+
onClick: () => m(!s),
|
|
96
|
+
className: i(
|
|
35
97
|
"Bear-RichEditor__color-trigger",
|
|
36
|
-
|
|
37
|
-
|
|
98
|
+
O,
|
|
99
|
+
T,
|
|
38
100
|
"flex items-center gap-0.5",
|
|
39
|
-
|
|
101
|
+
l && `Bear-RichEditor__color-trigger--disabled ${B}`
|
|
40
102
|
),
|
|
41
103
|
children: [
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ e(I, { size: 16 }),
|
|
105
|
+
/* @__PURE__ */ e(
|
|
44
106
|
"span",
|
|
45
107
|
{
|
|
46
108
|
className: "w-3 h-1 rounded-sm mt-0.5",
|
|
47
|
-
style: { backgroundColor:
|
|
109
|
+
style: { backgroundColor: a || (c === "text" ? "#000000" : "#fef08a") }
|
|
48
110
|
}
|
|
49
111
|
)
|
|
50
112
|
]
|
|
51
113
|
}
|
|
52
114
|
),
|
|
53
|
-
|
|
115
|
+
x && g && /* @__PURE__ */ e(
|
|
54
116
|
"button",
|
|
55
117
|
{
|
|
56
118
|
type: "button",
|
|
57
|
-
title: `Apply ${
|
|
58
|
-
disabled:
|
|
59
|
-
onClick: () =>
|
|
60
|
-
className:
|
|
119
|
+
title: `Apply ${c === "text" ? "text" : "highlight"} color`,
|
|
120
|
+
disabled: l,
|
|
121
|
+
onClick: () => g(x),
|
|
122
|
+
className: i(
|
|
61
123
|
"Bear-RichEditor__color-apply",
|
|
62
124
|
"p-0.5 rounded transition-colors",
|
|
63
125
|
"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700",
|
|
64
|
-
|
|
126
|
+
l && "opacity-50 cursor-not-allowed"
|
|
65
127
|
),
|
|
66
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ e(M, { size: 12 })
|
|
67
129
|
}
|
|
68
130
|
),
|
|
69
|
-
|
|
70
|
-
"div",
|
|
71
|
-
{
|
|
72
|
-
className: "Bear-RichEditor__color-menu absolute bottom-full left-0 mb-1 p-3 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px]",
|
|
73
|
-
style: { zIndex: 9999 },
|
|
74
|
-
children: [
|
|
75
|
-
l.length > 0 && /* @__PURE__ */ r("div", { className: "mb-3", children: [
|
|
76
|
-
/* @__PURE__ */ t("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1.5", children: "Recent" }),
|
|
77
|
-
/* @__PURE__ */ t("div", { className: "flex gap-1", children: l.slice(0, 6).map((e, g) => /* @__PURE__ */ t(
|
|
78
|
-
"button",
|
|
79
|
-
{
|
|
80
|
-
type: "button",
|
|
81
|
-
onClick: () => d(e),
|
|
82
|
-
className: a(
|
|
83
|
-
"w-6 h-6 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",
|
|
84
|
-
o === e && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
|
|
85
|
-
),
|
|
86
|
-
style: { backgroundColor: e },
|
|
87
|
-
title: e
|
|
88
|
-
},
|
|
89
|
-
`recent-${g}`
|
|
90
|
-
)) })
|
|
91
|
-
] }),
|
|
92
|
-
/* @__PURE__ */ t("div", { className: "grid grid-cols-8 gap-1", children: v.map((e) => /* @__PURE__ */ t(
|
|
93
|
-
"button",
|
|
94
|
-
{
|
|
95
|
-
type: "button",
|
|
96
|
-
onClick: () => d(e),
|
|
97
|
-
className: a(
|
|
98
|
-
"Bear-RichEditor__color-swatch",
|
|
99
|
-
"w-5 h-5 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",
|
|
100
|
-
o === e && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
|
|
101
|
-
),
|
|
102
|
-
style: { backgroundColor: e },
|
|
103
|
-
title: e
|
|
104
|
-
},
|
|
105
|
-
e
|
|
106
|
-
)) }),
|
|
107
|
-
/* @__PURE__ */ r(
|
|
108
|
-
"button",
|
|
109
|
-
{
|
|
110
|
-
type: "button",
|
|
111
|
-
onClick: () => d(""),
|
|
112
|
-
className: "w-full mt-2 px-2 py-1.5 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors",
|
|
113
|
-
children: [
|
|
114
|
-
"Remove ",
|
|
115
|
-
i === "text" ? "color" : "highlight"
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
)
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
)
|
|
131
|
+
s && (o && typeof document < "u" ? N(y, document.body) : y)
|
|
122
132
|
] });
|
|
123
133
|
};
|
|
124
134
|
export {
|
|
125
|
-
|
|
135
|
+
Q as ToolbarColorPicker
|
|
126
136
|
};
|