@khanacademy/math-input
Advanced tools
Comparing version 0.0.0-PR580-20230621214658 to 0.0.0-PR581-20230621230716
# @khanacademy/math-input | ||
## 0.0.0-PR580-20230621214658 | ||
## 0.0.0-PR581-20230621230716 | ||
### Major Changes | ||
- bff7fbcd: Update contextForCursor to further abstract MathQuill cursor | ||
### Patch Changes | ||
@@ -10,0 +6,0 @@ |
import Key from "../../data/keys"; | ||
import { Cursor } from "../../types"; | ||
import { MathFieldInterface } from "./mathquill-types"; | ||
import { MathFieldInterface, MathFieldCursor } from "./mathquill-types"; | ||
/** | ||
@@ -34,3 +34,3 @@ * This file contains a wrapper around MathQuill so that we can provide a | ||
getCursor(): any; | ||
contextForCursor(): import("./cursor-contexts").CursorContext; | ||
contextForCursor(cursor: MathFieldCursor): import("./cursor-contexts").CursorContext; | ||
getSelection(): any; | ||
@@ -37,0 +37,0 @@ getContent(): string; |
@@ -46,2 +46,2 @@ import { CursorContext } from "./cursor-contexts"; | ||
} | null; | ||
export declare function getCursorContext(mathField?: MathFieldInterface): CursorContext; | ||
export declare function contextForCursor(cursor: MathFieldCursor): CursorContext; |
/// <reference types="react" /> | ||
import Key from "../../data/keys"; | ||
import { ClickKeyCallback } from "../../types"; | ||
import { CursorContext } from "../input/cursor-contexts"; | ||
export type Props = { | ||
onClickKey: ClickKeyCallback; | ||
cursorContext?: CursorContext; | ||
trigonometry?: boolean; | ||
@@ -17,8 +15,2 @@ extraKeys: ReadonlyArray<Key>; | ||
}; | ||
declare function Keypad(props: Props): JSX.Element; | ||
declare namespace Keypad { | ||
var defaultProps: { | ||
extraKeys: never[]; | ||
}; | ||
} | ||
export default Keypad; | ||
export default function Keypad(props: Props): JSX.Element; |
/// <reference types="react" /> | ||
import { ClickKeyCallback } from "../../types"; | ||
import { CursorContext } from "../input/cursor-contexts"; | ||
type Props = { | ||
onClickKey: ClickKeyCallback; | ||
cursorContext?: CursorContext; | ||
multiplicationDot?: boolean; | ||
@@ -8,0 +6,0 @@ divisionKey?: boolean; |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "0.0.0-PR580-20230621214658", | ||
"version": "0.0.0-PR581-20230621230716", | ||
"publishConfig": { | ||
@@ -9,0 +9,0 @@ "access": "public" |
@@ -26,7 +26,11 @@ // Notes about MathQuill | ||
getCursor, | ||
getCursorContext, | ||
contextForCursor, | ||
maybeFindCommand, | ||
} from "./mathquill-helpers"; | ||
import {createMathField, mathQuillInstance} from "./mathquill-instance"; | ||
import {MathFieldInterface, MathFieldUpdaterCallback} from "./mathquill-types"; | ||
import { | ||
MathFieldInterface, | ||
MathFieldCursor, | ||
MathFieldUpdaterCallback, | ||
} from "./mathquill-types"; | ||
@@ -112,3 +116,3 @@ const mobileKeyTranslator: Record<Key, MathFieldUpdaterCallback> = { | ||
return { | ||
context: this.contextForCursor(), | ||
context: this.contextForCursor(cursor), | ||
}; | ||
@@ -158,3 +162,3 @@ } | ||
this.callbacks.onCursorMove({ | ||
context: this.contextForCursor(), | ||
context: this.contextForCursor(cursor), | ||
}); | ||
@@ -173,4 +177,4 @@ } | ||
// but it's part of the public MathWrapper API | ||
contextForCursor() { | ||
return getCursorContext(this.mathField); | ||
contextForCursor(cursor: MathFieldCursor) { | ||
return contextForCursor(cursor); | ||
} | ||
@@ -177,0 +181,0 @@ |
@@ -241,11 +241,4 @@ import {CursorContext} from "./cursor-contexts"; | ||
export function getCursorContext( | ||
mathField?: MathFieldInterface, | ||
): CursorContext { | ||
if (!mathField) { | ||
return CursorContext.NONE; | ||
} | ||
export function contextForCursor(cursor: MathFieldCursor): CursorContext { | ||
// First, try to find any fraction to the right, unimpeded. | ||
const cursor = getCursor(mathField); | ||
let visitor = cursor; | ||
@@ -252,0 +245,0 @@ while (visitor[mathQuillInstance.R] !== MathFieldActionType.MQ_END) { |
@@ -6,3 +6,3 @@ import Key from "../../data/keys"; | ||
isParens, | ||
getCursorContext, | ||
contextForCursor, | ||
getCursor, | ||
@@ -30,3 +30,3 @@ } from "../input/mathquill-helpers"; | ||
const cursor = getCursor(mathField); | ||
const context = getCursorContext(mathField); | ||
const context = contextForCursor(cursor); | ||
@@ -48,3 +48,2 @@ // Validate that the current cursor context matches the key's intent. | ||
cursor.insRightOf(cursor.parent.parent); | ||
mathField.keystroke("Right"); | ||
break; | ||
@@ -51,0 +50,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3010290
334
33221