@pairdraw/vue 0.19.1 → 0.20.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 +2 -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/islands/state.js +5 -0
- package/dist/canvas/islands/state.js.map +1 -1
- package/dist/canvas/pointer/drag-move.js +4 -0
- package/dist/canvas/pointer/drag-move.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 +30 -1
- package/dist/canvas/surface/lifecycle.js.map +1 -1
- package/dist/canvas/surface/types.d.ts +9 -0
- package/dist/canvas/surface/types.d.ts.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 +146 -4
- 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/document-colors/index.d.ts +2 -0
- package/dist/controls/document-colors/index.js +2 -0
- package/dist/controls/document-colors/use.d.ts +14 -0
- package/dist/controls/document-colors/use.d.ts.map +1 -0
- package/dist/controls/document-colors/use.js +27 -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/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/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/index.d.ts +5 -2
- package/dist/i18n/index.js +5 -2
- package/dist/i18n/locales/de/ai.json.js +55 -3
- package/dist/i18n/locales/de/commands.json.js +2 -0
- package/dist/i18n/locales/de/credentials.json.js +2 -0
- 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 +95 -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 +54 -2
- package/dist/i18n/locales/es/commands.json.js +2 -0
- package/dist/i18n/locales/es/credentials.json.js +2 -0
- 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 +95 -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 +55 -3
- package/dist/i18n/locales/fr/commands.json.js +2 -0
- package/dist/i18n/locales/fr/credentials.json.js +2 -0
- 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 +95 -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/it/ai.json.js +55 -3
- package/dist/i18n/locales/it/commands.json.js +2 -0
- package/dist/i18n/locales/it/credentials.json.js +2 -0
- 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 +95 -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 +55 -3
- package/dist/i18n/locales/ja/commands.json.js +2 -0
- package/dist/i18n/locales/ja/credentials.json.js +2 -0
- 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 +92 -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 +55 -3
- package/dist/i18n/locales/pl/commands.json.js +2 -0
- package/dist/i18n/locales/pl/credentials.json.js +2 -0
- 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 +96 -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 +55 -3
- package/dist/i18n/locales/ru/commands.json.js +3 -1
- package/dist/i18n/locales/ru/credentials.json.js +2 -0
- 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 +96 -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 +55 -3
- package/dist/i18n/locales/zh-cn/commands.json.js +2 -0
- package/dist/i18n/locales/zh-cn/credentials.json.js +2 -0
- 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 +92 -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 +69 -3
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +55 -3
- 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/credentials.d.ts +2 -0
- package/dist/i18n/messages/credentials.d.ts.map +1 -1
- package/dist/i18n/messages/credentials.js +2 -0
- package/dist/i18n/messages/credentials.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 +120 -0
- package/dist/i18n/messages/panels.d.ts.map +1 -1
- package/dist/i18n/messages/panels.js +96 -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 +367 -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 +1237 -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/ColorPickerRoot.vue.d.ts +5 -2
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +12 -3
- 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/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/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +6 -11
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
- package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts +2 -2
- 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,6 +1,8 @@
|
|
|
1
1
|
import { PresentationColorSpace } from "./color-space.js";
|
|
2
|
+
import { RenderedPlayScene } from "@pairdraw/core/canvas";
|
|
2
3
|
import { EditorState } from "@pairdraw/core";
|
|
3
4
|
import { ViewportTransform } from "@pairdraw/core/geometry";
|
|
5
|
+
import { Vector } from "@pairdraw/scene-graph/primitives";
|
|
4
6
|
//#region src/canvas/surface/types.d.ts
|
|
5
7
|
/**
|
|
6
8
|
* Options for {@link useCanvas}.
|
|
@@ -69,6 +71,13 @@ interface UseCanvasOptions {
|
|
|
69
71
|
* presentation shows only its slide. Null draws every layer of the page.
|
|
70
72
|
*/
|
|
71
73
|
getSceneScope?: () => string | null;
|
|
74
|
+
/**
|
|
75
|
+
* The top-level frames a playing prototype changed, which this canvas draws from their play
|
|
76
|
+
* scenes instead of the document, by frame id. Null or absent draws the document.
|
|
77
|
+
*/
|
|
78
|
+
getPlayScenes?: () => ReadonlyMap<string, RenderedPlayScene> | null;
|
|
79
|
+
/** How far a playing prototype scrolled each frame's content, by frame id. */
|
|
80
|
+
getPlayScroll?: () => ReadonlyMap<string, Vector> | null;
|
|
72
81
|
/**
|
|
73
82
|
* Called after each frame this canvas draws, with the pan and zoom it was drawn at. DOM laid
|
|
74
83
|
* over the canvas, such as preview islands, follows these to stay in step with the drawing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/canvas/surface/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/canvas/surface/types.ts"],"mappings":";;;;;;;;;KAUY;UAEK;EACf;EACA,eAAe;IAAY;IAAuB;;;;;EAIlD,QAAQ;;;;EAIR;;;;;EAKA;;;;;EAKA;;;;;;EAMA;;;;;;;EAOA;;;;EAIA;;;;;EAKA,YAAY;;;;;EAKZ,kBAAkB,YAAY;;;;;;;EAO9B,uBAAuB;;;;;EAKvB;;;;;EAKA,sBAAsB,oBAAoB;;EAE1C,sBAAsB,oBAAoB;;;;;;EAM1C,WAAW,MAAM;;;;EAIjB,oBAAoB,eAAe;;;;;;EAMnC;;;;;EAKA,qBAAqB,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.d.ts","names":[],"sources":["../../../src/canvas/text-edit/textarea.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","names":[],"sources":["../../../src/canvas/text-edit/textarea.ts"],"mappings":";;;;;;;;iBAYgB,kBAAkB,SAAS"}
|
|
@@ -3,6 +3,7 @@ import { HAND_GRAB_CURSOR } from "../../editor/tool-cursor/index.js";
|
|
|
3
3
|
import { startPenInput, updatePenHover } from "../pen/input.js";
|
|
4
4
|
import { attachModifiers, startConnectorDraw } from "../../shared/input/connector/draw.js";
|
|
5
5
|
import { startShapeDraw, startTextDraw } from "../../shared/input/draw.js";
|
|
6
|
+
import { handleEyedropperDown } from "../eyedropper/index.js";
|
|
6
7
|
import { onSelectionHandle, scaleHoverCursor, tryStartScaleDrag } from "../scale/input.js";
|
|
7
8
|
import { startZoomDrag, zoomToolCursor } from "../zoom/input.js";
|
|
8
9
|
import { startPanDrag } from "../../shared/input/pan/drag.js";
|
|
@@ -17,7 +18,7 @@ const pan = { press: ({ event }, { editor, setDrag, cursorOverride }) => {
|
|
|
17
18
|
const shape = { press: ({ cx, cy }, { editor, setDrag }) => startShapeDraw(cx, cy, editor, setDrag) };
|
|
18
19
|
/** Selects, moves, resizes, and turns layers: the Move tool. */
|
|
19
20
|
const select = {
|
|
20
|
-
press: ({ event, cx, cy, sx, sy }, context) => handleSelectDown(event, cx, cy, sx, sy, context.editor, context.hitFns, context.tryStartRotation, context.handleTextEditClick, context.setDrag),
|
|
21
|
+
press: ({ event, cx, cy, sx, sy }, context) => handleSelectDown(event, cx, cy, sx, sy, context.editor, context.hitFns, context.tryStartRotation, context.handleTextEditClick, context.setDrag, context.bigNudge()),
|
|
21
22
|
hover: (pointer, { hoverLayers }) => hoverLayers(pointer)
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
@@ -53,6 +54,9 @@ const CANVAS_TOOLS = {
|
|
|
53
54
|
},
|
|
54
55
|
HAND: pan,
|
|
55
56
|
COMMENT: { press: () => void 0 },
|
|
57
|
+
EYEDROPPER: { press: ({ event, cx, cy }, { editor }) => {
|
|
58
|
+
if (event.button === 0) handleEyedropperDown(editor, cx, cy, event.altKey);
|
|
59
|
+
} },
|
|
56
60
|
PEN: {
|
|
57
61
|
press: ({ event, cx, cy }, { editor, setDrag, cursorOverride }) => startPenInput(event, cx, cy, editor, setDrag, cursorOverride),
|
|
58
62
|
hover: ({ cx, cy }, { editor }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../../../src/canvas/tools/registry.ts"],"sourcesContent":["import type { Ref } from 'vue'\n\nimport type { Editor, Tool } from '@pairdraw/core'\n\nimport { startPenInput, updatePenHover } from '#vue/canvas/pen/input'\nimport { startPencilInput } from '#vue/canvas/pencil/input'\nimport { onSelectionHandle, scaleHoverCursor, tryStartScaleDrag } from '#vue/canvas/scale/input'\nimport { startZoomDrag, zoomToolCursor } from '#vue/canvas/zoom/input'\nimport { HAND_GRAB_CURSOR } from '#vue/editor/tool-cursor'\nimport { attachModifiers, startConnectorDraw } from '#vue/shared/input/connector/draw'\nimport { startShapeDraw, startTextDraw } from '#vue/shared/input/draw'\nimport { startPanDrag } from '#vue/shared/input/pan/drag'\nimport { handleSelectDown } from '#vue/shared/input/select'\nimport type { HitTestFns } from '#vue/shared/input/select'\nimport { startStickyDraw } from '#vue/shared/input/sticky/draw'\nimport type { DragState } from '#vue/shared/input/types'\n\n/** Where the pointer is, in canvas (`cx`, `cy`) and screen (`sx`, `sy`) coordinates. */\nexport interface CanvasToolPointer {\n event: MouseEvent\n cx: number\n cy: number\n sx: number\n sy: number\n}\n\n/** What a canvas tool works with: the editor and the canvas input's own pieces. */\nexport interface CanvasToolContext {\n editor: Editor\n hitFns: HitTestFns\n cursorOverride: Ref<string | null>\n setDrag: (d: DragState) => void\n tryStartRotation: (cx: number, cy: number) => boolean\n handleTextEditClick: (cx: number, cy: number, shiftKey: boolean) => boolean\n /** Shows what the pointer is over while selecting: the cursor, guides, and auto layout. */\n hoverLayers: (pointer: CanvasToolPointer) => void\n}\n\n/** What a tool does on the canvas: on a press, and while the pointer moves with no drag. */\nexport interface CanvasTool {\n press: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n hover?: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n}\n\nconst pan: CanvasTool = {\n press: ({ event }, { editor, setDrag, cursorOverride }) => {\n startPanDrag(event, setDrag, editor)\n cursorOverride.value = HAND_GRAB_CURSOR\n }\n}\n\n/** Draws the layer of the tool's own type, from the press to the release. */\nconst shape: CanvasTool = {\n press: ({ cx, cy }, { editor, setDrag }) => startShapeDraw(cx, cy, editor, setDrag)\n}\n\n/** Selects, moves, resizes, and turns layers: the Move tool. */\nconst select: CanvasTool = {\n press: ({ event, cx, cy, sx, sy }, context) =>\n handleSelectDown(\n event,\n cx,\n cy,\n sx,\n sy,\n context.editor,\n context.hitFns,\n context.tryStartRotation,\n context.handleTextEditClick,\n context.setDrag\n ),\n hover: (pointer, { hoverLayers }) => hoverLayers(pointer)\n}\n\n/**\n * Every tool's canvas behaviour, by id. A tool added to `Tool` needs an entry here, and the\n * editor's profile decides which tools are on offer.\n */\nexport const CANVAS_TOOLS: Readonly<Record<Tool, CanvasTool>> = {\n SELECT: select,\n // Handles scale the selection with its contents, and never resize it as Move's do; elsewhere a\n // press selects as Move does.\n SCALE: {\n press: (pointer, context) => {\n const drag = tryStartScaleDrag(pointer.cx, pointer.cy, context.editor)\n if (drag) {\n context.setDrag(drag)\n context.cursorOverride.value = drag.cursor\n } else if (!onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n select.press(pointer, context)\n }\n },\n hover: (pointer, context) => {\n context.hoverLayers(pointer)\n const cursor = scaleHoverCursor(pointer.cx, pointer.cy, context.editor)\n if (cursor) context.cursorOverride.value = cursor\n else if (onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n context.cursorOverride.value = null\n }\n }\n },\n ZOOM: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag, cursorOverride }) => {\n if (event.button !== 0) return\n setDrag(startZoomDrag(cx, cy, sx, sy, event.altKey, editor))\n cursorOverride.value = zoomToolCursor(event.altKey)\n },\n hover: ({ event }, { cursorOverride }) => {\n cursorOverride.value = zoomToolCursor(event.altKey)\n }\n },\n HAND: pan,\n // Comments are placed by the app's comments layer above the canvas.\n COMMENT: { press: () => undefined },\n PEN: {\n press: ({ event, cx, cy }, { editor, setDrag, cursorOverride }) =>\n startPenInput(event, cx, cy, editor, setDrag, cursorOverride),\n hover: ({ cx, cy }, { editor }) => {\n updatePenHover(cx, cy, editor)\n }\n },\n PENCIL: { press: ({ cx, cy }, { editor, setDrag }) => startPencilInput(cx, cy, editor, setDrag) },\n TEXT: { press: ({ cx, cy }, { editor, setDrag }) => startTextDraw(cx, cy, editor, setDrag) },\n CONNECTOR: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag }) =>\n startConnectorDraw(cx, cy, sx, sy, editor, setDrag, attachModifiers(event)),\n hover: ({ event, cx, cy }, { editor }) => editor.connectorHover(cx, cy, attachModifiers(event))\n },\n STICKY: { press: ({ cx, cy }, { editor, setDrag }) => startStickyDraw(cx, cy, editor, setDrag) },\n FRAME: shape,\n SECTION: shape,\n RECTANGLE: shape,\n ELLIPSE: shape,\n LINE: shape,\n POLYGON: shape,\n STAR: shape,\n SHAPE_WITH_TEXT: shape\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../../src/canvas/tools/registry.ts"],"sourcesContent":["import type { Ref } from 'vue'\n\nimport type { Editor, Tool } from '@pairdraw/core'\n\nimport { handleEyedropperDown } from '#vue/canvas/eyedropper'\nimport { startPenInput, updatePenHover } from '#vue/canvas/pen/input'\nimport { startPencilInput } from '#vue/canvas/pencil/input'\nimport { onSelectionHandle, scaleHoverCursor, tryStartScaleDrag } from '#vue/canvas/scale/input'\nimport { startZoomDrag, zoomToolCursor } from '#vue/canvas/zoom/input'\nimport { HAND_GRAB_CURSOR } from '#vue/editor/tool-cursor'\nimport { attachModifiers, startConnectorDraw } from '#vue/shared/input/connector/draw'\nimport { startShapeDraw, startTextDraw } from '#vue/shared/input/draw'\nimport { startPanDrag } from '#vue/shared/input/pan/drag'\nimport { handleSelectDown } from '#vue/shared/input/select'\nimport type { HitTestFns } from '#vue/shared/input/select'\nimport { startStickyDraw } from '#vue/shared/input/sticky/draw'\nimport type { DragState } from '#vue/shared/input/types'\n\n/** Where the pointer is, in canvas (`cx`, `cy`) and screen (`sx`, `sy`) coordinates. */\nexport interface CanvasToolPointer {\n event: MouseEvent\n cx: number\n cy: number\n sx: number\n sy: number\n}\n\n/** What a canvas tool works with: the editor and the canvas input's own pieces. */\nexport interface CanvasToolContext {\n editor: Editor\n hitFns: HitTestFns\n cursorOverride: Ref<string | null>\n setDrag: (d: DragState) => void\n tryStartRotation: (cx: number, cy: number) => boolean\n handleTextEditClick: (cx: number, cy: number, shiftKey: boolean) => boolean\n /** Settings → Editor's large nudge, in pixels. */\n bigNudge: () => number\n /** Shows what the pointer is over while selecting: the cursor, guides, and auto layout. */\n hoverLayers: (pointer: CanvasToolPointer) => void\n}\n\n/** What a tool does on the canvas: on a press, and while the pointer moves with no drag. */\nexport interface CanvasTool {\n press: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n hover?: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n}\n\nconst pan: CanvasTool = {\n press: ({ event }, { editor, setDrag, cursorOverride }) => {\n startPanDrag(event, setDrag, editor)\n cursorOverride.value = HAND_GRAB_CURSOR\n }\n}\n\n/** Draws the layer of the tool's own type, from the press to the release. */\nconst shape: CanvasTool = {\n press: ({ cx, cy }, { editor, setDrag }) => startShapeDraw(cx, cy, editor, setDrag)\n}\n\n/** Selects, moves, resizes, and turns layers: the Move tool. */\nconst select: CanvasTool = {\n press: ({ event, cx, cy, sx, sy }, context) =>\n handleSelectDown(\n event,\n cx,\n cy,\n sx,\n sy,\n context.editor,\n context.hitFns,\n context.tryStartRotation,\n context.handleTextEditClick,\n context.setDrag,\n context.bigNudge()\n ),\n hover: (pointer, { hoverLayers }) => hoverLayers(pointer)\n}\n\n/**\n * Every tool's canvas behaviour, by id. A tool added to `Tool` needs an entry here, and the\n * editor's profile decides which tools are on offer.\n */\nexport const CANVAS_TOOLS: Readonly<Record<Tool, CanvasTool>> = {\n SELECT: select,\n // Handles scale the selection with its contents, and never resize it as Move's do; elsewhere a\n // press selects as Move does.\n SCALE: {\n press: (pointer, context) => {\n const drag = tryStartScaleDrag(pointer.cx, pointer.cy, context.editor)\n if (drag) {\n context.setDrag(drag)\n context.cursorOverride.value = drag.cursor\n } else if (!onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n select.press(pointer, context)\n }\n },\n hover: (pointer, context) => {\n context.hoverLayers(pointer)\n const cursor = scaleHoverCursor(pointer.cx, pointer.cy, context.editor)\n if (cursor) context.cursorOverride.value = cursor\n else if (onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n context.cursorOverride.value = null\n }\n }\n },\n ZOOM: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag, cursorOverride }) => {\n if (event.button !== 0) return\n setDrag(startZoomDrag(cx, cy, sx, sy, event.altKey, editor))\n cursorOverride.value = zoomToolCursor(event.altKey)\n },\n hover: ({ event }, { cursorOverride }) => {\n cursorOverride.value = zoomToolCursor(event.altKey)\n }\n },\n HAND: pan,\n // Comments are placed by the app's comments layer above the canvas.\n COMMENT: { press: () => undefined },\n EYEDROPPER: {\n press: ({ event, cx, cy }, { editor }) => {\n if (event.button === 0) handleEyedropperDown(editor, cx, cy, event.altKey)\n }\n },\n PEN: {\n press: ({ event, cx, cy }, { editor, setDrag, cursorOverride }) =>\n startPenInput(event, cx, cy, editor, setDrag, cursorOverride),\n hover: ({ cx, cy }, { editor }) => {\n updatePenHover(cx, cy, editor)\n }\n },\n PENCIL: { press: ({ cx, cy }, { editor, setDrag }) => startPencilInput(cx, cy, editor, setDrag) },\n TEXT: { press: ({ cx, cy }, { editor, setDrag }) => startTextDraw(cx, cy, editor, setDrag) },\n CONNECTOR: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag }) =>\n startConnectorDraw(cx, cy, sx, sy, editor, setDrag, attachModifiers(event)),\n hover: ({ event, cx, cy }, { editor }) => editor.connectorHover(cx, cy, attachModifiers(event))\n },\n STICKY: { press: ({ cx, cy }, { editor, setDrag }) => startStickyDraw(cx, cy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,QAAQ,OAAO,EAAE;CAC/F,OAAO;CACP,SAAS;CACT,WAAW;CACX,SAAS;CACT,MAAM;CACN,SAAS;CACT,MAAM;CACN,iBAAiB;AACnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CanvasLabelEdit } from "./labels/edit.js";
|
|
2
|
-
import { AutoLayoutValueField } from "../shared/input/auto-layout
|
|
2
|
+
import { AutoLayoutValueField } from "../shared/input/auto-layout/hover.js";
|
|
3
3
|
import { DragState } from "../shared/input/types.js";
|
|
4
4
|
import { WheelZoomOptions } from "../shared/input/wheel.js";
|
|
5
5
|
import { Ref } from "vue";
|
|
@@ -10,8 +10,15 @@ declare function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, editor
|
|
|
10
10
|
/** How far wheel and pinch zoom move per event; 1 is the default rate. */
|
|
11
11
|
zoomSpeed?: () => number,
|
|
12
12
|
/** Whether a plain wheel zooms and whether a wheel zoom is inverted. */
|
|
13
|
-
zoomOptions?: () => WheelZoomOptions
|
|
13
|
+
zoomOptions?: () => WheelZoomOptions,
|
|
14
|
+
/** Settings → Editor's large nudge, in pixels, for handle drags with Shift. */
|
|
15
|
+
bigNudge?: () => number): {
|
|
14
16
|
drag: Ref<{
|
|
17
|
+
type: "auto-layout";
|
|
18
|
+
update: (screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) => void;
|
|
19
|
+
commit: () => void;
|
|
20
|
+
cancel: () => void;
|
|
21
|
+
} | {
|
|
15
22
|
type: "shape-handle";
|
|
16
23
|
update: (screenX: number, screenY: number, shiftKey: boolean) => void;
|
|
17
24
|
commit: () => void;
|
|
@@ -1270,6 +1277,23 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
1270
1277
|
derivedSymbolDataLayoutVersion: number | null;
|
|
1271
1278
|
uniformScaleFactor: number | null;
|
|
1272
1279
|
};
|
|
1280
|
+
drawio?: {
|
|
1281
|
+
styleNames: string[];
|
|
1282
|
+
styleValues: Partial<Record<string, string>>;
|
|
1283
|
+
labelX: number;
|
|
1284
|
+
points: {
|
|
1285
|
+
x: number;
|
|
1286
|
+
y: number;
|
|
1287
|
+
}[];
|
|
1288
|
+
sourcePoint: {
|
|
1289
|
+
x: number;
|
|
1290
|
+
y: number;
|
|
1291
|
+
} | null;
|
|
1292
|
+
targetPoint: {
|
|
1293
|
+
x: number;
|
|
1294
|
+
y: number;
|
|
1295
|
+
} | null;
|
|
1296
|
+
} | null | undefined;
|
|
1273
1297
|
};
|
|
1274
1298
|
derivedLayout: {
|
|
1275
1299
|
x?: number | undefined;
|
|
@@ -1466,6 +1490,51 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
1466
1490
|
uniformBindings?: Record<string, string> | undefined;
|
|
1467
1491
|
visible: boolean;
|
|
1468
1492
|
blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
|
|
1493
|
+
} | {
|
|
1494
|
+
type: "NOISE";
|
|
1495
|
+
color: {
|
|
1496
|
+
r: number;
|
|
1497
|
+
g: number;
|
|
1498
|
+
b: number;
|
|
1499
|
+
a: number;
|
|
1500
|
+
};
|
|
1501
|
+
visible: boolean;
|
|
1502
|
+
blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
|
|
1503
|
+
noise: {
|
|
1504
|
+
noiseType: import("@pairdraw/scene-graph").NoiseType;
|
|
1505
|
+
noiseSize: {
|
|
1506
|
+
x: number;
|
|
1507
|
+
y: number;
|
|
1508
|
+
};
|
|
1509
|
+
density: number;
|
|
1510
|
+
secondaryColor?: {
|
|
1511
|
+
r: number;
|
|
1512
|
+
g: number;
|
|
1513
|
+
b: number;
|
|
1514
|
+
a: number;
|
|
1515
|
+
} | undefined;
|
|
1516
|
+
opacity?: number | undefined;
|
|
1517
|
+
seed?: number | undefined;
|
|
1518
|
+
};
|
|
1519
|
+
} | {
|
|
1520
|
+
type: "TEXTURE";
|
|
1521
|
+
color: {
|
|
1522
|
+
r: number;
|
|
1523
|
+
g: number;
|
|
1524
|
+
b: number;
|
|
1525
|
+
a: number;
|
|
1526
|
+
};
|
|
1527
|
+
radius: number;
|
|
1528
|
+
visible: boolean;
|
|
1529
|
+
blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
|
|
1530
|
+
texture: {
|
|
1531
|
+
noiseSize: {
|
|
1532
|
+
x: number;
|
|
1533
|
+
y: number;
|
|
1534
|
+
};
|
|
1535
|
+
clipToShape: boolean;
|
|
1536
|
+
seed?: number | undefined;
|
|
1537
|
+
};
|
|
1469
1538
|
})[];
|
|
1470
1539
|
layoutGrids: {
|
|
1471
1540
|
visible?: boolean | undefined;
|
|
@@ -1511,6 +1580,8 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
1511
1580
|
visible: boolean;
|
|
1512
1581
|
locked: boolean;
|
|
1513
1582
|
clipsContent: boolean;
|
|
1583
|
+
overflowDirection: import("@pairdraw/scene-graph").OverflowDirection;
|
|
1584
|
+
scrollBehavior: import("@pairdraw/scene-graph").ScrollBehavior;
|
|
1514
1585
|
blendMode: import("@pairdraw/scene-graph").BlendMode;
|
|
1515
1586
|
text: string;
|
|
1516
1587
|
fontSize: number;
|
|
@@ -1905,7 +1976,7 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
1905
1976
|
}[];
|
|
1906
1977
|
} | null;
|
|
1907
1978
|
handleMirroring: import("@pairdraw/scene-graph").HandleMirroring;
|
|
1908
|
-
booleanOperation: "
|
|
1979
|
+
booleanOperation: import("@pairdraw/scene-graph").BooleanOperation | undefined;
|
|
1909
1980
|
fillGeometry: {
|
|
1910
1981
|
windingRule: import("@pairdraw/scene-graph").WindingRule;
|
|
1911
1982
|
commandsBlob: {
|
|
@@ -2384,6 +2455,7 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
2384
2455
|
transition: {
|
|
2385
2456
|
type: import("@pairdraw/scene-graph").PrototypeTransitionType;
|
|
2386
2457
|
duration: number;
|
|
2458
|
+
easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
|
|
2387
2459
|
};
|
|
2388
2460
|
overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
|
|
2389
2461
|
} | {
|
|
@@ -2765,6 +2837,11 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
2765
2837
|
originalOwnerId?: string | undefined;
|
|
2766
2838
|
originalPosition?: number | undefined;
|
|
2767
2839
|
} | null, DragState | {
|
|
2840
|
+
type: "auto-layout";
|
|
2841
|
+
update: (screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) => void;
|
|
2842
|
+
commit: () => void;
|
|
2843
|
+
cancel: () => void;
|
|
2844
|
+
} | {
|
|
2768
2845
|
type: "shape-handle";
|
|
2769
2846
|
update: (screenX: number, screenY: number, shiftKey: boolean) => void;
|
|
2770
2847
|
commit: () => void;
|
|
@@ -4023,6 +4100,23 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
4023
4100
|
derivedSymbolDataLayoutVersion: number | null;
|
|
4024
4101
|
uniformScaleFactor: number | null;
|
|
4025
4102
|
};
|
|
4103
|
+
drawio?: {
|
|
4104
|
+
styleNames: string[];
|
|
4105
|
+
styleValues: Partial<Record<string, string>>;
|
|
4106
|
+
labelX: number;
|
|
4107
|
+
points: {
|
|
4108
|
+
x: number;
|
|
4109
|
+
y: number;
|
|
4110
|
+
}[];
|
|
4111
|
+
sourcePoint: {
|
|
4112
|
+
x: number;
|
|
4113
|
+
y: number;
|
|
4114
|
+
} | null;
|
|
4115
|
+
targetPoint: {
|
|
4116
|
+
x: number;
|
|
4117
|
+
y: number;
|
|
4118
|
+
} | null;
|
|
4119
|
+
} | null | undefined;
|
|
4026
4120
|
};
|
|
4027
4121
|
derivedLayout: {
|
|
4028
4122
|
x?: number | undefined;
|
|
@@ -4219,6 +4313,51 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
4219
4313
|
uniformBindings?: Record<string, string> | undefined;
|
|
4220
4314
|
visible: boolean;
|
|
4221
4315
|
blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
|
|
4316
|
+
} | {
|
|
4317
|
+
type: "NOISE";
|
|
4318
|
+
color: {
|
|
4319
|
+
r: number;
|
|
4320
|
+
g: number;
|
|
4321
|
+
b: number;
|
|
4322
|
+
a: number;
|
|
4323
|
+
};
|
|
4324
|
+
visible: boolean;
|
|
4325
|
+
blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
|
|
4326
|
+
noise: {
|
|
4327
|
+
noiseType: import("@pairdraw/scene-graph").NoiseType;
|
|
4328
|
+
noiseSize: {
|
|
4329
|
+
x: number;
|
|
4330
|
+
y: number;
|
|
4331
|
+
};
|
|
4332
|
+
density: number;
|
|
4333
|
+
secondaryColor?: {
|
|
4334
|
+
r: number;
|
|
4335
|
+
g: number;
|
|
4336
|
+
b: number;
|
|
4337
|
+
a: number;
|
|
4338
|
+
} | undefined;
|
|
4339
|
+
opacity?: number | undefined;
|
|
4340
|
+
seed?: number | undefined;
|
|
4341
|
+
};
|
|
4342
|
+
} | {
|
|
4343
|
+
type: "TEXTURE";
|
|
4344
|
+
color: {
|
|
4345
|
+
r: number;
|
|
4346
|
+
g: number;
|
|
4347
|
+
b: number;
|
|
4348
|
+
a: number;
|
|
4349
|
+
};
|
|
4350
|
+
radius: number;
|
|
4351
|
+
visible: boolean;
|
|
4352
|
+
blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
|
|
4353
|
+
texture: {
|
|
4354
|
+
noiseSize: {
|
|
4355
|
+
x: number;
|
|
4356
|
+
y: number;
|
|
4357
|
+
};
|
|
4358
|
+
clipToShape: boolean;
|
|
4359
|
+
seed?: number | undefined;
|
|
4360
|
+
};
|
|
4222
4361
|
})[];
|
|
4223
4362
|
layoutGrids: {
|
|
4224
4363
|
visible?: boolean | undefined;
|
|
@@ -4264,6 +4403,8 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
4264
4403
|
visible: boolean;
|
|
4265
4404
|
locked: boolean;
|
|
4266
4405
|
clipsContent: boolean;
|
|
4406
|
+
overflowDirection: import("@pairdraw/scene-graph").OverflowDirection;
|
|
4407
|
+
scrollBehavior: import("@pairdraw/scene-graph").ScrollBehavior;
|
|
4267
4408
|
blendMode: import("@pairdraw/scene-graph").BlendMode;
|
|
4268
4409
|
text: string;
|
|
4269
4410
|
fontSize: number;
|
|
@@ -4658,7 +4799,7 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
4658
4799
|
}[];
|
|
4659
4800
|
} | null;
|
|
4660
4801
|
handleMirroring: import("@pairdraw/scene-graph").HandleMirroring;
|
|
4661
|
-
booleanOperation: "
|
|
4802
|
+
booleanOperation: import("@pairdraw/scene-graph").BooleanOperation | undefined;
|
|
4662
4803
|
fillGeometry: {
|
|
4663
4804
|
windingRule: import("@pairdraw/scene-graph").WindingRule;
|
|
4664
4805
|
commandsBlob: {
|
|
@@ -5137,6 +5278,7 @@ zoomOptions?: () => WheelZoomOptions): {
|
|
|
5137
5278
|
transition: {
|
|
5138
5279
|
type: import("@pairdraw/scene-graph").PrototypeTransitionType;
|
|
5139
5280
|
duration: number;
|
|
5281
|
+
easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
|
|
5140
5282
|
};
|
|
5141
5283
|
overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
|
|
5142
5284
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanvasInput.d.ts","names":[],"sources":["../../src/canvas/useCanvasInput.ts"],"mappings":";;;;;;;;iBAwDgB,eACd,WAAW,IAAI,2BACf,QAAQ,QACR,sBAAsB,YAAY,eAAe,kBACjD,wBAAwB,YAAY,eAAe,kBACnD,oBAAoB,YAAY,eAAe,kBAC/C,gBAAgB,YAAY,qBAC5B,yBACA,2BAEA;;AAAA,0BAEA;;AAAA,oBAAmB"}
|
|
1
|
+
{"version":3,"file":"useCanvasInput.d.ts","names":[],"sources":["../../src/canvas/useCanvasInput.ts"],"mappings":";;;;;;;;iBAwDgB,eACd,WAAW,IAAI,2BACf,QAAQ,QACR,sBAAsB,YAAY,eAAe,kBACjD,wBAAwB,YAAY,eAAe,kBACnD,oBAAoB,YAAY,eAAe,kBAC/C,gBAAgB,YAAY,qBAC5B,yBACA,2BAEA;;AAAA,0BAEA;;AAAA,oBAAmB,kBAEnB;;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveAutoLayoutHover } from "../shared/input/auto-layout
|
|
1
|
+
import { resolveAutoLayoutHover } from "../shared/input/auto-layout/hover.js";
|
|
2
2
|
import { createAutoLayoutValueEdit } from "./auto-layout/value-edit.js";
|
|
3
3
|
import { createGuideInput } from "./guides/input.js";
|
|
4
4
|
import { createCanvasLabelEdit } from "./labels/edit.js";
|
|
@@ -44,7 +44,7 @@ const ESCAPABLE_DRAGS = /* @__PURE__ */ new Set([
|
|
|
44
44
|
"zoom",
|
|
45
45
|
"scale"
|
|
46
46
|
]);
|
|
47
|
-
function useCanvasInput(canvasRef, editor, hitTestSectionTitle, hitTestComponentLabel, hitTestFrameTitle, onCursorMove, onActivate, isEnabled = () => true, zoomSpeed = () => 1, zoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS) {
|
|
47
|
+
function useCanvasInput(canvasRef, editor, hitTestSectionTitle, hitTestComponentLabel, hitTestFrameTitle, onCursorMove, onActivate, isEnabled = () => true, zoomSpeed = () => 1, zoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS, bigNudge = () => 10) {
|
|
48
48
|
const drag = ref(null);
|
|
49
49
|
const profile = () => resolveEditorProfile(editor.state);
|
|
50
50
|
watch(() => drag.value?.type, (type) => editor.setTransforming(type === "move" || type === "resize" || type === "rotate"));
|
|
@@ -155,6 +155,7 @@ function useCanvasInput(canvasRef, editor, hitTestSectionTitle, hitTestComponent
|
|
|
155
155
|
setDrag,
|
|
156
156
|
tryStartRotation,
|
|
157
157
|
handleTextEditClick,
|
|
158
|
+
bigNudge,
|
|
158
159
|
hoverLayers
|
|
159
160
|
};
|
|
160
161
|
function onMouseDown(e) {
|
|
@@ -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,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,cA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,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,CAAC,OAAO,MAAM,iBACd,CAAC,OAAO,MAAM;CAElB;;CAGA,SAAS,UAAU,GAAgB;EACjC,OAAO,IAAI,EAAE,WAAW,EAAE,UAAU,YAAY;CAClD;CAEA,SAAS,qBAAqB;EAC5B,MAAM,OAAO,WAAW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;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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComputedRef } from "vue";
|
|
2
|
+
import { DocumentColor } from "@pairdraw/core";
|
|
3
|
+
//#region src/controls/document-colors/use.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The solid colours the active page uses, most used first.
|
|
6
|
+
*
|
|
7
|
+
* Recomputed only when the scene or page changes (the dependency on `sceneVersion`), so an open
|
|
8
|
+
* picker walks the tree once, not on every render. Outside an editor, such as a preference picker,
|
|
9
|
+
* the list is empty.
|
|
10
|
+
*/
|
|
11
|
+
declare function useDocumentColors(): ComputedRef<DocumentColor[]>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useDocumentColors };
|
|
14
|
+
//# sourceMappingURL=use.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/controls/document-colors/use.ts"],"mappings":";;;;;;;;;;iBAcgB,qBAAqB,YAAY"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/** The injected editor, or null when the holder is not an editor subtree. */
|
|
21
|
+
function injectEditor() {
|
|
22
|
+
return inject(EDITOR_KEY, null) ?? null;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useDocumentColors };
|
|
26
|
+
|
|
27
|
+
//# 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'\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/** 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":";;;;;;;;;;;AAcA,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;;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"}
|