@pie-lib/math-input-mathlive 1.1.5-beta.3 → 1.1.5-beta.5

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.
@@ -41,11 +41,32 @@ var log = (0, _debug["default"])('pie-lib:math-input-mathlive:keypad');
41
41
  * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math
42
42
  * instances.
43
43
  */
44
+ // Labels that the legacy keypad drew slanted. MathQuill styled `\parallel` as
45
+ // italic, which slants the two bars; MathLive draws it upright. A skew is used
46
+ // rather than `font-style: italic` so the slant does not depend on the font
47
+ // having an italic face for this glyph.
48
+ var SLANTED_LABELS = ['\\parallel'];
49
+ var SLANT = 'skewX(-15deg)';
50
+ // MathLive's `∥` has hairline bars next to the radical sign and the other keys, so
51
+ // they are thickened with a text stroke and stretched a little taller.
52
+ var SLANTED_STROKE = '0.03em currentColor';
53
+ var SLANTED_SCALE_Y = 1.25;
54
+
44
55
  // The `color.*()` helpers must be called lazily, inside the styled callback.
45
56
  // Evaluating them in a plain object literal runs them at module load, which
46
57
  // breaks any consumer that mocks a subset of @pie-lib/render-ui.
47
- var LabelHolder = (0, _styles.styled)('span')(function () {
48
- return _objectSpread({
58
+ var LabelHolder = (0, _styles.styled)('span', {
59
+ shouldForwardProp: function shouldForwardProp(prop) {
60
+ return prop !== 'slanted';
61
+ }
62
+ })(function (_ref) {
63
+ var slanted = _ref.slanted;
64
+ return _objectSpread(_objectSpread({}, slanted && {
65
+ transform: "".concat(SLANT, " scaleY(").concat(SLANTED_SCALE_Y, ")"),
66
+ '& *': {
67
+ WebkitTextStroke: SLANTED_STROKE
68
+ }
69
+ }), {}, {
49
70
  pointerEvents: 'none',
50
71
  textTransform: 'none',
51
72
  color: _renderUi.color.text(),
@@ -161,10 +182,13 @@ var LatexLabel = exports.LatexLabel = /*#__PURE__*/function (_React$Component) {
161
182
  /*#__PURE__*/
162
183
  // eslint-disable-next-line react/no-danger
163
184
  _react["default"].createElement(LabelHolder, {
185
+ slanted: SLANTED_LABELS.includes(this.props.latex),
164
186
  dangerouslySetInnerHTML: {
165
187
  __html: markup
166
188
  }
167
- }) : /*#__PURE__*/_react["default"].createElement(LabelHolder, null, this.props.latex);
189
+ }) : /*#__PURE__*/_react["default"].createElement(LabelHolder, {
190
+ slanted: SLANTED_LABELS.includes(this.props.latex)
191
+ }, this.props.latex);
168
192
  }
169
193
  }]);
170
194
  }(_react["default"].Component);
@@ -209,11 +233,11 @@ var buttonBackground = function buttonBackground(category) {
209
233
  }
210
234
  };
211
235
  };
212
- var StyledButton = (0, _styles.styled)(_Button["default"])(function (_ref) {
213
- var category = _ref.category,
214
- isDelete = _ref.isDelete,
215
- isComma = _ref.isComma,
216
- isDot = _ref.isDot;
236
+ var StyledButton = (0, _styles.styled)(_Button["default"])(function (_ref2) {
237
+ var category = _ref2.category,
238
+ isDelete = _ref2.isDelete,
239
+ isComma = _ref2.isComma,
240
+ isDot = _ref2.isDot;
217
241
  return _objectSpread(_objectSpread({
218
242
  minWidth: 'auto',
219
243
  textTransform: 'none',
@@ -226,8 +250,8 @@ var StyledButton = (0, _styles.styled)(_Button["default"])(function (_ref) {
226
250
  fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
227
251
  });
228
252
  });
229
- var StyledLatexButtonWrapper = (0, _styles.styled)(_Button["default"])(function (_ref2) {
230
- var category = _ref2.category;
253
+ var StyledLatexButtonWrapper = (0, _styles.styled)(_Button["default"])(function (_ref3) {
254
+ var category = _ref3.category;
231
255
  return _objectSpread({
232
256
  textTransform: 'none',
233
257
  padding: 0,
@@ -237,8 +261,8 @@ var StyledLatexButtonWrapper = (0, _styles.styled)(_Button["default"])(function
237
261
  borderRadius: 0
238
262
  }, buttonBackground(category));
239
263
  });
240
- var StyledIconButton = (0, _styles.styled)(_IconButton["default"])(function (_ref3) {
241
- var category = _ref3.category;
264
+ var StyledIconButton = (0, _styles.styled)(_IconButton["default"])(function (_ref4) {
265
+ var category = _ref4.category;
242
266
  return _objectSpread(_objectSpread({
243
267
  minWidth: 'auto'
244
268
  }, buttonBackground(category)), {}, {
@@ -1 +1 @@
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 </St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CAAC;AAAA,IAAAhL,gBAAA,aAZUqG,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAkE,QAAA,GAAA1J,OAAA,cAiKY8E,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_Button","_IconButton","_styles","_debug","_lodashEs","_renderUi","_keys","_keysLayout","_commonStyles","_mathliveInstance","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","ownKeys","r","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","log","debug","SLANTED_LABELS","SLANT","SLANTED_STROKE","SLANTED_SCALE_Y","LabelHolder","styled","shouldForwardProp","prop","_ref","slanted","transform","concat","WebkitTextStroke","pointerEvents","textTransform","color","text","display","textAlign","lineHeight","maxWidth","overflow","backgroundColor","keypadEmptyPlaceholder","undefined","opacity","rootIndexStyles","LatexLabel","exports","_React$Component","props","_this","_classCallCheck2","state","markup","latexToMarkup","latex","_inherits2","_createClass2","key","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_context","prev","next","abrupt","loadMathLive","unmounted","setState","warned","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","createElement","includes","dangerouslySetInnerHTML","__html","React","Component","PropTypes","string","isRequired","createCustomLayout","layoutObj","gridTemplateColumns","columns","gridTemplateRows","rows","gridAutoFlow","KeyPadContainer","commonKeyboardStyles","width","gridRowGap","gridColumnGap","fontFamily","buttonBackground","category","keypadButtonOperator","keypadButton","keypadButtonOperatorHover","keypadButtonHover","StyledButton","Button","_ref2","isDelete","isComma","isDot","minWidth","fontSize","borderRadius","StyledLatexButtonWrapper","_ref3","padding","margin","StyledIconButton","IconButton","_ref4","height","KeyPad","_React$Component2","_this2","setKeypadInteraction","onPress","base","extras","flatten","_toConsumableArray2","sortKeys","noDecimal","write","label","keypadRef","createRef","_this$keypadRef","keyPadElement","current","mainContainer","closest","currentToolbar","controlledKeypadMode","mainContainerPosition","getBoundingClientRect","currentToolbarPosition","difference","top","totalHeight","style","addEventListener","handleKeypadInteraction","_this$keypadRef2","removeEventListener","_this3","_this$props","className","baseSet","additionalKeys","layoutForKeyPad","onFocus","mode","noBaseSet","keysWithoutBaseSet","allKeys","flowKeys","shift","Math","floor","ref","join","map","k","index","command","extra","actions","extraProps","onClick","buttonClick","bind","disabled","keyIsNotAllowed","ariaLabel","name","_extends2","Icon","icon","tabIndex","size","bool","array","object","func","oneOfType","number","_default"],"sources":["../../src/keypad/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport { flatten } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nimport { baseSet } from '../keys';\nimport { sortKeys } from './keys-layout';\nimport { commonKeyboardStyles, rootIndexStyles } from '../mf/common-styles';\nimport { loadMathLive, latexToMarkup } from '../mathlive-instance';\n\nconst log = debug('pie-lib:math-input-mathlive:keypad');\n\n/**\n * A LaTeX keypad label.\n *\n * The MathQuill implementation rendered every LaTeX label as its own\n * `MQ.StaticMath` instance. Here each label is static HTML produced once by\n * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math\n * instances.\n */\n// Labels that the legacy keypad drew slanted. MathQuill styled `\\parallel` as\n// italic, which slants the two bars; MathLive draws it upright. A skew is used\n// rather than `font-style: italic` so the slant does not depend on the font\n// having an italic face for this glyph.\nconst SLANTED_LABELS = ['\\\\parallel'];\nconst SLANT = 'skewX(-15deg)';\n// MathLive's `∥` has hairline bars next to the radical sign and the other keys, so\n// they are thickened with a text stroke and stretched a little taller.\nconst SLANTED_STROKE = '0.03em currentColor';\nconst SLANTED_SCALE_Y = 1.25;\n\n// The `color.*()` helpers must be called lazily, inside the styled callback.\n// Evaluating them in a plain object literal runs them at module load, which\n// breaks any consumer that mocks a subset of @pie-lib/render-ui.\nconst LabelHolder = styled('span', { shouldForwardProp: (prop) => prop !== 'slanted' })(({ slanted }) => ({\n ...(slanted && {\n transform: `${SLANT} scaleY(${SLANTED_SCALE_Y})`,\n '& *': { WebkitTextStroke: SLANTED_STROKE },\n }),\n pointerEvents: 'none',\n textTransform: 'none',\n color: color.text(),\n // Deliberately inline-block, NOT inline-flex: MathLive's markup relies on\n // normal inline flow. Making its spans flex items collapses their width, and\n // stretchy accents render an <svg width=\"100%\" preserveAspectRatio=\"none\">\n // that then squeezes into a spike instead of spanning the content.\n display: 'inline-block',\n textAlign: 'center',\n lineHeight: 1,\n // Keep a label from sizing its grid column. `overflow: hidden` also collapses\n // the label's min-content contribution, so a wide accent cannot drag the\n // column across the screen. The svg's own positioning is left to\n // mathlive-static.css (injected by the package) - duplicating it here broke\n // the accent's containing block.\n maxWidth: '100%',\n overflow: 'hidden',\n // Answer-block / empty-slot boxes inside a label.\n '& .ML__placeholder': {\n backgroundColor: color.keypadEmptyPlaceholder ? color.keypadEmptyPlaceholder() : undefined,\n },\n // The stand-in glyph for an empty argument slot (see EMPTY_SLOT). Muted so it\n // reads as \"a slot goes here\" rather than as part of the symbol, matching how\n // MathQuill shaded `.mq-empty`.\n '& [data-pie-empty]': {\n opacity: 0.5,\n },\n // A readable index on the nth-root key. Carried by the label itself, not only\n // by the keypad container, so it holds wherever a LatexLabel is mounted.\n ...rootIndexStyles,\n}));\n\nexport class LatexLabel extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = { markup: latexToMarkup(props.latex) };\n }\n\n async componentDidMount() {\n // MathLive may not have finished loading when the keypad first mounts.\n if (this.state.markup) {\n return;\n }\n\n await loadMathLive();\n\n if (this.unmounted) {\n return;\n }\n\n const markup = latexToMarkup(this.props.latex);\n\n if (markup) {\n this.setState({ markup });\n return;\n }\n\n // Still nothing: the engine is genuinely unavailable (a missing chunk, a\n // blocked request). Keep the raw-latex fallback visible rather than an\n // empty button, and log once so this is diagnosable.\n if (!LatexLabel.warned) {\n LatexLabel.warned = true;\n log('MathLive unavailable - keypad labels are falling back to raw latex');\n }\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex !== this.props.latex) {\n this.setState({ markup: latexToMarkup(this.props.latex) });\n }\n }\n\n componentWillUnmount() {\n this.unmounted = true;\n }\n\n render() {\n const { markup } = this.state;\n\n // Fall back to the raw latex so a button is never blank.\n return markup ? (\n // eslint-disable-next-line react/no-danger\n <LabelHolder slanted={SLANTED_LABELS.includes(this.props.latex)} dangerouslySetInnerHTML={{ __html: markup }} />\n ) : (\n <LabelHolder slanted={SLANTED_LABELS.includes(this.props.latex)}>{this.props.latex}</LabelHolder>\n );\n }\n}\n\nconst createCustomLayout = (layoutObj) => {\n if (layoutObj) {\n return {\n gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,\n gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,\n gridAutoFlow: 'initial',\n };\n }\n\n return {};\n};\n\nconst KeyPadContainer = styled('div')(() => ({\n ...commonKeyboardStyles,\n width: '100%',\n display: 'grid',\n gridTemplateRows: 'repeat(5, minmax(40px, 60px))',\n gridRowGap: '0px',\n gridColumnGap: '0px',\n gridAutoFlow: 'column',\n '&.character': {\n textTransform: 'initial !important',\n gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',\n },\n '&.language': {\n gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n}));\n\nconst buttonBackground = (category) => ({\n backgroundColor: category === 'operators' ? color.keypadButtonOperator() : color.keypadButton(),\n '&:hover': {\n backgroundColor: category === 'operators' ? color.keypadButtonOperatorHover() : color.keypadButtonHover(),\n },\n});\n\nconst StyledButton = styled(Button)(({ category, isDelete, isComma, isDot }) => ({\n minWidth: 'auto',\n textTransform: 'none',\n fontSize: isComma || isDot ? '200% !important' : '140% !important',\n lineHeight: isComma || isDot ? '100%' : 'normal',\n color: color.text(),\n ...buttonBackground(category),\n borderRadius: 0,\n ...(isDelete && {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n }),\n}));\n\nconst StyledLatexButtonWrapper = styled(Button)(({ category }) => ({\n textTransform: 'none',\n padding: 0,\n margin: 0,\n fontSize: '110% !important',\n minWidth: 'auto',\n borderRadius: 0,\n ...buttonBackground(category),\n}));\n\nconst StyledIconButton = styled(IconButton)(({ category }) => ({\n minWidth: 'auto',\n ...buttonBackground(category),\n borderRadius: 0,\n '& .icon': {\n height: '30px',\n },\n}));\n\nexport class KeyPad extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n controlledKeypadMode: PropTypes.bool,\n baseSet: PropTypes.array,\n additionalKeys: PropTypes.array,\n layoutForKeyPad: PropTypes.object,\n onPress: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n noDecimal: PropTypes.bool,\n setKeypadInteraction: PropTypes.func,\n mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n };\n\n static defaultProps = {\n baseSet: baseSet,\n noDecimal: false,\n };\n\n constructor(props) {\n super(props);\n this.keypadRef = React.createRef();\n }\n\n componentDidMount() {\n // Ensure MathLive is available for the LaTeX labels.\n loadMathLive();\n\n const keyPadElement = this.keypadRef?.current;\n const mainContainer = keyPadElement?.closest('.main-container');\n const currentToolbar = keyPadElement?.closest('.pie-toolbar');\n\n // need only for math keyboard so we need also controlledKeypadMode\n if (this.props.controlledKeypadMode && mainContainer && currentToolbar) {\n const mainContainerPosition = mainContainer.getBoundingClientRect();\n const currentToolbarPosition = currentToolbar.getBoundingClientRect();\n const difference =\n mainContainerPosition.top +\n mainContainerPosition.height -\n (currentToolbarPosition.top + currentToolbarPosition.height);\n\n if (difference < 0) {\n const totalHeight = mainContainerPosition.height + mainContainerPosition.top - difference;\n\n mainContainer.style.height = `${totalHeight}px`;\n }\n }\n\n if (keyPadElement) {\n keyPadElement.addEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.addEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n componentWillUnmount() {\n const keyPadElement = this.keypadRef?.current;\n\n if (this.props.controlledKeypadMode && keyPadElement) {\n const mainContainer = keyPadElement.closest('.main-container');\n\n if (mainContainer) {\n mainContainer.style.height = 'unset';\n }\n }\n\n if (keyPadElement) {\n keyPadElement.removeEventListener('touchstart', this.handleKeypadInteraction, true);\n keyPadElement.removeEventListener('mousedown', this.handleKeypadInteraction, true);\n }\n }\n\n handleKeypadInteraction = () => {\n if (this.props.setKeypadInteraction) {\n this.props.setKeypadInteraction(true);\n }\n };\n\n buttonClick = (key) => {\n log('[buttonClick]', key);\n this.props.onPress(key);\n };\n\n flowKeys = (base, extras) => flatten([...sortKeys(base), ...sortKeys(extras)]);\n\n keyIsNotAllowed = (key) => {\n const { noDecimal } = this.props;\n\n return !!(((key.write === '.' && key.label === '.') || (key.write === ',' && key.label === ',')) && noDecimal);\n };\n\n render() {\n const { className, baseSet: base, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;\n\n const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];\n const keysWithoutBaseSet = noBaseSet.includes(mode);\n const allKeys = keysWithoutBaseSet\n ? this.flowKeys([], additionalKeys || [])\n : this.flowKeys(base, additionalKeys || []);\n\n const shift = allKeys.length % 5 ? 1 : 0;\n const style = {\n gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) + shift}, minmax(min-content, 150px))`,\n ...createCustomLayout(layoutForKeyPad),\n };\n\n return (\n <KeyPadContainer\n ref={this.keypadRef}\n className={[className, mode].filter(Boolean).join(' ')}\n style={style}\n onFocus={onFocus}\n >\n {allKeys.map((k, index) => {\n if (!k) {\n return <span key={`empty-${index}`} />;\n }\n\n const key = `${k.label || k.latex || k.command}-${index}`;\n const category = !keysWithoutBaseSet ? k.category : undefined;\n const extra = { ...(k.actions || {}), ...(k.extraProps || {}) };\n const onClick = this.buttonClick.bind(this, k);\n const disabled = this.keyIsNotAllowed(k);\n const ariaLabel = k.ariaLabel ? k.ariaLabel : k.name || k.label;\n\n if (k.latex) {\n return (\n <StyledLatexButtonWrapper\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n aria-label={ariaLabel}\n {...extra}\n >\n <LatexLabel latex={k.latex} />\n </StyledLatexButtonWrapper>\n );\n }\n\n if (k.label) {\n return (\n <StyledButton\n key={key}\n onClick={onClick}\n disabled={disabled}\n category={category}\n isDelete={k.label === '⌫'}\n isComma={k.label === ','}\n isDot={k.label === '.'}\n aria-label={ariaLabel}\n {...extra}\n >\n {k.label}\n </StyledButton>\n );\n }\n\n const Icon = k.icon ? k.icon : 'div';\n\n return (\n <StyledIconButton\n key={key}\n tabIndex={'-1'}\n onClick={onClick}\n disabled={disabled}\n category={category}\n size=\"large\"\n {...extra}\n >\n <Icon className=\"icon\" />\n </StyledIconButton>\n );\n })}\n </KeyPadContainer>\n );\n }\n}\n\nexport default KeyPad;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,aAAA,GAAAV,OAAA;AACA,IAAAW,iBAAA,GAAAX,OAAA;AAAmE,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CAAC+G,IAAI;EACpChC,IAAI,EAAE/E,qBAAS,CAACgH,SAAS,CAAC,CAAChH,qBAAS,CAACC,MAAM,EAAED,qBAAS,CAACiH,MAAM,CAAC;AAChE,CAAC;AAAA,IAAA1L,gBAAA,aAZUgH,MAAM,kBAcK;EACpBoC,OAAO,EAAEA,aAAO;EAChB1B,SAAS,EAAE;AACb,CAAC;AAAA,IAAAiE,QAAA,GAAAzJ,OAAA,cAiKY8E,MAAM","ignoreList":[]}
@@ -75,6 +75,14 @@ var DEFAULT_FIELD_ID = exports.DEFAULT_FIELD_ID = 'r1';
75
75
  */
76
76
  var EMPTY_SLOT = '\\htmlData{pie-empty=1}{\\rule{0.55em}{0.55em}}';
77
77
  var EMPTY_GROUP_REGEX = /\{\s*\}/g;
78
+ // Empty delimiter pairs: `\abs{}` is converted to `\left|\right|`, and the
79
+ // parenthesis / bracket keys are `\left(\right)` / `\left[\right]`. None has a
80
+ // `{}` group for the rule above to catch, so they would render as bare fences.
81
+ var EMPTY_FENCE_REGEX = /\\left([(\[|])\s*\\right([)\]|])/g;
82
+ // The same muted fill as the other slots (`pie-empty`), but a tall rectangle
83
+ // rather than a square. It also sets the fences' height: `\left...\right` stretch
84
+ // to their content, so a taller slot gives taller parentheses.
85
+ var EMPTY_FENCE_SLOT = '\\htmlData{pie-empty=1}{\\rule{0.55em}{1em}}';
78
86
 
79
87
  /**
80
88
  * Make empty argument slots visible, for static rendering.
@@ -86,7 +94,9 @@ var EMPTY_GROUP_REGEX = /\{\s*\}/g;
86
94
  * @returns {string}
87
95
  */
88
96
  var withVisibleEmptySlots = exports.withVisibleEmptySlots = function withVisibleEmptySlots(latex) {
89
- return (latex || '').replace(EMPTY_GROUP_REGEX, "{".concat(EMPTY_SLOT, "}"));
97
+ return (latex || '').replace(EMPTY_GROUP_REGEX, "{".concat(EMPTY_SLOT, "}")).replace(EMPTY_FENCE_REGEX, function (_m, open, close) {
98
+ return "\\left".concat(open).concat(EMPTY_FENCE_SLOT, "\\right").concat(close);
99
+ });
90
100
  };
91
101
 
92
102
  /**
@@ -250,7 +260,28 @@ var MATHQUILL_ALIASES = exports.MATHQUILL_ALIASES = {
250
260
  var MATHQUILL_ALIAS_REGEX = /\\(divide|perpendicular)(?![a-zA-Z])/g;
251
261
 
252
262
  /**
253
- * Replace MathQuill alias names with the command MathQuill actually stored.
263
+ * Primes. MathLive turns a prime that follows a base into a superscript atom and
264
+ * serialises it as `^{\\prime}`, or `^{\\doubleprime}` for the keypad's double
265
+ * prime key (`5''` comes back out as `5^{\\doubleprime}`). MathJax has no
266
+ * `\\doubleprime`, and two adjacent `^{\\prime}` groups - what typing `'` twice
267
+ * produces - are a "double exponent" error. MathQuill stored plain apostrophes,
268
+ * which both MathJax and MathLive read as primes, so store those.
269
+ *
270
+ * Only a superscript made of primes alone is rewritten: `x^{\\prime 2}` keeps
271
+ * its group, since it holds more than primes.
272
+ */
273
+ var PRIME_SUPERSCRIPT_REGEX = /\^\{((?:\s*\\(?:prime|doubleprime)(?![a-zA-Z]))+)\s*\}/g;
274
+ var BARE_DOUBLEPRIME_REGEX = /\\doubleprime(?![a-zA-Z])/g;
275
+ var primesToApostrophes = function primesToApostrophes(primes) {
276
+ return (
277
+ // eslint-disable-next-line quotes
278
+ "'".repeat((primes.match(/\\prime(?![a-zA-Z])/g) || []).length + 2 * (primes.match(BARE_DOUBLEPRIME_REGEX) || []).length)
279
+ );
280
+ };
281
+
282
+ /**
283
+ * Rewrite what MathLive serialises into the form MathQuill stored: alias
284
+ * command names, and primes.
254
285
  *
255
286
  * @param {string} latex
256
287
  * @returns {string}
@@ -258,7 +289,11 @@ var MATHQUILL_ALIAS_REGEX = /\\(divide|perpendicular)(?![a-zA-Z])/g;
258
289
  var toCanonicalCommands = exports.toCanonicalCommands = function toCanonicalCommands(latex) {
259
290
  return typeof latex === 'string' ? latex.replace(MATHQUILL_ALIAS_REGEX, function (m) {
260
291
  return MATHQUILL_ALIASES[m];
261
- }) : latex;
292
+ }).replace(PRIME_SUPERSCRIPT_REGEX, function (_m, primes) {
293
+ return primesToApostrophes(primes);
294
+ })
295
+ // eslint-disable-next-line quotes
296
+ .replace(BARE_DOUBLEPRIME_REGEX, "''") : latex;
262
297
  };
263
298
 
264
299
  /**
@@ -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","escapeBareComments","indexOf","backslashes","i","length","ch","idx","open","depth","close","inner","slice","fieldIds","match","lastIndex","exec","push","toMathLive","_m","id","content","split","join","MATHQUILL_ALIASES","MATHQUILL_ALIAS_REGEX","toCanonicalCommands","m","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 * Keypad command names that MathQuill treated as ALIASES of a different command.\n *\n * MathQuill registered `\\\\divide` as another name for `\\\\div` (and\n * `\\\\perpendicular` for `\\\\perp`), so pressing the key stored the real command.\n * MathLive only knows these names through `PIE_MACROS`, and serialises a macro\n * under its own name - so `\\\\divide` reached storage verbatim, where MathJax\n * (@pie-lib/math-rendering) has no such command and renders it as red text.\n *\n * Every other keypad command already matches what MathQuill stored (`\\\\degree`,\n * `\\\\nsim`, `\\\\ncong`, `\\\\nparallel`, `\\\\square`, `\\\\napprox`,\n * `\\\\parallelogram`), and MathJax understands those.\n */\nconst MATHQUILL_ALIASES = {\n '\\\\divide': '\\\\div',\n '\\\\perpendicular': '\\\\perp',\n};\n\n// Whole command names only: `\\\\divideontimes` is a real AMS symbol.\nconst MATHQUILL_ALIAS_REGEX = /\\\\(divide|perpendicular)(?![a-zA-Z])/g;\n\n/**\n * Replace MathQuill alias names with the command MathQuill actually stored.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const toCanonicalCommands = (latex) =>\n typeof latex === 'string' ? latex.replace(MATHQUILL_ALIAS_REGEX, (m) => MATHQUILL_ALIASES[m]) : latex;\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 // Store the command MathQuill stored, not the alias - also heals latex that was\n // saved with `\\\\divide` before the keypad resolved it.\n return toCanonicalCommands(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] || MATHQUILL_ALIASES[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, MATHQUILL_ALIASES };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,IAAMA,aAAa,GAA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AAC,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,IAAI3B,iBAAiB,CAAC2B,CAAC,CAAC,IAAIA,CAAC;IAAA,EAAC,CAAC5B,IAAI,CAAC,EAAE,CAAC;IAE3F,OAAO;MAAEsB,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","EMPTY_FENCE_REGEX","EMPTY_FENCE_SLOT","withVisibleEmptySlots","latex","replace","concat","_m","open","close","toNativeCommands","out","replaceAbs","escapeBareComments","indexOf","backslashes","i","length","ch","idx","depth","inner","slice","fieldIds","match","lastIndex","exec","push","toMathLive","id","content","split","join","MATHQUILL_ALIASES","MATHQUILL_ALIAS_REGEX","PRIME_SUPERSCRIPT_REGEX","BARE_DOUBLEPRIME_REGEX","primesToApostrophes","primes","repeat","toCanonicalCommands","m","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// Empty delimiter pairs: `\\abs{}` is converted to `\\left|\\right|`, and the\n// parenthesis / bracket keys are `\\left(\\right)` / `\\left[\\right]`. None has a\n// `{}` group for the rule above to catch, so they would render as bare fences.\nconst EMPTY_FENCE_REGEX = /\\\\left([(\\[|])\\s*\\\\right([)\\]|])/g;\n// The same muted fill as the other slots (`pie-empty`), but a tall rectangle\n// rather than a square. It also sets the fences' height: `\\left...\\right` stretch\n// to their content, so a taller slot gives taller parentheses.\nconst EMPTY_FENCE_SLOT = '\\\\htmlData{pie-empty=1}{\\\\rule{0.55em}{1em}}';\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) =>\n (latex || '')\n .replace(EMPTY_GROUP_REGEX, `{${EMPTY_SLOT}}`)\n .replace(EMPTY_FENCE_REGEX, (_m, open, close) => `\\\\left${open}${EMPTY_FENCE_SLOT}\\\\right${close}`);\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 * Keypad command names that MathQuill treated as ALIASES of a different command.\n *\n * MathQuill registered `\\\\divide` as another name for `\\\\div` (and\n * `\\\\perpendicular` for `\\\\perp`), so pressing the key stored the real command.\n * MathLive only knows these names through `PIE_MACROS`, and serialises a macro\n * under its own name - so `\\\\divide` reached storage verbatim, where MathJax\n * (@pie-lib/math-rendering) has no such command and renders it as red text.\n *\n * Every other keypad command already matches what MathQuill stored (`\\\\degree`,\n * `\\\\nsim`, `\\\\ncong`, `\\\\nparallel`, `\\\\square`, `\\\\napprox`,\n * `\\\\parallelogram`), and MathJax understands those.\n */\nconst MATHQUILL_ALIASES = {\n '\\\\divide': '\\\\div',\n '\\\\perpendicular': '\\\\perp',\n};\n\n// Whole command names only: `\\\\divideontimes` is a real AMS symbol.\nconst MATHQUILL_ALIAS_REGEX = /\\\\(divide|perpendicular)(?![a-zA-Z])/g;\n\n/**\n * Primes. MathLive turns a prime that follows a base into a superscript atom and\n * serialises it as `^{\\\\prime}`, or `^{\\\\doubleprime}` for the keypad's double\n * prime key (`5''` comes back out as `5^{\\\\doubleprime}`). MathJax has no\n * `\\\\doubleprime`, and two adjacent `^{\\\\prime}` groups - what typing `'` twice\n * produces - are a \"double exponent\" error. MathQuill stored plain apostrophes,\n * which both MathJax and MathLive read as primes, so store those.\n *\n * Only a superscript made of primes alone is rewritten: `x^{\\\\prime 2}` keeps\n * its group, since it holds more than primes.\n */\nconst PRIME_SUPERSCRIPT_REGEX = /\\^\\{((?:\\s*\\\\(?:prime|doubleprime)(?![a-zA-Z]))+)\\s*\\}/g;\nconst BARE_DOUBLEPRIME_REGEX = /\\\\doubleprime(?![a-zA-Z])/g;\n\nconst primesToApostrophes = (primes) =>\n // eslint-disable-next-line quotes\n \"'\".repeat(\n (primes.match(/\\\\prime(?![a-zA-Z])/g) || []).length + 2 * (primes.match(BARE_DOUBLEPRIME_REGEX) || []).length,\n );\n\n/**\n * Rewrite what MathLive serialises into the form MathQuill stored: alias\n * command names, and primes.\n *\n * @param {string} latex\n * @returns {string}\n */\nexport const toCanonicalCommands = (latex) =>\n typeof latex === 'string'\n ? latex\n .replace(MATHQUILL_ALIAS_REGEX, (m) => MATHQUILL_ALIASES[m])\n .replace(PRIME_SUPERSCRIPT_REGEX, (_m, primes) => primesToApostrophes(primes))\n // eslint-disable-next-line quotes\n .replace(BARE_DOUBLEPRIME_REGEX, \"''\")\n : latex;\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 // Store the command MathQuill stored, not the alias - also heals latex that was\n // saved with `\\\\divide` before the keypad resolved it.\n return toCanonicalCommands(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] || MATHQUILL_ALIASES[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, MATHQUILL_ALIASES };\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;AACpC;AACA;AACA;AACA,IAAMC,iBAAiB,GAAG,mCAAmC;AAC7D;AACA;AACA;AACA,IAAMC,gBAAgB,GAAG,8CAA8C;;AAEvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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K;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,IAAIhC,iBAAiB,CAACgC,CAAC,CAAC,IAAIA,CAAC;IAAA,EAAC,CAACjC,IAAI,CAAC,EAAE,CAAC;IAE3F,OAAO;MAAE2B,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":[]}
@@ -140,6 +140,9 @@ var PIE_MACROS = exports.PIE_MACROS = {
140
140
  // Argument-less symbols. Atomic is correct here: backspace should remove the
141
141
  // whole glyph, and there is nothing to type into.
142
142
  parallelogram: "\\htmlData{pie-macro=parallelogram}{\\unicode{\"25B1}}",
143
+ // Same glyph as the built-in `\\parallel` (U+2225), tagged so it can be sized -
144
+ // see `parallelStyles`.
145
+ parallel: "\\htmlData{pie-macro=parallel}{\\unicode{\"2225}}",
143
146
  napprox: '\\not\\approx',
144
147
  nsim: '\\not\\sim',
145
148
  ncong: '\\not\\cong',
@@ -242,7 +245,7 @@ var PLACEHOLDER_CARET_CSS = [":host(.".concat(PLACEHOLDER_CARET_CLASS, ") .ML__s
242
245
  // A live mathfield needs the readable radical index too: `rootIndexStyles` is
243
246
  // written for static markup in the host page, which cannot cross the shadow
244
247
  // boundary.
245
- var SHADOW_CSS = '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}' + _commonStyles.ROOT_INDEX_CSS + PLACEHOLDER_CARET_CSS;
248
+ var SHADOW_CSS = '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}' + _commonStyles.ROOT_INDEX_CSS + _commonStyles.PARALLEL_CSS + PLACEHOLDER_CARET_CSS;
246
249
 
247
250
  /**
248
251
  * Keep {@link PLACEHOLDER_CARET_CLASS} in step with the selection.
@@ -1 +1 @@
1
- {"version":3,"file":"mathlive-instance.js","names":["_debug","_interopRequireDefault","require","_latexBridge","_commonStyles","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","PLACEHOLDER_CARET_CLASS","PLACEHOLDER_LATEX","PLACEHOLDER_CARET_CSS","join","SHADOW_CSS","ROOT_INDEX_CSS","trackPlaceholderCaret","mathField","addEventListener","update","selected","selectionIsCollapsed","selection","getValue","classList","toggle","removeEventListener","applyShadowStyles","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';\nimport { ROOT_INDEX_CSS } from './mf/common-styles';\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 */\n/**\n * Marker put on the host `<math-field>` while a `\\placeholder{}` is selected,\n * so the caret rules below apply to a placeholder and nothing else.\n */\nexport const PLACEHOLDER_CARET_CLASS = 'pie-caret-in-placeholder';\n\n/** What MathLive serialises a `#?` slot as. */\nconst PLACEHOLDER_LATEX = '\\\\placeholder{}';\n\n/**\n * A blinking caret inside a selected placeholder box.\n *\n * A keypad key such as `\\frac` inserts `\\frac{#?}{#?}`. MathLive turns each\n * `#?` into a `\\placeholder{}` atom and *selects* the first one. That atom is a\n * leaf - the offsets around it are \"before\" and \"after\", there is no position\n * inside it - so MathLive renders **no caret element at all** and shows only\n * the selection highlight. The box therefore looked focused (blue) but dead,\n * where MathQuill used to blink a cursor inside its empty box.\n *\n * So the caret is drawn here. `:not(:has(.ML__selected))` picks the innermost\n * selected element (MathLive puts the class on a wrapper *and* the glyph span,\n * which would otherwise give two carets), and the `ML__caret-blink` keyframes\n * plus `--_caret-color` are MathLive's own, already in this shadow root.\n *\n * Typing still replaces the whole placeholder, which for an empty box is\n * indistinguishable from inserting at the caret.\n */\nconst PLACEHOLDER_CARET_CSS = [\n `:host(.${PLACEHOLDER_CARET_CLASS}) .ML__selected:not(:has(.ML__selected)){position:relative}`,\n `:host(.${PLACEHOLDER_CARET_CLASS}) .ML__selected:not(:has(.ML__selected))::after{`,\n 'content:\"\";position:absolute;left:50%;top:12%;height:76%;',\n 'border-right:2px solid var(--_caret-color, currentColor);',\n 'animation:ML__caret-blink 1.05s step-end forwards infinite}',\n].join('');\n\n// A live mathfield needs the readable radical index too: `rootIndexStyles` is\n// written for static markup in the host page, which cannot cross the shadow\n// boundary.\nconst SHADOW_CSS =\n '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}' + ROOT_INDEX_CSS + PLACEHOLDER_CARET_CSS;\n\n/**\n * Keep {@link PLACEHOLDER_CARET_CLASS} in step with the selection.\n *\n * Gating on the class is what keeps the caret specific to placeholders: an\n * ordinary selection (`x+1`) must not sprout one. MathLive fires\n * `selection-change` for every caret move, including the one that lands on the\n * placeholder straight after an insert.\n *\n * @param {HTMLElement} mathField\n * @returns {function|undefined} teardown, to call on unmount\n */\nexport const trackPlaceholderCaret = (mathField) => {\n if (!mathField || typeof mathField.addEventListener !== 'function') {\n return undefined;\n }\n\n const update = () => {\n let selected = '';\n\n try {\n // A collapsed selection already has a real MathLive caret.\n if (!mathField.selectionIsCollapsed && mathField.selection) {\n selected = mathField.getValue(mathField.selection, 'latex');\n }\n } catch (e) {\n log('could not read the selection: %s', e && e.message);\n }\n\n if (mathField.classList) {\n mathField.classList.toggle(PLACEHOLDER_CARET_CLASS, selected === PLACEHOLDER_LATEX);\n }\n };\n\n mathField.addEventListener('selection-change', update);\n update();\n\n return () => mathField.removeEventListener('selection-change', update);\n};\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;AACA,IAAAE,aAAA,GAAAF,OAAA;AAAoD,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IA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A;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASW,aAAaA,CAACzB,KAAK,EAAgB;EAAA,IAAde,OAAO,GAAA5I,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAwC,SAAA,GAAAxC,SAAA,MAAG,CAAC,CAAC;EAC/C;EACA;EACA,IAAM8I,EAAE,GAAGtB,WAAW,CAAC,CAAC,IAAIxB,gBAAgB,CAAC,CAAC;EAE9C,IAAI,CAAC8C,EAAE,IAAI,CAACjB,KAAK,EAAE;IACjB,OAAO,EAAE;EACX;EAEA,IAAI;IACF;IACA;IACA;IACA,OAAOiB,EAAE,CAACI,oBAAoB,CAAC,IAAAC,kCAAqB,EAAC,IAAAC,uBAAU,EAACvB,KAAK,CAAC,CAAC,EAAA9H,aAAA;MACrEsJ,MAAM,EAAAtJ,aAAA,CAAAA,aAAA,KAAO0H,SAAS,CAAC,CAAC,GAAMmB,OAAO,CAACS,MAAM,IAAI,CAAC,CAAC;IAAG,GAClDT,OAAO,CACX,CAAC;EACJ,CAAC,CAAC,OAAOzJ,CAAC,EAAE;IACVkC,GAAG,CAAC,0CAA0C,EAAEwG,KAAK,EAAE1I,CAAC,CAAC6C,OAAO,CAAC;IACjE,OAAO,EAAE;EACX;AACF","ignoreList":[]}
1
+ {"version":3,"file":"mathlive-instance.js","names":["_debug","_interopRequireDefault","require","_latexBridge","_commonStyles","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","parallel","napprox","nsim","ncong","nparallel","perpendicular","divide","degree","square","longdiv","overarc","abs","embeds","Map","KNOWN_EMBED_LATEX","newLine","answerBlock","loadWarned","configureLoaded","injectCoreStylesheet","PLACEHOLDER_CARET_CLASS","PLACEHOLDER_LATEX","PLACEHOLDER_CARET_CSS","join","SHADOW_CSS","ROOT_INDEX_CSS","PARALLEL_CSS","trackPlaceholderCaret","mathField","addEventListener","update","selected","selectionIsCollapsed","selection","getValue","classList","toggle","removeEventListener","applyShadowStyles","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';\nimport { ROOT_INDEX_CSS, PARALLEL_CSS } from './mf/common-styles';\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 // Same glyph as the built-in `\\\\parallel` (U+2225), tagged so it can be sized -\n // see `parallelStyles`.\n parallel: '\\\\htmlData{pie-macro=parallel}{\\\\unicode{\"2225}}',\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 */\n/**\n * Marker put on the host `<math-field>` while a `\\placeholder{}` is selected,\n * so the caret rules below apply to a placeholder and nothing else.\n */\nexport const PLACEHOLDER_CARET_CLASS = 'pie-caret-in-placeholder';\n\n/** What MathLive serialises a `#?` slot as. */\nconst PLACEHOLDER_LATEX = '\\\\placeholder{}';\n\n/**\n * A blinking caret inside a selected placeholder box.\n *\n * A keypad key such as `\\frac` inserts `\\frac{#?}{#?}`. MathLive turns each\n * `#?` into a `\\placeholder{}` atom and *selects* the first one. That atom is a\n * leaf - the offsets around it are \"before\" and \"after\", there is no position\n * inside it - so MathLive renders **no caret element at all** and shows only\n * the selection highlight. The box therefore looked focused (blue) but dead,\n * where MathQuill used to blink a cursor inside its empty box.\n *\n * So the caret is drawn here. `:not(:has(.ML__selected))` picks the innermost\n * selected element (MathLive puts the class on a wrapper *and* the glyph span,\n * which would otherwise give two carets), and the `ML__caret-blink` keyframes\n * plus `--_caret-color` are MathLive's own, already in this shadow root.\n *\n * Typing still replaces the whole placeholder, which for an empty box is\n * indistinguishable from inserting at the caret.\n */\nconst PLACEHOLDER_CARET_CSS = [\n `:host(.${PLACEHOLDER_CARET_CLASS}) .ML__selected:not(:has(.ML__selected)){position:relative}`,\n `:host(.${PLACEHOLDER_CARET_CLASS}) .ML__selected:not(:has(.ML__selected))::after{`,\n 'content:\"\";position:absolute;left:50%;top:12%;height:76%;',\n 'border-right:2px solid var(--_caret-color, currentColor);',\n 'animation:ML__caret-blink 1.05s step-end forwards infinite}',\n].join('');\n\n// A live mathfield needs the readable radical index too: `rootIndexStyles` is\n// written for static markup in the host page, which cannot cross the shadow\n// boundary.\nconst SHADOW_CSS =\n '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}' +\n ROOT_INDEX_CSS +\n PARALLEL_CSS +\n PLACEHOLDER_CARET_CSS;\n\n/**\n * Keep {@link PLACEHOLDER_CARET_CLASS} in step with the selection.\n *\n * Gating on the class is what keeps the caret specific to placeholders: an\n * ordinary selection (`x+1`) must not sprout one. MathLive fires\n * `selection-change` for every caret move, including the one that lands on the\n * placeholder straight after an insert.\n *\n * @param {HTMLElement} mathField\n * @returns {function|undefined} teardown, to call on unmount\n */\nexport const trackPlaceholderCaret = (mathField) => {\n if (!mathField || typeof mathField.addEventListener !== 'function') {\n return undefined;\n }\n\n const update = () => {\n let selected = '';\n\n try {\n // A collapsed selection already has a real MathLive caret.\n if (!mathField.selectionIsCollapsed && mathField.selection) {\n selected = mathField.getValue(mathField.selection, 'latex');\n }\n } catch (e) {\n log('could not read the selection: %s', e && e.message);\n }\n\n if (mathField.classList) {\n mathField.classList.toggle(PLACEHOLDER_CARET_CLASS, selected === PLACEHOLDER_LATEX);\n }\n };\n\n mathField.addEventListener('selection-change', update);\n update();\n\n return () => mathField.removeEventListener('selection-change', update);\n};\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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AC;IAAG,GAClDT,OAAO,CACX,CAAC;EACJ,CAAC,CAAC,OAAO3J,CAAC,EAAE;IACVkC,GAAG,CAAC,0CAA0C,EAAE0G,KAAK,EAAE5I,CAAC,CAAC6C,OAAO,CAAC;IACjE,OAAO,EAAE;EACX;AACF","ignoreList":[]}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.supsubStyles = exports.rootIndexStyles = exports.placeholderStyles = exports.longdivStyles = exports["default"] = exports.commonMqKeyboardStyles = exports.commonMqFontStyles = exports.commonMathLiveStyles = exports.commonKeyboardStyles = exports.ROOT_INDEX_CSS = void 0;
7
+ exports.supsubStyles = exports.rootIndexStyles = exports.placeholderStyles = exports.parallelStyles = exports.longdivStyles = exports["default"] = exports.commonMqKeyboardStyles = exports.commonMqFontStyles = exports.commonMathLiveStyles = exports.commonKeyboardStyles = exports.ROOT_INDEX_CSS = exports.PARALLEL_CSS = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  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; }
10
10
  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; }
@@ -82,12 +82,27 @@ var rootIndexStyles = exports.rootIndexStyles = (0, _defineProperty2["default"])
82
82
  */
83
83
  var ROOT_INDEX_CSS = exports.ROOT_INDEX_CSS = "".concat(ROOT_INDEX_SELECTOR, "{font-size:").concat(ROOT_INDEX_FONT_SIZE, " !important}");
84
84
 
85
+ /**
86
+ * Size of the parallel sign (`\parallel`, tagged `data-pie-macro="parallel"` by
87
+ * `PIE_MACROS`). The legacy editor enlarged it (`updateSpans` set 32px) because
88
+ * the bars read too small next to the letters of `AB ∥ CD`; MathLive draws it at
89
+ * the surrounding size, so it is scaled up here. Not applied to keypad labels.
90
+ */
91
+ var PARALLEL_SELECTOR = '[data-pie-macro="parallel"]';
92
+ var PARALLEL_FONT_SIZE = '1.4em';
93
+ var parallelStyles = exports.parallelStyles = (0, _defineProperty2["default"])({}, "& ".concat(PARALLEL_SELECTOR), {
94
+ fontSize: PARALLEL_FONT_SIZE
95
+ });
96
+
97
+ /** The same rule as a CSS string, for a live mathfield's shadow root. */
98
+ var PARALLEL_CSS = exports.PARALLEL_CSS = "".concat(PARALLEL_SELECTOR, "{font-size:").concat(PARALLEL_FONT_SIZE, "}");
99
+
85
100
  /**
86
101
  * Superscript/subscript sizing. MathLive follows TeX metrics for scripts, so the
87
102
  * MathQuill-era corrections are gone; the radical index is the one place where a
88
103
  * TeX-correct size reads too small in the authoring UI.
89
104
  */
90
- var supsubStyles = exports.supsubStyles = _objectSpread({}, rootIndexStyles);
105
+ var supsubStyles = exports.supsubStyles = _objectSpread(_objectSpread({}, rootIndexStyles), parallelStyles);
91
106
 
92
107
  /** Empty placeholder boxes (answer blocks / open slots). */
93
108
  var placeholderStyles = exports.placeholderStyles = {
@@ -1 +1 @@
1
- {"version":3,"file":"common-styles.js","names":["commonMqFontStyles","exports","fontFamily","longdivStyles","display","ROOT_INDEX_SELECTOR","ROOT_INDEX_FONT_SIZE","rootIndexStyles","_defineProperty2","concat","fontSize","ROOT_INDEX_CSS","supsubStyles","_objectSpread","placeholderStyles","borderBottom","minWidth","opacity","position","left","width","marginLeft","commonMqKeyboardStyles","touchAction","outline","commonMathLiveStyles","commonKeyboardStyles","_default"],"sources":["../../src/mf/common-styles.js"],"sourcesContent":["/**\n * Shared MathLive styling.\n *\n * Replaces @pie-lib/math-input's `common-mq-styles.js`. That file was built\n * around MathQuill's `.mq-*` class names, none of which exist in MathLive\n * output, so the selectors here target MathLive's own structure instead.\n *\n * The four named groups are kept because consumers destructure them:\n *\n * const { commonMqFontStyles, commonMqKeyboardStyles, longdivStyles, supsubStyles }\n * = mq.CommonMqStyles; // math-toolbar/src/editor-and-pad.jsx, math-preview.jsx\n *\n * Most are intentionally near-empty: MathLive sizes scripts, radicals and\n * fences correctly on its own, so the MathQuill-era corrections are not needed.\n * They stay as documented extension points rather than being deleted, so the\n * destructuring above keeps working. The exception is the radical index, which\n * MathLive sizes to TeX metrics that read too small here - see\n * `rootIndexStyles`.\n */\n\n/**\n * Font styling. MathQuill needed explicit MathJax font families to match the\n * static renderer; MathLive ships the KaTeX fonts it renders with, so this only\n * smooths rendering and lets the host override the family.\n */\nexport const commonMqFontStyles = {\n '-webkit-font-smoothing': 'antialiased',\n '& math-field': {\n fontFamily: 'inherit',\n },\n};\n\n/**\n * Long division. The MathQuill fork drew this with nested `.mq-longdiv-*`\n * elements that needed manual offsets; here it comes from the `\\longdiv` macro\n * (see `PIE_MACROS`), tagged with `data-pie-macro=\"longdiv\"`.\n */\nexport const longdivStyles = {\n '& [data-pie-macro=\"longdiv\"]': {\n display: 'inline-flex',\n },\n};\n\n/**\n * How the index of a radical is sized.\n *\n * MathLive follows TeX and sets the index of `\\sqrt[n]{x}` in scriptscriptstyle,\n * which it emits as an inline `font-size: 50%` on the span wrapping the index's\n * glyphs. At authoring sizes that leaves the index - on the nth-root key, and in\n * any radical the author types - too small to read next to the radicand, so it is\n * scaled up to 80% - 1.6x what MathLive asks for.\n *\n * Only that innermost span is resized. `.ML__sqrt-index` itself keeps its font\n * size on purpose: the vlist inside it tucks the index into the radical's crook\n * with em-based `top`/`height` offsets, and scaling those lifts the index clear\n * of the radical instead of just enlarging it.\n *\n * The child chain is spelled out so that nothing nested deeper inside the index\n * (a fraction's numerator, another radical) is caught by the same rule, and\n * `!important` is required because the 50% is an INLINE style.\n */\nconst ROOT_INDEX_SELECTOR = '.ML__sqrt-index > .ML__vlist-t > .ML__vlist-r > .ML__vlist > span > [style*=\"font-size\"]';\nconst ROOT_INDEX_FONT_SIZE = '80%';\n\nexport const rootIndexStyles = {\n [`& ${ROOT_INDEX_SELECTOR}`]: {\n fontSize: `${ROOT_INDEX_FONT_SIZE} !important`,\n },\n};\n\n/**\n * The same rule as a CSS string, for a live mathfield's shadow root - see\n * `SHADOW_CSS` in mathlive-instance.js. Static markup is styled by\n * {@link rootIndexStyles}.\n */\nexport const ROOT_INDEX_CSS = `${ROOT_INDEX_SELECTOR}{font-size:${ROOT_INDEX_FONT_SIZE} !important}`;\n\n/**\n * Superscript/subscript sizing. MathLive follows TeX metrics for scripts, so the\n * MathQuill-era corrections are gone; the radical index is the one place where a\n * TeX-correct size reads too small in the authoring UI.\n */\nexport const supsubStyles = {\n ...rootIndexStyles,\n};\n\n/** Empty placeholder boxes (answer blocks / open slots). */\nexport const placeholderStyles = {\n '& .ML__placeholder': {\n borderBottom: '1px solid currentColor',\n minWidth: '1em',\n },\n // Stand-in glyph for an empty argument slot in STATIC math (see\n // `withVisibleEmptySlots`). Muted so it reads as \"a slot goes here\" rather\n // than as part of the symbol, matching how MathQuill shaded `.mq-empty`.\n '& [data-pie-empty]': {\n opacity: 0.5,\n },\n // Stretchy accents (\\overarc, \\overleftrightarrow, \\overrightarrow) render an\n // <svg width=\"100%\" preserveAspectRatio=\"none\"> inside a `.ML__stretchy`. That\n // span is absolutely positioned, so its immediate wrapper computes to 0px and\n // the width has to resolve against a *positioned* ancestor. Pin that to\n // `.ML__base`, whose width already equals the accent's content (measured:\n // 9.85px for a 0.56em slot), so the arc spans exactly its content.\n //\n // Do NOT write a bare `& svg` rule instead: MathLive's own rule is\n // descendant-scoped (`.ML__latex .ML__stretchy svg`), and a global one\n // re-parents every svg in the subtree.\n '& .ML__base': {\n position: 'relative',\n },\n '& .ML__stretchy': {\n position: 'absolute',\n left: 0,\n width: '100%',\n },\n // MathLive centres an accent by shifting it right half the content width -\n // `margin-left: 0.28em` for a 0.56em slot - which assumes a glyph with its own\n // side bearings. Over a synthetic empty slot it just pushes the arc right.\n //\n // `!important` is required: MathLive writes this as an INLINE style\n // (`style=\"top:-3.4em;margin-left:0.28em\"`), which a class cannot override.\n //\n // It also fixes the width. `.ML__center` is the stretchy's containing block\n // (MathLive gives `.ML__vlist > span` position:relative), and its width is the\n // base minus that margin - measured 9.85px - 4.93px = 4.93px, exactly half,\n // which is why the arc came out half-width AND offset right.\n //\n // Scoped with `:has(.ML__stretchy)`: only stretchy accents are affected.\n // A single-glyph accent (`\\hat{x}`, `\\vec{x}`) genuinely needs its centring\n // offset, and must keep it.\n '& .ML__center:has(.ML__stretchy)': {\n marginLeft: '0 !important',\n },\n};\n\n/**\n * Styling for the on-screen keyboard and any container rendering math labels.\n * Also hides MathLive's own affordances, since pie supplies its own keypad.\n */\nexport const commonMqKeyboardStyles = {\n ...commonMqFontStyles,\n ...longdivStyles,\n ...rootIndexStyles,\n ...placeholderStyles,\n touchAction: 'manipulation',\n '& math-field': {\n fontSize: 'inherit',\n outline: 'none',\n },\n '& math-field::part(virtual-keyboard-toggle)': {\n display: 'none',\n },\n '& math-field::part(menu-toggle)': {\n display: 'none',\n },\n};\n\n/** Everything combined - the common case for a container of math. */\nexport const commonMathLiveStyles = {\n ...commonMqFontStyles,\n ...longdivStyles,\n ...supsubStyles,\n ...placeholderStyles,\n '& math-field': {\n fontSize: 'inherit',\n outline: 'none',\n },\n '& math-field::part(virtual-keyboard-toggle)': {\n display: 'none',\n },\n '& math-field::part(menu-toggle)': {\n display: 'none',\n },\n};\n\nexport const commonKeyboardStyles = commonMqKeyboardStyles;\n\n/**\n * Default export mirrors @pie-lib/math-input's `CommonMqStyles` object so\n * existing destructuring keeps working.\n */\nexport default {\n commonMqFontStyles,\n longdivStyles,\n rootIndexStyles,\n supsubStyles,\n commonMqKeyboardStyles,\n placeholderStyles,\n commonMathLiveStyles,\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChC,wBAAwB,EAAE,aAAa;EACvC,cAAc,EAAE;IACdE,UAAU,EAAE;EACd;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACO,IAAMC,aAAa,GAAAF,OAAA,CAAAE,aAAA,GAAG;EAC3B,8BAA8B,EAAE;IAC9BC,OAAO,EAAE;EACX;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,mBAAmB,GAAG,0FAA0F;AACtH,IAAMC,oBAAoB,GAAG,KAAK;AAE3B,IAAMC,eAAe,GAAAN,OAAA,CAAAM,eAAA,OAAAC,gBAAA,sBAAAC,MAAA,CACpBJ,mBAAmB,GAAK;EAC5BK,QAAQ,KAAAD,MAAA,CAAKH,oBAAoB;AACnC,CAAC,CACF;;AAED;AACA;AACA;AACA;AACA;AACO,IAAMK,cAAc,GAAAV,OAAA,CAAAU,cAAA,MAAAF,MAAA,CAAMJ,mBAAmB,iBAAAI,MAAA,CAAcH,oBAAoB,iBAAc;;AAEpG;AACA;AACA;AACA;AACA;AACO,IAAMM,YAAY,GAAAX,OAAA,CAAAW,YAAA,GAAAC,aAAA,KACpBN,eAAe,CACnB;;AAED;AACO,IAAMO,iBAAiB,GAAAb,OAAA,CAAAa,iBAAA,GAAG;EAC/B,oBAAoB,EAAE;IACpBC,YAAY,EAAE,wBAAwB;IACtCC,QAAQ,EAAE;EACZ,CAAC;EACD;EACA;EACA;EACA,oBAAoB,EAAE;IACpBC,OAAO,EAAE;EACX,CAAC;EACD;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BA,kBAAkB;EAClBG,aAAa,EAAbA,aAAa;EACbI,eAAe,EAAfA,eAAe;EACfK,YAAY,EAAZA,YAAY;EACZU,sBAAsB,EAAtBA,sBAAsB;EACtBR,iBAAiB,EAAjBA,iBAAiB;EACjBW,oBAAoB,EAApBA;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"common-styles.js","names":["commonMqFontStyles","exports","fontFamily","longdivStyles","display","ROOT_INDEX_SELECTOR","ROOT_INDEX_FONT_SIZE","rootIndexStyles","_defineProperty2","concat","fontSize","ROOT_INDEX_CSS","PARALLEL_SELECTOR","PARALLEL_FONT_SIZE","parallelStyles","PARALLEL_CSS","supsubStyles","_objectSpread","placeholderStyles","borderBottom","minWidth","opacity","position","left","width","marginLeft","commonMqKeyboardStyles","touchAction","outline","commonMathLiveStyles","commonKeyboardStyles","_default"],"sources":["../../src/mf/common-styles.js"],"sourcesContent":["/**\n * Shared MathLive styling.\n *\n * Replaces @pie-lib/math-input's `common-mq-styles.js`. That file was built\n * around MathQuill's `.mq-*` class names, none of which exist in MathLive\n * output, so the selectors here target MathLive's own structure instead.\n *\n * The four named groups are kept because consumers destructure them:\n *\n * const { commonMqFontStyles, commonMqKeyboardStyles, longdivStyles, supsubStyles }\n * = mq.CommonMqStyles; // math-toolbar/src/editor-and-pad.jsx, math-preview.jsx\n *\n * Most are intentionally near-empty: MathLive sizes scripts, radicals and\n * fences correctly on its own, so the MathQuill-era corrections are not needed.\n * They stay as documented extension points rather than being deleted, so the\n * destructuring above keeps working. The exception is the radical index, which\n * MathLive sizes to TeX metrics that read too small here - see\n * `rootIndexStyles`.\n */\n\n/**\n * Font styling. MathQuill needed explicit MathJax font families to match the\n * static renderer; MathLive ships the KaTeX fonts it renders with, so this only\n * smooths rendering and lets the host override the family.\n */\nexport const commonMqFontStyles = {\n '-webkit-font-smoothing': 'antialiased',\n '& math-field': {\n fontFamily: 'inherit',\n },\n};\n\n/**\n * Long division. The MathQuill fork drew this with nested `.mq-longdiv-*`\n * elements that needed manual offsets; here it comes from the `\\longdiv` macro\n * (see `PIE_MACROS`), tagged with `data-pie-macro=\"longdiv\"`.\n */\nexport const longdivStyles = {\n '& [data-pie-macro=\"longdiv\"]': {\n display: 'inline-flex',\n },\n};\n\n/**\n * How the index of a radical is sized.\n *\n * MathLive follows TeX and sets the index of `\\sqrt[n]{x}` in scriptscriptstyle,\n * which it emits as an inline `font-size: 50%` on the span wrapping the index's\n * glyphs. At authoring sizes that leaves the index - on the nth-root key, and in\n * any radical the author types - too small to read next to the radicand, so it is\n * scaled up to 80% - 1.6x what MathLive asks for.\n *\n * Only that innermost span is resized. `.ML__sqrt-index` itself keeps its font\n * size on purpose: the vlist inside it tucks the index into the radical's crook\n * with em-based `top`/`height` offsets, and scaling those lifts the index clear\n * of the radical instead of just enlarging it.\n *\n * The child chain is spelled out so that nothing nested deeper inside the index\n * (a fraction's numerator, another radical) is caught by the same rule, and\n * `!important` is required because the 50% is an INLINE style.\n */\nconst ROOT_INDEX_SELECTOR = '.ML__sqrt-index > .ML__vlist-t > .ML__vlist-r > .ML__vlist > span > [style*=\"font-size\"]';\nconst ROOT_INDEX_FONT_SIZE = '80%';\n\nexport const rootIndexStyles = {\n [`& ${ROOT_INDEX_SELECTOR}`]: {\n fontSize: `${ROOT_INDEX_FONT_SIZE} !important`,\n },\n};\n\n/**\n * The same rule as a CSS string, for a live mathfield's shadow root - see\n * `SHADOW_CSS` in mathlive-instance.js. Static markup is styled by\n * {@link rootIndexStyles}.\n */\nexport const ROOT_INDEX_CSS = `${ROOT_INDEX_SELECTOR}{font-size:${ROOT_INDEX_FONT_SIZE} !important}`;\n\n/**\n * Size of the parallel sign (`\\parallel`, tagged `data-pie-macro=\"parallel\"` by\n * `PIE_MACROS`). The legacy editor enlarged it (`updateSpans` set 32px) because\n * the bars read too small next to the letters of `AB ∥ CD`; MathLive draws it at\n * the surrounding size, so it is scaled up here. Not applied to keypad labels.\n */\nconst PARALLEL_SELECTOR = '[data-pie-macro=\"parallel\"]';\nconst PARALLEL_FONT_SIZE = '1.4em';\n\nexport const parallelStyles = {\n [`& ${PARALLEL_SELECTOR}`]: {\n fontSize: PARALLEL_FONT_SIZE,\n },\n};\n\n/** The same rule as a CSS string, for a live mathfield's shadow root. */\nexport const PARALLEL_CSS = `${PARALLEL_SELECTOR}{font-size:${PARALLEL_FONT_SIZE}}`;\n\n/**\n * Superscript/subscript sizing. MathLive follows TeX metrics for scripts, so the\n * MathQuill-era corrections are gone; the radical index is the one place where a\n * TeX-correct size reads too small in the authoring UI.\n */\nexport const supsubStyles = {\n ...rootIndexStyles,\n ...parallelStyles,\n};\n\n/** Empty placeholder boxes (answer blocks / open slots). */\nexport const placeholderStyles = {\n '& .ML__placeholder': {\n borderBottom: '1px solid currentColor',\n minWidth: '1em',\n },\n // Stand-in glyph for an empty argument slot in STATIC math (see\n // `withVisibleEmptySlots`). Muted so it reads as \"a slot goes here\" rather\n // than as part of the symbol, matching how MathQuill shaded `.mq-empty`.\n '& [data-pie-empty]': {\n opacity: 0.5,\n },\n // Stretchy accents (\\overarc, \\overleftrightarrow, \\overrightarrow) render an\n // <svg width=\"100%\" preserveAspectRatio=\"none\"> inside a `.ML__stretchy`. That\n // span is absolutely positioned, so its immediate wrapper computes to 0px and\n // the width has to resolve against a *positioned* ancestor. Pin that to\n // `.ML__base`, whose width already equals the accent's content (measured:\n // 9.85px for a 0.56em slot), so the arc spans exactly its content.\n //\n // Do NOT write a bare `& svg` rule instead: MathLive's own rule is\n // descendant-scoped (`.ML__latex .ML__stretchy svg`), and a global one\n // re-parents every svg in the subtree.\n '& .ML__base': {\n position: 'relative',\n },\n '& .ML__stretchy': {\n position: 'absolute',\n left: 0,\n width: '100%',\n },\n // MathLive centres an accent by shifting it right half the content width -\n // `margin-left: 0.28em` for a 0.56em slot - which assumes a glyph with its own\n // side bearings. Over a synthetic empty slot it just pushes the arc right.\n //\n // `!important` is required: MathLive writes this as an INLINE style\n // (`style=\"top:-3.4em;margin-left:0.28em\"`), which a class cannot override.\n //\n // It also fixes the width. `.ML__center` is the stretchy's containing block\n // (MathLive gives `.ML__vlist > span` position:relative), and its width is the\n // base minus that margin - measured 9.85px - 4.93px = 4.93px, exactly half,\n // which is why the arc came out half-width AND offset right.\n //\n // Scoped with `:has(.ML__stretchy)`: only stretchy accents are affected.\n // A single-glyph accent (`\\hat{x}`, `\\vec{x}`) genuinely needs its centring\n // offset, and must keep it.\n '& .ML__center:has(.ML__stretchy)': {\n marginLeft: '0 !important',\n },\n};\n\n/**\n * Styling for the on-screen keyboard and any container rendering math labels.\n * Also hides MathLive's own affordances, since pie supplies its own keypad.\n */\nexport const commonMqKeyboardStyles = {\n ...commonMqFontStyles,\n ...longdivStyles,\n ...rootIndexStyles,\n ...placeholderStyles,\n touchAction: 'manipulation',\n '& math-field': {\n fontSize: 'inherit',\n outline: 'none',\n },\n '& math-field::part(virtual-keyboard-toggle)': {\n display: 'none',\n },\n '& math-field::part(menu-toggle)': {\n display: 'none',\n },\n};\n\n/** Everything combined - the common case for a container of math. */\nexport const commonMathLiveStyles = {\n ...commonMqFontStyles,\n ...longdivStyles,\n ...supsubStyles,\n ...placeholderStyles,\n '& math-field': {\n fontSize: 'inherit',\n outline: 'none',\n },\n '& math-field::part(virtual-keyboard-toggle)': {\n display: 'none',\n },\n '& math-field::part(menu-toggle)': {\n display: 'none',\n },\n};\n\nexport const commonKeyboardStyles = commonMqKeyboardStyles;\n\n/**\n * Default export mirrors @pie-lib/math-input's `CommonMqStyles` object so\n * existing destructuring keeps working.\n */\nexport default {\n commonMqFontStyles,\n longdivStyles,\n rootIndexStyles,\n supsubStyles,\n commonMqKeyboardStyles,\n placeholderStyles,\n commonMathLiveStyles,\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kB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M0B,oBAAoB,GAAA7B,OAAA,CAAA6B,oBAAA,GAAGJ,sBAAsB;;AAE1D;AACA;AACA;AACA;AAHA,IAAAK,QAAA,GAAA9B,OAAA,cAIe;EACbD,kBAAkB,EAAlBA,kBAAkB;EAClBG,aAAa,EAAbA,aAAa;EACbI,eAAe,EAAfA,eAAe;EACfS,YAAY,EAAZA,YAAY;EACZU,sBAAsB,EAAtBA,sBAAsB;EACtBR,iBAAiB,EAAjBA,iBAAiB;EACjBW,oBAAoB,EAApBA;AACF,CAAC","ignoreList":[]}
package/lib/mf/index.js CHANGED
@@ -53,6 +53,12 @@ Object.defineProperty(exports, "longdivStyles", {
53
53
  return _commonStyles.longdivStyles;
54
54
  }
55
55
  });
56
+ Object.defineProperty(exports, "parallelStyles", {
57
+ enumerable: true,
58
+ get: function get() {
59
+ return _commonStyles.parallelStyles;
60
+ }
61
+ });
56
62
  Object.defineProperty(exports, "placeholderStyles", {
57
63
  enumerable: true,
58
64
  get: function get() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_input","_interopRequireDefault","require","_static","_commonStyles","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor"],"sources":["../../src/mf/index.js"],"sourcesContent":["import Input from './input';\nimport Static from './static';\nimport CommonMqStyles, {\n commonMathLiveStyles,\n commonKeyboardStyles,\n commonMqFontStyles,\n commonMqKeyboardStyles,\n longdivStyles,\n rootIndexStyles,\n supsubStyles,\n placeholderStyles,\n} from './common-styles';\n\nexport {\n Input,\n Static,\n // Same object shape as @pie-lib/math-input's `mq.CommonMqStyles`, so\n // `const { commonMqFontStyles, ... } = mq.CommonMqStyles` keeps working.\n CommonMqStyles,\n commonMathLiveStyles,\n commonKeyboardStyles,\n commonMqFontStyles,\n commonMqKeyboardStyles,\n longdivStyles,\n rootIndexStyles,\n supsubStyles,\n placeholderStyles,\n};\n"],"mappings":";;;;;;;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Styles","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor"],"sources":["../../src/mf/index.js"],"sourcesContent":["import Input from './input';\nimport Static from './static';\nimport CommonMqStyles, {\n commonMathLiveStyles,\n commonKeyboardStyles,\n commonMqFontStyles,\n commonMqKeyboardStyles,\n longdivStyles,\n rootIndexStyles,\n parallelStyles,\n supsubStyles,\n placeholderStyles,\n} from './common-styles';\n\nexport {\n Input,\n Static,\n // Same object shape as @pie-lib/math-input's `mq.CommonMqStyles`, so\n // `const { commonMqFontStyles, ... } = mq.CommonMqStyles` keeps working.\n CommonMqStyles,\n commonMathLiveStyles,\n commonKeyboardStyles,\n commonMqFontStyles,\n commonMqKeyboardStyles,\n longdivStyles,\n rootIndexStyles,\n parallelStyles,\n supsubStyles,\n placeholderStyles,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,aAAA,GAAAC,uBAAA,CAAAH,OAAA;AAUyB,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,wBAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAAP,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAM,EAAA,EAAAP,CAAA,IAAAC,CAAA,CAAAM,EAAA,IAAAd,CAAA,CAAAc,EAAA,WAAAN,CAAA,KAAAR,CAAA,EAAAC,CAAA","ignoreList":[]}
package/lib/mf/static.js CHANGED
@@ -26,9 +26,9 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
26
26
  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; }
27
27
  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; }
28
28
  var log = (0, _debug["default"])('pie-lib:math-input-mathlive:static');
29
- var Holder = (0, _styles.styled)('span')(_objectSpread(_objectSpread(_objectSpread({
29
+ var Holder = (0, _styles.styled)('span')(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
30
30
  display: 'inline-block'
31
- }, _commonStyles.placeholderStyles), _commonStyles.rootIndexStyles), {}, {
31
+ }, _commonStyles.placeholderStyles), _commonStyles.rootIndexStyles), _commonStyles.parallelStyles), {}, {
32
32
  '& math-field': {
33
33
  display: 'inline-block',
34
34
  border: 'none',
@@ -1 +1 @@
1
- {"version":3,"file":"static.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_debug","_mathliveInstance","_latexBridge","_commonStyles","_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","Holder","styled","display","placeholderStyles","rootIndexStyles","border","background","Static","exports","_React$Component","props","_this","_classCallCheck2","document","liveRegion","createElement","assign","style","position","width","height","marginTop","clip","overflow","setAttribute","body","appendChild","parentNode","removeChild","undefined","message","textContent","clearTimeout","announceTimeout","setTimeout","event","isDeleting","key","next","converted","some","id","before","promptValues","after","test","slice","announce","_this$props","onSubFieldChange","getFieldName","mathField","values","announceConversion","fields","innerFields","name","promptHandle","_this$props2","onSubFieldFocus","ids","getPrompts","focused","find","range","getPromptRange","selection","ranges","_range","_slicedToArray2","start","end","_selection$ranges$","selStart","handle","setInput","holderRef","React","createRef","state","markup","_inherits2","_createClass2","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","generation","ml","wrap","_context","prev","mountGeneration","isInteractive","loadMathLive","renderMarkup","abrupt","sent","current","MathfieldElement","macros","getMacros","readOnly","mathVirtualKeyboardPolicy","mathModeSpace","MATH_MODE_SPACE","toMathLive","latex","applyShadowStyles","untrackCaret","trackPlaceholderCaret","addEventListener","onPromptInput","onPromptFocus","onKeyDown","replaceChildren","createLiveRegion","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","removeEventListener","remove","removeLiveRegion","fieldIds","indexOf","latexToMarkup","setState","_this2","out","fromMathLive","getPromptValue","_this3","focus","focusPrompt","setPromptValue","get","_this4","map","promptContaining","_this5","target","executeCommand","blur","render","_this$props3","className","onFocus","onBlur","ref","dangerouslySetInnerHTML","__html","Component","PropTypes","string","isRequired","func"],"sources":["../../src/mf/static.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport {\n loadMathLive,\n getMacros,\n latexToMarkup,\n MATH_MODE_SPACE,\n applyShadowStyles,\n trackPlaceholderCaret,\n} from '../mathlive-instance';\nimport { toMathLive, fromMathLive, fieldIds } from '../latex-bridge';\nimport { placeholderStyles, rootIndexStyles } from './common-styles';\n\nconst log = debug('pie-lib:math-input-mathlive:static');\n\nconst Holder = styled('span')({\n display: 'inline-block',\n // Shared static-math rules: muted empty-slot glyphs and svg containment.\n ...placeholderStyles,\n // Readable radical index - display mode renders in the light DOM, so the\n // shadow-root copy of this rule does not reach it.\n ...rootIndexStyles,\n '& math-field': {\n display: 'inline-block',\n border: 'none',\n background: 'transparent',\n },\n '& math-field::part(virtual-keyboard-toggle)': {\n display: 'none',\n },\n '& math-field::part(menu-toggle)': {\n display: 'none',\n },\n});\n\n/**\n * Static math. Drop-in replacement for @pie-lib/math-input's `mq.Static`.\n *\n * Two modes, chosen automatically:\n *\n * - **display** (no answer blocks in the latex): rendered with\n * `convertLatexToMarkup`. No mathfield instance, so it is cheap enough for\n * keypad labels - the old implementation created a full MathQuill\n * StaticMath per button.\n *\n * - **interactive** (latex contains `\\MathQuillMathField[..]{}` /\n * `\\placeholder[..]{}`): a read-only `<math-field>` whose placeholders stay\n * editable. Sub-field values are surfaced through the prompts API, replacing\n * MathQuill's `innerFields`.\n */\nexport default class Static extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n className: PropTypes.string,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n getFieldName: PropTypes.func,\n onSubFieldChange: PropTypes.func,\n onSubFieldFocus: PropTypes.func,\n setInput: PropTypes.func,\n };\n\n static defaultProps = {\n getFieldName: () => {},\n };\n\n constructor(props) {\n super(props);\n this.holderRef = React.createRef();\n this.state = { markup: '' };\n this.promptValues = {};\n }\n\n async componentDidMount() {\n // See the note in mf/input.jsx: a generation counter, not a boolean, so a\n // StrictMode mount -> unmount -> mount on the same instance still ends up\n // with exactly one field.\n const generation = (this.mountGeneration = (this.mountGeneration || 0) + 1);\n\n if (!this.isInteractive()) {\n await loadMathLive();\n\n if (generation === this.mountGeneration) {\n this.renderMarkup();\n }\n\n return;\n }\n\n const ml = await loadMathLive();\n\n if (generation !== this.mountGeneration || !ml || !this.holderRef.current || this.mathField) {\n return;\n }\n\n this.mathField = new ml.MathfieldElement({ macros: getMacros() });\n this.mathField.readOnly = true;\n this.mathField.mathVirtualKeyboardPolicy = 'manual';\n // Without this the spacebar does nothing: MathLive's mathModeSpace\n // defaults to an empty string.\n this.mathField.mathModeSpace = MATH_MODE_SPACE;\n this.mathField.value = toMathLive(this.props.latex);\n\n // The mathfield renders in shadow DOM, so page CSS cannot reach it - the\n // stretchy-accent fix has to be injected there directly.\n applyShadowStyles(this.mathField);\n\n // A selected `\\placeholder{}` gets no MathLive caret; draw one. Answer\n // blocks are typed into with the same keypad, so they grow placeholders too.\n this.untrackCaret = trackPlaceholderCaret(this.mathField);\n\n this.mathField.addEventListener('input', this.onPromptInput);\n this.mathField.addEventListener('focusin', this.onPromptFocus);\n this.mathField.addEventListener('keydown', this.onKeyDown);\n\n // Belt and braces: drop anything a previous mount may have left behind.\n this.holderRef.current.replaceChildren(this.mathField);\n\n this.createLiveRegion();\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex === this.props.latex) {\n return;\n }\n\n if (this.mathField) {\n this.mathField.value = toMathLive(this.props.latex);\n } else {\n this.renderMarkup();\n }\n }\n\n componentWillUnmount() {\n // Invalidate any mount still awaiting the MathLive load.\n this.mountGeneration = (this.mountGeneration || 0) + 1;\n\n if (this.untrackCaret) {\n this.untrackCaret();\n this.untrackCaret = undefined;\n }\n\n if (this.mathField) {\n this.mathField.removeEventListener('input', this.onPromptInput);\n this.mathField.removeEventListener('focusin', this.onPromptFocus);\n this.mathField.removeEventListener('keydown', this.onKeyDown);\n this.mathField.remove();\n this.mathField = undefined;\n }\n\n this.removeLiveRegion();\n }\n\n /**\n * Off-screen aria-live region, ported from @pie-lib/math-input's Static.\n *\n * MathLive has its own accessibility layer, but it does not announce that\n * typed input was converted into a math symbol, which screen-reader users\n * relied on in the MathQuill implementation.\n */\n createLiveRegion = () => {\n if (typeof document === 'undefined' || this.liveRegion) {\n return;\n }\n\n this.liveRegion = document.createElement('div');\n Object.assign(this.liveRegion.style, {\n position: 'absolute',\n width: '1px',\n height: '1px',\n marginTop: '-1px',\n clip: 'rect(1px, 1px, 1px, 1px)',\n overflow: 'hidden',\n });\n this.liveRegion.setAttribute('aria-live', 'polite');\n this.liveRegion.setAttribute('aria-atomic', 'true');\n\n document.body.appendChild(this.liveRegion);\n };\n\n removeLiveRegion = () => {\n if (this.liveRegion && this.liveRegion.parentNode) {\n this.liveRegion.parentNode.removeChild(this.liveRegion);\n }\n\n this.liveRegion = undefined;\n };\n\n announce = (message) => {\n if (!this.liveRegion) {\n return;\n }\n\n this.liveRegion.textContent = message;\n\n // Clear once announced, so the same message can be announced again.\n clearTimeout(this.announceTimeout);\n this.announceTimeout = setTimeout(() => {\n if (this.liveRegion) {\n this.liveRegion.textContent = '';\n }\n }, 500);\n };\n\n onKeyDown = (event) => {\n // Deletions should not be announced as conversions.\n this.isDeleting = event?.key === 'Backspace' || event?.key === 'Delete';\n };\n\n /**\n * Announce when typed input became a math symbol. The MathQuill version\n * inferred this by counting braces; here a prompt whose latex grew by more\n * than the single character typed means a command was expanded.\n */\n announceConversion = (next) => {\n if (this.isDeleting) {\n this.isDeleting = false;\n return;\n }\n\n const converted = Object.keys(next).some((id) => {\n const before = this.promptValues[id] || '';\n const after = next[id] || '';\n\n return after.length > before.length + 1 && /\\\\/.test(after.slice(before.length));\n });\n\n if (converted) {\n this.announce('Converted to math symbol');\n }\n };\n\n /** Does this latex contain answer blocks? */\n isInteractive() {\n const latex = this.props.latex || '';\n\n return fieldIds(latex).length > 0 || latex.indexOf('\\\\placeholder') !== -1;\n }\n\n renderMarkup() {\n const markup = latexToMarkup(this.props.latex);\n\n if (markup !== this.state.markup) {\n this.setState({ markup });\n }\n }\n\n /** MathQuill's `innerFields` equivalent, keyed by prompt id. */\n values() {\n if (!this.mathField) {\n return {};\n }\n\n const out = {};\n\n (this.mathField.getPrompts() || []).forEach((id) => {\n out[id] = fromMathLive(this.mathField.getPromptValue(id));\n });\n\n return out;\n }\n\n /**\n * A MathQuill-inner-field-like handle for a prompt.\n *\n * The old API handed callers a MathQuill field object, and consumers commonly\n * called `field.latex()` on it. There is no equivalent object in MathLive -\n * prompts are addressed by id - so this adapter exposes the parts that were\n * actually used: `id` and a get/set `latex()`.\n */\n promptHandle(id) {\n return {\n id,\n // MathQuill's inner fields could be focused directly; keep that.\n focus: () => {\n if (this.mathField) {\n this.mathField.focus();\n this.focusPrompt(id);\n }\n },\n latex: (value) => {\n if (!this.mathField) {\n return '';\n }\n\n if (value === undefined) {\n return fromMathLive(this.mathField.getPromptValue(id));\n }\n\n this.mathField.setPromptValue(id, toMathLive(value), {});\n\n return value;\n },\n };\n }\n\n /** All prompt handles, the analogue of `mathField.innerFields`. */\n get innerFields() {\n if (!this.mathField) {\n return [];\n }\n\n return (this.mathField.getPrompts() || []).map((id) => this.promptHandle(id));\n }\n\n onPromptInput = () => {\n const { onSubFieldChange, getFieldName } = this.props;\n\n if (!this.mathField) {\n return;\n }\n\n const next = this.values();\n\n this.announceConversion(next);\n\n if (!onSubFieldChange) {\n this.promptValues = next;\n return;\n }\n\n const fields = this.innerFields;\n\n // Emit only the prompts whose value actually changed, mirroring the\n // per-field granularity of the old onSubFieldChange(name, latex).\n Object.keys(next).forEach((id) => {\n if (next[id] === this.promptValues[id]) {\n return;\n }\n\n const name = getFieldName(this.promptHandle(id), fields) || id;\n\n onSubFieldChange(name, next[id]);\n });\n\n this.promptValues = next;\n };\n\n onPromptFocus = () => {\n const { onSubFieldFocus, getFieldName } = this.props;\n\n if (!this.mathField || !onSubFieldFocus) {\n return;\n }\n\n try {\n const ids = this.mathField.getPrompts() || [];\n // The focused prompt is the one containing the current selection.\n const focused = ids.find((id) => {\n const range = this.mathField.getPromptRange(id);\n const selection = this.mathField.selection;\n\n if (!range || !selection || !selection.ranges || !selection.ranges.length) {\n return false;\n }\n\n const [start, end] = range;\n const [selStart] = selection.ranges[0];\n\n return selStart >= start && selStart <= end;\n });\n\n if (focused) {\n const handle = this.promptHandle(focused);\n const name = getFieldName(handle, this.innerFields) || focused;\n\n if (this.props.setInput) {\n this.props.setInput(handle);\n }\n\n onSubFieldFocus(name, handle);\n }\n } catch (e) {\n log('error resolving focused prompt: %s', e.message);\n }\n };\n\n /** The id of the prompt whose range contains `position`, if any. */\n promptContaining(position) {\n if (!this.mathField || typeof position !== 'number') {\n return undefined;\n }\n\n return (this.mathField.getPrompts() || []).find((id) => {\n const range = this.mathField.getPromptRange(id);\n\n return range && position >= range[0] && position <= range[1];\n });\n }\n\n /**\n * Put a blinking caret inside an answer block.\n *\n * MathLive only makes the caret visible while the field element carries the\n * `ML__focused` class, and it adds that class during a *render*, gated on\n * `isSelectionEditable && hasFocus()`. In a read-only field only prompt\n * interiors are editable, so the two things both have to be true:\n *\n * - the selection must sit inside a prompt, and\n * - a render must run afterwards.\n *\n * Assigning `selection` satisfies the first but not the second - it updates\n * the model without re-rendering, so the class stays off and the caret span\n * remains `visibility: hidden`. Executing any command does trigger the\n * render, and `scrollIntoView` is the one with no other effect: it keeps the\n * caret on screen, which the preceding `focus()` already does anyway.\n *\n * @param {string} [id] prompt to focus; defaults to the first one\n */\n focusPrompt(id) {\n if (!this.mathField) {\n return;\n }\n\n const ids = this.mathField.getPrompts() || [];\n const target = id && ids.indexOf(id) !== -1 ? id : ids[0];\n\n if (!target) {\n return;\n }\n\n const range = this.mathField.getPromptRange(target);\n\n if (!range) {\n return;\n }\n\n this.mathField.selection = { ranges: [[range[0], range[0]]] };\n\n if (typeof this.mathField.executeCommand === 'function') {\n this.mathField.executeCommand('scrollIntoView');\n }\n }\n\n focus() {\n if (!this.mathField) {\n return;\n }\n\n this.mathField.focus();\n\n // A bare focus() leaves the selection outside every prompt, which in a\n // read-only field is not editable - the block looked focused but had no\n // cursor. Clicking a prompt already works, because MathLive's own pointer\n // handling moves the selection and re-renders.\n if (!this.promptContaining(this.mathField.position)) {\n this.focusPrompt();\n }\n }\n\n blur() {\n this.mathField && this.mathField.blur();\n }\n\n render() {\n const { className, onFocus, onBlur } = this.props;\n const { markup } = this.state;\n\n if (this.mathField || this.isInteractive()) {\n return <Holder className={className} onFocus={onFocus} onBlur={onBlur} ref={this.holderRef} />;\n }\n\n return (\n <Holder\n className={className}\n onFocus={onFocus}\n onBlur={onBlur}\n ref={this.holderRef}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: markup }}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAQA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAAqE,SAAAO,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,KA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M,EAAEA,MAAO;UAACC,GAAG,EAAE,IAAI,CAAC5E;QAAU,CAAE,CAAC;MAChG;MAEA,oBACEvH,MAAA,YAAA0D,aAAA,CAACf,MAAM;QACLqJ,SAAS,EAAEA,SAAU;QACrBC,OAAO,EAAEA,OAAQ;QACjBC,MAAM,EAAEA,MAAO;QACfC,GAAG,EAAE,IAAI,CAAC5E;QACV;QAAA;QACA6E,uBAAuB,EAAE;UAAEC,MAAM,EAAE1E;QAAO;MAAE,CAC7C,CAAC;IAEN;EAAC;AAAA,EAtaiCH,iBAAK,CAAC8E,SAAS;AAAA,IAAAjK,gBAAA,aAA9Ba,MAAM,eACN;EACjBsG,KAAK,EAAE+C,qBAAS,CAACC,MAAM,CAACC,UAAU;EAClCT,SAAS,EAAEO,qBAAS,CAACC,MAAM;EAC3BP,OAAO,EAAEM,qBAAS,CAACG,IAAI;EACvBR,MAAM,EAAEK,qBAAS,CAACG,IAAI;EACtB7G,YAAY,EAAE0G,qBAAS,CAACG,IAAI;EAC5B9G,gBAAgB,EAAE2G,qBAAS,CAACG,IAAI;EAChCpG,eAAe,EAAEiG,qBAAS,CAACG,IAAI;EAC/BpF,QAAQ,EAAEiF,qBAAS,CAACG;AACtB,CAAC;AAAA,IAAArK,gBAAA,aAVkBa,MAAM,kBAYH;EACpB2C,YAAY,EAAE,SAAdA,YAAYA,CAAA,EAAQ,CAAC;AACvB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"static.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_debug","_mathliveInstance","_latexBridge","_commonStyles","_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","Holder","styled","display","placeholderStyles","rootIndexStyles","parallelStyles","border","background","Static","exports","_React$Component","props","_this","_classCallCheck2","document","liveRegion","createElement","assign","style","position","width","height","marginTop","clip","overflow","setAttribute","body","appendChild","parentNode","removeChild","undefined","message","textContent","clearTimeout","announceTimeout","setTimeout","event","isDeleting","key","next","converted","some","id","before","promptValues","after","test","slice","announce","_this$props","onSubFieldChange","getFieldName","mathField","values","announceConversion","fields","innerFields","name","promptHandle","_this$props2","onSubFieldFocus","ids","getPrompts","focused","find","range","getPromptRange","selection","ranges","_range","_slicedToArray2","start","end","_selection$ranges$","selStart","handle","setInput","holderRef","React","createRef","state","markup","_inherits2","_createClass2","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","generation","ml","wrap","_context","prev","mountGeneration","isInteractive","loadMathLive","renderMarkup","abrupt","sent","current","MathfieldElement","macros","getMacros","readOnly","mathVirtualKeyboardPolicy","mathModeSpace","MATH_MODE_SPACE","toMathLive","latex","applyShadowStyles","untrackCaret","trackPlaceholderCaret","addEventListener","onPromptInput","onPromptFocus","onKeyDown","replaceChildren","createLiveRegion","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","removeEventListener","remove","removeLiveRegion","fieldIds","indexOf","latexToMarkup","setState","_this2","out","fromMathLive","getPromptValue","_this3","focus","focusPrompt","setPromptValue","get","_this4","map","promptContaining","_this5","target","executeCommand","blur","render","_this$props3","className","onFocus","onBlur","ref","dangerouslySetInnerHTML","__html","Component","PropTypes","string","isRequired","func"],"sources":["../../src/mf/static.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport {\n loadMathLive,\n getMacros,\n latexToMarkup,\n MATH_MODE_SPACE,\n applyShadowStyles,\n trackPlaceholderCaret,\n} from '../mathlive-instance';\nimport { toMathLive, fromMathLive, fieldIds } from '../latex-bridge';\nimport { placeholderStyles, rootIndexStyles, parallelStyles } from './common-styles';\n\nconst log = debug('pie-lib:math-input-mathlive:static');\n\nconst Holder = styled('span')({\n display: 'inline-block',\n // Shared static-math rules: muted empty-slot glyphs and svg containment.\n ...placeholderStyles,\n // Readable radical index - display mode renders in the light DOM, so the\n // shadow-root copy of this rule does not reach it.\n ...rootIndexStyles,\n ...parallelStyles,\n '& math-field': {\n display: 'inline-block',\n border: 'none',\n background: 'transparent',\n },\n '& math-field::part(virtual-keyboard-toggle)': {\n display: 'none',\n },\n '& math-field::part(menu-toggle)': {\n display: 'none',\n },\n});\n\n/**\n * Static math. Drop-in replacement for @pie-lib/math-input's `mq.Static`.\n *\n * Two modes, chosen automatically:\n *\n * - **display** (no answer blocks in the latex): rendered with\n * `convertLatexToMarkup`. No mathfield instance, so it is cheap enough for\n * keypad labels - the old implementation created a full MathQuill\n * StaticMath per button.\n *\n * - **interactive** (latex contains `\\MathQuillMathField[..]{}` /\n * `\\placeholder[..]{}`): a read-only `<math-field>` whose placeholders stay\n * editable. Sub-field values are surfaced through the prompts API, replacing\n * MathQuill's `innerFields`.\n */\nexport default class Static extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n className: PropTypes.string,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n getFieldName: PropTypes.func,\n onSubFieldChange: PropTypes.func,\n onSubFieldFocus: PropTypes.func,\n setInput: PropTypes.func,\n };\n\n static defaultProps = {\n getFieldName: () => {},\n };\n\n constructor(props) {\n super(props);\n this.holderRef = React.createRef();\n this.state = { markup: '' };\n this.promptValues = {};\n }\n\n async componentDidMount() {\n // See the note in mf/input.jsx: a generation counter, not a boolean, so a\n // StrictMode mount -> unmount -> mount on the same instance still ends up\n // with exactly one field.\n const generation = (this.mountGeneration = (this.mountGeneration || 0) + 1);\n\n if (!this.isInteractive()) {\n await loadMathLive();\n\n if (generation === this.mountGeneration) {\n this.renderMarkup();\n }\n\n return;\n }\n\n const ml = await loadMathLive();\n\n if (generation !== this.mountGeneration || !ml || !this.holderRef.current || this.mathField) {\n return;\n }\n\n this.mathField = new ml.MathfieldElement({ macros: getMacros() });\n this.mathField.readOnly = true;\n this.mathField.mathVirtualKeyboardPolicy = 'manual';\n // Without this the spacebar does nothing: MathLive's mathModeSpace\n // defaults to an empty string.\n this.mathField.mathModeSpace = MATH_MODE_SPACE;\n this.mathField.value = toMathLive(this.props.latex);\n\n // The mathfield renders in shadow DOM, so page CSS cannot reach it - the\n // stretchy-accent fix has to be injected there directly.\n applyShadowStyles(this.mathField);\n\n // A selected `\\placeholder{}` gets no MathLive caret; draw one. Answer\n // blocks are typed into with the same keypad, so they grow placeholders too.\n this.untrackCaret = trackPlaceholderCaret(this.mathField);\n\n this.mathField.addEventListener('input', this.onPromptInput);\n this.mathField.addEventListener('focusin', this.onPromptFocus);\n this.mathField.addEventListener('keydown', this.onKeyDown);\n\n // Belt and braces: drop anything a previous mount may have left behind.\n this.holderRef.current.replaceChildren(this.mathField);\n\n this.createLiveRegion();\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.latex === this.props.latex) {\n return;\n }\n\n if (this.mathField) {\n this.mathField.value = toMathLive(this.props.latex);\n } else {\n this.renderMarkup();\n }\n }\n\n componentWillUnmount() {\n // Invalidate any mount still awaiting the MathLive load.\n this.mountGeneration = (this.mountGeneration || 0) + 1;\n\n if (this.untrackCaret) {\n this.untrackCaret();\n this.untrackCaret = undefined;\n }\n\n if (this.mathField) {\n this.mathField.removeEventListener('input', this.onPromptInput);\n this.mathField.removeEventListener('focusin', this.onPromptFocus);\n this.mathField.removeEventListener('keydown', this.onKeyDown);\n this.mathField.remove();\n this.mathField = undefined;\n }\n\n this.removeLiveRegion();\n }\n\n /**\n * Off-screen aria-live region, ported from @pie-lib/math-input's Static.\n *\n * MathLive has its own accessibility layer, but it does not announce that\n * typed input was converted into a math symbol, which screen-reader users\n * relied on in the MathQuill implementation.\n */\n createLiveRegion = () => {\n if (typeof document === 'undefined' || this.liveRegion) {\n return;\n }\n\n this.liveRegion = document.createElement('div');\n Object.assign(this.liveRegion.style, {\n position: 'absolute',\n width: '1px',\n height: '1px',\n marginTop: '-1px',\n clip: 'rect(1px, 1px, 1px, 1px)',\n overflow: 'hidden',\n });\n this.liveRegion.setAttribute('aria-live', 'polite');\n this.liveRegion.setAttribute('aria-atomic', 'true');\n\n document.body.appendChild(this.liveRegion);\n };\n\n removeLiveRegion = () => {\n if (this.liveRegion && this.liveRegion.parentNode) {\n this.liveRegion.parentNode.removeChild(this.liveRegion);\n }\n\n this.liveRegion = undefined;\n };\n\n announce = (message) => {\n if (!this.liveRegion) {\n return;\n }\n\n this.liveRegion.textContent = message;\n\n // Clear once announced, so the same message can be announced again.\n clearTimeout(this.announceTimeout);\n this.announceTimeout = setTimeout(() => {\n if (this.liveRegion) {\n this.liveRegion.textContent = '';\n }\n }, 500);\n };\n\n onKeyDown = (event) => {\n // Deletions should not be announced as conversions.\n this.isDeleting = event?.key === 'Backspace' || event?.key === 'Delete';\n };\n\n /**\n * Announce when typed input became a math symbol. The MathQuill version\n * inferred this by counting braces; here a prompt whose latex grew by more\n * than the single character typed means a command was expanded.\n */\n announceConversion = (next) => {\n if (this.isDeleting) {\n this.isDeleting = false;\n return;\n }\n\n const converted = Object.keys(next).some((id) => {\n const before = this.promptValues[id] || '';\n const after = next[id] || '';\n\n return after.length > before.length + 1 && /\\\\/.test(after.slice(before.length));\n });\n\n if (converted) {\n this.announce('Converted to math symbol');\n }\n };\n\n /** Does this latex contain answer blocks? */\n isInteractive() {\n const latex = this.props.latex || '';\n\n return fieldIds(latex).length > 0 || latex.indexOf('\\\\placeholder') !== -1;\n }\n\n renderMarkup() {\n const markup = latexToMarkup(this.props.latex);\n\n if (markup !== this.state.markup) {\n this.setState({ markup });\n }\n }\n\n /** MathQuill's `innerFields` equivalent, keyed by prompt id. */\n values() {\n if (!this.mathField) {\n return {};\n }\n\n const out = {};\n\n (this.mathField.getPrompts() || []).forEach((id) => {\n out[id] = fromMathLive(this.mathField.getPromptValue(id));\n });\n\n return out;\n }\n\n /**\n * A MathQuill-inner-field-like handle for a prompt.\n *\n * The old API handed callers a MathQuill field object, and consumers commonly\n * called `field.latex()` on it. There is no equivalent object in MathLive -\n * prompts are addressed by id - so this adapter exposes the parts that were\n * actually used: `id` and a get/set `latex()`.\n */\n promptHandle(id) {\n return {\n id,\n // MathQuill's inner fields could be focused directly; keep that.\n focus: () => {\n if (this.mathField) {\n this.mathField.focus();\n this.focusPrompt(id);\n }\n },\n latex: (value) => {\n if (!this.mathField) {\n return '';\n }\n\n if (value === undefined) {\n return fromMathLive(this.mathField.getPromptValue(id));\n }\n\n this.mathField.setPromptValue(id, toMathLive(value), {});\n\n return value;\n },\n };\n }\n\n /** All prompt handles, the analogue of `mathField.innerFields`. */\n get innerFields() {\n if (!this.mathField) {\n return [];\n }\n\n return (this.mathField.getPrompts() || []).map((id) => this.promptHandle(id));\n }\n\n onPromptInput = () => {\n const { onSubFieldChange, getFieldName } = this.props;\n\n if (!this.mathField) {\n return;\n }\n\n const next = this.values();\n\n this.announceConversion(next);\n\n if (!onSubFieldChange) {\n this.promptValues = next;\n return;\n }\n\n const fields = this.innerFields;\n\n // Emit only the prompts whose value actually changed, mirroring the\n // per-field granularity of the old onSubFieldChange(name, latex).\n Object.keys(next).forEach((id) => {\n if (next[id] === this.promptValues[id]) {\n return;\n }\n\n const name = getFieldName(this.promptHandle(id), fields) || id;\n\n onSubFieldChange(name, next[id]);\n });\n\n this.promptValues = next;\n };\n\n onPromptFocus = () => {\n const { onSubFieldFocus, getFieldName } = this.props;\n\n if (!this.mathField || !onSubFieldFocus) {\n return;\n }\n\n try {\n const ids = this.mathField.getPrompts() || [];\n // The focused prompt is the one containing the current selection.\n const focused = ids.find((id) => {\n const range = this.mathField.getPromptRange(id);\n const selection = this.mathField.selection;\n\n if (!range || !selection || !selection.ranges || !selection.ranges.length) {\n return false;\n }\n\n const [start, end] = range;\n const [selStart] = selection.ranges[0];\n\n return selStart >= start && selStart <= end;\n });\n\n if (focused) {\n const handle = this.promptHandle(focused);\n const name = getFieldName(handle, this.innerFields) || focused;\n\n if (this.props.setInput) {\n this.props.setInput(handle);\n }\n\n onSubFieldFocus(name, handle);\n }\n } catch (e) {\n log('error resolving focused prompt: %s', e.message);\n }\n };\n\n /** The id of the prompt whose range contains `position`, if any. */\n promptContaining(position) {\n if (!this.mathField || typeof position !== 'number') {\n return undefined;\n }\n\n return (this.mathField.getPrompts() || []).find((id) => {\n const range = this.mathField.getPromptRange(id);\n\n return range && position >= range[0] && position <= range[1];\n });\n }\n\n /**\n * Put a blinking caret inside an answer block.\n *\n * MathLive only makes the caret visible while the field element carries the\n * `ML__focused` class, and it adds that class during a *render*, gated on\n * `isSelectionEditable && hasFocus()`. In a read-only field only prompt\n * interiors are editable, so the two things both have to be true:\n *\n * - the selection must sit inside a prompt, and\n * - a render must run afterwards.\n *\n * Assigning `selection` satisfies the first but not the second - it updates\n * the model without re-rendering, so the class stays off and the caret span\n * remains `visibility: hidden`. Executing any command does trigger the\n * render, and `scrollIntoView` is the one with no other effect: it keeps the\n * caret on screen, which the preceding `focus()` already does anyway.\n *\n * @param {string} [id] prompt to focus; defaults to the first one\n */\n focusPrompt(id) {\n if (!this.mathField) {\n return;\n }\n\n const ids = this.mathField.getPrompts() || [];\n const target = id && ids.indexOf(id) !== -1 ? id : ids[0];\n\n if (!target) {\n return;\n }\n\n const range = this.mathField.getPromptRange(target);\n\n if (!range) {\n return;\n }\n\n this.mathField.selection = { ranges: [[range[0], range[0]]] };\n\n if (typeof this.mathField.executeCommand === 'function') {\n this.mathField.executeCommand('scrollIntoView');\n }\n }\n\n focus() {\n if (!this.mathField) {\n return;\n }\n\n this.mathField.focus();\n\n // A bare focus() leaves the selection outside every prompt, which in a\n // read-only field is not editable - the block looked focused but had no\n // cursor. Clicking a prompt already works, because MathLive's own pointer\n // handling moves the selection and re-renders.\n if (!this.promptContaining(this.mathField.position)) {\n this.focusPrompt();\n }\n }\n\n blur() {\n this.mathField && this.mathField.blur();\n }\n\n render() {\n const { className, onFocus, onBlur } = this.props;\n const { markup } = this.state;\n\n if (this.mathField || this.isInteractive()) {\n return <Holder className={className} onFocus={onFocus} onBlur={onBlur} ref={this.holderRef} />;\n }\n\n return (\n <Holder\n className={className}\n onFocus={onFocus}\n onBlur={onBlur}\n ref={this.holderRef}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: markup }}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAQA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAAqF,SAAAO,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,qBAAA,QAAAjB,CAAA,GAAAe,MAAA,CAAAE,qBAAA,CAAAhB,CAAA,GAAAa,CAAA,KAAAd,CAAA,GAAAA,CAAA,CAAAkB,MAAA,WAAAJ,CAAA,WAAAC,MAAA,CAAAI,wBAAA,CAAAlB,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,EAAEO,qBAAS,CAACC,MAAM;EAC3BP,OAAO,EAAEM,qBAAS,CAACG,IAAI;EACvBR,MAAM,EAAEK,qBAAS,CAACG,IAAI;EACtB7G,YAAY,EAAE0G,qBAAS,CAACG,IAAI;EAC5B9G,gBAAgB,EAAE2G,qBAAS,CAACG,IAAI;EAChCpG,eAAe,EAAEiG,qBAAS,CAACG,IAAI;EAC/BpF,QAAQ,EAAEiF,qBAAS,CAACG;AACtB,CAAC;AAAA,IAAAtK,gBAAA,aAVkBc,MAAM,kBAYH;EACpB2C,YAAY,EAAE,SAAdA,YAAYA,CAAA,EAAQ,CAAC;AACvB,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.1.5-beta.3",
6
+ "version": "1.1.5-beta.5",
7
7
  "description": "MathLive-based math input (drop-in alternative to @pie-lib/math-input)",
8
8
  "main": "lib/index.js",
9
9
  "module": "src/index.jsx",
@@ -22,10 +22,25 @@ const log = debug('pie-lib:math-input-mathlive:keypad');
22
22
  * `convertLatexToMarkup`, so a 40-key keypad no longer creates 40 live math
23
23
  * instances.
24
24
  */
25
+ // Labels that the legacy keypad drew slanted. MathQuill styled `\parallel` as
26
+ // italic, which slants the two bars; MathLive draws it upright. A skew is used
27
+ // rather than `font-style: italic` so the slant does not depend on the font
28
+ // having an italic face for this glyph.
29
+ const SLANTED_LABELS = ['\\parallel'];
30
+ const SLANT = 'skewX(-15deg)';
31
+ // MathLive's `∥` has hairline bars next to the radical sign and the other keys, so
32
+ // they are thickened with a text stroke and stretched a little taller.
33
+ const SLANTED_STROKE = '0.03em currentColor';
34
+ const SLANTED_SCALE_Y = 1.25;
35
+
25
36
  // The `color.*()` helpers must be called lazily, inside the styled callback.
26
37
  // Evaluating them in a plain object literal runs them at module load, which
27
38
  // breaks any consumer that mocks a subset of @pie-lib/render-ui.
28
- const LabelHolder = styled('span')(() => ({
39
+ const LabelHolder = styled('span', { shouldForwardProp: (prop) => prop !== 'slanted' })(({ slanted }) => ({
40
+ ...(slanted && {
41
+ transform: `${SLANT} scaleY(${SLANTED_SCALE_Y})`,
42
+ '& *': { WebkitTextStroke: SLANTED_STROKE },
43
+ }),
29
44
  pointerEvents: 'none',
30
45
  textTransform: 'none',
31
46
  color: color.text(),
@@ -112,9 +127,9 @@ export class LatexLabel extends React.Component {
112
127
  // Fall back to the raw latex so a button is never blank.
113
128
  return markup ? (
114
129
  // eslint-disable-next-line react/no-danger
115
- <LabelHolder dangerouslySetInnerHTML={{ __html: markup }} />
130
+ <LabelHolder slanted={SLANTED_LABELS.includes(this.props.latex)} dangerouslySetInnerHTML={{ __html: markup }} />
116
131
  ) : (
117
- <LabelHolder>{this.props.latex}</LabelHolder>
132
+ <LabelHolder slanted={SLANTED_LABELS.includes(this.props.latex)}>{this.props.latex}</LabelHolder>
118
133
  );
119
134
  }
120
135
  }
@@ -69,6 +69,14 @@ export const DEFAULT_FIELD_ID = 'r1';
69
69
  */
70
70
  const EMPTY_SLOT = '\\htmlData{pie-empty=1}{\\rule{0.55em}{0.55em}}';
71
71
  const EMPTY_GROUP_REGEX = /\{\s*\}/g;
72
+ // Empty delimiter pairs: `\abs{}` is converted to `\left|\right|`, and the
73
+ // parenthesis / bracket keys are `\left(\right)` / `\left[\right]`. None has a
74
+ // `{}` group for the rule above to catch, so they would render as bare fences.
75
+ const EMPTY_FENCE_REGEX = /\\left([(\[|])\s*\\right([)\]|])/g;
76
+ // The same muted fill as the other slots (`pie-empty`), but a tall rectangle
77
+ // rather than a square. It also sets the fences' height: `\left...\right` stretch
78
+ // to their content, so a taller slot gives taller parentheses.
79
+ const EMPTY_FENCE_SLOT = '\\htmlData{pie-empty=1}{\\rule{0.55em}{1em}}';
72
80
 
73
81
  /**
74
82
  * Make empty argument slots visible, for static rendering.
@@ -79,7 +87,10 @@ const EMPTY_GROUP_REGEX = /\{\s*\}/g;
79
87
  * @param {string} latex
80
88
  * @returns {string}
81
89
  */
82
- export const withVisibleEmptySlots = (latex) => (latex || '').replace(EMPTY_GROUP_REGEX, `{${EMPTY_SLOT}}`);
90
+ export const withVisibleEmptySlots = (latex) =>
91
+ (latex || '')
92
+ .replace(EMPTY_GROUP_REGEX, `{${EMPTY_SLOT}}`)
93
+ .replace(EMPTY_FENCE_REGEX, (_m, open, close) => `\\left${open}${EMPTY_FENCE_SLOT}\\right${close}`);
83
94
 
84
95
  /**
85
96
  * Pie commands that take an argument, and their native MathLive equivalents.
@@ -258,13 +269,40 @@ const MATHQUILL_ALIASES = {
258
269
  const MATHQUILL_ALIAS_REGEX = /\\(divide|perpendicular)(?![a-zA-Z])/g;
259
270
 
260
271
  /**
261
- * Replace MathQuill alias names with the command MathQuill actually stored.
272
+ * Primes. MathLive turns a prime that follows a base into a superscript atom and
273
+ * serialises it as `^{\\prime}`, or `^{\\doubleprime}` for the keypad's double
274
+ * prime key (`5''` comes back out as `5^{\\doubleprime}`). MathJax has no
275
+ * `\\doubleprime`, and two adjacent `^{\\prime}` groups - what typing `'` twice
276
+ * produces - are a "double exponent" error. MathQuill stored plain apostrophes,
277
+ * which both MathJax and MathLive read as primes, so store those.
278
+ *
279
+ * Only a superscript made of primes alone is rewritten: `x^{\\prime 2}` keeps
280
+ * its group, since it holds more than primes.
281
+ */
282
+ const PRIME_SUPERSCRIPT_REGEX = /\^\{((?:\s*\\(?:prime|doubleprime)(?![a-zA-Z]))+)\s*\}/g;
283
+ const BARE_DOUBLEPRIME_REGEX = /\\doubleprime(?![a-zA-Z])/g;
284
+
285
+ const primesToApostrophes = (primes) =>
286
+ // eslint-disable-next-line quotes
287
+ "'".repeat(
288
+ (primes.match(/\\prime(?![a-zA-Z])/g) || []).length + 2 * (primes.match(BARE_DOUBLEPRIME_REGEX) || []).length,
289
+ );
290
+
291
+ /**
292
+ * Rewrite what MathLive serialises into the form MathQuill stored: alias
293
+ * command names, and primes.
262
294
  *
263
295
  * @param {string} latex
264
296
  * @returns {string}
265
297
  */
266
298
  export const toCanonicalCommands = (latex) =>
267
- typeof latex === 'string' ? latex.replace(MATHQUILL_ALIAS_REGEX, (m) => MATHQUILL_ALIASES[m]) : latex;
299
+ typeof latex === 'string'
300
+ ? latex
301
+ .replace(MATHQUILL_ALIAS_REGEX, (m) => MATHQUILL_ALIASES[m])
302
+ .replace(PRIME_SUPERSCRIPT_REGEX, (_m, primes) => primesToApostrophes(primes))
303
+ // eslint-disable-next-line quotes
304
+ .replace(BARE_DOUBLEPRIME_REGEX, "''")
305
+ : latex;
268
306
 
269
307
  /**
270
308
  * Convert latex out of MathLive back into the stored form, so items authored
@@ -1,6 +1,6 @@
1
1
  import debug from 'debug';
2
2
  import { NEWLINE_EMBED, toMathLive, withVisibleEmptySlots } from './latex-bridge';
3
- import { ROOT_INDEX_CSS } from './mf/common-styles';
3
+ import { ROOT_INDEX_CSS, PARALLEL_CSS } from './mf/common-styles';
4
4
 
5
5
  const log = debug('pie-lib:math-input-mathlive:instance');
6
6
 
@@ -116,6 +116,9 @@ export const PIE_MACROS = {
116
116
  // Argument-less symbols. Atomic is correct here: backspace should remove the
117
117
  // whole glyph, and there is nothing to type into.
118
118
  parallelogram: '\\htmlData{pie-macro=parallelogram}{\\unicode{"25B1}}',
119
+ // Same glyph as the built-in `\\parallel` (U+2225), tagged so it can be sized -
120
+ // see `parallelStyles`.
121
+ parallel: '\\htmlData{pie-macro=parallel}{\\unicode{"2225}}',
119
122
  napprox: '\\not\\approx',
120
123
  nsim: '\\not\\sim',
121
124
  ncong: '\\not\\cong',
@@ -236,7 +239,10 @@ const PLACEHOLDER_CARET_CSS = [
236
239
  // written for static markup in the host page, which cannot cross the shadow
237
240
  // boundary.
238
241
  const SHADOW_CSS =
239
- '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}' + ROOT_INDEX_CSS + PLACEHOLDER_CARET_CSS;
242
+ '.ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}' +
243
+ ROOT_INDEX_CSS +
244
+ PARALLEL_CSS +
245
+ PLACEHOLDER_CARET_CSS;
240
246
 
241
247
  /**
242
248
  * Keep {@link PLACEHOLDER_CARET_CLASS} in step with the selection.
@@ -75,6 +75,24 @@ export const rootIndexStyles = {
75
75
  */
76
76
  export const ROOT_INDEX_CSS = `${ROOT_INDEX_SELECTOR}{font-size:${ROOT_INDEX_FONT_SIZE} !important}`;
77
77
 
78
+ /**
79
+ * Size of the parallel sign (`\parallel`, tagged `data-pie-macro="parallel"` by
80
+ * `PIE_MACROS`). The legacy editor enlarged it (`updateSpans` set 32px) because
81
+ * the bars read too small next to the letters of `AB ∥ CD`; MathLive draws it at
82
+ * the surrounding size, so it is scaled up here. Not applied to keypad labels.
83
+ */
84
+ const PARALLEL_SELECTOR = '[data-pie-macro="parallel"]';
85
+ const PARALLEL_FONT_SIZE = '1.4em';
86
+
87
+ export const parallelStyles = {
88
+ [`& ${PARALLEL_SELECTOR}`]: {
89
+ fontSize: PARALLEL_FONT_SIZE,
90
+ },
91
+ };
92
+
93
+ /** The same rule as a CSS string, for a live mathfield's shadow root. */
94
+ export const PARALLEL_CSS = `${PARALLEL_SELECTOR}{font-size:${PARALLEL_FONT_SIZE}}`;
95
+
78
96
  /**
79
97
  * Superscript/subscript sizing. MathLive follows TeX metrics for scripts, so the
80
98
  * MathQuill-era corrections are gone; the radical index is the one place where a
@@ -82,6 +100,7 @@ export const ROOT_INDEX_CSS = `${ROOT_INDEX_SELECTOR}{font-size:${ROOT_INDEX_FON
82
100
  */
83
101
  export const supsubStyles = {
84
102
  ...rootIndexStyles,
103
+ ...parallelStyles,
85
104
  };
86
105
 
87
106
  /** Empty placeholder boxes (answer blocks / open slots). */
package/src/mf/index.js CHANGED
@@ -7,6 +7,7 @@ import CommonMqStyles, {
7
7
  commonMqKeyboardStyles,
8
8
  longdivStyles,
9
9
  rootIndexStyles,
10
+ parallelStyles,
10
11
  supsubStyles,
11
12
  placeholderStyles,
12
13
  } from './common-styles';
@@ -23,6 +24,7 @@ export {
23
24
  commonMqKeyboardStyles,
24
25
  longdivStyles,
25
26
  rootIndexStyles,
27
+ parallelStyles,
26
28
  supsubStyles,
27
29
  placeholderStyles,
28
30
  };
package/src/mf/static.jsx CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  trackPlaceholderCaret,
12
12
  } from '../mathlive-instance';
13
13
  import { toMathLive, fromMathLive, fieldIds } from '../latex-bridge';
14
- import { placeholderStyles, rootIndexStyles } from './common-styles';
14
+ import { placeholderStyles, rootIndexStyles, parallelStyles } from './common-styles';
15
15
 
16
16
  const log = debug('pie-lib:math-input-mathlive:static');
17
17
 
@@ -22,6 +22,7 @@ const Holder = styled('span')({
22
22
  // Readable radical index - display mode renders in the light DOM, so the
23
23
  // shadow-root copy of this rule does not reach it.
24
24
  ...rootIndexStyles,
25
+ ...parallelStyles,
25
26
  '& math-field': {
26
27
  display: 'inline-block',
27
28
  border: 'none',