@pie-lib/math-input-mathlive 1.0.9 → 1.0.11
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 +2 -2
- package/lib/__tests__/keypad-label.test.js +75 -1
- package/lib/__tests__/keypad-label.test.js.map +1 -1
- package/lib/__tests__/latex-bridge.test.js +29 -0
- package/lib/__tests__/latex-bridge.test.js.map +1 -1
- package/lib/__tests__/mathlive-instance.test.js +42 -0
- package/lib/__tests__/mathlive-instance.test.js.map +1 -1
- package/lib/__tests__/mount-race.test.js +1 -0
- package/lib/__tests__/mount-race.test.js.map +1 -1
- package/lib/keypad/index.js +11 -13
- 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/latex-bridge.js +18 -3
- package/lib/latex-bridge.js.map +1 -1
- package/lib/mathlive-instance.js +56 -1
- package/lib/mathlive-instance.js.map +1 -1
- package/lib/mf/common-styles.js +33 -4
- package/lib/mf/common-styles.js.map +1 -1
- package/lib/mf/input.js +4 -0
- package/lib/mf/input.js.map +1 -1
- package/lib/mf/static.js +4 -0
- package/lib/mf/static.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/keypad-label.test.jsx +76 -1
- package/src/__tests__/latex-bridge.test.js +21 -0
- package/src/__tests__/mathlive-instance.test.js +47 -0
- package/src/__tests__/mount-race.test.jsx +1 -0
- package/src/keypad/index.jsx +11 -13
- package/src/keys/geometry.js +7 -2
- package/src/latex-bridge.js +18 -3
- package/src/mathlive-instance.js +61 -0
- package/src/mf/common-styles.js +33 -4
- package/src/mf/input.jsx +5 -1
- package/src/mf/static.jsx +5 -1
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}\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,s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AEpC,oBACEnN,MAAA,YAAAoG,aAAA,CAACwC,gBAAgB,MAAAqE,SAAA;UACfnI,GAAG,EAAEA,GAAI;UACTsI,QAAQ,EAAE,IAAK;UACfV,OAAO,EAAEA,OAAQ;UACjBG,QAAQ,EAAEA,QAAS;UACnBnF,QAAQ,EAAEA,QAAS;UACnB2F,IAAI,EAAC;QAAO,GACRd,KAAK,gBAETvM,MAAA,YAAAoG,aAAA,CAAC8G,IAAI;UAAC/B,SAAS,EAAC;QAAM,CAAE,CACR,CAAC;MAEvB,CAAC,CACc,CAAC;IAEtB;EAAC;AAAA,EA/KyB5E,iBAAK,CAACC,SAAS;AAAA,IAAAzE,gBAAA,aAA9BiH,MAAM,eACE;EACjBmC,SAAS,EAAE1E,qBAAS,CAACC,MAAM;EAC3B2D,oBAAoB,EAAE5D,qBAAS,CAAC6G,IAAI;EACpClC,OAAO,EAAE3E,qBAAS,CAAC8G,KAAK;EACxBlC,cAAc,EAAE5E,qBAAS,CAAC8G,KAAK;EAC/BjC,eAAe,EAAE7E,qBAAS,CAAC+G,MAAM;EACjCpE,OAAO,EAAE3C,qBAAS,CAACgH,IAAI,CAAC9G,UAAU;EAClC4E,OAAO,EAAE9E,qBAAS,CAACgH,IAAI;EACvB/D,SAAS,EAAEjD,qBAAS,CAAC6G,IAAI;EACzBnE,oBAAoB,EAAE1C,qBAAS,CAACgH,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","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","textAlign","lineHeight","maxWidth","overflow","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","width","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 // 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}));\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}\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,CAA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MAAA,YAAAiG,aAAA,CAACyC,gBAAgB,MAAAqE,SAAA;UACfpI,GAAG,EAAEA,GAAI;UACTuI,QAAQ,EAAE,IAAK;UACfV,OAAO,EAAEA,OAAQ;UACjBG,QAAQ,EAAEA,QAAS;UACnBnF,QAAQ,EAAEA,QAAS;UACnB2F,IAAI,EAAC;QAAO,GACRd,KAAK,gBAETrM,MAAA,YAAAiG,aAAA,CAAC+G,IAAI;UAAC/B,SAAS,EAAC;QAAM,CAAE,CACR,CAAC;MAEvB,CAAC,CACc,CAAC;IAEtB;EAAC;AAAA,EA/KyB7E,iBAAK,CAACC,SAAS;AAAA,IAAAtE,gBAAA,aAA9B+G,MAAM,eACE;EACjBmC,SAAS,EAAE3E,qBAAS,CAACC,MAAM;EAC3B4D,oBAAoB,EAAE7D,qBAAS,CAAC8G,IAAI;EACpClC,OAAO,EAAE5E,qBAAS,CAAC+G,KAAK;EACxBlC,cAAc,EAAE7E,qBAAS,CAAC+G,KAAK;EAC/BjC,eAAe,EAAE9E,qBAAS,CAACgH,MAAM;EACjCpE,OAAO,EAAE5C,qBAAS,CAACiH,IAAI,CAAC/G,UAAU;EAClC6E,OAAO,EAAE/E,qBAAS,CAACiH,IAAI;EACvB/D,SAAS,EAAElD,qBAAS,CAAC8G,IAAI;EACzBnE,oBAAoB,EAAE3C,qBAAS,CAACiH,IAAI;EACpCjC,IAAI,EAAEhF,qBAAS,CAACkH,SAAS,CAAC,CAAClH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACmH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAA1L,gBAAA,aAZU+G,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAA1J,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,KAA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;EACjBD,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMqB,cAAc,GAAAvB,OAAA,CAAAuB,cAAA,GAAG5B,GAAG,CAAC;EAChCM,IAAI,EAAE,kBAAkB;EACxBE,OAAO,EAAE,SAAS;EAClBD,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMsB,cAAc,GAAAxB,OAAA,CAAAwB,cAAA,GAAG7B,GAAG,CAAC;EAChCM,IAAI,EAAE,OAAO;EACbQ,KAAK,EAAE,KAAK;EACZ;EACAP,KAAK,EAAE,GAAG;EACV;EACAM,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMiB,oBAAoB,GAAAzB,OAAA,CAAAyB,oBAAA,GAAG9B,GAAG,CAAC;EACtCM,IAAI,EAAE,cAAc;EACpB;EACAC,KAAK,EAAE,IAAI;EACX;EACAM,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMkB,SAAS,GAAA1B,OAAA,CAAA0B,SAAA,GAAG/B,GAAG,CAAC;EAC3BM,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,aAAa;EACpBC,OAAO,EAAE;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/latex-bridge.js
CHANGED
|
@@ -61,11 +61,19 @@ 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;
|
|
70
78
|
|
|
71
79
|
/**
|
|
@@ -234,8 +242,15 @@ var fromMathLive = exports.fromMathLive = function fromMathLive(latex) {
|
|
|
234
242
|
* placeholders in the inserted latex.
|
|
235
243
|
*/
|
|
236
244
|
var COMMANDS_WITH_ARGS = exports.COMMANDS_WITH_ARGS = {
|
|
245
|
+
// An explicit "blank over blank" key: both slots start empty.
|
|
237
246
|
'\\frac': '\\frac{#?}{#?}',
|
|
238
|
-
'
|
|
247
|
+
// Division, which must behave like MathQuill's `/`: whatever precedes the
|
|
248
|
+
// cursor becomes the numerator and the caret lands in the denominator. `#@`
|
|
249
|
+
// is MathLive's token for "the selection, or the item before the cursor" -
|
|
250
|
+
// this is exactly the template MathLive binds to the `/` key itself. Using
|
|
251
|
+
// `#?` here instead produced an empty fraction and left the typed number
|
|
252
|
+
// stranded outside it.
|
|
253
|
+
'/': '\\frac{#@}{#?}',
|
|
239
254
|
'\\sqrt': '\\sqrt{#?}',
|
|
240
255
|
'\\nthroot': '\\sqrt[#?]{#?}',
|
|
241
256
|
'\\overline': '\\overline{#?}',
|
package/lib/latex-bridge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latex-bridge.js","names":["NEWLINE_EMBED","exports","NEWLINE_EMBED_REGEX","DISPLAYLINES_REGEX","MQ_FIELD_REGEX","PLACEHOLDER_REGEX","BARE_PLACEHOLDER_REGEX","BARE_PLACEHOLDER_NO_ARG_REGEX","DEFAULT_FIELD_ID","EMPTY_SLOT","EMPTY_GROUP_REGEX","withVisibleEmptySlots","latex","replace","concat","toNativeCommands","out","replaceAbs","idx","indexOf","open","length","depth","close","i","inner","slice","fieldIds","match","lastIndex","exec","push","toMathLive","_m","id","content","split","join","fromMathLive","trim","map","s","COMMANDS_WITH_ARGS","_","KEYSTROKES","Left","Right","Backspace","Delete","Up","Down","keyToAction","key","undefined","command","type","value","write","parts","Array","isArray","c","keystroke","selector"],"sources":["../src/latex-bridge.js"],"sourcesContent":["/**\n * LaTeX translation layer between the MathQuill-era content model and MathLive.\n *\n * Two independent concerns live here:\n *\n * 1. Newlines. MathQuill had no line break, so pie-lib registered a custom\n * `newLine` embed that serialises to `\\embed{newLine}[]`. MathLive has no\n * embed system but supports real multiline environments, so we translate\n * `\\embed{newLine}[]` <-> `\\\\` inside `\\displaylines{}`.\n *\n * Authored content keeps its `\\embed{newLine}[]` on-disk form (that is what\n * @pie-lib/math-rendering already normalises for MathJax), so each renderer\n * normalises at its own boundary and stored items stay compatible.\n *\n * 2. Keypad key -> MathLive action. MathQuill keys carry `write`/`command`/\n * `keystroke` built for `mf.write()` / `mf.cmd()` / `mf.keystroke()`.\n * MathLive has `insert()` and `executeCommand()` instead.\n */\n\nexport const NEWLINE_EMBED = '\\\\embed{newLine}[]';\nconst NEWLINE_EMBED_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst DISPLAYLINES_REGEX = /^\\\\displaylines\\{([\\s\\S]*)\\}$/;\n\n/**\n * MathQuill's editable sub-field syntax, e.g. `\\MathQuillMathField[r1]{}`.\n * These are the answer blocks in templated math items; MathLive expresses the\n * same idea as `\\placeholder[id]{}` and reads them back via the prompts API.\n */\nconst MQ_FIELD_REGEX = /\\\\MathQuillMathField\\[([^\\]]*)\\]\\{([^{}]*)\\}/g;\nconst PLACEHOLDER_REGEX = /\\\\placeholder\\[([^\\]]*)\\]\\{([^{}]*)\\}/g;\n\n/**\n * Unnamed placeholders, which MathLive inserts on its own.\n *\n * Typing a command with empty arguments (`\\longdiv{}`, `\\frac{}{}`) makes\n * MathLive serialise the empty slots as `\\placeholder{}`. That token is\n * MathLive-specific: MathJax - which @pie-lib/math-rendering uses to render\n * prompts and previews - has no such command and renders it as red error text.\n * Stored latex must therefore keep plain empty groups.\n */\nconst BARE_PLACEHOLDER_REGEX = /\\\\placeholder\\{([^{}]*)\\}/g;\nconst BARE_PLACEHOLDER_NO_ARG_REGEX = /\\\\placeholder(?![[{a-zA-Z])/g;\n\n/** Default id used when stored latex has an unnamed field. */\nexport const DEFAULT_FIELD_ID = 'r1';\n\n/**\n * A visible stand-in for an empty argument slot, used for STATIC rendering only.\n *\n * Stored latex legitimately contains empty groups - `\\longdiv{}`, `\\frac{}{}`,\n * `x^{}` - to express a command's shape. MathQuill drew those as a shaded box\n * (`.mq-empty`); MathLive renders `{}` as nothing, so `convertLatexToMarkup`\n * output comes out completely blank (not even the surrounding bracket, in the\n * case of `\\enclose{longdiv}{}`).\n *\n * `\\placeholder{}` is not usable here: in static markup it renders as a\n * non-breaking space, because its editable box only exists inside a live\n * mathfield. So an actual glyph is required.\n *\n * Live mathfields need none of this - MathLive manages empty slots itself.\n */\nconst EMPTY_SLOT = '\\\\htmlData{pie-empty=1}{\\\\unicode{\"25AB}}';\nconst EMPTY_GROUP_REGEX = /\\{\\s*\\}/g;\n\n/**\n * Make empty argument slots visible, for static rendering.\n *\n * Display-only: never feed the result to a mathfield or to storage - the\n * original latex is what gets typed and saved.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const withVisibleEmptySlots = (latex) => (latex || '').replace(EMPTY_GROUP_REGEX, `{${EMPTY_SLOT}}`);\n\n/**\n * Pie commands that take an argument, and their native MathLive equivalents.\n *\n * These MUST NOT be handled as MathLive macros. A macro is serialised from the\n * arguments it was created with, so text typed inside its expansion never makes\n * it back out: `getValue('latex')` keeps returning `\\longdiv{\\placeholder{}}`\n * while `getValue('ascii-math')` shows the typed content. Setting\n * `captureSelection: false` lets the cursor in but does not change\n * serialisation.\n *\n * Expanding to native constructs instead gives real, editable atoms that\n * round-trip. All three targets are understood by MathJax too, so stored latex\n * still renders in @pie-lib/math-rendering without a reverse mapping.\n */\n/**\n * Rewrite argument-taking pie commands into native MathLive latex.\n * Applied on the way *into* a mathfield.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const toNativeCommands = (latex) => {\n if (typeof latex !== 'string' || !latex) {\n return latex || '';\n }\n\n let out = latex;\n\n // \\abs{x} -> \\left|x\\right| needs brace-aware handling, the rest are prefix\n // swaps.\n out = replaceAbs(out);\n out = out.replace(/\\\\longdiv\\{/g, '\\\\enclose{longdiv}{');\n out = out.replace(/\\\\overarc\\{/g, '\\\\overparen{');\n\n return out;\n};\n\n/** `\\abs{x}` -> `\\left|x\\right|`, matching balanced braces. */\nconst replaceAbs = (latex) => {\n let out = latex;\n let idx = out.indexOf('\\\\abs{');\n\n while (idx !== -1) {\n const open = idx + '\\\\abs{'.length - 1;\n let depth = 0;\n let close = -1;\n\n for (let i = open; i < out.length; i++) {\n if (out[i] === '{') depth++;\n else if (out[i] === '}') {\n depth--;\n if (depth === 0) {\n close = i;\n break;\n }\n }\n }\n\n if (close === -1) {\n break;\n }\n\n const inner = out.slice(open + 1, close);\n\n out = `${out.slice(0, idx)}\\\\left|${inner}\\\\right|${out.slice(close + 1)}`;\n idx = out.indexOf('\\\\abs{');\n }\n\n return out;\n};\n\n/**\n * Ids of the answer blocks in a piece of stored latex, in document order.\n *\n * @param {string} latex\n * @returns {string[]}\n */\nexport const fieldIds = (latex) => {\n if (typeof latex !== 'string') {\n return [];\n }\n\n const out = [];\n let match;\n\n MQ_FIELD_REGEX.lastIndex = 0;\n\n while ((match = MQ_FIELD_REGEX.exec(latex)) !== null) {\n out.push(match[1] || DEFAULT_FIELD_ID);\n }\n\n return out;\n};\n\n/**\n * Convert stored latex (which may contain `\\embed{newLine}[]`) into latex that\n * MathLive can parse and render as multiple lines.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const toMathLive = (latex) => {\n if (typeof latex !== 'string' || !latex) {\n return latex || '';\n }\n\n // Argument-taking pie commands -> native constructs, so their content stays\n // editable and serialises back correctly (see toNativeCommands).\n let out = toNativeCommands(latex);\n\n // Answer blocks: \\MathQuillMathField[id]{x} -> \\placeholder[id]{x}\n out = out.replace(MQ_FIELD_REGEX, (_m, id, content) => `\\\\placeholder[${id || DEFAULT_FIELD_ID}]{${content}}`);\n\n // Newlines: \\embed{newLine}[] -> a multiline environment\n if (out.indexOf(NEWLINE_EMBED) !== -1) {\n out = `\\\\displaylines{${out.split(NEWLINE_EMBED_REGEX).join(' \\\\\\\\ ')}}`;\n }\n\n return out;\n};\n\n/**\n * Convert latex out of MathLive back into the stored form, so items authored\n * with the MathLive editor remain readable by @pie-lib/math-rendering and by\n * the existing MathQuill implementation.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const fromMathLive = (latex) => {\n if (typeof latex !== 'string' || !latex) {\n return latex || '';\n }\n\n const match = latex.trim().match(DISPLAYLINES_REGEX);\n let out = match ? match[1] : latex;\n\n // `\\\\` is the line separator inside a multiline environment.\n if (out.indexOf('\\\\\\\\') !== -1) {\n out = out\n .split(/\\s*\\\\\\\\\\s*/)\n .map((s) => s.trim())\n .join(NEWLINE_EMBED);\n }\n\n // Answer blocks: \\placeholder[id]{x} -> \\MathQuillMathField[id]{x}\n out = out.replace(\n PLACEHOLDER_REGEX,\n (_m, id, content) => `\\\\MathQuillMathField[${id || DEFAULT_FIELD_ID}]{${content}}`,\n );\n\n // Unnamed placeholders are MathLive's own representation of an empty slot and\n // must not reach storage or MathJax. Unwrap them: keep any content, drop the\n // command itself (the surrounding braces are already part of the host latex,\n // so re-adding them here would produce `\\longdiv{{}}`).\n out = out.replace(BARE_PLACEHOLDER_REGEX, (_m, content) => content);\n out = out.replace(BARE_PLACEHOLDER_NO_ARG_REGEX, '');\n\n return out;\n};\n\n/**\n * MathQuill `cmd()` semantics: commands that take arguments should land the\n * cursor inside the first argument. MathLive expresses that with `#?`\n * placeholders in the inserted latex.\n */\nconst COMMANDS_WITH_ARGS = {\n '\\\\frac': '\\\\frac{#?}{#?}',\n '/': '\\\\frac{#?}{#?}',\n '\\\\sqrt': '\\\\sqrt{#?}',\n '\\\\nthroot': '\\\\sqrt[#?]{#?}',\n '\\\\overline': '\\\\overline{#?}',\n '\\\\overrightarrow': '\\\\overrightarrow{#?}',\n '\\\\overleftrightarrow': '\\\\overleftrightarrow{#?}',\n // Native forms, not the pie macros: a macro would not serialise the user's\n // typed content back out (see toNativeCommands).\n '\\\\overarc': '\\\\overparen{#?}',\n '\\\\longdiv': '\\\\enclose{longdiv}{#?}',\n '^': '^{#?}',\n _: '_{#?}',\n '(': '\\\\left(#?\\\\right)',\n '[': '\\\\left[#?\\\\right]',\n '|': '\\\\left|#?\\\\right|',\n};\n\n/**\n * MathQuill keystroke names -> MathLive command selectors.\n */\nconst KEYSTROKES = {\n Left: 'moveToPreviousChar',\n Right: 'moveToNextChar',\n Backspace: 'deleteBackward',\n Delete: 'deleteForward',\n Up: 'moveUp',\n Down: 'moveDown',\n};\n\n/**\n * Translate a keypad key definition into a MathLive action.\n *\n * Mirrors the precedence in @pie-lib/math-input's MathInput.keypadPress:\n * latex (unless a command is present) -> write -> command -> keystroke.\n *\n * @param {object} key\n * @returns {{type: 'insert'|'command', value: string}|undefined}\n */\nexport const keyToAction = (key) => {\n if (!key) {\n return undefined;\n }\n\n if (key.latex && !key.command) {\n return { type: 'insert', value: key.latex };\n }\n\n if (key.write) {\n return { type: 'insert', value: key.write };\n }\n\n if (key.command) {\n // Some keys carry an array of commands (e.g. Measured Angle is\n // ['m', '\\\\angle'], log-base-n is ['\\\\log', '_']). MathQuill's `cmd()`\n // applied them in sequence; MathLive inserts one latex string, so expand\n // each part and concatenate.\n const parts = Array.isArray(key.command) ? key.command : [key.command];\n const value = parts.map((c) => COMMANDS_WITH_ARGS[c] || c).join('');\n\n return { type: 'insert', value };\n }\n\n if (key.keystroke) {\n const selector = KEYSTROKES[key.keystroke];\n\n return selector ? { type: 'command', value: selector } : undefined;\n }\n\n return undefined;\n};\n\nexport { COMMANDS_WITH_ARGS, KEYSTROKES };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,IAAMA,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,oBAAoB;AACjD,IAAME,mBAAmB,GAAG,yBAAyB;AACrD,IAAMC,kBAAkB,GAAG,+BAA+B;;AAE1D;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,+CAA+C;AACtE,IAAMC,iBAAiB,GAAG,wCAAwC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,sBAAsB,GAAG,4BAA4B;AAC3D,IAAMC,6BAA6B,GAAG,8BAA8B;;AAEpE;AACO,IAAMC,gBAAgB,GAAAP,OAAA,CAAAO,gBAAA,GAAG,IAAI;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,UAAU,GAAG,4CAA2C;AAC9D,IAAMC,iBAAiB,GAAG,UAAU;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMC,qBAAqB,GAAAV,OAAA,CAAAU,qBAAA,GAAG,SAAxBA,qBAAqBA,CAAIC,KAAK;EAAA,OAAK,CAACA,KAAK,IAAI,EAAE,EAAEC,OAAO,CAACH,iBAA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,CAACxC,KAAK,IAAI,CAACwC,GAAG,CAACE,OAAO,EAAE;IAC7B,OAAO;MAAEC,IAAI,EAAE,QAAQ;MAAEC,KAAK,EAAEJ,GAAG,CAACxC;IAAM,CAAC;EAC7C;EAEA,IAAIwC,GAAG,CAACK,KAAK,EAAE;IACb,OAAO;MAAEF,IAAI,EAAE,QAAQ;MAAEC,KAAK,EAAEJ,GAAG,CAACK;IAAM,CAAC;EAC7C;EAEA,IAAIL,GAAG,CAACE,OAAO,EAAE;IACf;IACA;IACA;IACA;IACA,IAAMI,KAAK,GAAGC,KAAK,CAACC,OAAO,CAACR,GAAG,CAACE,OAAO,CAAC,GAAGF,GAAG,CAACE,OAAO,GAAG,CAACF,GAAG,CAACE,OAAO,CAAC;IACtE,IAAME,KAAK,GAAGE,KAAK,CAAClB,GAAG,CAAC,UAACqB,CAAC;MAAA,OAAKnB,kBAAkB,CAACmB,CAAC,CAAC,IAAIA,CAAC;IAAA,EAAC,CAACxB,IAAI,CAAC,EAAE,CAAC;IAEnE,OAAO;MAAEkB,IAAI,EAAE,QAAQ;MAAEC,KAAK,EAALA;IAAM,CAAC;EAClC;EAEA,IAAIJ,GAAG,CAACU,SAAS,EAAE;IACjB,IAAMC,QAAQ,GAAGnB,UAAU,CAACQ,GAAG,CAACU,SAAS,CAAC;IAE1C,OAAOC,QAAQ,GAAG;MAAER,IAAI,EAAE,SAAS;MAAEC,KAAK,EAAEO;IAAS,CAAC,GAAGV,SAAS;EACpE;EAEA,OAAOA,SAAS;AAClB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"latex-bridge.js","names":["NEWLINE_EMBED","exports","NEWLINE_EMBED_REGEX","DISPLAYLINES_REGEX","MQ_FIELD_REGEX","PLACEHOLDER_REGEX","BARE_PLACEHOLDER_REGEX","BARE_PLACEHOLDER_NO_ARG_REGEX","DEFAULT_FIELD_ID","EMPTY_SLOT","EMPTY_GROUP_REGEX","withVisibleEmptySlots","latex","replace","concat","toNativeCommands","out","replaceAbs","idx","indexOf","open","length","depth","close","i","inner","slice","fieldIds","match","lastIndex","exec","push","toMathLive","_m","id","content","split","join","fromMathLive","trim","map","s","COMMANDS_WITH_ARGS","_","KEYSTROKES","Left","Right","Backspace","Delete","Up","Down","keyToAction","key","undefined","command","type","value","write","parts","Array","isArray","c","keystroke","selector"],"sources":["../src/latex-bridge.js"],"sourcesContent":["/**\n * LaTeX translation layer between the MathQuill-era content model and MathLive.\n *\n * Two independent concerns live here:\n *\n * 1. Newlines. MathQuill had no line break, so pie-lib registered a custom\n * `newLine` embed that serialises to `\\embed{newLine}[]`. MathLive has no\n * embed system but supports real multiline environments, so we translate\n * `\\embed{newLine}[]` <-> `\\\\` inside `\\displaylines{}`.\n *\n * Authored content keeps its `\\embed{newLine}[]` on-disk form (that is what\n * @pie-lib/math-rendering already normalises for MathJax), so each renderer\n * normalises at its own boundary and stored items stay compatible.\n *\n * 2. Keypad key -> MathLive action. MathQuill keys carry `write`/`command`/\n * `keystroke` built for `mf.write()` / `mf.cmd()` / `mf.keystroke()`.\n * MathLive has `insert()` and `executeCommand()` instead.\n */\n\nexport const NEWLINE_EMBED = '\\\\embed{newLine}[]';\nconst NEWLINE_EMBED_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst DISPLAYLINES_REGEX = /^\\\\displaylines\\{([\\s\\S]*)\\}$/;\n\n/**\n * MathQuill's editable sub-field syntax, e.g. `\\MathQuillMathField[r1]{}`.\n * These are the answer blocks in templated math items; MathLive expresses the\n * same idea as `\\placeholder[id]{}` and reads them back via the prompts API.\n */\nconst MQ_FIELD_REGEX = /\\\\MathQuillMathField\\[([^\\]]*)\\]\\{([^{}]*)\\}/g;\nconst PLACEHOLDER_REGEX = /\\\\placeholder\\[([^\\]]*)\\]\\{([^{}]*)\\}/g;\n\n/**\n * Unnamed placeholders, which MathLive inserts on its own.\n *\n * Typing a command with empty arguments (`\\longdiv{}`, `\\frac{}{}`) makes\n * MathLive serialise the empty slots as `\\placeholder{}`. That token is\n * MathLive-specific: MathJax - which @pie-lib/math-rendering uses to render\n * prompts and previews - has no such command and renders it as red error text.\n * Stored latex must therefore keep plain empty groups.\n */\nconst BARE_PLACEHOLDER_REGEX = /\\\\placeholder\\{([^{}]*)\\}/g;\nconst BARE_PLACEHOLDER_NO_ARG_REGEX = /\\\\placeholder(?![[{a-zA-Z])/g;\n\n/** Default id used when stored latex has an unnamed field. */\nexport const DEFAULT_FIELD_ID = 'r1';\n\n/**\n * A visible stand-in for an empty argument slot, used for STATIC rendering only.\n *\n * Stored latex legitimately contains empty groups - `\\longdiv{}`, `\\frac{}{}`,\n * `x^{}` - to express a command's shape. MathQuill drew those as a shaded box\n * (`.mq-empty`); MathLive renders `{}` as nothing, so `convertLatexToMarkup`\n * output comes out completely blank (not even the surrounding bracket, in the\n * case of `\\enclose{longdiv}{}`).\n *\n * `\\placeholder{}` is not usable here: in static markup it renders as a\n * non-breaking space, because its editable box only exists inside a live\n * mathfield. So something with real width is required.\n *\n * It must be a `\\rule`, not a unicode glyph. A glyph's width comes from font\n * metrics, and U+25AB is not in the KaTeX fonts - the browser substitutes a\n * wider fallback while MathLive still sizes surrounding accents from its own\n * metrics. That left stretchy accents (`\\overarc`, `\\overleftrightarrow`)\n * visibly narrower than the box they were meant to span. A rule carries an\n * explicit em width, so accents size correctly - and a filled box is closer to\n * MathQuill's `.mq-empty` anyway.\n *\n * Live mathfields need none of this - MathLive manages empty slots itself.\n */\nconst EMPTY_SLOT = '\\\\htmlData{pie-empty=1}{\\\\rule{0.55em}{0.55em}}';\nconst EMPTY_GROUP_REGEX = /\\{\\s*\\}/g;\n\n/**\n * Make empty argument slots visible, for static rendering.\n *\n * Display-only: never feed the result to a mathfield or to storage - the\n * original latex is what gets typed and saved.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const withVisibleEmptySlots = (latex) => (latex || '').replace(EMPTY_GROUP_REGEX, `{${EMPTY_SLOT}}`);\n\n/**\n * Pie commands that take an argument, and their native MathLive equivalents.\n *\n * These MUST NOT be handled as MathLive macros. A macro is serialised from the\n * arguments it was created with, so text typed inside its expansion never makes\n * it back out: `getValue('latex')` keeps returning `\\longdiv{\\placeholder{}}`\n * while `getValue('ascii-math')` shows the typed content. Setting\n * `captureSelection: false` lets the cursor in but does not change\n * serialisation.\n *\n * Expanding to native constructs instead gives real, editable atoms that\n * round-trip. All three targets are understood by MathJax too, so stored latex\n * still renders in @pie-lib/math-rendering without a reverse mapping.\n */\n/**\n * Rewrite argument-taking pie commands into native MathLive latex.\n * Applied on the way *into* a mathfield.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const toNativeCommands = (latex) => {\n if (typeof latex !== 'string' || !latex) {\n return latex || '';\n }\n\n let out = latex;\n\n // \\abs{x} -> \\left|x\\right| needs brace-aware handling, the rest are prefix\n // swaps.\n out = replaceAbs(out);\n out = out.replace(/\\\\longdiv\\{/g, '\\\\enclose{longdiv}{');\n out = out.replace(/\\\\overarc\\{/g, '\\\\overparen{');\n\n return out;\n};\n\n/** `\\abs{x}` -> `\\left|x\\right|`, matching balanced braces. */\nconst replaceAbs = (latex) => {\n let out = latex;\n let idx = out.indexOf('\\\\abs{');\n\n while (idx !== -1) {\n const open = idx + '\\\\abs{'.length - 1;\n let depth = 0;\n let close = -1;\n\n for (let i = open; i < out.length; i++) {\n if (out[i] === '{') depth++;\n else if (out[i] === '}') {\n depth--;\n if (depth === 0) {\n close = i;\n break;\n }\n }\n }\n\n if (close === -1) {\n break;\n }\n\n const inner = out.slice(open + 1, close);\n\n out = `${out.slice(0, idx)}\\\\left|${inner}\\\\right|${out.slice(close + 1)}`;\n idx = out.indexOf('\\\\abs{');\n }\n\n return out;\n};\n\n/**\n * Ids of the answer blocks in a piece of stored latex, in document order.\n *\n * @param {string} latex\n * @returns {string[]}\n */\nexport const fieldIds = (latex) => {\n if (typeof latex !== 'string') {\n return [];\n }\n\n const out = [];\n let match;\n\n MQ_FIELD_REGEX.lastIndex = 0;\n\n while ((match = MQ_FIELD_REGEX.exec(latex)) !== null) {\n out.push(match[1] || DEFAULT_FIELD_ID);\n }\n\n return out;\n};\n\n/**\n * Convert stored latex (which may contain `\\embed{newLine}[]`) into latex that\n * MathLive can parse and render as multiple lines.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const toMathLive = (latex) => {\n if (typeof latex !== 'string' || !latex) {\n return latex || '';\n }\n\n // Argument-taking pie commands -> native constructs, so their content stays\n // editable and serialises back correctly (see toNativeCommands).\n let out = toNativeCommands(latex);\n\n // Answer blocks: \\MathQuillMathField[id]{x} -> \\placeholder[id]{x}\n out = out.replace(MQ_FIELD_REGEX, (_m, id, content) => `\\\\placeholder[${id || DEFAULT_FIELD_ID}]{${content}}`);\n\n // Newlines: \\embed{newLine}[] -> a multiline environment\n if (out.indexOf(NEWLINE_EMBED) !== -1) {\n out = `\\\\displaylines{${out.split(NEWLINE_EMBED_REGEX).join(' \\\\\\\\ ')}}`;\n }\n\n return out;\n};\n\n/**\n * Convert latex out of MathLive back into the stored form, so items authored\n * with the MathLive editor remain readable by @pie-lib/math-rendering and by\n * the existing MathQuill implementation.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const fromMathLive = (latex) => {\n if (typeof latex !== 'string' || !latex) {\n return latex || '';\n }\n\n const match = latex.trim().match(DISPLAYLINES_REGEX);\n let out = match ? match[1] : latex;\n\n // `\\\\` is the line separator inside a multiline environment.\n if (out.indexOf('\\\\\\\\') !== -1) {\n out = out\n .split(/\\s*\\\\\\\\\\s*/)\n .map((s) => s.trim())\n .join(NEWLINE_EMBED);\n }\n\n // Answer blocks: \\placeholder[id]{x} -> \\MathQuillMathField[id]{x}\n out = out.replace(\n PLACEHOLDER_REGEX,\n (_m, id, content) => `\\\\MathQuillMathField[${id || DEFAULT_FIELD_ID}]{${content}}`,\n );\n\n // Unnamed placeholders are MathLive's own representation of an empty slot and\n // must not reach storage or MathJax. Unwrap them: keep any content, drop the\n // command itself (the surrounding braces are already part of the host latex,\n // so re-adding them here would produce `\\longdiv{{}}`).\n out = out.replace(BARE_PLACEHOLDER_REGEX, (_m, content) => content);\n out = out.replace(BARE_PLACEHOLDER_NO_ARG_REGEX, '');\n\n return out;\n};\n\n/**\n * MathQuill `cmd()` semantics: commands that take arguments should land the\n * cursor inside the first argument. MathLive expresses that with `#?`\n * placeholders in the inserted latex.\n */\nconst COMMANDS_WITH_ARGS = {\n // An explicit \"blank over blank\" key: both slots start empty.\n '\\\\frac': '\\\\frac{#?}{#?}',\n // Division, which must behave like MathQuill's `/`: whatever precedes the\n // cursor becomes the numerator and the caret lands in the denominator. `#@`\n // is MathLive's token for \"the selection, or the item before the cursor\" -\n // this is exactly the template MathLive binds to the `/` key itself. Using\n // `#?` here instead produced an empty fraction and left the typed number\n // stranded outside it.\n '/': '\\\\frac{#@}{#?}',\n '\\\\sqrt': '\\\\sqrt{#?}',\n '\\\\nthroot': '\\\\sqrt[#?]{#?}',\n '\\\\overline': '\\\\overline{#?}',\n '\\\\overrightarrow': '\\\\overrightarrow{#?}',\n '\\\\overleftrightarrow': '\\\\overleftrightarrow{#?}',\n // Native forms, not the pie macros: a macro would not serialise the user's\n // typed content back out (see toNativeCommands).\n '\\\\overarc': '\\\\overparen{#?}',\n '\\\\longdiv': '\\\\enclose{longdiv}{#?}',\n '^': '^{#?}',\n _: '_{#?}',\n '(': '\\\\left(#?\\\\right)',\n '[': '\\\\left[#?\\\\right]',\n '|': '\\\\left|#?\\\\right|',\n};\n\n/**\n * MathQuill keystroke names -> MathLive command selectors.\n */\nconst KEYSTROKES = {\n Left: 'moveToPreviousChar',\n Right: 'moveToNextChar',\n Backspace: 'deleteBackward',\n Delete: 'deleteForward',\n Up: 'moveUp',\n Down: 'moveDown',\n};\n\n/**\n * Translate a keypad key definition into a MathLive action.\n *\n * Mirrors the precedence in @pie-lib/math-input's MathInput.keypadPress:\n * latex (unless a command is present) -> write -> command -> keystroke.\n *\n * @param {object} key\n * @returns {{type: 'insert'|'command', value: string}|undefined}\n */\nexport const keyToAction = (key) => {\n if (!key) {\n return undefined;\n }\n\n if (key.latex && !key.command) {\n return { type: 'insert', value: key.latex };\n }\n\n if (key.write) {\n return { type: 'insert', value: key.write };\n }\n\n if (key.command) {\n // Some keys carry an array of commands (e.g. Measured Angle is\n // ['m', '\\\\angle'], log-base-n is ['\\\\log', '_']). MathQuill's `cmd()`\n // applied them in sequence; MathLive inserts one latex string, so expand\n // each part and concatenate.\n const parts = Array.isArray(key.command) ? key.command : [key.command];\n const value = parts.map((c) => COMMANDS_WITH_ARGS[c] || c).join('');\n\n return { type: 'insert', value };\n }\n\n if (key.keystroke) {\n const selector = KEYSTROKES[key.keystroke];\n\n return selector ? { type: 'command', value: selector } : undefined;\n }\n\n return undefined;\n};\n\nexport { COMMANDS_WITH_ARGS, KEYSTROKES };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,IAAMA,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,oBAAoB;AACjD,IAAME,mBAAmB,GAAG,yBAAyB;AACrD,IAAMC,kBAAkB,GAAG,+BAA+B;;AAE1D;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,+CAA+C;AACtE,IAAMC,iBAAiB,GAAG,wCAAwC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,sBAAsB,GAAG,4BAA4B;AAC3D,IAAMC,6BAA6B,GAAG,8BAA8B;;AAEpE;AACO,IAAMC,gBAAgB,GAAAP,OAAA,CAAAO,gBAAA,GAAG,IAAI;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,UAAU,GAAG,iDAAiD;AACpE,IAAMC,iBAAiB,GAAG,UAAU;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMC,qBAA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E_EMBED;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
exports.__setMathLiveForTest = exports.__resetEmbeds = exports.PIE_MACROS = void 0;
|
|
15
|
+
exports.applyShadowStyles = exports.__setMathLiveForTest = exports.__resetEmbeds = exports.PIE_MACROS = void 0;
|
|
16
16
|
exports.applyStaticMath = applyStaticMath;
|
|
17
17
|
exports.getMathLive = exports.getMacros = exports.configureFonts = void 0;
|
|
18
18
|
exports.latexToMarkup = latexToMarkup;
|
|
@@ -22,6 +22,7 @@ exports.registeredEmbeds = void 0;
|
|
|
22
22
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
23
23
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
24
24
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
25
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
25
26
|
var _debug = _interopRequireDefault(require("debug"));
|
|
26
27
|
var _latexBridge = require("./latex-bridge");
|
|
27
28
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -192,6 +193,60 @@ var configureLoaded = function configureLoaded() {
|
|
|
192
193
|
injectCoreStylesheet();
|
|
193
194
|
};
|
|
194
195
|
|
|
196
|
+
/**
|
|
197
|
+
* CSS that has to live *inside* a mathfield's shadow root.
|
|
198
|
+
*
|
|
199
|
+
* A live `<math-field>` renders in shadow DOM (`attachShadow({mode:'open'})`),
|
|
200
|
+
* so nothing in the host page's stylesheets reaches it. The stretchy-accent
|
|
201
|
+
* problem therefore needs fixing twice: once for static markup (see
|
|
202
|
+
* `placeholderStyles`) and once here for the editor.
|
|
203
|
+
*
|
|
204
|
+
* MathLive centres an accent with `margin-left: <half the content width>` as an
|
|
205
|
+
* inline style. For a stretchy accent that also shrinks its containing block
|
|
206
|
+
* (`.ML__center` is position:relative), so the arc ends up half-width and offset
|
|
207
|
+
* - visibly failing to span the text underneath.
|
|
208
|
+
*
|
|
209
|
+
* `:has(.ML__stretchy)` keeps the fix to stretchy accents; single-glyph accents
|
|
210
|
+
* (`\hat{x}`, `\vec{x}`) still need their centring offset.
|
|
211
|
+
*/
|
|
212
|
+
var SHADOW_CSS = '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}';
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Apply {@link SHADOW_CSS} inside a mathfield's shadow root.
|
|
216
|
+
*
|
|
217
|
+
* Uses `adoptedStyleSheets` when available (which is how MathLive loads its own
|
|
218
|
+
* stylesheets) and falls back to appending a <style> node.
|
|
219
|
+
*
|
|
220
|
+
* @param {HTMLElement} mathField
|
|
221
|
+
*/
|
|
222
|
+
var applyShadowStyles = exports.applyShadowStyles = function applyShadowStyles(mathField) {
|
|
223
|
+
var root = mathField && mathField.shadowRoot;
|
|
224
|
+
if (!root) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
if ('adoptedStyleSheets' in root && typeof CSSStyleSheet !== 'undefined') {
|
|
229
|
+
// Do not re-add on a re-render.
|
|
230
|
+
if (root.__pieAccentSheet) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
var sheet = new CSSStyleSheet();
|
|
234
|
+
sheet.replaceSync(SHADOW_CSS);
|
|
235
|
+
root.adoptedStyleSheets = [].concat((0, _toConsumableArray2["default"])(root.adoptedStyleSheets), [sheet]);
|
|
236
|
+
root.__pieAccentSheet = sheet;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (!root.querySelector('style[data-pie-accent]')) {
|
|
240
|
+
var style = document.createElement('style');
|
|
241
|
+
style.setAttribute('data-pie-accent', '');
|
|
242
|
+
style.textContent = SHADOW_CSS;
|
|
243
|
+
root.appendChild(style);
|
|
244
|
+
}
|
|
245
|
+
} catch (e) {
|
|
246
|
+
log('could not apply shadow styles to the mathfield: %s', e && e.message);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
195
250
|
/**
|
|
196
251
|
* Ensure MathLive's "core" stylesheet is in the document.
|
|
197
252
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathlive-instance.js","names":["_debug","_interopRequireDefault","require","_latexBridge","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_interopRequireWildcard","WeakMap","n","__esModule","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","log","debug","mathlive","fontsDirectory","absoluteFontsDirectory","dir","test","URL","document","baseURI","href","message","FALLBACK_MATHLIVE_VERSION","cdnFontsDirectory","version","concat","configureFonts","exports","MathfieldElement","undefined","MATH_MODE_SPACE","PIE_MACROS","parallelogram","napprox","nsim","ncong","nparallel","perpendicular","divide","degree","square","longdiv","overarc","abs","embeds","Map","KNOWN_EMBED_LATEX","newLine","answerBlock","loadWarned","configureLoaded","injectCoreStylesheet","renderMathInElement","createElement","loadMathLiveSync","window","loadMathLive","_ref","_asyncToGenerator2","_regenerator","mark","_callee","_t","wrap","_context","prev","next","abrupt","Promise","resolve","then","sent","process","env","NODE_ENV","console","warn","stop","getMathLive","getMacros","out","_ref2","name","latex","registerEmbed","factory","definition","prototype","mathliveLatex","registeredEmbeds","Array","from","__resetEmbeds","clear","__setMathLiveForTest","stub","applyStaticMath","element","options","source","textContent","ml","loaded","isConnected","innerHTML","convertLatexToMarkup","withVisibleEmptySlots","toMathLive","macros","latexToMarkup"],"sources":["../src/mathlive-instance.js"],"sourcesContent":["import debug from 'debug';\nimport { NEWLINE_EMBED, toMathLive, withVisibleEmptySlots } from './latex-bridge';\n\nconst log = debug('pie-lib:math-input-mathlive:instance');\n\n/**\n * MathLive bootstrap + compatibility shims for @pie-lib/math-input's public API.\n *\n * MathLive is loaded lazily and only in the browser: the editor bundle is\n * ~227KB gzip and registers custom elements, so it must never run during SSR.\n */\n\nlet mathlive;\n\n/**\n * Where the KaTeX woff2 fonts are served from, as configured by the host app.\n * `undefined` means \"not configured\"; `null` means \"explicitly disabled\".\n */\nlet fontsDirectory;\n\n/**\n * Turn a fonts path into a fully-qualified URL.\n *\n * MathLive's default `fontsDirectory` is the relative `'./fonts/'`, which it\n * resolves against its own script URL. Under a bundler (webpack/Next) that\n * script URL is empty, so `new URL('./fonts/', '')` throws\n * \"Failed to construct 'URL': Invalid base URL\" from `loadFonts`.\n * Resolving against `document.baseURI` avoids that entirely and honours any\n * <base href> / asset prefix the host app uses.\n */\nconst absoluteFontsDirectory = (dir) => {\n if (!dir) {\n return dir;\n }\n\n // Already absolute (http://, https://, //cdn...) - MathLive handles these.\n if (/^(?:[a-z+]+:)?\\/\\//i.test(dir)) {\n return dir;\n }\n\n try {\n return new URL(dir, document.baseURI).href;\n } catch (e) {\n log('could not resolve fontsDirectory \"%s\": %s', dir, e && e.message);\n return null;\n }\n};\n\n/**\n * Version-pinned CDN fallback for the KaTeX fonts.\n *\n * Some symbols are composed from Private Use Area glyphs that exist only in\n * those fonts: `\\\\neq` is U+E020 (a negation slash) overlapped on `=`, and\n * `\\\\nsim` / `\\\\ncong` work the same way. With no fonts the browser substitutes\n * an arbitrary glyph for U+E020, so those keys render as garbage rather than\n * simply falling back to a plainer face.\n *\n * The version comes from MathLive itself, so the fonts always match the engine.\n * Hosts that would rather not depend on a third party should serve the fonts and\n * call `configureFonts('/their/path')`, or pass `null` to opt out.\n */\nconst FALLBACK_MATHLIVE_VERSION = '0.110.0';\n\nconst cdnFontsDirectory = () => {\n const version = (mathlive && mathlive.version && mathlive.version.mathlive) || FALLBACK_MATHLIVE_VERSION;\n\n // NOTE: `/fonts`, not `/dist/fonts` - the published package root holds them.\n return `https://unpkg.com/mathlive@${version}/fonts`;\n};\n\n/**\n * Tell the package where the MathLive fonts are served from.\n *\n * Call before `loadMathLive()`.\n *\n * - a path/URL: served by you, no third-party request\n * - `null`: skip font loading; note `\\\\neq`, `\\\\nsim` and `\\\\ncong` then\n * render incorrectly, being built from Private Use Area glyphs\n * - not called: falls back to a version-pinned CDN\n *\n * The fonts ship inside the `mathlive` package (`node_modules/mathlive/fonts`)\n * ready to copy into whatever the host app serves statically.\n *\n * @param {string|null} [dir]\n */\nexport const configureFonts = (dir) => {\n fontsDirectory = dir;\n\n if (mathlive) {\n mathlive.MathfieldElement.fontsDirectory = dir === undefined ? cdnFontsDirectory() : absoluteFontsDirectory(dir);\n }\n};\n\n/**\n * What the spacebar inserts in math mode.\n *\n * MathLive's `mathModeSpace` defaults to an empty string, which makes the\n * spacebar a no-op - users cannot type a space at all. `\\\\ ` (a LaTeX control\n * space) is what MathQuill serialised spaces as, so existing content and the\n * MathJax renderer in @pie-lib/math-rendering both already understand it.\n *\n * A literal \" \" is not usable: LaTeX skips raw whitespace.\n */\nexport const MATH_MODE_SPACE = '\\\\ ';\n\n/**\n * Custom macros for the pie-specific commands that the MathQuill fork\n * understood but stock LaTeX does not.\n *\n * Kept deliberately in sync with the MathJax macros in\n * @pie-lib/math-rendering (`render-math.js`) so the same latex renders the same\n * way in the editor and in the static renderer.\n */\nexport const PIE_MACROS = {\n // Argument-less symbols. Atomic is correct here: backspace should remove the\n // whole glyph, and there is nothing to type into.\n parallelogram: '\\\\htmlData{pie-macro=parallelogram}{\\\\unicode{\"25B1}}',\n napprox: '\\\\not\\\\approx',\n nsim: '\\\\not\\\\sim',\n ncong: '\\\\not\\\\cong',\n nparallel: '\\\\not\\\\parallel',\n perpendicular: '\\\\perp',\n divide: '\\\\div',\n degree: '^{\\\\circ}',\n square: '\\\\unicode{\"25A1}',\n\n // Argument-taking commands, kept ONLY so previously authored latex still\n // parses and renders. They are never used for editing: MathLive serialises a\n // macro from the arguments it was created with, so text typed inside the\n // expansion never comes back out of `getValue('latex')`. Anything entering a\n // mathfield is rewritten to the native equivalent first - see\n // `toNativeCommands` in latex-bridge.\n longdiv: '\\\\enclose{longdiv}{#1}',\n overarc: '\\\\overparen{#1}',\n abs: '\\\\left|#1\\\\right|',\n};\n\n/**\n * Registry for `registerEmbed`.\n *\n * MathLive has no embed plugin system, so an embed is expressed as a macro that\n * expands to real LaTeX. `\\htmlData{embed=<name>}` tags the rendered output so\n * consumers can target it with CSS exactly as they targeted the old\n * `htmlString` markup.\n *\n * Known embeds map to native constructs:\n * - `newLine` -> structural, handled by latex-bridge (`\\displaylines` + `\\\\`)\n * - `answerBlock`-> `\\placeholder{}` (interactive, read via the prompts API)\n *\n * @type {Map<string, {factory: Function, latex: string}>}\n */\nconst embeds = new Map();\n\nconst KNOWN_EMBED_LATEX = {\n // newLine is structural: it is translated by latex-bridge before it ever\n // reaches MathLive, so the macro only needs to be harmless.\n newLine: '',\n answerBlock: '\\\\placeholder{}',\n};\n\nlet loadWarned = false;\n\n/** Apply post-load configuration exactly once. */\nconst configureLoaded = () => {\n // Always replace MathLive's relative `'./fonts/'` default: it throws\n // \"Invalid base URL\" when bundled. Use the host's copy if one was configured,\n // otherwise the version-pinned CDN.\n if (fontsDirectory === undefined) {\n log(\n 'no fontsDirectory configured - falling back to the CDN (%s). ' +\n 'Serve the fonts yourself and call configureFonts(\"/path/to/fonts\") to avoid the network request, ' +\n 'or configureFonts(null) to opt out.',\n cdnFontsDirectory(),\n );\n }\n\n mathlive.MathfieldElement.fontsDirectory =\n fontsDirectory === undefined ? cdnFontsDirectory() : absoluteFontsDirectory(fontsDirectory);\n\n injectCoreStylesheet();\n};\n\n/**\n * Ensure MathLive's \"core\" stylesheet is in the document.\n *\n * `convertLatexToMarkup` - which renders keypad labels and static math - does\n * NOT inject it, while `renderMathInElement` and live mathfields do. Without it\n * the generated markup is unstyled: glyphs misalign and the <svg> used by\n * stretchy accents lays out statically at an unbounded width.\n *\n * Hosts that can import CSS should `import 'mathlive/static.css'`. For bundles\n * that cannot handle CSS imports (pie-elements ships JS-only web components),\n * this triggers MathLive's own injection against a detached element, so the\n * styles come from MathLive itself rather than being duplicated here.\n */\nconst injectCoreStylesheet = () => {\n if (typeof document === 'undefined' || !mathlive || !mathlive.renderMathInElement) {\n return;\n }\n\n try {\n mathlive.renderMathInElement(document.createElement('span'));\n } catch (e) {\n log('could not trigger MathLive core stylesheet injection: %s', e && e.message);\n }\n};\n\n/**\n * Load MathLive synchronously when the bundler allows it.\n *\n * `require` keeps MathLive inside the host's bundle. An `import()` would make\n * webpack emit a separate chunk, and a deployment that does not serve that\n * chunk fails with a 404 at runtime - leaving every mathfield and keypad label\n * blank with no obvious cause. Being in the main bundle also makes the engine\n * available on first render, so callers that run synchronously (applyStaticMath,\n * keypad labels) work without a second pass.\n *\n * Returns undefined during SSR or if the module is genuinely unavailable.\n *\n * @returns {object|undefined}\n */\nexport const loadMathLiveSync = () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (!mathlive) {\n try {\n // eslint-disable-next-line global-require\n mathlive = require('mathlive');\n configureLoaded();\n } catch (e) {\n log('synchronous MathLive load unavailable: %s', e && e.message);\n return undefined;\n }\n }\n\n return mathlive;\n};\n\n/**\n * Load MathLive. Prefers the synchronous path; falls back to a dynamic import.\n * Resolves to undefined during SSR.\n *\n * @returns {Promise<object|undefined>}\n */\nexport const loadMathLive = async () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (mathlive) {\n return mathlive;\n }\n\n if (loadMathLiveSync()) {\n return mathlive;\n }\n\n try {\n mathlive = await import('mathlive');\n configureLoaded();\n } catch (e) {\n // Surface this once: a silent failure here renders every field and keypad\n // label blank, which is very hard to trace back to a module load.\n // Skipped under test, where jsdom cannot load the browser build.\n if (!loadWarned && process.env.NODE_ENV !== 'test') {\n loadWarned = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[@pie-lib/math-input-mathlive] MathLive could not be loaded; math input will not render. ' +\n 'If this is a bundling issue, ensure \"mathlive\" is resolvable from the host bundle. Cause: ' +\n (e && e.message),\n );\n }\n\n return undefined;\n }\n\n return mathlive;\n};\n\n/**\n * Synchronous accessor for an already-loaded MathLive.\n * @returns {object|undefined}\n */\nexport const getMathLive = () => mathlive;\n\n/**\n * The macro dictionary to hand to a mathfield: pie macros plus anything\n * registered through `registerEmbed`.\n *\n * @returns {object}\n */\nexport const getMacros = () => {\n const out = { ...PIE_MACROS };\n\n embeds.forEach(({ latex }, name) => {\n out[name] = `\\\\htmlData{embed=${name}}{${latex}}`;\n });\n\n return out;\n};\n\n/**\n * Register an embed. API-compatible with @pie-lib/math-input's `registerEmbed`\n * so existing callers do not change.\n *\n * MathQuill's factory returns `{ htmlString, text, latex }`. Only the\n * declarative parts survive: `latex` round-trips through a macro and the\n * styling hook becomes a `data-embed` attribute. Arbitrary DOM injection via\n * `htmlString` has no MathLive equivalent and is ignored.\n *\n * @param {string} name\n * @param {Function} factory\n */\nexport function registerEmbed(name, factory) {\n if (!name || typeof factory !== 'function') {\n return;\n }\n\n let definition = {};\n\n try {\n definition = factory() || {};\n } catch (e) {\n log('embed factory threw for \"%s\": %s', name, e.message);\n }\n\n const latex = Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name)\n ? KNOWN_EMBED_LATEX[name]\n : definition.mathliveLatex || '\\\\placeholder{}';\n\n if (!Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name) && !definition.mathliveLatex) {\n // Unknown third-party embed: degrade instead of throwing. `htmlString`\n // cannot be reproduced, so it renders as an editable slot.\n log(\n 'embed \"%s\" is not natively supported by MathLive; rendering as a placeholder. ' +\n 'Provide `mathliveLatex` in the factory result to control this.',\n name,\n );\n }\n\n embeds.set(name, { factory, latex });\n}\n\n/**\n * Embeds registered so far. Exposed for tests/diagnostics.\n * @returns {string[]}\n */\nexport const registeredEmbeds = () => Array.from(embeds.keys());\n\n/** Reset the embed registry. Test helper. */\nexport const __resetEmbeds = () => embeds.clear();\n\n/** Inject a stub MathLive instance. Test helper. */\nexport const __setMathLiveForTest = (stub) => {\n mathlive = stub;\n};\n\n/**\n * Render static math into an element. API-compatible with\n * @pie-lib/math-input's `applyStaticMath`.\n *\n * Callers written against MathQuill invoke this synchronously from lifecycle\n * methods, where MathLive (a dynamic import) may not have loaded yet. Rather\n * than silently rendering nothing, this kicks off the load and re-applies once\n * the engine is ready, so the element fills in on the next tick.\n *\n * @param {HTMLElement} element\n * @param {string} [latex] assigned to the element before rendering\n * @param {object} [options] `{ macros }` overrides\n * @returns {HTMLElement|undefined} the element, or undefined if deferred\n */\nexport function applyStaticMath(element, latex, options = {}) {\n if (!element || typeof window === 'undefined') {\n return undefined;\n }\n\n // Capture the source now: if we defer, the element's textContent may have\n // been overwritten by the time MathLive is ready.\n const source = latex === undefined || latex === null ? element.textContent : latex;\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml) {\n log('applyStaticMath called before MathLive loaded - deferring until it is ready');\n\n loadMathLive().then((loaded) => {\n // The element may have been unmounted while loading.\n if (loaded && element.isConnected !== false) {\n applyStaticMath(element, source, options);\n }\n });\n\n return undefined;\n }\n\n element.innerHTML = ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(source)), {\n macros: { ...getMacros(), ...(options.macros || {}) },\n });\n\n return element;\n}\n\n/**\n * Convert latex to markup using the pie macro set. Used for keypad labels and\n * any read-only rendering that does not need a live mathfield.\n *\n * @param {string} latex\n * @param {object} [options]\n * @returns {string} HTML markup, or '' if MathLive is not loaded\n */\nexport function latexToMarkup(latex, options = {}) {\n // Try the synchronous load so the very first render can produce markup\n // instead of falling back to raw latex.\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml || !latex) {\n return '';\n }\n\n try {\n // Empty groups render as nothing in static markup, so give them a visible\n // box. This covers every static path: keypad labels, mf.Static in display\n // mode, and applyStaticMath.\n return ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(latex)), {\n macros: { ...getMacros(), ...(options.macros || {}) },\n ...options,\n });\n }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"file":"mathlive-instance.js","names":["_debug","_interopRequireDefault","require","_latexBridge","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_interopRequireWildcard","WeakMap","n","__esModule","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","log","debug","mathlive","fontsDirectory","absoluteFontsDirectory","dir","test","URL","document","baseURI","href","message","FALLBACK_MATHLIVE_VERSION","cdnFontsDirectory","version","concat","configureFonts","exports","MathfieldElement","undefined","MATH_MODE_SPACE","PIE_MACROS","parallelogram","napprox","nsim","ncong","nparallel","perpendicular","divide","degree","square","longdiv","overarc","abs","embeds","Map","KNOWN_EMBED_LATEX","newLine","answerBlock","loadWarned","configureLoaded","injectCoreStylesheet","SHADOW_CSS","applyShadowStyles","mathField","root","shadowRoot","CSSStyleSheet","__pieAccentSheet","sheet","replaceSync","adoptedStyleSheets","_toConsumableArray2","querySelector","style","createElement","setAttribute","textContent","appendChild","renderMathInElement","loadMathLiveSync","window","loadMathLive","_ref","_asyncToGenerator2","_regenerator","mark","_callee","_t","wrap","_context","prev","next","abrupt","Promise","resolve","then","sent","process","env","NODE_ENV","console","warn","stop","getMathLive","getMacros","out","_ref2","name","latex","registerEmbed","factory","definition","prototype","mathliveLatex","registeredEmbeds","Array","from","__resetEmbeds","clear","__setMathLiveForTest","stub","applyStaticMath","element","options","source","ml","loaded","isConnected","innerHTML","convertLatexToMarkup","withVisibleEmptySlots","toMathLive","macros","latexToMarkup"],"sources":["../src/mathlive-instance.js"],"sourcesContent":["import debug from 'debug';\nimport { NEWLINE_EMBED, toMathLive, withVisibleEmptySlots } from './latex-bridge';\n\nconst log = debug('pie-lib:math-input-mathlive:instance');\n\n/**\n * MathLive bootstrap + compatibility shims for @pie-lib/math-input's public API.\n *\n * MathLive is loaded lazily and only in the browser: the editor bundle is\n * ~227KB gzip and registers custom elements, so it must never run during SSR.\n */\n\nlet mathlive;\n\n/**\n * Where the KaTeX woff2 fonts are served from, as configured by the host app.\n * `undefined` means \"not configured\"; `null` means \"explicitly disabled\".\n */\nlet fontsDirectory;\n\n/**\n * Turn a fonts path into a fully-qualified URL.\n *\n * MathLive's default `fontsDirectory` is the relative `'./fonts/'`, which it\n * resolves against its own script URL. Under a bundler (webpack/Next) that\n * script URL is empty, so `new URL('./fonts/', '')` throws\n * \"Failed to construct 'URL': Invalid base URL\" from `loadFonts`.\n * Resolving against `document.baseURI` avoids that entirely and honours any\n * <base href> / asset prefix the host app uses.\n */\nconst absoluteFontsDirectory = (dir) => {\n if (!dir) {\n return dir;\n }\n\n // Already absolute (http://, https://, //cdn...) - MathLive handles these.\n if (/^(?:[a-z+]+:)?\\/\\//i.test(dir)) {\n return dir;\n }\n\n try {\n return new URL(dir, document.baseURI).href;\n } catch (e) {\n log('could not resolve fontsDirectory \"%s\": %s', dir, e && e.message);\n return null;\n }\n};\n\n/**\n * Version-pinned CDN fallback for the KaTeX fonts.\n *\n * Some symbols are composed from Private Use Area glyphs that exist only in\n * those fonts: `\\\\neq` is U+E020 (a negation slash) overlapped on `=`, and\n * `\\\\nsim` / `\\\\ncong` work the same way. With no fonts the browser substitutes\n * an arbitrary glyph for U+E020, so those keys render as garbage rather than\n * simply falling back to a plainer face.\n *\n * The version comes from MathLive itself, so the fonts always match the engine.\n * Hosts that would rather not depend on a third party should serve the fonts and\n * call `configureFonts('/their/path')`, or pass `null` to opt out.\n */\nconst FALLBACK_MATHLIVE_VERSION = '0.110.0';\n\nconst cdnFontsDirectory = () => {\n const version = (mathlive && mathlive.version && mathlive.version.mathlive) || FALLBACK_MATHLIVE_VERSION;\n\n // NOTE: `/fonts`, not `/dist/fonts` - the published package root holds them.\n return `https://unpkg.com/mathlive@${version}/fonts`;\n};\n\n/**\n * Tell the package where the MathLive fonts are served from.\n *\n * Call before `loadMathLive()`.\n *\n * - a path/URL: served by you, no third-party request\n * - `null`: skip font loading; note `\\\\neq`, `\\\\nsim` and `\\\\ncong` then\n * render incorrectly, being built from Private Use Area glyphs\n * - not called: falls back to a version-pinned CDN\n *\n * The fonts ship inside the `mathlive` package (`node_modules/mathlive/fonts`)\n * ready to copy into whatever the host app serves statically.\n *\n * @param {string|null} [dir]\n */\nexport const configureFonts = (dir) => {\n fontsDirectory = dir;\n\n if (mathlive) {\n mathlive.MathfieldElement.fontsDirectory = dir === undefined ? cdnFontsDirectory() : absoluteFontsDirectory(dir);\n }\n};\n\n/**\n * What the spacebar inserts in math mode.\n *\n * MathLive's `mathModeSpace` defaults to an empty string, which makes the\n * spacebar a no-op - users cannot type a space at all. `\\\\ ` (a LaTeX control\n * space) is what MathQuill serialised spaces as, so existing content and the\n * MathJax renderer in @pie-lib/math-rendering both already understand it.\n *\n * A literal \" \" is not usable: LaTeX skips raw whitespace.\n */\nexport const MATH_MODE_SPACE = '\\\\ ';\n\n/**\n * Custom macros for the pie-specific commands that the MathQuill fork\n * understood but stock LaTeX does not.\n *\n * Kept deliberately in sync with the MathJax macros in\n * @pie-lib/math-rendering (`render-math.js`) so the same latex renders the same\n * way in the editor and in the static renderer.\n */\nexport const PIE_MACROS = {\n // Argument-less symbols. Atomic is correct here: backspace should remove the\n // whole glyph, and there is nothing to type into.\n parallelogram: '\\\\htmlData{pie-macro=parallelogram}{\\\\unicode{\"25B1}}',\n napprox: '\\\\not\\\\approx',\n nsim: '\\\\not\\\\sim',\n ncong: '\\\\not\\\\cong',\n nparallel: '\\\\not\\\\parallel',\n perpendicular: '\\\\perp',\n divide: '\\\\div',\n degree: '^{\\\\circ}',\n square: '\\\\unicode{\"25A1}',\n\n // Argument-taking commands, kept ONLY so previously authored latex still\n // parses and renders. They are never used for editing: MathLive serialises a\n // macro from the arguments it was created with, so text typed inside the\n // expansion never comes back out of `getValue('latex')`. Anything entering a\n // mathfield is rewritten to the native equivalent first - see\n // `toNativeCommands` in latex-bridge.\n longdiv: '\\\\enclose{longdiv}{#1}',\n overarc: '\\\\overparen{#1}',\n abs: '\\\\left|#1\\\\right|',\n};\n\n/**\n * Registry for `registerEmbed`.\n *\n * MathLive has no embed plugin system, so an embed is expressed as a macro that\n * expands to real LaTeX. `\\htmlData{embed=<name>}` tags the rendered output so\n * consumers can target it with CSS exactly as they targeted the old\n * `htmlString` markup.\n *\n * Known embeds map to native constructs:\n * - `newLine` -> structural, handled by latex-bridge (`\\displaylines` + `\\\\`)\n * - `answerBlock`-> `\\placeholder{}` (interactive, read via the prompts API)\n *\n * @type {Map<string, {factory: Function, latex: string}>}\n */\nconst embeds = new Map();\n\nconst KNOWN_EMBED_LATEX = {\n // newLine is structural: it is translated by latex-bridge before it ever\n // reaches MathLive, so the macro only needs to be harmless.\n newLine: '',\n answerBlock: '\\\\placeholder{}',\n};\n\nlet loadWarned = false;\n\n/** Apply post-load configuration exactly once. */\nconst configureLoaded = () => {\n // Always replace MathLive's relative `'./fonts/'` default: it throws\n // \"Invalid base URL\" when bundled. Use the host's copy if one was configured,\n // otherwise the version-pinned CDN.\n if (fontsDirectory === undefined) {\n log(\n 'no fontsDirectory configured - falling back to the CDN (%s). ' +\n 'Serve the fonts yourself and call configureFonts(\"/path/to/fonts\") to avoid the network request, ' +\n 'or configureFonts(null) to opt out.',\n cdnFontsDirectory(),\n );\n }\n\n mathlive.MathfieldElement.fontsDirectory =\n fontsDirectory === undefined ? cdnFontsDirectory() : absoluteFontsDirectory(fontsDirectory);\n\n injectCoreStylesheet();\n};\n\n/**\n * CSS that has to live *inside* a mathfield's shadow root.\n *\n * A live `<math-field>` renders in shadow DOM (`attachShadow({mode:'open'})`),\n * so nothing in the host page's stylesheets reaches it. The stretchy-accent\n * problem therefore needs fixing twice: once for static markup (see\n * `placeholderStyles`) and once here for the editor.\n *\n * MathLive centres an accent with `margin-left: <half the content width>` as an\n * inline style. For a stretchy accent that also shrinks its containing block\n * (`.ML__center` is position:relative), so the arc ends up half-width and offset\n * - visibly failing to span the text underneath.\n *\n * `:has(.ML__stretchy)` keeps the fix to stretchy accents; single-glyph accents\n * (`\\hat{x}`, `\\vec{x}`) still need their centring offset.\n */\nconst SHADOW_CSS = '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}';\n\n/**\n * Apply {@link SHADOW_CSS} inside a mathfield's shadow root.\n *\n * Uses `adoptedStyleSheets` when available (which is how MathLive loads its own\n * stylesheets) and falls back to appending a <style> node.\n *\n * @param {HTMLElement} mathField\n */\nexport const applyShadowStyles = (mathField) => {\n const root = mathField && mathField.shadowRoot;\n\n if (!root) {\n return;\n }\n\n try {\n if ('adoptedStyleSheets' in root && typeof CSSStyleSheet !== 'undefined') {\n // Do not re-add on a re-render.\n if (root.__pieAccentSheet) {\n return;\n }\n\n const sheet = new CSSStyleSheet();\n\n sheet.replaceSync(SHADOW_CSS);\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n root.__pieAccentSheet = sheet;\n\n return;\n }\n\n if (!root.querySelector('style[data-pie-accent]')) {\n const style = document.createElement('style');\n\n style.setAttribute('data-pie-accent', '');\n style.textContent = SHADOW_CSS;\n root.appendChild(style);\n }\n } catch (e) {\n log('could not apply shadow styles to the mathfield: %s', e && e.message);\n }\n};\n\n/**\n * Ensure MathLive's \"core\" stylesheet is in the document.\n *\n * `convertLatexToMarkup` - which renders keypad labels and static math - does\n * NOT inject it, while `renderMathInElement` and live mathfields do. Without it\n * the generated markup is unstyled: glyphs misalign and the <svg> used by\n * stretchy accents lays out statically at an unbounded width.\n *\n * Hosts that can import CSS should `import 'mathlive/static.css'`. For bundles\n * that cannot handle CSS imports (pie-elements ships JS-only web components),\n * this triggers MathLive's own injection against a detached element, so the\n * styles come from MathLive itself rather than being duplicated here.\n */\nconst injectCoreStylesheet = () => {\n if (typeof document === 'undefined' || !mathlive || !mathlive.renderMathInElement) {\n return;\n }\n\n try {\n mathlive.renderMathInElement(document.createElement('span'));\n } catch (e) {\n log('could not trigger MathLive core stylesheet injection: %s', e && e.message);\n }\n};\n\n/**\n * Load MathLive synchronously when the bundler allows it.\n *\n * `require` keeps MathLive inside the host's bundle. An `import()` would make\n * webpack emit a separate chunk, and a deployment that does not serve that\n * chunk fails with a 404 at runtime - leaving every mathfield and keypad label\n * blank with no obvious cause. Being in the main bundle also makes the engine\n * available on first render, so callers that run synchronously (applyStaticMath,\n * keypad labels) work without a second pass.\n *\n * Returns undefined during SSR or if the module is genuinely unavailable.\n *\n * @returns {object|undefined}\n */\nexport const loadMathLiveSync = () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (!mathlive) {\n try {\n // eslint-disable-next-line global-require\n mathlive = require('mathlive');\n configureLoaded();\n } catch (e) {\n log('synchronous MathLive load unavailable: %s', e && e.message);\n return undefined;\n }\n }\n\n return mathlive;\n};\n\n/**\n * Load MathLive. Prefers the synchronous path; falls back to a dynamic import.\n * Resolves to undefined during SSR.\n *\n * @returns {Promise<object|undefined>}\n */\nexport const loadMathLive = async () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (mathlive) {\n return mathlive;\n }\n\n if (loadMathLiveSync()) {\n return mathlive;\n }\n\n try {\n mathlive = await import('mathlive');\n configureLoaded();\n } catch (e) {\n // Surface this once: a silent failure here renders every field and keypad\n // label blank, which is very hard to trace back to a module load.\n // Skipped under test, where jsdom cannot load the browser build.\n if (!loadWarned && process.env.NODE_ENV !== 'test') {\n loadWarned = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[@pie-lib/math-input-mathlive] MathLive could not be loaded; math input will not render. ' +\n 'If this is a bundling issue, ensure \"mathlive\" is resolvable from the host bundle. Cause: ' +\n (e && e.message),\n );\n }\n\n return undefined;\n }\n\n return mathlive;\n};\n\n/**\n * Synchronous accessor for an already-loaded MathLive.\n * @returns {object|undefined}\n */\nexport const getMathLive = () => mathlive;\n\n/**\n * The macro dictionary to hand to a mathfield: pie macros plus anything\n * registered through `registerEmbed`.\n *\n * @returns {object}\n */\nexport const getMacros = () => {\n const out = { ...PIE_MACROS };\n\n embeds.forEach(({ latex }, name) => {\n out[name] = `\\\\htmlData{embed=${name}}{${latex}}`;\n });\n\n return out;\n};\n\n/**\n * Register an embed. API-compatible with @pie-lib/math-input's `registerEmbed`\n * so existing callers do not change.\n *\n * MathQuill's factory returns `{ htmlString, text, latex }`. Only the\n * declarative parts survive: `latex` round-trips through a macro and the\n * styling hook becomes a `data-embed` attribute. Arbitrary DOM injection via\n * `htmlString` has no MathLive equivalent and is ignored.\n *\n * @param {string} name\n * @param {Function} factory\n */\nexport function registerEmbed(name, factory) {\n if (!name || typeof factory !== 'function') {\n return;\n }\n\n let definition = {};\n\n try {\n definition = factory() || {};\n } catch (e) {\n log('embed factory threw for \"%s\": %s', name, e.message);\n }\n\n const latex = Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name)\n ? KNOWN_EMBED_LATEX[name]\n : definition.mathliveLatex || '\\\\placeholder{}';\n\n if (!Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name) && !definition.mathliveLatex) {\n // Unknown third-party embed: degrade instead of throwing. `htmlString`\n // cannot be reproduced, so it renders as an editable slot.\n log(\n 'embed \"%s\" is not natively supported by MathLive; rendering as a placeholder. ' +\n 'Provide `mathliveLatex` in the factory result to control this.',\n name,\n );\n }\n\n embeds.set(name, { factory, latex });\n}\n\n/**\n * Embeds registered so far. Exposed for tests/diagnostics.\n * @returns {string[]}\n */\nexport const registeredEmbeds = () => Array.from(embeds.keys());\n\n/** Reset the embed registry. Test helper. */\nexport const __resetEmbeds = () => embeds.clear();\n\n/** Inject a stub MathLive instance. Test helper. */\nexport const __setMathLiveForTest = (stub) => {\n mathlive = stub;\n};\n\n/**\n * Render static math into an element. API-compatible with\n * @pie-lib/math-input's `applyStaticMath`.\n *\n * Callers written against MathQuill invoke this synchronously from lifecycle\n * methods, where MathLive (a dynamic import) may not have loaded yet. Rather\n * than silently rendering nothing, this kicks off the load and re-applies once\n * the engine is ready, so the element fills in on the next tick.\n *\n * @param {HTMLElement} element\n * @param {string} [latex] assigned to the element before rendering\n * @param {object} [options] `{ macros }` overrides\n * @returns {HTMLElement|undefined} the element, or undefined if deferred\n */\nexport function applyStaticMath(element, latex, options = {}) {\n if (!element || typeof window === 'undefined') {\n return undefined;\n }\n\n // Capture the source now: if we defer, the element's textContent may have\n // been overwritten by the time MathLive is ready.\n const source = latex === undefined || latex === null ? element.textContent : latex;\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml) {\n log('applyStaticMath called before MathLive loaded - deferring until it is ready');\n\n loadMathLive().then((loaded) => {\n // The element may have been unmounted while loading.\n if (loaded && element.isConnected !== false) {\n applyStaticMath(element, source, options);\n }\n });\n\n return undefined;\n }\n\n element.innerHTML = ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(source)), {\n macros: { ...getMacros(), ...(options.macros || {}) },\n });\n\n return element;\n}\n\n/**\n * Convert latex to markup using the pie macro set. Used for keypad labels and\n * any read-only rendering that does not need a live mathfield.\n *\n * @param {string} latex\n * @param {object} [options]\n * @returns {string} HTML markup, or '' if MathLive is not loaded\n */\nexport function latexToMarkup(latex, options = {}) {\n // Try the synchronous load so the very first render can produce markup\n // instead of falling back to raw latex.\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml || !latex) {\n return '';\n }\n\n try {\n // Empty groups render as nothing in static markup, so give them a visible\n // box. This covers every static path: keypad labels, mf.Static in display\n // mode, and applyStaticMath.\n return ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(latex)), {\n macros: { ...getMacros(), ...(options.macros || {}) },\n ...options,\n });\n } catch (e) {\n log('convertLatexToMarkup failed for \"%s\": %s', latex, e.message);\n return '';\n }\n}\n\nexport { NEWLINE_EMBED };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAkF,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,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