@yuzhouu/canvas-kit 0.1.2
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/README.md +145 -0
- package/_vendor/canvas-core/bindings/BindingUtil.ts +92 -0
- package/_vendor/canvas-core/bindings/BindingUtilRegistry.ts +22 -0
- package/_vendor/canvas-core/bindings/arrow/arrowBindingHelpers.ts +52 -0
- package/_vendor/canvas-core/contextMenu.ts +85 -0
- package/_vendor/canvas-core/editor/Editor.ts +2614 -0
- package/_vendor/canvas-core/editor/HistoryManager.ts +83 -0
- package/_vendor/canvas-core/editor/StateNode.ts +162 -0
- package/_vendor/canvas-core/editor/camera.ts +6 -0
- package/_vendor/canvas-core/editor/clipboard.ts +478 -0
- package/_vendor/canvas-core/editor/commands.ts +833 -0
- package/_vendor/canvas-core/editor/edgeScroll.ts +37 -0
- package/_vendor/canvas-core/editor/editorComputedHelpers.ts +257 -0
- package/_vendor/canvas-core/editor/editorSelectionTransforms.ts +116 -0
- package/_vendor/canvas-core/editor/events.ts +93 -0
- package/_vendor/canvas-core/editor/index.ts +12 -0
- package/_vendor/canvas-core/editor/interactions.ts +101 -0
- package/_vendor/canvas-core/editor/internal.ts +22 -0
- package/_vendor/canvas-core/editor/managers/BindingManager.ts +262 -0
- package/_vendor/canvas-core/editor/managers/CameraManager.ts +147 -0
- package/_vendor/canvas-core/editor/managers/ClipboardManager.ts +32 -0
- package/_vendor/canvas-core/editor/managers/DocumentSnapshotManager.ts +256 -0
- package/_vendor/canvas-core/editor/managers/InputsManager.ts +319 -0
- package/_vendor/canvas-core/editor/managers/InteractionTransientManager.ts +218 -0
- package/_vendor/canvas-core/editor/managers/QueryManager.ts +837 -0
- package/_vendor/canvas-core/editor/managers/RenderWindowManager.ts +347 -0
- package/_vendor/canvas-core/editor/managers/SelectionLayoutManager.ts +196 -0
- package/_vendor/canvas-core/editor/managers/SelectionManager.ts +98 -0
- package/_vendor/canvas-core/editor/managers/SelectionOverlayManager.ts +308 -0
- package/_vendor/canvas-core/editor/managers/ShapeEditingManager.ts +226 -0
- package/_vendor/canvas-core/editor/managers/ShapeGeometryManager.ts +162 -0
- package/_vendor/canvas-core/editor/managers/ShapeHierarchyManager.ts +797 -0
- package/_vendor/canvas-core/editor/managers/SideEffectManager.ts +83 -0
- package/_vendor/canvas-core/editor/managers/SnapManager.ts +433 -0
- package/_vendor/canvas-core/editor/managers/SnapSnapshotBuilder.ts +430 -0
- package/_vendor/canvas-core/editor/managers/SpatialIndexManager.ts +354 -0
- package/_vendor/canvas-core/editor/managers/ToolManager.ts +81 -0
- package/_vendor/canvas-core/editor/managers/queryState.ts +583 -0
- package/_vendor/canvas-core/editor/managers/selectionGeometry.ts +287 -0
- package/_vendor/canvas-core/editor/managers/shapeOrder.ts +350 -0
- package/_vendor/canvas-core/editor/managers/shapeReparenting.ts +160 -0
- package/_vendor/canvas-core/editor/managers/snapCalculations.ts +412 -0
- package/_vendor/canvas-core/editor/managers/snapGeometry.ts +202 -0
- package/_vendor/canvas-core/editor/managers/snapIndicators.ts +403 -0
- package/_vendor/canvas-core/editor/managers/snapTypes.ts +122 -0
- package/_vendor/canvas-core/editor/queries/shapeTransforms.ts +171 -0
- package/_vendor/canvas-core/editor/renderWindow.ts +439 -0
- package/_vendor/canvas-core/editor/resizeGeometry.ts +654 -0
- package/_vendor/canvas-core/editor/selection.ts +489 -0
- package/_vendor/canvas-core/editor/selectionHandleInteractions.ts +43 -0
- package/_vendor/canvas-core/editor/selectionOverlay.ts +567 -0
- package/_vendor/canvas-core/exports/integrity.ts +174 -0
- package/_vendor/canvas-core/exports/svg.ts +494 -0
- package/_vendor/canvas-core/geometry/Box.ts +80 -0
- package/_vendor/canvas-core/geometry/Ellipse2d.ts +67 -0
- package/_vendor/canvas-core/geometry/Geometry2d.ts +52 -0
- package/_vendor/canvas-core/geometry/Mat.ts +92 -0
- package/_vendor/canvas-core/geometry/Polyline2d.ts +63 -0
- package/_vendor/canvas-core/geometry/Rectangle2d.ts +64 -0
- package/_vendor/canvas-core/geometry/Vec.ts +123 -0
- package/_vendor/canvas-core/geometry/index.ts +13 -0
- package/_vendor/canvas-core/geometry/segments.ts +65 -0
- package/_vendor/canvas-core/index.ts +391 -0
- package/_vendor/canvas-core/plugins/index.ts +5 -0
- package/_vendor/canvas-core/plugins/types.ts +53 -0
- package/_vendor/canvas-core/reactivity.ts +16 -0
- package/_vendor/canvas-core/schema/records.ts +221 -0
- package/_vendor/canvas-core/schema/snapshots.ts +527 -0
- package/_vendor/canvas-core/shapes/ShapeUtil.ts +516 -0
- package/_vendor/canvas-core/shapes/ShapeUtilRegistry.ts +26 -0
- package/_vendor/canvas-core/shapes/capabilities.ts +67 -0
- package/_vendor/canvas-core/shapes/types.ts +20 -0
- package/_vendor/canvas-core/toolbar.ts +148 -0
- package/_vendor/canvas-core/tools/hand/HandTool.ts +75 -0
- package/_vendor/canvas-core/tools/index.ts +2 -0
- package/_vendor/canvas-core/tools/select/SelectTool.ts +33 -0
- package/_vendor/canvas-core/tools/select/selectContainment.ts +104 -0
- package/_vendor/canvas-core/tools/select/selectToolHelpers.ts +801 -0
- package/_vendor/canvas-core/tools/select/states/BrushingState.ts +145 -0
- package/_vendor/canvas-core/tools/select/states/DraggingSelectionHandleInteractionState.ts +116 -0
- package/_vendor/canvas-core/tools/select/states/IdleState.ts +159 -0
- package/_vendor/canvas-core/tools/select/states/PointingCanvasState.ts +41 -0
- package/_vendor/canvas-core/tools/select/states/PointingResizeHandleState.ts +78 -0
- package/_vendor/canvas-core/tools/select/states/PointingRotateHandleState.ts +64 -0
- package/_vendor/canvas-core/tools/select/states/PointingSelectionHandleInteractionState.ts +34 -0
- package/_vendor/canvas-core/tools/select/states/PointingShapeState.ts +140 -0
- package/_vendor/canvas-core/tools/select/states/ResizingState.ts +171 -0
- package/_vendor/canvas-core/tools/select/states/RotatingState.ts +124 -0
- package/_vendor/canvas-core/tools/select/states/SelectStateNode.ts +128 -0
- package/_vendor/canvas-core/tools/select/states/TranslatingState.ts +139 -0
- package/_vendor/canvas-core/tools/select/states/index.ts +11 -0
- package/_vendor/canvas-plugin-api/feature.ts +204 -0
- package/_vendor/canvas-plugin-api/index.ts +142 -0
- package/_vendor/canvas-product-react/api/apiRegistry.ts +35 -0
- package/_vendor/canvas-product-react/api/canvasProductApi.ts +422 -0
- package/_vendor/canvas-product-react/api/index.ts +31 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/clipboardService.ts +36 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/systemClipboard.ts +245 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/systemContextMenu.ts +396 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/useContextMenuSurface.ts +59 -0
- package/_vendor/canvas-product-react/capabilities/export/useSvgExport.ts +156 -0
- package/_vendor/canvas-product-react/capabilities/history/useHistoryControls.ts +23 -0
- package/_vendor/canvas-product-react/capabilities/pages/usePageControls.ts +41 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/systemToolbar.ts +490 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/useToolbarSurfaces.ts +92 -0
- package/_vendor/canvas-product-react/capabilities/zoom/useZoomControls.ts +27 -0
- package/_vendor/canvas-product-react/index.ts +84 -0
- package/_vendor/canvas-product-react/persistence/index.ts +18 -0
- package/_vendor/canvas-product-react/persistence/localSnapshotPersistence.ts +294 -0
- package/_vendor/canvas-product-react/runtime/CanvasProductRoot.tsx +250 -0
- package/_vendor/canvas-product-react/runtime/productDefinition.ts +72 -0
- package/_vendor/canvas-product-react/runtime/productServices.ts +96 -0
- package/_vendor/canvas-react/components/CanvasView.tsx +796 -0
- package/_vendor/canvas-react/components/OverlayLayer.tsx +879 -0
- package/_vendor/canvas-react/components/PageSpace.tsx +34 -0
- package/_vendor/canvas-react/components/ShapeLayer.tsx +428 -0
- package/_vendor/canvas-react/components/index.ts +4 -0
- package/_vendor/canvas-react/hooks/useEditor.ts +11 -0
- package/_vendor/canvas-react/hooks/useValue.ts +14 -0
- package/_vendor/canvas-react/host/CanvasRendererRegistryContext.tsx +14 -0
- package/_vendor/canvas-react/host/contextMenuRegistry.ts +61 -0
- package/_vendor/canvas-react/host/domEventGuards.ts +61 -0
- package/_vendor/canvas-react/host/index.ts +38 -0
- package/_vendor/canvas-react/host/pluginHost.ts +635 -0
- package/_vendor/canvas-react/host/rendererRegistry.tsx +58 -0
- package/_vendor/canvas-react/host/toolbarRegistry.ts +100 -0
- package/_vendor/canvas-react/index.ts +3 -0
- package/_vendor/plugin-arrow/ArrowBindingUtil.ts +239 -0
- package/_vendor/plugin-arrow/ArrowShapeUtil.ts +311 -0
- package/_vendor/plugin-arrow/ArrowTool.ts +208 -0
- package/_vendor/plugin-arrow/arrowGeometry.ts +441 -0
- package/_vendor/plugin-arrow/arrowTerminalBindingResolver.ts +253 -0
- package/_vendor/plugin-arrow/arrowTerminalCommands.ts +230 -0
- package/_vendor/plugin-arrow/canvas.tsx +92 -0
- package/_vendor/plugin-arrow/core.ts +409 -0
- package/_vendor/plugin-arrow/feature.ts +20 -0
- package/_vendor/plugin-arrow/index.ts +28 -0
- package/_vendor/plugin-arrow/selectionHandleInteractions.ts +154 -0
- package/_vendor/plugin-arrow/types.ts +63 -0
- package/_vendor/plugin-draw/DrawShapeRenderer.tsx +60 -0
- package/_vendor/plugin-draw/DrawShapeUtil.ts +372 -0
- package/_vendor/plugin-draw/DrawTool.ts +444 -0
- package/_vendor/plugin-draw/canvas.tsx +24 -0
- package/_vendor/plugin-draw/core.ts +515 -0
- package/_vendor/plugin-draw/drawGeometry.ts +491 -0
- package/_vendor/plugin-draw/drawHitTest.ts +271 -0
- package/_vendor/plugin-draw/drawInterpolation.ts +250 -0
- package/_vendor/plugin-draw/drawPath.ts +550 -0
- package/_vendor/plugin-draw/drawSegments.ts +106 -0
- package/_vendor/plugin-draw/drawSelectionTransform.ts +67 -0
- package/_vendor/plugin-draw/drawShapeGeometry.ts +307 -0
- package/_vendor/plugin-draw/drawStrokeGeometry.ts +454 -0
- package/_vendor/plugin-draw/feature.ts +20 -0
- package/_vendor/plugin-draw/index.ts +31 -0
- package/_vendor/plugin-draw/types.ts +36 -0
- package/_vendor/plugin-eraser/EraserTool.ts +297 -0
- package/_vendor/plugin-eraser/canvas.tsx +616 -0
- package/_vendor/plugin-eraser/core.ts +49 -0
- package/_vendor/plugin-eraser/feature.ts +20 -0
- package/_vendor/plugin-eraser/index.ts +4 -0
- package/_vendor/plugin-frame/FrameShapeUtil.ts +173 -0
- package/_vendor/plugin-frame/FrameTool.ts +225 -0
- package/_vendor/plugin-frame/canvas.tsx +75 -0
- package/_vendor/plugin-frame/core.ts +534 -0
- package/_vendor/plugin-frame/feature.ts +20 -0
- package/_vendor/plugin-frame/index.ts +6 -0
- package/_vendor/plugin-geo/GeoShapeUtil.ts +463 -0
- package/_vendor/plugin-geo/GeoTools.ts +247 -0
- package/_vendor/plugin-geo/canvas.tsx +90 -0
- package/_vendor/plugin-geo/core.ts +495 -0
- package/_vendor/plugin-geo/feature.ts +20 -0
- package/_vendor/plugin-geo/index.ts +7 -0
- package/_vendor/plugin-geo/types.ts +27 -0
- package/_vendor/plugin-group/GroupShapeUtil.ts +59 -0
- package/_vendor/plugin-group/canvas.tsx +59 -0
- package/_vendor/plugin-group/core.ts +40 -0
- package/_vendor/plugin-group/feature.ts +20 -0
- package/_vendor/plugin-group/index.ts +5 -0
- package/_vendor/plugin-image/ImageShapeUtil.ts +95 -0
- package/_vendor/plugin-image/canvas.tsx +212 -0
- package/_vendor/plugin-image/core.ts +542 -0
- package/_vendor/plugin-image/crop.ts +770 -0
- package/_vendor/plugin-image/cropInteractions.ts +350 -0
- package/_vendor/plugin-image/cropSession.ts +38 -0
- package/_vendor/plugin-image/feature.ts +20 -0
- package/_vendor/plugin-image/index.ts +29 -0
- package/_vendor/plugin-image/types.ts +55 -0
- package/_vendor/plugin-image-product-react/ImageImportController.tsx +143 -0
- package/_vendor/plugin-image-product-react/imageAssetService.ts +52 -0
- package/_vendor/plugin-image-product-react/imageBlobStore.ts +315 -0
- package/_vendor/plugin-image-product-react/imageHostActions.ts +438 -0
- package/_vendor/plugin-image-product-react/imageProductApi.ts +88 -0
- package/_vendor/plugin-image-product-react/imageToolbarHostBridge.ts +48 -0
- package/_vendor/plugin-image-product-react/imageToolbarRuntime.ts +21 -0
- package/_vendor/plugin-image-product-react/index.ts +60 -0
- package/_vendor/plugin-image-product-react/snapshotGuards.ts +33 -0
- package/_vendor/plugin-image-product-react/svgImageAssetInliner.ts +54 -0
- package/_vendor/plugin-image-product-react/useImageImport.ts +64 -0
- package/_vendor/plugin-laser/LaserTool.ts +154 -0
- package/_vendor/plugin-laser/canvas.tsx +645 -0
- package/_vendor/plugin-laser/core.ts +49 -0
- package/_vendor/plugin-laser/feature.ts +20 -0
- package/_vendor/plugin-laser/index.ts +4 -0
- package/_vendor/plugin-text/ArrowLabelBindingUtil.ts +336 -0
- package/_vendor/plugin-text/GeoLabelBindingUtil.ts +391 -0
- package/_vendor/plugin-text/TextShapeSvgExporter.ts +101 -0
- package/_vendor/plugin-text/TextShapeUtil.ts +284 -0
- package/_vendor/plugin-text/TextTool.ts +228 -0
- package/_vendor/plugin-text/canvas.tsx +115 -0
- package/_vendor/plugin-text/core.ts +422 -0
- package/_vendor/plugin-text/feature.ts +20 -0
- package/_vendor/plugin-text/host/RichTextEditingBox.tsx +144 -0
- package/_vendor/plugin-text/host/RichTextToolbar.tsx +266 -0
- package/_vendor/plugin-text/host/TiptapTextEditor.tsx +191 -0
- package/_vendor/plugin-text/host/richTextRendering.tsx +49 -0
- package/_vendor/plugin-text/host/textDomSelection.ts +93 -0
- package/_vendor/plugin-text/host/textEditingBoxStyle.ts +36 -0
- package/_vendor/plugin-text/host/textEntryFocus.ts +307 -0
- package/_vendor/plugin-text/host/textFontLoader.ts +149 -0
- package/_vendor/plugin-text/host/textMeasurement.ts +258 -0
- package/_vendor/plugin-text/host/textMeasurementSync.ts +77 -0
- package/_vendor/plugin-text/host/textRangeSelection.ts +134 -0
- package/_vendor/plugin-text/host/textShapeRendererRuntime.tsx +89 -0
- package/_vendor/plugin-text/host/textShapeSync.ts +173 -0
- package/_vendor/plugin-text/host/tiptapTextEditorController.ts +148 -0
- package/_vendor/plugin-text/index.ts +18 -0
- package/_vendor/plugin-text/richTextUtils.ts +259 -0
- package/_vendor/plugin-text/textInteractions.ts +366 -0
- package/_vendor/plugin-text/textLabelHelpers.ts +235 -0
- package/_vendor/plugin-text/textShapeHelpers.ts +123 -0
- package/_vendor/plugin-text/textStyle.ts +96 -0
- package/_vendor/plugin-text/textTypes.ts +48 -0
- package/_vendor/signals/atom.ts +74 -0
- package/_vendor/signals/computed.ts +132 -0
- package/_vendor/signals/core.ts +130 -0
- package/_vendor/signals/effect.ts +117 -0
- package/_vendor/signals/index.ts +9 -0
- package/_vendor/signals/types.ts +17 -0
- package/_vendor/store/Store.ts +171 -0
- package/_vendor/store/diff.ts +229 -0
- package/_vendor/store/history.ts +177 -0
- package/_vendor/store/index.ts +32 -0
- package/_vendor/store/types.ts +37 -0
- package/api/canvasKitApi.d.ts +29 -0
- package/index.css +3 -0
- package/index.d.ts +16 -0
- package/index.mjs +1 -0
- package/internal-modules.d.ts +187 -0
- package/package.json +48 -0
- package/product/Shell.d.ts +19 -0
- package/product/chromeContext.d.ts +70 -0
- package/product/createCanvasKitEditor.d.ts +6 -0
- package/product/index.d.ts +7 -0
- package/product/persistence.d.ts +3 -0
- package/product/product.d.ts +22 -0
- package/product/useCanvasClipboardShortcuts.d.ts +6 -0
- package/product-iyBbEPIs.mjs +4 -0
- package/product.mjs +1 -0
- package/standard/extensions.d.ts +1 -0
- package/standard/index.d.ts +3 -0
- package/standard/standardApi.d.ts +91 -0
- package/standard-BmrxwqpJ.mjs +44 -0
- package/standard.mjs +1 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { UNINITIALIZED, computed, type Signal } from "@land/signals";
|
|
2
|
+
import type {
|
|
3
|
+
Editor,
|
|
4
|
+
EditorOverlayDebugState,
|
|
5
|
+
} from "../Editor";
|
|
6
|
+
import {
|
|
7
|
+
areOverlayDebugStatesEqual,
|
|
8
|
+
getBoxDebugSummary,
|
|
9
|
+
} from "../editorComputedHelpers";
|
|
10
|
+
import type {
|
|
11
|
+
SelectionOverlayFrameState,
|
|
12
|
+
SelectionOverlayFrameGeometryState,
|
|
13
|
+
SelectionOverlayFrameStyleState,
|
|
14
|
+
SelectionOverlayHandleAnchorsState,
|
|
15
|
+
SelectionOverlayHandleCountsState,
|
|
16
|
+
SelectionOverlayHandlesState,
|
|
17
|
+
SelectionOverlayState,
|
|
18
|
+
} from "../selection";
|
|
19
|
+
import {
|
|
20
|
+
areSelectionOverlayFrameGeometryArraysEqual,
|
|
21
|
+
areSelectionOverlayFrameGeometryStatesEqual,
|
|
22
|
+
areSelectionOverlayFrameStatesEqual,
|
|
23
|
+
areSelectionOverlayFrameStyleStatesEqual,
|
|
24
|
+
areSelectionOverlayHandleAnchorsStatesEqual,
|
|
25
|
+
areSelectionOverlayHandleCountsStatesEqual,
|
|
26
|
+
areSelectionOverlayHandlesStatesEqual,
|
|
27
|
+
getSelectionHandleAnchorsState,
|
|
28
|
+
isSingleSelectionPathOverlay,
|
|
29
|
+
materializeSelectionHandleState,
|
|
30
|
+
} from "../selectionOverlay";
|
|
31
|
+
|
|
32
|
+
const SELECTION_STROKE_WIDTH_SCREEN = 2;
|
|
33
|
+
const SELECTION_CORNER_RADIUS_SCREEN = 3;
|
|
34
|
+
|
|
35
|
+
interface OverlayDebugSnapshot {
|
|
36
|
+
metrics: EditorOverlayDebugState;
|
|
37
|
+
frame: SelectionOverlayFrameState | null;
|
|
38
|
+
handleCounts: SelectionOverlayHandleCountsState | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Selection overlay derived state: frame geometry/style, handles, combined
|
|
43
|
+
* overlay state, companion frames, and debug metrics. The Editor exposes thin
|
|
44
|
+
* signal aliases that forward here.
|
|
45
|
+
*/
|
|
46
|
+
export class SelectionOverlayManager {
|
|
47
|
+
readonly frameGeometrySignal: Signal<SelectionOverlayFrameGeometryState | null>;
|
|
48
|
+
readonly companionFrameGeometriesSignal: Signal<
|
|
49
|
+
SelectionOverlayFrameGeometryState[]
|
|
50
|
+
>;
|
|
51
|
+
readonly arrowPathSignal: Signal<string | null>;
|
|
52
|
+
readonly frameStyleSignal: Signal<SelectionOverlayFrameStyleState>;
|
|
53
|
+
readonly frameSignal: Signal<SelectionOverlayFrameState | null>;
|
|
54
|
+
readonly handleAnchorsSignal: Signal<SelectionOverlayHandleAnchorsState | null>;
|
|
55
|
+
readonly handlesSignal: Signal<SelectionOverlayHandlesState | null>;
|
|
56
|
+
readonly handleCountsSignal: Signal<SelectionOverlayHandleCountsState | null>;
|
|
57
|
+
readonly overlaySignal: Signal<SelectionOverlayState | null>;
|
|
58
|
+
readonly debugStateSignal: Signal<EditorOverlayDebugState>;
|
|
59
|
+
|
|
60
|
+
private readonly debugStateSnapshotSignal: Signal<OverlayDebugSnapshot>;
|
|
61
|
+
|
|
62
|
+
constructor(private readonly editor: Editor) {
|
|
63
|
+
this.frameGeometrySignal =
|
|
64
|
+
computed<SelectionOverlayFrameGeometryState | null>(
|
|
65
|
+
"editor.selectionOverlayFrameGeometry",
|
|
66
|
+
() => {
|
|
67
|
+
const selectedShapeItems =
|
|
68
|
+
editor.selectedShapeOverlayItemsSignal.get();
|
|
69
|
+
if (selectedShapeItems.length === 0) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if (isSingleSelectionPathOverlay(selectedShapeItems)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const selectionFrame = editor.getSelectionFrame();
|
|
76
|
+
if (!selectionFrame) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
bounds: selectionFrame.bounds,
|
|
82
|
+
rotation: selectionFrame.rotation,
|
|
83
|
+
rotationCenter: selectionFrame.rotationCenter,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
{ isEqual: areSelectionOverlayFrameGeometryStatesEqual },
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
this.companionFrameGeometriesSignal = computed<
|
|
90
|
+
SelectionOverlayFrameGeometryState[]
|
|
91
|
+
>(
|
|
92
|
+
"editor.selectionOverlayCompanionFrameGeometries",
|
|
93
|
+
() => {
|
|
94
|
+
if (editor.toolStateSignal.get().activeToolId !== "select") {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const geometries: SelectionOverlayFrameGeometryState[] = [];
|
|
98
|
+
for (const selectedShape of editor.selectedShapesSignal.get()) {
|
|
99
|
+
for (const binding of editor.getBindingsForShape(selectedShape.id)) {
|
|
100
|
+
geometries.push(
|
|
101
|
+
...(
|
|
102
|
+
editor.getBindingUtil(binding).getSelectionCompanionFrameGeometries?.(
|
|
103
|
+
editor,
|
|
104
|
+
binding as never,
|
|
105
|
+
{ selectedShape },
|
|
106
|
+
) ?? []
|
|
107
|
+
),
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return geometries;
|
|
112
|
+
},
|
|
113
|
+
{ isEqual: areSelectionOverlayFrameGeometryArraysEqual },
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
this.arrowPathSignal = computed<string | null>(
|
|
117
|
+
"editor.selectionOverlayArrowPath",
|
|
118
|
+
() => {
|
|
119
|
+
const selectedShapeItems = editor.selectedShapeOverlayItemsSignal.get();
|
|
120
|
+
if (!isSingleSelectionPathOverlay(selectedShapeItems)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return selectedShapeItems[0]?.path ?? null;
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
this.frameStyleSignal = computed<SelectionOverlayFrameStyleState>(
|
|
128
|
+
"editor.selectionOverlayFrameStyle",
|
|
129
|
+
() => {
|
|
130
|
+
const zoom = editor.cameraZoomSignal.get();
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
strokeWidth: SELECTION_STROKE_WIDTH_SCREEN / zoom,
|
|
134
|
+
cornerRadius: SELECTION_CORNER_RADIUS_SCREEN / zoom,
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
{ isEqual: areSelectionOverlayFrameStyleStatesEqual },
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
this.frameSignal = computed<SelectionOverlayFrameState | null>(
|
|
141
|
+
"editor.selectionOverlayFrame",
|
|
142
|
+
() => {
|
|
143
|
+
const frameGeometry = this.frameGeometrySignal.get();
|
|
144
|
+
if (!frameGeometry) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const frameStyle = this.frameStyleSignal.get();
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
...frameGeometry,
|
|
151
|
+
...frameStyle,
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
{ isEqual: areSelectionOverlayFrameStatesEqual },
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
this.handleAnchorsSignal =
|
|
158
|
+
computed<SelectionOverlayHandleAnchorsState | null>(
|
|
159
|
+
"editor.selectionOverlayHandleAnchors",
|
|
160
|
+
() => {
|
|
161
|
+
if (editor.toolStateSignal.get().activeToolId !== "select") {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
const selectedShapes = editor.selectedShapesSignal.get();
|
|
165
|
+
if (selectedShapes.length === 0) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
const selectionFrame = editor.getSelectionFrame();
|
|
169
|
+
const zoom = editor.cameraZoomSignal.get();
|
|
170
|
+
const isOnlySelected = selectedShapes.length === 1;
|
|
171
|
+
|
|
172
|
+
return getSelectionHandleAnchorsState(
|
|
173
|
+
selectedShapes,
|
|
174
|
+
selectionFrame,
|
|
175
|
+
zoom,
|
|
176
|
+
(shape) =>
|
|
177
|
+
editor.getShapeUtil(shape).getSelectionHandleAnchors(shape, {
|
|
178
|
+
isOnlySelected,
|
|
179
|
+
editor,
|
|
180
|
+
}),
|
|
181
|
+
(shape) =>
|
|
182
|
+
editor.getShapeUtil(shape).canUseSelectionFrameHandles(shape, {
|
|
183
|
+
editor,
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
},
|
|
187
|
+
{ isEqual: areSelectionOverlayHandleAnchorsStatesEqual },
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
this.handlesSignal = computed<SelectionOverlayHandlesState | null>(
|
|
191
|
+
"editor.selectionOverlayHandles",
|
|
192
|
+
() => {
|
|
193
|
+
const anchors = this.handleAnchorsSignal.get();
|
|
194
|
+
if (!anchors) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const zoom = editor.cameraZoomSignal.get();
|
|
198
|
+
const {
|
|
199
|
+
resizeHandles,
|
|
200
|
+
rotateHandles,
|
|
201
|
+
terminalHandles,
|
|
202
|
+
middleHandles,
|
|
203
|
+
customHandles,
|
|
204
|
+
} = materializeSelectionHandleState(anchors, zoom);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
resizeHandles,
|
|
208
|
+
rotateHandles,
|
|
209
|
+
terminalHandles,
|
|
210
|
+
middleHandles,
|
|
211
|
+
customHandles,
|
|
212
|
+
strokeWidth: SELECTION_STROKE_WIDTH_SCREEN / zoom,
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
{ isEqual: areSelectionOverlayHandlesStatesEqual },
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
this.handleCountsSignal =
|
|
219
|
+
computed<SelectionOverlayHandleCountsState | null>(
|
|
220
|
+
"editor.selectionOverlayHandleCounts",
|
|
221
|
+
() => {
|
|
222
|
+
const anchors = this.handleAnchorsSignal.get();
|
|
223
|
+
if (!anchors) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
resizeHandleCount: anchors.resizeHandleAnchors.length,
|
|
229
|
+
rotateHandleCount: anchors.rotateHandleAnchors.length,
|
|
230
|
+
terminalHandleCount: anchors.terminalHandleAnchors.length,
|
|
231
|
+
middleHandleCount: anchors.middleHandleAnchors.length,
|
|
232
|
+
customHandleCount: anchors.customHandleAnchors.length,
|
|
233
|
+
};
|
|
234
|
+
},
|
|
235
|
+
{ isEqual: areSelectionOverlayHandleCountsStatesEqual },
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
this.overlaySignal = computed<SelectionOverlayState | null>(
|
|
239
|
+
"editor.selectionOverlay",
|
|
240
|
+
() => {
|
|
241
|
+
const frame = this.frameSignal.get();
|
|
242
|
+
const handles = this.handlesSignal.get();
|
|
243
|
+
if (!frame || !handles) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
...frame,
|
|
249
|
+
...handles,
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
this.debugStateSnapshotSignal = computed<OverlayDebugSnapshot>(
|
|
255
|
+
"editor.overlayDebugState.snapshot",
|
|
256
|
+
(previous) => {
|
|
257
|
+
const frame = this.frameSignal.get();
|
|
258
|
+
const handleCounts = this.handleCountsSignal.get();
|
|
259
|
+
const previousSnapshot = previous !== UNINITIALIZED ? previous : null;
|
|
260
|
+
const frameChanged =
|
|
261
|
+
!previousSnapshot ||
|
|
262
|
+
!areSelectionOverlayFrameStatesEqual(previousSnapshot.frame, frame);
|
|
263
|
+
const handlesChanged =
|
|
264
|
+
!previousSnapshot ||
|
|
265
|
+
!areSelectionOverlayHandleCountsStatesEqual(
|
|
266
|
+
previousSnapshot.handleCounts,
|
|
267
|
+
handleCounts,
|
|
268
|
+
);
|
|
269
|
+
const metrics: EditorOverlayDebugState = {
|
|
270
|
+
selectionFrameActive: frame !== null,
|
|
271
|
+
selectionHandlesActive: handleCounts !== null,
|
|
272
|
+
bindingPreviewActive: editor.bindingPreviewActiveSignal.get(),
|
|
273
|
+
brushBoxActive: editor.brushBoxActiveSignal.get(),
|
|
274
|
+
selectionFrameChangeCount:
|
|
275
|
+
(previousSnapshot?.metrics.selectionFrameChangeCount ?? 0) +
|
|
276
|
+
(frameChanged ? 1 : 0),
|
|
277
|
+
selectionHandlesChangeCount:
|
|
278
|
+
(previousSnapshot?.metrics.selectionHandlesChangeCount ?? 0) +
|
|
279
|
+
(handlesChanged ? 1 : 0),
|
|
280
|
+
resizeHandleCount: handleCounts?.resizeHandleCount ?? 0,
|
|
281
|
+
rotateHandleCount: handleCounts?.rotateHandleCount ?? 0,
|
|
282
|
+
terminalHandleCount: handleCounts?.terminalHandleCount ?? 0,
|
|
283
|
+
middleHandleCount: handleCounts?.middleHandleCount ?? 0,
|
|
284
|
+
customHandleCount: handleCounts?.customHandleCount ?? 0,
|
|
285
|
+
boundsSummary: getBoxDebugSummary(frame?.bounds ?? null),
|
|
286
|
+
rotation: frame?.rotation ?? null,
|
|
287
|
+
strokeWidth: frame?.strokeWidth ?? null,
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
metrics,
|
|
292
|
+
frame,
|
|
293
|
+
handleCounts,
|
|
294
|
+
};
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
isEqual: (left, right) =>
|
|
298
|
+
areOverlayDebugStatesEqual(left.metrics, right.metrics),
|
|
299
|
+
},
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
this.debugStateSignal = computed<EditorOverlayDebugState>(
|
|
303
|
+
"editor.overlayDebugState.public",
|
|
304
|
+
() => this.debugStateSnapshotSignal.get().metrics,
|
|
305
|
+
{ isEqual: areOverlayDebugStatesEqual },
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { atom, type Atom, type Signal } from "@land/signals";
|
|
2
|
+
import type { ChangeSource } from "@land/store";
|
|
3
|
+
import type {
|
|
4
|
+
ShapeEditingEntryRequest,
|
|
5
|
+
ShapeEditingSession,
|
|
6
|
+
ShapeId,
|
|
7
|
+
ShapeRecord,
|
|
8
|
+
} from "../../schema/records";
|
|
9
|
+
import type { StartEditingShapeInput } from "../commands";
|
|
10
|
+
import type { Editor } from "../Editor";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Shape editing lifecycle for the editor: edit-session entry, completion,
|
|
14
|
+
* cancellation, composition state, and focus-entry requests. The Editor exposes
|
|
15
|
+
* thin wrappers that forward here.
|
|
16
|
+
*/
|
|
17
|
+
export class ShapeEditingManager {
|
|
18
|
+
private readonly entryRequestAtom: Atom<ShapeEditingEntryRequest | null> =
|
|
19
|
+
atom<ShapeEditingEntryRequest | null>(
|
|
20
|
+
"editor.shapeEditingEntryRequest",
|
|
21
|
+
null,
|
|
22
|
+
);
|
|
23
|
+
readonly entryRequestSignal: Signal<ShapeEditingEntryRequest | null> =
|
|
24
|
+
this.entryRequestAtom;
|
|
25
|
+
|
|
26
|
+
private nextEntryRequestId = 1;
|
|
27
|
+
|
|
28
|
+
constructor(private readonly editor: Editor) {}
|
|
29
|
+
|
|
30
|
+
canEditShape(shapeOrId: ShapeRecord | ShapeId | null | undefined): boolean {
|
|
31
|
+
const shape =
|
|
32
|
+
typeof shapeOrId === "string" ? this.editor.getShape(shapeOrId) : shapeOrId;
|
|
33
|
+
if (!shape) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (shape.isLocked) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return this.editor.getShapeUtil(shape).canEdit(shape);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
start(
|
|
43
|
+
input: StartEditingShapeInput,
|
|
44
|
+
source: ChangeSource = "user",
|
|
45
|
+
): ShapeEditingSession | null {
|
|
46
|
+
const shape = this.editor.getShape(input.shapeId);
|
|
47
|
+
if (!shape || !this.canEditShape(shape)) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const currentSession = this.editor.getShapeEditingSession();
|
|
52
|
+
if (currentSession?.shapeId === shape.id) {
|
|
53
|
+
const nextSession: ShapeEditingSession = {
|
|
54
|
+
...currentSession,
|
|
55
|
+
entryMode: input.entryMode ?? currentSession.entryMode,
|
|
56
|
+
caretPagePoint: input.caretPagePoint
|
|
57
|
+
? { ...input.caretPagePoint }
|
|
58
|
+
: currentSession.caretPagePoint,
|
|
59
|
+
};
|
|
60
|
+
this.editor.updateSession(
|
|
61
|
+
{
|
|
62
|
+
editingShapeId: shape.id,
|
|
63
|
+
shapeEditingSession: nextSession,
|
|
64
|
+
},
|
|
65
|
+
source,
|
|
66
|
+
);
|
|
67
|
+
this.publishEntryRequest({
|
|
68
|
+
shapeId: shape.id,
|
|
69
|
+
entryMode: nextSession.entryMode,
|
|
70
|
+
caretPagePoint: nextSession.caretPagePoint,
|
|
71
|
+
});
|
|
72
|
+
return nextSession;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!input.preserveInteraction) {
|
|
76
|
+
this.editor.cancelInteractionForCommand();
|
|
77
|
+
}
|
|
78
|
+
this.end({ runEditEnd: true, source });
|
|
79
|
+
const markId = input.markId ?? `editing:${shape.id}`;
|
|
80
|
+
if (!input.reuseExistingMark) {
|
|
81
|
+
this.editor.history.mark(markId);
|
|
82
|
+
}
|
|
83
|
+
const session: ShapeEditingSession = {
|
|
84
|
+
shapeId: shape.id,
|
|
85
|
+
markId,
|
|
86
|
+
entryMode: input.entryMode ?? "focusEnd",
|
|
87
|
+
caretPagePoint: input.caretPagePoint
|
|
88
|
+
? { ...input.caretPagePoint }
|
|
89
|
+
: undefined,
|
|
90
|
+
isComposing: false,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
this.editor.commands.setSelectedShapeIds([shape.id], { source });
|
|
94
|
+
this.editor.updateSession(
|
|
95
|
+
{
|
|
96
|
+
editingShapeId: shape.id,
|
|
97
|
+
shapeEditingSession: session,
|
|
98
|
+
},
|
|
99
|
+
source,
|
|
100
|
+
);
|
|
101
|
+
this.publishEntryRequest({
|
|
102
|
+
shapeId: shape.id,
|
|
103
|
+
entryMode: session.entryMode,
|
|
104
|
+
caretPagePoint: session.caretPagePoint,
|
|
105
|
+
});
|
|
106
|
+
return session;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
complete(source: ChangeSource = "user"): boolean {
|
|
110
|
+
const session = this.editor.getShapeEditingSession();
|
|
111
|
+
if (!session) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (session.isComposing) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.end({ runEditEnd: true, source });
|
|
119
|
+
this.editor.history.squashToMark(session.markId, "shape.edit");
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
cancel(source: ChangeSource = "user"): boolean {
|
|
124
|
+
const session = this.editor.getShapeEditingSession();
|
|
125
|
+
if (!session) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (session.isComposing) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.editor.updateSession(
|
|
133
|
+
{
|
|
134
|
+
editingShapeId: null,
|
|
135
|
+
shapeEditingSession: null,
|
|
136
|
+
},
|
|
137
|
+
source,
|
|
138
|
+
);
|
|
139
|
+
this.editor.history.bailToMark(session.markId);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
setComposition(
|
|
144
|
+
isComposing: boolean,
|
|
145
|
+
source: ChangeSource = "system",
|
|
146
|
+
): void {
|
|
147
|
+
const session = this.editor.getShapeEditingSession();
|
|
148
|
+
if (!session || session.isComposing === isComposing) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.editor.updateSession(
|
|
153
|
+
{
|
|
154
|
+
shapeEditingSession: {
|
|
155
|
+
...session,
|
|
156
|
+
isComposing,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
source,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
consumeEntryRequest(requestId: number): void {
|
|
164
|
+
const current = this.entryRequestAtom.get();
|
|
165
|
+
if (!current || current.id !== requestId) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.entryRequestAtom.set(null);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
removeShapeIds(ids: ShapeId[], source: ChangeSource = "system"): void {
|
|
172
|
+
const session = this.editor.getShapeEditingSession();
|
|
173
|
+
if (!session || !ids.includes(session.shapeId)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this.editor.updateSession(
|
|
178
|
+
{
|
|
179
|
+
editingShapeId: null,
|
|
180
|
+
shapeEditingSession: null,
|
|
181
|
+
},
|
|
182
|
+
source,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
end(options: { runEditEnd: boolean; source: ChangeSource }): void {
|
|
187
|
+
const session = this.editor.getShapeEditingSession();
|
|
188
|
+
if (!session) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.entryRequestAtom.set(null);
|
|
193
|
+
const shape = this.editor.getShape(session.shapeId);
|
|
194
|
+
this.editor.updateSession(
|
|
195
|
+
{
|
|
196
|
+
editingShapeId: null,
|
|
197
|
+
shapeEditingSession: null,
|
|
198
|
+
},
|
|
199
|
+
options.source,
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
if (!options.runEditEnd || !shape) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const result = this.editor.getShapeUtil(shape).onEditEnd(shape);
|
|
207
|
+
if (result?.deleteShapeIds && result.deleteShapeIds.length > 0) {
|
|
208
|
+
this.editor.commands.deleteShapes(result.deleteShapeIds, {
|
|
209
|
+
source: options.source,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private publishEntryRequest(
|
|
215
|
+
input: Omit<ShapeEditingEntryRequest, "id">,
|
|
216
|
+
): void {
|
|
217
|
+
this.entryRequestAtom.set({
|
|
218
|
+
id: this.nextEntryRequestId++,
|
|
219
|
+
shapeId: input.shapeId,
|
|
220
|
+
entryMode: input.entryMode,
|
|
221
|
+
caretPagePoint: input.caretPagePoint
|
|
222
|
+
? { ...input.caretPagePoint }
|
|
223
|
+
: undefined,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Box } from "../../geometry/Box";
|
|
2
|
+
import { Mat } from "../../geometry/Mat";
|
|
3
|
+
import { Vec } from "../../geometry/Vec";
|
|
4
|
+
import type { ShapeId, ShapeRecord } from "../../schema/records";
|
|
5
|
+
import type { Editor } from "../Editor";
|
|
6
|
+
import {
|
|
7
|
+
getShapeExportBounds,
|
|
8
|
+
getShapeExportPageBounds,
|
|
9
|
+
getShapeExportToPageTransform,
|
|
10
|
+
getShapeGeometry,
|
|
11
|
+
getShapeLocalBounds,
|
|
12
|
+
getShapeLocalToPageTransform,
|
|
13
|
+
getShapePageBounds,
|
|
14
|
+
getShapePositionedToPageTransform,
|
|
15
|
+
getShapeRenderBounds,
|
|
16
|
+
getShapeRenderToPageTransform,
|
|
17
|
+
type ShapeGeometry,
|
|
18
|
+
} from "../queries/shapeTransforms";
|
|
19
|
+
import { selectionPagePointToLocalPoint } from "../selection";
|
|
20
|
+
import type { SelectionFrame } from "../selection";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Shape and selection geometry facade helpers. Query-backed methods read the
|
|
24
|
+
* current editor state; compute methods operate on the provided shape snapshot.
|
|
25
|
+
*/
|
|
26
|
+
export class ShapeGeometryManager {
|
|
27
|
+
constructor(private readonly editor: Editor) {}
|
|
28
|
+
|
|
29
|
+
computeShapeBounds(shape: ShapeRecord): Box {
|
|
30
|
+
return this.editor.getShapeUtil(shape).getBounds(shape);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
computeShapeLocalBounds(shape: ShapeRecord): Box {
|
|
34
|
+
return getShapeLocalBounds(shape, this.editor.getShapeUtil(shape));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
computeShapeRenderBounds(shape: ShapeRecord): Box {
|
|
38
|
+
return getShapeRenderBounds(shape, this.editor.getShapeUtil(shape));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
computeShapeExportBounds(shape: ShapeRecord): Box {
|
|
42
|
+
return getShapeExportBounds(shape, this.editor.getShapeUtil(shape));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
computeShapeLocalToPageTransform(shape: ShapeRecord): Mat {
|
|
46
|
+
return getShapeLocalToPageTransform(shape, this.editor.getShapeUtil(shape));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
computeShapeRenderToPageTransform(shape: ShapeRecord): Mat {
|
|
50
|
+
return getShapeRenderToPageTransform(shape, this.editor.getShapeUtil(shape));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
computeShapeExportToPageTransform(shape: ShapeRecord): Mat {
|
|
54
|
+
return getShapeExportToPageTransform(shape, this.editor.getShapeUtil(shape));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
computeShapePageBounds(shape: ShapeRecord): Box {
|
|
58
|
+
return getShapePageBounds(shape, this.editor.getShapeUtil(shape));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
computeShapeExportPageBounds(shape: ShapeRecord): Box {
|
|
62
|
+
return getShapeExportPageBounds(shape, this.editor.getShapeUtil(shape));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
computeShapeGeometry(shape: ShapeRecord): ShapeGeometry {
|
|
66
|
+
return getShapeGeometry(shape, this.editor.getShapeUtil(shape));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
computeShapePositionedToPageTransform(shape: ShapeRecord): Mat {
|
|
70
|
+
return getShapePositionedToPageTransform(
|
|
71
|
+
shape,
|
|
72
|
+
this.editor.getShapeUtil(shape),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
computeShapePageCenter(shape: ShapeRecord): Vec {
|
|
77
|
+
return this.computeShapeGeometry(shape).center;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
computeShapePageCorners(shape: ShapeRecord): Vec[] {
|
|
81
|
+
return this.computeShapeGeometry(shape).corners;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
computeShapePageOutlineVertices(shape: ShapeRecord): Vec[] {
|
|
85
|
+
return this.computeShapeGeometry(shape).outlineVertices;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getShapeBounds(shapeId: ShapeId): Box | null {
|
|
89
|
+
return this.editor.queries.getShapeBounds(shapeId) ?? null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getShapePageBounds(shapeId: ShapeId): Box | null {
|
|
93
|
+
return this.editor.queries.getShapePageBounds(shapeId) ?? null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getShapeGeometry(shapeId: ShapeId): ShapeGeometry | null {
|
|
97
|
+
return this.editor.queries.getShapeGeometry(shapeId) ?? null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getShapePositionedToPageTransform(shapeId: ShapeId): Mat | null {
|
|
101
|
+
return this.editor.queries.getShapePositionedToPageTransform(shapeId) ?? null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getShapePageCenter(shapeId: ShapeId): Vec | null {
|
|
105
|
+
return this.editor.queries.getShapePageCenter(shapeId) ?? null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getShapePageCorners(shapeId: ShapeId): Vec[] | null {
|
|
109
|
+
return this.editor.queries.getShapePageCorners(shapeId) ?? null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getShapePageOutlineVertices(shapeId: ShapeId): Vec[] {
|
|
113
|
+
return this.editor.queries.getShapePageOutlineVertices(shapeId) ?? [];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
getSelectionPageBounds(): Box | null {
|
|
117
|
+
return this.editor.queries.getSelectionPageBounds();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
getSelectionFrame(): SelectionFrame | null {
|
|
121
|
+
const bounds = this.editor.queries.getSelectionFrameBounds();
|
|
122
|
+
const rotationCenter = this.editor.queries.getSelectionRotationCenter();
|
|
123
|
+
if (!bounds || !rotationCenter) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
bounds,
|
|
129
|
+
rotation: this.editor.queries.getSelectionRotation(),
|
|
130
|
+
rotationCenter,
|
|
131
|
+
hasCompatibleRotation:
|
|
132
|
+
this.editor.queries.getSelectionHasCompatibleRotation(),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
isPointInSelectionBounds(point: Vec): boolean {
|
|
137
|
+
const selectionFrame = this.getSelectionFrame();
|
|
138
|
+
if (!selectionFrame) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const localPoint = this.getSelectionFrameLocalBoundsPoint(point);
|
|
143
|
+
return localPoint ? selectionFrame.bounds.containsPoint(localPoint) : false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
getSelectionFrameLocalBoundsPoint(point: Vec): Vec | null {
|
|
147
|
+
const selectionFrame = this.getSelectionFrame();
|
|
148
|
+
if (!selectionFrame) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return selectionPagePointToLocalPoint(point, selectionFrame);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getSelectionPageOutlineVertices(): Vec[] {
|
|
156
|
+
return this.editor.queries.getSelectionPageOutlineVertices();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
getSelectionToolbarAnchorPagePoint(): Vec | null {
|
|
160
|
+
return this.editor.queries.getSelectionToolbarAnchorPagePoint();
|
|
161
|
+
}
|
|
162
|
+
}
|