@pairdraw/core 0.21.0 → 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/canvas/shaders/compile.d.ts +3 -1
- package/dist/canvas/shaders/compile.d.ts.map +1 -1
- package/dist/canvas/shaders/compile.js +12 -3
- package/dist/canvas/shaders/compile.js.map +1 -1
- package/dist/canvas/shaders/draw.d.ts.map +1 -1
- package/dist/canvas/shaders/draw.js +10 -3
- package/dist/canvas/shaders/draw.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +6 -16
- package/dist/canvas/shaders/effect.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/bridges/undo.d.ts +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/export.js +2 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- 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 +30 -3
- 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/drawio/warnings.d.ts +17 -2
- package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
- package/dist/io/formats/drawio/warnings.js +14 -7
- package/dist/io/formats/drawio/warnings.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/index.d.ts +1 -0
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +5 -3
- package/dist/io/formats/html/index.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/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +13 -4
- package/dist/io/formats/pen/index.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 +30 -17
- package/dist/io/formats.js.map +1 -1
- package/dist/io/index.d.ts +2 -2
- package/dist/io/types.d.ts +11 -2
- package/dist/io/types.d.ts.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/canvas/shaders/compile.ts +14 -3
- package/src/canvas/shaders/draw.ts +11 -4
- package/src/canvas/shaders/effect.ts +6 -18
- 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/export.ts +2 -2
- 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/drawio/warnings.ts +27 -8
- 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/index.ts +9 -3
- 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/pen/index.ts +14 -6
- 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 +45 -19
- package/src/io/index.ts +1 -0
- package/src/io/types.ts +10 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure.d.ts","names":[],"sources":["../../src/editor/structure.ts"],"mappings":";;;;;;iBAuBgB,uBAAuB,KAAK;EAgId,aAAA;EA+CY,wBAAA,SAAA,2BAAA;EAIP,iBAAA,SAAA;EA8BT,aAAA,YAAM;;;;;;EAvGmB,2BAAA,eAAA,aAAW,WAAa;
|
|
1
|
+
{"version":3,"file":"structure.d.ts","names":[],"sources":["../../src/editor/structure.ts"],"mappings":";;;;;;iBAuBgB,uBAAuB,KAAK;EAgId,aAAA;EA+CY,wBAAA,SAAA,2BAAA;EAIP,iBAAA,SAAA;EA8BT,aAAA,YAAM;;;;;;EAvGmB,2BAAA,eAAA,aAAW,WAAa,qBAAgB;EAIlD,kBAAA,cAAA;EAIC,kBAAA,eAAA;EAII,sBAAA,eAAA;EAME,wBAAA,eAAA;2CAAA;EA/Gd,gBAAA,mBAAQ;EAuBvB,2BAAA,kEAAiD,eACjD,aAAW,aACb,QAAQ;EAKkB,mBAAA,eAAA;EAIH,gBAAA,eAAA;EAoBD,eAAA,eAAA;EAmCE,iBAAA,eAAA;;;;;;;;EAjGT,aAAA;EA+NA,kBAAA;EACA,kBAAA;EACI,qBAAA,WAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EditorContext } from "./types.js";
|
|
2
|
+
import { NodeActions } from "./nodes.js";
|
|
3
|
+
import { SceneNode, SharedStyleKind, SharedStyleType } from "@pairdraw/scene-graph";
|
|
4
|
+
//#region src/editor/styles.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A new style node, which redo makes again with the same ids so layers stay attached. The one
|
|
7
|
+
* creator the token import and the style picker share.
|
|
8
|
+
*/
|
|
9
|
+
declare function createStyleNode(ctx: EditorContext, type: SharedStyleType, fields: Partial<SceneNode>): SceneNode;
|
|
10
|
+
/** Whether a layer can carry this kind of style at all, as the picker's own fields say. */
|
|
11
|
+
declare function supportsStyleKind(node: SceneNode, kind: SharedStyleKind): boolean;
|
|
12
|
+
/** Makes shared styles from what a layer shows, as the style picker asks. */
|
|
13
|
+
declare function createStyleActions(ctx: EditorContext, nodes: NodeActions): {
|
|
14
|
+
createStyleFromSelection: (kind: SharedStyleKind, name: string) => SceneNode | null;
|
|
15
|
+
/** Whether the selection holds something to save for this kind, so the picker can offer it. */
|
|
16
|
+
updateSharedStyle: (styleId: string, kind: SharedStyleKind, changes: SharedStyleDefinitionChanges) => {
|
|
17
|
+
styleId: string;
|
|
18
|
+
layerIds: string[];
|
|
19
|
+
} | null;
|
|
20
|
+
canCreateStyle: (kind: SharedStyleKind) => boolean;
|
|
21
|
+
};
|
|
22
|
+
/** The fields an edit of a shared definition writes for its kind. */
|
|
23
|
+
type SharedStyleDefinitionChanges = Partial<Pick<SceneNode, 'name' | 'symbolDescription' | 'fills' | 'strokes' | 'effects' | 'layoutGrids' | 'fontFamily' | 'fontWeight' | 'italic' | 'fontStyle' | 'fontSize' | 'lineHeight' | 'letterSpacing' | 'textDecoration' | 'textCase' | 'fontFeatures' | 'paragraphSpacing' | 'paragraphIndent' | 'listSpacing'>>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { SharedStyleDefinitionChanges, createStyleActions, createStyleNode, supportsStyleKind };
|
|
26
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","names":[],"sources":["../../src/editor/styles.ts"],"mappings":";;;;;;;;iBAoBgB,gBACd,KAAK,eACL,MAAM,iBACN,QAAQ,QAAQ,aACf;;iBA0Ba,kBAAkB,MAAM,WAAW,MAAM;;iBA4DzC,mBAAmB,KAAK,eAAe,OAAO;EAEzB,2BAAA,MAAA,iBAAe,iBAAc;;EAInD,oBAAA,iBAAM,MACT,iBAAe,SACZ;IAiDD;IAAkB;;EA/CL,iBAAA,MAAA;;;KAUf,+BAA+B,QACzC,KACE"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { styleNodeProps, styleNodeType } from "../io/formats/design-tokens/apply.js";
|
|
2
|
+
import { SHARED_STYLE_FIELDS, sharedStyleLayers, sharedStyleRefKey, sharedStyleTypeForKind } from "@pairdraw/scene-graph/shared-styles";
|
|
3
|
+
import { isNil } from "es-toolkit";
|
|
4
|
+
import { hasInstanceOverride } from "@pairdraw/scene-graph/instances";
|
|
5
|
+
//#region src/editor/styles.ts
|
|
6
|
+
/**
|
|
7
|
+
* A new style node, which redo makes again with the same ids so layers stay attached. The one
|
|
8
|
+
* creator the token import and the style picker share.
|
|
9
|
+
*/
|
|
10
|
+
function createStyleNode(ctx, type, fields) {
|
|
11
|
+
const node = ctx.graph.createNode(styleNodeType({ kind: type }), ctx.state.currentPageId, styleNodeProps({ kind: type }, fields));
|
|
12
|
+
node.source.id = crypto.randomUUID();
|
|
13
|
+
const snapshot = structuredClone(node);
|
|
14
|
+
const parentId = node.parentId;
|
|
15
|
+
ctx.undo.push({
|
|
16
|
+
label: "Add style",
|
|
17
|
+
forward: () => {
|
|
18
|
+
ctx.graph.createNodeWithId(snapshot.id, snapshot.type, parentId, structuredClone(snapshot));
|
|
19
|
+
ctx.requestRender();
|
|
20
|
+
},
|
|
21
|
+
inverse: () => {
|
|
22
|
+
ctx.graph.deleteNode(snapshot.id);
|
|
23
|
+
ctx.requestRender();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return node;
|
|
27
|
+
}
|
|
28
|
+
const GRID_KINDS = /* @__PURE__ */ new Set([
|
|
29
|
+
"FRAME",
|
|
30
|
+
"COMPONENT",
|
|
31
|
+
"COMPONENT_SET",
|
|
32
|
+
"INSTANCE"
|
|
33
|
+
]);
|
|
34
|
+
/** Whether a layer can carry this kind of style at all, as the picker's own fields say. */
|
|
35
|
+
function supportsStyleKind(node, kind) {
|
|
36
|
+
if (node.type === "CANVAS") return false;
|
|
37
|
+
if (kind === "text") return node.type === "TEXT";
|
|
38
|
+
if (kind === "grid") return GRID_KINDS.has(node.type);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
/** Whether the layer shows something of this kind, such as a fill or an effect to save. */
|
|
42
|
+
function carriesStyleKind(node, kind) {
|
|
43
|
+
return SHARED_STYLE_FIELDS[kind].some((field) => {
|
|
44
|
+
const value = node[field];
|
|
45
|
+
return Array.isArray(value) ? value.length > 0 : !isNil(value);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** The layer a created style takes its fields from: the first selected one that shows the kind. */
|
|
49
|
+
function styleSource(layers, kind) {
|
|
50
|
+
return layers.find((layer) => supportsStyleKind(layer, kind) && carriesStyleKind(layer, kind));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Turns what the selected layers show into one shared style and binds every layer that supports
|
|
54
|
+
* it, as one undo step. The style takes the first layer that shows the kind, so binding changes
|
|
55
|
+
* nothing the person can see; a name may carry `/` groups. Without such a layer nothing is made,
|
|
56
|
+
* as Figma hides creation without paints.
|
|
57
|
+
*/
|
|
58
|
+
function createStyleFromSelection(ctx, nodes, kind, name) {
|
|
59
|
+
const layers = [...ctx.state.selectedIds].map((id) => ctx.graph.getNode(id)).filter((node) => node !== void 0);
|
|
60
|
+
const first = styleSource(layers, kind);
|
|
61
|
+
if (!first) return null;
|
|
62
|
+
const fields = {};
|
|
63
|
+
for (const key of SHARED_STYLE_FIELDS[kind]) Object.assign(fields, { [key]: structuredClone(first[key]) });
|
|
64
|
+
return ctx.undo.runBatch("Create style", () => {
|
|
65
|
+
const style = createStyleNode(ctx, sharedStyleTypeForKind(kind), {
|
|
66
|
+
...fields,
|
|
67
|
+
name: name.trim() || first.name
|
|
68
|
+
});
|
|
69
|
+
const styleId = style.source.id;
|
|
70
|
+
const refKey = sharedStyleRefKey(kind);
|
|
71
|
+
for (const layer of layers) {
|
|
72
|
+
if (!supportsStyleKind(layer, kind)) continue;
|
|
73
|
+
nodes.updateNodeWithUndo(layer.id, { [refKey]: styleId }, `Apply ${kind} style`);
|
|
74
|
+
}
|
|
75
|
+
ctx.requestRender();
|
|
76
|
+
return style;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/** Makes shared styles from what a layer shows, as the style picker asks. */
|
|
80
|
+
function createStyleActions(ctx, nodes) {
|
|
81
|
+
return {
|
|
82
|
+
createStyleFromSelection: (kind, name) => createStyleFromSelection(ctx, nodes, kind, name),
|
|
83
|
+
/** Whether the selection holds something to save for this kind, so the picker can offer it. */
|
|
84
|
+
updateSharedStyle: (styleId, kind, changes) => updateSharedStyle(ctx, nodes, styleId, kind, changes),
|
|
85
|
+
canCreateStyle: (kind) => {
|
|
86
|
+
return styleSource([...ctx.state.selectedIds].map((id) => ctx.graph.getNode(id)).filter((node) => node !== void 0), kind) !== void 0;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Writes a shared style's definition and re-applies its fields to every layer linked to that style,
|
|
92
|
+
* as one undo step. A layer's own name and description never follow the style. A layer that detached
|
|
93
|
+
* (its reference cleared) is not touched. An instance field the person overrode keeps its value, as
|
|
94
|
+
* in Figma; the other fields still follow.
|
|
95
|
+
*/
|
|
96
|
+
function updateSharedStyle(ctx, nodes, styleId, kind, changes) {
|
|
97
|
+
const style = [...sharedStyleLayers(ctx.graph).values()].find((node) => node.source.id === styleId && node.sharedStyleType === sharedStyleTypeForKind(kind));
|
|
98
|
+
if (!style) return null;
|
|
99
|
+
const fields = SHARED_STYLE_FIELDS[kind];
|
|
100
|
+
const patch = {};
|
|
101
|
+
for (const field of fields) if (field in changes) Object.assign(patch, { [field]: structuredClone(changes[field]) });
|
|
102
|
+
if (changes.name !== void 0) patch.name = changes.name.trim() || style.name;
|
|
103
|
+
if (changes.symbolDescription !== void 0) patch.symbolDescription = changes.symbolDescription;
|
|
104
|
+
const reference = sharedStyleRefKey(kind);
|
|
105
|
+
const linked = [...ctx.graph.getAllNodes()].filter((node) => node.id !== style.id && node[reference] === styleId);
|
|
106
|
+
ctx.undo.runBatch("Edit style", () => {
|
|
107
|
+
for (const layer of linked) {
|
|
108
|
+
const layerPatch = { [reference]: styleId };
|
|
109
|
+
for (const field of fields) {
|
|
110
|
+
if (!(field in patch) || hasInstanceOverride(ctx.graph, layer.id, field)) continue;
|
|
111
|
+
Object.assign(layerPatch, { [field]: structuredClone(patch[field]) });
|
|
112
|
+
}
|
|
113
|
+
if (Object.keys(layerPatch).length === 1) continue;
|
|
114
|
+
nodes.updateNodeWithUndo(layer.id, layerPatch, "Update style layer");
|
|
115
|
+
}
|
|
116
|
+
nodes.updateNodeWithUndo(style.id, patch, "Edit style");
|
|
117
|
+
});
|
|
118
|
+
ctx.requestRender();
|
|
119
|
+
return {
|
|
120
|
+
styleId,
|
|
121
|
+
layerIds: linked.map((node) => node.id)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { createStyleActions, createStyleNode, supportsStyleKind };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","names":[],"sources":["../../src/editor/styles.ts"],"sourcesContent":["import { isNil } from 'es-toolkit'\n\nimport type { SceneNode, SharedStyleKind, SharedStyleType } from '@pairdraw/scene-graph'\nimport { hasInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport {\n SHARED_STYLE_FIELDS,\n sharedStyleLayers,\n sharedStyleRefKey,\n sharedStyleTypeForKind\n} from '@pairdraw/scene-graph/shared-styles'\n\nimport { styleNodeProps, styleNodeType } from '#core/io/formats/design-tokens/apply'\n\nimport type { NodeActions } from './nodes'\nimport type { EditorContext } from './types'\n\n/**\n * A new style node, which redo makes again with the same ids so layers stay attached. The one\n * creator the token import and the style picker share.\n */\nexport function createStyleNode(\n ctx: EditorContext,\n type: SharedStyleType,\n fields: Partial<SceneNode>\n): SceneNode {\n const node = ctx.graph.createNode(\n styleNodeType({ kind: type }),\n ctx.state.currentPageId,\n styleNodeProps({ kind: type }, fields)\n )\n node.source.id = crypto.randomUUID()\n const snapshot = structuredClone(node)\n const parentId = node.parentId\n ctx.undo.push({\n label: 'Add style',\n forward: () => {\n ctx.graph.createNodeWithId(snapshot.id, snapshot.type, parentId, structuredClone(snapshot))\n ctx.requestRender()\n },\n inverse: () => {\n ctx.graph.deleteNode(snapshot.id)\n ctx.requestRender()\n }\n })\n return node\n}\n\nconst GRID_KINDS = new Set(['FRAME', 'COMPONENT', 'COMPONENT_SET', 'INSTANCE'])\n\n/** Whether a layer can carry this kind of style at all, as the picker's own fields say. */\nexport function supportsStyleKind(node: SceneNode, kind: SharedStyleKind): boolean {\n if (node.type === 'CANVAS') return false\n if (kind === 'text') return node.type === 'TEXT'\n if (kind === 'grid') return GRID_KINDS.has(node.type)\n return true\n}\n\n/** Whether the layer shows something of this kind, such as a fill or an effect to save. */\nfunction carriesStyleKind(node: SceneNode, kind: SharedStyleKind): boolean {\n return SHARED_STYLE_FIELDS[kind].some((field) => {\n const value = node[field]\n return Array.isArray(value) ? value.length > 0 : !isNil(value)\n })\n}\n\n/** The layer a created style takes its fields from: the first selected one that shows the kind. */\nfunction styleSource(layers: readonly SceneNode[], kind: SharedStyleKind): SceneNode | undefined {\n return layers.find((layer) => supportsStyleKind(layer, kind) && carriesStyleKind(layer, kind))\n}\n\n/**\n * Turns what the selected layers show into one shared style and binds every layer that supports\n * it, as one undo step. The style takes the first layer that shows the kind, so binding changes\n * nothing the person can see; a name may carry `/` groups. Without such a layer nothing is made,\n * as Figma hides creation without paints.\n */\nfunction createStyleFromSelection(\n ctx: EditorContext,\n nodes: NodeActions,\n kind: SharedStyleKind,\n name: string\n): SceneNode | null {\n const layers = [...ctx.state.selectedIds]\n .map((id) => ctx.graph.getNode(id))\n .filter((node): node is SceneNode => node !== undefined)\n const first = styleSource(layers, kind)\n if (!first) return null\n\n const fields: Partial<SceneNode> = {}\n for (const key of SHARED_STYLE_FIELDS[kind]) {\n Object.assign(fields, { [key]: structuredClone(first[key]) })\n }\n\n return ctx.undo.runBatch('Create style', () => {\n const style = createStyleNode(ctx, sharedStyleTypeForKind(kind), {\n ...fields,\n name: name.trim() || first.name\n })\n const styleId = style.source.id\n const refKey = sharedStyleRefKey(kind)\n for (const layer of layers) {\n if (!supportsStyleKind(layer, kind)) continue\n nodes.updateNodeWithUndo(layer.id, { [refKey]: styleId }, `Apply ${kind} style`)\n }\n ctx.requestRender()\n return style\n })\n}\n\n/** Makes shared styles from what a layer shows, as the style picker asks. */\nexport function createStyleActions(ctx: EditorContext, nodes: NodeActions) {\n return {\n createStyleFromSelection: (kind: SharedStyleKind, name: string) =>\n createStyleFromSelection(ctx, nodes, kind, name),\n /** Whether the selection holds something to save for this kind, so the picker can offer it. */\n updateSharedStyle: (\n styleId: string,\n kind: SharedStyleKind,\n changes: SharedStyleDefinitionChanges\n ) => updateSharedStyle(ctx, nodes, styleId, kind, changes),\n canCreateStyle: (kind: SharedStyleKind) => {\n const layers = [...ctx.state.selectedIds]\n .map((id) => ctx.graph.getNode(id))\n .filter((node): node is SceneNode => node !== undefined)\n return styleSource(layers, kind) !== undefined\n }\n }\n}\n\n/** The fields an edit of a shared definition writes for its kind. */\nexport type SharedStyleDefinitionChanges = Partial<\n Pick<\n SceneNode,\n | 'name'\n | 'symbolDescription'\n | 'fills'\n | 'strokes'\n | 'effects'\n | 'layoutGrids'\n | 'fontFamily'\n | 'fontWeight'\n | 'italic'\n | 'fontStyle'\n | 'fontSize'\n | 'lineHeight'\n | 'letterSpacing'\n | 'textDecoration'\n | 'textCase'\n | 'fontFeatures'\n | 'paragraphSpacing'\n | 'paragraphIndent'\n | 'listSpacing'\n >\n>\n\n/**\n * Writes a shared style's definition and re-applies its fields to every layer linked to that style,\n * as one undo step. A layer's own name and description never follow the style. A layer that detached\n * (its reference cleared) is not touched. An instance field the person overrode keeps its value, as\n * in Figma; the other fields still follow.\n */\nfunction updateSharedStyle(\n ctx: EditorContext,\n nodes: NodeActions,\n styleId: string,\n kind: SharedStyleKind,\n changes: SharedStyleDefinitionChanges\n): { styleId: string; layerIds: string[] } | null {\n const style = [...sharedStyleLayers(ctx.graph).values()].find(\n (node) => node.source.id === styleId && node.sharedStyleType === sharedStyleTypeForKind(kind)\n )\n if (!style) return null\n\n const fields = SHARED_STYLE_FIELDS[kind]\n const patch: Partial<SceneNode> = {}\n for (const field of fields) {\n if (field in changes) Object.assign(patch, { [field]: structuredClone(changes[field]) })\n }\n if (changes.name !== undefined) patch.name = changes.name.trim() || style.name\n if (changes.symbolDescription !== undefined) patch.symbolDescription = changes.symbolDescription\n\n const reference = sharedStyleRefKey(kind)\n const linked = [...ctx.graph.getAllNodes()].filter(\n (node) => node.id !== style.id && node[reference] === styleId\n )\n ctx.undo.runBatch('Edit style', () => {\n for (const layer of linked) {\n // Naming the same reference keeps the node action from treating a definition reapply as a\n // local paint edit.\n const layerPatch: Partial<SceneNode> = { [reference]: styleId }\n for (const field of fields) {\n if (!(field in patch) || hasInstanceOverride(ctx.graph, layer.id, field)) continue\n Object.assign(layerPatch, { [field]: structuredClone(patch[field]) })\n }\n // A rename or description edit changes no linked layer.\n if (Object.keys(layerPatch).length === 1) continue\n nodes.updateNodeWithUndo(layer.id, layerPatch, 'Update style layer')\n }\n nodes.updateNodeWithUndo(style.id, patch, 'Edit style')\n })\n ctx.requestRender()\n return { styleId, layerIds: linked.map((node) => node.id) }\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,gBACd,KACA,MACA,QACW;CACX,MAAM,OAAO,IAAI,MAAM,WACrB,cAAc,EAAE,MAAM,KAAK,CAAC,GAC5B,IAAI,MAAM,eACV,eAAe,EAAE,MAAM,KAAK,GAAG,MAAM,CACvC;CACA,KAAK,OAAO,KAAK,OAAO,WAAW;CACnC,MAAM,WAAW,gBAAgB,IAAI;CACrC,MAAM,WAAW,KAAK;CACtB,IAAI,KAAK,KAAK;EACZ,OAAO;EACP,eAAe;GACb,IAAI,MAAM,iBAAiB,SAAS,IAAI,SAAS,MAAM,UAAU,gBAAgB,QAAQ,CAAC;GAC1F,IAAI,cAAc;EACpB;EACA,eAAe;GACb,IAAI,MAAM,WAAW,SAAS,EAAE;GAChC,IAAI,cAAc;EACpB;CACF,CAAC;CACD,OAAO;AACT;AAEA,MAAM,6BAAa,IAAI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;CACA,IAAI,KAAK,SAAS,oBAAoB;EACpC,KAAK,MAAM,SAAS,QAAQ;GAG1B,MAAM,aAAiC,GAAG,YAAY,QAAQ;GAC9D,KAAK,MAAM,SAAS,QAAQ;IAC1B,IAAI,EAAE,SAAS,UAAU,oBAAoB,IAAI,OAAO,MAAM,IAAI,KAAK,GAAG;IAC1E,OAAO,OAAO,YAAY,GAAG,QAAQ,gBAAgB,MAAM,MAAM,EAAE,CAAC;GACtE;GAEA,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,WAAW,GAAG;GAC1C,MAAM,mBAAmB,MAAM,IAAI,YAAY,oBAAoB;EACrE;EACA,MAAM,mBAAmB,MAAM,IAAI,OAAO,YAAY;CACxD,CAAC;CACD,IAAI,cAAc;CAClB,OAAO;EAAE;EAAS,UAAU,OAAO,KAAK,SAAS,KAAK,EAAE;CAAE;AAC5D"}
|
|
@@ -13,6 +13,7 @@ declare function createTextSelectionStyle(ctx: EditorContext, runTextEditStep: (
|
|
|
13
13
|
commitNodeUpdate: (id: string, previous: Partial<SceneNode>, commit: NodeUpdate, updateWithUndo: NodeUpdate) => void;
|
|
14
14
|
selectionStyle: (node: SceneNode) => Partial<SceneNode> | null;
|
|
15
15
|
layerChanges: (id: string, changes: Partial<SceneNode>) => Partial<SceneNode>;
|
|
16
|
+
isTextStyleMixed: (id: string, key: string) => boolean;
|
|
16
17
|
};
|
|
17
18
|
//#endregion
|
|
18
19
|
export { createTextSelectionStyle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-style.d.ts","names":[],"sources":["../../../src/editor/text/selection-style.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"selection-style.d.ts","names":[],"sources":["../../../src/editor/text/selection-style.ts"],"mappings":";;;KAgBK,cAAc,YAAY,SAAS,QAAQ;;;;;;iBAWhC,yBACd,KAAK,eACL,kBAAkB;EA6BM,aAAA,YAAM,SAAW,QAAQ,YAAU,QAAU;EAkBrC,qBAAA,YAAM,SAAW,QAAQ,YAAU,QAAU;EAevE,mBAAA,YAAM,UACA,QAAQ,YAAU,QACpB,YAAU,gBACF;EAuBY,iBAAA,MAAA,cAAY,QAAQ;EAaxB,eAAA,YAAM,SAAW,QAAQ,eAAa,QAAQ;EAO1C,mBAAA,YAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TEXT_STYLE_KEYS, characterStyles, layerTextStyleChanges, shownTextStyle, styleRunsWithPatch } from "../../text/character-style.js";
|
|
1
|
+
import { TEXT_STYLE_KEYS, characterStyles, layerTextStyleChanges, mixedTextStyleKeys, shownTextStyle, styleRunsWithPatch } from "../../text/character-style.js";
|
|
2
2
|
import { isEqual } from "es-toolkit/predicate";
|
|
3
3
|
import { omit, pick } from "es-toolkit/object";
|
|
4
4
|
//#region src/editor/text/selection-style.ts
|
|
@@ -103,12 +103,20 @@ function createTextSelectionStyle(ctx, runTextEditStep) {
|
|
|
103
103
|
if (!node || ctx.state.editingTextId === id) return changes;
|
|
104
104
|
return layerTextStyleChanges(node, changes);
|
|
105
105
|
}
|
|
106
|
+
/** Whether the characters the panel would edit differ in this style, so the row shows Mixed. */
|
|
107
|
+
function isTextStyleMixed(id, key) {
|
|
108
|
+
const node = ctx.graph.getNode(id);
|
|
109
|
+
if (!node) return false;
|
|
110
|
+
const range = selectedRange(id);
|
|
111
|
+
return (range ? mixedTextStyleKeys(node, range[0], range[1]) : mixedTextStyleKeys(node)).includes(key);
|
|
112
|
+
}
|
|
106
113
|
return {
|
|
107
114
|
updateNode,
|
|
108
115
|
updateNodeWithUndo,
|
|
109
116
|
commitNodeUpdate,
|
|
110
117
|
selectionStyle,
|
|
111
|
-
layerChanges
|
|
118
|
+
layerChanges,
|
|
119
|
+
isTextStyleMixed
|
|
112
120
|
};
|
|
113
121
|
}
|
|
114
122
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-style.js","names":[],"sources":["../../../src/editor/text/selection-style.ts"],"sourcesContent":["import { omit, pick } from 'es-toolkit/object'\nimport { isEqual } from 'es-toolkit/predicate'\n\nimport type { CharacterStyleOverride, SceneNode, StyleRun } from '@pairdraw/scene-graph'\n\nimport type { EditorContext } from '#core/editor/types'\nimport {\n characterStyles,\n layerTextStyleChanges,\n shownTextStyle,\n styleRunsWithPatch,\n TEXT_STYLE_KEYS,\n type TextStyleKey\n} from '#core/text/character-style'\n\ntype NodeUpdate = (id: string, changes: Partial<SceneNode>) => void\n\nfunction styleKeys(changes: Partial<SceneNode>): TextStyleKey[] {\n return TEXT_STYLE_KEYS.filter((key) => Object.hasOwn(changes, key))\n}\n\n/**\n * While text is edited with characters selected, a property its characters can each have, such\n * as a fill or font size, styles the selected characters instead of the layer, as in Figma. A\n * change that applies a text style still applies to the layer.\n */\nexport function createTextSelectionStyle(\n ctx: EditorContext,\n runTextEditStep: (change: () => void) => void\n) {\n /**\n * The style runs a previewed change started from, which its commit records as undone to, and\n * the runs it last left; anything else changing them since ends the preview.\n */\n let preview: { nodeId: string; start: StyleRun[]; shown: StyleRun[] } | null = null\n\n function previewOf(id: string) {\n const node = ctx.graph.getNode(id)\n // Graph values are replaced rather than written into, so the runs it left are still its own.\n return preview?.nodeId === id && node?.styleRuns === preview.shown ? preview : null\n }\n\n function selectedRange(id: string): [number, number] | null {\n if (ctx.state.editingTextId !== id) return null\n return ctx.getTextEditor()?.getSelectionRange() ?? null\n }\n\n function rangeChanges(id: string, changes: Partial<SceneNode>): Partial<SceneNode> | null {\n const range = selectedRange(id)\n const node = ctx.graph.getNode(id)\n const keys = styleKeys(changes)\n if (!range || !node || keys.length === 0 || Object.hasOwn(changes, 'textStyleId')) return null\n const patch = pick(changes, keys) as CharacterStyleOverride\n return { ...omit(changes, keys), styleRuns: styleRunsWithPatch(node, ...range, patch) }\n }\n\n /** A change shown before it is committed, such as a dragged field. */\n function updateNode(id: string, changes: Partial<SceneNode>, update: NodeUpdate) {\n const ranged = rangeChanges(id, changes)\n if (!ranged) {\n update(id, changes)\n return\n }\n const current = previewOf(id)\n let start = current?.start ?? []\n // What was typed becomes a step of its own before the preview starts.\n if (!current) {\n runTextEditStep(() => {\n start = structuredClone(ctx.graph.getNode(id)?.styleRuns ?? [])\n })\n }\n update(id, ranged)\n preview = { nodeId: id, start, shown: ctx.graph.getNode(id)?.styleRuns ?? [] }\n }\n\n function updateNodeWithUndo(id: string, changes: Partial<SceneNode>, update: NodeUpdate) {\n const ranged = rangeChanges(id, changes)\n if (!ranged) {\n update(id, changes)\n return\n }\n preview = null\n runTextEditStep(() => update(id, ranged))\n }\n\n /**\n * Records a previewed change, given the values it replaced. The selected characters had\n * styles of their own, so the step undoes to the runs the preview started from.\n */\n function commitNodeUpdate(\n id: string,\n previous: Partial<SceneNode>,\n commit: NodeUpdate,\n updateWithUndo: NodeUpdate\n ) {\n const current = previewOf(id)\n const keys = styleKeys(previous)\n preview = null\n if (!current || keys.length === 0) {\n commit(id, previous)\n return\n }\n const previewed = current.shown\n // Back to where the preview started, so the edit session records nothing of its own.\n ctx.graph.updateNode(id, { styleRuns: current.start })\n runTextEditStep(() => {\n if (!isEqual(previewed, current.start)) updateWithUndo(id, { styleRuns: previewed })\n commit(id, omit(previous, keys))\n })\n }\n\n /**\n * The style of the selected characters as the layer's own properties, for the panel to show;\n * characters styled differently show the first one's. A text not being edited shows its first\n * character's, so a style its ranges set shows instead of one they hide.\n */\n function selectionStyle(node: SceneNode): Partial<SceneNode> | null {\n const range = selectedRange(node.id)\n if (!range) return shownTextStyle(node)\n const [style] = characterStyles(node, range[0], range[0] + 1)\n // Links, styles, and bindings of characters are not the layer's own properties.\n return pick(style, TEXT_STYLE_KEYS)\n }\n\n /**\n * A change the panel makes to a layer: on a text not being edited, a style it sets applies to\n * every character, so a range styled on its own no longer hides it. While text is edited the\n * change goes to the selected characters, as `updateNode` sends it.\n */\n function layerChanges(id: string, changes: Partial<SceneNode>): Partial<SceneNode> {\n const node = ctx.graph.getNode(id)\n if (!node || ctx.state.editingTextId === id) return changes\n return layerTextStyleChanges(node, changes)\n }\n\n
|
|
1
|
+
{"version":3,"file":"selection-style.js","names":[],"sources":["../../../src/editor/text/selection-style.ts"],"sourcesContent":["import { omit, pick } from 'es-toolkit/object'\nimport { isEqual } from 'es-toolkit/predicate'\n\nimport type { CharacterStyleOverride, SceneNode, StyleRun } from '@pairdraw/scene-graph'\n\nimport type { EditorContext } from '#core/editor/types'\nimport {\n characterStyles,\n layerTextStyleChanges,\n mixedTextStyleKeys,\n shownTextStyle,\n styleRunsWithPatch,\n TEXT_STYLE_KEYS,\n type TextStyleKey\n} from '#core/text/character-style'\n\ntype NodeUpdate = (id: string, changes: Partial<SceneNode>) => void\n\nfunction styleKeys(changes: Partial<SceneNode>): TextStyleKey[] {\n return TEXT_STYLE_KEYS.filter((key) => Object.hasOwn(changes, key))\n}\n\n/**\n * While text is edited with characters selected, a property its characters can each have, such\n * as a fill or font size, styles the selected characters instead of the layer, as in Figma. A\n * change that applies a text style still applies to the layer.\n */\nexport function createTextSelectionStyle(\n ctx: EditorContext,\n runTextEditStep: (change: () => void) => void\n) {\n /**\n * The style runs a previewed change started from, which its commit records as undone to, and\n * the runs it last left; anything else changing them since ends the preview.\n */\n let preview: { nodeId: string; start: StyleRun[]; shown: StyleRun[] } | null = null\n\n function previewOf(id: string) {\n const node = ctx.graph.getNode(id)\n // Graph values are replaced rather than written into, so the runs it left are still its own.\n return preview?.nodeId === id && node?.styleRuns === preview.shown ? preview : null\n }\n\n function selectedRange(id: string): [number, number] | null {\n if (ctx.state.editingTextId !== id) return null\n return ctx.getTextEditor()?.getSelectionRange() ?? null\n }\n\n function rangeChanges(id: string, changes: Partial<SceneNode>): Partial<SceneNode> | null {\n const range = selectedRange(id)\n const node = ctx.graph.getNode(id)\n const keys = styleKeys(changes)\n if (!range || !node || keys.length === 0 || Object.hasOwn(changes, 'textStyleId')) return null\n const patch = pick(changes, keys) as CharacterStyleOverride\n return { ...omit(changes, keys), styleRuns: styleRunsWithPatch(node, ...range, patch) }\n }\n\n /** A change shown before it is committed, such as a dragged field. */\n function updateNode(id: string, changes: Partial<SceneNode>, update: NodeUpdate) {\n const ranged = rangeChanges(id, changes)\n if (!ranged) {\n update(id, changes)\n return\n }\n const current = previewOf(id)\n let start = current?.start ?? []\n // What was typed becomes a step of its own before the preview starts.\n if (!current) {\n runTextEditStep(() => {\n start = structuredClone(ctx.graph.getNode(id)?.styleRuns ?? [])\n })\n }\n update(id, ranged)\n preview = { nodeId: id, start, shown: ctx.graph.getNode(id)?.styleRuns ?? [] }\n }\n\n function updateNodeWithUndo(id: string, changes: Partial<SceneNode>, update: NodeUpdate) {\n const ranged = rangeChanges(id, changes)\n if (!ranged) {\n update(id, changes)\n return\n }\n preview = null\n runTextEditStep(() => update(id, ranged))\n }\n\n /**\n * Records a previewed change, given the values it replaced. The selected characters had\n * styles of their own, so the step undoes to the runs the preview started from.\n */\n function commitNodeUpdate(\n id: string,\n previous: Partial<SceneNode>,\n commit: NodeUpdate,\n updateWithUndo: NodeUpdate\n ) {\n const current = previewOf(id)\n const keys = styleKeys(previous)\n preview = null\n if (!current || keys.length === 0) {\n commit(id, previous)\n return\n }\n const previewed = current.shown\n // Back to where the preview started, so the edit session records nothing of its own.\n ctx.graph.updateNode(id, { styleRuns: current.start })\n runTextEditStep(() => {\n if (!isEqual(previewed, current.start)) updateWithUndo(id, { styleRuns: previewed })\n commit(id, omit(previous, keys))\n })\n }\n\n /**\n * The style of the selected characters as the layer's own properties, for the panel to show;\n * characters styled differently show the first one's. A text not being edited shows its first\n * character's, so a style its ranges set shows instead of one they hide.\n */\n function selectionStyle(node: SceneNode): Partial<SceneNode> | null {\n const range = selectedRange(node.id)\n if (!range) return shownTextStyle(node)\n const [style] = characterStyles(node, range[0], range[0] + 1)\n // Links, styles, and bindings of characters are not the layer's own properties.\n return pick(style, TEXT_STYLE_KEYS)\n }\n\n /**\n * A change the panel makes to a layer: on a text not being edited, a style it sets applies to\n * every character, so a range styled on its own no longer hides it. While text is edited the\n * change goes to the selected characters, as `updateNode` sends it.\n */\n function layerChanges(id: string, changes: Partial<SceneNode>): Partial<SceneNode> {\n const node = ctx.graph.getNode(id)\n if (!node || ctx.state.editingTextId === id) return changes\n return layerTextStyleChanges(node, changes)\n }\n\n /** Whether the characters the panel would edit differ in this style, so the row shows Mixed. */\n function isTextStyleMixed(id: string, key: string): boolean {\n const node = ctx.graph.getNode(id)\n if (!node) return false\n const range = selectedRange(id)\n const keys = range ? mixedTextStyleKeys(node, range[0], range[1]) : mixedTextStyleKeys(node)\n return (keys as readonly string[]).includes(key)\n }\n\n return {\n updateNode,\n updateNodeWithUndo,\n commitNodeUpdate,\n selectionStyle,\n layerChanges,\n isTextStyleMixed\n }\n}\n"],"mappings":";;;;AAkBA,SAAS,UAAU,SAA6C;CAC9D,OAAO,gBAAgB,QAAQ,QAAQ,OAAO,OAAO,SAAS,GAAG,CAAC;AACpE;;;;;;AAOA,SAAgB,yBACd,KACA,iBACA;;;;;CAKA,IAAI,UAA2E;CAE/E,SAAS,UAAU,IAAY;EAC7B,MAAM,OAAO,IAAI,MAAM,QAAQ,EAAE;EAEjC,OAAO,SAAS,WAAW,MAAM,MAAM,cAAc,QAAQ,QAAQ,UAAU;CACjF;CAEA,SAAS,cAAc,IAAqC;EAC1D,IAAI,IAAI,MAAM,kBAAkB,IAAI,OAAO;EAC3C,OAAO,IAAI,cAAc,CAAC,EAAE,kBAAkB,KAAK;CACrD;CAEA,SAAS,aAAa,IAAY,SAAwD;EACxF,MAAM,QAAQ,cAAc,EAAE;EAC9B,MAAM,OAAO,IAAI,MAAM,QAAQ,EAAE;EACjC,MAAM,OAAO,UAAU,OAAO;EAC9B,IAAI,CAAC,SAAS,CAAC,QAAQ,KAAK,WAAW,KAAK,OAAO,OAAO,SAAS,aAAa,GAAG,OAAO;EAC1F,MAAM,QAAQ,KAAK,SAAS,IAAI;EAChC,OAAO;GAAE,GAAG,KAAK,SAAS,IAAI;GAAG,WAAW,mBAAmB,MAAM,GAAG,OAAO,KAAK;EAAE;CACxF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MAAM,MAAM,IAAI,MAAM,KAAK,CAAC;EAE5D,OAAO,KAAK,OAAO,eAAe;CACpC;;;;;;CAOA,SAAS,aAAa,IAAY,SAAiD;EACjF,MAAM,OAAO,IAAI,MAAM,QAAQ,EAAE;EACjC,IAAI,CAAC,QAAQ,IAAI,MAAM,kBAAkB,IAAI,OAAO;EACpD,OAAO,sBAAsB,MAAM,OAAO;CAC5C;;CAGA,SAAS,iBAAiB,IAAY,KAAsB;EAC1D,MAAM,OAAO,IAAI,MAAM,QAAQ,EAAE;EACjC,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,QAAQ,cAAc,EAAE;EAE9B,QADa,QAAQ,mBAAmB,MAAM,MAAM,IAAI,MAAM,EAAE,IAAI,mBAAmB,IAAI,EAAA,CACxD,SAAS,GAAG;CACjD;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.d.ts","names":[],"sources":["../../src/editor/tool-registry.ts"],"mappings":";;UAEiB;EACf,KAAK;EACL;EACA;EACA,SAAS;;cAGE,cAAc;
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","names":[],"sources":["../../src/editor/tool-registry.ts"],"mappings":";;UAEiB;EACf,KAAK;EACL;EACA;EACA,SAAS;;cAGE,cAAc;cAwBd,gBAAgB,QAAQ,eAAe;;;;;cAuBvC,aAAa,YAAY;;cAazB,sBAAsB,QAAQ,eAAe"}
|
|
@@ -30,6 +30,11 @@ const EDITOR_TOOLS = [
|
|
|
30
30
|
shortcut: "P",
|
|
31
31
|
flyout: ["PEN", "PENCIL"]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
key: "SLICE",
|
|
35
|
+
label: "Slice",
|
|
36
|
+
shortcut: "S"
|
|
37
|
+
},
|
|
33
38
|
{
|
|
34
39
|
key: "TEXT",
|
|
35
40
|
label: "Text",
|
|
@@ -68,6 +73,7 @@ const TOOL_SHORTCUTS = {
|
|
|
68
73
|
KeyA: "FRAME",
|
|
69
74
|
"Shift+KeyS": "SECTION",
|
|
70
75
|
KeyR: "RECTANGLE",
|
|
76
|
+
KeyS: "SLICE",
|
|
71
77
|
KeyO: "ELLIPSE",
|
|
72
78
|
KeyL: "LINE",
|
|
73
79
|
KeyT: "TEXT",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.js","names":[],"sources":["../../src/editor/tool-registry.ts"],"sourcesContent":["import type { Tool } from './types'\n\nexport interface EditorToolDef {\n key: Tool\n label: string\n shortcut: string\n flyout?: Tool[]\n}\n\nexport const EDITOR_TOOLS: EditorToolDef[] = [\n // Figma keeps Scale (K) in the Move flyout.\n { key: 'SELECT', label: 'Move', shortcut: 'V', flyout: ['SELECT', 'SCALE'] },\n { key: 'FRAME', label: 'Frame', shortcut: 'F', flyout: ['FRAME', 'SECTION'] },\n {\n key: 'RECTANGLE',\n label: 'Rectangle',\n shortcut: 'R',\n flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR']\n },\n { key: 'PEN', label: 'Pen', shortcut: 'P', flyout: ['PEN', 'PENCIL'] },\n { key: 'TEXT', label: 'Text', shortcut: 'T' },\n // Figma's S is Slice, and FigJam's sticky tool has no key in Figma Design.\n { key: 'STICKY', label: 'Sticky note', shortcut: '' },\n // FigJam's R; here R is the rectangle, as in Figma Design.\n { key: 'SHAPE_WITH_TEXT', label: 'Shape', shortcut: '' },\n // FigJam's X; Figma Design has no connector tool to take a key from.\n { key: 'CONNECTOR', label: 'Connector', shortcut: '' },\n // Zoom is held on Z, as in Figma, or picked here to stay on.\n { key: 'HAND', label: 'Hand', shortcut: 'H', flyout: ['HAND', 'ZOOM'] },\n { key: 'COMMENT', label: 'Comment', shortcut: 'C' }\n]\n\nexport const TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyF: 'FRAME',\n KeyA: 'FRAME',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'RECTANGLE',\n KeyO: 'ELLIPSE',\n KeyL: 'LINE',\n KeyT: 'TEXT',\n KeyP: 'PEN',\n 'Shift+KeyP': 'PENCIL',\n KeyH: 'HAND',\n KeyC: 'COMMENT',\n KeyK: 'SCALE',\n KeyZ: 'ZOOM',\n KeyI: 'EYEDROPPER'\n}\n\n/**\n * The tools a board offers, as FigJam's toolbar does: moving and panning, sticky notes, shapes,\n * connectors, sections, text, and comments, without Figma Design's drawing tools.\n */\nexport const BOARD_TOOLS: ReadonlySet<Tool> = new Set<Tool>([\n 'SELECT',\n 'HAND',\n 'STICKY',\n 'SHAPE_WITH_TEXT',\n 'CONNECTOR',\n 'SECTION',\n 'TEXT',\n 'COMMENT',\n 'ZOOM'\n])\n\n/** A board's tool keys, as in FigJam: S places a sticky note, R a shape, and X a connector. */\nexport const BOARD_TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyH: 'HAND',\n KeyS: 'STICKY',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'SHAPE_WITH_TEXT',\n KeyX: 'CONNECTOR',\n KeyT: 'TEXT',\n KeyC: 'COMMENT',\n KeyZ: 'ZOOM'\n}\n"],"mappings":";AASA,MAAa,eAAgC;CAE3C;EAAE,KAAK;EAAU,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,UAAU,OAAO;CAAE;CAC3E;EAAE,KAAK;EAAS,OAAO;EAAS,UAAU;EAAK,QAAQ,CAAC,SAAS,SAAS;CAAE;CAC5E;EACE,KAAK;EACL,OAAO;EACP,UAAU;EACV,QAAQ;GAAC;GAAa;GAAQ;GAAW;GAAW;EAAM;CAC5D;CACA;EAAE,KAAK;EAAO,OAAO;EAAO,UAAU;EAAK,QAAQ,CAAC,OAAO,QAAQ;CAAE;CACrE;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;CAAI;CAE5C;EAAE,KAAK;EAAU,OAAO;EAAe,UAAU;CAAG;CAEpD;EAAE,KAAK;EAAmB,OAAO;EAAS,UAAU;CAAG;CAEvD;EAAE,KAAK;EAAa,OAAO;EAAa,UAAU;CAAG;CAErD;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,QAAQ,MAAM;CAAE;CACtE;EAAE,KAAK;EAAW,OAAO;EAAW,UAAU;CAAI;AACpD;AAEA,MAAa,iBAAgD;CAC3D,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR;;;;;AAMA,MAAa,8BAAiC,IAAI,IAAU;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,uBAAsD;CACjE,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR"}
|
|
1
|
+
{"version":3,"file":"tool-registry.js","names":[],"sources":["../../src/editor/tool-registry.ts"],"sourcesContent":["import type { Tool } from './types'\n\nexport interface EditorToolDef {\n key: Tool\n label: string\n shortcut: string\n flyout?: Tool[]\n}\n\nexport const EDITOR_TOOLS: EditorToolDef[] = [\n // Figma keeps Scale (K) in the Move flyout.\n { key: 'SELECT', label: 'Move', shortcut: 'V', flyout: ['SELECT', 'SCALE'] },\n { key: 'FRAME', label: 'Frame', shortcut: 'F', flyout: ['FRAME', 'SECTION'] },\n {\n key: 'RECTANGLE',\n label: 'Rectangle',\n shortcut: 'R',\n flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR']\n },\n { key: 'PEN', label: 'Pen', shortcut: 'P', flyout: ['PEN', 'PENCIL'] },\n { key: 'SLICE', label: 'Slice', shortcut: 'S' },\n { key: 'TEXT', label: 'Text', shortcut: 'T' },\n // Figma's S is Slice, and FigJam's sticky tool has no key in Figma Design.\n { key: 'STICKY', label: 'Sticky note', shortcut: '' },\n // FigJam's R; here R is the rectangle, as in Figma Design.\n { key: 'SHAPE_WITH_TEXT', label: 'Shape', shortcut: '' },\n // FigJam's X; Figma Design has no connector tool to take a key from.\n { key: 'CONNECTOR', label: 'Connector', shortcut: '' },\n // Zoom is held on Z, as in Figma, or picked here to stay on.\n { key: 'HAND', label: 'Hand', shortcut: 'H', flyout: ['HAND', 'ZOOM'] },\n { key: 'COMMENT', label: 'Comment', shortcut: 'C' }\n]\n\nexport const TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyF: 'FRAME',\n KeyA: 'FRAME',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'RECTANGLE',\n KeyS: 'SLICE',\n KeyO: 'ELLIPSE',\n KeyL: 'LINE',\n KeyT: 'TEXT',\n KeyP: 'PEN',\n 'Shift+KeyP': 'PENCIL',\n KeyH: 'HAND',\n KeyC: 'COMMENT',\n KeyK: 'SCALE',\n KeyZ: 'ZOOM',\n KeyI: 'EYEDROPPER'\n}\n\n/**\n * The tools a board offers, as FigJam's toolbar does: moving and panning, sticky notes, shapes,\n * connectors, sections, text, and comments, without Figma Design's drawing tools.\n */\nexport const BOARD_TOOLS: ReadonlySet<Tool> = new Set<Tool>([\n 'SELECT',\n 'HAND',\n 'STICKY',\n 'SHAPE_WITH_TEXT',\n 'CONNECTOR',\n 'SECTION',\n 'TEXT',\n 'COMMENT',\n 'ZOOM'\n])\n\n/** A board's tool keys, as in FigJam: S places a sticky note, R a shape, and X a connector. */\nexport const BOARD_TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyH: 'HAND',\n KeyS: 'STICKY',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'SHAPE_WITH_TEXT',\n KeyX: 'CONNECTOR',\n KeyT: 'TEXT',\n KeyC: 'COMMENT',\n KeyZ: 'ZOOM'\n}\n"],"mappings":";AASA,MAAa,eAAgC;CAE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";
|
|
|
22
22
|
import { Color as Color$1, Rect, Vector } from "@pairdraw/scene-graph/primitives";
|
|
23
23
|
import { SnapGuide } from "@pairdraw/scene-graph/snap";
|
|
24
24
|
//#region src/editor/types.d.ts
|
|
25
|
-
type Tool = 'SELECT' | 'FRAME' | 'SECTION' | 'RECTANGLE' | 'ELLIPSE' | 'LINE' | 'POLYGON' | 'STAR' | 'TEXT' | 'STICKY' | 'SHAPE_WITH_TEXT' | 'CONNECTOR' | 'PEN' | 'PENCIL' | 'HAND' | 'COMMENT' |
|
|
25
|
+
type Tool = 'SELECT' | 'FRAME' | 'SECTION' | 'SLICE' | 'RECTANGLE' | 'ELLIPSE' | 'LINE' | 'POLYGON' | 'STAR' | 'TEXT' | 'STICKY' | 'SHAPE_WITH_TEXT' | 'CONNECTOR' | 'PEN' | 'PENCIL' | 'HAND' | 'COMMENT' |
|
|
26
26
|
/** Figma's Z: a click zooms in, ⌥ and a click out, and a drag zooms to the dragged area. */
|
|
27
27
|
'ZOOM' |
|
|
28
28
|
/** Figma's K: handles scale layers with their text, strokes, effects, and spacing. */
|
|
@@ -69,6 +69,10 @@ interface EditorSharedState {
|
|
|
69
69
|
snappingPreferences: SnappingPreferences;
|
|
70
70
|
/** Draw the pixel grid once zoomed in far enough, as Figma's View › Pixel grid; shown unless false. */
|
|
71
71
|
showPixelGrid?: boolean;
|
|
72
|
+
/** Figma's View › Layout grids; false hides every layout grid while it is off. */
|
|
73
|
+
showLayoutGrids?: boolean;
|
|
74
|
+
/** Figma's View › Annotations. */
|
|
75
|
+
showAnnotations?: boolean;
|
|
72
76
|
/** The gradient being edited, whose handles the canvas draws and drags. */
|
|
73
77
|
gradientEdit?: GradientEdit | null;
|
|
74
78
|
/** The image fill whose crop and framing the canvas edits, in place of the selection handles. */
|
|
@@ -163,6 +167,8 @@ interface EditorViewState {
|
|
|
163
167
|
index?: number;
|
|
164
168
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
165
169
|
} | null;
|
|
170
|
+
/** The flow layer a panel spacing control is showing the padding and gap bands of. */
|
|
171
|
+
layoutSpacingNodeId: string | null;
|
|
166
172
|
shapeHandleHover: ShapeHandleHover | null;
|
|
167
173
|
/** The layer a connector end being drawn or dragged would attach to, and by which magnet. */
|
|
168
174
|
connectorTarget: ConnectorTarget | null;
|
|
@@ -193,6 +199,11 @@ interface ClipboardImageResolution {
|
|
|
193
199
|
missing: number;
|
|
194
200
|
fetchAttempted: boolean;
|
|
195
201
|
}
|
|
202
|
+
/** The pattern fills a paste received whose source layer is not in the document. */
|
|
203
|
+
interface ClipboardPatternSources {
|
|
204
|
+
total: number;
|
|
205
|
+
missing: number;
|
|
206
|
+
}
|
|
196
207
|
type FigmaClipboardImageResolver = (fileKey: string, hashes: string[]) => Promise<ReadonlyMap<string, Uint8Array>>;
|
|
197
208
|
interface EditorEvents extends SceneGraphEvents {
|
|
198
209
|
'render:requested': (versions: {
|
|
@@ -217,6 +228,7 @@ interface EditorEvents extends SceneGraphEvents {
|
|
|
217
228
|
'page:leaving': (pageId: string, nextPageId: string) => void;
|
|
218
229
|
'guides:changed': (ownerId: string, guides: readonly CanvasGuide[]) => void;
|
|
219
230
|
'clipboard:images-missing': (resolution: ClipboardImageResolution) => void;
|
|
231
|
+
'clipboard:pattern-sources-missing': (resolution: ClipboardPatternSources) => void;
|
|
220
232
|
/** Turning a main component back into a frame was asked for; the front end confirms it. */
|
|
221
233
|
'component:to-frame-requested': (componentId: string) => void;
|
|
222
234
|
/** A text link to a web or mail address was followed; the front end opens it outside. */
|
|
@@ -308,5 +320,5 @@ interface EditorContext {
|
|
|
308
320
|
subscribeToGraph: () => void;
|
|
309
321
|
}
|
|
310
322
|
//#endregion
|
|
311
|
-
export { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, NavigationPhase, NavigationState, PencilState, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas };
|
|
323
|
+
export { ClipboardImageResolution, ClipboardPatternSources, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, NavigationPhase, NavigationState, PencilState, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas };
|
|
312
324
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/editor/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KAsCY;;;;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/editor/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KAsCY;;;;;;;;UA0BK;EACf;EACA;EACA;;EAEA;;;UAIe;EACf;;EAEA;;;UAIe;EACf;;EAEA;;EAEA,QAAQ;;EAER;;EAEA,SAAS;;UAGM;EACf,YAAY;;EAEZ,mBAAmB;;;;;;EAMnB,cAAc;EACd,kBAAkB;EAClB,qBAAqB;;EAErB;;EAEA;;EAEA;;EAEA,eAAe;;EAEf,YAAY;EACZ,iBAAiB;EACjB;;EAEA,sBAAsB;;EAEtB;EACA,aAAa;;EAEb,iBAAiB;;EAEjB,QAAQ;;EAER;;;;;EAKA;;;;;;UAOe;EACf,SAAS;;EAET;;EAEA,UAAU;IAAQ;IAAe;;;UAGlB;EACf,QAAQ;;EAER;;EAEA;IAAW,OAAO;IAAO;;;UAGV;EACf;EACA,aAAa;EACb,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,iBAAiB;EACjB;EACA;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;EAEA;EACA,iBAAiB;EACjB;;EAEA;EACA;IACE,UAAU;IACV,UAAU;IACV,aAAa;IACb,qBAAqB;IACrB;IACA;IACA;IACA,cAAc;IACd,eAAe;IACf,iBAAiB;;EAEnB;EACA;;EAEA,aAAa;EACb;IACE;IACA;;IAEA;IACA;IAC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C,yBAAyB;EACzB;EACA,OAAO;EACP,aAAa;EACb,mBAAmB;;EAEnB,oBAAoB,SAAS;EAC7B,qBAAqB;EACrB;;EAEA;EACA;EACA;EACA,gBAAgB,UAAU,iBAAiB,OAAO,GAAG,SAAS,aAAa;EAC3E,kBAAkB,UAAU,iBAC1B,OAAO,MACJ,MAAM,WAAW,aAAa;EAEnC,iBAAiB,KAAK;EACtB,gBAAgB,MAAM;EACtB,qBAAqB,OAAO,iBAAiB;EAC7C,mBAAmB;EACnB,sBAAsB,WAAW;EACjC,wBAAwB,GACtB,iBAAiB,IAAI,QAAQ,IAC7B,qBAEA;;EAAA,gBAAgB,QAAQ,GAAG,QAAQ,wBAAwB,yBACxD,QAAQ;EACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable-bindings.d.ts","names":[],"sources":["../../src/editor/variable-bindings.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"variable-bindings.d.ts","names":[],"sources":["../../src/editor/variable-bindings.ts"],"mappings":";;iBA0BgB,6BAA6B,KAAK;EA8FvB,eAAA,gBAAM,cAAc;EAElB,iBAAA,gBAAM"}
|
|
@@ -2,7 +2,7 @@ import { reconcileVariableLayouts } from "../layout/variables.js";
|
|
|
2
2
|
import { loadBoundFonts } from "./text/bound-fonts.js";
|
|
3
3
|
import { loadBoundIcons } from "./icons.js";
|
|
4
4
|
import { copyFills, copyStrokes } from "@pairdraw/scene-graph/copy";
|
|
5
|
-
import { isNumericVariableBindingField, paintBindingTarget, variableBindingOwner } from "@pairdraw/scene-graph/variables";
|
|
5
|
+
import { effectBindingTarget, isNumericVariableBindingField, layoutGridBindingTarget, paintBindingTarget, variableBindingOwner } from "@pairdraw/scene-graph/variables";
|
|
6
6
|
import { findInstanceAncestor, recordInstanceOverride } from "@pairdraw/scene-graph/instances";
|
|
7
7
|
import { cloneInstanceOverrideState } from "@pairdraw/scene-graph/instances/overrides";
|
|
8
8
|
//#region src/editor/variable-bindings.ts
|
|
@@ -38,6 +38,10 @@ function createVariableBindingActions(ctx) {
|
|
|
38
38
|
color: { ...targetPaint.color },
|
|
39
39
|
opacity: targetPaint.opacity
|
|
40
40
|
} : null;
|
|
41
|
+
let listField = null;
|
|
42
|
+
if (effectBindingTarget(path)) listField = "effects";
|
|
43
|
+
else if (layoutGridBindingTarget(path)) listField = "layoutGrids";
|
|
44
|
+
const previousList = listField ? structuredClone(listField === "effects" ? node.effects : node.layoutGrids) : null;
|
|
41
45
|
const owner = variableBindingOwner(ctx.graph, node);
|
|
42
46
|
const nearest = findInstanceAncestor(ctx.graph, nodeId);
|
|
43
47
|
const owners = new Map([owner, ...nearest ? [nearest] : []].map((item) => [item.id, cloneInstanceOverrideState(item.instanceOverrides)]));
|
|
@@ -72,6 +76,7 @@ function createVariableBindingActions(ctx) {
|
|
|
72
76
|
});
|
|
73
77
|
Object.assign(restored, { [list]: paints });
|
|
74
78
|
}
|
|
79
|
+
if (listField && previousList) Object.assign(restored, { [listField]: previousList });
|
|
75
80
|
ctx.graph.updateNode(nodeId, restored);
|
|
76
81
|
refreshBindings(nodeId);
|
|
77
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable-bindings.js","names":[],"sources":["../../src/editor/variable-bindings.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\nimport { copyFills, copyStrokes } from '@pairdraw/scene-graph/copy'\nimport { findInstanceAncestor, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport { cloneInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'\nimport {\n variableBindingOwner,\n isNumericVariableBindingField,\n paintBindingTarget\n} from '@pairdraw/scene-graph/variables'\n\nimport { reconcileVariableLayouts } from '#core/layout/variables'\n\nimport { loadBoundIcons } from './icons'\nimport { loadBoundFonts } from './text/bound-fonts'\nimport type { EditorContext } from './types'\n\n/**\n * Fields whose value undoing a binding puts back: numbers, and a font family, whose change shows\n * as a different typeface. Text and visibility keep what the variable gave them, as in Figma.\n */\nfunction restoresValue(path: string): boolean {\n return isNumericVariableBindingField(path) || path === 'fontFamily'\n}\n\nexport function createVariableBindingActions(ctx: EditorContext) {\n /** A binding change reaches only the layer it is on and the layers inside it. */\n function refreshBindings(nodeId: string) {\n const changed = reconcileVariableLayouts(ctx.graph, { subtrees: [nodeId] })\n loadBoundFonts(ctx, changed)\n void loadBoundIcons(ctx, { subtrees: [nodeId] }).catch((error: unknown) => {\n console.warn(\n 'Loading a bound icon failed:',\n error instanceof Error ? error.message : String(error)\n )\n })\n ctx.requestRender()\n }\n\n function changeBinding(nodeId: string, path: string, variableId?: string) {\n const node = ctx.graph.getNode(nodeId)\n if (!node || (variableId === undefined && !(path in node.boundVariables))) return\n const previous = {\n boundVariables: { ...node.boundVariables },\n variableBindingScales: { ...node.variableBindingScales },\n ...(restoresValue(path) ? { [path]: node[path as keyof SceneNode] } : {})\n }\n // Binding a paint gives it its variable's color, which undo takes back from that paint alone.\n const target = paintBindingTarget(path)\n const targetPaint = target ? node[target.list].at(target.index) : undefined\n const previousPaint =\n target && targetPaint\n ? { ...target, color: { ...targetPaint.color }, opacity: targetPaint.opacity }\n : null\n const owner = variableBindingOwner(ctx.graph, node)\n const nearest = findInstanceAncestor(ctx.graph, nodeId)\n const owners = new Map(\n [owner, ...(nearest ? [nearest] : [])].map(\n (item) => [item.id, cloneInstanceOverrideState(item.instanceOverrides)] as const\n )\n )\n const apply = () => {\n if (variableId === undefined) ctx.graph.unbindVariable(nodeId, path)\n else ctx.graph.bindVariable(nodeId, path, variableId)\n // The field a path names (`fills/0/color` names `fills`) is an instance override, as the\n // file records it: an instance that draws a variable's colour keeps it when its component\n // changes, and the live document has to name that field too.\n recordInstanceOverride(ctx.graph, nodeId, [path.split('/')[0] ?? path])\n refreshBindings(nodeId)\n }\n apply()\n ctx.undo.push({\n label: variableId === undefined ? 'Unbind variable' : 'Bind variable',\n forward: () => {\n try {\n apply()\n } catch (error) {\n console.warn(\n 'Redo variable binding failed:',\n error instanceof Error ? error.message : String(error)\n )\n }\n },\n inverse: () => {\n for (const [id, state] of owners) {\n ctx.graph.updateNode(id, { instanceOverrides: cloneInstanceOverrideState(state) })\n }\n const restored = structuredClone(previous)\n restored.boundVariables = Object.fromEntries(\n Object.entries(restored.boundVariables).filter(([, id]) => ctx.graph.variables.has(id))\n )\n restored.variableBindingScales = Object.fromEntries(\n Object.entries(restored.variableBindingScales).filter(\n ([field]) => field in restored.boundVariables\n )\n )\n const current = ctx.graph.getNode(nodeId)\n if (previousPaint && current?.[previousPaint.list].at(previousPaint.index)) {\n const { list, index, color, opacity } = previousPaint\n const paints = list === 'fills' ? copyFills(current.fills) : copyStrokes(current.strokes)\n Object.assign(paints[index], { color: { ...color }, opacity })\n Object.assign(restored, { [list]: paints })\n }\n ctx.graph.updateNode(nodeId, restored)\n refreshBindings(nodeId)\n }\n })\n }\n\n return {\n bindVariable: (nodeId: string, path: string, variableId: string) =>\n changeBinding(nodeId, path, variableId),\n unbindVariable: (nodeId: string, path: string) => changeBinding(nodeId, path)\n }\n}\n"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"variable-bindings.js","names":[],"sources":["../../src/editor/variable-bindings.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\nimport { copyFills, copyStrokes } from '@pairdraw/scene-graph/copy'\nimport { findInstanceAncestor, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport { cloneInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'\nimport {\n effectBindingTarget,\n variableBindingOwner,\n isNumericVariableBindingField,\n layoutGridBindingTarget,\n paintBindingTarget\n} from '@pairdraw/scene-graph/variables'\n\nimport { reconcileVariableLayouts } from '#core/layout/variables'\n\nimport { loadBoundIcons } from './icons'\nimport { loadBoundFonts } from './text/bound-fonts'\nimport type { EditorContext } from './types'\n\n/**\n * Fields whose value undoing a binding puts back: numbers, and a font family, whose change shows\n * as a different typeface. Text and visibility keep what the variable gave them, as in Figma.\n */\nfunction restoresValue(path: string): boolean {\n return isNumericVariableBindingField(path) || path === 'fontFamily'\n}\n\nexport function createVariableBindingActions(ctx: EditorContext) {\n /** A binding change reaches only the layer it is on and the layers inside it. */\n function refreshBindings(nodeId: string) {\n const changed = reconcileVariableLayouts(ctx.graph, { subtrees: [nodeId] })\n loadBoundFonts(ctx, changed)\n void loadBoundIcons(ctx, { subtrees: [nodeId] }).catch((error: unknown) => {\n console.warn(\n 'Loading a bound icon failed:',\n error instanceof Error ? error.message : String(error)\n )\n })\n ctx.requestRender()\n }\n\n function changeBinding(nodeId: string, path: string, variableId?: string) {\n const node = ctx.graph.getNode(nodeId)\n if (!node || (variableId === undefined && !(path in node.boundVariables))) return\n const previous = {\n boundVariables: { ...node.boundVariables },\n variableBindingScales: { ...node.variableBindingScales },\n ...(restoresValue(path) ? { [path]: node[path as keyof SceneNode] } : {})\n }\n // Binding a paint gives it its variable's color, which undo takes back from that paint alone.\n const target = paintBindingTarget(path)\n const targetPaint = target ? node[target.list].at(target.index) : undefined\n const previousPaint =\n target && targetPaint\n ? { ...target, color: { ...targetPaint.color }, opacity: targetPaint.opacity }\n : null\n // An effect or grid field lives in a list, so undoing has to put that list back, as a paint's\n // colour does.\n let listField: 'effects' | 'layoutGrids' | null = null\n if (effectBindingTarget(path)) listField = 'effects'\n else if (layoutGridBindingTarget(path)) listField = 'layoutGrids'\n const previousList = listField\n ? structuredClone(listField === 'effects' ? node.effects : node.layoutGrids)\n : null\n const owner = variableBindingOwner(ctx.graph, node)\n const nearest = findInstanceAncestor(ctx.graph, nodeId)\n const owners = new Map(\n [owner, ...(nearest ? [nearest] : [])].map(\n (item) => [item.id, cloneInstanceOverrideState(item.instanceOverrides)] as const\n )\n )\n const apply = () => {\n if (variableId === undefined) ctx.graph.unbindVariable(nodeId, path)\n else ctx.graph.bindVariable(nodeId, path, variableId)\n // The field a path names (`fills/0/color` names `fills`) is an instance override, as the\n // file records it: an instance that draws a variable's colour keeps it when its component\n // changes, and the live document has to name that field too.\n recordInstanceOverride(ctx.graph, nodeId, [path.split('/')[0] ?? path])\n refreshBindings(nodeId)\n }\n apply()\n ctx.undo.push({\n label: variableId === undefined ? 'Unbind variable' : 'Bind variable',\n forward: () => {\n try {\n apply()\n } catch (error) {\n console.warn(\n 'Redo variable binding failed:',\n error instanceof Error ? error.message : String(error)\n )\n }\n },\n inverse: () => {\n for (const [id, state] of owners) {\n ctx.graph.updateNode(id, { instanceOverrides: cloneInstanceOverrideState(state) })\n }\n const restored = structuredClone(previous)\n restored.boundVariables = Object.fromEntries(\n Object.entries(restored.boundVariables).filter(([, id]) => ctx.graph.variables.has(id))\n )\n restored.variableBindingScales = Object.fromEntries(\n Object.entries(restored.variableBindingScales).filter(\n ([field]) => field in restored.boundVariables\n )\n )\n const current = ctx.graph.getNode(nodeId)\n if (previousPaint && current?.[previousPaint.list].at(previousPaint.index)) {\n const { list, index, color, opacity } = previousPaint\n const paints = list === 'fills' ? copyFills(current.fills) : copyStrokes(current.strokes)\n Object.assign(paints[index], { color: { ...color }, opacity })\n Object.assign(restored, { [list]: paints })\n }\n if (listField && previousList) Object.assign(restored, { [listField]: previousList })\n ctx.graph.updateNode(nodeId, restored)\n refreshBindings(nodeId)\n }\n })\n }\n\n return {\n bindVariable: (nodeId: string, path: string, variableId: string) =>\n changeBinding(nodeId, path, variableId),\n unbindVariable: (nodeId: string, path: string) => changeBinding(nodeId, path)\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,SAAS,cAAc,MAAuB;CAC5C,OAAO,8BAA8B,IAAI,KAAK,SAAS;AACzD;AAEA,SAAgB,6BAA6B,KAAoB;;CAE/D,SAAS,gBAAgB,QAAgB;EACvC,MAAM,UAAU,yBAAyB,IAAI,OAAO,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;EAC1E,eAAe,KAAK,OAAO;EAC3B,eAAoB,KAAK,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,UAAmB;GACzE,QAAQ,KACN,gCACA,iBAAi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ACxC,iBAAiB,QAAgB,SAAiB,cAAc,QAAQ,IAAI;CAC9E;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.d.ts","names":[],"sources":["../../../src/figma-api/accessors/basic.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"basic.d.ts","names":[],"sources":["../../../src/figma-api/accessors/basic.ts"],"mappings":";;;iBA0GgB,+BACd,mBACA,WAAW"}
|
|
@@ -2,8 +2,8 @@ import { figmaRotation } from "../../geometry/figma.js";
|
|
|
2
2
|
import { computeAccurateBounds } from "../../vector/curve-math.js";
|
|
3
3
|
import { assertNodeEditable } from "../../editor/capabilities.js";
|
|
4
4
|
import { restoredHuggedSize } from "../../layout/apply.js";
|
|
5
|
-
import { invalid, numberProblem } from "./text/messages.js";
|
|
6
5
|
import { fitGroupsAround, graph, hostFitOptions, nodeId, prepareFollowedFieldEdit, raw, updateNode } from "../accessor-utils.js";
|
|
6
|
+
import { invalid, numberProblem } from "./text/messages.js";
|
|
7
7
|
import { flushPendingLayout, flushPendingLayoutBefore } from "../pending-layout.js";
|
|
8
8
|
import { namedByText } from "../../editor/text/name.js";
|
|
9
9
|
import { syncVariantName } from "../variants.js";
|
|
@@ -61,6 +61,27 @@ function setTransform(target, internals, change) {
|
|
|
61
61
|
}
|
|
62
62
|
function installBasicNodeProxyAccessors(prototype, internals) {
|
|
63
63
|
Object.defineProperties(prototype, {
|
|
64
|
+
annotations: {
|
|
65
|
+
get() {
|
|
66
|
+
return raw(this, internals).annotations.map((annotation) => {
|
|
67
|
+
const read = { properties: annotation.properties.map((type) => ({ type })) };
|
|
68
|
+
if (annotation.label) read.label = annotation.label;
|
|
69
|
+
if (annotation.labelMarkdown) read.labelMarkdown = annotation.labelMarkdown;
|
|
70
|
+
if (annotation.categoryId) read.categoryId = annotation.categoryId;
|
|
71
|
+
return read;
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
set(value) {
|
|
75
|
+
updateNode(this, internals, { annotations: value.map((annotation) => ({
|
|
76
|
+
label: annotation.label ?? "",
|
|
77
|
+
labelMarkdown: annotation.labelMarkdown ?? annotation.label ?? "",
|
|
78
|
+
properties: (annotation.properties ?? []).map((property) => property.type),
|
|
79
|
+
categoryId: annotation.categoryId ?? null
|
|
80
|
+
})) });
|
|
81
|
+
},
|
|
82
|
+
enumerable: true,
|
|
83
|
+
configurable: true
|
|
84
|
+
},
|
|
64
85
|
id: { get() {
|
|
65
86
|
return nodeId(this, internals);
|
|
66
87
|
} },
|