Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

feat: add download property to link component (#4024)

Oleg Isonen4a42c3b11101
diff --git a/packages/sdk-components-react-remix/src/__generated__/body.props.ts b/packages/sdk-components-react-remix/src/__generated__/body.props.ts
index 659b4ec6e0..b22b1021eb 100644
--- a/packages/sdk-components-react-remix/src/__generated__/body.props.ts
+++ b/packages/sdk-components-react-remix/src/__generated__/body.props.ts
@@ -422,6 +422,7 @@ export const props: Record<string, PropMeta> = {
},
datatype: { required: false, control: "text", type: "string" },
defaultChecked: { required: false, control: "boolean", type: "boolean" },
+ defaultValue: { required: false, control: "text", type: "string" },
dir: {
required: false,
control: "text",
diff --git a/packages/sdk-components-react-remix/src/__generated__/link.props.ts b/packages/sdk-components-react-remix/src/__generated__/link.props.ts
index 847de6563b..6dafc3f847 100644
--- a/packages/sdk-components-react-remix/src/__generated__/link.props.ts
+++ b/packages/sdk-components-react-remix/src/__generated__/link.props.ts
@@ -422,6 +422,7 @@ export const props: Record<string, PropMeta> = {
},
datatype: { required: false, control: "text", type: "string" },
defaultChecked: { required: false, control: "boolean", type: "boolean" },
+ defaultValue: { required: false, control: "text", type: "string" },
dir: {
required: false,
control: "text",
@@ -429,6 +430,13 @@ export const props: Record<string, PropMeta> = {
description:
"Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)",
},
+ download: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description:
+ "Indicates that the hyperlink is to be used for downloading a resource.",
+ },
draggable: {
required: false,
control: "boolean",
diff --git a/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.ts b/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.ts
index 8523074801..56101b5b54 100644
--- a/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.ts
+++ b/packages/sdk-components-react-remix/src/__generated__/rich-text-link.props.ts
@@ -422,6 +422,7 @@ export const props: Record<string, PropMeta> = {
},
datatype: { required: false, control: "text", type: "string" },
defaultChecked: { required: false, control: "boolean", type: "boolean" },
+ defaultValue: { required: false, control: "text", type: "string" },
dir: {
required: false,
control: "text",
@@ -429,6 +430,13 @@ export const props: Record<string, PropMeta> = {
description:
"Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)",
},
+ download: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description:
+ "Indicates that the hyperlink is to be used for downloading a resource.",
+ },
draggable: {
required: false,
control: "boolean",
diff --git a/packages/sdk-components-react-remix/src/link.ws.ts b/packages/sdk-components-react-remix/src/link.ws.ts
index fd05f63173..191649790a 100644
--- a/packages/sdk-components-react-remix/src/link.ws.ts
+++ b/packages/sdk-components-react-remix/src/link.ws.ts
@@ -12,5 +12,5 @@ export const propsMeta: WsComponentPropsMeta = {
required: false,
},
},
- initialProps: ["id", "className", "href", "target", "prefetch"],
+ initialProps: ["id", "className", "href", "target", "prefetch", "download"],
};
diff --git a/packages/sdk-components-react/src/__generated__/link.props.ts b/packages/sdk-components-react/src/__generated__/link.props.ts
index b48ad2cc83..371a0ca6d8 100644
--- a/packages/sdk-components-react/src/__generated__/link.props.ts
+++ b/packages/sdk-components-react/src/__generated__/link.props.ts
@@ -430,6 +430,13 @@ export const props: Record<string, PropMeta> = {
description:
"Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)",
},
+ download: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description:
+ "Indicates that the hyperlink is to be used for downloading a resource.",
+ },
draggable: {
required: false,
control: "boolean",
diff --git a/packages/sdk-components-react/src/__generated__/rich-text-link.props.ts b/packages/sdk-components-react/src/__generated__/rich-text-link.props.ts
index b48ad2cc83..371a0ca6d8 100644
--- a/packages/sdk-components-react/src/__generated__/rich-text-link.props.ts
+++ b/packages/sdk-components-react/src/__generated__/rich-text-link.props.ts
@@ -430,6 +430,13 @@ export const props: Record<string, PropMeta> = {
description:
"Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)",
},
+ download: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description:
+ "Indicates that the hyperlink is to be used for downloading a resource.",
+ },
draggable: {
required: false,
control: "boolean",
diff --git a/packages/sdk-components-react/src/image.tsx b/packages/sdk-components-react/src/image.tsx
index e954354b2d..0001f6acf4 100644
--- a/packages/sdk-components-react/src/image.tsx
+++ b/packages/sdk-components-react/src/image.tsx
@@ -22,6 +22,7 @@ export const Image = forwardRef<
height,
optimize = true,
decoding: decodingProp,
+ // @todo: it's a hack made for the builder and should't be in the runtime at all.
$webstudio$canvasOnly$assetId,
...props
},
diff --git a/packages/sdk-components-react/src/link.tsx b/packages/sdk-components-react/src/link.tsx
index 98e1b965fd..4347efe6de 100644
--- a/packages/sdk-components-react/src/link.tsx
+++ b/packages/sdk-components-react/src/link.tsx
@@ -2,19 +2,27 @@ import { forwardRef, type ComponentProps } from "react";
export const defaultTag = "a";
-type Props = Omit<ComponentProps<"a">, "target"> & {
+type Props = Omit<ComponentProps<"a">, "target" | "download"> & {
// override (string & {}) in target to generate keywords
target?: "_self" | "_blank" | "_parent" | "_top";
+ download?: boolean;
};
-export const Link = forwardRef<HTMLAnchorElement, Props>(
- ({ children, ...props }, ref) => {
- return (
- <a {...props} href={props.href ?? "#"} ref={ref}>
- {children}
- </a>
- );
- }
-);
+export const Link = forwardRef<
+ HTMLAnchorElement,
+ Props & { $webstudio$canvasOnly$assetId?: string | undefined }
+>((props, ref) => {
+ const {
+ children,
+ // @todo: it's a hack made for Image component for the builder and should't be in the runtime at all.
+ $webstudio$canvasOnly$assetId,
+ ...rest
+ } = props;
+ return (
+ <a {...rest} href={rest.href ?? "#"} ref={ref}>
+ {children}
+ </a>
+ );
+});
Link.displayName = "Link";
diff --git a/packages/sdk-components-react/src/link.ws.ts b/packages/sdk-components-react/src/link.ws.ts
index 9ee59481ce..6315d9fb8f 100644
--- a/packages/sdk-components-react/src/link.ws.ts
+++ b/packages/sdk-components-react/src/link.ws.ts
@@ -68,5 +68,5 @@ export const propsMeta: WsComponentPropsMeta = {
required: false,
},
},
- initialProps: ["id", "className", "href", "target"],
+ initialProps: ["id", "className", "href", "target", "download"],
};