@pairdraw/vue 0.19.2 → 0.21.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/CanvasRoot.vue.js +5 -0
- package/dist/canvas/CanvasRoot.vue.js.map +1 -1
- package/dist/canvas/auto-layout/value-edit.js +1 -1
- package/dist/canvas/auto-layout/value-edit.js.map +1 -1
- package/dist/canvas/eyedropper/index.d.ts +26 -0
- package/dist/canvas/eyedropper/index.d.ts.map +1 -0
- package/dist/canvas/eyedropper/index.js +62 -0
- package/dist/canvas/eyedropper/index.js.map +1 -0
- package/dist/canvas/eyedropper/sample.js +13 -0
- package/dist/canvas/eyedropper/sample.js.map +1 -0
- package/dist/canvas/eyedropper/use.d.ts +33 -0
- package/dist/canvas/eyedropper/use.d.ts.map +1 -0
- package/dist/canvas/eyedropper/use.js +52 -0
- package/dist/canvas/eyedropper/use.js.map +1 -0
- package/dist/canvas/pointer/drag-move.js +4 -0
- package/dist/canvas/pointer/drag-move.js.map +1 -1
- package/dist/canvas/surface/color-space.d.ts +1 -0
- package/dist/canvas/surface/color-space.d.ts.map +1 -1
- package/dist/canvas/surface/gl-surface.js +5 -1
- package/dist/canvas/surface/gl-surface.js.map +1 -1
- package/dist/canvas/surface/kit-loader.js +2 -3
- package/dist/canvas/surface/kit-loader.js.map +1 -1
- package/dist/canvas/surface/lifecycle.js +34 -3
- package/dist/canvas/surface/lifecycle.js.map +1 -1
- package/dist/canvas/surface/origin.js +14 -0
- package/dist/canvas/surface/origin.js.map +1 -0
- package/dist/canvas/surface/shader/plan.js +40 -0
- package/dist/canvas/surface/shader/plan.js.map +1 -0
- package/dist/canvas/surface/shader/playback.js +132 -36
- package/dist/canvas/surface/shader/playback.js.map +1 -1
- package/dist/canvas/surface/shader/stage.d.ts.map +1 -1
- package/dist/canvas/surface/shader/stage.js +42 -5
- package/dist/canvas/surface/shader/stage.js.map +1 -1
- package/dist/canvas/surface/types.d.ts +25 -0
- package/dist/canvas/surface/types.d.ts.map +1 -1
- package/dist/canvas/surface/use.js +3 -1
- package/dist/canvas/surface/use.js.map +1 -1
- package/dist/canvas/text-edit/textarea.d.ts +1 -0
- package/dist/canvas/text-edit/textarea.d.ts.map +1 -1
- package/dist/canvas/tools/registry.js +5 -1
- package/dist/canvas/tools/registry.js.map +1 -1
- package/dist/canvas/useCanvasInput.d.ts +144 -2
- package/dist/canvas/useCanvasInput.d.ts.map +1 -1
- package/dist/canvas/useCanvasInput.js +3 -2
- package/dist/canvas/useCanvasInput.js.map +1 -1
- package/dist/controls/appearance/use.d.ts +1 -1
- package/dist/controls/binding-provider/pairdraw.js +1 -1
- package/dist/controls/binding-provider/pairdraw.js.map +1 -1
- package/dist/controls/color-model/types.d.ts +6 -0
- package/dist/controls/color-model/types.d.ts.map +1 -1
- package/dist/controls/color-model/use.d.ts.map +1 -1
- package/dist/controls/color-model/use.js +5 -3
- package/dist/controls/color-model/use.js.map +1 -1
- package/dist/controls/document-colors/index.d.ts +2 -0
- package/dist/controls/document-colors/index.js +2 -0
- package/dist/controls/document-colors/use.d.ts +20 -0
- package/dist/controls/document-colors/use.d.ts.map +1 -0
- package/dist/controls/document-colors/use.js +35 -0
- package/dist/controls/document-colors/use.js.map +1 -0
- package/dist/controls/effects/helpers.d.ts +13 -2
- package/dist/controls/effects/helpers.d.ts.map +1 -1
- package/dist/controls/effects/helpers.js +89 -34
- package/dist/controls/effects/helpers.js.map +1 -1
- package/dist/controls/effects/index.d.ts +2 -1
- package/dist/controls/effects/index.js +2 -1
- package/dist/controls/effects/use.d.ts +9 -7
- package/dist/controls/effects/use.d.ts.map +1 -1
- package/dist/controls/effects/use.js +6 -3
- package/dist/controls/effects/use.js.map +1 -1
- package/dist/controls/okhcl/use.d.ts +2 -2
- package/dist/controls/shader/catalog.d.ts +11 -0
- package/dist/controls/shader/catalog.d.ts.map +1 -1
- package/dist/controls/shader/catalog.js +35 -6
- package/dist/controls/shader/catalog.js.map +1 -1
- package/dist/controls/shader/gallery.d.ts +1 -1
- package/dist/controls/shader/gallery.d.ts.map +1 -1
- package/dist/controls/shader/gallery.js +292 -0
- package/dist/controls/shader/gallery.js.map +1 -1
- package/dist/controls/shader/index.d.ts +3 -1
- package/dist/controls/shader/index.js +3 -1
- package/dist/controls/shader/shapes.d.ts +18 -0
- package/dist/controls/shader/shapes.d.ts.map +1 -0
- package/dist/controls/shader/shapes.js +227 -0
- package/dist/controls/shader/shapes.js.map +1 -0
- package/dist/controls/shader/stops.d.ts +22 -0
- package/dist/controls/shader/stops.d.ts.map +1 -0
- package/dist/controls/shader/stops.js +73 -0
- package/dist/controls/shader/stops.js.map +1 -0
- package/dist/controls/typography/features.d.ts +24 -0
- package/dist/controls/typography/features.d.ts.map +1 -0
- package/dist/controls/typography/features.js +130 -0
- package/dist/controls/typography/features.js.map +1 -0
- package/dist/controls/typography/index.d.ts +2 -1
- package/dist/controls/typography/index.js +2 -1
- package/dist/controls/typography/use.d.ts +6 -0
- package/dist/controls/typography/use.d.ts.map +1 -1
- package/dist/controls/typography/use.js +4 -1
- package/dist/controls/typography/use.js.map +1 -1
- package/dist/controls/variable-modes/helpers.d.ts.map +1 -1
- package/dist/controls/variable-modes/helpers.js +4 -2
- package/dist/controls/variable-modes/helpers.js.map +1 -1
- package/dist/editor/commands/registry.d.ts +4 -0
- package/dist/editor/commands/registry.d.ts.map +1 -1
- package/dist/editor/commands/registry.js +2 -0
- package/dist/editor/commands/registry.js.map +1 -1
- package/dist/editor/commands/selection.js +22 -0
- package/dist/editor/commands/selection.js.map +1 -1
- package/dist/editor/commands/types.d.ts +1 -1
- package/dist/editor/commands/types.d.ts.map +1 -1
- package/dist/editor/menu-model/canvas.d.ts.map +1 -1
- package/dist/editor/menu-model/canvas.js +7 -1
- package/dist/editor/menu-model/canvas.js.map +1 -1
- package/dist/editor/selection-capabilities/use.d.ts +2 -0
- package/dist/editor/selection-capabilities/use.js +5 -0
- package/dist/editor/selection-capabilities/use.js.map +1 -1
- package/dist/editor/selection-state/use.d.ts +1 -0
- package/dist/editor/selection-state/use.js +5 -0
- package/dist/editor/selection-state/use.js.map +1 -1
- package/dist/editor/tool-cursor/index.d.ts.map +1 -1
- package/dist/editor/tool-cursor/index.js +5 -1
- package/dist/editor/tool-cursor/index.js.map +1 -1
- package/dist/i18n/create.d.ts +1 -1
- package/dist/i18n/create.d.ts.map +1 -1
- package/dist/i18n/create.js +1 -0
- package/dist/i18n/create.js.map +1 -1
- package/dist/i18n/index.d.ts +5 -2
- package/dist/i18n/index.js +5 -2
- package/dist/i18n/locale.d.ts +5 -4
- package/dist/i18n/locale.d.ts.map +1 -1
- package/dist/i18n/locale.js +4 -0
- package/dist/i18n/locale.js.map +1 -1
- package/dist/i18n/locales/de/ai.json.js +68 -2
- package/dist/i18n/locales/de/commands.json.js +2 -0
- package/dist/i18n/locales/de/comments.json.js +1 -1
- package/dist/i18n/locales/de/design-check.json.js +13 -1
- package/dist/i18n/locales/de/design-memory.json.js +82 -0
- package/dist/i18n/locales/de/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/de/fonts.json.js +10 -0
- package/dist/i18n/locales/de/index.js +5 -1
- package/dist/i18n/locales/de/index.js.map +1 -1
- package/dist/i18n/locales/de/menu.json.js +2 -0
- package/dist/i18n/locales/de/panels.json.js +109 -1
- package/dist/i18n/locales/de/settings.json.js +1 -0
- package/dist/i18n/locales/de/tools.json.js +3 -1
- package/dist/i18n/locales/de/variables/panel.json.js +20 -0
- package/dist/i18n/locales/de/variations.json.js +23 -0
- package/dist/i18n/locales/de/variations.json.js.map +1 -0
- package/dist/i18n/locales/es/ai.json.js +67 -1
- package/dist/i18n/locales/es/commands.json.js +2 -0
- package/dist/i18n/locales/es/comments.json.js +1 -1
- package/dist/i18n/locales/es/design-check.json.js +13 -1
- package/dist/i18n/locales/es/design-memory.json.js +82 -0
- package/dist/i18n/locales/es/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/es/fonts.json.js +10 -0
- package/dist/i18n/locales/es/index.js +5 -1
- package/dist/i18n/locales/es/index.js.map +1 -1
- package/dist/i18n/locales/es/menu.json.js +2 -0
- package/dist/i18n/locales/es/panels.json.js +109 -1
- package/dist/i18n/locales/es/settings.json.js +1 -0
- package/dist/i18n/locales/es/tools.json.js +3 -1
- package/dist/i18n/locales/es/variables/panel.json.js +20 -0
- package/dist/i18n/locales/es/variations.json.js +23 -0
- package/dist/i18n/locales/es/variations.json.js.map +1 -0
- package/dist/i18n/locales/fr/ai.json.js +68 -2
- package/dist/i18n/locales/fr/commands.json.js +2 -0
- package/dist/i18n/locales/fr/comments.json.js +1 -1
- package/dist/i18n/locales/fr/design-check.json.js +13 -1
- package/dist/i18n/locales/fr/design-memory.json.js +82 -0
- package/dist/i18n/locales/fr/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/fr/fonts.json.js +10 -0
- package/dist/i18n/locales/fr/index.js +5 -1
- package/dist/i18n/locales/fr/index.js.map +1 -1
- package/dist/i18n/locales/fr/menu.json.js +2 -0
- package/dist/i18n/locales/fr/panels.json.js +109 -1
- package/dist/i18n/locales/fr/settings.json.js +1 -0
- package/dist/i18n/locales/fr/tools.json.js +3 -1
- package/dist/i18n/locales/fr/variables/panel.json.js +20 -0
- package/dist/i18n/locales/fr/variations.json.js +23 -0
- package/dist/i18n/locales/fr/variations.json.js.map +1 -0
- package/dist/i18n/locales/id/agents.json.js +31 -0
- package/dist/i18n/locales/id/agents.json.js.map +1 -0
- package/dist/i18n/locales/id/ai.json.js +608 -0
- package/dist/i18n/locales/id/ai.json.js.map +1 -0
- package/dist/i18n/locales/id/automation.json.js +150 -0
- package/dist/i18n/locales/id/automation.json.js.map +1 -0
- package/dist/i18n/locales/id/browser.json.js +50 -0
- package/dist/i18n/locales/id/browser.json.js.map +1 -0
- package/dist/i18n/locales/id/chat-context.json.js +62 -0
- package/dist/i18n/locales/id/chat-context.json.js.map +1 -0
- package/dist/i18n/locales/id/cloud/editor.json.js +337 -0
- package/dist/i18n/locales/id/cloud/editor.json.js.map +1 -0
- package/dist/i18n/locales/id/cloud/portal.json.js +435 -0
- package/dist/i18n/locales/id/cloud/portal.json.js.map +1 -0
- package/dist/i18n/locales/id/code.json.js +43 -0
- package/dist/i18n/locales/id/code.json.js.map +1 -0
- package/dist/i18n/locales/id/collaboration.json.js +84 -0
- package/dist/i18n/locales/id/collaboration.json.js.map +1 -0
- package/dist/i18n/locales/id/commands.json.js +111 -0
- package/dist/i18n/locales/id/commands.json.js.map +1 -0
- package/dist/i18n/locales/id/comments.json.js +37 -0
- package/dist/i18n/locales/id/comments.json.js.map +1 -0
- package/dist/i18n/locales/id/common.json.js +51 -0
- package/dist/i18n/locales/id/common.json.js.map +1 -0
- package/dist/i18n/locales/id/credentials.json.js +21 -0
- package/dist/i18n/locales/id/credentials.json.js.map +1 -0
- package/dist/i18n/locales/id/design-check.json.js +101 -0
- package/dist/i18n/locales/id/design-check.json.js.map +1 -0
- package/dist/i18n/locales/id/design-memory.json.js +61 -0
- package/dist/i18n/locales/id/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/id/diagnostics.json.js +78 -0
- package/dist/i18n/locales/id/diagnostics.json.js.map +1 -0
- package/dist/i18n/locales/id/editor.json.js +62 -0
- package/dist/i18n/locales/id/editor.json.js.map +1 -0
- package/dist/i18n/locales/id/explore.json.js +30 -0
- package/dist/i18n/locales/id/explore.json.js.map +1 -0
- package/dist/i18n/locales/id/figjam.json.js +39 -0
- package/dist/i18n/locales/id/figjam.json.js.map +1 -0
- package/dist/i18n/locales/id/files.json.js +86 -0
- package/dist/i18n/locales/id/files.json.js.map +1 -0
- package/dist/i18n/locales/id/fonts.json.js +54 -0
- package/dist/i18n/locales/id/fonts.json.js.map +1 -0
- package/dist/i18n/locales/id/index.js +85 -0
- package/dist/i18n/locales/id/index.js.map +1 -0
- package/dist/i18n/locales/id/media.json.js +52 -0
- package/dist/i18n/locales/id/media.json.js.map +1 -0
- package/dist/i18n/locales/id/menu.json.js +118 -0
- package/dist/i18n/locales/id/menu.json.js.map +1 -0
- package/dist/i18n/locales/id/pages.json.js +16 -0
- package/dist/i18n/locales/id/pages.json.js.map +1 -0
- package/dist/i18n/locales/id/panels.json.js +838 -0
- package/dist/i18n/locales/id/panels.json.js.map +1 -0
- package/dist/i18n/locales/id/recovery.json.js +36 -0
- package/dist/i18n/locales/id/recovery.json.js.map +1 -0
- package/dist/i18n/locales/id/rename.json.js +19 -0
- package/dist/i18n/locales/id/rename.json.js.map +1 -0
- package/dist/i18n/locales/id/rendering.json.js +18 -0
- package/dist/i18n/locales/id/rendering.json.js.map +1 -0
- package/dist/i18n/locales/id/settings.json.js +169 -0
- package/dist/i18n/locales/id/settings.json.js.map +1 -0
- package/dist/i18n/locales/id/shaders.json.js +24 -0
- package/dist/i18n/locales/id/shaders.json.js.map +1 -0
- package/dist/i18n/locales/id/shapes.json.js +48 -0
- package/dist/i18n/locales/id/shapes.json.js.map +1 -0
- package/dist/i18n/locales/id/slides.json.js +27 -0
- package/dist/i18n/locales/id/slides.json.js.map +1 -0
- package/dist/i18n/locales/id/statuses.json.js +38 -0
- package/dist/i18n/locales/id/statuses.json.js.map +1 -0
- package/dist/i18n/locales/id/storage.json.js +21 -0
- package/dist/i18n/locales/id/storage.json.js.map +1 -0
- package/dist/i18n/locales/id/tools.json.js +27 -0
- package/dist/i18n/locales/id/tools.json.js.map +1 -0
- package/dist/i18n/locales/id/updates.json.js +31 -0
- package/dist/i18n/locales/id/updates.json.js.map +1 -0
- package/dist/i18n/locales/id/variables/panel.json.js +175 -0
- package/dist/i18n/locales/id/variables/panel.json.js.map +1 -0
- package/dist/i18n/locales/id/variables/types.json.js +15 -0
- package/dist/i18n/locales/id/variables/types.json.js.map +1 -0
- package/dist/i18n/locales/id/variations.json.js +23 -0
- package/dist/i18n/locales/id/variations.json.js.map +1 -0
- package/dist/i18n/locales/it/ai.json.js +68 -2
- package/dist/i18n/locales/it/commands.json.js +2 -0
- package/dist/i18n/locales/it/comments.json.js +1 -1
- package/dist/i18n/locales/it/design-check.json.js +13 -1
- package/dist/i18n/locales/it/design-memory.json.js +82 -0
- package/dist/i18n/locales/it/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/it/fonts.json.js +10 -0
- package/dist/i18n/locales/it/index.js +5 -1
- package/dist/i18n/locales/it/index.js.map +1 -1
- package/dist/i18n/locales/it/menu.json.js +2 -0
- package/dist/i18n/locales/it/panels.json.js +109 -1
- package/dist/i18n/locales/it/settings.json.js +1 -0
- package/dist/i18n/locales/it/tools.json.js +3 -1
- package/dist/i18n/locales/it/variables/panel.json.js +20 -0
- package/dist/i18n/locales/it/variations.json.js +23 -0
- package/dist/i18n/locales/it/variations.json.js.map +1 -0
- package/dist/i18n/locales/ja/ai.json.js +68 -2
- package/dist/i18n/locales/ja/commands.json.js +2 -0
- package/dist/i18n/locales/ja/comments.json.js +1 -1
- package/dist/i18n/locales/ja/design-check.json.js +13 -1
- package/dist/i18n/locales/ja/design-memory.json.js +61 -0
- package/dist/i18n/locales/ja/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/ja/fonts.json.js +10 -0
- package/dist/i18n/locales/ja/index.js +5 -1
- package/dist/i18n/locales/ja/index.js.map +1 -1
- package/dist/i18n/locales/ja/menu.json.js +2 -0
- package/dist/i18n/locales/ja/panels.json.js +106 -1
- package/dist/i18n/locales/ja/settings.json.js +1 -0
- package/dist/i18n/locales/ja/tools.json.js +3 -1
- package/dist/i18n/locales/ja/variables/panel.json.js +20 -0
- package/dist/i18n/locales/ja/variations.json.js +23 -0
- package/dist/i18n/locales/ja/variations.json.js.map +1 -0
- package/dist/i18n/locales/pl/ai.json.js +68 -2
- package/dist/i18n/locales/pl/commands.json.js +2 -0
- package/dist/i18n/locales/pl/comments.json.js +1 -1
- package/dist/i18n/locales/pl/design-check.json.js +13 -1
- package/dist/i18n/locales/pl/design-memory.json.js +89 -0
- package/dist/i18n/locales/pl/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/pl/fonts.json.js +10 -0
- package/dist/i18n/locales/pl/index.js +5 -1
- package/dist/i18n/locales/pl/index.js.map +1 -1
- package/dist/i18n/locales/pl/menu.json.js +2 -0
- package/dist/i18n/locales/pl/panels.json.js +110 -1
- package/dist/i18n/locales/pl/settings.json.js +1 -0
- package/dist/i18n/locales/pl/tools.json.js +3 -1
- package/dist/i18n/locales/pl/variables/panel.json.js +20 -0
- package/dist/i18n/locales/pl/variations.json.js +23 -0
- package/dist/i18n/locales/pl/variations.json.js.map +1 -0
- package/dist/i18n/locales/ru/ai.json.js +68 -2
- package/dist/i18n/locales/ru/commands.json.js +3 -1
- package/dist/i18n/locales/ru/comments.json.js +1 -1
- package/dist/i18n/locales/ru/design-check.json.js +13 -1
- package/dist/i18n/locales/ru/design-memory.json.js +89 -0
- package/dist/i18n/locales/ru/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/ru/fonts.json.js +10 -0
- package/dist/i18n/locales/ru/index.js +5 -1
- package/dist/i18n/locales/ru/index.js.map +1 -1
- package/dist/i18n/locales/ru/menu.json.js +2 -0
- package/dist/i18n/locales/ru/panels.json.js +110 -1
- package/dist/i18n/locales/ru/settings.json.js +1 -0
- package/dist/i18n/locales/ru/tools.json.js +3 -1
- package/dist/i18n/locales/ru/variables/panel.json.js +20 -0
- package/dist/i18n/locales/ru/variations.json.js +23 -0
- package/dist/i18n/locales/ru/variations.json.js.map +1 -0
- package/dist/i18n/locales/zh-cn/ai.json.js +68 -2
- package/dist/i18n/locales/zh-cn/commands.json.js +2 -0
- package/dist/i18n/locales/zh-cn/comments.json.js +1 -1
- package/dist/i18n/locales/zh-cn/design-check.json.js +13 -1
- package/dist/i18n/locales/zh-cn/design-memory.json.js +61 -0
- package/dist/i18n/locales/zh-cn/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/zh-cn/fonts.json.js +10 -0
- package/dist/i18n/locales/zh-cn/index.js +5 -1
- package/dist/i18n/locales/zh-cn/index.js.map +1 -1
- package/dist/i18n/locales/zh-cn/menu.json.js +2 -0
- package/dist/i18n/locales/zh-cn/panels.json.js +106 -1
- package/dist/i18n/locales/zh-cn/settings.json.js +1 -0
- package/dist/i18n/locales/zh-cn/tools.json.js +3 -1
- package/dist/i18n/locales/zh-cn/variables/panel.json.js +20 -0
- package/dist/i18n/locales/zh-cn/variations.json.js +23 -0
- package/dist/i18n/locales/zh-cn/variations.json.js.map +1 -0
- package/dist/i18n/messages/ai.d.ts +98 -2
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +70 -2
- package/dist/i18n/messages/ai.js.map +1 -1
- package/dist/i18n/messages/chat-usage.d.ts +34 -0
- package/dist/i18n/messages/chat-usage.d.ts.map +1 -0
- package/dist/i18n/messages/chat-usage.js +25 -0
- package/dist/i18n/messages/chat-usage.js.map +1 -0
- package/dist/i18n/messages/commands.d.ts +2 -0
- package/dist/i18n/messages/commands.d.ts.map +1 -1
- package/dist/i18n/messages/commands.js +2 -0
- package/dist/i18n/messages/commands.js.map +1 -1
- package/dist/i18n/messages/comments.d.ts +2 -2
- package/dist/i18n/messages/comments.js +2 -2
- package/dist/i18n/messages/comments.js.map +1 -1
- package/dist/i18n/messages/design-check.d.ts +12 -0
- package/dist/i18n/messages/design-check.d.ts.map +1 -1
- package/dist/i18n/messages/design-check.js +13 -1
- package/dist/i18n/messages/design-check.js.map +1 -1
- package/dist/i18n/messages/design-memory.d.ts +68 -0
- package/dist/i18n/messages/design-memory.d.ts.map +1 -0
- package/dist/i18n/messages/design-memory.js +85 -0
- package/dist/i18n/messages/design-memory.js.map +1 -0
- package/dist/i18n/messages/fonts.d.ts +12 -0
- package/dist/i18n/messages/fonts.d.ts.map +1 -1
- package/dist/i18n/messages/fonts.js +10 -0
- package/dist/i18n/messages/fonts.js.map +1 -1
- package/dist/i18n/messages/menu.d.ts +2 -0
- package/dist/i18n/messages/menu.d.ts.map +1 -1
- package/dist/i18n/messages/menu.js +2 -0
- package/dist/i18n/messages/menu.js.map +1 -1
- package/dist/i18n/messages/panels.d.ts +131 -0
- package/dist/i18n/messages/panels.d.ts.map +1 -1
- package/dist/i18n/messages/panels.js +109 -1
- package/dist/i18n/messages/panels.js.map +1 -1
- package/dist/i18n/messages/settings.d.ts +1 -0
- package/dist/i18n/messages/settings.d.ts.map +1 -1
- package/dist/i18n/messages/settings.js +1 -0
- package/dist/i18n/messages/settings.js.map +1 -1
- package/dist/i18n/messages/tools.d.ts +2 -0
- package/dist/i18n/messages/tools.d.ts.map +1 -1
- package/dist/i18n/messages/tools.js +3 -1
- package/dist/i18n/messages/tools.js.map +1 -1
- package/dist/i18n/messages/variables/panel.d.ts +24 -0
- package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
- package/dist/i18n/messages/variables/panel.js +20 -0
- package/dist/i18n/messages/variables/panel.js.map +1 -1
- package/dist/i18n/messages/variations.d.ts +28 -0
- package/dist/i18n/messages/variations.d.ts.map +1 -0
- package/dist/i18n/messages/variations.js +26 -0
- package/dist/i18n/messages/variations.js.map +1 -0
- package/dist/i18n/messages.d.ts +405 -4
- package/dist/i18n/messages.d.ts.map +1 -1
- package/dist/i18n/messages.js +8 -2
- package/dist/i18n/messages.js.map +1 -1
- package/dist/i18n/useI18n.d.ts +1389 -13
- package/dist/i18n/useI18n.d.ts.map +1 -1
- package/dist/i18n/useI18n.js +8 -1
- package/dist/i18n/useI18n.js.map +1 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts +6 -0
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.js +3 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.js.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +11 -2
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +15 -5
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
- package/dist/primitives/ColorPicker/index.d.ts +2 -1
- package/dist/primitives/ColorPicker/index.js +2 -1
- package/dist/primitives/ColorPicker/outside.d.ts +16 -0
- package/dist/primitives/ColorPicker/outside.d.ts.map +1 -0
- package/dist/primitives/ColorPicker/outside.js +20 -0
- package/dist/primitives/ColorPicker/outside.js.map +1 -0
- package/dist/primitives/Fill/FillRoot.vue.d.ts +2 -1
- package/dist/primitives/Fill/FillRoot.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillRoot.vue.js +5 -2
- package/dist/primitives/Fill/FillRoot.vue.js.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.js +2 -1
- package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
- package/dist/primitives/Fill/types.d.ts +6 -1
- package/dist/primitives/Fill/types.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.d.ts +10 -4
- package/dist/primitives/Fill/useFill.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.js +14 -10
- package/dist/primitives/Fill/useFill.js.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +5 -0
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js +63 -56
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts +2 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js +5 -2
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.js +4 -3
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/types.d.ts +3 -1
- package/dist/primitives/GradientEditor/types.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/useGradientStops.d.ts +5 -3
- package/dist/primitives/GradientEditor/useGradientStops.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/useGradientStops.js +9 -4
- package/dist/primitives/GradientEditor/useGradientStops.js.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +6 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +16 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts +3 -0
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts.map +1 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js +3 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js.map +1 -1
- package/dist/shared/assets/cursors/eyedropper.svg.js +6 -0
- package/dist/shared/assets/cursors/eyedropper.svg.js.map +1 -0
- package/dist/shared/frame.d.ts +28 -0
- package/dist/shared/frame.d.ts.map +1 -0
- package/dist/shared/frame.js +92 -0
- package/dist/shared/frame.js.map +1 -0
- package/dist/shared/input/auto-layout/drag.js +71 -0
- package/dist/shared/input/auto-layout/drag.js.map +1 -0
- package/dist/shared/input/{auto-layout-hover.d.ts → auto-layout/hover.d.ts} +3 -3
- package/dist/shared/input/auto-layout/hover.d.ts.map +1 -0
- package/dist/shared/input/{auto-layout-hover.js → auto-layout/hover.js} +42 -86
- package/dist/shared/input/auto-layout/hover.js.map +1 -0
- package/dist/shared/input/{auto-layout.js → auto-layout/index.js} +2 -2
- package/dist/shared/input/auto-layout/index.js.map +1 -0
- package/dist/shared/input/index.d.ts +1 -1
- package/dist/shared/input/index.js +1 -1
- package/dist/shared/input/move/drag.js +1 -1
- package/dist/shared/input/resize.js +1 -1
- package/dist/shared/input/select.js +5 -3
- package/dist/shared/input/select.js.map +1 -1
- package/dist/shared/input/types.d.ts +10 -2
- package/dist/shared/input/types.d.ts.map +1 -1
- package/dist/shared/input/types.js.map +1 -1
- package/package.json +19 -4
- package/dist/shared/input/auto-layout-hover.d.ts.map +0 -1
- package/dist/shared/input/auto-layout-hover.js.map +0 -1
- package/dist/shared/input/auto-layout.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanvasInput.js","names":["createCanvasTransformInput"],"sources":["../../src/canvas/useCanvasInput.ts"],"sourcesContent":["import { useEventListener } from '@vueuse/core'\nimport { onScopeDispose, ref, watch, type Ref } from 'vue'\n\nimport { resolveEditorProfile, type Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { createAutoLayoutValueEdit } from '#vue/canvas/auto-layout/value-edit'\nimport { createGuideInput } from '#vue/canvas/guides/input'\nimport { createCanvasLabelEdit } from '#vue/canvas/labels/edit'\nimport { finishPencilDrag } from '#vue/canvas/pencil/input'\nimport { moveDrag, type DragMoveContext } from '#vue/canvas/pointer/drag-move'\nimport { createCanvasPointer } from '#vue/canvas/pointer/use'\nimport { createTextEditInput } from '#vue/canvas/text-edit/input'\nimport { hoverCanvasTool, pressCanvasTool } from '#vue/canvas/tools/input'\nimport type { CanvasToolContext, CanvasToolPointer } from '#vue/canvas/tools/registry'\nimport { createCanvasTransformInput } from '#vue/canvas/transform/input'\nimport { finishMarquee } from '#vue/canvas/transform/marquee'\nimport {\n cancelNodeEditDrag,\n handleNodeEditPointerUp,\n updateNodeEditHover\n} from '#vue/canvas/vector-input/input'\nimport { stopViewportTween } from '#vue/canvas/viewport/tween'\nimport { resolveAutoLayoutHover } from '#vue/shared/input/auto-layout-hover'\nimport { createClickCounter } from '#vue/shared/input/click-count'\nimport { refreshConnectorDrag } from '#vue/shared/input/connector/draw'\nimport { cancelMove, handleMoveUp } from '#vue/shared/input/move/drag'\nimport { setupPanZoom } from '#vue/shared/input/pan/zoom'\nimport { cancelResizePreview, commitResizePreview } from '#vue/shared/input/resize'\nimport { updateHoverCursor } from '#vue/shared/input/select'\nimport { resolveShapeHandleHover } from '#vue/shared/input/shape-handles'\nimport { useSpaceHeld } from '#vue/shared/input/space-key'\nimport type { DragState } from '#vue/shared/input/types'\nimport { DEFAULT_WHEEL_ZOOM_OPTIONS, type WheelZoomOptions } from '#vue/shared/input/wheel'\n\n/**\n * Wires pointer and mouse interaction to a Pairdraw canvas.\n *\n * This composable coordinates selection, dragging, resizing, rotation,\n * panning, drawing tools, scoped hit testing, and text-edit interaction.\n * It is primarily intended for editor shell components that own the canvas.\n */\n/** Drags Escape abandons, leaving the document as it was before the press. */\nconst ESCAPABLE_DRAGS: ReadonlySet<DragState['type']> = new Set<DragState['type']>([\n 'draw',\n 'gradient',\n 'image-crop',\n 'rotate',\n 'connector-draw',\n 'connector-end',\n 'connector-line',\n 'line-end',\n 'zoom',\n 'scale'\n])\n\nexport function useCanvasInput(\n canvasRef: Ref<HTMLCanvasElement | null>,\n editor: Editor,\n hitTestSectionTitle: (cx: number, cy: number) => SceneNode | null,\n hitTestComponentLabel: (cx: number, cy: number) => SceneNode | null,\n hitTestFrameTitle: (cx: number, cy: number) => SceneNode | null,\n onCursorMove?: (cx: number, cy: number) => void,\n onActivate?: () => void,\n isEnabled: () => boolean = () => true,\n /** How far wheel and pinch zoom move per event; 1 is the default rate. */\n zoomSpeed: () => number = () => 1,\n /** Whether a plain wheel zooms and whether a wheel zoom is inverted. */\n zoomOptions: () => WheelZoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS\n) {\n const drag = ref<DragState | null>(null)\n const profile = () => resolveEditorProfile(editor.state)\n // Canvas chrome that explains layout, such as auto layout child outlines, steps aside while\n // layers move, resize, or rotate.\n watch(\n () => drag.value?.type,\n (type) => editor.setTransforming(type === 'move' || type === 'resize' || type === 'rotate')\n )\n const canvasLabelEdit = createCanvasLabelEdit(editor)\n const cursorOverride = ref<string | null>(null)\n /** Whether the primary button is held on a preview control, such as a slider thumb. */\n const valueEdit = createAutoLayoutValueEdit(editor)\n const selectedIdsBeforeClickSequence = ref<ReadonlySet<string>>(new Set())\n const lastPointer = ref<{ cx: number; cy: number; sx: number; sy: number } | null>(null)\n const pointerInside = ref(false)\n let altHeld = false\n let metaHeld = false\n let controlHeld = false\n const spaceHeld = useSpaceHeld()\n const { recordClick, getClickCount } = createClickCounter()\n\n const { getCoords, canvasToLocal, hitTestInScope, hitFns } = createCanvasPointer(\n canvasRef,\n editor,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle\n )\n\n function canMeasure() {\n return (\n pointerInside.value &&\n !drag.value &&\n editor.state.activeTool === 'SELECT' &&\n editor.state.selectedIds.size > 0 &&\n !editor.state.editingTextId &&\n !editor.state.nodeEditState &&\n !editor.state.penState\n )\n }\n\n /** ⌘ or Ctrl held: hover reaches the deepest layer, the one a click would select, as in Figma. */\n function hoverDeep(e?: MouseEvent) {\n return e ? e.metaKey || e.ctrlKey : metaHeld || controlHeld\n }\n\n function refreshMeasurement() {\n const mode = altHeld && canMeasure() ? (metaHeld || controlHeld ? 'deep' : 'shallow') : 'off'\n editor.setMeasurementMode(mode)\n const pointer = lastPointer.value\n if (!pointer || drag.value || editor.state.activeTool !== 'SELECT' || !pointerInside.value)\n return\n cursorOverride.value = updateHoverCursor(\n pointer.cx,\n pointer.cy,\n editor,\n hitFns,\n mode === 'deep' || hoverDeep()\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(pointer.cx, pointer.cy, mode))\n editor.setShapeHandleHover(shapeHandleHoverAt(pointer.sx, pointer.sy, altHeld))\n }\n\n // Handles that edit, which a read-only document does not offer.\n function autoLayoutHoverAt(cx: number, cy: number, mode: typeof editor.state.measurementMode) {\n return mode === 'off' && profile().edits ? resolveAutoLayoutHover(cx, cy, editor) : null\n }\n\n function shapeHandleHoverAt(sx: number, sy: number, altKey: boolean) {\n return profile().edits ? resolveShapeHandleHover(editor, sx, sy, altKey) : null\n }\n\n function updateModifier(code: string, held: boolean) {\n if (!isEnabled()) return\n if (code === 'AltLeft' || code === 'AltRight') altHeld = held\n if (code === 'MetaLeft' || code === 'MetaRight') metaHeld = held\n if (code === 'ControlLeft' || code === 'ControlRight') controlHeld = held\n if (code.startsWith('Alt') || code.startsWith('Meta') || code.startsWith('Control')) {\n refreshMeasurement()\n }\n }\n\n function resetMeasurementModifiers() {\n altHeld = false\n metaHeld = false\n controlHeld = false\n editor.setMeasurementMode('off')\n }\n\n function setDrag(d: DragState) {\n editor.setMeasurementMode('off')\n drag.value = d\n }\n\n const guideInput = createGuideInput({\n canvasRef,\n editor,\n canvasToLocal,\n setDrag,\n setCursor: (cursor) => {\n cursorOverride.value = cursor\n }\n })\n\n const { handleTextEditClick, onDblClick: onTextDblClick } = createTextEditInput({\n editor,\n getCoords,\n hitTestInScope,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle,\n getClickCount,\n wasSelectedBeforeClickSequence: (id) => selectedIdsBeforeClickSequence.value.has(id),\n onEditCanvasLabel: canvasLabelEdit.start,\n setDrag\n })\n\n const {\n tryStartRotation,\n handlePanMove,\n handleRotateMove,\n handleTextSelectMove,\n handleMarqueeMove\n } = createCanvasTransformInput(editor, setDrag)\n const dragMoveContext: DragMoveContext = {\n editor,\n guideInput,\n transform: { handlePanMove, handleRotateMove, handleTextSelectMove, handleMarqueeMove },\n spaceHeld: () => spaceHeld.value\n }\n\n function onDblClick(e: MouseEvent) {\n if (profile().pointer === 'pan') return\n const { cx, cy } = getCoords(e)\n if (profile().edits && valueEdit.start(cx, cy)) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n onTextDblClick(e)\n }\n\n function hoverLayers({ event, cx, cy, sx, sy }: CanvasToolPointer) {\n const guideCursor = profile().edits ? guideInput.updateHover(sx, sy) : null\n cursorOverride.value =\n guideCursor ??\n updateHoverCursor(\n cx,\n cy,\n editor,\n hitFns,\n editor.state.measurementMode === 'deep' || hoverDeep(event)\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(cx, cy, editor.state.measurementMode))\n }\n\n const toolContext: CanvasToolContext = {\n editor,\n hitFns,\n cursorOverride,\n setDrag,\n tryStartRotation,\n handleTextEditClick,\n hoverLayers\n }\n\n function onMouseDown(e: MouseEvent) {\n onActivate?.()\n if (!isEnabled()) return\n // A canvas that only pans, as a preview's does, leaves its controls to the islands above it.\n const panOnly = profile().pointer === 'pan'\n if (panOnly && e.button === 0 && editor.state.activeTool !== 'HAND') {\n e.preventDefault()\n return\n }\n // Safari treats an unprevented press as the start of a text selection drag and freezes the\n // cursor until the pointer leaves the canvas; the canvas handles its own drags.\n if (e.button === 0) e.preventDefault()\n editor.setMeasurementMode('off')\n // A press takes the view over from a glide, where it is.\n stopViewportTween(editor)\n const openValueEdit = valueEdit.edit.value\n if (openValueEdit) valueEdit.commit(openValueEdit.value)\n if (!editor.state.editingTextId) canvasRef.value?.focus()\n editor.setHoveredNode(null)\n const { sx, sy, cx, cy } = getCoords(e)\n // Guides belong to the document, so a read-only one neither moves nor gains them.\n const guidesEditable = e.button === 0 && profile().edits\n if (guidesEditable && guideInput.tryStartExisting(sx, sy, e.altKey)) {\n e.preventDefault()\n return\n }\n if (guidesEditable && guideInput.tryStartFromRuler(sx, sy, cx, cy)) {\n e.preventDefault()\n return\n }\n editor.setSelectedGuide(null)\n\n const selectedIdsBeforeMouseDown = new Set(editor.state.selectedIds)\n const clickCount = recordClick(sx, sy)\n if (clickCount === 1) selectedIdsBeforeClickSequence.value = selectedIdsBeforeMouseDown\n pressCanvasTool({ event: e, cx, cy, sx, sy }, toolContext)\n }\n\n function onMouseMove(e: MouseEvent) {\n if (!isEnabled()) return\n pointerInside.value = true\n const coords = getCoords(e)\n lastPointer.value = { cx: coords.cx, cy: coords.cy, sx: coords.sx, sy: coords.sy }\n if (onCursorMove) {\n onCursorMove(coords.cx, coords.cy)\n }\n\n if (profile().pointer === 'pan' && !drag.value) return\n\n if (!drag.value) {\n const { cx, cy, sx, sy } = coords\n updateNodeEditHover(editor, cx, cy)\n editor.setShapeHandleHover(shapeHandleHoverAt(sx, sy, e.altKey))\n hoverCanvasTool({ event: e, ...coords }, toolContext)\n }\n\n if (!drag.value) return\n moveDrag(drag.value, e, coords, dragMoveContext)\n }\n\n function onMouseUp() {\n if (!drag.value) return\n const d = drag.value\n\n if (handleNodeEditPointerUp(drag, editor)) return\n\n if (d.type === 'guide') {\n guideInput.finish(d)\n } else if (d.type === 'move') handleMoveUp(d, editor)\n else if (d.type === 'text-select') {\n drag.value = null\n return\n } else if (d.type === 'resize') commitResizePreview(d, editor)\n else if (d.type === 'pen-drag') {\n const penState = editor.state.penState\n if (penState?.pendingClose) {\n editor.penCommit(true)\n }\n drag.value = null\n return\n } else if (d.type === 'pencil-drag') finishPencilDrag(editor)\n else if (d.type === 'rotate') {\n const preview = editor.state.rotationPreview\n if (preview?.nodeId === d.nodeId && preview.angle !== d.origRotation) {\n editor.updateNode(d.nodeId, { rotation: preview.angle })\n editor.commitRotation(d.nodeId, d.origRotation)\n }\n if (editor.state.rotationPreview === preview) editor.setRotationPreview(null)\n } else if ('commit' in d) d.commit()\n else if (d.type === 'marquee') finishMarquee(editor, d)\n\n drag.value = null\n cursorOverride.value = null\n refreshMeasurement()\n }\n\n function clearTransientInteractionFeedback() {\n editor.setSnapGuides([])\n editor.setLayoutInsertIndicator(null)\n editor.setDropTarget(null)\n editor.setShapeHandleHover(null)\n guideInput.clearHoverAndPreview()\n }\n\n /** Drops what a drag showed without changing the document. */\n function discardDrawnPreview(d: DragState) {\n if (d.type === 'resize') cancelResizePreview(d, editor)\n else if ('cancel' in d) d.cancel()\n else if (d.type === 'pencil-drag') editor.pencilCancel()\n }\n\n /** Takes back what a drag in progress has previewed, by its kind. */\n function discardDrag(d: DragState) {\n discardDrawnPreview(d)\n if (d.type === 'move') cancelMove(d, editor)\n else if (d.type === 'rotate') {\n if (editor.state.rotationPreview?.nodeId === d.nodeId) editor.setRotationPreview(null)\n } else cancelNodeEditDrag(d, editor)\n }\n\n function cancelPointerInteraction() {\n const d = drag.value\n // Cleared first: ending a preview fires events whose listeners cancel again.\n drag.value = null\n if (d) discardDrag(d)\n cursorOverride.value = null\n clearTransientInteractionFeedback()\n }\n\n function onPointerDown(e: PointerEvent) {\n if (e.pointerType !== 'mouse' || e.button !== 0) return\n canvasRef.value?.setPointerCapture(e.pointerId)\n }\n\n function onPointerUp(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n onMouseUp()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n function onPointerCancel(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n cancelPointerInteraction()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n useEventListener(canvasRef, 'pointerdown', onPointerDown)\n useEventListener(canvasRef, 'pointerup', onPointerUp)\n useEventListener(canvasRef, 'pointercancel', onPointerCancel)\n useEventListener(canvasRef, 'dblclick', onDblClick)\n useEventListener(canvasRef, 'mousedown', onMouseDown)\n useEventListener(canvasRef, 'mousemove', onMouseMove)\n useEventListener(canvasRef, 'mouseup', onMouseUp)\n useEventListener(window, 'keydown', (event) => {\n if (guideInput.deleteSelected(event)) return\n updateModifier(event.code, true)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n useEventListener(window, 'keyup', (event) => {\n updateModifier(event.code, false)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n // Pressing or releasing ⌘ or Ctrl mid-drag switches a marquee between deep and plain at once.\n useEventListener(window, ['keydown', 'keyup'], (event: KeyboardEvent) => {\n const d = drag.value\n const pointer = lastPointer.value\n // Before the first move there is no marquee to redo.\n if (d?.type !== 'marquee' || !pointer || !editor.state.marquee || !isEnabled()) return\n if (!event.code.startsWith('Meta') && !event.code.startsWith('Control')) return\n handleMarqueeMove(d, pointer.cx, pointer.cy, event.metaKey || event.ctrlKey)\n })\n useEventListener(\n window,\n 'keydown',\n (event) => {\n if (event.code !== 'Escape' || event.isComposing || !isEnabled()) return\n const type = drag.value?.type\n // A vector edit marquee carries on through Escape, as in Figma, and keeps the path open.\n const swallowed = type === 'edit-marquee'\n if (!type || (!ESCAPABLE_DRAGS.has(type) && !swallowed)) return\n event.preventDefault()\n event.stopImmediatePropagation()\n if (!swallowed) cancelPointerInteraction()\n },\n { capture: true }\n )\n // Space during a move keeps layers in their parents, as in Figma, instead of switching to the hand.\n function holdParentsDuringMove(event: KeyboardEvent, held: boolean) {\n if (event.code !== 'Space' || drag.value?.type !== 'move' || !isEnabled()) return\n event.preventDefault()\n event.stopImmediatePropagation()\n drag.value.keepParents = held\n if (held) editor.setDropTarget(null)\n }\n useEventListener(window, 'keydown', (event) => holdParentsDuringMove(event, true), {\n capture: true\n })\n useEventListener(window, 'keyup', (event) => holdParentsDuringMove(event, false), {\n capture: true\n })\n useEventListener(window, 'blur', () => {\n resetMeasurementModifiers()\n cancelPointerInteraction()\n })\n useEventListener(canvasRef, 'mouseleave', () => {\n pointerInside.value = false\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n if (!drag.value) {\n editor.setHoveredNode(null)\n editor.setHoveredGuide(null)\n editor.setShapeHandleHover(null)\n }\n })\n useEventListener(\n window,\n 'mouseup',\n () => {\n if (drag.value) onMouseUp()\n },\n { capture: true }\n )\n\n const stopRotationListener = editor.onEditorEvent('rotation:preview-changed', (preview) => {\n if (drag.value?.type === 'rotate' && preview?.nodeId !== drag.value.nodeId)\n cancelPointerInteraction()\n })\n const stopToolListener = editor.onEditorEvent('tool:changed', () => {\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n cancelPointerInteraction()\n })\n // A document that turns read-only mid-gesture drops the gesture and any open inline edit.\n const stopReadOnlyListener = editor.onEditorEvent('document:read-only-changed', (readOnly) => {\n if (!readOnly) return\n valueEdit.cancel()\n canvasLabelEdit.cancel()\n cancelPointerInteraction()\n })\n const stopPlayListeners = (['selection:changed', 'page:changed', 'graph:replaced'] as const).map(\n (event) =>\n editor.onEditorEvent(event, () => {\n const type = drag.value?.type\n if (\n type === 'draw' ||\n type === 'sticky-draw' ||\n type === 'rotate' ||\n type === 'shape-handle' ||\n type === 'image-crop' ||\n type === 'sticky-scale' ||\n type === 'scale'\n )\n cancelPointerInteraction()\n })\n )\n onScopeDispose(() => {\n stopRotationListener()\n stopToolListener()\n stopReadOnlyListener()\n for (const stop of stopPlayListeners) stop()\n cancelPointerInteraction()\n // A canvas unmounted mid-rename keeps the name typed, as the field's blur does in Chromium.\n canvasLabelEdit.commit()\n })\n\n setupPanZoom(canvasRef, editor, drag, onMouseDown, onMouseMove, onMouseUp, zoomSpeed, zoomOptions)\n return {\n drag,\n cursorOverride,\n canvasLabelEdit: canvasLabelEdit.edit,\n updateCanvasLabelEdit: canvasLabelEdit.update,\n commitCanvasLabelEdit: canvasLabelEdit.commit,\n cancelCanvasLabelEdit: canvasLabelEdit.cancel,\n autoLayoutValueEdit: valueEdit.edit,\n updateAutoLayoutValueEdit: valueEdit.update,\n commitAutoLayoutValueEdit: valueEdit.commit,\n cancelAutoLayoutValueEdit: valueEdit.cancel,\n cleanupInteractions() {\n valueEdit.cancel()\n cancelPointerInteraction()\n pointerInside.value = false\n resetMeasurementModifiers()\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,kCAAkD,IAAI,IAAuB;CACjF;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,eACd,WACA,QACA,qBACA,uBACA,mBACA,cACA,YACA,kBAAiC,MAEjC,kBAAgC,GAEhC,oBAA4C,4BAC5C;CACA,MAAM,OAAO,IAAsB,IAAI;CACvC,MAAM,gBAAgB,qBAAqB,OAAO,KAAK;CAGvD,YACQ,KAAK,OAAO,OACjB,SAAS,OAAO,gBAAgB,SAAS,UAAU,SAAS,YAAY,SAAS,QAAQ,CAC5F;CACA,MAAM,kBAAkB,sBAAsB,MAAM;CACpD,MAAM,iBAAiB,IAAmB,IAAI;;CAE9C,MAAM,YAAY,0BAA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,OAAO,cAAc,+BAA+B,aAAa;EAC5F,IAAI,CAAC,UAAU;EACf,UAAU,OAAO;EACjB,gBAAgB,OAAO;EACvB,yBAAyB;CAC3B,CAAC;CACD,MAAM,oBAAqB;EAAC;EAAqB;EAAgB;CAAgB,CAAC,CAAW,KAC1F,UACC,OAAO,cAAc,aAAa;EAChC,MAAM,OAAO,KAAK,OAAO;EACzB,IACE,SAAS,UACT,SAAS,iBACT,SAAS,YACT,SAAS,kBACT,SAAS,gBACT,SAAS,kBACT,SAAS,SAET,yBAAyB;CAC7B,CAAC,CACL;CACA,qBAAqB;EACnB,qBAAqB;EACrB,iBAAiB;EACjB,qBAAqB;EACrB,KAAK,MAAM,QAAQ,mBAAmB,KAAK;EAC3C,yBAAyB;EAEzB,gBAAgB,OAAO;CACzB,CAAC;CAED,aAAa,WAAW,QAAQ,MAAM,aAAa,aAAa,WAAW,WAAW,WAAW;CACjG,OAAO;EACL;EACA;EACA,iBAAiB,gBAAgB;EACjC,uBAAuB,gBAAgB;EACvC,uBAAuB,gBAAgB;EACvC,uBAAuB,gBAAgB;EACvC,qBAAqB,UAAU;EAC/B,2BAA2B,UAAU;EACrC,2BAA2B,UAAU;EACrC,2BAA2B,UAAU;EACrC,sBAAsB;GACpB,UAAU,OAAO;GACjB,yBAAyB;GACzB,cAAc,QAAQ;GACtB,0BAA0B;EAC5B;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useCanvasInput.js","names":["createCanvasTransformInput"],"sources":["../../src/canvas/useCanvasInput.ts"],"sourcesContent":["import { useEventListener } from '@vueuse/core'\nimport { onScopeDispose, ref, watch, type Ref } from 'vue'\n\nimport { resolveEditorProfile, type Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { createAutoLayoutValueEdit } from '#vue/canvas/auto-layout/value-edit'\nimport { createGuideInput } from '#vue/canvas/guides/input'\nimport { createCanvasLabelEdit } from '#vue/canvas/labels/edit'\nimport { finishPencilDrag } from '#vue/canvas/pencil/input'\nimport { moveDrag, type DragMoveContext } from '#vue/canvas/pointer/drag-move'\nimport { createCanvasPointer } from '#vue/canvas/pointer/use'\nimport { createTextEditInput } from '#vue/canvas/text-edit/input'\nimport { hoverCanvasTool, pressCanvasTool } from '#vue/canvas/tools/input'\nimport type { CanvasToolContext, CanvasToolPointer } from '#vue/canvas/tools/registry'\nimport { createCanvasTransformInput } from '#vue/canvas/transform/input'\nimport { finishMarquee } from '#vue/canvas/transform/marquee'\nimport {\n cancelNodeEditDrag,\n handleNodeEditPointerUp,\n updateNodeEditHover\n} from '#vue/canvas/vector-input/input'\nimport { stopViewportTween } from '#vue/canvas/viewport/tween'\nimport { resolveAutoLayoutHover } from '#vue/shared/input/auto-layout/hover'\nimport { createClickCounter } from '#vue/shared/input/click-count'\nimport { refreshConnectorDrag } from '#vue/shared/input/connector/draw'\nimport { cancelMove, handleMoveUp } from '#vue/shared/input/move/drag'\nimport { setupPanZoom } from '#vue/shared/input/pan/zoom'\nimport { cancelResizePreview, commitResizePreview } from '#vue/shared/input/resize'\nimport { updateHoverCursor } from '#vue/shared/input/select'\nimport { resolveShapeHandleHover } from '#vue/shared/input/shape-handles'\nimport { useSpaceHeld } from '#vue/shared/input/space-key'\nimport type { DragState } from '#vue/shared/input/types'\nimport { DEFAULT_WHEEL_ZOOM_OPTIONS, type WheelZoomOptions } from '#vue/shared/input/wheel'\n\n/**\n * Wires pointer and mouse interaction to a Pairdraw canvas.\n *\n * This composable coordinates selection, dragging, resizing, rotation,\n * panning, drawing tools, scoped hit testing, and text-edit interaction.\n * It is primarily intended for editor shell components that own the canvas.\n */\n/** Drags Escape abandons, leaving the document as it was before the press. */\nconst ESCAPABLE_DRAGS: ReadonlySet<DragState['type']> = new Set<DragState['type']>([\n 'draw',\n 'gradient',\n 'image-crop',\n 'rotate',\n 'connector-draw',\n 'connector-end',\n 'connector-line',\n 'line-end',\n 'zoom',\n 'scale'\n])\n\nexport function useCanvasInput(\n canvasRef: Ref<HTMLCanvasElement | null>,\n editor: Editor,\n hitTestSectionTitle: (cx: number, cy: number) => SceneNode | null,\n hitTestComponentLabel: (cx: number, cy: number) => SceneNode | null,\n hitTestFrameTitle: (cx: number, cy: number) => SceneNode | null,\n onCursorMove?: (cx: number, cy: number) => void,\n onActivate?: () => void,\n isEnabled: () => boolean = () => true,\n /** How far wheel and pinch zoom move per event; 1 is the default rate. */\n zoomSpeed: () => number = () => 1,\n /** Whether a plain wheel zooms and whether a wheel zoom is inverted. */\n zoomOptions: () => WheelZoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS,\n /** Settings → Editor's large nudge, in pixels, for handle drags with Shift. */\n bigNudge: () => number = () => 10\n) {\n const drag = ref<DragState | null>(null)\n const profile = () => resolveEditorProfile(editor.state)\n // Canvas chrome that explains layout, such as auto layout child outlines, steps aside while\n // layers move, resize, or rotate.\n watch(\n () => drag.value?.type,\n (type) => editor.setTransforming(type === 'move' || type === 'resize' || type === 'rotate')\n )\n const canvasLabelEdit = createCanvasLabelEdit(editor)\n const cursorOverride = ref<string | null>(null)\n /** Whether the primary button is held on a preview control, such as a slider thumb. */\n const valueEdit = createAutoLayoutValueEdit(editor)\n const selectedIdsBeforeClickSequence = ref<ReadonlySet<string>>(new Set())\n const lastPointer = ref<{ cx: number; cy: number; sx: number; sy: number } | null>(null)\n const pointerInside = ref(false)\n let altHeld = false\n let metaHeld = false\n let controlHeld = false\n const spaceHeld = useSpaceHeld()\n const { recordClick, getClickCount } = createClickCounter()\n\n const { getCoords, canvasToLocal, hitTestInScope, hitFns } = createCanvasPointer(\n canvasRef,\n editor,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle\n )\n\n function canMeasure() {\n return (\n pointerInside.value &&\n !drag.value &&\n editor.state.activeTool === 'SELECT' &&\n editor.state.selectedIds.size > 0 &&\n !editor.state.editingTextId &&\n !editor.state.nodeEditState &&\n !editor.state.penState\n )\n }\n\n /** ⌘ or Ctrl held: hover reaches the deepest layer, the one a click would select, as in Figma. */\n function hoverDeep(e?: MouseEvent) {\n return e ? e.metaKey || e.ctrlKey : metaHeld || controlHeld\n }\n\n function refreshMeasurement() {\n const mode = altHeld && canMeasure() ? (metaHeld || controlHeld ? 'deep' : 'shallow') : 'off'\n editor.setMeasurementMode(mode)\n const pointer = lastPointer.value\n if (!pointer || drag.value || editor.state.activeTool !== 'SELECT' || !pointerInside.value)\n return\n cursorOverride.value = updateHoverCursor(\n pointer.cx,\n pointer.cy,\n editor,\n hitFns,\n mode === 'deep' || hoverDeep()\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(pointer.cx, pointer.cy, mode))\n editor.setShapeHandleHover(shapeHandleHoverAt(pointer.sx, pointer.sy, altHeld))\n }\n\n // Handles that edit, which a read-only document does not offer.\n function autoLayoutHoverAt(cx: number, cy: number, mode: typeof editor.state.measurementMode) {\n return mode === 'off' && profile().edits ? resolveAutoLayoutHover(cx, cy, editor) : null\n }\n\n function shapeHandleHoverAt(sx: number, sy: number, altKey: boolean) {\n return profile().edits ? resolveShapeHandleHover(editor, sx, sy, altKey) : null\n }\n\n function updateModifier(code: string, held: boolean) {\n if (!isEnabled()) return\n if (code === 'AltLeft' || code === 'AltRight') altHeld = held\n if (code === 'MetaLeft' || code === 'MetaRight') metaHeld = held\n if (code === 'ControlLeft' || code === 'ControlRight') controlHeld = held\n if (code.startsWith('Alt') || code.startsWith('Meta') || code.startsWith('Control')) {\n refreshMeasurement()\n }\n }\n\n function resetMeasurementModifiers() {\n altHeld = false\n metaHeld = false\n controlHeld = false\n editor.setMeasurementMode('off')\n }\n\n function setDrag(d: DragState) {\n editor.setMeasurementMode('off')\n drag.value = d\n }\n\n const guideInput = createGuideInput({\n canvasRef,\n editor,\n canvasToLocal,\n setDrag,\n setCursor: (cursor) => {\n cursorOverride.value = cursor\n }\n })\n\n const { handleTextEditClick, onDblClick: onTextDblClick } = createTextEditInput({\n editor,\n getCoords,\n hitTestInScope,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle,\n getClickCount,\n wasSelectedBeforeClickSequence: (id) => selectedIdsBeforeClickSequence.value.has(id),\n onEditCanvasLabel: canvasLabelEdit.start,\n setDrag\n })\n\n const {\n tryStartRotation,\n handlePanMove,\n handleRotateMove,\n handleTextSelectMove,\n handleMarqueeMove\n } = createCanvasTransformInput(editor, setDrag)\n const dragMoveContext: DragMoveContext = {\n editor,\n guideInput,\n transform: { handlePanMove, handleRotateMove, handleTextSelectMove, handleMarqueeMove },\n spaceHeld: () => spaceHeld.value\n }\n\n function onDblClick(e: MouseEvent) {\n if (profile().pointer === 'pan') return\n const { cx, cy } = getCoords(e)\n if (profile().edits && valueEdit.start(cx, cy)) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n onTextDblClick(e)\n }\n\n function hoverLayers({ event, cx, cy, sx, sy }: CanvasToolPointer) {\n const guideCursor = profile().edits ? guideInput.updateHover(sx, sy) : null\n cursorOverride.value =\n guideCursor ??\n updateHoverCursor(\n cx,\n cy,\n editor,\n hitFns,\n editor.state.measurementMode === 'deep' || hoverDeep(event)\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(cx, cy, editor.state.measurementMode))\n }\n\n const toolContext: CanvasToolContext = {\n editor,\n hitFns,\n cursorOverride,\n setDrag,\n tryStartRotation,\n handleTextEditClick,\n bigNudge,\n hoverLayers\n }\n\n function onMouseDown(e: MouseEvent) {\n onActivate?.()\n if (!isEnabled()) return\n // A canvas that only pans, as a preview's does, leaves its controls to the islands above it.\n const panOnly = profile().pointer === 'pan'\n if (panOnly && e.button === 0 && editor.state.activeTool !== 'HAND') {\n e.preventDefault()\n return\n }\n // Safari treats an unprevented press as the start of a text selection drag and freezes the\n // cursor until the pointer leaves the canvas; the canvas handles its own drags.\n if (e.button === 0) e.preventDefault()\n editor.setMeasurementMode('off')\n // A press takes the view over from a glide, where it is.\n stopViewportTween(editor)\n const openValueEdit = valueEdit.edit.value\n if (openValueEdit) valueEdit.commit(openValueEdit.value)\n if (!editor.state.editingTextId) canvasRef.value?.focus()\n editor.setHoveredNode(null)\n const { sx, sy, cx, cy } = getCoords(e)\n // Guides belong to the document, so a read-only one neither moves nor gains them.\n const guidesEditable = e.button === 0 && profile().edits\n if (guidesEditable && guideInput.tryStartExisting(sx, sy, e.altKey)) {\n e.preventDefault()\n return\n }\n if (guidesEditable && guideInput.tryStartFromRuler(sx, sy, cx, cy)) {\n e.preventDefault()\n return\n }\n editor.setSelectedGuide(null)\n\n const selectedIdsBeforeMouseDown = new Set(editor.state.selectedIds)\n const clickCount = recordClick(sx, sy)\n if (clickCount === 1) selectedIdsBeforeClickSequence.value = selectedIdsBeforeMouseDown\n pressCanvasTool({ event: e, cx, cy, sx, sy }, toolContext)\n }\n\n function onMouseMove(e: MouseEvent) {\n if (!isEnabled()) return\n pointerInside.value = true\n const coords = getCoords(e)\n lastPointer.value = { cx: coords.cx, cy: coords.cy, sx: coords.sx, sy: coords.sy }\n if (onCursorMove) {\n onCursorMove(coords.cx, coords.cy)\n }\n\n if (profile().pointer === 'pan' && !drag.value) return\n\n if (!drag.value) {\n const { cx, cy, sx, sy } = coords\n updateNodeEditHover(editor, cx, cy)\n editor.setShapeHandleHover(shapeHandleHoverAt(sx, sy, e.altKey))\n hoverCanvasTool({ event: e, ...coords }, toolContext)\n }\n\n if (!drag.value) return\n moveDrag(drag.value, e, coords, dragMoveContext)\n }\n\n function onMouseUp() {\n if (!drag.value) return\n const d = drag.value\n\n if (handleNodeEditPointerUp(drag, editor)) return\n\n if (d.type === 'guide') {\n guideInput.finish(d)\n } else if (d.type === 'move') handleMoveUp(d, editor)\n else if (d.type === 'text-select') {\n drag.value = null\n return\n } else if (d.type === 'resize') commitResizePreview(d, editor)\n else if (d.type === 'pen-drag') {\n const penState = editor.state.penState\n if (penState?.pendingClose) {\n editor.penCommit(true)\n }\n drag.value = null\n return\n } else if (d.type === 'pencil-drag') finishPencilDrag(editor)\n else if (d.type === 'rotate') {\n const preview = editor.state.rotationPreview\n if (preview?.nodeId === d.nodeId && preview.angle !== d.origRotation) {\n editor.updateNode(d.nodeId, { rotation: preview.angle })\n editor.commitRotation(d.nodeId, d.origRotation)\n }\n if (editor.state.rotationPreview === preview) editor.setRotationPreview(null)\n } else if ('commit' in d) d.commit()\n else if (d.type === 'marquee') finishMarquee(editor, d)\n\n drag.value = null\n cursorOverride.value = null\n refreshMeasurement()\n }\n\n function clearTransientInteractionFeedback() {\n editor.setSnapGuides([])\n editor.setLayoutInsertIndicator(null)\n editor.setDropTarget(null)\n editor.setShapeHandleHover(null)\n guideInput.clearHoverAndPreview()\n }\n\n /** Drops what a drag showed without changing the document. */\n function discardDrawnPreview(d: DragState) {\n if (d.type === 'resize') cancelResizePreview(d, editor)\n else if ('cancel' in d) d.cancel()\n else if (d.type === 'pencil-drag') editor.pencilCancel()\n }\n\n /** Takes back what a drag in progress has previewed, by its kind. */\n function discardDrag(d: DragState) {\n discardDrawnPreview(d)\n if (d.type === 'move') cancelMove(d, editor)\n else if (d.type === 'rotate') {\n if (editor.state.rotationPreview?.nodeId === d.nodeId) editor.setRotationPreview(null)\n } else cancelNodeEditDrag(d, editor)\n }\n\n function cancelPointerInteraction() {\n const d = drag.value\n // Cleared first: ending a preview fires events whose listeners cancel again.\n drag.value = null\n if (d) discardDrag(d)\n cursorOverride.value = null\n clearTransientInteractionFeedback()\n }\n\n function onPointerDown(e: PointerEvent) {\n if (e.pointerType !== 'mouse' || e.button !== 0) return\n canvasRef.value?.setPointerCapture(e.pointerId)\n }\n\n function onPointerUp(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n onMouseUp()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n function onPointerCancel(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n cancelPointerInteraction()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n useEventListener(canvasRef, 'pointerdown', onPointerDown)\n useEventListener(canvasRef, 'pointerup', onPointerUp)\n useEventListener(canvasRef, 'pointercancel', onPointerCancel)\n useEventListener(canvasRef, 'dblclick', onDblClick)\n useEventListener(canvasRef, 'mousedown', onMouseDown)\n useEventListener(canvasRef, 'mousemove', onMouseMove)\n useEventListener(canvasRef, 'mouseup', onMouseUp)\n useEventListener(window, 'keydown', (event) => {\n if (guideInput.deleteSelected(event)) return\n updateModifier(event.code, true)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n useEventListener(window, 'keyup', (event) => {\n updateModifier(event.code, false)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n // Pressing or releasing ⌘ or Ctrl mid-drag switches a marquee between deep and plain at once.\n useEventListener(window, ['keydown', 'keyup'], (event: KeyboardEvent) => {\n const d = drag.value\n const pointer = lastPointer.value\n // Before the first move there is no marquee to redo.\n if (d?.type !== 'marquee' || !pointer || !editor.state.marquee || !isEnabled()) return\n if (!event.code.startsWith('Meta') && !event.code.startsWith('Control')) return\n handleMarqueeMove(d, pointer.cx, pointer.cy, event.metaKey || event.ctrlKey)\n })\n useEventListener(\n window,\n 'keydown',\n (event) => {\n if (event.code !== 'Escape' || event.isComposing || !isEnabled()) return\n const type = drag.value?.type\n // A vector edit marquee carries on through Escape, as in Figma, and keeps the path open.\n const swallowed = type === 'edit-marquee'\n if (!type || (!ESCAPABLE_DRAGS.has(type) && !swallowed)) return\n event.preventDefault()\n event.stopImmediatePropagation()\n if (!swallowed) cancelPointerInteraction()\n },\n { capture: true }\n )\n // Space during a move keeps layers in their parents, as in Figma, instead of switching to the hand.\n function holdParentsDuringMove(event: KeyboardEvent, held: boolean) {\n if (event.code !== 'Space' || drag.value?.type !== 'move' || !isEnabled()) return\n event.preventDefault()\n event.stopImmediatePropagation()\n drag.value.keepParents = held\n if (held) editor.setDropTarget(null)\n }\n useEventListener(window, 'keydown', (event) => holdParentsDuringMove(event, true), {\n capture: true\n })\n useEventListener(window, 'keyup', (event) => holdParentsDuringMove(event, false), {\n capture: true\n })\n useEventListener(window, 'blur', () => {\n resetMeasurementModifiers()\n cancelPointerInteraction()\n })\n useEventListener(canvasRef, 'mouseleave', () => {\n pointerInside.value = false\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n if (!drag.value) {\n editor.setHoveredNode(null)\n editor.setHoveredGuide(null)\n editor.setShapeHandleHover(null)\n }\n })\n useEventListener(\n window,\n 'mouseup',\n () => {\n if (drag.value) onMouseUp()\n },\n { capture: true }\n )\n\n const stopRotationListener = editor.onEditorEvent('rotation:preview-changed', (preview) => {\n if (drag.value?.type === 'rotate' && preview?.nodeId !== drag.value.nodeId)\n cancelPointerInteraction()\n })\n const stopToolListener = editor.onEditorEvent('tool:changed', () => {\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n cancelPointerInteraction()\n })\n // A document that turns read-only mid-gesture drops the gesture and any open inline edit.\n const stopReadOnlyListener = editor.onEditorEvent('document:read-only-changed', (readOnly) => {\n if (!readOnly) return\n valueEdit.cancel()\n canvasLabelEdit.cancel()\n cancelPointerInteraction()\n })\n const stopPlayListeners = (['selection:changed', 'page:changed', 'graph:replaced'] as const).map(\n (event) =>\n editor.onEditorEvent(event, () => {\n const type = drag.value?.type\n if (\n type === 'draw' ||\n type === 'sticky-draw' ||\n type === 'rotate' ||\n type === 'shape-handle' ||\n type === 'image-crop' ||\n type === 'sticky-scale' ||\n type === 'scale'\n )\n cancelPointerInteraction()\n })\n )\n onScopeDispose(() => {\n stopRotationListener()\n stopToolListener()\n stopReadOnlyListener()\n for (const stop of stopPlayListeners) stop()\n cancelPointerInteraction()\n // A canvas unmounted mid-rename keeps the name typed, as the field's blur does in Chromium.\n canvasLabelEdit.commit()\n })\n\n setupPanZoom(canvasRef, editor, drag, onMouseDown, onMouseMove, onMouseUp, zoomSpeed, zoomOptions)\n return {\n drag,\n cursorOverride,\n canvasLabelEdit: canvasLabelEdit.edit,\n updateCanvasLabelEdit: canvasLabelEdit.update,\n commitCanvasLabelEdit: canvasLabelEdit.commit,\n cancelCanvasLabelEdit: canvasLabelEdit.cancel,\n autoLayoutValueEdit: valueEdit.edit,\n updateAutoLayoutValueEdit: valueEdit.update,\n commitAutoLayoutValueEdit: valueEdit.commit,\n cancelAutoLayoutValueEdit: valueEdit.cancel,\n cleanupInteractions() {\n valueEdit.cancel()\n cancelPointerInteraction()\n pointerInside.value = false\n resetMeasurementModifiers()\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,kCAAkD,IAAI,IAAuB;CACjF;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,eACd,WACA,QACA,qBACA,uBACA,mBACA,cACA,YACA,kBAAiC,MAEjC,kBAAgC,GAEhC,oBAA4C,4BAE5C,iBAA+B,IAC/B;CACA,MAAM,OAAO,IAAsB,IAAI;CACvC,MAAM,gBAAgB,qBAAqB,OAAO,KAAK;CAGvD,YACQ,KAAK,OAAO,OACjB,SAAS,OAAO,gBAAgB,SAAS,UAAU,SAAS,YAAY,SAAS,QAAQ,CAC5F;CACA,MAAM,kBAAkB,sBAAsB,MAAM;CACpD,MAAM,iBAAiB,IAAmB,IAAI;;CAE9C,MAAM,YAAY,0BAA0B,MAAM;CAClD,MAAM,iCAAiC,oBAAyB,IAAI,IAAI,CAAC;CACzE,MAAM,cAAc,IAA+D,IAAI;CACvF,MAAM,gBAAgB,IAAI,KAAK;CAC/B,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAAI,cAAc;CAClB,MAAM,YAAY,aAAa;CAC/B,MAAM,EAAE,aAAa,kBAAkB,mBAAmB;CAE1D,MAAM,EAAE,WAAW,eAAe,gBAAgB,WAAW,oBAC3D,WACA,QACA,qBACA,uBACA,iBACF;CAEA,SAAS,aAAa;EACpB,OACE,cAAc,SACd,CAAC,KAAK,SACN,OAAO,MAAM,eAAe,YAC5B,OAAO,MAAM,YAAY,OAAO,KAChC,CAAC,OAAO,MAAM,iBACd,CAA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C,yBAAyB;EAEzB,gBAAgB,OAAO;CACzB,CAAC;CAED,aAAa,WAAW,QAAQ,MAAM,aAAa,aAAa,WAAW,WAAW,WAAW;CACjG,OAAO;EACL;EACA;EACA,iBAAiB,gBAAgB;EACjC,uBAAuB,gBAAgB;EACvC,uBAAuB,gBAAgB;EACvC,uBAAuB,gBAAgB;EACvC,qBAAqB,UAAU;EAC/B,2BAA2B,UAAU;EACrC,2BAA2B,UAAU;EACrC,2BAA2B,UAAU;EACrC,sBAAsB;GACpB,UAAU,OAAO;GACjB,yBAAyB;GACzB,cAAc,QAAQ;GACtB,0BAA0B;EAC5B;CACF;AACF"}
|
|
@@ -31,7 +31,7 @@ declare function useAppearance(): {
|
|
|
31
31
|
cornerSmoothingPercent: import("vue").ComputedRef<number | typeof MIXED>;
|
|
32
32
|
opacityPercent: import("vue").ComputedRef<number | typeof MIXED>;
|
|
33
33
|
blendModeValue: import("vue").ComputedRef<import("@pairdraw/scene-graph").BlendMode | typeof MIXED>;
|
|
34
|
-
visibilityState: import("vue").ComputedRef<"
|
|
34
|
+
visibilityState: import("vue").ComputedRef<"mixed" | "visible" | "hidden">;
|
|
35
35
|
editor: import("@pairdraw/core").Editor;
|
|
36
36
|
nodes: import("vue").ComputedRef<import("@pairdraw/scene-graph").SceneNode[]>;
|
|
37
37
|
node: import("vue").ComputedRef<import("@pairdraw/scene-graph").SceneNode | null>;
|
|
@@ -6,7 +6,7 @@ import { isEqual } from "es-toolkit";
|
|
|
6
6
|
//#region src/controls/binding-provider/pairdraw.ts
|
|
7
7
|
function createPairdrawBindingProvider(editor, options, revision) {
|
|
8
8
|
const { contains } = useFilter({ sensitivity: "base" });
|
|
9
|
-
const variables = () =>
|
|
9
|
+
const variables = () => editor.graph.getLiveVariables().filter((variable) => options.types.includes(variable.type));
|
|
10
10
|
const interactiveEdits = [];
|
|
11
11
|
/**
|
|
12
12
|
* A picker keeps one batch open while it is used. Undo and redo commit it first and reopen it,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pairdraw.js","names":[],"sources":["../../../src/controls/binding-provider/pairdraw.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit'\nimport { useFilter } from 'reka-ui'\n\nimport type { Editor } from '@pairdraw/core'\nimport type { Variable, VariableType } from '@pairdraw/scene-graph'\n\nimport type {\n BindingValueEdit,\n BindingProvider,\n BindingState,\n BindingTarget\n} from '#vue/controls/binding-provider/types'\nimport { useEditor } from '#vue/editor/context'\nimport { useSceneComputed } from '#vue/internal/scene-computed/use'\n\nimport { resolveEffectiveBindingValue } from './resolution'\n\nexport interface PairdrawBindingProviderOptions<V> {\n /** The variable types the field binds to, which the picker lists. */\n types: readonly VariableType[]\n resolve(editor: Editor, variableId: string, target?: BindingTarget): V | undefined\n create?(editor: Editor, target: BindingTarget, value: V, name: string): void\n prepareEdit?(\n editor: Editor,\n variableId: string,\n target: BindingTarget\n ): BindingValueEdit<V> | undefined\n}\n\nexport function createPairdrawBindingProvider<V>(\n editor: Editor,\n options: PairdrawBindingProviderOptions<V>,\n revision?: BindingProvider<V>['revision']\n): BindingProvider<V> {\n const { contains } = useFilter({ sensitivity: 'base' })\n const variables = () =>\n
|
|
1
|
+
{"version":3,"file":"pairdraw.js","names":[],"sources":["../../../src/controls/binding-provider/pairdraw.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit'\nimport { useFilter } from 'reka-ui'\n\nimport type { Editor } from '@pairdraw/core'\nimport type { Variable, VariableType } from '@pairdraw/scene-graph'\n\nimport type {\n BindingValueEdit,\n BindingProvider,\n BindingState,\n BindingTarget\n} from '#vue/controls/binding-provider/types'\nimport { useEditor } from '#vue/editor/context'\nimport { useSceneComputed } from '#vue/internal/scene-computed/use'\n\nimport { resolveEffectiveBindingValue } from './resolution'\n\nexport interface PairdrawBindingProviderOptions<V> {\n /** The variable types the field binds to, which the picker lists. */\n types: readonly VariableType[]\n resolve(editor: Editor, variableId: string, target?: BindingTarget): V | undefined\n create?(editor: Editor, target: BindingTarget, value: V, name: string): void\n prepareEdit?(\n editor: Editor,\n variableId: string,\n target: BindingTarget\n ): BindingValueEdit<V> | undefined\n}\n\nexport function createPairdrawBindingProvider<V>(\n editor: Editor,\n options: PairdrawBindingProviderOptions<V>,\n revision?: BindingProvider<V>['revision']\n): BindingProvider<V> {\n const { contains } = useFilter({ sensitivity: 'base' })\n const variables = () =>\n editor.graph.getLiveVariables().filter((variable) => options.types.includes(variable.type))\n const interactiveEdits: Array<{ end: () => void; stopSettling: () => void }> = []\n\n /**\n * A picker keeps one batch open while it is used. Undo and redo commit it first and reopen it,\n * so they act on the picker's changes and later changes still form one step.\n */\n function beginBatch(label: string) {\n editor.undo.beginBatch(label)\n const stopSettling = editor.undo.onBeforeHistory(() => {\n editor.undo.commitBatch()\n editor.undo.beginBatch(label)\n })\n interactiveEdits.push({ end: editor.beginInteractiveEdit(), stopSettling })\n }\n\n function finishBatch(commit: boolean) {\n const edit = interactiveEdits.pop()\n edit?.stopSettling()\n try {\n if (commit) editor.undo.commitBatch()\n else editor.undo.rollbackBatch()\n } finally {\n edit?.end()\n }\n }\n\n function filterVariables(term: string): Variable[] {\n if (!term) return variables()\n return variables().filter((variable) => contains(variable.name, term))\n }\n\n function getBound(target: BindingTarget): Variable | undefined {\n void revision?.value\n const variableId = editor.getNode(target.nodeId)?.boundVariables[target.path]\n return variableId ? editor.getVariable(variableId) : undefined\n }\n\n function getState(targets: BindingTarget[]): BindingState {\n if (targets.length === 0) return 'unbound'\n const variableIds = new Set(\n targets.map(\n (target) => editor.getNode(target.nodeId)?.boundVariables[target.path] ?? undefined\n )\n )\n // Identity takes precedence: an explicit mixed edit can detach the selection.\n // edit-variable still requires every bound destination to prepare successfully.\n if (variableIds.size > 1) return 'mixed'\n const unresolved = targets.some((target) => {\n const id = editor.getNode(target.nodeId)?.boundVariables[target.path]\n return (\n id !== undefined &&\n (resolveEffectiveBindingValue(editor, id, target) === undefined ||\n options.resolve(editor, id, target) === undefined)\n )\n })\n if (unresolved) return 'unresolved'\n if (variableIds.has(undefined)) return 'unbound'\n const values = targets.map((target) => {\n const id = editor.getNode(target.nodeId)?.boundVariables[target.path]\n return id ? options.resolve(editor, id, target) : undefined\n })\n if (values.some((value) => value === undefined)) return 'unresolved'\n return values.every((value) => isEqual(value, values[0])) ? 'bound' : 'mixed'\n }\n\n return {\n revision,\n listVariables: variables,\n collectionName: (variable) => editor.getCollection(variable.collectionId)?.name,\n filterVariables,\n getBindingId: (target) => editor.getNode(target.nodeId)?.boundVariables[target.path],\n getBound,\n getState,\n resolve: (variableId, target) => options.resolve(editor, variableId, target),\n bind: (target, variableId) => editor.bindVariable(target.nodeId, target.path, variableId),\n unbind: (target) => editor.unbindVariable(target.nodeId, target.path),\n create: options.create\n ? (target, value, name) => options.create?.(editor, target, value, name)\n : undefined,\n prepareEdit: options.prepareEdit\n ? (variableId, target) => options.prepareEdit?.(editor, variableId, target)\n : undefined,\n runBatch: (label, action) => editor.undo.runBatch(label, action),\n beginBatch,\n commitBatch: () => finishBatch(true),\n rollbackBatch: () => finishBatch(false)\n }\n}\n\nexport function usePairdrawBindingProvider<V>(\n options: PairdrawBindingProviderOptions<V>\n): BindingProvider<V> {\n const editor = useEditor()\n const revision = useSceneComputed(() => editor.state.sceneVersion)\n return createPairdrawBindingProvider(editor, options, revision)\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,8BACd,QACA,SACA,UACoB;CACpB,MAAM,EAAE,aAAa,UAAU,EAAE,aAAa,OAAO,CAAC;CACtD,MAAM,kBACJ,OAAO,MAAM,iBAAiB,CAAC,CAAC,QAAQ,aAAa,QAAQ,MAAM,SAAS,SAAS,IAAI,CAAC;CAC5F,MAAM,mBAAyE,CAAC;;;;;CAMhF,SAAS,WAAW,OAAe;EACjC,OAAO,KAAK,WAAW,KAAK;EAC5B,MAAM,eAAe,OAAO,KAAK,sBAAsB;GACrD,OAAO,KAAK,YAAY;GACxB,OAAO,KAAK,WAAW,KAAK;EAC9B,CAAC;EACD,iBAAiB,KAAK;GAAE,K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,IAAI,OAAO,MAAM,UAAU,UAAU,KAAA,CAAS,GAAG,OAAO;EACxD,OAAO,OAAO,OAAO,UAAU,QAAQ,OAAO,OAAO,EAAE,CAAC,IAAI,UAAU;CACxE;CAEA,OAAO;EACL;EACA,eAAe;EACf,iBAAiB,aAAa,OAAO,cAAc,SAAS,YAAY,CAAC,EAAE;EAC3E;EACA,eAAe,WAAW,OAAO,QAAQ,OAAO,MAAM,CAAC,EAAE,eAAe,OAAO;EAC/E;EACA;EACA,UAAU,YAAY,WAAW,QAAQ,QAAQ,QAAQ,YAAY,MAAM;EAC3E,OAAO,QAAQ,eAAe,OAAO,aAAa,OAAO,QAAQ,OAAO,MAAM,UAAU;EACxF,SAAS,WAAW,OAAO,eAAe,OAAO,QAAQ,OAAO,IAAI;EACpE,QAAQ,QAAQ,UACX,QAAQ,OAAO,SAAS,QAAQ,SAAS,QAAQ,QAAQ,OAAO,IAAI,IACrE,KAAA;EACJ,aAAa,QAAQ,eAChB,YAAY,WAAW,QAAQ,cAAc,QAAQ,YAAY,MAAM,IACxE,KAAA;EACJ,WAAW,OAAO,WAAW,OAAO,KAAK,SAAS,OAAO,MAAM;EAC/D;EACA,mBAAmB,YAAY,IAAI;EACnC,qBAAqB,YAAY,KAAK;CACxC;AACF;AAEA,SAAgB,2BACd,SACoB;CACpB,MAAM,SAAS,UAAU;CAEzB,OAAO,8BAA8B,QAAQ,SAD5B,uBAAuB,OAAO,MAAM,YACQ,CAAC;AAChE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MaybeRefOrGetter } from "vue";
|
|
2
2
|
import { Color } from "reka-ui";
|
|
3
3
|
import { OkHCLColor, RenderColorSpace } from "@pairdraw/scene-graph/color";
|
|
4
|
+
import { ColorProfile } from "@pairdraw/scene-graph";
|
|
4
5
|
import { Color as Color$1 } from "@pairdraw/scene-graph/primitives";
|
|
5
6
|
//#region src/controls/color-model/types.d.ts
|
|
6
7
|
type BuiltInColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsb' | 'okhcl';
|
|
@@ -24,6 +25,11 @@ interface OkHCLControls {
|
|
|
24
25
|
}
|
|
25
26
|
interface UseColorModelOptions {
|
|
26
27
|
color: MaybeRefOrGetter<Color$1>;
|
|
28
|
+
/**
|
|
29
|
+
* The profile the color is stored in; the hex readout converts it into sRGB, the space a hex
|
|
30
|
+
* code names, so it shows the color a Display P3 document draws. Defaults to sRGB.
|
|
31
|
+
*/
|
|
32
|
+
colorProfile?: MaybeRefOrGetter<ColorProfile>;
|
|
27
33
|
okhcl?: MaybeRefOrGetter<OkHCLColor | null | undefined>;
|
|
28
34
|
format?: MaybeRefOrGetter<ColorFieldFormat | undefined>;
|
|
29
35
|
defaultFormat?: ColorFieldFormat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/controls/color-model/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/controls/color-model/types.ts"],"mappings":";;;;;;KAOY;KACA,mBAAmB;KAEnB;KACA;KACA;KACA;UAEK;EACf,OAAO;EACP;;UAGe;EACf,aAAa;EACb,cAAc;EACd,OAAO;EACP,oBAAoB;EACpB;EACA,iBAAiB,QAAQ;EACzB,cAAc,OAAO,QAAQ;;UAGd;EACf,OAAO,iBAAiB;;;;;EAKxB,eAAe,iBAAiB;EAChC,QAAQ,iBAAiB;EACzB,SAAS,iBAAiB;EAC1B,gBAAgB;EAChB,YAAY,OAAO;EACnB,iBAAiB,OAAO,QAAQ;EAChC,kBAAkB,QAAQ;;UAGX;EACf,KAAK;EACL,eAAe;EACf,cAAc;EACd,eAAe;EACf,eAAe;;UAGA;EACf,UAAU;EACV,aAAa;EACb,gBAAgB;;UAGD;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;;KAGU,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/controls/color-model/use.ts"],"mappings":";;;;cAiCa;;;;;iBAMG,cAAc,SAAS;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/controls/color-model/use.ts"],"mappings":";;;;cAiCa;;;;;iBAMG,cAAc,SAAS;;;;;;;;;;;;;EA6BN,YAAA,YAAA;EAdD,cAAA,WAAA,UAAQ;EAKZ,YAAA,kBAAM;EAeG,iBAAA,WAAA,mBAAc;EAIzB,YAAA,gBAAM;EAIF,cAAA,kBAAM;EAIC,mBAAA,SAAA,YAAU,yBAAsB;EAIhC,mBAAA,SAAA,YAAU,yBAAsB;EAIhC,mBAAA,SAAA,YAAU,yBAAsB;EAI9B,qBAAA,SAAA,cAAY,+DAAsB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyOkHCLPatch, colorsEqual, createColorModelValue, createOkHCLSliderGradientModel, createOkHCLSliderPreviewModel, createSliderGradientModel, createSliderPreviewModel, normalizeOkHCLPatch, okhclPatchChangesColor, rekaToSceneColor, withAlpha, withHSBChannel, withHSLChannel, withHue, withRGBChannel } from "./model.js";
|
|
2
2
|
import { computed, ref, toValue } from "vue";
|
|
3
|
-
import { colorToHexRaw, okhclToRGBA, parseColor } from "@pairdraw/scene-graph/color";
|
|
3
|
+
import { colorToHexRaw, convertColor, okhclToRGBA, parseColor } from "@pairdraw/scene-graph/color";
|
|
4
4
|
//#region src/controls/color-model/use.ts
|
|
5
5
|
/** Built-in presentation formats understood by the color model. */
|
|
6
6
|
const BUILT_IN_COLOR_FORMATS = [
|
|
@@ -20,7 +20,8 @@ function useColorModel(options) {
|
|
|
20
20
|
const sourceOkHCL = computed(() => toValue(options.okhcl));
|
|
21
21
|
const value = computed(() => createColorModelValue(color.value, sourceOkHCL.value));
|
|
22
22
|
const format = computed(() => toValue(options.format) ?? localFormat.value);
|
|
23
|
-
const
|
|
23
|
+
const colorProfile = computed(() => toValue(options.colorProfile ?? "srgb"));
|
|
24
|
+
const hex = computed(() => colorToHexRaw(convertColor(color.value, colorProfile.value, "srgb")));
|
|
24
25
|
const sliderPreview = computed(() => createSliderPreviewModel(value.value));
|
|
25
26
|
const sliderGradient = computed(() => createSliderGradientModel(value.value));
|
|
26
27
|
const okhclSliderPreview = computed(() => createOkHCLSliderPreviewModel(value.value.okhcl));
|
|
@@ -30,8 +31,9 @@ function useColorModel(options) {
|
|
|
30
31
|
return nextColor;
|
|
31
32
|
}
|
|
32
33
|
function updateHex(input) {
|
|
34
|
+
const parsed = parseColor(input.startsWith("#") ? input : `#${input}`);
|
|
33
35
|
return emitColor({
|
|
34
|
-
...
|
|
36
|
+
...colorProfile.value === "srgb" ? parsed : convertColor(parsed, "srgb", colorProfile.value),
|
|
35
37
|
a: color.value.a
|
|
36
38
|
});
|
|
37
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","names":[],"sources":["../../../src/controls/color-model/use.ts"],"sourcesContent":["import { computed, ref, toValue } from 'vue'\n\nimport { colorToHexRaw, okhclToRGBA, parseColor } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport {\n applyOkHCLPatch,\n colorsEqual,\n createColorModelValue,\n createOkHCLSliderGradientModel,\n createOkHCLSliderPreviewModel,\n createSliderGradientModel,\n createSliderPreviewModel,\n normalizeOkHCLPatch,\n okhclPatchChangesColor,\n rekaToSceneColor,\n withAlpha,\n withHSBChannel,\n withHSLChannel,\n withHue,\n withRGBChannel\n} from '#vue/controls/color-model/model'\nimport type {\n ColorFieldFormat,\n HSBChannel,\n HSLChannel,\n OkHCLChannel,\n RGBChannel,\n RekaColorValue,\n UseColorModelOptions\n} from '#vue/controls/color-model/types'\n\n/** Built-in presentation formats understood by the color model. */\nexport const BUILT_IN_COLOR_FORMATS = ['hex', 'rgb', 'hsl', 'hsb', 'okhcl'] as const\n\n/**\n * Creates reactive color-space values, channel actions, and slider presentation data without\n * requiring an editor context.\n */\nexport function useColorModel(options: UseColorModelOptions) {\n const localFormat = ref<ColorFieldFormat>(options.defaultFormat ?? 'rgb')\n const color = computed(() => toValue(options.color))\n const sourceOkHCL = computed(() => toValue(options.okhcl))\n const value = computed(() => createColorModelValue(color.value, sourceOkHCL.value))\n const format = computed(() => toValue(options.format) ?? localFormat.value)\n const hex = computed(() => colorToHexRaw(color.value))\n const sliderPreview = computed(() => createSliderPreviewModel(value.value))\n const sliderGradient = computed(() => createSliderGradientModel(value.value))\n const okhclSliderPreview = computed(() => createOkHCLSliderPreviewModel(value.value.okhcl))\n const okhclSliderGradient = computed(() => createOkHCLSliderGradientModel(value.value.okhcl))\n\n function emitColor(nextColor: Color): Color {\n if (!colorsEqual(color.value, nextColor)) options.onUpdate?.(nextColor)\n return nextColor\n }\n\n function updateHex(input: string) {\n const parsed = parseColor(input.startsWith('#') ? input : `#${input}`)\n return emitColor({ ...
|
|
1
|
+
{"version":3,"file":"use.js","names":[],"sources":["../../../src/controls/color-model/use.ts"],"sourcesContent":["import { computed, ref, toValue } from 'vue'\n\nimport { colorToHexRaw, convertColor, okhclToRGBA, parseColor } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport {\n applyOkHCLPatch,\n colorsEqual,\n createColorModelValue,\n createOkHCLSliderGradientModel,\n createOkHCLSliderPreviewModel,\n createSliderGradientModel,\n createSliderPreviewModel,\n normalizeOkHCLPatch,\n okhclPatchChangesColor,\n rekaToSceneColor,\n withAlpha,\n withHSBChannel,\n withHSLChannel,\n withHue,\n withRGBChannel\n} from '#vue/controls/color-model/model'\nimport type {\n ColorFieldFormat,\n HSBChannel,\n HSLChannel,\n OkHCLChannel,\n RGBChannel,\n RekaColorValue,\n UseColorModelOptions\n} from '#vue/controls/color-model/types'\n\n/** Built-in presentation formats understood by the color model. */\nexport const BUILT_IN_COLOR_FORMATS = ['hex', 'rgb', 'hsl', 'hsb', 'okhcl'] as const\n\n/**\n * Creates reactive color-space values, channel actions, and slider presentation data without\n * requiring an editor context.\n */\nexport function useColorModel(options: UseColorModelOptions) {\n const localFormat = ref<ColorFieldFormat>(options.defaultFormat ?? 'rgb')\n const color = computed(() => toValue(options.color))\n const sourceOkHCL = computed(() => toValue(options.okhcl))\n const value = computed(() => createColorModelValue(color.value, sourceOkHCL.value))\n const format = computed(() => toValue(options.format) ?? localFormat.value)\n const colorProfile = computed(() => toValue(options.colorProfile ?? 'srgb'))\n // A hex code names an sRGB color, so a Display P3 document's stored components are converted\n // into sRGB for the readout, as the swatch beside it shows the color the canvas draws.\n const hex = computed(() => colorToHexRaw(convertColor(color.value, colorProfile.value, 'srgb')))\n const sliderPreview = computed(() => createSliderPreviewModel(value.value))\n const sliderGradient = computed(() => createSliderGradientModel(value.value))\n const okhclSliderPreview = computed(() => createOkHCLSliderPreviewModel(value.value.okhcl))\n const okhclSliderGradient = computed(() => createOkHCLSliderGradientModel(value.value.okhcl))\n\n function emitColor(nextColor: Color): Color {\n if (!colorsEqual(color.value, nextColor)) options.onUpdate?.(nextColor)\n return nextColor\n }\n\n function updateHex(input: string) {\n const parsed = parseColor(input.startsWith('#') ? input : `#${input}`)\n // The field shows a hex code's sRGB color, so a typed code is converted back into the\n // document's own components; the field then reads the code that was typed.\n const stored =\n colorProfile.value === 'srgb' ? parsed : convertColor(parsed, 'srgb', colorProfile.value)\n return emitColor({ ...stored, a: color.value.a })\n }\n\n function setFormat(nextFormat: ColorFieldFormat) {\n if (format.value === nextFormat) return\n localFormat.value = nextFormat\n options.onFormatChange?.(nextFormat)\n }\n\n function updateFromReka(nextColor: RekaColorValue) {\n return emitColor(rekaToSceneColor(nextColor))\n }\n\n function updateHue(hue: number) {\n return emitColor(withHue(value.value, hue))\n }\n\n function updateAlpha(alpha: number) {\n return emitColor(withAlpha(color.value, alpha))\n }\n\n function updateRGBChannel(channel: RGBChannel, channelValue: number) {\n return emitColor(withRGBChannel(color.value, channel, channelValue))\n }\n\n function updateHSLChannel(channel: HSLChannel, channelValue: number) {\n return emitColor(withHSLChannel(value.value, channel, channelValue))\n }\n\n function updateHSBChannel(channel: HSBChannel, channelValue: number) {\n return emitColor(withHSBChannel(value.value, channel, channelValue))\n }\n\n function updateOkHCLChannel(channel: OkHCLChannel, channelValue: number) {\n const patch = normalizeOkHCLPatch(channel, channelValue)\n if (!okhclPatchChangesColor(value.value.okhcl, patch)) return value.value.okhcl\n\n if (options.onUpdateOkHCL) {\n options.onUpdateOkHCL(patch)\n return applyOkHCLPatch(value.value.okhcl, patch)\n }\n\n const next = applyOkHCLPatch(value.value.okhcl, patch)\n emitColor(okhclToRGBA(next))\n return next\n }\n\n return {\n color,\n format,\n hex,\n rekaColor: computed(() => value.value.rekaColor),\n rgb: computed(() => value.value.rgb),\n hsl: computed(() => value.value.hsl),\n hsb: computed(() => value.value.hsb),\n okhcl: computed(() => value.value.okhcl),\n sliderPreview,\n sliderGradient,\n okhclSliderPreview,\n okhclSliderGradient,\n setFormat,\n updateColor: emitColor,\n updateHex,\n updateFromReka,\n updateHue,\n updateAlpha,\n updateRGBChannel,\n updateHSLChannel,\n updateHSBChannel,\n updateOkHCLChannel\n }\n}\n"],"mappings":";;;;;AAiCA,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAO;CAAO;AAAO;;;;;AAM1E,SAAgB,cAAc,SAA+B;CAC3D,MAAM,cAAc,IAAsB,QAAQ,iBAAiB,KAAK;CACxE,MAAM,QAAQ,eAAe,QAAQ,QAAQ,KAAK,CAAC;CACnD,MAAM,cAAc,eAAe,QAAQ,QAAQ,KAAK,CAAC;CACzD,MAAM,QAAQ,eAAe,sBAAsB,MAAM,OAAO,YAAY,KAAK,CAAC;CAClF,MAAM,SAAS,eAAe,QAAQ,QAAQ,MAAM,KAAK,YAAY,KAAK;CAC1E,MAAM,eAAe,eAAe,QAAQ,QAAQ,gBAAgB,MAAM,CAAC;CAG3E,MAAM,MAAM,eAAe,cAAc,aAAa,MAAM,OAAO,aAAa,OAAO,MAAM,CAAC,CAAC;CAC/F,MAAM,gBAAgB,eAAe,yBAAyB,MAAM,KAAK,CA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BAAuB,MAAM,MAAM,OAAO,KAAK,GAAG,OAAO,MAAM,MAAM;EAE1E,IAAI,QAAQ,eAAe;GACzB,QAAQ,cAAc,KAAK;GAC3B,OAAO,gBAAgB,MAAM,MAAM,OAAO,KAAK;EACjD;EAEA,MAAM,OAAO,gBAAgB,MAAM,MAAM,OAAO,KAAK;EACrD,UAAU,YAAY,IAAI,CAAC;EAC3B,OAAO;CACT;CAEA,OAAO;EACL;EACA;EACA;EACA,WAAW,eAAe,MAAM,MAAM,SAAS;EAC/C,KAAK,eAAe,MAAM,MAAM,GAAG;EACnC,KAAK,eAAe,MAAM,MAAM,GAAG;EACnC,KAAK,eAAe,MAAM,MAAM,GAAG;EACnC,OAAO,eAAe,MAAM,MAAM,KAAK;EACvC;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComputedRef } from "vue";
|
|
2
|
+
import { DocumentColor } from "@pairdraw/core";
|
|
3
|
+
import { DocumentColorSpace } from "@pairdraw/scene-graph";
|
|
4
|
+
//#region src/controls/document-colors/use.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The solid colours the active page uses, most used first.
|
|
7
|
+
*
|
|
8
|
+
* Recomputed only when the scene or page changes (the dependency on `sceneVersion`), so an open
|
|
9
|
+
* picker walks the tree once, not on every render. Outside an editor, such as a preference picker,
|
|
10
|
+
* the list is empty.
|
|
11
|
+
*/
|
|
12
|
+
declare function useDocumentColors(): ComputedRef<DocumentColor[]>;
|
|
13
|
+
/**
|
|
14
|
+
* The profile the document stores its colors in, so a preview can draw the color the canvas draws.
|
|
15
|
+
* Follows the injected editor's document and falls back to sRGB outside an editor subtree.
|
|
16
|
+
*/
|
|
17
|
+
declare function useDocumentColorSpace(): ComputedRef<DocumentColorSpace>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useDocumentColorSpace, useDocumentColors };
|
|
20
|
+
//# sourceMappingURL=use.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/controls/document-colors/use.ts"],"mappings":";;;;;;;;;;;iBAegB,qBAAqB,YAAY;;;;;iBAajC,yBAAyB,YAAY"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EDITOR_KEY } from "../../editor/context/index.js";
|
|
2
|
+
import { computed, inject } from "vue";
|
|
3
|
+
import { documentColors } from "@pairdraw/core";
|
|
4
|
+
//#region src/controls/document-colors/use.ts
|
|
5
|
+
/**
|
|
6
|
+
* The solid colours the active page uses, most used first.
|
|
7
|
+
*
|
|
8
|
+
* Recomputed only when the scene or page changes (the dependency on `sceneVersion`), so an open
|
|
9
|
+
* picker walks the tree once, not on every render. Outside an editor, such as a preference picker,
|
|
10
|
+
* the list is empty.
|
|
11
|
+
*/
|
|
12
|
+
function useDocumentColors() {
|
|
13
|
+
const editor = injectEditor();
|
|
14
|
+
return computed(() => {
|
|
15
|
+
if (!editor) return [];
|
|
16
|
+
editor.state.sceneVersion;
|
|
17
|
+
return documentColors(editor.graph, editor.state.currentPageId);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The profile the document stores its colors in, so a preview can draw the color the canvas draws.
|
|
22
|
+
* Follows the injected editor's document and falls back to sRGB outside an editor subtree.
|
|
23
|
+
*/
|
|
24
|
+
function useDocumentColorSpace() {
|
|
25
|
+
const editor = injectEditor();
|
|
26
|
+
return computed(() => editor?.graph.documentColorSpace ?? "srgb");
|
|
27
|
+
}
|
|
28
|
+
/** The injected editor, or null when the holder is not an editor subtree. */
|
|
29
|
+
function injectEditor() {
|
|
30
|
+
return inject(EDITOR_KEY, null) ?? null;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { useDocumentColorSpace, useDocumentColors };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.js","names":[],"sources":["../../../src/controls/document-colors/use.ts"],"sourcesContent":["import { computed, inject } from 'vue'\nimport type { ComputedRef } from 'vue'\n\nimport { documentColors, type DocumentColor, type Editor } from '@pairdraw/core'\nimport type { DocumentColorSpace } from '@pairdraw/scene-graph'\n\nimport { EDITOR_KEY } from '#vue/editor/context'\n\n/**\n * The solid colours the active page uses, most used first.\n *\n * Recomputed only when the scene or page changes (the dependency on `sceneVersion`), so an open\n * picker walks the tree once, not on every render. Outside an editor, such as a preference picker,\n * the list is empty.\n */\nexport function useDocumentColors(): ComputedRef<DocumentColor[]> {\n const editor = injectEditor()\n return computed(() => {\n if (!editor) return []\n void editor.state.sceneVersion\n return documentColors(editor.graph, editor.state.currentPageId)\n })\n}\n\n/**\n * The profile the document stores its colors in, so a preview can draw the color the canvas draws.\n * Follows the injected editor's document and falls back to sRGB outside an editor subtree.\n */\nexport function useDocumentColorSpace(): ComputedRef<DocumentColorSpace> {\n const editor = injectEditor()\n return computed(() => editor?.graph.documentColorSpace ?? 'srgb')\n}\n\n/** The injected editor, or null when the holder is not an editor subtree. */\nfunction injectEditor(): Editor | null {\n const editor = inject(EDITOR_KEY, null)\n return editor ?? null\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,oBAAkD;CAChE,MAAM,SAAS,aAAa;CAC5B,OAAO,eAAe;EACpB,IAAI,CAAC,QAAQ,OAAO,CAAC;EACrB,OAAY,MAAM;EAClB,OAAO,eAAe,OAAO,OAAO,OAAO,MAAM,aAAa;CAChE,CAAC;AACH;;;;;AAMA,SAAgB,wBAAyD;CACvE,MAAM,SAAS,aAAa;CAC5B,OAAO,eAAe,QAAQ,MAAM,sBAAsB,MAAM;AAClE;;AAGA,SAAS,eAA8B;CAErC,OADe,OAAO,YAAY,IACtB,KAAK;AACnB"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
2
|
import { Editor } from "@pairdraw/core";
|
|
3
|
-
import { Effect, SceneNode, ShadowEffect } from "@pairdraw/scene-graph";
|
|
3
|
+
import { Effect, NoiseEffectParams, SceneNode, ShadowEffect, TextureEffectParams } from "@pairdraw/scene-graph";
|
|
4
4
|
import { Color } from "@pairdraw/scene-graph/primitives";
|
|
5
5
|
//#region src/controls/effects/helpers.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* One change to an effect: values to merge, or a function that reads the layer's own effect and
|
|
8
|
+
* returns only what it changes, so every selected layer keeps its other values.
|
|
9
|
+
*/
|
|
10
|
+
type EffectChange = Partial<Effect> | ((current: Effect) => Partial<Effect>);
|
|
11
|
+
/** A noise value change that keeps every other grain value the layer has. */
|
|
12
|
+
declare function noiseChange(changes: Partial<NoiseEffectParams>): EffectChange;
|
|
13
|
+
/** A texture value change that keeps every other grain value the layer has. */
|
|
14
|
+
declare function textureChange(changes: Partial<TextureEffectParams>): EffectChange;
|
|
15
|
+
/** A change of a noise's type, which also keeps the grain square. */
|
|
16
|
+
declare function noiseTypeChange(type: NoiseEffectParams['noiseType']): EffectChange;
|
|
6
17
|
declare function isShadow(type: Effect['type']): type is ShadowEffect['type'];
|
|
7
18
|
declare function isShadowEffect(effect: Effect): effect is ShadowEffect;
|
|
8
19
|
declare function createDefaultEffect(): Effect;
|
|
9
20
|
//#endregion
|
|
10
|
-
export { createDefaultEffect, isShadow, isShadowEffect };
|
|
21
|
+
export { EffectChange, createDefaultEffect, isShadow, isShadowEffect, noiseChange, noiseTypeChange, textureChange };
|
|
11
22
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/controls/effects/helpers.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/controls/effects/helpers.ts"],"mappings":";;;;;;;;;KA6BY,eAAe,QAAQ,YAAY,SAAS,WAAW,QAAQ;;iBAG3D,YAAY,SAAS,QAAQ,qBAAqB;;iBAQlD,cAAc,SAAS,QAAQ,uBAAuB;;iBAQtD,gBAAgB,MAAM,iCAAiC;iBAqCvD,SAAS,MAAM,iBAAiB,QAAQ;iBAIxC,eAAe,QAAQ,SAAS,UAAU;iBAI1C,uBAAuB"}
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import { useI18n } from "../../i18n/useI18n.js";
|
|
2
2
|
import { copyEffects } from "@pairdraw/scene-graph/copy";
|
|
3
|
+
import { BLACK, DEFAULT_NOISE, DEFAULT_NOISE_COLOR, DEFAULT_TEXTURE, UNSET_NOISE, UNSET_TEXTURE } from "@pairdraw/scene-graph/constants";
|
|
3
4
|
//#region src/controls/effects/helpers.ts
|
|
5
|
+
/** A noise value change that keeps every other grain value the layer has. */
|
|
6
|
+
function noiseChange(changes) {
|
|
7
|
+
return (current) => {
|
|
8
|
+
return { noise: {
|
|
9
|
+
...current.type === "NOISE" ? current.noise : UNSET_NOISE,
|
|
10
|
+
...changes
|
|
11
|
+
} };
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** A texture value change that keeps every other grain value the layer has. */
|
|
15
|
+
function textureChange(changes) {
|
|
16
|
+
return (current) => {
|
|
17
|
+
return { texture: {
|
|
18
|
+
...current.type === "TEXTURE" ? current.texture : UNSET_TEXTURE,
|
|
19
|
+
...changes
|
|
20
|
+
} };
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** A change of a noise's type, which also keeps the grain square. */
|
|
24
|
+
function noiseTypeChange(type) {
|
|
25
|
+
return noiseChange({ noiseType: type });
|
|
26
|
+
}
|
|
4
27
|
const { panels } = useI18n();
|
|
5
28
|
const EFFECT_LABELS = {
|
|
6
29
|
DROP_SHADOW: panels.value.dropShadow,
|
|
@@ -8,8 +31,12 @@ const EFFECT_LABELS = {
|
|
|
8
31
|
LAYER_BLUR: panels.value.layerBlur,
|
|
9
32
|
BACKGROUND_BLUR: panels.value.backgroundBlur,
|
|
10
33
|
FOREGROUND_BLUR: panels.value.foregroundBlur,
|
|
34
|
+
NOISE: panels.value.noise,
|
|
35
|
+
TEXTURE: panels.value.texture,
|
|
11
36
|
SHADER: panels.value.shader
|
|
12
37
|
};
|
|
38
|
+
/** Radius of a shadow or blur that does not set one. */
|
|
39
|
+
const DEFAULT_EFFECT_RADIUS = 8;
|
|
13
40
|
/** The code a new layer shader starts from: it tints the layer it sits on. */
|
|
14
41
|
const DEFAULT_SHADER_SOURCE = `uniform sampler2D layer; /* @object */
|
|
15
42
|
uniform vec2 resolution; /* @resolution */
|
|
@@ -50,11 +77,12 @@ function createDefaultEffect() {
|
|
|
50
77
|
}
|
|
51
78
|
/** Effects scrubbed on every selected node, each committed from its own value before the scrub. */
|
|
52
79
|
function createEffectEditActions(editor, effectsBeforeScrub) {
|
|
53
|
-
function apply(nodes, index,
|
|
80
|
+
function apply(nodes, index, change) {
|
|
54
81
|
for (const node of nodes) {
|
|
55
82
|
const effects = [...node.effects];
|
|
56
83
|
const current = effects.at(index);
|
|
57
84
|
if (!current) continue;
|
|
85
|
+
const changes = typeof change === "function" ? change(current) : change;
|
|
58
86
|
effects[index] = {
|
|
59
87
|
...current,
|
|
60
88
|
...changes
|
|
@@ -63,19 +91,19 @@ function createEffectEditActions(editor, effectsBeforeScrub) {
|
|
|
63
91
|
}
|
|
64
92
|
editor.requestRender();
|
|
65
93
|
}
|
|
66
|
-
function scrubEffect(nodes, index,
|
|
94
|
+
function scrubEffect(nodes, index, change) {
|
|
67
95
|
if (nodes.length === 0) return;
|
|
68
96
|
effectsBeforeScrub.value ??= new Map(nodes.map((node) => [node.id, {
|
|
69
97
|
effects: copyEffects(node.effects),
|
|
70
98
|
effectStyleId: node.effectStyleId
|
|
71
99
|
}]));
|
|
72
|
-
apply(nodes, index,
|
|
100
|
+
apply(nodes, index, change);
|
|
73
101
|
}
|
|
74
|
-
function commitEffect(nodes, index,
|
|
102
|
+
function commitEffect(nodes, index, change) {
|
|
75
103
|
if (nodes.length === 0) return;
|
|
76
104
|
const previous = effectsBeforeScrub.value;
|
|
77
105
|
effectsBeforeScrub.value = null;
|
|
78
|
-
apply(nodes, index,
|
|
106
|
+
apply(nodes, index, change);
|
|
79
107
|
if (!previous) return;
|
|
80
108
|
editor.undo.runBatch("Change effect", () => {
|
|
81
109
|
for (const node of nodes) {
|
|
@@ -93,38 +121,65 @@ function createEffectEditActions(editor, effectsBeforeScrub) {
|
|
|
93
121
|
commitEffect
|
|
94
122
|
};
|
|
95
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* `type` as a complete effect, keeping what every kind can carry. A shadow blurs away from the
|
|
126
|
+
* layer and a blur is centred on it, so switching between the two rewrites the geometry; a noise
|
|
127
|
+
* or texture starts where Figma's effects panel starts one.
|
|
128
|
+
*/
|
|
129
|
+
function effectOfType(type, previous) {
|
|
130
|
+
const blendMode = previous.blendMode;
|
|
131
|
+
const visible = previous.visible;
|
|
132
|
+
if (type === "SHADER") return {
|
|
133
|
+
type,
|
|
134
|
+
source: DEFAULT_SHADER_SOURCE,
|
|
135
|
+
uniforms: {},
|
|
136
|
+
visible,
|
|
137
|
+
blendMode
|
|
138
|
+
};
|
|
139
|
+
if (type === "NOISE") return {
|
|
140
|
+
type,
|
|
141
|
+
color: { ...DEFAULT_NOISE_COLOR },
|
|
142
|
+
visible,
|
|
143
|
+
blendMode,
|
|
144
|
+
noise: {
|
|
145
|
+
...DEFAULT_NOISE,
|
|
146
|
+
noiseSize: { ...DEFAULT_NOISE.noiseSize }
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
if (type === "TEXTURE") return {
|
|
150
|
+
type,
|
|
151
|
+
color: { ...BLACK },
|
|
152
|
+
radius: DEFAULT_TEXTURE.noiseSize.x,
|
|
153
|
+
visible,
|
|
154
|
+
blendMode,
|
|
155
|
+
texture: {
|
|
156
|
+
...DEFAULT_TEXTURE,
|
|
157
|
+
noiseSize: { ...DEFAULT_TEXTURE.noiseSize }
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const radius = previous.type === "SHADER" || previous.type === "NOISE" ? DEFAULT_EFFECT_RADIUS : previous.radius;
|
|
161
|
+
return {
|
|
162
|
+
type,
|
|
163
|
+
color: previous.type === "SHADER" ? { ...BLACK } : { ...previous.color },
|
|
164
|
+
radius,
|
|
165
|
+
spread: 0,
|
|
166
|
+
offset: isShadow(type) ? {
|
|
167
|
+
x: 0,
|
|
168
|
+
y: 4
|
|
169
|
+
} : {
|
|
170
|
+
x: 0,
|
|
171
|
+
y: 0
|
|
172
|
+
},
|
|
173
|
+
visible,
|
|
174
|
+
blendMode
|
|
175
|
+
};
|
|
176
|
+
}
|
|
96
177
|
function createEffectControlActions(expandedIndex) {
|
|
97
178
|
function updateType(patch, node, index, type) {
|
|
98
179
|
if (!node) return;
|
|
99
180
|
const previous = node.effects[index];
|
|
100
|
-
if (type ===
|
|
101
|
-
|
|
102
|
-
type,
|
|
103
|
-
source: DEFAULT_SHADER_SOURCE,
|
|
104
|
-
uniforms: {}
|
|
105
|
-
});
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
const shadow = isShadow(type);
|
|
109
|
-
const wasShadow = previous.type !== "SHADER" && isShadow(previous.type);
|
|
110
|
-
let geometry = {};
|
|
111
|
-
if (shadow !== wasShadow) geometry = shadow ? {
|
|
112
|
-
offset: {
|
|
113
|
-
x: 0,
|
|
114
|
-
y: 4
|
|
115
|
-
},
|
|
116
|
-
spread: 0
|
|
117
|
-
} : {
|
|
118
|
-
offset: {
|
|
119
|
-
x: 0,
|
|
120
|
-
y: 0
|
|
121
|
-
},
|
|
122
|
-
spread: 0
|
|
123
|
-
};
|
|
124
|
-
patch(index, {
|
|
125
|
-
...geometry,
|
|
126
|
-
type
|
|
127
|
-
});
|
|
181
|
+
if (type === previous.type) return;
|
|
182
|
+
patch(index, effectOfType(type, previous));
|
|
128
183
|
}
|
|
129
184
|
function updateColor(patch, index, color) {
|
|
130
185
|
patch(index, { color });
|
|
@@ -149,6 +204,6 @@ function createEffectControlActions(expandedIndex) {
|
|
|
149
204
|
};
|
|
150
205
|
}
|
|
151
206
|
//#endregion
|
|
152
|
-
export { EFFECT_OPTIONS, createDefaultEffect, createEffectControlActions, createEffectEditActions, isShadow, isShadowEffect };
|
|
207
|
+
export { EFFECT_OPTIONS, createDefaultEffect, createEffectControlActions, createEffectEditActions, isShadow, isShadowEffect, noiseChange, noiseTypeChange, textureChange };
|
|
153
208
|
|
|
154
209
|
//# sourceMappingURL=helpers.js.map
|