mathlean-canvas 0.3.4 → 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 +5 -1
- package/dist/MathCanvas/components/CanvasOverlayViewport.d.ts +5 -3
- package/dist/MathCanvas/components/CollaborationOverlay.d.ts +10 -0
- package/dist/MathCanvas/components/ShortcutMenu.d.ts +10 -0
- package/dist/MathCanvas/components/Toolbar.d.ts +7 -6
- package/dist/MathCanvas/components/icons.d.ts +13 -1
- package/dist/MathCanvas/core/hooks/useCanvasGlobalActions.d.ts +2 -9
- package/dist/MathCanvas/core/hooks/useCanvasSnapshot.d.ts +7 -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/plot/components/PlotControls.d.ts +2 -1
- package/dist/MathCanvas/features/plot/components/PlotLayer.d.ts +3 -2
- package/dist/MathCanvas/features/plot/utils/plotCompiler.d.ts +6 -2
- package/dist/MathCanvas/features/plot/utils/plotModel.d.ts +3 -1
- package/dist/MathCanvas/features/stroke/hooks/useStrokeState.d.ts +13 -3
- package/dist/MathCanvas/features/text/components/InlineMathBubble.d.ts +3 -1
- package/dist/MathCanvas/features/text/components/TextBlockEditor.d.ts +3 -7
- package/dist/MathCanvas/features/text/components/TextBlockMenu.d.ts +8 -3
- package/dist/MathCanvas/features/text/components/TextBlockView.d.ts +7 -5
- 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/useTextBlockEditingActions.d.ts +1 -5
- package/dist/MathCanvas/features/text/hooks/useTextBlockLayoutEffects.d.ts +15 -22
- package/dist/MathCanvas/features/text/hooks/useTextBlockRenderHelpers.d.ts +1 -5
- package/dist/MathCanvas/features/text/hooks/useTextboxResize.d.ts +1 -5
- package/dist/MathCanvas/shortcuts.d.ts +20 -0
- package/dist/MathCanvas/types.d.ts +123 -0
- package/dist/MathCanvas/utils/latex.d.ts +1 -0
- package/dist/MathCanvas.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18381 -15903
- package/dist/useInlineMathSession.d.ts +4 -2
- package/package.json +1 -1
|
@@ -26,21 +26,17 @@ type TextBlockEditorProps = {
|
|
|
26
26
|
inlineMathBubbleRef: RefObject<HTMLDivElement | null>;
|
|
27
27
|
inlineMathFieldRef: RefObject<MathfieldElement | null>;
|
|
28
28
|
insertInlineMathAtSelection: (start: number, end: number) => void;
|
|
29
|
+
isOpeningInlineMathSession: boolean;
|
|
29
30
|
isOpeningInlineMathSessionRef: MutableRefObject<boolean>;
|
|
30
31
|
latexPreviewStart: number | null;
|
|
31
32
|
mathOverlayCaret: MathOverlayCaret;
|
|
32
33
|
openTextBlockMenu: (block: TextBlock) => void;
|
|
33
34
|
rememberEditingSelection: (target: HTMLTextAreaElement) => void;
|
|
34
|
-
reopenInlineMathSessionAtBoundary: (direction: "before" | "after") => boolean;
|
|
35
|
+
reopenInlineMathSessionAtBoundary: (direction: "before" | "after", selection?: number) => boolean;
|
|
35
36
|
setEditingValue: Dispatch<SetStateAction<string>>;
|
|
36
37
|
setRenderMode: Dispatch<SetStateAction<RenderMode>>;
|
|
37
38
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
38
|
-
size: {
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
};
|
|
42
39
|
textareaRef: RefObject<HTMLTextAreaElement | null>;
|
|
43
|
-
toggleLatexMode: () => void;
|
|
44
40
|
};
|
|
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,
|
|
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;
|
|
46
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 {};
|
|
@@ -11,12 +11,14 @@ type TextBlockViewProps = {
|
|
|
11
11
|
selectedBlockId: string | null;
|
|
12
12
|
setRenderMode: Dispatch<SetStateAction<RenderMode>>;
|
|
13
13
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
14
|
-
size: {
|
|
15
|
-
width: number;
|
|
16
|
-
height: number;
|
|
17
|
-
};
|
|
18
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
|
+
}>;
|
|
19
21
|
tool: Tool;
|
|
20
22
|
};
|
|
21
|
-
export default function TextBlockView({ block, blockWidths, clearGraphSelection, clearMatrixSelection, colors, openTextBlockMenu, overlayRefs, selectedBlockId, setRenderMode, setSelectedBlockId,
|
|
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;
|
|
22
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[];
|
|
@@ -42,12 +42,8 @@ type UseTextBlockEditingActionsOptions = {
|
|
|
42
42
|
} | null>>;
|
|
43
43
|
setRenderMode: Dispatch<SetStateAction<RenderMode>>;
|
|
44
44
|
setSelectedBlockId: Dispatch<SetStateAction<string | null>>;
|
|
45
|
-
size: {
|
|
46
|
-
width: number;
|
|
47
|
-
height: number;
|
|
48
|
-
};
|
|
49
45
|
};
|
|
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,
|
|
46
|
+
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, }: UseTextBlockEditingActionsOptions): {
|
|
51
47
|
clearEditing: () => void;
|
|
52
48
|
commitEditing: () => void;
|
|
53
49
|
createTextBlock: (x: number, y: number) => void;
|
|
@@ -9,6 +9,17 @@ type LatexPreview = {
|
|
|
9
9
|
fallback: string;
|
|
10
10
|
caretOffset?: number;
|
|
11
11
|
} | null;
|
|
12
|
+
type MathOverlayCaret = {
|
|
13
|
+
left: number;
|
|
14
|
+
top: number;
|
|
15
|
+
height: number;
|
|
16
|
+
} | null;
|
|
17
|
+
type InlineMathEditorRect = {
|
|
18
|
+
left: number;
|
|
19
|
+
top: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
} | null;
|
|
12
23
|
type UseTextBlockLayoutEffectsOptions = {
|
|
13
24
|
activeInlineMathDraft: string;
|
|
14
25
|
activeInlineMathSession: InlineMathSession;
|
|
@@ -24,12 +35,7 @@ type UseTextBlockLayoutEffectsOptions = {
|
|
|
24
35
|
editingSelection: number;
|
|
25
36
|
editingValue: string;
|
|
26
37
|
editingWidth: number;
|
|
27
|
-
inlineMathEditorRect:
|
|
28
|
-
left: number;
|
|
29
|
-
top: number;
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
} | null;
|
|
38
|
+
inlineMathEditorRect: InlineMathEditorRect;
|
|
33
39
|
inlineMathBubbleRef: MutableRefObject<HTMLDivElement | null>;
|
|
34
40
|
inlineMathFieldRef: MutableRefObject<HTMLElement | null>;
|
|
35
41
|
latexPreview: LatexPreview;
|
|
@@ -41,22 +47,9 @@ type UseTextBlockLayoutEffectsOptions = {
|
|
|
41
47
|
setEditingHeight: Dispatch<SetStateAction<number>>;
|
|
42
48
|
setEditingInlineMathAtoms: Dispatch<SetStateAction<InlineMathAtom[]>>;
|
|
43
49
|
setEditingWidth: Dispatch<SetStateAction<number>>;
|
|
44
|
-
setInlineMathEditorRect: Dispatch<SetStateAction<
|
|
45
|
-
|
|
46
|
-
top: number;
|
|
47
|
-
width: number;
|
|
48
|
-
height: number;
|
|
49
|
-
} | null>>;
|
|
50
|
-
setMathOverlayCaret: Dispatch<SetStateAction<{
|
|
51
|
-
left: number;
|
|
52
|
-
top: number;
|
|
53
|
-
height: number;
|
|
54
|
-
} | null>>;
|
|
55
|
-
size: {
|
|
56
|
-
width: number;
|
|
57
|
-
height: number;
|
|
58
|
-
};
|
|
50
|
+
setInlineMathEditorRect: Dispatch<SetStateAction<InlineMathEditorRect>>;
|
|
51
|
+
setMathOverlayCaret: Dispatch<SetStateAction<MathOverlayCaret>>;
|
|
59
52
|
textareaRef: MutableRefObject<HTMLTextAreaElement | null>;
|
|
60
53
|
};
|
|
61
|
-
export declare function useTextBlockLayoutEffects({ activeInlineMathDraft, activeInlineMathSession, blocks, containerRef, editableMirrorContentRef, editableMirrorRef, editingBlockId, editingDisplayValue, editingHeight, editingSelection, editingValue, editingWidth, inlineMathEditorRect, inlineMathBubbleRef, inlineMathFieldRef, latexPreview, overlayRefs, renderMode, resetInlineMathState, setBlockHeights, setBlockWidths, setEditingHeight, setEditingInlineMathAtoms, setEditingWidth, setInlineMathEditorRect, setMathOverlayCaret,
|
|
54
|
+
export declare function useTextBlockLayoutEffects({ activeInlineMathDraft, activeInlineMathSession, blockHeights, blockWidths, blocks, containerRef, editableMirrorContentRef, editableMirrorRef, editingBlockId, editingDisplayValue, editingHeight, editingSelection, editingValue, editingWidth, inlineMathEditorRect, inlineMathBubbleRef, inlineMathFieldRef, latexPreview, overlayRefs, renderMode, resetInlineMathState, setBlockHeights, setBlockWidths, setEditingHeight, setEditingInlineMathAtoms, setEditingWidth, setInlineMathEditorRect, setMathOverlayCaret, textareaRef, }: UseTextBlockLayoutEffectsOptions): void;
|
|
62
55
|
export {};
|
|
@@ -3,12 +3,8 @@ type UseTextBlockRenderHelpersOptions = {
|
|
|
3
3
|
blockHeights: Record<string, number>;
|
|
4
4
|
blockWidths: Record<string, number>;
|
|
5
5
|
blocks: TextBlock[];
|
|
6
|
-
size: {
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
};
|
|
10
6
|
};
|
|
11
|
-
export declare function useTextBlockRenderHelpers({ blockHeights, blockWidths, blocks,
|
|
7
|
+
export declare function useTextBlockRenderHelpers({ blockHeights, blockWidths, blocks, }: UseTextBlockRenderHelpersOptions): {
|
|
12
8
|
findTextBlockBlockingCreation: (x: number, y: number) => TextBlock | null;
|
|
13
9
|
findTextBlockNearPoint: (x: number, y: number) => TextBlock | null;
|
|
14
10
|
getTextMathAxisY: (block: TextBlock) => number | null;
|
|
@@ -7,13 +7,9 @@ type UseTextboxResizeOptions = {
|
|
|
7
7
|
pushHistoryState: () => void;
|
|
8
8
|
setEditingHeight: Dispatch<SetStateAction<number>>;
|
|
9
9
|
setEditingWidth: Dispatch<SetStateAction<number>>;
|
|
10
|
-
size: {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
};
|
|
14
10
|
updateBlock: (id: string, updater: (block: TextBlock) => TextBlock) => void;
|
|
15
11
|
};
|
|
16
|
-
export declare function useTextboxResize({ editingHeight, editingWidth, getBlockById, pushHistoryState, setEditingHeight, setEditingWidth,
|
|
12
|
+
export declare function useTextboxResize({ editingHeight, editingWidth, getBlockById, pushHistoryState, setEditingHeight, setEditingWidth, updateBlock, }: UseTextboxResizeOptions): {
|
|
17
13
|
beginTextboxResize: (block: TextBlock, anchor: TextboxResizeAnchor, event: React.MouseEvent<HTMLDivElement>) => void;
|
|
18
14
|
};
|
|
19
15
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ShortcutSettings } from "./types";
|
|
2
|
+
export type ShortcutCategory = "arrows" | "greek" | "styles" | "functions" | "calculus" | "algebra" | "sets" | "relations" | "geometry" | "operators" | "physics" | "probability" | "custom";
|
|
3
|
+
export type ShortcutEntry = {
|
|
4
|
+
id: string;
|
|
5
|
+
trigger: string;
|
|
6
|
+
latex: string;
|
|
7
|
+
category: ShortcutCategory;
|
|
8
|
+
source: "built-in" | "custom";
|
|
9
|
+
plotSafe: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const shortcutCategoryLabels: Record<ShortcutCategory, string>;
|
|
12
|
+
export declare const shortcutCategorySymbols: Record<ShortcutCategory, string>;
|
|
13
|
+
export declare const shortcutCategoryOrder: ShortcutCategory[];
|
|
14
|
+
export declare const builtInShortcutEntries: ShortcutEntry[];
|
|
15
|
+
export declare function normalizeShortcutSettings(settings?: ShortcutSettings): ShortcutSettings;
|
|
16
|
+
export declare function getShortcutEntries(settings?: ShortcutSettings): ShortcutEntry[];
|
|
17
|
+
export declare function getEnabledShortcutEntries(settings?: ShortcutSettings, scope?: "math" | "plot"): ShortcutEntry[];
|
|
18
|
+
export declare function getInlineShortcuts(settings?: ShortcutSettings, scope?: "math" | "plot"): {
|
|
19
|
+
[k: string]: string;
|
|
20
|
+
};
|
|
@@ -3,11 +3,22 @@ import type { MathJsonExpression } from "@cortex-js/compute-engine/math-json";
|
|
|
3
3
|
export type Tool = "select" | "pan" | "pen" | "eraser" | "text" | "graph" | "plot" | "matrix" | "table" | "geometry";
|
|
4
4
|
export type DrawingTool = "pen" | "eraser";
|
|
5
5
|
export type RenderMode = "plain" | "latex";
|
|
6
|
+
export type CustomShortcut = {
|
|
7
|
+
id: string;
|
|
8
|
+
trigger: string;
|
|
9
|
+
latex: string;
|
|
10
|
+
};
|
|
11
|
+
export type ShortcutSettings = {
|
|
12
|
+
disabledShortcutIds?: string[];
|
|
13
|
+
disabledShortcutCategories?: string[];
|
|
14
|
+
customShortcuts?: CustomShortcut[];
|
|
15
|
+
};
|
|
6
16
|
export type GeometryMode = "point" | "segment" | "angle" | "circle" | "label" | "midpoint" | "perpendicular" | "parallel" | "fixed" | "regular" | "rightAngle" | "equalSide";
|
|
7
17
|
export type GeometryObjectKind = "point" | "segment" | "polygon" | "angle" | "circle";
|
|
8
18
|
export type GeometryDirection = "left" | "right" | "up" | "down";
|
|
9
19
|
export type GraphDirection = "upLeft" | "up" | "upRight" | "left" | "right" | "downLeft" | "down" | "downRight";
|
|
10
20
|
export type CoordinatePlaneMode = "blank" | "grid" | "plane";
|
|
21
|
+
export type TextboxMenuPanel = "color" | "format" | "mode" | null;
|
|
11
22
|
export type GeometryLabelTarget = {
|
|
12
23
|
kind: "segment" | "angle" | "circle";
|
|
13
24
|
id: string;
|
|
@@ -65,6 +76,13 @@ export type PlotEquation = {
|
|
|
65
76
|
mathJson: MathJsonExpression | null;
|
|
66
77
|
color: string;
|
|
67
78
|
};
|
|
79
|
+
export type PlotParameter = {
|
|
80
|
+
name: string;
|
|
81
|
+
value: number;
|
|
82
|
+
min: number;
|
|
83
|
+
max: number;
|
|
84
|
+
step?: number;
|
|
85
|
+
};
|
|
68
86
|
export type PlotFunction = {
|
|
69
87
|
id: string;
|
|
70
88
|
x: number;
|
|
@@ -75,6 +93,10 @@ export type PlotFunction = {
|
|
|
75
93
|
mathJson: MathJsonExpression | null;
|
|
76
94
|
color: string;
|
|
77
95
|
scale?: number;
|
|
96
|
+
viewCenterX?: number;
|
|
97
|
+
viewCenterY?: number;
|
|
98
|
+
parameters?: PlotParameter[];
|
|
99
|
+
dismissedParameterNames?: string[];
|
|
78
100
|
equations?: PlotEquation[];
|
|
79
101
|
equationPanelX?: number;
|
|
80
102
|
equationPanelY?: number;
|
|
@@ -206,8 +228,92 @@ export type CanvasState = {
|
|
|
206
228
|
geoHelperSegments: GeoHelperSegment[];
|
|
207
229
|
geoRightAngleMarkers: GeoRightAngleMarker[];
|
|
208
230
|
coordinatePlaneMode: CoordinatePlaneMode;
|
|
231
|
+
coordinateLabelsVisible?: boolean;
|
|
232
|
+
renderMode: RenderMode;
|
|
233
|
+
shortcutSettings?: ShortcutSettings;
|
|
234
|
+
};
|
|
235
|
+
export type DocumentCanvasState = Omit<CanvasState, "shortcutSettings">;
|
|
236
|
+
export type PointerPresence = {
|
|
237
|
+
x: number;
|
|
238
|
+
y: number;
|
|
239
|
+
xPct: number;
|
|
240
|
+
yPct: number;
|
|
241
|
+
tool: string | null;
|
|
242
|
+
};
|
|
243
|
+
export type StrokePreviewPoint = {
|
|
244
|
+
x: number;
|
|
245
|
+
y: number;
|
|
246
|
+
};
|
|
247
|
+
export type StrokePreview = {
|
|
248
|
+
id: string;
|
|
249
|
+
tool: "pen" | "eraser" | string;
|
|
250
|
+
color?: string;
|
|
251
|
+
width?: number;
|
|
252
|
+
points: StrokePreviewPoint[];
|
|
253
|
+
};
|
|
254
|
+
export type RemotePointerPresence = PointerPresence & {
|
|
255
|
+
id: string;
|
|
256
|
+
color?: string;
|
|
257
|
+
label?: string;
|
|
258
|
+
};
|
|
259
|
+
export type ObjectTransformPreview = {
|
|
260
|
+
id: string;
|
|
261
|
+
objectType: "text" | "graphNode";
|
|
262
|
+
objectId: string;
|
|
263
|
+
x: number;
|
|
264
|
+
y: number;
|
|
265
|
+
width?: number;
|
|
266
|
+
height?: number;
|
|
267
|
+
textBlock?: TextBlock;
|
|
268
|
+
graphNode?: GraphNode;
|
|
269
|
+
};
|
|
270
|
+
export type TextDraftPreview = {
|
|
271
|
+
id: string;
|
|
272
|
+
blockId: string;
|
|
273
|
+
x: number;
|
|
274
|
+
y: number;
|
|
275
|
+
width: number;
|
|
276
|
+
height: number;
|
|
277
|
+
content: string;
|
|
209
278
|
renderMode: RenderMode;
|
|
279
|
+
selectionStart?: number;
|
|
280
|
+
selectionEnd?: number;
|
|
281
|
+
fontSize?: number;
|
|
282
|
+
textBlock?: TextBlock;
|
|
283
|
+
};
|
|
284
|
+
export type CollaborationPreviewPhase = "start" | "update" | "end";
|
|
285
|
+
export type CollaborationMessageBase = {
|
|
286
|
+
senderId: string;
|
|
287
|
+
documentId?: string;
|
|
288
|
+
sentAt?: number;
|
|
289
|
+
};
|
|
290
|
+
export type CollaborationDocumentMessage = CollaborationMessageBase & {
|
|
291
|
+
type: "document";
|
|
292
|
+
revision?: string | number;
|
|
293
|
+
state: DocumentCanvasState;
|
|
294
|
+
};
|
|
295
|
+
export type CollaborationPresenceMessage = CollaborationMessageBase & {
|
|
296
|
+
type: "presence";
|
|
297
|
+
presence: PointerPresence;
|
|
298
|
+
color?: string;
|
|
299
|
+
label?: string;
|
|
300
|
+
};
|
|
301
|
+
export type CollaborationStrokePreviewMessage = CollaborationMessageBase & {
|
|
302
|
+
type: "stroke-preview";
|
|
303
|
+
phase: CollaborationPreviewPhase;
|
|
304
|
+
preview: StrokePreview;
|
|
305
|
+
};
|
|
306
|
+
export type CollaborationObjectTransformMessage = CollaborationMessageBase & {
|
|
307
|
+
type: "object-transform";
|
|
308
|
+
phase: CollaborationPreviewPhase;
|
|
309
|
+
preview: ObjectTransformPreview;
|
|
310
|
+
};
|
|
311
|
+
export type CollaborationTextDraftMessage = CollaborationMessageBase & {
|
|
312
|
+
type: "text-draft";
|
|
313
|
+
phase: CollaborationPreviewPhase;
|
|
314
|
+
preview: TextDraftPreview;
|
|
210
315
|
};
|
|
316
|
+
export type CollaborationMessage = CollaborationDocumentMessage | CollaborationPresenceMessage | CollaborationStrokePreviewMessage | CollaborationObjectTransformMessage | CollaborationTextDraftMessage;
|
|
211
317
|
export type StageMouseEvent = Parameters<NonNullable<React.ComponentProps<typeof Stage>["onMouseDown"]>>[0];
|
|
212
318
|
export type StageTouchEvent = Parameters<NonNullable<React.ComponentProps<typeof Stage>["onTouchStart"]>>[0];
|
|
213
319
|
export type StagePointerEvent = StageMouseEvent | StageTouchEvent;
|
|
@@ -237,5 +343,22 @@ export type MathCanvasProps = {
|
|
|
237
343
|
className?: string;
|
|
238
344
|
style?: React.CSSProperties;
|
|
239
345
|
initialState?: CanvasState;
|
|
346
|
+
documentState?: DocumentCanvasState;
|
|
347
|
+
idPrefix?: string;
|
|
240
348
|
onStateChange?: (state: CanvasState) => void;
|
|
349
|
+
onDocumentStateChange?: (state: DocumentCanvasState) => void;
|
|
350
|
+
onPointerPresence?: (presence: PointerPresence) => void;
|
|
351
|
+
onStrokePreviewStart?: (preview: StrokePreview) => void;
|
|
352
|
+
onStrokePreviewUpdate?: (preview: StrokePreview) => void;
|
|
353
|
+
onStrokePreviewEnd?: (preview: StrokePreview) => void;
|
|
354
|
+
onObjectTransformPreviewStart?: (preview: ObjectTransformPreview) => void;
|
|
355
|
+
onObjectTransformPreviewUpdate?: (preview: ObjectTransformPreview) => void;
|
|
356
|
+
onObjectTransformPreviewEnd?: (preview: ObjectTransformPreview) => void;
|
|
357
|
+
onTextDraftPreviewStart?: (preview: TextDraftPreview) => void;
|
|
358
|
+
onTextDraftPreviewUpdate?: (preview: TextDraftPreview) => void;
|
|
359
|
+
onTextDraftPreviewEnd?: (preview: TextDraftPreview) => void;
|
|
360
|
+
remotePresence?: RemotePointerPresence[];
|
|
361
|
+
remoteStrokePreviews?: StrokePreview[];
|
|
362
|
+
remoteObjectTransformPreviews?: ObjectTransformPreview[];
|
|
363
|
+
remoteTextDraftPreviews?: TextDraftPreview[];
|
|
241
364
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function shouldPreferDisplayStyle(expression: string, displayMode: boolean): boolean;
|
|
2
|
+
export declare function getRenderableLatex(expression: string): string;
|
|
2
3
|
export declare function getPreferredRenderedLatex(expression: string, displayMode: boolean): string;
|
|
3
4
|
export declare function canRenderLatex(value: string): boolean;
|
|
4
5
|
export declare function parseLatexSegments(content: string): ({
|
package/dist/MathCanvas.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import "katex/dist/katex.min.css";
|
|
|
2
2
|
import "mathlive";
|
|
3
3
|
import "mathlive/fonts.css";
|
|
4
4
|
import "mathlive/static.css";
|
|
5
|
-
export type { CanvasState, MathCanvasProps, GeoPoint, GeoSegment, GeoPolygon, GeoAngle, GeoCircle, GeoHelperSegment, GeoRightAngleMarker, } from "./MathCanvas/types";
|
|
5
|
+
export type { CanvasState, CollaborationMessage, CollaborationMessageBase, CollaborationDocumentMessage, CollaborationObjectTransformMessage, CollaborationPresenceMessage, CollaborationPreviewPhase, CollaborationStrokePreviewMessage, CollaborationTextDraftMessage, DocumentCanvasState, MathCanvasProps, ObjectTransformPreview, PointerPresence, RemotePointerPresence, StrokePreview, TextboxMenuPanel, TextDraftPreview, GeoPoint, GeoSegment, GeoPolygon, GeoAngle, GeoCircle, GeoHelperSegment, GeoRightAngleMarker, } from "./MathCanvas/types";
|
|
6
6
|
import type { MathCanvasProps } from "./MathCanvas/types";
|
|
7
|
-
export default function MathCanvas(
|
|
7
|
+
export default function MathCanvas(props: MathCanvasProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default } from "./MathCanvas";
|
|
2
2
|
export { default as MathCanvas } from "./MathCanvas";
|
|
3
|
-
export type { CanvasState, MathCanvasProps } from "./MathCanvas";
|
|
3
|
+
export type { CanvasState, CollaborationMessage, CollaborationMessageBase, CollaborationDocumentMessage, CollaborationObjectTransformMessage, CollaborationPresenceMessage, CollaborationPreviewPhase, CollaborationStrokePreviewMessage, CollaborationTextDraftMessage, DocumentCanvasState, MathCanvasProps, ObjectTransformPreview, PointerPresence, RemotePointerPresence, StrokePreview, TextDraftPreview, } from "./MathCanvas";
|