@pairdraw/core 0.21.1 → 0.22.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/dist/canvas/boolean.d.ts +6 -1
- package/dist/canvas/boolean.d.ts.map +1 -1
- package/dist/canvas/boolean.js +10 -2
- package/dist/canvas/boolean.js.map +1 -1
- package/dist/canvas/color-space.d.ts +45 -0
- package/dist/canvas/color-space.d.ts.map +1 -0
- package/dist/canvas/color-space.js +39 -0
- package/dist/canvas/color-space.js.map +1 -0
- package/dist/canvas/fills.d.ts +10 -10
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +116 -62
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/flatten.d.ts +11 -3
- package/dist/canvas/flatten.d.ts.map +1 -1
- package/dist/canvas/flatten.js +62 -4
- package/dist/canvas/flatten.js.map +1 -1
- package/dist/canvas/index.d.ts +2 -1
- package/dist/canvas/index.js +2 -1
- package/dist/canvas/layout-grids.d.ts +5 -2
- package/dist/canvas/layout-grids.d.ts.map +1 -1
- package/dist/canvas/layout-grids.js +7 -2
- package/dist/canvas/layout-grids.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +17 -4
- package/dist/canvas/noise/render.d.ts.map +1 -1
- package/dist/canvas/noise/render.js +21 -6
- package/dist/canvas/noise/render.js.map +1 -1
- package/dist/canvas/noise/shader.d.ts +4 -4
- package/dist/canvas/noise/shader.d.ts.map +1 -1
- package/dist/canvas/noise/shader.js +5 -6
- package/dist/canvas/noise/shader.js.map +1 -1
- package/dist/canvas/overlays/annotations.d.ts +19 -0
- package/dist/canvas/overlays/annotations.d.ts.map +1 -0
- package/dist/canvas/overlays/annotations.js +110 -0
- package/dist/canvas/overlays/annotations.js.map +1 -0
- package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +25 -1
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/feedback.js +1 -1
- package/dist/canvas/overlays/feedback.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/measurement.d.ts +7 -1
- package/dist/canvas/overlays/measurement.d.ts.map +1 -1
- package/dist/canvas/overlays/measurement.js +42 -4
- package/dist/canvas/overlays/measurement.js.map +1 -1
- package/dist/canvas/overlays/presence.d.ts.map +1 -1
- package/dist/canvas/overlays/presence.js +21 -24
- package/dist/canvas/overlays/presence.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts +7 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +9 -1
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +15 -6
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
- package/dist/canvas/renderer/document-surface.js +1 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +2 -2
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +1 -0
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +4 -1
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +6 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +7 -0
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +10 -0
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +10 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +15 -3
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +9 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/clipboard/pairdraw.d.ts.map +1 -1
- package/dist/clipboard/pairdraw.js +1 -0
- package/dist/clipboard/pairdraw.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +2 -0
- package/dist/editor/bridges/clipboard.d.ts.map +1 -1
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +14 -7
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +6 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -1
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/clipboard/code.d.ts +32 -0
- package/dist/editor/clipboard/code.d.ts.map +1 -0
- package/dist/editor/clipboard/code.js +30 -0
- package/dist/editor/clipboard/code.js.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.js +0 -0
- package/dist/editor/clipboard/paste/run.d.ts +14 -0
- package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/run.js +47 -0
- package/dist/editor/clipboard/paste/run.js.map +1 -0
- package/dist/editor/clipboard/styled.d.ts +2 -8
- package/dist/editor/clipboard/styled.d.ts.map +1 -1
- package/dist/editor/clipboard/styled.js +2 -32
- package/dist/editor/clipboard/styled.js.map +1 -1
- package/dist/editor/clipboard.d.ts +2 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +34 -0
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +5 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +69 -4
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/slots/index.d.ts.map +1 -1
- package/dist/editor/components/slots/index.js +7 -0
- package/dist/editor/components/slots/index.js.map +1 -1
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.js +14 -2
- package/dist/editor/components.js.map +1 -1
- package/dist/editor/create.d.ts +29 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +11 -2
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-tokens.d.ts +1 -1
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +4 -18
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/image-edit.d.ts.map +1 -1
- package/dist/editor/image-edit.js +1 -2
- package/dist/editor/image-edit.js.map +1 -1
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts +3 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +97 -2
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/nodes.d.ts +2 -0
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +22 -7
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts +1 -0
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +7 -0
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +8 -0
- package/dist/editor/selection.d.ts +9 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/state/shared.js +1 -0
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/state/view.d.ts.map +1 -1
- package/dist/editor/state/view.js +2 -0
- package/dist/editor/state/view.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +1 -1
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js +20 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/container-wrap.d.ts +8 -2
- package/dist/editor/structure/container-wrap.d.ts.map +1 -1
- package/dist/editor/structure/container-wrap.js +17 -5
- package/dist/editor/structure/container-wrap.js.map +1 -1
- package/dist/editor/structure/flatten.d.ts.map +1 -1
- package/dist/editor/structure/flatten.js +8 -7
- package/dist/editor/structure/flatten.js.map +1 -1
- package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
- package/dist/editor/structure/group/ungroup.js +2 -0
- package/dist/editor/structure/group/ungroup.js.map +1 -1
- package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
- package/dist/editor/structure/outline-stroke.js +5 -0
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -1
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/styles.d.ts +26 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/styles.js +127 -0
- package/dist/editor/styles.js.map +1 -0
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +10 -2
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +6 -0
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +14 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +6 -1
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +22 -1
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/shape.js +1 -1
- package/dist/figma-api/accessors/text/index.js +1 -1
- package/dist/figma-api/accessors/text/ranges.js +1 -1
- package/dist/figma-api/accessors/text/references.js +1 -1
- package/dist/figma-api/accessors/variables.js +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +8 -22
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.js +1 -1
- package/dist/figma-api/compatibility.d.ts +1 -1
- package/dist/figma-api/compatibility.d.ts.map +1 -1
- package/dist/figma-api/component-scope.d.ts +14 -0
- package/dist/figma-api/component-scope.d.ts.map +1 -0
- package/dist/figma-api/component-scope.js +28 -0
- package/dist/figma-api/component-scope.js.map +1 -0
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +26 -2
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/flatten.js +3 -3
- package/dist/figma-api/flatten.js.map +1 -1
- package/dist/figma-api/index.d.ts +77 -6
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +188 -2
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/node-types.d.ts +2 -1
- package/dist/figma-api/node-types.d.ts.map +1 -1
- package/dist/figma-api/overrides.d.ts +26 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +157 -10
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +2 -0
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +10 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +61 -5
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +144 -11
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/shape-with-text.js +1 -1
- package/dist/figma-api/slots.d.ts +3 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +9 -8
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/io/formats/code/detect.d.ts +23 -0
- package/dist/io/formats/code/detect.d.ts.map +1 -0
- package/dist/io/formats/code/detect.js +46 -0
- package/dist/io/formats/code/detect.js.map +1 -0
- package/dist/io/formats/code/index.d.ts +5 -0
- package/dist/io/formats/code/index.js +5 -0
- package/dist/io/formats/code/read.d.ts +45 -0
- package/dist/io/formats/code/read.d.ts.map +1 -0
- package/dist/io/formats/code/read.js +86 -0
- package/dist/io/formats/code/read.js.map +1 -0
- package/dist/io/formats/code/stylesheet.d.ts +13 -0
- package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
- package/dist/io/formats/code/stylesheet.js +21 -0
- package/dist/io/formats/code/stylesheet.js.map +1 -0
- package/dist/io/formats/code/tokens.d.ts +18 -0
- package/dist/io/formats/code/tokens.d.ts.map +1 -0
- package/dist/io/formats/code/tokens.js +135 -0
- package/dist/io/formats/code/tokens.js.map +1 -0
- package/dist/io/formats/design-tokens/apply.d.ts +7 -3
- package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/apply.js.map +1 -1
- package/dist/io/formats/fig/export/patch/fields.js +5 -0
- package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +20 -20
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +5 -1
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +3 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +5 -2
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +3 -1
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +6 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +7 -3
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/plan.d.ts +3 -0
- package/dist/io/formats/pdf/plan.d.ts.map +1 -1
- package/dist/io/formats/pdf/plan.js +60 -36
- package/dist/io/formats/pdf/plan.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +3 -2
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +10 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +35 -9
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +19 -1
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts +5 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +59 -10
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/index.d.ts +2 -2
- package/dist/io/formats/svg/index.js +2 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +4 -2
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/record.d.ts.map +1 -1
- package/dist/io/formats/video/record.js +24 -9
- package/dist/io/formats/video/record.js.map +1 -1
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +20 -13
- package/dist/io/formats.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +2 -1
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +46 -2
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +113 -5
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/options.d.ts +4 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +8 -4
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.js +1 -1
- package/dist/layout/auto-layout-handles.js.map +1 -1
- package/dist/layout/axis-sizing.d.ts.map +1 -1
- package/dist/layout/axis-sizing.js +1 -1
- package/dist/layout/axis-sizing.js.map +1 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +1 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/effective-generated-text.js +1 -1
- package/dist/layout/effective-generated-text.js.map +1 -1
- package/dist/layout/grid.d.ts +3 -1
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +57 -16
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +6 -5
- package/dist/layout.js.map +1 -1
- package/dist/node/fs.d.ts.map +1 -1
- package/dist/node/fs.js +28 -7
- package/dist/node/fs.js.map +1 -1
- package/dist/prototype/easing.d.ts +13 -5
- package/dist/prototype/easing.d.ts.map +1 -1
- package/dist/prototype/easing.js +46 -6
- package/dist/prototype/easing.js.map +1 -1
- package/dist/prototype/scenes.d.ts +31 -0
- package/dist/prototype/scenes.d.ts.map +1 -1
- package/dist/prototype/scenes.js +220 -31
- package/dist/prototype/scenes.js.map +1 -1
- package/dist/prototype/session.d.ts.map +1 -1
- package/dist/prototype/session.js +1 -0
- package/dist/prototype/session.js.map +1 -1
- package/dist/prototype/smart-animate/animation.d.ts +2 -1
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
- package/dist/prototype/smart-animate/animation.js +2 -2
- package/dist/prototype/smart-animate/animation.js.map +1 -1
- package/dist/prototype/timeline.d.ts +10 -1
- package/dist/prototype/timeline.d.ts.map +1 -1
- package/dist/prototype/timeline.js +69 -23
- package/dist/prototype/timeline.js.map +1 -1
- package/dist/prototype/variables.d.ts +23 -0
- package/dist/prototype/variables.d.ts.map +1 -0
- package/dist/prototype/variables.js +237 -0
- package/dist/prototype/variables.js.map +1 -0
- package/dist/rpc/read-commands.d.ts +5 -0
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +4 -1
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/character-style.d.ts +8 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +39 -1
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/index.d.ts +2 -2
- package/dist/text/index.js +2 -2
- package/dist/tools/create/basic.js +3 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/code.d.ts +6 -0
- package/dist/tools/create/code.d.ts.map +1 -0
- package/dist/tools/create/code.js +68 -0
- package/dist/tools/create/code.js.map +1 -0
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +9 -57
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.js +1 -1
- package/dist/tools/create/inputs.d.ts +11 -0
- package/dist/tools/create/inputs.d.ts.map +1 -0
- package/dist/tools/create/inputs.js +15 -0
- package/dist/tools/create/inputs.js.map +1 -0
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +5 -6
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/place.d.ts +30 -0
- package/dist/tools/create/place.d.ts.map +1 -0
- package/dist/tools/create/place.js +70 -0
- package/dist/tools/create/place.js.map +1 -0
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/create.d.ts +2 -1
- package/dist/tools/create.js +2 -1
- package/dist/tools/css/gradient.d.ts +28 -0
- package/dist/tools/css/gradient.d.ts.map +1 -0
- package/dist/tools/css/gradient.js +118 -0
- package/dist/tools/css/gradient.js.map +1 -0
- package/dist/tools/image-ai/generate.js +1 -1
- package/dist/tools/modify/geometry.js +5 -5
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +7 -1
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/overrides.d.ts +6 -0
- package/dist/tools/modify/overrides.d.ts.map +1 -0
- package/dist/tools/modify/overrides.js +27 -0
- package/dist/tools/modify/overrides.js.map +1 -0
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +84 -39
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/text.d.ts +2 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +79 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +18 -2
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +3 -2
- package/dist/tools/modify.js +3 -2
- package/dist/tools/read/css.d.ts.map +1 -1
- package/dist/tools/read/css.js +29 -12
- package/dist/tools/read/css.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +19 -5
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/text-range.d.ts +11 -0
- package/dist/tools/text-range.d.ts.map +1 -0
- package/dist/tools/text-range.js +26 -0
- package/dist/tools/text-range.js.map +1 -0
- package/dist/tools/variables/bindings.js +1 -1
- package/dist/tools/variables/bindings.js.map +1 -1
- package/dist/tools/variables/unbind.js +1 -1
- package/dist/tools/variables/unbind.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +7 -21
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/vector/rebase.d.ts +17 -0
- package/dist/vector/rebase.d.ts.map +1 -0
- package/dist/vector/rebase.js +32 -0
- package/dist/vector/rebase.js.map +1 -0
- package/package.json +14 -9
- package/src/canvas/boolean.ts +12 -1
- package/src/canvas/color-space.ts +73 -0
- package/src/canvas/fills.ts +130 -83
- package/src/canvas/flatten.ts +92 -7
- package/src/canvas/index.ts +9 -0
- package/src/canvas/layout-grids.ts +15 -2
- package/src/canvas/noise/render.ts +35 -7
- package/src/canvas/noise/shader.ts +8 -10
- package/src/canvas/overlays/annotations.ts +117 -0
- package/src/canvas/overlays/auto-layout-hover.ts +41 -1
- package/src/canvas/overlays/feedback.ts +7 -2
- package/src/canvas/overlays/index.ts +1 -1
- package/src/canvas/overlays/measurement.ts +49 -3
- package/src/canvas/overlays/presence.ts +35 -32
- package/src/canvas/renderer/colors.ts +14 -0
- package/src/canvas/renderer/document-surface.ts +16 -6
- package/src/canvas/renderer/lifecycle.ts +2 -2
- package/src/canvas/renderer/methods.ts +4 -0
- package/src/canvas/renderer/overlay-pass.ts +4 -0
- package/src/canvas/renderer/pipeline.ts +8 -0
- package/src/canvas/renderer/types.ts +8 -0
- package/src/canvas/renderer.ts +21 -2
- package/src/canvas/scene.ts +15 -7
- package/src/clipboard/pairdraw.ts +1 -0
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +10 -0
- package/src/editor/clipboard/code.ts +50 -0
- package/src/editor/clipboard/paste/dependencies.ts +18 -0
- package/src/editor/clipboard/paste/run.ts +64 -0
- package/src/editor/clipboard/styled.ts +4 -52
- package/src/editor/clipboard.ts +40 -0
- package/src/editor/components/instances.ts +92 -4
- package/src/editor/components/slots/index.ts +7 -0
- package/src/editor/components.ts +16 -2
- package/src/editor/create.ts +15 -1
- package/src/editor/design-tokens.ts +3 -23
- package/src/editor/image-edit.ts +5 -2
- package/src/editor/index.ts +1 -0
- package/src/editor/layout-mode.ts +131 -3
- package/src/editor/nodes.ts +30 -5
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/selection/overlays.ts +8 -0
- package/src/editor/state/shared.ts +1 -0
- package/src/editor/state/view.ts +2 -0
- package/src/editor/structure/boolean.ts +29 -1
- package/src/editor/structure/container-wrap.ts +20 -4
- package/src/editor/structure/flatten.ts +15 -8
- package/src/editor/structure/group/ungroup.ts +2 -0
- package/src/editor/structure/outline-stroke.ts +5 -0
- package/src/editor/styles.ts +203 -0
- package/src/editor/text/selection-style.ts +18 -1
- package/src/editor/tool-registry.ts +2 -0
- package/src/editor/types.ts +14 -0
- package/src/editor/variable-bindings.ts +11 -0
- package/src/figma-api/accessors/basic.ts +33 -1
- package/src/figma-api/accessors/vector.ts +6 -13
- package/src/figma-api/compatibility.ts +1 -0
- package/src/figma-api/component-scope.ts +36 -0
- package/src/figma-api/components.ts +24 -0
- package/src/figma-api/flatten.ts +7 -3
- package/src/figma-api/index.ts +302 -6
- package/src/figma-api/node-types.ts +1 -0
- package/src/figma-api/overrides.ts +192 -5
- package/src/figma-api/proxy.ts +16 -1
- package/src/figma-api/reactions.ts +163 -12
- package/src/figma-api/slots.ts +10 -9
- package/src/io/formats/code/detect.ts +67 -0
- package/src/io/formats/code/index.ts +17 -0
- package/src/io/formats/code/read.ts +143 -0
- package/src/io/formats/code/stylesheet.ts +24 -0
- package/src/io/formats/code/tokens.ts +159 -0
- package/src/io/formats/design-tokens/apply.ts +3 -2
- package/src/io/formats/fig/export/patch/fields.ts +11 -0
- package/src/io/formats/fig/export/patch/index.ts +23 -19
- package/src/io/formats/fig/export/setup.ts +8 -1
- package/src/io/formats/fig/index.ts +6 -0
- package/src/io/formats/fig/read.ts +11 -2
- package/src/io/formats/html/layers.ts +7 -0
- package/src/io/formats/pdf/export.ts +19 -7
- package/src/io/formats/pdf/plan.ts +71 -32
- package/src/io/formats/raster/headless.ts +3 -1
- package/src/io/formats/raster/index.ts +2 -0
- package/src/io/formats/raster/render.ts +49 -9
- package/src/io/formats/svg/defs.ts +27 -1
- package/src/io/formats/svg/export.ts +75 -13
- package/src/io/formats/svg/index.ts +1 -0
- package/src/io/formats/svg/text/layout.ts +5 -3
- package/src/io/formats/video/record.ts +33 -9
- package/src/io/formats.ts +35 -15
- package/src/kiwi/fig/population/client.ts +6 -1
- package/src/kiwi/fig/session/document-state.ts +195 -5
- package/src/kiwi/fig/session/options.ts +2 -0
- package/src/layout/apply.ts +12 -4
- package/src/layout/auto-layout-handles.ts +1 -1
- package/src/layout/axis-sizing.ts +3 -1
- package/src/layout/derived.ts +3 -1
- package/src/layout/effective-generated-text.ts +1 -1
- package/src/layout/grid.ts +91 -21
- package/src/layout.ts +16 -3
- package/src/node/fs.ts +32 -7
- package/src/prototype/easing.ts +79 -7
- package/src/prototype/scenes.ts +244 -15
- package/src/prototype/session.ts +1 -0
- package/src/prototype/smart-animate/animation.ts +4 -3
- package/src/prototype/timeline.ts +118 -26
- package/src/prototype/variables.ts +189 -0
- package/src/rpc/read-commands.ts +19 -1
- package/src/text/character-style.ts +47 -0
- package/src/text/index.ts +1 -1
- package/src/tools/create/basic.ts +2 -3
- package/src/tools/create/code.ts +85 -0
- package/src/tools/create/html.ts +9 -46
- package/src/tools/create/inputs.ts +12 -0
- package/src/tools/create/mermaid.ts +6 -6
- package/src/tools/create/place.ts +80 -0
- package/src/tools/create.ts +1 -0
- package/src/tools/css/gradient.ts +147 -0
- package/src/tools/modify/geometry.ts +5 -5
- package/src/tools/modify/layout.ts +19 -0
- package/src/tools/modify/overrides.ts +35 -0
- package/src/tools/modify/paint.ts +124 -54
- package/src/tools/modify/text.ts +91 -7
- package/src/tools/modify/update.ts +23 -2
- package/src/tools/modify.ts +9 -1
- package/src/tools/read/css.ts +46 -12
- package/src/tools/read/nodes.ts +26 -4
- package/src/tools/registry/extended.ts +6 -0
- package/src/tools/text-range.ts +29 -0
- package/src/tools/variables/bindings.ts +4 -1
- package/src/tools/variables/unbind.ts +4 -1
- package/src/tools/vector/path.ts +11 -13
- package/src/vector/rebase.ts +33 -0
package/src/canvas/scene.ts
CHANGED
|
@@ -82,9 +82,10 @@ function drawVisibleFills(
|
|
|
82
82
|
r: SkiaRenderer,
|
|
83
83
|
node: SceneNode,
|
|
84
84
|
graph: SceneGraph,
|
|
85
|
+
canvas: Canvas,
|
|
85
86
|
draw: (fill: Fill) => void
|
|
86
87
|
): void {
|
|
87
|
-
paintFills(r, node.fills, node, graph, draw)
|
|
88
|
+
paintFills(r, node.fills, node, graph, draw, { canvas })
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
function hasNodeTransform(node: SceneNode): boolean {
|
|
@@ -339,6 +340,7 @@ export function renderNodeSelf(
|
|
|
339
340
|
node.internalOnly ||
|
|
340
341
|
!node.visible ||
|
|
341
342
|
node.isMask ||
|
|
343
|
+
node.type === 'SLICE' ||
|
|
342
344
|
fontManager.isNodeBlocked(nodeId)
|
|
343
345
|
) {
|
|
344
346
|
return
|
|
@@ -347,7 +349,7 @@ export function renderNodeSelf(
|
|
|
347
349
|
canvas.translate(node.x, node.y)
|
|
348
350
|
applyNodeTransforms(canvas, node, overlays)
|
|
349
351
|
renderNodeContent(r, canvas, graph, node, overlays)
|
|
350
|
-
drawLayoutGrids(r, canvas, node)
|
|
352
|
+
drawLayoutGrids(r, canvas, node, overlays)
|
|
351
353
|
canvas.restore()
|
|
352
354
|
}
|
|
353
355
|
|
|
@@ -412,7 +414,13 @@ function reportNodeDrawFailure(renderer: SkiaRenderer, nodeId: string, error: un
|
|
|
412
414
|
* node-edit mode, or left to a live island while the canvas previews.
|
|
413
415
|
*/
|
|
414
416
|
function drawsNode(node: SceneNode, overlays: RenderOverlays): boolean {
|
|
415
|
-
if (
|
|
417
|
+
if (
|
|
418
|
+
node.internalOnly ||
|
|
419
|
+
!node.visible ||
|
|
420
|
+
node.isMask ||
|
|
421
|
+
node.type === 'SLICE' ||
|
|
422
|
+
fontManager.isNodeBlocked(node.id)
|
|
423
|
+
)
|
|
416
424
|
return false
|
|
417
425
|
return overlays.nodeEditState?.nodeId !== node.id && !overlays.playIslands?.has(node.id)
|
|
418
426
|
}
|
|
@@ -494,7 +502,7 @@ export function renderNode(
|
|
|
494
502
|
if (shaderEffects.length > 0) {
|
|
495
503
|
drawShaderEffectChain(r, canvas, graph, node, shaderEffects, (target) => {
|
|
496
504
|
renderNodeContent(r, target, graph, node, overlays)
|
|
497
|
-
drawLayoutGrids(r, target, node)
|
|
505
|
+
drawLayoutGrids(r, target, node, overlays)
|
|
498
506
|
renderChildren(
|
|
499
507
|
r,
|
|
500
508
|
target,
|
|
@@ -508,7 +516,7 @@ export function renderNode(
|
|
|
508
516
|
})
|
|
509
517
|
} else {
|
|
510
518
|
renderNodeContent(r, canvas, graph, node, overlays)
|
|
511
|
-
drawLayoutGrids(r, canvas, node)
|
|
519
|
+
drawLayoutGrids(r, canvas, node, overlays)
|
|
512
520
|
renderChildren(
|
|
513
521
|
r,
|
|
514
522
|
canvas,
|
|
@@ -586,7 +594,7 @@ function fillRoundedBounds(
|
|
|
586
594
|
graph: SceneGraph
|
|
587
595
|
): Float32Array {
|
|
588
596
|
const rrect = makeNodeRRect(r, node, node.cornerRadius)
|
|
589
|
-
drawVisibleFills(r, node, graph, () => canvas.drawRRect(rrect, r.fillPaint))
|
|
597
|
+
drawVisibleFills(r, node, graph, canvas, () => canvas.drawRRect(rrect, r.fillPaint))
|
|
590
598
|
return rrect
|
|
591
599
|
}
|
|
592
600
|
|
|
@@ -1175,7 +1183,7 @@ export function paintShapeContent(
|
|
|
1175
1183
|
const isolated = afterFills !== undefined && isolatesInnerShadows(node)
|
|
1176
1184
|
if (isolated) canvas.saveLayer()
|
|
1177
1185
|
if (!drawVectorMultiStyleFills(r, canvas, node, graph)) {
|
|
1178
|
-
drawVisibleFills(r, node, graph, (fill) => r.drawNodeFill(canvas, node, fill))
|
|
1186
|
+
drawVisibleFills(r, node, graph, canvas, (fill) => r.drawNodeFill(canvas, node, fill))
|
|
1179
1187
|
}
|
|
1180
1188
|
if (node.type === 'TEXT') drawTextEmoji(r, canvas, node)
|
|
1181
1189
|
afterFills?.()
|
|
@@ -21,6 +21,7 @@ export function createClipboardBridge(clipboard: ClipboardActions, selection: Se
|
|
|
21
21
|
pasteSVG: clipboard.pasteSVG,
|
|
22
22
|
pasteMermaid: clipboard.pasteMermaid,
|
|
23
23
|
pasteStyledDocument: clipboard.pasteStyledDocument,
|
|
24
|
+
pasteCode: clipboard.pasteCode,
|
|
24
25
|
loadFontsForNodes: clipboard.loadFontsForNodes,
|
|
25
26
|
copySelectionAsText: clipboard.copySelectionAsText,
|
|
26
27
|
copySelectionAsSVG: clipboard.copySelectionAsSVG,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
|
|
1
3
|
import type { createComponentActions } from '#core/editor/components'
|
|
2
4
|
import type { createPageActions } from '#core/editor/pages'
|
|
3
5
|
import type { createSelectionActions } from '#core/editor/selection'
|
|
@@ -25,12 +27,20 @@ export function createComponentBridge(
|
|
|
25
27
|
selection.getSelectedNodes(),
|
|
26
28
|
structure.wrapSelectionInContainer
|
|
27
29
|
),
|
|
30
|
+
canCombineComponentsAsVariants: (nodes: readonly SceneNode[]) =>
|
|
31
|
+
components.canCombineComponentsAsVariants(nodes),
|
|
28
32
|
createInstanceFromComponent: components.createInstanceFromComponent,
|
|
29
33
|
detachInstance: () => components.detachInstance(selection.getSelectedNode()),
|
|
30
34
|
instanceHasOverrides: components.instanceHasOverrides,
|
|
31
35
|
canPushInstanceOverrides: (id: string) => components.canPushInstanceOverrides(id),
|
|
32
36
|
pushInstanceOverrides: (id: string) => components.pushInstanceOverrides(id),
|
|
33
37
|
resetInstanceOverrides: (id: string) => components.resetInstanceOverrides(id),
|
|
38
|
+
layerHasOverrides: components.layerHasOverrides,
|
|
39
|
+
canOverrideFields: components.canOverrideFields,
|
|
40
|
+
overriddenFields: components.overriddenFields,
|
|
41
|
+
resetLayerOverrides: (id: string) => components.resetLayerOverrides(id),
|
|
42
|
+
resetLayerOverrideFields: (id: string, fields: readonly string[]) =>
|
|
43
|
+
components.resetLayerOverrideFields(id, fields),
|
|
34
44
|
canConvertToFrame: components.canConvertToFrame,
|
|
35
45
|
componentInstanceCount: components.componentInstanceCount,
|
|
36
46
|
requestComponentToFrame: components.requestComponentToFrame,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
3
|
+
|
|
4
|
+
import type { EditorContext } from '#core/editor/types'
|
|
5
|
+
import { bindCodeTokens, codeLayerNodes } from '#core/io/formats/code'
|
|
6
|
+
|
|
7
|
+
import type { PasteDependencies } from './paste/dependencies'
|
|
8
|
+
import { placePastedLayers } from './paste/run'
|
|
9
|
+
|
|
10
|
+
/** What a pasted code layer tree could not keep, plus what the target document bound. */
|
|
11
|
+
export interface CodePasteReport {
|
|
12
|
+
placeholders: number
|
|
13
|
+
componentsAsFrames: number
|
|
14
|
+
droppedProps: number
|
|
15
|
+
approximations: number
|
|
16
|
+
imagesAsPlaceholders: number
|
|
17
|
+
layers: number
|
|
18
|
+
variantsStripped: number
|
|
19
|
+
tokensBound: number
|
|
20
|
+
tokensAmbiguous: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface CodePasteResult {
|
|
24
|
+
ids: string[]
|
|
25
|
+
report: CodePasteReport
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Paste of the layers a pasted JSX or HTML source draws: the target document's variables bind to
|
|
30
|
+
* matching colours and numbers first, then the layers land as any foreign paste does, in one undo
|
|
31
|
+
* step, and the report says what the paste could not keep.
|
|
32
|
+
*/
|
|
33
|
+
export function createCodePasteActions(ctx: EditorContext, deps: PasteDependencies) {
|
|
34
|
+
async function pasteCode(
|
|
35
|
+
source: SceneGraph,
|
|
36
|
+
report: CodePasteReport,
|
|
37
|
+
cursorPos?: Vector
|
|
38
|
+
): Promise<CodePasteResult> {
|
|
39
|
+
const created = placePastedLayers(ctx, deps, source, 'Paste code', cursorPos, (ids) => {
|
|
40
|
+
// Bound after the transfer: the layers now hold the document's own variable IDs.
|
|
41
|
+
bindCodeTokens(codeLayerNodes(ctx.graph, ids), ctx.graph, report)
|
|
42
|
+
})
|
|
43
|
+
if (created.length === 0) return { ids: created, report }
|
|
44
|
+
await deps.loadFontsForNodes(created)
|
|
45
|
+
ctx.requestRender()
|
|
46
|
+
return { ids: created, report }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { pasteCode }
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
2
|
+
|
|
3
|
+
import type { PasteHistoryOperation } from './replace'
|
|
4
|
+
|
|
5
|
+
/** The undo entry a paste pushes once its layers are in the document. */
|
|
6
|
+
export type PushCreatedNodesUndo = (
|
|
7
|
+
created: string[],
|
|
8
|
+
previousSelection: Set<string>,
|
|
9
|
+
label?: string,
|
|
10
|
+
operation?: PasteHistoryOperation
|
|
11
|
+
) => void
|
|
12
|
+
|
|
13
|
+
/** What a clipboard paste needs from its host, shared by the code and styled-HTML pastes. */
|
|
14
|
+
export interface PasteDependencies {
|
|
15
|
+
pushCreatedNodesUndo: PushCreatedNodesUndo
|
|
16
|
+
placeForeignPaste: (nodeIds: string[], parentId: string, cursor?: Vector) => void
|
|
17
|
+
loadFontsForNodes: (nodeIds: string[]) => Promise<unknown>
|
|
18
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
3
|
+
import {
|
|
4
|
+
applyGraphTransfer,
|
|
5
|
+
captureTransferredState,
|
|
6
|
+
prepareGraphTransfer,
|
|
7
|
+
removeGraphTransfer
|
|
8
|
+
} from '@pairdraw/scene-graph/transfer'
|
|
9
|
+
|
|
10
|
+
import { resolvePasteTarget } from '#core/editor/clipboard/paste/target'
|
|
11
|
+
import { prepareSlotEdits } from '#core/editor/components/slots'
|
|
12
|
+
import type { EditorContext } from '#core/editor/types'
|
|
13
|
+
import { computeAllLayouts, layoutAuthoredNodes } from '#core/layout'
|
|
14
|
+
|
|
15
|
+
import type { PasteDependencies } from './dependencies'
|
|
16
|
+
import type { PasteHistoryOperation } from './replace'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Places a source graph's roots as one undoable paste, then lays them out, selects them, and
|
|
20
|
+
* reports them to the host. `beforeLayout` binds document tokens once the layers hold this
|
|
21
|
+
* document's ids. Returns the new ids, or none when the source draws nothing.
|
|
22
|
+
*/
|
|
23
|
+
export function placePastedLayers(
|
|
24
|
+
ctx: EditorContext,
|
|
25
|
+
deps: PasteDependencies,
|
|
26
|
+
source: SceneGraph,
|
|
27
|
+
label: string,
|
|
28
|
+
cursorPos?: Vector,
|
|
29
|
+
beforeLayout?: (ids: string[]) => void
|
|
30
|
+
): string[] {
|
|
31
|
+
const page = source.getPages().at(0)
|
|
32
|
+
const rootIds = page?.childIds ?? []
|
|
33
|
+
if (rootIds.length === 0) return []
|
|
34
|
+
|
|
35
|
+
return ctx.undo.runBatch(label, () => {
|
|
36
|
+
const previousSelection = new Set(ctx.state.selectedIds)
|
|
37
|
+
const parentId = resolvePasteTarget(ctx)
|
|
38
|
+
if (!prepareSlotEdits(ctx, [parentId])) return []
|
|
39
|
+
const plan = prepareGraphTransfer({
|
|
40
|
+
source,
|
|
41
|
+
rootIds,
|
|
42
|
+
dependencyPageIds: [],
|
|
43
|
+
target: ctx.graph,
|
|
44
|
+
parentId
|
|
45
|
+
})
|
|
46
|
+
let snapshot = plan
|
|
47
|
+
const operation: PasteHistoryOperation = {
|
|
48
|
+
capture: () => {
|
|
49
|
+
snapshot = captureTransferredState(ctx.graph, plan)
|
|
50
|
+
},
|
|
51
|
+
undo: () => removeGraphTransfer(ctx.graph, snapshot),
|
|
52
|
+
redo: () => applyGraphTransfer(ctx.graph, snapshot)
|
|
53
|
+
}
|
|
54
|
+
applyGraphTransfer(ctx.graph, plan)
|
|
55
|
+
const ids = plan.rootIds
|
|
56
|
+
beforeLayout?.(ids)
|
|
57
|
+
layoutAuthoredNodes(ctx.graph, ids)
|
|
58
|
+
deps.placeForeignPaste(ids, parentId, cursorPos)
|
|
59
|
+
computeAllLayouts(ctx.graph, ctx.state.currentPageId)
|
|
60
|
+
ctx.setSelectedIds(new Set(ids))
|
|
61
|
+
deps.pushCreatedNodesUndo(ids, previousSelection, label, operation)
|
|
62
|
+
return ids
|
|
63
|
+
})
|
|
64
|
+
}
|
|
@@ -1,43 +1,22 @@
|
|
|
1
1
|
import type { DesignDocument } from '@pairdraw/dom-css'
|
|
2
2
|
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
3
|
-
import {
|
|
4
|
-
applyGraphTransfer,
|
|
5
|
-
captureTransferredState,
|
|
6
|
-
prepareGraphTransfer,
|
|
7
|
-
removeGraphTransfer
|
|
8
|
-
} from '@pairdraw/scene-graph/transfer'
|
|
9
3
|
|
|
10
|
-
import { resolvePasteTarget } from '#core/editor/clipboard/paste/target'
|
|
11
|
-
import { prepareSlotEdits } from '#core/editor/components/slots'
|
|
12
4
|
import type { EditorContext } from '#core/editor/types'
|
|
13
5
|
import { sceneGraphFromStyledHTML } from '#core/io/formats/html/layers'
|
|
14
|
-
import { computeAllLayouts, layoutAuthoredNodes } from '#core/layout'
|
|
15
6
|
|
|
16
|
-
import type {
|
|
7
|
+
import type { PasteDependencies } from './paste/dependencies'
|
|
8
|
+
import { placePastedLayers } from './paste/run'
|
|
17
9
|
|
|
18
10
|
export interface StyledPasteOptions {
|
|
19
11
|
/** The name of the pasted layer when the content is one box, such as a captured page's title. */
|
|
20
12
|
name?: string
|
|
21
13
|
}
|
|
22
14
|
|
|
23
|
-
type PushCreatedNodesUndo = (
|
|
24
|
-
created: string[],
|
|
25
|
-
previousSelection: Set<string>,
|
|
26
|
-
label?: string,
|
|
27
|
-
operation?: PasteHistoryOperation
|
|
28
|
-
) => void
|
|
29
|
-
|
|
30
|
-
interface StyledPasteDependencies {
|
|
31
|
-
pushCreatedNodesUndo: PushCreatedNodesUndo
|
|
32
|
-
placeForeignPaste: (nodeIds: string[], parentId: string, cursor?: Vector) => void
|
|
33
|
-
loadFontsForNodes: (nodeIds: string[]) => Promise<unknown>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
15
|
/**
|
|
37
16
|
* Paste of a styled DOM, such as web HTML the app styled or a web capture: layers built by
|
|
38
17
|
* `sceneGraphFromStyledHTML`, placed as a paste from another application is, in one undo step.
|
|
39
18
|
*/
|
|
40
|
-
export function createStyledPasteActions(ctx: EditorContext, deps:
|
|
19
|
+
export function createStyledPasteActions(ctx: EditorContext, deps: PasteDependencies) {
|
|
41
20
|
/** Pastes the styled DOM as layers and returns their ids; none when it draws nothing. */
|
|
42
21
|
async function pasteStyledDocument(
|
|
43
22
|
styled: DesignDocument,
|
|
@@ -53,34 +32,7 @@ export function createStyledPasteActions(ctx: EditorContext, deps: StyledPasteDe
|
|
|
53
32
|
source.updateNode(onlyRoot, { name: options.name })
|
|
54
33
|
}
|
|
55
34
|
|
|
56
|
-
const created = ctx
|
|
57
|
-
const previousSelection = new Set(ctx.state.selectedIds)
|
|
58
|
-
const parentId = resolvePasteTarget(ctx)
|
|
59
|
-
if (!prepareSlotEdits(ctx, [parentId])) return []
|
|
60
|
-
const plan = prepareGraphTransfer({
|
|
61
|
-
source,
|
|
62
|
-
rootIds,
|
|
63
|
-
dependencyPageIds: [],
|
|
64
|
-
target: ctx.graph,
|
|
65
|
-
parentId
|
|
66
|
-
})
|
|
67
|
-
let snapshot = plan
|
|
68
|
-
const operation: PasteHistoryOperation = {
|
|
69
|
-
capture: () => {
|
|
70
|
-
snapshot = captureTransferredState(ctx.graph, plan)
|
|
71
|
-
},
|
|
72
|
-
undo: () => removeGraphTransfer(ctx.graph, snapshot),
|
|
73
|
-
redo: () => applyGraphTransfer(ctx.graph, snapshot)
|
|
74
|
-
}
|
|
75
|
-
applyGraphTransfer(ctx.graph, plan)
|
|
76
|
-
const ids = plan.rootIds
|
|
77
|
-
layoutAuthoredNodes(ctx.graph, ids)
|
|
78
|
-
deps.placeForeignPaste(ids, parentId, cursorPos)
|
|
79
|
-
computeAllLayouts(ctx.graph, ctx.state.currentPageId)
|
|
80
|
-
ctx.setSelectedIds(new Set(ids))
|
|
81
|
-
deps.pushCreatedNodesUndo(ids, previousSelection, 'Paste', operation)
|
|
82
|
-
return ids
|
|
83
|
-
})
|
|
35
|
+
const created = placePastedLayers(ctx, deps, source, 'Paste', cursorPos)
|
|
84
36
|
if (created.length === 0) return created
|
|
85
37
|
await deps.loadFontsForNodes(created)
|
|
86
38
|
ctx.requestRender()
|
package/src/editor/clipboard.ts
CHANGED
|
@@ -13,10 +13,12 @@ import { keepPastedBoundPaints, type AppliedBoundPaints } from '@pairdraw/scene-
|
|
|
13
13
|
|
|
14
14
|
import { parsePairdrawClipboard } from '#core/clipboard'
|
|
15
15
|
import { prepareClipboardImport } from '#core/clipboard/fig-import'
|
|
16
|
+
import { prepareSlotInsertion } from '#core/figma-api/slots'
|
|
16
17
|
import { computeAllLayouts, layoutAuthoredNodes } from '#core/layout'
|
|
17
18
|
import { reconcileVariableLayouts } from '#core/layout/variables'
|
|
18
19
|
|
|
19
20
|
import { createClipboardAssetActions } from './clipboard/assets'
|
|
21
|
+
import { createCodePasteActions } from './clipboard/code'
|
|
20
22
|
import type { ClipboardImportChoice } from './clipboard/conflicts'
|
|
21
23
|
import type { ClipboardSnapshot } from './clipboard/copy'
|
|
22
24
|
import { createClipboardCopyActions } from './clipboard/copy'
|
|
@@ -75,6 +77,7 @@ export function duplicateNode(
|
|
|
75
77
|
parentId: string,
|
|
76
78
|
position: Vector
|
|
77
79
|
): SceneNode | null {
|
|
80
|
+
prepareSlotInsertion(ctx.graph, parentId, 'duplicate')
|
|
78
81
|
const parent = ctx.graph.getNode(parentId)
|
|
79
82
|
if (node.type === 'COMPONENT' && parent?.type !== 'COMPONENT_SET') {
|
|
80
83
|
return ctx.graph.createInstance(node.id, parentId, { name: node.name, ...position })
|
|
@@ -223,6 +226,7 @@ export function createClipboardActions(ctx: EditorContext) {
|
|
|
223
226
|
}
|
|
224
227
|
)
|
|
225
228
|
})
|
|
229
|
+
reportMissingPatternSources(created)
|
|
226
230
|
await fontActions.loadFontsForNodes(created)
|
|
227
231
|
}
|
|
228
232
|
|
|
@@ -241,6 +245,7 @@ export function createClipboardActions(ctx: EditorContext) {
|
|
|
241
245
|
options
|
|
242
246
|
)
|
|
243
247
|
)
|
|
248
|
+
reportMissingPatternSources(created)
|
|
244
249
|
await fontActions.loadFontsForNodes(created)
|
|
245
250
|
return
|
|
246
251
|
}
|
|
@@ -286,6 +291,7 @@ export function createClipboardActions(ctx: EditorContext) {
|
|
|
286
291
|
})
|
|
287
292
|
if (!pasted) return
|
|
288
293
|
const { created, deliveryError } = pasted
|
|
294
|
+
reportMissingPatternSources(created)
|
|
289
295
|
|
|
290
296
|
if (deliveryError) throw deliveryError
|
|
291
297
|
await Promise.all([
|
|
@@ -471,6 +477,34 @@ export function createClipboardActions(ctx: EditorContext) {
|
|
|
471
477
|
return created
|
|
472
478
|
}
|
|
473
479
|
|
|
480
|
+
/**
|
|
481
|
+
* The pattern fills among `nodeIds` whose source layer is not in the document. A `.fig` names
|
|
482
|
+
* its pattern source by Figma GUID, and a copy carries that name even when the layer it means
|
|
483
|
+
* stayed behind, so the paste draws the fallback colour instead of the pattern.
|
|
484
|
+
*/
|
|
485
|
+
function patternSourceReport(nodeIds: string[]) {
|
|
486
|
+
const sources = new Set<string>()
|
|
487
|
+
const missing = new Set<string>()
|
|
488
|
+
for (const node of collectSubtrees(ctx.graph, nodeIds)) {
|
|
489
|
+
for (const fill of node.fills) {
|
|
490
|
+
if (fill.type !== 'PATTERN' || !fill.sourceNodeId) continue
|
|
491
|
+
sources.add(fill.sourceNodeId)
|
|
492
|
+
const found =
|
|
493
|
+
ctx.graph.getNode(fill.sourceNodeId) ??
|
|
494
|
+
[...ctx.graph.nodes.values()].find(
|
|
495
|
+
(candidate) => candidate.source.id === fill.sourceNodeId
|
|
496
|
+
)
|
|
497
|
+
if (!found) missing.add(fill.sourceNodeId)
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return { total: sources.size, missing: missing.size }
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function reportMissingPatternSources(nodeIds: string[]) {
|
|
504
|
+
const report = patternSourceReport(nodeIds)
|
|
505
|
+
if (report.missing > 0) ctx.emitEditorEvent('clipboard:pattern-sources-missing', report)
|
|
506
|
+
}
|
|
507
|
+
|
|
474
508
|
function missingImageHashes(nodeIds: string[]) {
|
|
475
509
|
const hashes = new Set<string>()
|
|
476
510
|
for (const node of collectSubtrees(ctx.graph, nodeIds)) {
|
|
@@ -633,6 +667,11 @@ export function createClipboardActions(ctx: EditorContext) {
|
|
|
633
667
|
const fontActions = createClipboardFontActions(ctx)
|
|
634
668
|
const assetActions = createClipboardAssetActions(ctx, pushCreatedNodesUndo)
|
|
635
669
|
const placementActions = createClipboardPlacementActions(ctx)
|
|
670
|
+
const codeActions = createCodePasteActions(ctx, {
|
|
671
|
+
pushCreatedNodesUndo,
|
|
672
|
+
placeForeignPaste: placementActions.placeForeignPaste,
|
|
673
|
+
loadFontsForNodes: fontActions.loadFontsForNodes
|
|
674
|
+
})
|
|
636
675
|
const styledActions = createStyledPasteActions(ctx, {
|
|
637
676
|
pushCreatedNodesUndo,
|
|
638
677
|
placeForeignPaste: placementActions.placeForeignPaste,
|
|
@@ -655,6 +694,7 @@ export function createClipboardActions(ctx: EditorContext) {
|
|
|
655
694
|
deleteSelected,
|
|
656
695
|
...assetActions,
|
|
657
696
|
...styledActions,
|
|
697
|
+
...codeActions,
|
|
658
698
|
...exportActions
|
|
659
699
|
}
|
|
660
700
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
1
|
+
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
2
|
import { getAxisAlignedWorldBounds, getWorldMatrix } from '@pairdraw/scene-graph/coordinate'
|
|
3
|
-
import { canCreateInstance } from '@pairdraw/scene-graph/instances'
|
|
3
|
+
import { canCreateInstance, INSTANCE_SYNC_FIELD_OWNERS } from '@pairdraw/scene-graph/instances'
|
|
4
4
|
import {
|
|
5
5
|
cloneInstanceOverrideState,
|
|
6
6
|
type InstanceOverrideState
|
|
7
7
|
} from '@pairdraw/scene-graph/instances/overrides'
|
|
8
8
|
import Matrix from '@pairdraw/scene-graph/matrix'
|
|
9
9
|
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
10
|
+
import { slotScope } from '@pairdraw/scene-graph/slots'
|
|
10
11
|
|
|
11
12
|
import { getNodeEditCapability } from '#core/editor/capabilities'
|
|
12
13
|
import { prepareSlotEdits } from '#core/editor/components/slots'
|
|
@@ -17,7 +18,9 @@ import type { EditorContext } from '#core/editor/types'
|
|
|
17
18
|
import {
|
|
18
19
|
canPushInstanceOverrides as canPushInstanceOverridesInGraph,
|
|
19
20
|
instanceOverrides,
|
|
21
|
+
overrideRecordedKeys,
|
|
20
22
|
pushInstanceOverrides as pushInstanceOverridesInGraph,
|
|
23
|
+
resetInstanceOverrideFields,
|
|
21
24
|
resetInstanceOverrides as resetInstanceOverridesInGraph
|
|
22
25
|
} from '#core/figma-api/overrides'
|
|
23
26
|
|
|
@@ -168,10 +171,15 @@ export function createComponentInstanceActions(ctx: EditorContext) {
|
|
|
168
171
|
})
|
|
169
172
|
}
|
|
170
173
|
|
|
171
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* Whether `id` is an instance holding any edit of its own, so Reset all changes has work. An
|
|
176
|
+
* older file may have saved an edit inside a slot as an override; slot content is the instance's
|
|
177
|
+
* own and its reset does nothing, so it does not count.
|
|
178
|
+
*/
|
|
172
179
|
function instanceHasOverrides(id: string): boolean {
|
|
173
180
|
const node = ctx.graph.getNode(id)
|
|
174
|
-
|
|
181
|
+
if (node?.type !== 'INSTANCE') return false
|
|
182
|
+
return instanceOverrides(ctx.graph, node).some((entry) => !isSlotContent(ctx.graph, entry.id))
|
|
175
183
|
}
|
|
176
184
|
|
|
177
185
|
/** Figma's Reset all changes: the instance and the ones inside it go back to their components. */
|
|
@@ -183,6 +191,80 @@ export function createComponentInstanceActions(ctx: EditorContext) {
|
|
|
183
191
|
)
|
|
184
192
|
}
|
|
185
193
|
|
|
194
|
+
/** Whether a layer is the content an instance put inside its slot. */
|
|
195
|
+
function isSlotContent(graph: SceneGraph, id: string): boolean {
|
|
196
|
+
const parentId = graph.getNode(id)?.parentId
|
|
197
|
+
return !!parentId && slotScope(graph, parentId).kind === 'slot'
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The instance a layer's own edits are recorded on: the layer itself, or its nearest instance. */
|
|
201
|
+
function overrideOwner(id: string): SceneNode | undefined {
|
|
202
|
+
const node = ctx.graph.getNode(id)
|
|
203
|
+
if (!node) return undefined
|
|
204
|
+
if (node.type === 'INSTANCE') return node
|
|
205
|
+
return node.parentId
|
|
206
|
+
? ctx.graph.closest(node.parentId, (current) => current.type === 'INSTANCE')
|
|
207
|
+
: undefined
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Whether this layer differs from its component: its own fields, or for an instance, the state
|
|
212
|
+
* of the layers it holds (resetting it clears all of them, as the review found). Content inside
|
|
213
|
+
* a slot is never an override, even when an older file recorded one.
|
|
214
|
+
*/
|
|
215
|
+
function layerHasOverrides(id: string): boolean {
|
|
216
|
+
const node = ctx.graph.getNode(id)
|
|
217
|
+
if (!node || isSlotContent(ctx.graph, id)) return false
|
|
218
|
+
if (node.type === 'INSTANCE')
|
|
219
|
+
return node.instanceOverrides.self.size > 0 || node.instanceOverrides.descendants.size > 0
|
|
220
|
+
const owner = overrideOwner(id)
|
|
221
|
+
return (owner?.instanceOverrides.descendants.get(id)?.size ?? 0) > 0
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The fields this layer changes relative to its component, read from the instance's own override
|
|
226
|
+
* state rather than by comparing the two layers. Slot content changes nothing: it is the
|
|
227
|
+
* instance's content, not an override.
|
|
228
|
+
*/
|
|
229
|
+
function overriddenFields(id: string): ReadonlySet<string> {
|
|
230
|
+
const node = ctx.graph.getNode(id)
|
|
231
|
+
if (!node || isSlotContent(ctx.graph, id)) return new Set()
|
|
232
|
+
const entry =
|
|
233
|
+
node.type === 'INSTANCE'
|
|
234
|
+
? node.instanceOverrides.self
|
|
235
|
+
: overrideOwner(id)?.instanceOverrides.descendants.get(id)
|
|
236
|
+
const fields = new Set<string>()
|
|
237
|
+
for (const field of entry?.keys() ?? []) fields.add(INSTANCE_SYNC_FIELD_OWNERS[field] ?? field)
|
|
238
|
+
return fields
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Whether this layer can differ from a component at all, so a row may reserve a marker slot. */
|
|
242
|
+
function canOverrideFields(id: string): boolean {
|
|
243
|
+
return !!ctx.graph.getNode(id) && !isSlotContent(ctx.graph, id) && !!overrideOwner(id)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Figma's reset on one layer of an instance: the layer goes back to its component's value while
|
|
248
|
+
* the rest of the instance keeps its changes, over one undo step.
|
|
249
|
+
*/
|
|
250
|
+
function resetLayerOverridesFromSelection(id: string, fields?: readonly string[]): void {
|
|
251
|
+
const node = ctx.graph.getNode(id)
|
|
252
|
+
const owner = node ? overrideOwner(id) : undefined
|
|
253
|
+
if (!node || !owner) return
|
|
254
|
+
// Slot content is not an override, so resetting its row would revert the instance's own copy.
|
|
255
|
+
if (isSlotContent(ctx.graph, id)) return
|
|
256
|
+
// A row's names stand for the keys they are mapped from, such as `text` for a styled range.
|
|
257
|
+
const keys = fields ? overrideRecordedKeys(fields) : undefined
|
|
258
|
+
recordSubtreeEdit(
|
|
259
|
+
ctx,
|
|
260
|
+
keys ? 'Reset property changes' : 'Reset layer changes',
|
|
261
|
+
owner.id,
|
|
262
|
+
() => {
|
|
263
|
+
resetInstanceOverrideFields(ctx.graph, id, fields)
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
186
268
|
/** Whether a library owns the main component, whose changes only its library can take. */
|
|
187
269
|
function mainComponentEditable(componentId: string): boolean {
|
|
188
270
|
return getNodeEditCapability(ctx.graph, componentId).editable
|
|
@@ -212,6 +294,12 @@ export function createComponentInstanceActions(ctx: EditorContext) {
|
|
|
212
294
|
createInstanceFromComponent,
|
|
213
295
|
detachInstance,
|
|
214
296
|
instanceHasOverrides,
|
|
297
|
+
layerHasOverrides,
|
|
298
|
+
canOverrideFields,
|
|
299
|
+
overriddenFields,
|
|
300
|
+
resetLayerOverrides: resetLayerOverridesFromSelection,
|
|
301
|
+
resetLayerOverrideFields: (id: string, fields: readonly string[]) =>
|
|
302
|
+
resetLayerOverridesFromSelection(id, fields),
|
|
215
303
|
canPushInstanceOverrides,
|
|
216
304
|
pushInstanceOverrides: pushInstanceOverridesFromSelection,
|
|
217
305
|
resetInstanceOverrides: resetInstanceOverridesFromSelection
|
|
@@ -21,6 +21,7 @@ type InstanceSlot = Extract<SlotScope, { kind: 'slot' }>
|
|
|
21
21
|
export function prepareSlotEdits(ctx: EditorContext, parentIds: Iterable<string>): boolean {
|
|
22
22
|
const slots = new Map<string, InstanceSlot>()
|
|
23
23
|
for (const parentId of parentIds) {
|
|
24
|
+
if (ctx.graph.getNode(parentId)?.type === 'SLICE') return false
|
|
24
25
|
const scope = slotScope(ctx.graph, parentId)
|
|
25
26
|
if (scope.kind === 'locked') return false
|
|
26
27
|
if (scope.kind === 'slot') slots.set(scope.frame.id, scope)
|
|
@@ -34,6 +35,7 @@ export function prepareSlotEdits(ctx: EditorContext, parentIds: Iterable<string>
|
|
|
34
35
|
|
|
35
36
|
/** Whether layers may be added to or removed from this parent at all. */
|
|
36
37
|
export function acceptsChildren(ctx: Pick<EditorContext, 'graph'>, parentId: string): boolean {
|
|
38
|
+
if (ctx.graph.getNode(parentId)?.type === 'SLICE') return false
|
|
37
39
|
return slotScope(ctx.graph, parentId).kind !== 'locked'
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -41,6 +43,11 @@ export function acceptsChildren(ctx: Pick<EditorContext, 'graph'>, parentId: str
|
|
|
41
43
|
export function acceptingParent(ctx: Pick<EditorContext, 'graph'>, parentId: string): string {
|
|
42
44
|
let id = parentId
|
|
43
45
|
for (;;) {
|
|
46
|
+
const node = ctx.graph.getNode(id)
|
|
47
|
+
if (node?.type === 'SLICE' && node.parentId) {
|
|
48
|
+
id = node.parentId
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
44
51
|
const scope = slotScope(ctx.graph, id)
|
|
45
52
|
if (scope.kind !== 'locked' || !scope.owner.parentId) return id
|
|
46
53
|
id = scope.owner.parentId
|
package/src/editor/components.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
2
2
|
|
|
3
|
+
import { assertComponentSourceScope } from '#core/figma-api/component-scope'
|
|
4
|
+
|
|
3
5
|
import { createComponentAuthoringActions } from './components/authoring'
|
|
4
6
|
import { createBehaviourActions } from './components/behaviours'
|
|
5
7
|
import { becomesComponent, componentWrapProps } from './components/create'
|
|
@@ -12,6 +14,7 @@ import { createSlotAuthoringActions } from './components/slots/authoring'
|
|
|
12
14
|
import { createComponentToFrameActions } from './components/to-frame'
|
|
13
15
|
import { applyVariantProperties, variantSetProps } from './components/variant-set'
|
|
14
16
|
import { createVariantActions } from './components/variants'
|
|
17
|
+
import { wrappableParentId } from './structure/container-wrap'
|
|
15
18
|
import type { EditorContext } from './types'
|
|
16
19
|
|
|
17
20
|
export function createComponentActions(ctx: EditorContext) {
|
|
@@ -32,6 +35,7 @@ export function createComponentActions(ctx: EditorContext) {
|
|
|
32
35
|
const prevType = node.type
|
|
33
36
|
|
|
34
37
|
if (node.type === 'COMPONENT') return
|
|
38
|
+
assertComponentSourceScope(ctx.graph, node.id, 'Create component', { instancesOnly: true })
|
|
35
39
|
|
|
36
40
|
if (becomesComponent(node)) {
|
|
37
41
|
ctx.graph.updateNode(node.id, { type: 'COMPONENT' })
|
|
@@ -54,6 +58,16 @@ export function createComponentActions(ctx: EditorContext) {
|
|
|
54
58
|
wrapSelectionInContainer('COMPONENT', selectedNodes, componentWrapProps(selectedNodes))
|
|
55
59
|
}
|
|
56
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Whether two or more selected components can become one variant set: they must be siblings,
|
|
63
|
+
* writable components on the same page, with a parent a new set can wrap them into.
|
|
64
|
+
*/
|
|
65
|
+
function canCombineComponentsAsVariants(nodes: readonly SceneNode[]): boolean {
|
|
66
|
+
if (nodes.length < 2) return false
|
|
67
|
+
if (!nodes.every((node) => node.type === 'COMPONENT' && !node.internalOnly)) return false
|
|
68
|
+
return wrappableParentId(ctx, nodes) !== null
|
|
69
|
+
}
|
|
70
|
+
|
|
57
71
|
function createComponentSetFromComponents(
|
|
58
72
|
selectedNodes: SceneNode[],
|
|
59
73
|
wrapSelectionInContainer: (
|
|
@@ -62,8 +76,7 @@ export function createComponentActions(ctx: EditorContext) {
|
|
|
62
76
|
extra?: Partial<SceneNode>
|
|
63
77
|
) => string | null
|
|
64
78
|
) {
|
|
65
|
-
if (selectedNodes
|
|
66
|
-
if (!selectedNodes.every((n) => n.type === 'COMPONENT')) return
|
|
79
|
+
if (!canCombineComponentsAsVariants(selectedNodes)) return
|
|
67
80
|
const parentId = selectedNodes[0].parentId ?? ctx.state.currentPageId
|
|
68
81
|
const containerId = wrapSelectionInContainer(
|
|
69
82
|
'COMPONENT_SET',
|
|
@@ -84,6 +97,7 @@ export function createComponentActions(ctx: EditorContext) {
|
|
|
84
97
|
|
|
85
98
|
return {
|
|
86
99
|
createComponentFromSelection,
|
|
100
|
+
canCombineComponentsAsVariants,
|
|
87
101
|
createComponentSetFromComponents,
|
|
88
102
|
...instanceActions,
|
|
89
103
|
...focusActions,
|