mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Add types for react-mathquill * Fix formatting issues * Fix typescript header version * Remove single quote character from typescript version header * Fix typing for function * Add type definitions for @edtr-io/mathquill and update react-mathquill to reflect that. * Add paths property to @edtr-io/mathquill tsconfig * Fix dt-header package version * Update types/react-mathquill/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/edtr-io__mathquill/edtr-io__mathquill-tests.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/react-mathquill/tsconfig.json Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/react-mathquill/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/react-mathquill/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/react-mathquill/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/react-mathquill/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/react-mathquill/react-mathquill-tests.tsx Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> Co-authored-by: Dmitry Demensky <10235949+demensky@users.noreply.github.com>
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import * as React from 'react';
|
|
import MathQuill, { addStyles } from 'react-mathquill';
|
|
import { Config, MQ } from '@edtr-io/mathquill';
|
|
|
|
addStyles();
|
|
|
|
const Test = () => {
|
|
const [latex, setLatex] = React.useState<string>('');
|
|
|
|
const config: Config = {
|
|
spaceBehavesLikeTab: true,
|
|
leftRightIntoCmdGoes: 'up',
|
|
autoSubscriptNumerals: true,
|
|
maxDepth: 10,
|
|
substituteTextarea() {
|
|
return '';
|
|
},
|
|
restrictMismatchedBrackets: true,
|
|
sumStartsWithNEquals: true,
|
|
supSubsRequireOperand: true,
|
|
charsThatBreakOutOfSupSub: '+-=<>',
|
|
autoCommands: 'pi theta sqrt',
|
|
autoOperatorNames: 'sin cos tan log',
|
|
handlers: {
|
|
edit(mathField: MQ) {
|
|
return mathField;
|
|
},
|
|
enter(mathField: MQ) {
|
|
mathField.blur();
|
|
mathField.focus();
|
|
mathField.keystroke('Tab');
|
|
mathField.typedText('test');
|
|
mathField.moveToLeftEnd();
|
|
mathField.moveToRightEnd();
|
|
mathField.moveToDirEnd(1);
|
|
},
|
|
upOutOf(mathField: MQ) {
|
|
mathField.keystroke('Enter');
|
|
},
|
|
moveOutOf(dir: number, mathField: MQ) {
|
|
if (dir === 1) mathField.clearSelection();
|
|
},
|
|
},
|
|
};
|
|
|
|
return (
|
|
<MathQuill
|
|
latex={latex}
|
|
onChange={(MQ: MQ) => setLatex(MQ.latex())}
|
|
config={config}
|
|
mathquillDidMount={(MQ: MQ) => MQ.latex('\\sqrt{}')}
|
|
/>
|
|
);
|
|
};
|