@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","names":[],"sources":["../../src/editor/create.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\nimport { createNanoEvents } from 'nanoevents'\nimport type { Emitter } from 'nanoevents'\n\nimport { SceneGraph, type SceneNode } from '@pairdraw/scene-graph'\nimport { UndoManager, type UndoEntry, type UndoHistory } from '@pairdraw/scene-graph/undo'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { prefetchFigmaSchema } from '#core/clipboard'\nimport { IS_BROWSER } from '#core/constants'\nimport {\n getPageColor,\n hasStoredBackground,\n setDefaultPageBackground\n} from '#core/figma-api/page-backgrounds'\nimport { defaultIcons } from '#core/icons'\nimport { releaseFigPopulationWorker } from '#core/kiwi/fig/population/client'\nimport { releaseOriginalFigArchive } from '#core/kiwi/fig/session/original-archive'\nimport { installTextMeasurer } from '#core/layout'\nimport { createLayoutRunner } from '#core/layout/mutations'\nimport { TextEditor } from '#core/text/editor'\nimport { fontManager } from '#core/text/font/manager'\nimport { fontResolver } from '#core/text/resolver'\n\nimport { createAlignmentActions } from './alignment'\nimport { createClipboardBridge } from './bridges/clipboard'\nimport { createComponentBridge } from './bridges/components'\nimport { createFrameNavigationBridge } from './bridges/frames'\nimport { createLintFixBridge } from './bridges/lint'\nimport { createStructureBridge } from './bridges/structure'\nimport { createUndoBridge } from './bridges/undo'\nimport { createClipboardActions } from './clipboard'\nimport { createClipboardPropertiesActions } from './clipboard/paste/properties'\nimport { createColorSpaceActions } from './color-space'\nimport { createComponentSyncScheduler } from './component-sync'\nimport { createComponentActions } from './components'\nimport { createConnectorDrawActions, createConnectorEndpointActions } from './connectors/draw'\nimport { createConnectorLineActions } from './connectors/line'\nimport { createConnectorRouting } from './connectors/routing'\nimport { createConnectorStyleActions } from './connectors/style'\nimport { createDesignMemoryActions } from './design-memory'\nimport { createDesignTokenActions } from './design-tokens'\nimport { createDocumentSettingsActions } from './document-settings'\nimport { createFigCompressionActions } from './fig-compression'\nimport { createFontActions } from './fonts'\nimport { createGraphEventSubscription } from './graph-events'\nimport { createGraphReadActions } from './graph-reads'\nimport { createGuideActions } from './guides'\nimport { createIconActions } from './icons'\nimport { createImageEditActions } from './image-edit'\nimport { createDesignIssueActions } from './issues'\nimport { createLineEndActions } from './line-ends'\nimport { createNodeActions } from './nodes'\nimport { createPageActions } from './pages'\nimport { createReadOnlyActions, guardReadOnly, guardUndo } from './read-only'\nimport { createRenderRequests } from './render-requests'\nimport { createScaleActions } from './scale'\nimport { createSelectionActions } from './selection'\nimport { createShaderActions } from './shaders/actions'\nimport { createShaderFrames } from './shaders/frames'\nimport { createShapeActions } from './shapes'\nimport { createShapeWithTextActions } from './shapes/with-text'\nimport { createDefaultEditorState } from './state'\nimport { createStatusActions } from './statuses'\nimport { createStickyActions } from './stickies'\nimport { createStructureActions } from './structure'\nimport { createTextActions } from './text'\nimport { createTextHyperlinkActions } from './text/hyperlink'\nimport { createPendingTextLayout } from './text/pending-layout'\nimport { createTextSelectionStyle } from './text/selection-style'\nimport { createGeneratedTextActions } from './text/typeface'\nimport type {\n EditorContext,\n EditorEventName,\n EditorEvents,\n EditorOptions,\n EditorState,\n ViewportInsets\n} from './types'\nimport { createUndoActions } from './undo'\nimport { createVariableActions } from './variables'\nimport { createVariationActions } from './variations'\nimport { createVectorizeActions } from './vectorize'\nimport { createViewportActions, NO_VIEWPORT_INSETS } from './viewport'\nimport { createCanvasViewActions, offeredTool, resolveEditorProfile } from './views'\n\nexport { createDefaultEditorState } from './state'\n\n/** A canvas with no chrome reports nothing, which is the same as none covering it. */\nfunction resolveViewportInsets(options?: EditorOptions): () => ViewportInsets {\n return options?.getViewportInsets ?? (() => NO_VIEWPORT_INSETS)\n}\n\nexport function createEditor(options?: EditorOptions) {\n let _graph = options?.graph ?? new SceneGraph()\n const skipInitialGraphSetup = options?.skipInitialGraphSetup ?? false\n const undo = new UndoManager({\n onChange: () => emitEditorEvent('history:changed'),\n // A step owns the edited-field marks its edit added, so undo takes them back and redo\n // marks them again. The marks are the graph's, and the document can be replaced.\n marks: {\n take: () => _graph.takeSourceMarks(),\n add: (id, fields) => _graph.addSourceMarks(id, fields),\n remove: (id, fields) => _graph.removeSourceMarks(id, fields),\n preserve: (run) => _graph.preserveSourceMetadataDuring(run)\n }\n })\n const _loadFont = options?.loadFont ?? fontManager.loadFont.bind(fontManager)\n const _getViewportSize =\n options?.getViewportSize ??\n (() => {\n if (IS_BROWSER) return { width: window.innerWidth, height: window.innerHeight }\n return { width: 800, height: 600 }\n })\n const _getViewportInsets = resolveViewportInsets(options)\n let _ck: CanvasKit | null = null\n let _renderer: SkiaRenderer | null = null\n const _renderers = new Set<SkiaRenderer>()\n let uninstallTextMeasurer: (() => void) | null = null\n const interactiveEdits = new Set<symbol>()\n let _textEditor: TextEditor | null = null\n const events: Emitter<EditorEvents> = createNanoEvents()\n const stopFontResolutionEvents = fontResolver.subscribe((event, snapshot) => {\n if (event === 'settled') pendingTextLayout.relayoutReady(_renderer)\n events.emit('font:resolution-changed', event, snapshot)\n })\n const stopFontLoadEvents = fontManager.onFaceLoaded((family, style) => {\n // Text measured in a substitute takes its own face's size once a face of its family loads.\n pendingTextLayout.relayoutSubstituted(_renderer, family)\n events.emit('font:loaded', family, style)\n })\n // Text blocked while its fonts were prepared is missing from the tiles drawn meanwhile.\n const stopUnblockEvents = fontManager.onNodesUnblocked((nodeIds) => {\n let redrawn = false\n for (const renderer of _renderers) {\n for (const id of nodeIds) {\n if (!_graph.getNode(id)) continue\n renderer.invalidateNodePicture(id)\n redrawn = true\n }\n }\n if (redrawn) requestRender()\n })\n\n void prefetchFigmaSchema()\n\n const state: EditorState = options?.state ?? createDefaultEditorState(_graph.getPages()[0].id)\n state.documentKind = _graph.documentKind\n state.activeTool = offeredTool(state, state.activeTool)\n\n function emitEditorEvent<K extends EditorEventName>(\n event: K,\n ...args: Parameters<EditorEvents[K]>\n ) {\n events.emit(event, ...args)\n }\n\n function onEditorEvent<K extends EditorEventName>(event: K, handler: EditorEvents[K]) {\n return events.on(event, handler)\n }\n\n const {\n requestRender,\n requestRefresh,\n requestRepaint,\n textSelectionChanged,\n setNavigationPhase\n } = createRenderRequests(state, emitEditorEvent)\n\n /** Track an actual live edit independently of history batching. Release is idempotent. */\n function beginInteractiveEdit() {\n const token = Symbol('interactive-edit')\n interactiveEdits.add(token)\n requestRepaint()\n return () => {\n if (interactiveEdits.delete(token)) requestRepaint()\n }\n }\n\n function setSelectedIds(ids: Set<string>) {\n const previous = [...state.selectedIds]\n state.selectedIds = ids\n if (ids.size === 0) state.measurementMode = 'off'\n const selected = [...ids]\n if (\n previous.length !== selected.length ||\n previous.some((id, index) => id !== selected[index])\n ) {\n emitEditorEvent('selection:changed', selected, previous)\n }\n }\n\n function setActiveTool(tool: EditorState['activeTool']) {\n if (offeredTool(state, tool) !== tool) return\n const previous = state.activeTool\n state.activeTool = tool\n if (tool !== 'SELECT') state.measurementMode = 'off'\n if (previous === tool) return\n // Guides the pen showed for its next point do not belong to the next tool.\n if (previous === 'PEN') state.snapGuides = []\n emitEditorEvent('tool:changed', tool, previous)\n }\n\n const graphReads = createGraphReadActions(() => _graph)\n const { runLayoutForNode, runLayoutForParents, runMutationWithLayout } = createLayoutRunner(\n () => _graph\n )\n const pendingTextLayout = createPendingTextLayout({\n getGraph: () => _graph,\n runLayoutForNode,\n requestRender\n })\n const { scheduleComponentSync, flushComponentSync, isSyncingComponents } =\n createComponentSyncScheduler(() => _graph, requestRender)\n\n const { subscribeToGraph, unsubscribeFromGraph } = createGraphEventSubscription({\n getGraph: () => _graph,\n getRenderers: () => _renderers,\n scheduleComponentSync,\n requestRender,\n emitEditorEvent\n })\n\n if (!skipInitialGraphSetup) {\n subscribeToGraph()\n // A new document's first page takes Figma's background for the interface theme the app gives;\n // a page that already has one keeps it.\n const firstPage = _graph.getPages()[0]\n if (options?.state?.theme && !hasStoredBackground(firstPage)) {\n setDefaultPageBackground(_graph, firstPage, options.state.theme)\n options.state.pageColor = getPageColor(firstPage)\n }\n }\n\n // Build the shared context\n const ctx: EditorContext = {\n get graph() {\n return _graph\n },\n set graph(g) {\n _graph = g\n },\n undo,\n parkStep,\n state,\n loadFont: _loadFont,\n resolveFigmaClipboardImages: options?.resolveFigmaClipboardImages ?? null,\n getViewportSize: _getViewportSize,\n getViewportInsets: _getViewportInsets,\n getUserName: () => options?.getUserName?.() ?? '',\n icons: options?.icons ?? defaultIcons,\n getCk: () => _ck,\n getRenderer: () => _renderer,\n getRenderers: () => _renderers,\n getTextEditor: () => _textEditor,\n requestRender,\n requestRefresh,\n requestRepaint,\n beginInteractiveEdit,\n onEditorEvent,\n emitEditorEvent,\n setSelectedIds,\n setActiveTool,\n setNavigationPhase,\n runLayoutForNode,\n runLayoutForParents,\n runMutationWithLayout,\n subscribeToGraph\n }\n\n // Assemble domain modules\n const viewport = createViewportActions(ctx)\n const selection = createSelectionActions(ctx)\n const shaderFrames = createShaderFrames(ctx, options)\n const pages = createPageActions(ctx, shaderFrames)\n const guides = createGuideActions(ctx)\n const designIssues = createDesignIssueActions(ctx)\n const structure = createStructureActions(ctx)\n const components = createComponentActions(ctx)\n const clipboard = createClipboardActions(ctx)\n const colorSpace = createColorSpaceActions(ctx)\n const documentSettings = createDocumentSettingsActions(ctx)\n const undoActions = createUndoActions(ctx)\n const text = createTextActions(ctx)\n const fonts = createFontActions(ctx)\n const nodes = createNodeActions(ctx)\n const shapes = createShapeActions(ctx, nodes.updateNodeWithUndo)\n const clipboardProperties = createClipboardPropertiesActions(\n ctx,\n nodes.updateNodeWithUndo,\n clipboard.loadFontsForNodes\n )\n const variables = createVariableActions(ctx)\n const designTokens = createDesignTokenActions(ctx, variables, nodes)\n const vectorize = createVectorizeActions(ctx)\n const icons = createIconActions(ctx)\n const stickies = createStickyActions(ctx, nodes)\n const scale = createScaleActions(ctx, nodes.beginNodePreview)\n const shapesWithText = createShapeWithTextActions(ctx, nodes)\n const generatedText = createGeneratedTextActions(ctx, nodes)\n const statuses = createStatusActions(ctx)\n const designMemory = createDesignMemoryActions(ctx)\n const variations = createVariationActions(ctx)\n const figCompression = createFigCompressionActions(ctx)\n createConnectorRouting(ctx)\n const connectorDrawing = createConnectorDrawActions(ctx)\n const connectorEndpoints = createConnectorEndpointActions(\n ctx,\n nodes.beginNodePreview,\n clipboard.deleteNodes\n )\n const connectorLines = createConnectorLineActions(ctx, nodes.beginNodePreview)\n const connectorStyles = createConnectorStyleActions(ctx, nodes)\n const lineEnds = createLineEndActions(ctx, nodes.beginNodePreview)\n const imageEdit = createImageEditActions(ctx, nodes.updateNodeWithUndo)\n const shaders = createShaderActions(ctx, nodes)\n const alignment = createAlignmentActions(ctx)\n const canvasViews = createCanvasViewActions(ctx, viewport)\n const clipboardBridge = createClipboardBridge(clipboard, selection)\n const componentBridge = createComponentBridge(components, selection, structure, pages)\n const structureBridge = createStructureBridge(structure, selection)\n const frameNavigation = createFrameNavigationBridge(ctx, selection, viewport)\n const undoBridge = createUndoBridge(undoActions, selection, nodes.flushNudge)\n const lintFixBridge = createLintFixBridge(ctx, nodes, structure, clipboard)\n const textSelectionStyle = createTextSelectionStyle(ctx, text.runTextEditStep)\n const textHyperlinks = createTextHyperlinkActions(ctx, {\n updateNodeWithUndo: nodes.updateNodeWithUndo,\n runTextEditStep: text.runTextEditStep,\n switchPage: (pageId) => pages.switchPage(pageId),\n revealNodes: viewport.revealNodes\n })\n /** Whether the editor refuses edits: its profile offers none, as for a read-only document. */\n const readsOnly = () => !resolveEditorProfile(state).edits\n const readOnly = createReadOnlyActions(ctx, () => {\n nodes.flushNudge()\n nodes.cancelNodePreviews()\n if (state.editingTextId) text.commitTextEdit()\n shapes.penCancel()\n shapes.pencilCancel()\n state.gradientEdit = null\n state.imageEdit = null\n })\n\n // The edited text follows changes made outside the editor, such as a panel field being\n // dragged, so its caret and selection move with the text instead of after the change.\n const invalidateEditedText = (id: string) => {\n if (id !== state.editingTextId) return\n const node = _graph.getNode(id)\n if (node) _textEditor?.invalidateParagraph(node)\n }\n onEditorEvent('node:updated', invalidateEditedText)\n onEditorEvent('node:previewUpdated', invalidateEditedText)\n\n function setCanvasKit(ck: CanvasKit, renderer: SkiaRenderer) {\n _ck = ck\n _renderer = renderer\n const first = _renderers.size === 0\n _renderers.add(renderer)\n _textEditor ??= new TextEditor(ck)\n uninstallTextMeasurer?.()\n uninstallTextMeasurer =\n typeof renderer.measureTextNode === 'function'\n ? installTextMeasurer((node, maxWidth) =>\n pendingTextLayout.measure(renderer, node, maxWidth)\n )\n : null\n // A page shown before this editor had a canvas to measure its text, as one a tab opens while\n // its canvas loads, is laid out now that one can.\n if (first) pages.layOutStaleCurrentPage()\n }\n\n function releaseTextMeasurer() {\n uninstallTextMeasurer?.()\n uninstallTextMeasurer = null\n }\n\n function removeCanvasRenderer(renderer: SkiaRenderer) {\n _renderers.delete(renderer)\n if (_renderer === renderer) {\n _renderer = _renderers.values().next().value ?? null\n }\n if (_renderers.size === 0) releaseTextMeasurer()\n }\n\n /** Each graph's committed history, kept aside while another graph is open in this editor. */\n const histories = new WeakMap<SceneGraph, UndoHistory>()\n\n /** A step recorded while its document was swapped away joins that document's own history. */\n function parkStep(graph: SceneGraph, entry: UndoEntry) {\n const history = histories.get(graph)\n if (history) histories.set(graph, undo.pushIntoParked(history, entry))\n }\n\n function replaceGraph(newGraph: SceneGraph) {\n nodes.cancelNodePreviews()\n if (newGraph !== _graph) {\n // Undo steps name layers by id and act on whichever graph is open, so history stays with\n // the graph it was recorded on: a document opened in this editor starts with its own,\n // instead of undoing the last document's layers that share an id.\n histories.set(_graph, undo.takeHistory())\n undo.adoptHistory(histories.get(newGraph))\n // Menus show the new graph's history; a step still being recorded keeps its own notice,\n // which is how it learns another write happened beside it.\n if (!undo.isRecording) emitEditorEvent('history:changed')\n }\n _graph = newGraph\n state.documentKind = _graph.documentKind\n setActiveTool(offeredTool(state, state.activeTool))\n pendingTextLayout.clear()\n subscribeToGraph()\n const previousPageId = state.currentPageId\n state.currentPageId = _graph.getPages()[0]?.id ?? _graph.rootId\n setSelectedIds(new Set())\n state.hoveredNodeId = null\n state.transforming = false\n state.measurementMode = 'off'\n state.snapGuides = []\n state.guides = { preview: null, hovered: null, selected: null, redline: null }\n state.layoutInsertIndicator = null\n state.dropTargetId = null\n pages.clearPageViewports()\n for (const renderer of _renderers) renderer.tiledScene.invalidateStructure()\n emitEditorEvent('graph:replaced', _graph)\n if (previousPageId !== state.currentPageId) {\n emitEditorEvent('page:changed', state.currentPageId, previousPageId)\n }\n requestRender()\n }\n\n function dispose() {\n releaseTextMeasurer()\n nodes.cancelNodePreviews()\n interactiveEdits.clear()\n stopFontResolutionEvents()\n stopFontLoadEvents()\n stopUnblockEvents()\n unsubscribeFromGraph()\n }\n\n function releaseGraphResources(graph: SceneGraph = _graph) {\n releaseFigPopulationWorker(graph)\n releaseOriginalFigArchive(graph)\n }\n\n const editor = {\n get graph() {\n return _graph\n },\n /** Instances are being brought in line with their components: results, not edits. */\n isSyncingComponents,\n get renderer() {\n return _renderer\n },\n get canvasRenderers() {\n return [..._renderers]\n },\n get textEditor() {\n return _textEditor\n },\n undo: guardUndo(undo, readsOnly),\n parkStep,\n state,\n\n // Graph reads\n runLayoutForNode,\n runLayoutForParents,\n runMutationWithLayout,\n ...graphReads,\n\n // Lifecycle\n beginInteractiveEdit,\n isInteractiveEditing: () => interactiveEdits.size > 0,\n flushComponentSync,\n requestRender,\n requestRefresh,\n textSelectionChanged,\n requestRepaint,\n onEditorEvent,\n setCanvasKit,\n setNavigationPhase,\n removeCanvasRenderer,\n replaceGraph,\n subscribeToGraph,\n dispose,\n releaseGraphResources,\n\n // Selection\n ...selection,\n\n // Pages\n ...pages,\n\n // Canvas and frame guides\n ...guides,\n ...designIssues,\n\n // Shapes & tools\n ...shapes,\n\n // Structure (group, reorder, reparent, z-order)\n ...structure,\n\n // Nodes (update, layout); while text is edited, character styles go to its selection\n ...nodes,\n updateNode: (id: string, changes: Partial<SceneNode>) =>\n textSelectionStyle.updateNode(id, changes, nodes.updateNode),\n updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label = 'Update') =>\n textSelectionStyle.updateNodeWithUndo(id, changes, (target, next) =>\n nodes.updateNodeWithUndo(target, next, label)\n ),\n getTextSelectionStyle: textSelectionStyle.selectionStyle,\n layerChanges: textSelectionStyle.layerChanges,\n\n // Alignment (align, flip, rotate)\n ...alignment,\n\n // Canvas views: editing, or a preview where instances with a behaviour respond to the pointer\n ...canvasViews,\n\n // Bitmap-to-vector replacement\n ...vectorize,\n ...icons,\n ...stickies,\n // The Scale tool: layers scale with their text, strokes, effects, radii, and spacing\n ...scale,\n ...shapesWithText,\n ...generatedText,\n statusWorkflow: statuses.statusWorkflow,\n getShownStatus: statuses.getShownStatus,\n setStatus: statuses.setStatus,\n setStatusWorkflow: statuses.setStatusWorkflow,\n ...designMemory,\n // Variations: copies of a layer side by side, one of which can replace it\n ...variations,\n ...connectorDrawing,\n ...connectorEndpoints,\n ...connectorLines,\n ...lineEnds,\n ...imageEdit,\n ...connectorStyles,\n ...shaders,\n ...shaderFrames,\n\n // Variables\n ...variables,\n ...designTokens,\n\n // Text editing\n ...text,\n ...fonts,\n ...textHyperlinks,\n\n // Viewport\n ...viewport,\n ...frameNavigation,\n\n // Undo — bridge functions that need cross-module refs\n ...undoBridge,\n commitNodeUpdate: (id: string, previous: Partial<SceneNode>, label = 'Update') =>\n textSelectionStyle.commitNodeUpdate(\n id,\n previous,\n (target, values) => undoBridge.commitNodeUpdate(target, values, label),\n (target, next) => nodes.updateNodeWithUndo(target, next, label)\n ),\n // While text is edited, what was typed undoes first and the editor keeps the result.\n undoAction: () => text.runTextEditStep(undoBridge.undoAction),\n redoAction: () => text.runTextEditStep(undoBridge.redoAction),\n\n setDocumentColorSpace: colorSpace.setDocumentColorSpace,\n updateEnabledLibraries: documentSettings.updateEnabledLibraries,\n refreshDocumentSettings: documentSettings.refreshDocumentSettings,\n setDocumentKind: documentSettings.setDocumentKind,\n figCompression: figCompression.figCompression,\n setFigCompression: figCompression.setFigCompression,\n\n // Clipboard — bridge functions that need selectedNodes\n ...clipboardBridge,\n\n // Paste properties: the look of a copied layer, onto the selection\n ...clipboardProperties,\n\n // Components — bridge functions\n ...componentBridge,\n\n // Structure — bridge functions that need selectedNodes\n ...structureBridge,\n\n // Lint fixes, which touch nodes, structure and deletion in one undo step\n ...lintFixBridge,\n\n // Read-only documents, which refuse every action above that changes them\n ...readOnly\n }\n return guardReadOnly(editor, readsOnly)\n}\n\n/**\n * The editor `createEditor` returns. An interface rather than an alias, so declarations that\n * mention it, such as a Vue composable's inferred return type, name it instead of spelling out\n * its members, some of whose types are internal to Core.\n */\n// eslint-disable-next-line typescript/no-empty-object-type -- The interface is the point: an alias's members are spelled out in emitted declarations.\nexport interface Editor extends ReturnType<typeof createEditor> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,SAAS,sBAAsB,SAA+C;CAC5E,OAAO,SAAS,4BAA4B;AAC9C;AAEA,SAAgB,aAAa,SAAyB;CACpD,IAAI,SAAS,SAAS,SAAS,IAAI,WAAW;CAC9C,MAAM,wBAAwB,SAAS,yBAAyB;CAChE,MAAM,OAAO,IAAI,YAAY;EAC3B,gBAAgB,gBAAgB,iBAAiB;EAGjD,OAAO;GACL,YAAY,OAAO,gBAAgB;GACnC,MAAM,IAAI,WAAW,OAAO,eAAe,IAAI,MAAM;GACrD,SAAS,IAAI,WAAW,OAAO,kBAAkB,IAAI,MAAM;GAC3D,WAAW,QAAQ,OAAO,6BAA6B,GAAG;EAC5D;CACF,CAAC;CACD,MAAM,YAAY,SAAS,YAAY,YAAY,SAAS,KAAK,WAAW;CAC5E,MAAM,mBACJ,SAAS,0BACF;EACL,IAAI,YAAY,OAAO;GAAE,OAAO,OAAO;GAAY,QAAQ,OAAO;EAAY;EAC9E,OAAO;GAAE,OAAO;GAAK,QAAQ;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,UAAU;EAC7D,qBAAqB,IAAY,SAA6B,QAAQ,aACpE,mBAAmB,mBAAmB,IAAI,UAAU,QAAQ,SAC1D,MAAM,mBAAmB,QAAQ,MAAM,KAAK,CAC9C;EACF,uBAAuB,mBAAmB;EAC1C,cAAc,mBAAmB;EAGjC,GAAG;EAGH,GAAG;EAGH,GAAG;EACH,GAAG;EACH,GAAG;EAEH,GAAG;EACH,GAAG;EACH,GAAG;EACH,gBAAgB,SAAS;EACzB,gBAAgB,SAAS;EACzB,WAAW,SAAS;EACpB,mBAAmB,SAAS;EAC5B,GAAG;EAEH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EAGH,GAAG;EACH,GAAG;EAGH,GAAG;EACH,GAAG;EACH,GAAG;EAGH,GAAG;EACH,GAAG;EAGH,GAAG;EACH,mBAAmB,IAAY,UAA8B,QAAQ,aACnE,mBAAmB,iBACjB,IACA,WACC,QAAQ,WAAW,WAAW,iBAAiB,QAAQ,QAAQ,KAAK,IACpE,QAAQ,SAAS,MAAM,mBAAmB,QAAQ,MAAM,KAAK,CAChE;EAEF,kBAAkB,KAAK,gBAAgB,WAAW,UAAU;EAC5D,kBAAkB,KAAK,gBAAgB,WAAW,UAAU;EAE5D,uBAAuB,WAAW;EAClC,wBAAwB,iBAAiB;EACzC,yBAAyB,iBAAiB;EAC1C,iBAAiB,iBAAiB;EAClC,gBAAgB,eAAe;EAC/B,mBAAmB,eAAe;EAGlC,GAAG;EAGH,GAAG;EAGH,GAAG;EAGH,GAAG;EAGH,GAAG;EAGH,GAAG;CACL;CACA,OAAO,cAAc,QAAQ,SAAS;AACxC"}
|
|
1
|
+
{"version":3,"file":"create.js","names":[],"sources":["../../src/editor/create.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\nimport { createNanoEvents } from 'nanoevents'\nimport type { Emitter } from 'nanoevents'\n\nimport { SceneGraph, type SceneNode } from '@pairdraw/scene-graph'\nimport { UndoManager, type UndoEntry, type UndoHistory } from '@pairdraw/scene-graph/undo'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { prefetchFigmaSchema } from '#core/clipboard'\nimport { IS_BROWSER } from '#core/constants'\nimport {\n getPageColor,\n hasStoredBackground,\n setDefaultPageBackground\n} from '#core/figma-api/page-backgrounds'\nimport { defaultIcons } from '#core/icons'\nimport { releaseFigPopulationWorker } from '#core/kiwi/fig/population/client'\nimport { releaseOriginalFigArchive } from '#core/kiwi/fig/session/original-archive'\nimport { installTextMeasurer } from '#core/layout'\nimport { createLayoutRunner } from '#core/layout/mutations'\nimport { TextEditor } from '#core/text/editor'\nimport { fontManager } from '#core/text/font/manager'\nimport { fontResolver } from '#core/text/resolver'\n\nimport { createAlignmentActions } from './alignment'\nimport { createClipboardBridge } from './bridges/clipboard'\nimport { createComponentBridge } from './bridges/components'\nimport { createFrameNavigationBridge } from './bridges/frames'\nimport { createLintFixBridge } from './bridges/lint'\nimport { createStructureBridge } from './bridges/structure'\nimport { createUndoBridge } from './bridges/undo'\nimport { createClipboardActions } from './clipboard'\nimport { createClipboardPropertiesActions } from './clipboard/paste/properties'\nimport { createColorSpaceActions } from './color-space'\nimport { createComponentSyncScheduler } from './component-sync'\nimport { createComponentActions } from './components'\nimport { createConnectorDrawActions, createConnectorEndpointActions } from './connectors/draw'\nimport { createConnectorLineActions } from './connectors/line'\nimport { createConnectorRouting } from './connectors/routing'\nimport { createConnectorStyleActions } from './connectors/style'\nimport { createDesignMemoryActions } from './design-memory'\nimport { createDesignTokenActions } from './design-tokens'\nimport { createDocumentSettingsActions } from './document-settings'\nimport { createFigCompressionActions } from './fig-compression'\nimport { createFontActions } from './fonts'\nimport { createGraphEventSubscription } from './graph-events'\nimport { createGraphReadActions } from './graph-reads'\nimport { createGuideActions } from './guides'\nimport { createIconActions } from './icons'\nimport { createImageEditActions } from './image-edit'\nimport { createDesignIssueActions } from './issues'\nimport { createLineEndActions } from './line-ends'\nimport { createNodeActions } from './nodes'\nimport { createPageActions } from './pages'\nimport { createReadOnlyActions, guardReadOnly, guardUndo } from './read-only'\nimport { createRenderRequests } from './render-requests'\nimport { createScaleActions } from './scale'\nimport { createSelectionActions } from './selection'\nimport { createShaderActions } from './shaders/actions'\nimport { createShaderFrames } from './shaders/frames'\nimport { createShapeActions } from './shapes'\nimport { createShapeWithTextActions } from './shapes/with-text'\nimport { createDefaultEditorState } from './state'\nimport { createStatusActions } from './statuses'\nimport { createStickyActions } from './stickies'\nimport { createStructureActions } from './structure'\nimport { createStyleActions } from './styles'\nimport { createTextActions } from './text'\nimport { createTextHyperlinkActions } from './text/hyperlink'\nimport { createPendingTextLayout } from './text/pending-layout'\nimport { createTextSelectionStyle } from './text/selection-style'\nimport { createGeneratedTextActions } from './text/typeface'\nimport type {\n EditorContext,\n EditorEventName,\n EditorEvents,\n EditorOptions,\n EditorState,\n ViewportInsets\n} from './types'\nimport { createUndoActions } from './undo'\nimport { createVariableActions } from './variables'\nimport { createVariationActions } from './variations'\nimport { createVectorizeActions } from './vectorize'\nimport { createViewportActions, NO_VIEWPORT_INSETS } from './viewport'\nimport { createCanvasViewActions, offeredTool, resolveEditorProfile } from './views'\n\nexport { createDefaultEditorState } from './state'\n\n/** A canvas with no chrome reports nothing, which is the same as none covering it. */\nfunction resolveViewportInsets(options?: EditorOptions): () => ViewportInsets {\n return options?.getViewportInsets ?? (() => NO_VIEWPORT_INSETS)\n}\n\nexport function createEditor(options?: EditorOptions) {\n let _graph = options?.graph ?? new SceneGraph()\n const skipInitialGraphSetup = options?.skipInitialGraphSetup ?? false\n const undo = new UndoManager({\n onChange: () => emitEditorEvent('history:changed'),\n // A step owns the edited-field marks its edit added, so undo takes them back and redo\n // marks them again. The marks are the graph's, and the document can be replaced.\n marks: {\n take: () => _graph.takeSourceMarks(),\n add: (id, fields) => _graph.addSourceMarks(id, fields),\n remove: (id, fields) => _graph.removeSourceMarks(id, fields),\n preserve: (run) => _graph.preserveSourceMetadataDuring(run)\n }\n })\n const _loadFont = options?.loadFont ?? fontManager.loadFont.bind(fontManager)\n const _getViewportSize =\n options?.getViewportSize ??\n (() => {\n if (IS_BROWSER) return { width: window.innerWidth, height: window.innerHeight }\n return { width: 800, height: 600 }\n })\n const _getViewportInsets = resolveViewportInsets(options)\n let _ck: CanvasKit | null = null\n let _renderer: SkiaRenderer | null = null\n const _renderers = new Set<SkiaRenderer>()\n let uninstallTextMeasurer: (() => void) | null = null\n const interactiveEdits = new Set<symbol>()\n let _textEditor: TextEditor | null = null\n const events: Emitter<EditorEvents> = createNanoEvents()\n const stopFontResolutionEvents = fontResolver.subscribe((event, snapshot) => {\n if (event === 'settled') pendingTextLayout.relayoutReady(_renderer)\n events.emit('font:resolution-changed', event, snapshot)\n })\n const stopFontLoadEvents = fontManager.onFaceLoaded((family, style) => {\n // Text measured in a substitute takes its own face's size once a face of its family loads.\n pendingTextLayout.relayoutSubstituted(_renderer, family)\n events.emit('font:loaded', family, style)\n })\n // Text blocked while its fonts were prepared is missing from the tiles drawn meanwhile.\n const stopUnblockEvents = fontManager.onNodesUnblocked((nodeIds) => {\n let redrawn = false\n for (const renderer of _renderers) {\n for (const id of nodeIds) {\n if (!_graph.getNode(id)) continue\n renderer.invalidateNodePicture(id)\n redrawn = true\n }\n }\n if (redrawn) requestRender()\n })\n\n void prefetchFigmaSchema()\n\n const state: EditorState = options?.state ?? createDefaultEditorState(_graph.getPages()[0].id)\n state.documentKind = _graph.documentKind\n state.activeTool = offeredTool(state, state.activeTool)\n\n function emitEditorEvent<K extends EditorEventName>(\n event: K,\n ...args: Parameters<EditorEvents[K]>\n ) {\n events.emit(event, ...args)\n }\n\n function onEditorEvent<K extends EditorEventName>(event: K, handler: EditorEvents[K]) {\n return events.on(event, handler)\n }\n\n const {\n requestRender,\n requestRefresh,\n requestRepaint,\n textSelectionChanged,\n setNavigationPhase\n } = createRenderRequests(state, emitEditorEvent)\n\n /** Track an actual live edit independently of history batching. Release is idempotent. */\n function beginInteractiveEdit() {\n const token = Symbol('interactive-edit')\n interactiveEdits.add(token)\n requestRepaint()\n return () => {\n if (interactiveEdits.delete(token)) requestRepaint()\n }\n }\n\n function setSelectedIds(ids: Set<string>) {\n const previous = [...state.selectedIds]\n state.selectedIds = ids\n if (ids.size === 0) state.measurementMode = 'off'\n // The spacing bands belong to the layer whose field asked for them; a selection that no\n // longer holds it must not keep showing them.\n if (state.layoutSpacingNodeId && !ids.has(state.layoutSpacingNodeId))\n state.layoutSpacingNodeId = null\n const selected = [...ids]\n if (\n previous.length !== selected.length ||\n previous.some((id, index) => id !== selected[index])\n ) {\n emitEditorEvent('selection:changed', selected, previous)\n }\n }\n\n function setActiveTool(tool: EditorState['activeTool']) {\n if (offeredTool(state, tool) !== tool) return\n const previous = state.activeTool\n state.activeTool = tool\n if (tool !== 'SELECT') {\n state.measurementMode = 'off'\n state.layoutSpacingNodeId = null\n }\n if (previous === tool) return\n // Guides the pen showed for its next point do not belong to the next tool.\n if (previous === 'PEN') state.snapGuides = []\n emitEditorEvent('tool:changed', tool, previous)\n }\n\n const graphReads = createGraphReadActions(() => _graph)\n const { runLayoutForNode, runLayoutForParents, runMutationWithLayout } = createLayoutRunner(\n () => _graph\n )\n const pendingTextLayout = createPendingTextLayout({\n getGraph: () => _graph,\n runLayoutForNode,\n requestRender\n })\n const { scheduleComponentSync, flushComponentSync, isSyncingComponents } =\n createComponentSyncScheduler(() => _graph, requestRender)\n\n const { subscribeToGraph, unsubscribeFromGraph } = createGraphEventSubscription({\n getGraph: () => _graph,\n getRenderers: () => _renderers,\n scheduleComponentSync,\n requestRender,\n emitEditorEvent\n })\n\n if (!skipInitialGraphSetup) {\n subscribeToGraph()\n // A new document's first page takes Figma's background for the interface theme the app gives;\n // a page that already has one keeps it.\n const firstPage = _graph.getPages()[0]\n if (options?.state?.theme && !hasStoredBackground(firstPage)) {\n setDefaultPageBackground(_graph, firstPage, options.state.theme)\n options.state.pageColor = getPageColor(firstPage)\n }\n }\n\n // Build the shared context\n const ctx: EditorContext = {\n get graph() {\n return _graph\n },\n set graph(g) {\n _graph = g\n },\n undo,\n parkStep,\n state,\n loadFont: _loadFont,\n resolveFigmaClipboardImages: options?.resolveFigmaClipboardImages ?? null,\n getViewportSize: _getViewportSize,\n getViewportInsets: _getViewportInsets,\n getUserName: () => options?.getUserName?.() ?? '',\n icons: options?.icons ?? defaultIcons,\n getCk: () => _ck,\n getRenderer: () => _renderer,\n getRenderers: () => _renderers,\n getTextEditor: () => _textEditor,\n requestRender,\n requestRefresh,\n requestRepaint,\n beginInteractiveEdit,\n onEditorEvent,\n emitEditorEvent,\n setSelectedIds,\n setActiveTool,\n setNavigationPhase,\n runLayoutForNode,\n runLayoutForParents,\n runMutationWithLayout,\n subscribeToGraph\n }\n\n // Assemble domain modules\n const viewport = createViewportActions(ctx)\n const selection = createSelectionActions(ctx)\n const shaderFrames = createShaderFrames(ctx, options)\n const pages = createPageActions(ctx, shaderFrames)\n const guides = createGuideActions(ctx)\n const designIssues = createDesignIssueActions(ctx)\n const structure = createStructureActions(ctx)\n const components = createComponentActions(ctx)\n const clipboard = createClipboardActions(ctx)\n const colorSpace = createColorSpaceActions(ctx)\n const documentSettings = createDocumentSettingsActions(ctx)\n const undoActions = createUndoActions(ctx)\n const text = createTextActions(ctx)\n const fonts = createFontActions(ctx)\n const nodes = createNodeActions(ctx)\n const shapes = createShapeActions(ctx, nodes.updateNodeWithUndo)\n const clipboardProperties = createClipboardPropertiesActions(\n ctx,\n nodes.updateNodeWithUndo,\n clipboard.loadFontsForNodes\n )\n const variables = createVariableActions(ctx)\n const designTokens = createDesignTokenActions(ctx, variables, nodes)\n const styles = createStyleActions(ctx, nodes)\n const vectorize = createVectorizeActions(ctx)\n const icons = createIconActions(ctx)\n const stickies = createStickyActions(ctx, nodes)\n const scale = createScaleActions(ctx, nodes.beginNodePreview)\n const shapesWithText = createShapeWithTextActions(ctx, nodes)\n const generatedText = createGeneratedTextActions(ctx, nodes)\n const statuses = createStatusActions(ctx)\n const designMemory = createDesignMemoryActions(ctx)\n const variations = createVariationActions(ctx)\n const figCompression = createFigCompressionActions(ctx)\n createConnectorRouting(ctx)\n const connectorDrawing = createConnectorDrawActions(ctx)\n const connectorEndpoints = createConnectorEndpointActions(\n ctx,\n nodes.beginNodePreview,\n clipboard.deleteNodes\n )\n const connectorLines = createConnectorLineActions(ctx, nodes.beginNodePreview)\n const connectorStyles = createConnectorStyleActions(ctx, nodes)\n const lineEnds = createLineEndActions(ctx, nodes.beginNodePreview)\n const imageEdit = createImageEditActions(ctx, nodes.updateNodeWithUndo)\n const shaders = createShaderActions(ctx, nodes)\n const alignment = createAlignmentActions(ctx)\n const canvasViews = createCanvasViewActions(ctx, viewport)\n const clipboardBridge = createClipboardBridge(clipboard, selection)\n const componentBridge = createComponentBridge(components, selection, structure, pages)\n const structureBridge = createStructureBridge(structure, selection)\n const frameNavigation = createFrameNavigationBridge(ctx, selection, viewport)\n const undoBridge = createUndoBridge(undoActions, selection, nodes.flushNudge)\n const lintFixBridge = createLintFixBridge(ctx, nodes, structure, clipboard)\n const textSelectionStyle = createTextSelectionStyle(ctx, text.runTextEditStep)\n const textHyperlinks = createTextHyperlinkActions(ctx, {\n updateNodeWithUndo: nodes.updateNodeWithUndo,\n runTextEditStep: text.runTextEditStep,\n switchPage: (pageId) => pages.switchPage(pageId),\n revealNodes: viewport.revealNodes\n })\n /** Whether the editor refuses edits: its profile offers none, as for a read-only document. */\n const readsOnly = () => !resolveEditorProfile(state).edits\n const readOnly = createReadOnlyActions(ctx, () => {\n nodes.flushNudge()\n nodes.cancelNodePreviews()\n if (state.editingTextId) text.commitTextEdit()\n shapes.penCancel()\n shapes.pencilCancel()\n state.gradientEdit = null\n state.imageEdit = null\n })\n\n // The edited text follows changes made outside the editor, such as a panel field being\n // dragged, so its caret and selection move with the text instead of after the change.\n const invalidateEditedText = (id: string) => {\n if (id !== state.editingTextId) return\n const node = _graph.getNode(id)\n if (node) _textEditor?.invalidateParagraph(node)\n }\n onEditorEvent('node:updated', invalidateEditedText)\n onEditorEvent('node:previewUpdated', invalidateEditedText)\n\n function setCanvasKit(ck: CanvasKit, renderer: SkiaRenderer) {\n _ck = ck\n _renderer = renderer\n const first = _renderers.size === 0\n _renderers.add(renderer)\n _textEditor ??= new TextEditor(ck)\n uninstallTextMeasurer?.()\n uninstallTextMeasurer =\n typeof renderer.measureTextNode === 'function'\n ? installTextMeasurer((node, maxWidth) =>\n pendingTextLayout.measure(renderer, node, maxWidth)\n )\n : null\n // A page shown before this editor had a canvas to measure its text, as one a tab opens while\n // its canvas loads, is laid out now that one can.\n if (first) pages.layOutStaleCurrentPage()\n }\n\n function releaseTextMeasurer() {\n uninstallTextMeasurer?.()\n uninstallTextMeasurer = null\n }\n\n function removeCanvasRenderer(renderer: SkiaRenderer) {\n _renderers.delete(renderer)\n if (_renderer === renderer) {\n _renderer = _renderers.values().next().value ?? null\n }\n if (_renderers.size === 0) releaseTextMeasurer()\n }\n\n /** Each graph's committed history, kept aside while another graph is open in this editor. */\n const histories = new WeakMap<SceneGraph, UndoHistory>()\n\n /** A step recorded while its document was swapped away joins that document's own history. */\n function parkStep(graph: SceneGraph, entry: UndoEntry) {\n const history = histories.get(graph)\n if (history) histories.set(graph, undo.pushIntoParked(history, entry))\n }\n\n function replaceGraph(newGraph: SceneGraph) {\n nodes.cancelNodePreviews()\n if (newGraph !== _graph) {\n // Undo steps name layers by id and act on whichever graph is open, so history stays with\n // the graph it was recorded on: a document opened in this editor starts with its own,\n // instead of undoing the last document's layers that share an id.\n histories.set(_graph, undo.takeHistory())\n undo.adoptHistory(histories.get(newGraph))\n // Menus show the new graph's history; a step still being recorded keeps its own notice,\n // which is how it learns another write happened beside it.\n if (!undo.isRecording) emitEditorEvent('history:changed')\n }\n _graph = newGraph\n state.documentKind = _graph.documentKind\n setActiveTool(offeredTool(state, state.activeTool))\n pendingTextLayout.clear()\n subscribeToGraph()\n const previousPageId = state.currentPageId\n state.currentPageId = _graph.getPages()[0]?.id ?? _graph.rootId\n setSelectedIds(new Set())\n state.hoveredNodeId = null\n state.transforming = false\n state.measurementMode = 'off'\n state.layoutSpacingNodeId = null\n state.snapGuides = []\n state.guides = { preview: null, hovered: null, selected: null, redline: null }\n state.layoutInsertIndicator = null\n state.dropTargetId = null\n pages.clearPageViewports()\n for (const renderer of _renderers) renderer.tiledScene.invalidateStructure()\n emitEditorEvent('graph:replaced', _graph)\n if (previousPageId !== state.currentPageId) {\n emitEditorEvent('page:changed', state.currentPageId, previousPageId)\n }\n requestRender()\n }\n\n function dispose() {\n releaseTextMeasurer()\n nodes.cancelNodePreviews()\n interactiveEdits.clear()\n stopFontResolutionEvents()\n stopFontLoadEvents()\n stopUnblockEvents()\n unsubscribeFromGraph()\n }\n\n function releaseGraphResources(graph: SceneGraph = _graph) {\n releaseFigPopulationWorker(graph)\n releaseOriginalFigArchive(graph)\n }\n\n const editor = {\n get graph() {\n return _graph\n },\n /** Instances are being brought in line with their components: results, not edits. */\n isSyncingComponents,\n get renderer() {\n return _renderer\n },\n get canvasRenderers() {\n return [..._renderers]\n },\n get textEditor() {\n return _textEditor\n },\n undo: guardUndo(undo, readsOnly),\n parkStep,\n state,\n\n // Graph reads\n runLayoutForNode,\n runLayoutForParents,\n runMutationWithLayout,\n ...graphReads,\n\n // Lifecycle\n beginInteractiveEdit,\n isInteractiveEditing: () => interactiveEdits.size > 0,\n flushComponentSync,\n requestRender,\n requestRefresh,\n textSelectionChanged,\n requestRepaint,\n onEditorEvent,\n setCanvasKit,\n setNavigationPhase,\n removeCanvasRenderer,\n replaceGraph,\n subscribeToGraph,\n dispose,\n releaseGraphResources,\n\n // Selection\n ...selection,\n\n // Pages\n ...pages,\n\n // Canvas and frame guides\n ...guides,\n ...designIssues,\n\n // Shapes & tools\n ...shapes,\n\n // Structure (group, reorder, reparent, z-order)\n ...structure,\n\n // Nodes (update, layout); while text is edited, character styles go to its selection\n ...nodes,\n updateNode: (id: string, changes: Partial<SceneNode>) =>\n textSelectionStyle.updateNode(id, changes, nodes.updateNode),\n updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label = 'Update') =>\n textSelectionStyle.updateNodeWithUndo(id, changes, (target, next) =>\n nodes.updateNodeWithUndo(target, next, label)\n ),\n getTextSelectionStyle: textSelectionStyle.selectionStyle,\n isTextStyleMixed: textSelectionStyle.isTextStyleMixed,\n layerChanges: textSelectionStyle.layerChanges,\n\n // Alignment (align, flip, rotate)\n ...alignment,\n\n // Canvas views: editing, or a preview where instances with a behaviour respond to the pointer\n ...canvasViews,\n\n // Bitmap-to-vector replacement\n ...vectorize,\n ...icons,\n ...stickies,\n // The Scale tool: layers scale with their text, strokes, effects, radii, and spacing\n ...scale,\n ...shapesWithText,\n ...generatedText,\n statusWorkflow: statuses.statusWorkflow,\n getShownStatus: statuses.getShownStatus,\n setStatus: statuses.setStatus,\n setStatusWorkflow: statuses.setStatusWorkflow,\n ...designMemory,\n // Variations: copies of a layer side by side, one of which can replace it\n ...variations,\n ...connectorDrawing,\n ...connectorEndpoints,\n ...connectorLines,\n ...lineEnds,\n ...imageEdit,\n ...connectorStyles,\n ...shaders,\n ...shaderFrames,\n\n // Variables\n ...variables,\n ...designTokens,\n\n // Shared styles\n ...styles,\n\n // Text editing\n ...text,\n ...fonts,\n ...textHyperlinks,\n\n // Viewport\n ...viewport,\n ...frameNavigation,\n\n // Undo — bridge functions that need cross-module refs\n ...undoBridge,\n commitNodeUpdate: (id: string, previous: Partial<SceneNode>, label = 'Update') =>\n textSelectionStyle.commitNodeUpdate(\n id,\n previous,\n (target, values) => undoBridge.commitNodeUpdate(target, values, label),\n (target, next) => nodes.updateNodeWithUndo(target, next, label)\n ),\n // While text is edited, what was typed undoes first and the editor keeps the result.\n undoAction: () => text.runTextEditStep(undoBridge.undoAction),\n redoAction: () => text.runTextEditStep(undoBridge.redoAction),\n\n setDocumentColorSpace: colorSpace.setDocumentColorSpace,\n updateEnabledLibraries: documentSettings.updateEnabledLibraries,\n refreshDocumentSettings: documentSettings.refreshDocumentSettings,\n setDocumentKind: documentSettings.setDocumentKind,\n figCompression: figCompression.figCompression,\n setFigCompression: figCompression.setFigCompression,\n\n // Clipboard — bridge functions that need selectedNodes\n ...clipboardBridge,\n\n // Paste properties: the look of a copied layer, onto the selection\n ...clipboardProperties,\n\n // Components — bridge functions\n ...componentBridge,\n\n // Structure — bridge functions that need selectedNodes\n ...structureBridge,\n\n // Lint fixes, which touch nodes, structure and deletion in one undo step\n ...lintFixBridge,\n\n // Read-only documents, which refuse every action above that changes them\n ...readOnly\n }\n return guardReadOnly(editor, readsOnly)\n}\n\n/**\n * The editor `createEditor` returns. An interface rather than an alias, so declarations that\n * mention it, such as a Vue composable's inferred return type, name it instead of spelling out\n * its members, some of whose types are internal to Core.\n */\n// eslint-disable-next-line typescript/no-empty-object-type -- The interface is the point: an alias's members are spelled out in emitted declarations.\nexport interface Editor extends ReturnType<typeof createEditor> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAS,sBAAsB,SAA+C;CAC5E,OAAO,SAAS,4BAA4B;AAC9C;AAEA,SAAgB,aAAa,SAAyB;CACpD,IAAI,SAAS,SAAS,SAAS,IAAI,WAAW;CAC9C,MAAM,wBAAwB,SAAS,yBAAyB;CAChE,MAAM,OAAO,IAAI,YAAY;EAC3B,gBAAgB,gBAAgB,iBAAiB;EAGjD,OAAO;GACL,YAAY,OAAO,gBAAgB;GACnC,MAAM,IAAI,WAAW,OAAO,eAAe,IAAI,MAAM;GACrD,SAAS,IAAI,WAAW,OAAO,kBAAkB,IAAI,MAAM;GAC3D,WAAW,QAAQ,OAAO,6BAA6B,GAAG;EAC5D;CACF,CAAC;CACD,MAAM,YAAY,SAAS,YAAY,YAAY,SAAS,KAAK,WAAW;CAC5E,MAAM,mBACJ,SAAS,0BACF;EACL,IAAI,YAAY,OAAO;GAAE,OAAO,OAAO;GAAY,QAAQ,OAAO;EAAY;EAC9E,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H,GAAG;EAGH,GAAG;CACL;CACA,OAAO,cAAc,QAAQ,SAAS;AACxC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EditorContext } from "./types.js";
|
|
2
|
+
import { NodeActions } from "./nodes.js";
|
|
2
3
|
import { TokenImportPlan } from "../io/formats/design-tokens/plan/index.js";
|
|
3
4
|
import { TokenImportResult } from "../io/formats/design-tokens/apply.js";
|
|
4
5
|
import { createVariableActions } from "./variables.js";
|
|
5
|
-
import { NodeActions } from "./nodes.js";
|
|
6
6
|
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
7
7
|
import { TokenSource } from "@pairdraw/scene-graph/token-sources";
|
|
8
8
|
//#region src/editor/design-tokens.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-tokens.d.ts","names":[],"sources":["../../src/editor/design-tokens.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"design-tokens.d.ts","names":[],"sources":["../../src/editor/design-tokens.ts"],"mappings":";;;;;;;;KAoBK,kBAAkB,kBAAkB;iBACzB,yBACd,KAAK,eACL,WAAW,iBACX,OAAO;EAqC2B,qBAAA,MAAA,oBAAkB;EAa3C,mBAAA,gBAAS,mBAAiB,UACvB,OAAO,eAAe,kBAC/B;EAkB4B,oBAAA"}
|
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import { applyTokenImport
|
|
1
|
+
import { applyTokenImport } from "../io/formats/design-tokens/apply.js";
|
|
2
|
+
import { createStyleNode } from "./styles.js";
|
|
2
3
|
import { readTokenSources, tokenSourcesPluginData } from "@pairdraw/scene-graph/token-sources";
|
|
3
4
|
//#region src/editor/design-tokens.ts
|
|
4
5
|
function createDesignTokenActions(ctx, variables, nodes) {
|
|
5
|
-
/** A new style node,
|
|
6
|
+
/** A new style node, shared with the style picker's creation action. */
|
|
6
7
|
function addStyle(style, fields) {
|
|
7
|
-
|
|
8
|
-
node.source.id = crypto.randomUUID();
|
|
9
|
-
const snapshot = structuredClone(node);
|
|
10
|
-
const parentId = node.parentId;
|
|
11
|
-
ctx.undo.push({
|
|
12
|
-
label: "Add style",
|
|
13
|
-
forward: () => {
|
|
14
|
-
ctx.graph.createNodeWithId(snapshot.id, snapshot.type, parentId, structuredClone(snapshot));
|
|
15
|
-
ctx.requestRender();
|
|
16
|
-
},
|
|
17
|
-
inverse: () => {
|
|
18
|
-
ctx.graph.deleteNode(snapshot.id);
|
|
19
|
-
ctx.requestRender();
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return node;
|
|
8
|
+
return createStyleNode(ctx, style.kind, fields);
|
|
23
9
|
}
|
|
24
10
|
/** The import's changes made through the editor's actions, each one undoable. */
|
|
25
11
|
const target = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-tokens.js","names":[],"sources":["../../src/editor/design-tokens.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n readTokenSources,\n tokenSourcesPluginData,\n type TokenSource\n} from '@pairdraw/scene-graph/token-sources'\n\n// Not the format's barrel: the editor always loads this file, and the exporter is loaded on demand.\nimport {\n applyTokenImport,\n
|
|
1
|
+
{"version":3,"file":"design-tokens.js","names":[],"sources":["../../src/editor/design-tokens.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n readTokenSources,\n tokenSourcesPluginData,\n type TokenSource\n} from '@pairdraw/scene-graph/token-sources'\n\n// Not the format's barrel: the editor always loads this file, and the exporter is loaded on demand.\nimport {\n applyTokenImport,\n type TokenImportResult,\n type TokenImportTarget\n} from '#core/io/formats/design-tokens/apply'\nimport type { TokenImportPlan } from '#core/io/formats/design-tokens/plan'\n\nimport type { NodeActions } from './nodes'\nimport { createStyleNode } from './styles'\nimport type { EditorContext } from './types'\nimport type { createVariableActions } from './variables'\n\ntype VariableActions = ReturnType<typeof createVariableActions>\nexport function createDesignTokenActions(\n ctx: EditorContext,\n variables: VariableActions,\n nodes: NodeActions\n) {\n /** A new style node, shared with the style picker's creation action. */\n function addStyle(\n style: Parameters<TokenImportTarget['addStyle']>[0],\n fields: Partial<SceneNode>\n ) {\n return createStyleNode(ctx, style.kind, fields)\n }\n\n /** The import's changes made through the editor's actions, each one undoable. */\n const target: Omit<TokenImportTarget, 'graph'> = {\n addCollection: (name) => {\n const collection = ctx.graph.createCollection(name)\n variables.addCollection(collection)\n return collection\n },\n addMode: (collectionId, name) => variables.addMode(collectionId, name),\n renameMode: (collectionId, modeId, name) => variables.renameMode(collectionId, modeId, name),\n setDefaultMode: (collectionId, modeId) => variables.setDefaultMode(collectionId, modeId),\n setModeCondition: (collectionId, modeId, condition) =>\n variables.setModeCondition(collectionId, modeId, condition),\n setModeAttribute: (collectionId, name) => variables.setModeAttribute(collectionId, name),\n addVariable: (planned, collectionId) => {\n const variable = ctx.graph.createVariable(planned.name, planned.type, collectionId)\n variables.addVariable(variable)\n return variable\n },\n setValue: (variableId, modeId, value) =>\n variables.updateVariableValue(variableId, modeId, value),\n setTokenFields: (variableId, fields) => variables.updateVariableToken(variableId, fields),\n addStyle,\n updateNode: (nodeId, changes) => nodes.updateNodeWithUndo(nodeId, changes, 'Update style'),\n bindVariable: (nodeId, field, variableId) => nodes.bindVariable(nodeId, field, variableId)\n }\n\n /** Applies an import plan as one undo step; nothing is deleted. */\n function importDesignTokens(plan: TokenImportPlan): TokenImportResult {\n return ctx.undo.runBatch('Import design tokens', () => {\n const result = applyTokenImport({ ...target, graph: ctx.graph }, plan)\n ctx.requestRender()\n return result\n })\n }\n\n /**\n * Brings linked code in as one undo step: the imports in order, then the document's links as\n * `sources` gives them once the imports are applied, so undo takes back both.\n */\n function syncDesignTokens(\n plans: readonly TokenImportPlan[],\n sources: (graph: SceneGraph) => TokenSource[]\n ): TokenImportResult[] {\n return ctx.undo.runBatch('Sync design tokens', () => {\n const results = plans.map((plan) => applyTokenImport({ ...target, graph: ctx.graph }, plan))\n writeTokenSources(sources(ctx.graph), 'Sync design tokens')\n ctx.requestRender()\n return results\n })\n }\n\n function writeTokenSources(sources: readonly TokenSource[], label: string) {\n nodes.updateNodeWithUndo(\n ctx.graph.rootId,\n { pluginData: tokenSourcesPluginData(ctx.graph, sources) },\n label\n )\n }\n\n /** Forgets a link to code; the variables it brought in stay. */\n function unlinkTokenSource(id: string) {\n const sources = readTokenSources(ctx.graph)\n if (!sources.some((source) => source.id === id)) return\n writeTokenSources(\n sources.filter((source) => source.id !== id),\n 'Unlink code'\n )\n }\n\n return { importDesignTokens, syncDesignTokens, unlinkTokenSource }\n}\n"],"mappings":";;;;AAqBA,SAAgB,yBACd,KACA,WACA,OACA;;CAEA,SAAS,SACP,OACA,QACA;EACA,OAAO,gBAAgB,KAAK,MAAM,MAAM,MAAM;CAChD;;CAGA,MAAM,SAA2C;EAC/C,gBAAgB,SAAS;GACvB,MAAM,aAAa,IAAI,MAAM,iBAAiB,IAAI;GAClD,UAAU,cAAc,UAAU;GAClC,OAAO;EACT;EACA,UAAU,cAAc,SAAS,UAAU,QAAQ,cAAc,IAAI;EACrE,aAAa,cAAc,QAAQ,SAAS,UAAU,WAAW,cAAc,QAAQ,IAAI;EAC3F,iBAAiB,cAAc,WAAW,UAAU,eAAe,cAAc,MAAM;EACvF,mBAAmB,cAAc,QAAQ,cACvC,UAAU,iBAAiB,cAAc,QAAQ,SAAS;EAC5D,mBAAmB,cAAc,SAAS,UAAU,iBAAiB,cAAc,IAAI;EACvF,cAAc,SAAS,iBAAiB;GACtC,MAAM,WAAW,IAAI,MAAM,eAAe,QAAQ,MAAM,QAAQ,MAAM,YAAY;GAClF,UAAU,YAAY,QAAQ;GAC9B,OAAO;EACT;EACA,WAAW,YAAY,QAAQ,UAC7B,UAAU,oBAAoB,YAAY,QAAQ,KAAK;EACzD,iBAAiB,YAAY,WAAW,UAAU,oBAAoB,YAAY,MAAM;EACxF;EACA,aAAa,QAAQ,YAAY,MAAM,mBAAmB,QAAQ,SAAS,cAAc;EACzF,eAAe,QAAQ,OAAO,eAAe,MAAM,aAAa,QAAQ,OAAO,UAAU;CAC3F;;CAGA,SAAS,mBAAmB,MAA0C;EACpE,OAAO,IAAI,KAAK,SAAS,8BAA8B;GACrD,MAAM,SAAS,iBAAiB;IAAE,GAAG;IAAQ,OAAO,IAAI;GAAM,GAAG,IAAI;GACrE,IAAI,cAAc;GAClB,OAAO;EACT,CAAC;CACH;;;;;CAMA,SAAS,iBACP,OACA,SACqB;EACrB,OAAO,IAAI,KAAK,SAAS,4BAA4B;GACnD,MAAM,UAAU,MAAM,KAAK,SAAS,iBAAiB;IAAE,GAAG;IAAQ,OAAO,IAAI;GAAM,GAAG,IAAI,CAAC;GAC3F,kBAAkB,QAAQ,IAAI,KAAK,GAAG,oBAAoB;GAC1D,IAAI,cAAc;GAClB,OAAO;EACT,CAAC;CACH;CAEA,SAAS,kBAAkB,SAAiC,OAAe;EACzE,MAAM,mBACJ,IAAI,MAAM,QACV,EAAE,YAAY,uBAAuB,IAAI,OAAO,OAAO,EAAE,GACzD,KACF;CACF;;CAGA,SAAS,kBAAkB,IAAY;EACrC,MAAM,UAAU,iBAAiB,IAAI,KAAK;EAC1C,IAAI,CAAC,QAAQ,MAAM,WAAW,OAAO,OAAO,EAAE,GAAG;EACjD,kBACE,QAAQ,QAAQ,WAAW,OAAO,OAAO,EAAE,GAC3C,aACF;CACF;CAEA,OAAO;EAAE;EAAoB;EAAkB;CAAkB;AACnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-edit.d.ts","names":[],"sources":["../../src/editor/image-edit.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"image-edit.d.ts","names":[],"sources":["../../src/editor/image-edit.ts"],"mappings":";;;;;;;;;;;iBAiFgB,uBAAuB,MAAM,WAAW;;;;;;iBAWxC,eAAe,OAAO,YAAY,MAAM;;;;;iBAYxC,mBAAmB,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;UAc7D;EACf,MAAM;EACN,MAAM;EACN;EACA,OAAO;;EAEP,WAAW;EACX;;;iBAIc,YACd,OAAO,YACP,MAAM,+BACL;;iBAmBa,kBACd,OAAO,YACP,MAAM,8BACN,UAAU,mBACV,UAAU,yBACT;UAkBc;;EAEf;;EAEA;;;;;;;iBAQc,iBACd,QAAQ,aACR,KAAK,cACL,MAAM,QACN,IAAI,QACJ,YAAW,qBACV,QAAQ;;;;;iBA6CK,iBACd,OAAO,YACP,MAAM,uBACN,iBACC,QAAQ;;;;;;iBAUK,uBACd,KAAK,eACL,qBAAqB,YAAY,SAAS,QAAQ,YAAY;EAY9B,eAAA,gBAAM;EAaL,iBAAA,iBAAM"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { coveringImageBounds, croppedImageTransform, imageCropLayout, imageTransformFromLocalMatrix, pannedImageTransform, resizedCropRect, scaledImageTransform } from "../geometry/image-crop.js";
|
|
2
2
|
import { createSceneGeometry } from "../geometry/scene.js";
|
|
3
|
-
import { makeImageFillLocalMatrix } from "../canvas/fills.js";
|
|
4
3
|
import { resolveEditorProfile } from "./views/profile.js";
|
|
5
4
|
import { getNodeEditCapability } from "./capabilities.js";
|
|
6
5
|
import { getNodeLocalMatrix } from "@pairdraw/scene-graph/coordinate";
|
|
7
6
|
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
8
|
-
import { coverImageTransform, imageSize } from "@pairdraw/scene-graph/images";
|
|
7
|
+
import { coverImageTransform, imageSize, makeImageFillLocalMatrix } from "@pairdraw/scene-graph/images";
|
|
9
8
|
//#region src/editor/image-edit.ts
|
|
10
9
|
/** Layers whose image fills are reframed on the canvas; text and lines draw no image area. */
|
|
11
10
|
const IMAGE_EDIT_EXCLUDED = /* @__PURE__ */ new Set([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-edit.js","names":[],"sources":["../../src/editor/image-edit.ts"],"sourcesContent":["import type {\n Fill,\n GradientTransform,\n NodeType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { getNodeLocalMatrix } from '@pairdraw/scene-graph/coordinate'\nimport { coverImageTransform, imageSize } from '@pairdraw/scene-graph/images'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport type { Size, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { makeImageFillLocalMatrix } from '#core/canvas/fills'\nimport {\n coveringImageBounds,\n createSceneGeometry,\n croppedImageTransform,\n imageCropLayout,\n imageTransformFromLocalMatrix,\n pannedImageTransform,\n resizedCropRect,\n scaledImageTransform,\n type ImageCropHit,\n type ImageCropLayout,\n type RotationPreview,\n type ViewportTransform\n} from '#core/geometry'\n\nimport { getNodeEditCapability } from './capabilities'\nimport type { EditorContext, ImageEdit } from './types'\nimport { resolveEditorProfile } from './views'\n\n/** Layers whose image fills are reframed on the canvas; text and lines draw no image area. */\nconst IMAGE_EDIT_EXCLUDED: ReadonlySet<NodeType> = new Set([\n 'CANVAS',\n 'TEXT',\n 'LINE',\n 'GROUP',\n 'SECTION',\n 'COMPONENT_SET',\n 'CONNECTOR',\n 'STICKY'\n])\n\n/**\n * Layers whose edges crop: shapes drawn from their size alone. Vectors keep their paths and\n * layers with children their children's places, which moving their edges would change.\n */\nconst CROPPABLE: ReadonlySet<NodeType> = new Set([\n 'RECTANGLE',\n 'ROUNDED_RECTANGLE',\n 'ELLIPSE',\n 'STAR',\n 'POLYGON',\n 'FRAME'\n])\n\nconst imageSizes = new WeakMap<Uint8Array, Size | null>()\n\nfunction storedImageSize(graph: SceneGraph, hash: string): Size | null {\n const bytes = graph.images.get(hash)\n if (!bytes) return null\n let size = imageSizes.get(bytes)\n if (size === undefined) {\n size = imageSize(bytes)\n imageSizes.set(bytes, size)\n }\n return size && size.width > 0 && size.height > 0 ? size : null\n}\n\nfunction editableImageFill(fill: Fill | undefined): boolean {\n return fill?.visible === true && fill.type === 'IMAGE' && Boolean(fill.imageHash)\n}\n\n/**\n * The fill an image edit works on: `index` when that fill is a visible image, else the topmost\n * visible image fill without an index; −1 when there is none.\n */\nexport function editableImageFillIndex(node: SceneNode, index?: number): number {\n if (IMAGE_EDIT_EXCLUDED.has(node.type)) return -1\n if (index !== undefined) return editableImageFill(node.fills[index]) ? index : -1\n return node.fills.findLastIndex(editableImageFill)\n}\n\n/**\n * Whether cropping may move the layer's edges, rather than only reframe its image. Auto layout\n * sets the place, and may set the size, of a layer it lays out and of an auto layout frame's own\n * size, so those undo a crop's new edges and would move or stretch the image.\n */\nexport function imageEditCrops(graph: SceneGraph, node: SceneNode): boolean {\n if (!CROPPABLE.has(node.type) || node.childIds.length > 0 || node.layoutMode !== 'NONE')\n return false\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n const laidOut = parent !== undefined && parent.layoutMode !== 'NONE'\n return !laidOut || node.layoutPositioning === 'ABSOLUTE'\n}\n\n/**\n * The crop that draws `fill` as it is drawn now: its own for a crop, else the Fill framing with\n * its turn, which a new crop starts from, as in Figma.\n */\nexport function imageCropTransform(fill: Fill, node: SceneNode, image: Size): GradientTransform {\n if (fill.imageScaleMode === 'CROP' && fill.imageTransform) return fill.imageTransform\n const local = makeImageFillLocalMatrix(\n { ...fill, imageScaleMode: 'FILL' },\n node,\n image.width,\n image.height\n )\n return (\n imageTransformFromLocalMatrix(local, node.width, node.height, image.width, image.height) ??\n coverImageTransform(node.width, node.height, image.width, image.height)\n )\n}\n\nexport interface EditedImage {\n node: SceneNode\n fill: Fill\n index: number\n image: Size\n /** The crop the fill draws with, whether it is stored as a crop yet or not. */\n transform: GradientTransform\n croppable: boolean\n}\n\n/** The image fill being edited and its layer, while both still exist. */\nexport function editedImage(\n graph: SceneGraph,\n edit: ImageEdit | null | undefined\n): EditedImage | null {\n if (!edit) return null\n const node = graph.getNode(edit.nodeId)\n const fill = node?.fills[edit.index]\n if (!node || fill?.type !== 'IMAGE' || !fill.imageHash) return null\n if (node.width <= 0 || node.height <= 0) return null\n const image = storedImageSize(graph, fill.imageHash)\n if (!image) return null\n return {\n node,\n fill,\n index: edit.index,\n image,\n transform: imageCropTransform(fill, node, image),\n croppable: imageEditCrops(graph, node)\n }\n}\n\n/** Where the edited image and its layer sit on screen, for drawing and hit testing alike. */\nexport function editedImageLayout(\n graph: SceneGraph,\n edit: ImageEdit | null | undefined,\n viewport: ViewportTransform,\n preview?: RotationPreview | null\n): ImageCropLayout | null {\n const edited = editedImage(graph, edit)\n if (!edited) return null\n const geometry = createSceneGeometry(graph, preview)\n const { node } = edited\n return imageCropLayout(edited.transform, node.width, node.height, edited.croppable, (local) =>\n geometry.toScreen(node, local, viewport)\n )\n}\n\nfunction fillsWith(edited: EditedImage, transform: GradientTransform): Fill[] {\n return edited.node.fills.map((fill, index) =>\n index === edited.index\n ? { ...fill, imageScaleMode: 'CROP', imageTransform: { ...transform } }\n : fill\n )\n}\n\nexport interface ImageEditModifiers {\n /** Shift: keep proportions while cropping, or move along one axis. */\n shift?: boolean\n /** Alt: crop or scale about the centre. */\n alt?: boolean\n}\n\n/**\n * The layer's changes after dragging `hit` from `from` to `to`, both in the layer's pixels as the\n * drag found it. Cropping moves and resizes the layer over a still image; reframing moves or\n * scales the image behind a still layer. Either way the fill is stored as a crop.\n */\nexport function imageEditChanges(\n edited: EditedImage,\n hit: ImageCropHit,\n from: Vector,\n to: Vector,\n modifiers: ImageEditModifiers = {}\n): Partial<SceneNode> {\n const { node, transform } = edited\n const { width, height } = node\n if (hit.kind === 'pan') {\n let dx = to.x - from.x\n let dy = to.y - from.y\n if (modifiers.shift) {\n if (Math.abs(dx) >= Math.abs(dy)) dy = 0\n else dx = 0\n }\n return {\n fills: fillsWith(edited, pannedImageTransform(transform, width, height, { x: dx, y: dy }))\n }\n }\n if (hit.kind === 'scale') {\n const scaled = scaledImageTransform(transform, width, height, hit.corner, to, {\n fromCenter: modifiers.alt\n })\n return { fills: fillsWith(edited, scaled) }\n }\n if (!edited.croppable) return {}\n const rect = resizedCropRect(hit.handle, width, height, to, {\n keepRatio: modifiers.shift,\n fromCenter: modifiers.alt,\n limit: coveringImageBounds(transform, width, height)\n })\n // The layer's new top-left corner lands where that point of the old layer was.\n const corner = Matrix.mapPoint(getNodeLocalMatrix(node), { x: rect.x, y: rect.y })\n const offset = Matrix.mapPoint(\n getNodeLocalMatrix({ ...node, width: rect.width, height: rect.height }, { x: 0, y: 0 }),\n { x: 0, y: 0 }\n )\n return {\n x: corner.x - offset.x,\n y: corner.y - offset.y,\n width: rect.width,\n height: rect.height,\n fills: fillsWith(edited, croppedImageTransform(transform, width, height, rect))\n }\n}\n\n/**\n * Whether `node` has an image fill, the one at `index` when given, that the canvas can crop and\n * reframe: unlocked and outside a read-only library definition, as text editing requires.\n */\nexport function hasEditableImage(\n graph: SceneGraph,\n node: SceneNode | undefined,\n index?: number\n): node is SceneNode {\n if (!node || node.locked || !getNodeEditCapability(graph, node.id).editable) return false\n return editableImageFillIndex(node, index) >= 0\n}\n\n/**\n * Image edit mode, as Figma's crop: the layer's image shows whole, the part outside the layer\n * faded; its edges crop and the image moves and scales behind it. Selecting something else,\n * switching tool or page, or replacing the document leaves it.\n */\nexport function createImageEditActions(\n ctx: EditorContext,\n updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label?: string) => void\n) {\n function endImageEdit() {\n if (!ctx.state.imageEdit) return\n ctx.state.imageEdit = null\n ctx.requestRepaint()\n }\n\n /**\n * Whether the layer `nodeId` can enter image edit mode, on its fill at `index` when given and\n * otherwise on its topmost visible image fill.\n */\n function canEditImageOf(nodeId: string, index?: number): boolean {\n return (\n resolveEditorProfile(ctx.state).edits &&\n hasEditableImage(ctx.graph, ctx.graph.getNode(nodeId), index)\n )\n }\n\n /**\n * Enters image edit mode on `nodeId`, the single selected layer when omitted, selecting it; on\n * the fill at `index`, or the topmost visible image fill when omitted.\n * Fit and Tile frame the image unlike a crop, so they turn into the crop that covers the layer,\n * as Fill frames it, in one undo step; Fill draws just as its crop, which the first change stores.\n */\n function startImageEdit(nodeId?: string, fillIndex?: number): boolean {\n const id = nodeId ?? (ctx.state.selectedIds.size === 1 ? [...ctx.state.selectedIds][0] : null)\n const node = id ? ctx.graph.getNode(id) : undefined\n if (!node || !canEditImageOf(node.id, fillIndex)) return false\n const index = editableImageFillIndex(node, fillIndex)\n // An image whose bytes are not here yet has no size to frame by.\n const edited = editedImage(ctx.graph, { nodeId: node.id, index })\n if (!edited) return false\n if (ctx.state.activeTool !== 'SELECT') ctx.setActiveTool('SELECT')\n if (ctx.state.selectedIds.size !== 1 || !ctx.state.selectedIds.has(node.id))\n ctx.setSelectedIds(new Set([node.id]))\n ctx.state.gradientEdit = null\n const mode = edited.fill.imageScaleMode ?? 'FILL'\n if (mode === 'FIT' || mode === 'TILE')\n updateNodeWithUndo(node.id, { fills: fillsWith(edited, edited.transform) }, 'Crop image')\n ctx.state.imageEdit = { nodeId: node.id, index }\n ctx.requestRepaint()\n return true\n }\n\n ctx.onEditorEvent('selection:changed', (ids) => {\n const edit = ctx.state.imageEdit\n if (edit && (ids.length !== 1 || ids[0] !== edit.nodeId)) endImageEdit()\n })\n ctx.onEditorEvent('tool:changed', (tool) => {\n if (tool !== 'SELECT') endImageEdit()\n })\n ctx.onEditorEvent('page:changed', endImageEdit)\n ctx.onEditorEvent('graph:replaced', endImageEdit)\n // Locking the layer, removing its image, or undoing a Fit or Tile image's turn into a crop\n // leaves the mode: its handles would edit a layer that may not change, or frame the image\n // other than it draws.\n ctx.onEditorEvent('node:updated', (id) => {\n const edit = ctx.state.imageEdit\n if (!edit || id !== edit.nodeId) return\n const mode = ctx.graph.getNode(id)?.fills[edit.index]?.imageScaleMode\n if (!canEditImageOf(id, edit.index) || mode === 'FIT' || mode === 'TILE') endImageEdit()\n })\n ctx.onEditorEvent('node:deleted', (id) => {\n if (id === ctx.state.imageEdit?.nodeId) endImageEdit()\n })\n\n return { canEditImage: canEditImageOf, startImageEdit, endImageEdit }\n}\n"],"mappings":";;;;;;;;;;AAiCA,MAAM,sCAA6C,IAAI,IAAI;CACzD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,MAAM,4BAAmC,IAAI,IAAI;C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B,IAAI,SAAS,IAAI,WAAW,KAAK,IAAI,OAAO,KAAK,SAAS,aAAa;CACzE,CAAC;CACD,IAAI,cAAc,iBAAiB,SAAS;EAC1C,IAAI,SAAS,UAAU,aAAa;CACtC,CAAC;CACD,IAAI,cAAc,gBAAgB,YAAY;CAC9C,IAAI,cAAc,kBAAkB,YAAY;CAIhD,IAAI,cAAc,iBAAiB,OAAO;EACxC,MAAM,OAAO,IAAI,MAAM;EACvB,IAAI,CAAC,QAAQ,OAAO,KAAK,QAAQ;EACjC,MAAM,OAAO,IAAI,MAAM,QAAQ,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE;EACvD,IAAI,CAAC,eAAe,IAAI,KAAK,KAAK,KAAK,SAAS,SAAS,SAAS,QAAQ,aAAa;CACzF,CAAC;CACD,IAAI,cAAc,iBAAiB,OAAO;EACxC,IAAI,OAAO,IAAI,MAAM,WAAW,QAAQ,aAAa;CACvD,CAAC;CAED,OAAO;EAAE,cAAc;EAAgB;EAAgB;CAAa;AACtE"}
|
|
1
|
+
{"version":3,"file":"image-edit.js","names":[],"sources":["../../src/editor/image-edit.ts"],"sourcesContent":["import type {\n Fill,\n GradientTransform,\n NodeType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { getNodeLocalMatrix } from '@pairdraw/scene-graph/coordinate'\nimport {\n coverImageTransform,\n imageSize,\n makeImageFillLocalMatrix\n} from '@pairdraw/scene-graph/images'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport type { Size, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport {\n coveringImageBounds,\n createSceneGeometry,\n croppedImageTransform,\n imageCropLayout,\n imageTransformFromLocalMatrix,\n pannedImageTransform,\n resizedCropRect,\n scaledImageTransform,\n type ImageCropHit,\n type ImageCropLayout,\n type RotationPreview,\n type ViewportTransform\n} from '#core/geometry'\n\nimport { getNodeEditCapability } from './capabilities'\nimport type { EditorContext, ImageEdit } from './types'\nimport { resolveEditorProfile } from './views'\n\n/** Layers whose image fills are reframed on the canvas; text and lines draw no image area. */\nconst IMAGE_EDIT_EXCLUDED: ReadonlySet<NodeType> = new Set([\n 'CANVAS',\n 'TEXT',\n 'LINE',\n 'GROUP',\n 'SECTION',\n 'COMPONENT_SET',\n 'CONNECTOR',\n 'STICKY'\n])\n\n/**\n * Layers whose edges crop: shapes drawn from their size alone. Vectors keep their paths and\n * layers with children their children's places, which moving their edges would change.\n */\nconst CROPPABLE: ReadonlySet<NodeType> = new Set([\n 'RECTANGLE',\n 'ROUNDED_RECTANGLE',\n 'ELLIPSE',\n 'STAR',\n 'POLYGON',\n 'FRAME'\n])\n\nconst imageSizes = new WeakMap<Uint8Array, Size | null>()\n\nfunction storedImageSize(graph: SceneGraph, hash: string): Size | null {\n const bytes = graph.images.get(hash)\n if (!bytes) return null\n let size = imageSizes.get(bytes)\n if (size === undefined) {\n size = imageSize(bytes)\n imageSizes.set(bytes, size)\n }\n return size && size.width > 0 && size.height > 0 ? size : null\n}\n\nfunction editableImageFill(fill: Fill | undefined): boolean {\n return fill?.visible === true && fill.type === 'IMAGE' && Boolean(fill.imageHash)\n}\n\n/**\n * The fill an image edit works on: `index` when that fill is a visible image, else the topmost\n * visible image fill without an index; −1 when there is none.\n */\nexport function editableImageFillIndex(node: SceneNode, index?: number): number {\n if (IMAGE_EDIT_EXCLUDED.has(node.type)) return -1\n if (index !== undefined) return editableImageFill(node.fills[index]) ? index : -1\n return node.fills.findLastIndex(editableImageFill)\n}\n\n/**\n * Whether cropping may move the layer's edges, rather than only reframe its image. Auto layout\n * sets the place, and may set the size, of a layer it lays out and of an auto layout frame's own\n * size, so those undo a crop's new edges and would move or stretch the image.\n */\nexport function imageEditCrops(graph: SceneGraph, node: SceneNode): boolean {\n if (!CROPPABLE.has(node.type) || node.childIds.length > 0 || node.layoutMode !== 'NONE')\n return false\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n const laidOut = parent !== undefined && parent.layoutMode !== 'NONE'\n return !laidOut || node.layoutPositioning === 'ABSOLUTE'\n}\n\n/**\n * The crop that draws `fill` as it is drawn now: its own for a crop, else the Fill framing with\n * its turn, which a new crop starts from, as in Figma.\n */\nexport function imageCropTransform(fill: Fill, node: SceneNode, image: Size): GradientTransform {\n if (fill.imageScaleMode === 'CROP' && fill.imageTransform) return fill.imageTransform\n const local = makeImageFillLocalMatrix(\n { ...fill, imageScaleMode: 'FILL' },\n node,\n image.width,\n image.height\n )\n return (\n imageTransformFromLocalMatrix(local, node.width, node.height, image.width, image.height) ??\n coverImageTransform(node.width, node.height, image.width, image.height)\n )\n}\n\nexport interface EditedImage {\n node: SceneNode\n fill: Fill\n index: number\n image: Size\n /** The crop the fill draws with, whether it is stored as a crop yet or not. */\n transform: GradientTransform\n croppable: boolean\n}\n\n/** The image fill being edited and its layer, while both still exist. */\nexport function editedImage(\n graph: SceneGraph,\n edit: ImageEdit | null | undefined\n): EditedImage | null {\n if (!edit) return null\n const node = graph.getNode(edit.nodeId)\n const fill = node?.fills[edit.index]\n if (!node || fill?.type !== 'IMAGE' || !fill.imageHash) return null\n if (node.width <= 0 || node.height <= 0) return null\n const image = storedImageSize(graph, fill.imageHash)\n if (!image) return null\n return {\n node,\n fill,\n index: edit.index,\n image,\n transform: imageCropTransform(fill, node, image),\n croppable: imageEditCrops(graph, node)\n }\n}\n\n/** Where the edited image and its layer sit on screen, for drawing and hit testing alike. */\nexport function editedImageLayout(\n graph: SceneGraph,\n edit: ImageEdit | null | undefined,\n viewport: ViewportTransform,\n preview?: RotationPreview | null\n): ImageCropLayout | null {\n const edited = editedImage(graph, edit)\n if (!edited) return null\n const geometry = createSceneGeometry(graph, preview)\n const { node } = edited\n return imageCropLayout(edited.transform, node.width, node.height, edited.croppable, (local) =>\n geometry.toScreen(node, local, viewport)\n )\n}\n\nfunction fillsWith(edited: EditedImage, transform: GradientTransform): Fill[] {\n return edited.node.fills.map((fill, index) =>\n index === edited.index\n ? { ...fill, imageScaleMode: 'CROP', imageTransform: { ...transform } }\n : fill\n )\n}\n\nexport interface ImageEditModifiers {\n /** Shift: keep proportions while cropping, or move along one axis. */\n shift?: boolean\n /** Alt: crop or scale about the centre. */\n alt?: boolean\n}\n\n/**\n * The layer's changes after dragging `hit` from `from` to `to`, both in the layer's pixels as the\n * drag found it. Cropping moves and resizes the layer over a still image; reframing moves or\n * scales the image behind a still layer. Either way the fill is stored as a crop.\n */\nexport function imageEditChanges(\n edited: EditedImage,\n hit: ImageCropHit,\n from: Vector,\n to: Vector,\n modifiers: ImageEditModifiers = {}\n): Partial<SceneNode> {\n const { node, transform } = edited\n const { width, height } = node\n if (hit.kind === 'pan') {\n let dx = to.x - from.x\n let dy = to.y - from.y\n if (modifiers.shift) {\n if (Math.abs(dx) >= Math.abs(dy)) dy = 0\n else dx = 0\n }\n return {\n fills: fillsWith(edited, pannedImageTransform(transform, width, height, { x: dx, y: dy }))\n }\n }\n if (hit.kind === 'scale') {\n const scaled = scaledImageTransform(transform, width, height, hit.corner, to, {\n fromCenter: modifiers.alt\n })\n return { fills: fillsWith(edited, scaled) }\n }\n if (!edited.croppable) return {}\n const rect = resizedCropRect(hit.handle, width, height, to, {\n keepRatio: modifiers.shift,\n fromCenter: modifiers.alt,\n limit: coveringImageBounds(transform, width, height)\n })\n // The layer's new top-left corner lands where that point of the old layer was.\n const corner = Matrix.mapPoint(getNodeLocalMatrix(node), { x: rect.x, y: rect.y })\n const offset = Matrix.mapPoint(\n getNodeLocalMatrix({ ...node, width: rect.width, height: rect.height }, { x: 0, y: 0 }),\n { x: 0, y: 0 }\n )\n return {\n x: corner.x - offset.x,\n y: corner.y - offset.y,\n width: rect.width,\n height: rect.height,\n fills: fillsWith(edited, croppedImageTransform(transform, width, height, rect))\n }\n}\n\n/**\n * Whether `node` has an image fill, the one at `index` when given, that the canvas can crop and\n * reframe: unlocked and outside a read-only library definition, as text editing requires.\n */\nexport function hasEditableImage(\n graph: SceneGraph,\n node: SceneNode | undefined,\n index?: number\n): node is SceneNode {\n if (!node || node.locked || !getNodeEditCapability(graph, node.id).editable) return false\n return editableImageFillIndex(node, index) >= 0\n}\n\n/**\n * Image edit mode, as Figma's crop: the layer's image shows whole, the part outside the layer\n * faded; its edges crop and the image moves and scales behind it. Selecting something else,\n * switching tool or page, or replacing the document leaves it.\n */\nexport function createImageEditActions(\n ctx: EditorContext,\n updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label?: string) => void\n) {\n function endImageEdit() {\n if (!ctx.state.imageEdit) return\n ctx.state.imageEdit = null\n ctx.requestRepaint()\n }\n\n /**\n * Whether the layer `nodeId` can enter image edit mode, on its fill at `index` when given and\n * otherwise on its topmost visible image fill.\n */\n function canEditImageOf(nodeId: string, index?: number): boolean {\n return (\n resolveEditorProfile(ctx.state).edits &&\n hasEditableImage(ctx.graph, ctx.graph.getNode(nodeId), index)\n )\n }\n\n /**\n * Enters image edit mode on `nodeId`, the single selected layer when omitted, selecting it; on\n * the fill at `index`, or the topmost visible image fill when omitted.\n * Fit and Tile frame the image unlike a crop, so they turn into the crop that covers the layer,\n * as Fill frames it, in one undo step; Fill draws just as its crop, which the first change stores.\n */\n function startImageEdit(nodeId?: string, fillIndex?: number): boolean {\n const id = nodeId ?? (ctx.state.selectedIds.size === 1 ? [...ctx.state.selectedIds][0] : null)\n const node = id ? ctx.graph.getNode(id) : undefined\n if (!node || !canEditImageOf(node.id, fillIndex)) return false\n const index = editableImageFillIndex(node, fillIndex)\n // An image whose bytes are not here yet has no size to frame by.\n const edited = editedImage(ctx.graph, { nodeId: node.id, index })\n if (!edited) return false\n if (ctx.state.activeTool !== 'SELECT') ctx.setActiveTool('SELECT')\n if (ctx.state.selectedIds.size !== 1 || !ctx.state.selectedIds.has(node.id))\n ctx.setSelectedIds(new Set([node.id]))\n ctx.state.gradientEdit = null\n const mode = edited.fill.imageScaleMode ?? 'FILL'\n if (mode === 'FIT' || mode === 'TILE')\n updateNodeWithUndo(node.id, { fills: fillsWith(edited, edited.transform) }, 'Crop image')\n ctx.state.imageEdit = { nodeId: node.id, index }\n ctx.requestRepaint()\n return true\n }\n\n ctx.onEditorEvent('selection:changed', (ids) => {\n const edit = ctx.state.imageEdit\n if (edit && (ids.length !== 1 || ids[0] !== edit.nodeId)) endImageEdit()\n })\n ctx.onEditorEvent('tool:changed', (tool) => {\n if (tool !== 'SELECT') endImageEdit()\n })\n ctx.onEditorEvent('page:changed', endImageEdit)\n ctx.onEditorEvent('graph:replaced', endImageEdit)\n // Locking the layer, removing its image, or undoing a Fit or Tile image's turn into a crop\n // leaves the mode: its handles would edit a layer that may not change, or frame the image\n // other than it draws.\n ctx.onEditorEvent('node:updated', (id) => {\n const edit = ctx.state.imageEdit\n if (!edit || id !== edit.nodeId) return\n const mode = ctx.graph.getNode(id)?.fills[edit.index]?.imageScaleMode\n if (!canEditImageOf(id, edit.index) || mode === 'FIT' || mode === 'TILE') endImageEdit()\n })\n ctx.onEditorEvent('node:deleted', (id) => {\n if (id === ctx.state.imageEdit?.nodeId) endImageEdit()\n })\n\n return { canEditImage: canEditImageOf, startImageEdit, endImageEdit }\n}\n"],"mappings":";;;;;;;;;AAoCA,MAAM,sCAA6C,IAAI,IAAI;CACzD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,MAAM,4BAAmC,IAAI,IAAI;CAC/C;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,6BAAa,IAAI,QAAiC;AAExD,SAAS,gBAAgB,OAAmB,MAA2B;CACrE,MAAM,QAAQ,MAAM,OAAO,IAAI,IAAI;CACnC,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,OAAO,WAAW,IAAI,KAAK;CAC/B,IAAI,SAAS,KAAA,GAAW;EACtB,OAAO,UAAU,KAAK;EACtB,WAAW,IAAI,OAAO,IAAI;CAC5B;CACA,OAAO,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,IAAI,OAAO;AAC5D;AAEA,SAAS,kBAAkB,MAAiC;CAC1D,OAAO,MAAM,YAAY,QAAQ,KAAK,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KAAK,SAAS,SAAS,SAAS,QAAQ,aAAa;CACzF,CAAC;CACD,IAAI,cAAc,iBAAiB,OAAO;EACxC,IAAI,OAAO,IAAI,MAAM,WAAW,QAAQ,aAAa;CACvD,CAAC;CAED,OAAO;EAAE,cAAc;EAAgB;EAAgB;CAAa;AACtE"}
|
package/dist/editor/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AttachModifiers } from "./connectors/attach.js";
|
|
|
2
2
|
import { DEFAULT_SNAPPING_PREFERENCES, SnappingPreferences } from "./preferences.js";
|
|
3
3
|
import { ShaderRasterizer } from "./shaders/types.js";
|
|
4
4
|
import { CanvasView, EditorProfile, EditorProfileInputs, EditorRestrictions, PresentationScale, ShaderView } from "./views/types.js";
|
|
5
|
-
import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./types.js";
|
|
5
|
+
import { ClipboardImageResolution, ClipboardPatternSources, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./types.js";
|
|
6
6
|
import { ClipboardCollectionDependency, ClipboardConflictResolution, ClipboardImportChoice, ClipboardImportPlan, ClipboardStyleDependency, clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./clipboard/conflicts.js";
|
|
7
7
|
import { ClipboardSnapshot } from "./clipboard/snapshot.js";
|
|
8
8
|
import { ClipboardPayload, CopyOptions } from "./clipboard/copy.js";
|
|
@@ -22,8 +22,9 @@ import { DOCUMENT_COLOR_LIMIT, DocumentColor, documentColors } from "./document-
|
|
|
22
22
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./state/view.js";
|
|
23
23
|
import { VariantConflict, VariantMutationResult, VariantValidationIssue } from "./components/variants/model.js";
|
|
24
24
|
import "./components/variants/index.js";
|
|
25
|
-
import { VariableTokenFields } from "./variables.js";
|
|
26
25
|
import { NodePreview } from "./node-preview.js";
|
|
26
|
+
import { opacityFromBuffer } from "./nodes.js";
|
|
27
|
+
import { VariableTokenFields } from "./variables.js";
|
|
27
28
|
import { DEFAULT_SCALE_ANCHOR, SCALE_ANCHORS, ScaleAnchor, isScaleAnchor, parseScaleFactor, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds } from "./scale/anchor.js";
|
|
28
29
|
import { ScaleSession } from "./scale/actions.js";
|
|
29
30
|
import { RescaleSnapshot, rescaleNodes } from "./scale/rescale.js";
|
|
@@ -50,10 +51,9 @@ import { reapplyInstanceComponentProperties } from "./components/properties.js";
|
|
|
50
51
|
import { createGuideActions } from "./guides.js";
|
|
51
52
|
import { createTextActions } from "./text.js";
|
|
52
53
|
import { resizedPathTextGlyphs } from "./text/path-edit.js";
|
|
53
|
-
import { opacityFromBuffer } from "./nodes.js";
|
|
54
54
|
import { LayerType, layerTypeOptions } from "./structure/layer-type.js";
|
|
55
55
|
import { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, EDITOR_TOOLS, EditorToolDef, TOOL_SHORTCUTS } from "./tool-registry.js";
|
|
56
56
|
import { EyedropperTarget, ScenePixels, applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./eyedropper.js";
|
|
57
57
|
import { newLayerDefaults } from "./shapes/defaults.js";
|
|
58
58
|
import { RenameSelectionOptions, RenameSelectionPreview } from "./structure/rename.js";
|
|
59
|
-
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
|
59
|
+
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPatternSources, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
package/dist/editor/index.js
CHANGED
|
@@ -15,12 +15,12 @@ import { replaceSelectionColor, selectionColors, selectionColorsShown } from "./
|
|
|
15
15
|
import { DOCUMENT_COLOR_LIMIT, documentColors } from "./document-colors.js";
|
|
16
16
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./state/view.js";
|
|
17
17
|
import { applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, touchedTopLevelIds } from "./history/document-change.js";
|
|
18
|
+
import { syncEditedComponents } from "./component-sync.js";
|
|
18
19
|
import { resolvePasteTarget } from "./clipboard/paste/target.js";
|
|
19
20
|
import { clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./clipboard/conflicts.js";
|
|
20
21
|
import { reapplyInstanceComponentProperties } from "./components/properties.js";
|
|
21
22
|
import { newLayerDefaults } from "./shapes/defaults.js";
|
|
22
23
|
import { pastedPropertyChanges } from "./clipboard/paste/properties.js";
|
|
23
|
-
import { syncEditedComponents } from "./component-sync.js";
|
|
24
24
|
import { resizedPathTextGlyphs } from "./text/path-edit.js";
|
|
25
25
|
import { createGuideActions } from "./guides.js";
|
|
26
26
|
import { opacityFromBuffer } from "./nodes.js";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { EditorContext } from "./types.js";
|
|
2
2
|
import { NodePreview } from "./node-preview.js";
|
|
3
|
-
import { LayoutMode, SceneNode } from "@pairdraw/scene-graph";
|
|
3
|
+
import { GridPosition, LayoutMode, SceneNode } from "@pairdraw/scene-graph";
|
|
4
4
|
//#region src/editor/layout-mode.d.ts
|
|
5
5
|
declare function createLayoutModeActions(ctx: EditorContext, beginNodePreview: (label: string) => NodePreview): {
|
|
6
6
|
setLayoutMode: (id: string, mode: LayoutMode) => void;
|
|
7
7
|
setLayoutPositioning: (ids: string[], positioning: SceneNode["layoutPositioning"]) => void;
|
|
8
|
+
setGridPlacement: (ids: readonly string[], patch: Partial<GridPosition>) => void;
|
|
9
|
+
removeGridTrack: (id: string, prop: "gridTemplateColumns" | "gridTemplateRows", index: number) => void;
|
|
8
10
|
};
|
|
9
11
|
//#endregion
|
|
10
12
|
export { createLayoutModeActions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-mode.d.ts","names":[],"sources":["../../src/editor/layout-mode.ts"],"mappings":";;;;iBAKgB,wBACd,KAAK,eACL,mBAAmB,kBAAkB;EAOV,gBAAA,YAAM,MAAQ;
|
|
1
|
+
{"version":3,"file":"layout-mode.d.ts","names":[],"sources":["../../src/editor/layout-mode.ts"],"mappings":";;;;iBAKgB,wBACd,KAAK,eACL,mBAAmB,kBAAkB;EAOV,gBAAA,YAAM,MAAQ;EA0BN,uBAAA,eAAQ,aAAe;EA6B3B,mBAAA,wBAAiB,OAAS,QAAQ;EAuB3D,kBAAA,YAAM,kDACsC"}
|
|
@@ -10,7 +10,9 @@ function createLayoutModeActions(ctx, beginNodePreview) {
|
|
|
10
10
|
if (!node || node.layoutMode === mode) return;
|
|
11
11
|
const preview = beginNodePreview(mode === "NONE" ? "Remove auto layout" : "Add auto layout");
|
|
12
12
|
if (node.type === "GROUP" && mode !== "NONE") preview.update(id, { type: "FRAME" });
|
|
13
|
-
|
|
13
|
+
const updates = layoutModeUpdates(ctx, node, id, mode);
|
|
14
|
+
preview.update(id, updates);
|
|
15
|
+
if (mode === "GRID" && updates.gridTemplateColumns && updates.gridTemplateRows) clampGridChildren(ctx, preview, node, updates.gridTemplateColumns.length, updates.gridTemplateRows.length);
|
|
14
16
|
preview.commit();
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
@@ -39,11 +41,104 @@ function createLayoutModeActions(ctx, beginNodePreview) {
|
|
|
39
41
|
} : { layoutPositioning: positioning });
|
|
40
42
|
preview.commit();
|
|
41
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A grid child's start line or span, from the panel's grid placement fields. `0` starts and a
|
|
46
|
+
* span of `1` mean auto placement, so a layer back on those defaults carries no position and
|
|
47
|
+
* `.fig` and JSX leave it out. Every selected grid child changes in one undo step.
|
|
48
|
+
*/
|
|
49
|
+
function setGridPlacement(ids, patch) {
|
|
50
|
+
const targets = ids.flatMap((id) => {
|
|
51
|
+
const node = ctx.graph.getNode(id);
|
|
52
|
+
if (!node) return [];
|
|
53
|
+
if ((node.parentId ? ctx.graph.getNode(node.parentId) : void 0)?.layoutMode !== "GRID") return [];
|
|
54
|
+
const next = normalizedGridPosition({
|
|
55
|
+
...node.gridPosition ?? {
|
|
56
|
+
column: 0,
|
|
57
|
+
row: 0,
|
|
58
|
+
columnSpan: 1,
|
|
59
|
+
rowSpan: 1
|
|
60
|
+
},
|
|
61
|
+
...patch
|
|
62
|
+
});
|
|
63
|
+
if (sameGridPosition(node.gridPosition, next)) return [];
|
|
64
|
+
return [{
|
|
65
|
+
id,
|
|
66
|
+
next
|
|
67
|
+
}];
|
|
68
|
+
});
|
|
69
|
+
if (targets.length === 0) return;
|
|
70
|
+
const preview = beginNodePreview("Change grid placement");
|
|
71
|
+
for (const { id, next } of targets) preview.update(id, { gridPosition: next });
|
|
72
|
+
preview.commit();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Removes one column or row track and keeps every placed child inside the grid that remains:
|
|
76
|
+
* a start past the new count moves to the nearest track and a span shrinks to fit. The track and
|
|
77
|
+
* the placements commit as one undo step.
|
|
78
|
+
*/
|
|
79
|
+
function removeGridTrack(id, prop, index) {
|
|
80
|
+
const node = ctx.graph.getNode(id);
|
|
81
|
+
if (node?.layoutMode !== "GRID") return;
|
|
82
|
+
const tracks = node[prop];
|
|
83
|
+
if (index < 0 || index >= tracks.length) return;
|
|
84
|
+
const remaining = tracks.filter((_, trackIndex) => trackIndex !== index);
|
|
85
|
+
const preview = beginNodePreview("Remove grid track");
|
|
86
|
+
preview.update(id, { [prop]: remaining });
|
|
87
|
+
if (remaining.length > 0) clampGridChildren(ctx, preview, node, prop === "gridTemplateColumns" ? remaining.length : node.gridTemplateColumns.length, prop === "gridTemplateRows" ? remaining.length : node.gridTemplateRows.length);
|
|
88
|
+
preview.commit();
|
|
89
|
+
}
|
|
42
90
|
return {
|
|
43
91
|
setLayoutMode,
|
|
44
|
-
setLayoutPositioning
|
|
92
|
+
setLayoutPositioning,
|
|
93
|
+
setGridPlacement,
|
|
94
|
+
removeGridTrack
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Moves every placed child of a grid inside its track counts: a start past the last line moves to
|
|
99
|
+
* the nearest one and a span shrinks to fit, while an auto start stays auto.
|
|
100
|
+
*/
|
|
101
|
+
function clampGridChildren(ctx, preview, parent, columns, rows) {
|
|
102
|
+
for (const childId of parent.childIds) {
|
|
103
|
+
const position = ctx.graph.getNode(childId)?.gridPosition;
|
|
104
|
+
if (!position) continue;
|
|
105
|
+
const next = clampedGridPosition(position, columns, rows);
|
|
106
|
+
if (next.column === position.column && next.row === position.row && next.columnSpan === position.columnSpan && next.rowSpan === position.rowSpan) continue;
|
|
107
|
+
preview.update(childId, { gridPosition: next });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** The nearest placement a grid keeps after its track counts change. */
|
|
111
|
+
function clampedGridPosition(position, columns, rows) {
|
|
112
|
+
const axis = (start, span, count) => {
|
|
113
|
+
const nextSpan = Math.min(span, count);
|
|
114
|
+
return {
|
|
115
|
+
start: start === 0 ? 0 : Math.max(1, Math.min(start, count - nextSpan + 1)),
|
|
116
|
+
span: nextSpan
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const column = axis(position.column, position.columnSpan, columns);
|
|
120
|
+
const row = axis(position.row, position.rowSpan, rows);
|
|
121
|
+
return {
|
|
122
|
+
column: column.start,
|
|
123
|
+
columnSpan: column.span,
|
|
124
|
+
row: row.start,
|
|
125
|
+
rowSpan: row.span
|
|
45
126
|
};
|
|
46
127
|
}
|
|
128
|
+
function normalizedGridPosition(position) {
|
|
129
|
+
const whole = (value, min) => Math.max(min, Math.round(value));
|
|
130
|
+
const next = {
|
|
131
|
+
column: whole(position.column, 0),
|
|
132
|
+
row: whole(position.row, 0),
|
|
133
|
+
columnSpan: whole(position.columnSpan, 1),
|
|
134
|
+
rowSpan: whole(position.rowSpan, 1)
|
|
135
|
+
};
|
|
136
|
+
return next.column === 0 && next.row === 0 && next.columnSpan === 1 && next.rowSpan === 1 ? null : next;
|
|
137
|
+
}
|
|
138
|
+
function sameGridPosition(current, next) {
|
|
139
|
+
if (!current || !next) return current === next;
|
|
140
|
+
return current.column === next.column && current.row === next.row && current.columnSpan === next.columnSpan && current.rowSpan === next.rowSpan;
|
|
141
|
+
}
|
|
47
142
|
function layoutModeUpdates(ctx, node, id, mode) {
|
|
48
143
|
const updates = { layoutMode: mode };
|
|
49
144
|
if (mode === "GRID" && node.layoutMode !== "GRID") applyGridDefaults(ctx, node, id, updates);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-mode.js","names":[],"sources":["../../src/editor/layout-mode.ts"],"sourcesContent":["import type { LayoutMode, SceneNode } from '@pairdraw/scene-graph'\n\nimport type { NodePreview } from './node-preview'\nimport type { EditorContext } from './types'\n\nexport function createLayoutModeActions(\n ctx: EditorContext,\n beginNodePreview: (label: string) => NodePreview\n) {\n /**\n * Adding, switching, or removing auto layout moves and resizes children, nested layouts, and\n * Hug ancestors. A node preview records every layer it changes, so one undo puts them all back\n * where they were; setting the mode a frame already has records nothing.\n */\n function setLayoutMode(id: string, mode: LayoutMode) {\n const node = ctx.graph.getNode(id)\n if (!node || node.layoutMode === mode) return\n const preview = beginNodePreview(mode === 'NONE' ? 'Remove auto layout' : 'Add auto layout')\n // A group is only its children's bounds; a flow needs a frame to own it, as Figma converts.\n if (node.type === 'GROUP' && mode !== 'NONE') preview.update(id, { type: 'FRAME' })\n preview.update(id, layoutModeUpdates(ctx, node, id, mode))\n preview.commit()\n }\n\n /**\n * Takes layers out of their parent's auto layout or puts them back, as Figma's Ignore auto\n * layout toggle does. A layer taken out stays where it is and keeps its sizing, which applies\n * again when it returns; its siblings close the gap in the same undo step.\n */\n function setLayoutPositioning(ids: string[], positioning: SceneNode['layoutPositioning']) {\n // Read every place first: taking one layer out moves the siblings after it.\n const targets = ids.flatMap((id) => {\n const node = ctx.graph.getNode(id)\n const parent = node?.parentId ? ctx.graph.getNode(node.parentId) : undefined\n if (!node || !parent || parent.layoutMode === 'NONE') return []\n if (node.layoutPositioning === positioning) return []\n return [{ id, x: node.x, y: node.y }]\n })\n if (targets.length === 0) return\n const preview = beginNodePreview(\n positioning === 'ABSOLUTE' ? 'Ignore auto layout' : 'Use auto layout'\n )\n for (const { id, x, y } of targets) {\n preview.update(\n id,\n positioning === 'ABSOLUTE'\n ? { layoutPositioning: positioning, x, y }\n : { layoutPositioning: positioning }\n )\n }\n preview.commit()\n }\n\n return { setLayoutMode, setLayoutPositioning }\n}\n\nfunction layoutModeUpdates(\n ctx: EditorContext,\n node: SceneNode,\n id: string,\n mode: LayoutMode\n): Partial<SceneNode> {\n const updates: Partial<SceneNode> = { layoutMode: mode }\n if (mode === 'GRID' && node.layoutMode !== 'GRID') {\n applyGridDefaults(ctx, node, id, updates)\n } else if (mode === 'NONE') {\n // A frame with no flow cannot wrap, align or space one, and the format stores none of it, so\n // the frame gives them all up rather than reopening with them dropped.\n Object.assign(updates, {\n itemSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n counterAxisSpacing: 0,\n layoutDirection: 'AUTO'\n })\n } else if (node.layoutMode === 'NONE') {\n Object.assign(updates, autoLayoutDefaults())\n }\n return updates\n}\n\nfunction applyGridDefaults(\n ctx: EditorContext,\n node: SceneNode,\n id: string,\n updates: Partial<SceneNode>\n) {\n const children = ctx.graph.getChildren(id)\n const cols = Math.max(2, Math.ceil(Math.sqrt(children.length)))\n const rows = Math.max(1, Math.ceil(children.length / cols))\n updates.gridTemplateColumns = Array.from({ length: cols }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n updates.gridTemplateRows = Array.from({ length: rows }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n updates.gridColumnGap = 0\n updates.gridRowGap = 0\n updates.primaryAxisSizing = 'FIXED'\n updates.counterAxisSizing = 'FIXED'\n if (node.primaryAxisSizing === 'HUG' || node.counterAxisSizing === 'HUG') {\n const maxChildW = Math.max(...children.map((child) => child.width), 100)\n const maxChildH = Math.max(...children.map((child) => child.height), 100)\n updates.width = maxChildW * cols\n updates.height = maxChildH * rows\n }\n updates.paddingTop = 0\n updates.paddingRight = 0\n updates.paddingBottom = 0\n updates.paddingLeft = 0\n}\n\nfunction autoLayoutDefaults(): Partial<SceneNode> {\n return {\n itemSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: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QAAQ,cAAc;AACxB;AAEA,SAAS,qBAAyC;CAChD,OAAO;EACL,aAAa;EACb,YAAY;EACZ,cAAc;EACd,eAAe;EACf,aAAa;EACb,mBAAmB;EACnB,mBAAmB;EACnB,kBAAkB;EAClB,kBAAkB;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"layout-mode.js","names":[],"sources":["../../src/editor/layout-mode.ts"],"sourcesContent":["import type { GridPosition, LayoutMode, SceneNode } from '@pairdraw/scene-graph'\n\nimport type { NodePreview } from './node-preview'\nimport type { EditorContext } from './types'\n\nexport function createLayoutModeActions(\n ctx: EditorContext,\n beginNodePreview: (label: string) => NodePreview\n) {\n /**\n * Adding, switching, or removing auto layout moves and resizes children, nested layouts, and\n * Hug ancestors. A node preview records every layer it changes, so one undo puts them all back\n * where they were; setting the mode a frame already has records nothing.\n */\n function setLayoutMode(id: string, mode: LayoutMode) {\n const node = ctx.graph.getNode(id)\n if (!node || node.layoutMode === mode) return\n const preview = beginNodePreview(mode === 'NONE' ? 'Remove auto layout' : 'Add auto layout')\n // A group is only its children's bounds; a flow needs a frame to own it, as Figma converts.\n if (node.type === 'GROUP' && mode !== 'NONE') preview.update(id, { type: 'FRAME' })\n const updates = layoutModeUpdates(ctx, node, id, mode)\n preview.update(id, updates)\n // A grid that returns from auto layout may have fewer tracks than the placements left behind.\n if (mode === 'GRID' && updates.gridTemplateColumns && updates.gridTemplateRows) {\n clampGridChildren(\n ctx,\n preview,\n node,\n updates.gridTemplateColumns.length,\n updates.gridTemplateRows.length\n )\n }\n preview.commit()\n }\n\n /**\n * Takes layers out of their parent's auto layout or puts them back, as Figma's Ignore auto\n * layout toggle does. A layer taken out stays where it is and keeps its sizing, which applies\n * again when it returns; its siblings close the gap in the same undo step.\n */\n function setLayoutPositioning(ids: string[], positioning: SceneNode['layoutPositioning']) {\n // Read every place first: taking one layer out moves the siblings after it.\n const targets = ids.flatMap((id) => {\n const node = ctx.graph.getNode(id)\n const parent = node?.parentId ? ctx.graph.getNode(node.parentId) : undefined\n if (!node || !parent || parent.layoutMode === 'NONE') return []\n if (node.layoutPositioning === positioning) return []\n return [{ id, x: node.x, y: node.y }]\n })\n if (targets.length === 0) return\n const preview = beginNodePreview(\n positioning === 'ABSOLUTE' ? 'Ignore auto layout' : 'Use auto layout'\n )\n for (const { id, x, y } of targets) {\n preview.update(\n id,\n positioning === 'ABSOLUTE'\n ? { layoutPositioning: positioning, x, y }\n : { layoutPositioning: positioning }\n )\n }\n preview.commit()\n }\n\n /**\n * A grid child's start line or span, from the panel's grid placement fields. `0` starts and a\n * span of `1` mean auto placement, so a layer back on those defaults carries no position and\n * `.fig` and JSX leave it out. Every selected grid child changes in one undo step.\n */\n function setGridPlacement(ids: readonly string[], patch: Partial<GridPosition>) {\n const targets = ids.flatMap((id) => {\n const node = ctx.graph.getNode(id)\n if (!node) return []\n const parent = node.parentId ? ctx.graph.getNode(node.parentId) : undefined\n if (parent?.layoutMode !== 'GRID') return []\n const current = node.gridPosition ?? { column: 0, row: 0, columnSpan: 1, rowSpan: 1 }\n const next = normalizedGridPosition({ ...current, ...patch })\n if (sameGridPosition(node.gridPosition, next)) return []\n return [{ id, next }]\n })\n if (targets.length === 0) return\n const preview = beginNodePreview('Change grid placement')\n for (const { id, next } of targets) preview.update(id, { gridPosition: next })\n preview.commit()\n }\n\n /**\n * Removes one column or row track and keeps every placed child inside the grid that remains:\n * a start past the new count moves to the nearest track and a span shrinks to fit. The track and\n * the placements commit as one undo step.\n */\n function removeGridTrack(\n id: string,\n prop: 'gridTemplateColumns' | 'gridTemplateRows',\n index: number\n ) {\n const node = ctx.graph.getNode(id)\n if (node?.layoutMode !== 'GRID') return\n const tracks = node[prop]\n if (index < 0 || index >= tracks.length) return\n const remaining = tracks.filter((_, trackIndex) => trackIndex !== index)\n const preview = beginNodePreview('Remove grid track')\n preview.update(id, { [prop]: remaining })\n // A last track leaves no line to clamp to; the placements stay for a grid that returns.\n if (remaining.length > 0) {\n const columns =\n prop === 'gridTemplateColumns' ? remaining.length : node.gridTemplateColumns.length\n const rows = prop === 'gridTemplateRows' ? remaining.length : node.gridTemplateRows.length\n clampGridChildren(ctx, preview, node, columns, rows)\n }\n preview.commit()\n }\n\n return { setLayoutMode, setLayoutPositioning, setGridPlacement, removeGridTrack }\n}\n\n/**\n * Moves every placed child of a grid inside its track counts: a start past the last line moves to\n * the nearest one and a span shrinks to fit, while an auto start stays auto.\n */\nfunction clampGridChildren(\n ctx: EditorContext,\n preview: NodePreview,\n parent: SceneNode,\n columns: number,\n rows: number\n) {\n for (const childId of parent.childIds) {\n const position = ctx.graph.getNode(childId)?.gridPosition\n if (!position) continue\n const next = clampedGridPosition(position, columns, rows)\n if (\n next.column === position.column &&\n next.row === position.row &&\n next.columnSpan === position.columnSpan &&\n next.rowSpan === position.rowSpan\n ) {\n continue\n }\n preview.update(childId, { gridPosition: next })\n }\n}\n\n/** The nearest placement a grid keeps after its track counts change. */\nfunction clampedGridPosition(position: GridPosition, columns: number, rows: number): GridPosition {\n const axis = (start: number, span: number, count: number) => {\n const nextSpan = Math.min(span, count)\n return {\n start: start === 0 ? 0 : Math.max(1, Math.min(start, count - nextSpan + 1)),\n span: nextSpan\n }\n }\n const column = axis(position.column, position.columnSpan, columns)\n const row = axis(position.row, position.rowSpan, rows)\n return {\n column: column.start,\n columnSpan: column.span,\n row: row.start,\n rowSpan: row.span\n }\n}\n\nfunction normalizedGridPosition(position: GridPosition): GridPosition | null {\n const whole = (value: number, min: number) => Math.max(min, Math.round(value))\n const next = {\n column: whole(position.column, 0),\n row: whole(position.row, 0),\n columnSpan: whole(position.columnSpan, 1),\n rowSpan: whole(position.rowSpan, 1)\n }\n const auto = next.column === 0 && next.row === 0 && next.columnSpan === 1 && next.rowSpan === 1\n return auto ? null : next\n}\n\nfunction sameGridPosition(current: GridPosition | null, next: GridPosition | null): boolean {\n if (!current || !next) return current === next\n return (\n current.column === next.column &&\n current.row === next.row &&\n current.columnSpan === next.columnSpan &&\n current.rowSpan === next.rowSpan\n )\n}\n\nfunction layoutModeUpdates(\n ctx: EditorContext,\n node: SceneNode,\n id: string,\n mode: LayoutMode\n): Partial<SceneNode> {\n const updates: Partial<SceneNode> = { layoutMode: mode }\n if (mode === 'GRID' && node.layoutMode !== 'GRID') {\n applyGridDefaults(ctx, node, id, updates)\n } else if (mode === 'NONE') {\n // A frame with no flow cannot wrap, align or space one, and the format stores none of it, so\n // the frame gives them all up rather than reopening with them dropped.\n Object.assign(updates, {\n itemSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n counterAxisSpacing: 0,\n layoutDirection: 'AUTO'\n })\n } else if (node.layoutMode === 'NONE') {\n Object.assign(updates, autoLayoutDefaults())\n }\n return updates\n}\n\nfunction applyGridDefaults(\n ctx: EditorContext,\n node: SceneNode,\n id: string,\n updates: Partial<SceneNode>\n) {\n const children = ctx.graph.getChildren(id)\n const cols = Math.max(2, Math.ceil(Math.sqrt(children.length)))\n const rows = Math.max(1, Math.ceil(children.length / cols))\n updates.gridTemplateColumns = Array.from({ length: cols }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n updates.gridTemplateRows = Array.from({ length: rows }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n updates.gridColumnGap = 0\n updates.gridRowGap = 0\n updates.primaryAxisSizing = 'FIXED'\n updates.counterAxisSizing = 'FIXED'\n if (node.primaryAxisSizing === 'HUG' || node.counterAxisSizing === 'HUG') {\n const maxChildW = Math.max(...children.map((child) => child.width), 100)\n const maxChildH = Math.max(...children.map((child) => child.height), 100)\n updates.width = maxChildW * cols\n updates.height = maxChildH * rows\n }\n updates.paddingTop = 0\n updates.paddingRight = 0\n updates.paddingBottom = 0\n updates.paddingLeft = 0\n}\n\nfunction autoLayoutDefaults(): Partial<SceneNode> {\n return {\n itemSpac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