@arkyn/components 1.3.122 → 1.3.124
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/bundle.js +6417 -6257
- package/dist/bundle.umd.cjs +209 -34
- package/dist/components/RichText/functions/deserialize.js +1 -1
- package/dist/components/RichText/functions/isHtml.d.ts +3 -0
- package/dist/components/RichText/functions/isHtml.d.ts.map +1 -0
- package/dist/components/RichText/functions/isHtml.js +5 -0
- package/dist/components/RichText/index.d.ts.map +1 -1
- package/dist/components/RichText/index.js +3 -2
- package/dist/provider/ToastProvider.js +1 -1
- package/package.json +3 -3
- package/src/components/RichText/functions/deserialize.ts +1 -1
- package/src/components/RichText/functions/isHtml.ts +6 -0
- package/src/components/RichText/index.tsx +6 -2
- package/src/provider/ToastProvider.tsx +1 -1
@@ -25,7 +25,7 @@ const deserialize = (el) => {
|
|
25
25
|
case "ol":
|
26
26
|
return { type: "numberedList", children };
|
27
27
|
case "strong":
|
28
|
-
return { text: childrenString, bold: true };
|
28
|
+
return { type: "paragraph", text: childrenString, bold: true };
|
29
29
|
case "code":
|
30
30
|
return { text: childrenString, code: true };
|
31
31
|
case "em":
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isHtml.d.ts","sourceRoot":"","sources":["../../../../src/components/RichText/functions/isHtml.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM,QAAS,MAAM,KAAG,OAG7B,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RichText/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAgB,UAAU,EAAc,MAAM,OAAO,CAAC;AAc7D,OAAO,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RichText/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAgB,UAAU,EAAc,MAAM,OAAO,CAAC;AAc7D,OAAO,cAAc,CAAC;AAOtB,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uBAAuB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IACzC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,YAAY,EACZ,qBAA6B,EAC7B,uBAAuB,EACvB,QAAe,EACf,aAAa,EACb,QAAQ,EACR,OAAO,EAAE,WAAW,GACrB,EAAE,aAAa,2CA2Gf;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
@@ -18,16 +18,17 @@ import "./styles.css";
|
|
18
18
|
import { getSlateFromHtml } from "./functions/deserialize";
|
19
19
|
import { extractText } from "./functions/extractText";
|
20
20
|
import { getHtmlFromSlate } from "./functions/serialize";
|
21
|
+
import { isHtml } from "./functions/isHtml";
|
21
22
|
function RichText({ name, defaultValue, enforceCharacterLimit = false, onChangeCharactersCount, maxLimit = 2000, onValueChange, onChange, isError: baseIsError, }) {
|
22
23
|
const editor = useMemo(() => withHistory(withReact(createEditor())), []);
|
23
24
|
const { id, inputRef, error } = useFormController();
|
24
25
|
const baseRef = useRef(null);
|
25
|
-
const defaultNodes = defaultValue
|
26
|
+
const defaultNodes = isHtml(defaultValue)
|
26
27
|
? getSlateFromHtml(defaultValue)
|
27
28
|
: INITIAL_VALUE;
|
28
29
|
const textFromNodes = extractText(defaultNodes);
|
29
30
|
const [charactersCount, setCharactersCount] = useState(textFromNodes.length);
|
30
|
-
const [inputValue, setInputValue] = useState(defaultValue);
|
31
|
+
const [inputValue, setInputValue] = useState(isHtml(defaultValue) ? defaultValue : "");
|
31
32
|
const [onFocus, setOnFocus] = useState(false);
|
32
33
|
const ref = inputRef || baseRef;
|
33
34
|
const isError = baseIsError || !!error;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { Toaster, toast } from "
|
2
|
+
import { Toaster, toast } from "react-hot-toast";
|
3
3
|
import { ToastContext } from "../context/ToastContext";
|
4
4
|
import { Toast } from "../components/Toast";
|
5
5
|
function ToastProvider({ children }) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arkyn/components",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.124",
|
4
4
|
"main": "./dist/bundle.js",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"author": "Lucas Gonçalves",
|
@@ -17,11 +17,11 @@
|
|
17
17
|
"html-react-parser": "^5.1.16",
|
18
18
|
"is-hotkey": "^0.2.0",
|
19
19
|
"lucide-react": "^0.424.0",
|
20
|
+
"react-hot-toast": "^2.4.1",
|
20
21
|
"react-scroll": "^1.9.0",
|
21
22
|
"slate": "^0.103.0",
|
22
23
|
"slate-history": "^0.109.0",
|
23
|
-
"slate-react": "^0.110.1"
|
24
|
-
"sonner": "^1.5.0"
|
24
|
+
"slate-react": "^0.110.1"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
27
27
|
"@remix-run/react": "^2.9.2",
|
@@ -35,7 +35,7 @@ const deserialize = (el: ParseElement): Descendant => {
|
|
35
35
|
case "ol":
|
36
36
|
return { type: "numberedList", children };
|
37
37
|
case "strong":
|
38
|
-
return { text: childrenString, bold: true };
|
38
|
+
return { type: "paragraph", text: childrenString, bold: true };
|
39
39
|
case "code":
|
40
40
|
return { text: childrenString, code: true };
|
41
41
|
case "em":
|
@@ -32,6 +32,7 @@ import "./styles.css";
|
|
32
32
|
import { getSlateFromHtml } from "./functions/deserialize";
|
33
33
|
import { extractText } from "./functions/extractText";
|
34
34
|
import { getHtmlFromSlate } from "./functions/serialize";
|
35
|
+
import { isHtml } from "./functions/isHtml";
|
35
36
|
|
36
37
|
type RichTextProps = {
|
37
38
|
name: string;
|
@@ -59,14 +60,17 @@ function RichText({
|
|
59
60
|
|
60
61
|
const baseRef = useRef<HTMLInputElement>(null);
|
61
62
|
|
62
|
-
const defaultNodes = defaultValue
|
63
|
+
const defaultNodes = isHtml(defaultValue)
|
63
64
|
? getSlateFromHtml(defaultValue)
|
64
65
|
: INITIAL_VALUE;
|
65
66
|
|
66
67
|
const textFromNodes = extractText(defaultNodes);
|
67
68
|
|
68
69
|
const [charactersCount, setCharactersCount] = useState(textFromNodes.length);
|
69
|
-
const [inputValue, setInputValue] = useState(
|
70
|
+
const [inputValue, setInputValue] = useState(
|
71
|
+
isHtml(defaultValue) ? defaultValue : ""
|
72
|
+
);
|
73
|
+
|
70
74
|
const [onFocus, setOnFocus] = useState(false);
|
71
75
|
|
72
76
|
const ref = inputRef || baseRef;
|