@pie-lib/math-input-mathlive 1.1.4 → 1.1.5-beta.2

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 CHANGED
@@ -108,19 +108,28 @@ widget do not port and need a redesign (`mf.getElementInfo()` exposes per-elemen
108
108
  corrupt these fonts (it emits a JS module under a `.woff2` name). Exclude
109
109
  mathlive from such rules - see `packages/demo/next.config.js`.
110
110
 
111
+ **Fonts are required, not cosmetic.** Some symbols are composed from Private
112
+ Use Area glyphs that exist only in the KaTeX fonts: `\neq` is U+E020 (a
113
+ negation slash) overlapped on `=`, and `\nsim` / `\ncong` are the same. With
114
+ no fonts the browser substitutes an arbitrary glyph for U+E020, so those keys
115
+ render as garbage rather than in a plainer face.
116
+
111
117
  **Alternative** - serve the fonts yourself (a static path, or a CDN):
112
118
 
113
119
  ```js
114
120
  import { configureFonts } from '@pie-lib/math-input-mathlive';
115
121
 
116
122
  configureFonts('/mathlive-fonts'); // before loadMathLive()
117
- configureFonts('https://unpkg.com/mathlive@0.110.0/dist/fonts');
118
- configureFonts(null); // system fonts
123
+ configureFonts('https://unpkg.com/mathlive@0.110.0/fonts'); // note: /fonts, /dist/fonts 404s
124
+ configureFonts(null); // opt out; \neq and friends will render incorrectly
119
125
  ```
120
126
 
121
- Paths are resolved to absolute URLs against `document.baseURI`. If you neither
122
- import the stylesheet nor call `configureFonts`, the package disables font
123
- loading rather than leaving MathLive's crashing default in place.
127
+ Paths are resolved to absolute URLs against `document.baseURI`.
128
+
129
+ If you neither import the stylesheet nor call `configureFonts`, the package
130
+ falls back to a **version-pinned CDN** - `https://unpkg.com/mathlive@<engine
131
+ version>/fonts` - so those glyph-dependent symbols still render. Serve the
132
+ fonts yourself to avoid the third-party request.
124
133
 
125
134
  - **Custom macros.** `PIE_MACROS` covers the pie-specific commands the MathQuill
126
135
  fork understood (`\parallelogram`, `\longdiv`, `\napprox`, …) and is kept in
@@ -27,10 +27,10 @@ var _keys = require("../keys");
27
27
  var _keysLayout = require("./keys-layout");
28
28
  var _commonStyles = require("../mf/common-styles");
29
29
  var _mathliveInstance = require("../mathlive-instance");
30
- 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; }
31
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
30
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
33
31
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
32
+ 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; }
33
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
34
34
  var log = (0, _debug["default"])('pie-lib:math-input-mathlive:keypad');
35
35
 
36
36
  /**
@@ -45,26 +45,24 @@ var log = (0, _debug["default"])('pie-lib:math-input-mathlive:keypad');
45
45
  // Evaluating them in a plain object literal runs them at module load, which
46
46
  // breaks any consumer that mocks a subset of @pie-lib/render-ui.
47
47
  var LabelHolder = (0, _styles.styled)('span')(function () {
48
- return {
48
+ return _objectSpread({
49
49
  pointerEvents: 'none',
50
50
  textTransform: 'none',
51
51
  color: _renderUi.color.text(),
52
- display: 'inline-flex',
53
- alignItems: 'center',
54
- justifyContent: 'center',
52
+ // Deliberately inline-block, NOT inline-flex: MathLive's markup relies on
53
+ // normal inline flow. Making its spans flex items collapses their width, and
54
+ // stretchy accents render an <svg width="100%" preserveAspectRatio="none">
55
+ // that then squeezes into a spike instead of spanning the content.
56
+ display: 'inline-block',
57
+ textAlign: 'center',
55
58
  lineHeight: 1,
56
- // Never let a label size its grid column. Stretchy accents
57
- // (\overrightarrow, \overleftrightarrow, \overarc) render an <svg> that
58
- // mathlive-static.css positions absolutely at width:100%; if that stylesheet
59
- // is missing the svg lays out statically and expands without bound, dragging
60
- // the whole column across the screen. `overflow: hidden` also collapses the
61
- // label's min-content contribution, so the grid can't blow out either way.
59
+ // Keep a label from sizing its grid column. `overflow: hidden` also collapses
60
+ // the label's min-content contribution, so a wide accent cannot drag the
61
+ // column across the screen. The svg's own positioning is left to
62
+ // mathlive-static.css (injected by the package) - duplicating it here broke
63
+ // the accent's containing block.
62
64
  maxWidth: '100%',
63
65
  overflow: 'hidden',
64
- '& svg': {
65
- position: 'absolute',
66
- width: '100%'
67
- },
68
66
  // Answer-block / empty-slot boxes inside a label.
69
67
  '& .ML__placeholder': {
70
68
  backgroundColor: _renderUi.color.keypadEmptyPlaceholder ? _renderUi.color.keypadEmptyPlaceholder() : undefined
@@ -75,7 +73,7 @@ var LabelHolder = (0, _styles.styled)('span')(function () {
75
73
  '& [data-pie-empty]': {
76
74
  opacity: 0.5
77
75
  }
78
- };
76
+ }, _commonStyles.rootIndexStyles);
79
77
  });
80
78
  var LatexLabel = exports.LatexLabel = /*#__PURE__*/function (_React$Component) {
81
79
  function LatexLabel(props) {
@@ -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"],"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C;AAChE,CAAC;AAAA,IAAA5L,gBAAA,aAZUiH,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAAzJ,OAAA,cAiKY6E,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_Button","_IconButton","_styles","_debug","_lodashEs","_renderUi","_keys","_keysLayout","_commonStyles","_mathliveInstance","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","ownKeys","r","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","log","debug","LabelHolder","styled","pointerEvents","textTransform","color","text","display","textAlign","lineHeight","maxWidth","overflow","backgroundColor","keypadEmptyPlaceholder","undefined","opacity","rootIndexStyles","LatexLabel","exports","_React$Component","props","_this","_classCallCheck2","state","markup","latexToMarkup","latex","_inherits2","_createClass2","key","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_context","prev","next","abrupt","loadMathLive","unmounted","setState","warned","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","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, rootIndexStyles } from '../mf/common-styles';\nimport { loadMathLive, latexToMarkup } from '../mathlive-instance';\n\nconst log = debug('pie-lib:math-input-mathlive:keypad');\n\n/**\n * A LaTeX keypad label.\n *\n * The MathQuill implementation rendered every LaTeX label as its own\n * `MQ.StaticMath` instance. Here each label is static HTML produced once by\n * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math\n * instances.\n */\n// 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 // A readable index on the nth-root key. Carried by the label itself, not only\n // by the keypad container, so it holds wherever a LatexLabel is mounted.\n ...rootIndexStyles,\n}));\n\nexport class LatexLabel extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = { markup: latexToMarkup(props.latex) };\n }\n\n async componentDidMount() {\n // MathLive may not have finished loading when the keypad first mounts.\n if (this.state.markup) {\n return;\n }\n\n await loadMathLive();\n\n if (this.unmounted) {\n return;\n }\n\n const markup = latexToMarkup(this.props.latex);\n\n if (markup) {\n this.setState({ markup });\n return;\n }\n\n // Still nothing: the engine is genuinely unavailable (a missing chunk, a\n // blocked request). Keep the raw-latex fallback visible rather than an\n // empty button, and log once so this is diagnosable.\n if (!LatexLabel.warned) {\n LatexLabel.warned = true;\n log('MathLive unavailable - keypad labels are falling back to raw latex');\n }\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex !== this.props.latex) {\n this.setState({ markup: latexToMarkup(this.props.latex) });\n }\n }\n\n componentWillUnmount() {\n this.unmounted = true;\n }\n\n render() {\n const { markup } = this.state;\n\n // Fall back to the raw latex so a button is never blank.\n return markup ? (\n // eslint-disable-next-line react/no-danger\n <LabelHolder 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,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,aAAA,GAAAV,OAAA;AACA,IAAAW,iBAAA,GAAAX,OAAA;AAAmE,SAAAY,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAAA,aAAAH,CAAA,EAAAQ,WAAA,IAAAP,CAAA,CAAAQ,KAAA,CAAAT,CAAA,EAAAE,CAAA;AAAA,SAAAG,0BAAA,cAAAL,CAAA,IAAAU,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAV,CAAA,aAAAK,yBAAA,YAAAA,0BAAA,aAAAL,CAAA;AAAA,SAAAc,QAAAZ,CAAA,EAAAa,CAAA,QAAAf,CAAA,GAAAgB,MAAA,CAAAC,IAAA,CAAAf,CAAA,OAAAc,MAAA,CAAAE,q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,EAAEhF,qBAAS,CAACkH,SAAS,CAAC,CAAClH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACmH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAAhL,gBAAA,aAZUqG,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAA1J,OAAA,cAiKY8E,MAAM","ignoreList":[]}
@@ -25,8 +25,10 @@ var overRightArrow = exports.overRightArrow = set({
25
25
  });
26
26
  var overLeftRightArrow = exports.overLeftRightArrow = set({
27
27
  name: 'Segment',
28
- latex: '\\overleftrightarrow{\\overline{}}',
29
- // used this notation to display the pink box
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
- latex: '\\overarc{\\overline{}}',
62
- // used this notation to display the pink box
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({
@@ -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 latex: '\\\\overleftrightarrow{\\\\overline{}}', // used this notation to display the pink box\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 latex: '\\\\overarc{\\\\overline{}}', // used this notation to display the pink box\n command: '\\\\overarc',\n});\nexport const measureOfAngle = set({\n name: 'Measured Angle',\n latex: '\\\\measuredangle',\n command: ['m', '\\\\angle'],\n});\n\nexport const triangle = set({\n name: 'Triangle',\n latex: '\\\\triangle',\n command: '\\\\triangle',\n});\n\nexport const square = set({\n name: 'Square',\n latex: '\\\\square',\n command: '\\\\square',\n});\n\nexport const parallelogram = set({\n name: 'Parallelogram',\n latex: '\\\\parallelogram',\n command: '\\\\parallelogram',\n});\n\nexport const circledDot = set({\n name: 'Circled Dot',\n latex: '\\\\odot',\n command: '\\\\odot',\n});\n\nexport const degree = set({\n name: 'Degree',\n latex: '\\\\degree',\n command: '\\\\degree',\n});\n\nexport const similarTo = set({\n name: 'Similar',\n command: '\\\\sim',\n latex: '\\\\sim',\n});\n\nexport const congruentTo = set({\n name: 'Congruent To',\n command: '\\\\cong',\n latex: '\\\\cong',\n});\n\nexport const notCongruentTo = set({\n name: 'Not Congruent To',\n command: '\\\\ncong',\n latex: '\\\\ncong',\n});\n\nexport const primeArcminute = set({\n name: 'Prime',\n label: 'pam',\n // eslint-disable-next-line\n latex: \"'\",\n // eslint-disable-next-line\n write: \"'\",\n});\n\nexport const doublePrimeArcSecond = set({\n name: 'Double Prime',\n // eslint-disable-next-line\n latex: \"''\",\n // eslint-disable-next-line\n write: \"''\",\n});\n\nexport const leftArrow = set({\n name: 'Left Arrow',\n latex: '\\\\leftarrow',\n command: '\\\\leftarrow',\n});\n\nexport const rightArrow = set({\n name: 'Right Arrow',\n latex: '\\\\rightarrow',\n command: '\\\\rightarrow',\n});\n\nexport const leftrightArrow = set({\n name: 'Left and Right Arrow',\n latex: '\\\\leftrightarrow',\n command: '\\\\leftrightarrow',\n});\n"],"mappings":";;;;;;;;;;AAAA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAIC,CAAC;EAAA,OAAAC,aAAA,CAAAA,aAAA,KAAWD,CAAC;IAAEE,QAAQ,EAAE;EAAU;AAAA,CAAG;AAE5C,IAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGJ,GAAG,CAAC;EAC1BM,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,cAAc;EACrBC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMC,cAAc,GAAAJ,OAAA,CAAAI,cAAA,GAAGT,GAAG,CAAC;EAChCM,IAAI,EAAE,KAAK;EACXC,KAAK,EAAE,oBAAoB;EAC3BC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAME,kBAAkB,GAAAL,OAAA,CAAAK,kBAAA,GAAGV,GAAG,CAAC;EACpCM,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,oCAAoC;EAAE;EAC7CI,MAAM,EAAE,IAAI;EACZH,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMI,OAAO,GAAAP,OAAA,CAAAO,OAAA,GAAGZ,GAAG,CAAC;EACzBM,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,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T,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":[]}
1
+ {"version":3,"file":"geometry.js","names":["set","o","_objectSpread","category","overline","exports","name","latex","command","overRightArrow","overLeftRightArrow","symbol","segment","write","label","parallel","notParallel","perpindicular","angle","overArc","measureOfAngle","triangle","square","parallelogram","circledDot","degree","similarTo","congruentTo","notCongruentTo","primeArcminute","doublePrimeArcSecond","leftArrow","rightArrow","leftrightArrow"],"sources":["../../src/keys/geometry.js"],"sourcesContent":["const set = (o) => ({ ...o, category: 'geometry' });\n\nexport const overline = set({\n name: 'Line',\n latex: '\\\\overline{}',\n command: '\\\\overline',\n});\n\nexport const overRightArrow = set({\n name: 'Ray',\n latex: '\\\\overrightarrow{}',\n command: '\\\\overrightarrow',\n});\n\nexport const overLeftRightArrow = set({\n name: 'Segment',\n // MathQuill needed a nested \\overline{} to draw the empty box; MathLive\n // renders that as a real line, so the label showed a spurious bar under the\n // arrows. `withVisibleEmptySlots` supplies the box for `{}` instead.\n latex: '\\\\overleftrightarrow{}',\n symbol: 'AB',\n command: '\\\\overleftrightarrow',\n});\n\nexport const segment = set({\n name: 'Segment',\n latex: '\\\\overleftrightarrow{AB}',\n write: '\\\\overleftrightarrow{AB}',\n label: 'AB',\n});\n\nexport const parallel = set({\n name: 'Parallel',\n latex: '\\\\parallel',\n command: '\\\\parallel',\n});\n\nexport const notParallel = set({\n name: 'Not Parallel',\n latex: '\\\\nparallel',\n command: '\\\\nparallel',\n});\n\nexport const perpindicular = set({\n name: 'Perpendicular',\n latex: '\\\\perp',\n command: '\\\\perpendicular',\n});\n\nexport const angle = set({\n name: 'Angle',\n latex: '\\\\angle',\n command: '\\\\angle',\n});\nexport const overArc = set({\n name: 'Over arc',\n // See the note on Segment above: the nested \\overline{} drew a straight line\n // instead of leaving the arc visible.\n latex: '\\\\overarc{}',\n command: '\\\\overarc',\n});\nexport const measureOfAngle = set({\n name: 'Measured Angle',\n latex: '\\\\measuredangle',\n command: ['m', '\\\\angle'],\n});\n\nexport const triangle = set({\n name: 'Triangle',\n latex: '\\\\triangle',\n command: '\\\\triangle',\n});\n\nexport const square = set({\n name: 'Square',\n latex: '\\\\square',\n command: '\\\\square',\n});\n\nexport const parallelogram = set({\n name: 'Parallelogram',\n latex: '\\\\parallelogram',\n command: '\\\\parallelogram',\n});\n\nexport const circledDot = set({\n name: 'Circled Dot',\n latex: '\\\\odot',\n command: '\\\\odot',\n});\n\nexport const degree = set({\n name: 'Degree',\n latex: '\\\\degree',\n command: '\\\\degree',\n});\n\nexport const similarTo = set({\n name: 'Similar',\n command: '\\\\sim',\n latex: '\\\\sim',\n});\n\nexport const congruentTo = set({\n name: 'Congruent To',\n command: '\\\\cong',\n latex: '\\\\cong',\n});\n\nexport const notCongruentTo = set({\n name: 'Not Congruent To',\n command: '\\\\ncong',\n latex: '\\\\ncong',\n});\n\nexport const primeArcminute = set({\n name: 'Prime',\n label: 'pam',\n // eslint-disable-next-line\n latex: \"'\",\n // eslint-disable-next-line\n write: \"'\",\n});\n\nexport const doublePrimeArcSecond = set({\n name: 'Double Prime',\n // eslint-disable-next-line\n latex: \"''\",\n // eslint-disable-next-line\n write: \"''\",\n});\n\nexport const leftArrow = set({\n name: 'Left Arrow',\n latex: '\\\\leftarrow',\n command: '\\\\leftarrow',\n});\n\nexport const rightArrow = set({\n name: 'Right Arrow',\n latex: '\\\\rightarrow',\n command: '\\\\rightarrow',\n});\n\nexport const leftrightArrow = set({\n name: 'Left and Right Arrow',\n latex: '\\\\leftrightarrow',\n command: '\\\\leftrightarrow',\n});\n"],"mappings":";;;;;;;;;;AAAA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAIC,CAAC;EAAA,OAAAC,aAAA,CAAAA,aAAA,KAAWD,CAAC;IAAEE,QAAQ,EAAE;EAAU;AAAA,CAAG;AAE5C,IAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGJ,GAAG,CAAC;EAC1BM,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,cAAc;EACrBC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMC,cAAc,GAAAJ,OAAA,CAAAI,cAAA,GAAGT,GAAG,CAAC;EAChCM,IAAI,EAAE,KAAK;EACXC,KAAK,EAAE,oBAAoB;EAC3BC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAME,kBAAkB,GAAAL,OAAA,CAAAK,kBAAA,GAAGV,GAAG,CAAC;EACpCM,IAAI,EAAE,SAAS;EACf;EACA;EACA;EACAC,KAAK,EAAE,wBAAwB;EAC/BI,MAAM,EAAE,IAAI;EACZH,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMI,OAAO,GAAAP,OAAA,CAAAO,OAAA,GAAGZ,GAAG,CAAC;EACzBM,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,0BAA0B;EACjCM,KAAK,EAAE,0BAA0B;EACjCC,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMC,QAAQ,GAAAV,OAAA,CAAAU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c;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/keys/misc.js CHANGED
@@ -29,10 +29,17 @@ var brackets = exports.brackets = set({
29
29
  symbol: '[ ]',
30
30
  command: '['
31
31
  });
32
+
33
+ // `%` must be escaped. MathQuill was not a real LaTeX parser: it defined
34
+ // `LatexCmds['%']` as a symbol that *serialised* to `\%`, so a bare `%` worked
35
+ // both as a label and as a command. MathLive parses LaTeX properly, where `%`
36
+ // begins a comment - it rendered nothing (a blank button) and, once inserted,
37
+ // silently swallowed the rest of the expression. `\%` is what MathQuill stored
38
+ // all along, so this changes the key only, not the saved latex.
32
39
  var percentage = exports.percentage = set({
33
40
  name: 'Percent',
34
- latex: '%',
35
- command: '%'
41
+ latex: '\\%',
42
+ command: '\\%'
36
43
  });
37
44
  var approx = exports.approx = set({
38
45
  latex: '\\approx',
@@ -1 +1 @@
1
- {"version":3,"file":"misc.js","names":["_utils","require","set","mkSet","plusMinus","exports","name","latex","write","absValue","symbol","command","parenthesis","brackets","percentage","approx","ariaLabel","nApprox","notEqual","similar","notSimilar"],"sources":["../../src/keys/misc.js"],"sourcesContent":["import { mkSet } from './utils';\n\nconst set = mkSet('misc');\n\nexport const plusMinus = set({\n name: 'Plus or Minus',\n latex: '\\\\pm',\n write: '\\\\pm',\n});\n\nexport const absValue = set({\n name: 'Absolute Value',\n latex: '\\\\abs{}',\n symbol: '| |',\n command: '|',\n});\n\nexport const parenthesis = set({\n name: 'Parenthesis',\n latex: '\\\\left(\\\\right)',\n symbol: '( )',\n command: '(',\n});\n\nexport const brackets = set({\n name: 'Brackets',\n latex: '\\\\left[\\\\right]',\n symbol: '[ ]',\n command: '[',\n});\n\nexport const percentage = set({\n name: 'Percent',\n latex: '%',\n command: '%',\n});\n\nexport const approx = set({\n latex: '\\\\approx',\n command: '\\\\approx',\n ariaLabel: 'Approximately equal to',\n});\n\nexport const nApprox = set({\n latex: '\\\\napprox',\n command: '\\\\napprox',\n ariaLabel: 'Not pproximately equal to',\n});\n\nexport const notEqual = set({\n latex: '\\\\neq',\n command: '\\\\neq',\n ariaLabel: 'Not equals',\n});\n\nexport const similar = set({\n latex: '\\\\sim',\n command: '\\\\sim',\n ariaLabel: 'Similar',\n});\nexport const notSimilar = set({\n latex: '\\\\nsim',\n command: '\\\\nsim',\n ariaLabel: 'Not similar',\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAMC,GAAG,GAAG,IAAAC,YAAK,EAAC,MAAM,CAAC;AAElB,IAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAGF,GAAG,CAAC;EAC3BI,IAAI,EAAE,eAAe;EACrBC,KAAK,EAAE,MAAM;EACbC,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,IAAMC,QAAQ,GAAAJ,OAAA,CAAAI,QAAA,GAAGP,GAAG,CAAC;EAC1BI,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,SAAS;EAChBG,MAAM,EAAE,KAAK;EACbC,OAAO,EAAE;AACX,CAAC,CAAC;AAEK,IAAMC,WAAW,GAAAP,OAAA,CAAAO,WAAA,GAAGV,GAAG,CAAC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3,"file":"misc.js","names":["_utils","require","set","mkSet","plusMinus","exports","name","latex","write","absValue","symbol","command","parenthesis","brackets","percentage","approx","ariaLabel","nApprox","notEqual","similar","notSimilar"],"sources":["../../src/keys/misc.js"],"sourcesContent":["import { mkSet } from './utils';\n\nconst set = mkSet('misc');\n\nexport const plusMinus = set({\n name: 'Plus or Minus',\n latex: '\\\\pm',\n write: '\\\\pm',\n});\n\nexport const absValue = set({\n name: 'Absolute Value',\n latex: '\\\\abs{}',\n symbol: '| |',\n command: '|',\n});\n\nexport const parenthesis = set({\n name: 'Parenthesis',\n latex: '\\\\left(\\\\right)',\n symbol: '( )',\n command: '(',\n});\n\nexport const brackets = set({\n name: 'Brackets',\n latex: '\\\\left[\\\\right]',\n symbol: '[ ]',\n command: '[',\n});\n\n// `%` must be escaped. MathQuill was not a real LaTeX parser: it defined\n// `LatexCmds['%']` as a symbol that *serialised* to `\\%`, so a bare `%` worked\n// both as a label and as a command. MathLive parses LaTeX properly, where `%`\n// begins a comment - it rendered nothing (a blank button) and, once inserted,\n// silently swallowed the rest of the expression. `\\%` is what MathQuill stored\n// all along, so this changes the key only, not the saved latex.\nexport const percentage = set({\n name: 'Percent',\n latex: '\\\\%',\n command: '\\\\%',\n});\n\nexport const approx = set({\n latex: '\\\\approx',\n command: '\\\\approx',\n ariaLabel: 'Approximately equal to',\n});\n\nexport const nApprox = set({\n latex: '\\\\napprox',\n command: '\\\\napprox',\n ariaLabel: 'Not pproximately equal to',\n});\n\nexport const notEqual = set({\n latex: '\\\\neq',\n command: '\\\\neq',\n ariaLabel: 'Not equals',\n});\n\nexport const similar = set({\n latex: '\\\\sim',\n command: '\\\\sim',\n ariaLabel: 'Similar',\n});\nexport const notSimilar = set({\n latex: '\\\\nsim',\n command: '\\\\nsim',\n ariaLabel: 'Not similar',\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAMC,GAAG,GAAG,IAAAC,YAAK,EAAC,MAAM,CAAC;AAElB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G,CAAC;EAC1BK,KAAK,EAAE,OAAO;EACdI,OAAO,EAAE,OAAO;EAChBK,SAAS,EAAE;AACb,CAAC,CAAC;AAEK,IAAMG,OAAO,GAAAd,OAAA,CAAAc,OAAA,GAAGjB,GAAG,CAAC;EACzBK,KAAK,EAAE,OAAO;EACdI,OAAO,EAAE,OAAO;EAChBK,SAAS,EAAE;AACb,CAAC,CAAC;AACK,IAAMI,UAAU,GAAAf,OAAA,CAAAe,UAAA,GAAGlB,GAAG,CAAC;EAC5BK,KAAK,EAAE,QAAQ;EACfI,OAAO,EAAE,QAAQ;EACjBK,SAAS,EAAE;AACb,CAAC,CAAC","ignoreList":[]}
@@ -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 an actual glyph is required.
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 = "\\htmlData{pie-empty=1}{\\unicode{\"25AB}}";
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
  /**
@@ -113,6 +121,36 @@ var toNativeCommands = exports.toNativeCommands = function toNativeCommands(late
113
121
  out = replaceAbs(out);
114
122
  out = out.replace(/\\longdiv\{/g, '\\enclose{longdiv}{');
115
123
  out = out.replace(/\\overarc\{/g, '\\overparen{');
124
+ out = escapeBareComments(out);
125
+ return out;
126
+ };
127
+
128
+ /**
129
+ * Escape an unescaped `%`.
130
+ *
131
+ * In real LaTeX `%` starts a comment, so MathLive discards it *and everything
132
+ * after it*: `50%` renders as `50`, and `x%y` as just `x`. MathQuill had no
133
+ * such notion - it treated `%` as a symbol - so latex from anywhere outside the
134
+ * keypad may still carry a bare one.
135
+ *
136
+ * Only a `%` preceded by an even number of backslashes is bare: `\%` is already
137
+ * escaped, while the `%` in `\\%` (a line break, then a comment) is not.
138
+ *
139
+ * @param {string} latex
140
+ * @returns {string}
141
+ */
142
+ var escapeBareComments = function escapeBareComments(latex) {
143
+ if (latex.indexOf('%') === -1) {
144
+ return latex;
145
+ }
146
+ var out = '';
147
+ // Consecutive backslashes immediately before the current character.
148
+ var backslashes = 0;
149
+ for (var i = 0; i < latex.length; i++) {
150
+ var ch = latex[i];
151
+ out += ch === '%' && backslashes % 2 === 0 ? '\\%' : ch;
152
+ backslashes = ch === '\\' ? backslashes + 1 : 0;
153
+ }
116
154
  return out;
117
155
  };
118
156
 
@@ -234,8 +272,15 @@ var fromMathLive = exports.fromMathLive = function fromMathLive(latex) {
234
272
  * placeholders in the inserted latex.
235
273
  */
236
274
  var COMMANDS_WITH_ARGS = exports.COMMANDS_WITH_ARGS = {
275
+ // An explicit "blank over blank" key: both slots start empty.
237
276
  '\\frac': '\\frac{#?}{#?}',
238
- '/': '\\frac{#?}{#?}',
277
+ // Division, which must behave like MathQuill's `/`: whatever precedes the
278
+ // cursor becomes the numerator and the caret lands in the denominator. `#@`
279
+ // is MathLive's token for "the selection, or the item before the cursor" -
280
+ // this is exactly the template MathLive binds to the `/` key itself. Using
281
+ // `#?` here instead produced an empty fraction and left the typed number
282
+ // stranded outside it.
283
+ '/': '\\frac{#@}{#?}',
239
284
  '\\sqrt': '\\sqrt{#?}',
240
285
  '\\nthroot': '\\sqrt[#?]{#?}',
241
286
  '\\overline': '\\overline{#?}',
@@ -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,iBAAiB,MAAAI,MAAA,CAAML,UAAU,MAAG,CAAC;AAAA;;AAE3G;AACA;AACA;AACA;AACA;AAC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,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","escapeBareComments","indexOf","backslashes","i","length","ch","idx","open","depth","close","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 out = escapeBareComments(out);\n\n return out;\n};\n\n/**\n * Escape an unescaped `%`.\n *\n * In real LaTeX `%` starts a comment, so MathLive discards it *and everything\n * after it*: `50%` renders as `50`, and `x%y` as just `x`. MathQuill had no\n * such notion - it treated `%` as a symbol - so latex from anywhere outside the\n * keypad may still carry a bare one.\n *\n * Only a `%` preceded by an even number of backslashes is bare: `\\%` is already\n * escaped, while the `%` in `\\\\%` (a line break, then a comment) is not.\n *\n * @param {string} latex\n * @returns {string}\n */\nconst escapeBareComments = (latex) => {\n if (latex.indexOf('%') === -1) {\n return latex;\n }\n\n let out = '';\n // Consecutive backslashes immediately before the current character.\n let backslashes = 0;\n\n for (let i = 0; i < latex.length; i++) {\n const ch = latex[i];\n\n out += ch === '%' && backslashes % 2 === 0 ? '\\\\%' : ch;\n backslashes = ch === '\\\\' ? backslashes + 1 : 0;\n }\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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