@webstudio-is/react-sdk 0.65.0 → 0.67.0
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/lib/app/custom-components/form.ws.js +2 -2
- package/lib/app/custom-components/image.js +7 -13
- package/lib/app/custom-components/index.js +4 -1
- package/lib/app/params.js +1 -0
- package/lib/cjs/app/custom-components/form.ws.js +2 -2
- package/lib/cjs/app/custom-components/image.js +3 -12
- package/lib/cjs/app/custom-components/index.js +4 -1
- package/lib/cjs/app/params.js +1 -0
- package/lib/cjs/components/__generated__/{code.props.js → code-text.props.js} +3 -3
- package/lib/cjs/components/__generated__/html-embed.props.js +31 -0
- package/lib/cjs/components/blockquote.ws.js +2 -2
- package/lib/cjs/components/body.ws.js +2 -2
- package/lib/cjs/components/bold.ws.js +2 -2
- package/lib/cjs/components/box.ws.js +2 -2
- package/lib/cjs/components/button.ws.js +2 -2
- package/lib/cjs/components/checkbox-field.ws.js +2 -2
- package/lib/cjs/components/checkbox.ws.js +2 -2
- package/lib/cjs/components/{code.js → code-text.js} +6 -6
- package/lib/cjs/components/{code.ws.js → code-text.ws.js} +10 -10
- package/lib/cjs/components/component-meta.js +2 -2
- package/lib/cjs/components/components-utils.js +1 -43
- package/lib/cjs/components/components.js +4 -2
- package/lib/cjs/components/error-message.ws.js +2 -2
- package/lib/cjs/components/form.ws.js +2 -2
- package/lib/cjs/components/fragment.ws.js +1 -1
- package/lib/cjs/components/heading.ws.js +2 -2
- package/lib/cjs/components/html-embed.js +80 -0
- package/lib/cjs/components/html-embed.ws.js +43 -0
- package/lib/cjs/components/image.ws.js +2 -2
- package/lib/cjs/components/index.js +11 -57
- package/lib/cjs/components/input.ws.js +2 -2
- package/lib/cjs/components/italic.ws.js +2 -2
- package/lib/cjs/components/label.ws.js +2 -2
- package/lib/cjs/components/link-block.ws.js +2 -2
- package/lib/cjs/components/link.ws.js +2 -2
- package/lib/cjs/components/list-item.ws.js +2 -2
- package/lib/cjs/components/list.ws.js +2 -2
- package/lib/cjs/components/paragraph.ws.js +2 -2
- package/lib/cjs/components/radio-button-field.ws.js +2 -2
- package/lib/cjs/components/radio-button.ws.js +2 -2
- package/lib/cjs/components/separator.ws.js +2 -2
- package/lib/cjs/components/slot.ws.js +2 -2
- package/lib/cjs/components/span.ws.js +2 -2
- package/lib/cjs/components/subscript.ws.js +2 -2
- package/lib/cjs/components/success-message.ws.js +2 -2
- package/lib/cjs/components/superscript.ws.js +2 -2
- package/lib/cjs/components/text-block.ws.js +2 -2
- package/lib/cjs/components/textarea.ws.js +2 -2
- package/lib/cjs/css/css.js +2 -5
- package/lib/cjs/css/normalize.js +1 -1
- package/lib/cjs/css/presets.js +8 -1
- package/lib/cjs/tree/create-elements-tree.js +2 -4
- package/lib/components/__generated__/html-embed.props.js +11 -0
- package/lib/components/blockquote.ws.js +2 -2
- package/lib/components/body.ws.js +2 -2
- package/lib/components/bold.ws.js +2 -2
- package/lib/components/box.ws.js +2 -2
- package/lib/components/button.ws.js +2 -2
- package/lib/components/checkbox-field.ws.js +2 -2
- package/lib/components/checkbox.ws.js +2 -2
- package/lib/components/{code.js → code-text.js} +3 -3
- package/lib/components/{code.ws.js → code-text.ws.js} +5 -5
- package/lib/components/component-meta.js +3 -3
- package/lib/components/components-utils.js +1 -43
- package/lib/components/components.js +4 -2
- package/lib/components/error-message.ws.js +2 -2
- package/lib/components/form.ws.js +2 -2
- package/lib/components/fragment.ws.js +1 -1
- package/lib/components/heading.ws.js +2 -2
- package/lib/components/html-embed.js +65 -0
- package/lib/components/html-embed.ws.js +23 -0
- package/lib/components/image.ws.js +2 -2
- package/lib/components/index.js +11 -57
- package/lib/components/input.ws.js +2 -2
- package/lib/components/italic.ws.js +2 -2
- package/lib/components/label.ws.js +2 -2
- package/lib/components/link-block.ws.js +2 -2
- package/lib/components/link.ws.js +2 -2
- package/lib/components/list-item.ws.js +2 -2
- package/lib/components/list.ws.js +2 -2
- package/lib/components/paragraph.ws.js +2 -2
- package/lib/components/radio-button-field.ws.js +2 -2
- package/lib/components/radio-button.ws.js +2 -2
- package/lib/components/separator.ws.js +2 -2
- package/lib/components/slot.ws.js +2 -2
- package/lib/components/span.ws.js +2 -2
- package/lib/components/subscript.ws.js +2 -2
- package/lib/components/success-message.ws.js +2 -2
- package/lib/components/superscript.ws.js +2 -2
- package/lib/components/text-block.ws.js +2 -2
- package/lib/components/textarea.ws.js +2 -2
- package/lib/css/css.js +2 -5
- package/lib/css/normalize.js +2 -2
- package/lib/css/presets.js +8 -1
- package/lib/tree/create-elements-tree.js +2 -4
- package/lib/types/app/params.d.ts +22 -1
- package/lib/types/components/__generated__/html-embed.props.d.ts +2 -0
- package/lib/types/components/{code.d.ts → code-text.d.ts} +1 -1
- package/lib/types/components/{code.stories.d.ts → code-text.stories.d.ts} +1 -1
- package/lib/types/components/component-meta.d.ts +1785 -10
- package/lib/types/components/components-utils.d.ts +6 -3
- package/lib/types/components/components.d.ts +2 -1
- package/lib/types/components/html-embed.d.ts +7 -0
- package/lib/types/components/html-embed.stories.d.ts +11 -0
- package/lib/types/components/html-embed.ws.d.ts +3 -0
- package/lib/types/components/index.d.ts +2 -2
- package/lib/types/context.d.ts +1 -0
- package/lib/types/css/css.d.ts +2 -0
- package/lib/types/css/presets.d.ts +1 -0
- package/lib/types/css/style-rules.d.ts +1 -1
- package/lib/types/embed-template.d.ts +1 -1
- package/lib/types/tree/create-elements-tree.d.ts +2 -2
- package/package.json +14 -13
- package/src/app/custom-components/form.ws.tsx +2 -2
- package/src/app/custom-components/image.tsx +7 -13
- package/src/app/custom-components/index.ts +4 -1
- package/src/app/params.ts +23 -1
- package/src/components/__generated__/html-embed.props.ts +10 -0
- package/src/components/blockquote.ws.tsx +2 -2
- package/src/components/body.ws.tsx +2 -2
- package/src/components/bold.ws.tsx +2 -2
- package/src/components/box.ws.ts +2 -2
- package/src/components/button.ws.tsx +2 -2
- package/src/components/checkbox-field.ws.tsx +2 -2
- package/src/components/checkbox.ws.tsx +2 -2
- package/src/components/code-text.stories.tsx +16 -0
- package/src/components/{code.tsx → code-text.tsx} +2 -2
- package/src/components/{code.ws.tsx → code-text.ws.tsx} +5 -5
- package/src/components/component-meta.ts +3 -6
- package/src/components/components-utils.ts +14 -58
- package/src/components/components.ts +2 -1
- package/src/components/error-message.ws.tsx +2 -2
- package/src/components/form.ws.tsx +2 -2
- package/src/components/fragment.ws.ts +1 -1
- package/src/components/heading.ws.tsx +2 -2
- package/src/components/html-embed.stories.tsx +16 -0
- package/src/components/html-embed.tsx +96 -0
- package/src/components/html-embed.ws.ts +22 -0
- package/src/components/image.ws.tsx +2 -2
- package/src/components/index.ts +10 -87
- package/src/components/input.ws.tsx +2 -2
- package/src/components/italic.ws.tsx +2 -2
- package/src/components/label.ws.tsx +2 -2
- package/src/components/link-block.ws.tsx +2 -2
- package/src/components/link.ws.tsx +2 -2
- package/src/components/list-item.ws.tsx +2 -2
- package/src/components/list.ws.tsx +2 -2
- package/src/components/paragraph.ws.tsx +2 -2
- package/src/components/radio-button-field.ws.tsx +2 -2
- package/src/components/radio-button.ws.tsx +2 -2
- package/src/components/separator.ws.tsx +2 -2
- package/src/components/slot.ws.ts +2 -2
- package/src/components/span.ws.tsx +2 -2
- package/src/components/subscript.ws.tsx +2 -2
- package/src/components/success-message.ws.tsx +2 -2
- package/src/components/superscript.ws.tsx +2 -2
- package/src/components/text-block.ws.tsx +2 -2
- package/src/components/textarea.ws.tsx +2 -2
- package/src/context.tsx +1 -0
- package/src/css/css.ts +4 -5
- package/src/css/normalize.ts +2 -2
- package/src/css/presets.ts +7 -0
- package/src/tree/create-elements-tree.tsx +3 -5
- package/lib/cjs/tree/session-storage-polyfill.js +0 -65
- package/lib/tree/session-storage-polyfill.js +0 -45
- package/lib/types/tree/session-storage-polyfill.d.ts +0 -2
- package/src/components/code.stories.tsx +0 -16
- package/src/tree/session-storage-polyfill.tsx +0 -50
- /package/lib/components/__generated__/{code.props.js → code-text.props.js} +0 -0
- /package/lib/types/components/__generated__/{code.props.d.ts → code-text.props.d.ts} +0 -0
- /package/lib/types/components/{code.ws.d.ts → code-text.ws.d.ts} +0 -0
- /package/src/components/__generated__/{code.props.ts → code-text.props.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BodyIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { BodyIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { body } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -34,7 +34,7 @@ const presetStyle = {
|
|
|
34
34
|
const meta = {
|
|
35
35
|
type: "container",
|
|
36
36
|
label: "Body",
|
|
37
|
-
|
|
37
|
+
icon: BodyIcon,
|
|
38
38
|
states: defaultStates,
|
|
39
39
|
presetStyle
|
|
40
40
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoldIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { BoldIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
@@ -10,7 +10,7 @@ const presetStyle = {
|
|
|
10
10
|
const meta = {
|
|
11
11
|
type: "rich-text-child",
|
|
12
12
|
label: "Bold Text",
|
|
13
|
-
|
|
13
|
+
icon: BoldIcon,
|
|
14
14
|
states: defaultStates,
|
|
15
15
|
presetStyle
|
|
16
16
|
};
|
package/lib/components/box.ws.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoxIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { BoxIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
@@ -31,7 +31,7 @@ const meta = {
|
|
|
31
31
|
category: "general",
|
|
32
32
|
type: "container",
|
|
33
33
|
label: "Box",
|
|
34
|
-
|
|
34
|
+
icon: BoxIcon,
|
|
35
35
|
states: defaultStates,
|
|
36
36
|
presetStyle
|
|
37
37
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonElementIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { ButtonElementIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { button } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -11,7 +11,7 @@ const meta = {
|
|
|
11
11
|
category: "forms",
|
|
12
12
|
type: "container",
|
|
13
13
|
label: "Button",
|
|
14
|
-
|
|
14
|
+
icon: ButtonElementIcon,
|
|
15
15
|
presetStyle,
|
|
16
16
|
states: [
|
|
17
17
|
...defaultStates,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckboxCheckedIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { CheckboxCheckedIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
@@ -14,7 +14,7 @@ const meta = {
|
|
|
14
14
|
category: "forms",
|
|
15
15
|
type: "container",
|
|
16
16
|
label: "Checkbox",
|
|
17
|
-
|
|
17
|
+
icon: CheckboxCheckedIcon,
|
|
18
18
|
states: defaultStates,
|
|
19
19
|
presetStyle,
|
|
20
20
|
children: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckboxCheckedIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { CheckboxCheckedIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
@@ -16,7 +16,7 @@ const presetStyle = {
|
|
|
16
16
|
const meta = {
|
|
17
17
|
type: "control",
|
|
18
18
|
label: "Checkbox Input",
|
|
19
|
-
|
|
19
|
+
icon: CheckboxCheckedIcon,
|
|
20
20
|
presetStyle,
|
|
21
21
|
states: [
|
|
22
22
|
...defaultStates,
|
|
@@ -8,15 +8,15 @@ const displayVarNamespace = cssVars.unique("code-display");
|
|
|
8
8
|
const blockStyle = {
|
|
9
9
|
[cssVars.define(displayVarNamespace, true)]: "block"
|
|
10
10
|
};
|
|
11
|
-
const
|
|
11
|
+
const CodeText = forwardRef(
|
|
12
12
|
({ inline = false, ...props }, ref) => {
|
|
13
13
|
const style = inline ? void 0 : blockStyle;
|
|
14
14
|
return createElement(defaultTag, { ...props, style, ref });
|
|
15
15
|
}
|
|
16
16
|
);
|
|
17
|
-
|
|
17
|
+
CodeText.displayName = "CodeText";
|
|
18
18
|
export {
|
|
19
|
-
|
|
19
|
+
CodeText,
|
|
20
20
|
defaultTag,
|
|
21
21
|
displayVarNamespace
|
|
22
22
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CodeTextIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
5
|
-
import { displayVarNamespace } from "./code";
|
|
6
|
-
import { props } from "./__generated__/code.props";
|
|
5
|
+
import { displayVarNamespace } from "./code-text";
|
|
6
|
+
import { props } from "./__generated__/code-text.props";
|
|
7
7
|
import { code } from "../css/normalize";
|
|
8
8
|
const presetStyle = {
|
|
9
9
|
code: [
|
|
@@ -33,8 +33,8 @@ const presetStyle = {
|
|
|
33
33
|
const meta = {
|
|
34
34
|
category: "general",
|
|
35
35
|
type: "rich-text",
|
|
36
|
-
label: "Code",
|
|
37
|
-
|
|
36
|
+
label: "Code Text",
|
|
37
|
+
icon: CodeTextIcon,
|
|
38
38
|
states: defaultStates,
|
|
39
39
|
presetStyle,
|
|
40
40
|
children: [{ type: "text", value: "Code you can edit" }]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PropMeta } from "@webstudio-is/generate-arg-types";
|
|
3
|
-
import { WsEmbedTemplate } from "../embed-template";
|
|
3
|
+
import { EmbedTemplateStyleDecl, WsEmbedTemplate } from "../embed-template";
|
|
4
4
|
const WsComponentPropsMeta = z.object({
|
|
5
5
|
props: z.record(PropMeta),
|
|
6
6
|
initialProps: z.array(z.string()).optional()
|
|
@@ -40,8 +40,8 @@ const WsComponentMeta = z.object({
|
|
|
40
40
|
]),
|
|
41
41
|
acceptedParents: z.optional(z.array(z.string())),
|
|
42
42
|
label: z.string(),
|
|
43
|
-
|
|
44
|
-
presetStyle: z.optional(z.
|
|
43
|
+
icon: z.string(),
|
|
44
|
+
presetStyle: z.optional(z.record(z.string(), EmbedTemplateStyleDecl)),
|
|
45
45
|
states: z.optional(z.array(ComponentState)),
|
|
46
46
|
children: z.optional(WsEmbedTemplate)
|
|
47
47
|
});
|
|
@@ -1,46 +1,5 @@
|
|
|
1
1
|
import * as components from "./components";
|
|
2
2
|
import { registeredComponents } from "./index";
|
|
3
|
-
const componentNames = Object.keys({
|
|
4
|
-
Slot: 1,
|
|
5
|
-
Fragment: 1,
|
|
6
|
-
Box: 1,
|
|
7
|
-
Body: 1,
|
|
8
|
-
TextBlock: 1,
|
|
9
|
-
Heading: 1,
|
|
10
|
-
Paragraph: 1,
|
|
11
|
-
Link: 1,
|
|
12
|
-
LinkBlock: 1,
|
|
13
|
-
RichTextLink: 1,
|
|
14
|
-
Span: 1,
|
|
15
|
-
Bold: 1,
|
|
16
|
-
Italic: 1,
|
|
17
|
-
Superscript: 1,
|
|
18
|
-
Subscript: 1,
|
|
19
|
-
Button: 1,
|
|
20
|
-
Input: 1,
|
|
21
|
-
Form: 1,
|
|
22
|
-
Image: 1,
|
|
23
|
-
Blockquote: 1,
|
|
24
|
-
List: 1,
|
|
25
|
-
ListItem: 1,
|
|
26
|
-
Separator: 1,
|
|
27
|
-
Code: 1,
|
|
28
|
-
Label: 1,
|
|
29
|
-
SuccessMessage: 1,
|
|
30
|
-
ErrorMessage: 1,
|
|
31
|
-
Textarea: 1,
|
|
32
|
-
RadioButtonField: 1,
|
|
33
|
-
RadioButton: 1,
|
|
34
|
-
CheckboxField: 1,
|
|
35
|
-
Checkbox: 1
|
|
36
|
-
});
|
|
37
|
-
const getComponentNames = () => {
|
|
38
|
-
const uniqueNames = /* @__PURE__ */ new Set([
|
|
39
|
-
...componentNames,
|
|
40
|
-
...Object.keys(registeredComponents || {})
|
|
41
|
-
]);
|
|
42
|
-
return Array.from(uniqueNames);
|
|
43
|
-
};
|
|
44
3
|
const getComponent = (name) => {
|
|
45
4
|
return registeredComponents != null && name in registeredComponents ? registeredComponents[name] : components[name];
|
|
46
5
|
};
|
|
@@ -51,6 +10,5 @@ const createGetComponent = (comps) => {
|
|
|
51
10
|
};
|
|
52
11
|
export {
|
|
53
12
|
createGetComponent,
|
|
54
|
-
getComponent
|
|
55
|
-
getComponentNames
|
|
13
|
+
getComponent
|
|
56
14
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Slot } from "./slot";
|
|
2
2
|
import { Fragment } from "./fragment";
|
|
3
|
+
import { HtmlEmbed } from "./html-embed";
|
|
3
4
|
import { Body } from "./body";
|
|
4
5
|
import { Box } from "./box";
|
|
5
6
|
import { TextBlock } from "./text-block";
|
|
@@ -21,7 +22,7 @@ import { Blockquote } from "./blockquote";
|
|
|
21
22
|
import { List } from "./list";
|
|
22
23
|
import { ListItem } from "./list-item";
|
|
23
24
|
import { Separator } from "./separator";
|
|
24
|
-
import {
|
|
25
|
+
import { CodeText } from "./code-text";
|
|
25
26
|
import { Label } from "./label";
|
|
26
27
|
import { SuccessMessage } from "./success-message";
|
|
27
28
|
import { ErrorMessage } from "./error-message";
|
|
@@ -38,11 +39,12 @@ export {
|
|
|
38
39
|
Button,
|
|
39
40
|
Checkbox,
|
|
40
41
|
CheckboxField,
|
|
41
|
-
|
|
42
|
+
CodeText,
|
|
42
43
|
ErrorMessage,
|
|
43
44
|
Form,
|
|
44
45
|
Fragment,
|
|
45
46
|
Heading,
|
|
47
|
+
HtmlEmbed,
|
|
46
48
|
Image,
|
|
47
49
|
Input,
|
|
48
50
|
Italic,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoxIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { BoxIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { props } from "./__generated__/error-message.props";
|
|
3
3
|
import { div } from "../css/normalize";
|
|
4
4
|
const presetStyle = {
|
|
@@ -7,7 +7,7 @@ const presetStyle = {
|
|
|
7
7
|
const meta = {
|
|
8
8
|
type: "container",
|
|
9
9
|
label: "Error Message",
|
|
10
|
-
|
|
10
|
+
icon: BoxIcon,
|
|
11
11
|
presetStyle
|
|
12
12
|
};
|
|
13
13
|
const propsMeta = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { FormIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { form } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -14,7 +14,7 @@ const meta = {
|
|
|
14
14
|
category: "forms",
|
|
15
15
|
type: "container",
|
|
16
16
|
label: "Form",
|
|
17
|
-
|
|
17
|
+
icon: FormIcon,
|
|
18
18
|
states: defaultStates,
|
|
19
19
|
presetStyle,
|
|
20
20
|
children: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HeadingIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { HeadingIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { h1, h2, h3, h4, h5, h6 } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -16,7 +16,7 @@ const meta = {
|
|
|
16
16
|
category: "typography",
|
|
17
17
|
type: "rich-text",
|
|
18
18
|
label: "Heading",
|
|
19
|
-
|
|
19
|
+
icon: HeadingIcon,
|
|
20
20
|
children: [{ type: "text", value: "Heading you can edit" }],
|
|
21
21
|
states: defaultStates,
|
|
22
22
|
presetStyle
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef
|
|
7
|
+
} from "react";
|
|
8
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
9
|
+
import { ReactSdkContext } from "../context";
|
|
10
|
+
const ExecutableHtml = (props) => {
|
|
11
|
+
const { code, innerRef, ...rest } = props;
|
|
12
|
+
const containerRef = useRef(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const container = containerRef.current;
|
|
15
|
+
if (container === null || code === void 0) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const range = document.createRange();
|
|
19
|
+
range.setStart(container, 0);
|
|
20
|
+
const fragment = range.createContextualFragment(code);
|
|
21
|
+
while (container.firstChild) {
|
|
22
|
+
container.removeChild(container.firstChild);
|
|
23
|
+
}
|
|
24
|
+
container.append(fragment);
|
|
25
|
+
}, [code]);
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
...rest,
|
|
30
|
+
ref: mergeRefs(innerRef, containerRef),
|
|
31
|
+
style: { display: "contents" }
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
const InnerHtml = (props) => {
|
|
36
|
+
const { code, innerRef, ...rest } = props;
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
...rest,
|
|
41
|
+
ref: innerRef,
|
|
42
|
+
style: { display: "contents" },
|
|
43
|
+
dangerouslySetInnerHTML: { __html: props.code ?? "" }
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
const Placeholder = (props) => {
|
|
48
|
+
const { code, innerRef, ...rest } = props;
|
|
49
|
+
return /* @__PURE__ */ jsx("div", { ref: innerRef, ...rest, style: { padding: "20px" }, children: 'Open "Properties" panel to insert HTML code' });
|
|
50
|
+
};
|
|
51
|
+
const HtmlEmbed = forwardRef((props, ref) => {
|
|
52
|
+
const { renderer } = useContext(ReactSdkContext);
|
|
53
|
+
const { code, executeScriptOnCanvas, ...rest } = props;
|
|
54
|
+
if (code === void 0 || code.trim().length === 0) {
|
|
55
|
+
return /* @__PURE__ */ jsx(Placeholder, { innerRef: ref, ...rest });
|
|
56
|
+
}
|
|
57
|
+
if (renderer === "canvas" && executeScriptOnCanvas === true) {
|
|
58
|
+
return /* @__PURE__ */ jsx(ExecutableHtml, { innerRef: ref, code, ...rest });
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ jsx(InnerHtml, { innerRef: ref, code, ...rest });
|
|
61
|
+
});
|
|
62
|
+
HtmlEmbed.displayName = "HtmlEmbed";
|
|
63
|
+
export {
|
|
64
|
+
HtmlEmbed
|
|
65
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EmbedIcon } from "@webstudio-is/icons/svg";
|
|
2
|
+
import { props } from "./__generated__/html-embed.props";
|
|
3
|
+
const meta = {
|
|
4
|
+
category: "general",
|
|
5
|
+
type: "embed",
|
|
6
|
+
label: "HTML Embed",
|
|
7
|
+
icon: EmbedIcon
|
|
8
|
+
};
|
|
9
|
+
const propsMeta = {
|
|
10
|
+
props: {
|
|
11
|
+
...props,
|
|
12
|
+
code: {
|
|
13
|
+
required: true,
|
|
14
|
+
control: "code",
|
|
15
|
+
type: "string",
|
|
16
|
+
rows: 10
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
meta,
|
|
22
|
+
propsMeta
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImageIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { ImageIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { img } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -24,7 +24,7 @@ const meta = {
|
|
|
24
24
|
category: "media",
|
|
25
25
|
type: "embed",
|
|
26
26
|
label: "Image",
|
|
27
|
-
|
|
27
|
+
icon: ImageIcon,
|
|
28
28
|
states: defaultStates,
|
|
29
29
|
presetStyle
|
|
30
30
|
};
|
package/lib/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PropMeta } from "@webstudio-is/generate-arg-types";
|
|
2
1
|
import { meta as SlotMeta } from "./slot.ws";
|
|
3
2
|
import { meta as FragmentMeta } from "./fragment.ws";
|
|
3
|
+
import { meta as HtmlEmbedMeta } from "./html-embed.ws";
|
|
4
4
|
import { meta as BodyMeta } from "./body.ws";
|
|
5
5
|
import { meta as BoxMeta } from "./box.ws";
|
|
6
6
|
import { meta as TextBlockMeta } from "./text-block.ws";
|
|
@@ -22,7 +22,7 @@ import { meta as BlockquoteMeta } from "./blockquote.ws";
|
|
|
22
22
|
import { meta as ListMeta } from "./list.ws";
|
|
23
23
|
import { meta as ListItemMeta } from "./list-item.ws";
|
|
24
24
|
import { meta as SeparatorMeta } from "./separator.ws";
|
|
25
|
-
import { meta as
|
|
25
|
+
import { meta as CodeTextMeta } from "./code-text.ws";
|
|
26
26
|
import { meta as LabelMeta } from "./label.ws";
|
|
27
27
|
import { meta as SuccessMessageMeta } from "./success-message.ws";
|
|
28
28
|
import { meta as ErrorMessageMeta } from "./error-message.ws";
|
|
@@ -33,6 +33,7 @@ import { meta as CheckboxFieldMeta } from "./checkbox-field.ws";
|
|
|
33
33
|
import { meta as CheckboxMeta } from "./checkbox.ws";
|
|
34
34
|
import { propsMeta as SlotMetaPropsMeta } from "./slot.ws";
|
|
35
35
|
import { propsMeta as FragmentMetaPropsMeta } from "./fragment.ws";
|
|
36
|
+
import { propsMeta as HtmlEmbedMetaPropsMeta } from "./html-embed.ws";
|
|
36
37
|
import { propsMeta as BodyMetaPropsMeta } from "./body.ws";
|
|
37
38
|
import { propsMeta as BoxMetaPropsMeta } from "./box.ws";
|
|
38
39
|
import { propsMeta as TextBlockMetaPropsMeta } from "./text-block.ws";
|
|
@@ -54,7 +55,7 @@ import { propsMeta as BlockquotePropsMeta } from "./blockquote.ws";
|
|
|
54
55
|
import { propsMeta as ListPropsMeta } from "./list.ws";
|
|
55
56
|
import { propsMeta as ListItemPropsMeta } from "./list-item.ws";
|
|
56
57
|
import { propsMeta as SeparatorPropsMeta } from "./separator.ws";
|
|
57
|
-
import { propsMeta as
|
|
58
|
+
import { propsMeta as CodeTextPropsMeta } from "./code-text.ws";
|
|
58
59
|
import { propsMeta as LabelPropsMeta } from "./label.ws";
|
|
59
60
|
import { propsMeta as SuccessMessagePropsMeta } from "./success-message.ws";
|
|
60
61
|
import { propsMeta as ErrorMessagePropsMeta } from "./error-message.ws";
|
|
@@ -66,6 +67,7 @@ import { propsMeta as CheckboxPropsMeta } from "./checkbox.ws";
|
|
|
66
67
|
const defaultMetas = {
|
|
67
68
|
Slot: SlotMeta,
|
|
68
69
|
Fragment: FragmentMeta,
|
|
70
|
+
HtmlEmbed: HtmlEmbedMeta,
|
|
69
71
|
Box: BoxMeta,
|
|
70
72
|
Body: BodyMeta,
|
|
71
73
|
TextBlock: TextBlockMeta,
|
|
@@ -87,7 +89,7 @@ const defaultMetas = {
|
|
|
87
89
|
List: ListMeta,
|
|
88
90
|
ListItem: ListItemMeta,
|
|
89
91
|
Separator: SeparatorMeta,
|
|
90
|
-
|
|
92
|
+
CodeText: CodeTextMeta,
|
|
91
93
|
Label: LabelMeta,
|
|
92
94
|
SuccessMessage: SuccessMessageMeta,
|
|
93
95
|
ErrorMessage: ErrorMessageMeta,
|
|
@@ -108,9 +110,10 @@ const registerComponentMetas = (overrides) => {
|
|
|
108
110
|
}
|
|
109
111
|
currentMetas = result;
|
|
110
112
|
};
|
|
111
|
-
const
|
|
113
|
+
const defaultPropsMetas = {
|
|
112
114
|
Slot: SlotMetaPropsMeta,
|
|
113
115
|
Fragment: FragmentMetaPropsMeta,
|
|
116
|
+
HtmlEmbed: HtmlEmbedMetaPropsMeta,
|
|
114
117
|
Box: BoxMetaPropsMeta,
|
|
115
118
|
Body: BodyMetaPropsMeta,
|
|
116
119
|
TextBlock: TextBlockMetaPropsMeta,
|
|
@@ -132,7 +135,7 @@ const defaultPropsMetasRaw = {
|
|
|
132
135
|
List: ListPropsMeta,
|
|
133
136
|
ListItem: ListItemPropsMeta,
|
|
134
137
|
Separator: SeparatorPropsMeta,
|
|
135
|
-
|
|
138
|
+
CodeText: CodeTextPropsMeta,
|
|
136
139
|
Label: LabelPropsMeta,
|
|
137
140
|
SuccessMessage: SuccessMessagePropsMeta,
|
|
138
141
|
ErrorMessage: ErrorMessagePropsMeta,
|
|
@@ -142,59 +145,10 @@ const defaultPropsMetasRaw = {
|
|
|
142
145
|
CheckboxField: CheckboxFieldPropsMeta,
|
|
143
146
|
Checkbox: CheckboxPropsMeta
|
|
144
147
|
};
|
|
145
|
-
const defaultPropsMetas = defaultPropsMetasRaw;
|
|
146
|
-
let registeredPropsMetas = {};
|
|
147
|
-
let currentPropsMetas = void 0;
|
|
148
|
-
const getComponentPropsMeta = (name) => {
|
|
149
|
-
if (currentPropsMetas === void 0) {
|
|
150
|
-
currentPropsMetas = {};
|
|
151
|
-
for (const name2 of Object.keys(defaultPropsMetas)) {
|
|
152
|
-
const props = computeProps(
|
|
153
|
-
defaultPropsMetas[name2],
|
|
154
|
-
registeredPropsMetas[name2] ?? {}
|
|
155
|
-
);
|
|
156
|
-
const initialProps = computeInitialProps(
|
|
157
|
-
props,
|
|
158
|
-
defaultPropsMetas[name2],
|
|
159
|
-
registeredPropsMetas[name2] ?? {}
|
|
160
|
-
);
|
|
161
|
-
currentPropsMetas[name2] = { props, initialProps };
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return currentPropsMetas[name];
|
|
165
|
-
};
|
|
166
|
-
const registerComponentPropsMetas = (metas) => {
|
|
167
|
-
registeredPropsMetas = metas;
|
|
168
|
-
currentPropsMetas = void 0;
|
|
169
|
-
};
|
|
170
148
|
let registeredComponents;
|
|
171
149
|
const registerComponents = (components) => {
|
|
172
150
|
registeredComponents = components;
|
|
173
151
|
};
|
|
174
|
-
const computeProps = (defaults, overrides) => {
|
|
175
|
-
if (overrides) {
|
|
176
|
-
const allNames = (/* @__PURE__ */ new Set([
|
|
177
|
-
...Object.keys(defaults.props ?? {}),
|
|
178
|
-
...Object.keys(overrides?.props ?? {})
|
|
179
|
-
])).values();
|
|
180
|
-
const result = {};
|
|
181
|
-
for (const name of allNames) {
|
|
182
|
-
result[name] = PropMeta.parse({
|
|
183
|
-
...defaults.props[name],
|
|
184
|
-
...overrides?.props?.[name]
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return result;
|
|
188
|
-
}
|
|
189
|
-
return defaults.props;
|
|
190
|
-
};
|
|
191
|
-
const computeInitialProps = (props, defaults, overrides) => {
|
|
192
|
-
const initialProps = overrides?.initialProps ?? defaults?.initialProps ?? [];
|
|
193
|
-
const requiredProps = props ? Object.entries(props).filter(
|
|
194
|
-
([name, value]) => value?.required && initialProps.includes(name) === false
|
|
195
|
-
).map(([name]) => name) : [];
|
|
196
|
-
return [...initialProps, ...requiredProps];
|
|
197
|
-
};
|
|
198
152
|
const canAcceptComponent = (parentComponent, childComponent) => {
|
|
199
153
|
const parentMeta = getComponentMeta(parentComponent);
|
|
200
154
|
const childMeta = getComponentMeta(childComponent);
|
|
@@ -205,10 +159,10 @@ const canAcceptComponent = (parentComponent, childComponent) => {
|
|
|
205
159
|
};
|
|
206
160
|
export {
|
|
207
161
|
canAcceptComponent,
|
|
162
|
+
defaultMetas,
|
|
163
|
+
defaultPropsMetas,
|
|
208
164
|
getComponentMeta,
|
|
209
|
-
getComponentPropsMeta,
|
|
210
165
|
registerComponentMetas,
|
|
211
|
-
registerComponentPropsMetas,
|
|
212
166
|
registerComponents,
|
|
213
167
|
registeredComponents
|
|
214
168
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormTextFieldIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { FormTextFieldIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { input } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -11,7 +11,7 @@ const meta = {
|
|
|
11
11
|
category: "forms",
|
|
12
12
|
type: "control",
|
|
13
13
|
label: "Text Input",
|
|
14
|
-
|
|
14
|
+
icon: FormTextFieldIcon,
|
|
15
15
|
presetStyle,
|
|
16
16
|
states: [
|
|
17
17
|
...defaultStates,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextItalicIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { TextItalicIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
@@ -16,7 +16,7 @@ const presetStyle = {
|
|
|
16
16
|
const meta = {
|
|
17
17
|
type: "rich-text-child",
|
|
18
18
|
label: "Italic Text",
|
|
19
|
-
|
|
19
|
+
icon: TextItalicIcon,
|
|
20
20
|
states: defaultStates,
|
|
21
21
|
presetStyle
|
|
22
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextBlockIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { TextBlockIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
@@ -14,7 +14,7 @@ const meta = {
|
|
|
14
14
|
category: "forms",
|
|
15
15
|
type: "rich-text",
|
|
16
16
|
label: "Input Label",
|
|
17
|
-
|
|
17
|
+
icon: TextBlockIcon,
|
|
18
18
|
states: defaultStates,
|
|
19
19
|
presetStyle,
|
|
20
20
|
children: [{ type: "text", value: "Form Label" }]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LinkBlockIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { LinkBlockIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { props } from "./__generated__/link-block.props";
|
|
3
3
|
import { meta as linkMeta, propsMeta as linkPropsMeta } from "./link.ws";
|
|
4
4
|
import { a } from "../css/normalize";
|
|
@@ -15,7 +15,7 @@ const meta = {
|
|
|
15
15
|
category: "general",
|
|
16
16
|
type: "container",
|
|
17
17
|
label: "Link Block",
|
|
18
|
-
|
|
18
|
+
icon: LinkBlockIcon,
|
|
19
19
|
states: linkMeta.states,
|
|
20
20
|
presetStyle
|
|
21
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LinkIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { LinkIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { a } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -21,7 +21,7 @@ const meta = {
|
|
|
21
21
|
category: "general",
|
|
22
22
|
type: "rich-text",
|
|
23
23
|
label: "Link Text",
|
|
24
|
-
|
|
24
|
+
icon: LinkIcon,
|
|
25
25
|
presetStyle,
|
|
26
26
|
states: [
|
|
27
27
|
...defaultStates,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListItemIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { ListItemIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { li } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -12,7 +12,7 @@ const meta = {
|
|
|
12
12
|
type: "rich-text",
|
|
13
13
|
acceptedParents: ["List"],
|
|
14
14
|
label: "List Item",
|
|
15
|
-
|
|
15
|
+
icon: ListItemIcon,
|
|
16
16
|
children: [{ type: "text", value: "List Item you can edit" }],
|
|
17
17
|
states: defaultStates,
|
|
18
18
|
presetStyle
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { ListIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import {
|
|
3
3
|
defaultStates
|
|
4
4
|
} from "./component-meta";
|
|
@@ -40,7 +40,7 @@ const meta = {
|
|
|
40
40
|
category: "typography",
|
|
41
41
|
type: "container",
|
|
42
42
|
label: "List",
|
|
43
|
-
|
|
43
|
+
icon: ListIcon,
|
|
44
44
|
states: defaultStates,
|
|
45
45
|
presetStyle,
|
|
46
46
|
children: []
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextAlignLeftIcon } from "@webstudio-is/icons";
|
|
1
|
+
import { TextAlignLeftIcon } from "@webstudio-is/icons/svg";
|
|
2
2
|
import { p } from "../css/normalize";
|
|
3
3
|
import {
|
|
4
4
|
defaultStates
|
|
@@ -11,7 +11,7 @@ const meta = {
|
|
|
11
11
|
category: "typography",
|
|
12
12
|
type: "rich-text",
|
|
13
13
|
label: "Paragraph",
|
|
14
|
-
|
|
14
|
+
icon: TextAlignLeftIcon,
|
|
15
15
|
children: [{ type: "text", value: "Pragraph you can edit" }],
|
|
16
16
|
states: defaultStates,
|
|
17
17
|
presetStyle
|