|
1 | 1 | import { useMemo, useEffect, useState, useLayoutEffect, useRef } from "react";
|
2 | 2 | import { ErrorBoundary, type FallbackProps } from "react-error-boundary";
|
3 | 3 | import { useStore } from "@nanostores/react";
|
4 |
| -import { type Instances, coreMetas, corePropsMetas } from "@webstudio-is/sdk"; |
| 4 | +import { |
| 5 | + type Instances, |
| 6 | + PropMeta, |
| 7 | + coreMetas, |
| 8 | + corePropsMetas, |
| 9 | +} from "@webstudio-is/sdk"; |
5 | 10 | import { coreTemplates } from "@webstudio-is/sdk/core-templates";
|
6 | 11 | import type { Components } from "@webstudio-is/react-sdk";
|
7 | 12 | import { wsImageLoader } from "@webstudio-is/image";
|
@@ -239,16 +244,31 @@ export const Canvas = () => {
|
239 | 244 | propsMetas: Object.fromEntries(
|
240 | 245 | Object.entries(baseComponentPropsMetas).map(
|
241 | 246 | ([component, propsMeta]) => {
|
242 |
| - propsMeta.props.comment = { |
243 |
| - type: "string", |
244 |
| - control: "text", |
245 |
| - required: false, |
246 |
| - description: |
247 |
| - "Describe the behavior of this layer and optionally its children.", |
248 |
| - maxRows: 20, |
| 247 | + const globalProps: Record<string, PropMeta> = { |
| 248 | + comment: { |
| 249 | + type: "string", |
| 250 | + control: "text", |
| 251 | + required: false, |
| 252 | + description: |
| 253 | + "Describe the behavior of this layer and optionally its children.", |
| 254 | + maxRows: 20, |
| 255 | + }, |
| 256 | + callsFunctionOnClick: { |
| 257 | + type: "boolean", |
| 258 | + control: "boolean", |
| 259 | + required: false, |
| 260 | + description: |
| 261 | + "When true, this layer calls a component prop when clicked.", |
| 262 | + }, |
249 | 263 | };
|
250 |
| - propsMeta.initialProps ??= []; |
251 |
| - propsMeta.initialProps.push("comment"); |
| 264 | + |
| 265 | + Object.assign(propsMeta.props, globalProps); |
| 266 | + |
| 267 | + const initialProps = (propsMeta.initialProps ??= []); |
| 268 | + Object.keys(globalProps).forEach((key) => { |
| 269 | + initialProps.push(key); |
| 270 | + }); |
| 271 | + |
252 | 272 | return [component, propsMeta];
|
253 | 273 | }
|
254 | 274 | )
|
|
0 commit comments