@oh-just-another/state 0.57.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/actions/actionClipboard.d.ts +6 -0
- package/dist/actions/actionClipboard.d.ts.map +1 -0
- package/dist/actions/actionClipboard.js +26 -0
- package/dist/actions/actionClipboard.js.map +1 -0
- package/dist/actions/actionGrouping.d.ts +5 -0
- package/dist/actions/actionGrouping.d.ts.map +1 -0
- package/dist/actions/actionGrouping.js +26 -0
- package/dist/actions/actionGrouping.js.map +1 -0
- package/dist/actions/actionHistory.d.ts +5 -0
- package/dist/actions/actionHistory.d.ts.map +1 -0
- package/dist/actions/actionHistory.js +25 -0
- package/dist/actions/actionHistory.js.map +1 -0
- package/dist/actions/actionKeyboard.d.ts +3 -0
- package/dist/actions/actionKeyboard.d.ts.map +1 -0
- package/dist/actions/actionKeyboard.js +130 -0
- package/dist/actions/actionKeyboard.js.map +1 -0
- package/dist/actions/actionLayout.d.ts +3 -0
- package/dist/actions/actionLayout.d.ts.map +1 -0
- package/dist/actions/actionLayout.js +65 -0
- package/dist/actions/actionLayout.js.map +1 -0
- package/dist/actions/actionMode.d.ts +13 -0
- package/dist/actions/actionMode.d.ts.map +1 -0
- package/dist/actions/actionMode.js +116 -0
- package/dist/actions/actionMode.js.map +1 -0
- package/dist/actions/actionSelection.d.ts +9 -0
- package/dist/actions/actionSelection.d.ts.map +1 -0
- package/dist/actions/actionSelection.js +57 -0
- package/dist/actions/actionSelection.js.map +1 -0
- package/dist/actions/actionView.d.ts +7 -0
- package/dist/actions/actionView.d.ts.map +1 -0
- package/dist/actions/actionView.js +14 -0
- package/dist/actions/actionView.js.map +1 -0
- package/dist/actions/actionZOrder.d.ts +7 -0
- package/dist/actions/actionZOrder.d.ts.map +1 -0
- package/dist/actions/actionZOrder.js +42 -0
- package/dist/actions/actionZOrder.js.map +1 -0
- package/dist/actions/actionZoom.d.ts +8 -0
- package/dist/actions/actionZoom.d.ts.map +1 -0
- package/dist/actions/actionZoom.js +61 -0
- package/dist/actions/actionZoom.js.map +1 -0
- package/dist/actions/index.d.ts +12 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +11 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/registry.d.ts +68 -0
- package/dist/actions/registry.d.ts.map +1 -0
- package/dist/actions/registry.js +300 -0
- package/dist/actions/registry.js.map +1 -0
- package/dist/actions/types.d.ts +103 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/types.js +10 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/animation-tick.d.ts +28 -0
- package/dist/animation-tick.d.ts.map +1 -0
- package/dist/animation-tick.js +50 -0
- package/dist/animation-tick.js.map +1 -0
- package/dist/auto-compact.d.ts +27 -0
- package/dist/auto-compact.d.ts.map +1 -0
- package/dist/auto-compact.js +46 -0
- package/dist/auto-compact.js.map +1 -0
- package/dist/auto-layout-scheduler.d.ts +50 -0
- package/dist/auto-layout-scheduler.d.ts.map +1 -0
- package/dist/auto-layout-scheduler.js +94 -0
- package/dist/auto-layout-scheduler.js.map +1 -0
- package/dist/built-in-handlers.d.ts +24 -0
- package/dist/built-in-handlers.d.ts.map +1 -0
- package/dist/built-in-handlers.js +210 -0
- package/dist/built-in-handlers.js.map +1 -0
- package/dist/clipboard.d.ts +51 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +105 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/constants.d.ts +544 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +537 -0
- package/dist/constants.js.map +1 -0
- package/dist/dom-events.d.ts +13 -0
- package/dist/dom-events.d.ts.map +1 -0
- package/dist/dom-events.js +70 -0
- package/dist/dom-events.js.map +1 -0
- package/dist/editor/anchor-points.d.ts +22 -0
- package/dist/editor/anchor-points.d.ts.map +1 -0
- package/dist/editor/anchor-points.js +28 -0
- package/dist/editor/anchor-points.js.map +1 -0
- package/dist/editor/applies/create.d.ts +60 -0
- package/dist/editor/applies/create.d.ts.map +1 -0
- package/dist/editor/applies/create.js +107 -0
- package/dist/editor/applies/create.js.map +1 -0
- package/dist/editor/applies/edge.d.ts +32 -0
- package/dist/editor/applies/edge.d.ts.map +1 -0
- package/dist/editor/applies/edge.js +44 -0
- package/dist/editor/applies/edge.js.map +1 -0
- package/dist/editor/applies/link-move.d.ts +53 -0
- package/dist/editor/applies/link-move.d.ts.map +1 -0
- package/dist/editor/applies/link-move.js +160 -0
- package/dist/editor/applies/link-move.js.map +1 -0
- package/dist/editor/applies/move.d.ts +38 -0
- package/dist/editor/applies/move.d.ts.map +1 -0
- package/dist/editor/applies/move.js +83 -0
- package/dist/editor/applies/move.js.map +1 -0
- package/dist/editor/applies/resize.d.ts +68 -0
- package/dist/editor/applies/resize.d.ts.map +1 -0
- package/dist/editor/applies/resize.js +199 -0
- package/dist/editor/applies/resize.js.map +1 -0
- package/dist/editor/applies/selection.d.ts +34 -0
- package/dist/editor/applies/selection.d.ts.map +1 -0
- package/dist/editor/applies/selection.js +65 -0
- package/dist/editor/applies/selection.js.map +1 -0
- package/dist/editor/applies/snap-grid.d.ts +45 -0
- package/dist/editor/applies/snap-grid.d.ts.map +1 -0
- package/dist/editor/applies/snap-grid.js +90 -0
- package/dist/editor/applies/snap-grid.js.map +1 -0
- package/dist/editor/container-ops.d.ts +74 -0
- package/dist/editor/container-ops.d.ts.map +1 -0
- package/dist/editor/container-ops.js +262 -0
- package/dist/editor/container-ops.js.map +1 -0
- package/dist/editor/event-fanout.d.ts +48 -0
- package/dist/editor/event-fanout.d.ts.map +1 -0
- package/dist/editor/event-fanout.js +53 -0
- package/dist/editor/event-fanout.js.map +1 -0
- package/dist/editor/gesture-tx.d.ts +77 -0
- package/dist/editor/gesture-tx.d.ts.map +1 -0
- package/dist/editor/gesture-tx.js +93 -0
- package/dist/editor/gesture-tx.js.map +1 -0
- package/dist/editor/hit-test.d.ts +178 -0
- package/dist/editor/hit-test.d.ts.map +1 -0
- package/dist/editor/hit-test.js +460 -0
- package/dist/editor/hit-test.js.map +1 -0
- package/dist/editor/long-press.d.ts +34 -0
- package/dist/editor/long-press.d.ts.map +1 -0
- package/dist/editor/long-press.js +58 -0
- package/dist/editor/long-press.js.map +1 -0
- package/dist/editor/pinch.d.ts +37 -0
- package/dist/editor/pinch.d.ts.map +1 -0
- package/dist/editor/pinch.js +90 -0
- package/dist/editor/pinch.js.map +1 -0
- package/dist/editor/pointer-binding.d.ts +18 -0
- package/dist/editor/pointer-binding.d.ts.map +1 -0
- package/dist/editor/pointer-binding.js +1087 -0
- package/dist/editor/pointer-binding.js.map +1 -0
- package/dist/editor/public/annotations.d.ts +54 -0
- package/dist/editor/public/annotations.d.ts.map +1 -0
- package/dist/editor/public/annotations.js +106 -0
- package/dist/editor/public/annotations.js.map +1 -0
- package/dist/editor/public/arrange-group.d.ts +81 -0
- package/dist/editor/public/arrange-group.d.ts.map +1 -0
- package/dist/editor/public/arrange-group.js +193 -0
- package/dist/editor/public/arrange-group.js.map +1 -0
- package/dist/editor/public/brush.d.ts +33 -0
- package/dist/editor/public/brush.d.ts.map +1 -0
- package/dist/editor/public/brush.js +54 -0
- package/dist/editor/public/brush.js.map +1 -0
- package/dist/editor/public/clipboard.d.ts +31 -0
- package/dist/editor/public/clipboard.d.ts.map +1 -0
- package/dist/editor/public/clipboard.js +35 -0
- package/dist/editor/public/clipboard.js.map +1 -0
- package/dist/editor/public/image-insert.d.ts +30 -0
- package/dist/editor/public/image-insert.d.ts.map +1 -0
- package/dist/editor/public/image-insert.js +57 -0
- package/dist/editor/public/image-insert.js.map +1 -0
- package/dist/editor/public/layers.d.ts +56 -0
- package/dist/editor/public/layers.d.ts.map +1 -0
- package/dist/editor/public/layers.js +104 -0
- package/dist/editor/public/layers.js.map +1 -0
- package/dist/editor/public/link.d.ts +25 -0
- package/dist/editor/public/link.d.ts.map +1 -0
- package/dist/editor/public/link.js +74 -0
- package/dist/editor/public/link.js.map +1 -0
- package/dist/editor/public/placement.d.ts +60 -0
- package/dist/editor/public/placement.d.ts.map +1 -0
- package/dist/editor/public/placement.js +111 -0
- package/dist/editor/public/placement.js.map +1 -0
- package/dist/editor/public/selection-ops.d.ts +78 -0
- package/dist/editor/public/selection-ops.d.ts.map +1 -0
- package/dist/editor/public/selection-ops.js +226 -0
- package/dist/editor/public/selection-ops.js.map +1 -0
- package/dist/editor/public/text-edit.d.ts +17 -0
- package/dist/editor/public/text-edit.d.ts.map +1 -0
- package/dist/editor/public/text-edit.js +28 -0
- package/dist/editor/public/text-edit.js.map +1 -0
- package/dist/editor/public/z-order.d.ts +47 -0
- package/dist/editor/public/z-order.d.ts.map +1 -0
- package/dist/editor/public/z-order.js +151 -0
- package/dist/editor/public/z-order.js.map +1 -0
- package/dist/editor/public/zoom-pan.d.ts +44 -0
- package/dist/editor/public/zoom-pan.d.ts.map +1 -0
- package/dist/editor/public/zoom-pan.js +116 -0
- package/dist/editor/public/zoom-pan.js.map +1 -0
- package/dist/editor/render-orchestrator.d.ts +11 -0
- package/dist/editor/render-orchestrator.d.ts.map +1 -0
- package/dist/editor/render-orchestrator.js +473 -0
- package/dist/editor/render-orchestrator.js.map +1 -0
- package/dist/editor/resize-helpers.d.ts +30 -0
- package/dist/editor/resize-helpers.d.ts.map +1 -0
- package/dist/editor/resize-helpers.js +121 -0
- package/dist/editor/resize-helpers.js.map +1 -0
- package/dist/editor/shape-filters.d.ts +11 -0
- package/dist/editor/shape-filters.d.ts.map +1 -0
- package/dist/editor/shape-filters.js +19 -0
- package/dist/editor/shape-filters.js.map +1 -0
- package/dist/editor/shape-traits.d.ts +16 -0
- package/dist/editor/shape-traits.d.ts.map +1 -0
- package/dist/editor/shape-traits.js +29 -0
- package/dist/editor/shape-traits.js.map +1 -0
- package/dist/editor/viewport-helpers.d.ts +24 -0
- package/dist/editor/viewport-helpers.d.ts.map +1 -0
- package/dist/editor/viewport-helpers.js +63 -0
- package/dist/editor/viewport-helpers.js.map +1 -0
- package/dist/editor-events.d.ts +33 -0
- package/dist/editor-events.d.ts.map +1 -0
- package/dist/editor-events.js +2 -0
- package/dist/editor-events.js.map +1 -0
- package/dist/editor.d.ts +1841 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +4803 -0
- package/dist/editor.js.map +1 -0
- package/dist/file-drop.d.ts +99 -0
- package/dist/file-drop.d.ts.map +1 -0
- package/dist/file-drop.js +198 -0
- package/dist/file-drop.js.map +1 -0
- package/dist/frame-helpers.d.ts +30 -0
- package/dist/frame-helpers.d.ts.map +1 -0
- package/dist/frame-helpers.js +105 -0
- package/dist/frame-helpers.js.map +1 -0
- package/dist/group-helpers.d.ts +39 -0
- package/dist/group-helpers.d.ts.map +1 -0
- package/dist/group-helpers.js +116 -0
- package/dist/group-helpers.js.map +1 -0
- package/dist/handle.d.ts +73 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +184 -0
- package/dist/handle.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive.d.ts +21 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +11 -0
- package/dist/interactive.js.map +1 -0
- package/dist/link-selection.d.ts +21 -0
- package/dist/link-selection.d.ts.map +1 -0
- package/dist/link-selection.js +37 -0
- package/dist/link-selection.js.map +1 -0
- package/dist/machine.d.ts +322 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +568 -0
- package/dist/machine.js.map +1 -0
- package/dist/modes.d.ts +24 -0
- package/dist/modes.d.ts.map +1 -0
- package/dist/modes.js +2 -0
- package/dist/modes.js.map +1 -0
- package/dist/overlay.d.ts +262 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +673 -0
- package/dist/overlay.js.map +1 -0
- package/dist/platform.d.ts +70 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +115 -0
- package/dist/platform.js.map +1 -0
- package/dist/selection.d.ts +18 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +31 -0
- package/dist/selection.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../../src/editor/public/placement.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,EACL,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,aAAa,GAId,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAY,EACZ,IAAU,EACV,WAAiB,EACjB,OAAgB,EAChB,EAAa,EACJ,EAAE;IACX,MAAM,KAAK,GAAG,WAAW,CACvB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CACtF,CAAC;IACF,MAAM,IAAI,GAAoB,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAChF,MAAM,KAAK,GAAG,GAAG,CAAC;IAClB,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,OAAO;QACL,EAAE;QACF,OAAO;QACP,IAAI;QACJ,QAAQ,EAAE,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,MAA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,EAAE,SAAS,CAAC,EAAE,EAAa,CAAC;IAC3E,MAAM,KAAK,GAAU;QACnB,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;QACpB,MAAM,EAAE,KAAK,CAAC,OAAO;QACrB,KAAK,EAAE,UAAU;KAClB,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AACjE,CAAC,CAAC;AAEF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAGhD,EAAE;IACF,MAAM,IAAI,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC/B,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAC5C,CAAC;QACD,KAAK,EAAE;YACL,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;YACzB,UAAU,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC;SAC5B;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAY,EACZ,SAAoB,EACO,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Scene, type Patch, type TextStyle } from "@oh-just-another/scene";
|
|
2
|
+
import type { LinkId, LayerId, ElementId, Vec2 } from "@oh-just-another/types";
|
|
3
|
+
import * as Selection from "../../selection.js";
|
|
4
|
+
/**
|
|
5
|
+
* Nudge every selected shape (plus descendants) by `delta`, skipping
|
|
6
|
+
* shapes on locked layers. Returns the next scene + patches + count of
|
|
7
|
+
* actually-moved shapes; `null` when nothing qualifies.
|
|
8
|
+
*/
|
|
9
|
+
export declare const computeMoveSelectionBy: (scene: Scene, targets: ReadonlySet<ElementId>, delta: Vec2, isLayerLocked: (id: LayerId) => boolean) => {
|
|
10
|
+
readonly scene: Scene;
|
|
11
|
+
readonly patches: Patch[];
|
|
12
|
+
readonly moved: number;
|
|
13
|
+
} | null;
|
|
14
|
+
/**
|
|
15
|
+
* Delete selected shapes + a selected edge, dropping any edges
|
|
16
|
+
* attached to selected shapes first so endpoint refs don't dangle.
|
|
17
|
+
* Returns the next scene + patches; `null` when nothing is selected.
|
|
18
|
+
*/
|
|
19
|
+
export declare const computeDeleteSelection: (scene: Scene, selection: Selection.Selection, selectedLinks: ReadonlySet<LinkId>) => {
|
|
20
|
+
readonly scene: Scene;
|
|
21
|
+
readonly patches: Patch[];
|
|
22
|
+
} | null;
|
|
23
|
+
/**
|
|
24
|
+
* Duplicate selected shapes 10 px down-right of the originals. Returns
|
|
25
|
+
* the next scene + patches + new ids; `null` for an empty selection.
|
|
26
|
+
* `nextIdSeed` is the editor's monotonic counter (bumped per new
|
|
27
|
+
* shape).
|
|
28
|
+
*/
|
|
29
|
+
export declare const computeDuplicateSelection: (scene: Scene, selection: Selection.Selection, nextIdSeed: () => number) => {
|
|
30
|
+
readonly scene: Scene;
|
|
31
|
+
readonly patches: Patch[];
|
|
32
|
+
readonly newIds: readonly ElementId[];
|
|
33
|
+
} | null;
|
|
34
|
+
/**
|
|
35
|
+
* Replace the selection with `ids`, dropping any id that doesn't
|
|
36
|
+
* resolve. Returns the next selection, or `null` when it would equal
|
|
37
|
+
* `current`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const computeSetSelection: (scene: Scene, ids: Iterable<ElementId>, current: Selection.Selection) => Selection.Selection | null;
|
|
40
|
+
/**
|
|
41
|
+
* Select every shape on a visible / unlocked layer. Returns the next
|
|
42
|
+
* selection, or `null` when it would equal `current`.
|
|
43
|
+
*/
|
|
44
|
+
export declare const computeSelectAll: (scene: Scene, current: Selection.Selection) => Selection.Selection | null;
|
|
45
|
+
/**
|
|
46
|
+
* Every link on a visible / unlocked layer — the link half of Cmd+A.
|
|
47
|
+
* Returns the full set (caller diffs against the current link
|
|
48
|
+
* selection to decide whether anything changed).
|
|
49
|
+
*/
|
|
50
|
+
export declare const computeSelectAllLinks: (scene: Scene) => Set<LinkId>;
|
|
51
|
+
/**
|
|
52
|
+
* Merge `partial` into the `style` of every shape in `ids`. Returns
|
|
53
|
+
* the next scene + a single (or `batch`) patch ready to push as one
|
|
54
|
+
* undo step; `null` when nothing applies.
|
|
55
|
+
*/
|
|
56
|
+
export declare const computeUpdateStyle: (scene: Scene, ids: Iterable<ElementId>, partial: Partial<TextStyle>) => {
|
|
57
|
+
readonly scene: Scene;
|
|
58
|
+
readonly patch: Patch;
|
|
59
|
+
} | null;
|
|
60
|
+
/**
|
|
61
|
+
* Merge non-style text properties (`fontSize`, `fontFamily`,
|
|
62
|
+
* `maxWidth`) into every selected text shape. Non-text shapes in `ids`
|
|
63
|
+
* are skipped. Returns the next scene + a single (or batched) patch,
|
|
64
|
+
* or `null` when no text shape applied.
|
|
65
|
+
*/
|
|
66
|
+
export declare const computeUpdateTextProps: (scene: Scene, ids: Iterable<ElementId>, partial: {
|
|
67
|
+
readonly fontSize?: number;
|
|
68
|
+
readonly fontFamily?: string;
|
|
69
|
+
readonly maxWidth?: number;
|
|
70
|
+
}) => {
|
|
71
|
+
readonly scene: Scene;
|
|
72
|
+
readonly patch: Patch;
|
|
73
|
+
} | null;
|
|
74
|
+
/** Human-readable description for the live-region announce after a nudge. */
|
|
75
|
+
export declare const describeNudge: (delta: Vec2, count: number) => string;
|
|
76
|
+
/** Compose a selection from a freshly-created id list. */
|
|
77
|
+
export declare const selectionFromNewIds: (ids: readonly ElementId[]) => Selection.Selection;
|
|
78
|
+
//# sourceMappingURL=selection-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-ops.d.ts","sourceRoot":"","sources":["../../../src/editor/public/selection-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EAEV,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,KAAK,EACZ,SAAS,WAAW,CAAC,SAAS,CAAC,EAC/B,OAAO,IAAI,EACX,eAAe,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,KACtC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAmBjF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,KAAK,EACZ,WAAW,SAAS,CAAC,SAAS,EAC9B,eAAe,WAAW,CAAC,MAAM,CAAC,KACjC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAA;CAAE,GAAG,IA6BzD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,KAAK,EACZ,WAAW,SAAS,CAAC,SAAS,EAC9B,YAAY,MAAM,MAAM,KACvB;IACD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAA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AAS,EAAE,KAAG,SAAS,CAAC,SAIzE,CAAC"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { addElement, getElement, orderForTop, removeLink, removeElement, updateElement, } from "@oh-just-another/scene";
|
|
2
|
+
import { elementId as castElementId } from "@oh-just-another/types";
|
|
3
|
+
import * as Selection from "../../selection.js";
|
|
4
|
+
/**
|
|
5
|
+
* Nudge every selected shape (plus descendants) by `delta`, skipping
|
|
6
|
+
* shapes on locked layers. Returns the next scene + patches + count of
|
|
7
|
+
* actually-moved shapes; `null` when nothing qualifies.
|
|
8
|
+
*/
|
|
9
|
+
export const computeMoveSelectionBy = (scene, targets, delta, isLayerLocked) => {
|
|
10
|
+
if (delta.x === 0 && delta.y === 0)
|
|
11
|
+
return null;
|
|
12
|
+
let s = scene;
|
|
13
|
+
const patches = [];
|
|
14
|
+
let moved = 0;
|
|
15
|
+
for (const id of targets) {
|
|
16
|
+
const shape = getElement(s, id);
|
|
17
|
+
if (!shape)
|
|
18
|
+
continue;
|
|
19
|
+
if (isLayerLocked(shape.layerId))
|
|
20
|
+
continue;
|
|
21
|
+
const r = updateElement(s, id, (sh) => ({
|
|
22
|
+
...sh,
|
|
23
|
+
position: { x: sh.position.x + delta.x, y: sh.position.y + delta.y },
|
|
24
|
+
}));
|
|
25
|
+
s = r.scene;
|
|
26
|
+
patches.push(r.patch);
|
|
27
|
+
moved++;
|
|
28
|
+
}
|
|
29
|
+
if (moved === 0)
|
|
30
|
+
return null;
|
|
31
|
+
return { scene: s, patches, moved };
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Delete selected shapes + a selected edge, dropping any edges
|
|
35
|
+
* attached to selected shapes first so endpoint refs don't dangle.
|
|
36
|
+
* Returns the next scene + patches; `null` when nothing is selected.
|
|
37
|
+
*/
|
|
38
|
+
export const computeDeleteSelection = (scene, selection, selectedLinks) => {
|
|
39
|
+
if (selection.size === 0 && selectedLinks.size === 0)
|
|
40
|
+
return null;
|
|
41
|
+
let s = scene;
|
|
42
|
+
const patches = [];
|
|
43
|
+
// Track removed links so an explicitly-selected link that's also
|
|
44
|
+
// attached to a deleted element isn't removed twice (removeLink throws).
|
|
45
|
+
const removed = new Set();
|
|
46
|
+
const dropLink = (id) => {
|
|
47
|
+
if (removed.has(id) || !s.links.has(id))
|
|
48
|
+
return;
|
|
49
|
+
const r = removeLink(s, id);
|
|
50
|
+
s = r.scene;
|
|
51
|
+
patches.push(r.patch);
|
|
52
|
+
removed.add(id);
|
|
53
|
+
};
|
|
54
|
+
for (const id of selection) {
|
|
55
|
+
for (const edge of [...s.links.values()]) {
|
|
56
|
+
if ((edge.from.kind !== "point" && edge.from.elementId === id) ||
|
|
57
|
+
(edge.to.kind !== "point" && edge.to.elementId === id)) {
|
|
58
|
+
dropLink(edge.id);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const r = removeElement(s, id);
|
|
62
|
+
s = r.scene;
|
|
63
|
+
patches.push(r.patch);
|
|
64
|
+
}
|
|
65
|
+
for (const id of selectedLinks)
|
|
66
|
+
dropLink(id);
|
|
67
|
+
return { scene: s, patches };
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Duplicate selected shapes 10 px down-right of the originals. Returns
|
|
71
|
+
* the next scene + patches + new ids; `null` for an empty selection.
|
|
72
|
+
* `nextIdSeed` is the editor's monotonic counter (bumped per new
|
|
73
|
+
* shape).
|
|
74
|
+
*/
|
|
75
|
+
export const computeDuplicateSelection = (scene, selection, nextIdSeed) => {
|
|
76
|
+
const targets = [...selection];
|
|
77
|
+
if (targets.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
let s = scene;
|
|
80
|
+
const patches = [];
|
|
81
|
+
const newIds = [];
|
|
82
|
+
for (const id of targets) {
|
|
83
|
+
const shape = getElement(s, id);
|
|
84
|
+
if (!shape)
|
|
85
|
+
continue;
|
|
86
|
+
const newId = castElementId(`shape-${nextIdSeed()}-${Date.now().toString(36)}`);
|
|
87
|
+
const order = orderForTop([...s.elements.values()].filter((sh) => sh.layerId === shape.layerId).map((sh) => sh.order));
|
|
88
|
+
const clone = {
|
|
89
|
+
...shape,
|
|
90
|
+
id: newId,
|
|
91
|
+
position: { x: shape.position.x + 10, y: shape.position.y + 10 },
|
|
92
|
+
order,
|
|
93
|
+
};
|
|
94
|
+
const r = addElement(s, clone);
|
|
95
|
+
s = r.scene;
|
|
96
|
+
patches.push(r.patch);
|
|
97
|
+
newIds.push(newId);
|
|
98
|
+
}
|
|
99
|
+
return { scene: s, patches, newIds };
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Replace the selection with `ids`, dropping any id that doesn't
|
|
103
|
+
* resolve. Returns the next selection, or `null` when it would equal
|
|
104
|
+
* `current`.
|
|
105
|
+
*/
|
|
106
|
+
export const computeSetSelection = (scene, ids, current) => {
|
|
107
|
+
let next = Selection.EMPTY;
|
|
108
|
+
for (const id of ids) {
|
|
109
|
+
if (!scene.elements.has(id))
|
|
110
|
+
continue;
|
|
111
|
+
next = Selection.add(next, id);
|
|
112
|
+
}
|
|
113
|
+
if (Selection.equals(next, current))
|
|
114
|
+
return null;
|
|
115
|
+
return next;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Select every shape on a visible / unlocked layer. Returns the next
|
|
119
|
+
* selection, or `null` when it would equal `current`.
|
|
120
|
+
*/
|
|
121
|
+
export const computeSelectAll = (scene, current) => {
|
|
122
|
+
let next = Selection.EMPTY;
|
|
123
|
+
for (const shape of scene.elements.values()) {
|
|
124
|
+
const layer = scene.layers.get(shape.layerId);
|
|
125
|
+
if (!layer || !layer.visible || layer.locked)
|
|
126
|
+
continue;
|
|
127
|
+
next = Selection.add(next, shape.id);
|
|
128
|
+
}
|
|
129
|
+
if (Selection.equals(next, current))
|
|
130
|
+
return null;
|
|
131
|
+
return next;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Every link on a visible / unlocked layer — the link half of Cmd+A.
|
|
135
|
+
* Returns the full set (caller diffs against the current link
|
|
136
|
+
* selection to decide whether anything changed).
|
|
137
|
+
*/
|
|
138
|
+
export const computeSelectAllLinks = (scene) => {
|
|
139
|
+
const next = new Set();
|
|
140
|
+
for (const edge of scene.links.values()) {
|
|
141
|
+
const layer = scene.layers.get(edge.layerId);
|
|
142
|
+
if (!layer || !layer.visible || layer.locked)
|
|
143
|
+
continue;
|
|
144
|
+
next.add(edge.id);
|
|
145
|
+
}
|
|
146
|
+
return next;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Merge `partial` into the `style` of every shape in `ids`. Returns
|
|
150
|
+
* the next scene + a single (or `batch`) patch ready to push as one
|
|
151
|
+
* undo step; `null` when nothing applies.
|
|
152
|
+
*/
|
|
153
|
+
export const computeUpdateStyle = (scene, ids, partial) => {
|
|
154
|
+
const targetIds = [];
|
|
155
|
+
for (const id of ids) {
|
|
156
|
+
if (scene.elements.has(id))
|
|
157
|
+
targetIds.push(id);
|
|
158
|
+
}
|
|
159
|
+
if (targetIds.length === 0)
|
|
160
|
+
return null;
|
|
161
|
+
let s = scene;
|
|
162
|
+
const patches = [];
|
|
163
|
+
for (const id of targetIds) {
|
|
164
|
+
const r = updateElement(s, id, (sh) => ({ ...sh, style: { ...sh.style, ...partial } }));
|
|
165
|
+
s = r.scene;
|
|
166
|
+
patches.push(r.patch);
|
|
167
|
+
}
|
|
168
|
+
const firstPatch = patches[0];
|
|
169
|
+
return {
|
|
170
|
+
scene: s,
|
|
171
|
+
patch: patches.length === 1 && firstPatch !== undefined
|
|
172
|
+
? firstPatch
|
|
173
|
+
: { kind: "batch", patches },
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Merge non-style text properties (`fontSize`, `fontFamily`,
|
|
178
|
+
* `maxWidth`) into every selected text shape. Non-text shapes in `ids`
|
|
179
|
+
* are skipped. Returns the next scene + a single (or batched) patch,
|
|
180
|
+
* or `null` when no text shape applied.
|
|
181
|
+
*/
|
|
182
|
+
export const computeUpdateTextProps = (scene, ids, partial) => {
|
|
183
|
+
const targetIds = [];
|
|
184
|
+
for (const id of ids) {
|
|
185
|
+
if (getElement(scene, id)?.type === "text")
|
|
186
|
+
targetIds.push(id);
|
|
187
|
+
}
|
|
188
|
+
if (targetIds.length === 0)
|
|
189
|
+
return null;
|
|
190
|
+
let s = scene;
|
|
191
|
+
const patches = [];
|
|
192
|
+
for (const id of targetIds) {
|
|
193
|
+
const r = updateElement(s, id, (sh) => ({ ...sh, ...partial }));
|
|
194
|
+
s = r.scene;
|
|
195
|
+
patches.push(r.patch);
|
|
196
|
+
}
|
|
197
|
+
const firstPatch = patches[0];
|
|
198
|
+
return {
|
|
199
|
+
scene: s,
|
|
200
|
+
patch: patches.length === 1 && firstPatch !== undefined
|
|
201
|
+
? firstPatch
|
|
202
|
+
: { kind: "batch", patches },
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
/** Human-readable description for the live-region announce after a nudge. */
|
|
206
|
+
export const describeNudge = (delta, count) => {
|
|
207
|
+
const parts = [];
|
|
208
|
+
if (delta.x > 0)
|
|
209
|
+
parts.push(`${delta.x} px right`);
|
|
210
|
+
else if (delta.x < 0)
|
|
211
|
+
parts.push(`${-delta.x} px left`);
|
|
212
|
+
if (delta.y > 0)
|
|
213
|
+
parts.push(`${delta.y} px down`);
|
|
214
|
+
else if (delta.y < 0)
|
|
215
|
+
parts.push(`${-delta.y} px up`);
|
|
216
|
+
const subject = count === 1 ? "shape" : `${count} shapes`;
|
|
217
|
+
return `Moved ${subject} ${parts.join(" and ")}`;
|
|
218
|
+
};
|
|
219
|
+
/** Compose a selection from a freshly-created id list. */
|
|
220
|
+
export const selectionFromNewIds = (ids) => {
|
|
221
|
+
let next = Selection.EMPTY;
|
|
222
|
+
for (const id of ids)
|
|
223
|
+
next = Selection.add(next, id);
|
|
224
|
+
return next;
|
|
225
|
+
};
|
|
226
|
+
//# sourceMappingURL=selection-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AC,UAAU,CAAC,CAAC;SAC7C,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC;IAC1D,OAAO,SAAS,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;AACnD,CAAC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAyB,EAAuB,EAAE;IACpF,IAAI,IAAI,GAAwB,SAAS,CAAC,KAAK,CAAC;IAChD,KAAK,MAAM,EAAE,IAAI,GAAG;QAAE,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Scene, type Patch } from "@oh-just-another/scene";
|
|
2
|
+
import type { LayerId, ElementId } from "@oh-just-another/types";
|
|
3
|
+
/**
|
|
4
|
+
* Precondition check for `beginTextEdit`. Returns `true` when the
|
|
5
|
+
* shape exists, is a text shape, and lives on an unlocked layer.
|
|
6
|
+
*/
|
|
7
|
+
export declare const canBeginTextEdit: (scene: Scene, id: ElementId, isLayerLocked: (id: LayerId) => boolean) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Compute the patch for replacing a text shape's body. Returns `null`
|
|
10
|
+
* when the shape disappeared or the text didn't actually change (the
|
|
11
|
+
* caller still clears `_editingTextElement` and notifies on null).
|
|
12
|
+
*/
|
|
13
|
+
export declare const computeCommitTextEdit: (scene: Scene, id: ElementId, next: string) => {
|
|
14
|
+
readonly scene: Scene;
|
|
15
|
+
readonly patch: Patch;
|
|
16
|
+
} | null;
|
|
17
|
+
//# sourceMappingURL=text-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-edit.d.ts","sourceRoot":"","sources":["../../../src/editor/public/text-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,KAAK,EACZ,IAAI,SAAS,EACb,eAAe,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,KACtC,OAKF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,OAAO,KAAK,EACZ,IAAI,SAAS,EACb,MAAM,MAAM,KACX;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,IAMrD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getElement, updateElement, } from "@oh-just-another/scene";
|
|
2
|
+
/**
|
|
3
|
+
* Precondition check for `beginTextEdit`. Returns `true` when the
|
|
4
|
+
* shape exists, is a text shape, and lives on an unlocked layer.
|
|
5
|
+
*/
|
|
6
|
+
export const canBeginTextEdit = (scene, id, isLayerLocked) => {
|
|
7
|
+
const shape = getElement(scene, id);
|
|
8
|
+
if (shape?.type !== "text")
|
|
9
|
+
return false;
|
|
10
|
+
if (isLayerLocked(shape.layerId))
|
|
11
|
+
return false;
|
|
12
|
+
return true;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compute the patch for replacing a text shape's body. Returns `null`
|
|
16
|
+
* when the shape disappeared or the text didn't actually change (the
|
|
17
|
+
* caller still clears `_editingTextElement` and notifies on null).
|
|
18
|
+
*/
|
|
19
|
+
export const computeCommitTextEdit = (scene, id, next) => {
|
|
20
|
+
const shape = getElement(scene, id);
|
|
21
|
+
if (shape?.type !== "text")
|
|
22
|
+
return null;
|
|
23
|
+
if (shape.text === next)
|
|
24
|
+
return null;
|
|
25
|
+
const r = updateElement(scene, id, (s) => ({ ...s, text: next }));
|
|
26
|
+
return { scene: r.scene, patch: r.patch };
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=text-edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-edit.js","sourceRoot":"","sources":["../../../src/editor/public/text-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,GAGd,MAAM,wBAAwB,CAAC;AAGhC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAY,EACZ,EAAa,EACb,aAAuC,EAC9B,EAAE;IACX,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACpC,IAAI,KAAK,EAAE,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAY,EACZ,EAAa,EACb,IAAY,EAC6C,EAAE;IAC3D,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACpC,IAAI,KAAK,EAAE,IAAI,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACxC,IAAK,KAA2B,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC5D,MAAM,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAClE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AAC5C,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type FractionalIndex, type Scene, type Patch } from "@oh-just-another/scene";
|
|
2
|
+
import type { LayerId, ElementId } from "@oh-just-another/types";
|
|
3
|
+
/** Move a shape to the top of its layer. */
|
|
4
|
+
export declare const computeBringToFront: (scene: Scene, id: ElementId | undefined, selection: ReadonlySet<ElementId>) => {
|
|
5
|
+
readonly scene: Scene;
|
|
6
|
+
readonly patch: Patch;
|
|
7
|
+
} | null;
|
|
8
|
+
/** Move a shape to the bottom of its layer. */
|
|
9
|
+
export declare const computeSendToBack: (scene: Scene, id: ElementId | undefined, selection: ReadonlySet<ElementId>) => {
|
|
10
|
+
readonly scene: Scene;
|
|
11
|
+
readonly patch: Patch;
|
|
12
|
+
} | null;
|
|
13
|
+
/**
|
|
14
|
+
* Swap the shape with its next neighbour up the z-stack (one step
|
|
15
|
+
* toward the top). Returns `null` when the shape is already on top or
|
|
16
|
+
* doesn't exist. Only same-layer shapes are considered neighbours.
|
|
17
|
+
*/
|
|
18
|
+
export declare const computeBringForward: (scene: Scene, id: ElementId | undefined, selection: ReadonlySet<ElementId>) => {
|
|
19
|
+
readonly scene: Scene;
|
|
20
|
+
readonly patch: Patch;
|
|
21
|
+
} | null;
|
|
22
|
+
/**
|
|
23
|
+
* Swap the shape with its next neighbour down the z-stack (one step
|
|
24
|
+
* toward the bottom). Mirror of `computeBringForward`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const computeSendBackward: (scene: Scene, id: ElementId | undefined, selection: ReadonlySet<ElementId>) => {
|
|
27
|
+
readonly scene: Scene;
|
|
28
|
+
readonly patch: Patch;
|
|
29
|
+
} | null;
|
|
30
|
+
/**
|
|
31
|
+
* Rewrite the `order` field of every entity in `entities` to the i-th
|
|
32
|
+
* key of `orderBetweenMany(null, null, n)`. Returns the count of
|
|
33
|
+
* entities whose order actually changed.
|
|
34
|
+
*
|
|
35
|
+
* `apply` is the side-effect callback — the caller threads scene + tx
|
|
36
|
+
* through it.
|
|
37
|
+
*/
|
|
38
|
+
export declare const rewriteOrders: <T extends {
|
|
39
|
+
readonly order: FractionalIndex;
|
|
40
|
+
}>(entities: readonly T[], apply: (entity: T, order: FractionalIndex) => void) => number;
|
|
41
|
+
/**
|
|
42
|
+
* Run `rewriteOrders` over shapes + edges of every requested layer,
|
|
43
|
+
* mutating the scene through the supplied `mutate` callback. Caller
|
|
44
|
+
* owns transaction lifecycle and final notify.
|
|
45
|
+
*/
|
|
46
|
+
export declare const compactLayerZOrderPatches: (scene: Scene, layerIds: readonly LayerId[], mutate: (nextScene: Scene, patch: Patch) => void) => number;
|
|
47
|
+
//# sourceMappingURL=z-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"z-order.d.ts","sourceRoot":"","sources":["../../../src/editor/public/z-order.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,KAAK,EACV,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAiBjE,4CAA4C;AAC5C,eAAO,MAAM,mBAAmB,GAC9B,OAAO,KAAK,EACZ,IAAI,SAAS,GAAG,SAAS,EACzB,WAAW,WAAW,CAAC,SAAS,CAAC,KAChC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,IAarD,CAAC;AAEF,+CAA+C;AAC/C,eAAO,MAAM,iBAAiB,GAC5B,OAAO,KAAK,EACZ,IAAI,SAAS,GAAG,SAAS,EACzB,WAAW,WAAW,CAAC,SAAS,CAAC,KAChC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,IAarD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,KAAK,EACZ,IAAI,SAAS,GAAG,SAAS,EACzB,WAAW,WAAW,CAAC,SAAS,CAAC,KAChC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,IAuBrD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,KAAK,EACZ,IAAI,SAAS,GAAG,SAAS,EACzB,WAAW,WAAW,CAAC,SAAS,CAAC,KAChC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,IAmBrD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;CAAE,EACzE,UAAU,SAAS,CAAC,EAAE,EACtB,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,KACjD,MAcF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,KAAK,EACZ,UAAU,SAAS,OAAO,EAAE,EAC5B,QAAQ,CACN,SAAS,EAAE,KAAK,EAChB,KAAK,EAAE,KAAK,KACT,IAAI,KACR,MAsBF,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { getElement, orderBetween, orderBetweenMany, orderForBottom, orderForTop, updateLink, updateElement, } from "@oh-just-another/scene";
|
|
2
|
+
/**
|
|
3
|
+
* Pick the target shape for a single-shape z-order command. Defaults
|
|
4
|
+
* to the lone selected shape when `id` is omitted; null when neither
|
|
5
|
+
* path resolves.
|
|
6
|
+
*/
|
|
7
|
+
const resolveTarget = (scene, id, selection) => {
|
|
8
|
+
const target = id ?? (selection.size === 1 ? [...selection][0] ?? null : null);
|
|
9
|
+
if (!target)
|
|
10
|
+
return null;
|
|
11
|
+
return scene.elements.has(target) ? target : null;
|
|
12
|
+
};
|
|
13
|
+
/** Move a shape to the top of its layer. */
|
|
14
|
+
export const computeBringToFront = (scene, id, selection) => {
|
|
15
|
+
const targetId = resolveTarget(scene, id, selection);
|
|
16
|
+
if (!targetId)
|
|
17
|
+
return null;
|
|
18
|
+
const shape = getElement(scene, targetId);
|
|
19
|
+
if (!shape)
|
|
20
|
+
return null;
|
|
21
|
+
const order = orderForTop([...scene.elements.values()]
|
|
22
|
+
.filter((s) => s.layerId === shape.layerId && s.id !== shape.id)
|
|
23
|
+
.map((s) => s.order));
|
|
24
|
+
if (order === shape.order)
|
|
25
|
+
return null;
|
|
26
|
+
const r = updateElement(scene, shape.id, (s) => ({ ...s, order }));
|
|
27
|
+
return { scene: r.scene, patch: r.patch };
|
|
28
|
+
};
|
|
29
|
+
/** Move a shape to the bottom of its layer. */
|
|
30
|
+
export const computeSendToBack = (scene, id, selection) => {
|
|
31
|
+
const targetId = resolveTarget(scene, id, selection);
|
|
32
|
+
if (!targetId)
|
|
33
|
+
return null;
|
|
34
|
+
const shape = getElement(scene, targetId);
|
|
35
|
+
if (!shape)
|
|
36
|
+
return null;
|
|
37
|
+
const order = orderForBottom([...scene.elements.values()]
|
|
38
|
+
.filter((s) => s.layerId === shape.layerId && s.id !== shape.id)
|
|
39
|
+
.map((s) => s.order));
|
|
40
|
+
if (order === shape.order)
|
|
41
|
+
return null;
|
|
42
|
+
const r = updateElement(scene, shape.id, (s) => ({ ...s, order }));
|
|
43
|
+
return { scene: r.scene, patch: r.patch };
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Swap the shape with its next neighbour up the z-stack (one step
|
|
47
|
+
* toward the top). Returns `null` when the shape is already on top or
|
|
48
|
+
* doesn't exist. Only same-layer shapes are considered neighbours.
|
|
49
|
+
*/
|
|
50
|
+
export const computeBringForward = (scene, id, selection) => {
|
|
51
|
+
const targetId = resolveTarget(scene, id, selection);
|
|
52
|
+
if (!targetId)
|
|
53
|
+
return null;
|
|
54
|
+
const shape = getElement(scene, targetId);
|
|
55
|
+
if (!shape)
|
|
56
|
+
return null;
|
|
57
|
+
// Siblings on the same layer, sorted bottom → top.
|
|
58
|
+
const siblings = [...scene.elements.values()]
|
|
59
|
+
.filter((s) => s.layerId === shape.layerId && s.id !== shape.id)
|
|
60
|
+
.sort((a, b) => (a.order < b.order ? -1 : a.order > b.order ? 1 : 0));
|
|
61
|
+
// Neighbour directly above = smallest order strictly greater than
|
|
62
|
+
// the shape's own. Anything above the neighbour follows.
|
|
63
|
+
const above = siblings.find((s) => s.order > shape.order) ?? null;
|
|
64
|
+
if (!above)
|
|
65
|
+
return null; // already topmost
|
|
66
|
+
const aboveAbove = siblings.find((s) => s.order > above.order) ?? null;
|
|
67
|
+
// Place the shape strictly between `above` and the one after it. If
|
|
68
|
+
// `above` is the topmost sibling, jump to top-of-stack via
|
|
69
|
+
// `orderForTop` to avoid colliding with existing keys.
|
|
70
|
+
const order = aboveAbove
|
|
71
|
+
? orderBetween(above.order, aboveAbove.order)
|
|
72
|
+
: orderForTop(siblings.map((s) => s.order));
|
|
73
|
+
if (order === shape.order)
|
|
74
|
+
return null;
|
|
75
|
+
const r = updateElement(scene, shape.id, (s) => ({ ...s, order }));
|
|
76
|
+
return { scene: r.scene, patch: r.patch };
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Swap the shape with its next neighbour down the z-stack (one step
|
|
80
|
+
* toward the bottom). Mirror of `computeBringForward`.
|
|
81
|
+
*/
|
|
82
|
+
export const computeSendBackward = (scene, id, selection) => {
|
|
83
|
+
const targetId = resolveTarget(scene, id, selection);
|
|
84
|
+
if (!targetId)
|
|
85
|
+
return null;
|
|
86
|
+
const shape = getElement(scene, targetId);
|
|
87
|
+
if (!shape)
|
|
88
|
+
return null;
|
|
89
|
+
// Sorted top → bottom so `find` picks the immediate neighbour below
|
|
90
|
+
// (largest order strictly less than the shape's own).
|
|
91
|
+
const siblings = [...scene.elements.values()]
|
|
92
|
+
.filter((s) => s.layerId === shape.layerId && s.id !== shape.id)
|
|
93
|
+
.sort((a, b) => (a.order > b.order ? -1 : a.order < b.order ? 1 : 0));
|
|
94
|
+
const below = siblings.find((s) => s.order < shape.order) ?? null;
|
|
95
|
+
if (!below)
|
|
96
|
+
return null; // already bottom-most
|
|
97
|
+
const belowBelow = siblings.find((s) => s.order < below.order) ?? null;
|
|
98
|
+
const order = belowBelow
|
|
99
|
+
? orderBetween(belowBelow.order, below.order)
|
|
100
|
+
: orderForBottom(siblings.map((s) => s.order));
|
|
101
|
+
if (order === shape.order)
|
|
102
|
+
return null;
|
|
103
|
+
const r = updateElement(scene, shape.id, (s) => ({ ...s, order }));
|
|
104
|
+
return { scene: r.scene, patch: r.patch };
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Rewrite the `order` field of every entity in `entities` to the i-th
|
|
108
|
+
* key of `orderBetweenMany(null, null, n)`. Returns the count of
|
|
109
|
+
* entities whose order actually changed.
|
|
110
|
+
*
|
|
111
|
+
* `apply` is the side-effect callback — the caller threads scene + tx
|
|
112
|
+
* through it.
|
|
113
|
+
*/
|
|
114
|
+
export const rewriteOrders = (entities, apply) => {
|
|
115
|
+
if (entities.length === 0)
|
|
116
|
+
return 0;
|
|
117
|
+
const sorted = [...entities].sort((a, b) => a.order < b.order ? -1 : a.order > b.order ? 1 : 0);
|
|
118
|
+
const fresh = orderBetweenMany(null, null, sorted.length);
|
|
119
|
+
let changed = 0;
|
|
120
|
+
sorted.forEach((entity, i) => {
|
|
121
|
+
const next = fresh[i];
|
|
122
|
+
if (next === undefined || next === entity.order)
|
|
123
|
+
return;
|
|
124
|
+
apply(entity, next);
|
|
125
|
+
changed++;
|
|
126
|
+
});
|
|
127
|
+
return changed;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Run `rewriteOrders` over shapes + edges of every requested layer,
|
|
131
|
+
* mutating the scene through the supplied `mutate` callback. Caller
|
|
132
|
+
* owns transaction lifecycle and final notify.
|
|
133
|
+
*/
|
|
134
|
+
export const compactLayerZOrderPatches = (scene, layerIds, mutate) => {
|
|
135
|
+
let s = scene;
|
|
136
|
+
let touched = 0;
|
|
137
|
+
for (const lid of layerIds) {
|
|
138
|
+
touched += rewriteOrders([...s.elements.values()].filter((sh) => sh.layerId === lid), (shape, order) => {
|
|
139
|
+
const r = updateElement(s, shape.id, (sh) => ({ ...sh, order }));
|
|
140
|
+
s = r.scene;
|
|
141
|
+
mutate(s, r.patch);
|
|
142
|
+
});
|
|
143
|
+
touched += rewriteOrders([...s.links.values()].filter((e) => e.layerId === lid), (edge, order) => {
|
|
144
|
+
const r = updateLink(s, edge.id, (e) => ({ ...e, order }));
|
|
145
|
+
s = r.scene;
|
|
146
|
+
mutate(s, r.patch);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return touched;
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=z-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"z-order.js","sourceRoot":"","sources":["../../../src/editor/public/z-order.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,GAId,MAAM,wBAAwB,CAAC;AAGhC;;;;GAIG;AACH,MAAM,aAAa,GAAG,CACpB,KAAY,EACZ,EAAyB,EACzB,SAAiC,EACf,EAAE;IACpB,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/E,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,KAAK,CAAC,QAAQ,CA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,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CACF,CAAC;QACF,OAAO,IAAI,aAAa,CACtB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,GAAG,CAAC,EACtD,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACd,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YAC3D,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;YACZ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CACF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type GridStyle, type Scene } from "@oh-just-another/scene";
|
|
2
|
+
import type { Bounds, Vec2 } from "@oh-just-another/types";
|
|
3
|
+
/**
|
|
4
|
+
* Shift the camera by a screen-space delta. Returns the next scene, or
|
|
5
|
+
* `null` for a zero-delta no-op. Viewport state is editor-local —
|
|
6
|
+
* caller does not record this in history.
|
|
7
|
+
*/
|
|
8
|
+
export declare const computePan: (scene: Scene, deltaScreen: Vec2) => Scene | null;
|
|
9
|
+
/**
|
|
10
|
+
* Multiplicative zoom around a world-space anchor. The anchor stays
|
|
11
|
+
* under the same screen pixel. Result is clamped to `[MIN_ZOOM,
|
|
12
|
+
* MAX_ZOOM]`; a zero-effect call returns `null`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const computeZoomAt: (scene: Scene, factor: number, anchorWorld: Vec2) => Scene | null;
|
|
15
|
+
/**
|
|
16
|
+
* Reset zoom to 1.0 around the viewport center — the world point
|
|
17
|
+
* currently under the screen center stays centered, only the scale
|
|
18
|
+
* changes. Returns `null` when already at zoom 1.
|
|
19
|
+
*/
|
|
20
|
+
export declare const computeResetZoom: (scene: Scene) => Scene | null;
|
|
21
|
+
/**
|
|
22
|
+
* Fit the camera to an arbitrary world `bounds` with `padding` screen
|
|
23
|
+
* px on each side. Returns `null` when the viewport or bounds are
|
|
24
|
+
* degenerate. Shared by zoom-to-fit (all content) and
|
|
25
|
+
* zoom-to-selection.
|
|
26
|
+
*/
|
|
27
|
+
export declare const computeZoomToBounds: (scene: Scene, bounds: Bounds, padding: number) => Scene | null;
|
|
28
|
+
export declare const computeZoomToFit: (scene: Scene, padding: number) => Scene | null;
|
|
29
|
+
/**
|
|
30
|
+
* Update the camera's screen-pixel size. Returns `null` when size is
|
|
31
|
+
* unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export declare const computeViewportResize: (scene: Scene, width: number, height: number) => Scene | null;
|
|
34
|
+
/**
|
|
35
|
+
* Merge a partial grid update (`size` and/or `style`). Returns `null`
|
|
36
|
+
* when nothing actually changed. Grid settings are view preferences —
|
|
37
|
+
* caller doesn't touch history.
|
|
38
|
+
*/
|
|
39
|
+
export declare const computeSetGrid: (scene: Scene, patch: {
|
|
40
|
+
size?: number;
|
|
41
|
+
style?: GridStyle;
|
|
42
|
+
snap?: boolean;
|
|
43
|
+
}) => Scene | null;
|
|
44
|
+
//# sourceMappingURL=zoom-pan.d.ts.map
|