mathlean-canvas 0.3.2 → 0.3.3

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.
Files changed (67) hide show
  1. package/README.md +213 -68
  2. package/dist/InlineMathLiveField.d.ts +17 -0
  3. package/dist/MathCanvas/components/CanvasOverlayViewport.d.ts +21 -0
  4. package/dist/MathCanvas/components/ObjectOverlays.d.ts +36 -0
  5. package/dist/MathCanvas/components/Toolbar.d.ts +34 -0
  6. package/dist/MathCanvas/components/icons.d.ts +58 -0
  7. package/dist/MathCanvas/constants.d.ts +70 -0
  8. package/dist/MathCanvas/core/hooks/useCanvasEditorFocus.d.ts +32 -0
  9. package/dist/MathCanvas/core/hooks/useCanvasGlobalActions.d.ts +41 -0
  10. package/dist/MathCanvas/core/hooks/useCanvasGlobalDragEffects.d.ts +35 -0
  11. package/dist/MathCanvas/core/hooks/useCanvasHistory.d.ts +13 -0
  12. package/dist/MathCanvas/core/hooks/useCanvasKeyboardShortcuts.d.ts +76 -0
  13. package/dist/MathCanvas/core/hooks/useCanvasSnapshot.d.ts +23 -0
  14. package/dist/MathCanvas/core/hooks/useCanvasStageInteractions.d.ts +103 -0
  15. package/dist/MathCanvas/core/hooks/useCanvasTransformers.d.ts +28 -0
  16. package/dist/MathCanvas/core/hooks/useCanvasViewport.d.ts +25 -0
  17. package/dist/MathCanvas/core/index.d.ts +9 -0
  18. package/dist/MathCanvas/features/geometry/components/CoordinatePlaneLayer.d.ts +15 -0
  19. package/dist/MathCanvas/features/geometry/components/GeometryLayer.d.ts +65 -0
  20. package/dist/MathCanvas/features/geometry/components/GeometryOverlays.d.ts +57 -0
  21. package/dist/MathCanvas/features/geometry/hooks/useGeometryCanvasActions.d.ts +29 -0
  22. package/dist/MathCanvas/features/geometry/hooks/useGeometryRenderData.d.ts +60 -0
  23. package/dist/MathCanvas/features/geometry/hooks/useGeometryState.d.ts +147 -0
  24. package/dist/MathCanvas/features/geometry/index.d.ts +6 -0
  25. package/dist/MathCanvas/features/graph/components/GraphLayer.d.ts +39 -0
  26. package/dist/MathCanvas/features/graph/components/GraphNodeEditor.d.ts +14 -0
  27. package/dist/MathCanvas/features/graph/hooks/useGraphCanvasActions.d.ts +44 -0
  28. package/dist/MathCanvas/features/graph/hooks/useGraphState.d.ts +77 -0
  29. package/dist/MathCanvas/features/graph/index.d.ts +4 -0
  30. package/dist/MathCanvas/features/grid/components/CellMathEditor.d.ts +17 -0
  31. package/dist/MathCanvas/features/grid/components/GridObjectOverlays.d.ts +71 -0
  32. package/dist/MathCanvas/features/grid/components/MatrixBlock.d.ts +20 -0
  33. package/dist/MathCanvas/features/grid/components/MatrixBrackets.d.ts +6 -0
  34. package/dist/MathCanvas/features/grid/components/MatrixEditorBlock.d.ts +50 -0
  35. package/dist/MathCanvas/features/grid/components/MatrixLayer.d.ts +31 -0
  36. package/dist/MathCanvas/features/grid/components/TableBlock.d.ts +21 -0
  37. package/dist/MathCanvas/features/grid/components/TableEditorBlock.d.ts +46 -0
  38. package/dist/MathCanvas/features/grid/hooks/useGridCanvasActions.d.ts +66 -0
  39. package/dist/MathCanvas/features/grid/hooks/useGridObjectState.d.ts +147 -0
  40. package/dist/MathCanvas/features/grid/index.d.ts +5 -0
  41. package/dist/MathCanvas/features/grid/utils/matrixOps.d.ts +36 -0
  42. package/dist/MathCanvas/features/stroke/components/StrokeLayer.d.ts +8 -0
  43. package/dist/MathCanvas/features/stroke/hooks/useStrokeState.d.ts +33 -0
  44. package/dist/MathCanvas/features/stroke/index.d.ts +2 -0
  45. package/dist/MathCanvas/features/text/components/BlockRenderers.d.ts +24 -0
  46. package/dist/MathCanvas/features/text/components/InlineMathBubble.d.ts +36 -0
  47. package/dist/MathCanvas/features/text/components/TextBlockEditor.d.ts +46 -0
  48. package/dist/MathCanvas/features/text/components/TextBlockMenu.d.ts +25 -0
  49. package/dist/MathCanvas/features/text/components/TextBlockView.d.ts +22 -0
  50. package/dist/MathCanvas/features/text/components/TextInteractionLayer.d.ts +29 -0
  51. package/dist/MathCanvas/features/text/hooks/useTextBlockActions.d.ts +40 -0
  52. package/dist/MathCanvas/features/text/hooks/useTextBlockEditingActions.d.ts +57 -0
  53. package/dist/MathCanvas/features/text/hooks/useTextBlockLayoutEffects.d.ts +62 -0
  54. package/dist/MathCanvas/features/text/hooks/useTextBlockRenderHelpers.d.ts +15 -0
  55. package/dist/MathCanvas/features/text/hooks/useTextboxResize.d.ts +19 -0
  56. package/dist/MathCanvas/features/text/index.d.ts +12 -0
  57. package/dist/MathCanvas/features/text/utils/textLayout.d.ts +33 -0
  58. package/dist/MathCanvas/types.d.ts +219 -0
  59. package/dist/MathCanvas/utils/geometryMath.d.ts +13 -0
  60. package/dist/MathCanvas/utils/graphDirection.d.ts +3 -0
  61. package/dist/MathCanvas/utils/latex.d.ts +20 -0
  62. package/dist/MathCanvas.d.ts +7 -0
  63. package/dist/index.d.ts +3 -0
  64. package/dist/index.js +11777 -10143
  65. package/dist/inlineMathModel.d.ts +26 -0
  66. package/dist/useInlineMathSession.d.ts +67 -0
  67. package/package.json +4 -2
@@ -0,0 +1,6 @@
1
+ export { default as CoordinatePlaneLayer } from "./components/CoordinatePlaneLayer";
2
+ export { default as GeometryLayer } from "./components/GeometryLayer";
3
+ export { default as GeometryOverlays } from "./components/GeometryOverlays";
4
+ export { useGeometryCanvasActions } from "./hooks/useGeometryCanvasActions";
5
+ export { useGeometryRenderData } from "./hooks/useGeometryRenderData";
6
+ export { useGeometryState } from "./hooks/useGeometryState";
@@ -0,0 +1,39 @@
1
+ import type Konva from "konva";
2
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
3
+ import type { GraphEdge, GraphNode, MathCanvasTheme, Tool } from "../../../types";
4
+ type GraphSelectionBox = {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ type GraphLayerProps = {
11
+ graphNodes: GraphNode[];
12
+ graphEdges: GraphEdge[];
13
+ graphSelectionBox: GraphSelectionBox | null;
14
+ graphNodeRefs: MutableRefObject<Record<string, Konva.Group | null>>;
15
+ selectedGraphEdgeId: string | null;
16
+ selectedGraphNodeId: string | null;
17
+ selectedGraphNodeIds: string[];
18
+ armedSourceNodeId: string | null;
19
+ hoveredGraphNodeId: string | null;
20
+ editingGraphNodeId: string | null;
21
+ tool: Tool;
22
+ colors: MathCanvasTheme;
23
+ darkMode: boolean;
24
+ clearMatrixSelection: () => void;
25
+ connectGraphNodes: (sourceId: string, targetId: string) => void;
26
+ pushHistoryState: () => void;
27
+ selectOnlyGraphNode: (id: string) => void;
28
+ setArmedSourceNodeId: Dispatch<SetStateAction<string | null>>;
29
+ setHoveredGraphNodeId: Dispatch<SetStateAction<string | null>>;
30
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
31
+ setSelectedGraphEdgeId: Dispatch<SetStateAction<string | null>>;
32
+ setSelectedGraphNodeId: Dispatch<SetStateAction<string | null>>;
33
+ setSelectedGraphNodeIds: Dispatch<SetStateAction<string[]>>;
34
+ startGraphEditing: (id: string) => void;
35
+ toggleGraphNodeSelection: (id: string) => void;
36
+ updateGraphNode: (id: string, updater: (node: GraphNode) => GraphNode) => void;
37
+ };
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;
39
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Dispatch, RefObject, SetStateAction } from "react";
2
+ import type { GraphNode, MathCanvasTheme, Tool } from "../../../types";
3
+ type GraphNodeEditorProps = {
4
+ colors: MathCanvasTheme;
5
+ commitGraphEditing: () => void;
6
+ cancelGraphEditing: () => void;
7
+ editingGraphNode: GraphNode | null;
8
+ editingGraphValue: string;
9
+ graphInputRef: RefObject<HTMLInputElement | null>;
10
+ setEditingGraphValue: Dispatch<SetStateAction<string>>;
11
+ tool: Tool;
12
+ };
13
+ export default function GraphNodeEditor({ colors, commitGraphEditing, cancelGraphEditing, editingGraphNode, editingGraphValue, graphInputRef, setEditingGraphValue, tool, }: GraphNodeEditorProps): import("react/jsx-runtime").JSX.Element | null;
14
+ export {};
@@ -0,0 +1,44 @@
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ import type { GraphDirection } from "../../../types";
3
+ type CreateGraphNodeStateOptions = {
4
+ id: string;
5
+ x: number;
6
+ y: number;
7
+ label?: string;
8
+ connectFromId?: string | null;
9
+ edgeId?: string;
10
+ beginEditing?: boolean;
11
+ };
12
+ type UseGraphCanvasActionsOptions = {
13
+ beginGraphEditing: (id: string) => boolean;
14
+ clearEditing: () => void;
15
+ clearMatrixEditing: () => void;
16
+ clearMatrixSelection: () => void;
17
+ connectGraphNodesState: (sourceId: string, targetId: string, edgeId: string) => void;
18
+ createConnectedGraphNodeInDirectionState: (direction: GraphDirection, createId: () => string, beginEditing?: boolean) => boolean;
19
+ createGraphNodeState: (options: CreateGraphNodeStateOptions) => void;
20
+ createId: () => string;
21
+ pasteGraphClipboardState: (createId: () => string) => boolean;
22
+ scheduleGraphDirectionalCreateState: (direction: GraphDirection, createId: () => string, onCreated: () => void) => void;
23
+ selectGraphNodesState: (ids: string[], primaryId?: string | null) => void;
24
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
25
+ toggleGraphNodeSelectionState: (id: string) => void;
26
+ traverseGraphNeighborState: (direction: "left" | "right" | "up" | "down", extendSelection?: boolean) => boolean;
27
+ };
28
+ export declare function useGraphCanvasActions({ beginGraphEditing, clearEditing, clearMatrixEditing, clearMatrixSelection, connectGraphNodesState, createConnectedGraphNodeInDirectionState, createGraphNodeState, createId, pasteGraphClipboardState, scheduleGraphDirectionalCreateState, selectGraphNodesState, setSelectedBlockId, toggleGraphNodeSelectionState, traverseGraphNeighborState, }: UseGraphCanvasActionsOptions): {
29
+ connectGraphNodes: (sourceId: string, targetId: string) => void;
30
+ createConnectedGraphNodeInDirection: (direction: GraphDirection, beginEditing?: boolean) => void;
31
+ createGraphNode: (x: number, y: number, options?: {
32
+ label?: string;
33
+ connectFromId?: string | null;
34
+ beginEditing?: boolean;
35
+ }) => void;
36
+ pasteGraphClipboard: () => void;
37
+ scheduleGraphDirectionalCreate: (direction: GraphDirection) => void;
38
+ selectGraphNodes: (ids: string[], primaryId?: string) => void;
39
+ selectOnlyGraphNode: (id: string) => void;
40
+ startGraphEditing: (id: string) => void;
41
+ toggleGraphNodeSelection: (id: string) => void;
42
+ traverseGraphNeighbor: (direction: "left" | "right" | "up" | "down", extendSelection?: boolean) => void;
43
+ };
44
+ export {};
@@ -0,0 +1,77 @@
1
+ import { type MutableRefObject } from "react";
2
+ import type { CanvasState, GraphDirection, GraphEdge, GraphNode } from "../../../types";
3
+ type UseGraphStateOptions = {
4
+ initialState?: Pick<CanvasState, "graphNodes" | "graphEdges">;
5
+ pushHistoryStateRef: MutableRefObject<() => void>;
6
+ };
7
+ type GraphNeighborDirection = "left" | "right" | "up" | "down";
8
+ type GraphPoint = {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ export declare function useGraphState({ initialState, pushHistoryStateRef }: UseGraphStateOptions): {
13
+ armedSourceNodeId: string | null;
14
+ beginGraphSelectionDrag: (point: GraphPoint) => void;
15
+ beginGraphEditing: (id: string) => boolean;
16
+ cancelGraphEditing: () => void;
17
+ cancelPendingGraphDirectionalCreate: () => void;
18
+ clearGraphEditing: () => void;
19
+ clearGraphSelection: () => void;
20
+ commitGraphEditing: () => void;
21
+ connectGraphNodes: (sourceId: string, targetId: string, edgeId: string) => void;
22
+ copySelectedGraphNodes: () => void;
23
+ createGraphNode: ({ id, x, y, label, connectFromId, edgeId, beginEditing, }: {
24
+ id: string;
25
+ x: number;
26
+ y: number;
27
+ label?: string;
28
+ connectFromId?: string | null;
29
+ edgeId?: string;
30
+ beginEditing?: boolean;
31
+ }) => void;
32
+ createConnectedGraphNodeInDirection: (direction: GraphDirection, createId: () => string, beginEditing?: boolean) => boolean;
33
+ deleteSelectedGraphEdge: () => void;
34
+ deleteSelectedGraphNode: () => void;
35
+ editingGraphNodeId: string | null;
36
+ editingGraphValue: string;
37
+ findGraphNodeAtPoint: (x: number, y: number) => GraphNode | null;
38
+ finishGraphSelectionDrag: () => boolean;
39
+ getGraphNodeById: (id: string | null) => GraphNode | null;
40
+ getGraphNeighborId: (sourceId: string | null, direction: GraphNeighborDirection) => string | null;
41
+ graphCreationArrowKeysRef: import("react").RefObject<Set<string>>;
42
+ graphCreationChordActiveRef: import("react").RefObject<boolean>;
43
+ graphEdges: GraphEdge[];
44
+ graphInputRef: import("react").RefObject<HTMLInputElement | null>;
45
+ graphNodeRefs: import("react").RefObject<Record<string, import("konva/lib/Group").Group | null>>;
46
+ graphNodes: GraphNode[];
47
+ graphSelectionBox: {
48
+ x: number;
49
+ y: number;
50
+ width: number;
51
+ height: number;
52
+ } | null;
53
+ graphTransformerRef: import("react").RefObject<import("konva/lib/shapes/Transformer").Transformer | null>;
54
+ hoveredGraphNodeId: string | null;
55
+ nudgeSelectedGraphNode: (dx: number, dy: number) => void;
56
+ pasteGraphClipboard: (createId: () => string) => boolean;
57
+ selectedGraphEdgeId: string | null;
58
+ selectedGraphNodeId: string | null;
59
+ selectedGraphNodeIds: string[];
60
+ selectGraphNodes: (ids: string[], primaryId?: string) => void;
61
+ selectOnlyGraphNode: (id: string) => void;
62
+ scheduleGraphDirectionalCreate: (direction: GraphDirection, createId: () => string, onCreated: () => void) => void;
63
+ setArmedSourceNodeId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
64
+ setEditingGraphValue: import("react").Dispatch<import("react").SetStateAction<string>>;
65
+ setGraphEdges: import("react").Dispatch<import("react").SetStateAction<GraphEdge[]>>;
66
+ setGraphNodes: import("react").Dispatch<import("react").SetStateAction<GraphNode[]>>;
67
+ setHoveredGraphNodeId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
68
+ setSelectedGraphEdgeId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
69
+ setSelectedGraphNodeId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
70
+ setSelectedGraphNodeIds: import("react").Dispatch<import("react").SetStateAction<string[]>>;
71
+ suppressNextGraphActivationRef: import("react").RefObject<boolean>;
72
+ traverseGraphNeighbor: (direction: GraphNeighborDirection, extendSelection?: boolean) => boolean;
73
+ toggleGraphNodeSelection: (id: string) => void;
74
+ updateGraphSelectionDrag: (point: GraphPoint) => boolean;
75
+ updateGraphNode: (id: string, updater: (node: GraphNode) => GraphNode) => void;
76
+ };
77
+ export {};
@@ -0,0 +1,4 @@
1
+ export { default as GraphLayer } from "./components/GraphLayer";
2
+ export { default as GraphNodeEditor } from "./components/GraphNodeEditor";
3
+ export { useGraphCanvasActions } from "./hooks/useGraphCanvasActions";
4
+ export { useGraphState } from "./hooks/useGraphState";
@@ -0,0 +1,17 @@
1
+ import type { MathCanvasTheme } from "../../../types";
2
+ export declare function CellMathEditor({ value, valid, dataAttributes, colors, inputRef, onChange, onBlur, onMouseDown, onClick, onFocus, onKeyDown, onCopy, onPaste, minWidth, }: {
3
+ value: string;
4
+ valid: boolean;
5
+ dataAttributes?: Record<string, string>;
6
+ colors: MathCanvasTheme;
7
+ inputRef?: (node: HTMLInputElement | null) => void;
8
+ onChange: React.ChangeEventHandler<HTMLInputElement>;
9
+ onBlur: React.FocusEventHandler<HTMLInputElement>;
10
+ onMouseDown: React.MouseEventHandler<HTMLInputElement>;
11
+ onClick: React.MouseEventHandler<HTMLInputElement>;
12
+ onFocus: React.FocusEventHandler<HTMLInputElement>;
13
+ onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
14
+ onCopy?: React.ClipboardEventHandler<HTMLInputElement>;
15
+ onPaste?: React.ClipboardEventHandler<HTMLInputElement>;
16
+ minWidth: number;
17
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,71 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import type { GridSelection, MathCanvasTheme, MatrixObject, TableObject, Tool } from "../../../types";
3
+ type GridMovePreview = {
4
+ kind: "matrix" | "table";
5
+ id: string;
6
+ mode: "row" | "column";
7
+ targetIndex: number;
8
+ } | null;
9
+ type GridKeyboardSelectionAnchor = {
10
+ kind: "matrix" | "table";
11
+ id: string;
12
+ row: number;
13
+ col: number;
14
+ } | null;
15
+ type GridObjectOverlaysProps = {
16
+ beginGridSelection: (kind: "matrix" | "table", id: string, row: number, col: number, mode: "cell" | "row" | "column") => void;
17
+ beginGridStructureDrag: (kind: "matrix" | "table", id: string, mode: "row" | "column", index: number) => void;
18
+ clearGraphSelection: () => void;
19
+ clearMatrixSelection: () => void;
20
+ colors: MathCanvasTheme;
21
+ commitMatrixEditing: () => void;
22
+ commitTableEditing: () => void;
23
+ darkMode: boolean;
24
+ editingMatrixId: string | null;
25
+ editingTableId: string | null;
26
+ extendGridSelection: (kind: "matrix" | "table", id: string, row: number, col: number) => void;
27
+ extendGridSelectionWithKeyboard: (kind: "matrix" | "table", id: string, anchorRow: number, anchorCol: number, row: number, col: number) => void;
28
+ getGridSelectionClipboardText: () => string;
29
+ getMatrixColSeparatorIndexForCell: (colIndex: number, colCount: number) => number | null;
30
+ getMatrixRowSeparatorIndexForCell: (rowIndex: number, rowCount: number) => number | null;
31
+ gridKeyboardSelectionAnchorRef: MutableRefObject<GridKeyboardSelectionAnchor>;
32
+ gridMovePreview: GridMovePreview;
33
+ gridSelection: GridSelection | null;
34
+ isCellInGridSelection: (kind: "matrix" | "table", id: string, row: number, col: number) => boolean;
35
+ matrices: MatrixObject[];
36
+ matrixInputRefs: MutableRefObject<Record<string, HTMLInputElement | null>>;
37
+ matrixOverlayRefs: MutableRefObject<Record<string, HTMLDivElement | null>>;
38
+ openMatrixLatexPopover: (matrixId: string, clientX: number, clientY: number) => void;
39
+ pasteGridSelectionClipboardText: (text: string) => void;
40
+ pushHistoryState: () => void;
41
+ resizeMatrix: (id: string, rows: number, cols: number) => void;
42
+ resizeTable: (id: string, rows: number, cols: number) => void;
43
+ selectWholeMatrix: (matrixId: string) => void;
44
+ selectedMatrixId: string | null;
45
+ selectedTableId: string | null;
46
+ setEditingMatrixCell: Dispatch<SetStateAction<{
47
+ row: number;
48
+ col: number;
49
+ } | null>>;
50
+ setEditingTableCell: Dispatch<SetStateAction<{
51
+ row: number;
52
+ col: number;
53
+ } | null>>;
54
+ setGridSelection: Dispatch<SetStateAction<GridSelection | null>>;
55
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
56
+ setSelectedMatrixId: Dispatch<SetStateAction<string | null>>;
57
+ setSelectedTableId: Dispatch<SetStateAction<string | null>>;
58
+ startMatrixEditing: (id: string) => void;
59
+ startTableEditing: (id: string) => void;
60
+ tableInputRefs: MutableRefObject<Record<string, HTMLInputElement | null>>;
61
+ tableOverlayRefs: MutableRefObject<Record<string, HTMLDivElement | null>>;
62
+ tables: TableObject[];
63
+ toggleMatrixColSeparator: (matrixId: string, index: number, forceFull?: boolean) => void;
64
+ toggleMatrixRowSeparator: (matrixId: string, index: number, forceFull?: boolean) => void;
65
+ tool: Tool;
66
+ updateGridStructureDragTarget: (kind: "matrix" | "table", id: string, mode: "row" | "column", index: number) => void;
67
+ updateMatrixSelectionCells: (matrixId: string, row: number, col: number, value: string) => void;
68
+ updateTableSelectionCells: (tableId: string, row: number, col: number, value: string) => void;
69
+ };
70
+ export default function GridObjectOverlays({ beginGridSelection, beginGridStructureDrag, clearGraphSelection, clearMatrixSelection, colors, commitMatrixEditing, commitTableEditing, darkMode, editingMatrixId, editingTableId, extendGridSelection, extendGridSelectionWithKeyboard, getGridSelectionClipboardText, getMatrixColSeparatorIndexForCell, getMatrixRowSeparatorIndexForCell, gridKeyboardSelectionAnchorRef, gridMovePreview, gridSelection, isCellInGridSelection, matrices, matrixInputRefs, matrixOverlayRefs, openMatrixLatexPopover, pasteGridSelectionClipboardText, pushHistoryState, resizeMatrix, resizeTable, selectWholeMatrix, selectedMatrixId, selectedTableId, setEditingMatrixCell, setEditingTableCell, setGridSelection, setSelectedBlockId, setSelectedMatrixId, setSelectedTableId, startMatrixEditing, startTableEditing, tableInputRefs, tableOverlayRefs, tables, toggleMatrixColSeparator, toggleMatrixRowSeparator, tool, updateGridStructureDragTarget, updateMatrixSelectionCells, updateTableSelectionCells, }: GridObjectOverlaysProps): import("react/jsx-runtime").JSX.Element;
71
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import type { MathCanvasTheme, MatrixObject, Tool } from "../../../types";
3
+ type MatrixBlockProps = {
4
+ clearGraphSelection: () => void;
5
+ colors: MathCanvasTheme;
6
+ columnWidths: number[];
7
+ matrix: MatrixObject;
8
+ matrixHeight: number;
9
+ matrixOverlayRefs: MutableRefObject<Record<string, HTMLDivElement | null>>;
10
+ matrixSeparatorColor: string;
11
+ matrixWidth: number;
12
+ openMatrixLatexPopover: (matrixId: string, clientX: number, clientY: number) => void;
13
+ selectedMatrixId: string | null;
14
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
15
+ setSelectedMatrixId: Dispatch<SetStateAction<string | null>>;
16
+ startMatrixEditing: (id: string) => void;
17
+ tool: Tool;
18
+ };
19
+ export default function MatrixBlock({ clearGraphSelection, colors, columnWidths, matrix, matrixHeight, matrixOverlayRefs, matrixSeparatorColor, matrixWidth, openMatrixLatexPopover, selectedMatrixId, setSelectedBlockId, setSelectedMatrixId, startMatrixEditing, tool, }: MatrixBlockProps): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { MathCanvasTheme } from "../../../types";
2
+ type MatrixBracketsProps = {
3
+ colors: MathCanvasTheme;
4
+ };
5
+ export default function MatrixBrackets({ colors }: MatrixBracketsProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,50 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import type { GridSelection, MathCanvasTheme, MatrixObject } from "../../../types";
3
+ type GridMovePreview = {
4
+ kind: "matrix" | "table";
5
+ id: string;
6
+ mode: "row" | "column";
7
+ targetIndex: number;
8
+ } | null;
9
+ type GridKeyboardSelectionAnchor = {
10
+ kind: "matrix" | "table";
11
+ id: string;
12
+ row: number;
13
+ col: number;
14
+ } | null;
15
+ type MatrixEditorBlockProps = {
16
+ beginGridSelection: (kind: "matrix", id: string, row: number, col: number, mode: "cell" | "row" | "column") => void;
17
+ beginGridStructureDrag: (kind: "matrix", id: string, mode: "row" | "column", index: number) => void;
18
+ colors: MathCanvasTheme;
19
+ columnWidths: number[];
20
+ commitMatrixEditing: () => void;
21
+ extendGridSelection: (kind: "matrix", id: string, row: number, col: number) => void;
22
+ extendGridSelectionWithKeyboard: (kind: "matrix", id: string, anchorRow: number, anchorCol: number, row: number, col: number) => void;
23
+ getMatrixColSeparatorIndexForCell: (colIndex: number, colCount: number) => number | null;
24
+ getMatrixRowSeparatorIndexForCell: (rowIndex: number, rowCount: number) => number | null;
25
+ getGridSelectionClipboardText: () => string;
26
+ gridKeyboardSelectionAnchorRef: MutableRefObject<GridKeyboardSelectionAnchor>;
27
+ gridMovePreview: GridMovePreview;
28
+ gridSelection: GridSelection | null;
29
+ isCellInGridSelection: (kind: "matrix", id: string, row: number, col: number) => boolean;
30
+ matrix: MatrixObject;
31
+ matrixHeight: number;
32
+ matrixInputRefs: MutableRefObject<Record<string, HTMLInputElement | null>>;
33
+ matrixSeparatorColor: string;
34
+ matrixWidth: number;
35
+ pasteGridSelectionClipboardText: (text: string) => void;
36
+ pushHistoryState: () => void;
37
+ resizeMatrix: (id: string, rows: number, cols: number) => void;
38
+ selectWholeMatrix: (matrixId: string) => void;
39
+ setEditingMatrixCell: Dispatch<SetStateAction<{
40
+ row: number;
41
+ col: number;
42
+ } | null>>;
43
+ setGridSelection: Dispatch<SetStateAction<GridSelection | null>>;
44
+ toggleMatrixColSeparator: (matrixId: string, index: number, forceFull?: boolean) => void;
45
+ toggleMatrixRowSeparator: (matrixId: string, index: number, forceFull?: boolean) => void;
46
+ updateGridStructureDragTarget: (kind: "matrix", id: string, mode: "row" | "column", index: number) => void;
47
+ updateMatrixSelectionCells: (matrixId: string, row: number, col: number, value: string) => void;
48
+ };
49
+ export default function MatrixEditorBlock({ beginGridSelection, beginGridStructureDrag, colors, columnWidths, commitMatrixEditing, extendGridSelection, extendGridSelectionWithKeyboard, getMatrixColSeparatorIndexForCell, getMatrixRowSeparatorIndexForCell, getGridSelectionClipboardText, gridKeyboardSelectionAnchorRef, gridMovePreview, gridSelection, isCellInGridSelection, matrix, matrixHeight, matrixInputRefs, matrixSeparatorColor, matrixWidth, pasteGridSelectionClipboardText, pushHistoryState, resizeMatrix, selectWholeMatrix, setEditingMatrixCell, setGridSelection, toggleMatrixColSeparator, toggleMatrixRowSeparator, updateGridStructureDragTarget, updateMatrixSelectionCells, }: MatrixEditorBlockProps): import("react/jsx-runtime").JSX.Element;
50
+ export {};
@@ -0,0 +1,31 @@
1
+ import type Konva from "konva";
2
+ import type { MutableRefObject } from "react";
3
+ import type { MatrixObject, TableObject, Tool } from "../../../types";
4
+ type MatrixLayerProps = {
5
+ matrices: MatrixObject[];
6
+ tables: TableObject[];
7
+ matrixNodeRefs: MutableRefObject<Record<string, Konva.Rect | null>>;
8
+ tableNodeRefs: MutableRefObject<Record<string, Konva.Rect | null>>;
9
+ tool: Tool;
10
+ clearGraphSelection: () => void;
11
+ clearMatrixSelection: () => void;
12
+ openMatrixLatexPopover: (matrixId: string, clientX: number, clientY: number) => void;
13
+ pushHistoryState: () => void;
14
+ setSelectedBlockId: (id: string | null) => void;
15
+ setSelectedMatrixId: (id: string | null) => void;
16
+ setSelectedTableId: (id: string | null) => void;
17
+ snapMatrixPosition: (matrix: MatrixObject, x: number, y: number) => {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ snapTablePosition: (table: TableObject, x: number, y: number) => {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ startMatrixEditing: (id: string) => void;
26
+ startTableEditing: (id: string) => void;
27
+ updateMatrix: (id: string, updater: (matrix: MatrixObject) => MatrixObject) => void;
28
+ updateTable: (id: string, updater: (table: TableObject) => TableObject) => void;
29
+ };
30
+ export default function MatrixLayer({ matrices, tables, matrixNodeRefs, tableNodeRefs, tool, clearGraphSelection, clearMatrixSelection, openMatrixLatexPopover, pushHistoryState, setSelectedBlockId, setSelectedMatrixId, setSelectedTableId, snapMatrixPosition, snapTablePosition, startMatrixEditing, startTableEditing, updateMatrix, updateTable, }: MatrixLayerProps): import("react/jsx-runtime").JSX.Element;
31
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import type { MathCanvasTheme, TableObject, Tool } from "../../../types";
3
+ type TableBlockProps = {
4
+ clearGraphSelection: () => void;
5
+ clearMatrixSelection: () => void;
6
+ colors: MathCanvasTheme;
7
+ columnWidths: number[];
8
+ selectedTableId: string | null;
9
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
10
+ setSelectedTableId: Dispatch<SetStateAction<string | null>>;
11
+ startTableEditing: (id: string) => void;
12
+ table: TableObject;
13
+ tableGridColor: string;
14
+ tableHeight: number;
15
+ tableOuterBorderColor: string;
16
+ tableOverlayRefs: MutableRefObject<Record<string, HTMLDivElement | null>>;
17
+ tableWidth: number;
18
+ tool: Tool;
19
+ };
20
+ export default function TableBlock({ clearGraphSelection, clearMatrixSelection, colors, columnWidths, selectedTableId, setSelectedBlockId, setSelectedTableId, startTableEditing, table, tableGridColor, tableHeight, tableOuterBorderColor, tableOverlayRefs, tableWidth, tool, }: TableBlockProps): import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1,46 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import type { GridSelection, MathCanvasTheme, TableObject } from "../../../types";
3
+ type GridMovePreview = {
4
+ kind: "matrix" | "table";
5
+ id: string;
6
+ mode: "row" | "column";
7
+ targetIndex: number;
8
+ } | null;
9
+ type GridKeyboardSelectionAnchor = {
10
+ kind: "matrix" | "table";
11
+ id: string;
12
+ row: number;
13
+ col: number;
14
+ } | null;
15
+ type TableEditorBlockProps = {
16
+ beginGridSelection: (kind: "table", id: string, row: number, col: number, mode: "cell" | "row" | "column") => void;
17
+ beginGridStructureDrag: (kind: "table", id: string, mode: "row" | "column", index: number) => void;
18
+ colors: MathCanvasTheme;
19
+ columnWidths: number[];
20
+ commitTableEditing: () => void;
21
+ extendGridSelection: (kind: "table", id: string, row: number, col: number) => void;
22
+ extendGridSelectionWithKeyboard: (kind: "table", id: string, anchorRow: number, anchorCol: number, row: number, col: number) => void;
23
+ getGridSelectionClipboardText: () => string;
24
+ gridKeyboardSelectionAnchorRef: MutableRefObject<GridKeyboardSelectionAnchor>;
25
+ gridMovePreview: GridMovePreview;
26
+ gridSelection: GridSelection | null;
27
+ isCellInGridSelection: (kind: "table", id: string, row: number, col: number) => boolean;
28
+ pasteGridSelectionClipboardText: (text: string) => void;
29
+ pushHistoryState: () => void;
30
+ resizeTable: (id: string, rows: number, cols: number) => void;
31
+ setEditingTableCell: Dispatch<SetStateAction<{
32
+ row: number;
33
+ col: number;
34
+ } | null>>;
35
+ setGridSelection: Dispatch<SetStateAction<GridSelection | null>>;
36
+ table: TableObject;
37
+ tableGridColor: string;
38
+ tableHeight: number;
39
+ tableInputRefs: MutableRefObject<Record<string, HTMLInputElement | null>>;
40
+ tableOuterBorderColor: string;
41
+ tableWidth: number;
42
+ updateGridStructureDragTarget: (kind: "table", id: string, mode: "row" | "column", index: number) => void;
43
+ updateTableSelectionCells: (tableId: string, row: number, col: number, value: string) => void;
44
+ };
45
+ export default function TableEditorBlock({ beginGridSelection, beginGridStructureDrag, colors, columnWidths, commitTableEditing, extendGridSelection, extendGridSelectionWithKeyboard, getGridSelectionClipboardText, gridKeyboardSelectionAnchorRef, gridMovePreview, gridSelection, isCellInGridSelection, pasteGridSelectionClipboardText, pushHistoryState, resizeTable, setEditingTableCell, setGridSelection, table, tableGridColor, tableHeight, tableInputRefs, tableOuterBorderColor, tableWidth, updateGridStructureDragTarget, updateTableSelectionCells, }: TableEditorBlockProps): import("react/jsx-runtime").JSX.Element;
46
+ export {};
@@ -0,0 +1,66 @@
1
+ import type { MutableRefObject } from "react";
2
+ import type { MatrixObject, TableObject, TextBlock } from "../../../types";
3
+ type GridCell = {
4
+ row: number;
5
+ col: number;
6
+ };
7
+ type UseGridCanvasActionsOptions = {
8
+ beginMatrixEditing: (id: string, cell?: GridCell) => void;
9
+ beginTableEditing: (id: string, cell?: GridCell) => void;
10
+ blocks: TextBlock[];
11
+ clearEditing: () => void;
12
+ clearGraphEditing: () => void;
13
+ clearGraphSelection: () => void;
14
+ clearMatrixEditing: () => void;
15
+ clearMatrixSelection: () => void;
16
+ clearTableEditing: () => void;
17
+ clearTableSelection: () => void;
18
+ commitMatrixEditingState: () => void;
19
+ commitTableEditingState: () => void;
20
+ containerRef: MutableRefObject<HTMLDivElement | null>;
21
+ createId: () => string;
22
+ createMatrixObject: (id: string, x: number, y: number, rows: number, cols: number) => void;
23
+ createTableObject: (id: string, x: number, y: number, rows: number, cols: number) => void;
24
+ getTextMathAxisY: (block: TextBlock) => number | null;
25
+ matrices: MatrixObject[];
26
+ setMatrixLatexPopover: (popover: {
27
+ matrixId: string;
28
+ left: number;
29
+ top: number;
30
+ } | null) => void;
31
+ setSelectedBlockId: (id: string | null) => void;
32
+ tables: TableObject[];
33
+ };
34
+ export declare function useGridCanvasActions({ beginMatrixEditing, beginTableEditing, blocks, clearEditing, clearGraphEditing, clearGraphSelection, clearMatrixEditing, clearMatrixSelection, clearTableEditing, clearTableSelection, commitMatrixEditingState, commitTableEditingState, containerRef, createId, createMatrixObject, createTableObject, getTextMathAxisY, matrices, setMatrixLatexPopover, setSelectedBlockId, tables, }: UseGridCanvasActionsOptions): {
35
+ commitMatrixEditing: () => void;
36
+ commitTableEditing: () => void;
37
+ copyMatrixLatex: (matrix: MatrixObject) => Promise<void>;
38
+ createMatrix: (x: number, y: number, rows?: number, cols?: number) => void;
39
+ createTable: (x: number, y: number, rows?: number, cols?: number) => void;
40
+ getDefaultMatrixPosition: (x: number, y: number) => {
41
+ x: number;
42
+ y: number;
43
+ };
44
+ getDefaultTablePosition: (x: number, y: number) => {
45
+ x: number;
46
+ y: number;
47
+ };
48
+ openMatrixLatexPopover: (matrixId: string, clientX: number, clientY: number) => void;
49
+ snapMatrixPosition: (matrix: MatrixObject, x: number, y: number) => {
50
+ x: number;
51
+ y: number;
52
+ };
53
+ snapTablePosition: (table: TableObject, x: number, y: number) => {
54
+ x: number;
55
+ y: number;
56
+ };
57
+ startMatrixEditing: (id: string, cell?: {
58
+ row: number;
59
+ col: number;
60
+ }) => void;
61
+ startTableEditing: (id: string, cell?: {
62
+ row: number;
63
+ col: number;
64
+ }) => void;
65
+ };
66
+ export {};