mathlean-canvas 0.3.5 → 0.3.6
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 +124 -6
- package/dist/InlineMathLiveField.d.ts +2 -1
- package/dist/MathCanvas/components/CanvasOverlayViewport.d.ts +5 -3
- package/dist/MathCanvas/components/CollaborationOverlay.d.ts +10 -0
- package/dist/MathCanvas/components/Toolbar.d.ts +5 -6
- package/dist/MathCanvas/components/icons.d.ts +8 -0
- package/dist/MathCanvas/core/hooks/useCanvasGlobalActions.d.ts +2 -9
- package/dist/MathCanvas/core/hooks/useCanvasSnapshot.d.ts +6 -2
- package/dist/MathCanvas/core/hooks/useCanvasStageInteractions.d.ts +31 -6
- package/dist/MathCanvas/core/hooks/useCanvasViewport.d.ts +5 -1
- package/dist/MathCanvas/features/geometry/components/CoordinatePlaneLayer.d.ts +2 -1
- package/dist/MathCanvas/features/graph/components/GraphLayer.d.ts +17 -2
- package/dist/MathCanvas/features/stroke/hooks/useStrokeState.d.ts +13 -3
- package/dist/MathCanvas/features/text/components/InlineMathBubble.d.ts +2 -1
- package/dist/MathCanvas/features/text/components/TextBlockEditor.d.ts +1 -2
- package/dist/MathCanvas/features/text/components/TextBlockMenu.d.ts +8 -3
- package/dist/MathCanvas/features/text/components/TextBlockView.d.ts +7 -1
- package/dist/MathCanvas/features/text/components/TextInteractionLayer.d.ts +11 -2
- package/dist/MathCanvas/features/text/hooks/useTextBlockActions.d.ts +2 -2
- package/dist/MathCanvas/features/text/hooks/useTextBlockLayoutEffects.d.ts +15 -18
- package/dist/MathCanvas/types.d.ts +101 -0
- package/dist/MathCanvas.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14973 -14105
- package/dist/useInlineMathSession.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ It is built as a single `MathCanvas` component. The component includes its own t
|
|
|
15
15
|
- Square grid and coordinate plane backgrounds
|
|
16
16
|
- Undo/redo and clear canvas controls
|
|
17
17
|
- Controlled persistence through `initialState` and `onStateChange`
|
|
18
|
+
- Optional collaboration hooks for committed document state, pointer presence, and transient stroke previews
|
|
18
19
|
|
|
19
20
|
For the full user-facing tool guide and shortcut reference, see [features.md](./features.md).
|
|
20
21
|
|
|
@@ -95,6 +96,68 @@ export default function NotesCanvas() {
|
|
|
95
96
|
/>
|
|
96
97
|
```
|
|
97
98
|
|
|
99
|
+
## Realtime Collaboration Hooks
|
|
100
|
+
|
|
101
|
+
`MathCanvas` can emit collaboration-friendly events without requiring a realtime provider. Use these callbacks to connect MathCanvas to your own transport, such as Supabase Realtime, WebSockets, or a local `BroadcastChannel`.
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { MathCanvas, type CollaborationMessage, type DocumentCanvasState, type PointerPresence, type StrokePreview } from "mathlean-canvas";
|
|
105
|
+
|
|
106
|
+
<MathCanvas
|
|
107
|
+
initialState={state}
|
|
108
|
+
onDocumentStateChange={(state: DocumentCanvasState) => {
|
|
109
|
+
// Persist or broadcast committed document state.
|
|
110
|
+
}}
|
|
111
|
+
onPointerPresence={(presence: PointerPresence) => {
|
|
112
|
+
// Broadcast local cursor position.
|
|
113
|
+
}}
|
|
114
|
+
onStrokePreviewStart={(preview: StrokePreview) => {
|
|
115
|
+
// Broadcast transient stroke start.
|
|
116
|
+
}}
|
|
117
|
+
onStrokePreviewUpdate={(preview: StrokePreview) => {
|
|
118
|
+
// Broadcast transient stroke updates while dragging.
|
|
119
|
+
}}
|
|
120
|
+
onStrokePreviewEnd={(preview: StrokePreview) => {
|
|
121
|
+
// Broadcast transient stroke completion/cleanup.
|
|
122
|
+
}}
|
|
123
|
+
onObjectTransformPreviewUpdate={(preview) => {
|
|
124
|
+
// Broadcast live object movement/resizing previews.
|
|
125
|
+
}}
|
|
126
|
+
onTextDraftPreviewUpdate={(preview) => {
|
|
127
|
+
// Broadcast live textbox typing/caret previews.
|
|
128
|
+
}}
|
|
129
|
+
remotePresence={remotePresence}
|
|
130
|
+
remoteStrokePreviews={remoteStrokePreviews}
|
|
131
|
+
remoteObjectTransformPreviews={remoteObjectTransformPreviews}
|
|
132
|
+
remoteTextDraftPreviews={remoteTextDraftPreviews}
|
|
133
|
+
/>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`onDocumentStateChange` only includes committed document data: strokes, text blocks, graph objects, plots, grids, geometry objects, coordinate-plane mode, and render mode. It does not include selected tools, selected objects, active editors, viewport/pan/zoom, cursors, undo history, or empty draft textboxes.
|
|
137
|
+
|
|
138
|
+
`remotePresence`, `remoteStrokePreviews`, `remoteObjectTransformPreviews`, and `remoteTextDraftPreviews` render as overlays in the same canvas coordinate space as local content. Remote stroke previews are automatically hidden when the committed document state contains a stroke with the same id.
|
|
139
|
+
|
|
140
|
+
Use `idPrefix` in collaborative hosts to keep locally-created object ids unique across users. Use `documentState` when you want to apply remote committed snapshots without remounting the canvas. `MathCanvas` skips incoming `documentState` snapshots while the local user has an active editor or drag interaction, so stale remote commits do not overwrite local in-progress work.
|
|
141
|
+
|
|
142
|
+
The exported `CollaborationMessage` union is designed to be sent over Supabase Realtime broadcast channels, WebSockets, or any other JSON transport. For Supabase, keep committed snapshots and transient previews on the same channel but separate them by the `type` field:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
const eventName = "mathcanvas";
|
|
146
|
+
const send = (message: CollaborationMessage) =>
|
|
147
|
+
channel.send({
|
|
148
|
+
type: "broadcast",
|
|
149
|
+
event: eventName,
|
|
150
|
+
payload: { ...message, senderId, documentId, sentAt: Date.now() },
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
channel.on("broadcast", { event: eventName }, ({ payload }) => {
|
|
154
|
+
const message = payload as CollaborationMessage;
|
|
155
|
+
if (message.senderId === senderId) return;
|
|
156
|
+
// Apply document messages to documentState.
|
|
157
|
+
// Apply presence and preview messages to remote overlay arrays.
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
98
161
|
## Dark Mode
|
|
99
162
|
|
|
100
163
|
```tsx
|
|
@@ -111,7 +174,24 @@ type MathCanvasProps = {
|
|
|
111
174
|
className?: string;
|
|
112
175
|
style?: React.CSSProperties;
|
|
113
176
|
initialState?: CanvasState;
|
|
177
|
+
documentState?: DocumentCanvasState;
|
|
178
|
+
idPrefix?: string;
|
|
114
179
|
onStateChange?: (state: CanvasState) => void;
|
|
180
|
+
onDocumentStateChange?: (state: DocumentCanvasState) => void;
|
|
181
|
+
onPointerPresence?: (presence: PointerPresence) => void;
|
|
182
|
+
onStrokePreviewStart?: (preview: StrokePreview) => void;
|
|
183
|
+
onStrokePreviewUpdate?: (preview: StrokePreview) => void;
|
|
184
|
+
onStrokePreviewEnd?: (preview: StrokePreview) => void;
|
|
185
|
+
onObjectTransformPreviewStart?: (preview: ObjectTransformPreview) => void;
|
|
186
|
+
onObjectTransformPreviewUpdate?: (preview: ObjectTransformPreview) => void;
|
|
187
|
+
onObjectTransformPreviewEnd?: (preview: ObjectTransformPreview) => void;
|
|
188
|
+
onTextDraftPreviewStart?: (preview: TextDraftPreview) => void;
|
|
189
|
+
onTextDraftPreviewUpdate?: (preview: TextDraftPreview) => void;
|
|
190
|
+
onTextDraftPreviewEnd?: (preview: TextDraftPreview) => void;
|
|
191
|
+
remotePresence?: RemotePointerPresence[];
|
|
192
|
+
remoteStrokePreviews?: StrokePreview[];
|
|
193
|
+
remoteObjectTransformPreviews?: ObjectTransformPreview[];
|
|
194
|
+
remoteTextDraftPreviews?: TextDraftPreview[];
|
|
115
195
|
};
|
|
116
196
|
```
|
|
117
197
|
|
|
@@ -120,7 +200,24 @@ Exports:
|
|
|
120
200
|
```ts
|
|
121
201
|
export { MathCanvas };
|
|
122
202
|
export default MathCanvas;
|
|
123
|
-
export type {
|
|
203
|
+
export type {
|
|
204
|
+
CanvasState,
|
|
205
|
+
CollaborationMessage,
|
|
206
|
+
CollaborationMessageBase,
|
|
207
|
+
CollaborationDocumentMessage,
|
|
208
|
+
CollaborationObjectTransformMessage,
|
|
209
|
+
CollaborationPresenceMessage,
|
|
210
|
+
CollaborationPreviewPhase,
|
|
211
|
+
CollaborationStrokePreviewMessage,
|
|
212
|
+
CollaborationTextDraftMessage,
|
|
213
|
+
DocumentCanvasState,
|
|
214
|
+
MathCanvasProps,
|
|
215
|
+
ObjectTransformPreview,
|
|
216
|
+
PointerPresence,
|
|
217
|
+
RemotePointerPresence,
|
|
218
|
+
StrokePreview,
|
|
219
|
+
TextDraftPreview,
|
|
220
|
+
};
|
|
124
221
|
```
|
|
125
222
|
|
|
126
223
|
## Tools At A Glance
|
|
@@ -131,11 +228,12 @@ export type { CanvasState, MathCanvasProps };
|
|
|
131
228
|
- Eraser: erase freehand strokes.
|
|
132
229
|
- Text: place text boxes and math text.
|
|
133
230
|
- Graph: create nodes and connect relationships.
|
|
134
|
-
- Matrix: create and edit matrices.
|
|
135
|
-
- Table: create and edit tables.
|
|
136
|
-
- Geometry: construct mathematical diagrams.
|
|
137
|
-
- Toggle
|
|
138
|
-
-
|
|
231
|
+
- Matrix: create and edit matrices.
|
|
232
|
+
- Table: create and edit tables.
|
|
233
|
+
- Geometry: construct mathematical diagrams.
|
|
234
|
+
- Toggle grid: show or hide the centered square grid with axes. When enabled, its secondary control toggles coordinate numbers.
|
|
235
|
+
- Mixed math: available from a textbox menu when a textbox should treat `$` as a literal character.
|
|
236
|
+
- Clear: clear the canvas.
|
|
139
237
|
|
|
140
238
|
See [features.md](./features.md) for detailed tutorials and shortcuts.
|
|
141
239
|
|
|
@@ -176,6 +274,26 @@ Run the demo app:
|
|
|
176
274
|
npm run dev
|
|
177
275
|
```
|
|
178
276
|
|
|
277
|
+
Run the local collaboration demo:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
npm run dev -- --host 127.0.0.1 --port 4173
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Then open this URL in two browser tabs:
|
|
284
|
+
|
|
285
|
+
```text
|
|
286
|
+
http://127.0.0.1:4173/?collab=local
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The local collaboration demo uses the browser `BroadcastChannel` API, so it does not need Supabase or any backend. Move the pointer, draw, type in textboxes, and drag text/graph objects in one tab to see remote presence and in-progress previews in the other tab. When content is committed, the demo broadcasts the committed document snapshot back into `MathCanvas` through `documentState`.
|
|
290
|
+
|
|
291
|
+
The demo also stores the last committed document snapshot in `localStorage`, so refreshing one tab restores the current canvas instead of waiting for another realtime message.
|
|
292
|
+
|
|
293
|
+
This is a transport emulator. It is useful for proving the MathCanvas collaboration hooks and message shape locally before wiring the same events into Supabase Realtime.
|
|
294
|
+
|
|
295
|
+
For the realtime collaboration behavior contract, scaling notes, and test plan, see [docs/collaboration-behavior.md](./docs/collaboration-behavior.md).
|
|
296
|
+
|
|
179
297
|
Build the library package:
|
|
180
298
|
|
|
181
299
|
```bash
|
|
@@ -3,6 +3,7 @@ import type { MathfieldElement } from "mathlive";
|
|
|
3
3
|
type InlineMathLiveFieldProps = {
|
|
4
4
|
fieldRef: RefObject<MathfieldElement | null>;
|
|
5
5
|
bubbleRef: RefObject<HTMLDivElement | null>;
|
|
6
|
+
preserveFocusTargetRefs?: RefObject<Element | null>[];
|
|
6
7
|
initialLatex: string;
|
|
7
8
|
initialPosition?: "start" | "end";
|
|
8
9
|
style: CSSProperties;
|
|
@@ -16,5 +17,5 @@ type InlineMathLiveFieldProps = {
|
|
|
16
17
|
onError: () => void;
|
|
17
18
|
onContextMenu?: (event: MouseEvent<MathfieldElement>) => void;
|
|
18
19
|
};
|
|
19
|
-
export default function InlineMathLiveField({ fieldRef, bubbleRef, initialLatex, initialPosition, style, inlineShortcuts, onReady, onLatexChange, onCommit, onCancel, onArrowExit, onStableEnter, onError, onContextMenu, }: InlineMathLiveFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default function InlineMathLiveField({ fieldRef, bubbleRef, preserveFocusTargetRefs, initialLatex, initialPosition, style, inlineShortcuts, onReady, onLatexChange, onCommit, onCancel, onArrowExit, onStableEnter, onError, onContextMenu, }: InlineMathLiveFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentProps } from "react";
|
|
2
|
-
import type { TextBlock } from "../types";
|
|
2
|
+
import type { ObjectTransformPreview, TextBlock, TextDraftPreview } from "../types";
|
|
3
3
|
import { GraphNodeEditor } from "../features/graph";
|
|
4
4
|
import { GridObjectOverlays } from "../features/grid";
|
|
5
5
|
import { InlineMathBubble, TextBlockEditor, TextBlockMenu, TextBlockView } from "../features/text";
|
|
@@ -10,12 +10,14 @@ type CanvasOverlayViewportProps = {
|
|
|
10
10
|
gridObjectOverlaysProps: ComponentProps<typeof GridObjectOverlays>;
|
|
11
11
|
inlineMathBubbleProps: ComponentProps<typeof InlineMathBubble>;
|
|
12
12
|
textBlockEditorProps: ComponentProps<typeof TextBlockEditor>;
|
|
13
|
-
textBlockMenuProps: ComponentProps<typeof TextBlockMenu>;
|
|
13
|
+
textBlockMenuProps: Omit<ComponentProps<typeof TextBlockMenu>, "viewport">;
|
|
14
14
|
textBlockViewProps: Omit<ComponentProps<typeof TextBlockView>, "block">;
|
|
15
|
+
remoteObjectTransformPreviews: ObjectTransformPreview[];
|
|
16
|
+
remoteTextDraftPreviews: TextDraftPreview[];
|
|
15
17
|
viewport: {
|
|
16
18
|
x: number;
|
|
17
19
|
y: number;
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
|
-
export default function CanvasOverlayViewport({ blocks, editingBlockId, graphNodeEditorProps, gridObjectOverlaysProps, inlineMathBubbleProps, textBlockEditorProps, textBlockMenuProps, textBlockViewProps, viewport, }: CanvasOverlayViewportProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default function CanvasOverlayViewport({ blocks, editingBlockId, graphNodeEditorProps, gridObjectOverlaysProps, inlineMathBubbleProps, textBlockEditorProps, textBlockMenuProps, textBlockViewProps, remoteObjectTransformPreviews, remoteTextDraftPreviews, viewport, }: CanvasOverlayViewportProps): import("react/jsx-runtime").JSX.Element;
|
|
21
23
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MathCanvasTheme, ObjectTransformPreview, RemotePointerPresence, Stroke, StrokePreview } from "../types";
|
|
2
|
+
type CollaborationOverlayProps = {
|
|
3
|
+
colors: MathCanvasTheme;
|
|
4
|
+
remoteObjectTransformPreviews: ObjectTransformPreview[];
|
|
5
|
+
remotePresence: RemotePointerPresence[];
|
|
6
|
+
remoteStrokePreviews: StrokePreview[];
|
|
7
|
+
strokes: Stroke[];
|
|
8
|
+
};
|
|
9
|
+
export default function CollaborationOverlay({ colors, remoteObjectTransformPreviews, remotePresence, remoteStrokePreviews, strokes, }: CollaborationOverlayProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Dispatch, type SetStateAction } from "react";
|
|
2
2
|
import { PEN_SIZE_OPTIONS } from "../constants";
|
|
3
3
|
import type { CoordinatePlaneMode, GeometryMode, MathCanvasTheme, Tool } from "../types";
|
|
4
4
|
type ToolbarProps = {
|
|
5
5
|
colors: MathCanvasTheme;
|
|
6
6
|
darkMode: boolean;
|
|
7
|
+
compact: boolean;
|
|
7
8
|
tool: Tool;
|
|
8
9
|
setTool: Dispatch<SetStateAction<Tool>>;
|
|
9
|
-
renderMode: "plain" | "latex";
|
|
10
|
-
toggleLatexMode: () => void;
|
|
11
10
|
pastStateCount: number;
|
|
12
11
|
futureStateCount: number;
|
|
13
12
|
handleUndo: () => void;
|
|
@@ -23,14 +22,14 @@ type ToolbarProps = {
|
|
|
23
22
|
setGeometryMode: Dispatch<SetStateAction<GeometryMode>>;
|
|
24
23
|
clearGeometryDraft: () => void;
|
|
25
24
|
clearGeometryLabelEditing: () => void;
|
|
26
|
-
regularPolygonSides: number;
|
|
27
|
-
setRegularPolygonSides: Dispatch<SetStateAction<number>>;
|
|
28
25
|
coordinatePlaneMode: CoordinatePlaneMode;
|
|
26
|
+
coordinateLabelsVisible: boolean;
|
|
27
|
+
setCoordinateLabelsVisible: Dispatch<SetStateAction<boolean>>;
|
|
29
28
|
setCoordinatePlaneMode: Dispatch<SetStateAction<CoordinatePlaneMode>>;
|
|
30
29
|
pushHistoryState: () => void;
|
|
31
30
|
clearCanvas: () => void;
|
|
32
31
|
shortcutMenuOpen: boolean;
|
|
33
32
|
setShortcutMenuOpen: Dispatch<SetStateAction<boolean>>;
|
|
34
33
|
};
|
|
35
|
-
export default function Toolbar({ colors, darkMode, tool, setTool,
|
|
34
|
+
export default function Toolbar({ colors, darkMode, compact, tool, setTool, pastStateCount, futureStateCount, handleUndo, handleRedo, showPenSizes, setShowPenSizes, penWidth, setPenWidth, penColor, setPenColor, penColorOptions, geometryMode, setGeometryMode, clearGeometryDraft, clearGeometryLabelEditing, coordinatePlaneMode, coordinateLabelsVisible, setCoordinateLabelsVisible, setCoordinatePlaneMode, pushHistoryState, clearCanvas, shortcutMenuOpen, setShortcutMenuOpen, }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
36
35
|
export {};
|
|
@@ -45,6 +45,14 @@ export declare function TableIcon({ active }: {
|
|
|
45
45
|
export declare function LatexToggleIcon({ active }: {
|
|
46
46
|
active: boolean;
|
|
47
47
|
}): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare function MixedMathIcon({ active }: {
|
|
49
|
+
active: boolean;
|
|
50
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export declare function GridIcon({ active }: {
|
|
52
|
+
active: boolean;
|
|
53
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export declare function GridNumbersIcon(): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
export declare function MenuIcon(): import("react/jsx-runtime").JSX.Element;
|
|
48
56
|
export declare function ShortcutIcon({ active }: {
|
|
49
57
|
active: boolean;
|
|
50
58
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
|
-
import type { GeoAngle, GeoCircle, GeoHelperSegment, GeoPoint, GeoPolygon, GeoRightAngleMarker, GeoSegment, GraphEdge, GraphNode, MatrixObject,
|
|
2
|
+
import type { GeoAngle, GeoCircle, GeoHelperSegment, GeoPoint, GeoPolygon, GeoRightAngleMarker, GeoSegment, GraphEdge, GraphNode, MatrixObject, Stroke, TableObject, TextBlock } from "../../types";
|
|
3
3
|
type UseCanvasGlobalActionsOptions = {
|
|
4
4
|
clearEditing: () => void;
|
|
5
5
|
clearGeometryDraft: () => void;
|
|
@@ -11,11 +11,8 @@ type UseCanvasGlobalActionsOptions = {
|
|
|
11
11
|
clearMatrixSelection: () => void;
|
|
12
12
|
clearTableEditing: () => void;
|
|
13
13
|
clearTableSelection: () => void;
|
|
14
|
-
editingBlockId: string | null;
|
|
15
14
|
isDrawing: MutableRefObject<boolean>;
|
|
16
15
|
pushHistoryState: () => void;
|
|
17
|
-
renderMode: RenderMode;
|
|
18
|
-
selectedBlockId: string | null;
|
|
19
16
|
setBlocks: Dispatch<SetStateAction<TextBlock[]>>;
|
|
20
17
|
setGeoAngles: Dispatch<SetStateAction<GeoAngle[]>>;
|
|
21
18
|
setGeoCircles: Dispatch<SetStateAction<GeoCircle[]>>;
|
|
@@ -27,15 +24,11 @@ type UseCanvasGlobalActionsOptions = {
|
|
|
27
24
|
setGraphEdges: Dispatch<SetStateAction<GraphEdge[]>>;
|
|
28
25
|
setGraphNodes: Dispatch<SetStateAction<GraphNode[]>>;
|
|
29
26
|
setMatrices: Dispatch<SetStateAction<MatrixObject[]>>;
|
|
30
|
-
setRenderMode: Dispatch<SetStateAction<RenderMode>>;
|
|
31
27
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
32
28
|
setStrokes: Dispatch<SetStateAction<Stroke[]>>;
|
|
33
29
|
setTables: Dispatch<SetStateAction<TableObject[]>>;
|
|
34
|
-
updateBlock: (id: string, updater: (block: TextBlock) => TextBlock) => void;
|
|
35
30
|
};
|
|
36
|
-
export declare function useCanvasGlobalActions({ clearEditing, clearGeometryDraft, clearGeometryLabelEditing, clearGeometrySelection, clearGraphEditing, clearGraphSelection, clearMatrixEditing, clearMatrixSelection, clearTableEditing, clearTableSelection,
|
|
31
|
+
export declare function useCanvasGlobalActions({ clearEditing, clearGeometryDraft, clearGeometryLabelEditing, clearGeometrySelection, clearGraphEditing, clearGraphSelection, clearMatrixEditing, clearMatrixSelection, clearTableEditing, clearTableSelection, isDrawing, pushHistoryState, setBlocks, setGeoAngles, setGeoCircles, setGeoHelperSegments, setGeoPoints, setGeoPolygons, setGeoRightAngleMarkers, setGeoSegments, setGraphEdges, setGraphNodes, setMatrices, setSelectedBlockId, setStrokes, setTables, }: UseCanvasGlobalActionsOptions): {
|
|
37
32
|
clearCanvas: () => void;
|
|
38
|
-
handleRenderModeChange: (nextMode: RenderMode) => void;
|
|
39
|
-
toggleLatexMode: () => void;
|
|
40
33
|
};
|
|
41
34
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { CanvasState, CoordinatePlaneMode, GeoAngle, GeoCircle, GeoHelperSegment, GeoPoint, GeoPolygon, GeoRightAngleMarker, GeoSegment, GraphEdge, GraphNode, MatrixObject, PlotFunction, RenderMode, ShortcutSettings, Stroke, TableObject, TextBlock } from "../../types";
|
|
1
|
+
import type { CanvasState, CoordinatePlaneMode, DocumentCanvasState, GeoAngle, GeoCircle, GeoHelperSegment, GeoPoint, GeoPolygon, GeoRightAngleMarker, GeoSegment, GraphEdge, GraphNode, MatrixObject, PlotFunction, RenderMode, ShortcutSettings, Stroke, TableObject, TextBlock } from "../../types";
|
|
2
2
|
type UseCanvasSnapshotOptions = {
|
|
3
3
|
blocks: TextBlock[];
|
|
4
|
+
coordinateLabelsVisible: boolean;
|
|
4
5
|
coordinatePlaneMode: CoordinatePlaneMode;
|
|
5
6
|
geoAngles: GeoAngle[];
|
|
6
7
|
geoCircles: GeoCircle[];
|
|
@@ -12,14 +13,17 @@ type UseCanvasSnapshotOptions = {
|
|
|
12
13
|
graphEdges: GraphEdge[];
|
|
13
14
|
graphNodes: GraphNode[];
|
|
14
15
|
matrices: MatrixObject[];
|
|
16
|
+
onDocumentStateChange?: (state: DocumentCanvasState) => void;
|
|
15
17
|
onStateChange?: (state: CanvasState) => void;
|
|
16
18
|
plots: PlotFunction[];
|
|
17
19
|
renderMode: RenderMode;
|
|
18
20
|
shortcutSettings: ShortcutSettings;
|
|
21
|
+
suppressDocumentStateChange?: boolean;
|
|
19
22
|
strokes: Stroke[];
|
|
20
23
|
tables: TableObject[];
|
|
21
24
|
};
|
|
22
|
-
export declare function useCanvasSnapshot({ blocks, coordinatePlaneMode, geoAngles, geoCircles, geoHelperSegments, geoPoints, geoPolygons, geoRightAngleMarkers, geoSegments, graphEdges, graphNodes, matrices, onStateChange, plots, renderMode, shortcutSettings, strokes, tables, }: UseCanvasSnapshotOptions): {
|
|
25
|
+
export declare function useCanvasSnapshot({ blocks, coordinateLabelsVisible, coordinatePlaneMode, geoAngles, geoCircles, geoHelperSegments, geoPoints, geoPolygons, geoRightAngleMarkers, geoSegments, graphEdges, graphNodes, matrices, onDocumentStateChange, onStateChange, plots, renderMode, shortcutSettings, suppressDocumentStateChange, strokes, tables, }: UseCanvasSnapshotOptions): {
|
|
23
26
|
getCanvasState: () => CanvasState;
|
|
27
|
+
getDocumentState: () => DocumentCanvasState;
|
|
24
28
|
};
|
|
25
29
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
2
|
import type Konva from "konva";
|
|
3
|
-
import type { GeoPoint, GeoSegment, GeometryLabelTarget, GeometryMode, GraphNode, MatrixObject, RenderMode, StageActivationEvent, StagePointerEvent, TableObject, TextBlock, Tool } from "../../types";
|
|
3
|
+
import type { GeoPoint, GeoSegment, GeometryLabelTarget, GeometryMode, GraphNode, MatrixObject, RenderMode, StageActivationEvent, StagePointerEvent, StrokePreview, TableObject, TextBlock, Tool } from "../../types";
|
|
4
4
|
type ScenePoint = {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
@@ -9,7 +9,7 @@ type SnapPoint = ScenePoint & {
|
|
|
9
9
|
kind: "point" | "grid" | "midpoint";
|
|
10
10
|
};
|
|
11
11
|
type UseCanvasStageInteractionsOptions = {
|
|
12
|
-
|
|
12
|
+
activeStrokePreviewRef: MutableRefObject<StrokePreview | null>;
|
|
13
13
|
clearEraserPreview: () => void;
|
|
14
14
|
clearGeometryDraft: () => void;
|
|
15
15
|
clearGeometrySelection: () => void;
|
|
@@ -31,7 +31,10 @@ type UseCanvasStageInteractionsOptions = {
|
|
|
31
31
|
editingGraphNodeId: string | null;
|
|
32
32
|
editingMatrixId: string | null;
|
|
33
33
|
editingTableId: string | null;
|
|
34
|
-
eraseAtPointState: (x: number, y: number, radius: number, createId: () => string
|
|
34
|
+
eraseAtPointState: (x: number, y: number, radius: number, createId: () => string, from?: {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
} | null) => void;
|
|
35
38
|
extendStroke: (x: number, y: number) => void;
|
|
36
39
|
findGeoPointNear: (x: number, y: number) => GeoPoint | null;
|
|
37
40
|
findGeoSegmentNear: (x: number, y: number) => GeoSegment | null;
|
|
@@ -53,6 +56,16 @@ type UseCanvasStageInteractionsOptions = {
|
|
|
53
56
|
isErasing: MutableRefObject<boolean>;
|
|
54
57
|
isPanning: MutableRefObject<boolean>;
|
|
55
58
|
lastPanPoint: MutableRefObject<ScenePoint | null>;
|
|
59
|
+
onPointerPresence?: (presence: {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
xPct: number;
|
|
63
|
+
yPct: number;
|
|
64
|
+
tool: string | null;
|
|
65
|
+
}) => void;
|
|
66
|
+
onStrokePreviewEnd?: (preview: StrokePreview) => void;
|
|
67
|
+
onStrokePreviewStart?: (preview: StrokePreview) => void;
|
|
68
|
+
onStrokePreviewUpdate?: (preview: StrokePreview) => void;
|
|
56
69
|
penColor: string;
|
|
57
70
|
penWidth: number;
|
|
58
71
|
pushHistoryState: () => void;
|
|
@@ -70,6 +83,7 @@ type UseCanvasStageInteractionsOptions = {
|
|
|
70
83
|
left: number;
|
|
71
84
|
top: number;
|
|
72
85
|
} | null) => void;
|
|
86
|
+
setPreviewInteractionActive: (active: boolean) => void;
|
|
73
87
|
setRenderMode: Dispatch<SetStateAction<RenderMode>>;
|
|
74
88
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
75
89
|
setSelectedGraphEdgeId: Dispatch<SetStateAction<string | null>>;
|
|
@@ -87,15 +101,26 @@ type UseCanvasStageInteractionsOptions = {
|
|
|
87
101
|
startGeometryLabelEditing: (target: GeometryLabelTarget) => void;
|
|
88
102
|
startGraphEditing: (id: string) => void;
|
|
89
103
|
startMatrixEditing: (id: string) => void;
|
|
90
|
-
startStrokeState: (x: number, y: number, tool: Tool, strokeWidth: number, color: string,
|
|
104
|
+
startStrokeState: (x: number, y: number, tool: Tool, strokeWidth: number, color: string, id: string) => void;
|
|
91
105
|
startTableEditing: (id: string) => void;
|
|
92
106
|
suppressNextGraphActivationRef: MutableRefObject<boolean>;
|
|
107
|
+
stageSize: {
|
|
108
|
+
width: number;
|
|
109
|
+
height: number;
|
|
110
|
+
};
|
|
93
111
|
toggleEqualSideMarker: (segmentId: string) => void;
|
|
94
112
|
tool: Tool;
|
|
95
|
-
updateEraserPreview: (x: number, y: number) =>
|
|
113
|
+
updateEraserPreview: (x: number, y: number) => {
|
|
114
|
+
radius: number;
|
|
115
|
+
previous: {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
time: number;
|
|
119
|
+
} | null;
|
|
120
|
+
};
|
|
96
121
|
updateGraphSelectionDrag: (point: ScenePoint) => boolean;
|
|
97
122
|
};
|
|
98
|
-
export declare function useCanvasStageInteractions({
|
|
123
|
+
export declare function useCanvasStageInteractions({ activeStrokePreviewRef, clearEraserPreview, clearGeometryDraft, clearGeometrySelection, clearGraphSelection, clearMatrixSelection, clearTableSelection, commitEditing, commitGeometryLabelEditing, commitGraphEditing, commitMatrixEditing, commitTableEditing, createGraphNode, createId, createMatrix, createTable, createTextBlock, editingBlockId, editingGeometryLabel, editingGraphNodeId, editingMatrixId, editingTableId, eraseAtPointState, extendStroke, findGeoPointNear, findGeoSegmentNear, findGeometryLabelTargetNear, findGraphNodeAtPoint, findMatrixAtPoint, findTableAtPoint, findTextBlockBlockingCreation, findTextBlockNearPoint, finishGraphSelectionDrag, getDefaultMatrixPosition, getDefaultTablePosition, getGeoSnap, getScenePoint, geometryMode, handleGeometryCanvasPoint, handleGeometryPointChoice, isDrawing, isErasing, isPanning, lastPanPoint, onPointerPresence, onStrokePreviewEnd, onStrokePreviewStart, onStrokePreviewUpdate, penColor, penWidth, pushHistoryState, selectedGraphNodeId, selectedMatrixId, selectedPointId, selectedTableId, selectOnlyGeoSegment, selectOnlyGraphNode, setArmedSourceNodeId, setGeometryDraftPointIds, setGeometryPointer, setMatrixLatexPopover, setPreviewInteractionActive, setRenderMode, setSelectedBlockId, setSelectedGraphEdgeId, setSelectedMatrixId, setSelectedTableId, setSnapPreview, setTextBlockMenu, setViewport, skipNextMatrixCreationRef, skipNextTextCreationRef, skipNextTextCreationResetRef, startGeometryLabelEditing, startGraphEditing, startMatrixEditing, startStrokeState, startTableEditing, suppressNextGraphActivationRef, stageSize, toggleEqualSideMarker, tool, updateEraserPreview, updateGraphSelectionDrag, }: UseCanvasStageInteractionsOptions): {
|
|
99
124
|
handleCanvasActivation: (e: StageActivationEvent) => void;
|
|
100
125
|
handlePointerDown: (e: StagePointerEvent) => void;
|
|
101
126
|
handlePointerMove: (e: StagePointerEvent) => void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type Konva from "konva";
|
|
2
|
-
|
|
2
|
+
type UseCanvasViewportOptions = {
|
|
3
|
+
centerInitialViewport?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function useCanvasViewport({ centerInitialViewport }?: UseCanvasViewportOptions): {
|
|
3
6
|
containerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
4
7
|
getScenePoint: (stage: Konva.Stage | null) => {
|
|
5
8
|
x: number;
|
|
@@ -23,3 +26,4 @@ export declare function useCanvasViewport(): {
|
|
|
23
26
|
y: number;
|
|
24
27
|
};
|
|
25
28
|
};
|
|
29
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CoordinatePlaneMode, MathCanvasTheme } from "../../../types";
|
|
2
2
|
type CoordinatePlaneLayerProps = {
|
|
3
3
|
coordinatePlaneMode: CoordinatePlaneMode;
|
|
4
|
+
coordinateLabelsVisible: boolean;
|
|
4
5
|
colors: MathCanvasTheme;
|
|
5
6
|
size: {
|
|
6
7
|
width: number;
|
|
@@ -11,5 +12,5 @@ type CoordinatePlaneLayerProps = {
|
|
|
11
12
|
y: number;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
|
-
export default function CoordinatePlaneLayer({ coordinatePlaneMode, colors, size, viewport, }: CoordinatePlaneLayerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export default function CoordinatePlaneLayer({ coordinatePlaneMode, coordinateLabelsVisible, colors, size, viewport, }: CoordinatePlaneLayerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
16
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Konva from "konva";
|
|
2
2
|
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
3
|
-
import type { GraphEdge, GraphNode, MathCanvasTheme, Tool } from "../../../types";
|
|
3
|
+
import type { GraphEdge, GraphNode, MathCanvasTheme, ObjectTransformPreview, Tool } from "../../../types";
|
|
4
4
|
type GraphSelectionBox = {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
@@ -10,6 +10,12 @@ type GraphSelectionBox = {
|
|
|
10
10
|
type GraphLayerProps = {
|
|
11
11
|
graphNodes: GraphNode[];
|
|
12
12
|
graphEdges: GraphEdge[];
|
|
13
|
+
liveGraphNodeTransforms: Record<string, {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width?: number;
|
|
17
|
+
height?: number;
|
|
18
|
+
}>;
|
|
13
19
|
graphSelectionBox: GraphSelectionBox | null;
|
|
14
20
|
graphNodeRefs: MutableRefObject<Record<string, Konva.Group | null>>;
|
|
15
21
|
selectedGraphEdgeId: string | null;
|
|
@@ -34,6 +40,15 @@ type GraphLayerProps = {
|
|
|
34
40
|
startGraphEditing: (id: string) => void;
|
|
35
41
|
toggleGraphNodeSelection: (id: string) => void;
|
|
36
42
|
updateGraphNode: (id: string, updater: (node: GraphNode) => GraphNode) => void;
|
|
43
|
+
setLiveGraphNodeTransforms: Dispatch<SetStateAction<Record<string, {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
width?: number;
|
|
47
|
+
height?: number;
|
|
48
|
+
}>>>;
|
|
49
|
+
onObjectTransformPreviewStart?: (preview: ObjectTransformPreview) => void;
|
|
50
|
+
onObjectTransformPreviewUpdate?: (preview: ObjectTransformPreview) => void;
|
|
51
|
+
onObjectTransformPreviewEnd?: (preview: ObjectTransformPreview) => void;
|
|
37
52
|
};
|
|
38
|
-
export default function GraphLayer({ graphNodes, graphEdges, graphSelectionBox, graphNodeRefs, selectedGraphEdgeId, selectedGraphNodeId, selectedGraphNodeIds, armedSourceNodeId, hoveredGraphNodeId, editingGraphNodeId, tool, colors, darkMode, clearMatrixSelection, connectGraphNodes, pushHistoryState, selectOnlyGraphNode, setArmedSourceNodeId, setHoveredGraphNodeId, setSelectedBlockId, setSelectedGraphEdgeId, setSelectedGraphNodeId, setSelectedGraphNodeIds, startGraphEditing, toggleGraphNodeSelection, updateGraphNode, }: GraphLayerProps): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export default function GraphLayer({ graphNodes, graphEdges, liveGraphNodeTransforms, graphSelectionBox, graphNodeRefs, selectedGraphEdgeId, selectedGraphNodeId, selectedGraphNodeIds, armedSourceNodeId, hoveredGraphNodeId, editingGraphNodeId, tool, colors, darkMode, clearMatrixSelection, connectGraphNodes, pushHistoryState, selectOnlyGraphNode, setArmedSourceNodeId, setHoveredGraphNodeId, setSelectedBlockId, setSelectedGraphEdgeId, setSelectedGraphNodeId, setSelectedGraphNodeIds, startGraphEditing, toggleGraphNodeSelection, updateGraphNode, setLiveGraphNodeTransforms, onObjectTransformPreviewStart, onObjectTransformPreviewUpdate, onObjectTransformPreviewEnd, }: GraphLayerProps): import("react/jsx-runtime").JSX.Element;
|
|
39
54
|
export {};
|
|
@@ -13,7 +13,10 @@ export declare function useStrokeState({ initialState, defaultPenColor, pushHist
|
|
|
13
13
|
radius: number;
|
|
14
14
|
visible: boolean;
|
|
15
15
|
};
|
|
16
|
-
eraseAtPoint: (x: number, y: number, radius: number, createId: () => string
|
|
16
|
+
eraseAtPoint: (x: number, y: number, radius: number, createId: () => string, from?: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
} | null) => void;
|
|
17
20
|
extendStroke: (x: number, y: number) => void;
|
|
18
21
|
isDrawing: import("react").RefObject<boolean>;
|
|
19
22
|
isErasing: import("react").RefObject<boolean>;
|
|
@@ -26,8 +29,15 @@ export declare function useStrokeState({ initialState, defaultPenColor, pushHist
|
|
|
26
29
|
setShowPenSizes: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
27
30
|
showPenSizes: boolean;
|
|
28
31
|
showPenSizePreviewBriefly: () => void;
|
|
29
|
-
startStroke: (x: number, y: number, tool: Tool, strokeWidth: number, color: string,
|
|
32
|
+
startStroke: (x: number, y: number, tool: Tool, strokeWidth: number, color: string, id: string) => boolean;
|
|
30
33
|
strokes: Stroke[];
|
|
31
|
-
updateEraserPreview: (x: number, y: number) =>
|
|
34
|
+
updateEraserPreview: (x: number, y: number) => {
|
|
35
|
+
radius: number;
|
|
36
|
+
previous: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
time: number;
|
|
40
|
+
} | null;
|
|
41
|
+
};
|
|
32
42
|
};
|
|
33
43
|
export {};
|
|
@@ -32,6 +32,7 @@ type InlineMathBubbleProps = {
|
|
|
32
32
|
setActiveInlineMathDraft: Dispatch<SetStateAction<string>>;
|
|
33
33
|
setRenderMode: Dispatch<SetStateAction<"plain" | "latex">>;
|
|
34
34
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
35
|
+
textareaRef: RefObject<HTMLTextAreaElement | null>;
|
|
35
36
|
};
|
|
36
|
-
export default function InlineMathBubble({ activeInlineMathAtomId, activeInlineMathDraft, activeInlineMathSession, activateInlineMathFallback, cancelActiveInlineMathDraft, colors, commitActiveInlineMathDraft, darkMode, editingBlock, editingBlockId, exitActiveInlineMathDraft, handleInlineMathLatexChange, inlineMathBubbleRef, inlineShortcuts, inlineMathEditorMode, inlineMathEditorRect, inlineMathFieldRef, latexPreview, markInlineMathEditorReady, openTextBlockMenu, setActiveInlineMathDraft, setRenderMode, setSelectedBlockId, }: InlineMathBubbleProps): import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
export default function InlineMathBubble({ activeInlineMathAtomId, activeInlineMathDraft, activeInlineMathSession, activateInlineMathFallback, cancelActiveInlineMathDraft, colors, commitActiveInlineMathDraft, darkMode, editingBlock, editingBlockId, exitActiveInlineMathDraft, handleInlineMathLatexChange, inlineMathBubbleRef, inlineShortcuts, inlineMathEditorMode, inlineMathEditorRect, inlineMathFieldRef, latexPreview, markInlineMathEditorReady, openTextBlockMenu, setActiveInlineMathDraft, setRenderMode, setSelectedBlockId, textareaRef, }: InlineMathBubbleProps): import("react/jsx-runtime").JSX.Element | null;
|
|
37
38
|
export {};
|
|
@@ -37,7 +37,6 @@ type TextBlockEditorProps = {
|
|
|
37
37
|
setRenderMode: Dispatch<SetStateAction<RenderMode>>;
|
|
38
38
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
39
39
|
textareaRef: RefObject<HTMLTextAreaElement | null>;
|
|
40
|
-
toggleLatexMode: () => void;
|
|
41
40
|
};
|
|
42
|
-
export default function TextBlockEditor({ activeInlineMathSession, activeInlineMathSessionRef, beginTextboxResize, clearEditing, colors, commitActiveInlineMathDraft, commitEditing, editableMirrorContentRef, editableMirrorRef, editingBlock, editingDisplayValue, editingHeight, editingSelection, editingValue, editingWidth, inlineMathBubbleRef, inlineMathFieldRef, insertInlineMathAtSelection, isOpeningInlineMathSession, isOpeningInlineMathSessionRef, latexPreviewStart, mathOverlayCaret, openTextBlockMenu, rememberEditingSelection, reopenInlineMathSessionAtBoundary, setEditingValue, setRenderMode, setSelectedBlockId, textareaRef,
|
|
41
|
+
export default function TextBlockEditor({ activeInlineMathSession, activeInlineMathSessionRef, beginTextboxResize, clearEditing, colors, commitActiveInlineMathDraft, commitEditing, editableMirrorContentRef, editableMirrorRef, editingBlock, editingDisplayValue, editingHeight, editingSelection, editingValue, editingWidth, inlineMathBubbleRef, inlineMathFieldRef, insertInlineMathAtSelection, isOpeningInlineMathSession, isOpeningInlineMathSessionRef, latexPreviewStart, mathOverlayCaret, openTextBlockMenu, rememberEditingSelection, reopenInlineMathSessionAtBoundary, setEditingValue, setRenderMode, setSelectedBlockId, textareaRef, }: TextBlockEditorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
43
42
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import type { MathCanvasTheme, TextBlock, TextStyleRange } from "../../../types";
|
|
2
|
+
import type { MathCanvasTheme, TextBlock, TextboxMenuPanel, TextStyleRange } from "../../../types";
|
|
3
3
|
type TextBlockMenuState = {
|
|
4
4
|
blockId: string;
|
|
5
|
-
panel:
|
|
5
|
+
panel: TextboxMenuPanel;
|
|
6
6
|
} | null;
|
|
7
7
|
type TextBlockMenuProps = {
|
|
8
8
|
blockWidths: Record<string, number>;
|
|
@@ -19,7 +19,12 @@ type TextBlockMenuProps = {
|
|
|
19
19
|
penColorOptions: readonly string[];
|
|
20
20
|
setTextBlockMenu: Dispatch<SetStateAction<TextBlockMenuState>>;
|
|
21
21
|
textBlockMenu: TextBlockMenuState;
|
|
22
|
+
toggleTextBlockMixedMath: (blockId: string) => void;
|
|
22
23
|
updateTextBlockStyle: (blockId: string, patch: Partial<Omit<TextStyleRange, "id" | "start" | "end">>) => void;
|
|
24
|
+
viewport: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
23
28
|
};
|
|
24
|
-
export default function TextBlockMenu({ blockWidths, colors, copyTextBlock, deleteTextBlock, editingBlockId, getBlockById, getResolvedEditingValue, getTextboxSelectionRange, penColorOptions, setTextBlockMenu, textBlockMenu, updateTextBlockStyle, }: TextBlockMenuProps): import("react/jsx-runtime").JSX.Element | null;
|
|
29
|
+
export default function TextBlockMenu({ blockWidths, colors, copyTextBlock, deleteTextBlock, editingBlockId, getBlockById, getResolvedEditingValue, getTextboxSelectionRange, penColorOptions, setTextBlockMenu, textBlockMenu, toggleTextBlockMixedMath, updateTextBlockStyle, viewport, }: TextBlockMenuProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
30
|
export {};
|
|
@@ -12,7 +12,13 @@ type TextBlockViewProps = {
|
|
|
12
12
|
setRenderMode: Dispatch<SetStateAction<RenderMode>>;
|
|
13
13
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
14
14
|
startEditing: (id: string, selectionOverride?: number | null) => void;
|
|
15
|
+
liveTextBlockTransforms: Record<string, {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
height?: number;
|
|
20
|
+
}>;
|
|
15
21
|
tool: Tool;
|
|
16
22
|
};
|
|
17
|
-
export default function TextBlockView({ block, blockWidths, clearGraphSelection, clearMatrixSelection, colors, openTextBlockMenu, overlayRefs, selectedBlockId, setRenderMode, setSelectedBlockId, startEditing, tool, }: TextBlockViewProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default function TextBlockView({ block, blockWidths, clearGraphSelection, clearMatrixSelection, colors, openTextBlockMenu, overlayRefs, selectedBlockId, setRenderMode, setSelectedBlockId, startEditing, liveTextBlockTransforms, tool, }: TextBlockViewProps): import("react/jsx-runtime").JSX.Element;
|
|
18
24
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Konva from "konva";
|
|
2
2
|
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
3
|
-
import type { MathCanvasTheme, RenderMode, TextBlock, Tool } from "../../../types";
|
|
3
|
+
import type { MathCanvasTheme, ObjectTransformPreview, RenderMode, TextBlock, Tool } from "../../../types";
|
|
4
4
|
type TextInteractionLayerProps = {
|
|
5
5
|
blocks: TextBlock[];
|
|
6
6
|
blockWidths: Record<string, number>;
|
|
@@ -24,6 +24,15 @@ type TextInteractionLayerProps = {
|
|
|
24
24
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
25
25
|
startEditing: (id: string) => void;
|
|
26
26
|
updateBlock: (id: string, updater: (block: TextBlock) => TextBlock) => void;
|
|
27
|
+
setLiveTextBlockTransforms: Dispatch<SetStateAction<Record<string, {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
width?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
}>>>;
|
|
33
|
+
onObjectTransformPreviewStart?: (preview: ObjectTransformPreview) => void;
|
|
34
|
+
onObjectTransformPreviewUpdate?: (preview: ObjectTransformPreview) => void;
|
|
35
|
+
onObjectTransformPreviewEnd?: (preview: ObjectTransformPreview) => void;
|
|
27
36
|
};
|
|
28
|
-
export default function TextInteractionLayer({ blocks, blockWidths, blockHeights, size, tool, colors, blockNodeRefs, transformerRef, graphTransformerRef, matrixTransformerRef, tableTransformerRef, clearGraphSelection, clearMatrixSelection, openTextBlockMenu, pushHistoryState, setRenderMode, setSelectedBlockId, startEditing, updateBlock, }: TextInteractionLayerProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export default function TextInteractionLayer({ blocks, blockWidths, blockHeights, size, tool, colors, blockNodeRefs, transformerRef, graphTransformerRef, matrixTransformerRef, tableTransformerRef, clearGraphSelection, clearMatrixSelection, openTextBlockMenu, pushHistoryState, setRenderMode, setSelectedBlockId, startEditing, updateBlock, setLiveTextBlockTransforms, onObjectTransformPreviewStart, onObjectTransformPreviewUpdate, onObjectTransformPreviewEnd, }: TextInteractionLayerProps): import("react/jsx-runtime").JSX.Element;
|
|
29
38
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
|
-
import type { TextBlock, TextStyleRange } from "../../../types";
|
|
2
|
+
import type { TextBlock, TextboxMenuPanel, TextStyleRange } from "../../../types";
|
|
3
3
|
type TextBlockMenu = {
|
|
4
4
|
blockId: string;
|
|
5
|
-
panel:
|
|
5
|
+
panel: TextboxMenuPanel;
|
|
6
6
|
};
|
|
7
7
|
type UseTextBlockActionsOptions = {
|
|
8
8
|
blocks: TextBlock[];
|