@pairdraw/vue 0.19.2 → 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/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 +152 -10
- 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/node-props/use.d.ts +3 -3
- package/dist/controls/position/use.d.ts +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 +53 -2
- package/dist/i18n/locales/de/commands.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 +94 -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 +52 -1
- package/dist/i18n/locales/es/commands.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 +94 -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 +53 -2
- package/dist/i18n/locales/fr/commands.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 +94 -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 +53 -2
- package/dist/i18n/locales/it/commands.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 +94 -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 +53 -2
- package/dist/i18n/locales/ja/commands.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 +91 -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 +53 -2
- package/dist/i18n/locales/pl/commands.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 +95 -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 +53 -2
- package/dist/i18n/locales/ru/commands.json.js +3 -1
- package/dist/i18n/locales/ru/design-check.json.js +13 -1
- package/dist/i18n/locales/ru/design-memory.json.js +89 -0
- package/dist/i18n/locales/ru/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/ru/fonts.json.js +10 -0
- package/dist/i18n/locales/ru/index.js +5 -1
- package/dist/i18n/locales/ru/index.js.map +1 -1
- package/dist/i18n/locales/ru/menu.json.js +2 -0
- package/dist/i18n/locales/ru/panels.json.js +95 -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 +53 -2
- package/dist/i18n/locales/zh-cn/commands.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 +91 -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 +65 -2
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +53 -2
- package/dist/i18n/messages/ai.js.map +1 -1
- package/dist/i18n/messages/chat-usage.d.ts +34 -0
- package/dist/i18n/messages/chat-usage.d.ts.map +1 -0
- package/dist/i18n/messages/chat-usage.js +25 -0
- package/dist/i18n/messages/chat-usage.js.map +1 -0
- package/dist/i18n/messages/commands.d.ts +2 -0
- package/dist/i18n/messages/commands.d.ts.map +1 -1
- package/dist/i18n/messages/commands.js +2 -0
- package/dist/i18n/messages/commands.js.map +1 -1
- package/dist/i18n/messages/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 +114 -0
- package/dist/i18n/messages/panels.d.ts.map +1 -1
- package/dist/i18n/messages/panels.js +94 -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 +356 -3
- 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 +1193 -9
- 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 +1 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts +3 -0
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts.map +1 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js +3 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js.map +1 -1
- package/dist/shared/assets/cursors/eyedropper.svg.js +6 -0
- package/dist/shared/assets/cursors/eyedropper.svg.js.map +1 -0
- package/dist/shared/frame.d.ts +28 -0
- package/dist/shared/frame.d.ts.map +1 -0
- package/dist/shared/frame.js +92 -0
- package/dist/shared/frame.js.map +1 -0
- package/dist/shared/input/auto-layout/drag.js +71 -0
- package/dist/shared/input/auto-layout/drag.js.map +1 -0
- package/dist/shared/input/{auto-layout-hover.d.ts → auto-layout/hover.d.ts} +3 -3
- package/dist/shared/input/auto-layout/hover.d.ts.map +1 -0
- package/dist/shared/input/{auto-layout-hover.js → auto-layout/hover.js} +42 -86
- package/dist/shared/input/auto-layout/hover.js.map +1 -0
- package/dist/shared/input/{auto-layout.js → auto-layout/index.js} +2 -2
- package/dist/shared/input/auto-layout/index.js.map +1 -0
- package/dist/shared/input/index.d.ts +1 -1
- package/dist/shared/input/index.js +1 -1
- package/dist/shared/input/move/drag.js +1 -1
- package/dist/shared/input/resize.js +1 -1
- package/dist/shared/input/select.js +5 -3
- package/dist/shared/input/select.js.map +1 -1
- package/dist/shared/input/types.d.ts +10 -2
- package/dist/shared/input/types.d.ts.map +1 -1
- package/dist/shared/input/types.js.map +1 -1
- package/package.json +19 -4
- package/dist/shared/input/auto-layout-hover.d.ts.map +0 -1
- package/dist/shared/input/auto-layout-hover.js.map +0 -1
- package/dist/shared/input/auto-layout.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MixedValue } from "../../controls/node-props/helpers.js";
|
|
2
|
+
import { TypographyFeature } from "../../controls/typography/features.js";
|
|
2
3
|
import { TypographyAxis } from "../../controls/typography/axes.js";
|
|
3
4
|
import { TypographyFontLoader } from "../../controls/typography/use.js";
|
|
4
5
|
import { AcceptableValue } from "reka-ui";
|
|
@@ -25,6 +26,8 @@ declare var __VLS_1: {
|
|
|
25
26
|
listType: import("vue").ComputedRef<import("@pairdraw/scene-graph").TextListType | null>;
|
|
26
27
|
axes: import("vue").ComputedRef<TypographyAxis[]>;
|
|
27
28
|
opticalSizeAuto: import("vue").ComputedRef<MixedValue<boolean>>;
|
|
29
|
+
availableFeatures: import("vue").ComputedRef<TypographyFeature[]>;
|
|
30
|
+
featureState: (tag: string) => MixedValue<boolean>;
|
|
28
31
|
actions: {
|
|
29
32
|
setFamily: (family: string) => Promise<void>;
|
|
30
33
|
setWeight: (weight: number, targets?: import("@pairdraw/scene-graph").SceneNode[]) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypographyControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypographyControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"mappings":";;;;;;KA4EK;EACH,aAAa;;iBAON,cAAc,KAAK;iBAInB,mBAAmB,KAAK,kBAAkB;YAoE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,gBAAA,2CAAA,qCAAA,iDAAA,aAAA,SAAA,eAAA,oDAAA;cAGV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -20,7 +20,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
20
20
|
setVerticalAlign: ctx.setVerticalAlign,
|
|
21
21
|
setTextCase: ctx.setTextCase,
|
|
22
22
|
setTruncation: ctx.setTruncation,
|
|
23
|
-
setFontFeature: ctx.
|
|
23
|
+
setFontFeature: ctx.features.set,
|
|
24
24
|
setListType: ctx.setListType,
|
|
25
25
|
setHangingList: ctx.setHangingList,
|
|
26
26
|
previewParagraphSpacing: ctx.previewParagraphSpacing,
|
|
@@ -53,6 +53,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
53
53
|
listType: unref(ctx).listType,
|
|
54
54
|
axes: unref(ctx).axes,
|
|
55
55
|
opticalSizeAuto: unref(ctx).opticalSizeAuto,
|
|
56
|
+
availableFeatures: unref(ctx).features.available,
|
|
57
|
+
featureState: unref(ctx).features.state,
|
|
56
58
|
actions
|
|
57
59
|
});
|
|
58
60
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypographyControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { AcceptableValue } from 'reka-ui'\n\nimport { useTypography } from '#vue/controls/typography/use'\nimport type { TypographyFontLoader } from '#vue/controls/typography/use'\n\nconst { fontLoader } = defineProps<{\n fontLoader?: TypographyFontLoader\n}>()\n\nconst ctx = useTypography({ fontLoader })\n\nfunction onAlignChange(val: AcceptableValue) {\n if (val) ctx.setAlign(val as 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED')\n}\n\nfunction onFormattingChange(val: AcceptableValue | AcceptableValue[]) {\n if (Array.isArray(val)) ctx.onFormattingChange(val as string[])\n}\n\nconst actions = {\n setFamily: ctx.setFamily,\n setWeight: ctx.setWeight,\n setFace: ctx.setFace,\n setDirection: ctx.setDirection,\n setVerticalAlign: ctx.setVerticalAlign,\n setTextCase: ctx.setTextCase,\n setTruncation: ctx.setTruncation,\n setFontFeature: ctx.
|
|
1
|
+
{"version":3,"file":"TypographyControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { AcceptableValue } from 'reka-ui'\n\nimport { useTypography } from '#vue/controls/typography/use'\nimport type { TypographyFontLoader } from '#vue/controls/typography/use'\n\nconst { fontLoader } = defineProps<{\n fontLoader?: TypographyFontLoader\n}>()\n\nconst ctx = useTypography({ fontLoader })\n\nfunction onAlignChange(val: AcceptableValue) {\n if (val) ctx.setAlign(val as 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED')\n}\n\nfunction onFormattingChange(val: AcceptableValue | AcceptableValue[]) {\n if (Array.isArray(val)) ctx.onFormattingChange(val as string[])\n}\n\nconst actions = {\n setFamily: ctx.setFamily,\n setWeight: ctx.setWeight,\n setFace: ctx.setFace,\n setDirection: ctx.setDirection,\n setVerticalAlign: ctx.setVerticalAlign,\n setTextCase: ctx.setTextCase,\n setTruncation: ctx.setTruncation,\n setFontFeature: ctx.features.set,\n setListType: ctx.setListType,\n setHangingList: ctx.setHangingList,\n previewParagraphSpacing: ctx.previewParagraphSpacing,\n setParagraphSpacing: ctx.setParagraphSpacing,\n updateProp: ctx.updateProp,\n commitProp: ctx.commitProp,\n cancelProp: ctx.cancelProp,\n align: onAlignChange,\n formatting: onFormattingChange,\n toggleBold: ctx.toggleBold,\n toggleItalic: ctx.toggleItalic,\n toggleDecoration: ctx.toggleDecoration,\n previewAxis: ctx.previewAxis,\n cancelAxis: ctx.cancelAxis,\n setAxis: ctx.setAxis,\n setOpticalSizeAuto: ctx.setOpticalSizeAuto\n}\n</script>\n\n<template>\n <slot\n :node=\"ctx.node\"\n :nodes=\"ctx.nodes\"\n :merged=\"ctx.merged\"\n :paragraph-spacing=\"ctx.paragraphSpacing\"\n :font-feature=\"ctx.fontFeature\"\n :faces=\"ctx.faces\"\n :face-name=\"ctx.faceName\"\n :missing-fonts=\"ctx.missingFonts\"\n :has-missing-fonts=\"ctx.hasMissingFonts\"\n :active-formatting=\"ctx.activeFormatting\"\n :list-type=\"ctx.listType\"\n :axes=\"ctx.axes\"\n :optical-size-auto=\"ctx.opticalSizeAuto\"\n :available-features=\"ctx.features.available\"\n :feature-state=\"ctx.features.state\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;EAUA,MAAM,MAAM,cAAc,EAAE,YAAS,QAAA,WAAE,CAAC;EAExC,SAAS,cAAc,KAAsB;GAC3C,IAAI,KAAK,IAAI,SAAS,GAAgD;EACxE;EAEA,SAAS,mBAAmB,KAA0C;GACpE,IAAI,MAAM,QAAQ,GAAG,GAAG,IAAI,mBAAmB,GAAe;EAChE;EAEA,MAAM,UAAU;GACd,WAAW,IAAI;GACf,WAAW,IAAI;GACf,SAAS,IAAI;GACb,cAAc,IAAI;GAClB,kBAAkB,IAAI;GACtB,aAAa,IAAI;GACjB,eAAe,IAAI;GACnB,gBAAgB,IAAI,SAAS;GAC7B,aAAa,IAAI;GACjB,gBAAgB,IAAI;GACpB,yBAAyB,IAAI;GAC7B,qBAAqB,IAAI;GACzB,YAAY,IAAI;GAChB,YAAY,IAAI;GAChB,YAAY,IAAI;GAChB,OAAO;GACP,YAAY;GACZ,YAAY,IAAI;GAChB,cAAc,IAAI;GAClB,kBAAkB,IAAI;GACtB,aAAa,IAAI;GACjB,YAAY,IAAI;GAChB,SAAS,IAAI;GACb,oBAAoB,IAAI;EAC1B;;GAIE,OAAA,WAiBE,KAAA,QAAA,WAAA;IAhBC,MAAM,MAAA,GAAA,CAAG,CAAC;IACV,OAAO,MAAA,GAAA,CAAG,CAAC;IACX,QAAQ,MAAA,GAAA,CAAG,CAAC;IACZ,kBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,aAAc,MAAA,GAAA,CAAG,CAAC;IAClB,OAAO,MAAA,GAAA,CAAG,CAAC;IACX,UAAW,MAAA,GAAA,CAAG,CAAC;IACf,cAAe,MAAA,GAAA,CAAG,CAAC;IACnB,iBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,kBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,UAAW,MAAA,GAAA,CAAG,CAAC;IACf,MAAM,MAAA,GAAA,CAAG,CAAC;IACV,iBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,mBAAoB,MAAA,GAAA,CAAG,CAAC,SAAS;IACjC,cAAe,MAAA,GAAA,CAAG,CAAC,SAAS;IACnB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/shared/assets/cursors/eyedropper.svg?raw
|
|
2
|
+
var eyedropper_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\">\n <filter id=\"shadow\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feDropShadow dx=\"0\" dy=\"1.25\" stdDeviation=\"1\" flood-opacity=\"0.5\"/>\n </filter>\n <g filter=\"url(#shadow)\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <g transform=\"translate(2.16 2.16) scale(0.8)\">\n <g fill=\"#fff\" stroke=\"#fff\" stroke-width=\"3.75\">\n <path d=\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\"/>\n <path d=\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z\"/>\n </g>\n <g fill=\"none\" stroke=\"#000\" stroke-width=\"1.25\">\n <path d=\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\"/>\n <path d=\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3zM2 22l.414-.414\"/>\n </g>\n </g>\n </g>\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { eyedropper_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=eyedropper.svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eyedropper.svg.js","names":[],"sources":["../../../../src/shared/assets/cursors/eyedropper.svg?raw"],"sourcesContent":["export default \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"32\\\" height=\\\"32\\\" viewBox=\\\"0 0 32 32\\\">\\n <filter id=\\\"shadow\\\" x=\\\"-50%\\\" y=\\\"-50%\\\" width=\\\"200%\\\" height=\\\"200%\\\">\\n <feDropShadow dx=\\\"0\\\" dy=\\\"1.25\\\" stdDeviation=\\\"1\\\" flood-opacity=\\\"0.5\\\"/>\\n </filter>\\n <g filter=\\\"url(#shadow)\\\" stroke-linecap=\\\"round\\\" stroke-linejoin=\\\"round\\\">\\n <g transform=\\\"translate(2.16 2.16) scale(0.8)\\\">\\n <g fill=\\\"#fff\\\" stroke=\\\"#fff\\\" stroke-width=\\\"3.75\\\">\\n <path d=\\\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\\\"/>\\n <path d=\\\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z\\\"/>\\n </g>\\n <g fill=\\\"none\\\" stroke=\\\"#000\\\" stroke-width=\\\"1.25\\\">\\n <path d=\\\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\\\"/>\\n <path d=\\\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3zM2 22l.414-.414\\\"/>\\n </g>\\n </g>\\n </g>\\n</svg>\\n\""],"mappings":";AAAA,IAAA,qBAAe"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
//#region src/shared/frame.d.ts
|
|
3
|
+
type Visibility = Readonly<Ref<DocumentVisibilityState>>;
|
|
4
|
+
interface NextFrameOptions {
|
|
5
|
+
/** Whether the browser shows the page; the document's own by default. */
|
|
6
|
+
visibility?: Visibility;
|
|
7
|
+
}
|
|
8
|
+
interface NextShownFrameOptions extends NextFrameOptions {
|
|
9
|
+
/** Stops waiting, rejecting with the signal's reason, when the work it is for is cancelled. */
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Lets the page lay out and draw before going on: resolves on the next animation frame. A
|
|
14
|
+
* hidden tab draws no frames and shows nothing, so work started in a background tab, such as
|
|
15
|
+
* opening a file or starting the canvas, goes on at once rather than waiting until the tab is
|
|
16
|
+
* shown again, and a tab hidden while waiting stops waiting.
|
|
17
|
+
*/
|
|
18
|
+
declare function nextFrame(options?: NextFrameOptions): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Waits for a frame drawn while the page is shown, by which the canvas has reported its size:
|
|
21
|
+
* a hidden tab reports none. Placing the view, such as fitting a page, waits for this so it
|
|
22
|
+
* uses the canvas's own size, while work before it goes on in a background tab. A tab hidden
|
|
23
|
+
* before its frame waits to be shown again.
|
|
24
|
+
*/
|
|
25
|
+
declare function nextShownFrame(options?: NextShownFrameOptions): Promise<void>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { NextFrameOptions, NextShownFrameOptions, nextFrame, nextShownFrame };
|
|
28
|
+
//# sourceMappingURL=frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.d.ts","names":[],"sources":["../../src/shared/frame.ts"],"mappings":";;KAMK,aAAa,SAAS,IAAI;UAEd;;EAEf,aAAa;;UAGE,8BAA8B;;EAE7C,SAAS;;;;;;;;iBAsEW,UAAU,UAAS,mBAAwB;;;;;;;iBAY3C,eAAe,UAAS,wBAA6B"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
import { useDocumentVisibility } from "@vueuse/core";
|
|
3
|
+
//#region src/shared/frame.ts
|
|
4
|
+
/** Whether the browser shows the page; shared by every wait. */
|
|
5
|
+
const documentVisibility = useDocumentVisibility();
|
|
6
|
+
function abortReason(signal) {
|
|
7
|
+
return signal.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError");
|
|
8
|
+
}
|
|
9
|
+
/** True once a frame runs while the page is shown; false if the page is hidden first. */
|
|
10
|
+
function frameWhileShown(visibility, signal) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
if (signal?.aborted) {
|
|
13
|
+
reject(abortReason(signal));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let frame = 0;
|
|
17
|
+
const stop = watch(visibility, (state) => {
|
|
18
|
+
if (state === "hidden") finish(false);
|
|
19
|
+
});
|
|
20
|
+
const abort = () => {
|
|
21
|
+
cleanup();
|
|
22
|
+
if (signal) reject(abortReason(signal));
|
|
23
|
+
};
|
|
24
|
+
function cleanup() {
|
|
25
|
+
if (frame !== 0 && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame);
|
|
26
|
+
stop();
|
|
27
|
+
signal?.removeEventListener("abort", abort);
|
|
28
|
+
}
|
|
29
|
+
function finish(drawn) {
|
|
30
|
+
cleanup();
|
|
31
|
+
resolve(drawn);
|
|
32
|
+
}
|
|
33
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
34
|
+
frame = requestAnimationFrame(() => finish(true));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** Resolves once the page is shown. */
|
|
38
|
+
function shown(visibility, signal) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
if (signal?.aborted) {
|
|
41
|
+
reject(abortReason(signal));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (visibility.value !== "hidden") {
|
|
45
|
+
resolve(void 0);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const stop = watch(visibility, (state) => {
|
|
49
|
+
if (state === "hidden") return;
|
|
50
|
+
cleanup();
|
|
51
|
+
resolve(void 0);
|
|
52
|
+
});
|
|
53
|
+
const abort = () => {
|
|
54
|
+
cleanup();
|
|
55
|
+
if (signal) reject(abortReason(signal));
|
|
56
|
+
};
|
|
57
|
+
function cleanup() {
|
|
58
|
+
stop();
|
|
59
|
+
signal?.removeEventListener("abort", abort);
|
|
60
|
+
}
|
|
61
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Lets the page lay out and draw before going on: resolves on the next animation frame. A
|
|
66
|
+
* hidden tab draws no frames and shows nothing, so work started in a background tab, such as
|
|
67
|
+
* opening a file or starting the canvas, goes on at once rather than waiting until the tab is
|
|
68
|
+
* shown again, and a tab hidden while waiting stops waiting.
|
|
69
|
+
*/
|
|
70
|
+
async function nextFrame(options = {}) {
|
|
71
|
+
const visibility = options.visibility ?? documentVisibility;
|
|
72
|
+
if (visibility.value === "hidden") return;
|
|
73
|
+
await frameWhileShown(visibility);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Waits for a frame drawn while the page is shown, by which the canvas has reported its size:
|
|
77
|
+
* a hidden tab reports none. Placing the view, such as fitting a page, waits for this so it
|
|
78
|
+
* uses the canvas's own size, while work before it goes on in a background tab. A tab hidden
|
|
79
|
+
* before its frame waits to be shown again.
|
|
80
|
+
*/
|
|
81
|
+
async function nextShownFrame(options = {}) {
|
|
82
|
+
const visibility = options.visibility ?? documentVisibility;
|
|
83
|
+
const { signal } = options;
|
|
84
|
+
for (;;) {
|
|
85
|
+
await shown(visibility, signal);
|
|
86
|
+
if (await frameWhileShown(visibility, signal)) return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { nextFrame, nextShownFrame };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.js","names":[],"sources":["../../src/shared/frame.ts"],"sourcesContent":["import { useDocumentVisibility } from '@vueuse/core'\nimport { watch, type Ref } from 'vue'\n\n/** Whether the browser shows the page; shared by every wait. */\nconst documentVisibility = useDocumentVisibility()\n\ntype Visibility = Readonly<Ref<DocumentVisibilityState>>\n\nexport interface NextFrameOptions {\n /** Whether the browser shows the page; the document's own by default. */\n visibility?: Visibility\n}\n\nexport interface NextShownFrameOptions extends NextFrameOptions {\n /** Stops waiting, rejecting with the signal's reason, when the work it is for is cancelled. */\n signal?: AbortSignal\n}\n\nfunction abortReason(signal: AbortSignal): Error {\n return signal.reason instanceof Error ? signal.reason : new DOMException('Aborted', 'AbortError')\n}\n\n/** True once a frame runs while the page is shown; false if the page is hidden first. */\nfunction frameWhileShown(visibility: Visibility, signal?: AbortSignal): Promise<boolean> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(abortReason(signal))\n return\n }\n let frame = 0\n const stop = watch(visibility, (state) => {\n if (state === 'hidden') finish(false)\n })\n const abort = () => {\n cleanup()\n if (signal) reject(abortReason(signal))\n }\n function cleanup() {\n if (frame !== 0 && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame)\n stop()\n signal?.removeEventListener('abort', abort)\n }\n function finish(drawn: boolean) {\n cleanup()\n resolve(drawn)\n }\n signal?.addEventListener('abort', abort, { once: true })\n frame = requestAnimationFrame(() => finish(true))\n })\n}\n\n/** Resolves once the page is shown. */\nfunction shown(visibility: Visibility, signal?: AbortSignal): Promise<undefined> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(abortReason(signal))\n return\n }\n if (visibility.value !== 'hidden') {\n resolve(undefined)\n return\n }\n const stop = watch(visibility, (state) => {\n if (state === 'hidden') return\n cleanup()\n resolve(undefined)\n })\n const abort = () => {\n cleanup()\n if (signal) reject(abortReason(signal))\n }\n function cleanup() {\n stop()\n signal?.removeEventListener('abort', abort)\n }\n signal?.addEventListener('abort', abort, { once: true })\n })\n}\n\n/**\n * Lets the page lay out and draw before going on: resolves on the next animation frame. A\n * hidden tab draws no frames and shows nothing, so work started in a background tab, such as\n * opening a file or starting the canvas, goes on at once rather than waiting until the tab is\n * shown again, and a tab hidden while waiting stops waiting.\n */\nexport async function nextFrame(options: NextFrameOptions = {}): Promise<void> {\n const visibility = options.visibility ?? documentVisibility\n if (visibility.value === 'hidden') return\n await frameWhileShown(visibility)\n}\n\n/**\n * Waits for a frame drawn while the page is shown, by which the canvas has reported its size:\n * a hidden tab reports none. Placing the view, such as fitting a page, waits for this so it\n * uses the canvas's own size, while work before it goes on in a background tab. A tab hidden\n * before its frame waits to be shown again.\n */\nexport async function nextShownFrame(options: NextShownFrameOptions = {}): Promise<void> {\n const visibility = options.visibility ?? documentVisibility\n const { signal } = options\n for (;;) {\n await shown(visibility, signal)\n if (await frameWhileShown(visibility, signal)) return\n }\n}\n"],"mappings":";;;;AAIA,MAAM,qBAAqB,sBAAsB;AAcjD,SAAS,YAAY,QAA4B;CAC/C,OAAO,OAAO,kBAAkB,QAAQ,OAAO,SAAS,IAAI,aAAa,WAAW,YAAY;AAClG;;AAGA,SAAS,gBAAgB,YAAwB,QAAwC;CACvF,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI,QAAQ,SAAS;GACnB,OAAO,YAAY,MAAM,CAAC;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,QAAQ,cAAc;CACzC,MAAM,EAAE,WAAW;CACnB,SAAS;EACP,MAAM,MAAM,YAAY,MAAM;EAC9B,IAAI,MAAM,gBAAgB,YAAY,MAAM,GAAG;CACjD;AACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isPastPointerDragThreshold } from "../drag-threshold.js";
|
|
2
|
+
import { autoLayoutDragChanges, hitAutoLayoutHandle, measureAutoLayoutHandles } from "@pairdraw/core/layout";
|
|
3
|
+
import { isGeneratedFrame } from "@pairdraw/scene-graph/generated";
|
|
4
|
+
//#region src/shared/input/auto-layout/drag.ts
|
|
5
|
+
const HANDLE_DRAG_THRESHOLD_PX = 5;
|
|
6
|
+
function visibleChildren(editor, node) {
|
|
7
|
+
return node.childIds.map((id) => editor.graph.getNode(id)).filter((child) => !!child);
|
|
8
|
+
}
|
|
9
|
+
/** The hover state that keeps the pink zone and its value pill on while a handle is dragged. */
|
|
10
|
+
function dragHover(node, hit) {
|
|
11
|
+
if (hit.kind === "padding") return {
|
|
12
|
+
nodeId: node.id,
|
|
13
|
+
kind: "padding-value",
|
|
14
|
+
side: hit.side
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
nodeId: node.id,
|
|
18
|
+
kind: "spacing-value",
|
|
19
|
+
axis: hit.axis,
|
|
20
|
+
index: hit.index
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Starts dragging a padding edge or an item gap of the selected auto layout frame. Alt edits the
|
|
25
|
+
* opposite side on the dragged axis (with Shift, every side); Shift moves padding or spacing by
|
|
26
|
+
* the large nudge; the drag previews on the frame and commits as one undo step.
|
|
27
|
+
*/
|
|
28
|
+
function tryStartAutoLayoutHandleDrag(editor, cx, cy, sx, sy, setDrag, bigNudge = 10) {
|
|
29
|
+
if (editor.state.selectedIds.size !== 1) return false;
|
|
30
|
+
const nodeId = [...editor.state.selectedIds][0];
|
|
31
|
+
const node = editor.graph.getNode(nodeId);
|
|
32
|
+
if (!node || isGeneratedFrame(node) || node.layoutMode !== "HORIZONTAL" && node.layoutMode !== "VERTICAL") return false;
|
|
33
|
+
const layout = measureAutoLayoutHandles(node, visibleChildren(editor, node));
|
|
34
|
+
if (!layout?.editable) return false;
|
|
35
|
+
const abs = editor.graph.getAbsolutePosition(node.id);
|
|
36
|
+
const hit = hitAutoLayoutHandle(layout, cx - abs.x, cy - abs.y);
|
|
37
|
+
if (!hit) return false;
|
|
38
|
+
const handleLayout = layout;
|
|
39
|
+
const handleHit = hit;
|
|
40
|
+
const target = node;
|
|
41
|
+
const preview = editor.beginNodePreview("Adjust auto layout");
|
|
42
|
+
let moved = false;
|
|
43
|
+
function update(screenX, screenY, altKey, shiftKey) {
|
|
44
|
+
moved ||= isPastPointerDragThreshold(sx, sy, screenX, screenY, HANDLE_DRAG_THRESHOLD_PX);
|
|
45
|
+
if (!moved || preview.closed) return;
|
|
46
|
+
if (!editor.graph.getNode(target.id)) return;
|
|
47
|
+
const next = autoLayoutDragChanges(handleLayout, handleHit, {
|
|
48
|
+
dx: screenX - sx,
|
|
49
|
+
dy: screenY - sy,
|
|
50
|
+
zoom: editor.state.zoom,
|
|
51
|
+
alt: altKey,
|
|
52
|
+
shift: shiftKey,
|
|
53
|
+
bigNudge
|
|
54
|
+
});
|
|
55
|
+
preview.update(target.id, next.changes);
|
|
56
|
+
editor.setAutoLayoutHover(dragHover(target, handleHit));
|
|
57
|
+
}
|
|
58
|
+
const drag = {
|
|
59
|
+
type: "auto-layout",
|
|
60
|
+
update,
|
|
61
|
+
commit: () => preview.commit(),
|
|
62
|
+
cancel: () => preview.cancel()
|
|
63
|
+
};
|
|
64
|
+
editor.setAutoLayoutHover(dragHover(target, handleHit));
|
|
65
|
+
setDrag(drag);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { tryStartAutoLayoutHandleDrag };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=drag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag.js","names":[],"sources":["../../../../src/shared/input/auto-layout/drag.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport {\n autoLayoutDragChanges,\n hitAutoLayoutHandle,\n measureAutoLayoutHandles,\n type AutoLayoutHandleHit,\n type AutoLayoutHandleLayout\n} from '@pairdraw/core/layout'\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { isGeneratedFrame } from '@pairdraw/scene-graph/generated'\n\nimport { isPastPointerDragThreshold } from '#vue/shared/input/drag-threshold'\nimport type { DragAutoLayout, DragState } from '#vue/shared/input/types'\n\nconst HANDLE_DRAG_THRESHOLD_PX = 5\n\nfunction visibleChildren(editor: Editor, node: SceneNode): SceneNode[] {\n return node.childIds\n .map((id) => editor.graph.getNode(id))\n .filter((child): child is SceneNode => !!child)\n}\n\n/** The hover state that keeps the pink zone and its value pill on while a handle is dragged. */\nfunction dragHover(node: SceneNode, hit: AutoLayoutHandleHit) {\n if (hit.kind === 'padding') {\n return { nodeId: node.id, kind: 'padding-value' as const, side: hit.side }\n }\n return {\n nodeId: node.id,\n kind: 'spacing-value' as const,\n axis: hit.axis,\n index: hit.index\n }\n}\n\n/**\n * Starts dragging a padding edge or an item gap of the selected auto layout frame. Alt edits the\n * opposite side on the dragged axis (with Shift, every side); Shift moves padding or spacing by\n * the large nudge; the drag previews on the frame and commits as one undo step.\n */\nexport function tryStartAutoLayoutHandleDrag(\n editor: Editor,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n setDrag: (drag: DragState) => void,\n bigNudge = 10\n): boolean {\n if (editor.state.selectedIds.size !== 1) return false\n const nodeId = [...editor.state.selectedIds][0]\n const node = editor.graph.getNode(nodeId)\n if (\n !node ||\n isGeneratedFrame(node) ||\n (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')\n )\n return false\n const layout = measureAutoLayoutHandles(node, visibleChildren(editor, node))\n if (!layout?.editable) return false\n const abs = editor.graph.getAbsolutePosition(node.id)\n const hit = hitAutoLayoutHandle(layout, cx - abs.x, cy - abs.y)\n if (!hit) return false\n\n const handleLayout: AutoLayoutHandleLayout = layout\n const handleHit: AutoLayoutHandleHit = hit\n const target = node\n const preview = editor.beginNodePreview('Adjust auto layout')\n let moved = false\n\n function update(screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) {\n moved ||= isPastPointerDragThreshold(sx, sy, screenX, screenY, HANDLE_DRAG_THRESHOLD_PX)\n if (!moved || preview.closed) return\n const current = editor.graph.getNode(target.id)\n if (!current) return\n const next = autoLayoutDragChanges(handleLayout, handleHit, {\n dx: screenX - sx,\n dy: screenY - sy,\n zoom: editor.state.zoom,\n alt: altKey,\n shift: shiftKey,\n bigNudge\n })\n preview.update(target.id, next.changes)\n editor.setAutoLayoutHover(dragHover(target, handleHit))\n }\n\n const drag: DragAutoLayout = {\n type: 'auto-layout',\n update,\n commit: () => preview.commit(),\n cancel: () => preview.cancel()\n }\n editor.setAutoLayoutHover(dragHover(target, handleHit))\n setDrag(drag)\n return true\n}\n"],"mappings":";;;;AAcA,MAAM,2BAA2B;AAEjC,SAAS,gBAAgB,QAAgB,MAA8B;CACrE,OAAO,KAAK,SACT,KAAK,OAAO,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,CACrC,QAAQ,UAA8B,CAAC,CAAC,KAAK;AAClD;;AAGA,SAAS,UAAU,MAAiB,KAA0B;CAC5D,IAAI,IAAI,SAAS,WACf,OAAO;EAAE,QAAQ,KAAK;EAAI,MAAM;EAA0B,MAAM,IAAI;CAAK;CAE3E,OAAO;EACL,QAAQ,KAAK;EACb,MAAM;EACN,MAAM,IAAI;EACV,OAAO,IAAI;CACb;AACF;;;;;;AAOA,SAAgB,6BACd,QACA,IACA,IACA,IACA,IACA,SACA,WAAW,IACF;CACT,IAAI,OAAO,MAAM,YAAY,SAAS,GAAG,OAAO;CAChD,MAAM,SAAS,CAAC,GAAG,OAAO,MAAM,WAAW,CAAC,CAAC;CAC7C,MAAM,OAAO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//#region src/shared/input/auto-layout/hover.d.ts
|
|
4
4
|
/** An auto layout frame's value the canvas edits in place: a padding or the gap. */
|
|
5
|
-
type AutoLayoutValueField = 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'itemSpacing';
|
|
5
|
+
type AutoLayoutValueField = 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'itemSpacing' | 'counterAxisSpacing';
|
|
6
6
|
/**
|
|
7
7
|
* Where the editor for a value sits, in canvas coordinates: the middle of the padding, or of
|
|
8
8
|
* the gap a double-click opened, as the hover draws its tick.
|
|
@@ -10,4 +10,4 @@ type AutoLayoutValueField = 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'p
|
|
|
10
10
|
declare function autoLayoutValueAnchor(editor: Editor, nodeId: string, field: AutoLayoutValueField, gap?: number): Vector | null;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { AutoLayoutValueField, autoLayoutValueAnchor };
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=hover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover.d.ts","names":[],"sources":["../../../../src/shared/input/auto-layout/hover.ts"],"mappings":";;;;KA6GY;;;;;iBA4BI,sBACd,QAAQ,QACR,gBACA,OAAO,sBACP,eACC"}
|
|
@@ -1,95 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE } from "@pairdraw/core/constants";
|
|
2
|
+
import { hitAutoLayoutHandle, measureAutoLayoutHandles } from "@pairdraw/core/layout";
|
|
2
3
|
import { isGeneratedFrame } from "@pairdraw/scene-graph/generated";
|
|
3
|
-
//#region src/shared/input/auto-layout
|
|
4
|
+
//#region src/shared/input/auto-layout/hover.ts
|
|
4
5
|
function visibleLayoutChildren(node, editor) {
|
|
5
6
|
return node.childIds.map((id) => editor.graph.getNode(id)).filter((child) => !!child && child.visible && child.layoutPositioning !== "ABSOLUTE");
|
|
6
7
|
}
|
|
7
8
|
function isNear(value, target, tolerance = AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE) {
|
|
8
9
|
return Math.abs(value - target) <= tolerance;
|
|
9
10
|
}
|
|
10
|
-
function resolvePaddingHover(node, localX, localY) {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
if (node.paddingBottom > 0) {
|
|
27
|
-
const tickY = node.height - node.paddingBottom / 2;
|
|
28
|
-
if (isNear(localX, centerX) && isNear(localY, tickY)) return {
|
|
29
|
-
nodeId: node.id,
|
|
30
|
-
kind: "padding-value",
|
|
31
|
-
side: "bottom"
|
|
32
|
-
};
|
|
33
|
-
if (localY >= node.height - Math.min(node.paddingBottom, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) return {
|
|
34
|
-
nodeId: node.id,
|
|
35
|
-
kind: "padding",
|
|
36
|
-
side: "bottom"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (node.paddingLeft > 0) {
|
|
40
|
-
if (isNear(localX, node.paddingLeft / 2) && isNear(localY, centerY)) return {
|
|
41
|
-
nodeId: node.id,
|
|
42
|
-
kind: "padding-value",
|
|
43
|
-
side: "left"
|
|
44
|
-
};
|
|
45
|
-
if (localX <= Math.min(node.paddingLeft, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) return {
|
|
46
|
-
nodeId: node.id,
|
|
47
|
-
kind: "padding",
|
|
48
|
-
side: "left"
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (node.paddingRight > 0) {
|
|
52
|
-
if (isNear(localX, node.width - node.paddingRight / 2) && isNear(localY, centerY)) return {
|
|
53
|
-
nodeId: node.id,
|
|
54
|
-
kind: "padding-value",
|
|
55
|
-
side: "right"
|
|
56
|
-
};
|
|
57
|
-
if (localX >= node.width - Math.min(node.paddingRight, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) return {
|
|
58
|
-
nodeId: node.id,
|
|
59
|
-
kind: "padding",
|
|
60
|
-
side: "right"
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
11
|
+
function resolvePaddingHover(node, children, localX, localY) {
|
|
12
|
+
const layout = measureAutoLayoutHandles(node, children);
|
|
13
|
+
const hit = hitAutoLayoutHandle(layout, localX, localY);
|
|
14
|
+
if (hit?.kind !== "padding" || !layout) return null;
|
|
15
|
+
const handle = layout.padding.find((padding) => padding.side === hit.side);
|
|
16
|
+
if (!handle) return null;
|
|
17
|
+
const isVertical = hit.side === "left" || hit.side === "right";
|
|
18
|
+
const tickX = handle.rect.x + handle.rect.width / 2;
|
|
19
|
+
const tickY = handle.rect.y + handle.rect.height / 2;
|
|
20
|
+
const atTick = isVertical ? isNear(localY, node.height / 2) && isNear(localX, tickX) : isNear(localX, node.width / 2) && isNear(localY, tickY);
|
|
21
|
+
return {
|
|
22
|
+
nodeId: node.id,
|
|
23
|
+
kind: atTick ? "padding-value" : "padding",
|
|
24
|
+
side: hit.side
|
|
25
|
+
};
|
|
64
26
|
}
|
|
65
27
|
function resolveSpacingHover(node, children, localX, localY) {
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const tickMain = (gapStart + gapEnd) / 2;
|
|
80
|
-
const tickCross = (contentCrossStart + contentCrossEnd) / 2;
|
|
81
|
-
if (isNear(cursor, tickMain) && isNear(cross, tickCross)) return {
|
|
82
|
-
nodeId: node.id,
|
|
83
|
-
kind: "spacing-value",
|
|
84
|
-
index: i
|
|
85
|
-
};
|
|
86
|
-
if (cursor >= gapStart - AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE && cursor <= gapEnd + AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE) return {
|
|
87
|
-
nodeId: node.id,
|
|
88
|
-
kind: "spacing",
|
|
89
|
-
index: i
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
28
|
+
const layout = measureAutoLayoutHandles(node, children);
|
|
29
|
+
const hit = hitAutoLayoutHandle(layout, localX, localY);
|
|
30
|
+
if (hit?.kind !== "gap" || !layout) return null;
|
|
31
|
+
const handle = layout.gaps.find((gap) => gap.axis === hit.axis && gap.index === hit.index);
|
|
32
|
+
if (!handle) return null;
|
|
33
|
+
const { x, y, width, height } = handle.rect;
|
|
34
|
+
const atTick = isNear(localX, x + width / 2) && isNear(localY, y + height / 2);
|
|
35
|
+
return {
|
|
36
|
+
nodeId: node.id,
|
|
37
|
+
kind: atTick ? "spacing-value" : "spacing",
|
|
38
|
+
axis: hit.axis,
|
|
39
|
+
index: hit.index
|
|
40
|
+
};
|
|
93
41
|
}
|
|
94
42
|
function resolveChildrenHover(node, children, localX, localY) {
|
|
95
43
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -113,7 +61,7 @@ function resolveAutoLayoutHover(cx, cy, editor) {
|
|
|
113
61
|
const localY = cy - abs.y;
|
|
114
62
|
if (localX < 0 || localY < 0 || localX > node.width || localY > node.height) return null;
|
|
115
63
|
const children = visibleLayoutChildren(node, editor);
|
|
116
|
-
return
|
|
64
|
+
return resolvePaddingHover(node, children, localX, localY) ?? resolveSpacingHover(node, children, localX, localY) ?? resolveChildrenHover(node, children, localX, localY) ?? {
|
|
117
65
|
nodeId: node.id,
|
|
118
66
|
kind: "frame"
|
|
119
67
|
};
|
|
@@ -127,7 +75,7 @@ const PADDING_FIELDS = {
|
|
|
127
75
|
/** The value a hover over a padding or a gap edits, as Figma opens it on a double-click. */
|
|
128
76
|
function autoLayoutValueField(hover) {
|
|
129
77
|
if ((hover.kind === "padding" || hover.kind === "padding-value") && hover.side) return PADDING_FIELDS[hover.side];
|
|
130
|
-
if (hover.kind === "spacing" || hover.kind === "spacing-value") return "itemSpacing";
|
|
78
|
+
if (hover.kind === "spacing" || hover.kind === "spacing-value") return hover.axis === "counter" ? "counterAxisSpacing" : "itemSpacing";
|
|
131
79
|
return null;
|
|
132
80
|
}
|
|
133
81
|
/**
|
|
@@ -159,6 +107,14 @@ function autoLayoutValueAnchor(editor, nodeId, field, gap = 0) {
|
|
|
159
107
|
y: middle.y
|
|
160
108
|
};
|
|
161
109
|
const children = visibleLayoutChildren(node, editor);
|
|
110
|
+
if (field === "counterAxisSpacing") {
|
|
111
|
+
const handle = measureAutoLayoutHandles(node, children)?.gaps.find((candidate) => candidate.axis === "counter" && candidate.index === gap);
|
|
112
|
+
if (handle) return {
|
|
113
|
+
x: abs.x + handle.rect.x + handle.rect.width / 2,
|
|
114
|
+
y: abs.y + handle.rect.y + handle.rect.height / 2
|
|
115
|
+
};
|
|
116
|
+
return middle;
|
|
117
|
+
}
|
|
162
118
|
const prev = children.at(gap);
|
|
163
119
|
const next = children.at(gap + 1);
|
|
164
120
|
if (!prev || !next) return middle;
|
|
@@ -177,4 +133,4 @@ function autoLayoutValueAnchor(editor, nodeId, field, gap = 0) {
|
|
|
177
133
|
//#endregion
|
|
178
134
|
export { autoLayoutValueAnchor, autoLayoutValueField, resolveAutoLayoutHover };
|
|
179
135
|
|
|
180
|
-
//# sourceMappingURL=
|
|
136
|
+
//# sourceMappingURL=hover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover.js","names":[],"sources":["../../../../src/shared/input/auto-layout/hover.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport { AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE } from '@pairdraw/core/constants'\nimport { hitAutoLayoutHandle, measureAutoLayoutHandles } from '@pairdraw/core/layout'\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 children: SceneNode[],\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n const layout = measureAutoLayoutHandles(node, children)\n const hit = hitAutoLayoutHandle(layout, localX, localY)\n if (hit?.kind !== 'padding' || !layout) return null\n const handle = layout.padding.find((padding) => padding.side === hit.side)\n if (!handle) return null\n const isVertical = hit.side === 'left' || hit.side === 'right'\n const tickX = handle.rect.x + handle.rect.width / 2\n const tickY = handle.rect.y + handle.rect.height / 2\n const atTick = isVertical\n ? isNear(localY, node.height / 2) && isNear(localX, tickX)\n : isNear(localX, node.width / 2) && isNear(localY, tickY)\n return { nodeId: node.id, kind: atTick ? 'padding-value' : 'padding', side: hit.side }\n}\n\nfunction resolveSpacingHover(\n node: SceneNode,\n children: SceneNode[],\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n const layout = measureAutoLayoutHandles(node, children)\n const hit = hitAutoLayoutHandle(layout, localX, localY)\n if (hit?.kind !== 'gap' || !layout) return null\n const handle = layout.gaps.find((gap) => gap.axis === hit.axis && gap.index === hit.index)\n if (!handle) return null\n const { x, y, width, height } = handle.rect\n const atTick = isNear(localX, x + width / 2) && isNear(localY, y + height / 2)\n return {\n nodeId: node.id,\n kind: atTick ? 'spacing-value' : 'spacing',\n axis: hit.axis,\n index: hit.index\n }\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 resolvePaddingHover(node, children, localX, localY) ??\n resolveSpacingHover(node, children, 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 | 'counterAxisSpacing'\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')\n return hover.axis === 'counter' ? 'counterAxisSpacing' : '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 if (field === 'counterAxisSpacing') {\n const handle = measureAutoLayoutHandles(node, children)?.gaps.find(\n (candidate) => candidate.axis === 'counter' && candidate.index === gap\n )\n if (handle) {\n return {\n x: abs.x + handle.rect.x + handle.rect.width / 2,\n y: abs.y + handle.rect.y + handle.rect.height / 2\n }\n }\n return middle\n }\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":";;;;AASA,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,YA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AK,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,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,MAAM,SAAS,SAAS,QAAQ,OAAO,MAAM;CAE7C,IAAI,SAAS,WAAW,GAAG;EACzB,IAAI,OACF,OAAO,SACH,UAAU,IAAI,OAAO,QAAQ,OAAO,eACpC,UAAU,IAAI,OAAO;EAE3B,OAAO,UAAU,IAAI,OAAO;CAC9B;CACA,IAAI,gBAAgB,GAAG;EACrB,MAAM,WAAW,OAAO,MAAM,oBAAoB,SAAS,EAAE,CAAC,EAAE;EAChE,IAAI,OACF,OAAO,SACH,SAAS,IAAI,SAAS,EAAE,CAAC,QAAQ,OAAO,cAAc,IACtD,SAAS,IAAI,OAAO,cAAc;EAExC,OAAO,SAAS,IAAI,OAAO,cAAc;CAC3C;CACA,IAAI,eAAe,SAAS,QAAQ;EAClC,MAAM,OAAO,SAAS,SAAS,SAAS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AAW,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";
|