@xom11/whiteboard 0.24.2 → 0.27.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/README.md +84 -11
- package/dist/{ExcalidrawWithMenus-WENZRYYE.mjs → ExcalidrawWithMenus-2QPPTXJM.mjs} +3 -2
- package/dist/ExcalidrawWithMenus-2QPPTXJM.mjs.map +1 -0
- package/dist/ai.d.mts +3217 -434
- package/dist/ai.d.ts +3217 -434
- package/dist/ai.js +7679 -598
- package/dist/ai.js.map +1 -1
- package/dist/ai.mjs +5707 -679
- package/dist/ai.mjs.map +1 -1
- package/dist/catalog.json +5 -5
- package/dist/{chunk-7WQXXEVR.mjs → chunk-4ETJ4CDY.mjs} +5 -5
- package/dist/{chunk-7WQXXEVR.mjs.map → chunk-4ETJ4CDY.mjs.map} +1 -1
- package/dist/chunk-AJAHD35N.mjs +1708 -0
- package/dist/chunk-AJAHD35N.mjs.map +1 -0
- package/dist/chunk-AYJPOHCI.mjs +265 -0
- package/dist/chunk-AYJPOHCI.mjs.map +1 -0
- package/dist/chunk-B4NJJZFR.mjs +18 -0
- package/dist/chunk-B4NJJZFR.mjs.map +1 -0
- package/dist/{chunk-AZIARTGX.mjs → chunk-BNBOIDO5.mjs} +3 -3
- package/dist/{chunk-AZIARTGX.mjs.map → chunk-BNBOIDO5.mjs.map} +1 -1
- package/dist/{chunk-LVNCYP4J.mjs → chunk-CXHNVYMD.mjs} +5 -5
- package/dist/{chunk-LVNCYP4J.mjs.map → chunk-CXHNVYMD.mjs.map} +1 -1
- package/dist/{chunk-45CGKJ7S.mjs → chunk-D5JLJ3PT.mjs} +4 -4
- package/dist/{chunk-45CGKJ7S.mjs.map → chunk-D5JLJ3PT.mjs.map} +1 -1
- package/dist/{chunk-WM2VDYQA.mjs → chunk-D5LWSN2Y.mjs} +944 -196
- package/dist/chunk-D5LWSN2Y.mjs.map +1 -0
- package/dist/{chunk-KRC2XOIG.mjs → chunk-HLAOGXEK.mjs} +3 -3
- package/dist/{chunk-KRC2XOIG.mjs.map → chunk-HLAOGXEK.mjs.map} +1 -1
- package/dist/{chunk-2WF6KIGF.mjs → chunk-I3L56GVH.mjs} +212 -71
- package/dist/chunk-I3L56GVH.mjs.map +1 -0
- package/dist/{chunk-ZBJBQKJ2.mjs → chunk-IHUFOV7L.mjs} +4 -19
- package/dist/chunk-IHUFOV7L.mjs.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/{chunk-BEZSQKPY.mjs → chunk-KYMBUTPO.mjs} +5 -4
- package/dist/chunk-KYMBUTPO.mjs.map +1 -0
- package/dist/{chunk-4DS3MKID.mjs → chunk-KZGPSTZI.mjs} +4 -4
- package/dist/{chunk-4DS3MKID.mjs.map → chunk-KZGPSTZI.mjs.map} +1 -1
- package/dist/{chunk-SGFJLHHG.mjs → chunk-PPKHCRRE.mjs} +3 -3
- package/dist/{chunk-SGFJLHHG.mjs.map → chunk-PPKHCRRE.mjs.map} +1 -1
- package/dist/{chunk-BKSXPNPQ.mjs → chunk-SZDAS7LK.mjs} +81 -3
- package/dist/chunk-SZDAS7LK.mjs.map +1 -0
- package/dist/chunk-T3SOHYB2.mjs +851 -0
- package/dist/chunk-T3SOHYB2.mjs.map +1 -0
- package/dist/geometry-2d.d.mts +2 -2
- package/dist/geometry-2d.d.ts +2 -2
- package/dist/geometry-2d.js +6288 -901
- package/dist/geometry-2d.js.map +1 -1
- package/dist/geometry-2d.mjs +7 -5
- package/dist/geometry-3d.d.mts +2 -2
- package/dist/geometry-3d.d.ts +2 -2
- package/dist/geometry-3d.js +1335 -253
- package/dist/geometry-3d.js.map +1 -1
- package/dist/geometry-3d.mjs +6 -4
- package/dist/graph-2d.d.mts +2 -2
- package/dist/graph-2d.d.ts +2 -2
- package/dist/graph-2d.js +1501 -342
- package/dist/graph-2d.js.map +1 -1
- package/dist/graph-2d.mjs +9 -7
- package/dist/handleExtractProblem-C-U5KluK.d.mts +158 -0
- package/dist/handleExtractProblem-C-U5KluK.d.ts +158 -0
- package/dist/{host-EPZCNFLH.mjs → host-HAYCJJ2T.mjs} +1390 -376
- package/dist/host-HAYCJJ2T.mjs.map +1 -0
- package/dist/{host-LKCMYEAV.mjs → host-LTJHAY5A.mjs} +12 -10
- package/dist/host-LTJHAY5A.mjs.map +1 -0
- package/dist/{host-ZIQ77W33.mjs → host-M26FS244.mjs} +8 -6
- package/dist/host-M26FS244.mjs.map +1 -0
- package/dist/{host-QS2EOTRJ.mjs → host-ZQCDAT6O.mjs} +3 -2
- package/dist/host-ZQCDAT6O.mjs.map +1 -0
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +6493 -1102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -21
- package/dist/index.mjs.map +1 -1
- package/dist/latex.d.mts +2 -2
- package/dist/latex.d.ts +2 -2
- package/dist/latex.mjs +2 -1
- package/dist/render-ZX2O2IK7.mjs +10 -0
- package/dist/{render-SA4JTOW3.mjs.map → render-ZX2O2IK7.mjs.map} +1 -1
- package/dist/serialize-C3LSUMSA.mjs +9 -0
- package/dist/{serialize-JAVOU22E.mjs.map → serialize-C3LSUMSA.mjs.map} +1 -1
- package/dist/types-zc_Pa0mp.d.mts +418 -0
- package/dist/types-zc_Pa0mp.d.ts +418 -0
- package/package.json +10 -1
- package/dist/ExcalidrawWithMenus-WENZRYYE.mjs.map +0 -1
- package/dist/chunk-2WF6KIGF.mjs.map +0 -1
- package/dist/chunk-BEZSQKPY.mjs.map +0 -1
- package/dist/chunk-BKSXPNPQ.mjs.map +0 -1
- package/dist/chunk-CGZZO4BX.mjs +0 -96
- package/dist/chunk-CGZZO4BX.mjs.map +0 -1
- package/dist/chunk-WM2VDYQA.mjs.map +0 -1
- package/dist/chunk-ZBJBQKJ2.mjs.map +0 -1
- package/dist/host-EPZCNFLH.mjs.map +0 -1
- package/dist/host-LKCMYEAV.mjs.map +0 -1
- package/dist/host-QS2EOTRJ.mjs.map +0 -1
- package/dist/host-ZIQ77W33.mjs.map +0 -1
- package/dist/render-SA4JTOW3.mjs +0 -8
- package/dist/serialize-JAVOU22E.mjs +0 -7
- package/dist/types-Crbefnfe.d.ts +0 -128
- package/dist/types-DxlMPh-6.d.mts +0 -49
- package/dist/types-DxlMPh-6.d.ts +0 -49
- package/dist/types-vtvyKGAA.d.mts +0 -128
package/dist/types-Crbefnfe.d.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { ReactNode, ComponentType, RefAttributes } from 'react';
|
|
2
|
-
import { ExcalidrawElement } from '@excalidraw/excalidraw/element/types';
|
|
3
|
-
import { S as State } from './types-DxlMPh-6.js';
|
|
4
|
-
|
|
5
|
-
/** Minimal client-safe response required by the geometry AI editor. */
|
|
6
|
-
type AiFigureUiResult = {
|
|
7
|
-
ok: true;
|
|
8
|
-
state: State;
|
|
9
|
-
} | {
|
|
10
|
-
ok: false;
|
|
11
|
-
message: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Consumer-provided bridge to a server-side `generateFigure()` call.
|
|
15
|
-
* Implementations must keep API credentials outside the browser bundle.
|
|
16
|
-
*/
|
|
17
|
-
type GenerateGeometryFigure = (problem: string, options: {
|
|
18
|
-
signal: AbortSignal;
|
|
19
|
-
}) => Promise<AiFigureUiResult>;
|
|
20
|
-
/**
|
|
21
|
-
* Kết quả trả về từ `restoreFileFromCustomData`. Chứa đủ thông tin để
|
|
22
|
-
* consumer gọi `api.addFiles(...)`.
|
|
23
|
-
*/
|
|
24
|
-
interface RestoredStampFile {
|
|
25
|
-
fileId: string;
|
|
26
|
-
dataURL: string;
|
|
27
|
-
mimeType: 'image/svg+xml' | 'image/png';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Tối thiểu mọi custom data của stamp cần có. Các stamp cụ thể (geometry,
|
|
31
|
-
* latex, ...) extend interface này với fields riêng.
|
|
32
|
-
*/
|
|
33
|
-
interface BaseStampCustomData {
|
|
34
|
-
kind: string;
|
|
35
|
-
version: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Props mà mỗi StampHost nhận từ Whiteboard. Host component tự
|
|
39
|
-
* quản lý state nội bộ (panel ref, undo stack, displayMode...) — main view
|
|
40
|
-
* chỉ điều phối show/hide.
|
|
41
|
-
*/
|
|
42
|
-
interface StampHostProps {
|
|
43
|
-
api: any;
|
|
44
|
-
/**
|
|
45
|
-
* Element đang re-edit (double-click) hoặc null nếu đang tạo mới.
|
|
46
|
-
* Host tự parse customData để load state ban đầu.
|
|
47
|
-
*/
|
|
48
|
-
editingElement: {
|
|
49
|
-
id: string;
|
|
50
|
-
customData: unknown;
|
|
51
|
-
} | null;
|
|
52
|
-
/** Đóng stamp panel (gọi sau khi insert hoặc khi user huỷ). */
|
|
53
|
-
onClose: () => void;
|
|
54
|
-
/** Dark theme flag. */
|
|
55
|
-
isDark: boolean;
|
|
56
|
-
/** Optional client-safe bridge for the geometry-2d AI prompt editor. */
|
|
57
|
-
generateGeometryFigure?: GenerateGeometryFigure;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Imperative API mà main view truy cập qua ref:
|
|
61
|
-
* - tryInsert(): khi user click ra ngoài → auto-commit nếu valid.
|
|
62
|
-
* Trả về true nếu chèn thành công, false nếu chưa có nội dung.
|
|
63
|
-
* - hasContent(): có nội dung để chèn không.
|
|
64
|
-
*/
|
|
65
|
-
interface StampHostHandle {
|
|
66
|
-
tryInsert(): boolean;
|
|
67
|
-
hasContent(): boolean;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Component contract của Host. Chấp nhận cả `forwardRef` thông thường lẫn
|
|
71
|
-
* `React.lazy(() => import('./host'))` (LazyExoticComponent forwards ref).
|
|
72
|
-
*/
|
|
73
|
-
type StampHostComponent = ComponentType<StampHostProps & RefAttributes<StampHostHandle>>;
|
|
74
|
-
/**
|
|
75
|
-
* Định nghĩa 1 loại stamp. Mỗi stamp khai báo:
|
|
76
|
-
* - kind: unique string (khớp với customData.kind)
|
|
77
|
-
* - phím tắt + UI toolbar
|
|
78
|
-
* - cách nhận biết customData thuộc về stamp này (matchesCustomData)
|
|
79
|
-
* - cách re-render SVG từ customData (cho restore sau reload)
|
|
80
|
-
* - Host component: bọc trọn editor + left panel + insert logic
|
|
81
|
-
*
|
|
82
|
-
* Main view dispatch generic: `<stamp.Host ... />` — không cần biết kind.
|
|
83
|
-
*/
|
|
84
|
-
interface StampType<TCustomData extends BaseStampCustomData = BaseStampCustomData> {
|
|
85
|
-
/** Unique kind. VD: 'geometry', 'latex'. Phải khớp với customData.kind. */
|
|
86
|
-
kind: string;
|
|
87
|
-
/** Phím tắt mở/đóng stamp (lowercase, 1 ký tự). VD: 'g', 'l'. */
|
|
88
|
-
shortcutKey: string;
|
|
89
|
-
/** Chữ hiển thị overlay góc dưới nút toolbar (e.g. "G"). */
|
|
90
|
-
toolbarLabel: string;
|
|
91
|
-
/** Tooltip + aria-label của nút toolbar. */
|
|
92
|
-
toolbarTitle: string;
|
|
93
|
-
/** Icon SVG (ReactNode) trong nút toolbar. */
|
|
94
|
-
toolbarIcon: ReactNode;
|
|
95
|
-
/** Test data-testid cho nút toolbar (optional). */
|
|
96
|
-
toolbarTestId?: string;
|
|
97
|
-
/** Type guard: customData có thuộc về stamp này không. */
|
|
98
|
-
matchesCustomData(data: unknown): data is TCustomData;
|
|
99
|
-
/**
|
|
100
|
-
* Re-render SVG từ customData. Dùng khi restore math-stamp file sau reload
|
|
101
|
-
* page (Excalidraw không persist binary file payload, chỉ giữ fileId trong
|
|
102
|
-
* element). SVG render với light palette (nét đậm) — Excalidraw tự đảo
|
|
103
|
-
* màu trong dark mode qua CSS filter.
|
|
104
|
-
*/
|
|
105
|
-
renderSvgFromCustomData(data: TCustomData): Promise<string>;
|
|
106
|
-
/**
|
|
107
|
-
* Regenerate file SVG/PNG cho element thuộc stamp này khi reload từ persisted
|
|
108
|
-
* snapshot. Trả về `RestoredStampFile` để consumer gọi `api.addFiles`, hoặc
|
|
109
|
-
* `null` nếu element không cần file (vd stamp chỉ là text overlay).
|
|
110
|
-
*
|
|
111
|
-
* Khi method này có mặt, `restoreMissingStampFiles` sẽ ưu tiên gọi method
|
|
112
|
-
* này thay vì dùng `renderSvgFromCustomData`. Stamp tự chịu trách nhiệm lấy
|
|
113
|
-
* `fileId` từ element và render file.
|
|
114
|
-
*/
|
|
115
|
-
restoreFileFromCustomData?: (element: ExcalidrawElement) => Promise<RestoredStampFile | null>;
|
|
116
|
-
/**
|
|
117
|
-
* Host component bọc toàn bộ UI editing (panel + left panel + insert
|
|
118
|
-
* handler). Whiteboard mount Host khi activeStamp khớp kind.
|
|
119
|
-
*/
|
|
120
|
-
Host: StampHostComponent;
|
|
121
|
-
/**
|
|
122
|
-
* Đánh dấu stamp chưa production-ready. Consumer mặc định bỏ qua
|
|
123
|
-
* (xem `DEFAULT_STAMPS` chỉ gồm stamp không `experimental`).
|
|
124
|
-
*/
|
|
125
|
-
experimental?: boolean;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export type { AiFigureUiResult as A, BaseStampCustomData as B, GenerateGeometryFigure as G, StampType as S };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
type SceneObject<A = Record<string, unknown>> = {
|
|
2
|
-
id: string;
|
|
3
|
-
kind: string;
|
|
4
|
-
label: string;
|
|
5
|
-
visible: boolean;
|
|
6
|
-
locked: boolean;
|
|
7
|
-
layer: string;
|
|
8
|
-
schemaVersion: number;
|
|
9
|
-
attrs: A;
|
|
10
|
-
};
|
|
11
|
-
type View2D = {
|
|
12
|
-
readonly bbox: readonly [number, number, number, number];
|
|
13
|
-
readonly showAxis: boolean;
|
|
14
|
-
readonly showGrid: boolean;
|
|
15
|
-
};
|
|
16
|
-
type View3D = {
|
|
17
|
-
readonly bbox3D: readonly [number, number, number, number, number, number];
|
|
18
|
-
readonly azimuth: number;
|
|
19
|
-
readonly elevation: number;
|
|
20
|
-
};
|
|
21
|
-
type ViewGraph2D = {
|
|
22
|
-
readonly xMin: number;
|
|
23
|
-
readonly xMax: number;
|
|
24
|
-
readonly yMin: number;
|
|
25
|
-
readonly yMax: number;
|
|
26
|
-
readonly showAxis: boolean;
|
|
27
|
-
readonly showGrid: boolean;
|
|
28
|
-
};
|
|
29
|
-
type StateMeta = {
|
|
30
|
-
readonly domain: '2d';
|
|
31
|
-
readonly version: number;
|
|
32
|
-
readonly view: View2D;
|
|
33
|
-
} | {
|
|
34
|
-
readonly domain: '3d';
|
|
35
|
-
readonly version: number;
|
|
36
|
-
readonly view: View3D;
|
|
37
|
-
} | {
|
|
38
|
-
readonly domain: 'graph2d';
|
|
39
|
-
readonly version: number;
|
|
40
|
-
readonly view: ViewGraph2D;
|
|
41
|
-
};
|
|
42
|
-
type State = {
|
|
43
|
-
readonly objects: Readonly<Record<string, SceneObject>>;
|
|
44
|
-
readonly order: readonly string[];
|
|
45
|
-
readonly counter: number;
|
|
46
|
-
readonly meta: StateMeta;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type { State as S };
|
package/dist/types-DxlMPh-6.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
type SceneObject<A = Record<string, unknown>> = {
|
|
2
|
-
id: string;
|
|
3
|
-
kind: string;
|
|
4
|
-
label: string;
|
|
5
|
-
visible: boolean;
|
|
6
|
-
locked: boolean;
|
|
7
|
-
layer: string;
|
|
8
|
-
schemaVersion: number;
|
|
9
|
-
attrs: A;
|
|
10
|
-
};
|
|
11
|
-
type View2D = {
|
|
12
|
-
readonly bbox: readonly [number, number, number, number];
|
|
13
|
-
readonly showAxis: boolean;
|
|
14
|
-
readonly showGrid: boolean;
|
|
15
|
-
};
|
|
16
|
-
type View3D = {
|
|
17
|
-
readonly bbox3D: readonly [number, number, number, number, number, number];
|
|
18
|
-
readonly azimuth: number;
|
|
19
|
-
readonly elevation: number;
|
|
20
|
-
};
|
|
21
|
-
type ViewGraph2D = {
|
|
22
|
-
readonly xMin: number;
|
|
23
|
-
readonly xMax: number;
|
|
24
|
-
readonly yMin: number;
|
|
25
|
-
readonly yMax: number;
|
|
26
|
-
readonly showAxis: boolean;
|
|
27
|
-
readonly showGrid: boolean;
|
|
28
|
-
};
|
|
29
|
-
type StateMeta = {
|
|
30
|
-
readonly domain: '2d';
|
|
31
|
-
readonly version: number;
|
|
32
|
-
readonly view: View2D;
|
|
33
|
-
} | {
|
|
34
|
-
readonly domain: '3d';
|
|
35
|
-
readonly version: number;
|
|
36
|
-
readonly view: View3D;
|
|
37
|
-
} | {
|
|
38
|
-
readonly domain: 'graph2d';
|
|
39
|
-
readonly version: number;
|
|
40
|
-
readonly view: ViewGraph2D;
|
|
41
|
-
};
|
|
42
|
-
type State = {
|
|
43
|
-
readonly objects: Readonly<Record<string, SceneObject>>;
|
|
44
|
-
readonly order: readonly string[];
|
|
45
|
-
readonly counter: number;
|
|
46
|
-
readonly meta: StateMeta;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type { State as S };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { ReactNode, ComponentType, RefAttributes } from 'react';
|
|
2
|
-
import { ExcalidrawElement } from '@excalidraw/excalidraw/element/types';
|
|
3
|
-
import { S as State } from './types-DxlMPh-6.mjs';
|
|
4
|
-
|
|
5
|
-
/** Minimal client-safe response required by the geometry AI editor. */
|
|
6
|
-
type AiFigureUiResult = {
|
|
7
|
-
ok: true;
|
|
8
|
-
state: State;
|
|
9
|
-
} | {
|
|
10
|
-
ok: false;
|
|
11
|
-
message: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Consumer-provided bridge to a server-side `generateFigure()` call.
|
|
15
|
-
* Implementations must keep API credentials outside the browser bundle.
|
|
16
|
-
*/
|
|
17
|
-
type GenerateGeometryFigure = (problem: string, options: {
|
|
18
|
-
signal: AbortSignal;
|
|
19
|
-
}) => Promise<AiFigureUiResult>;
|
|
20
|
-
/**
|
|
21
|
-
* Kết quả trả về từ `restoreFileFromCustomData`. Chứa đủ thông tin để
|
|
22
|
-
* consumer gọi `api.addFiles(...)`.
|
|
23
|
-
*/
|
|
24
|
-
interface RestoredStampFile {
|
|
25
|
-
fileId: string;
|
|
26
|
-
dataURL: string;
|
|
27
|
-
mimeType: 'image/svg+xml' | 'image/png';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Tối thiểu mọi custom data của stamp cần có. Các stamp cụ thể (geometry,
|
|
31
|
-
* latex, ...) extend interface này với fields riêng.
|
|
32
|
-
*/
|
|
33
|
-
interface BaseStampCustomData {
|
|
34
|
-
kind: string;
|
|
35
|
-
version: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Props mà mỗi StampHost nhận từ Whiteboard. Host component tự
|
|
39
|
-
* quản lý state nội bộ (panel ref, undo stack, displayMode...) — main view
|
|
40
|
-
* chỉ điều phối show/hide.
|
|
41
|
-
*/
|
|
42
|
-
interface StampHostProps {
|
|
43
|
-
api: any;
|
|
44
|
-
/**
|
|
45
|
-
* Element đang re-edit (double-click) hoặc null nếu đang tạo mới.
|
|
46
|
-
* Host tự parse customData để load state ban đầu.
|
|
47
|
-
*/
|
|
48
|
-
editingElement: {
|
|
49
|
-
id: string;
|
|
50
|
-
customData: unknown;
|
|
51
|
-
} | null;
|
|
52
|
-
/** Đóng stamp panel (gọi sau khi insert hoặc khi user huỷ). */
|
|
53
|
-
onClose: () => void;
|
|
54
|
-
/** Dark theme flag. */
|
|
55
|
-
isDark: boolean;
|
|
56
|
-
/** Optional client-safe bridge for the geometry-2d AI prompt editor. */
|
|
57
|
-
generateGeometryFigure?: GenerateGeometryFigure;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Imperative API mà main view truy cập qua ref:
|
|
61
|
-
* - tryInsert(): khi user click ra ngoài → auto-commit nếu valid.
|
|
62
|
-
* Trả về true nếu chèn thành công, false nếu chưa có nội dung.
|
|
63
|
-
* - hasContent(): có nội dung để chèn không.
|
|
64
|
-
*/
|
|
65
|
-
interface StampHostHandle {
|
|
66
|
-
tryInsert(): boolean;
|
|
67
|
-
hasContent(): boolean;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Component contract của Host. Chấp nhận cả `forwardRef` thông thường lẫn
|
|
71
|
-
* `React.lazy(() => import('./host'))` (LazyExoticComponent forwards ref).
|
|
72
|
-
*/
|
|
73
|
-
type StampHostComponent = ComponentType<StampHostProps & RefAttributes<StampHostHandle>>;
|
|
74
|
-
/**
|
|
75
|
-
* Định nghĩa 1 loại stamp. Mỗi stamp khai báo:
|
|
76
|
-
* - kind: unique string (khớp với customData.kind)
|
|
77
|
-
* - phím tắt + UI toolbar
|
|
78
|
-
* - cách nhận biết customData thuộc về stamp này (matchesCustomData)
|
|
79
|
-
* - cách re-render SVG từ customData (cho restore sau reload)
|
|
80
|
-
* - Host component: bọc trọn editor + left panel + insert logic
|
|
81
|
-
*
|
|
82
|
-
* Main view dispatch generic: `<stamp.Host ... />` — không cần biết kind.
|
|
83
|
-
*/
|
|
84
|
-
interface StampType<TCustomData extends BaseStampCustomData = BaseStampCustomData> {
|
|
85
|
-
/** Unique kind. VD: 'geometry', 'latex'. Phải khớp với customData.kind. */
|
|
86
|
-
kind: string;
|
|
87
|
-
/** Phím tắt mở/đóng stamp (lowercase, 1 ký tự). VD: 'g', 'l'. */
|
|
88
|
-
shortcutKey: string;
|
|
89
|
-
/** Chữ hiển thị overlay góc dưới nút toolbar (e.g. "G"). */
|
|
90
|
-
toolbarLabel: string;
|
|
91
|
-
/** Tooltip + aria-label của nút toolbar. */
|
|
92
|
-
toolbarTitle: string;
|
|
93
|
-
/** Icon SVG (ReactNode) trong nút toolbar. */
|
|
94
|
-
toolbarIcon: ReactNode;
|
|
95
|
-
/** Test data-testid cho nút toolbar (optional). */
|
|
96
|
-
toolbarTestId?: string;
|
|
97
|
-
/** Type guard: customData có thuộc về stamp này không. */
|
|
98
|
-
matchesCustomData(data: unknown): data is TCustomData;
|
|
99
|
-
/**
|
|
100
|
-
* Re-render SVG từ customData. Dùng khi restore math-stamp file sau reload
|
|
101
|
-
* page (Excalidraw không persist binary file payload, chỉ giữ fileId trong
|
|
102
|
-
* element). SVG render với light palette (nét đậm) — Excalidraw tự đảo
|
|
103
|
-
* màu trong dark mode qua CSS filter.
|
|
104
|
-
*/
|
|
105
|
-
renderSvgFromCustomData(data: TCustomData): Promise<string>;
|
|
106
|
-
/**
|
|
107
|
-
* Regenerate file SVG/PNG cho element thuộc stamp này khi reload từ persisted
|
|
108
|
-
* snapshot. Trả về `RestoredStampFile` để consumer gọi `api.addFiles`, hoặc
|
|
109
|
-
* `null` nếu element không cần file (vd stamp chỉ là text overlay).
|
|
110
|
-
*
|
|
111
|
-
* Khi method này có mặt, `restoreMissingStampFiles` sẽ ưu tiên gọi method
|
|
112
|
-
* này thay vì dùng `renderSvgFromCustomData`. Stamp tự chịu trách nhiệm lấy
|
|
113
|
-
* `fileId` từ element và render file.
|
|
114
|
-
*/
|
|
115
|
-
restoreFileFromCustomData?: (element: ExcalidrawElement) => Promise<RestoredStampFile | null>;
|
|
116
|
-
/**
|
|
117
|
-
* Host component bọc toàn bộ UI editing (panel + left panel + insert
|
|
118
|
-
* handler). Whiteboard mount Host khi activeStamp khớp kind.
|
|
119
|
-
*/
|
|
120
|
-
Host: StampHostComponent;
|
|
121
|
-
/**
|
|
122
|
-
* Đánh dấu stamp chưa production-ready. Consumer mặc định bỏ qua
|
|
123
|
-
* (xem `DEFAULT_STAMPS` chỉ gồm stamp không `experimental`).
|
|
124
|
-
*/
|
|
125
|
-
experimental?: boolean;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export type { AiFigureUiResult as A, BaseStampCustomData as B, GenerateGeometryFigure as G, StampType as S };
|