@pairdraw/vue 0.18.0 → 0.19.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 +1 -0
- package/dist/canvas/CanvasRoot.vue.js.map +1 -1
- package/dist/canvas/drop/use.d.ts.map +1 -1
- package/dist/canvas/drop/use.js +5 -3
- package/dist/canvas/drop/use.js.map +1 -1
- package/dist/canvas/guides/input.js +2 -1
- package/dist/canvas/guides/input.js.map +1 -1
- package/dist/canvas/pen/input.js +20 -6
- package/dist/canvas/pen/input.js.map +1 -1
- package/dist/canvas/surface/gl-surface.js +82 -4
- package/dist/canvas/surface/gl-surface.js.map +1 -1
- package/dist/canvas/surface/lifecycle.js +5 -0
- package/dist/canvas/surface/lifecycle.js.map +1 -1
- package/dist/canvas/surface/resize-observer.js +11 -4
- package/dist/canvas/surface/resize-observer.js.map +1 -1
- package/dist/canvas/surface/types.d.ts +5 -0
- package/dist/canvas/surface/types.d.ts.map +1 -1
- package/dist/canvas/surface/use.d.ts +1 -0
- package/dist/canvas/surface/use.js +1 -0
- package/dist/canvas/surface/use.js.map +1 -1
- package/dist/canvas/text-edit/editing.js +11 -8
- package/dist/canvas/text-edit/editing.js.map +1 -1
- package/dist/canvas/text-edit/keyboard.js +12 -0
- package/dist/canvas/text-edit/keyboard.js.map +1 -1
- package/dist/canvas/useCanvasInput.d.ts +240 -0
- package/dist/controls/appearance/use.d.ts +1 -1
- package/dist/controls/layout/helpers.d.ts.map +1 -1
- package/dist/controls/layout/helpers.js +36 -7
- package/dist/controls/layout/helpers.js.map +1 -1
- package/dist/controls/layout/use.d.ts +1 -0
- package/dist/controls/layout/use.d.ts.map +1 -1
- package/dist/controls/layout/use.js +3 -0
- package/dist/controls/layout/use.js.map +1 -1
- package/dist/controls/node-preview/use.js +21 -1
- package/dist/controls/node-preview/use.js.map +1 -1
- package/dist/controls/position/use.d.ts +2 -1
- package/dist/controls/position/use.d.ts.map +1 -1
- package/dist/controls/position/use.js +13 -5
- package/dist/controls/position/use.js.map +1 -1
- package/dist/controls/property-list/use.d.ts.map +1 -1
- package/dist/controls/property-list/use.js +27 -5
- package/dist/controls/property-list/use.js.map +1 -1
- package/dist/controls/selection-layout/use.d.ts.map +1 -1
- package/dist/controls/selection-layout/use.js +2 -1
- package/dist/controls/selection-layout/use.js.map +1 -1
- package/dist/controls/slots/authoring.d.ts.map +1 -1
- package/dist/controls/slots/authoring.js +2 -1
- package/dist/controls/slots/authoring.js.map +1 -1
- package/dist/controls/typography/actions.js +18 -10
- package/dist/controls/typography/actions.js.map +1 -1
- package/dist/controls/typography/axes.d.ts.map +1 -1
- package/dist/controls/typography/axes.js +62 -19
- package/dist/controls/typography/axes.js.map +1 -1
- package/dist/editor/commands/registry.d.ts +1 -0
- package/dist/editor/commands/registry.d.ts.map +1 -1
- package/dist/editor/commands/registry.js +1 -0
- package/dist/editor/commands/registry.js.map +1 -1
- package/dist/editor/commands/selection.js +12 -3
- 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.js +5 -1
- package/dist/editor/menu-model/canvas.js.map +1 -1
- package/dist/editor/selection-capabilities/use.d.ts +1 -0
- package/dist/editor/selection-capabilities/use.js +4 -0
- package/dist/editor/selection-capabilities/use.js.map +1 -1
- package/dist/editor/selection-state/nodes.js +2 -2
- package/dist/editor/selection-state/nodes.js.map +1 -1
- package/dist/i18n/locale.d.ts.map +1 -1
- package/dist/i18n/locale.js +16 -6
- package/dist/i18n/locale.js.map +1 -1
- package/dist/i18n/locales/de/ai.json.js +3 -0
- package/dist/i18n/locales/de/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/de/commands.json.js +1 -0
- package/dist/i18n/locales/de/comments.json.js +1 -0
- package/dist/i18n/locales/de/editor.json.js +2 -2
- package/dist/i18n/locales/de/menu.json.js +1 -1
- package/dist/i18n/locales/de/variables/panel.json.js +2 -0
- package/dist/i18n/locales/es/ai.json.js +3 -0
- package/dist/i18n/locales/es/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/es/commands.json.js +1 -0
- package/dist/i18n/locales/es/comments.json.js +1 -0
- package/dist/i18n/locales/es/editor.json.js +2 -2
- package/dist/i18n/locales/es/menu.json.js +1 -1
- package/dist/i18n/locales/es/variables/panel.json.js +2 -0
- package/dist/i18n/locales/fr/ai.json.js +3 -0
- package/dist/i18n/locales/fr/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/fr/commands.json.js +1 -0
- package/dist/i18n/locales/fr/comments.json.js +1 -0
- package/dist/i18n/locales/fr/editor.json.js +2 -2
- package/dist/i18n/locales/fr/menu.json.js +1 -1
- package/dist/i18n/locales/fr/variables/panel.json.js +2 -0
- package/dist/i18n/locales/it/ai.json.js +3 -0
- package/dist/i18n/locales/it/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/it/commands.json.js +1 -0
- package/dist/i18n/locales/it/comments.json.js +1 -0
- package/dist/i18n/locales/it/editor.json.js +2 -2
- package/dist/i18n/locales/it/menu.json.js +1 -1
- package/dist/i18n/locales/it/variables/panel.json.js +2 -0
- package/dist/i18n/locales/ja/ai.json.js +3 -0
- package/dist/i18n/locales/ja/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/ja/commands.json.js +1 -0
- package/dist/i18n/locales/ja/comments.json.js +1 -0
- package/dist/i18n/locales/ja/editor.json.js +2 -2
- package/dist/i18n/locales/ja/menu.json.js +1 -1
- package/dist/i18n/locales/ja/variables/panel.json.js +2 -0
- package/dist/i18n/locales/pl/ai.json.js +3 -0
- package/dist/i18n/locales/pl/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/pl/commands.json.js +1 -0
- package/dist/i18n/locales/pl/comments.json.js +1 -0
- package/dist/i18n/locales/pl/editor.json.js +2 -2
- package/dist/i18n/locales/pl/menu.json.js +1 -1
- package/dist/i18n/locales/pl/variables/panel.json.js +2 -0
- package/dist/i18n/locales/ru/ai.json.js +3 -0
- package/dist/i18n/locales/ru/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/ru/commands.json.js +1 -0
- package/dist/i18n/locales/ru/comments.json.js +1 -0
- package/dist/i18n/locales/ru/editor.json.js +2 -2
- package/dist/i18n/locales/ru/menu.json.js +1 -1
- package/dist/i18n/locales/ru/variables/panel.json.js +2 -0
- package/dist/i18n/locales/zh-cn/ai.json.js +3 -0
- package/dist/i18n/locales/zh-cn/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/zh-cn/commands.json.js +1 -0
- package/dist/i18n/locales/zh-cn/comments.json.js +1 -0
- package/dist/i18n/locales/zh-cn/editor.json.js +2 -2
- package/dist/i18n/locales/zh-cn/menu.json.js +1 -1
- package/dist/i18n/locales/zh-cn/variables/panel.json.js +2 -0
- package/dist/i18n/messages/ai.d.ts +6 -0
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +4 -0
- package/dist/i18n/messages/ai.js.map +1 -1
- package/dist/i18n/messages/cloud/portal.d.ts +1 -1
- package/dist/i18n/messages/cloud/portal.js +1 -1
- package/dist/i18n/messages/cloud/portal.js.map +1 -1
- package/dist/i18n/messages/commands.d.ts +1 -0
- package/dist/i18n/messages/commands.d.ts.map +1 -1
- package/dist/i18n/messages/commands.js +1 -0
- package/dist/i18n/messages/commands.js.map +1 -1
- package/dist/i18n/messages/comments.d.ts +1 -0
- package/dist/i18n/messages/comments.d.ts.map +1 -1
- package/dist/i18n/messages/comments.js +1 -0
- package/dist/i18n/messages/comments.js.map +1 -1
- package/dist/i18n/messages/editor.d.ts +1 -1
- package/dist/i18n/messages/editor.js +1 -1
- package/dist/i18n/messages/editor.js.map +1 -1
- package/dist/i18n/messages/menu.d.ts +1 -1
- package/dist/i18n/messages/menu.js +1 -1
- package/dist/i18n/messages/menu.js.map +1 -1
- package/dist/i18n/messages/panels.d.ts +1 -1
- package/dist/i18n/messages/panels.js +1 -1
- package/dist/i18n/messages/panels.js.map +1 -1
- package/dist/i18n/messages/variables/panel.d.ts +2 -0
- package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
- package/dist/i18n/messages/variables/panel.js +2 -0
- package/dist/i18n/messages/variables/panel.js.map +1 -1
- package/dist/i18n/messages.d.ts +13 -4
- package/dist/i18n/useI18n.d.ts +48 -14
- package/dist/i18n/useI18n.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +12 -2
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +39 -10
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
- package/dist/primitives/ColorPicker/gesture.d.ts +40 -0
- package/dist/primitives/ColorPicker/gesture.d.ts.map +1 -0
- package/dist/primitives/ColorPicker/gesture.js +120 -0
- package/dist/primitives/ColorPicker/gesture.js.map +1 -0
- package/dist/primitives/ColorPicker/index.d.ts +2 -1
- package/dist/primitives/ColorPicker/index.js +2 -1
- package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.js +6 -1
- package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
- package/dist/primitives/Fill/types.d.ts +5 -0
- package/dist/primitives/Fill/types.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.js +15 -7
- package/dist/primitives/Fill/useFill.js.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +1 -0
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js +7 -2
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +2 -0
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +14 -3
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
- package/dist/primitives/LayerTree/model.js +1 -1
- package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js +1 -0
- package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js.map +1 -1
- package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts +2 -2
- package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts.map +1 -1
- package/dist/primitives/NumberField/NumberFieldRoot.vue.js +3 -2
- package/dist/primitives/NumberField/NumberFieldRoot.vue.js.map +1 -1
- package/dist/primitives/NumberField/types.d.ts +5 -0
- package/dist/primitives/NumberField/types.d.ts.map +1 -1
- package/dist/primitives/PageList/PageListRoot.vue.d.ts +3 -3
- package/dist/primitives/PageList/PageListRoot.vue.d.ts.map +1 -1
- package/dist/primitives/PageList/PageListRoot.vue.js +3 -2
- package/dist/primitives/PageList/PageListRoot.vue.js.map +1 -1
- package/dist/primitives/PageList/usePageList.d.ts +1 -1
- package/dist/primitives/PageList/usePageList.d.ts.map +1 -1
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts +1 -0
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts.map +1 -1
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.js +11 -13
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.js.map +1 -1
- package/dist/primitives/PropertyList/PropertyListRoot.vue.d.ts.map +1 -1
- package/dist/primitives/PropertyList/PropertyListRoot.vue.js +10 -1
- package/dist/primitives/PropertyList/PropertyListRoot.vue.js.map +1 -1
- package/dist/primitives/PropertyList/index.d.ts +2 -2
- package/dist/primitives/PropertyList/types.d.ts +14 -2
- package/dist/primitives/PropertyList/types.d.ts.map +1 -1
- package/dist/shared/input/drop-target.js +2 -1
- package/dist/shared/input/drop-target.js.map +1 -1
- package/dist/shared/input/duplicate-drag.js.map +1 -1
- package/dist/shared/input/move/drag.js +25 -4
- package/dist/shared/input/move/drag.js.map +1 -1
- package/dist/shared/input/resize/start.js +2 -1
- package/dist/shared/input/resize/start.js.map +1 -1
- package/dist/shared/input/select/move.js +8 -3
- package/dist/shared/input/select/move.js.map +1 -1
- package/dist/shared/input/select.js +22 -12
- package/dist/shared/input/select.js.map +1 -1
- package/dist/shared/input/types.d.ts +2 -0
- package/dist/shared/input/types.d.ts.map +1 -1
- package/dist/shared/input/types.js.map +1 -1
- package/dist/variables/use.d.ts.map +1 -1
- package/dist/variables/use.js +2 -1
- package/dist/variables/use.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag.js","names":[],"sources":["../../../../src/shared/input/move/drag.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport {\n autoLayoutInsertIndex,\n computeAutoLayoutIndicator,\n computeIndicatorPosition,\n computeAutoLayoutIndicatorForFrame\n} from '#vue/shared/input/auto-layout'\nimport {\n isPastPointerDragThreshold,\n POINTER_DRAG_START_THRESHOLD_PX\n} from '#vue/shared/input/drag-threshold'\nimport { findMoveDropTarget, reparentDroppedNodes } from '#vue/shared/input/drop-target'\nimport { flowBlockBounds, flowOrder, flowSlot, type FlowDrag } from '#vue/shared/input/flow-reorder'\nimport { applyMoveSnap } from '#vue/shared/input/move/snap'\nimport type { DragMove } from '#vue/shared/input/types'\n\nconst AUTO_LAYOUT_REORDER_CLICK_SLOP = 3\n/**\n * How far past its auto layout frame's edge a dragged layer's near edge goes before the layer\n * leaves the frame, in canvas units, as measured in Figma desktop 126: 5 across the flow, and\n * 13 to 20 along it depending on the layer's size.\n */\nconst AUTO_LAYOUT_LEAVE_MARGIN_ACROSS = 5\nconst AUTO_LAYOUT_LEAVE_MARGIN_ALONG = 15\nexport const MOVE_DRAG_START_THRESHOLD_PX = POINTER_DRAG_START_THRESHOLD_PX\n\n/** Whether layers whose box in the frame's own space is `bounds` stay close enough to its flow. */\nfunction staysInAutoLayout(\n parentId: string,\n bounds: { left: number; top: number; right: number; bottom: number },\n editor: Editor\n) {\n const parent = editor.graph.getNode(parentId)\n if (!parent) return false\n // How far the layers' near edge is past the frame's edge on each of the frame's own axes, with\n // `bounds` in the frame's space; negative while they overlap.\n const pastX = Math.max(-bounds.right, bounds.left - parent.width)\n const pastY = Math.max(-bounds.bottom, bounds.top - parent.height)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const along = isRow ? pastX : pastY\n const across = isRow ? pastY : pastX\n return along <= AUTO_LAYOUT_LEAVE_MARGIN_ALONG && across <= AUTO_LAYOUT_LEAVE_MARGIN_ACROSS\n}\n\n/**\n * Keeps dragged layers in their flows while they stay close, as Figma does: each flow's block\n * takes the slot the drag has reached, which the indicator shows for the first flow that moved.\n * Returns false once a flow's layers leave it, and the move goes on as a free drag.\n */\nfunction dragAlongFlows(d: DragMove, flows: FlowDrag[], dx: number, dy: number, editor: Editor) {\n if (d.ignoreAutoLayout) return false\n if (\n !flows.every((flow) =>\n staysInAutoLayout(flow.parentId, flowBlockBounds(flow, dx, dy, editor), editor)\n )\n )\n return false\n d.flowSlots = flows.map((flow) => flowSlot(flow, dx, dy, editor))\n const moved = flows.findIndex((flow, i) => d.flowSlots?.[i] !== flow.start)\n const flow = moved === -1 ? undefined : flows[moved]\n const parent = flow && editor.graph.getNode(flow.parentId)\n if (!flow || !parent) {\n editor.setLayoutInsertIndicator(null)\n return true\n }\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const others = flow.others.flatMap((id) => editor.graph.getNode(id) ?? [])\n const parentAbs = editor.graph.getAbsolutePosition(parent.id)\n const position = computeIndicatorPosition(\n others,\n d.flowSlots[moved],\n parent,\n parentAbs,\n isRow,\n editor\n )\n editor.setLayoutInsertIndicator({\n parentId: parent.id,\n index: d.flowSlots[moved],\n x: isRow ? position : parentAbs.x + parent.paddingLeft,\n y: isRow ? parentAbs.y + parent.paddingTop : position,\n length: isRow\n ? parent.height - parent.paddingTop - parent.paddingBottom\n : parent.width - parent.paddingLeft - parent.paddingRight,\n direction: isRow ? 'VERTICAL' : 'HORIZONTAL'\n })\n return true\n}\n\n/** Puts each flow's block in the slot the drag reached, as one undo step. */\nfunction dropAlongFlows(d: DragMove, flows: FlowDrag[], editor: Editor) {\n editor.undo.runBatch('Reorder', () => {\n for (const [i, flow] of flows.entries()) {\n const slot = d.flowSlots?.[i] ?? flow.start\n if (slot === flow.start) continue\n editor.setChildOrder(flow.parentId, flowOrder(flow, slot, editor))\n }\n })\n}\n\n/** Keys held during a move. Figma maps Control to both, Shift to an axis lock. */\nexport interface MoveModifiers {\n /** Turns off snapping and drops into auto layout as an absolute-positioned layer. */\n ctrlKey?: boolean\n /** Locks the move to the axis it has travelled furthest along. */\n shiftKey?: boolean\n}\n\nfunction lockToAxis(dx: number, dy: number, lock: boolean) {\n if (!lock) return { dx, dy }\n return Math.abs(dx) >= Math.abs(dy) ? { dx, dy: 0 } : { dx: 0, dy }\n}\n\n/**\n * Where Control drops layers among an auto layout frame's children. Like Figma, layers from\n * elsewhere go in at the cursor; layers already in the frame go on top.\n */\nfunction absoluteInsertIndex(\n d: DragMove,\n target: SceneNode | null,\n cx: number,\n cy: number,\n editor: Editor,\n moving: ReadonlySet<string>\n) {\n if (!d.ignoreAutoLayout || !target || target.layoutMode === 'NONE') return undefined\n // The graph clamps an index past the end, which puts the layers on top.\n if ([...d.originals.values()].some((orig) => orig.parentId === target.id))\n return target.childIds.length\n return autoLayoutInsertIndex(target, cx, cy, editor, moving)\n}\n\nfunction isPastDragStartThreshold(d: DragMove, sx: number, sy: number) {\n return isPastPointerDragThreshold(d.startScreenX, d.startScreenY, sx, sy)\n}\n\n/**\n * Keeps a move in the auto layout the layers started in while they stay close to it; returns\n * whether it did. Once they leave, the move goes on as a free drag.\n */\nfunction keepsOwnAutoLayout(\n d: DragMove,\n dx: number,\n dy: number,\n cx: number,\n cy: number,\n editor: Editor\n): boolean {\n if (d.flows) {\n if (dragAlongFlows(d, d.flows, dx, dy, editor)) return true\n d.flowSlots = undefined\n } else if (d.autoLayoutParentId && !d.ignoreAutoLayout) {\n // A wrapped flow, which still reorders by the cursor.\n const [id] = d.originals.keys()\n const block = { parentId: d.autoLayoutParentId, ids: id ? [id] : [], others: [], start: 0 }\n if (staysInAutoLayout(d.autoLayoutParentId, flowBlockBounds(block, dx, dy, editor), editor)) {\n computeAutoLayoutIndicator(d, cx, cy, editor)\n return true\n }\n } else if (!d.autoLayoutParentId) {\n return false\n }\n d.brokeFromAutoLayout = true\n editor.setLayoutInsertIndicator(null)\n return false\n}\n\nexport function handleMoveMove(\n d: DragMove,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor,\n modifiers: MoveModifiers = {}\n) {\n d.currentX = cx\n d.currentY = cy\n d.ignoreAutoLayout = modifiers.ctrlKey === true\n\n if (!d.dragStarted) {\n if (!isPastDragStartThreshold(d, sx, sy)) return\n d.dragStarted = true\n }\n\n let { dx, dy } = lockToAxis(cx - d.startX, cy - d.startY, modifiers.shiftKey === true)\n\n if (!d.brokeFromAutoLayout && keepsOwnAutoLayout(d, dx, dy, cx, cy, editor)) return\n\n const moving = new Set(d.originals.keys())\n const dropTarget = d.keepParents ? null : findMoveDropTarget(cx, cy, editor, moving)\n d.absoluteInsertIndex = absoluteInsertIndex(d, dropTarget, cx, cy, editor, moving)\n\n if (dropTarget && dropTarget.layoutMode !== 'NONE' && !d.ignoreAutoLayout) {\n computeAutoLayoutIndicatorForFrame(dropTarget, cx, cy, editor)\n editor.setDropTarget(dropTarget.id)\n let firstApplied: { dx: number; dy: number } | null = null\n for (const [id, orig] of d.originals) {\n const previewX = Math.round(orig.x + dx)\n const previewY = Math.round(orig.y + dy)\n firstApplied ??= { dx: previewX - orig.x, dy: previewY - orig.y }\n editor.graph.updateNodePositionPreview(id, previewX, previewY)\n }\n if (firstApplied) {\n d.appliedDx = firstApplied.dx\n d.appliedDy = firstApplied.dy\n }\n editor.requestRepaint()\n return\n }\n\n editor.setLayoutInsertIndicator(null)\n\n const snapped = applyMoveSnap(d, dx, dy, editor, modifiers.ctrlKey === true)\n // Snapping must not pull the layer off a locked axis.\n ;({ dx, dy } = lockToAxis(snapped.dx, snapped.dy, modifiers.shiftKey === true))\n d.appliedDx = dx\n d.appliedDy = dy\n\n for (const [id, orig] of d.originals) {\n editor.graph.updateNodePositionPreview(id, orig.x + dx, orig.y + dy)\n }\n\n editor.setDropTarget(dropTarget?.id ?? null)\n editor.requestRepaint()\n}\n\nfunction getMoveDistance(d: DragMove) {\n return Math.hypot(d.currentX - d.startX, d.currentY - d.startY)\n}\n\nfunction hasMoved(d: DragMove, editor: Editor) {\n return [...d.originals].some(([id, orig]) => {\n const node = editor.graph.getNode(id)\n return node && (node.x !== orig.x || node.y !== orig.y)\n })\n}\n\nfunction restoreOriginalPositions(d: DragMove, editor: Editor) {\n for (const [id, orig] of d.originals) {\n editor.graph.updateNodePositionPreview(id, orig.x, orig.y)\n }\n}\n\nfunction isLeavingAutoLayout(d: DragMove, id: string, editor: Editor) {\n const node = editor.graph.getNode(id)\n const parent = editor.graph.getNode(node?.parentId ?? '')\n if (d.keepParents || !parent || parent.layoutMode === 'NONE') return false\n if (node?.layoutPositioning === 'ABSOLUTE') return false\n return (editor.state.dropTargetId ?? editor.state.currentPageId) !== parent.id\n}\n\nfunction applyFinalPositions(d: DragMove, editor: Editor) {\n for (const [id, orig] of d.originals) {\n const position = { x: orig.x + d.appliedDx, y: orig.y + d.appliedDy }\n // Laying out now would snap the layer back into its slot before it leaves the frame.\n if (isLeavingAutoLayout(d, id, editor)) editor.graph.updateNode(id, position)\n else editor.updateNode(id, position)\n }\n}\n\n/** Closes the gaps moved layers leave in auto layout frames. */\nfunction layOutOriginalParents(d: DragMove, editor: Editor) {\n for (const parentId of new Set([...d.originals.values()].map((orig) => orig.parentId))) {\n if (editor.graph.getNode(parentId)?.layoutMode !== 'NONE') editor.runLayoutForNode(parentId)\n }\n}\n\n/** Control into auto layout: absolute first, so layout keeps the positions the move writes. */\nfunction ignoreTargetAutoLayout(d: DragMove, editor: Editor) {\n const targetId = editor.state.dropTargetId\n const target = targetId ? editor.graph.getNode(targetId) : null\n if (d.keepParents || !d.ignoreAutoLayout || !target || target.layoutMode === 'NONE') return\n for (const id of d.originals.keys()) {\n if (editor.graph.getNode(id)?.layoutPositioning === 'ABSOLUTE') continue\n editor.updateNodeWithUndo(id, { layoutPositioning: 'ABSOLUTE' }, 'Ignore auto layout')\n }\n}\n\nfunction dropMovedNodes(d: DragMove, editor: Editor) {\n const ids = [...d.originals.keys()]\n reparentDroppedNodes(editor, ids, editor.state.dropTargetId)\n for (const id of ids) {\n if (editor.graph.getNode(id)?.type === 'SECTION') editor.adoptCoveredLayers(id)\n }\n}\n\nfunction movedParentIds(d: DragMove, editor: Editor) {\n const ids = new Set<string>()\n for (const [id, orig] of d.originals) {\n ids.add(orig.parentId)\n const parentId = editor.graph.getNode(id)?.parentId\n if (parentId) ids.add(parentId)\n }\n return ids\n}\n\nfunction placeAbsoluteDrop(d: DragMove, editor: Editor) {\n const targetId = editor.state.dropTargetId\n const index = d.absoluteInsertIndex\n if (!targetId || index === undefined) return\n const ids = [...d.originals.keys()].filter(\n (id) => editor.graph.getNode(id)?.parentId === targetId\n )\n for (const [offset, id] of ids.entries())\n editor.reorderChildWithUndo(id, targetId, index + offset)\n}\n\n/**\n * Ends a move without recording it: the layers go back where the drag found them, and a\n * duplicate's copies go away with the selection before them coming back.\n */\nexport function cancelMove(d: DragMove, editor: Editor) {\n if (d.duplicated) {\n for (const id of [...d.originals.keys()].toReversed()) editor.graph.deleteNode(id)\n editor.select([...(d.duplicatedPreviousSelection ?? [])])\n } else {\n restoreOriginalPositions(d, editor)\n }\n editor.setDropTarget(null)\n editor.requestRender()\n}\n\nexport function handleMoveUp(d: DragMove, editor: Editor) {\n if (!d.dragStarted) {\n editor.setLayoutInsertIndicator(null)\n editor.setSnapGuides([])\n editor.setDropTarget(null)\n if (d.selectOnClick) editor.select([d.selectOnClick])\n return\n }\n\n const indicator = editor.state.layoutInsertIndicator\n editor.setLayoutInsertIndicator(null)\n editor.setSnapGuides([])\n\n // Slots exist only once the drag started, so a reached slot is a reorder however short the drag.\n if (d.flows && d.flowSlots && !d.brokeFromAutoLayout) {\n dropAlongFlows(d, d.flows, editor)\n editor.setDropTarget(null)\n return\n }\n\n if (indicator) {\n if (getMoveDistance(d) < AUTO_LAYOUT_REORDER_CLICK_SLOP) {\n editor.setDropTarget(null)\n return\n }\n // Claiming a slot records its own step; the batch makes it one undo with the reorder.\n editor.undo.runBatch('Reorder', () => {\n for (const id of d.originals.keys()) {\n editor.reorderInAutoLayout(id, indicator.parentId, indicator.index)\n }\n })\n editor.setDropTarget(null)\n return\n }\n\n const moved = hasMoved(d, editor)\n\n if (d.duplicated && !moved) {\n const previousSelection = d.duplicatedPreviousSelection ?? new Set<string>()\n for (const id of [...d.originals.keys()].toReversed()) editor.graph.deleteNode(id)\n editor.select([...previousSelection])\n editor.requestRender()\n editor.setDropTarget(null)\n return\n }\n\n // The batch keeps a slot claim in the same undo step; it carries the edit's own name.\n editor.undo.runBatch(d.duplicated ? 'Duplicate' : 'Move', () => {\n if (moved) {\n ignoreTargetAutoLayout(d, editor)\n restoreOriginalPositions(d, editor)\n applyFinalPositions(d, editor)\n if (!d.keepParents) dropMovedNodes(d, editor)\n layOutOriginalParents(d, editor)\n }\n if (d.duplicated) {\n editor.commitDuplicateMove(\n [...d.originals.keys()],\n d.duplicatedPreviousSelection ?? new Set<string>()\n )\n } else if (moved) {\n editor.commitMoveWithReparent(d.originals)\n }\n // After the move is recorded, so undo restores the order before taking the layers back out.\n if (moved && !d.keepParents) placeAbsoluteDrop(d, editor)\n // Groups and booleans the layers left or moved inside fit their children again.\n if (moved) editor.fitEnclosingGroups(movedParentIds(d, editor))\n })\n editor.setDropTarget(null)\n}\n"],"mappings":";;;;;;AAkBA,MAAM,iCAAiC;;;;;;AAMvC,MAAM,kCAAkC;AACxC,M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OAAO,oBACL,CAAC,GAAG,EAAE,UAAU,KAAK,CAAC,GACtB,EAAE,+CAA+B,IAAI,IAAY,CACnD;OACK,IAAI,OACT,OAAO,uBAAuB,EAAE,SAAS;EAG3C,IAAI,SAAS,CAAC,EAAE,aAAa,kBAAkB,GAAG,MAAM;EAExD,IAAI,OAAO,OAAO,mBAAmB,eAAe,GAAG,MAAM,CAAC;CAChE,CAAC;CACD,OAAO,cAAc,IAAI;AAC3B"}
|
|
1
|
+
{"version":3,"file":"drag.js","names":[],"sources":["../../../../src/shared/input/move/drag.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport {\n autoLayoutInsertIndex,\n computeAutoLayoutIndicator,\n computeIndicatorPosition,\n computeAutoLayoutIndicatorForFrame\n} from '#vue/shared/input/auto-layout'\nimport {\n isPastPointerDragThreshold,\n POINTER_DRAG_START_THRESHOLD_PX\n} from '#vue/shared/input/drag-threshold'\nimport { findMoveDropTarget, reparentDroppedNodes } from '#vue/shared/input/drop-target'\nimport { flowBlockBounds, flowOrder, flowSlot, type FlowDrag } from '#vue/shared/input/flow-reorder'\nimport { applyMoveSnap } from '#vue/shared/input/move/snap'\nimport type { DragMove } from '#vue/shared/input/types'\n\nconst AUTO_LAYOUT_REORDER_CLICK_SLOP = 3\n/**\n * How far past its auto layout frame's edge a dragged layer's near edge goes before the layer\n * leaves the frame, in canvas units, as measured in Figma desktop 126: 5 across the flow, and\n * 13 to 20 along it depending on the layer's size.\n */\nconst AUTO_LAYOUT_LEAVE_MARGIN_ACROSS = 5\nconst AUTO_LAYOUT_LEAVE_MARGIN_ALONG = 15\nexport const MOVE_DRAG_START_THRESHOLD_PX = POINTER_DRAG_START_THRESHOLD_PX\n\n/** Whether layers whose box in the frame's own space is `bounds` stay close enough to its flow. */\nfunction staysInAutoLayout(\n parentId: string,\n bounds: { left: number; top: number; right: number; bottom: number },\n editor: Editor\n) {\n const parent = editor.graph.getNode(parentId)\n if (!parent) return false\n // How far the layers' near edge is past the frame's edge on each of the frame's own axes, with\n // `bounds` in the frame's space; negative while they overlap.\n const pastX = Math.max(-bounds.right, bounds.left - parent.width)\n const pastY = Math.max(-bounds.bottom, bounds.top - parent.height)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const along = isRow ? pastX : pastY\n const across = isRow ? pastY : pastX\n return along <= AUTO_LAYOUT_LEAVE_MARGIN_ALONG && across <= AUTO_LAYOUT_LEAVE_MARGIN_ACROSS\n}\n\n/**\n * Keeps dragged layers in their flows while they stay close, as Figma does: each flow's block\n * takes the slot the drag has reached, which the indicator shows for the first flow that moved.\n * Returns false once a flow's layers leave it, and the move goes on as a free drag.\n */\nfunction dragAlongFlows(d: DragMove, flows: FlowDrag[], dx: number, dy: number, editor: Editor) {\n if (d.ignoreAutoLayout) return false\n if (\n !flows.every((flow) =>\n staysInAutoLayout(flow.parentId, flowBlockBounds(flow, dx, dy, editor), editor)\n )\n )\n return false\n d.flowSlots = flows.map((flow) => flowSlot(flow, dx, dy, editor))\n const moved = flows.findIndex((flow, i) => d.flowSlots?.[i] !== flow.start)\n const flow = moved === -1 ? undefined : flows[moved]\n const parent = flow && editor.graph.getNode(flow.parentId)\n if (!flow || !parent) {\n editor.setLayoutInsertIndicator(null)\n return true\n }\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const others = flow.others.flatMap((id) => editor.graph.getNode(id) ?? [])\n const parentAbs = editor.graph.getAbsolutePosition(parent.id)\n const position = computeIndicatorPosition(\n others,\n d.flowSlots[moved],\n parent,\n parentAbs,\n isRow,\n editor\n )\n editor.setLayoutInsertIndicator({\n parentId: parent.id,\n index: d.flowSlots[moved],\n x: isRow ? position : parentAbs.x + parent.paddingLeft,\n y: isRow ? parentAbs.y + parent.paddingTop : position,\n length: isRow\n ? parent.height - parent.paddingTop - parent.paddingBottom\n : parent.width - parent.paddingLeft - parent.paddingRight,\n direction: isRow ? 'VERTICAL' : 'HORIZONTAL'\n })\n return true\n}\n\n/** Puts each flow's block in the slot the drag reached, as one undo step. */\nfunction dropAlongFlows(d: DragMove, flows: FlowDrag[], editor: Editor) {\n editor.undo.runBatch('Reorder', () => {\n for (const [i, flow] of flows.entries()) {\n const slot = d.flowSlots?.[i] ?? flow.start\n if (slot === flow.start) continue\n editor.setChildOrder(flow.parentId, flowOrder(flow, slot, editor))\n }\n })\n}\n\n/** Keys held during a move. Figma maps Control to both, Shift to an axis lock. */\nexport interface MoveModifiers {\n /** Turns off snapping and drops into auto layout as an absolute-positioned layer. */\n ctrlKey?: boolean\n /** Locks the move to the axis it has travelled furthest along. */\n shiftKey?: boolean\n}\n\nfunction lockToAxis(dx: number, dy: number, lock: boolean) {\n if (!lock) return { dx, dy }\n return Math.abs(dx) >= Math.abs(dy) ? { dx, dy: 0 } : { dx: 0, dy }\n}\n\n/**\n * Where Control drops layers among an auto layout frame's children. Like Figma, layers from\n * elsewhere go in at the cursor; layers already in the frame go on top.\n */\nfunction absoluteInsertIndex(\n d: DragMove,\n target: SceneNode | null,\n cx: number,\n cy: number,\n editor: Editor,\n moving: ReadonlySet<string>\n) {\n if (!d.ignoreAutoLayout || !target || target.layoutMode === 'NONE') return undefined\n // The graph clamps an index past the end, which puts the layers on top.\n if ([...d.originals.values()].some((orig) => orig.parentId === target.id))\n return target.childIds.length\n return autoLayoutInsertIndex(target, cx, cy, editor, moving)\n}\n\nfunction isPastDragStartThreshold(d: DragMove, sx: number, sy: number) {\n return isPastPointerDragThreshold(d.startScreenX, d.startScreenY, sx, sy)\n}\n\n/**\n * Keeps a move in the auto layout the layers started in while they stay close to it; returns\n * whether it did. Once they leave, the move goes on as a free drag.\n */\nfunction keepsOwnAutoLayout(\n d: DragMove,\n dx: number,\n dy: number,\n cx: number,\n cy: number,\n editor: Editor\n): boolean {\n if (d.flows) {\n if (dragAlongFlows(d, d.flows, dx, dy, editor)) return true\n d.flowSlots = undefined\n } else if (d.autoLayoutParentId && !d.ignoreAutoLayout) {\n // A wrapped flow, which still reorders by the cursor.\n const [id] = d.originals.keys()\n const block = { parentId: d.autoLayoutParentId, ids: id ? [id] : [], others: [], start: 0 }\n if (staysInAutoLayout(d.autoLayoutParentId, flowBlockBounds(block, dx, dy, editor), editor)) {\n computeAutoLayoutIndicator(d, cx, cy, editor)\n return true\n }\n } else if (!d.autoLayoutParentId) {\n return false\n }\n d.brokeFromAutoLayout = true\n editor.setLayoutInsertIndicator(null)\n return false\n}\n\nexport function handleMoveMove(\n d: DragMove,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor,\n modifiers: MoveModifiers = {}\n) {\n d.currentX = cx\n d.currentY = cy\n d.ignoreAutoLayout = modifiers.ctrlKey === true\n\n if (!d.dragStarted) {\n if (!isPastDragStartThreshold(d, sx, sy)) return\n d.dragStarted = true\n }\n\n let { dx, dy } = lockToAxis(cx - d.startX, cy - d.startY, modifiers.shiftKey === true)\n\n if (!d.brokeFromAutoLayout && keepsOwnAutoLayout(d, dx, dy, cx, cy, editor)) return\n\n const moving = new Set(d.originals.keys())\n const dropTarget = d.keepParents ? null : findMoveDropTarget(cx, cy, editor, moving)\n d.absoluteInsertIndex = absoluteInsertIndex(d, dropTarget, cx, cy, editor, moving)\n\n if (dropTarget && dropTarget.layoutMode !== 'NONE' && !d.ignoreAutoLayout) {\n computeAutoLayoutIndicatorForFrame(dropTarget, cx, cy, editor)\n editor.setDropTarget(dropTarget.id)\n let firstApplied: { dx: number; dy: number } | null = null\n for (const [id, orig] of d.originals) {\n const previewX = Math.round(orig.x + dx)\n const previewY = Math.round(orig.y + dy)\n firstApplied ??= { dx: previewX - orig.x, dy: previewY - orig.y }\n editor.graph.updateNodePositionPreview(id, previewX, previewY)\n }\n if (firstApplied) {\n d.appliedDx = firstApplied.dx\n d.appliedDy = firstApplied.dy\n }\n editor.requestRepaint()\n return\n }\n\n editor.setLayoutInsertIndicator(null)\n\n const snapped = applyMoveSnap(d, dx, dy, editor, modifiers.ctrlKey === true)\n // Snapping must not pull the layer off a locked axis.\n ;({ dx, dy } = lockToAxis(snapped.dx, snapped.dy, modifiers.shiftKey === true))\n d.appliedDx = dx\n d.appliedDy = dy\n\n for (const [id, orig] of d.originals) {\n editor.graph.updateNodePositionPreview(id, orig.x + dx, orig.y + dy)\n }\n\n editor.setDropTarget(dropTarget?.id ?? null)\n editor.requestRepaint()\n}\n\nfunction getMoveDistance(d: DragMove) {\n return Math.hypot(d.currentX - d.startX, d.currentY - d.startY)\n}\n\nfunction hasMoved(d: DragMove, editor: Editor) {\n return [...d.originals].some(([id, orig]) => {\n const node = editor.graph.getNode(id)\n return node && (node.x !== orig.x || node.y !== orig.y)\n })\n}\n\nfunction restoreOriginalPositions(d: DragMove, editor: Editor) {\n for (const [id, orig] of d.originals) {\n editor.graph.updateNodePositionPreview(id, orig.x, orig.y)\n }\n}\n\nfunction isLeavingAutoLayout(d: DragMove, id: string, editor: Editor) {\n const node = editor.graph.getNode(id)\n const parent = editor.graph.getNode(node?.parentId ?? '')\n if (d.keepParents || !parent || parent.layoutMode === 'NONE') return false\n if (node?.layoutPositioning === 'ABSOLUTE') return false\n return (editor.state.dropTargetId ?? editor.state.currentPageId) !== parent.id\n}\n\nfunction applyFinalPositions(d: DragMove, editor: Editor) {\n for (const [id, orig] of d.originals) {\n const position = { x: orig.x + d.appliedDx, y: orig.y + d.appliedDy }\n // Laying out now would snap the layer back into its slot before it leaves the frame.\n if (isLeavingAutoLayout(d, id, editor)) editor.graph.updateNode(id, position)\n else editor.updateNode(id, position)\n }\n}\n\n/** Closes the gaps moved layers leave in auto layout frames. */\nfunction layOutOriginalParents(d: DragMove, editor: Editor) {\n for (const parentId of new Set([...d.originals.values()].map((orig) => orig.parentId))) {\n if (editor.graph.getNode(parentId)?.layoutMode !== 'NONE') editor.runLayoutForNode(parentId)\n }\n}\n\n/** Control into auto layout: absolute first, so layout keeps the positions the move writes. */\nfunction ignoreTargetAutoLayout(d: DragMove, editor: Editor) {\n const targetId = editor.state.dropTargetId\n const target = targetId ? editor.graph.getNode(targetId) : null\n if (d.keepParents || !d.ignoreAutoLayout || !target || target.layoutMode === 'NONE') return\n for (const id of d.originals.keys()) {\n if (editor.graph.getNode(id)?.layoutPositioning === 'ABSOLUTE') continue\n editor.updateNodeWithUndo(id, { layoutPositioning: 'ABSOLUTE' }, 'Ignore auto layout')\n }\n}\n\nfunction dropMovedNodes(d: DragMove, editor: Editor) {\n const ids = [...d.originals.keys()]\n reparentDroppedNodes(editor, ids, editor.state.dropTargetId)\n for (const id of ids) {\n if (editor.graph.getNode(id)?.type === 'SECTION') editor.adoptCoveredLayers(id)\n }\n}\n\nfunction movedParentIds(d: DragMove, editor: Editor) {\n const ids = new Set<string>()\n for (const [id, orig] of d.originals) {\n ids.add(orig.parentId)\n const parentId = editor.graph.getNode(id)?.parentId\n if (parentId) ids.add(parentId)\n }\n return ids\n}\n\nfunction placeAbsoluteDrop(d: DragMove, editor: Editor) {\n const targetId = editor.state.dropTargetId\n const index = d.absoluteInsertIndex\n if (!targetId || index === undefined) return\n const ids = [...d.originals.keys()].filter(\n (id) => editor.graph.getNode(id)?.parentId === targetId\n )\n for (const [offset, id] of ids.entries())\n editor.reorderChildWithUndo(id, targetId, index + offset)\n}\n\n/**\n * Ends a move without recording it: the layers go back where the drag found them, and a\n * duplicate's copies go away with the selection before them coming back.\n */\nexport function cancelMove(d: DragMove, editor: Editor) {\n if (d.duplicated) {\n for (const id of [...d.originals.keys()].toReversed()) editor.graph.deleteNode(id)\n editor.select([...(d.duplicatedPreviousSelection ?? [])])\n } else {\n restoreOriginalPositions(d, editor)\n }\n editor.setDropTarget(null)\n editor.requestRender()\n}\n\nfunction isFlowClick(d: DragMove, flows: FlowDrag[], slots: number[]) {\n const keptSlots = flows.every((flow, i) => slots[i] === flow.start)\n return keptSlots && getMoveDistance(d) < AUTO_LAYOUT_REORDER_CLICK_SLOP\n}\n\nfunction deselectClicked(d: DragMove, editor: Editor) {\n if (d.clickDeselectsId && editor.state.selectedIds.has(d.clickDeselectsId)) {\n editor.select([d.clickDeselectsId], true)\n }\n}\n\nfunction discardDuplicates(d: DragMove, editor: Editor) {\n const previousSelection = d.duplicatedPreviousSelection ?? new Set<string>()\n for (const id of [...d.originals.keys()].toReversed()) {\n editor.graph.deleteNode(id)\n }\n editor.select([...previousSelection].filter((id) => id !== d.clickDeselectsId))\n editor.requestRender()\n editor.setDropTarget(null)\n}\n\nexport function handleMoveUp(d: DragMove, editor: Editor) {\n if (!d.dragStarted) {\n editor.setLayoutInsertIndicator(null)\n editor.setSnapGuides([])\n editor.setDropTarget(null)\n if (d.selectOnClick) editor.select([d.selectOnClick])\n deselectClicked(d, editor)\n return\n }\n\n const indicator = editor.state.layoutInsertIndicator\n editor.setLayoutInsertIndicator(null)\n editor.setSnapGuides([])\n\n // Slots exist only once the drag started, so a reached slot is a reorder however short the drag.\n if (d.flows && d.flowSlots && !d.brokeFromAutoLayout) {\n dropAlongFlows(d, d.flows, editor)\n editor.setDropTarget(null)\n if (isFlowClick(d, d.flows, d.flowSlots)) {\n deselectClicked(d, editor)\n }\n return\n }\n\n if (indicator) {\n if (getMoveDistance(d) < AUTO_LAYOUT_REORDER_CLICK_SLOP) {\n if (d.duplicated) {\n discardDuplicates(d, editor)\n return\n }\n editor.setDropTarget(null)\n deselectClicked(d, editor)\n return\n }\n // Claiming a slot records its own step; the batch makes it one undo with the reorder.\n editor.undo.runBatch('Reorder', () => {\n for (const id of d.originals.keys()) {\n editor.reorderInAutoLayout(id, indicator.parentId, indicator.index)\n }\n })\n editor.setDropTarget(null)\n return\n }\n\n const moved = hasMoved(d, editor)\n\n if (d.duplicated && !moved) {\n discardDuplicates(d, editor)\n return\n }\n\n if (!moved && !d.duplicated && getMoveDistance(d) < AUTO_LAYOUT_REORDER_CLICK_SLOP) {\n editor.setDropTarget(null)\n deselectClicked(d, editor)\n return\n }\n\n // The batch keeps a slot claim in the same undo step; it carries the edit's own name.\n editor.undo.runBatch(d.duplicated ? 'Duplicate' : 'Move', () => {\n if (moved) {\n ignoreTargetAutoLayout(d, editor)\n restoreOriginalPositions(d, editor)\n applyFinalPositions(d, editor)\n if (!d.keepParents) dropMovedNodes(d, editor)\n layOutOriginalParents(d, editor)\n }\n if (d.duplicated) {\n editor.commitDuplicateMove(\n [...d.originals.keys()],\n d.duplicatedPreviousSelection ?? new Set<string>()\n )\n } else if (moved) {\n editor.commitMoveWithReparent(d.originals)\n }\n // After the move is recorded, so undo restores the order before taking the layers back out.\n if (moved && !d.keepParents) placeAbsoluteDrop(d, editor)\n // Groups and booleans the layers left or moved inside fit their children again.\n if (moved) editor.fitEnclosingGroups(movedParentIds(d, editor))\n })\n editor.setDropTarget(null)\n}\n"],"mappings":";;;;;;AAkBA,MAAM,iCAAiC;;;;;;AAMvC,MAAM,kCAAkC;AACxC,MAAM,iCAAiC;;AAIvC,SAAS,kBACP,UACA,QACA,QACA;CACA,MAAM,SAAS,OAAO,MAAM,QAAQ,QAAQ;CAC5C,IAAI,CAAC,QAAQ,OAAO;CAGpB,MAAM,QAAQ,KAAK,IAAI,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;CAChE,MAAM,QAAQ,KAAK,IAAI,CAAC,OAAO,QAAQ,OAAO,MAAM,OAAO,MAAM;CACjE,MAAM,QAAQ,OAAO,eAAe;CAGpC,QAFc,QAAQ,QAAQ,UAEd,mCADD,QAAQ,QAAQ,UAC6B;AAC9D;;;;;;AAOA,SAAS,eAAe,GAAa,OAAmB,IAAY,IAAY,QAAgB;CAC9F,IAAI,EAAE,kBAAkB,OAAO;CAC/B,IACE,CAAC,MAAM,OAAO,SACZ,kBAAkB,KAAK,UAAU,gBAAgB,MAAM,IAAI,IAAI,MAAM,GAAG,MAAM,CAChF,GAEA,OAAO;CACT,EAAE,YAAY,MAAM,KAAK,SAAS,SAAS,MAAM,IAAI,IAAI,MAAM,CAAC;CAChE,MAAM,QAAQ,MAAM,WAAW,MAAM,MAAM,EAAE,YAAY,OAAO,KAAK,KAAK;CAC1E,MAAM,OAAO,UAAU,KAAK,KAAA,IAA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AAK,CAAC,GACtB,EAAE,+CAA+B,IAAI,IAAY,CACnD;OACK,IAAI,OACT,OAAO,uBAAuB,EAAE,SAAS;EAG3C,IAAI,SAAS,CAAC,EAAE,aAAa,kBAAkB,GAAG,MAAM;EAExD,IAAI,OAAO,OAAO,mBAAmB,eAAe,GAAG,MAAM,CAAC;CAChE,CAAC;CACD,OAAO,cAAc,IAAI;AAC3B"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getHitHandleByMatrix } from "../geometry.js";
|
|
2
2
|
import { layerResizes } from "@pairdraw/scene-graph/generated";
|
|
3
|
+
import { takesOwnSize } from "@pairdraw/scene-graph/instances";
|
|
3
4
|
import { enforcedAspectRatio } from "@pairdraw/scene-graph/layout";
|
|
4
5
|
import { collectResizeDescendants, createResizeSnapshot } from "@pairdraw/scene-graph/resize";
|
|
5
6
|
//#region src/shared/input/resize/start.ts
|
|
6
7
|
function tryStartResize(cx, cy, editor) {
|
|
7
8
|
for (const id of editor.state.selectedIds) {
|
|
8
9
|
const node = editor.graph.getNode(id);
|
|
9
|
-
if (!node || node.locked || !layerResizes(node)) continue;
|
|
10
|
+
if (!node || node.locked || !layerResizes(node) || !takesOwnSize(editor.graph, node)) continue;
|
|
10
11
|
const handleResult = getHitHandleByMatrix(cx, cy, node, editor.graph, editor.renderer?.zoom, editor.state.rotationPreview);
|
|
11
12
|
if (handleResult) {
|
|
12
13
|
const snap = createResizeSnapshot(node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","names":[],"sources":["../../../../src/shared/input/resize/start.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport { layerResizes } from '@pairdraw/scene-graph/generated'\nimport { enforcedAspectRatio } from '@pairdraw/scene-graph/layout'\nimport { collectResizeDescendants, createResizeSnapshot } from '@pairdraw/scene-graph/resize'\n\nimport { getHitHandleByMatrix } from '#vue/shared/input/geometry'\nimport type { DragResize } from '#vue/shared/input/types'\n\nexport function tryStartResize(cx: number, cy: number, editor: Editor): DragResize | null {\n for (const id of editor.state.selectedIds) {\n const node = editor.graph.getNode(id)\n // A sticky note only scales, from its corners; see `tryStartStickyScale`. A connector is\n // shaped by its ends.\n if (!node || node.locked || !layerResizes(node)) continue\n const handleResult = getHitHandleByMatrix(\n cx,\n cy,\n node,\n editor.graph,\n editor.renderer?.zoom,\n editor.state.rotationPreview\n )\n if (handleResult) {\n const snap = createResizeSnapshot(node)\n return {\n type: 'resize',\n handle: handleResult.handle,\n startX: cx,\n startY: cy,\n origRect: { x: node.x, y: node.y, width: node.width, height: node.height },\n nodeId: id,\n origVectorNetwork: snap.vectorNetwork,\n origFillGeometry: snap.fillGeometry,\n origStrokeGeometry: snap.strokeGeometry,\n origDerivedTextGlyphs: snap.derivedTextGlyphs,\n origStrokes: snap.strokes,\n origTextPathData: snap.textPathData,\n origTextPathBox: snap.textPathBox,\n origChildren: collectResizeDescendants(editor.graph, id),\n lockedAspectRatio: enforcedAspectRatio(node),\n appliedRect: { x: node.x, y: node.y, width: node.width, height: node.height }\n }\n }\n }\n return null\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"start.js","names":[],"sources":["../../../../src/shared/input/resize/start.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport { layerResizes } from '@pairdraw/scene-graph/generated'\nimport { takesOwnSize } from '@pairdraw/scene-graph/instances'\nimport { enforcedAspectRatio } from '@pairdraw/scene-graph/layout'\nimport { collectResizeDescendants, createResizeSnapshot } from '@pairdraw/scene-graph/resize'\n\nimport { getHitHandleByMatrix } from '#vue/shared/input/geometry'\nimport type { DragResize } from '#vue/shared/input/types'\n\nexport function tryStartResize(cx: number, cy: number, editor: Editor): DragResize | null {\n for (const id of editor.state.selectedIds) {\n const node = editor.graph.getNode(id)\n // A sticky note only scales, from its corners; see `tryStartStickyScale`. A connector is\n // shaped by its ends. A layer inside an instance takes its component's size, as in Figma.\n if (!node || node.locked || !layerResizes(node) || !takesOwnSize(editor.graph, node)) continue\n const handleResult = getHitHandleByMatrix(\n cx,\n cy,\n node,\n editor.graph,\n editor.renderer?.zoom,\n editor.state.rotationPreview\n )\n if (handleResult) {\n const snap = createResizeSnapshot(node)\n return {\n type: 'resize',\n handle: handleResult.handle,\n startX: cx,\n startY: cy,\n origRect: { x: node.x, y: node.y, width: node.width, height: node.height },\n nodeId: id,\n origVectorNetwork: snap.vectorNetwork,\n origFillGeometry: snap.fillGeometry,\n origStrokeGeometry: snap.strokeGeometry,\n origDerivedTextGlyphs: snap.derivedTextGlyphs,\n origStrokes: snap.strokes,\n origTextPathData: snap.textPathData,\n origTextPathBox: snap.textPathBox,\n origChildren: collectResizeDescendants(editor.graph, id),\n lockedAspectRatio: enforcedAspectRatio(node),\n appliedRect: { x: node.x, y: node.y, width: node.width, height: node.height }\n }\n }\n }\n return null\n}\n"],"mappings":";;;;;;AASA,SAAgB,eAAe,IAAY,IAAY,QAAmC;CACxF,KAAK,MAAM,MAAM,OAAO,MAAM,aAAa;EACzC,MAAM,OAAO,OAAO,MAAM,QAAQ,EAAE;EAGpC,IAAI,CAAC,QAAQ,KAAK,UAAU,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,OAAO,OAAO,IAAI,GAAG;EACtF,MAAM,eAAe,qBACnB,IACA,IACA,MACA,OAAO,OACP,OAAO,UAAU,MACjB,OAAO,MAAM,eACf;EACA,IAAI,cAAc;GAChB,MAAM,OAAO,qBAAqB,IAAI;GACtC,OAAO;IACL,MAAM;IACN,QAAQ,aAAa;IACrB,QAAQ;IACR,QAAQ;IACR,UAAU;KAAE,GAAG,KAAK;KAAG,GAAG,KAAK;KAAG,OAAO,KAAK;KAAO,QAAQ,KAAK;IAAO;IACzE,QAAQ;IACR,mBAAmB,KAAK;IACxB,kBAAkB,KAAK;IACvB,oBAAoB,KAAK;IACzB,uBAAuB,KAAK;IAC5B,aAAa,KAAK;IAClB,kBAAkB,KAAK;IACvB,iBAAiB,KAAK;IACtB,cAAc,yBAAyB,OAAO,OAAO,EAAE;IACvD,mBAAmB,oBAAoB,IAAI;IAC3C,aAAa;KAAE,GAAG,KAAK;KAAG,GAAG,KAAK;KAAG,OAAO,KAAK;KAAO,QAAQ,KAAK;IAAO;GAC9E;EACF;CACF;CACA,OAAO;AACT"}
|
|
@@ -13,8 +13,8 @@ function selectionIsLocked(editor) {
|
|
|
13
13
|
* Whether pressing `hit` should drag the current selection, as in Figma: the hit lies inside a
|
|
14
14
|
* selected layer, or a selected layer under the point lies inside the hit group or boolean.
|
|
15
15
|
*/
|
|
16
|
-
function
|
|
17
|
-
return [...editor.state.selectedIds].
|
|
16
|
+
function selectedLayerHoldingPress(hit, cx, cy, editor) {
|
|
17
|
+
return [...editor.state.selectedIds].find((id) => {
|
|
18
18
|
if (id === hit.id) return false;
|
|
19
19
|
if (editor.graph.isDescendant(hit.id, id)) return true;
|
|
20
20
|
return editor.graph.isDescendant(id, hit.id) && editor.graph.isPointInNode(id, cx, cy);
|
|
@@ -90,7 +90,12 @@ function createSelectionMoveDrag(cx, cy, sx, sy, editor, duplicate) {
|
|
|
90
90
|
flows: collectFlowDrags(originals, editor)
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
+
function pressedSelectedLayer(hit, selects, cx, cy, editor) {
|
|
94
|
+
if (editor.state.selectedIds.has(hit.id)) return hit.id;
|
|
95
|
+
if (selects) return void 0;
|
|
96
|
+
return selectedLayerHoldingPress(hit, cx, cy, editor);
|
|
97
|
+
}
|
|
93
98
|
//#endregion
|
|
94
|
-
export { clickSelectsInside, createSelectionMoveDrag,
|
|
99
|
+
export { clickSelectsInside, createSelectionMoveDrag, pressedSelectedLayer, selectedLayerHoldingPress, selectionIsLocked };
|
|
95
100
|
|
|
96
101
|
//# sourceMappingURL=move.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move.js","names":[],"sources":["../../../../src/shared/input/select/move.ts"],"sourcesContent":["import type { Editor, MovePlace } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { duplicateAndDrag } from '#vue/shared/input/duplicate-drag'\nimport { collectFlowDrags } from '#vue/shared/input/flow-reorder'\nimport type {
|
|
1
|
+
{"version":3,"file":"move.js","names":[],"sources":["../../../../src/shared/input/select/move.ts"],"sourcesContent":["import type { Editor, MovePlace } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { duplicateAndDrag } from '#vue/shared/input/duplicate-drag'\nimport { collectFlowDrags } from '#vue/shared/input/flow-reorder'\nimport type { DragMove } from '#vue/shared/input/types'\n\nfunction isLockedInTree(id: string, editor: Editor) {\n for (\n let node = editor.graph.getNode(id);\n node;\n node = editor.graph.getNode(node.parentId ?? '')\n ) {\n if (node.locked) return true\n }\n return false\n}\n\n/** Whether nothing selected can move: locked layers, and layers inside locked ones, stay put. */\nexport function selectionIsLocked(editor: Editor) {\n return [...editor.state.selectedIds].every((id) => isLockedInTree(id, editor))\n}\n\n/**\n * Whether pressing `hit` should drag the current selection, as in Figma: the hit lies inside a\n * selected layer, or a selected layer under the point lies inside the hit group or boolean.\n */\nexport function selectedLayerHoldingPress(hit: SceneNode, cx: number, cy: number, editor: Editor) {\n return [...editor.state.selectedIds].find((id) => {\n if (id === hit.id) return false\n if (editor.graph.isDescendant(hit.id, id)) return true\n return editor.graph.isDescendant(id, hit.id) && editor.graph.isPointInNode(id, cx, cy)\n })\n}\n\n/** Whether clicking `hit` inside the selection selects it: not when a selected group holds it. */\nexport function clickSelectsInside(hit: SceneNode, editor: Editor) {\n for (let node = editor.graph.getNode(hit.parentId ?? ''); node;) {\n if (editor.state.selectedIds.has(node.id)) {\n return node.type !== 'GROUP' && node.type !== 'BOOLEAN_OPERATION'\n }\n node = editor.graph.getNode(node.parentId ?? '')\n }\n return false\n}\n\nfunction autoLayoutMoveTarget(id: string, editor: Editor): string {\n let current = editor.graph.getNode(id)\n let target = current\n\n while (current?.parentId) {\n const parent = editor.graph.getNode(current.parentId)\n if (!parent) break\n if (\n current.type === 'INSTANCE' &&\n parent.layoutMode !== 'NONE' &&\n current.layoutPositioning !== 'ABSOLUTE'\n ) {\n target = current\n }\n current = parent\n }\n\n return target?.id ?? id\n}\n\n/** Whether a connector holds onto a layer at either end. */\nfunction joinsLayer(node: SceneNode) {\n return (\n node.type === 'CONNECTOR' && [node.connectorStart, node.connectorEnd].some((end) => end?.nodeId)\n )\n}\n\nfunction collectMoveOriginals(editor: Editor) {\n const originals = new Map<string, MovePlace>()\n for (const selectedId of editor.state.selectedIds) {\n if (isLockedInTree(selectedId, editor)) continue\n const id = autoLayoutMoveTarget(selectedId, editor)\n const node = editor.graph.getNode(id)\n if (node) {\n const parentId = node.parentId ?? editor.state.currentPageId\n originals.set(id, {\n x: node.x,\n y: node.y,\n parentId,\n index: editor.graph.getNode(parentId)?.childIds.indexOf(id)\n })\n }\n }\n // FigJam moves a connector held by a layer only along with other layers; dragged alone, it\n // stays put.\n const [only] = originals.keys()\n const lone = originals.size === 1 ? editor.graph.getNode(only) : undefined\n if (lone && joinsLayer(lone)) originals.clear()\n return originals\n}\n\nfunction detectDragAutoLayoutParent(originals: Map<string, MovePlace>, editor: Editor) {\n if (originals.size !== 1) return undefined\n const [id, original] = [...originals][0]\n const node = editor.graph.getNode(id)\n const parent = editor.graph.getNode(original.parentId)\n if (parent && parent.layoutMode !== 'NONE' && node?.layoutPositioning !== 'ABSOLUTE') {\n return parent.id\n }\n return undefined\n}\n\nexport function createSelectionMoveDrag(\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor,\n duplicate: boolean\n): DragMove {\n if (duplicate && editor.state.selectedIds.size > 0)\n return duplicateAndDrag(cx, cy, sx, sy, editor).drag\n\n const originals = collectMoveOriginals(editor)\n\n return {\n type: 'move',\n startX: cx,\n startY: cy,\n currentX: cx,\n currentY: cy,\n appliedDx: 0,\n appliedDy: 0,\n startScreenX: sx,\n startScreenY: sy,\n dragStarted: false,\n originals,\n autoLayoutParentId: detectDragAutoLayoutParent(originals, editor),\n flows: collectFlowDrags(originals, editor)\n }\n}\n\nexport function pressedSelectedLayer(\n hit: SceneNode,\n selects: boolean,\n cx: number,\n cy: number,\n editor: Editor\n): string | undefined {\n if (editor.state.selectedIds.has(hit.id)) return hit.id\n if (selects) return undefined\n return selectedLayerHoldingPress(hit, cx, cy, editor)\n}\n"],"mappings":";;;AAOA,SAAS,eAAe,IAAY,QAAgB;CAClD,KACE,IAAI,OAAO,OAAO,MAAM,QAAQ,EAAE,GAClC,MACA,OAAO,OAAO,MAAM,QAAQ,KAAK,YAAY,EAAE,GAE/C,IAAI,KAAK,QAAQ,OAAO;CAE1B,OAAO;AACT;;AAGA,SAAgB,kBAAkB,QAAgB;CAChD,OAAO,CAAC,GAAG,OAAO,MAAM,WAAW,CAAC,CAAC,OAAO,OAAO,eAAe,IAAI,MAAM,CAAC;AAC/E;;;;;AAMA,SAAgB,0BAA0B,KAAgB,IAAY,IAAY,QAAgB;CAChG,OAAO,CAAC,GAAG,OAAO,MAAM,WAAW,CAAC,CAAC,MAAM,OAAO;EAChD,IAAI,OAAO,IAAI,IAAI,OAAO;EAC1B,IAAI,OAAO,MAAM,aAAa,IAAI,IAAI,EAAE,GAAG,OAAO;EAClD,OAAO,OAAO,MAAM,aAAa,IAAI,IAAI,EAAE,KAAK,OAAO,MAAM,cAAc,IAAI,IAAI,EAAE;CACvF,CAAC;AACH;;AAGA,SAAgB,mBAAmB,KAAgB,QAAgB;CACjE,KAAK,IAAI,OAAO,OAAO,MAAM,QAAQ,IAAI,YAAY,EAAE,GAAG,OAAO;EAC/D,IAAI,OAAO,MAAM,YAAY,IAAI,KAAK,EAAE,GACtC,OAAO,KAAK,SAAS,WAAW,KAAK,SAAS;EAEhD,OAAO,OAAO,MAAM,QAAQ,KAAK,YAAY,EAAE;CACjD;CACA,OAAO;AACT;AAEA,SAAS,qBAAqB,IAAY,QAAwB;CAChE,IAAI,UAAU,OAAO,MAAM,QAAQ,EAAE;CACrC,IAAI,SAAS;CAEb,OAAO,SAAS,UAAU;EACxB,MAAM,S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OAAO;AAGlB;AAEA,SAAgB,wBACd,IACA,IACA,IACA,IACA,QACA,WACU;CACV,IAAI,aAAa,OAAO,MAAM,YAAY,OAAO,GAC/C,OAAO,iBAAiB,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC;CAElD,MAAM,YAAY,qBAAqB,MAAM;CAE7C,OAAO;EACL,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,UAAU;EACV,WAAW;EACX,WAAW;EACX,cAAc;EACd,cAAc;EACd,aAAa;EACb;EACA,oBAAoB,2BAA2B,WAAW,MAAM;EAChE,OAAO,iBAAiB,WAAW,MAAM;CAC3C;AACF;AAEA,SAAgB,qBACd,KACA,SACA,IACA,IACA,QACoB;CACpB,IAAI,OAAO,MAAM,YAAY,IAAI,IAAI,EAAE,GAAG,OAAO,IAAI;CACrD,IAAI,SAAS,OAAO,KAAA;CACpB,OAAO,0BAA0B,KAAK,IAAI,IAAI,MAAM;AACtD"}
|
|
@@ -9,7 +9,7 @@ import { tryStartLineEndDrag } from "./line/end.js";
|
|
|
9
9
|
import { updateHoverCursor } from "./select/hover.js";
|
|
10
10
|
import { tryStartConnectorEndDrag } from "./connector/end.js";
|
|
11
11
|
import { tryStartGradientDrag } from "./gradient.js";
|
|
12
|
-
import { clickSelectsInside, createSelectionMoveDrag,
|
|
12
|
+
import { clickSelectsInside, createSelectionMoveDrag, pressedSelectedLayer, selectedLayerHoldingPress, selectionIsLocked } from "./select/move.js";
|
|
13
13
|
import { tryStartShapeHandleDrag } from "./shape-handles.js";
|
|
14
14
|
import { editedGradient, editedImage, resolveEditorProfile } from "@pairdraw/core";
|
|
15
15
|
//#region src/shared/input/select.ts
|
|
@@ -36,7 +36,7 @@ function startMarquee(cx, cy, editor, setDrag) {
|
|
|
36
36
|
*/
|
|
37
37
|
function startsDeepMarquee(hit, e, cx, cy, editor, fns) {
|
|
38
38
|
const scopeId = editor.state.enteredContainerId ?? editor.state.currentPageId;
|
|
39
|
-
return !e.shiftKey && !hit.locked && !editor.state.selectedIds.has(hit.id) && !
|
|
39
|
+
return !e.shiftKey && !hit.locked && !editor.state.selectedIds.has(hit.id) && !selectedLayerHoldingPress(hit, cx, cy, editor) && !hitTestLabel(cx, cy, fns) && editor.graph.hitTestOpenContainer(cx, cy, scopeId)?.id === hit.id;
|
|
40
40
|
}
|
|
41
41
|
/** Starts a ⌘ marquee scoped to the pressed container; a click without a drag still selects it. */
|
|
42
42
|
function startDeepMarquee(hit, cx, cy, editor, setDrag) {
|
|
@@ -85,6 +85,25 @@ function selectOnPress(hit, shiftKey, keepsSelection, editor) {
|
|
|
85
85
|
function selectInsideOnPress(hit, keepsSelection, editor) {
|
|
86
86
|
if (keepsSelection && !editor.state.selectedIds.has(hit.id) && clickSelectsInside(hit, editor)) editor.select([hit.id]);
|
|
87
87
|
}
|
|
88
|
+
/** What a press on `hit` selects, and the drag it starts, as a layer press does. */
|
|
89
|
+
function pressLayers(hit, e, cx, cy, sx, sy, editor, setDrag) {
|
|
90
|
+
const keepsSelection = !e.shiftKey && Boolean(selectedLayerHoldingPress(hit, cx, cy, editor));
|
|
91
|
+
const shiftPressedSelectedId = e.shiftKey ? pressedSelectedLayer(hit, !keepsSelection, cx, cy, editor) : void 0;
|
|
92
|
+
if (!shiftPressedSelectedId) selectOnPress(hit, e.shiftKey, keepsSelection, editor);
|
|
93
|
+
if (!resolveEditorProfile(editor.state).edits) {
|
|
94
|
+
if (shiftPressedSelectedId) editor.select([shiftPressedSelectedId], true);
|
|
95
|
+
selectInsideOnPress(hit, keepsSelection, editor);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (selectionIsLocked(editor)) {
|
|
99
|
+
if (shiftPressedSelectedId) editor.select([shiftPressedSelectedId], true);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const drag = createSelectionMoveDrag(cx, cy, sx, sy, editor, e.altKey);
|
|
103
|
+
drag.clickDeselectsId = shiftPressedSelectedId;
|
|
104
|
+
if (keepsSelection && !editor.state.selectedIds.has(hit.id)) drag.selectOnClick = clickSelectsInside(hit, editor) ? hit.id : void 0;
|
|
105
|
+
setDrag(drag);
|
|
106
|
+
}
|
|
88
107
|
function handleSelectDown(e, cx, cy, sx, sy, editor, fns, tryStartRotation, handleTextEditClick, setDrag) {
|
|
89
108
|
if (getNodeEditState(editor)) {
|
|
90
109
|
handleNodeEditDown(e, cx, cy, editor, setDrag);
|
|
@@ -103,16 +122,7 @@ function handleSelectDown(e, cx, cy, sx, sy, editor, fns, tryStartRotation, hand
|
|
|
103
122
|
startDeepMarquee(hit, cx, cy, editor, setDrag);
|
|
104
123
|
return;
|
|
105
124
|
}
|
|
106
|
-
|
|
107
|
-
selectOnPress(hit, e.shiftKey, keepsSelection, editor);
|
|
108
|
-
if (!resolveEditorProfile(editor.state).edits) {
|
|
109
|
-
selectInsideOnPress(hit, keepsSelection, editor);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (selectionIsLocked(editor)) return;
|
|
113
|
-
const drag = createSelectionMoveDrag(cx, cy, sx, sy, editor, e.altKey);
|
|
114
|
-
if (drag.type === "move" && keepsSelection && !editor.state.selectedIds.has(hit.id)) drag.selectOnClick = clickSelectsInside(hit, editor) ? hit.id : void 0;
|
|
115
|
-
setDrag(drag);
|
|
125
|
+
pressLayers(hit, e, cx, cy, sx, sy, editor, setDrag);
|
|
116
126
|
}
|
|
117
127
|
//#endregion
|
|
118
128
|
export { handleSelectDown, updateHoverCursor };
|
|
@@ -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 pressesSelection,\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 !pressesSelection(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\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 const keepsSelection = !e.shiftKey && pressesSelection(hit, cx, cy, editor)\n selectOnPress(hit, e.shiftKey, keepsSelection, editor)\n\n if (!resolveEditorProfile(editor.state).edits) {\n selectInsideOnPress(hit, keepsSelection, editor)\n return\n }\n if (selectionIsLocked(editor)) return\n\n const drag = createSelectionMoveDrag(cx, cy, sx, sy, editor, e.altKey)\n // A click without dragging still selects a layer inside a selected frame; groups need a double-click.\n if (drag.type === 'move' && keepsSelection && !editor.state.selectedIds.has(hit.id)) {\n drag.selectOnClick = clickSelectsInside(hit, editor) ? hit.id : undefined\n }\n setDrag(drag)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,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,iBAAiB,KAAK,IAAI,IAAI,MAAM,KACrC,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,SAAS,mBACP,IACA,IACA,IACA,IACA,QACA,QACA,KACA,kBACA,SACS;CACT,IAAI,CAAC,qBAAqB,OAAO,KAAK,CAAC,CAAC,OAAO,OAAO;CACtD,IAAI,qBAAqB,QAAQ,IAAI,IAAI,OAAO,GAAG,OAAO;CAE1D,IAAI,eAAe,OAAO,OAAO,OAAO,MAAM,YAAY,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AI,OAAO,MAAM,iBAAiB,oBAAoB,IAAI,IAAI,EAAE,QAAQ,GAAG;CAE3E,IAAI,OAAO,MAAM,eAAe,OAAO,eAAe;CAEtD,IAAI,mBAAmB,IAAI,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,MAAM,iBAAiB,CAAC,EAAE,YAAY,iBAAiB,KAAK,IAAI,IAAI,MAAM;CAC1E,cAAc,KAAK,EAAE,UAAU,gBAAgB,MAAM;CAErD,IAAI,CAAC,qBAAqB,OAAO,KAAK,CAAC,CAAC,OAAO;EAC7C,oBAAoB,KAAK,gBAAgB,MAAM;EAC/C;CACF;CACA,IAAI,kBAAkB,MAAM,GAAG;CAE/B,MAAM,OAAO,wBAAwB,IAAI,IAAI,IAAI,IAAI,QAAQ,EAAE,MAAM;CAErE,IAAI,KAAK,SAAS,UAAU,kBAAkB,CAAC,OAAO,MAAM,YAAY,IAAI,IAAI,EAAE,GAChF,KAAK,gBAAgB,mBAAmB,KAAK,MAAM,IAAI,IAAI,KAAK,KAAA;CAElE,QAAQ,IAAI;AACd"}
|
|
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,EAA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,KAAA;CAElE,QAAQ,IAAI;AACd;AAEA,SAAgB,iBACd,GACA,IACA,IACA,IACA,IACA,QACA,KACA,kBACA,qBACA,SACA;CAEA,IAAI,iBAAiB,MAAM,GAAG;EAC5B,mBAAmB,GAAG,IAAI,IAAI,QAAQ,OAAO;EAC7C;CACF;CAEA,IAAI,OAAO,MAAM,iBAAiB,oBAAoB,IAAI,IAAI,EAAE,QAAQ,GAAG;CAE3E,IAAI,OAAO,MAAM,eAAe,OAAO,eAAe;CAEtD,IAAI,mBAAmB,IAAI,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"}
|
|
@@ -115,6 +115,8 @@ interface DragMove {
|
|
|
115
115
|
selectOnClick?: string;
|
|
116
116
|
/** Where Control drops layers among an auto layout frame's children. */
|
|
117
117
|
absoluteInsertIndex?: number;
|
|
118
|
+
/** A selected layer a Shift-press on it deselects when it ends without a drag. */
|
|
119
|
+
clickDeselectsId?: string;
|
|
118
120
|
}
|
|
119
121
|
interface DragPan {
|
|
120
122
|
type: 'pan';
|
|
@@ -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;;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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ACA,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}\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":";AAkYA,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\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.d.ts","names":[],"sources":["../../src/variables/use.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"use.d.ts","names":[],"sources":["../../src/variables/use.ts"],"mappings":";;iBAUgB;;;;;;;;;;;;;;;;;;;;uCAAA;;EAIe,gBAAA"}
|
package/dist/variables/use.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useSceneComputed } from "../internal/scene-computed/use.js";
|
|
|
3
3
|
import { fuzzyFilter } from "../shared/search/fuzzy.js";
|
|
4
4
|
import { createVariableCollectionActions, createVariableValueActions } from "./helpers.js";
|
|
5
5
|
import { computed, ref, watch } from "vue";
|
|
6
|
+
import { modesInListedOrder } from "@pairdraw/scene-graph/variables";
|
|
6
7
|
//#region src/variables/use.ts
|
|
7
8
|
function useVariables() {
|
|
8
9
|
const editor = useEditor();
|
|
@@ -20,7 +21,7 @@ function useVariables() {
|
|
|
20
21
|
if (!activeCollectionId.value && cols[0]) activeCollectionId.value = cols[0].id;
|
|
21
22
|
});
|
|
22
23
|
const activeCollection = computed(() => collections.value.find((collection) => collection.id === activeCollectionId.value) ?? null);
|
|
23
|
-
const activeModes = computed(() => activeCollection.value
|
|
24
|
+
const activeModes = computed(() => activeCollection.value ? modesInListedOrder(activeCollection.value) : []);
|
|
24
25
|
const variables = useSceneComputed(() => {
|
|
25
26
|
if (!activeCollectionId.value) return [];
|
|
26
27
|
const all = editor.getVariablesForCollection(activeCollectionId.value).map((variable) => structuredClone(variable));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","names":[],"sources":["../../src/variables/use.ts"],"sourcesContent":["import { ref, computed, watch } from 'vue'\n\nimport type { Variable } from '@pairdraw/scene-graph'\n\nimport { useEditor } from '#vue/editor/context'\nimport { useSceneComputed } from '#vue/internal/scene-computed/use'\nimport { fuzzyFilter } from '#vue/shared/search/fuzzy'\nimport { createVariableCollectionActions, createVariableValueActions } from '#vue/variables/helpers'\n\nexport function useVariables() {\n const editor = useEditor()\n const searchTerm = ref('')\n\n function setSearchTerm(term: string) {\n searchTerm.value = term\n }\n\n /**\n * Snapshots, not the graph's own objects: the editor edits collections in place, so a component\n * given the same object again would not see a mode added, renamed, or given a condition.\n */\n const collections = useSceneComputed(() =>\n editor.getCollections().map((collection) => structuredClone(collection))\n )\n\n const activeCollectionId = ref(collections.value[0]?.id ?? '')\n watch(collections, (cols) => {\n if (!activeCollectionId.value && cols[0]) activeCollectionId.value = cols[0].id\n })\n\n const activeCollection = computed(\n () => collections.value.find((collection) => collection.id === activeCollectionId.value) ?? null\n )\n const activeModes = computed(()
|
|
1
|
+
{"version":3,"file":"use.js","names":[],"sources":["../../src/variables/use.ts"],"sourcesContent":["import { ref, computed, watch } from 'vue'\n\nimport type { Variable } from '@pairdraw/scene-graph'\nimport { modesInListedOrder } from '@pairdraw/scene-graph/variables'\n\nimport { useEditor } from '#vue/editor/context'\nimport { useSceneComputed } from '#vue/internal/scene-computed/use'\nimport { fuzzyFilter } from '#vue/shared/search/fuzzy'\nimport { createVariableCollectionActions, createVariableValueActions } from '#vue/variables/helpers'\n\nexport function useVariables() {\n const editor = useEditor()\n const searchTerm = ref('')\n\n function setSearchTerm(term: string) {\n searchTerm.value = term\n }\n\n /**\n * Snapshots, not the graph's own objects: the editor edits collections in place, so a component\n * given the same object again would not see a mode added, renamed, or given a condition.\n */\n const collections = useSceneComputed(() =>\n editor.getCollections().map((collection) => structuredClone(collection))\n )\n\n const activeCollectionId = ref(collections.value[0]?.id ?? '')\n watch(collections, (cols) => {\n if (!activeCollectionId.value && cols[0]) activeCollectionId.value = cols[0].id\n })\n\n const activeCollection = computed(\n () => collections.value.find((collection) => collection.id === activeCollectionId.value) ?? null\n )\n // The panel lists modes as Figma does, by sort position; the collection's array keeps the\n // file's saved order for export.\n const activeModes = computed(() =>\n activeCollection.value ? modesInListedOrder(activeCollection.value) : []\n )\n\n const variables = useSceneComputed(() => {\n if (!activeCollectionId.value) return [] as Variable[]\n const all = editor\n .getVariablesForCollection(activeCollectionId.value)\n .map((variable) => structuredClone(variable))\n return fuzzyFilter(all, ['name', 'description'], searchTerm.value)\n })\n\n const collectionActions = createVariableCollectionActions(editor, activeCollectionId)\n const variableActions = createVariableValueActions(editor, () => activeCollection.value)\n\n return {\n editor,\n collections,\n activeCollectionId,\n activeCollection,\n activeModes,\n variables,\n searchTerm,\n setSearchTerm,\n ...collectionActions,\n ...variableActions\n }\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,eAAe;CAC7B,MAAM,SAAS,UAAU;CACzB,MAAM,aAAa,IAAI,EAAE;CAEzB,SAAS,cAAc,MAAc;EACnC,WAAW,QAAQ;CACrB;;;;;CAMA,MAAM,cAAc,uBAClB,OAAO,eAAe,CAAC,CAAC,KAAK,eAAe,gBAAgB,UAAU,CAAC,CACzE;CAEA,MAAM,qBAAqB,IAAI,YAAY,MAAM,EAAE,EAAE,MAAM,EAAE;CAC7D,MAAM,cAAc,SAAS;EAC3B,IAAI,CAAC,mBAAmB,SAAS,KAAK,IAAI,mBAAmB,QAAQ,KAAK,EAAE,CAAC;CAC/E,CAAC;CAED,MAAM,mBAAmB,eACjB,YAAY,MAAM,MAAM,eAAe,WAAW,OAAO,mBAAmB,KAAK,KAAK,IAC9F;CAGA,MAAM,cAAc,eAClB,iBAAiB,QAAQ,mBAAmB,iBAAiB,KAAK,IAAI,CAAC,CACzE;CAEA,MAAM,YAAY,uBAAuB;EACvC,IAAI,CAAC,mBAAmB,OAAO,OAAO,CAAC;EACvC,MAAM,MAAM,OACT,0BAA0B,mBAAmB,KAAK,CAAC,CACnD,KAAK,aAAa,gBAAgB,QAAQ,CAAC;EAC9C,OAAO,YAAY,KAAK,CAAC,QAAQ,aAAa,GAAG,WAAW,KAAK;CACnE,CAAC;CAED,MAAM,oBAAoB,gCAAgC,QAAQ,kBAAkB;CACpF,MAAM,kBAAkB,2BAA2B,cAAc,iBAAiB,KAAK;CAEvF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;EACH,GAAG;CACL;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pairdraw/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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.19.0",
|
|
17
|
+
"@pairdraw/scene-graph": "^0.19.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.19.0",
|
|
28
28
|
"canvaskit-wasm": ">=0.41.1",
|
|
29
29
|
"vue": "^3.5.41"
|
|
30
30
|
},
|