@arkyn/components 3.0.4 → 3.0.6
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/richText/index.d.ts +11 -1
- package/dist/components/richText/index.d.ts.map +1 -1
- package/dist/components/richText/insertLink/index.d.ts +5 -0
- package/dist/components/richText/insertLink/index.d.ts.map +1 -0
- package/dist/components/richText/insertVideo/index.d.ts.map +1 -1
- package/dist/components/richText/leaf/index.d.ts +1 -0
- package/dist/components/richText/leaf/index.d.ts.map +1 -1
- package/dist/index.js +723 -637
- package/dist/index.js.map +1 -1
- package/dist/modules/components/richText/index.js +80 -76
- package/dist/modules/components/richText/index.js.map +1 -1
- package/dist/modules/components/richText/insertLink/index.js +68 -0
- package/dist/modules/components/richText/insertLink/index.js.map +1 -0
- package/dist/modules/components/richText/insertLink/styles.css +1 -0
- package/dist/modules/components/richText/insertVideo/index.js +45 -41
- package/dist/modules/components/richText/insertVideo/index.js.map +1 -1
- package/dist/modules/components/richText/leaf/index.js +6 -1
- package/dist/modules/components/richText/leaf/index.js.map +1 -1
- package/dist/modules/components/richText/leaf/styles.css +1 -0
- package/dist/modules/components/richText/styles.css +4 -0
- package/dist/modules/services/clearLinkMarkAtBoundary.js +12 -0
- package/dist/modules/services/clearLinkMarkAtBoundary.js.map +1 -0
- package/dist/modules/services/isValidHttpsUrl.js +12 -0
- package/dist/modules/services/isValidHttpsUrl.js.map +1 -0
- package/dist/modules/utils/richTextUtilities.js +24 -17
- package/dist/modules/utils/richTextUtilities.js.map +1 -1
- package/dist/services/clearLinkMarkAtBoundary.d.ts +4 -0
- package/dist/services/clearLinkMarkAtBoundary.d.ts.map +1 -0
- package/dist/services/isValidHttpsUrl.d.ts +3 -0
- package/dist/services/isValidHttpsUrl.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/types/richTextTypes.d.ts +13 -2
- package/dist/types/richTextTypes.d.ts.map +1 -1
- package/dist/utils/richTextUtilities.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import { Element as e, Text as t } from "slate";
|
|
|
3
3
|
function n(r) {
|
|
4
4
|
if (t.isText(r)) {
|
|
5
5
|
let e = r?.text;
|
|
6
|
-
return r?.bold && (e = `<strong>${e}</strong>`), r?.code && (e = `<code>${e}</code>`), r?.italic && (e = `<em>${e}</em>`), r?.underline && (e = `<u>${e}</u>`), e;
|
|
6
|
+
return r?.bold && (e = `<strong>${e}</strong>`), r?.code && (e = `<code>${e}</code>`), r?.italic && (e = `<em>${e}</em>`), r?.underline && (e = `<u>${e}</u>`), r?.link && (e = `<a href="${r.href}">${e}</a>`), e;
|
|
7
7
|
}
|
|
8
8
|
if (e.isElement(r)) {
|
|
9
9
|
let e = r.children?.map((e) => n(e)).join(""), t = r.align || "left";
|
|
@@ -24,48 +24,50 @@ function n(r) {
|
|
|
24
24
|
}
|
|
25
25
|
function r(e) {
|
|
26
26
|
if (typeof e == "string") return { text: e };
|
|
27
|
-
let t =
|
|
27
|
+
let t = e.props.children, n;
|
|
28
|
+
n = Array.isArray(t) ? t.map((e) => r(e)) : typeof t == "string" || !t ? [{ text: t || "" }] : [r(t)];
|
|
29
|
+
let i = e.props.className?.replace("align_", "");
|
|
28
30
|
switch (e.type) {
|
|
29
31
|
case "img": return {
|
|
30
32
|
type: "image",
|
|
31
|
-
align:
|
|
33
|
+
align: i,
|
|
32
34
|
src: e.props.src,
|
|
33
35
|
children: [{ text: "" }]
|
|
34
36
|
};
|
|
35
37
|
case "p": return {
|
|
36
38
|
type: "paragraph",
|
|
37
|
-
align:
|
|
38
|
-
children:
|
|
39
|
+
align: i,
|
|
40
|
+
children: n
|
|
39
41
|
};
|
|
40
42
|
case "blockquote": return {
|
|
41
43
|
type: "blockQuote",
|
|
42
|
-
align:
|
|
43
|
-
children:
|
|
44
|
+
align: i,
|
|
45
|
+
children: n
|
|
44
46
|
};
|
|
45
47
|
case "ul": return {
|
|
46
48
|
type: "bulletedList",
|
|
47
|
-
align:
|
|
48
|
-
children:
|
|
49
|
+
align: i,
|
|
50
|
+
children: n
|
|
49
51
|
};
|
|
50
52
|
case "ol": return {
|
|
51
53
|
type: "numberedList",
|
|
52
|
-
align:
|
|
53
|
-
children:
|
|
54
|
+
align: i,
|
|
55
|
+
children: n
|
|
54
56
|
};
|
|
55
57
|
case "li": return {
|
|
56
58
|
type: "listItem",
|
|
57
|
-
align:
|
|
58
|
-
children:
|
|
59
|
+
align: i,
|
|
60
|
+
children: n
|
|
59
61
|
};
|
|
60
62
|
case "h1": return {
|
|
61
63
|
type: "headingOne",
|
|
62
|
-
align:
|
|
63
|
-
children:
|
|
64
|
+
align: i,
|
|
65
|
+
children: n
|
|
64
66
|
};
|
|
65
67
|
case "h2": return {
|
|
66
68
|
type: "headingTwo",
|
|
67
|
-
align:
|
|
68
|
-
children:
|
|
69
|
+
align: i,
|
|
70
|
+
children: n
|
|
69
71
|
};
|
|
70
72
|
case "strong": return {
|
|
71
73
|
text: e.props.children,
|
|
@@ -83,6 +85,11 @@ function r(e) {
|
|
|
83
85
|
text: e.props.children,
|
|
84
86
|
underline: !0
|
|
85
87
|
};
|
|
88
|
+
case "a": return {
|
|
89
|
+
text: e.props.children,
|
|
90
|
+
link: !0,
|
|
91
|
+
href: e.props.href
|
|
92
|
+
};
|
|
86
93
|
default: return { text: e.props.children || "" };
|
|
87
94
|
}
|
|
88
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richTextUtilities.js","names":[],"sources":["../../../src/utils/richTextUtilities.ts"],"sourcesContent":["import { Element, Text } from \"slate\";\nimport type { ParseElement } from \"../types/richTextTypes\";\n\n// biome-ignore lint/suspicious/noExplicitAny: intentional\nfunction serialize(node: any): string {\n\tif (Text.isText(node)) {\n\t\tlet text = node?.text;\n\t\tif (node?.bold) {\n\t\t\ttext = `<strong>${text}</strong>`;\n\t\t}\n\t\tif (node?.code) {\n\t\t\ttext = `<code>${text}</code>`;\n\t\t}\n\t\tif (node?.italic) {\n\t\t\ttext = `<em>${text}</em>`;\n\t\t}\n\t\tif (node?.underline) {\n\t\t\ttext = `<u>${text}</u>`;\n\t\t}\n\t\treturn text;\n\t}\n\n\tif (Element.isElement(node)) {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\t\tconst children = node.children?.map((n: any) => serialize(n)).join(\"\");\n\t\tconst alignStyle = node.align || \"left\";\n\n\t\tswitch (node.type) {\n\t\t\tcase \"video\":\n\t\t\t\treturn `<iframe src=\"${node.src}\" class=\"align_${alignStyle}\" />`;\n\t\t\tcase \"image\":\n\t\t\t\treturn `<img src=\"${node.src}\" class=\"align_${alignStyle}\" />`;\n\t\t\tcase \"paragraph\":\n\t\t\t\treturn `<p class=\"align_${alignStyle}\">${children}</p>`;\n\t\t\tcase \"blockQuote\":\n\t\t\t\treturn `<blockquote class=\"align_${alignStyle}\">${children}</blockquote>`;\n\t\t\tcase \"bulletedList\":\n\t\t\t\treturn `<ul class=\"align_${alignStyle}\">${children}</ul>`;\n\t\t\tcase \"headingOne\":\n\t\t\t\treturn `<h1 class=\"align_${alignStyle}\">${children}</h1>`;\n\t\t\tcase \"headingTwo\":\n\t\t\t\treturn `<h2 class=\"align_${alignStyle}\">${children}</h2>`;\n\t\t\tcase \"listItem\":\n\t\t\t\treturn `<li class=\"align_${alignStyle}\">${children}</li>`;\n\t\t\tcase \"numberedList\":\n\t\t\t\treturn `<ol class=\"align_${alignStyle}\">${children}</ol>`;\n\t\t\tdefault:\n\t\t\t\treturn \"\";\n\t\t}\n\t}\n\n\treturn \"\";\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: intentional\nfunction deserialize(el: ParseElement): any {\n\tif (typeof el === \"string\") {\n\t\treturn { text: el };\n\t}\n\n\tconst
|
|
1
|
+
{"version":3,"file":"richTextUtilities.js","names":[],"sources":["../../../src/utils/richTextUtilities.ts"],"sourcesContent":["import { Element, Text } from \"slate\";\nimport type { ParseElement } from \"../types/richTextTypes\";\n\n// biome-ignore lint/suspicious/noExplicitAny: intentional\nfunction serialize(node: any): string {\n\tif (Text.isText(node)) {\n\t\tlet text = node?.text;\n\t\tif (node?.bold) {\n\t\t\ttext = `<strong>${text}</strong>`;\n\t\t}\n\t\tif (node?.code) {\n\t\t\ttext = `<code>${text}</code>`;\n\t\t}\n\t\tif (node?.italic) {\n\t\t\ttext = `<em>${text}</em>`;\n\t\t}\n\t\tif (node?.underline) {\n\t\t\ttext = `<u>${text}</u>`;\n\t\t}\n\t\tif (node?.link) {\n\t\t\ttext = `<a href=\"${node.href}\">${text}</a>`;\n\t\t}\n\t\treturn text;\n\t}\n\n\tif (Element.isElement(node)) {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\t\tconst children = node.children?.map((n: any) => serialize(n)).join(\"\");\n\t\tconst alignStyle = node.align || \"left\";\n\n\t\tswitch (node.type) {\n\t\t\tcase \"video\":\n\t\t\t\treturn `<iframe src=\"${node.src}\" class=\"align_${alignStyle}\" />`;\n\t\t\tcase \"image\":\n\t\t\t\treturn `<img src=\"${node.src}\" class=\"align_${alignStyle}\" />`;\n\t\t\tcase \"paragraph\":\n\t\t\t\treturn `<p class=\"align_${alignStyle}\">${children}</p>`;\n\t\t\tcase \"blockQuote\":\n\t\t\t\treturn `<blockquote class=\"align_${alignStyle}\">${children}</blockquote>`;\n\t\t\tcase \"bulletedList\":\n\t\t\t\treturn `<ul class=\"align_${alignStyle}\">${children}</ul>`;\n\t\t\tcase \"headingOne\":\n\t\t\t\treturn `<h1 class=\"align_${alignStyle}\">${children}</h1>`;\n\t\t\tcase \"headingTwo\":\n\t\t\t\treturn `<h2 class=\"align_${alignStyle}\">${children}</h2>`;\n\t\t\tcase \"listItem\":\n\t\t\t\treturn `<li class=\"align_${alignStyle}\">${children}</li>`;\n\t\t\tcase \"numberedList\":\n\t\t\t\treturn `<ol class=\"align_${alignStyle}\">${children}</ol>`;\n\t\t\tdefault:\n\t\t\t\treturn \"\";\n\t\t}\n\t}\n\n\treturn \"\";\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: intentional\nfunction deserialize(el: ParseElement): any {\n\tif (typeof el === \"string\") {\n\t\treturn { text: el };\n\t}\n\n\tconst rawChildren = el.props.children;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\tlet children: any[];\n\tif (Array.isArray(rawChildren)) {\n\t\tchildren = rawChildren.map((child) => deserialize(child));\n\t} else if (typeof rawChildren === \"string\" || !rawChildren) {\n\t\tchildren = [{ text: rawChildren || \"\" }];\n\t} else {\n\t\tchildren = [deserialize(rawChildren)];\n\t}\n\n\tconst align = el.props.className?.replace(\"align_\", \"\") as\n\t\t| \"left\"\n\t\t| \"center\"\n\t\t| \"right\"\n\t\t| \"justify\";\n\n\tswitch (el.type) {\n\t\tcase \"img\":\n\t\t\treturn {\n\t\t\t\ttype: \"image\",\n\t\t\t\talign,\n\t\t\t\tsrc: el.props.src,\n\t\t\t\tchildren: [{ text: \"\" }],\n\t\t\t};\n\t\tcase \"p\":\n\t\t\treturn { type: \"paragraph\", align, children };\n\t\tcase \"blockquote\":\n\t\t\treturn { type: \"blockQuote\", align, children };\n\t\tcase \"ul\":\n\t\t\treturn { type: \"bulletedList\", align, children };\n\t\tcase \"ol\":\n\t\t\treturn { type: \"numberedList\", align, children };\n\t\tcase \"li\":\n\t\t\treturn { type: \"listItem\", align, children };\n\t\tcase \"h1\":\n\t\t\treturn { type: \"headingOne\", align, children };\n\t\tcase \"h2\":\n\t\t\treturn { type: \"headingTwo\", align, children };\n\t\tcase \"strong\":\n\t\t\treturn { text: el.props.children, bold: true };\n\t\tcase \"code\":\n\t\t\treturn { text: el.props.children, code: true };\n\t\tcase \"em\":\n\t\t\treturn { text: el.props.children, italic: true };\n\t\tcase \"u\":\n\t\t\treturn { text: el.props.children, underline: true };\n\t\tcase \"a\":\n\t\t\treturn { text: el.props.children, link: true, href: el.props.href };\n\t\tdefault:\n\t\t\treturn { text: el.props.children || \"\" };\n\t}\n}\n\nexport { deserialize, serialize };\n"],"mappings":";;AA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OAAO,CAAC;AAEtC,iBAAS,uBAAuB,CAAC,MAAM,EAAE,MAAM,QAU9C;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidHttpsUrl.d.ts","sourceRoot":"","sources":["../../src/services/isValidHttpsUrl.ts"],"names":[],"mappings":"AAAA,iBAAS,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAM7C;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|