@xom11/whiteboard 0.6.4 → 0.7.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 +36 -0
- package/dist/chunk-3SSQKRRO.mjs +58 -0
- package/dist/chunk-3SSQKRRO.mjs.map +1 -0
- package/dist/chunk-7P7SQFOW.mjs +39 -0
- package/dist/chunk-7P7SQFOW.mjs.map +1 -0
- package/dist/chunk-BJX4YNA5.mjs +137 -0
- package/dist/chunk-BJX4YNA5.mjs.map +1 -0
- package/dist/chunk-C6SCVOMC.mjs +111 -0
- package/dist/chunk-C6SCVOMC.mjs.map +1 -0
- package/dist/chunk-DJTBZEAR.mjs +25 -0
- package/dist/chunk-DJTBZEAR.mjs.map +1 -0
- package/dist/chunk-HM7RIXJE.mjs +331 -0
- package/dist/chunk-HM7RIXJE.mjs.map +1 -0
- package/dist/chunk-HTBLO5JO.mjs +41 -0
- package/dist/chunk-HTBLO5JO.mjs.map +1 -0
- package/dist/chunk-HYXFHEDJ.mjs +129 -0
- package/dist/chunk-HYXFHEDJ.mjs.map +1 -0
- package/dist/chunk-LPM4MM45.mjs +211 -0
- package/dist/chunk-LPM4MM45.mjs.map +1 -0
- package/dist/chunk-P2AOIF7S.mjs +40 -0
- package/dist/chunk-P2AOIF7S.mjs.map +1 -0
- package/dist/chunk-SHFOGORM.mjs +44 -0
- package/dist/chunk-SHFOGORM.mjs.map +1 -0
- package/dist/chunk-X5R72SSJ.mjs +52 -0
- package/dist/chunk-X5R72SSJ.mjs.map +1 -0
- package/dist/geometry-2d.d.mts +16 -0
- package/dist/geometry-2d.d.ts +16 -0
- package/dist/geometry-2d.js +3549 -0
- package/dist/geometry-2d.js.map +1 -0
- package/dist/geometry-2d.mjs +7 -0
- package/dist/geometry-2d.mjs.map +1 -0
- package/dist/geometry-3d.d.mts +16 -0
- package/dist/geometry-3d.d.ts +16 -0
- package/dist/geometry-3d.js +2030 -0
- package/dist/geometry-3d.js.map +1 -0
- package/dist/geometry-3d.mjs +6 -0
- package/dist/geometry-3d.mjs.map +1 -0
- package/dist/graph-2d.d.mts +16 -0
- package/dist/graph-2d.d.ts +16 -0
- package/dist/graph-2d.js +1725 -0
- package/dist/graph-2d.js.map +1 -0
- package/dist/graph-2d.mjs +6 -0
- package/dist/graph-2d.mjs.map +1 -0
- package/dist/host-2QGKMGCT.mjs +1066 -0
- package/dist/host-2QGKMGCT.mjs.map +1 -0
- package/dist/host-T2W6R6SO.mjs +2859 -0
- package/dist/host-T2W6R6SO.mjs.map +1 -0
- package/dist/host-XUFON6CQ.mjs +1422 -0
- package/dist/host-XUFON6CQ.mjs.map +1 -0
- package/dist/host-Z3TEJKZA.mjs +466 -0
- package/dist/host-Z3TEJKZA.mjs.map +1 -0
- package/dist/index.d.mts +27 -146
- package/dist/index.d.ts +27 -146
- package/dist/index.js +4694 -4482
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -7179
- package/dist/index.mjs.map +1 -1
- package/dist/latex.d.mts +15 -0
- package/dist/latex.d.ts +15 -0
- package/dist/latex.js +750 -0
- package/dist/latex.js.map +1 -0
- package/dist/latex.mjs +6 -0
- package/dist/latex.mjs.map +1 -0
- package/dist/types-CinstD7T.d.mts +110 -0
- package/dist/types-CinstD7T.d.ts +110 -0
- package/package.json +24 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { NonDeletedExcalidrawElement
|
|
2
|
+
import { NonDeletedExcalidrawElement } from '@excalidraw/excalidraw/element/types';
|
|
3
3
|
export { ExcalidrawElement, NonDeletedExcalidrawElement } from '@excalidraw/excalidraw/element/types';
|
|
4
4
|
import { AppState, BinaryFiles } from '@excalidraw/excalidraw/types';
|
|
5
5
|
export { AppState, BinaryFiles } from '@excalidraw/excalidraw/types';
|
|
6
|
-
import {
|
|
6
|
+
import { S as StampType } from './types-CinstD7T.mjs';
|
|
7
|
+
export { B as BaseStampCustomData } from './types-CinstD7T.mjs';
|
|
8
|
+
import { GeometryCustomData } from './geometry-2d.mjs';
|
|
9
|
+
export { geometryStamp, isGeometryCustomData } from './geometry-2d.mjs';
|
|
10
|
+
import { LatexCustomData } from './latex.mjs';
|
|
11
|
+
export { isLatexCustomData, latexStamp } from './latex.mjs';
|
|
12
|
+
import { Geometry3DCustomData } from './geometry-3d.mjs';
|
|
13
|
+
export { geometry3dStamp, isGeometry3DCustomData } from './geometry-3d.mjs';
|
|
14
|
+
import { Graph2DCustomData } from './graph-2d.mjs';
|
|
15
|
+
export { graph2dStamp, isGraph2DCustomData } from './graph-2d.mjs';
|
|
16
|
+
import 'react';
|
|
7
17
|
|
|
8
18
|
interface SyncableAppState {
|
|
9
19
|
viewBackgroundColor: string;
|
|
@@ -18,156 +28,27 @@ interface ExcalidrawSceneSnapshot {
|
|
|
18
28
|
appState: SyncableAppState;
|
|
19
29
|
}
|
|
20
30
|
|
|
31
|
+
/** Stamp ổn định, sẵn sàng production. */
|
|
32
|
+
declare const STABLE_STAMPS: ReadonlyArray<StampType>;
|
|
33
|
+
/** Stamp experimental — chưa ổn định cho production. Consumer phải opt-in. */
|
|
34
|
+
declare const EXPERIMENTAL_STAMPS: ReadonlyArray<StampType>;
|
|
35
|
+
/** Tất cả stamp (stable + experimental). Dùng khi consumer muốn full feature. */
|
|
36
|
+
declare const ALL_STAMPS: ReadonlyArray<StampType>;
|
|
21
37
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
interface RestoredStampFile {
|
|
26
|
-
fileId: string;
|
|
27
|
-
dataURL: string;
|
|
28
|
-
mimeType: 'image/svg+xml' | 'image/png';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Tối thiểu mọi custom data của stamp cần có. Các stamp cụ thể (geometry,
|
|
32
|
-
* latex, ...) extend interface này với fields riêng.
|
|
33
|
-
*/
|
|
34
|
-
interface BaseStampCustomData {
|
|
35
|
-
kind: string;
|
|
36
|
-
version: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Props mà mỗi StampHost nhận từ Whiteboard. Host component tự
|
|
40
|
-
* quản lý state nội bộ (panel ref, undo stack, displayMode...) — main view
|
|
41
|
-
* chỉ điều phối show/hide.
|
|
42
|
-
*/
|
|
43
|
-
interface StampHostProps {
|
|
44
|
-
api: any;
|
|
45
|
-
/**
|
|
46
|
-
* Element đang re-edit (double-click) hoặc null nếu đang tạo mới.
|
|
47
|
-
* Host tự parse customData để load state ban đầu.
|
|
48
|
-
*/
|
|
49
|
-
editingElement: {
|
|
50
|
-
id: string;
|
|
51
|
-
customData: unknown;
|
|
52
|
-
} | null;
|
|
53
|
-
/** Đóng stamp panel (gọi sau khi insert hoặc khi user huỷ). */
|
|
54
|
-
onClose: () => void;
|
|
55
|
-
/** Dark theme flag. */
|
|
56
|
-
isDark: boolean;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Imperative API mà main view truy cập qua ref:
|
|
60
|
-
* - tryInsert(): khi user click ra ngoài → auto-commit nếu valid.
|
|
61
|
-
* Trả về true nếu chèn thành công, false nếu chưa có nội dung.
|
|
62
|
-
* - hasContent(): có nội dung để chèn không.
|
|
63
|
-
*/
|
|
64
|
-
interface StampHostHandle {
|
|
65
|
-
tryInsert(): boolean;
|
|
66
|
-
hasContent(): boolean;
|
|
67
|
-
}
|
|
68
|
-
type StampHostComponent = ForwardRefExoticComponent<StampHostProps & RefAttributes<StampHostHandle>>;
|
|
69
|
-
/**
|
|
70
|
-
* Định nghĩa 1 loại stamp. Mỗi stamp khai báo:
|
|
71
|
-
* - kind: unique string (khớp với customData.kind)
|
|
72
|
-
* - phím tắt + UI toolbar
|
|
73
|
-
* - cách nhận biết customData thuộc về stamp này (matchesCustomData)
|
|
74
|
-
* - cách re-render SVG từ customData (cho restore sau reload)
|
|
75
|
-
* - Host component: bọc trọn editor + left panel + insert logic
|
|
76
|
-
*
|
|
77
|
-
* Main view dispatch generic: `<stamp.Host ... />` — không cần biết kind.
|
|
78
|
-
*/
|
|
79
|
-
interface StampType {
|
|
80
|
-
/** Unique kind. VD: 'geometry', 'latex'. Phải khớp với customData.kind. */
|
|
81
|
-
kind: string;
|
|
82
|
-
/** Phím tắt mở/đóng stamp (lowercase, 1 ký tự). VD: 'g', 'l'. */
|
|
83
|
-
shortcutKey: string;
|
|
84
|
-
/** Chữ hiển thị overlay góc dưới nút toolbar (e.g. "G"). */
|
|
85
|
-
toolbarLabel: string;
|
|
86
|
-
/** Tooltip + aria-label của nút toolbar. */
|
|
87
|
-
toolbarTitle: string;
|
|
88
|
-
/** Icon SVG (ReactNode) trong nút toolbar. */
|
|
89
|
-
toolbarIcon: ReactNode;
|
|
90
|
-
/** Test data-testid cho nút toolbar (optional). */
|
|
91
|
-
toolbarTestId?: string;
|
|
92
|
-
/** Type guard: customData có thuộc về stamp này không. */
|
|
93
|
-
matchesCustomData(data: unknown): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Re-render SVG từ customData. Dùng khi restore math-stamp file sau reload
|
|
96
|
-
* page (Excalidraw không persist binary file payload, chỉ giữ fileId trong
|
|
97
|
-
* element). SVG render với light palette (nét đậm) — Excalidraw tự đảo
|
|
98
|
-
* màu trong dark mode qua CSS filter.
|
|
99
|
-
*/
|
|
100
|
-
renderSvgFromCustomData(data: unknown): Promise<string>;
|
|
101
|
-
/**
|
|
102
|
-
* Regenerate file SVG/PNG cho element thuộc stamp này khi reload từ persisted
|
|
103
|
-
* snapshot. Trả về `RestoredStampFile` để consumer gọi `api.addFiles`, hoặc
|
|
104
|
-
* `null` nếu element không cần file (vd stamp chỉ là text overlay).
|
|
105
|
-
*
|
|
106
|
-
* Khi method này có mặt, `restoreMissingStampFiles` sẽ ưu tiên gọi method
|
|
107
|
-
* này thay vì dùng `renderSvgFromCustomData`. Stamp tự chịu trách nhiệm lấy
|
|
108
|
-
* `fileId` từ element và render file.
|
|
109
|
-
*/
|
|
110
|
-
restoreFileFromCustomData?: (element: ExcalidrawElement) => Promise<RestoredStampFile | null>;
|
|
111
|
-
/**
|
|
112
|
-
* Host component bọc toàn bộ UI editing (panel + left panel + insert
|
|
113
|
-
* handler). Whiteboard mount Host khi activeStamp khớp kind.
|
|
114
|
-
*/
|
|
115
|
-
Host: StampHostComponent;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
interface GeometryCustomData extends BaseStampCustomData {
|
|
119
|
-
kind: 'geometry';
|
|
120
|
-
version: 1;
|
|
121
|
-
jsonState: string;
|
|
122
|
-
svgWidth: number;
|
|
123
|
-
svgHeight: number;
|
|
124
|
-
}
|
|
125
|
-
declare function isGeometryCustomData(data: unknown): data is GeometryCustomData;
|
|
126
|
-
declare const geometryStamp: StampType;
|
|
127
|
-
|
|
128
|
-
interface LatexCustomData extends BaseStampCustomData {
|
|
129
|
-
kind: 'latex';
|
|
130
|
-
version: 1;
|
|
131
|
-
src: string;
|
|
132
|
-
displayMode: boolean;
|
|
133
|
-
}
|
|
134
|
-
declare function isLatexCustomData(data: unknown): data is LatexCustomData;
|
|
135
|
-
declare const latexStamp: StampType;
|
|
136
|
-
|
|
137
|
-
interface Geometry3DCustomData extends BaseStampCustomData {
|
|
138
|
-
kind: 'geometry3d';
|
|
139
|
-
version: 1;
|
|
140
|
-
jsonState: string;
|
|
141
|
-
svgWidth: number;
|
|
142
|
-
svgHeight: number;
|
|
143
|
-
}
|
|
144
|
-
declare function isGeometry3DCustomData(data: unknown): data is Geometry3DCustomData;
|
|
145
|
-
|
|
146
|
-
declare const geometry3dStamp: StampType;
|
|
147
|
-
|
|
148
|
-
interface Graph2DCustomData extends BaseStampCustomData {
|
|
149
|
-
kind: 'graph2d';
|
|
150
|
-
version: 1;
|
|
151
|
-
jsonState: string;
|
|
152
|
-
svgWidth: number;
|
|
153
|
-
svgHeight: number;
|
|
154
|
-
}
|
|
155
|
-
declare function isGraph2DCustomData(data: unknown): data is Graph2DCustomData;
|
|
156
|
-
declare const graph2dStamp: StampType;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Set stamp mặc định dùng trong Whiteboard. Consumer có thể
|
|
160
|
-
* truyền custom array để bật/tắt từng stamp hoặc đăng ký stamp mới.
|
|
38
|
+
* Set stamp mặc định cho Whiteboard. v0.7.0 trở đi = STABLE_STAMPS.
|
|
39
|
+
* Consumer muốn experimental: `<Whiteboard stamps={ALL_STAMPS} />` hoặc
|
|
40
|
+
* `[...DEFAULT_STAMPS, geometry3dStamp]`.
|
|
161
41
|
*
|
|
162
42
|
* Để thêm 1 stamp mới (vd chart):
|
|
163
|
-
* 1. Tạo `src/
|
|
164
|
-
* 2.
|
|
165
|
-
*
|
|
43
|
+
* 1. Tạo `src/stamps/chart/index.tsx` export `chartStamp: StampType`.
|
|
44
|
+
* 2. Import + add vào STABLE_STAMPS (production-ready) hoặc
|
|
45
|
+
* EXPERIMENTAL_STAMPS (chưa ổn định) ở file này.
|
|
46
|
+
* 3. Re-export `chartStamp` từ `src/stamps/index.ts` + `src/index.ts`.
|
|
166
47
|
*/
|
|
167
48
|
declare const DEFAULT_STAMPS: ReadonlyArray<StampType>;
|
|
168
49
|
/** Tìm stamp tương ứng với customData của element. null nếu không match. */
|
|
169
50
|
declare function findStampForCustomData(data: unknown, stamps?: ReadonlyArray<StampType>): StampType | null;
|
|
170
|
-
/** isMathStamp version dựa trên registry
|
|
51
|
+
/** isMathStamp version dựa trên registry. */
|
|
171
52
|
declare function isStampElement<T extends {
|
|
172
53
|
customData?: unknown;
|
|
173
54
|
}>(element: T, stamps?: ReadonlyArray<StampType>): boolean;
|
|
@@ -225,4 +106,4 @@ declare function restoreMissingStampFiles(api: any, elements: readonly ElementLi
|
|
|
225
106
|
|
|
226
107
|
type StampCustomData = GeometryCustomData | LatexCustomData | Geometry3DCustomData | Graph2DCustomData;
|
|
227
108
|
|
|
228
|
-
export {
|
|
109
|
+
export { ALL_STAMPS, DEFAULT_STAMPS, EXPERIMENTAL_STAMPS, type ExcalidrawSceneSnapshot, Geometry3DCustomData, GeometryCustomData, Graph2DCustomData, LatexCustomData, STABLE_STAMPS, type StampCustomData, StampType, type SyncableAppState, Whiteboard, type WhiteboardProps, findStampForCustomData, isStampElement, pickSyncableAppState, restoreMissingStampFiles };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { NonDeletedExcalidrawElement
|
|
2
|
+
import { NonDeletedExcalidrawElement } from '@excalidraw/excalidraw/element/types';
|
|
3
3
|
export { ExcalidrawElement, NonDeletedExcalidrawElement } from '@excalidraw/excalidraw/element/types';
|
|
4
4
|
import { AppState, BinaryFiles } from '@excalidraw/excalidraw/types';
|
|
5
5
|
export { AppState, BinaryFiles } from '@excalidraw/excalidraw/types';
|
|
6
|
-
import {
|
|
6
|
+
import { S as StampType } from './types-CinstD7T.js';
|
|
7
|
+
export { B as BaseStampCustomData } from './types-CinstD7T.js';
|
|
8
|
+
import { GeometryCustomData } from './geometry-2d.js';
|
|
9
|
+
export { geometryStamp, isGeometryCustomData } from './geometry-2d.js';
|
|
10
|
+
import { LatexCustomData } from './latex.js';
|
|
11
|
+
export { isLatexCustomData, latexStamp } from './latex.js';
|
|
12
|
+
import { Geometry3DCustomData } from './geometry-3d.js';
|
|
13
|
+
export { geometry3dStamp, isGeometry3DCustomData } from './geometry-3d.js';
|
|
14
|
+
import { Graph2DCustomData } from './graph-2d.js';
|
|
15
|
+
export { graph2dStamp, isGraph2DCustomData } from './graph-2d.js';
|
|
16
|
+
import 'react';
|
|
7
17
|
|
|
8
18
|
interface SyncableAppState {
|
|
9
19
|
viewBackgroundColor: string;
|
|
@@ -18,156 +28,27 @@ interface ExcalidrawSceneSnapshot {
|
|
|
18
28
|
appState: SyncableAppState;
|
|
19
29
|
}
|
|
20
30
|
|
|
31
|
+
/** Stamp ổn định, sẵn sàng production. */
|
|
32
|
+
declare const STABLE_STAMPS: ReadonlyArray<StampType>;
|
|
33
|
+
/** Stamp experimental — chưa ổn định cho production. Consumer phải opt-in. */
|
|
34
|
+
declare const EXPERIMENTAL_STAMPS: ReadonlyArray<StampType>;
|
|
35
|
+
/** Tất cả stamp (stable + experimental). Dùng khi consumer muốn full feature. */
|
|
36
|
+
declare const ALL_STAMPS: ReadonlyArray<StampType>;
|
|
21
37
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
interface RestoredStampFile {
|
|
26
|
-
fileId: string;
|
|
27
|
-
dataURL: string;
|
|
28
|
-
mimeType: 'image/svg+xml' | 'image/png';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Tối thiểu mọi custom data của stamp cần có. Các stamp cụ thể (geometry,
|
|
32
|
-
* latex, ...) extend interface này với fields riêng.
|
|
33
|
-
*/
|
|
34
|
-
interface BaseStampCustomData {
|
|
35
|
-
kind: string;
|
|
36
|
-
version: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Props mà mỗi StampHost nhận từ Whiteboard. Host component tự
|
|
40
|
-
* quản lý state nội bộ (panel ref, undo stack, displayMode...) — main view
|
|
41
|
-
* chỉ điều phối show/hide.
|
|
42
|
-
*/
|
|
43
|
-
interface StampHostProps {
|
|
44
|
-
api: any;
|
|
45
|
-
/**
|
|
46
|
-
* Element đang re-edit (double-click) hoặc null nếu đang tạo mới.
|
|
47
|
-
* Host tự parse customData để load state ban đầu.
|
|
48
|
-
*/
|
|
49
|
-
editingElement: {
|
|
50
|
-
id: string;
|
|
51
|
-
customData: unknown;
|
|
52
|
-
} | null;
|
|
53
|
-
/** Đóng stamp panel (gọi sau khi insert hoặc khi user huỷ). */
|
|
54
|
-
onClose: () => void;
|
|
55
|
-
/** Dark theme flag. */
|
|
56
|
-
isDark: boolean;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Imperative API mà main view truy cập qua ref:
|
|
60
|
-
* - tryInsert(): khi user click ra ngoài → auto-commit nếu valid.
|
|
61
|
-
* Trả về true nếu chèn thành công, false nếu chưa có nội dung.
|
|
62
|
-
* - hasContent(): có nội dung để chèn không.
|
|
63
|
-
*/
|
|
64
|
-
interface StampHostHandle {
|
|
65
|
-
tryInsert(): boolean;
|
|
66
|
-
hasContent(): boolean;
|
|
67
|
-
}
|
|
68
|
-
type StampHostComponent = ForwardRefExoticComponent<StampHostProps & RefAttributes<StampHostHandle>>;
|
|
69
|
-
/**
|
|
70
|
-
* Định nghĩa 1 loại stamp. Mỗi stamp khai báo:
|
|
71
|
-
* - kind: unique string (khớp với customData.kind)
|
|
72
|
-
* - phím tắt + UI toolbar
|
|
73
|
-
* - cách nhận biết customData thuộc về stamp này (matchesCustomData)
|
|
74
|
-
* - cách re-render SVG từ customData (cho restore sau reload)
|
|
75
|
-
* - Host component: bọc trọn editor + left panel + insert logic
|
|
76
|
-
*
|
|
77
|
-
* Main view dispatch generic: `<stamp.Host ... />` — không cần biết kind.
|
|
78
|
-
*/
|
|
79
|
-
interface StampType {
|
|
80
|
-
/** Unique kind. VD: 'geometry', 'latex'. Phải khớp với customData.kind. */
|
|
81
|
-
kind: string;
|
|
82
|
-
/** Phím tắt mở/đóng stamp (lowercase, 1 ký tự). VD: 'g', 'l'. */
|
|
83
|
-
shortcutKey: string;
|
|
84
|
-
/** Chữ hiển thị overlay góc dưới nút toolbar (e.g. "G"). */
|
|
85
|
-
toolbarLabel: string;
|
|
86
|
-
/** Tooltip + aria-label của nút toolbar. */
|
|
87
|
-
toolbarTitle: string;
|
|
88
|
-
/** Icon SVG (ReactNode) trong nút toolbar. */
|
|
89
|
-
toolbarIcon: ReactNode;
|
|
90
|
-
/** Test data-testid cho nút toolbar (optional). */
|
|
91
|
-
toolbarTestId?: string;
|
|
92
|
-
/** Type guard: customData có thuộc về stamp này không. */
|
|
93
|
-
matchesCustomData(data: unknown): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Re-render SVG từ customData. Dùng khi restore math-stamp file sau reload
|
|
96
|
-
* page (Excalidraw không persist binary file payload, chỉ giữ fileId trong
|
|
97
|
-
* element). SVG render với light palette (nét đậm) — Excalidraw tự đảo
|
|
98
|
-
* màu trong dark mode qua CSS filter.
|
|
99
|
-
*/
|
|
100
|
-
renderSvgFromCustomData(data: unknown): Promise<string>;
|
|
101
|
-
/**
|
|
102
|
-
* Regenerate file SVG/PNG cho element thuộc stamp này khi reload từ persisted
|
|
103
|
-
* snapshot. Trả về `RestoredStampFile` để consumer gọi `api.addFiles`, hoặc
|
|
104
|
-
* `null` nếu element không cần file (vd stamp chỉ là text overlay).
|
|
105
|
-
*
|
|
106
|
-
* Khi method này có mặt, `restoreMissingStampFiles` sẽ ưu tiên gọi method
|
|
107
|
-
* này thay vì dùng `renderSvgFromCustomData`. Stamp tự chịu trách nhiệm lấy
|
|
108
|
-
* `fileId` từ element và render file.
|
|
109
|
-
*/
|
|
110
|
-
restoreFileFromCustomData?: (element: ExcalidrawElement) => Promise<RestoredStampFile | null>;
|
|
111
|
-
/**
|
|
112
|
-
* Host component bọc toàn bộ UI editing (panel + left panel + insert
|
|
113
|
-
* handler). Whiteboard mount Host khi activeStamp khớp kind.
|
|
114
|
-
*/
|
|
115
|
-
Host: StampHostComponent;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
interface GeometryCustomData extends BaseStampCustomData {
|
|
119
|
-
kind: 'geometry';
|
|
120
|
-
version: 1;
|
|
121
|
-
jsonState: string;
|
|
122
|
-
svgWidth: number;
|
|
123
|
-
svgHeight: number;
|
|
124
|
-
}
|
|
125
|
-
declare function isGeometryCustomData(data: unknown): data is GeometryCustomData;
|
|
126
|
-
declare const geometryStamp: StampType;
|
|
127
|
-
|
|
128
|
-
interface LatexCustomData extends BaseStampCustomData {
|
|
129
|
-
kind: 'latex';
|
|
130
|
-
version: 1;
|
|
131
|
-
src: string;
|
|
132
|
-
displayMode: boolean;
|
|
133
|
-
}
|
|
134
|
-
declare function isLatexCustomData(data: unknown): data is LatexCustomData;
|
|
135
|
-
declare const latexStamp: StampType;
|
|
136
|
-
|
|
137
|
-
interface Geometry3DCustomData extends BaseStampCustomData {
|
|
138
|
-
kind: 'geometry3d';
|
|
139
|
-
version: 1;
|
|
140
|
-
jsonState: string;
|
|
141
|
-
svgWidth: number;
|
|
142
|
-
svgHeight: number;
|
|
143
|
-
}
|
|
144
|
-
declare function isGeometry3DCustomData(data: unknown): data is Geometry3DCustomData;
|
|
145
|
-
|
|
146
|
-
declare const geometry3dStamp: StampType;
|
|
147
|
-
|
|
148
|
-
interface Graph2DCustomData extends BaseStampCustomData {
|
|
149
|
-
kind: 'graph2d';
|
|
150
|
-
version: 1;
|
|
151
|
-
jsonState: string;
|
|
152
|
-
svgWidth: number;
|
|
153
|
-
svgHeight: number;
|
|
154
|
-
}
|
|
155
|
-
declare function isGraph2DCustomData(data: unknown): data is Graph2DCustomData;
|
|
156
|
-
declare const graph2dStamp: StampType;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Set stamp mặc định dùng trong Whiteboard. Consumer có thể
|
|
160
|
-
* truyền custom array để bật/tắt từng stamp hoặc đăng ký stamp mới.
|
|
38
|
+
* Set stamp mặc định cho Whiteboard. v0.7.0 trở đi = STABLE_STAMPS.
|
|
39
|
+
* Consumer muốn experimental: `<Whiteboard stamps={ALL_STAMPS} />` hoặc
|
|
40
|
+
* `[...DEFAULT_STAMPS, geometry3dStamp]`.
|
|
161
41
|
*
|
|
162
42
|
* Để thêm 1 stamp mới (vd chart):
|
|
163
|
-
* 1. Tạo `src/
|
|
164
|
-
* 2.
|
|
165
|
-
*
|
|
43
|
+
* 1. Tạo `src/stamps/chart/index.tsx` export `chartStamp: StampType`.
|
|
44
|
+
* 2. Import + add vào STABLE_STAMPS (production-ready) hoặc
|
|
45
|
+
* EXPERIMENTAL_STAMPS (chưa ổn định) ở file này.
|
|
46
|
+
* 3. Re-export `chartStamp` từ `src/stamps/index.ts` + `src/index.ts`.
|
|
166
47
|
*/
|
|
167
48
|
declare const DEFAULT_STAMPS: ReadonlyArray<StampType>;
|
|
168
49
|
/** Tìm stamp tương ứng với customData của element. null nếu không match. */
|
|
169
50
|
declare function findStampForCustomData(data: unknown, stamps?: ReadonlyArray<StampType>): StampType | null;
|
|
170
|
-
/** isMathStamp version dựa trên registry
|
|
51
|
+
/** isMathStamp version dựa trên registry. */
|
|
171
52
|
declare function isStampElement<T extends {
|
|
172
53
|
customData?: unknown;
|
|
173
54
|
}>(element: T, stamps?: ReadonlyArray<StampType>): boolean;
|
|
@@ -225,4 +106,4 @@ declare function restoreMissingStampFiles(api: any, elements: readonly ElementLi
|
|
|
225
106
|
|
|
226
107
|
type StampCustomData = GeometryCustomData | LatexCustomData | Geometry3DCustomData | Graph2DCustomData;
|
|
227
108
|
|
|
228
|
-
export {
|
|
109
|
+
export { ALL_STAMPS, DEFAULT_STAMPS, EXPERIMENTAL_STAMPS, type ExcalidrawSceneSnapshot, Geometry3DCustomData, GeometryCustomData, Graph2DCustomData, LatexCustomData, STABLE_STAMPS, type StampCustomData, StampType, type SyncableAppState, Whiteboard, type WhiteboardProps, findStampForCustomData, isStampElement, pickSyncableAppState, restoreMissingStampFiles };
|