@aivex/ui 1.2.0-dev.47 → 1.2.0-dev.48
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/components/ShapeEditor/ShapeEditor.d.ts +3 -5
- package/dist/components/ShapeEditor/_model/geometry.d.ts +4 -0
- package/dist/components/ShapeEditor/_model/imageLoad.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/overlays.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/polygonFill.d.ts +2 -0
- package/dist/components/ShapeEditor/_model/shapeHitTest.d.ts +9 -0
- package/dist/components/ShapeEditor/_model/shapeHitTest.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_renderers/PixiRenderer.d.ts +5 -10
- package/dist/components/ShapeEditor/_renderers/transformDriver.d.ts +55 -0
- package/dist/components/ShapeEditor/_renderers/transformDriver.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_renderers/transformSession.d.ts +9 -3
- package/dist/components/ShapeEditor/_renderers/transformSession.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_renderers/types.d.ts +5 -2
- package/dist/components/ShapeEditor/_state/buildContextMenuItems.d.ts +26 -0
- package/dist/components/ShapeEditor/_state/buildHotkeyActions.d.ts +42 -0
- package/dist/components/ShapeEditor/_state/createInteractionController.d.ts +14 -1
- package/dist/components/ShapeEditor/_state/editorActions.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +2 -3
- package/dist/components/ShapeEditor/_state/useLatestRef.d.ts +7 -0
- package/dist/components/ShapeEditor/_state/useSelectionActions.d.ts +1 -0
- package/dist/components/ShapeEditor/_state/useSelectionInfoOverlay.d.ts +32 -0
- package/dist/components/Slider/Slider.d.ts +3 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/keyboard-BPY-Ro06.cjs +2 -0
- package/dist/keyboard-BPY-Ro06.cjs.map +1 -0
- package/dist/{keyboard-B4NpK7Sx.js → keyboard-DvUDhDqH.js} +49 -39
- package/dist/keyboard-DvUDhDqH.js.map +1 -0
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +1895 -2578
- package/dist/shape-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/dist/components/ShapeEditor/_model/konva.d.ts +0 -4
- package/dist/components/ShapeEditor/_renderers/KonvaRenderer.d.ts +0 -138
- package/dist/keyboard-B4NpK7Sx.js.map +0 -1
- package/dist/keyboard-D3yExFth.cjs +0 -2
- package/dist/keyboard-D3yExFth.cjs.map +0 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { ShapeEditorProps } from "./_model/props";
|
|
2
2
|
/**
|
|
3
|
-
* ShapeEditor —
|
|
4
|
-
* 그리기·히트테스트·뷰포트는 `EditorRenderer`(
|
|
3
|
+
* ShapeEditor — 도형 에디터. 상호작용/문서/키보드/메뉴는 여기서 소유하고,
|
|
4
|
+
* 그리기·히트테스트·뷰포트는 `EditorRenderer`(Pixi)에 위임한다.
|
|
5
5
|
* 갭(회전/꼭짓점추가 등)은 여기서 한 번 구현하면 양쪽 렌더러에 적용된다.
|
|
6
6
|
*/
|
|
7
|
-
export default function ShapeEditor<TMeta, TMarkerMeta = unknown>({ document: editorDocument, clipboardScope, renderImageState, dimmed, selectedIds: controlledSelectedIds, activeTool, draftStyle, draftMeta, readOnly, disableMarquee, locked, onLockedInteraction, onDrawAttemptWithoutDraft, onIdleEscape, overrideShapeInteraction, defaultViewSettings, viewSettings, onViewSettingsChange, showMinimap, minimapPosition, showViewSettings, getContextMenuItems, strings, viewSettingItems, canMergeSelection, brushSize, zoomBound, zoomAnimationDuration, decorationShapes, regionMask, overlayMarkers, renderOverlayMarker, onOverlayMarkerClick, renderImageOverlay, getSelectionLabel, hideSelectionLabelDot, formatSelectionInfo, externalTools, assistant, keymap, handleRef,
|
|
8
|
-
backend?: "konva" | "pixi";
|
|
9
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default function ShapeEditor<TMeta, TMarkerMeta = unknown>({ document: editorDocument, clipboardScope, renderImageState, dimmed, selectedIds: controlledSelectedIds, activeTool, draftStyle, draftMeta, readOnly, disableMarquee, locked, onLockedInteraction, onDrawAttemptWithoutDraft, onIdleEscape, overrideShapeInteraction, defaultViewSettings, viewSettings, onViewSettingsChange, showMinimap, minimapPosition, showViewSettings, getContextMenuItems, strings, viewSettingItems, canMergeSelection, brushSize, zoomBound, zoomAnimationDuration, decorationShapes, regionMask, overlayMarkers, renderOverlayMarker, onOverlayMarkerClick, renderImageOverlay, getSelectionLabel, hideSelectionLabelDot, formatSelectionInfo, externalTools, assistant, keymap, handleRef, onActiveToolChange, onSelectionChange, onEditingChange, onShapesCreated, onShapesUpdated, onShapesDeleted, onDrawSessionChange, onDraftShapeChange, onViewportChange, onShapesTransformPreview, }: ShapeEditorProps<TMeta, TMarkerMeta>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -84,6 +84,8 @@ export declare function isShapeVisible(shape: EditorShape): boolean;
|
|
|
84
84
|
export declare function isShapeHitTestable(shape: EditorShape): boolean;
|
|
85
85
|
export declare function isShapeSelectable(shape: EditorShape): boolean;
|
|
86
86
|
export declare function isShapeEditable(shape: EditorShape): boolean;
|
|
87
|
+
/** 정점 편집모드에 들어갈 수 있는 도형(편집 가능한 폴리곤·라인). */
|
|
88
|
+
export declare function canEditVertices(shape: EditorShape): boolean;
|
|
87
89
|
export declare function isShapeDraggable(shape: EditorShape): boolean;
|
|
88
90
|
export declare function sortShapesForRender<TMeta>(shapes: EditorShape<TMeta>[]): EditorShape<TMeta>[];
|
|
89
91
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
@@ -135,6 +137,8 @@ export declare function resizeRotatedRectFromAnchor(points: Point[], anchor: Anc
|
|
|
135
137
|
export declare function rescalePoints(points: Point[], from: BBox, to: BBox): Point[];
|
|
136
138
|
/** 점이 닫힌 다각형 내부인가(ray casting, even-odd). */
|
|
137
139
|
export declare function pointInPolygon(p: Point, polygon: Point[]): boolean;
|
|
140
|
+
/** 정점이 박스 안이거나 어느 변이 박스와 교차하는가. closed면 마지막→첫 변도 검사. */
|
|
141
|
+
export declare function outlineIntersectsBox(points: Point[], box: BBox, closed: boolean): boolean;
|
|
138
142
|
/**
|
|
139
143
|
* 도형과 축정렬 박스의 실제 기하 충돌 — 마퀴 선택 판정. bbox 근사와 달리
|
|
140
144
|
* 오목 폴리곤의 빈 구석·타원 모서리·회전 사각형 바깥을 잡지 않는다.
|
|
@@ -8,7 +8,7 @@ export declare function loadImageElement(src: string, options?: {
|
|
|
8
8
|
* 어딘가의 no-cors `<img>`가 채운 오염 캐시(CORS 헤더 없는 응답)일 수 있으므로,
|
|
9
9
|
* cache:"reload" fetch로 캐시 항목을 정상 CORS 응답으로 수리한 뒤 한 번 더
|
|
10
10
|
* 시도한다. 그래도 실패면 null — 호출부가 상태/진단(imageDiagnosis.ts)을 처리한다.
|
|
11
|
-
*
|
|
11
|
+
* Pixi 렌더러와 ShapeViewer가 공유한다.
|
|
12
12
|
*/
|
|
13
13
|
export declare function loadCorsImage(url: string): Promise<HTMLImageElement | null>;
|
|
14
14
|
export interface DecodedImage {
|
|
@@ -62,7 +62,7 @@ export type OutlineSegment = [Point, Point];
|
|
|
62
62
|
/**
|
|
63
63
|
* Canvas2D에 벡터 딤을 그린다 — 이미지 전체를 딤 색으로 덮되 보이는 영역 합집합을
|
|
64
64
|
* 구멍(dimHoles, 무겹침이라 nonzero에서 안전)으로 뚫고, 가림 영역은 합집합 안쪽만
|
|
65
|
-
* 다시 덮는다.
|
|
65
|
+
* 다시 덮는다. ShapeViewer가 쓴다(전체 경로 커버리지 채움이라
|
|
66
66
|
* 인접 구멍 경계에 이음선이 생기지 않는다).
|
|
67
67
|
*/
|
|
68
68
|
export declare function drawRegionDim(ctx: CanvasRenderingContext2D, region: Pick<RegionOverlayData, "rects" | "zones" | "dimHoles" | "dim">, width: number, height: number): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type EditorShape, type Point } from "./geometry";
|
|
2
|
+
import { type ShapeRenderStyleDefaults } from "./shapeRenderStyle";
|
|
3
|
+
/**
|
|
4
|
+
* 선택 유지·Alt 순환에 쓰는 실제 도형 판정. 닫힌 도형은 내부/보이는 테두리를,
|
|
5
|
+
* 선은 화면 4px 이상의 여유를, 핀은 화면 고정 아이콘 영역을 사용한다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function shapeContainsPointer(shape: EditorShape, point: Point, scale: number, defaults?: ShapeRenderStyleDefaults): boolean;
|
|
8
|
+
/** 보이는 선택 가능 도형만 렌더 순서의 위→아래로 반환한다. */
|
|
9
|
+
export declare function shapesAtPointer<TMeta>(shapes: EditorShape<TMeta>[], point: Point, scale: number, defaults?: ShapeRenderStyleDefaults): EditorShape<TMeta>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -48,8 +48,6 @@ export declare class PixiRenderer {
|
|
|
48
48
|
private transformEnabled;
|
|
49
49
|
private handleNodes;
|
|
50
50
|
private vertexNodes;
|
|
51
|
-
private lastDragImg;
|
|
52
|
-
private activeDrag;
|
|
53
51
|
private midNodes;
|
|
54
52
|
private ghostNode;
|
|
55
53
|
private selectedVertices;
|
|
@@ -59,7 +57,9 @@ export declare class PixiRenderer {
|
|
|
59
57
|
private rotLineNode;
|
|
60
58
|
private transformerOutline;
|
|
61
59
|
private selectionBorderGfx;
|
|
60
|
+
private transform;
|
|
62
61
|
constructor(host: HTMLElement, cb: EditorRendererCallbacks);
|
|
62
|
+
private createTransformHost;
|
|
63
63
|
/** Pixi 이벤트 → 렌더러 추상화 이벤트. */
|
|
64
64
|
private ev;
|
|
65
65
|
init(): Promise<void>;
|
|
@@ -71,7 +71,6 @@ export declare class PixiRenderer {
|
|
|
71
71
|
};
|
|
72
72
|
setCursor(cursor: string): void;
|
|
73
73
|
private emitCursorHint;
|
|
74
|
-
private emitInteractionMode;
|
|
75
74
|
private applyCursor;
|
|
76
75
|
private syncShapeCursors;
|
|
77
76
|
private bindCursor;
|
|
@@ -171,8 +170,9 @@ export declare class PixiRenderer {
|
|
|
171
170
|
private orientedHandleAngle;
|
|
172
171
|
/** 핸들(8개 bbox + 단일 폴리곤/라인 꼭짓점)을 화면좌표로 그림. */
|
|
173
172
|
drawTransformer(): void;
|
|
174
|
-
/** 도형 본체 드래그 이동
|
|
175
|
-
beginMove(start: Point, ids: string[]): void;
|
|
173
|
+
/** 도형 본체 드래그 이동 시작. */
|
|
174
|
+
beginMove(start: Point, ids: string[], current?: Point): void;
|
|
175
|
+
cancelTransform(): boolean;
|
|
176
176
|
private repositionHandlesForBox;
|
|
177
177
|
private repositionOrientedHandles;
|
|
178
178
|
/** 폴리곤/라인 꼭짓점·변 중점 핸들을 이미지 좌표 기준으로 재배치. */
|
|
@@ -180,9 +180,4 @@ export declare class PixiRenderer {
|
|
|
180
180
|
/** 변(이미지 좌표 a→b) 주위 히트 쿼드 — 변 호버/클릭 히트영역(정점 핸들에 비례). */
|
|
181
181
|
private edgeHitQuad;
|
|
182
182
|
private resetMoveOffsets;
|
|
183
|
-
private commitTransformUpdates;
|
|
184
|
-
private dragTransform;
|
|
185
|
-
/** 진행 중인 드래그를 커밋 없이 취소 — 프리뷰가 옮긴 노드를 확정 좌표로 되돌린다. */
|
|
186
|
-
private cancelTransform;
|
|
187
|
-
private endTransform;
|
|
188
183
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type BBox, type EditorShape, type Point } from "../_model/geometry";
|
|
2
|
+
import { type ActiveDrag, type ShapeUpdate } from "./transformSession";
|
|
3
|
+
import type { EditorRendererCallbacks } from "./types";
|
|
4
|
+
export type TransformMode = "moving" | "resizing" | "rotating" | "vertexDragging";
|
|
5
|
+
/**
|
|
6
|
+
* 렌더러가 제공하는 노드 조작. 드래그 흐름은 TransformDriver가 소유하고,
|
|
7
|
+
* 렌더러는 그리기만 한다.
|
|
8
|
+
*/
|
|
9
|
+
export interface TransformHost {
|
|
10
|
+
/** 확정 도형(렌더러 복제본). 커밋 시 points가 갱신된다. */
|
|
11
|
+
shapes(): EditorShape[];
|
|
12
|
+
callbacks: Pick<EditorRendererCallbacks, "onTransformPreview" | "onTransformCommit" | "onCursorHint" | "onInteractionModeChange">;
|
|
13
|
+
/** 트랜스포머가 켜져 있는데 아직 핸들이 없으면 그린다. */
|
|
14
|
+
ensureTransformer(): void;
|
|
15
|
+
drawTransformer(): void;
|
|
16
|
+
drawSelectionBorders(): void;
|
|
17
|
+
updateSelectionBordersLive(pointsFor: (shape: EditorShape) => Point[]): void;
|
|
18
|
+
setTransformerOutline(box: BBox): void;
|
|
19
|
+
setTransformerOutlinePoints(points: Point[]): void;
|
|
20
|
+
layoutBoxHandles(box: BBox): void;
|
|
21
|
+
layoutOrientedHandles(points: Point[]): void;
|
|
22
|
+
/** 정점·변 핸들 재배치. 정점 핸들이 없으면 아무것도 하지 않는다. */
|
|
23
|
+
layoutPolygonHandles(points: Point[], isPolygon: boolean): void;
|
|
24
|
+
hasVertexHandles(): boolean;
|
|
25
|
+
/** 드래그 프리뷰 — 대상 노드를 updates 좌표로(이동은 노드 오프셋으로 대신해도 된다). */
|
|
26
|
+
previewShapes(drag: ActiveDrag, img: Point, updates: ShapeUpdate[]): void;
|
|
27
|
+
/** previewShapes가 남긴 일시 상태(이동 오프셋 등)를 지운다. */
|
|
28
|
+
clearShapePreview(drag: ActiveDrag): void;
|
|
29
|
+
repaintShape(id: string, points: Point[]): void;
|
|
30
|
+
applyCursor(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 트랜스포머 드래그(이동/리사이즈/회전/정점)의 진행·취소·커밋 흐름.
|
|
34
|
+
* 지오메트리 계산은 transformSession, 노드 조작은 TransformHost가 맡는다.
|
|
35
|
+
*/
|
|
36
|
+
export declare class TransformDriver {
|
|
37
|
+
private readonly host;
|
|
38
|
+
private drag;
|
|
39
|
+
private lastImg;
|
|
40
|
+
constructor(host: TransformHost);
|
|
41
|
+
get active(): ActiveDrag | null;
|
|
42
|
+
begin(drag: ActiveDrag, mode: TransformMode, cursor: string | null): void;
|
|
43
|
+
/** 도형 본체 이동 시작. current를 주면 첫 포인터 이동을 시작점 기준으로 즉시 반영한다. */
|
|
44
|
+
beginMove(start: Point, ids: string[], current?: Point): void;
|
|
45
|
+
move(img: Point): void;
|
|
46
|
+
/** 뷰포트가 바뀌면 화면고정 핸들을 마지막(또는 identity) 포인터 좌표로 재배치한다. */
|
|
47
|
+
refresh(): boolean;
|
|
48
|
+
/** 숨김·삭제·편집 권한/좌표가 바뀐 드래그는 시작 스냅샷으로 커밋하지 않고 취소한다. */
|
|
49
|
+
cancelIfStale(): void;
|
|
50
|
+
/** 진행 중인 드래그를 커밋 없이 취소 — 프리뷰가 옮긴 노드를 확정 좌표로 되돌린다. */
|
|
51
|
+
cancel(): boolean;
|
|
52
|
+
end(): void;
|
|
53
|
+
private commit;
|
|
54
|
+
private preview;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Anchor, type BBox, type EditorShape, type Point } from "../_model/geometry";
|
|
2
2
|
/**
|
|
3
|
-
* 트랜스포머 드래그(이동/리사이즈/회전/정점) 상태와 지오메트리
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* 트랜스포머 드래그(이동/리사이즈/회전/정점) 상태와 지오메트리 계산. 렌더러는 여기서
|
|
4
|
+
* 계산된 updates/box로 프리뷰(노드 갱신·핸들 재배치)만 수행한다 — 수학은 노드 조작과
|
|
5
|
+
* 분리돼 단위 테스트한다.
|
|
6
6
|
*/
|
|
7
7
|
export declare const ROT_SNAP: number;
|
|
8
8
|
export interface ShapeUpdate {
|
|
@@ -25,6 +25,8 @@ export type ActiveDrag = {
|
|
|
25
25
|
indices: number[];
|
|
26
26
|
base: Point[];
|
|
27
27
|
start: Point;
|
|
28
|
+
/** 변에서 정점을 추가하며 시작한 드래그의 추가 전 좌표 — 놓을 때 한 번에 커밋하고, 취소하면 여기로 되돌린다. */
|
|
29
|
+
original?: Point[];
|
|
28
30
|
} | {
|
|
29
31
|
kind: "rotate";
|
|
30
32
|
id: string;
|
|
@@ -33,6 +35,10 @@ export type ActiveDrag = {
|
|
|
33
35
|
points: Point[];
|
|
34
36
|
shiftKey: boolean;
|
|
35
37
|
};
|
|
38
|
+
/** 드래그가 움직이는 도형 id. */
|
|
39
|
+
export declare function dragTargetIds(drag: ActiveDrag): string[];
|
|
40
|
+
/** 숨김·삭제·편집 권한/좌표 변경 뒤에는 시작 시점의 스냅샷으로 커밋하면 안 된다. */
|
|
41
|
+
export declare function isDragCurrent(drag: ActiveDrag, shapes: EditorShape[]): boolean;
|
|
36
42
|
/** 드래그 대상이 단일 회전사각형인지(리사이즈/이동 핸들 분기용). */
|
|
37
43
|
export declare function dragTargetIsRotatedRect(shapes: EditorShape[], d: ActiveDrag): boolean;
|
|
38
44
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,7 @@ import type { ScalarMaskRaster } from "../_model/scalarMask";
|
|
|
5
5
|
import type { ShapeRenderStyleDefaults } from "../_model/shapeRenderStyle";
|
|
6
6
|
/**
|
|
7
7
|
* 렌더러 추상화 — Editor가 상호작용/문서/키보드를 소유하고, 그리기·히트테스트·
|
|
8
|
-
* 뷰포트만 이 인터페이스로 위임한다.
|
|
8
|
+
* 뷰포트만 이 인터페이스로 위임한다.
|
|
9
9
|
*/
|
|
10
10
|
export interface Viewport {
|
|
11
11
|
scale: number;
|
|
@@ -117,7 +117,10 @@ export interface EditorRenderer<TMeta = unknown> {
|
|
|
117
117
|
fit(): void;
|
|
118
118
|
zoom100(): void;
|
|
119
119
|
zoomAt(cx: number, cy: number, factor: number): void;
|
|
120
|
-
|
|
120
|
+
/** current는 첫 포인터 이동을 시작점 기준으로 즉시 반영한다. */
|
|
121
|
+
beginMove(start: Point, ids: string[], current?: Point): void;
|
|
122
|
+
/** 진행 중인 이동·리사이즈·회전·정점 드래그를 커밋 없이 복원한다. 취소했으면 true. */
|
|
123
|
+
cancelTransform(): boolean;
|
|
121
124
|
previewBox(kind: PreviewKind, a: Point, b: Point, style: ShapeStyle): void;
|
|
122
125
|
previewPoly(points: Point[], cursor: Point | null, style: ShapeStyle, closed: boolean, selectedPointIndices?: number[], showVertices?: boolean): void;
|
|
123
126
|
previewScalarMask(raster: ScalarMaskRaster, color: string): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ContextMenuItem } from "../_components/ContextMenu";
|
|
2
|
+
import { type EditorShape, type Point } from "../_model/geometry";
|
|
3
|
+
import type { EditorStrings } from "../_model/strings";
|
|
4
|
+
import type { EditorHistory } from "./buildHotkeyActions";
|
|
5
|
+
import type { SelectionActions } from "./useSelectionActions";
|
|
6
|
+
interface ContextMenuContext<TMeta> {
|
|
7
|
+
strings: EditorStrings["contextMenu"];
|
|
8
|
+
/** 메뉴를 연 지점(이미지 좌표) — 붙여넣기·어시스트 refine 위치. */
|
|
9
|
+
point: Point;
|
|
10
|
+
shapes: EditorShape<TMeta>[];
|
|
11
|
+
selectedIds: string[];
|
|
12
|
+
/** 호스트가 준 읽기전용(조회 메뉴만). 완료 잠금은 editLocked로만 막는다. */
|
|
13
|
+
hostReadOnly: boolean;
|
|
14
|
+
/** 읽기전용 또는 완료 잠금 — 편집 항목 비활성. */
|
|
15
|
+
editLocked: boolean;
|
|
16
|
+
selection: SelectionActions<TMeta>;
|
|
17
|
+
canMergeSelection?: (shapes: EditorShape<TMeta>[]) => boolean;
|
|
18
|
+
history: EditorHistory;
|
|
19
|
+
enterVertexEdit: (id: string) => void;
|
|
20
|
+
zoomToSelection: () => void;
|
|
21
|
+
/** 어시스트 refine(없으면 메뉴 항목 숨김). */
|
|
22
|
+
refineShape?: (shape: EditorShape<TMeta>, point: Point, positive: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
/** 기본 컨텍스트 메뉴 — 호스트 getContextMenuItems가 받아 가공하는 원본. */
|
|
25
|
+
export declare function buildContextMenuItems<TMeta>({ strings: S, point, shapes, selectedIds, hostReadOnly, editLocked, selection, canMergeSelection, history, enterVertexEdit, zoomToSelection, refineShape, }: ContextMenuContext<TMeta>): ContextMenuItem[];
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { EditorExternalTool } from "../_model/props";
|
|
2
|
+
import { type Tool } from "../_model/tools";
|
|
3
|
+
import type { InteractionController } from "./createInteractionController";
|
|
4
|
+
import type { AssistantSession } from "./useAssistant";
|
|
5
|
+
import type { DrawSession } from "./useDrawSession";
|
|
6
|
+
import type { EditorActionHandlers } from "./useEditorHotkeys";
|
|
7
|
+
import type { SelectionActions } from "./useSelectionActions";
|
|
8
|
+
/** 문서·그리기 세션 공용 실행 취소. 잠금·읽기전용이면 되돌리지 않는다. */
|
|
9
|
+
export interface EditorHistory {
|
|
10
|
+
undo: () => void;
|
|
11
|
+
redo: () => void;
|
|
12
|
+
canUndo: () => boolean;
|
|
13
|
+
canRedo: () => boolean;
|
|
14
|
+
}
|
|
15
|
+
interface HotkeyContext<TMeta> {
|
|
16
|
+
history: EditorHistory;
|
|
17
|
+
selection: SelectionActions<TMeta>;
|
|
18
|
+
drawSession: DrawSession<TMeta>;
|
|
19
|
+
assistant: AssistantSession<TMeta>;
|
|
20
|
+
controller: () => InteractionController | null;
|
|
21
|
+
externalTool: () => EditorExternalTool | undefined;
|
|
22
|
+
hasSelection: () => boolean;
|
|
23
|
+
/** 잠금으로 막힌 편집 시도면 호스트에 알리고 true. */
|
|
24
|
+
rejectLockedEdit: (hasTarget?: boolean) => boolean;
|
|
25
|
+
editLocked: boolean;
|
|
26
|
+
editingId: string | null;
|
|
27
|
+
setEditingId: (id: string | null) => void;
|
|
28
|
+
/** 선택된 단일 정점 편집 가능 도형 id(없으면 null). */
|
|
29
|
+
vertexEditTarget: () => string | null;
|
|
30
|
+
deleteEditingVertices: () => boolean;
|
|
31
|
+
zoomAtCenter: (factor: number) => void;
|
|
32
|
+
zoom100: () => void;
|
|
33
|
+
zoomFit: () => void;
|
|
34
|
+
toggleMinimap: () => void;
|
|
35
|
+
toggleCursorGuide: () => void;
|
|
36
|
+
togglePixelation: () => void;
|
|
37
|
+
selectTool: (tool: Tool) => void;
|
|
38
|
+
onIdleEscape?: () => void;
|
|
39
|
+
}
|
|
40
|
+
/** 기본 단축키 동작 — keymap prop이 키 배정을 재정의/비활성화한다. */
|
|
41
|
+
export declare function buildHotkeyActions<TMeta>(ctx: HotkeyContext<TMeta>): EditorActionHandlers;
|
|
42
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import type { RefObject } from "react";
|
|
|
2
2
|
import type { EditorInteractionMode } from "../_model/cursors";
|
|
3
3
|
import { type EditorShape, type Point, type ShapeStyle } from "../_model/geometry";
|
|
4
4
|
import type { EditorExternalTool } from "../_model/props";
|
|
5
|
+
import type { ShapeRenderStyleDefaults } from "../_model/shapeRenderStyle";
|
|
5
6
|
import { type Tool } from "../_model/tools";
|
|
6
7
|
import type { EditorRenderer, EditorRendererCallbacks } from "../_renderers/types";
|
|
7
8
|
import type { AssistantSession } from "./useAssistant";
|
|
@@ -20,6 +21,10 @@ export interface InteractionControllerCtx<TMeta> {
|
|
|
20
21
|
externalToolMapRef: RefObject<Map<string, EditorExternalTool>>;
|
|
21
22
|
spaceRef: RefObject<boolean>;
|
|
22
23
|
docRef: RefObject<EditorDocument<TMeta>>;
|
|
24
|
+
/** 숨김/비활성 오버라이드가 적용된 도형. 포인터 판정은 화면 상태를 따른다. */
|
|
25
|
+
renderShapesRef: RefObject<EditorShape<TMeta>[]>;
|
|
26
|
+
renderDefaultsRef: RefObject<ShapeRenderStyleDefaults>;
|
|
27
|
+
/** 부모가 확정한 선택. 단축키·메뉴·드래그 대상은 모두 이 값을 기준으로 한다. */
|
|
23
28
|
selRef: RefObject<string[]>;
|
|
24
29
|
draftRef: RefObject<ShapeStyle | undefined>;
|
|
25
30
|
readOnlyRef: RefObject<boolean | undefined>;
|
|
@@ -57,4 +62,12 @@ export interface InteractionControllerCtx<TMeta> {
|
|
|
57
62
|
points: Point[];
|
|
58
63
|
} | null) => void;
|
|
59
64
|
}
|
|
60
|
-
export
|
|
65
|
+
export interface InteractionController extends EditorRendererCallbacks {
|
|
66
|
+
/** 새 선택 요청 — 선택에 묶인 클릭 대기와 렌더러 변형만 취소한다. 취소했으면 true. */
|
|
67
|
+
interruptSelection: () => boolean;
|
|
68
|
+
/** Esc·도구/문서 전환 — 진행 중인 포인터 제스처와 렌더러 변형을 모두 취소한다. */
|
|
69
|
+
cancelGesture: () => boolean;
|
|
70
|
+
/** 부모가 확정 선택을 내려줄 때마다 호출 — 다른 선택으로 바뀌면 진행 중인 제스처를 취소한다. */
|
|
71
|
+
confirmSelection: (confirmed: string[]) => void;
|
|
72
|
+
}
|
|
73
|
+
export declare function createInteractionController<TMeta>(ctx: InteractionControllerCtx<TMeta>): InteractionController;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -34,7 +34,7 @@ export declare function shouldKeepViewportOnDocChange({ keepZoomOnImageChange, v
|
|
|
34
34
|
viewportSeeded: boolean;
|
|
35
35
|
}): boolean;
|
|
36
36
|
/**
|
|
37
|
-
* 렌더러 엔진 생명주기 —
|
|
37
|
+
* 렌더러 엔진 생명주기 — 마운트당 1회 생성/파괴, 이미지 전환(문서 전환 vs 화질 스왑),
|
|
38
38
|
* 휠 줌/팬·우클릭 메뉴 네이티브 리스너를 소유한다.
|
|
39
39
|
*
|
|
40
40
|
* 이미지 로딩/에러 상태는 별도 프리로드가 아니라 setImage 결과에서 파생한다 —
|
|
@@ -45,8 +45,7 @@ export declare function shouldKeepViewportOnDocChange({ keepZoomOnImageChange, v
|
|
|
45
45
|
* 이미지 변경은 엔진을 재사용해 setImage로 스왑한다. 문서 전환 중에는 이전 문서의
|
|
46
46
|
* 이미지·도형을 비우지만 캔버스 DOM과 렌더러 인스턴스는 유지한다.
|
|
47
47
|
*/
|
|
48
|
-
export declare function useEngineLifecycle<TMeta>({
|
|
49
|
-
backend: "konva" | "pixi";
|
|
48
|
+
export declare function useEngineLifecycle<TMeta>({ hostRef, engineRef, documentId, renderedImageUrl, makeCallbacks, viewRef, readOnlyRef, toolRef, renderShapesRef, coordinateSizeRef, imageSizeRef, selRef, regionOverlayRef, dimmedRef, syncMinimap, setImage, setImageVisible, setReady, setImageStatus, onContextMenuRequest, }: {
|
|
50
49
|
hostRef: RefObject<HTMLDivElement | null>;
|
|
51
50
|
engineRef: RefObject<EditorRenderer | null>;
|
|
52
51
|
/** 문서 identity — 문서 전환 vs 화질 스왑 구분용(URL 모양과 무관한 명시적 식별자). */
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import type { EditorShape, Point, ShapeStyle } from "../_model/geometry";
|
|
3
|
+
import type { ShapeEditorProps } from "../_model/props";
|
|
4
|
+
import type { EditorRenderer, Viewport } from "../_renderers/types";
|
|
5
|
+
import type { EditorDocument } from "./useEditorDocument";
|
|
6
|
+
interface Options<TMeta> {
|
|
7
|
+
engineRef: RefObject<EditorRenderer | null>;
|
|
8
|
+
docRef: RefObject<EditorDocument<TMeta>>;
|
|
9
|
+
draftRef: RefObject<ShapeStyle | undefined>;
|
|
10
|
+
draftMetaRef: RefObject<TMeta | undefined>;
|
|
11
|
+
/** 줌·이동 시 화면 좌표 오버레이 재배치 훅(미니맵 동기가 호출한다). */
|
|
12
|
+
screenOverlaySyncRef: RefObject<((viewport: Viewport) => void) | null>;
|
|
13
|
+
formatSelectionInfo: ShapeEditorProps<TMeta>["formatSelectionInfo"];
|
|
14
|
+
onDraftShapeChange: ShapeEditorProps<TMeta>["onDraftShapeChange"];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 선택 정보 배지(라벨·크기) — 드래그/변형·박스 그리기 중에는 React 리렌더 없이
|
|
18
|
+
* 배지 DOM을 직접 옮기고 텍스트만 바꾼다. 문서 커밋 전 프리뷰 좌표를 따라간다.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useSelectionInfoOverlay<TMeta>({ engineRef, docRef, draftRef, draftMetaRef, screenOverlaySyncRef, formatSelectionInfo, onDraftShapeChange, }: Options<TMeta>): {
|
|
21
|
+
register: (id: string, el: HTMLDivElement | null) => void;
|
|
22
|
+
applyPreview: (updates: {
|
|
23
|
+
id: string;
|
|
24
|
+
points: Point[];
|
|
25
|
+
}[]) => void;
|
|
26
|
+
onDrawPreview: (info: {
|
|
27
|
+
type: EditorShape<TMeta>["type"];
|
|
28
|
+
points: Point[];
|
|
29
|
+
} | null) => void;
|
|
30
|
+
drawPreviewShape: EditorShape<TMeta> | null;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
2
2
|
import type { ComponentPropsWithoutRef, Ref } from "react";
|
|
3
|
+
type SliderSize = "sm" | "md";
|
|
3
4
|
export interface SliderProps extends ComponentPropsWithoutRef<typeof SliderPrimitive.Root> {
|
|
5
|
+
size?: SliderSize;
|
|
4
6
|
trackClassName?: string | ((index: number) => string | undefined);
|
|
5
7
|
/** 트랙 자체(높이 등)를 한 번씩 다르게 써야 하는 호스트를 위한 국소 오버라이드. */
|
|
6
8
|
trackRootClassName?: string;
|
|
7
9
|
thumbClassName?: string | ((index: number) => string | undefined);
|
|
8
10
|
ref?: Ref<HTMLSpanElement>;
|
|
9
11
|
}
|
|
10
|
-
declare function Slider({ className, trackClassName, trackRootClassName, thumbClassName, defaultValue, value, min, max, step, onValueChange, ref, ...props }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function Slider({ size, className, trackClassName, trackRootClassName, thumbClassName, defaultValue, value, min, max, step, onValueChange, ref, ...props }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
export { Slider };
|