@forgedevstack/bear 1.1.0 → 1.1.3
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/AlertDialog/AlertDialog.cjs +1 -0
- package/dist/components/AlertDialog/AlertDialog.const.cjs +1 -0
- package/dist/components/AlertDialog/AlertDialog.const.d.ts +5 -0
- package/dist/components/AlertDialog/AlertDialog.const.js +8 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts +4 -0
- package/dist/components/AlertDialog/AlertDialog.js +107 -0
- package/dist/components/AlertDialog/AlertDialog.types.d.ts +34 -0
- package/dist/components/AlertDialog/index.d.ts +3 -0
- package/dist/components/AspectRatio/AspectRatio.cjs +1 -0
- package/dist/components/AspectRatio/AspectRatio.d.ts +3 -0
- package/dist/components/AspectRatio/AspectRatio.js +29 -0
- package/dist/components/AspectRatio/AspectRatio.types.d.ts +9 -0
- package/dist/components/AspectRatio/index.d.ts +2 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +2 -2
- package/dist/components/Button/Button.constants.d.ts +1 -0
- package/dist/components/Button/Button.constants.js +10 -3
- package/dist/components/Button/Button.js +92 -84
- package/dist/components/Button/Button.types.d.ts +2 -0
- package/dist/components/FormField/FormField.cjs +1 -0
- package/dist/components/FormField/FormField.const.cjs +1 -0
- package/dist/components/FormField/FormField.const.d.ts +20 -0
- package/dist/components/FormField/FormField.const.js +23 -0
- package/dist/components/FormField/FormField.d.ts +3 -0
- package/dist/components/FormField/FormField.js +127 -0
- package/dist/components/FormField/FormField.types.d.ts +23 -0
- package/dist/components/FormField/index.d.ts +2 -0
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +81 -44
- package/dist/components/Input/Input.types.d.ts +10 -0
- package/dist/components/Input/components/ClearIcon/ClearIcon.cjs +1 -0
- package/dist/components/Input/components/ClearIcon/ClearIcon.d.ts +7 -0
- package/dist/components/Input/components/ClearIcon/ClearIcon.js +25 -0
- package/dist/components/Input/components/ClearIcon/index.d.ts +1 -0
- package/dist/components/InputGroup/InputGroup.cjs +1 -0
- package/dist/components/InputGroup/InputGroup.d.ts +4 -0
- package/dist/components/InputGroup/InputGroup.js +63 -0
- package/dist/components/InputGroup/InputGroup.types.d.ts +23 -0
- package/dist/components/InputGroup/index.d.ts +2 -0
- package/dist/components/PasswordInput/PasswordInput.cjs +1 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts +3 -0
- package/dist/components/PasswordInput/PasswordInput.js +61 -0
- package/dist/components/PasswordInput/PasswordInput.types.d.ts +18 -0
- package/dist/components/PasswordInput/index.d.ts +2 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.cjs +1 -1
- package/dist/components/ResizableTextarea/ResizableTextarea.js +90 -54
- package/dist/components/ResizableTextarea/ResizableTextarea.types.d.ts +10 -0
- package/dist/components/RichEditor/RichEditor.cjs +1 -1
- package/dist/components/RichEditor/RichEditor.js +186 -169
- package/dist/components/RichEditor/RichEditor.types.d.ts +4 -0
- package/dist/components/Typewriter/Typewriter.cjs +1 -1
- package/dist/components/Typewriter/Typewriter.js +59 -65
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +44 -34
- package/dist/index.cjs +1 -1
- package/dist/index.js +126 -116
- package/dist/styles.css +1 -1
- package/dist/types/component.types.d.ts +13 -0
- package/package.json +1 -4
|
@@ -1,173 +1,176 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { getActiveFormats as
|
|
5
|
-
import { RICH_EDITOR_MIN_HEIGHT as
|
|
6
|
-
import { useMediaQuery as
|
|
1
|
+
import { jsxs as S, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ye, useState as C, useEffect as x, useCallback as d } from "react";
|
|
3
|
+
import { cn as p } from "../../utils/cn.js";
|
|
4
|
+
import { getActiveFormats as Le, queryCommandValue as xe, execCommand as u, insertLink as He, setTextColor as B, setHighlightColor as D, fileToDataUrl as N, insertImage as F } from "./helpers/formatHelpers.js";
|
|
5
|
+
import { RICH_EDITOR_MIN_HEIGHT as Oe, RICH_EDITOR_DEFAULT_TOOLBAR as ke, RICH_EDITOR_CONTENT_STYLES as ze, RICH_EDITOR_BUTTON_CONFIG as M, RICH_EDITOR_MOBILE_TOOLBAR as ve, RICH_EDITOR_TOOLBAR_CLASSES as Ae, RICH_EDITOR_CONTENT_CLASSES as Se, RICH_EDITOR_ROOT_CLASSES as Be, RICH_EDITOR_DIVIDER_CLASSES as De, RICH_EDITOR_HEADING_OPTIONS as Ne, RICH_EDITOR_MOBILE_MORE_ITEMS as Fe, RICH_EDITOR_MOBILE_BREAKPOINT as Me } from "./RichEditor.const.js";
|
|
6
|
+
import { useMediaQuery as we } from "../../hooks/useMediaQuery.js";
|
|
7
7
|
import { ToolbarButton as f } from "./components/ToolbarButton/ToolbarButton.js";
|
|
8
|
-
import { ToolbarDropdown as
|
|
9
|
-
import { ToolbarColorPicker as
|
|
10
|
-
import { ToolbarMore as
|
|
11
|
-
import { TextIcon as
|
|
12
|
-
const
|
|
8
|
+
import { ToolbarDropdown as Ue } from "./components/ToolbarDropdown/ToolbarDropdown.js";
|
|
9
|
+
import { ToolbarColorPicker as w } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
|
|
10
|
+
import { ToolbarMore as Ve } from "./components/ToolbarMore/ToolbarMore.js";
|
|
11
|
+
import { TextIcon as Pe, InsertLinkIcon as U, InsertPhotoIcon as V, AlignLeftIcon as P, AlignCenterIcon as j, AlignRightIcon as J, AlignJustifyIcon as $, IndentIncreaseIcon as q, IndentDecreaseIcon as G, FormatClearIcon as K, TableIcon as je, CodeIcon as Je, QuoteIcon as $e, ListNumberedIcon as qe, ListBulletIcon as Ge, Heading3Icon as Ke, Heading2Icon as Qe, Heading1Icon as Ye, StrikethroughIcon as We, UnderlineIcon as Xe, ItalicIcon as Ze, BoldIcon as et } from "../Icon/icons/editor.js";
|
|
12
|
+
const tt = 6, gt = (Q) => {
|
|
13
13
|
const {
|
|
14
|
-
value:
|
|
15
|
-
defaultValue:
|
|
16
|
-
onChange:
|
|
17
|
-
placeholder:
|
|
18
|
-
disabled:
|
|
14
|
+
value: I,
|
|
15
|
+
defaultValue: H = "",
|
|
16
|
+
onChange: R,
|
|
17
|
+
placeholder: Y = "Start typing...",
|
|
18
|
+
disabled: r = !1,
|
|
19
19
|
readOnly: o = !1,
|
|
20
|
-
minHeight:
|
|
20
|
+
minHeight: T = Oe,
|
|
21
21
|
maxHeight: m,
|
|
22
|
-
toolbar:
|
|
23
|
-
className:
|
|
24
|
-
testId:
|
|
25
|
-
id:
|
|
26
|
-
allowImagePaste:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
toolbar: W = ke,
|
|
23
|
+
className: X = "",
|
|
24
|
+
testId: Z,
|
|
25
|
+
id: ee,
|
|
26
|
+
allowImagePaste: O = !0,
|
|
27
|
+
showCharCount: _ = !1,
|
|
28
|
+
charCountMax: E,
|
|
29
|
+
...te
|
|
30
|
+
} = Q, l = ye(null), y = we(`(max-width: ${Me}px)`), k = y ? ve : W, [ne, re] = C(/* @__PURE__ */ new Set()), [oe, z] = C("p"), [v, ie] = C(0), [ae, le] = C("#000000"), [se, ce] = C("#fef08a"), [de, ue] = C([]), [fe, ge] = C([]);
|
|
31
|
+
x(() => {
|
|
30
32
|
const e = "bear-rich-editor-styles";
|
|
31
33
|
if (!document.getElementById(e)) {
|
|
32
34
|
const n = document.createElement("style");
|
|
33
|
-
n.id = e, n.textContent =
|
|
35
|
+
n.id = e, n.textContent = ze, document.head.appendChild(n);
|
|
34
36
|
}
|
|
35
|
-
}, []),
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
|
|
37
|
+
}, []), x(() => {
|
|
38
|
+
l.current && I !== void 0 && l.current.innerHTML !== I && (l.current.innerHTML = I);
|
|
39
|
+
}, [I]), x(() => {
|
|
40
|
+
l.current && H && !I && (l.current.innerHTML = H);
|
|
39
41
|
}, []);
|
|
40
42
|
const h = d(() => {
|
|
41
|
-
|
|
42
|
-
const e =
|
|
43
|
+
re(Le());
|
|
44
|
+
const e = xe("formatBlock");
|
|
43
45
|
e && z(e.toLowerCase().replace(/[<>]/g, ""));
|
|
44
|
-
}, []),
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
}, []), a = d(() => {
|
|
47
|
+
var e;
|
|
48
|
+
l.current && (R && R(l.current.innerHTML), _ && ie(((e = l.current.textContent) == null ? void 0 : e.length) ?? 0)), h();
|
|
49
|
+
}, [R, h, _]), he = d((e) => {
|
|
47
50
|
var s;
|
|
48
|
-
if (
|
|
49
|
-
(s =
|
|
50
|
-
const n =
|
|
51
|
+
if (r || o) return;
|
|
52
|
+
(s = l.current) == null || s.focus();
|
|
53
|
+
const n = M[e];
|
|
51
54
|
if (!n) return;
|
|
52
55
|
const c = "value" in n ? n.value : void 0;
|
|
53
|
-
c ? u(n.command, c) : u(n.command), h(),
|
|
54
|
-
}, [
|
|
56
|
+
c ? u(n.command, c) : u(n.command), h(), a();
|
|
57
|
+
}, [r, o, h, a]), Ce = d((e) => {
|
|
55
58
|
var n;
|
|
56
|
-
|
|
57
|
-
}, [
|
|
59
|
+
r || o || ((n = l.current) == null || n.focus(), u("formatBlock", e), z(e), a());
|
|
60
|
+
}, [r, o, a]), Ie = d(() => {
|
|
58
61
|
var s;
|
|
59
|
-
if (
|
|
62
|
+
if (r || o) return;
|
|
60
63
|
const e = window.getSelection(), n = e && e.toString().length > 0, c = prompt("Enter URL:", n ? "" : "https://");
|
|
61
|
-
c && ((s =
|
|
62
|
-
}, [
|
|
64
|
+
c && ((s = l.current) == null || s.focus(), He(c), a());
|
|
65
|
+
}, [r, o, a]), b = d((e, n) => {
|
|
63
66
|
if (!e) return;
|
|
64
|
-
(n === "text" ?
|
|
65
|
-
const
|
|
66
|
-
return [e, ...
|
|
67
|
+
(n === "text" ? ue : ge)((s) => {
|
|
68
|
+
const i = s.filter((g) => g !== e);
|
|
69
|
+
return [e, ...i].slice(0, tt);
|
|
67
70
|
});
|
|
68
|
-
}, []),
|
|
71
|
+
}, []), me = d((e) => {
|
|
69
72
|
var n;
|
|
70
|
-
|
|
71
|
-
}, [
|
|
73
|
+
r || o || ((n = l.current) == null || n.focus(), B(e), le(e), b(e, "text"), a());
|
|
74
|
+
}, [r, o, a, b]), pe = d((e) => {
|
|
72
75
|
var n;
|
|
73
|
-
|
|
74
|
-
}, [
|
|
76
|
+
r || o || ((n = l.current) == null || n.focus(), D(e), ce(e), b(e, "highlight"), a());
|
|
77
|
+
}, [r, o, a, b]), be = d((e) => {
|
|
75
78
|
var n;
|
|
76
|
-
|
|
77
|
-
}, [
|
|
79
|
+
r || o || ((n = l.current) == null || n.focus(), B(e), a());
|
|
80
|
+
}, [r, o, a]), Re = d((e) => {
|
|
78
81
|
var n;
|
|
79
|
-
|
|
80
|
-
}, [
|
|
82
|
+
r || o || ((n = l.current) == null || n.focus(), D(e), a());
|
|
83
|
+
}, [r, o, a]), Te = d(async (e) => {
|
|
81
84
|
var c;
|
|
82
|
-
if (!
|
|
85
|
+
if (!O) return;
|
|
83
86
|
const n = (c = e.clipboardData) == null ? void 0 : c.items;
|
|
84
87
|
if (n)
|
|
85
88
|
for (let s = 0; s < n.length; s++) {
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
89
|
+
const i = n[s];
|
|
90
|
+
if (i.type.startsWith("image/")) {
|
|
88
91
|
e.preventDefault();
|
|
89
|
-
const g =
|
|
92
|
+
const g = i.getAsFile();
|
|
90
93
|
if (g) {
|
|
91
|
-
const
|
|
92
|
-
|
|
94
|
+
const L = await N(g);
|
|
95
|
+
F(L), a();
|
|
93
96
|
}
|
|
94
97
|
return;
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
|
-
}, [
|
|
98
|
-
if (
|
|
100
|
+
}, [O, a]), _e = d(() => {
|
|
101
|
+
if (r || o) return;
|
|
99
102
|
const e = document.createElement("input");
|
|
100
103
|
e.type = "file", e.accept = "image/*", e.onchange = async (n) => {
|
|
101
|
-
var s,
|
|
104
|
+
var s, i;
|
|
102
105
|
const c = (s = n.target.files) == null ? void 0 : s[0];
|
|
103
106
|
if (c) {
|
|
104
|
-
const g = await
|
|
105
|
-
(
|
|
107
|
+
const g = await N(c);
|
|
108
|
+
(i = l.current) == null || i.focus(), F(g), a();
|
|
106
109
|
}
|
|
107
110
|
}, e.click();
|
|
108
|
-
}, [
|
|
109
|
-
bold: /* @__PURE__ */ t(
|
|
110
|
-
italic: /* @__PURE__ */ t(
|
|
111
|
-
underline: /* @__PURE__ */ t(
|
|
112
|
-
strikethrough: /* @__PURE__ */ t(
|
|
113
|
-
heading1: /* @__PURE__ */ t(
|
|
114
|
-
heading2: /* @__PURE__ */ t(
|
|
115
|
-
heading3: /* @__PURE__ */ t(
|
|
116
|
-
bulletList: /* @__PURE__ */ t(
|
|
117
|
-
orderedList: /* @__PURE__ */ t(
|
|
118
|
-
blockquote: /* @__PURE__ */ t(
|
|
119
|
-
code: /* @__PURE__ */ t(
|
|
120
|
-
link: /* @__PURE__ */ t(
|
|
121
|
-
alignLeft: /* @__PURE__ */ t(
|
|
122
|
-
alignCenter: /* @__PURE__ */ t(
|
|
123
|
-
alignRight: /* @__PURE__ */ t(
|
|
124
|
-
alignJustify: /* @__PURE__ */ t(
|
|
125
|
-
image: /* @__PURE__ */ t(
|
|
126
|
-
indent: /* @__PURE__ */ t(
|
|
127
|
-
outdent: /* @__PURE__ */ t(
|
|
128
|
-
clearFormat: /* @__PURE__ */ t(
|
|
129
|
-
table: /* @__PURE__ */ t(
|
|
130
|
-
},
|
|
111
|
+
}, [r, o, a]), Ee = {
|
|
112
|
+
bold: /* @__PURE__ */ t(et, { size: 16 }),
|
|
113
|
+
italic: /* @__PURE__ */ t(Ze, { size: 16 }),
|
|
114
|
+
underline: /* @__PURE__ */ t(Xe, { size: 16 }),
|
|
115
|
+
strikethrough: /* @__PURE__ */ t(We, { size: 16 }),
|
|
116
|
+
heading1: /* @__PURE__ */ t(Ye, { size: 16 }),
|
|
117
|
+
heading2: /* @__PURE__ */ t(Qe, { size: 16 }),
|
|
118
|
+
heading3: /* @__PURE__ */ t(Ke, { size: 16 }),
|
|
119
|
+
bulletList: /* @__PURE__ */ t(Ge, { size: 16 }),
|
|
120
|
+
orderedList: /* @__PURE__ */ t(qe, { size: 16 }),
|
|
121
|
+
blockquote: /* @__PURE__ */ t($e, { size: 16 }),
|
|
122
|
+
code: /* @__PURE__ */ t(Je, { size: 16 }),
|
|
123
|
+
link: /* @__PURE__ */ t(U, { size: 16 }),
|
|
124
|
+
alignLeft: /* @__PURE__ */ t(P, { size: 16 }),
|
|
125
|
+
alignCenter: /* @__PURE__ */ t(j, { size: 16 }),
|
|
126
|
+
alignRight: /* @__PURE__ */ t(J, { size: 16 }),
|
|
127
|
+
alignJustify: /* @__PURE__ */ t($, { size: 16 }),
|
|
128
|
+
image: /* @__PURE__ */ t(V, { size: 16 }),
|
|
129
|
+
indent: /* @__PURE__ */ t(q, { size: 16 }),
|
|
130
|
+
outdent: /* @__PURE__ */ t(G, { size: 16 }),
|
|
131
|
+
clearFormat: /* @__PURE__ */ t(K, { size: 16 }),
|
|
132
|
+
table: /* @__PURE__ */ t(je, { size: 16 })
|
|
133
|
+
}, A = (e, n) => {
|
|
131
134
|
if (e === "divider")
|
|
132
|
-
return /* @__PURE__ */ t("div", { className:
|
|
135
|
+
return /* @__PURE__ */ t("div", { className: p("Bear-RichEditor__divider", De) }, `divider-${n}`);
|
|
133
136
|
if (e === "headingDropdown")
|
|
134
137
|
return /* @__PURE__ */ t(
|
|
135
|
-
|
|
138
|
+
Ue,
|
|
136
139
|
{
|
|
137
|
-
options:
|
|
138
|
-
value:
|
|
139
|
-
onChange:
|
|
140
|
+
options: Ne,
|
|
141
|
+
value: oe,
|
|
142
|
+
onChange: Ce,
|
|
140
143
|
title: "Text Style",
|
|
141
|
-
disabled:
|
|
142
|
-
icon: /* @__PURE__ */ t(
|
|
144
|
+
disabled: r || o,
|
|
145
|
+
icon: /* @__PURE__ */ t(Pe, { size: 16 })
|
|
143
146
|
},
|
|
144
147
|
"heading-dropdown"
|
|
145
148
|
);
|
|
146
149
|
if (e === "textColor")
|
|
147
150
|
return /* @__PURE__ */ t(
|
|
148
|
-
|
|
151
|
+
w,
|
|
149
152
|
{
|
|
150
|
-
value:
|
|
151
|
-
onChange:
|
|
153
|
+
value: ae,
|
|
154
|
+
onChange: me,
|
|
152
155
|
title: "Text Color",
|
|
153
|
-
disabled:
|
|
156
|
+
disabled: r || o,
|
|
154
157
|
type: "text",
|
|
155
|
-
recentColors:
|
|
156
|
-
onApplyLast:
|
|
158
|
+
recentColors: de,
|
|
159
|
+
onApplyLast: be
|
|
157
160
|
},
|
|
158
161
|
"text-color"
|
|
159
162
|
);
|
|
160
163
|
if (e === "highlightColor")
|
|
161
164
|
return /* @__PURE__ */ t(
|
|
162
|
-
|
|
165
|
+
w,
|
|
163
166
|
{
|
|
164
|
-
value:
|
|
165
|
-
onChange:
|
|
167
|
+
value: se,
|
|
168
|
+
onChange: pe,
|
|
166
169
|
title: "Highlight Color",
|
|
167
|
-
disabled:
|
|
170
|
+
disabled: r || o,
|
|
168
171
|
type: "highlight",
|
|
169
|
-
recentColors:
|
|
170
|
-
onApplyLast:
|
|
172
|
+
recentColors: fe,
|
|
173
|
+
onApplyLast: Re
|
|
171
174
|
},
|
|
172
175
|
"highlight-color"
|
|
173
176
|
);
|
|
@@ -175,10 +178,10 @@ const We = 6, ct = ($) => {
|
|
|
175
178
|
return /* @__PURE__ */ t(
|
|
176
179
|
f,
|
|
177
180
|
{
|
|
178
|
-
icon: /* @__PURE__ */ t(
|
|
181
|
+
icon: /* @__PURE__ */ t(U, { size: 16 }),
|
|
179
182
|
title: "Insert Link",
|
|
180
|
-
onClick:
|
|
181
|
-
disabled:
|
|
183
|
+
onClick: Ie,
|
|
184
|
+
disabled: r || o
|
|
182
185
|
},
|
|
183
186
|
"link"
|
|
184
187
|
);
|
|
@@ -186,10 +189,10 @@ const We = 6, ct = ($) => {
|
|
|
186
189
|
return /* @__PURE__ */ t(
|
|
187
190
|
f,
|
|
188
191
|
{
|
|
189
|
-
icon: /* @__PURE__ */ t(
|
|
192
|
+
icon: /* @__PURE__ */ t(V, { size: 16 }),
|
|
190
193
|
title: "Insert Image",
|
|
191
|
-
onClick:
|
|
192
|
-
disabled:
|
|
194
|
+
onClick: _e,
|
|
195
|
+
disabled: r || o
|
|
193
196
|
},
|
|
194
197
|
"image"
|
|
195
198
|
);
|
|
@@ -197,13 +200,13 @@ const We = 6, ct = ($) => {
|
|
|
197
200
|
return /* @__PURE__ */ t(
|
|
198
201
|
f,
|
|
199
202
|
{
|
|
200
|
-
icon: /* @__PURE__ */ t(
|
|
203
|
+
icon: /* @__PURE__ */ t(P, { size: 16 }),
|
|
201
204
|
title: "Align Left",
|
|
202
205
|
onClick: () => {
|
|
203
|
-
var
|
|
204
|
-
(
|
|
206
|
+
var i;
|
|
207
|
+
(i = l.current) == null || i.focus(), u("justifyLeft"), a();
|
|
205
208
|
},
|
|
206
|
-
disabled:
|
|
209
|
+
disabled: r || o
|
|
207
210
|
},
|
|
208
211
|
"alignLeft"
|
|
209
212
|
);
|
|
@@ -211,13 +214,13 @@ const We = 6, ct = ($) => {
|
|
|
211
214
|
return /* @__PURE__ */ t(
|
|
212
215
|
f,
|
|
213
216
|
{
|
|
214
|
-
icon: /* @__PURE__ */ t(
|
|
217
|
+
icon: /* @__PURE__ */ t(j, { size: 16 }),
|
|
215
218
|
title: "Align Center",
|
|
216
219
|
onClick: () => {
|
|
217
|
-
var
|
|
218
|
-
(
|
|
220
|
+
var i;
|
|
221
|
+
(i = l.current) == null || i.focus(), u("justifyCenter"), a();
|
|
219
222
|
},
|
|
220
|
-
disabled:
|
|
223
|
+
disabled: r || o
|
|
221
224
|
},
|
|
222
225
|
"alignCenter"
|
|
223
226
|
);
|
|
@@ -225,13 +228,13 @@ const We = 6, ct = ($) => {
|
|
|
225
228
|
return /* @__PURE__ */ t(
|
|
226
229
|
f,
|
|
227
230
|
{
|
|
228
|
-
icon: /* @__PURE__ */ t(
|
|
231
|
+
icon: /* @__PURE__ */ t(J, { size: 16 }),
|
|
229
232
|
title: "Align Right",
|
|
230
233
|
onClick: () => {
|
|
231
|
-
var
|
|
232
|
-
(
|
|
234
|
+
var i;
|
|
235
|
+
(i = l.current) == null || i.focus(), u("justifyRight"), a();
|
|
233
236
|
},
|
|
234
|
-
disabled:
|
|
237
|
+
disabled: r || o
|
|
235
238
|
},
|
|
236
239
|
"alignRight"
|
|
237
240
|
);
|
|
@@ -239,13 +242,13 @@ const We = 6, ct = ($) => {
|
|
|
239
242
|
return /* @__PURE__ */ t(
|
|
240
243
|
f,
|
|
241
244
|
{
|
|
242
|
-
icon: /* @__PURE__ */ t(
|
|
245
|
+
icon: /* @__PURE__ */ t($, { size: 16 }),
|
|
243
246
|
title: "Justify",
|
|
244
247
|
onClick: () => {
|
|
245
|
-
var
|
|
246
|
-
(
|
|
248
|
+
var i;
|
|
249
|
+
(i = l.current) == null || i.focus(), u("justifyFull"), a();
|
|
247
250
|
},
|
|
248
|
-
disabled:
|
|
251
|
+
disabled: r || o
|
|
249
252
|
},
|
|
250
253
|
"alignJustify"
|
|
251
254
|
);
|
|
@@ -253,13 +256,13 @@ const We = 6, ct = ($) => {
|
|
|
253
256
|
return /* @__PURE__ */ t(
|
|
254
257
|
f,
|
|
255
258
|
{
|
|
256
|
-
icon: /* @__PURE__ */ t(
|
|
259
|
+
icon: /* @__PURE__ */ t(q, { size: 16 }),
|
|
257
260
|
title: "Increase Indent",
|
|
258
261
|
onClick: () => {
|
|
259
|
-
var
|
|
260
|
-
(
|
|
262
|
+
var i;
|
|
263
|
+
(i = l.current) == null || i.focus(), u("indent"), a();
|
|
261
264
|
},
|
|
262
|
-
disabled:
|
|
265
|
+
disabled: r || o
|
|
263
266
|
},
|
|
264
267
|
"indent"
|
|
265
268
|
);
|
|
@@ -267,13 +270,13 @@ const We = 6, ct = ($) => {
|
|
|
267
270
|
return /* @__PURE__ */ t(
|
|
268
271
|
f,
|
|
269
272
|
{
|
|
270
|
-
icon: /* @__PURE__ */ t(
|
|
273
|
+
icon: /* @__PURE__ */ t(G, { size: 16 }),
|
|
271
274
|
title: "Decrease Indent",
|
|
272
275
|
onClick: () => {
|
|
273
|
-
var
|
|
274
|
-
(
|
|
276
|
+
var i;
|
|
277
|
+
(i = l.current) == null || i.focus(), u("outdent"), a();
|
|
275
278
|
},
|
|
276
|
-
disabled:
|
|
279
|
+
disabled: r || o
|
|
277
280
|
},
|
|
278
281
|
"outdent"
|
|
279
282
|
);
|
|
@@ -281,18 +284,18 @@ const We = 6, ct = ($) => {
|
|
|
281
284
|
return /* @__PURE__ */ t(
|
|
282
285
|
f,
|
|
283
286
|
{
|
|
284
|
-
icon: /* @__PURE__ */ t(
|
|
287
|
+
icon: /* @__PURE__ */ t(K, { size: 16 }),
|
|
285
288
|
title: "Clear Formatting",
|
|
286
289
|
onClick: () => {
|
|
287
|
-
var
|
|
288
|
-
(
|
|
290
|
+
var i;
|
|
291
|
+
(i = l.current) == null || i.focus(), u("removeFormat"), a();
|
|
289
292
|
},
|
|
290
|
-
disabled:
|
|
293
|
+
disabled: r || o
|
|
291
294
|
},
|
|
292
295
|
"clearFormat"
|
|
293
296
|
);
|
|
294
297
|
if (e === "more")
|
|
295
|
-
return /* @__PURE__ */ t(
|
|
298
|
+
return /* @__PURE__ */ t(Ve, { disabled: r || o, isMobile: y, children: (y ? Fe : [
|
|
296
299
|
"alignLeft",
|
|
297
300
|
"alignCenter",
|
|
298
301
|
"alignRight",
|
|
@@ -302,63 +305,77 @@ const We = 6, ct = ($) => {
|
|
|
302
305
|
"blockquote",
|
|
303
306
|
"code",
|
|
304
307
|
"clearFormat"
|
|
305
|
-
]).map((g,
|
|
306
|
-
const c =
|
|
308
|
+
]).map((g, L) => A(g, L + 1e3)) }, "more");
|
|
309
|
+
const c = M[e], s = Ee[e];
|
|
307
310
|
return !c || !s ? null : /* @__PURE__ */ t(
|
|
308
311
|
f,
|
|
309
312
|
{
|
|
310
313
|
icon: s,
|
|
311
314
|
title: c.title,
|
|
312
|
-
active:
|
|
313
|
-
onClick: () =>
|
|
314
|
-
disabled:
|
|
315
|
+
active: ne.has(e),
|
|
316
|
+
onClick: () => he(e),
|
|
317
|
+
disabled: r || o
|
|
315
318
|
},
|
|
316
319
|
e
|
|
317
320
|
);
|
|
318
321
|
};
|
|
319
|
-
return /* @__PURE__ */
|
|
322
|
+
return /* @__PURE__ */ S(
|
|
320
323
|
"div",
|
|
321
324
|
{
|
|
322
|
-
id:
|
|
323
|
-
"data-testid":
|
|
324
|
-
className:
|
|
325
|
+
id: ee,
|
|
326
|
+
"data-testid": Z,
|
|
327
|
+
className: p(
|
|
325
328
|
"Bear-RichEditor",
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
Be,
|
|
330
|
+
r && "Bear-RichEditor--disabled",
|
|
328
331
|
o && "Bear-RichEditor--readonly",
|
|
329
|
-
|
|
332
|
+
X
|
|
330
333
|
),
|
|
331
|
-
...
|
|
334
|
+
...te,
|
|
332
335
|
children: [
|
|
333
|
-
|
|
336
|
+
k.length > 0 && /* @__PURE__ */ t("div", { className: p("Bear-RichEditor__toolbar", Ae), children: k.map((e, n) => A(e, n)) }),
|
|
334
337
|
/* @__PURE__ */ t(
|
|
335
338
|
"div",
|
|
336
339
|
{
|
|
337
|
-
ref:
|
|
338
|
-
contentEditable: !
|
|
339
|
-
onInput:
|
|
340
|
+
ref: l,
|
|
341
|
+
contentEditable: !r && !o,
|
|
342
|
+
onInput: a,
|
|
340
343
|
onSelect: h,
|
|
341
344
|
onKeyUp: h,
|
|
342
345
|
onMouseUp: h,
|
|
343
|
-
onPaste:
|
|
344
|
-
"data-placeholder":
|
|
345
|
-
className:
|
|
346
|
+
onPaste: Te,
|
|
347
|
+
"data-placeholder": Y,
|
|
348
|
+
className: p(
|
|
346
349
|
"Bear-RichEditor__content",
|
|
347
|
-
|
|
350
|
+
Se,
|
|
348
351
|
"[&:empty]:before:bear-content-[attr(data-placeholder)] [&:empty]:before:bear-text-gray-400 [&:empty]:before:bear-pointer-events-none",
|
|
349
|
-
|
|
352
|
+
r && "Bear-RichEditor__content--disabled bear-opacity-50 bear-cursor-not-allowed"
|
|
350
353
|
),
|
|
351
354
|
style: {
|
|
352
|
-
minHeight: typeof
|
|
355
|
+
minHeight: typeof T == "number" ? `${T}px` : T,
|
|
353
356
|
maxHeight: m ? typeof m == "number" ? `${m}px` : m : void 0,
|
|
354
357
|
overflowY: m ? "auto" : void 0
|
|
355
358
|
}
|
|
356
359
|
}
|
|
360
|
+
),
|
|
361
|
+
_ && E != null && /* @__PURE__ */ S(
|
|
362
|
+
"div",
|
|
363
|
+
{
|
|
364
|
+
className: p(
|
|
365
|
+
"Bear-RichEditor__char-count bear-text-xs bear-tabular-nums bear-px-3 bear-py-1.5 bear-text-right bear-border-t bear-border-gray-200 dark:bear-border-gray-700",
|
|
366
|
+
v > E ? "bear-text-red-500" : "bear-text-gray-400 dark:bear-text-gray-500"
|
|
367
|
+
),
|
|
368
|
+
children: [
|
|
369
|
+
v,
|
|
370
|
+
"/",
|
|
371
|
+
E
|
|
372
|
+
]
|
|
373
|
+
}
|
|
357
374
|
)
|
|
358
375
|
]
|
|
359
376
|
}
|
|
360
377
|
);
|
|
361
378
|
};
|
|
362
379
|
export {
|
|
363
|
-
|
|
380
|
+
gt as RichEditor
|
|
364
381
|
};
|
|
@@ -24,6 +24,10 @@ export interface RichEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'o
|
|
|
24
24
|
id?: string;
|
|
25
25
|
/** Enable image paste support */
|
|
26
26
|
allowImagePaste?: boolean;
|
|
27
|
+
/** Show live character count (plain-text length, HTML tags excluded) */
|
|
28
|
+
showCharCount?: boolean;
|
|
29
|
+
/** Max chars for counter display */
|
|
30
|
+
charCountMax?: number;
|
|
27
31
|
}
|
|
28
32
|
export type ToolbarOption = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'headingDropdown' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'image' | 'textColor' | 'highlightColor' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'indent' | 'outdent' | 'clearFormat' | 'table' | 'divider' | 'more';
|
|
29
33
|
export interface ToolbarButtonProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),t=require("react"),X=require("../../utils/cn.cjs"),e=require("./Typewriter.const.cjs"),k=g=>{const{text:I,speed:T=e.DEFAULT_SPEED,startDelay:C=e.DEFAULT_START_DELAY,deleteDelay:N=e.DEFAULT_DELETE_DELAY,deleteSpeed:R=e.DEFAULT_DELETE_SPEED,loop:d=!1,cursor:f=!0,cursorChar:U=e.DEFAULT_CURSOR_CHAR,cursorBlinkSpeed:y=e.DEFAULT_CURSOR_BLINK_SPEED,onComplete:n,onWordComplete:o,as:j="span",className:w,style:F,testId:H}=g,a=t.useMemo(()=>Array.isArray(I)?I:[I],[I]),[v,L]=t.useState(""),[p,S]=t.useState(e.INITIAL_TEXT_INDEX),[m,E]=t.useState(e.INITIAL_CHAR_INDEX),[b,h]=t.useState(!1),[B,q]=t.useState(!0),s=t.useRef(),_=t.useRef(p),c=t.useRef(m),D=t.useRef(b);_.current=p,c.current=m,D.current=b,t.useEffect(()=>{if(!f)return;const l=setInterval(()=>q(i=>!i),y);return()=>clearInterval(l)},[f,y]);const u=t.useCallback(()=>{const l=_.current,i=c.current,P=D.current,A=a[l];if(P)if(i>0){const r=i-1;E(r),c.current=r,L(A.slice(0,r)),s.current=setTimeout(u,R)}else{h(!1),D.current=!1;const r=l+1;r>=a.length?d?(S(e.INITIAL_TEXT_INDEX),_.current=e.INITIAL_TEXT_INDEX,E(e.INITIAL_CHAR_INDEX),c.current=e.INITIAL_CHAR_INDEX,s.current=setTimeout(u,T)):n==null||n():(S(r),_.current=r,E(e.INITIAL_CHAR_INDEX),c.current=e.INITIAL_CHAR_INDEX,s.current=setTimeout(u,T))}else if(i<A.length){const r=i+1;L(A.slice(0,r)),E(r),c.current=r,s.current=setTimeout(u,T)}else{if(o==null||o(l),a.length===1&&!d){n==null||n();return}s.current=setTimeout(()=>{h(!0),D.current=!0,u()},N)}},[a,T,R,N,d,n,o]);return t.useEffect(()=>(s.current=setTimeout(u,C),()=>{s.current&&clearTimeout(s.current)}),[]),x.jsxs(j,{className:X.cn("Bear-Typewriter","bear-inline",w),style:F,"data-testid":H,"aria-label":a.join(", "),children:[x.jsx("span",{className:"Bear-Typewriter__text",children:v}),f&&x.jsx("span",{className:X.cn("Bear-Typewriter__cursor","bear-inline-block bear-ml-0.5","bear-text-[var(--bear-primary-500)]"),style:{opacity:B?1:0},"aria-hidden":"true",children:U})]})};exports.Typewriter=k;
|