@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,5 +1,5 @@
|
|
|
1
1
|
import { resolveNodeLayoutDirection } from "@pairdraw/scene-graph/text/direction";
|
|
2
|
-
//#region src/shared/input/auto-layout.ts
|
|
2
|
+
//#region src/shared/input/auto-layout/index.ts
|
|
3
3
|
function resolveLayoutDirection(parent, editor) {
|
|
4
4
|
const ancestor = parent.parentId ? editor.graph.getNode(parent.parentId) : null;
|
|
5
5
|
const inheritedDirection = ancestor ? resolveLayoutDirection(ancestor, editor) : "LTR";
|
|
@@ -152,4 +152,4 @@ function computeAutoLayoutIndicator(d, cx, cy, editor) {
|
|
|
152
152
|
//#endregion
|
|
153
153
|
export { autoLayoutInsertIndex, computeAutoLayoutIndicator, computeAutoLayoutIndicatorForFrame, computeIndicatorPosition };
|
|
154
154
|
|
|
155
|
-
//# sourceMappingURL=
|
|
155
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/shared/input/auto-layout/index.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport type { DragMove } from '#vue/shared/input/types'\n\nfunction resolveLayoutDirection(parent: SceneNode, editor: Editor): 'LTR' | 'RTL' {\n const ancestor = parent.parentId ? editor.graph.getNode(parent.parentId) : null\n const inheritedDirection = ancestor ? resolveLayoutDirection(ancestor, editor) : 'LTR'\n return resolveNodeLayoutDirection(parent, inheritedDirection)\n}\n\nfunction isRTLRow(parent: SceneNode, isRow: boolean, editor: Editor) {\n return isRow && resolveLayoutDirection(parent, editor) === 'RTL'\n}\n\nexport function computeIndicatorPosition(\n children: SceneNode[],\n insertIndex: number,\n parent: SceneNode,\n parentAbs: Vector,\n isRow: boolean,\n editor: Editor\n): number {\n const rtlRow = isRTLRow(parent, isRow, editor)\n\n if (children.length === 0) {\n if (isRow) {\n return rtlRow\n ? parentAbs.x + parent.width - parent.paddingRight\n : parentAbs.x + parent.paddingLeft\n }\n return parentAbs.y + parent.paddingTop\n }\n if (insertIndex === 0) {\n const firstAbs = editor.graph.getAbsolutePosition(children[0].id)\n if (isRow) {\n return rtlRow\n ? firstAbs.x + children[0].width + parent.itemSpacing / 2\n : firstAbs.x - parent.itemSpacing / 2\n }\n return firstAbs.y - parent.itemSpacing / 2\n }\n if (insertIndex >= children.length) {\n const last = children[children.length - 1]\n const lastAbs = editor.graph.getAbsolutePosition(last.id)\n if (isRow) {\n return rtlRow\n ? lastAbs.x - parent.itemSpacing / 2\n : lastAbs.x + last.width + parent.itemSpacing / 2\n }\n return lastAbs.y + last.height + parent.itemSpacing / 2\n }\n const prev = children[insertIndex - 1]\n const next = children[insertIndex]\n const prevAbs = editor.graph.getAbsolutePosition(prev.id)\n const nextAbs = editor.graph.getAbsolutePosition(next.id)\n if (isRow) {\n return rtlRow\n ? (prevAbs.x + nextAbs.x + next.width) / 2\n : (prevAbs.x + prev.width + nextAbs.x) / 2\n }\n return (prevAbs.y + prev.height + nextAbs.y) / 2\n}\n\nfunction filteredToRealIndex(\n parentId: string,\n insertIndex: number,\n editor: Editor,\n movingIds: ReadonlySet<string> = editor.state.selectedIds\n): number {\n const allChildren = editor.graph.getChildren(parentId)\n let realIndex = 0\n let filteredCount = 0\n for (const child of allChildren) {\n if (movingIds.has(child.id)) continue\n if (child.layoutPositioning === 'ABSOLUTE') {\n realIndex++\n continue\n }\n if (filteredCount === insertIndex) break\n filteredCount++\n realIndex++\n }\n return realIndex\n}\n\ninterface FlowLine {\n /** Index of the line's first child among the frame's flow children. */\n offset: number\n children: SceneNode[]\n crossStart: number\n crossEnd: number\n}\n\n/** Splits wrapped children into lines along the cross axis; one line when nothing wraps. */\nfunction flowLines(parent: SceneNode, children: SceneNode[], isRow: boolean, editor: Editor) {\n const lines: FlowLine[] = []\n for (const [index, child] of children.entries()) {\n const abs = editor.graph.getAbsolutePosition(child.id)\n const start = isRow ? abs.y : abs.x\n const end = start + (isRow ? child.height : child.width)\n const line = parent.layoutWrap === 'WRAP' ? lines.at(-1) : lines[0]\n if (line && (parent.layoutWrap !== 'WRAP' || start < line.crossEnd)) {\n line.children.push(child)\n line.crossStart = Math.min(line.crossStart, start)\n line.crossEnd = Math.max(line.crossEnd, end)\n } else {\n lines.push({ offset: index, children: [child], crossStart: start, crossEnd: end })\n }\n }\n return lines\n}\n\n/** The wrapped line under the cursor, or the nearest one. */\nfunction lineAt(lines: FlowLine[], cross: number): FlowLine | undefined {\n return lines.find((line, i) => {\n const next = lines.at(i + 1)\n return !next || cross < (line.crossEnd + next.crossStart) / 2\n })\n}\n\nfunction autoLayoutInsertion(\n parent: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n movingIds: ReadonlySet<string>\n) {\n const children = editor.graph\n .getChildren(parent.id)\n .filter((c) => c.layoutPositioning !== 'ABSOLUTE' && !movingIds.has(c.id))\n\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const rtlRow = isRTLRow(parent, isRow, editor)\n const line = lineAt(flowLines(parent, children, isRow, editor), isRow ? cy : cx)\n const lineChildren = line?.children ?? []\n\n let lineIndex = lineChildren.length\n for (let i = 0; i < lineChildren.length; i++) {\n const childAbs = editor.graph.getAbsolutePosition(lineChildren[i].id)\n const mid = isRow\n ? childAbs.x + lineChildren[i].width / 2\n : childAbs.y + lineChildren[i].height / 2\n const cursor = isRow ? cx : cy\n const shouldInsertBefore = rtlRow ? cursor > mid : cursor < mid\n if (shouldInsertBefore) {\n lineIndex = i\n break\n }\n }\n\n const insertIndex = (line?.offset ?? 0) + lineIndex\n const realIndex = filteredToRealIndex(parent.id, insertIndex, editor, movingIds)\n return { line, lineIndex, realIndex, isRow }\n}\n\n/** Where layers dropped at the cursor go among an auto layout frame's children. */\nexport function autoLayoutInsertIndex(\n parent: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n movingIds: ReadonlySet<string>\n) {\n return autoLayoutInsertion(parent, cx, cy, editor, movingIds).realIndex\n}\n\n/** Where the indicator spans across the flow: the whole frame, or the wrapped line it joins. */\nfunction indicatorCrossExtent(\n parent: SceneNode,\n parentAbs: Vector,\n isRow: boolean,\n line: FlowLine | undefined\n) {\n if (parent.layoutWrap === 'WRAP' && line) {\n return { crossStart: line.crossStart, crossLength: line.crossEnd - line.crossStart }\n }\n if (isRow) {\n return {\n crossStart: parentAbs.y + parent.paddingTop,\n crossLength: parent.height - parent.paddingTop - parent.paddingBottom\n }\n }\n return {\n crossStart: parentAbs.x + parent.paddingLeft,\n crossLength: parent.width - parent.paddingLeft - parent.paddingRight\n }\n}\n\nexport function computeAutoLayoutIndicatorForFrame(\n parent: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n movingIds: ReadonlySet<string> = editor.state.selectedIds\n) {\n const { line, lineIndex, realIndex, isRow } = autoLayoutInsertion(\n parent,\n cx,\n cy,\n editor,\n movingIds\n )\n const parentAbs = editor.graph.getAbsolutePosition(parent.id)\n if (movingIds.size === 1) {\n const movingId = [...movingIds][0]\n const movingNode = editor.graph.getNode(movingId)\n const currentIndex = parent.childIds.indexOf(movingId)\n if (movingNode?.parentId === parent.id && realIndex === currentIndex) {\n editor.setLayoutInsertIndicator(null)\n return\n }\n }\n\n const indicatorPos = computeIndicatorPosition(\n line?.children ?? [],\n lineIndex,\n parent,\n parentAbs,\n isRow,\n editor\n )\n const { crossStart, crossLength } = indicatorCrossExtent(parent, parentAbs, isRow, line)\n\n editor.setLayoutInsertIndicator({\n parentId: parent.id,\n index: realIndex,\n x: isRow ? indicatorPos : crossStart,\n y: isRow ? crossStart : indicatorPos,\n length: crossLength,\n direction: isRow ? 'VERTICAL' : 'HORIZONTAL'\n })\n}\n\nexport function computeAutoLayoutIndicator(d: DragMove, cx: number, cy: number, editor: Editor) {\n if (!d.autoLayoutParentId) return\n const parent = editor.graph.getNode(d.autoLayoutParentId)\n if (!parent || parent.layoutMode === 'NONE') return\n computeAutoLayoutIndicatorForFrame(parent, cx, cy, editor, new Set(d.originals.keys()))\n}\n"],"mappings":";;AAOA,SAAS,uBAAuB,QAAmB,QAA+B;CAChF,MAAM,WAAW,OAAO,WAAW,OAAO,MAAM,QAAQ,OAAO,QAAQ,IAAI;CAC3E,MAAM,qBAAqB,WAAW,uBAAuB,UAAU,MAAM,IAAI;CACjF,OAAO,2BAA2B,QAAQ,kBAAkB;AAC9D;AAEA,SAAS,SAAS,QAAmB,OAAgB,QAAgB;CACnE,OAAO,SAAS,uBAAuB,QAAQ,MAAM,MAAM;AAC7D;AAEA,SAAgB,yBACd,UACA,aACA,QACA,WACA,OACA,QACQ;CACR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GAAG;EACxB,MAAM,WAAW,CAAC,GAAG,SAAS,CAAC,CAAC;EAChC,MAAM,aAAa,OAAO,MAAM,QAAQ,QAAQ;EAChD,MAAM,eAAe,OAAO,SAAS,QAAQ,QAAQ;EACrD,IAAI,YAAY,aAAa,OAAO,MAAM,cAAc,cAAc;GACpE,OAAO,yBAAyB,IAAI;GACpC;EACF;CACF;CAEA,MAAM,eAAe,yBACnB,MAAM,YAAY,CAAC,GACnB,WACA,QACA,WACA,OACA,MACF;CACA,MAAM,EAAE,YAAY,gBAAgB,qBAAqB,QAAQ,WAAW,OAAO,IAAI;CAEvF,OAAO,yBAAyB;EAC9B,UAAU,OAAO;EACjB,OAAO;EACP,GAAG,QAAQ,eAAe;EAC1B,GAAG,QAAQ,aAAa;EACxB,QAAQ;EACR,WAAW,QAAQ,aAAa;CAClC,CAAC;AACH;AAEA,SAAgB,2BAA2B,GAAa,IAAY,IAAY,QAAgB;CAC9F,IAAI,CAAC,EAAE,oBAAoB;CAC3B,MAAM,SAAS,OAAO,MAAM,QAAQ,EAAE,kBAAkB;CACxD,IAAI,CAAC,UAAU,OAAO,eAAe,QAAQ;CAC7C,mCAAmC,QAAQ,IAAI,IAAI,QAAQ,IAAI,IAAI,EAAE,UAAU,KAAK,CAAC,CAAC;AACxF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AutoLayoutValueField, autoLayoutValueAnchor } from "./auto-layout
|
|
1
|
+
import { AutoLayoutValueField, autoLayoutValueAnchor } from "./auto-layout/hover.js";
|
|
2
2
|
export { type AutoLayoutValueField, autoLayoutValueAnchor };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { autoLayoutValueAnchor } from "./auto-layout
|
|
1
|
+
import { autoLayoutValueAnchor } from "./auto-layout/hover.js";
|
|
2
2
|
export { autoLayoutValueAnchor };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPastPointerDragThreshold } from "../drag-threshold.js";
|
|
2
2
|
import { findMoveDropTarget, reparentDroppedNodes } from "../drop-target.js";
|
|
3
|
-
import { autoLayoutInsertIndex, computeAutoLayoutIndicator, computeAutoLayoutIndicatorForFrame, computeIndicatorPosition } from "../auto-layout.js";
|
|
3
|
+
import { autoLayoutInsertIndex, computeAutoLayoutIndicator, computeAutoLayoutIndicatorForFrame, computeIndicatorPosition } from "../auto-layout/index.js";
|
|
4
4
|
import { flowBlockBounds, flowOrder, flowSlot } from "../flow-reorder.js";
|
|
5
5
|
import { applyMoveSnap } from "./snap.js";
|
|
6
6
|
//#region src/shared/input/move/drag.ts
|
|
@@ -5,12 +5,12 @@ import { draggedSizing, layerSizing } from "./resize/sizing.js";
|
|
|
5
5
|
import { applyResizeSnap } from "./resize/snap.js";
|
|
6
6
|
import { toRaw } from "vue";
|
|
7
7
|
import { resizedPathTextGlyphs } from "@pairdraw/core";
|
|
8
|
+
import { computeAllLayouts } from "@pairdraw/core/layout";
|
|
8
9
|
import { findInstanceAncestor, recordInstanceOverride } from "@pairdraw/scene-graph/instances";
|
|
9
10
|
import { isEqual } from "es-toolkit";
|
|
10
11
|
import { recapturedAspectRatio } from "@pairdraw/scene-graph/layout";
|
|
11
12
|
import { cloneVectorNetwork } from "@pairdraw/scene-graph/vector-network";
|
|
12
13
|
import { computeConstrainedResizeChanges, scaledGeometryChanges } from "@pairdraw/scene-graph/resize";
|
|
13
|
-
import { computeAllLayouts } from "@pairdraw/core/layout";
|
|
14
14
|
import { calibratePathTextLayout, reflowPathTextGlyphs } from "@pairdraw/core/text";
|
|
15
15
|
import { copyDerivedGlyphs, copyGeometryPaths, copyStrokes } from "@pairdraw/scene-graph/copy";
|
|
16
16
|
import { cloneInstanceOverrideState } from "@pairdraw/scene-graph/instances/overrides";
|
|
@@ -7,6 +7,7 @@ import { tryStartConnectorLineDrag } from "./connector/line.js";
|
|
|
7
7
|
import { tryStartImageCropDrag } from "./image-crop.js";
|
|
8
8
|
import { tryStartLineEndDrag } from "./line/end.js";
|
|
9
9
|
import { updateHoverCursor } from "./select/hover.js";
|
|
10
|
+
import { tryStartAutoLayoutHandleDrag } from "./auto-layout/drag.js";
|
|
10
11
|
import { tryStartConnectorEndDrag } from "./connector/end.js";
|
|
11
12
|
import { tryStartGradientDrag } from "./gradient.js";
|
|
12
13
|
import { clickSelectsInside, createSelectionMoveDrag, pressedSelectedLayer, selectedLayerHoldingPress, selectionIsLocked } from "./select/move.js";
|
|
@@ -54,13 +55,14 @@ function startDeepMarquee(hit, cx, cy, editor, setDrag) {
|
|
|
54
55
|
* handles. A layer's label takes the press before rotation but after resizing, as in Figma; a
|
|
55
56
|
* read-only document has no handles.
|
|
56
57
|
*/
|
|
57
|
-
function tryStartHandleDrag(cx, cy, sx, sy, altKey, editor, fns, tryStartRotation, setDrag) {
|
|
58
|
+
function tryStartHandleDrag(cx, cy, sx, sy, altKey, editor, fns, tryStartRotation, setDrag, bigNudge) {
|
|
58
59
|
if (!resolveEditorProfile(editor.state).edits) return false;
|
|
59
60
|
if (tryStartGradientDrag(editor, sx, sy, setDrag)) return true;
|
|
60
61
|
if (editedGradient(editor.graph, editor.state.gradientEdit)) return false;
|
|
61
62
|
if (tryStartImageCropDrag(editor, sx, sy, setDrag)) return true;
|
|
62
63
|
if (editedImage(editor.graph, editor.state.imageEdit)) return false;
|
|
63
64
|
if (tryStartShapeHandleDrag(editor, sx, sy, altKey, setDrag)) return true;
|
|
65
|
+
if (tryStartAutoLayoutHandleDrag(editor, cx, cy, sx, sy, setDrag, bigNudge)) return true;
|
|
64
66
|
if (tryStartConnectorEndDrag(editor, sx, sy, setDrag)) return true;
|
|
65
67
|
if (tryStartConnectorLineDrag(editor, cx, cy, sx, sy, setDrag)) return true;
|
|
66
68
|
if (tryStartLineEndDrag(editor, cx, cy, setDrag)) return true;
|
|
@@ -104,14 +106,14 @@ function pressLayers(hit, e, cx, cy, sx, sy, editor, setDrag) {
|
|
|
104
106
|
if (keepsSelection && !editor.state.selectedIds.has(hit.id)) drag.selectOnClick = clickSelectsInside(hit, editor) ? hit.id : void 0;
|
|
105
107
|
setDrag(drag);
|
|
106
108
|
}
|
|
107
|
-
function handleSelectDown(e, cx, cy, sx, sy, editor, fns, tryStartRotation, handleTextEditClick, setDrag) {
|
|
109
|
+
function handleSelectDown(e, cx, cy, sx, sy, editor, fns, tryStartRotation, handleTextEditClick, setDrag, bigNudge = 10) {
|
|
108
110
|
if (getNodeEditState(editor)) {
|
|
109
111
|
handleNodeEditDown(e, cx, cy, editor, setDrag);
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
if (editor.state.editingTextId && handleTextEditClick(cx, cy, e.shiftKey)) return;
|
|
113
115
|
if (editor.state.editingTextId) editor.commitTextEdit();
|
|
114
|
-
if (tryStartHandleDrag(cx, cy, sx, sy, e.altKey, editor, fns, tryStartRotation, setDrag)) return;
|
|
116
|
+
if (tryStartHandleDrag(cx, cy, sx, sy, e.altKey, editor, fns, tryStartRotation, setDrag, bigNudge)) return;
|
|
115
117
|
const deep = e.metaKey || e.ctrlKey;
|
|
116
118
|
const hit = tinySelectionAt(cx, cy, editor) ?? resolveHit(cx, cy, editor, fns, deep);
|
|
117
119
|
if (!hit) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../src/shared/input/select.ts"],"sourcesContent":["import { hitTestLabel, resolveHit, tinySelectionAt } from '#vue/shared/input/select/hit'\nimport { getNodeEditState, handleNodeEditDown } from '#vue/shared/input/vector'\nexport { updateHoverCursor } from '#vue/shared/input/select/hover'\nimport { editedGradient, editedImage, resolveEditorProfile, type Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { tryStartConnectorEndDrag } from '#vue/shared/input/connector/end'\nimport { tryStartConnectorLineDrag } from '#vue/shared/input/connector/line'\nimport { tryStartGradientDrag } from '#vue/shared/input/gradient'\nimport { tryStartImageCropDrag } from '#vue/shared/input/image-crop'\nimport { tryStartLineEndDrag } from '#vue/shared/input/line/end'\nimport { tryStartResize } from '#vue/shared/input/resize'\nimport {\n createSelectionMoveDrag,\n clickSelectsInside,\n pressedSelectedLayer,\n selectedLayerHoldingPress,\n selectionIsLocked\n} from '#vue/shared/input/select/move'\nimport { tryStartShapeHandleDrag } from '#vue/shared/input/shape-handles'\nimport { tryStartStickyScale } from '#vue/shared/input/sticky/scale'\nimport type { DragState } from '#vue/shared/input/types'\n\nexport interface HitTestFns {\n hitTestInScope: (cx: number, cy: number, deep: boolean) => SceneNode | null\n isInsideContainerBounds: (cx: number, cy: number, containerId: string) => boolean\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}\n\n/**\n * Clears the selection and starts a marquee in the open frame or section under the press, looked\n * up inside the container the user entered, if any.\n */\nfunction startMarquee(cx: number, cy: number, editor: Editor, setDrag: (d: DragState) => void) {\n editor.clearSelection()\n const scopeId = editor.state.enteredContainerId ?? editor.state.currentPageId\n const container = editor.graph.hitTestOpenContainer(cx, cy, scopeId)\n setDrag({ type: 'marquee', startX: cx, startY: cy, containerId: container?.id })\n}\n\n/**\n * Whether a ⌘ press on `hit` starts a deep marquee rather than a move, as in Figma: only where a\n * plain press would start a marquee too, on the empty background of a board, section, or component\n * set, which a deep hit stops at when it is painted. Anywhere else, including the background of a\n * nested frame, component, instance, or group, a ⌘ press selects the deepest layer and moves it; a\n * press on the selection, a locked layer, a label, or with Shift keeps the usual press.\n */\nfunction startsDeepMarquee(\n hit: SceneNode,\n e: MouseEvent,\n cx: number,\n cy: number,\n editor: Editor,\n fns: HitTestFns\n) {\n const scopeId = editor.state.enteredContainerId ?? editor.state.currentPageId\n return (\n !e.shiftKey &&\n !hit.locked &&\n !editor.state.selectedIds.has(hit.id) &&\n !selectedLayerHoldingPress(hit, cx, cy, editor) &&\n !hitTestLabel(cx, cy, fns) &&\n editor.graph.hitTestOpenContainer(cx, cy, scopeId)?.id === hit.id\n )\n}\n\n/** Starts a ⌘ marquee scoped to the pressed container; a click without a drag still selects it. */\nfunction startDeepMarquee(\n hit: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n setDrag: (d: DragState) => void\n) {\n editor.clearSelection()\n setDrag({ type: 'marquee', startX: cx, startY: cy, containerId: hit.id, selectOnClick: hit.id })\n}\n\n/**\n * Starts dragging a gradient handle, or else the selection's corner radius, resize, or rotation\n * handles. A layer's label takes the press before rotation but after resizing, as in Figma; a\n * read-only document has no handles.\n */\nfunction tryStartHandleDrag(\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n altKey: boolean,\n editor: Editor,\n fns: HitTestFns,\n tryStartRotation: (cx: number, cy: number) => boolean,\n setDrag: (d: DragState) => void\n): boolean {\n if (!resolveEditorProfile(editor.state).edits) return false\n if (tryStartGradientDrag(editor, sx, sy, setDrag)) return true\n // An open gradient's handles replace the layer's selection handles, which then do not respond.\n if (editedGradient(editor.graph, editor.state.gradientEdit)) return false\n // So do an edited image's crop handles; a press outside the image leaves image edit mode.\n if (tryStartImageCropDrag(editor, sx, sy, setDrag)) return true\n if (editedImage(editor.graph, editor.state.imageEdit)) return false\n if (tryStartShapeHandleDrag(editor, sx, sy, altKey, setDrag)) return true\n if (tryStartConnectorEndDrag(editor, sx, sy, setDrag)) return true\n if (tryStartConnectorLineDrag(editor, cx, cy, sx, sy, setDrag)) return true\n if (tryStartLineEndDrag(editor, cx, cy, setDrag)) return true\n const scaleDrag = tryStartStickyScale(cx, cy, editor)\n if (scaleDrag) {\n setDrag(scaleDrag)\n return true\n }\n const resizeDrag = tryStartResize(cx, cy, editor)\n if (resizeDrag) {\n setDrag(resizeDrag)\n return true\n }\n return !hitTestLabel(cx, cy, fns) && tryStartRotation(cx, cy)\n}\n\n/** Shift adds to the selection; a plain press selects the layer unless it keeps the selection. */\nfunction selectOnPress(hit: SceneNode, shiftKey: boolean, keepsSelection: boolean, editor: Editor) {\n if (shiftKey) editor.select([hit.id], true)\n else if (!editor.state.selectedIds.has(hit.id) && !keepsSelection) editor.select([hit.id])\n}\n\n/** A read-only document moves nothing, so a press selects a layer inside a selected frame at once. */\nfunction selectInsideOnPress(hit: SceneNode, keepsSelection: boolean, editor: Editor) {\n if (keepsSelection && !editor.state.selectedIds.has(hit.id) && clickSelectsInside(hit, editor))\n editor.select([hit.id])\n}\n\n/** What a press on `hit` selects, and the drag it starts, as a layer press does. */\nfunction pressLayers(\n hit: SceneNode,\n e: MouseEvent,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor,\n setDrag: (d: DragState) => void\n): void {\n const keepsSelection = !e.shiftKey && Boolean(selectedLayerHoldingPress(hit, cx, cy, editor))\n // Shift-pressing a layer already selected keeps it selected to drag, and deselects it when the\n // press ends without moving it, as in Figma.\n const shiftPressedSelectedId = e.shiftKey\n ? pressedSelectedLayer(hit, !keepsSelection, cx, cy, editor)\n : undefined\n if (!shiftPressedSelectedId) selectOnPress(hit, e.shiftKey, keepsSelection, editor)\n\n if (!resolveEditorProfile(editor.state).edits) {\n if (shiftPressedSelectedId) editor.select([shiftPressedSelectedId], true)\n selectInsideOnPress(hit, keepsSelection, editor)\n return\n }\n if (selectionIsLocked(editor)) {\n if (shiftPressedSelectedId) editor.select([shiftPressedSelectedId], true)\n return\n }\n\n const drag = createSelectionMoveDrag(cx, cy, sx, sy, editor, e.altKey)\n drag.clickDeselectsId = shiftPressedSelectedId\n // A click without dragging still selects a layer inside a selected frame; groups need a double-click.\n if (keepsSelection && !editor.state.selectedIds.has(hit.id)) {\n drag.selectOnClick = clickSelectsInside(hit, editor) ? hit.id : undefined\n }\n setDrag(drag)\n}\n\nexport function handleSelectDown(\n e: MouseEvent,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor,\n fns: HitTestFns,\n tryStartRotation: (cx: number, cy: number) => boolean,\n handleTextEditClick: (cx: number, cy: number, shiftKey: boolean) => boolean,\n setDrag: (d: DragState) => void\n) {\n // Node edit mode intercept\n if (getNodeEditState(editor)) {\n handleNodeEditDown(e, cx, cy, editor, setDrag)\n return\n }\n\n if (editor.state.editingTextId && handleTextEditClick(cx, cy, e.shiftKey)) return\n\n if (editor.state.editingTextId) editor.commitTextEdit()\n\n if (tryStartHandleDrag(cx, cy, sx, sy, e.altKey, editor, fns, tryStartRotation, setDrag)) return\n\n const deep = e.metaKey || e.ctrlKey\n const hit = tinySelectionAt(cx, cy, editor) ?? resolveHit(cx, cy, editor, fns, deep)\n if (!hit) {\n // ⌘ drags a marquee from empty space inside an entered container too.\n if (deep || !editor.state.enteredContainerId) startMarquee(cx, cy, editor, setDrag)\n return\n }\n if (deep && startsDeepMarquee(hit, e, cx, cy, editor, fns)) {\n startDeepMarquee(hit, cx, cy, editor, setDrag)\n return\n }\n\n pressLayers(hit, e, cx, cy, sx, sy, editor, setDrag)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,SAAS,aAAa,IAAY,IAAY,QAAgB,SAAiC;CAC7F,OAAO,eAAe;CACtB,MAAM,UAAU,OAAO,MAAM,sBAAsB,OAAO,MAAM;CAEhE,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAI,QAAQ;EAAI,aADjC,OAAO,MAAM,qBAAqB,IAAI,IAAI,OACY,CAAC,EAAE;CAAG,CAAC;AACjF;;;;;;;;AASA,SAAS,kBACP,KACA,GACA,IACA,IACA,QACA,KACA;CACA,MAAM,UAAU,OAAO,MAAM,sBAAsB,OAAO,MAAM;CAChE,OACE,CAAC,EAAE,YACH,CAAC,IAAI,UACL,CAAC,OAAO,MAAM,YAAY,IAAI,IAAI,EAAE,KACpC,CAAC,0BAA0B,KAAK,IAAI,IAAI,MAAM,KAC9C,CAAC,aAAa,IAAI,IAAI,GAAG,KACzB,OAAO,MAAM,qBAAqB,IAAI,IAAI,OAAO,CAAC,EAAE,OAAO,IAAI;AAEnE;;AAGA,SAAS,iBACP,KACA,IACA,IACA,QACA,SACA;CACA,OAAO,eAAe;CACtB,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAI,QAAQ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,IAAI,IAAI,IAAI,EAAE,QAAQ,QAAQ,KAAK,kBAAkB,OAAO,GAAG;CAE1F,MAAM,OAAO,EAAE,WAAW,EAAE;CAC5B,MAAM,MAAM,gBAAgB,IAAI,IAAI,MAAM,KAAK,WAAW,IAAI,IAAI,QAAQ,KAAK,IAAI;CACnF,IAAI,CAAC,KAAK;EAER,IAAI,QAAQ,CAAC,OAAO,MAAM,oBAAoB,aAAa,IAAI,IAAI,QAAQ,OAAO;EAClF;CACF;CACA,IAAI,QAAQ,kBAAkB,KAAK,GAAG,IAAI,IAAI,QAAQ,GAAG,GAAG;EAC1D,iBAAiB,KAAK,IAAI,IAAI,QAAQ,OAAO;EAC7C;CACF;CAEA,YAAY,KAAK,GAAG,IAAI,IAAI,IAAI,IAAI,QAAQ,OAAO;AACrD"}
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../src/shared/input/select.ts"],"sourcesContent":["import { hitTestLabel, resolveHit, tinySelectionAt } from '#vue/shared/input/select/hit'\nimport { getNodeEditState, handleNodeEditDown } from '#vue/shared/input/vector'\nexport { updateHoverCursor } from '#vue/shared/input/select/hover'\nimport { editedGradient, editedImage, resolveEditorProfile, type Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { tryStartAutoLayoutHandleDrag } from '#vue/shared/input/auto-layout/drag'\nimport { tryStartConnectorEndDrag } from '#vue/shared/input/connector/end'\nimport { tryStartConnectorLineDrag } from '#vue/shared/input/connector/line'\nimport { tryStartGradientDrag } from '#vue/shared/input/gradient'\nimport { tryStartImageCropDrag } from '#vue/shared/input/image-crop'\nimport { tryStartLineEndDrag } from '#vue/shared/input/line/end'\nimport { tryStartResize } from '#vue/shared/input/resize'\nimport {\n createSelectionMoveDrag,\n clickSelectsInside,\n pressedSelectedLayer,\n selectedLayerHoldingPress,\n selectionIsLocked\n} from '#vue/shared/input/select/move'\nimport { tryStartShapeHandleDrag } from '#vue/shared/input/shape-handles'\nimport { tryStartStickyScale } from '#vue/shared/input/sticky/scale'\nimport type { DragState } from '#vue/shared/input/types'\n\nexport interface HitTestFns {\n hitTestInScope: (cx: number, cy: number, deep: boolean) => SceneNode | null\n isInsideContainerBounds: (cx: number, cy: number, containerId: string) => boolean\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}\n\n/**\n * Clears the selection and starts a marquee in the open frame or section under the press, looked\n * up inside the container the user entered, if any.\n */\nfunction startMarquee(cx: number, cy: number, editor: Editor, setDrag: (d: DragState) => void) {\n editor.clearSelection()\n const scopeId = editor.state.enteredContainerId ?? editor.state.currentPageId\n const container = editor.graph.hitTestOpenContainer(cx, cy, scopeId)\n setDrag({ type: 'marquee', startX: cx, startY: cy, containerId: container?.id })\n}\n\n/**\n * Whether a ⌘ press on `hit` starts a deep marquee rather than a move, as in Figma: only where a\n * plain press would start a marquee too, on the empty background of a board, section, or component\n * set, which a deep hit stops at when it is painted. Anywhere else, including the background of a\n * nested frame, component, instance, or group, a ⌘ press selects the deepest layer and moves it; a\n * press on the selection, a locked layer, a label, or with Shift keeps the usual press.\n */\nfunction startsDeepMarquee(\n hit: SceneNode,\n e: MouseEvent,\n cx: number,\n cy: number,\n editor: Editor,\n fns: HitTestFns\n) {\n const scopeId = editor.state.enteredContainerId ?? editor.state.currentPageId\n return (\n !e.shiftKey &&\n !hit.locked &&\n !editor.state.selectedIds.has(hit.id) &&\n !selectedLayerHoldingPress(hit, cx, cy, editor) &&\n !hitTestLabel(cx, cy, fns) &&\n editor.graph.hitTestOpenContainer(cx, cy, scopeId)?.id === hit.id\n )\n}\n\n/** Starts a ⌘ marquee scoped to the pressed container; a click without a drag still selects it. */\nfunction startDeepMarquee(\n hit: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n setDrag: (d: DragState) => void\n) {\n editor.clearSelection()\n setDrag({ type: 'marquee', startX: cx, startY: cy, containerId: hit.id, selectOnClick: hit.id })\n}\n\n/**\n * Starts dragging a gradient handle, or else the selection's corner radius, resize, or rotation\n * handles. A layer's label takes the press before rotation but after resizing, as in Figma; a\n * read-only document has no handles.\n */\nfunction tryStartHandleDrag(\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n altKey: boolean,\n editor: Editor,\n fns: HitTestFns,\n tryStartRotation: (cx: number, cy: number) => boolean,\n setDrag: (d: DragState) => void,\n bigNudge: number\n): boolean {\n if (!resolveEditorProfile(editor.state).edits) return false\n if (tryStartGradientDrag(editor, sx, sy, setDrag)) return true\n // An open gradient's handles replace the layer's selection handles, which then do not respond.\n if (editedGradient(editor.graph, editor.state.gradientEdit)) return false\n // So do an edited image's crop handles; a press outside the image leaves image edit mode.\n if (tryStartImageCropDrag(editor, sx, sy, setDrag)) return true\n if (editedImage(editor.graph, editor.state.imageEdit)) return false\n if (tryStartShapeHandleDrag(editor, sx, sy, altKey, setDrag)) return true\n if (tryStartAutoLayoutHandleDrag(editor, cx, cy, sx, sy, setDrag, bigNudge)) return true\n if (tryStartConnectorEndDrag(editor, sx, sy, setDrag)) return true\n if (tryStartConnectorLineDrag(editor, cx, cy, sx, sy, setDrag)) return true\n if (tryStartLineEndDrag(editor, cx, cy, setDrag)) return true\n const scaleDrag = tryStartStickyScale(cx, cy, editor)\n if (scaleDrag) {\n setDrag(scaleDrag)\n return true\n }\n const resizeDrag = tryStartResize(cx, cy, editor)\n if (resizeDrag) {\n setDrag(resizeDrag)\n return true\n }\n return !hitTestLabel(cx, cy, fns) && tryStartRotation(cx, cy)\n}\n\n/** Shift adds to the selection; a plain press selects the layer unless it keeps the selection. */\nfunction selectOnPress(hit: SceneNode, shiftKey: boolean, keepsSelection: boolean, editor: Editor) {\n if (shiftKey) editor.select([hit.id], true)\n else if (!editor.state.selectedIds.has(hit.id) && !keepsSelection) editor.select([hit.id])\n}\n\n/** A read-only document moves nothing, so a press selects a layer inside a selected frame at once. */\nfunction selectInsideOnPress(hit: SceneNode, keepsSelection: boolean, editor: Editor) {\n if (keepsSelection && !editor.state.selectedIds.has(hit.id) && clickSelectsInside(hit, editor))\n editor.select([hit.id])\n}\n\n/** What a press on `hit` selects, and the drag it starts, as a layer press does. */\nfunction pressLayers(\n hit: SceneNode,\n e: MouseEvent,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor,\n setDrag: (d: DragState) => void\n): void {\n const keepsSelection = !e.shiftKey && Boolean(selectedLayerHoldingPress(hit, cx, cy, editor))\n // Shift-pressing a layer already selected keeps it selected to drag, and deselects it when the\n // press ends without moving it, as in Figma.\n const shiftPressedSelectedId = e.shiftKey\n ? pressedSelectedLayer(hit, !keepsSelection, cx, cy, editor)\n : undefined\n if (!shiftPressedSelectedId) selectOnPress(hit, e.shiftKey, keepsSelection, editor)\n\n if (!resolveEditorProfile(editor.state).edits) {\n if (shiftPressedSelectedId) editor.select([shiftPressedSelectedId], true)\n selectInsideOnPress(hit, keepsSelection, editor)\n return\n }\n if (selectionIsLocked(editor)) {\n if (shiftPressedSelectedId) editor.select([shiftPressedSelectedId], true)\n return\n }\n\n const drag = createSelectionMoveDrag(cx, cy, sx, sy, editor, e.altKey)\n drag.clickDeselectsId = shiftPressedSelectedId\n // A click without dragging still selects a layer inside a selected frame; groups need a double-click.\n if (keepsSelection && !editor.state.selectedIds.has(hit.id)) {\n drag.selectOnClick = clickSelectsInside(hit, editor) ? hit.id : undefined\n }\n setDrag(drag)\n}\n\nexport function handleSelectDown(\n e: MouseEvent,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor,\n fns: HitTestFns,\n tryStartRotation: (cx: number, cy: number) => boolean,\n handleTextEditClick: (cx: number, cy: number, shiftKey: boolean) => boolean,\n setDrag: (d: DragState) => void,\n bigNudge = 10\n) {\n // Node edit mode intercept\n if (getNodeEditState(editor)) {\n handleNodeEditDown(e, cx, cy, editor, setDrag)\n return\n }\n\n if (editor.state.editingTextId && handleTextEditClick(cx, cy, e.shiftKey)) return\n\n if (editor.state.editingTextId) editor.commitTextEdit()\n\n if (\n tryStartHandleDrag(cx, cy, sx, sy, e.altKey, editor, fns, tryStartRotation, setDrag, bigNudge)\n )\n return\n\n const deep = e.metaKey || e.ctrlKey\n const hit = tinySelectionAt(cx, cy, editor) ?? resolveHit(cx, cy, editor, fns, deep)\n if (!hit) {\n // ⌘ drags a marquee from empty space inside an entered container too.\n if (deep || !editor.state.enteredContainerId) startMarquee(cx, cy, editor, setDrag)\n return\n }\n if (deep && startsDeepMarquee(hit, e, cx, cy, editor, fns)) {\n startDeepMarquee(hit, cx, cy, editor, setDrag)\n return\n }\n\n pressLayers(hit, e, cx, cy, sx, sy, editor, setDrag)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,aAAa,IAAY,IAAY,QAAgB,SAAiC;CAC7F,OAAO,eAAe;CACtB,MAAM,UAAU,OAAO,MAAM,sBAAsB,OAAO,MAAM;CAEhE,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAI,QAAQ;EAAI,aADjC,OAAO,MAAM,qBAAqB,IAAI,IAAI,OACY,CAAC,EAAE;CAAG,CAAC;AACjF;;;;;;;;AASA,SAAS,kBACP,KACA,GACA,IACA,IACA,QACA,KACA;CACA,MAAM,UAAU,OAAO,MAAM,sBAAsB,OAAO,MAAM;CAChE,OACE,CAAC,EAAE,YACH,CAAC,IAAI,UACL,CAAC,OAAO,MAAM,YAAY,IAAI,IAAI,EAAE,KACpC,CAAC,0BAA0B,KAAK,IAAI,IAAI,MAAM,KAC9C,CAAC,aAAa,IAAI,IAAI,GAAG,KACzB,OAAO,MAAM,qBAAqB,IAAI,IAAI,OAAO,CAAC,EAAE,OAAO,IAAI;AAEnE;;AAGA,SAAS,iBACP,KACA,IACA,IACA,QACA,SACA;CACA,OAAO,eAAe;CACtB,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAI,QAAQ;EAAI,aAAa,IAAI;EAAI,eAAe,IAAI;CAAG,CAAC;AACjG;;;;;;AAOA,SAA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D,IACE,mBAAmB,IAAI,IAAI,IAAI,IAAI,EAAE,QAAQ,QAAQ,KAAK,kBAAkB,SAAS,QAAQ,GAE7F;CAEF,MAAM,OAAO,EAAE,WAAW,EAAE;CAC5B,MAAM,MAAM,gBAAgB,IAAI,IAAI,MAAM,KAAK,WAAW,IAAI,IAAI,QAAQ,KAAK,IAAI;CACnF,IAAI,CAAC,KAAK;EAER,IAAI,QAAQ,CAAC,OAAO,MAAM,oBAAoB,aAAa,IAAI,IAAI,QAAQ,OAAO;EAClF;CACF;CACA,IAAI,QAAQ,kBAAkB,KAAK,GAAG,IAAI,IAAI,QAAQ,GAAG,GAAG;EAC1D,iBAAiB,KAAK,IAAI,IAAI,QAAQ,OAAO;EAC7C;CACF;CAEA,YAAY,KAAK,GAAG,IAAI,IAAI,IAAI,IAAI,QAAQ,OAAO;AACrD"}
|
|
@@ -328,7 +328,15 @@ interface DragShapeHandle {
|
|
|
328
328
|
commit: () => void;
|
|
329
329
|
cancel: () => void;
|
|
330
330
|
}
|
|
331
|
-
|
|
331
|
+
/** Dragging a padding edge or an item gap of the selected auto layout frame. */
|
|
332
|
+
interface DragAutoLayout {
|
|
333
|
+
type: 'auto-layout';
|
|
334
|
+
/** Sets the padding or gap so far; Alt edits the opposite side (with Shift, all sides), Shift the large nudge. */
|
|
335
|
+
update: (screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) => void;
|
|
336
|
+
commit: () => void;
|
|
337
|
+
cancel: () => void;
|
|
338
|
+
}
|
|
339
|
+
type DragState = DragAutoLayout | DragShapeHandle | DragDraw | DragStickyDraw | DragConnectorDraw | DragConnectorEnd | DragConnectorLine | DragLineEnd | DragGradient | DragImageCrop | DragMove | DragPan | DragResize | DragStickyScale | DragZoom | DragScale | DragMarquee | DragRotate | DragPen | DragPencil | DragTextSelect | DragEditNode | DragEditHandle | DragEditMarquee | DragBendHandle | DragBendSegment | DragEditTransform | DragGuide;
|
|
332
340
|
//#endregion
|
|
333
|
-
export { DragBendSegment, DragConnectorDraw, DragDraw, DragEditHandle, DragEditMarquee, DragEditNode, DragEditTransform, DragGradient, DragGuide, DragImageCrop, DragMarquee, DragMove, DragPan, DragResize, DragRotate, DragScale, DragShapeHandle, DragState, DragStickyDraw, DragStickyScale, DragZoom };
|
|
341
|
+
export { DragAutoLayout, DragBendSegment, DragConnectorDraw, DragDraw, DragEditHandle, DragEditMarquee, DragEditNode, DragEditTransform, DragGradient, DragGuide, DragImageCrop, DragMarquee, DragMove, DragPan, DragResize, DragRotate, DragScale, DragShapeHandle, DragState, DragStickyDraw, DragStickyScale, DragZoom };
|
|
334
342
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/shared/input/types.ts"],"mappings":";;;;;;;;UAiBiB;EACf;;EAEA;EACA;;EAEA,UAAU,WAAW,cAAc;;EAEnC;;EAEA,OAAO;EACP;EACA,SAAS,SAAS,QAAQ;EAC1B;EACA;;;;;;UAOe;EACf;EACA;EACA;EACA;;EAEA;EACA;;EAEA,WAAW;EACX;EACA;;;UAIQ;EACR;EACA;EACA;;;UAIQ;EACR;EACA;EACA;;;UAIQ;EACR;EACA;EACA;;;UAIe;EACf;;EAEA,OAAO,YAAY;EACnB;EACA;;;;;;UAOe;EACf;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA,UAAU;;EAEV,WAAW,YAAY;;EAEvB;EACA,UAAU;;EAEV;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,YAAY;EACvB;EACA,8BAA8B;EAC9B;EACA;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA,QAAQ;EACR;EACA;EACA,UAAU;EACV;EACA,mBAAmB;EACnB,kBAAkB;;EAElB,oBAAoB;EACpB,uBAAuB;EACvB,aAAa;EACb,kBAAkB;EAClB,iBAAiB;EACjB,cAAc,YAAY;;EAE1B;;EAEA;EACA,cAAc;;EAEd;;EAEA,aAAa;;EAEb,gBAAgB;;UAGD;EACf;EACA;EACA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;UAGQ;EACR;EACA;EACA;EACA;EACA,uBAAuB;EACvB;EACA;EACA;EACA;EACA;;UAGQ;EACR;;UAGQ;EACR;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,eAAe,YAAY;;;;;EAK3B;IAAU;IAA4B;IAAe;;;;;;EAKrD;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB;;;UAID;EACf;EACA;EACA;;EAEA,eAAe;;EAEf,cAAc;;UAGN;EACR;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;;;;;;UAOe;EACf;EACA;;EAEA;EACA;EACA;;EAEA,QAAQ;;;UAIO;EACf;EACA,MAAM;;EAEN;EACA,KAAK;EACL;EACA;;EAEA,QAAQ;;UAGO;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;;EAEA,SAAS,iBAAiB,iBAAiB;EAC3C;EACA;;;UAIe;EACf;;EAEA,SAAS,iBAAiB,iBAAiB;IAAa;IAAgB;;EACxE;EACA;;;UAIe;EACf;;EAEA,SAAS,YAAY,YAAY,YAAY,YAAY;EACzD;EACA;;;;;;UAOe;EACf;;EAEA;EACA,SAAS,YAAY,YAAY,YAAY,YAAY;EACzD;EACA;;;UAIe;EACf;;EAEA,SAAS,iBAAiB,iBAAiB;EAC3C;EACA;;KAGU,YACR,kBACA,WACA,iBACA,oBACA,mBACA,oBACA,cACA,eACA,gBACA,WACA,UACA,aACA,kBACA,WACA,YACA,cACA,aACA,UACA,aACA,iBACA,eACA,iBACA,kBACA,iBACA,kBACA,oBACA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/shared/input/types.ts"],"mappings":";;;;;;;;UAiBiB;EACf;;EAEA;EACA;;EAEA,UAAU,WAAW,cAAc;;EAEnC;;EAEA,OAAO;EACP;EACA,SAAS,SAAS,QAAQ;EAC1B;EACA;;;;;;UAOe;EACf;EACA;EACA;EACA;;EAEA;EACA;;EAEA,WAAW;EACX;EACA;;;UAIQ;EACR;EACA;EACA;;;UAIQ;EACR;EACA;EACA;;;UAIQ;EACR;EACA;EACA;;;UAIe;EACf;;EAEA,OAAO,YAAY;EACnB;EACA;;;;;;UAOe;EACf;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA,UAAU;;EAEV,WAAW,YAAY;;EAEvB;EACA,UAAU;;EAEV;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,YAAY;EACvB;EACA,8BAA8B;EAC9B;EACA;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA,QAAQ;EACR;EACA;EACA,UAAU;EACV;EACA,mBAAmB;EACnB,kBAAkB;;EAElB,oBAAoB;EACpB,uBAAuB;EACvB,aAAa;EACb,kBAAkB;EAClB,iBAAiB;EACjB,cAAc,YAAY;;EAE1B;;EAEA;EACA,cAAc;;EAEd;;EAEA,aAAa;;EAEb,gBAAgB;;UAGD;EACf;EACA;EACA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;UAGQ;EACR;EACA;EACA;EACA;EACA,uBAAuB;EACvB;EACA;EACA;EACA;EACA;;UAGQ;EACR;;UAGQ;EACR;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,eAAe,YAAY;;;;;EAK3B;IAAU;IAA4B;IAAe;;;;;;EAKrD;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB;;;UAID;EACf;EACA;EACA;;EAEA,eAAe;;EAEf,cAAc;;UAGN;EACR;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;;;;;;UAOe;EACf;EACA;;EAEA;EACA;EACA;;EAEA,QAAQ;;;UAIO;EACf;EACA,MAAM;;EAEN;EACA,KAAK;EACL;EACA;;EAEA,QAAQ;;UAGO;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;;EAEA,SAAS,iBAAiB,iBAAiB;EAC3C;EACA;;;UAIe;EACf;;EAEA,SAAS,iBAAiB,iBAAiB;IAAa;IAAgB;;EACxE;EACA;;;UAIe;EACf;;EAEA,SAAS,YAAY,YAAY,YAAY,YAAY;EACzD;EACA;;;;;;UAOe;EACf;;EAEA;EACA,SAAS,YAAY,YAAY,YAAY,YAAY;EACzD;EACA;;;UAIe;EACf;;EAEA,SAAS,iBAAiB,iBAAiB;EAC3C;EACA;;;UAIe;EACf;;EAEA,SAAS,iBAAiB,iBAAiB,iBAAiB;EAC5D;EACA;;KAGU,YACR,iBACA,kBACA,WACA,iBACA,oBACA,mBACA,oBACA,cACA,eACA,gBACA,WACA,UACA,aACA,kBACA,WACA,YACA,cACA,aACA,UACA,aACA,iBACA,eACA,iBACA,kBACA,iBACA,kBACA,oBACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/shared/input/types.ts"],"sourcesContent":["import type { AttachModifiers, MovePlace, Tool } from '@pairdraw/core'\nimport type { HandlePosition, TransformZone } from '@pairdraw/core/geometry'\nimport type {\n DerivedTextGlyph,\n GeometryPath,\n NodeType,\n SceneNode,\n Stroke,\n TextPathData,\n VectorNetwork\n} from '@pairdraw/scene-graph'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ResizeSnapshot } from '@pairdraw/scene-graph/resize'\n\nimport type { FlowDrag } from '#vue/shared/input/flow-reorder'\nimport type { LayerSizing } from '#vue/shared/input/resize/sizing'\n\nexport interface DragDraw {\n type: 'draw'\n /** Start point in the parent's axes. */\n startX: number\n startY: number\n /** Maps a canvas point into the parent's axes. */\n toLocal: (x: number, y: number) => Vector\n /** A line is drawn by its length and angle, as in Figma, not as a box. */\n line?: boolean\n /** Lands a coordinate on the pixel grid while Snap to pixel grid is on. */\n snap: (value: number) => number\n nodeId: string\n update: (changes: Partial<SceneNode>) => void\n commit: () => void\n cancel: () => void\n}\n\n/**\n * A connector drawn with the connector tool, from the press to the release or from one click to\n * the next. Positions are screen pixels, to tell a click from a drag.\n */\nexport interface DragConnectorDraw {\n type: 'connector-draw'\n startSX: number\n startSY: number\n moved: boolean\n /** Where the pointer is, in canvas coordinates. */\n x: number\n y: number\n /** The keys held at the last move, which the release attaches by. */\n modifiers: AttachModifiers\n commit: () => void\n cancel: () => void\n}\n\n/** An end of a selected connector dragged to another layer or point. */\ninterface DragConnectorEnd {\n type: 'connector-end'\n commit: () => void\n cancel: () => void\n}\n\n/** An elbow segment or the curve of a selected connector dragged into place. */\ninterface DragConnectorLine {\n type: 'connector-line'\n commit: () => void\n cancel: () => void\n}\n\n/** An end of a selected line or arrow dragged to aim it. */\ninterface DragLineEnd {\n type: 'line-end'\n commit: () => void\n cancel: () => void\n}\n\n/** A sticky note being drawn: it grows from the press corner with the drag, as a frame does. */\nexport interface DragStickyDraw {\n type: 'sticky-draw'\n /** Grows the note to the pointer, in canvas coordinates. */\n move: (cx: number, cy: number) => void\n commit: () => void\n cancel: () => void\n}\n\n/**\n * A sticky note's handle dragged: a corner, top, or bottom scales the whole note, a side switches\n * it between square and wide, as in FigJam.\n */\nexport interface DragStickyScale {\n type: 'sticky-scale'\n mode: 'scale' | 'wide'\n handle: HandlePosition\n startX: number\n startY: number\n nodeId: string\n origRect: Rect\n /** The note and its sublayers as the drag found them. */\n originals: Map<string, SceneNode>\n /** The scale and top-left the latest step reached. */\n scale: number\n position: Vector\n /** Whether a side drag has reached the wide width. */\n wide: boolean\n commit: () => void\n cancel: () => void\n}\n\nexport interface DragMove {\n type: 'move'\n startX: number\n startY: number\n currentX: number\n currentY: number\n appliedDx: number\n appliedDy: number\n startScreenX: number\n startScreenY: number\n dragStarted: boolean\n originals: Map<string, MovePlace>\n duplicated?: boolean\n duplicatedPreviousSelection?: Set<string>\n autoLayoutParentId?: string\n brokeFromAutoLayout?: boolean\n /** The auto layout flows the moved layers are dragged along, as blocks. */\n flows?: FlowDrag[]\n /** Each flow's slot for the block where the drag has reached. */\n flowSlots?: number[]\n /** Space is held: layers keep their parents wherever they are dropped. */\n keepParents?: boolean\n /** Control is held: auto layout frames take the layers as absolute-positioned children. */\n ignoreAutoLayout?: boolean\n /** Selected instead if the press ends as a click without dragging. */\n selectOnClick?: string\n /** Where Control drops layers among an auto layout frame's children. */\n absoluteInsertIndex?: number\n /** A selected layer a Shift-press on it deselects when it ends without a drag. */\n clickDeselectsId?: string\n}\n\nexport interface DragPan {\n type: 'pan'\n startScreenX: number\n startScreenY: number\n startPanX: number\n startPanY: number\n}\n\nexport interface DragResize {\n type: 'resize'\n handle: HandlePosition\n startX: number\n startY: number\n origRect: Rect\n nodeId: string\n origVectorNetwork: VectorNetwork | null\n origFillGeometry: GeometryPath[]\n /** Path-text OUTSIDE outlines / vector stroke blobs — must scale with the node. */\n origStrokeGeometry: GeometryPath[]\n origDerivedTextGlyphs: DerivedTextGlyph[] | null\n origStrokes: Stroke[]\n origTextPathData: TextPathData | null\n origTextPathBox: Rect | null\n origChildren: Map<string, ResizeSnapshot> | null\n /** The ratio the layer is locked to, kept unless Control frees it. */\n lockedAspectRatio: number | null\n /** Whether the latest step set the lock aside, so the commit stores the new size. */\n freesLock?: boolean\n appliedRect?: Rect\n /** The layer's edited fields before the drag marked its size, to put back if it changes nothing. */\n origEditedFields?: string[]\n /** The layer's sizing before the drag, taken on its first step. */\n origSizing?: LayerSizing\n /** The sizing the latest step left, which the commit keeps. */\n appliedSizing?: LayerSizing\n}\n\nexport interface DragMarquee {\n type: 'marquee'\n startX: number\n startY: number\n /** The open frame or section the marquee started in, whose layers it selects. */\n containerId?: string\n /** Selected instead if the press ends as a click without dragging. */\n selectOnClick?: string\n}\n\nexport interface DragRotate {\n type: 'rotate'\n nodeId: string\n centerX: number\n centerY: number\n startAngle: number\n origRotation: number\n rotationDirection: 1 | -1\n}\n\ninterface DragPen {\n type: 'pen-drag'\n startX: number\n startY: number\n modifierMode: 'default' | 'continuous' | 'independent'\n frozenOppositeTangent: Vector | null\n spaceDown: boolean\n spaceStartX: number\n spaceStartY: number\n knotStartX: number\n knotStartY: number\n}\n\ninterface DragPencil {\n type: 'pencil-drag'\n}\n\ninterface DragTextSelect {\n type: 'text-select'\n startX: number\n startY: number\n}\n\nexport interface DragEditNode {\n type: 'edit-node'\n startX: number\n startY: number\n origPositions: Map<number, Vector>\n /**\n * A selected segment or region that was pressed: releasing without a drag selects only it, or\n * with Shift takes it out of the selection.\n */\n click?: { part: 'segment' | 'region'; index: number; deselect: boolean }\n /**\n * ⌥/Alt was held on the press: once the pointer moves past the drag threshold the selection is\n * copied and the copies drag instead; `false` once copied.\n */\n duplicate?: boolean\n}\n\nexport interface DragEditHandle {\n type: 'edit-handle'\n segmentIndex: number\n tangentField: 'tangentStart' | 'tangentEnd'\n vertexIndex: number\n startX: number\n startY: number\n initialTangent: Vector | null\n}\n\n/** A drag over empty space while editing a path: selects the points and segments it encloses. */\nexport interface DragEditMarquee {\n type: 'edit-marquee'\n startX: number\n startY: number\n /** Points kept selected alongside the enclosed ones, as with Shift held. */\n baseSelection: Set<number>\n /** Segments kept selected alongside the enclosed ones, as with Shift held. */\n baseSegments: Set<number>\n}\n\ninterface DragBendHandle {\n type: 'bend-handle'\n vertexIndex: number\n startX: number\n startY: number\n lockedMode: 'symmetric' | 'independent' | null\n dragSamples: Vector[]\n targetSegmentIndex: number | null\n targetTangentField: 'tangentStart' | 'tangentEnd' | null\n}\n\n/**\n * A ⌘/Ctrl drag on a segment of the path being edited: bends the segment so the pressed point on it\n * follows the pointer, or with ⌥/Alt too, without turning the handles of the segments beside it.\n */\nexport interface DragBendSegment {\n type: 'bend-segment'\n segmentIndex: number\n /** Where along the segment it was pressed, as a share of it. */\n t: number\n startX: number\n startY: number\n /** The path as the press found it; each move bends from it. */\n origin: VectorNetwork\n}\n\n/** A drag on the transform box around selected points: scales them from a handle or turns them. */\nexport interface DragEditTransform {\n type: 'edit-transform'\n zone: TransformZone\n /** The selected points, and the box around them as the press found it. */\n points: number[]\n box: Rect\n startX: number\n startY: number\n /** The path as the press found it; each move transforms from it. */\n origin: VectorNetwork\n}\n\nexport interface DragGuide {\n type: 'guide'\n axis: 'x' | 'y'\n ownerId: string\n position: number\n startScreenX: number\n startScreenY: number\n currentScreenX: number\n currentScreenY: number\n dragStarted: boolean\n duplicate?: boolean\n guideId?: string\n originalOwnerId?: string\n originalPosition?: number\n}\n\n/** Dragging a handle or stop of the gradient whose picker is open. */\nexport interface DragGradient {\n type: 'gradient'\n /** Moves the dragged handle or stop to a screen point. */\n update: (screenX: number, screenY: number, shiftKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\n/** Dragging a crop handle, an image corner, or the image itself in image edit mode. */\nexport interface DragImageCrop {\n type: 'image-crop'\n /** Applies the drag up to a screen point; Shift keeps proportions or an axis, Alt the centre. */\n update: (screenX: number, screenY: number, modifiers: { shift: boolean; alt: boolean }) => void\n commit: () => void\n cancel: () => void\n}\n\n/** A zoom tool press: a click zooms in or out on the pointer, a drag frames an area to zoom to. */\nexport interface DragZoom {\n type: 'zoom'\n /** Follows the pointer, in canvas and screen coordinates; ⌥ or Alt zooms out. */\n update: (cx: number, cy: number, sx: number, sy: number, altKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\n/**\n * A Scale tool handle drag: the selection scales with its contents from the opposite handle, or\n * from its center while ⌥ or Alt is held.\n */\nexport interface DragScale {\n type: 'scale'\n /** The resize cursor the drag keeps. */\n cursor: string\n update: (cx: number, cy: number, sx: number, sy: number, altKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\n/** Dragging a radius, point count, or ratio handle of the selected rectangle, polygon, or star. */\nexport interface DragShapeHandle {\n type: 'shape-handle'\n /** Sets the value under a screen point; Shift rounds a radius to tens. */\n update: (screenX: number, screenY: number, shiftKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\nexport type DragState =\n | DragShapeHandle\n | DragDraw\n | DragStickyDraw\n | DragConnectorDraw\n | DragConnectorEnd\n | DragConnectorLine\n | DragLineEnd\n | DragGradient\n | DragImageCrop\n | DragMove\n | DragPan\n | DragResize\n | DragStickyScale\n | DragZoom\n | DragScale\n | DragMarquee\n | DragRotate\n | DragPen\n | DragPencil\n | DragTextSelect\n | DragEditNode\n | DragEditHandle\n | DragEditMarquee\n | DragBendHandle\n | DragBendSegment\n | DragEditTransform\n | DragGuide\n\nexport const TOOL_TO_NODE: Partial<Record<Tool, NodeType>> = {\n FRAME: 'FRAME',\n SECTION: 'SECTION',\n RECTANGLE: 'RECTANGLE',\n ELLIPSE: 'ELLIPSE',\n LINE: 'LINE',\n POLYGON: 'POLYGON',\n STAR: 'STAR',\n TEXT: 'TEXT',\n SHAPE_WITH_TEXT: 'SHAPE_WITH_TEXT'\n}\n"],"mappings":";AAoYA,MAAa,eAAgD;CAC3D,OAAO;CACP,SAAS;CACT,WAAW;CACX,SAAS;CACT,MAAM;CACN,SAAS;CACT,MAAM;CACN,MAAM;CACN,iBAAiB;AACnB"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/shared/input/types.ts"],"sourcesContent":["import type { AttachModifiers, MovePlace, Tool } from '@pairdraw/core'\nimport type { HandlePosition, TransformZone } from '@pairdraw/core/geometry'\nimport type {\n DerivedTextGlyph,\n GeometryPath,\n NodeType,\n SceneNode,\n Stroke,\n TextPathData,\n VectorNetwork\n} from '@pairdraw/scene-graph'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ResizeSnapshot } from '@pairdraw/scene-graph/resize'\n\nimport type { FlowDrag } from '#vue/shared/input/flow-reorder'\nimport type { LayerSizing } from '#vue/shared/input/resize/sizing'\n\nexport interface DragDraw {\n type: 'draw'\n /** Start point in the parent's axes. */\n startX: number\n startY: number\n /** Maps a canvas point into the parent's axes. */\n toLocal: (x: number, y: number) => Vector\n /** A line is drawn by its length and angle, as in Figma, not as a box. */\n line?: boolean\n /** Lands a coordinate on the pixel grid while Snap to pixel grid is on. */\n snap: (value: number) => number\n nodeId: string\n update: (changes: Partial<SceneNode>) => void\n commit: () => void\n cancel: () => void\n}\n\n/**\n * A connector drawn with the connector tool, from the press to the release or from one click to\n * the next. Positions are screen pixels, to tell a click from a drag.\n */\nexport interface DragConnectorDraw {\n type: 'connector-draw'\n startSX: number\n startSY: number\n moved: boolean\n /** Where the pointer is, in canvas coordinates. */\n x: number\n y: number\n /** The keys held at the last move, which the release attaches by. */\n modifiers: AttachModifiers\n commit: () => void\n cancel: () => void\n}\n\n/** An end of a selected connector dragged to another layer or point. */\ninterface DragConnectorEnd {\n type: 'connector-end'\n commit: () => void\n cancel: () => void\n}\n\n/** An elbow segment or the curve of a selected connector dragged into place. */\ninterface DragConnectorLine {\n type: 'connector-line'\n commit: () => void\n cancel: () => void\n}\n\n/** An end of a selected line or arrow dragged to aim it. */\ninterface DragLineEnd {\n type: 'line-end'\n commit: () => void\n cancel: () => void\n}\n\n/** A sticky note being drawn: it grows from the press corner with the drag, as a frame does. */\nexport interface DragStickyDraw {\n type: 'sticky-draw'\n /** Grows the note to the pointer, in canvas coordinates. */\n move: (cx: number, cy: number) => void\n commit: () => void\n cancel: () => void\n}\n\n/**\n * A sticky note's handle dragged: a corner, top, or bottom scales the whole note, a side switches\n * it between square and wide, as in FigJam.\n */\nexport interface DragStickyScale {\n type: 'sticky-scale'\n mode: 'scale' | 'wide'\n handle: HandlePosition\n startX: number\n startY: number\n nodeId: string\n origRect: Rect\n /** The note and its sublayers as the drag found them. */\n originals: Map<string, SceneNode>\n /** The scale and top-left the latest step reached. */\n scale: number\n position: Vector\n /** Whether a side drag has reached the wide width. */\n wide: boolean\n commit: () => void\n cancel: () => void\n}\n\nexport interface DragMove {\n type: 'move'\n startX: number\n startY: number\n currentX: number\n currentY: number\n appliedDx: number\n appliedDy: number\n startScreenX: number\n startScreenY: number\n dragStarted: boolean\n originals: Map<string, MovePlace>\n duplicated?: boolean\n duplicatedPreviousSelection?: Set<string>\n autoLayoutParentId?: string\n brokeFromAutoLayout?: boolean\n /** The auto layout flows the moved layers are dragged along, as blocks. */\n flows?: FlowDrag[]\n /** Each flow's slot for the block where the drag has reached. */\n flowSlots?: number[]\n /** Space is held: layers keep their parents wherever they are dropped. */\n keepParents?: boolean\n /** Control is held: auto layout frames take the layers as absolute-positioned children. */\n ignoreAutoLayout?: boolean\n /** Selected instead if the press ends as a click without dragging. */\n selectOnClick?: string\n /** Where Control drops layers among an auto layout frame's children. */\n absoluteInsertIndex?: number\n /** A selected layer a Shift-press on it deselects when it ends without a drag. */\n clickDeselectsId?: string\n}\n\nexport interface DragPan {\n type: 'pan'\n startScreenX: number\n startScreenY: number\n startPanX: number\n startPanY: number\n}\n\nexport interface DragResize {\n type: 'resize'\n handle: HandlePosition\n startX: number\n startY: number\n origRect: Rect\n nodeId: string\n origVectorNetwork: VectorNetwork | null\n origFillGeometry: GeometryPath[]\n /** Path-text OUTSIDE outlines / vector stroke blobs — must scale with the node. */\n origStrokeGeometry: GeometryPath[]\n origDerivedTextGlyphs: DerivedTextGlyph[] | null\n origStrokes: Stroke[]\n origTextPathData: TextPathData | null\n origTextPathBox: Rect | null\n origChildren: Map<string, ResizeSnapshot> | null\n /** The ratio the layer is locked to, kept unless Control frees it. */\n lockedAspectRatio: number | null\n /** Whether the latest step set the lock aside, so the commit stores the new size. */\n freesLock?: boolean\n appliedRect?: Rect\n /** The layer's edited fields before the drag marked its size, to put back if it changes nothing. */\n origEditedFields?: string[]\n /** The layer's sizing before the drag, taken on its first step. */\n origSizing?: LayerSizing\n /** The sizing the latest step left, which the commit keeps. */\n appliedSizing?: LayerSizing\n}\n\nexport interface DragMarquee {\n type: 'marquee'\n startX: number\n startY: number\n /** The open frame or section the marquee started in, whose layers it selects. */\n containerId?: string\n /** Selected instead if the press ends as a click without dragging. */\n selectOnClick?: string\n}\n\nexport interface DragRotate {\n type: 'rotate'\n nodeId: string\n centerX: number\n centerY: number\n startAngle: number\n origRotation: number\n rotationDirection: 1 | -1\n}\n\ninterface DragPen {\n type: 'pen-drag'\n startX: number\n startY: number\n modifierMode: 'default' | 'continuous' | 'independent'\n frozenOppositeTangent: Vector | null\n spaceDown: boolean\n spaceStartX: number\n spaceStartY: number\n knotStartX: number\n knotStartY: number\n}\n\ninterface DragPencil {\n type: 'pencil-drag'\n}\n\ninterface DragTextSelect {\n type: 'text-select'\n startX: number\n startY: number\n}\n\nexport interface DragEditNode {\n type: 'edit-node'\n startX: number\n startY: number\n origPositions: Map<number, Vector>\n /**\n * A selected segment or region that was pressed: releasing without a drag selects only it, or\n * with Shift takes it out of the selection.\n */\n click?: { part: 'segment' | 'region'; index: number; deselect: boolean }\n /**\n * ⌥/Alt was held on the press: once the pointer moves past the drag threshold the selection is\n * copied and the copies drag instead; `false` once copied.\n */\n duplicate?: boolean\n}\n\nexport interface DragEditHandle {\n type: 'edit-handle'\n segmentIndex: number\n tangentField: 'tangentStart' | 'tangentEnd'\n vertexIndex: number\n startX: number\n startY: number\n initialTangent: Vector | null\n}\n\n/** A drag over empty space while editing a path: selects the points and segments it encloses. */\nexport interface DragEditMarquee {\n type: 'edit-marquee'\n startX: number\n startY: number\n /** Points kept selected alongside the enclosed ones, as with Shift held. */\n baseSelection: Set<number>\n /** Segments kept selected alongside the enclosed ones, as with Shift held. */\n baseSegments: Set<number>\n}\n\ninterface DragBendHandle {\n type: 'bend-handle'\n vertexIndex: number\n startX: number\n startY: number\n lockedMode: 'symmetric' | 'independent' | null\n dragSamples: Vector[]\n targetSegmentIndex: number | null\n targetTangentField: 'tangentStart' | 'tangentEnd' | null\n}\n\n/**\n * A ⌘/Ctrl drag on a segment of the path being edited: bends the segment so the pressed point on it\n * follows the pointer, or with ⌥/Alt too, without turning the handles of the segments beside it.\n */\nexport interface DragBendSegment {\n type: 'bend-segment'\n segmentIndex: number\n /** Where along the segment it was pressed, as a share of it. */\n t: number\n startX: number\n startY: number\n /** The path as the press found it; each move bends from it. */\n origin: VectorNetwork\n}\n\n/** A drag on the transform box around selected points: scales them from a handle or turns them. */\nexport interface DragEditTransform {\n type: 'edit-transform'\n zone: TransformZone\n /** The selected points, and the box around them as the press found it. */\n points: number[]\n box: Rect\n startX: number\n startY: number\n /** The path as the press found it; each move transforms from it. */\n origin: VectorNetwork\n}\n\nexport interface DragGuide {\n type: 'guide'\n axis: 'x' | 'y'\n ownerId: string\n position: number\n startScreenX: number\n startScreenY: number\n currentScreenX: number\n currentScreenY: number\n dragStarted: boolean\n duplicate?: boolean\n guideId?: string\n originalOwnerId?: string\n originalPosition?: number\n}\n\n/** Dragging a handle or stop of the gradient whose picker is open. */\nexport interface DragGradient {\n type: 'gradient'\n /** Moves the dragged handle or stop to a screen point. */\n update: (screenX: number, screenY: number, shiftKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\n/** Dragging a crop handle, an image corner, or the image itself in image edit mode. */\nexport interface DragImageCrop {\n type: 'image-crop'\n /** Applies the drag up to a screen point; Shift keeps proportions or an axis, Alt the centre. */\n update: (screenX: number, screenY: number, modifiers: { shift: boolean; alt: boolean }) => void\n commit: () => void\n cancel: () => void\n}\n\n/** A zoom tool press: a click zooms in or out on the pointer, a drag frames an area to zoom to. */\nexport interface DragZoom {\n type: 'zoom'\n /** Follows the pointer, in canvas and screen coordinates; ⌥ or Alt zooms out. */\n update: (cx: number, cy: number, sx: number, sy: number, altKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\n/**\n * A Scale tool handle drag: the selection scales with its contents from the opposite handle, or\n * from its center while ⌥ or Alt is held.\n */\nexport interface DragScale {\n type: 'scale'\n /** The resize cursor the drag keeps. */\n cursor: string\n update: (cx: number, cy: number, sx: number, sy: number, altKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\n/** Dragging a radius, point count, or ratio handle of the selected rectangle, polygon, or star. */\nexport interface DragShapeHandle {\n type: 'shape-handle'\n /** Sets the value under a screen point; Shift rounds a radius to tens. */\n update: (screenX: number, screenY: number, shiftKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\n/** Dragging a padding edge or an item gap of the selected auto layout frame. */\nexport interface DragAutoLayout {\n type: 'auto-layout'\n /** Sets the padding or gap so far; Alt edits the opposite side (with Shift, all sides), Shift the large nudge. */\n update: (screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) => void\n commit: () => void\n cancel: () => void\n}\n\nexport type DragState =\n | DragAutoLayout\n | DragShapeHandle\n | DragDraw\n | DragStickyDraw\n | DragConnectorDraw\n | DragConnectorEnd\n | DragConnectorLine\n | DragLineEnd\n | DragGradient\n | DragImageCrop\n | DragMove\n | DragPan\n | DragResize\n | DragStickyScale\n | DragZoom\n | DragScale\n | DragMarquee\n | DragRotate\n | DragPen\n | DragPencil\n | DragTextSelect\n | DragEditNode\n | DragEditHandle\n | DragEditMarquee\n | DragBendHandle\n | DragBendSegment\n | DragEditTransform\n | DragGuide\n\nexport const TOOL_TO_NODE: Partial<Record<Tool, NodeType>> = {\n FRAME: 'FRAME',\n SECTION: 'SECTION',\n RECTANGLE: 'RECTANGLE',\n ELLIPSE: 'ELLIPSE',\n LINE: 'LINE',\n POLYGON: 'POLYGON',\n STAR: 'STAR',\n TEXT: 'TEXT',\n SHAPE_WITH_TEXT: 'SHAPE_WITH_TEXT'\n}\n"],"mappings":";AA8YA,MAAa,eAAgD;CAC3D,OAAO;CACP,SAAS;CACT,WAAW;CACX,SAAS;CACT,MAAM;CACN,SAAS;CACT,MAAM;CACN,MAAM;CACN,iBAAiB;AACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pairdraw/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.2.0",
|
|
14
14
|
"@nanostores/i18n": "^1.3.3",
|
|
15
15
|
"@nanostores/vue": "^1.1.0",
|
|
16
|
-
"@pairdraw/dom-css": "^0.
|
|
17
|
-
"@pairdraw/scene-graph": "^0.
|
|
16
|
+
"@pairdraw/dom-css": "^0.20.0",
|
|
17
|
+
"@pairdraw/scene-graph": "^0.20.0",
|
|
18
18
|
"@vueuse/core": "^14.4.0",
|
|
19
19
|
"es-toolkit": "^1.52.0",
|
|
20
20
|
"fuse.js": "^7.5.0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"valibot": "^1.5.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@pairdraw/core": "^0.
|
|
27
|
+
"@pairdraw/core": "^0.20.0",
|
|
28
28
|
"canvaskit-wasm": ">=0.41.1",
|
|
29
29
|
"vue": "^3.5.41"
|
|
30
30
|
},
|
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"import": "./dist/canvas/drop/index.js",
|
|
45
45
|
"default": "./dist/canvas/drop/index.js"
|
|
46
46
|
},
|
|
47
|
+
"./canvas/eyedropper": {
|
|
48
|
+
"types": "./dist/canvas/eyedropper/index.d.ts",
|
|
49
|
+
"import": "./dist/canvas/eyedropper/index.js",
|
|
50
|
+
"default": "./dist/canvas/eyedropper/index.js"
|
|
51
|
+
},
|
|
47
52
|
"./canvas/labels": {
|
|
48
53
|
"types": "./dist/canvas/labels/index.d.ts",
|
|
49
54
|
"import": "./dist/canvas/labels/index.js",
|
|
@@ -174,6 +179,11 @@
|
|
|
174
179
|
"import": "./dist/controls/property-list/index.js",
|
|
175
180
|
"default": "./dist/controls/property-list/index.js"
|
|
176
181
|
},
|
|
182
|
+
"./controls/document-colors": {
|
|
183
|
+
"types": "./dist/controls/document-colors/index.d.ts",
|
|
184
|
+
"import": "./dist/controls/document-colors/index.js",
|
|
185
|
+
"default": "./dist/controls/document-colors/index.js"
|
|
186
|
+
},
|
|
177
187
|
"./controls/selection-colors": {
|
|
178
188
|
"types": "./dist/controls/selection-colors/index.d.ts",
|
|
179
189
|
"import": "./dist/controls/selection-colors/index.js",
|
|
@@ -414,6 +424,11 @@
|
|
|
414
424
|
"import": "./dist/shared/font-status/index.js",
|
|
415
425
|
"default": "./dist/shared/font-status/index.js"
|
|
416
426
|
},
|
|
427
|
+
"./shared/frame": {
|
|
428
|
+
"types": "./dist/shared/frame.d.ts",
|
|
429
|
+
"import": "./dist/shared/frame.js",
|
|
430
|
+
"default": "./dist/shared/frame.js"
|
|
431
|
+
},
|
|
417
432
|
"./shared/input": {
|
|
418
433
|
"types": "./dist/shared/input/index.d.ts",
|
|
419
434
|
"import": "./dist/shared/input/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-layout-hover.d.ts","names":[],"sources":["../../../src/shared/input/auto-layout-hover.ts"],"mappings":";;;;KAoKY;;;;;iBA0BI,sBACd,QAAQ,QACR,gBACA,OAAO,sBACP,eACC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-layout-hover.js","names":[],"sources":["../../../src/shared/input/auto-layout-hover.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport {\n AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE,\n AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE,\n AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE\n} from '@pairdraw/core/constants'\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { isGeneratedFrame } from '@pairdraw/scene-graph/generated'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\ntype AutoLayoutHover = NonNullable<Editor['state']['autoLayoutHover']>\n\nfunction visibleLayoutChildren(node: SceneNode, editor: Editor) {\n return node.childIds\n .map((id) => editor.graph.getNode(id))\n .filter(\n (child): child is SceneNode =>\n !!child && child.visible && child.layoutPositioning !== 'ABSOLUTE'\n )\n}\n\nfunction isNear(value: number, target: number, tolerance = AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE) {\n return Math.abs(value - target) <= tolerance\n}\n\nfunction resolvePaddingHover(\n node: SceneNode,\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n const centerX = node.width / 2\n const centerY = node.height / 2\n\n if (node.paddingTop > 0) {\n const tickY = node.paddingTop / 2\n if (isNear(localX, centerX) && isNear(localY, tickY)) {\n return { nodeId: node.id, kind: 'padding-value', side: 'top' }\n }\n if (localY <= Math.min(node.paddingTop, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) {\n return { nodeId: node.id, kind: 'padding', side: 'top' }\n }\n }\n\n if (node.paddingBottom > 0) {\n const tickY = node.height - node.paddingBottom / 2\n if (isNear(localX, centerX) && isNear(localY, tickY)) {\n return { nodeId: node.id, kind: 'padding-value', side: 'bottom' }\n }\n if (\n localY >=\n node.height - Math.min(node.paddingBottom, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)\n ) {\n return { nodeId: node.id, kind: 'padding', side: 'bottom' }\n }\n }\n\n if (node.paddingLeft > 0) {\n const tickX = node.paddingLeft / 2\n if (isNear(localX, tickX) && isNear(localY, centerY)) {\n return { nodeId: node.id, kind: 'padding-value', side: 'left' }\n }\n if (localX <= Math.min(node.paddingLeft, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) {\n return { nodeId: node.id, kind: 'padding', side: 'left' }\n }\n }\n\n if (node.paddingRight > 0) {\n const tickX = node.width - node.paddingRight / 2\n if (isNear(localX, tickX) && isNear(localY, centerY)) {\n return { nodeId: node.id, kind: 'padding-value', side: 'right' }\n }\n if (\n localX >=\n node.width - Math.min(node.paddingRight, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)\n ) {\n return { nodeId: node.id, kind: 'padding', side: 'right' }\n }\n }\n\n return null\n}\n\nfunction resolveSpacingHover(\n node: SceneNode,\n children: SceneNode[],\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n if (children.length < 2 || node.itemSpacing <= 0) return null\n const isRow = node.layoutMode === 'HORIZONTAL'\n const contentCrossStart = isRow ? node.paddingTop : node.paddingLeft\n const contentCrossEnd = isRow ? node.height - node.paddingBottom : node.width - node.paddingRight\n const cross = isRow ? localY : localX\n if (cross < contentCrossStart || cross > contentCrossEnd) return null\n\n for (let i = 0; i < children.length - 1; i++) {\n const prev = children[i]\n const next = children[i + 1]\n const gapStart = isRow ? prev.x + prev.width : prev.y + prev.height\n const gapEnd = isRow ? next.x : next.y\n if (gapEnd < gapStart) continue\n\n const cursor = isRow ? localX : localY\n const tickMain = (gapStart + gapEnd) / 2\n const tickCross = (contentCrossStart + contentCrossEnd) / 2\n if (isNear(cursor, tickMain) && isNear(cross, tickCross)) {\n return { nodeId: node.id, kind: 'spacing-value', index: i }\n }\n if (\n cursor >= gapStart - AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE &&\n cursor <= gapEnd + AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE\n ) {\n return { nodeId: node.id, kind: 'spacing', index: i }\n }\n }\n return null\n}\n\nfunction resolveChildrenHover(\n node: SceneNode,\n children: SceneNode[],\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n if (\n localX >= child.x &&\n localX <= child.x + child.width &&\n localY >= child.y &&\n localY <= child.y + child.height\n ) {\n return { nodeId: node.id, kind: 'children', index: i }\n }\n }\n return null\n}\n\nexport function resolveAutoLayoutHover(\n cx: number,\n cy: number,\n editor: Editor\n): AutoLayoutHover | null {\n if (editor.state.selectedIds.size !== 1) return null\n const nodeId = [...editor.state.selectedIds][0]\n const node = editor.graph.getNode(nodeId)\n if (!node || (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')) return null\n // A generated frame, such as a sticky note, lays itself out; its spacing is not the user's.\n if (isGeneratedFrame(node)) return null\n\n const abs = editor.graph.getAbsolutePosition(node.id)\n const localX = cx - abs.x\n const localY = cy - abs.y\n if (localX < 0 || localY < 0 || localX > node.width || localY > node.height) return null\n\n const children = visibleLayoutChildren(node, editor)\n return (\n resolveSpacingHover(node, children, localX, localY) ??\n resolvePaddingHover(node, localX, localY) ??\n resolveChildrenHover(node, children, localX, localY) ?? { nodeId: node.id, kind: 'frame' }\n )\n}\n\n/** An auto layout frame's value the canvas edits in place: a padding or the gap. */\nexport type AutoLayoutValueField =\n | 'paddingTop'\n | 'paddingRight'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'itemSpacing'\n\nconst PADDING_FIELDS = {\n top: 'paddingTop',\n right: 'paddingRight',\n bottom: 'paddingBottom',\n left: 'paddingLeft'\n} as const satisfies Record<NonNullable<AutoLayoutHover['side']>, AutoLayoutValueField>\n\n/** The value a hover over a padding or a gap edits, as Figma opens it on a double-click. */\nexport function autoLayoutValueField(hover: AutoLayoutHover): AutoLayoutValueField | null {\n if ((hover.kind === 'padding' || hover.kind === 'padding-value') && hover.side)\n return PADDING_FIELDS[hover.side]\n if (hover.kind === 'spacing' || hover.kind === 'spacing-value') return 'itemSpacing'\n return null\n}\n\n/**\n * Where the editor for a value sits, in canvas coordinates: the middle of the padding, or of\n * the gap a double-click opened, as the hover draws its tick.\n */\nexport function autoLayoutValueAnchor(\n editor: Editor,\n nodeId: string,\n field: AutoLayoutValueField,\n gap = 0\n): Vector | null {\n const node = editor.graph.getNode(nodeId)\n if (!node) return null\n const abs = editor.graph.getAbsolutePosition(node.id)\n const middle = { x: abs.x + node.width / 2, y: abs.y + node.height / 2 }\n if (field === 'paddingTop') return { x: middle.x, y: abs.y + node.paddingTop / 2 }\n if (field === 'paddingBottom')\n return { x: middle.x, y: abs.y + node.height - node.paddingBottom / 2 }\n if (field === 'paddingLeft') return { x: abs.x + node.paddingLeft / 2, y: middle.y }\n if (field === 'paddingRight')\n return { x: abs.x + node.width - node.paddingRight / 2, y: middle.y }\n const children = visibleLayoutChildren(node, editor)\n const prev = children.at(gap)\n const next = children.at(gap + 1)\n if (!prev || !next) return middle\n // Across the flow, the middle of the content box, where the hover draws the gap's tick.\n if (node.layoutMode === 'HORIZONTAL') {\n const y = abs.y + (node.paddingTop + node.height - node.paddingBottom) / 2\n return { x: abs.x + (prev.x + prev.width + next.x) / 2, y }\n }\n const x = abs.x + (node.paddingLeft + node.width - node.paddingRight) / 2\n return { x, y: abs.y + (prev.y + prev.height + next.y) / 2 }\n}\n"],"mappings":";;;AAYA,SAAS,sBAAsB,MAAiB,QAAgB;CAC9D,OAAO,KAAK,SACT,KAAK,OAAO,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,CACrC,QACE,UACC,CAAC,CAAC,SAAS,MAAM,WAAW,MAAM,sBAAsB,UAC5D;AACJ;AAEA,SAAS,OAAO,OAAe,QAAgB,YAAY,sCAAsC;CAC/F,OAAO,KAAK,IAAI,QAAQ,MAAM,KAAK;AACrC;AAEA,SAAS,oBACP,MACA,QACA,QACwB;CACxB,MAAM,UAAU,KAAK,QAAQ;CAC7B,MAAM,UAAU,KAAK,SAAS;CAE9B,IAAI,KAAK,aAAa,GAAG;EACvB,MAAM,QAAQ,KAAK,aAAa;EAChC,IAAI,OAAO,QAAQ,OAAO,KAAK,OAAO,QAAQ,KAAK,GACjD,OAAO;GAAE,QAAQ,KAAK;GAAI,MAAM;GAAiB,MAAM;EAAM;EAE/D,IAAI,UAAU,KAAK,IAAI,KAAK,YAAY,0CAA0C,GAChF,OAAO;GAAE,QAAQ,KAAK;GAAI,MAAM;GAAW,MAAM;EAAM;CAE3D;CAEA,IAAI,KAAK,gBAAgB,GAAG;EAC1B,MAAM,QAAQ,KAAK,SAAS,KAAK,gBAAgB;EACjD,IAAI,OAAO,QAAQ,OAAO,KAAK,OAAO,QAAQ,KAAK,GACjD,OAAO;GAAE,QAAQ,KAAK;GAAI,MAAM;GAAiB,MAAM;EAAS;EAElE,IACE,UACA,KAAK,SAAS,KAAK,IAAI,K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AO;CAE3B,IAAI,KAAK,eAAe,cAAc;EACpC,MAAM,IAAI,IAAI,KAAK,KAAK,aAAa,KAAK,SAAS,KAAK,iBAAiB;EACzE,OAAO;GAAE,GAAG,IAAI,KAAK,KAAK,IAAI,KAAK,QAAQ,KAAK,KAAK;GAAG;EAAE;CAC5D;CAEA,OAAO;EAAE,GADC,IAAI,KAAK,KAAK,cAAc,KAAK,QAAQ,KAAK,gBAAgB;EAC5D,GAAG,IAAI,KAAK,KAAK,IAAI,KAAK,SAAS,KAAK,KAAK;CAAE;AAC7D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-layout.js","names":[],"sources":["../../../src/shared/input/auto-layout.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport type { DragMove } from '#vue/shared/input/types'\n\nfunction resolveLayoutDirection(parent: SceneNode, editor: Editor): 'LTR' | 'RTL' {\n const ancestor = parent.parentId ? editor.graph.getNode(parent.parentId) : null\n const inheritedDirection = ancestor ? resolveLayoutDirection(ancestor, editor) : 'LTR'\n return resolveNodeLayoutDirection(parent, inheritedDirection)\n}\n\nfunction isRTLRow(parent: SceneNode, isRow: boolean, editor: Editor) {\n return isRow && resolveLayoutDirection(parent, editor) === 'RTL'\n}\n\nexport function computeIndicatorPosition(\n children: SceneNode[],\n insertIndex: number,\n parent: SceneNode,\n parentAbs: Vector,\n isRow: boolean,\n editor: Editor\n): number {\n const rtlRow = isRTLRow(parent, isRow, editor)\n\n if (children.length === 0) {\n if (isRow) {\n return rtlRow\n ? parentAbs.x + parent.width - parent.paddingRight\n : parentAbs.x + parent.paddingLeft\n }\n return parentAbs.y + parent.paddingTop\n }\n if (insertIndex === 0) {\n const firstAbs = editor.graph.getAbsolutePosition(children[0].id)\n if (isRow) {\n return rtlRow\n ? firstAbs.x + children[0].width + parent.itemSpacing / 2\n : firstAbs.x - parent.itemSpacing / 2\n }\n return firstAbs.y - parent.itemSpacing / 2\n }\n if (insertIndex >= children.length) {\n const last = children[children.length - 1]\n const lastAbs = editor.graph.getAbsolutePosition(last.id)\n if (isRow) {\n return rtlRow\n ? lastAbs.x - parent.itemSpacing / 2\n : lastAbs.x + last.width + parent.itemSpacing / 2\n }\n return lastAbs.y + last.height + parent.itemSpacing / 2\n }\n const prev = children[insertIndex - 1]\n const next = children[insertIndex]\n const prevAbs = editor.graph.getAbsolutePosition(prev.id)\n const nextAbs = editor.graph.getAbsolutePosition(next.id)\n if (isRow) {\n return rtlRow\n ? (prevAbs.x + nextAbs.x + next.width) / 2\n : (prevAbs.x + prev.width + nextAbs.x) / 2\n }\n return (prevAbs.y + prev.height + nextAbs.y) / 2\n}\n\nfunction filteredToRealIndex(\n parentId: string,\n insertIndex: number,\n editor: Editor,\n movingIds: ReadonlySet<string> = editor.state.selectedIds\n): number {\n const allChildren = editor.graph.getChildren(parentId)\n let realIndex = 0\n let filteredCount = 0\n for (const child of allChildren) {\n if (movingIds.has(child.id)) continue\n if (child.layoutPositioning === 'ABSOLUTE') {\n realIndex++\n continue\n }\n if (filteredCount === insertIndex) break\n filteredCount++\n realIndex++\n }\n return realIndex\n}\n\ninterface FlowLine {\n /** Index of the line's first child among the frame's flow children. */\n offset: number\n children: SceneNode[]\n crossStart: number\n crossEnd: number\n}\n\n/** Splits wrapped children into lines along the cross axis; one line when nothing wraps. */\nfunction flowLines(parent: SceneNode, children: SceneNode[], isRow: boolean, editor: Editor) {\n const lines: FlowLine[] = []\n for (const [index, child] of children.entries()) {\n const abs = editor.graph.getAbsolutePosition(child.id)\n const start = isRow ? abs.y : abs.x\n const end = start + (isRow ? child.height : child.width)\n const line = parent.layoutWrap === 'WRAP' ? lines.at(-1) : lines[0]\n if (line && (parent.layoutWrap !== 'WRAP' || start < line.crossEnd)) {\n line.children.push(child)\n line.crossStart = Math.min(line.crossStart, start)\n line.crossEnd = Math.max(line.crossEnd, end)\n } else {\n lines.push({ offset: index, children: [child], crossStart: start, crossEnd: end })\n }\n }\n return lines\n}\n\n/** The wrapped line under the cursor, or the nearest one. */\nfunction lineAt(lines: FlowLine[], cross: number): FlowLine | undefined {\n return lines.find((line, i) => {\n const next = lines.at(i + 1)\n return !next || cross < (line.crossEnd + next.crossStart) / 2\n })\n}\n\nfunction autoLayoutInsertion(\n parent: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n movingIds: ReadonlySet<string>\n) {\n const children = editor.graph\n .getChildren(parent.id)\n .filter((c) => c.layoutPositioning !== 'ABSOLUTE' && !movingIds.has(c.id))\n\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const rtlRow = isRTLRow(parent, isRow, editor)\n const line = lineAt(flowLines(parent, children, isRow, editor), isRow ? cy : cx)\n const lineChildren = line?.children ?? []\n\n let lineIndex = lineChildren.length\n for (let i = 0; i < lineChildren.length; i++) {\n const childAbs = editor.graph.getAbsolutePosition(lineChildren[i].id)\n const mid = isRow\n ? childAbs.x + lineChildren[i].width / 2\n : childAbs.y + lineChildren[i].height / 2\n const cursor = isRow ? cx : cy\n const shouldInsertBefore = rtlRow ? cursor > mid : cursor < mid\n if (shouldInsertBefore) {\n lineIndex = i\n break\n }\n }\n\n const insertIndex = (line?.offset ?? 0) + lineIndex\n const realIndex = filteredToRealIndex(parent.id, insertIndex, editor, movingIds)\n return { line, lineIndex, realIndex, isRow }\n}\n\n/** Where layers dropped at the cursor go among an auto layout frame's children. */\nexport function autoLayoutInsertIndex(\n parent: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n movingIds: ReadonlySet<string>\n) {\n return autoLayoutInsertion(parent, cx, cy, editor, movingIds).realIndex\n}\n\n/** Where the indicator spans across the flow: the whole frame, or the wrapped line it joins. */\nfunction indicatorCrossExtent(\n parent: SceneNode,\n parentAbs: Vector,\n isRow: boolean,\n line: FlowLine | undefined\n) {\n if (parent.layoutWrap === 'WRAP' && line) {\n return { crossStart: line.crossStart, crossLength: line.crossEnd - line.crossStart }\n }\n if (isRow) {\n return {\n crossStart: parentAbs.y + parent.paddingTop,\n crossLength: parent.height - parent.paddingTop - parent.paddingBottom\n }\n }\n return {\n crossStart: parentAbs.x + parent.paddingLeft,\n crossLength: parent.width - parent.paddingLeft - parent.paddingRight\n }\n}\n\nexport function computeAutoLayoutIndicatorForFrame(\n parent: SceneNode,\n cx: number,\n cy: number,\n editor: Editor,\n movingIds: ReadonlySet<string> = editor.state.selectedIds\n) {\n const { line, lineIndex, realIndex, isRow } = autoLayoutInsertion(\n parent,\n cx,\n cy,\n editor,\n movingIds\n )\n const parentAbs = editor.graph.getAbsolutePosition(parent.id)\n if (movingIds.size === 1) {\n const movingId = [...movingIds][0]\n const movingNode = editor.graph.getNode(movingId)\n const currentIndex = parent.childIds.indexOf(movingId)\n if (movingNode?.parentId === parent.id && realIndex === currentIndex) {\n editor.setLayoutInsertIndicator(null)\n return\n }\n }\n\n const indicatorPos = computeIndicatorPosition(\n line?.children ?? [],\n lineIndex,\n parent,\n parentAbs,\n isRow,\n editor\n )\n const { crossStart, crossLength } = indicatorCrossExtent(parent, parentAbs, isRow, line)\n\n editor.setLayoutInsertIndicator({\n parentId: parent.id,\n index: realIndex,\n x: isRow ? indicatorPos : crossStart,\n y: isRow ? crossStart : indicatorPos,\n length: crossLength,\n direction: isRow ? 'VERTICAL' : 'HORIZONTAL'\n })\n}\n\nexport function computeAutoLayoutIndicator(d: DragMove, cx: number, cy: number, editor: Editor) {\n if (!d.autoLayoutParentId) return\n const parent = editor.graph.getNode(d.autoLayoutParentId)\n if (!parent || parent.layoutMode === 'NONE') return\n computeAutoLayoutIndicatorForFrame(parent, cx, cy, editor, new Set(d.originals.keys()))\n}\n"],"mappings":";;AAOA,SAAS,uBAAuB,QAAmB,QAA+B;CAChF,MAAM,WAAW,OAAO,WAAW,OAAO,MAAM,QAAQ,OAAO,QAAQ,IAAI;CAC3E,MAAM,qBAAqB,WAAW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