@plitzi/sdk-elements 0.38.5 → 0.38.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/CHANGELOG.md +226 -0
- package/dist/Element/hooks/useRscData.d.ts +1 -1
- package/dist/components/MarkdownDocument/MarkdownDocument.d.ts +32 -0
- package/dist/components/MarkdownDocument/MarkdownDocument.mjs +32 -0
- package/dist/components/MarkdownDocument/components/CodeBlock/CodeBlock.d.ts +14 -0
- package/dist/components/MarkdownDocument/components/CodeBlock/CodeBlock.mjs +34 -0
- package/dist/components/MarkdownDocument/components/CodeBlock/index.d.ts +3 -0
- package/dist/components/MarkdownDocument/components/CodeBlock/index.mjs +5 -0
- package/dist/components/MarkdownDocument/helpers/hastText.d.ts +10 -0
- package/dist/components/MarkdownDocument/helpers/hastText.mjs +4 -0
- package/dist/components/MarkdownDocument/helpers/markdownComponents.d.ts +10 -0
- package/dist/components/MarkdownDocument/helpers/markdownComponents.mjs +89 -0
- package/dist/components/MarkdownDocument/helpers/markdownParts.d.ts +16 -0
- package/dist/components/MarkdownDocument/helpers/markdownParts.mjs +4 -0
- package/dist/components/MarkdownDocument/helpers/rehypeHeadingAnchors.d.ts +8 -0
- package/dist/components/MarkdownDocument/helpers/rehypeHeadingAnchors.mjs +20 -0
- package/dist/components/MarkdownDocument/helpers/syntaxHighlighter.d.ts +3 -0
- package/dist/components/MarkdownDocument/helpers/syntaxHighlighter.mjs +24 -0
- package/dist/components/MarkdownDocument/index.d.ts +5 -0
- package/dist/components/MarkdownDocument/index.mjs +6 -0
- package/dist/dataSource/GlobalSources.mjs +101 -113
- package/dist/elements/advanced/Custom/declaration.d.ts +5 -1
- package/dist/elements/advanced/Custom/declaration.mjs +5 -1
- package/dist/elements/advanced/Custom/index.d.ts +5 -1
- package/dist/elements/basic/Button/declaration.d.ts +46 -34
- package/dist/elements/basic/Button/declaration.mjs +18 -42
- package/dist/elements/basic/Button/index.d.ts +46 -34
- package/dist/elements/basic/Dropdown/DropdownPopup/declaration.d.ts +2 -0
- package/dist/elements/basic/Dropdown/DropdownPopup/declaration.mjs +2 -0
- package/dist/elements/basic/Dropdown/DropdownPopup/index.d.ts +2 -0
- package/dist/elements/basic/Dropdown/index.d.ts +2 -0
- package/dist/elements/basic/Heading/declaration.d.ts +5 -1
- package/dist/elements/basic/Heading/declaration.mjs +5 -1
- package/dist/elements/basic/Heading/index.d.ts +5 -1
- package/dist/elements/basic/Link/Link.d.ts +7 -1
- package/dist/elements/basic/Link/Link.mjs +27 -27
- package/dist/elements/basic/Link/Settings.d.ts +2 -1
- package/dist/elements/basic/Link/Settings.mjs +42 -29
- package/dist/elements/basic/Link/ariaCurrent.d.ts +12 -0
- package/dist/elements/basic/Link/ariaCurrent.mjs +11 -0
- package/dist/elements/basic/Link/declaration.d.ts +5 -1
- package/dist/elements/basic/Link/declaration.mjs +7 -4
- package/dist/elements/basic/Link/index.d.ts +5 -1
- package/dist/elements/basic/Markdown/Markdown.d.ts +6 -1
- package/dist/elements/basic/Markdown/Markdown.mjs +19 -15
- package/dist/elements/basic/Markdown/Settings.d.ts +2 -1
- package/dist/elements/basic/Markdown/Settings.mjs +16 -10
- package/dist/elements/basic/Markdown/declaration.d.ts +32 -5
- package/dist/elements/basic/Markdown/declaration.mjs +37 -7
- package/dist/elements/basic/Markdown/hooks/useMarkdownClassNames.d.ts +7 -0
- package/dist/elements/basic/Markdown/hooks/useMarkdownClassNames.mjs +13 -0
- package/dist/elements/basic/Markdown/index.d.ts +32 -5
- package/dist/elements/basic/RichText/RichText.mjs +27 -20
- package/dist/elements/basic/RichText/classHtmlParts.d.ts +14 -0
- package/dist/elements/basic/RichText/classHtmlParts.mjs +48 -0
- package/dist/elements/basic/RichText/declaration.d.ts +28 -1
- package/dist/elements/basic/RichText/declaration.mjs +31 -2
- package/dist/elements/basic/RichText/index.d.ts +28 -1
- package/dist/elements/basic/Text/declaration.d.ts +0 -2
- package/dist/elements/basic/Text/declaration.mjs +1 -5
- package/dist/elements/basic/Text/index.d.ts +0 -2
- package/dist/elements/basic/ThemeToggle/ThemeToggle.mjs +20 -18
- package/dist/elements/basic/ThemeToggle/declaration.d.ts +48 -4
- package/dist/elements/basic/ThemeToggle/declaration.mjs +32 -8
- package/dist/elements/basic/ThemeToggle/index.d.ts +48 -4
- package/dist/elements/declarations/index.d.ts +781 -318
- package/dist/elements/form/FormControl/FormControl.mjs +51 -53
- package/dist/elements/form/FormControl/Settings.mjs +4 -0
- package/dist/elements/form/FormControl/components/Label.d.ts +3 -1
- package/dist/elements/form/FormControl/components/Label.mjs +5 -5
- package/dist/elements/form/FormControl/declaration.d.ts +479 -233
- package/dist/elements/form/FormControl/declaration.mjs +142 -76
- package/dist/elements/form/FormControl/helpers/isChecked.d.ts +8 -0
- package/dist/elements/form/FormControl/helpers/isChecked.mjs +4 -0
- package/dist/elements/form/FormControl/hocs/withFieldValue.mjs +2 -6
- package/dist/elements/form/FormControl/index.d.ts +479 -233
- package/dist/elements/form/FormControl/inputs/Checkbox.d.ts +7 -3
- package/dist/elements/form/FormControl/inputs/Checkbox.mjs +7 -6
- package/dist/elements/form/FormControl/inputs/Input.d.ts +6 -1
- package/dist/elements/form/FormControl/inputs/Input.mjs +29 -29
- package/dist/elements/form/FormControl/inputs/Select.d.ts +4 -1
- package/dist/elements/form/FormControl/inputs/Select.mjs +15 -15
- package/dist/elements/internal/NotFound/declaration.d.ts +5 -1
- package/dist/elements/internal/NotFound/declaration.mjs +5 -1
- package/dist/elements/internal/NotFound/index.d.ts +5 -1
- package/dist/elements/internal/Page/declaration.d.ts +1 -2
- package/dist/elements/internal/Page/declaration.mjs +2 -3
- package/dist/elements/internal/Page/index.d.ts +1 -2
- package/dist/elements/media/Image/declaration.d.ts +3 -2
- package/dist/elements/media/Image/declaration.mjs +3 -2
- package/dist/elements/media/Image/index.d.ts +3 -2
- package/dist/elements/provider/ApiContainer/ApiContainer.mjs +89 -80
- package/dist/elements/provider/ApiContainer/hooks/useApi.mjs +23 -23
- package/dist/elements/provider/ApiContainer/hooks/useProviderWrite.mjs +5 -5
- package/dist/elements/structure/Carousel/CarouselTrack/declaration.d.ts +4 -1
- package/dist/elements/structure/Carousel/CarouselTrack/declaration.mjs +4 -1
- package/dist/elements/structure/Carousel/CarouselTrack/index.d.ts +4 -1
- package/dist/elements/structure/Carousel/index.d.ts +4 -1
- package/dist/elements/structure/DialogContainer/DialogContainer.mjs +2 -2
- package/dist/elements/structure/DialogContainer/declaration.d.ts +72 -12
- package/dist/elements/structure/DialogContainer/declaration.mjs +58 -17
- package/dist/elements/structure/DialogContainer/index.d.ts +72 -12
- package/dist/elements/structure/List/declaration.d.ts +5 -1
- package/dist/elements/structure/List/declaration.mjs +5 -1
- package/dist/elements/structure/List/index.d.ts +5 -1
- package/dist/elements/structure/ModalContainer/declaration.d.ts +36 -16
- package/dist/elements/structure/ModalContainer/declaration.mjs +42 -24
- package/dist/elements/structure/ModalContainer/index.d.ts +36 -16
- package/dist/elements/structure/Pagination/Pagination.mjs +23 -23
- package/dist/elements/structure/Pagination/declaration.d.ts +5 -1
- package/dist/elements/structure/Pagination/declaration.mjs +8 -2
- package/dist/elements/structure/Pagination/index.d.ts +5 -1
- package/dist/elements/structure/TabContainer/TabContainerItem/TabContainerItem.mjs +2 -1
- package/dist/index.d.ts +781 -318
- package/package.json +77 -13
- package/dist/elements/basic/Link/isCurrentPage.d.ts +0 -5
- package/dist/elements/basic/Link/isCurrentPage.mjs +0 -12
|
@@ -7,14 +7,43 @@ declare const declaration: {
|
|
|
7
7
|
readonly content: {
|
|
8
8
|
readonly attributes: {
|
|
9
9
|
readonly content: "Markdown";
|
|
10
|
+
readonly headingLinks: true;
|
|
10
11
|
};
|
|
11
12
|
readonly definition: {
|
|
12
13
|
readonly label: "Markdown";
|
|
13
14
|
readonly type: "markdown";
|
|
14
|
-
readonly description:
|
|
15
|
+
readonly description: string;
|
|
15
16
|
readonly bindings: {};
|
|
16
17
|
readonly styleSelectors: {
|
|
17
18
|
readonly base: "";
|
|
19
|
+
readonly heading: "";
|
|
20
|
+
readonly heading1: "";
|
|
21
|
+
readonly heading2: "";
|
|
22
|
+
readonly heading3: "";
|
|
23
|
+
readonly heading4: "";
|
|
24
|
+
readonly heading5: "";
|
|
25
|
+
readonly heading6: "";
|
|
26
|
+
readonly paragraph: "";
|
|
27
|
+
readonly link: "";
|
|
28
|
+
readonly strong: "";
|
|
29
|
+
readonly emphasis: "";
|
|
30
|
+
readonly list: "";
|
|
31
|
+
readonly listItem: "";
|
|
32
|
+
readonly quote: "";
|
|
33
|
+
readonly divider: "";
|
|
34
|
+
readonly code: "";
|
|
35
|
+
readonly codeBlock: "";
|
|
36
|
+
readonly codeBlockFrame: "";
|
|
37
|
+
readonly codeBlockHeader: "";
|
|
38
|
+
readonly codeBlockLanguage: "";
|
|
39
|
+
readonly codeBlockCopy: "";
|
|
40
|
+
readonly image: "";
|
|
41
|
+
readonly table: "";
|
|
42
|
+
readonly tableHead: "";
|
|
43
|
+
readonly tableRow: "";
|
|
44
|
+
readonly tableHeaderCell: "";
|
|
45
|
+
readonly tableCell: "";
|
|
46
|
+
readonly anchor: "";
|
|
18
47
|
};
|
|
19
48
|
readonly initialState: {
|
|
20
49
|
readonly visibility: true;
|
|
@@ -43,10 +72,7 @@ declare const declaration: {
|
|
|
43
72
|
readonly displayMode: "desktop";
|
|
44
73
|
readonly style: {
|
|
45
74
|
readonly base: {
|
|
46
|
-
readonly default: {
|
|
47
|
-
readonly 'font-size': "14px";
|
|
48
|
-
readonly 'line-height': "1.714";
|
|
49
|
-
};
|
|
75
|
+
readonly default: {};
|
|
50
76
|
};
|
|
51
77
|
};
|
|
52
78
|
};
|
|
@@ -54,5 +80,6 @@ declare const declaration: {
|
|
|
54
80
|
};
|
|
55
81
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
56
82
|
content?: string | undefined;
|
|
83
|
+
headingLinks?: boolean | undefined;
|
|
57
84
|
}>>;
|
|
58
85
|
export default declaration;
|
|
@@ -3,13 +3,46 @@ import { elementDeclaration as e } from "@plitzi/sdk-shared/authoring/declare";
|
|
|
3
3
|
var t = e()({
|
|
4
4
|
type: "markdown",
|
|
5
5
|
content: {
|
|
6
|
-
attributes: {
|
|
6
|
+
attributes: {
|
|
7
|
+
content: "Markdown",
|
|
8
|
+
headingLinks: !0
|
|
9
|
+
},
|
|
7
10
|
definition: {
|
|
8
11
|
label: "Markdown",
|
|
9
12
|
type: "markdown",
|
|
10
|
-
description: "Renders a Markdown source string as
|
|
13
|
+
description: "Renders a Markdown source string (GitHub-flavoured) as HTML, inside a `div.markdown`. Each part of it takes a class through the slot named for it: `heading` (every `h1`–`h6`) and `heading1`…`heading6` (that level only, beside it — a property goes on one of the two, never both), `paragraph`, `link`, `strong`, `emphasis` (`em`), `list` (`ul`/`ol`), `listItem`, `quote` (`blockquote`), `divider` (`hr`), `code` (inline), `image`, `table`, `tableHead` (`thead`), `tableRow`, `tableHeaderCell` (`th`) and `tableCell` (`td`). A fenced block is `codeBlock` (its `pre`) in `codeBlockFrame`, under `codeBlockHeader`, which holds `codeBlockLanguage` and the `codeBlockCopy` button. Every heading carries an id made of its words, which `/page#its-words` lands on, and starts with an empty link to itself — `a.anchor > span.octicon-link`, the `anchor` slot; `headingLinks: false` leaves the link out and keeps the id. Unstyled, it reads as a document — headings, lists, code, tables — from the base layer of the SDK, which a class on the slot of a part replaces property by property.",
|
|
11
14
|
bindings: {},
|
|
12
|
-
styleSelectors: {
|
|
15
|
+
styleSelectors: {
|
|
16
|
+
base: "",
|
|
17
|
+
heading: "",
|
|
18
|
+
heading1: "",
|
|
19
|
+
heading2: "",
|
|
20
|
+
heading3: "",
|
|
21
|
+
heading4: "",
|
|
22
|
+
heading5: "",
|
|
23
|
+
heading6: "",
|
|
24
|
+
paragraph: "",
|
|
25
|
+
link: "",
|
|
26
|
+
strong: "",
|
|
27
|
+
emphasis: "",
|
|
28
|
+
list: "",
|
|
29
|
+
listItem: "",
|
|
30
|
+
quote: "",
|
|
31
|
+
divider: "",
|
|
32
|
+
code: "",
|
|
33
|
+
codeBlock: "",
|
|
34
|
+
codeBlockFrame: "",
|
|
35
|
+
codeBlockHeader: "",
|
|
36
|
+
codeBlockLanguage: "",
|
|
37
|
+
codeBlockCopy: "",
|
|
38
|
+
image: "",
|
|
39
|
+
table: "",
|
|
40
|
+
tableHead: "",
|
|
41
|
+
tableRow: "",
|
|
42
|
+
tableHeaderCell: "",
|
|
43
|
+
tableCell: "",
|
|
44
|
+
anchor: ""
|
|
45
|
+
},
|
|
13
46
|
initialState: { visibility: !0 }
|
|
14
47
|
},
|
|
15
48
|
builder: {
|
|
@@ -33,10 +66,7 @@ var t = e()({
|
|
|
33
66
|
defaultStyle: {
|
|
34
67
|
name: "Markdown",
|
|
35
68
|
displayMode: "desktop",
|
|
36
|
-
style: { base: { default: {
|
|
37
|
-
"font-size": "14px",
|
|
38
|
-
"line-height": "1.714"
|
|
39
|
-
} } }
|
|
69
|
+
style: { base: { default: {} } }
|
|
40
70
|
},
|
|
41
71
|
settings: {}
|
|
42
72
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MarkdownClassNames } from '../../../../components/MarkdownDocument';
|
|
2
|
+
/**
|
|
3
|
+
* The class of each part of a Markdown document, read off the element's slots of the same names — the same object
|
|
4
|
+
* while the classes stay the same: a new one rebuilds every tag of the document.
|
|
5
|
+
*/
|
|
6
|
+
declare const useMarkdownClassNames: (styleSelectors: Readonly<Partial<Record<string, string>>>) => MarkdownClassNames;
|
|
7
|
+
export default useMarkdownClassNames;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MARKDOWN_PARTS as e } from "../../../../components/MarkdownDocument/helpers/markdownParts.mjs";
|
|
2
|
+
import t from "@plitzi/sdk-shared/hooks/useStableValue";
|
|
3
|
+
//#region src/elements/basic/Markdown/hooks/useMarkdownClassNames.ts
|
|
4
|
+
var n = (n) => {
|
|
5
|
+
let r = {};
|
|
6
|
+
for (let t of e) {
|
|
7
|
+
let e = n[t];
|
|
8
|
+
e && (r[t] = e);
|
|
9
|
+
}
|
|
10
|
+
return t(r);
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as default };
|
|
@@ -6,14 +6,43 @@ declare const Markdown: {
|
|
|
6
6
|
readonly content: {
|
|
7
7
|
readonly attributes: {
|
|
8
8
|
readonly content: "Markdown";
|
|
9
|
+
readonly headingLinks: true;
|
|
9
10
|
};
|
|
10
11
|
readonly definition: {
|
|
11
12
|
readonly label: "Markdown";
|
|
12
13
|
readonly type: "markdown";
|
|
13
|
-
readonly description:
|
|
14
|
+
readonly description: string;
|
|
14
15
|
readonly bindings: {};
|
|
15
16
|
readonly styleSelectors: {
|
|
16
17
|
readonly base: "";
|
|
18
|
+
readonly heading: "";
|
|
19
|
+
readonly heading1: "";
|
|
20
|
+
readonly heading2: "";
|
|
21
|
+
readonly heading3: "";
|
|
22
|
+
readonly heading4: "";
|
|
23
|
+
readonly heading5: "";
|
|
24
|
+
readonly heading6: "";
|
|
25
|
+
readonly paragraph: "";
|
|
26
|
+
readonly link: "";
|
|
27
|
+
readonly strong: "";
|
|
28
|
+
readonly emphasis: "";
|
|
29
|
+
readonly list: "";
|
|
30
|
+
readonly listItem: "";
|
|
31
|
+
readonly quote: "";
|
|
32
|
+
readonly divider: "";
|
|
33
|
+
readonly code: "";
|
|
34
|
+
readonly codeBlock: "";
|
|
35
|
+
readonly codeBlockFrame: "";
|
|
36
|
+
readonly codeBlockHeader: "";
|
|
37
|
+
readonly codeBlockLanguage: "";
|
|
38
|
+
readonly codeBlockCopy: "";
|
|
39
|
+
readonly image: "";
|
|
40
|
+
readonly table: "";
|
|
41
|
+
readonly tableHead: "";
|
|
42
|
+
readonly tableRow: "";
|
|
43
|
+
readonly tableHeaderCell: "";
|
|
44
|
+
readonly tableCell: "";
|
|
45
|
+
readonly anchor: "";
|
|
17
46
|
};
|
|
18
47
|
readonly initialState: {
|
|
19
48
|
readonly visibility: true;
|
|
@@ -42,10 +71,7 @@ declare const Markdown: {
|
|
|
42
71
|
readonly displayMode: "desktop";
|
|
43
72
|
readonly style: {
|
|
44
73
|
readonly base: {
|
|
45
|
-
readonly default: {
|
|
46
|
-
readonly 'font-size': "14px";
|
|
47
|
-
readonly 'line-height': "1.714";
|
|
48
|
-
};
|
|
74
|
+
readonly default: {};
|
|
49
75
|
};
|
|
50
76
|
};
|
|
51
77
|
};
|
|
@@ -53,5 +79,6 @@ declare const Markdown: {
|
|
|
53
79
|
};
|
|
54
80
|
} & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
|
|
55
81
|
content?: string | undefined;
|
|
82
|
+
headingLinks?: boolean | undefined;
|
|
56
83
|
}>>;
|
|
57
84
|
export default Markdown;
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import e from "../../../Element/hocs/withElement.mjs";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
2
|
+
import t from "../../../Element/hooks/useElement.mjs";
|
|
3
|
+
import { RootElement as n } from "../../../Element/RootElement.mjs";
|
|
4
|
+
import r from "../../../components/MarkdownDocument/index.mjs";
|
|
5
|
+
import i from "../Markdown/hooks/useMarkdownClassNames.mjs";
|
|
6
|
+
import { classHtmlParts as a } from "./classHtmlParts.mjs";
|
|
7
|
+
import { rebaseHtmlMedia as o, sanitizeHtml as s } from "./sanitizeHtml.mjs";
|
|
8
|
+
import { useMemo as c } from "react";
|
|
9
|
+
import l from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
10
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
|
+
import f from "clsx";
|
|
9
12
|
//#region src/elements/basic/RichText/RichText.tsx
|
|
10
|
-
var
|
|
11
|
-
let { settings: { previewMode:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var p = ({ ref: e, className: p = "", content: m = "", format: h = "html", mediaBaseUrl: g = "" }) => {
|
|
14
|
+
let { settings: { previewMode: _ } } = l(), { definition: { styleSelectors: v } } = t(), y = i(v), b = c(() => h === "html" ? a(o(s(m), g), y) : "", [
|
|
15
|
+
h,
|
|
16
|
+
m,
|
|
17
|
+
g,
|
|
18
|
+
y
|
|
15
19
|
]);
|
|
16
|
-
return /* @__PURE__ */
|
|
20
|
+
return /* @__PURE__ */ d(n, {
|
|
17
21
|
ref: e,
|
|
18
|
-
className:
|
|
22
|
+
className: f("plitzi-component__rich-text", { "plitzi-component__rich-text--edit-mode": !_ }, p),
|
|
19
23
|
children: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
h === "html" && /* @__PURE__ */ u("div", { dangerouslySetInnerHTML: { __html: b } }),
|
|
25
|
+
h === "markdown" && /* @__PURE__ */ u(r, {
|
|
26
|
+
classNames: y,
|
|
27
|
+
children: m
|
|
28
|
+
}),
|
|
29
|
+
h === "text" && /* @__PURE__ */ u("div", {
|
|
23
30
|
className: "plitzi-component__rich-text-plain",
|
|
24
|
-
children:
|
|
31
|
+
children: m
|
|
25
32
|
})
|
|
26
33
|
]
|
|
27
34
|
});
|
|
28
|
-
},
|
|
35
|
+
}, m = e(p);
|
|
29
36
|
//#endregion
|
|
30
|
-
export {
|
|
37
|
+
export { p as RichText, m as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MarkdownClassNames, MarkdownPart } from '../../../components/MarkdownDocument';
|
|
2
|
+
/**
|
|
3
|
+
* The part each tag of a body's HTML is, named as the parts of a Markdown document are, so one set of slots dresses
|
|
4
|
+
* a body whichever format the CMS returns it in. `b` and `i` are the `strong` and `emphasis` an older editor writes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const HTML_TAG_PARTS: Readonly<Partial<Record<string, readonly MarkdownPart[]>>>;
|
|
7
|
+
/**
|
|
8
|
+
* A body's HTML with the class of each of its parts on the tags that are that part.
|
|
9
|
+
*
|
|
10
|
+
* Read off the markup as a string, as the sanitizer reads it, so the server renders the same classes the browser does.
|
|
11
|
+
* `code` is inline code, as in a Markdown document: the `code` of a `pre` is the block's, and the `pre` takes
|
|
12
|
+
* `codeBlock`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const classHtmlParts: (html: string, classNames: MarkdownClassNames) => string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import e from "clsx";
|
|
2
|
+
//#region src/elements/basic/RichText/classHtmlParts.ts
|
|
3
|
+
var t = {
|
|
4
|
+
h1: ["heading", "heading1"],
|
|
5
|
+
h2: ["heading", "heading2"],
|
|
6
|
+
h3: ["heading", "heading3"],
|
|
7
|
+
h4: ["heading", "heading4"],
|
|
8
|
+
h5: ["heading", "heading5"],
|
|
9
|
+
h6: ["heading", "heading6"],
|
|
10
|
+
p: ["paragraph"],
|
|
11
|
+
a: ["link"],
|
|
12
|
+
strong: ["strong"],
|
|
13
|
+
b: ["strong"],
|
|
14
|
+
em: ["emphasis"],
|
|
15
|
+
i: ["emphasis"],
|
|
16
|
+
ul: ["list"],
|
|
17
|
+
ol: ["list"],
|
|
18
|
+
li: ["listItem"],
|
|
19
|
+
blockquote: ["quote"],
|
|
20
|
+
hr: ["divider"],
|
|
21
|
+
code: ["code"],
|
|
22
|
+
pre: ["codeBlock"],
|
|
23
|
+
img: ["image"],
|
|
24
|
+
table: ["table"],
|
|
25
|
+
thead: ["tableHead"],
|
|
26
|
+
tr: ["tableRow"],
|
|
27
|
+
th: ["tableHeaderCell"],
|
|
28
|
+
td: ["tableCell"]
|
|
29
|
+
}, n = /<(\/?)([a-zA-Z][a-zA-Z0-9]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g, r = /\sclass\s*=\s*("[^"]*"|'[^']*'|[^\s"'>]+)/i, i = /^["']|["']$/g, a = /\s*\/$/, o = (t, n) => {
|
|
30
|
+
let o = r.exec(t);
|
|
31
|
+
if (o) {
|
|
32
|
+
let a = o[1].replace(i, "");
|
|
33
|
+
return t.replace(r, ` class="${e(a, n)}"`);
|
|
34
|
+
}
|
|
35
|
+
let s = a.exec(t)?.[0] ?? "";
|
|
36
|
+
return `${t.slice(0, t.length - s.length)} class="${n}"${s}`;
|
|
37
|
+
}, s = (r, i) => {
|
|
38
|
+
if (!Object.values(i).some(Boolean)) return r;
|
|
39
|
+
let a = 0;
|
|
40
|
+
return r.replace(n, (n, r, s, c) => {
|
|
41
|
+
let l = s.toLowerCase();
|
|
42
|
+
if (l === "pre" && (a = Math.max(a + (r ? -1 : 1), 0)), r || l === "code" && a > 0) return n;
|
|
43
|
+
let u = e((t[l] ?? []).map((e) => i[e]));
|
|
44
|
+
return u ? `<${s}${o(c, u)}>` : n;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { t as HTML_TAG_PARTS, s as classHtmlParts };
|
|
@@ -16,11 +16,38 @@ declare const declaration: {
|
|
|
16
16
|
readonly definition: {
|
|
17
17
|
readonly label: "Rich Text";
|
|
18
18
|
readonly type: "richText";
|
|
19
|
-
readonly description:
|
|
19
|
+
readonly description: string;
|
|
20
20
|
readonly items: readonly [];
|
|
21
21
|
readonly bindings: {};
|
|
22
22
|
readonly styleSelectors: {
|
|
23
23
|
readonly base: "";
|
|
24
|
+
readonly heading: "";
|
|
25
|
+
readonly heading1: "";
|
|
26
|
+
readonly heading2: "";
|
|
27
|
+
readonly heading3: "";
|
|
28
|
+
readonly heading4: "";
|
|
29
|
+
readonly heading5: "";
|
|
30
|
+
readonly heading6: "";
|
|
31
|
+
readonly paragraph: "";
|
|
32
|
+
readonly link: "";
|
|
33
|
+
readonly strong: "";
|
|
34
|
+
readonly emphasis: "";
|
|
35
|
+
readonly list: "";
|
|
36
|
+
readonly listItem: "";
|
|
37
|
+
readonly quote: "";
|
|
38
|
+
readonly divider: "";
|
|
39
|
+
readonly code: "";
|
|
40
|
+
readonly codeBlock: "";
|
|
41
|
+
readonly codeBlockFrame: "";
|
|
42
|
+
readonly codeBlockHeader: "";
|
|
43
|
+
readonly codeBlockLanguage: "";
|
|
44
|
+
readonly codeBlockCopy: "";
|
|
45
|
+
readonly image: "";
|
|
46
|
+
readonly table: "";
|
|
47
|
+
readonly tableHead: "";
|
|
48
|
+
readonly tableRow: "";
|
|
49
|
+
readonly tableHeaderCell: "";
|
|
50
|
+
readonly tableCell: "";
|
|
24
51
|
};
|
|
25
52
|
readonly initialState: {
|
|
26
53
|
readonly visibility: true;
|
|
@@ -16,10 +16,39 @@ var n = e()({
|
|
|
16
16
|
definition: {
|
|
17
17
|
label: "Rich Text",
|
|
18
18
|
type: "richText",
|
|
19
|
-
description: "Renders a body field coming from a CMS — HTML, markdown or plain text. Scripts and event handlers are stripped before rendering, so third-party content cannot execute.",
|
|
19
|
+
description: "Renders a body field coming from a CMS — HTML, markdown or plain text. Scripts and event handlers are stripped before rendering, so third-party content cannot execute. The parts of an HTML or markdown body take a class through the slots a `markdown` has, by the same names: `heading` and `heading1`…`heading6` (a property on one of the two, never both), `paragraph`, `link`, `strong` (`strong`/`b`), `emphasis` (`em`/`i`), `list`, `listItem`, `quote`, `divider`, `code` (inline), `codeBlock` (`pre`), `image`, `table`, `tableHead`, `tableRow`, `tableHeaderCell`, `tableCell`; the fenced block of a markdown body also sits in `codeBlockFrame`, under `codeBlockHeader` with `codeBlockLanguage` and `codeBlockCopy`. Unstyled, a body reads as a document from the base layer of the SDK, which a class on the slot of a part replaces property by property.",
|
|
20
20
|
items: [],
|
|
21
21
|
bindings: {},
|
|
22
|
-
styleSelectors: {
|
|
22
|
+
styleSelectors: {
|
|
23
|
+
base: "",
|
|
24
|
+
heading: "",
|
|
25
|
+
heading1: "",
|
|
26
|
+
heading2: "",
|
|
27
|
+
heading3: "",
|
|
28
|
+
heading4: "",
|
|
29
|
+
heading5: "",
|
|
30
|
+
heading6: "",
|
|
31
|
+
paragraph: "",
|
|
32
|
+
link: "",
|
|
33
|
+
strong: "",
|
|
34
|
+
emphasis: "",
|
|
35
|
+
list: "",
|
|
36
|
+
listItem: "",
|
|
37
|
+
quote: "",
|
|
38
|
+
divider: "",
|
|
39
|
+
code: "",
|
|
40
|
+
codeBlock: "",
|
|
41
|
+
codeBlockFrame: "",
|
|
42
|
+
codeBlockHeader: "",
|
|
43
|
+
codeBlockLanguage: "",
|
|
44
|
+
codeBlockCopy: "",
|
|
45
|
+
image: "",
|
|
46
|
+
table: "",
|
|
47
|
+
tableHead: "",
|
|
48
|
+
tableRow: "",
|
|
49
|
+
tableHeaderCell: "",
|
|
50
|
+
tableCell: ""
|
|
51
|
+
},
|
|
23
52
|
initialState: { visibility: !0 }
|
|
24
53
|
},
|
|
25
54
|
builder: {
|
|
@@ -15,11 +15,38 @@ declare const RichText: {
|
|
|
15
15
|
readonly definition: {
|
|
16
16
|
readonly label: "Rich Text";
|
|
17
17
|
readonly type: "richText";
|
|
18
|
-
readonly description:
|
|
18
|
+
readonly description: string;
|
|
19
19
|
readonly items: readonly [];
|
|
20
20
|
readonly bindings: {};
|
|
21
21
|
readonly styleSelectors: {
|
|
22
22
|
readonly base: "";
|
|
23
|
+
readonly heading: "";
|
|
24
|
+
readonly heading1: "";
|
|
25
|
+
readonly heading2: "";
|
|
26
|
+
readonly heading3: "";
|
|
27
|
+
readonly heading4: "";
|
|
28
|
+
readonly heading5: "";
|
|
29
|
+
readonly heading6: "";
|
|
30
|
+
readonly paragraph: "";
|
|
31
|
+
readonly link: "";
|
|
32
|
+
readonly strong: "";
|
|
33
|
+
readonly emphasis: "";
|
|
34
|
+
readonly list: "";
|
|
35
|
+
readonly listItem: "";
|
|
36
|
+
readonly quote: "";
|
|
37
|
+
readonly divider: "";
|
|
38
|
+
readonly code: "";
|
|
39
|
+
readonly codeBlock: "";
|
|
40
|
+
readonly codeBlockFrame: "";
|
|
41
|
+
readonly codeBlockHeader: "";
|
|
42
|
+
readonly codeBlockLanguage: "";
|
|
43
|
+
readonly codeBlockCopy: "";
|
|
44
|
+
readonly image: "";
|
|
45
|
+
readonly table: "";
|
|
46
|
+
readonly tableHead: "";
|
|
47
|
+
readonly tableRow: "";
|
|
48
|
+
readonly tableHeaderCell: "";
|
|
49
|
+
readonly tableCell: "";
|
|
23
50
|
};
|
|
24
51
|
readonly initialState: {
|
|
25
52
|
readonly visibility: true;
|
|
@@ -33,11 +33,7 @@ var t = e()({
|
|
|
33
33
|
defaultStyle: {
|
|
34
34
|
name: "Text",
|
|
35
35
|
displayMode: "desktop",
|
|
36
|
-
style: { base: { default: {
|
|
37
|
-
"font-size": "14px",
|
|
38
|
-
"line-height": "1.714",
|
|
39
|
-
display: "inline"
|
|
40
|
-
} } }
|
|
36
|
+
style: { base: { default: { display: "inline" } } }
|
|
41
37
|
},
|
|
42
38
|
settings: {}
|
|
43
39
|
}
|
|
@@ -37,11 +37,11 @@ var h = () => () => {}, g = () => !0, _ = () => !1, v = () => /* @__PURE__ */ f(
|
|
|
37
37
|
d: "M20.5 14.3A8.6 8.6 0 0 1 9.7 3.5a8.6 8.6 0 1 0 10.8 10.8Z"
|
|
38
38
|
})
|
|
39
39
|
}), b = ({ ref: e, className: b = "", subType: x = "switch", lightLabel: S = "Light", darkLabel: C = "Dark", systemLabel: w = "System", showSystem: T = !1 }) => {
|
|
40
|
-
let { theme: E,
|
|
41
|
-
t.preventDefault(),
|
|
42
|
-
}, [
|
|
43
|
-
e.preventDefault(),
|
|
44
|
-
}, [
|
|
40
|
+
let { theme: E, resolvedTheme: D, setTheme: O, toggleTheme: k } = m(), { id: A, definition: { styleSelectors: j } } = t(), { settings: { previewMode: M }, contexts: { InteractionsContext: N } } = u(), { interactionsManager: P } = i(N), F = l(h, g, _), I = a((e) => (t) => {
|
|
41
|
+
t.preventDefault(), M && O(e);
|
|
42
|
+
}, [M, O]), L = a((e) => {
|
|
43
|
+
e.preventDefault(), M && k();
|
|
44
|
+
}, [M, k]), R = s(() => [
|
|
45
45
|
...T ? [{
|
|
46
46
|
value: "system",
|
|
47
47
|
label: w,
|
|
@@ -62,14 +62,14 @@ var h = () => () => {}, g = () => !0, _ = () => !1, v = () => /* @__PURE__ */ f(
|
|
|
62
62
|
w,
|
|
63
63
|
S,
|
|
64
64
|
C
|
|
65
|
-
]),
|
|
65
|
+
]), z = c(null);
|
|
66
66
|
return o(() => {
|
|
67
|
-
let e =
|
|
68
|
-
|
|
67
|
+
let e = z.current;
|
|
68
|
+
z.current = E, e !== null && e !== E && P.interactionTrigger(A, "onThemeChange", { theme: E });
|
|
69
69
|
}, [
|
|
70
70
|
E,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
P,
|
|
72
|
+
A
|
|
73
73
|
]), x === "segmented" ? /* @__PURE__ */ d(n, {
|
|
74
74
|
ref: e,
|
|
75
75
|
tag: "div",
|
|
@@ -77,13 +77,13 @@ var h = () => () => {}, g = () => !0, _ = () => !1, v = () => /* @__PURE__ */ f(
|
|
|
77
77
|
"aria-label": `${S} / ${C}`,
|
|
78
78
|
className: p("plitzi-component__theme-toggle plitzi-component__theme-toggle--segmented", b),
|
|
79
79
|
interactionTriggers: r.triggers,
|
|
80
|
-
children:
|
|
80
|
+
children: R.map((e) => /* @__PURE__ */ f("button", {
|
|
81
81
|
type: "button",
|
|
82
|
-
className: p("plitzi-component__theme-toggle-option",
|
|
83
|
-
"data-active":
|
|
84
|
-
"aria-pressed":
|
|
82
|
+
className: p("plitzi-component__theme-toggle-option", j.option),
|
|
83
|
+
"data-active": F && E === e.value ? "true" : void 0,
|
|
84
|
+
"aria-pressed": F ? E === e.value : void 0,
|
|
85
85
|
"data-theme-option": e.value,
|
|
86
|
-
onClick:
|
|
86
|
+
onClick: I(e.value),
|
|
87
87
|
children: [e.icon, /* @__PURE__ */ d("span", { children: e.label })]
|
|
88
88
|
}, e.value))
|
|
89
89
|
}) : /* @__PURE__ */ f(n, {
|
|
@@ -92,16 +92,18 @@ var h = () => () => {}, g = () => !0, _ = () => !1, v = () => /* @__PURE__ */ f(
|
|
|
92
92
|
className: p("plitzi-component__theme-toggle plitzi-component__theme-toggle--switch", b),
|
|
93
93
|
interactionTriggers: r.triggers,
|
|
94
94
|
type: "button",
|
|
95
|
-
onClick:
|
|
95
|
+
onClick: L,
|
|
96
96
|
"aria-label": `${S} / ${C}`,
|
|
97
97
|
title: `${S} / ${C}`,
|
|
98
98
|
children: [/* @__PURE__ */ d("span", {
|
|
99
|
-
className: p("plitzi-component__theme-toggle-icon",
|
|
99
|
+
className: p("plitzi-component__theme-toggle-icon", j.icon),
|
|
100
100
|
"data-theme-icon": "light",
|
|
101
|
+
"aria-current": F && D === "light" ? "true" : void 0,
|
|
101
102
|
children: /* @__PURE__ */ d(v, {})
|
|
102
103
|
}), /* @__PURE__ */ d("span", {
|
|
103
|
-
className: p("plitzi-component__theme-toggle-icon",
|
|
104
|
+
className: p("plitzi-component__theme-toggle-icon", j.icon),
|
|
104
105
|
"data-theme-icon": "dark",
|
|
106
|
+
"aria-current": F && D === "dark" ? "true" : void 0,
|
|
105
107
|
children: /* @__PURE__ */ d(y, {})
|
|
106
108
|
})]
|
|
107
109
|
});
|
|
@@ -29,7 +29,7 @@ declare const declaration: {
|
|
|
29
29
|
readonly definition: {
|
|
30
30
|
readonly label: "Theme Toggle";
|
|
31
31
|
readonly type: "themeToggle";
|
|
32
|
-
readonly description:
|
|
32
|
+
readonly description: string;
|
|
33
33
|
readonly items: readonly [];
|
|
34
34
|
readonly bindings: {};
|
|
35
35
|
readonly styleSelectors: {
|
|
@@ -65,9 +65,53 @@ declare const declaration: {
|
|
|
65
65
|
readonly style: {
|
|
66
66
|
readonly base: {
|
|
67
67
|
readonly default: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
'margin-top': string;
|
|
69
|
+
'margin-right': string;
|
|
70
|
+
'margin-bottom': string;
|
|
71
|
+
'margin-left': string;
|
|
72
|
+
'padding-top': string;
|
|
73
|
+
'padding-right': string;
|
|
74
|
+
'padding-bottom': string;
|
|
75
|
+
'padding-left': string;
|
|
76
|
+
display: string;
|
|
77
|
+
'align-items': string;
|
|
78
|
+
'background-color': string;
|
|
79
|
+
color: string;
|
|
80
|
+
'font-family': string;
|
|
81
|
+
'font-size': string;
|
|
82
|
+
'font-style': string;
|
|
83
|
+
'font-weight': string;
|
|
84
|
+
'line-height': string;
|
|
85
|
+
'letter-spacing': string;
|
|
86
|
+
cursor: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly icon: {
|
|
90
|
+
readonly default: {};
|
|
91
|
+
};
|
|
92
|
+
readonly option: {
|
|
93
|
+
readonly default: {
|
|
94
|
+
readonly 'row-gap': "4px";
|
|
95
|
+
readonly 'column-gap': "4px";
|
|
96
|
+
readonly 'margin-top': string;
|
|
97
|
+
readonly 'margin-right': string;
|
|
98
|
+
readonly 'margin-bottom': string;
|
|
99
|
+
readonly 'margin-left': string;
|
|
100
|
+
readonly 'padding-top': string;
|
|
101
|
+
readonly 'padding-right': string;
|
|
102
|
+
readonly 'padding-bottom': string;
|
|
103
|
+
readonly 'padding-left': string;
|
|
104
|
+
readonly display: string;
|
|
105
|
+
readonly 'align-items': string;
|
|
106
|
+
readonly 'background-color': string;
|
|
107
|
+
readonly color: string;
|
|
108
|
+
readonly 'font-family': string;
|
|
109
|
+
readonly 'font-size': string;
|
|
110
|
+
readonly 'font-style': string;
|
|
111
|
+
readonly 'font-weight': string;
|
|
112
|
+
readonly 'line-height': string;
|
|
113
|
+
readonly 'letter-spacing': string;
|
|
114
|
+
readonly cursor: string;
|
|
71
115
|
};
|
|
72
116
|
};
|
|
73
117
|
};
|