mathlean-canvas 0.3.2 → 0.3.4

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 (72) 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 +61 -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 +24 -0
  14. package/dist/MathCanvas/core/hooks/useCanvasStageInteractions.d.ts +104 -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/plot/components/PlotControls.d.ts +28 -0
  43. package/dist/MathCanvas/features/plot/components/PlotLayer.d.ts +30 -0
  44. package/dist/MathCanvas/features/plot/index.d.ts +2 -0
  45. package/dist/MathCanvas/features/plot/utils/plotCompiler.d.ts +18 -0
  46. package/dist/MathCanvas/features/plot/utils/plotModel.d.ts +16 -0
  47. package/dist/MathCanvas/features/stroke/components/StrokeLayer.d.ts +8 -0
  48. package/dist/MathCanvas/features/stroke/hooks/useStrokeState.d.ts +33 -0
  49. package/dist/MathCanvas/features/stroke/index.d.ts +2 -0
  50. package/dist/MathCanvas/features/text/components/BlockRenderers.d.ts +24 -0
  51. package/dist/MathCanvas/features/text/components/InlineMathBubble.d.ts +36 -0
  52. package/dist/MathCanvas/features/text/components/TextBlockEditor.d.ts +46 -0
  53. package/dist/MathCanvas/features/text/components/TextBlockMenu.d.ts +25 -0
  54. package/dist/MathCanvas/features/text/components/TextBlockView.d.ts +22 -0
  55. package/dist/MathCanvas/features/text/components/TextInteractionLayer.d.ts +29 -0
  56. package/dist/MathCanvas/features/text/hooks/useTextBlockActions.d.ts +40 -0
  57. package/dist/MathCanvas/features/text/hooks/useTextBlockEditingActions.d.ts +57 -0
  58. package/dist/MathCanvas/features/text/hooks/useTextBlockLayoutEffects.d.ts +62 -0
  59. package/dist/MathCanvas/features/text/hooks/useTextBlockRenderHelpers.d.ts +16 -0
  60. package/dist/MathCanvas/features/text/hooks/useTextboxResize.d.ts +19 -0
  61. package/dist/MathCanvas/features/text/index.d.ts +12 -0
  62. package/dist/MathCanvas/features/text/utils/textLayout.d.ts +33 -0
  63. package/dist/MathCanvas/types.d.ts +241 -0
  64. package/dist/MathCanvas/utils/geometryMath.d.ts +13 -0
  65. package/dist/MathCanvas/utils/graphDirection.d.ts +3 -0
  66. package/dist/MathCanvas/utils/latex.d.ts +20 -0
  67. package/dist/MathCanvas.d.ts +7 -0
  68. package/dist/index.d.ts +3 -0
  69. package/dist/index.js +63216 -11372
  70. package/dist/inlineMathModel.d.ts +26 -0
  71. package/dist/useInlineMathSession.d.ts +67 -0
  72. package/package.json +5 -2
@@ -0,0 +1,147 @@
1
+ import { type MutableRefObject } from "react";
2
+ import type { CanvasState, GridSelection, MatrixObject, TableObject } from "../../../types";
3
+ type UseGridObjectStateOptions = {
4
+ initialState?: Pick<CanvasState, "matrices" | "tables">;
5
+ pushHistoryStateRef: MutableRefObject<() => void>;
6
+ };
7
+ export declare function useGridObjectState({ initialState, pushHistoryStateRef, }: UseGridObjectStateOptions): {
8
+ beginGridSelection: (kind: "matrix" | "table", id: string, row: number, col: number, mode?: "cell" | "row" | "column") => void;
9
+ beginGridStructureDrag: (kind: "matrix" | "table", id: string, mode: "row" | "column", index: number) => void;
10
+ beginMatrixEditing: (id: string, cell?: {
11
+ row: number;
12
+ col: number;
13
+ }) => void;
14
+ beginTableEditing: (id: string, cell?: {
15
+ row: number;
16
+ col: number;
17
+ }) => void;
18
+ clearGridSelectionCells: () => void;
19
+ clearMatrixEditing: () => void;
20
+ clearMatrixSelection: () => void;
21
+ clearTableEditing: () => void;
22
+ clearTableSelection: () => void;
23
+ commitMatrixEditing: () => void;
24
+ commitTableEditing: () => void;
25
+ createMatrixObject: (id: string, x: number, y: number, rows: number, cols: number) => void;
26
+ createTableObject: (id: string, x: number, y: number, rows: number, cols: number) => void;
27
+ editingMatrixCell: {
28
+ row: number;
29
+ col: number;
30
+ } | null;
31
+ editingMatrixId: string | null;
32
+ editingTableCell: {
33
+ row: number;
34
+ col: number;
35
+ } | null;
36
+ editingTableId: string | null;
37
+ endGridSelectionDrag: () => void;
38
+ extendGridSelection: (kind: "matrix" | "table", id: string, row: number, col: number) => void;
39
+ extendGridSelectionWithKeyboard: (kind: "matrix" | "table", id: string, row: number, col: number, nextRow: number, nextCol: number) => void;
40
+ deleteSelectedMatrix: () => void;
41
+ deleteSelectedTable: () => void;
42
+ deleteGridSelectionStructure: () => void;
43
+ fillIdentityMatrix: (id: string) => void;
44
+ findMatrixAtPoint: (x: number, y: number) => MatrixObject | null;
45
+ findTableAtPoint: (x: number, y: number) => TableObject | null;
46
+ getMatrixById: (id: string | null) => MatrixObject | null;
47
+ getGridSelectionClipboardText: () => string;
48
+ getMatrixColSeparatorIndexForCell: (colIndex: number, colCount: number) => number | null;
49
+ getMatrixRowSeparatorIndexForCell: (rowIndex: number, rowCount: number) => number | null;
50
+ getTableById: (id: string | null) => TableObject | null;
51
+ gridKeyboardSelectionAnchorRef: import("react").RefObject<{
52
+ kind: "matrix" | "table";
53
+ id: string;
54
+ row: number;
55
+ col: number;
56
+ } | null>;
57
+ gridMoveDragRef: import("react").RefObject<{
58
+ kind: "matrix" | "table";
59
+ id: string;
60
+ mode: "row" | "column";
61
+ startIndex: number;
62
+ endIndex: number;
63
+ targetIndex: number;
64
+ } | null>;
65
+ gridMovePreview: {
66
+ kind: "matrix" | "table";
67
+ id: string;
68
+ mode: "row" | "column";
69
+ targetIndex: number;
70
+ } | null;
71
+ gridSelection: GridSelection | null;
72
+ gridSelectionDragRef: import("react").RefObject<{
73
+ kind: "matrix" | "table";
74
+ id: string;
75
+ anchorRow: number;
76
+ anchorCol: number;
77
+ mode: "cell" | "row" | "column";
78
+ } | null>;
79
+ isCellInGridSelection: (kind: "matrix" | "table", id: string, row: number, col: number) => boolean;
80
+ insertGridSelectionStructure: () => void;
81
+ matrixInputRefs: import("react").RefObject<Record<string, HTMLInputElement | null>>;
82
+ matrixLatexPopover: {
83
+ matrixId: string;
84
+ left: number;
85
+ top: number;
86
+ } | null;
87
+ matrixNodeRefs: import("react").RefObject<Record<string, import("konva/lib/shapes/Rect").Rect | null>>;
88
+ matrixOverlayRefs: import("react").RefObject<Record<string, HTMLDivElement | null>>;
89
+ matrices: MatrixObject[];
90
+ matrixTransformerRef: import("react").RefObject<import("konva/lib/shapes/Transformer").Transformer | null>;
91
+ selectedMatrixId: string | null;
92
+ selectedTableId: string | null;
93
+ selectWholeMatrix: (id: string) => void;
94
+ moveGridSelectionRangeToIndex: (kind: "matrix" | "table", id: string, mode: "row" | "column", startIndex: number, endIndex: number, targetIndex: number) => void;
95
+ moveGridSelectionStructure: (direction: "up" | "down" | "left" | "right") => void;
96
+ pasteGridSelectionClipboardText: (text: string) => void;
97
+ resizeMatrix: (id: string, nextRows: number, nextCols: number) => void;
98
+ resizeTable: (id: string, nextRows: number, nextCols: number) => void;
99
+ rotateMatrixClockwise: (id: string) => void;
100
+ rotateMatrixCounterclockwise: (id: string) => void;
101
+ setEditingMatrixCell: import("react").Dispatch<import("react").SetStateAction<{
102
+ row: number;
103
+ col: number;
104
+ } | null>>;
105
+ setEditingMatrixId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
106
+ setEditingTableCell: import("react").Dispatch<import("react").SetStateAction<{
107
+ row: number;
108
+ col: number;
109
+ } | null>>;
110
+ setEditingTableId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
111
+ setGridMovePreview: import("react").Dispatch<import("react").SetStateAction<{
112
+ kind: "matrix" | "table";
113
+ id: string;
114
+ mode: "row" | "column";
115
+ targetIndex: number;
116
+ } | null>>;
117
+ setGridSelection: import("react").Dispatch<import("react").SetStateAction<GridSelection | null>>;
118
+ setMatrices: import("react").Dispatch<import("react").SetStateAction<MatrixObject[]>>;
119
+ setMatrixLatexPopover: import("react").Dispatch<import("react").SetStateAction<{
120
+ matrixId: string;
121
+ left: number;
122
+ top: number;
123
+ } | null>>;
124
+ setSelectedMatrixId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
125
+ setSelectedTableId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
126
+ setTables: import("react").Dispatch<import("react").SetStateAction<TableObject[]>>;
127
+ skipNextMatrixCreationRef: import("react").RefObject<boolean>;
128
+ tableInputRefs: import("react").RefObject<Record<string, HTMLInputElement | null>>;
129
+ tableNodeRefs: import("react").RefObject<Record<string, import("konva/lib/shapes/Rect").Rect | null>>;
130
+ tableOverlayRefs: import("react").RefObject<Record<string, HTMLDivElement | null>>;
131
+ tables: TableObject[];
132
+ tableTransformerRef: import("react").RefObject<import("konva/lib/shapes/Transformer").Transformer | null>;
133
+ toggleMatrixColSeparator: (id: string, colIndex: number, useSelectionRange?: boolean) => void;
134
+ toggleMatrixRowSeparator: (id: string, rowIndex: number, useSelectionRange?: boolean) => void;
135
+ transformGridSelectionToAntiDiagonal: () => void;
136
+ transformGridSelectionToDiagonal: () => void;
137
+ transformGridSelectionToLowerTriangular: () => void;
138
+ transformGridSelectionToUpperTriangular: () => void;
139
+ transformSelectedMatrixRegion: (transform: "rotateClockwise" | "rotateCounterclockwise" | "transpose") => void;
140
+ transposeMatrix: (id: string) => void;
141
+ updateMatrix: (id: string, updater: (matrix: MatrixObject) => MatrixObject) => void;
142
+ updateGridStructureDragTarget: (kind: "matrix" | "table", id: string, mode: "row" | "column", index: number) => void;
143
+ updateMatrixSelectionCells: (id: string, row: number, col: number, value: string) => void;
144
+ updateTable: (id: string, updater: (table: TableObject) => TableObject) => void;
145
+ updateTableSelectionCells: (id: string, row: number, col: number, value: string) => void;
146
+ };
147
+ export {};
@@ -0,0 +1,5 @@
1
+ export { default as GridObjectOverlays } from "./components/GridObjectOverlays";
2
+ export { default as MatrixLayer } from "./components/MatrixLayer";
3
+ export { useGridCanvasActions } from "./hooks/useGridCanvasActions";
4
+ export { useGridObjectState } from "./hooks/useGridObjectState";
5
+ export { getMatrixWidth, getTableWidth, matrixToLatex } from "./utils/matrixOps";
@@ -0,0 +1,36 @@
1
+ import type { GridSelection, MatrixObject, MatrixSeparator, MatrixSeparatorSegment, TableObject, TextBlock } from "../../../types";
2
+ export declare function createEmptyMatrixCells(rows: number, cols: number): string[][];
3
+ export declare function resizeMatrixCells(cells: string[][], nextRows: number, nextCols: number, fillValue?: string): string[][];
4
+ export declare function matrixSeparatorToSegment(separator: MatrixSeparator, maxEnd: number): MatrixSeparatorSegment;
5
+ export declare function normalizeMatrixSeparatorSegment(segment: MatrixSeparatorSegment, maxEnd: number): MatrixSeparatorSegment;
6
+ export declare function resizeSeparatorSegments(separators: MatrixSeparator[], maxExclusive: number, maxEnd: number): MatrixSeparatorSegment[];
7
+ export declare const resizeSeparatorIndices: typeof resizeSeparatorSegments;
8
+ export declare function getMatrixRowSeparatorSegments(matrix: MatrixObject): MatrixSeparatorSegment[];
9
+ export declare function getMatrixColSeparatorSegments(matrix: MatrixObject): MatrixSeparatorSegment[];
10
+ export declare function hasAnyMatrixSeparatorAtIndex(separators: MatrixSeparator[], index: number, maxEnd: number): boolean;
11
+ export declare function toggleMatrixSeparatorSegment(separators: MatrixSeparator[], index: number, start: number, end: number, maxEnd: number): MatrixSeparatorSegment[];
12
+ export declare function getMatrixColumnWidths(matrix: MatrixObject): number[];
13
+ export declare function getMatrixContentWidth(matrix: MatrixObject): number;
14
+ export declare function getMatrixColumnOffset(columnWidths: number[], colIndex: number): number;
15
+ export declare function getMatrixColumnSpanWidth(columnWidths: number[], startCol: number, endCol: number): number;
16
+ export declare function getMatrixRowOffset(rowIndex: number): number;
17
+ export declare function getMatrixRowSpanHeight(startRow: number, endRow: number): number;
18
+ export declare function matrixToLatex(matrix: MatrixObject): string;
19
+ export declare function getMatrixWidth(matrix: MatrixObject): number;
20
+ export declare function getMatrixHeight(matrix: MatrixObject): number;
21
+ export declare function getMatrixAxisY(matrix: MatrixObject): number;
22
+ export declare function getTableColumnWidths(table: TableObject): number[];
23
+ export declare function getTableWidth(table: TableObject): number;
24
+ export declare function getTableHeight(table: TableObject): number;
25
+ export declare function getTableAxisY(table: TableObject): number;
26
+ export declare function snapMatrixPositionToAxes(matrix: MatrixObject, x: number, y: number, matrices: MatrixObject[], blocks: TextBlock[], getTextMathAxisY: (block: TextBlock) => number | null): {
27
+ x: number;
28
+ y: number;
29
+ };
30
+ export declare function snapTablePositionToAxes(table: TableObject, x: number, y: number, tables: TableObject[], matrices: MatrixObject[], blocks: TextBlock[], getTextMathAxisY: (block: TextBlock) => number | null): {
31
+ x: number;
32
+ y: number;
33
+ };
34
+ export declare function normalizeGridSelection(selection: GridSelection): GridSelection;
35
+ export declare function getGridCellKey(row: number, col: number): string;
36
+ export declare function isCellSelectedByGridSelection(selection: GridSelection, kind: "matrix" | "table", id: string, row: number, col: number): boolean;
@@ -0,0 +1,28 @@
1
+ import { type Dispatch, type SetStateAction } from "react";
2
+ import type { MathCanvasTheme, PlotFunction } from "../../../types";
3
+ type PlotControlsProps = {
4
+ colors: MathCanvasTheme;
5
+ editingPlot: PlotFunction | null;
6
+ editingPlotEquationId: string | null;
7
+ editingPlotLatex: string;
8
+ plotColorOptions: readonly string[];
9
+ plotMenuPanel: "actions" | "color" | null;
10
+ copySelectedPlot: (plot: PlotFunction) => Promise<void>;
11
+ createPlotEquation: (plotId: string) => void;
12
+ deletePlotEquation: (plotId: string, equationId: string) => void;
13
+ deleteSelectedPlot: () => void;
14
+ commitPlotEditing: () => boolean;
15
+ pushHistoryState: () => void;
16
+ setEditingPlotEquationId: Dispatch<SetStateAction<string | null>>;
17
+ setEditingPlotId: Dispatch<SetStateAction<string | null>>;
18
+ setEditingPlotLatex: Dispatch<SetStateAction<string>>;
19
+ setPlotMenuPanel: (panel: "actions" | "color" | null) => void;
20
+ setPlots: Dispatch<SetStateAction<PlotFunction[]>>;
21
+ updatePlotEquationColor: (plotId: string, equationId: string, color: string) => void;
22
+ viewport: {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ };
27
+ export default function PlotControls({ colors, editingPlot, editingPlotEquationId, editingPlotLatex, plotColorOptions, plotMenuPanel, copySelectedPlot, createPlotEquation, deletePlotEquation, deleteSelectedPlot, commitPlotEditing, pushHistoryState, setEditingPlotEquationId, setEditingPlotId, setEditingPlotLatex, setPlotMenuPanel, setPlots, updatePlotEquationColor, viewport, }: PlotControlsProps): import("react/jsx-runtime").JSX.Element | null;
28
+ export {};
@@ -0,0 +1,30 @@
1
+ import type Konva from "konva";
2
+ import type { MutableRefObject } from "react";
3
+ import type { MathCanvasTheme, PlotFunction, Tool } from "../../../types";
4
+ type PlotLayerProps = {
5
+ plots: PlotFunction[];
6
+ colors: MathCanvasTheme;
7
+ darkMode: boolean;
8
+ size: {
9
+ width: number;
10
+ height: number;
11
+ };
12
+ viewport: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ plotNodeRefs: MutableRefObject<Record<string, Konva.Group | null>>;
17
+ selectedPlotId: string | null;
18
+ tool: Tool;
19
+ clearGraphSelection: () => void;
20
+ clearMatrixSelection: () => void;
21
+ clearTableSelection: () => void;
22
+ pushHistoryState: () => void;
23
+ setSelectedBlockId: (id: string | null) => void;
24
+ setSelectedPlotId: (id: string | null) => void;
25
+ openPlotActions: (id: string) => void;
26
+ startPlotEditing: (id: string) => void;
27
+ updatePlot: (id: string, updater: (plot: PlotFunction) => PlotFunction) => void;
28
+ };
29
+ export default function PlotLayer({ plots, colors, darkMode, size, viewport, plotNodeRefs, selectedPlotId, tool, clearGraphSelection, clearMatrixSelection, clearTableSelection, pushHistoryState, setSelectedBlockId, setSelectedPlotId, openPlotActions, startPlotEditing, updatePlot, }: PlotLayerProps): import("react/jsx-runtime").JSX.Element;
30
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default as PlotControls } from "./components/PlotControls";
2
+ export { default as PlotLayer } from "./components/PlotLayer";
@@ -0,0 +1,18 @@
1
+ import type { MathJsonExpression } from "@cortex-js/compute-engine/math-json";
2
+ export type PlotCompileResult = {
3
+ ok: true;
4
+ latex: string;
5
+ mathJson: MathJsonExpression;
6
+ } | {
7
+ ok: false;
8
+ error: string;
9
+ };
10
+ export type CompiledPlotFunction = {
11
+ kind: "explicit";
12
+ evaluate: (x: number) => number;
13
+ } | {
14
+ kind: "implicit";
15
+ evaluate: (x: number, y: number) => number;
16
+ };
17
+ export declare function compilePlotLatex(latex: string): PlotCompileResult;
18
+ export declare function compilePlotMathJson(mathJson: MathJsonExpression | null): CompiledPlotFunction | null;
@@ -0,0 +1,16 @@
1
+ import type { PlotEquation, PlotFunction } from "../../../types";
2
+ export declare const PLOT_EQUATION_ROW_HEIGHT = 42;
3
+ export declare const PLOT_EQUATION_TOP_PADDING = 8;
4
+ export declare const PLOT_EQUATION_BOTTOM_PADDING = 8;
5
+ export declare const PLOT_EQUATION_MIN_HEIGHT = 52;
6
+ export declare const PLOT_EQUATION_PANEL_WIDTH = 190;
7
+ export declare const PLOT_EQUATION_PANEL_MAX_WIDTH = 440;
8
+ export declare const PLOT_EQUATION_PANEL_GAP = 8;
9
+ export declare const PLOT_EQUATION_PANEL_DEFAULT_TOP = 10;
10
+ export declare function getPlotEquations(plot: PlotFunction): PlotEquation[];
11
+ export declare function getPlotEquationAreaHeight(plot: PlotFunction): number;
12
+ export declare function getPlotEquationPanelWidth(plot: PlotFunction): number;
13
+ export declare function getPlotEquationTextWidth(panelWidth: number): number;
14
+ export declare function getPlotEquationRowHeight(equation: PlotEquation, panelWidth: number): number;
15
+ export declare function getPlotEquationRowTop(plot: PlotFunction, index: number): number;
16
+ export declare function normalizePlot(plot: PlotFunction): PlotFunction;
@@ -0,0 +1,8 @@
1
+ import type { MathCanvasTheme, Stroke } from "../../../types";
2
+ type StrokeLayerProps = {
3
+ strokes: Stroke[];
4
+ colors: MathCanvasTheme;
5
+ penWidth: number;
6
+ };
7
+ export default function StrokeLayer({ strokes, colors, penWidth }: StrokeLayerProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,33 @@
1
+ import { type MutableRefObject } from "react";
2
+ import type { CanvasState, Stroke, Tool } from "../../../types";
3
+ type UseStrokeStateOptions = {
4
+ initialState?: Pick<CanvasState, "strokes">;
5
+ defaultPenColor: string;
6
+ pushHistoryStateRef: MutableRefObject<() => void>;
7
+ };
8
+ export declare function useStrokeState({ initialState, defaultPenColor, pushHistoryStateRef }: UseStrokeStateOptions): {
9
+ clearEraserPreview: () => void;
10
+ eraserPreview: {
11
+ x: number;
12
+ y: number;
13
+ radius: number;
14
+ visible: boolean;
15
+ };
16
+ eraseAtPoint: (x: number, y: number, radius: number, createId: () => string) => void;
17
+ extendStroke: (x: number, y: number) => void;
18
+ isDrawing: import("react").RefObject<boolean>;
19
+ isErasing: import("react").RefObject<boolean>;
20
+ penColor: string;
21
+ penColorOptions: readonly [string, "#d14343", "#2f6fed", "#2f9e44", "#c89b0e", "#f2d21b"];
22
+ penWidth: 2 | 12 | 8 | 6 | 4;
23
+ setStrokes: import("react").Dispatch<import("react").SetStateAction<Stroke[]>>;
24
+ setPenColor: import("react").Dispatch<import("react").SetStateAction<string>>;
25
+ setPenWidth: import("react").Dispatch<import("react").SetStateAction<2 | 12 | 8 | 6 | 4>>;
26
+ setShowPenSizes: import("react").Dispatch<import("react").SetStateAction<boolean>>;
27
+ showPenSizes: boolean;
28
+ showPenSizePreviewBriefly: () => void;
29
+ startStroke: (x: number, y: number, tool: Tool, strokeWidth: number, color: string, createId: () => string) => boolean;
30
+ strokes: Stroke[];
31
+ updateEraserPreview: (x: number, y: number) => number;
32
+ };
33
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default as StrokeLayer } from "./components/StrokeLayer";
2
+ export { useStrokeState } from "./hooks/useStrokeState";
@@ -0,0 +1,24 @@
1
+ import type { RenderMode, TextStyleRange } from "../../../types";
2
+ export declare function InlineKatex({ expression, fallback, displayMode, }: {
3
+ expression: string;
4
+ fallback: string;
5
+ displayMode?: boolean;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ export declare function RenderKatexExpression({ expression, fallback, displayMode, }: {
8
+ expression: string;
9
+ fallback: string;
10
+ displayMode?: boolean;
11
+ }): import("react/jsx-runtime").JSX.Element;
12
+ export declare function RenderBlockContent({ content, renderMode, styles, }: {
13
+ content: string;
14
+ renderMode: RenderMode;
15
+ styles?: TextStyleRange[];
16
+ }): import("react/jsx-runtime").JSX.Element;
17
+ export declare function RenderEditableBlockContent({ content, renderMode, styles, activeMathStart, caretPosition, hideActiveMath, }: {
18
+ content: string;
19
+ renderMode: RenderMode;
20
+ styles?: TextStyleRange[];
21
+ activeMathStart?: number | null;
22
+ caretPosition?: number | null;
23
+ hideActiveMath?: boolean;
24
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import type { Dispatch, RefObject, SetStateAction } from "react";
2
+ import type { MathfieldElement } from "mathlive";
3
+ import type { ActiveInlineMathSession, InlineMathPreview } from "../../../../useInlineMathSession";
4
+ import type { MathCanvasTheme, TextBlock } from "../../../types";
5
+ type InlineMathEditorRect = {
6
+ left: number;
7
+ top: number;
8
+ width: number;
9
+ height: number;
10
+ } | null;
11
+ type InlineMathBubbleProps = {
12
+ activeInlineMathAtomId: string | null;
13
+ activeInlineMathDraft: string;
14
+ activeInlineMathSession: ActiveInlineMathSession | null;
15
+ activateInlineMathFallback: () => void;
16
+ cancelActiveInlineMathDraft: () => void;
17
+ colors: MathCanvasTheme;
18
+ commitActiveInlineMathDraft: () => void;
19
+ darkMode: boolean;
20
+ editingBlock: TextBlock | null;
21
+ editingBlockId: string | null;
22
+ exitActiveInlineMathDraft: (direction: "before" | "after") => void;
23
+ handleInlineMathLatexChange: (latex: string) => void;
24
+ inlineMathBubbleRef: RefObject<HTMLDivElement | null>;
25
+ inlineMathEditorMode: "mathlive" | "fallback";
26
+ inlineMathEditorRect: InlineMathEditorRect;
27
+ inlineMathFieldRef: RefObject<MathfieldElement | null>;
28
+ latexPreview: InlineMathPreview;
29
+ markInlineMathEditorReady: () => void;
30
+ openTextBlockMenu: (block: TextBlock) => void;
31
+ setActiveInlineMathDraft: Dispatch<SetStateAction<string>>;
32
+ setRenderMode: Dispatch<SetStateAction<"plain" | "latex">>;
33
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
34
+ };
35
+ export default function InlineMathBubble({ activeInlineMathAtomId, activeInlineMathDraft, activeInlineMathSession, activateInlineMathFallback, cancelActiveInlineMathDraft, colors, commitActiveInlineMathDraft, darkMode, editingBlock, editingBlockId, exitActiveInlineMathDraft, handleInlineMathLatexChange, inlineMathBubbleRef, inlineMathEditorMode, inlineMathEditorRect, inlineMathFieldRef, latexPreview, markInlineMathEditorReady, openTextBlockMenu, setActiveInlineMathDraft, setRenderMode, setSelectedBlockId, }: InlineMathBubbleProps): import("react/jsx-runtime").JSX.Element | null;
36
+ export {};
@@ -0,0 +1,46 @@
1
+ import type { Dispatch, MouseEvent, MutableRefObject, RefObject, SetStateAction } from "react";
2
+ import type { MathfieldElement } from "mathlive";
3
+ import type { ActiveInlineMathSession } from "../../../../useInlineMathSession";
4
+ import type { MathCanvasTheme, RenderMode, TextBlock, TextboxResizeAnchor } from "../../../types";
5
+ type MathOverlayCaret = {
6
+ left: number;
7
+ top: number;
8
+ height: number;
9
+ } | null;
10
+ type TextBlockEditorProps = {
11
+ activeInlineMathSession: ActiveInlineMathSession | null;
12
+ activeInlineMathSessionRef: MutableRefObject<ActiveInlineMathSession | null>;
13
+ beginTextboxResize: (block: TextBlock, anchor: TextboxResizeAnchor, event: MouseEvent<HTMLDivElement>) => void;
14
+ clearEditing: () => void;
15
+ colors: MathCanvasTheme;
16
+ commitActiveInlineMathDraft: () => void;
17
+ commitEditing: () => void;
18
+ editableMirrorContentRef: RefObject<HTMLDivElement | null>;
19
+ editableMirrorRef: RefObject<HTMLDivElement | null>;
20
+ editingBlock: TextBlock | null;
21
+ editingDisplayValue: string;
22
+ editingHeight: number;
23
+ editingSelection: number;
24
+ editingValue: string;
25
+ editingWidth: number;
26
+ inlineMathBubbleRef: RefObject<HTMLDivElement | null>;
27
+ inlineMathFieldRef: RefObject<MathfieldElement | null>;
28
+ insertInlineMathAtSelection: (start: number, end: number) => void;
29
+ isOpeningInlineMathSessionRef: MutableRefObject<boolean>;
30
+ latexPreviewStart: number | null;
31
+ mathOverlayCaret: MathOverlayCaret;
32
+ openTextBlockMenu: (block: TextBlock) => void;
33
+ rememberEditingSelection: (target: HTMLTextAreaElement) => void;
34
+ reopenInlineMathSessionAtBoundary: (direction: "before" | "after") => boolean;
35
+ setEditingValue: Dispatch<SetStateAction<string>>;
36
+ setRenderMode: Dispatch<SetStateAction<RenderMode>>;
37
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
38
+ size: {
39
+ width: number;
40
+ height: number;
41
+ };
42
+ textareaRef: RefObject<HTMLTextAreaElement | null>;
43
+ toggleLatexMode: () => void;
44
+ };
45
+ export default function TextBlockEditor({ activeInlineMathSession, activeInlineMathSessionRef, beginTextboxResize, clearEditing, colors, commitActiveInlineMathDraft, commitEditing, editableMirrorContentRef, editableMirrorRef, editingBlock, editingDisplayValue, editingHeight, editingSelection, editingValue, editingWidth, inlineMathBubbleRef, inlineMathFieldRef, insertInlineMathAtSelection, isOpeningInlineMathSessionRef, latexPreviewStart, mathOverlayCaret, openTextBlockMenu, rememberEditingSelection, reopenInlineMathSessionAtBoundary, setEditingValue, setRenderMode, setSelectedBlockId, size, textareaRef, toggleLatexMode, }: TextBlockEditorProps): import("react/jsx-runtime").JSX.Element | null;
46
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ import type { MathCanvasTheme, TextBlock, TextStyleRange } from "../../../types";
3
+ type TextBlockMenuState = {
4
+ blockId: string;
5
+ panel: "format" | "color" | null;
6
+ } | null;
7
+ type TextBlockMenuProps = {
8
+ blockWidths: Record<string, number>;
9
+ colors: MathCanvasTheme;
10
+ copyTextBlock: (block: TextBlock) => Promise<void>;
11
+ deleteTextBlock: (id: string) => void;
12
+ editingBlockId: string | null;
13
+ getBlockById: (id: string | null) => TextBlock | null;
14
+ getResolvedEditingValue: () => string;
15
+ getTextboxSelectionRange: (blockId: string, contentLength: number) => {
16
+ start: number;
17
+ end: number;
18
+ } | null;
19
+ penColorOptions: readonly string[];
20
+ setTextBlockMenu: Dispatch<SetStateAction<TextBlockMenuState>>;
21
+ textBlockMenu: TextBlockMenuState;
22
+ updateTextBlockStyle: (blockId: string, patch: Partial<Omit<TextStyleRange, "id" | "start" | "end">>) => void;
23
+ };
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;
25
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import type { MathCanvasTheme, RenderMode, TextBlock, Tool } from "../../../types";
3
+ type TextBlockViewProps = {
4
+ block: TextBlock;
5
+ blockWidths: Record<string, number>;
6
+ clearGraphSelection: () => void;
7
+ clearMatrixSelection: () => void;
8
+ colors: MathCanvasTheme;
9
+ openTextBlockMenu: (block: TextBlock) => void;
10
+ overlayRefs: MutableRefObject<Record<string, HTMLDivElement | null>>;
11
+ selectedBlockId: string | null;
12
+ setRenderMode: Dispatch<SetStateAction<RenderMode>>;
13
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
14
+ size: {
15
+ width: number;
16
+ height: number;
17
+ };
18
+ startEditing: (id: string, selectionOverride?: number | null) => void;
19
+ tool: Tool;
20
+ };
21
+ export default function TextBlockView({ block, blockWidths, clearGraphSelection, clearMatrixSelection, colors, openTextBlockMenu, overlayRefs, selectedBlockId, setRenderMode, setSelectedBlockId, size, startEditing, tool, }: TextBlockViewProps): import("react/jsx-runtime").JSX.Element;
22
+ export {};
@@ -0,0 +1,29 @@
1
+ import type Konva from "konva";
2
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
3
+ import type { MathCanvasTheme, RenderMode, TextBlock, Tool } from "../../../types";
4
+ type TextInteractionLayerProps = {
5
+ blocks: TextBlock[];
6
+ blockWidths: Record<string, number>;
7
+ blockHeights: Record<string, number>;
8
+ size: {
9
+ width: number;
10
+ height: number;
11
+ };
12
+ tool: Tool;
13
+ colors: MathCanvasTheme;
14
+ blockNodeRefs: MutableRefObject<Record<string, Konva.Rect | null>>;
15
+ transformerRef: MutableRefObject<Konva.Transformer | null>;
16
+ graphTransformerRef: MutableRefObject<Konva.Transformer | null>;
17
+ matrixTransformerRef: MutableRefObject<Konva.Transformer | null>;
18
+ tableTransformerRef: MutableRefObject<Konva.Transformer | null>;
19
+ clearGraphSelection: () => void;
20
+ clearMatrixSelection: () => void;
21
+ openTextBlockMenu: (block: TextBlock) => void;
22
+ pushHistoryState: () => void;
23
+ setRenderMode: Dispatch<SetStateAction<RenderMode>>;
24
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
25
+ startEditing: (id: string) => void;
26
+ updateBlock: (id: string, updater: (block: TextBlock) => TextBlock) => void;
27
+ };
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;
29
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import type { TextBlock, TextStyleRange } from "../../../types";
3
+ type TextBlockMenu = {
4
+ blockId: string;
5
+ panel: "color" | "format" | null;
6
+ };
7
+ type UseTextBlockActionsOptions = {
8
+ blocks: TextBlock[];
9
+ clearEditing: () => void;
10
+ createId: () => string;
11
+ editingBlockId: string | null;
12
+ editingSelection: number;
13
+ editingSelectionEnd: number;
14
+ getResolvedEditingValue: () => string;
15
+ lastEditingSelectionRangeRef: MutableRefObject<{
16
+ blockId: string;
17
+ start: number;
18
+ end: number;
19
+ } | null>;
20
+ pushHistoryState: () => void;
21
+ selectedBlockId: string | null;
22
+ setBlocks: Dispatch<SetStateAction<TextBlock[]>>;
23
+ setEditingValue: Dispatch<SetStateAction<string>>;
24
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
25
+ setTextBlockMenu: Dispatch<SetStateAction<TextBlockMenu | null>>;
26
+ textareaRef: MutableRefObject<HTMLTextAreaElement | null>;
27
+ };
28
+ export declare function useTextBlockActions({ blocks, clearEditing, createId, editingBlockId, editingSelection, editingSelectionEnd, getResolvedEditingValue, lastEditingSelectionRangeRef, pushHistoryState, selectedBlockId, setBlocks, setEditingValue, setSelectedBlockId, setTextBlockMenu, textareaRef, }: UseTextBlockActionsOptions): {
29
+ copyTextBlock: (block: TextBlock) => Promise<void>;
30
+ deleteTextBlock: (blockId: string) => void;
31
+ getBlockById: (id: string | null) => TextBlock | null;
32
+ getTextboxSelectionRange: (blockId: string, contentLength: number) => {
33
+ start: number;
34
+ end: number;
35
+ } | null;
36
+ openTextBlockMenu: (block: TextBlock) => void;
37
+ updateBlock: (id: string, updater: (block: TextBlock) => TextBlock) => void;
38
+ updateTextBlockStyle: (blockId: string, stylePatch: Omit<TextStyleRange, "id" | "start" | "end">) => void;
39
+ };
40
+ export {};
@@ -0,0 +1,57 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import { type InlineMathAtom } from "../../../../inlineMathModel";
3
+ import type { RenderMode, TextBlock } from "../../../types";
4
+ type UseTextBlockEditingActionsOptions = {
5
+ blocks: TextBlock[];
6
+ clearGraphEditing: () => void;
7
+ clearGraphSelection: () => void;
8
+ clearMatrixEditing: () => void;
9
+ clearMatrixSelection: () => void;
10
+ createId: () => string;
11
+ editingBlockId: string | null;
12
+ editingHeight: number;
13
+ editingWidth: number;
14
+ getResolvedEditingValue: () => string;
15
+ lastEditingSelectionRangeRef: MutableRefObject<{
16
+ blockId: string;
17
+ start: number;
18
+ end: number;
19
+ } | null>;
20
+ pushHistoryState: () => void;
21
+ renderMode: RenderMode;
22
+ resetInlineMathState: () => void;
23
+ selectedBlockId: string | null;
24
+ setBlocks: Dispatch<SetStateAction<TextBlock[]>>;
25
+ setEditingBlockId: Dispatch<SetStateAction<string | null>>;
26
+ setEditingHeight: Dispatch<SetStateAction<number>>;
27
+ setEditingInlineMathAtoms: Dispatch<SetStateAction<InlineMathAtom[]>>;
28
+ setEditingSelection: Dispatch<SetStateAction<number>>;
29
+ setEditingSelectionEnd: Dispatch<SetStateAction<number>>;
30
+ setEditingValue: Dispatch<SetStateAction<string>>;
31
+ setEditingWidth: Dispatch<SetStateAction<number>>;
32
+ setInlineMathEditorRect: Dispatch<SetStateAction<{
33
+ left: number;
34
+ top: number;
35
+ width: number;
36
+ height: number;
37
+ } | null>>;
38
+ setMathOverlayCaret: Dispatch<SetStateAction<{
39
+ left: number;
40
+ top: number;
41
+ height: number;
42
+ } | null>>;
43
+ setRenderMode: Dispatch<SetStateAction<RenderMode>>;
44
+ setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
45
+ size: {
46
+ width: number;
47
+ height: number;
48
+ };
49
+ };
50
+ export declare function useTextBlockEditingActions({ blocks, clearGraphEditing, clearGraphSelection, clearMatrixEditing, clearMatrixSelection, createId, editingBlockId, editingHeight, editingWidth, getResolvedEditingValue, lastEditingSelectionRangeRef, pushHistoryState, renderMode, resetInlineMathState, selectedBlockId, setBlocks, setEditingBlockId, setEditingHeight, setEditingInlineMathAtoms, setEditingSelection, setEditingSelectionEnd, setEditingValue, setEditingWidth, setInlineMathEditorRect, setMathOverlayCaret, setRenderMode, setSelectedBlockId, size, }: UseTextBlockEditingActionsOptions): {
51
+ clearEditing: () => void;
52
+ commitEditing: () => void;
53
+ createTextBlock: (x: number, y: number) => void;
54
+ rememberEditingSelection: (target: HTMLTextAreaElement) => void;
55
+ startEditing: (id: string, selectionOverride?: number | null) => void;
56
+ };
57
+ export {};