@arkyn/components 3.0.1-beta.195 → 3.0.1-beta.197
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/richText/index.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAEX,aAAa,EACb,MAAM,2BAA2B,CAAC;AAQnC,OAAO,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/richText/index.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAEX,aAAa,EACb,MAAM,2BAA2B,CAAC;AAQnC,OAAO,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,+BAuMrC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3700,19 +3700,17 @@ function Ir({ children: e }) {
|
|
|
3700
3700
|
//#endregion
|
|
3701
3701
|
//#region src/components/richText/index.tsx
|
|
3702
3702
|
function Lr(e) {
|
|
3703
|
-
let { name: t, hiddenButtons: n, imageConfig: r, videoConfig: a, className: o = "", defaultValue: d = "[]", enforceCharacterLimit: f = !1, onChangeCharactersCount: h, baseErrorMessage: x, maxLimit: S = 1e4, onChange: C, isError: w, label: T, showAsterisk: D, id: O, orientation: k = "vertical", unShowFieldTemplate: A = !1 } = e, j = c(() => me(ve(pe())), []), { fieldErrors: P } = Z()
|
|
3704
|
-
function F() {
|
|
3703
|
+
let { name: t, hiddenButtons: n, imageConfig: r, videoConfig: a, className: o = "", defaultValue: d = "[]", enforceCharacterLimit: f = !1, onChangeCharactersCount: h, baseErrorMessage: x, maxLimit: S = 1e4, onChange: C, isError: w, label: T, showAsterisk: D, id: O, orientation: k = "vertical", unShowFieldTemplate: A = !1 } = e, j = c(() => me(ve(pe())), []), { fieldErrors: P } = Z(), F = c(() => {
|
|
3705
3704
|
try {
|
|
3706
3705
|
let e = JSON.parse(d);
|
|
3707
|
-
return !Array.isArray(e) || e.length
|
|
3706
|
+
return !Array.isArray(e) || e.length === 0 ? structuredClone(br) : e.every((e) => typeof e == "object" && !!e && "type" in e && "children" in e) ? e : structuredClone(br);
|
|
3708
3707
|
} catch {
|
|
3709
|
-
return br;
|
|
3708
|
+
return structuredClone(br);
|
|
3710
3709
|
}
|
|
3711
|
-
}
|
|
3712
|
-
let [L, R] = u(gr(F()).length), [z, B] = u(JSON.stringify(F()) || "[]"), [H, U] = u(!1), G = l(null), K = s(), q = O || K, ee = x || P?.[t], J = w || !!ee, te = i(Pr, []), ne = i(Er, []);
|
|
3710
|
+
}, [d]), [L, R] = u(gr(F).length), [z, B] = u(JSON.stringify(F) || "[]"), [H, U] = u(!1), G = l(null), K = s(), q = O || K, ee = x || P?.[t], J = w || !!ee, te = i(Pr, []), ne = i(Er, []);
|
|
3713
3711
|
function re(e) {
|
|
3714
3712
|
let t = gr(e);
|
|
3715
|
-
R(t.length), h?.(t.length), !(f && t.length >= S) && (B(JSON.stringify(e)), C?.(e)
|
|
3713
|
+
R(t.length), h?.(t.length), !(f && t.length >= S) && (B(JSON.stringify(e)), C?.(e));
|
|
3716
3714
|
}
|
|
3717
3715
|
let Y = `arkynRichText ${J || S < L ? "errorTrue" : "errorFalse"} ${H ? "focusTrue" : "focusFalse"}`, ie = S - L;
|
|
3718
3716
|
function X(e) {
|
|
@@ -3728,7 +3726,7 @@ function Lr(e) {
|
|
|
3728
3726
|
orientation: k,
|
|
3729
3727
|
children: /* @__PURE__ */ m(ge, {
|
|
3730
3728
|
editor: j,
|
|
3731
|
-
initialValue: F
|
|
3729
|
+
initialValue: F,
|
|
3732
3730
|
onChange: re,
|
|
3733
3731
|
onValueChange: re,
|
|
3734
3732
|
children: [
|
|
@@ -5,140 +5,138 @@ import { toggleMark as r } from "../../services/toggleMark.js";
|
|
|
5
5
|
import { hotKeys as i, initialValue as a } from "../../templates/richTextTemplates.js";
|
|
6
6
|
import { BlockButton as o } from "./blockButton/index.js";
|
|
7
7
|
import { Element as s } from "./element/index.js";
|
|
8
|
-
import { InsertImage as
|
|
9
|
-
import { InsertVideo as
|
|
10
|
-
import { Leaf as
|
|
11
|
-
import { MarkButton as
|
|
12
|
-
import { Toolbar as
|
|
8
|
+
import { InsertImage as c } from "./insertImage/index.js";
|
|
9
|
+
import { InsertVideo as l } from "./insertVideo/index.js";
|
|
10
|
+
import { Leaf as u } from "./leaf/index.js";
|
|
11
|
+
import { MarkButton as d } from "./markButton/index.js";
|
|
12
|
+
import { Toolbar as ee } from "./toolbar/index.js";
|
|
13
13
|
/* empty css */
|
|
14
|
-
import { useCallback as
|
|
15
|
-
import { jsx as
|
|
16
|
-
import { AlignCenter as
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import { withHistory as
|
|
20
|
-
import { Editable as
|
|
14
|
+
import { useCallback as f, useId as te, useMemo as p, useRef as m, useState as h } from "react";
|
|
15
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
16
|
+
import { AlignCenter as ne, AlignJustify as re, AlignLeft as ie, AlignRight as ae, Bold as oe, Code as se, Heading1 as v, Heading2 as y, Italic as b, Quote as x, Underline as S } from "lucide-react";
|
|
17
|
+
import C from "is-hotkey";
|
|
18
|
+
import { createEditor as w } from "slate";
|
|
19
|
+
import { withHistory as T } from "slate-history";
|
|
20
|
+
import { Editable as E, Slate as D, withReact as O } from "slate-react";
|
|
21
21
|
//#region src/components/richText/index.tsx
|
|
22
|
-
function
|
|
23
|
-
let { name:
|
|
24
|
-
function K() {
|
|
22
|
+
function k(k) {
|
|
23
|
+
let { name: A, hiddenButtons: j, imageConfig: M, videoConfig: N, className: P = "", defaultValue: F = "[]", enforceCharacterLimit: I = !1, onChangeCharactersCount: L, baseErrorMessage: R, maxLimit: z = 1e4, onChange: B, isError: V, label: ce, showAsterisk: H, id: U, orientation: W = "vertical", unShowFieldTemplate: G = !1 } = k, K = p(() => T(O(w())), []), { fieldErrors: le } = e(), q = p(() => {
|
|
25
24
|
try {
|
|
26
|
-
let e = JSON.parse(
|
|
27
|
-
return !Array.isArray(e) || e.length
|
|
25
|
+
let e = JSON.parse(F);
|
|
26
|
+
return !Array.isArray(e) || e.length === 0 ? structuredClone(a) : e.every((e) => typeof e == "object" && !!e && "type" in e && "children" in e) ? e : structuredClone(a);
|
|
28
27
|
} catch {
|
|
29
|
-
return a;
|
|
28
|
+
return structuredClone(a);
|
|
30
29
|
}
|
|
31
|
-
}
|
|
32
|
-
let [q, fe] = d(n(K()).length), [pe, me] = d(JSON.stringify(K()) || "[]"), [he, J] = d(!1), ge = ae(null), _e = re(), Y = U || _e, X = L || de?.[k], ve = B || !!X, ye = u(ne, []), be = u(s, []);
|
|
30
|
+
}, [F]), [J, ue] = h(n(q).length), [de, fe] = h(JSON.stringify(q) || "[]"), [pe, Y] = h(!1), me = m(null), he = te(), ge = U || he, X = R || le?.[A], _e = V || !!X, ve = f(u, []), ye = f(s, []);
|
|
33
31
|
function Z(e) {
|
|
34
32
|
let t = n(e);
|
|
35
|
-
|
|
33
|
+
ue(t.length), L?.(t.length), !(I && t.length >= z) && (fe(JSON.stringify(e)), B?.(e));
|
|
36
34
|
}
|
|
37
|
-
let
|
|
35
|
+
let be = `arkynRichText ${_e || z < J ? "errorTrue" : "errorFalse"} ${pe ? "focusTrue" : "focusFalse"}`, Q = z - J;
|
|
38
36
|
function $(e) {
|
|
39
|
-
return !
|
|
37
|
+
return !j?.includes(e);
|
|
40
38
|
}
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
name:
|
|
43
|
-
label:
|
|
39
|
+
return /* @__PURE__ */ g(t, {
|
|
40
|
+
name: A,
|
|
41
|
+
label: ce,
|
|
44
42
|
showAsterisk: H,
|
|
45
|
-
className:
|
|
43
|
+
className: P,
|
|
46
44
|
errorMessage: X,
|
|
47
|
-
unShowFieldTemplate:
|
|
45
|
+
unShowFieldTemplate: G,
|
|
48
46
|
orientation: W,
|
|
49
|
-
children: /* @__PURE__ */
|
|
50
|
-
editor:
|
|
51
|
-
initialValue:
|
|
47
|
+
children: /* @__PURE__ */ _(D, {
|
|
48
|
+
editor: K,
|
|
49
|
+
initialValue: q,
|
|
52
50
|
onChange: Z,
|
|
53
51
|
onValueChange: Z,
|
|
54
52
|
children: [
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
className:
|
|
53
|
+
/* @__PURE__ */ _("div", {
|
|
54
|
+
className: be,
|
|
57
55
|
children: [
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
$("headingOne") && /* @__PURE__ */
|
|
56
|
+
/* @__PURE__ */ _(ee, { children: [
|
|
57
|
+
$("headingOne") && /* @__PURE__ */ g(o, {
|
|
60
58
|
format: "headingOne",
|
|
61
|
-
icon:
|
|
59
|
+
icon: v
|
|
62
60
|
}),
|
|
63
|
-
$("headingTwo") && /* @__PURE__ */
|
|
61
|
+
$("headingTwo") && /* @__PURE__ */ g(o, {
|
|
64
62
|
format: "headingTwo",
|
|
65
|
-
icon:
|
|
63
|
+
icon: y
|
|
66
64
|
}),
|
|
67
|
-
$("blockQuote") && /* @__PURE__ */
|
|
65
|
+
$("blockQuote") && /* @__PURE__ */ g(o, {
|
|
68
66
|
format: "blockQuote",
|
|
69
|
-
icon:
|
|
67
|
+
icon: x
|
|
70
68
|
}),
|
|
71
|
-
$("bold") && /* @__PURE__ */
|
|
69
|
+
$("bold") && /* @__PURE__ */ g(d, {
|
|
72
70
|
format: "bold",
|
|
73
|
-
icon:
|
|
71
|
+
icon: oe
|
|
74
72
|
}),
|
|
75
|
-
$("italic") && /* @__PURE__ */
|
|
73
|
+
$("italic") && /* @__PURE__ */ g(d, {
|
|
76
74
|
format: "italic",
|
|
77
|
-
icon:
|
|
75
|
+
icon: b
|
|
78
76
|
}),
|
|
79
|
-
$("underline") && /* @__PURE__ */
|
|
77
|
+
$("underline") && /* @__PURE__ */ g(d, {
|
|
80
78
|
format: "underline",
|
|
81
|
-
icon:
|
|
79
|
+
icon: S
|
|
82
80
|
}),
|
|
83
|
-
$("code") && /* @__PURE__ */
|
|
81
|
+
$("code") && /* @__PURE__ */ g(d, {
|
|
84
82
|
format: "code",
|
|
85
|
-
icon:
|
|
83
|
+
icon: se
|
|
86
84
|
}),
|
|
87
|
-
$("left") && /* @__PURE__ */
|
|
85
|
+
$("left") && /* @__PURE__ */ g(o, {
|
|
88
86
|
format: "left",
|
|
89
|
-
icon:
|
|
87
|
+
icon: ie
|
|
90
88
|
}),
|
|
91
|
-
$("right") && /* @__PURE__ */
|
|
89
|
+
$("right") && /* @__PURE__ */ g(o, {
|
|
92
90
|
format: "right",
|
|
93
|
-
icon:
|
|
91
|
+
icon: ae
|
|
94
92
|
}),
|
|
95
|
-
$("center") && /* @__PURE__ */
|
|
93
|
+
$("center") && /* @__PURE__ */ g(o, {
|
|
96
94
|
format: "center",
|
|
97
|
-
icon:
|
|
95
|
+
icon: ne
|
|
98
96
|
}),
|
|
99
|
-
$("justify") && /* @__PURE__ */
|
|
97
|
+
$("justify") && /* @__PURE__ */ g(o, {
|
|
100
98
|
format: "justify",
|
|
101
|
-
icon:
|
|
99
|
+
icon: re
|
|
102
100
|
}),
|
|
103
|
-
|
|
104
|
-
$("video") && /* @__PURE__ */
|
|
101
|
+
M && $("image") && /* @__PURE__ */ g(c, { ...M }),
|
|
102
|
+
$("video") && /* @__PURE__ */ g(l, { ...N })
|
|
105
103
|
] }),
|
|
106
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ g(E, {
|
|
107
105
|
className: "editorContainer",
|
|
108
|
-
renderElement:
|
|
109
|
-
renderLeaf:
|
|
106
|
+
renderElement: ye,
|
|
107
|
+
renderLeaf: ve,
|
|
110
108
|
spellCheck: !0,
|
|
111
|
-
ref:
|
|
112
|
-
id:
|
|
113
|
-
onFocus: () =>
|
|
114
|
-
onBlur: () =>
|
|
109
|
+
ref: me,
|
|
110
|
+
id: ge,
|
|
111
|
+
onFocus: () => Y(!0),
|
|
112
|
+
onBlur: () => Y(!1),
|
|
115
113
|
onKeyDown: (e) => {
|
|
116
|
-
for (let t in i) if (
|
|
114
|
+
for (let t in i) if (C(t, e)) {
|
|
117
115
|
e.preventDefault();
|
|
118
116
|
let n = i[t];
|
|
119
|
-
r(
|
|
117
|
+
r(K, n);
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
}),
|
|
123
|
-
Q < 0 && /* @__PURE__ */
|
|
121
|
+
Q < 0 && /* @__PURE__ */ g("div", {
|
|
124
122
|
className: "restatesCharacters",
|
|
125
123
|
children: Q
|
|
126
124
|
})
|
|
127
125
|
]
|
|
128
126
|
}),
|
|
129
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ g("input", {
|
|
130
128
|
type: "hidden",
|
|
131
|
-
name:
|
|
132
|
-
value:
|
|
129
|
+
name: A,
|
|
130
|
+
value: de.slice(0, z)
|
|
133
131
|
}),
|
|
134
|
-
/* @__PURE__ */
|
|
132
|
+
/* @__PURE__ */ g("input", {
|
|
135
133
|
type: "hidden",
|
|
136
|
-
name: `${
|
|
137
|
-
value:
|
|
134
|
+
name: `${A}Count`,
|
|
135
|
+
value: J
|
|
138
136
|
})
|
|
139
137
|
]
|
|
140
138
|
})
|
|
141
139
|
});
|
|
142
140
|
}
|
|
143
141
|
//#endregion
|
|
144
|
-
export {
|
|
142
|
+
export { k as RichText };
|