@pie-lib/math-input-mathlive 1.1.4 → 1.1.5-beta.10
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 +14 -5
- package/lib/__tests__/composites.test.js +255 -0
- package/lib/__tests__/drop-in-compat.test.js +133 -0
- package/lib/__tests__/embedded-fonts.test.js +121 -0
- package/lib/__tests__/index.test.js +118 -0
- package/lib/__tests__/input-imperative.test.js +155 -0
- package/lib/__tests__/keypad-label.test.js +231 -0
- package/lib/__tests__/keypad-render.test.js +206 -0
- package/lib/__tests__/latex-bridge.test.js +386 -0
- package/lib/__tests__/mathlive-instance.test.js +419 -0
- package/lib/__tests__/mount-race.test.js +218 -0
- package/lib/__tests__/static-prompts.test.js +405 -0
- package/lib/__tests__/tmp-markup.test.js +26 -0
- package/lib/keypad/index.js +50 -28
- package/lib/keypad/index.js.map +1 -1
- package/lib/keys/geometry.js +7 -4
- package/lib/keys/geometry.js.map +1 -1
- package/lib/keys/misc.js +9 -2
- package/lib/keys/misc.js.map +1 -1
- package/lib/latex-bridge.js +207 -7
- package/lib/latex-bridge.js.map +1 -1
- package/lib/mathlive-instance.js +176 -12
- package/lib/mathlive-instance.js.map +1 -1
- package/lib/mf/common-styles.js +89 -10
- package/lib/mf/common-styles.js.map +1 -1
- package/lib/mf/index.js +12 -0
- package/lib/mf/index.js.map +1 -1
- package/lib/mf/input.js +34 -5
- package/lib/mf/input.js.map +1 -1
- package/lib/mf/static.js +107 -7
- package/lib/mf/static.js.map +1 -1
- package/package.json +3 -4
- package/src/__tests__/composites.test.jsx +220 -0
- package/src/__tests__/keypad-label.test.jsx +229 -2
- package/src/__tests__/keypad-render.test.jsx +123 -0
- package/src/__tests__/latex-bridge.test.js +159 -0
- package/src/__tests__/mathlive-instance.test.js +237 -0
- package/src/__tests__/mount-race.test.jsx +142 -0
- package/src/__tests__/static-prompts.test.jsx +364 -0
- package/src/keypad/index.jsx +33 -17
- package/src/keys/geometry.js +7 -2
- package/src/keys/misc.js +8 -2
- package/src/latex-bridge.js +223 -7
- package/src/mathlive-instance.js +196 -11
- package/src/mf/common-styles.js +97 -8
- package/src/mf/index.js +4 -0
- package/src/mf/input.jsx +42 -5
- package/src/mf/static.jsx +124 -6
- package/CHANGELOG.md +0 -30
- package/LICENSE.md +0 -5
package/lib/keypad/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_Button","_IconButton","_styles","_debug","_lodashEs","_renderUi","_keys","_keysLayout","_commonStyles","_mathliveInstance","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","Boolean","prototype","valueOf","call","log","debug","LabelHolder","styled","pointerEvents","textTransform","color","text","display","alignItems","justifyContent","lineHeight","maxWidth","overflow","position","width","backgroundColor","keypadEmptyPlaceholder","undefined","opacity","LatexLabel","exports","_React$Component","props","_this","_classCallCheck2","state","markup","latexToMarkup","latex","_inherits2","_createClass2","key","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_context","prev","next","abrupt","loadMathLive","unmounted","setState","warned","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","dangerouslySetInnerHTML","__html","React","Component","PropTypes","string","isRequired","createCustomLayout","layoutObj","gridTemplateColumns","concat","columns","gridTemplateRows","rows","gridAutoFlow","KeyPadContainer","commonKeyboardStyles","gridRowGap","gridColumnGap","fontFamily","buttonBackground","category","keypadButtonOperator","keypadButton","keypadButtonOperatorHover","keypadButtonHover","StyledButton","Button","_ref","isDelete","isComma","isDot","minWidth","fontSize","borderRadius","StyledLatexButtonWrapper","_ref2","padding","margin","StyledIconButton","IconButton","_ref3","height","KeyPad","_React$Component2","_this2","setKeypadInteraction","onPress","base","extras","flatten","_toConsumableArray2","sortKeys","noDecimal","write","label","keypadRef","createRef","_this$keypadRef","keyPadElement","current","mainContainer","closest","currentToolbar","controlledKeypadMode","mainContainerPosition","getBoundingClientRect","currentToolbarPosition","difference","top","totalHeight","style","addEventListener","handleKeypadInteraction","_this$keypadRef2","removeEventListener","_this3","_this$props","className","baseSet","additionalKeys","layoutForKeyPad","onFocus","mode","noBaseSet","keysWithoutBaseSet","includes","allKeys","flowKeys","shift","Math","floor","ref","join","map","k","index","command","extra","actions","extraProps","onClick","buttonClick","bind","disabled","keyIsNotAllowed","ariaLabel","name","_extends2","Icon","icon","tabIndex","size","bool","array","object","func","oneOfType","number","_default"],"sources":["../../src/keypad/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport { flatten } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nimport { baseSet } from '../keys';\nimport { sortKeys } from './keys-layout';\nimport { commonKeyboardStyles } from '../mf/common-styles';\nimport { loadMathLive, latexToMarkup } from '../mathlive-instance';\n\nconst log = debug('pie-lib:math-input-mathlive:keypad');\n\n/**\n * A LaTeX keypad label.\n *\n * The MathQuill implementation rendered every LaTeX label as its own\n * `MQ.StaticMath` instance. Here each label is static HTML produced once by\n * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math\n * instances.\n */\n// The `color.*()` helpers must be called lazily, inside the styled callback.\n// Evaluating them in a plain object literal runs them at module load, which\n// breaks any consumer that mocks a subset of @pie-lib/render-ui.\nconst LabelHolder = styled('span')(() => ({\n pointerEvents: 'none',\n textTransform: 'none',\n color: color.text(),\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n lineHeight: 1,\n // Never let a label size its grid column. Stretchy accents\n // (\\overrightarrow, \\overleftrightarrow, \\overarc) render an <svg> that\n // mathlive-static.css positions absolutely at width:100%; if that stylesheet\n // is missing the svg lays out statically and expands without bound, dragging\n // the whole column across the screen. `overflow: hidden` also collapses the\n // label's min-content contribution, so the grid can't blow out either way.\n maxWidth: '100%',\n overflow: 'hidden',\n '& svg': {\n position: 'absolute',\n width: '100%',\n },\n // Answer-block / empty-slot boxes inside a label.\n '& .ML__placeholder': {\n backgroundColor: color.keypadEmptyPlaceholder ? color.keypadEmptyPlaceholder() : undefined,\n },\n // The stand-in glyph for an empty argument slot (see EMPTY_SLOT). Muted so it\n // reads as \"a slot goes here\" rather than as part of the symbol, matching how\n // MathQuill shaded `.mq-empty`.\n '& [data-pie-empty]': {\n opacity: 0.5,\n },\n}));\n\nexport class LatexLabel extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = { markup: latexToMarkup(props.latex) };\n }\n\n async componentDidMount() {\n // MathLive may not have finished loading when the keypad first mounts.\n if (this.state.markup) {\n return;\n }\n\n await loadMathLive();\n\n if (this.unmounted) {\n return;\n }\n\n const markup = latexToMarkup(this.props.latex);\n\n if (markup) {\n this.setState({ markup });\n return;\n }\n\n // Still nothing: the engine is genuinely unavailable (a missing chunk, a\n // blocked request). Keep the raw-latex fallback visible rather than an\n // empty button, and log once so this is diagnosable.\n if (!LatexLabel.warned) {\n LatexLabel.warned = true;\n log('MathLive unavailable - keypad labels are falling back to raw latex');\n }\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex !== this.props.latex) {\n this.setState({ markup: latexToMarkup(this.props.latex) });\n }\n }\n\n componentWillUnmount() {\n this.unmounted = true;\n }\n\n render() {\n const { markup } = this.state;\n\n // Fall back to the raw latex so a button is never blank.\n return markup ? (\n // eslint-disable-next-line react/no-danger\n <LabelHolder dangerouslySetInnerHTML={{ __html: markup }} />\n ) : (\n <LabelHolder>{this.props.latex}</LabelHolder>\n );\n }\n}\n\nconst createCustomLayout = (layoutObj) => {\n if (layoutObj) {\n return {\n gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,\n gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,\n gridAutoFlow: 'initial',\n };\n }\n\n return {};\n};\n\nconst KeyPadContainer = styled('div')(() => ({\n ...commonKeyboardStyles,\n width: '100%',\n display: 'grid',\n gridTemplateRows: 'repeat(5, minmax(40px, 60px))',\n gridRowGap: '0px',\n gridColumnGap: '0px',\n gridAutoFlow: 'column',\n '&.character': {\n textTransform: 'initial !important',\n gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',\n },\n '&.language': {\n gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n}));\n\nconst buttonBackground = (category) => ({\n backgroundColor: category === 'operators' ? color.keypadButtonOperator() : color.keypadButton(),\n '&:hover': {\n backgroundColor: category === 'operators' ? color.keypadButtonOperatorHover() : color.keypadButtonHover(),\n },\n});\n\nconst StyledButton = styled(Button)(({ category, isDelete, isComma, isDot }) => ({\n minWidth: 'auto',\n textTransform: 'none',\n fontSize: isComma || isDot ? '200% !important' : '140% !important',\n lineHeight: isComma || isDot ? '100%' : 'normal',\n color: color.text(),\n ...buttonBackground(category),\n borderRadius: 0,\n ...(isDelete && {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n }),\n}));\n\nconst StyledLatexButtonWrapper = styled(Button)(({ category }) => ({\n textTransform: 'none',\n padding: 0,\n margin: 0,\n fontSize: '110% !important',\n minWidth: 'auto',\n borderRadius: 0,\n ...buttonBackground(category),\n}));\n\nconst StyledIconButton = styled(IconButton)(({ category }) => ({\n minWidth: 'auto',\n ...buttonBackground(category),\n borderRadius: 0,\n '& .icon': {\n height: '30px',\n },\n}));\n\nexport class KeyPad extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n controlledKeypadMode: PropTypes.bool,\n baseSet: PropTypes.array,\n additionalKeys: PropTypes.array,\n layoutForKeyPad: PropTypes.object,\n onPress: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n noDecimal: PropTypes.bool,\n setKeypadInteraction: PropTypes.func,\n mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n };\n\n static defaultProps = {\n baseSet: baseSet,\n noDecimal: false,\n };\n\n constructor(props) {\n super(props);\n this.keypadRef = React.createRef();\n }\n\n componentDidMount() {\n // Ensure MathLive is available for the LaTeX labels.\n loadMathLive();\n\n const keyPadElement = this.keypadRef?.current;\n const mainContainer = keyPadElement?.closest('.main-container');\n const currentToolbar = keyPadElement?.closest('.pie-toolbar');\n\n // need only for math keyboard so we need also controlledKeypadMode\n if (this.props.controlledKeypadMode && mainContainer && currentToolbar) {\n const mainContainerPosition = mainContainer.getBoundingClientRect();\n const currentToolbarPosition = currentToolbar.getBoundingClientRect();\n const difference =\n mainContainerPosition.top +\n mainContainerPosition.height -\n (currentToolbarPosition.top + currentToolbarPosition.height);\n\n if (difference < 0) {\n const totalHeight = mainContainerPosition.height + mainContainerPosition.top - difference;\n\n mainContainer.style.height = `${totalHeight}px`;\n }\n }\n\n if (keyPadElement) {\n keyPadElement.addEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.addEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n componentWillUnmount() {\n const keyPadElement = this.keypadRef?.current;\n\n if (this.props.controlledKeypadMode && keyPadElement) {\n const mainContainer = keyPadElement.closest('.main-container');\n\n if (mainContainer) {\n mainContainer.style.height = 'unset';\n }\n }\n\n if (keyPadElement) {\n keyPadElement.removeEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.removeEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n handleKeypadInteraction = () => {\n if (this.props.setKeypadInteraction) {\n this.props.setKeypadInteraction(true);\n }\n };\n\n buttonClick = (key) => {\n log('[buttonClick]', key);\n this.props.onPress(key);\n };\n\n flowKeys = (base, extras) => flatten([...sortKeys(base), ...sortKeys(extras)]);\n\n keyIsNotAllowed = (key) => {\n const { noDecimal } = this.props;\n\n return !!(((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) && noDecimal);\n };\n\n render() {\n const { className, baseSet: base, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;\n\n const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];\n const keysWithoutBaseSet = noBaseSet.includes(mode);\n const allKeys = keysWithoutBaseSet\n ? this.flowKeys([], additionalKeys || [])\n : this.flowKeys(base, additionalKeys || []);\n\n const shift = allKeys.length % 5 ? 1 : 0;\n const style = {\n gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) + shift}, minmax(min-content, 150px))`,\n ...createCustomLayout(layoutForKeyPad),\n };\n\n return (\n <KeyPadContainer\n ref={this.keypadRef}\n className={[className, mode].filter(Boolean).join(' ')}\n style={style}\n onFocus={onFocus}\n >\n {allKeys.map((k, index) => {\n if (!k) {\n return <span key={`empty-${index}`} />;\n }\n\n const key = `${k.label || k.latex || k.command}-${index}`;\n const category = !keysWithoutBaseSet ? k.category : undefined;\n const extra = { ...(k.actions || {}), ...(k.extraProps || {}) };\n const onClick = this.buttonClick.bind(this, k);\n const disabled = this.keyIsNotAllowed(k);\n const ariaLabel = k.ariaLabel ? k.ariaLabel : k.name || k.label;\n\n if (k.latex) {\n return (\n <StyledLatexButtonWrapper\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n aria-label={ariaLabel}\n {...extra}\n >\n <LatexLabel latex={k.latex} />\n </StyledLatexButtonWrapper>\n );\n }\n\n if (k.label) {\n return (\n <StyledButton\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n isDelete={k.label === '⌫'}\n isComma={k.label === ','}\n isDot={k.label === '.'}\n aria-label={ariaLabel}\n {...extra}\n >\n {k.label}\n </StyledButton>\n );\n }\n\n const Icon = k.icon ? k.icon : 'div';\n\n return (\n <StyledIconButton\n key={key}\n tabIndex={'-1'}\n onClick={onClick}\n disabled={disabled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AACgH,IAAI;EACpCjC,IAAI,EAAE/E,qBAAS,CAACiH,SAAS,CAAC,CAACjH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACkH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAA5L,gBAAA,aAZUiH,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAAzJ,OAAA,cAiKY6E,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_Button","_IconButton","_styles","_debug","_lodashEs","_renderUi","_keys","_keysLayout","_commonStyles","_mathliveInstance","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","ownKeys","r","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","log","debug","SLANTED_LABELS","SLANT","SLANTED_STROKE","SLANTED_SCALE_Y","LabelHolder","styled","shouldForwardProp","prop","_ref","slanted","transform","concat","WebkitTextStroke","pointerEvents","textTransform","color","text","display","textAlign","lineHeight","maxWidth","overflow","backgroundColor","keypadEmptyPlaceholder","undefined","opacity","rootIndexStyles","LatexLabel","exports","_React$Component","props","_this","_classCallCheck2","state","markup","latexToMarkup","latex","_inherits2","_createClass2","key","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_context","prev","next","abrupt","loadMathLive","unmounted","setState","warned","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","includes","dangerouslySetInnerHTML","__html","React","Component","PropTypes","string","isRequired","createCustomLayout","layoutObj","gridTemplateColumns","columns","gridTemplateRows","rows","gridAutoFlow","KeyPadContainer","commonKeyboardStyles","width","gridRowGap","gridColumnGap","fontFamily","buttonBackground","category","keypadButtonOperator","keypadButton","keypadButtonOperatorHover","keypadButtonHover","StyledButton","Button","_ref2","isDelete","isComma","isDot","minWidth","fontSize","borderRadius","StyledLatexButtonWrapper","_ref3","padding","margin","StyledIconButton","IconButton","_ref4","height","KeyPad","_React$Component2","_this2","setKeypadInteraction","onPress","base","extras","flatten","_toConsumableArray2","sortKeys","noDecimal","write","label","keypadRef","createRef","_this$keypadRef","keyPadElement","current","mainContainer","closest","currentToolbar","controlledKeypadMode","mainContainerPosition","getBoundingClientRect","currentToolbarPosition","difference","top","totalHeight","style","addEventListener","handleKeypadInteraction","_this$keypadRef2","removeEventListener","_this3","_this$props","className","baseSet","additionalKeys","layoutForKeyPad","onFocus","mode","noBaseSet","keysWithoutBaseSet","allKeys","flowKeys","shift","Math","floor","ref","join","map","k","index","command","extra","actions","extraProps","onClick","buttonClick","bind","disabled","keyIsNotAllowed","ariaLabel","name","_extends2","Icon","icon","tabIndex","size","bool","array","object","func","oneOfType","number","_default"],"sources":["../../src/keypad/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport { flatten } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nimport { baseSet } from '../keys';\nimport { sortKeys } from './keys-layout';\nimport { commonKeyboardStyles, rootIndexStyles } from '../mf/common-styles';\nimport { loadMathLive, latexToMarkup } from '../mathlive-instance';\n\nconst log = debug('pie-lib:math-input-mathlive:keypad');\n\n/**\n * A LaTeX keypad label.\n *\n * The MathQuill implementation rendered every LaTeX label as its own\n * `MQ.StaticMath` instance. Here each label is static HTML produced once by\n * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math\n * instances.\n */\n// Labels that the legacy keypad drew slanted. MathQuill styled `\\parallel` as\n// italic, which slants the two bars; MathLive draws it upright. A skew is used\n// rather than `font-style: italic` so the slant does not depend on the font\n// having an italic face for this glyph.\nconst SLANTED_LABELS = ['\\\\parallel'];\nconst SLANT = 'skewX(-15deg)';\n// MathLive's `∥` has hairline bars next to the radical sign and the other keys, so\n// they are thickened with a text stroke and stretched a little taller.\nconst SLANTED_STROKE = '0.03em currentColor';\nconst SLANTED_SCALE_Y = 1.25;\n\n// The `color.*()` helpers must be called lazily, inside the styled callback.\n// Evaluating them in a plain object literal runs them at module load, which\n// breaks any consumer that mocks a subset of @pie-lib/render-ui.\nconst LabelHolder = styled('span', { shouldForwardProp: (prop) => prop !== 'slanted' })(({ slanted }) => ({\n ...(slanted && {\n transform: `${SLANT} scaleY(${SLANTED_SCALE_Y})`,\n '& *': { WebkitTextStroke: SLANTED_STROKE },\n }),\n pointerEvents: 'none',\n textTransform: 'none',\n color: color.text(),\n // Deliberately inline-block, NOT inline-flex: MathLive's markup relies on\n // normal inline flow. Making its spans flex items collapses their width, and\n // stretchy accents render an <svg width=\"100%\" preserveAspectRatio=\"none\">\n // that then squeezes into a spike instead of spanning the content.\n display: 'inline-block',\n textAlign: 'center',\n lineHeight: 1,\n // Keep a label from sizing its grid column. `overflow: hidden` also collapses\n // the label's min-content contribution, so a wide accent cannot drag the\n // column across the screen. The svg's own positioning is left to\n // mathlive-static.css (injected by the package) - duplicating it here broke\n // the accent's containing block.\n maxWidth: '100%',\n overflow: 'hidden',\n // Answer-block / empty-slot boxes inside a label.\n '& .ML__placeholder': {\n backgroundColor: color.keypadEmptyPlaceholder ? color.keypadEmptyPlaceholder() : undefined,\n },\n // The stand-in glyph for an empty argument slot (see EMPTY_SLOT). Muted so it\n // reads as \"a slot goes here\" rather than as part of the symbol, matching how\n // MathQuill shaded `.mq-empty`.\n '& [data-pie-empty]': {\n opacity: 0.5,\n },\n // A readable index on the nth-root key. Carried by the label itself, not only\n // by the keypad container, so it holds wherever a LatexLabel is mounted.\n ...rootIndexStyles,\n}));\n\nexport class LatexLabel extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = { markup: latexToMarkup(props.latex) };\n }\n\n async componentDidMount() {\n // MathLive may not have finished loading when the keypad first mounts.\n if (this.state.markup) {\n return;\n }\n\n await loadMathLive();\n\n if (this.unmounted) {\n return;\n }\n\n const markup = latexToMarkup(this.props.latex);\n\n if (markup) {\n this.setState({ markup });\n return;\n }\n\n // Still nothing: the engine is genuinely unavailable (a missing chunk, a\n // blocked request). Keep the raw-latex fallback visible rather than an\n // empty button, and log once so this is diagnosable.\n if (!LatexLabel.warned) {\n LatexLabel.warned = true;\n log('MathLive unavailable - keypad labels are falling back to raw latex');\n }\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex !== this.props.latex) {\n this.setState({ markup: latexToMarkup(this.props.latex) });\n }\n }\n\n componentWillUnmount() {\n this.unmounted = true;\n }\n\n render() {\n const { markup } = this.state;\n\n // Fall back to the raw latex so a button is never blank.\n return markup ? (\n // eslint-disable-next-line react/no-danger\n <LabelHolder slanted={SLANTED_LABELS.includes(this.props.latex)} dangerouslySetInnerHTML={{ __html: markup }} />\n ) : (\n <LabelHolder slanted={SLANTED_LABELS.includes(this.props.latex)}>{this.props.latex}</LabelHolder>\n );\n }\n}\n\nconst createCustomLayout = (layoutObj) => {\n if (layoutObj) {\n return {\n gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,\n gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,\n gridAutoFlow: 'initial',\n };\n }\n\n return {};\n};\n\nconst KeyPadContainer = styled('div')(() => ({\n ...commonKeyboardStyles,\n width: '100%',\n display: 'grid',\n gridTemplateRows: 'repeat(5, minmax(40px, 60px))',\n gridRowGap: '0px',\n gridColumnGap: '0px',\n gridAutoFlow: 'column',\n '&.character': {\n textTransform: 'initial !important',\n gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',\n },\n '&.language': {\n gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n}));\n\nconst buttonBackground = (category) => ({\n backgroundColor: category === 'operators' ? color.keypadButtonOperator() : color.keypadButton(),\n '&:hover': {\n backgroundColor: category === 'operators' ? color.keypadButtonOperatorHover() : color.keypadButtonHover(),\n },\n});\n\nconst StyledButton = styled(Button)(({ category, isDelete, isComma, isDot }) => ({\n minWidth: 'auto',\n textTransform: 'none',\n fontSize: isComma || isDot ? '200% !important' : '140% !important',\n lineHeight: isComma || isDot ? '100%' : 'normal',\n color: color.text(),\n ...buttonBackground(category),\n borderRadius: 0,\n ...(isDelete && {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n }),\n}));\n\nconst StyledLatexButtonWrapper = styled(Button)(({ category }) => ({\n textTransform: 'none',\n padding: 0,\n margin: 0,\n fontSize: '110% !important',\n minWidth: 'auto',\n borderRadius: 0,\n ...buttonBackground(category),\n}));\n\nconst StyledIconButton = styled(IconButton)(({ category }) => ({\n minWidth: 'auto',\n ...buttonBackground(category),\n borderRadius: 0,\n '& .icon': {\n height: '30px',\n },\n}));\n\nexport class KeyPad extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n controlledKeypadMode: PropTypes.bool,\n baseSet: PropTypes.array,\n additionalKeys: PropTypes.array,\n layoutForKeyPad: PropTypes.object,\n onPress: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n noDecimal: PropTypes.bool,\n setKeypadInteraction: PropTypes.func,\n mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n };\n\n static defaultProps = {\n baseSet: baseSet,\n noDecimal: false,\n };\n\n constructor(props) {\n super(props);\n this.keypadRef = React.createRef();\n }\n\n componentDidMount() {\n // Ensure MathLive is available for the LaTeX labels.\n loadMathLive();\n\n const keyPadElement = this.keypadRef?.current;\n const mainContainer = keyPadElement?.closest('.main-container');\n const currentToolbar = keyPadElement?.closest('.pie-toolbar');\n\n // need only for math keyboard so we need also controlledKeypadMode\n if (this.props.controlledKeypadMode && mainContainer && currentToolbar) {\n const mainContainerPosition = mainContainer.getBoundingClientRect();\n const currentToolbarPosition = currentToolbar.getBoundingClientRect();\n const difference =\n mainContainerPosition.top +\n mainContainerPosition.height -\n (currentToolbarPosition.top + currentToolbarPosition.height);\n\n if (difference < 0) {\n const totalHeight = mainContainerPosition.height + mainContainerPosition.top - difference;\n\n mainContainer.style.height = `${totalHeight}px`;\n }\n }\n\n if (keyPadElement) {\n keyPadElement.addEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.addEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n componentWillUnmount() {\n const keyPadElement = this.keypadRef?.current;\n\n if (this.props.controlledKeypadMode && keyPadElement) {\n const mainContainer = keyPadElement.closest('.main-container');\n\n if (mainContainer) {\n mainContainer.style.height = 'unset';\n }\n }\n\n if (keyPadElement) {\n keyPadElement.removeEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.removeEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n handleKeypadInteraction = () => {\n if (this.props.setKeypadInteraction) {\n this.props.setKeypadInteraction(true);\n }\n };\n\n buttonClick = (key) => {\n log('[buttonClick]', key);\n this.props.onPress(key);\n };\n\n flowKeys = (base, extras) => flatten([...sortKeys(base), ...sortKeys(extras)]);\n\n keyIsNotAllowed = (key) => {\n const { noDecimal } = this.props;\n\n return !!(((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) && noDecimal);\n };\n\n render() {\n const { className, baseSet: base, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;\n\n const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];\n const keysWithoutBaseSet = noBaseSet.includes(mode);\n const allKeys = keysWithoutBaseSet\n ? this.flowKeys([], additionalKeys || [])\n : this.flowKeys(base, additionalKeys || []);\n\n const shift = allKeys.length % 5 ? 1 : 0;\n const style = {\n gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) + shift}, minmax(min-content, 150px))`,\n ...createCustomLayout(layoutForKeyPad),\n };\n\n return (\n <KeyPadContainer\n ref={this.keypadRef}\n className={[className, mode].filter(Boolean).join(' ')}\n style={style}\n onFocus={onFocus}\n >\n {allKeys.map((k, index) => {\n if (!k) {\n return <span key={`empty-${index}`} />;\n }\n\n const key = `${k.label || k.latex || k.command}-${index}`;\n const category = !keysWithoutBaseSet ? k.category : undefined;\n const extra = { ...(k.actions || {}), ...(k.extraProps || {}) };\n const onClick = this.buttonClick.bind(this, k);\n const disabled = this.keyIsNotAllowed(k);\n const ariaLabel = k.ariaLabel ? k.ariaLabel : k.name || k.label;\n\n if (k.latex) {\n return (\n <StyledLatexButtonWrapper\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n aria-label={ariaLabel}\n {...extra}\n >\n <LatexLabel latex={k.latex} />\n </StyledLatexButtonWrapper>\n );\n }\n\n if (k.label) {\n return (\n <StyledButton\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n isDelete={k.label === '⌫'}\n isComma={k.label === ','}\n isDot={k.label === '.'}\n aria-label={ariaLabel}\n {...extra}\n >\n {k.label}\n </StyledButton>\n );\n }\n\n const Icon = k.icon ? k.icon : 'div';\n\n return (\n <StyledIconButton\n key={key}\n tabIndex={'-1'}\n onClick={onClick}\n disabled={disabled}\n category={category}\n size=\"large\"\n {...extra}\n >\n <Icon className=\"icon\" />\n </StyledIconButton>\n );\n })}\n </KeyPadContainer>\n );\n }\n}\n\nexport default KeyPad;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;A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AAC7G,UAAU;EAClC4E,OAAO,EAAE9E,qBAAS,CAAC+G,IAAI;EACvB9D,SAAS,EAAEjD,qBAAS,CAAC4G,IAAI;EACzBlE,oBAAoB,EAAE1C,qBAAS,CAAC+G,IAAI;EACpChC,IAAI,EAAE/E,qBAAS,CAACgH,SAAS,CAAC,CAAChH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACiH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAA1L,gBAAA,aAZUgH,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAiE,QAAA,GAAAzJ,OAAA,cAiKY8E,MAAM","ignoreList":[]}
|
package/lib/keys/geometry.js
CHANGED
|
@@ -25,8 +25,10 @@ var overRightArrow = exports.overRightArrow = set({
|
|
|
25
25
|
});
|
|
26
26
|
var overLeftRightArrow = exports.overLeftRightArrow = set({
|
|
27
27
|
name: 'Segment',
|
|
28
|
-
|
|
29
|
-
//
|
|
28
|
+
// MathQuill needed a nested \overline{} to draw the empty box; MathLive
|
|
29
|
+
// renders that as a real line, so the label showed a spurious bar under the
|
|
30
|
+
// arrows. `withVisibleEmptySlots` supplies the box for `{}` instead.
|
|
31
|
+
latex: '\\overleftrightarrow{}',
|
|
30
32
|
symbol: 'AB',
|
|
31
33
|
command: '\\overleftrightarrow'
|
|
32
34
|
});
|
|
@@ -58,8 +60,9 @@ var angle = exports.angle = set({
|
|
|
58
60
|
});
|
|
59
61
|
var overArc = exports.overArc = set({
|
|
60
62
|
name: 'Over arc',
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
+
// See the note on Segment above: the nested \overline{} drew a straight line
|
|
64
|
+
// instead of leaving the arc visible.
|
|
65
|
+
latex: '\\overarc{}',
|
|
63
66
|
command: '\\overarc'
|
|
64
67
|
});
|
|
65
68
|
var measureOfAngle = exports.measureOfAngle = set({
|
package/lib/keys/geometry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","names":["set","o","_objectSpread","category","overline","exports","name","latex","command","overRightArrow","overLeftRightArrow","symbol","segment","write","label","parallel","notParallel","perpindicular","angle","overArc","measureOfAngle","triangle","square","parallelogram","circledDot","degree","similarTo","congruentTo","notCongruentTo","primeArcminute","doublePrimeArcSecond","leftArrow","rightArrow","leftrightArrow"],"sources":["../../src/keys/geometry.js"],"sourcesContent":["const set = (o) => ({ ...o, category: 'geometry' });\n\nexport const overline = set({\n name: 'Line',\n latex: '\\\\overline{}',\n command: '\\\\overline',\n});\n\nexport const overRightArrow = set({\n name: 'Ray',\n latex: '\\\\overrightarrow{}',\n command: '\\\\overrightarrow',\n});\n\nexport const overLeftRightArrow = set({\n name: 'Segment',\n
|
|
1
|
+
{"version":3,"file":"geometry.js","names":["set","o","_objectSpread","category","overline","exports","name","latex","command","overRightArrow","overLeftRightArrow","symbol","segment","write","label","parallel","notParallel","perpindicular","angle","overArc","measureOfAngle","triangle","square","parallelogram","circledDot","degree","similarTo","congruentTo","notCongruentTo","primeArcminute","doublePrimeArcSecond","leftArrow","rightArrow","leftrightArrow"],"sources":["../../src/keys/geometry.js"],"sourcesContent":["const set = (o) => ({ ...o, category: 'geometry' });\n\nexport const overline = set({\n name: 'Line',\n latex: '\\\\overline{}',\n command: '\\\\overline',\n});\n\nexport const overRightArrow = set({\n name: 'Ray',\n latex: '\\\\overrightarrow{}',\n command: '\\\\overrightarrow',\n});\n\nexport const overLeftRightArrow = set({\n name: 'Segment',\n // MathQuill needed a nested \\overline{} to draw the empty box; MathLive\n // renders that as a real line, so the label showed a spurious bar under the\n // arrows. `withVisibleEmptySlots` supplies the box for `{}` instead.\n latex: '\\\\overleftrightarrow{}',\n symbol: 'AB',\n command: '\\\\overleftrightarrow',\n});\n\nexport const segment = set({\n name: 'Segment',\n latex: '\\\\overleftrightarrow{AB}',\n write: '\\\\overleftrightarrow{AB}',\n label: 'AB',\n});\n\nexport const parallel = set({\n name: 'Parallel',\n latex: '\\\\parallel',\n command: '\\\\parallel',\n});\n\nexport const notParallel = set({\n name: 'Not Parallel',\n latex: '\\\\nparallel',\n command: '\\\\nparallel',\n});\n\nexport const perpindicular = set({\n name: 'Perpendicular',\n latex: '\\\\perp',\n command: '\\\\perpendicular',\n});\n\nexport const angle = set({\n name: 'Angle',\n latex: '\\\\angle',\n command: '\\\\angle',\n});\nexport const overArc = set({\n name: 'Over arc',\n // See the note on Segment above: the nested \\overline{} drew a straight line\n // instead of leaving the arc visible.\n latex: '\\\\overarc{}',\n command: '\\\\overarc',\n});\nexport const measureOfAngle = set({\n name: 'Measured Angle',\n latex: '\\\\measuredangle',\n command: ['m', '\\\\angle'],\n});\n\nexport const triangle = set({\n name: 'Triangle',\n latex: '\\\\triangle',\n command: '\\\\triangle',\n});\n\nexport const square = set({\n name: 'Square',\n latex: '\\\\square',\n command: '\\\\square',\n});\n\nexport const parallelogram = set({\n name: 'Parallelogram',\n latex: '\\\\parallelogram',\n command: '\\\\parallelogram',\n});\n\nexport const circledDot = set({\n name: 'Circled Dot',\n latex: '\\\\odot',\n command: '\\\\odot',\n});\n\nexport const degree = set({\n name: 'Degree',\n latex: '\\\\degree',\n command: '\\\\degree',\n});\n\nexport const similarTo = set({\n name: 'Similar',\n command: '\\\\sim',\n latex: '\\\\sim',\n});\n\nexport const congruentTo = set({\n name: 'Congruent To',\n command: '\\\\cong',\n latex: '\\\\cong',\n});\n\nexport const notCongruentTo = set({\n name: 'Not Congruent To',\n command: '\\\\ncong',\n latex: '\\\\ncong',\n});\n\nexport const primeArcminute = set({\n name: 'Prime',\n label: 'pam',\n // eslint-disable-next-line\n latex: \"'\",\n // eslint-disable-next-line\n write: \"'\",\n});\n\nexport const doublePrimeArcSecond = set({\n name: 'Double Prime',\n // eslint-disable-next-line\n latex: \"''\",\n // eslint-disable-next-line\n write: \"''\",\n});\n\nexport const leftArrow = set({\n name: 'Left Arrow',\n latex: '\\\\leftarrow',\n command: '\\\\leftarrow',\n});\n\nexport const rightArrow = set({\n name: 'Right Arrow',\n latex: '\\\\rightarrow',\n command: '\\\\rightarrow',\n});\n\nexport const leftrightArrow = set({\n name: 'Left and Right Arrow',\n latex: '\\\\leftrightarrow',\n command: '\\\\leftrightarrow',\n});\n"],"mappings":";;;;;;;;;;AAAA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAIC,CAAC;EAAA,OAAAC,aAAA,CAAAA,aAAA,KAAWD,CAAC;IAAEE,QAAQ,EAAE;EAAU;AAAA,CAAG;AAE5C,IAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGJ,GAAG,CAAC;EAC1BM,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,cAAc;EACrBC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMC,cAAc,GAAAJ,OAAA,CAAAI,cAAA,GAAGT,GAAG,CAAC;EAChCM,IAAI,EAAE,KAAK;EACXC,KAAK,EAAE,oBAAoB;EAC3BC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAME,kBAAkB,GAAAL,OAAA,CAAAK,kBAAA,GAAGV,GAAG,CAAC;EACpCM,IAAI,EAAE,SAAS;EACf;EACA;EACA;EACAC,KAAK,EAAE,wBAAwB;EAC/BI,MAAM,EAAE,IAAI;EACZH,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMI,OAAO,GAAAP,OAAA,CAAAO,OAAA,GAAGZ,GAAG,CAAC;EACzBM,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,0BAA0B;EACjCM,KAAK,EAAE,0BAA0B;EACjCC,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMC,QAAQ,GAAAV,OAAA,CAAAU,QAAA,GAAGf,GAAG,CAAC;EAC1BM,IAAI,EAAE,UAAU;EAChBC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMQ,WAAW,GAAAX,OAAA,CAAAW,WAAA,GAAGhB,GAAG,CAAC;EAC7BM,IAAI,EAAE,cAAc;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AAE;AACX,CAAC,CAAC;AAEK,IAAMwB,UAAU,GAAA3B,OAAA,CAAA2B,UAAA,GAAGhC,GAAG,CAAC;EAC5BM,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,cAAc;EACrBC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMyB,cAAc,GAAA5B,OAAA,CAAA4B,cAAA,GAAGjC,GAAG,CAAC;EAChCM,IAAI,EAAE,sBAAsB;EAC5BC,KAAK,EAAE,kBAAkB;EACzBC,OAAO,EAAE;AACX,CAAC,CAAC","ignoreList":[]}
|
package/lib/keys/misc.js
CHANGED
|
@@ -29,10 +29,17 @@ var brackets = exports.brackets = set({
|
|
|
29
29
|
symbol: '[ ]',
|
|
30
30
|
command: '['
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
// `%` must be escaped. MathQuill was not a real LaTeX parser: it defined
|
|
34
|
+
// `LatexCmds['%']` as a symbol that *serialised* to `\%`, so a bare `%` worked
|
|
35
|
+
// both as a label and as a command. MathLive parses LaTeX properly, where `%`
|
|
36
|
+
// begins a comment - it rendered nothing (a blank button) and, once inserted,
|
|
37
|
+
// silently swallowed the rest of the expression. `\%` is what MathQuill stored
|
|
38
|
+
// all along, so this changes the key only, not the saved latex.
|
|
32
39
|
var percentage = exports.percentage = set({
|
|
33
40
|
name: 'Percent',
|
|
34
|
-
latex: '
|
|
35
|
-
command: '
|
|
41
|
+
latex: '\\%',
|
|
42
|
+
command: '\\%'
|
|
36
43
|
});
|
|
37
44
|
var approx = exports.approx = set({
|
|
38
45
|
latex: '\\approx',
|
package/lib/keys/misc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.js","names":["_utils","require","set","mkSet","plusMinus","exports","name","latex","write","absValue","symbol","command","parenthesis","brackets","percentage","approx","ariaLabel","nApprox","notEqual","similar","notSimilar"],"sources":["../../src/keys/misc.js"],"sourcesContent":["import { mkSet } from './utils';\n\nconst set = mkSet('misc');\n\nexport const plusMinus = set({\n name: 'Plus or Minus',\n latex: '\\\\pm',\n write: '\\\\pm',\n});\n\nexport const absValue = set({\n name: 'Absolute Value',\n latex: '\\\\abs{}',\n symbol: '| |',\n command: '|',\n});\n\nexport const parenthesis = set({\n name: 'Parenthesis',\n latex: '\\\\left(\\\\right)',\n symbol: '( )',\n command: '(',\n});\n\nexport const brackets = set({\n name: 'Brackets',\n latex: '\\\\left[\\\\right]',\n symbol: '[ ]',\n command: '[',\n});\n\nexport const percentage = set({\n name: 'Percent',\n latex: '
|
|
1
|
+
{"version":3,"file":"misc.js","names":["_utils","require","set","mkSet","plusMinus","exports","name","latex","write","absValue","symbol","command","parenthesis","brackets","percentage","approx","ariaLabel","nApprox","notEqual","similar","notSimilar"],"sources":["../../src/keys/misc.js"],"sourcesContent":["import { mkSet } from './utils';\n\nconst set = mkSet('misc');\n\nexport const plusMinus = set({\n name: 'Plus or Minus',\n latex: '\\\\pm',\n write: '\\\\pm',\n});\n\nexport const absValue = set({\n name: 'Absolute Value',\n latex: '\\\\abs{}',\n symbol: '| |',\n command: '|',\n});\n\nexport const parenthesis = set({\n name: 'Parenthesis',\n latex: '\\\\left(\\\\right)',\n symbol: '( )',\n command: '(',\n});\n\nexport const brackets = set({\n name: 'Brackets',\n latex: '\\\\left[\\\\right]',\n symbol: '[ ]',\n command: '[',\n});\n\n// `%` must be escaped. MathQuill was not a real LaTeX parser: it defined\n// `LatexCmds['%']` as a symbol that *serialised* to `\\%`, so a bare `%` worked\n// both as a label and as a command. MathLive parses LaTeX properly, where `%`\n// begins a comment - it rendered nothing (a blank button) and, once inserted,\n// silently swallowed the rest of the expression. `\\%` is what MathQuill stored\n// all along, so this changes the key only, not the saved latex.\nexport const percentage = set({\n name: 'Percent',\n latex: '\\\\%',\n command: '\\\\%',\n});\n\nexport const approx = set({\n latex: '\\\\approx',\n command: '\\\\approx',\n ariaLabel: 'Approximately equal to',\n});\n\nexport const nApprox = set({\n latex: '\\\\napprox',\n command: '\\\\napprox',\n ariaLabel: 'Not pproximately equal to',\n});\n\nexport const notEqual = set({\n latex: '\\\\neq',\n command: '\\\\neq',\n ariaLabel: 'Not equals',\n});\n\nexport const similar = set({\n latex: '\\\\sim',\n command: '\\\\sim',\n ariaLabel: 'Similar',\n});\nexport const notSimilar = set({\n latex: '\\\\nsim',\n command: '\\\\nsim',\n ariaLabel: 'Not similar',\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAMC,GAAG,GAAG,IAAAC,YAAK,EAAC,MAAM,CAAC;AAElB,IAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAGF,GAAG,CAAC;EAC3BI,IAAI,EAAE,eAAe;EACrBC,KAAK,EAAE,MAAM;EACbC,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMC,QAAQ,GAAAJ,OAAA,CAAAI,QAAA,GAAGP,GAAG,CAAC;EAC1BI,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,SAAS;EAChBG,MAAM,EAAE,KAAK;EACbC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMC,WAAW,GAAAP,OAAA,CAAAO,WAAA,GAAGV,GAAG,CAAC;EAC7BI,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,iBAAiB;EACxBG,MAAM,EAAE,KAAK;EACbC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAME,QAAQ,GAAAR,OAAA,CAAAQ,QAAA,GAAGX,GAAG,CAAC;EAC1BI,IAAI,EAAE,UAAU;EAChBC,KAAK,EAAE,iBAAiB;EACxBG,MAAM,EAAE,KAAK;EACbC,OAAO,EAAE;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACO,IAAMG,UAAU,GAAAT,OAAA,CAAAS,UAAA,GAAGZ,GAAG,CAAC;EAC5BI,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,KAAK;EACZI,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMI,MAAM,GAAAV,OAAA,CAAAU,MAAA,GAAGb,GAAG,CAAC;EACxBK,KAAK,EAAE,UAAU;EACjBI,OAAO,EAAE,UAAU;EACnBK,SAAS,EAAE;AACb,CAAC,CAAC;AAEK,IAAMC,OAAO,GAAAZ,OAAA,CAAAY,OAAA,GAAGf,GAAG,CAAC;EACzBK,KAAK,EAAE,WAAW;EAClBI,OAAO,EAAE,WAAW;EACpBK,SAAS,EAAE;AACb,CAAC,CAAC;AAEK,IAAME,QAAQ,GAAAb,OAAA,CAAAa,QAAA,GAAGhB,GAAG,CAAC;EAC1BK,KAAK,EAAE,OAAO;EACdI,OAAO,EAAE,OAAO;EAChBK,SAAS,EAAE;AACb,CAAC,CAAC;AAEK,IAAMG,OAAO,GAAAd,OAAA,CAAAc,OAAA,GAAGjB,GAAG,CAAC;EACzBK,KAAK,EAAE,OAAO;EACdI,OAAO,EAAE,OAAO;EAChBK,SAAS,EAAE;AACb,CAAC,CAAC;AACK,IAAMI,UAAU,GAAAf,OAAA,CAAAe,UAAA,GAAGlB,GAAG,CAAC;EAC5BK,KAAK,EAAE,QAAQ;EACfI,OAAO,EAAE,QAAQ;EACjBK,SAAS,EAAE;AACb,CAAC,CAAC","ignoreList":[]}
|
package/lib/latex-bridge.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.withVisibleEmptySlots = exports.toNativeCommands = exports.toMathLive = exports.keyToAction = exports.fromMathLive = exports.fieldIds = exports.NEWLINE_EMBED = exports.KEYSTROKES = exports.DEFAULT_FIELD_ID = exports.COMMANDS_WITH_ARGS = void 0;
|
|
6
|
+
exports.withVisibleEmptySlots = exports.toNativeCommands = exports.toMathLive = exports.toCanonicalCommands = exports.keyToAction = exports.fromMathLive = exports.fieldIds = exports.NEWLINE_EMBED = exports.MATHQUILL_ALIASES = exports.KEYSTROKES = exports.DEFAULT_FIELD_ID = exports.COMMANDS_WITH_ARGS = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* LaTeX translation layer between the MathQuill-era content model and MathLive.
|
|
9
9
|
*
|
|
@@ -61,12 +61,49 @@ var DEFAULT_FIELD_ID = exports.DEFAULT_FIELD_ID = 'r1';
|
|
|
61
61
|
*
|
|
62
62
|
* `\placeholder{}` is not usable here: in static markup it renders as a
|
|
63
63
|
* non-breaking space, because its editable box only exists inside a live
|
|
64
|
-
* mathfield. So
|
|
64
|
+
* mathfield. So something with real width is required.
|
|
65
|
+
*
|
|
66
|
+
* It must be a `\rule`, not a unicode glyph. A glyph's width comes from font
|
|
67
|
+
* metrics, and U+25AB is not in the KaTeX fonts - the browser substitutes a
|
|
68
|
+
* wider fallback while MathLive still sizes surrounding accents from its own
|
|
69
|
+
* metrics. That left stretchy accents (`\overarc`, `\overleftrightarrow`)
|
|
70
|
+
* visibly narrower than the box they were meant to span. A rule carries an
|
|
71
|
+
* explicit em width, so accents size correctly - and a filled box is closer to
|
|
72
|
+
* MathQuill's `.mq-empty` anyway.
|
|
65
73
|
*
|
|
66
74
|
* Live mathfields need none of this - MathLive manages empty slots itself.
|
|
67
75
|
*/
|
|
68
|
-
var EMPTY_SLOT =
|
|
76
|
+
var EMPTY_SLOT = '\\htmlData{pie-empty=1}{\\rule{0.55em}{0.55em}}';
|
|
69
77
|
var EMPTY_GROUP_REGEX = /\{\s*\}/g;
|
|
78
|
+
// The segment key (`\overline{}`). The keypad centres every label in its cell, and
|
|
79
|
+
// a thin bar is a much shorter label than the ray and line keys' stretchy arrows,
|
|
80
|
+
// so by default both its bar and its box sit off from theirs: the bar is lower
|
|
81
|
+
// than the arrows' shafts, and the box higher than theirs. Two zero-width struts
|
|
82
|
+
// fix that, found by rendering the three keys at 14-28px and measuring:
|
|
83
|
+
// - inside the bar, above the box: pushes the bar up to the height of the
|
|
84
|
+
// arrows' shafts (the bar-to-box distance then matches theirs);
|
|
85
|
+
// - before the bar, from the baseline: raises the label's top, which moves the
|
|
86
|
+
// whole label down so the box lands where theirs does.
|
|
87
|
+
var EMPTY_OVERLINE_REGEX = /\\overline\{\s*\}/g;
|
|
88
|
+
var EMPTY_OVERLINE_BAR_STRUT = '\\rule{0em}{0.87em}';
|
|
89
|
+
var EMPTY_OVERLINE_LABEL_STRUT = '\\rule{0em}{1.3em}';
|
|
90
|
+
// Empty delimiter pairs: `\abs{}` is converted to `\left|\right|`, and the
|
|
91
|
+
// parenthesis / bracket keys are `\left(\right)` / `\left[\right]`. None has a
|
|
92
|
+
// `{}` group for the rule above to catch, so they would render as bare fences.
|
|
93
|
+
var EMPTY_FENCE_REGEX = /\\left([([|])\s*\\right([)\]|])/g;
|
|
94
|
+
// The same muted fill as the other slots (`pie-empty`), but a tall rectangle
|
|
95
|
+
// rather than a square. It also sets the fences' height: `\left...\right` stretch
|
|
96
|
+
// to their content, so a taller slot gives taller parentheses.
|
|
97
|
+
//
|
|
98
|
+
// A `\rule` stands on the baseline, but the fences are centred on the math axis
|
|
99
|
+
// (0.25em above it), so an un-lifted box sat high between them. `[-0.25em]`
|
|
100
|
+
// lowers it by (axis - height / 2) = 0.25 - 1 / 2, centring it on the axis.
|
|
101
|
+
//
|
|
102
|
+
// Lowering it alone also shrinks the fences, which size themselves to their
|
|
103
|
+
// content (MathLive switches to short bars). The zero-width `\rule{0em}{1em}`
|
|
104
|
+
// strut keeps the content as tall as before, so the bars keep their height and
|
|
105
|
+
// only the box moves.
|
|
106
|
+
var EMPTY_FENCE_SLOT = '\\rule{0em}{1em}\\htmlData{pie-empty=1}{\\rule[-0.25em]{0.55em}{1em}}';
|
|
70
107
|
|
|
71
108
|
/**
|
|
72
109
|
* Make empty argument slots visible, for static rendering.
|
|
@@ -78,7 +115,9 @@ var EMPTY_GROUP_REGEX = /\{\s*\}/g;
|
|
|
78
115
|
* @returns {string}
|
|
79
116
|
*/
|
|
80
117
|
var withVisibleEmptySlots = exports.withVisibleEmptySlots = function withVisibleEmptySlots(latex) {
|
|
81
|
-
return (latex || '').replace(EMPTY_GROUP_REGEX, "{".concat(EMPTY_SLOT, "}"))
|
|
118
|
+
return (latex || '').replace(EMPTY_OVERLINE_REGEX, "".concat(EMPTY_OVERLINE_LABEL_STRUT, "\\overline{").concat(EMPTY_OVERLINE_BAR_STRUT).concat(EMPTY_SLOT, "}")).replace(EMPTY_GROUP_REGEX, "{".concat(EMPTY_SLOT, "}")).replace(EMPTY_FENCE_REGEX, function (_m, open, close) {
|
|
119
|
+
return "\\left".concat(open).concat(EMPTY_FENCE_SLOT, "\\right").concat(close);
|
|
120
|
+
});
|
|
82
121
|
};
|
|
83
122
|
|
|
84
123
|
/**
|
|
@@ -113,6 +152,36 @@ var toNativeCommands = exports.toNativeCommands = function toNativeCommands(late
|
|
|
113
152
|
out = replaceAbs(out);
|
|
114
153
|
out = out.replace(/\\longdiv\{/g, '\\enclose{longdiv}{');
|
|
115
154
|
out = out.replace(/\\overarc\{/g, '\\overparen{');
|
|
155
|
+
out = escapeBareComments(out);
|
|
156
|
+
return out;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Escape an unescaped `%`.
|
|
161
|
+
*
|
|
162
|
+
* In real LaTeX `%` starts a comment, so MathLive discards it *and everything
|
|
163
|
+
* after it*: `50%` renders as `50`, and `x%y` as just `x`. MathQuill had no
|
|
164
|
+
* such notion - it treated `%` as a symbol - so latex from anywhere outside the
|
|
165
|
+
* keypad may still carry a bare one.
|
|
166
|
+
*
|
|
167
|
+
* Only a `%` preceded by an even number of backslashes is bare: `\%` is already
|
|
168
|
+
* escaped, while the `%` in `\\%` (a line break, then a comment) is not.
|
|
169
|
+
*
|
|
170
|
+
* @param {string} latex
|
|
171
|
+
* @returns {string}
|
|
172
|
+
*/
|
|
173
|
+
var escapeBareComments = function escapeBareComments(latex) {
|
|
174
|
+
if (latex.indexOf('%') === -1) {
|
|
175
|
+
return latex;
|
|
176
|
+
}
|
|
177
|
+
var out = '';
|
|
178
|
+
// Consecutive backslashes immediately before the current character.
|
|
179
|
+
var backslashes = 0;
|
|
180
|
+
for (var i = 0; i < latex.length; i++) {
|
|
181
|
+
var ch = latex[i];
|
|
182
|
+
out += ch === '%' && backslashes % 2 === 0 ? '\\%' : ch;
|
|
183
|
+
backslashes = ch === '\\' ? backslashes + 1 : 0;
|
|
184
|
+
}
|
|
116
185
|
return out;
|
|
117
186
|
};
|
|
118
187
|
|
|
@@ -190,6 +259,127 @@ var toMathLive = exports.toMathLive = function toMathLive(latex) {
|
|
|
190
259
|
return out;
|
|
191
260
|
};
|
|
192
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Keypad command names that MathQuill treated as ALIASES of a different command.
|
|
264
|
+
*
|
|
265
|
+
* MathQuill registered `\\divide` as another name for `\\div` (and
|
|
266
|
+
* `\\perpendicular` for `\\perp`), so pressing the key stored the real command.
|
|
267
|
+
* MathLive only knows these names through `PIE_MACROS`, and serialises a macro
|
|
268
|
+
* under its own name - so `\\divide` reached storage verbatim, where MathJax
|
|
269
|
+
* (@pie-lib/math-rendering) has no such command and renders it as red text.
|
|
270
|
+
*
|
|
271
|
+
* Every other keypad command already matches what MathQuill stored (`\\degree`,
|
|
272
|
+
* `\\nsim`, `\\ncong`, `\\nparallel`, `\\square`, `\\napprox`,
|
|
273
|
+
* `\\parallelogram`), and MathJax understands those.
|
|
274
|
+
*/
|
|
275
|
+
var MATHQUILL_ALIASES = exports.MATHQUILL_ALIASES = {
|
|
276
|
+
'\\divide': '\\div',
|
|
277
|
+
'\\perpendicular': '\\perp'
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// Whole command names only: `\\divideontimes` is a real AMS symbol.
|
|
281
|
+
var MATHQUILL_ALIAS_REGEX = /\\(divide|perpendicular)(?![a-zA-Z])/g;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Primes. MathLive turns a prime that follows a base into a superscript atom and
|
|
285
|
+
* serialises it as `^{\\prime}`, or `^{\\doubleprime}` for the keypad's double
|
|
286
|
+
* prime key (`5''` comes back out as `5^{\\doubleprime}`). MathJax has no
|
|
287
|
+
* `\\doubleprime`, and two adjacent `^{\\prime}` groups - what typing `'` twice
|
|
288
|
+
* produces - are a "double exponent" error. MathQuill stored plain apostrophes,
|
|
289
|
+
* which both MathJax and MathLive read as primes, so store those.
|
|
290
|
+
*
|
|
291
|
+
* Only a superscript made of primes alone is rewritten: `x^{\\prime 2}` keeps
|
|
292
|
+
* its group, since it holds more than primes.
|
|
293
|
+
*/
|
|
294
|
+
var PRIME_SUPERSCRIPT_REGEX = /\^\{((?:\s*\\(?:prime|doubleprime)(?![a-zA-Z]))+)\s*\}/g;
|
|
295
|
+
var BARE_DOUBLEPRIME_REGEX = /\\doubleprime(?![a-zA-Z])/g;
|
|
296
|
+
var primesToApostrophes = function primesToApostrophes(primes) {
|
|
297
|
+
return (
|
|
298
|
+
// eslint-disable-next-line quotes
|
|
299
|
+
"'".repeat((primes.match(/\\prime(?![a-zA-Z])/g) || []).length + 2 * (primes.match(BARE_DOUBLEPRIME_REGEX) || []).length)
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
var BARE_PRIME_COMMAND_REGEX = /^\\(doubleprime|prime)(?![a-zA-Z])/;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Primes that are *not* in a superscript.
|
|
306
|
+
*
|
|
307
|
+
* MathLive emits bare `\prime` / `\doubleprime` for a `′` or `″` typed or pasted
|
|
308
|
+
* as a character (`5′6″` serialises as `5\prime6\doubleprime`). A bare `\prime`
|
|
309
|
+
* is a full-size glyph in MathJax, while `''` is a superscript, so storing
|
|
310
|
+
* `5\prime6''` drew the single prime visibly larger than each stroke of the
|
|
311
|
+
* double prime. Both become apostrophes, the superscript primes MathQuill
|
|
312
|
+
* stored, so they always match.
|
|
313
|
+
*
|
|
314
|
+
* Inside a script (`x^{\prime 2}`, `x^\prime`) a prime is already a
|
|
315
|
+
* superscript, and an apostrophe there would mean something else, so
|
|
316
|
+
* `\prime` is kept and `\doubleprime` (unknown to MathJax) becomes
|
|
317
|
+
* `\prime\prime`.
|
|
318
|
+
*
|
|
319
|
+
* @param {string} latex
|
|
320
|
+
* @returns {string}
|
|
321
|
+
*/
|
|
322
|
+
var barePrimesToApostrophes = function barePrimesToApostrophes(latex) {
|
|
323
|
+
if (latex.indexOf('prime') === -1) {
|
|
324
|
+
return latex;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// One entry per open brace: is that group a super/subscript?
|
|
328
|
+
var groups = [];
|
|
329
|
+
var out = '';
|
|
330
|
+
var i = 0;
|
|
331
|
+
while (i < latex.length) {
|
|
332
|
+
var ch = latex[i];
|
|
333
|
+
if (ch === '\\') {
|
|
334
|
+
var match = latex.slice(i).match(BARE_PRIME_COMMAND_REGEX);
|
|
335
|
+
if (match) {
|
|
336
|
+
var isDouble = match[1] === 'doubleprime';
|
|
337
|
+
// `x^\prime`: the command is itself the script.
|
|
338
|
+
var isScriptArgument = /[\^_]\s*$/.test(out);
|
|
339
|
+
var inScript = isScriptArgument || groups.indexOf(true) !== -1;
|
|
340
|
+
if (inScript) {
|
|
341
|
+
out += isDouble ? '\\prime\\prime' : '\\prime';
|
|
342
|
+
} else {
|
|
343
|
+
// eslint-disable-next-line quotes
|
|
344
|
+
out += isDouble ? "''" : "'";
|
|
345
|
+
}
|
|
346
|
+
i += match[0].length;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Copy any other command, or an escaped character such as `\{`, whole.
|
|
351
|
+
var command = latex.slice(i).match(/^\\(?:[a-zA-Z]+|.)/);
|
|
352
|
+
var text = command ? command[0] : ch;
|
|
353
|
+
out += text;
|
|
354
|
+
i += text.length;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (ch === '{') {
|
|
358
|
+
groups.push(/[\^_]\s*$/.test(out));
|
|
359
|
+
} else if (ch === '}') {
|
|
360
|
+
groups.pop();
|
|
361
|
+
}
|
|
362
|
+
out += ch;
|
|
363
|
+
i += 1;
|
|
364
|
+
}
|
|
365
|
+
return out;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Rewrite what MathLive serialises into the form MathQuill stored: alias
|
|
370
|
+
* command names, and primes.
|
|
371
|
+
*
|
|
372
|
+
* @param {string} latex
|
|
373
|
+
* @returns {string}
|
|
374
|
+
*/
|
|
375
|
+
var toCanonicalCommands = exports.toCanonicalCommands = function toCanonicalCommands(latex) {
|
|
376
|
+
return typeof latex === 'string' ? barePrimesToApostrophes(latex.replace(MATHQUILL_ALIAS_REGEX, function (m) {
|
|
377
|
+
return MATHQUILL_ALIASES[m];
|
|
378
|
+
}).replace(PRIME_SUPERSCRIPT_REGEX, function (_m, primes) {
|
|
379
|
+
return primesToApostrophes(primes);
|
|
380
|
+
})) : latex;
|
|
381
|
+
};
|
|
382
|
+
|
|
193
383
|
/**
|
|
194
384
|
* Convert latex out of MathLive back into the stored form, so items authored
|
|
195
385
|
* with the MathLive editor remain readable by @pie-lib/math-rendering and by
|
|
@@ -225,7 +415,10 @@ var fromMathLive = exports.fromMathLive = function fromMathLive(latex) {
|
|
|
225
415
|
return content;
|
|
226
416
|
});
|
|
227
417
|
out = out.replace(BARE_PLACEHOLDER_NO_ARG_REGEX, '');
|
|
228
|
-
|
|
418
|
+
|
|
419
|
+
// Store the command MathQuill stored, not the alias - also heals latex that was
|
|
420
|
+
// saved with `\\divide` before the keypad resolved it.
|
|
421
|
+
return toCanonicalCommands(out);
|
|
229
422
|
};
|
|
230
423
|
|
|
231
424
|
/**
|
|
@@ -234,8 +427,15 @@ var fromMathLive = exports.fromMathLive = function fromMathLive(latex) {
|
|
|
234
427
|
* placeholders in the inserted latex.
|
|
235
428
|
*/
|
|
236
429
|
var COMMANDS_WITH_ARGS = exports.COMMANDS_WITH_ARGS = {
|
|
430
|
+
// An explicit "blank over blank" key: both slots start empty.
|
|
237
431
|
'\\frac': '\\frac{#?}{#?}',
|
|
238
|
-
'
|
|
432
|
+
// Division, which must behave like MathQuill's `/`: whatever precedes the
|
|
433
|
+
// cursor becomes the numerator and the caret lands in the denominator. `#@`
|
|
434
|
+
// is MathLive's token for "the selection, or the item before the cursor" -
|
|
435
|
+
// this is exactly the template MathLive binds to the `/` key itself. Using
|
|
436
|
+
// `#?` here instead produced an empty fraction and left the typed number
|
|
437
|
+
// stranded outside it.
|
|
438
|
+
'/': '\\frac{#@}{#?}',
|
|
239
439
|
'\\sqrt': '\\sqrt{#?}',
|
|
240
440
|
'\\nthroot': '\\sqrt[#?]{#?}',
|
|
241
441
|
'\\overline': '\\overline{#?}',
|
|
@@ -296,7 +496,7 @@ var keyToAction = exports.keyToAction = function keyToAction(key) {
|
|
|
296
496
|
// each part and concatenate.
|
|
297
497
|
var parts = Array.isArray(key.command) ? key.command : [key.command];
|
|
298
498
|
var value = parts.map(function (c) {
|
|
299
|
-
return COMMANDS_WITH_ARGS[c] || c;
|
|
499
|
+
return COMMANDS_WITH_ARGS[c] || MATHQUILL_ALIASES[c] || c;
|
|
300
500
|
}).join('');
|
|
301
501
|
return {
|
|
302
502
|
type: 'insert',
|