@pie-lib/math-input-mathlive 1.0.9-next.6618 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -6
- package/lib/__tests__/composites.test.js +255 -0
- package/lib/__tests__/composites.test.js.map +1 -0
- package/lib/__tests__/drop-in-compat.test.js +133 -0
- package/lib/__tests__/drop-in-compat.test.js.map +1 -0
- package/lib/__tests__/index.test.js +118 -0
- package/lib/__tests__/index.test.js.map +1 -0
- package/lib/__tests__/input-imperative.test.js +155 -0
- package/lib/__tests__/input-imperative.test.js.map +1 -0
- package/lib/__tests__/keypad-label.test.js +44 -0
- package/lib/__tests__/keypad-label.test.js.map +1 -0
- package/lib/__tests__/keypad-render.test.js +206 -0
- package/lib/__tests__/keypad-render.test.js.map +1 -0
- package/lib/__tests__/latex-bridge.test.js +251 -0
- package/lib/__tests__/latex-bridge.test.js.map +1 -0
- package/lib/__tests__/mathlive-instance.test.js +237 -0
- package/lib/__tests__/mathlive-instance.test.js.map +1 -0
- package/lib/__tests__/mount-race.test.js +194 -0
- package/lib/__tests__/mount-race.test.js.map +1 -0
- package/lib/__tests__/static-prompts.test.js +282 -0
- package/lib/__tests__/static-prompts.test.js.map +1 -0
- package/lib/mathlive-instance.js +47 -10
- package/lib/mathlive-instance.js.map +1 -1
- package/lib/mf/input.js +18 -5
- package/lib/mf/input.js.map +1 -1
- package/lib/mf/static.js +17 -4
- package/lib/mf/static.js.map +1 -1
- package/package.json +3 -4
- package/src/__tests__/composites.test.jsx +220 -0
- package/src/__tests__/keypad-label.test.jsx +5 -13
- package/src/__tests__/keypad-render.test.jsx +123 -0
- package/src/__tests__/mathlive-instance.test.js +40 -0
- package/src/__tests__/mount-race.test.jsx +129 -0
- package/src/__tests__/static-prompts.test.jsx +251 -0
- package/src/mathlive-instance.js +50 -11
- package/src/mf/input.jsx +19 -5
- package/src/mf/static.jsx +20 -4
- package/LICENSE.md +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathlive-instance.js","names":["_debug","_interopRequireDefault","require","_latexBridge","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_interopRequireWildcard","WeakMap","n","__esModule","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","log","debug","mathlive","fontsDirectory","absoluteFontsDirectory","dir","test","URL","document","baseURI","href","message","configureFonts","exports","MathfieldElement","PIE_MACROS","parallelogram","napprox","nsim","ncong","nparallel","perpendicular","divide","degree","square","longdiv","overarc","abs","embeds","Map","KNOWN_EMBED_LATEX","newLine","answerBlock","loadWarned","configureLoaded","undefined","injectCoreStylesheet","renderMathInElement","createElement","loadMathLiveSync","window","loadMathLive","_ref","_asyncToGenerator2","_regenerator","mark","_callee","_t","wrap","_context","prev","next","abrupt","Promise","resolve","then","sent","process","env","NODE_ENV","console","warn","stop","getMathLive","getMacros","out","_ref2","name","latex","concat","registerEmbed","factory","definition","prototype","mathliveLatex","registeredEmbeds","Array","from","__resetEmbeds","clear","__setMathLiveForTest","stub","applyStaticMath","element","options","source","textContent","ml","loaded","isConnected","innerHTML","convertLatexToMarkup","withVisibleEmptySlots","toMathLive","macros","latexToMarkup"],"sources":["../src/mathlive-instance.js"],"sourcesContent":["import debug from 'debug';\nimport { NEWLINE_EMBED, toMathLive, withVisibleEmptySlots } from './latex-bridge';\n\nconst log = debug('pie-lib:math-input-mathlive:instance');\n\n/**\n * MathLive bootstrap + compatibility shims for @pie-lib/math-input's public API.\n *\n * MathLive is loaded lazily and only in the browser: the editor bundle is\n * ~227KB gzip and registers custom elements, so it must never run during SSR.\n */\n\nlet mathlive;\n\n/**\n * Where the KaTeX woff2 fonts are served from, as configured by the host app.\n * `undefined` means \"not configured\"; `null` means \"explicitly disabled\".\n */\nlet fontsDirectory;\n\n/**\n * Turn a fonts path into a fully-qualified URL.\n *\n * MathLive's default `fontsDirectory` is the relative `'./fonts/'`, which it\n * resolves against its own script URL. Under a bundler (webpack/Next) that\n * script URL is empty, so `new URL('./fonts/', '')` throws\n * \"Failed to construct 'URL': Invalid base URL\" from `loadFonts`.\n * Resolving against `document.baseURI` avoids that entirely and honours any\n * <base href> / asset prefix the host app uses.\n */\nconst absoluteFontsDirectory = (dir) => {\n if (!dir) {\n return dir;\n }\n\n // Already absolute (http://, https://, //cdn...) - MathLive handles these.\n if (/^(?:[a-z+]+:)?\\/\\//i.test(dir)) {\n return dir;\n }\n\n try {\n return new URL(dir, document.baseURI).href;\n } catch (e) {\n log('could not resolve fontsDirectory \"%s\": %s', dir, e && e.message);\n return null;\n }\n};\n\n/**\n * Tell the package where the MathLive fonts are served from.\n *\n * Call before `loadMathLive()`. Accepts an absolute URL, a root-relative path\n * (`/mathlive-fonts`) or a relative one; pass `null` to skip font loading and\n * fall back to system fonts.\n *\n * The fonts ship inside the `mathlive` package (`node_modules/mathlive/fonts`)\n * and must be copied 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 = absoluteFontsDirectory(dir);\n }\n};\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. Either point at the host app's copy or\n // disable font loading, both of which are safe.\n if (fontsDirectory === undefined) {\n log(\n 'no fontsDirectory configured - MathLive will use fallback fonts. ' +\n 'Call configureFonts(\"/path/to/fonts\") with a copy of node_modules/mathlive/fonts to enable them.',\n );\n }\n\n mathlive.MathfieldElement.fontsDirectory =\n fontsDirectory === undefined ? null : absoluteFontsDirectory(fontsDirectory);\n\n injectCoreStylesheet();\n};\n\n/**\n * Ensure MathLive's \"core\" stylesheet is in the document.\n *\n * `convertLatexToMarkup` - which renders keypad labels and static math - does\n * NOT inject it, while `renderMathInElement` and live mathfields do. Without it\n * the generated markup is unstyled: glyphs misalign and the <svg> used by\n * stretchy accents lays out statically at an unbounded width.\n *\n * Hosts that can import CSS should `import 'mathlive/static.css'`. For bundles\n * that cannot handle CSS imports (pie-elements ships JS-only web components),\n * this triggers MathLive's own injection against a detached element, so the\n * styles come from MathLive itself rather than being duplicated here.\n */\nconst injectCoreStylesheet = () => {\n if (typeof document === 'undefined' || !mathlive || !mathlive.renderMathInElement) {\n return;\n }\n\n try {\n mathlive.renderMathInElement(document.createElement('span'));\n } catch (e) {\n log('could not trigger MathLive core stylesheet injection: %s', e && e.message);\n }\n};\n\n/**\n * Load MathLive synchronously when the bundler allows it.\n *\n * `require` keeps MathLive inside the host's bundle. An `import()` would make\n * webpack emit a separate chunk, and a deployment that does not serve that\n * chunk fails with a 404 at runtime - leaving every mathfield and keypad label\n * blank with no obvious cause. Being in the main bundle also makes the engine\n * available on first render, so callers that run synchronously (applyStaticMath,\n * keypad labels) work without a second pass.\n *\n * Returns undefined during SSR or if the module is genuinely unavailable.\n *\n * @returns {object|undefined}\n */\nexport const loadMathLiveSync = () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (!mathlive) {\n try {\n // eslint-disable-next-line global-require\n mathlive = require('mathlive');\n configureLoaded();\n } catch (e) {\n log('synchronous MathLive load unavailable: %s', e && e.message);\n return undefined;\n }\n }\n\n return mathlive;\n};\n\n/**\n * Load MathLive. Prefers the synchronous path; falls back to a dynamic import.\n * Resolves to undefined during SSR.\n *\n * @returns {Promise<object|undefined>}\n */\nexport const loadMathLive = async () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (mathlive) {\n return mathlive;\n }\n\n if (loadMathLiveSync()) {\n return mathlive;\n }\n\n try {\n mathlive = await import('mathlive');\n configureLoaded();\n } catch (e) {\n // Surface this once: a silent failure here renders every field and keypad\n // label blank, which is very hard to trace back to a module load.\n // Skipped under test, where jsdom cannot load the browser build.\n if (!loadWarned && process.env.NODE_ENV !== 'test') {\n loadWarned = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[@pie-lib/math-input-mathlive] MathLive could not be loaded; math input will not render. ' +\n 'If this is a bundling issue, ensure \"mathlive\" is resolvable from the host bundle. Cause: ' +\n (e && e.message),\n );\n }\n\n return undefined;\n }\n\n return mathlive;\n};\n\n/**\n * Synchronous accessor for an already-loaded MathLive.\n * @returns {object|undefined}\n */\nexport const getMathLive = () => mathlive;\n\n/**\n * The macro dictionary to hand to a mathfield: pie macros plus anything\n * registered through `registerEmbed`.\n *\n * @returns {object}\n */\nexport const getMacros = () => {\n const out = { ...PIE_MACROS };\n\n embeds.forEach(({ latex }, name) => {\n out[name] = `\\\\htmlData{embed=${name}}{${latex}}`;\n });\n\n return out;\n};\n\n/**\n * Register an embed. API-compatible with @pie-lib/math-input's `registerEmbed`\n * so existing callers do not change.\n *\n * MathQuill's factory returns `{ htmlString, text, latex }`. Only the\n * declarative parts survive: `latex` round-trips through a macro and the\n * styling hook becomes a `data-embed` attribute. Arbitrary DOM injection via\n * `htmlString` has no MathLive equivalent and is ignored.\n *\n * @param {string} name\n * @param {Function} factory\n */\nexport function registerEmbed(name, factory) {\n if (!name || typeof factory !== 'function') {\n return;\n }\n\n let definition = {};\n\n try {\n definition = factory() || {};\n } catch (e) {\n log('embed factory threw for \"%s\": %s', name, e.message);\n }\n\n const latex = Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name)\n ? KNOWN_EMBED_LATEX[name]\n : definition.mathliveLatex || '\\\\placeholder{}';\n\n if (!Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name) && !definition.mathliveLatex) {\n // Unknown third-party embed: degrade instead of throwing. `htmlString`\n // cannot be reproduced, so it renders as an editable slot.\n log(\n 'embed \"%s\" is not natively supported by MathLive; rendering as a placeholder. ' +\n 'Provide `mathliveLatex` in the factory result to control this.',\n name,\n );\n }\n\n embeds.set(name, { factory, latex });\n}\n\n/**\n * Embeds registered so far. Exposed for tests/diagnostics.\n * @returns {string[]}\n */\nexport const registeredEmbeds = () => Array.from(embeds.keys());\n\n/** Reset the embed registry. Test helper. */\nexport const __resetEmbeds = () => embeds.clear();\n\n/** Inject a stub MathLive instance. Test helper. */\nexport const __setMathLiveForTest = (stub) => {\n mathlive = stub;\n};\n\n/**\n * Render static math into an element. API-compatible with\n * @pie-lib/math-input's `applyStaticMath`.\n *\n * Callers written against MathQuill invoke this synchronously from lifecycle\n * methods, where MathLive (a dynamic import) may not have loaded yet. Rather\n * than silently rendering nothing, this kicks off the load and re-applies once\n * the engine is ready, so the element fills in on the next tick.\n *\n * @param {HTMLElement} element\n * @param {string} [latex] assigned to the element before rendering\n * @param {object} [options] `{ macros }` overrides\n * @returns {HTMLElement|undefined} the element, or undefined if deferred\n */\nexport function applyStaticMath(element, latex, options = {}) {\n if (!element || typeof window === 'undefined') {\n return undefined;\n }\n\n // Capture the source now: if we defer, the element's textContent may have\n // been overwritten by the time MathLive is ready.\n const source = latex === undefined || latex === null ? element.textContent : latex;\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml) {\n log('applyStaticMath called before MathLive loaded - deferring until it is ready');\n\n loadMathLive().then((loaded) => {\n // The element may have been unmounted while loading.\n if (loaded && element.isConnected !== false) {\n applyStaticMath(element, source, options);\n }\n });\n\n return undefined;\n }\n\n element.innerHTML = ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(source)), {\n macros: { ...getMacros(), ...(options.macros || {}) },\n });\n\n return element;\n}\n\n/**\n * Convert latex to markup using the pie macro set. Used for keypad labels and\n * any read-only rendering that does not need a live mathfield.\n *\n * @param {string} latex\n * @param {object} [options]\n * @returns {string} HTML markup, or '' if MathLive is not loaded\n */\nexport function latexToMarkup(latex, options = {}) {\n // Try the synchronous load so the very first render can produce markup\n // instead of falling back to raw latex.\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml || !latex) {\n return '';\n }\n\n try {\n // Empty groups render as nothing in static markup, so give them a visible\n // box. This covers every static path: keypad labels, mf.Static in display\n // mode, and applyStaticMath.\n return ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(latex)), {\n macros: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A,CAAAC,MAAA,QAAAD,SAAA,QAAAwD,SAAA,GAAAxD,SAAA,MAAG,CAAC,CAAC;EAC/C;EACA;EACA,IAAM4G,EAAE,GAAGxB,WAAW,CAAC,CAAC,IAAIxB,gBAAgB,CAAC,CAAC;EAE9C,IAAI,CAACgD,EAAE,IAAI,CAACnB,KAAK,EAAE;IACjB,OAAO,EAAE;EACX;EAEA,IAAI;IACF;IACA;IACA;IACA,OAAOmB,EAAE,CAACI,oBAAoB,CAAC,IAAAC,kCAAqB,EAAC,IAAAC,uBAAU,EAACzB,KAAK,CAAC,CAAC,EAAA1F,aAAA;MACrEoH,MAAM,EAAApH,aAAA,CAAAA,aAAA,KAAOsF,SAAS,CAAC,CAAC,GAAMoB,OAAO,CAACU,MAAM,IAAI,CAAC,CAAC;IAAG,GAClDV,OAAO,CACX,CAAC;EACJ,CAAC,CAAC,OAAOtH,CAAC,EAAE;IACVkC,GAAG,CAAC,0CAA0C,EAAEoE,KAAK,EAAEtG,CAAC,CAAC6C,OAAO,CAAC;IACjE,OAAO,EAAE;EACX;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"mathlive-instance.js","names":["_debug","_interopRequireDefault","require","_latexBridge","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_interopRequireWildcard","WeakMap","n","__esModule","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","log","debug","mathlive","fontsDirectory","absoluteFontsDirectory","dir","test","URL","document","baseURI","href","message","FALLBACK_MATHLIVE_VERSION","cdnFontsDirectory","version","concat","configureFonts","exports","MathfieldElement","undefined","MATH_MODE_SPACE","PIE_MACROS","parallelogram","napprox","nsim","ncong","nparallel","perpendicular","divide","degree","square","longdiv","overarc","abs","embeds","Map","KNOWN_EMBED_LATEX","newLine","answerBlock","loadWarned","configureLoaded","injectCoreStylesheet","renderMathInElement","createElement","loadMathLiveSync","window","loadMathLive","_ref","_asyncToGenerator2","_regenerator","mark","_callee","_t","wrap","_context","prev","next","abrupt","Promise","resolve","then","sent","process","env","NODE_ENV","console","warn","stop","getMathLive","getMacros","out","_ref2","name","latex","registerEmbed","factory","definition","prototype","mathliveLatex","registeredEmbeds","Array","from","__resetEmbeds","clear","__setMathLiveForTest","stub","applyStaticMath","element","options","source","textContent","ml","loaded","isConnected","innerHTML","convertLatexToMarkup","withVisibleEmptySlots","toMathLive","macros","latexToMarkup"],"sources":["../src/mathlive-instance.js"],"sourcesContent":["import debug from 'debug';\nimport { NEWLINE_EMBED, toMathLive, withVisibleEmptySlots } from './latex-bridge';\n\nconst log = debug('pie-lib:math-input-mathlive:instance');\n\n/**\n * MathLive bootstrap + compatibility shims for @pie-lib/math-input's public API.\n *\n * MathLive is loaded lazily and only in the browser: the editor bundle is\n * ~227KB gzip and registers custom elements, so it must never run during SSR.\n */\n\nlet mathlive;\n\n/**\n * Where the KaTeX woff2 fonts are served from, as configured by the host app.\n * `undefined` means \"not configured\"; `null` means \"explicitly disabled\".\n */\nlet fontsDirectory;\n\n/**\n * Turn a fonts path into a fully-qualified URL.\n *\n * MathLive's default `fontsDirectory` is the relative `'./fonts/'`, which it\n * resolves against its own script URL. Under a bundler (webpack/Next) that\n * script URL is empty, so `new URL('./fonts/', '')` throws\n * \"Failed to construct 'URL': Invalid base URL\" from `loadFonts`.\n * Resolving against `document.baseURI` avoids that entirely and honours any\n * <base href> / asset prefix the host app uses.\n */\nconst absoluteFontsDirectory = (dir) => {\n if (!dir) {\n return dir;\n }\n\n // Already absolute (http://, https://, //cdn...) - MathLive handles these.\n if (/^(?:[a-z+]+:)?\\/\\//i.test(dir)) {\n return dir;\n }\n\n try {\n return new URL(dir, document.baseURI).href;\n } catch (e) {\n log('could not resolve fontsDirectory \"%s\": %s', dir, e && e.message);\n return null;\n }\n};\n\n/**\n * Version-pinned CDN fallback for the KaTeX fonts.\n *\n * Some symbols are composed from Private Use Area glyphs that exist only in\n * those fonts: `\\\\neq` is U+E020 (a negation slash) overlapped on `=`, and\n * `\\\\nsim` / `\\\\ncong` work the same way. With no fonts the browser substitutes\n * an arbitrary glyph for U+E020, so those keys render as garbage rather than\n * simply falling back to a plainer face.\n *\n * The version comes from MathLive itself, so the fonts always match the engine.\n * Hosts that would rather not depend on a third party should serve the fonts and\n * call `configureFonts('/their/path')`, or pass `null` to opt out.\n */\nconst FALLBACK_MATHLIVE_VERSION = '0.110.0';\n\nconst cdnFontsDirectory = () => {\n const version = (mathlive && mathlive.version && mathlive.version.mathlive) || FALLBACK_MATHLIVE_VERSION;\n\n // NOTE: `/fonts`, not `/dist/fonts` - the published package root holds them.\n return `https://unpkg.com/mathlive@${version}/fonts`;\n};\n\n/**\n * Tell the package where the MathLive fonts are served from.\n *\n * Call before `loadMathLive()`.\n *\n * - a path/URL: served by you, no third-party request\n * - `null`: skip font loading; note `\\\\neq`, `\\\\nsim` and `\\\\ncong` then\n * render incorrectly, being built from Private Use Area glyphs\n * - not called: falls back to a version-pinned CDN\n *\n * The fonts ship inside the `mathlive` package (`node_modules/mathlive/fonts`)\n * ready to copy into whatever the host app serves statically.\n *\n * @param {string|null} [dir]\n */\nexport const configureFonts = (dir) => {\n fontsDirectory = dir;\n\n if (mathlive) {\n mathlive.MathfieldElement.fontsDirectory = dir === undefined ? cdnFontsDirectory() : absoluteFontsDirectory(dir);\n }\n};\n\n/**\n * What the spacebar inserts in math mode.\n *\n * MathLive's `mathModeSpace` defaults to an empty string, which makes the\n * spacebar a no-op - users cannot type a space at all. `\\\\ ` (a LaTeX control\n * space) is what MathQuill serialised spaces as, so existing content and the\n * MathJax renderer in @pie-lib/math-rendering both already understand it.\n *\n * A literal \" \" is not usable: LaTeX skips raw whitespace.\n */\nexport const MATH_MODE_SPACE = '\\\\ ';\n\n/**\n * Custom macros for the pie-specific commands that the MathQuill fork\n * understood but stock LaTeX does not.\n *\n * Kept deliberately in sync with the MathJax macros in\n * @pie-lib/math-rendering (`render-math.js`) so the same latex renders the same\n * way in the editor and in the static renderer.\n */\nexport const PIE_MACROS = {\n // Argument-less symbols. Atomic is correct here: backspace should remove the\n // whole glyph, and there is nothing to type into.\n parallelogram: '\\\\htmlData{pie-macro=parallelogram}{\\\\unicode{\"25B1}}',\n napprox: '\\\\not\\\\approx',\n nsim: '\\\\not\\\\sim',\n ncong: '\\\\not\\\\cong',\n nparallel: '\\\\not\\\\parallel',\n perpendicular: '\\\\perp',\n divide: '\\\\div',\n degree: '^{\\\\circ}',\n square: '\\\\unicode{\"25A1}',\n\n // Argument-taking commands, kept ONLY so previously authored latex still\n // parses and renders. They are never used for editing: MathLive serialises a\n // macro from the arguments it was created with, so text typed inside the\n // expansion never comes back out of `getValue('latex')`. Anything entering a\n // mathfield is rewritten to the native equivalent first - see\n // `toNativeCommands` in latex-bridge.\n longdiv: '\\\\enclose{longdiv}{#1}',\n overarc: '\\\\overparen{#1}',\n abs: '\\\\left|#1\\\\right|',\n};\n\n/**\n * Registry for `registerEmbed`.\n *\n * MathLive has no embed plugin system, so an embed is expressed as a macro that\n * expands to real LaTeX. `\\htmlData{embed=<name>}` tags the rendered output so\n * consumers can target it with CSS exactly as they targeted the old\n * `htmlString` markup.\n *\n * Known embeds map to native constructs:\n * - `newLine` -> structural, handled by latex-bridge (`\\displaylines` + `\\\\`)\n * - `answerBlock`-> `\\placeholder{}` (interactive, read via the prompts API)\n *\n * @type {Map<string, {factory: Function, latex: string}>}\n */\nconst embeds = new Map();\n\nconst KNOWN_EMBED_LATEX = {\n // newLine is structural: it is translated by latex-bridge before it ever\n // reaches MathLive, so the macro only needs to be harmless.\n newLine: '',\n answerBlock: '\\\\placeholder{}',\n};\n\nlet loadWarned = false;\n\n/** Apply post-load configuration exactly once. */\nconst configureLoaded = () => {\n // Always replace MathLive's relative `'./fonts/'` default: it throws\n // \"Invalid base URL\" when bundled. Use the host's copy if one was configured,\n // otherwise the version-pinned CDN.\n if (fontsDirectory === undefined) {\n log(\n 'no fontsDirectory configured - falling back to the CDN (%s). ' +\n 'Serve the fonts yourself and call configureFonts(\"/path/to/fonts\") to avoid the network request, ' +\n 'or configureFonts(null) to opt out.',\n cdnFontsDirectory(),\n );\n }\n\n mathlive.MathfieldElement.fontsDirectory =\n fontsDirectory === undefined ? cdnFontsDirectory() : absoluteFontsDirectory(fontsDirectory);\n\n injectCoreStylesheet();\n};\n\n/**\n * Ensure MathLive's \"core\" stylesheet is in the document.\n *\n * `convertLatexToMarkup` - which renders keypad labels and static math - does\n * NOT inject it, while `renderMathInElement` and live mathfields do. Without it\n * the generated markup is unstyled: glyphs misalign and the <svg> used by\n * stretchy accents lays out statically at an unbounded width.\n *\n * Hosts that can import CSS should `import 'mathlive/static.css'`. For bundles\n * that cannot handle CSS imports (pie-elements ships JS-only web components),\n * this triggers MathLive's own injection against a detached element, so the\n * styles come from MathLive itself rather than being duplicated here.\n */\nconst injectCoreStylesheet = () => {\n if (typeof document === 'undefined' || !mathlive || !mathlive.renderMathInElement) {\n return;\n }\n\n try {\n mathlive.renderMathInElement(document.createElement('span'));\n } catch (e) {\n log('could not trigger MathLive core stylesheet injection: %s', e && e.message);\n }\n};\n\n/**\n * Load MathLive synchronously when the bundler allows it.\n *\n * `require` keeps MathLive inside the host's bundle. An `import()` would make\n * webpack emit a separate chunk, and a deployment that does not serve that\n * chunk fails with a 404 at runtime - leaving every mathfield and keypad label\n * blank with no obvious cause. Being in the main bundle also makes the engine\n * available on first render, so callers that run synchronously (applyStaticMath,\n * keypad labels) work without a second pass.\n *\n * Returns undefined during SSR or if the module is genuinely unavailable.\n *\n * @returns {object|undefined}\n */\nexport const loadMathLiveSync = () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (!mathlive) {\n try {\n // eslint-disable-next-line global-require\n mathlive = require('mathlive');\n configureLoaded();\n } catch (e) {\n log('synchronous MathLive load unavailable: %s', e && e.message);\n return undefined;\n }\n }\n\n return mathlive;\n};\n\n/**\n * Load MathLive. Prefers the synchronous path; falls back to a dynamic import.\n * Resolves to undefined during SSR.\n *\n * @returns {Promise<object|undefined>}\n */\nexport const loadMathLive = async () => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n if (mathlive) {\n return mathlive;\n }\n\n if (loadMathLiveSync()) {\n return mathlive;\n }\n\n try {\n mathlive = await import('mathlive');\n configureLoaded();\n } catch (e) {\n // Surface this once: a silent failure here renders every field and keypad\n // label blank, which is very hard to trace back to a module load.\n // Skipped under test, where jsdom cannot load the browser build.\n if (!loadWarned && process.env.NODE_ENV !== 'test') {\n loadWarned = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[@pie-lib/math-input-mathlive] MathLive could not be loaded; math input will not render. ' +\n 'If this is a bundling issue, ensure \"mathlive\" is resolvable from the host bundle. Cause: ' +\n (e && e.message),\n );\n }\n\n return undefined;\n }\n\n return mathlive;\n};\n\n/**\n * Synchronous accessor for an already-loaded MathLive.\n * @returns {object|undefined}\n */\nexport const getMathLive = () => mathlive;\n\n/**\n * The macro dictionary to hand to a mathfield: pie macros plus anything\n * registered through `registerEmbed`.\n *\n * @returns {object}\n */\nexport const getMacros = () => {\n const out = { ...PIE_MACROS };\n\n embeds.forEach(({ latex }, name) => {\n out[name] = `\\\\htmlData{embed=${name}}{${latex}}`;\n });\n\n return out;\n};\n\n/**\n * Register an embed. API-compatible with @pie-lib/math-input's `registerEmbed`\n * so existing callers do not change.\n *\n * MathQuill's factory returns `{ htmlString, text, latex }`. Only the\n * declarative parts survive: `latex` round-trips through a macro and the\n * styling hook becomes a `data-embed` attribute. Arbitrary DOM injection via\n * `htmlString` has no MathLive equivalent and is ignored.\n *\n * @param {string} name\n * @param {Function} factory\n */\nexport function registerEmbed(name, factory) {\n if (!name || typeof factory !== 'function') {\n return;\n }\n\n let definition = {};\n\n try {\n definition = factory() || {};\n } catch (e) {\n log('embed factory threw for \"%s\": %s', name, e.message);\n }\n\n const latex = Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name)\n ? KNOWN_EMBED_LATEX[name]\n : definition.mathliveLatex || '\\\\placeholder{}';\n\n if (!Object.prototype.hasOwnProperty.call(KNOWN_EMBED_LATEX, name) && !definition.mathliveLatex) {\n // Unknown third-party embed: degrade instead of throwing. `htmlString`\n // cannot be reproduced, so it renders as an editable slot.\n log(\n 'embed \"%s\" is not natively supported by MathLive; rendering as a placeholder. ' +\n 'Provide `mathliveLatex` in the factory result to control this.',\n name,\n );\n }\n\n embeds.set(name, { factory, latex });\n}\n\n/**\n * Embeds registered so far. Exposed for tests/diagnostics.\n * @returns {string[]}\n */\nexport const registeredEmbeds = () => Array.from(embeds.keys());\n\n/** Reset the embed registry. Test helper. */\nexport const __resetEmbeds = () => embeds.clear();\n\n/** Inject a stub MathLive instance. Test helper. */\nexport const __setMathLiveForTest = (stub) => {\n mathlive = stub;\n};\n\n/**\n * Render static math into an element. API-compatible with\n * @pie-lib/math-input's `applyStaticMath`.\n *\n * Callers written against MathQuill invoke this synchronously from lifecycle\n * methods, where MathLive (a dynamic import) may not have loaded yet. Rather\n * than silently rendering nothing, this kicks off the load and re-applies once\n * the engine is ready, so the element fills in on the next tick.\n *\n * @param {HTMLElement} element\n * @param {string} [latex] assigned to the element before rendering\n * @param {object} [options] `{ macros }` overrides\n * @returns {HTMLElement|undefined} the element, or undefined if deferred\n */\nexport function applyStaticMath(element, latex, options = {}) {\n if (!element || typeof window === 'undefined') {\n return undefined;\n }\n\n // Capture the source now: if we defer, the element's textContent may have\n // been overwritten by the time MathLive is ready.\n const source = latex === undefined || latex === null ? element.textContent : latex;\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml) {\n log('applyStaticMath called before MathLive loaded - deferring until it is ready');\n\n loadMathLive().then((loaded) => {\n // The element may have been unmounted while loading.\n if (loaded && element.isConnected !== false) {\n applyStaticMath(element, source, options);\n }\n });\n\n return undefined;\n }\n\n element.innerHTML = ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(source)), {\n macros: { ...getMacros(), ...(options.macros || {}) },\n });\n\n return element;\n}\n\n/**\n * Convert latex to markup using the pie macro set. Used for keypad labels and\n * any read-only rendering that does not need a live mathfield.\n *\n * @param {string} latex\n * @param {object} [options]\n * @returns {string} HTML markup, or '' if MathLive is not loaded\n */\nexport function latexToMarkup(latex, options = {}) {\n // Try the synchronous load so the very first render can produce markup\n // instead of falling back to raw latex.\n const ml = getMathLive() || loadMathLiveSync();\n\n if (!ml || !latex) {\n return '';\n }\n\n try {\n // Empty groups render as nothing in static markup, so give them a visible\n // box. This covers every static path: keypad labels, mf.Static in display\n // mode, and applyStaticMath.\n return ml.convertLatexToMarkup(withVisibleEmptySlots(toMathLive(latex)), {\n macros: { ...getMacros(), ...(options.macros || {}) },\n ...options,\n });\n } catch (e) {\n log('convertLatexToMarkup failed for \"%s\": %s', latex, e.message);\n return '';\n }\n}\n\nexport { NEWLINE_EMBED };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAkF,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,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,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CA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ACF;IACA;IACA;IACA,OAAOkB,EAAE,CAACI,oBAAoB,CAAC,IAAAC,kCAAqB,EAAC,IAAAC,uBAAU,EAACxB,KAAK,CAAC,CAAC,EAAA/F,aAAA;MACrEwH,MAAM,EAAAxH,aAAA,CAAAA,aAAA,KAAO2F,SAAS,CAAC,CAAC,GAAMmB,OAAO,CAACU,MAAM,IAAI,CAAC,CAAC;IAAG,GAClDV,OAAO,CACX,CAAC;EACJ,CAAC,CAAC,OAAO1H,CAAC,EAAE;IACVkC,GAAG,CAAC,0CAA0C,EAAEyE,KAAK,EAAE3G,CAAC,CAAC6C,OAAO,CAAC;IACjE,OAAO,EAAE;EACX;AACF","ignoreList":[]}
|
package/lib/mf/input.js
CHANGED
|
@@ -80,16 +80,22 @@ var Input = exports.Input = /*#__PURE__*/function (_React$Component) {
|
|
|
80
80
|
key: "componentDidMount",
|
|
81
81
|
value: function () {
|
|
82
82
|
var _componentDidMount = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
83
|
-
var
|
|
84
|
-
var ml;
|
|
83
|
+
var generation, ml;
|
|
85
84
|
return _regenerator["default"].wrap(function (_context) {
|
|
86
85
|
while (1) switch (_context.prev = _context.next) {
|
|
87
86
|
case 0:
|
|
87
|
+
// MathLive loads asynchronously, so this method resumes after an await and
|
|
88
|
+
// has to know whether it is still the current mount. React StrictMode calls
|
|
89
|
+
// mount -> unmount -> mount on the SAME instance in dev, so a boolean
|
|
90
|
+
// "unmounted" flag would latch and block the remount from ever creating a
|
|
91
|
+
// field. A generation counter identifies the live mount instead: only the
|
|
92
|
+
// newest one proceeds, and a real unmount invalidates all pending ones.
|
|
93
|
+
generation = this.mountGeneration = (this.mountGeneration || 0) + 1;
|
|
88
94
|
_context.next = 1;
|
|
89
95
|
return (0, _mathliveInstance.loadMathLive)();
|
|
90
96
|
case 1:
|
|
91
97
|
ml = _context.sent;
|
|
92
|
-
if (!(!ml || !this.holderRef.current)) {
|
|
98
|
+
if (!(generation !== this.mountGeneration || !ml || !this.holderRef.current || this.mathField)) {
|
|
93
99
|
_context.next = 2;
|
|
94
100
|
break;
|
|
95
101
|
}
|
|
@@ -105,12 +111,16 @@ var Input = exports.Input = /*#__PURE__*/function (_React$Component) {
|
|
|
105
111
|
|
|
106
112
|
// pie drives input through its own keypad, so suppress MathLive's.
|
|
107
113
|
this.mathField.mathVirtualKeyboardPolicy = 'manual';
|
|
114
|
+
// Without this the spacebar does nothing: MathLive's mathModeSpace
|
|
115
|
+
// defaults to an empty string.
|
|
116
|
+
this.mathField.mathModeSpace = _mathliveInstance.MATH_MODE_SPACE;
|
|
108
117
|
this.mathField.addEventListener('input', this.onInputEdit);
|
|
109
|
-
|
|
118
|
+
|
|
119
|
+
// Belt and braces: drop anything a previous mount may have left behind.
|
|
120
|
+
this.holderRef.current.replaceChildren(this.mathField);
|
|
110
121
|
if (this.props.innerRef) {
|
|
111
122
|
this.props.innerRef(this);
|
|
112
123
|
}
|
|
113
|
-
(_this$setState = this.setState) === null || _this$setState === void 0 || _this$setState.call(this, {});
|
|
114
124
|
case 3:
|
|
115
125
|
case "end":
|
|
116
126
|
return _context.stop();
|
|
@@ -148,6 +158,9 @@ var Input = exports.Input = /*#__PURE__*/function (_React$Component) {
|
|
|
148
158
|
}, {
|
|
149
159
|
key: "componentWillUnmount",
|
|
150
160
|
value: function componentWillUnmount() {
|
|
161
|
+
// Invalidate any mount still awaiting the MathLive load, so it does not
|
|
162
|
+
// append a field into a holder that is going away.
|
|
163
|
+
this.mountGeneration = (this.mountGeneration || 0) + 1;
|
|
151
164
|
if (this.mathField) {
|
|
152
165
|
this.mathField.removeEventListener('input', this.onInputEdit);
|
|
153
166
|
this.mathField.remove();
|
package/lib/mf/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_debug","_mathliveInstance","_latexBridge","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","log","debug","Holder","styled","display","width","Input","exports","_React$Component","props","_this","_classCallCheck2","_defineProperty2","onChange","mathField","latex","fromMathLive","getValue","lastEmitted","event","key","preventDefault","holderRef","React","createRef","undefined","_inherits2","_createClass2","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","_this$setState","ml","wrap","_context","prev","next","loadMathLive","sent","current","abrupt","MathfieldElement","macros","getMacros","toMathLive","readOnly","mathVirtualKeyboardPolicy","addEventListener","onInputEdit","appendChild","innerRef","setState","stop","componentDidMount","arguments","componentDidUpdate","prevProps","_this$props","componentWillUnmount","removeEventListener","remove","get","_this2","v","setLatex","el","focus","blur","clear","command","action","keyToAction","insert","keystroke","selector","KEYSTROKES","executeCommand","message","write","_this3","values","Array","isArray","forEach","vv","render","_this$props2","className","onFocus","onBlur","onClick","createElement","onKeyDown","ref","Component","PropTypes","string","func","bool","_default"],"sources":["../../src/mf/input.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport { loadMathLive, getMacros } from '../mathlive-instance';\nimport { toMathLive, fromMathLive, keyToAction, KEYSTROKES } from '../latex-bridge';\n\nconst log = debug('pie-lib:math-input-mathlive:input');\n\nconst Holder = styled('span')({\n display: 'inline-block',\n '& math-field': {\n display: 'block',\n width: '100%',\n },\n // MathLive ships its own virtual keyboard toggle; pie supplies its own keypad.\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 * Editable math field. Drop-in replacement for @pie-lib/math-input's `mq.Input`.\n *\n * Keeps the same imperative surface used by MathInput's keypad\n * (`write`, `command`, `keystroke`, `clear`, `focus`, `blur`) so callers do not\n * change, and the same `latex` / `onChange` props.\n */\nexport class Input extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n latex: PropTypes.string,\n onChange: PropTypes.func,\n onClick: PropTypes.func,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n readOnly: PropTypes.bool,\n innerRef: PropTypes.func,\n };\n\n constructor(props) {\n super(props);\n this.holderRef = React.createRef();\n // Tracks the last latex we emitted, so prop echoes don't reset the cursor.\n this.lastEmitted = undefined;\n }\n\n async componentDidMount() {\n const ml = await loadMathLive();\n\n if (!ml || !this.holderRef.current) {\n return;\n }\n\n this.mathField = new ml.MathfieldElement({ macros: getMacros() });\n this.mathField.value = toMathLive(this.props.latex || '');\n\n if (this.props.readOnly) {\n this.mathField.readOnly = true;\n }\n\n // pie drives input through its own keypad, so suppress MathLive's.\n this.mathField.mathVirtualKeyboardPolicy = 'manual';\n\n this.mathField.addEventListener('input', this.onInputEdit);\n this.holderRef.current.appendChild(this.mathField);\n\n if (this.props.innerRef) {\n this.props.innerRef(this);\n }\n\n this.setState?.({});\n }\n\n componentDidUpdate(prevProps) {\n if (!this.mathField) {\n return;\n }\n\n const { latex, readOnly } = this.props;\n\n if (readOnly !== prevProps.readOnly) {\n this.mathField.readOnly = !!readOnly;\n }\n\n // Only push the prop back into the field when it genuinely differs from\n // what the field already holds. This is the analogue of the old\n // shouldComponentUpdate latex-equality guard and prevents cursor thrash.\n if (latex !== undefined && latex !== null && latex !== this.lastEmitted) {\n const next = toMathLive(latex);\n\n if (next !== this.mathField.value) {\n this.mathField.value = next;\n }\n }\n }\n\n componentWillUnmount() {\n if (this.mathField) {\n this.mathField.removeEventListener('input', this.onInputEdit);\n this.mathField.remove();\n this.mathField = undefined;\n }\n\n if (this.props.innerRef) {\n this.props.innerRef(null);\n }\n }\n\n onInputEdit = () => {\n const { onChange } = this.props;\n\n if (!this.mathField) {\n return;\n }\n\n const latex = fromMathLive(this.mathField.getValue('latex'));\n\n this.lastEmitted = latex;\n\n if (onChange) {\n onChange(latex);\n }\n };\n\n /** Current latex, in stored (MathQuill-compatible) form. */\n latex() {\n return this.mathField ? fromMathLive(this.mathField.getValue('latex')) : '';\n }\n\n /**\n * The underlying `<math-field>` element, or undefined until MathLive has\n * finished loading. Exposed for callers that need the real element.\n *\n * NOTE: this is NOT a MathQuill field. Code written against\n * `@pie-lib/math-input` often did `input.mathField.latex()`; that shape is\n * provided by `mqCompat` below, and `latex()` on this component is the\n * supported replacement.\n */\n get element() {\n return this.mathField;\n }\n\n /**\n * MathQuill-shaped facade, so existing `input.mathField.latex()` /\n * `.el()` call sites keep working instead of throwing. Only the members that\n * consumers actually used are provided; MathQuill internals such as\n * `__controller` have no MathLive equivalent and are deliberately absent.\n */\n get mqCompat() {\n return {\n latex: (v) => (v === undefined ? this.latex() : (this.setLatex(v), v)),\n el: () => this.mathField,\n focus: () => this.focus(),\n blur: () => this.blur(),\n };\n }\n\n /** Programmatically replace the content. */\n setLatex(v) {\n if (this.mathField) {\n this.mathField.value = toMathLive(v || '');\n }\n }\n\n clear() {\n if (this.mathField) {\n this.mathField.value = '';\n }\n\n return '';\n }\n\n blur() {\n log('blur mathfield');\n this.mathField && this.mathField.blur();\n }\n\n focus() {\n log('focus mathfield...');\n this.mathField && this.mathField.focus();\n }\n\n /**\n * MathQuill `cmd()` equivalent.\n *\n * Callers pass MathQuill command names (`'\\\\frac'`, `'\\\\sqrt'`, `'^'`, or an\n * array of them). Those must be expanded into latex with `#?` placeholders,\n * otherwise inserting a bare `\\frac` produces no editable slots.\n */\n command(v) {\n log('command: ', v);\n\n if (!this.mathField) {\n return '';\n }\n\n const action = keyToAction({ command: v });\n\n if (action) {\n this.mathField.insert(action.value, { focus: true });\n }\n\n this.mathField.focus();\n\n return this.latex();\n }\n\n /**\n * MathQuill `keystroke()` equivalent.\n *\n * Accepts MathQuill keystroke names (`'Left'`, `'Right'`, `'Backspace'`) as\n * the keypad emits them, and passes anything else through as a MathLive\n * selector.\n */\n keystroke(v) {\n log('keystroke: ', v);\n\n if (!this.mathField) {\n return '';\n }\n\n const selector = KEYSTROKES[v] || v;\n\n try {\n this.mathField.executeCommand(selector);\n } catch (e) {\n log('unknown keystroke/selector \"%s\": %s', v, e && e.message);\n }\n\n this.mathField.focus();\n\n return this.latex();\n }\n\n /** MathQuill `write()` equivalent. Accepts an array, as `cmd()` did. */\n write(v) {\n log('write: ', v);\n\n if (!this.mathField) {\n return '';\n }\n\n const values = Array.isArray(v) ? v : [v];\n\n values.forEach((vv) => this.mathField.insert(vv, { focus: true }));\n this.mathField.focus();\n\n return this.latex();\n }\n\n /**\n * Enter must not insert a line break: math input is single-expression, and\n * the MathQuill version swallowed charCode 13 for the same reason. Newlines\n * are authored explicitly through the newLine embed, not the Enter key.\n */\n onKeyDown = (event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n }\n };\n\n render() {\n const { className, onFocus, onBlur, onClick } = this.props;\n\n return (\n <Holder\n className={className}\n onFocus={onFocus}\n onBlur={onBlur}\n onClick={onClick}\n onKeyDown={this.onKeyDown}\n ref={this.holderRef}\n />\n );\n }\n}\n\nexport default Input;\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;AACA,IAAAK,YAAA,GAAAL,OAAA;AAAoF,SAAAM,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,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AAK,CAAC,CAAC;MAAA,EAAC;MAClE,IAAI,CAACvD,SAAS,CAACuD,KAAK,CAAC,CAAC;MAEtB,OAAO,IAAI,CAACtD,KAAK,CAAC,CAAC;IACrB;EAAC;IAAAK,GAAA;IAAAQ,KAAA,EAaD,SAAA4D,MAAMA,CAAA,EAAG;MACP,IAAAC,YAAA,GAAgD,IAAI,CAAChF,KAAK;QAAlDiF,SAAS,GAAAD,YAAA,CAATC,SAAS;QAAEC,OAAO,GAAAF,YAAA,CAAPE,OAAO;QAAEC,MAAM,GAAAH,YAAA,CAANG,MAAM;QAAEC,OAAO,GAAAJ,YAAA,CAAPI,OAAO;MAE3C,oBACEpH,MAAA,YAAAqH,aAAA,CAAC5F,MAAM;QACLwF,SAAS,EAAEA,SAAU;QACrBC,OAAO,EAAEA,OAAQ;QACjBC,MAAM,EAAEA,MAAO;QACfC,OAAO,EAAEA,OAAQ;QACjBE,SAAS,EAAE,IAAI,CAACA,SAAU;QAC1BC,GAAG,EAAE,IAAI,CAAC1E;MAAU,CACrB,CAAC;IAEN;EAAC;AAAA,EAvPwBC,iBAAK,CAAC0E,SAAS;AAAA,IAAArF,gBAAA,aAA7BN,KAAK,eACG;EACjBoF,SAAS,EAAEQ,qBAAS,CAACC,MAAM;EAC3BpF,KAAK,EAAEmF,qBAAS,CAACC,MAAM;EACvBtF,QAAQ,EAAEqF,qBAAS,CAACE,IAAI;EACxBP,OAAO,EAAEK,qBAAS,CAACE,IAAI;EACvBT,OAAO,EAAEO,qBAAS,CAACE,IAAI;EACvBR,MAAM,EAAEM,qBAAS,CAACE,IAAI;EACtBpD,QAAQ,EAAEkD,qBAAS,CAACG,IAAI;EACxBhD,QAAQ,EAAE6C,qBAAS,CAACE;AACtB,CAAC;AAAA,IAAAE,QAAA,GAAA/F,OAAA,cAgPYD,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"input.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_debug","_mathliveInstance","_latexBridge","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","log","debug","Holder","styled","display","width","Input","exports","_React$Component","props","_this","_classCallCheck2","_defineProperty2","onChange","mathField","latex","fromMathLive","getValue","lastEmitted","event","key","preventDefault","holderRef","React","createRef","undefined","_inherits2","_createClass2","value","_componentDidMount","_asyncToGenerator2","_regenerator","mark","_callee","generation","ml","wrap","_context","prev","next","mountGeneration","loadMathLive","sent","current","abrupt","MathfieldElement","macros","getMacros","toMathLive","readOnly","mathVirtualKeyboardPolicy","mathModeSpace","MATH_MODE_SPACE","addEventListener","onInputEdit","replaceChildren","innerRef","stop","componentDidMount","arguments","componentDidUpdate","prevProps","_this$props","componentWillUnmount","removeEventListener","remove","get","_this2","v","setLatex","el","focus","blur","clear","command","action","keyToAction","insert","keystroke","selector","KEYSTROKES","executeCommand","message","write","_this3","values","Array","isArray","forEach","vv","render","_this$props2","className","onFocus","onBlur","onClick","createElement","onKeyDown","ref","Component","PropTypes","string","func","bool","_default"],"sources":["../../src/mf/input.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport debug from 'debug';\nimport { loadMathLive, getMacros, MATH_MODE_SPACE } from '../mathlive-instance';\nimport { toMathLive, fromMathLive, keyToAction, KEYSTROKES } from '../latex-bridge';\n\nconst log = debug('pie-lib:math-input-mathlive:input');\n\nconst Holder = styled('span')({\n display: 'inline-block',\n '& math-field': {\n display: 'block',\n width: '100%',\n },\n // MathLive ships its own virtual keyboard toggle; pie supplies its own keypad.\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 * Editable math field. Drop-in replacement for @pie-lib/math-input's `mq.Input`.\n *\n * Keeps the same imperative surface used by MathInput's keypad\n * (`write`, `command`, `keystroke`, `clear`, `focus`, `blur`) so callers do not\n * change, and the same `latex` / `onChange` props.\n */\nexport class Input extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n latex: PropTypes.string,\n onChange: PropTypes.func,\n onClick: PropTypes.func,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n readOnly: PropTypes.bool,\n innerRef: PropTypes.func,\n };\n\n constructor(props) {\n super(props);\n this.holderRef = React.createRef();\n // Tracks the last latex we emitted, so prop echoes don't reset the cursor.\n this.lastEmitted = undefined;\n }\n\n async componentDidMount() {\n // MathLive loads asynchronously, so this method resumes after an await and\n // has to know whether it is still the current mount. React StrictMode calls\n // mount -> unmount -> mount on the SAME instance in dev, so a boolean\n // \"unmounted\" flag would latch and block the remount from ever creating a\n // field. A generation counter identifies the live mount instead: only the\n // newest one proceeds, and a real unmount invalidates all pending ones.\n const generation = (this.mountGeneration = (this.mountGeneration || 0) + 1);\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.value = toMathLive(this.props.latex || '');\n\n if (this.props.readOnly) {\n this.mathField.readOnly = true;\n }\n\n // pie drives input through its own keypad, so suppress MathLive's.\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\n this.mathField.addEventListener('input', this.onInputEdit);\n\n // Belt and braces: drop anything a previous mount may have left behind.\n this.holderRef.current.replaceChildren(this.mathField);\n\n if (this.props.innerRef) {\n this.props.innerRef(this);\n }\n }\n\n componentDidUpdate(prevProps) {\n if (!this.mathField) {\n return;\n }\n\n const { latex, readOnly } = this.props;\n\n if (readOnly !== prevProps.readOnly) {\n this.mathField.readOnly = !!readOnly;\n }\n\n // Only push the prop back into the field when it genuinely differs from\n // what the field already holds. This is the analogue of the old\n // shouldComponentUpdate latex-equality guard and prevents cursor thrash.\n if (latex !== undefined && latex !== null && latex !== this.lastEmitted) {\n const next = toMathLive(latex);\n\n if (next !== this.mathField.value) {\n this.mathField.value = next;\n }\n }\n }\n\n componentWillUnmount() {\n // Invalidate any mount still awaiting the MathLive load, so it does not\n // append a field into a holder that is going away.\n this.mountGeneration = (this.mountGeneration || 0) + 1;\n\n if (this.mathField) {\n this.mathField.removeEventListener('input', this.onInputEdit);\n this.mathField.remove();\n this.mathField = undefined;\n }\n\n if (this.props.innerRef) {\n this.props.innerRef(null);\n }\n }\n\n onInputEdit = () => {\n const { onChange } = this.props;\n\n if (!this.mathField) {\n return;\n }\n\n const latex = fromMathLive(this.mathField.getValue('latex'));\n\n this.lastEmitted = latex;\n\n if (onChange) {\n onChange(latex);\n }\n };\n\n /** Current latex, in stored (MathQuill-compatible) form. */\n latex() {\n return this.mathField ? fromMathLive(this.mathField.getValue('latex')) : '';\n }\n\n /**\n * The underlying `<math-field>` element, or undefined until MathLive has\n * finished loading. Exposed for callers that need the real element.\n *\n * NOTE: this is NOT a MathQuill field. Code written against\n * `@pie-lib/math-input` often did `input.mathField.latex()`; that shape is\n * provided by `mqCompat` below, and `latex()` on this component is the\n * supported replacement.\n */\n get element() {\n return this.mathField;\n }\n\n /**\n * MathQuill-shaped facade, so existing `input.mathField.latex()` /\n * `.el()` call sites keep working instead of throwing. Only the members that\n * consumers actually used are provided; MathQuill internals such as\n * `__controller` have no MathLive equivalent and are deliberately absent.\n */\n get mqCompat() {\n return {\n latex: (v) => (v === undefined ? this.latex() : (this.setLatex(v), v)),\n el: () => this.mathField,\n focus: () => this.focus(),\n blur: () => this.blur(),\n };\n }\n\n /** Programmatically replace the content. */\n setLatex(v) {\n if (this.mathField) {\n this.mathField.value = toMathLive(v || '');\n }\n }\n\n clear() {\n if (this.mathField) {\n this.mathField.value = '';\n }\n\n return '';\n }\n\n blur() {\n log('blur mathfield');\n this.mathField && this.mathField.blur();\n }\n\n focus() {\n log('focus mathfield...');\n this.mathField && this.mathField.focus();\n }\n\n /**\n * MathQuill `cmd()` equivalent.\n *\n * Callers pass MathQuill command names (`'\\\\frac'`, `'\\\\sqrt'`, `'^'`, or an\n * array of them). Those must be expanded into latex with `#?` placeholders,\n * otherwise inserting a bare `\\frac` produces no editable slots.\n */\n command(v) {\n log('command: ', v);\n\n if (!this.mathField) {\n return '';\n }\n\n const action = keyToAction({ command: v });\n\n if (action) {\n this.mathField.insert(action.value, { focus: true });\n }\n\n this.mathField.focus();\n\n return this.latex();\n }\n\n /**\n * MathQuill `keystroke()` equivalent.\n *\n * Accepts MathQuill keystroke names (`'Left'`, `'Right'`, `'Backspace'`) as\n * the keypad emits them, and passes anything else through as a MathLive\n * selector.\n */\n keystroke(v) {\n log('keystroke: ', v);\n\n if (!this.mathField) {\n return '';\n }\n\n const selector = KEYSTROKES[v] || v;\n\n try {\n this.mathField.executeCommand(selector);\n } catch (e) {\n log('unknown keystroke/selector \"%s\": %s', v, e && e.message);\n }\n\n this.mathField.focus();\n\n return this.latex();\n }\n\n /** MathQuill `write()` equivalent. Accepts an array, as `cmd()` did. */\n write(v) {\n log('write: ', v);\n\n if (!this.mathField) {\n return '';\n }\n\n const values = Array.isArray(v) ? v : [v];\n\n values.forEach((vv) => this.mathField.insert(vv, { focus: true }));\n this.mathField.focus();\n\n return this.latex();\n }\n\n /**\n * Enter must not insert a line break: math input is single-expression, and\n * the MathQuill version swallowed charCode 13 for the same reason. Newlines\n * are authored explicitly through the newLine embed, not the Enter key.\n */\n onKeyDown = (event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n }\n };\n\n render() {\n const { className, onFocus, onBlur, onClick } = this.props;\n\n return (\n <Holder\n className={className}\n onFocus={onFocus}\n onBlur={onBlur}\n onClick={onClick}\n onKeyDown={this.onKeyDown}\n ref={this.holderRef}\n />\n );\n }\n}\n\nexport default Input;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OA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EA,OAAQ;QACjBC,MAAM,EAAEA,MAAO;QACfC,OAAO,EAAEA,OAAQ;QACjBE,SAAS,EAAE,IAAI,CAACA,SAAU;QAC1BC,GAAG,EAAE,IAAI,CAAC5E;MAAU,CACrB,CAAC;IAEN;EAAC;AAAA,EArQwBC,iBAAK,CAAC4E,SAAS;AAAA,IAAAvF,gBAAA,aAA7BN,KAAK,eACG;EACjBsF,SAAS,EAAEQ,qBAAS,CAACC,MAAM;EAC3BtF,KAAK,EAAEqF,qBAAS,CAACC,MAAM;EACvBxF,QAAQ,EAAEuF,qBAAS,CAACE,IAAI;EACxBP,OAAO,EAAEK,qBAAS,CAACE,IAAI;EACvBT,OAAO,EAAEO,qBAAS,CAACE,IAAI;EACvBR,MAAM,EAAEM,qBAAS,CAACE,IAAI;EACtBrD,QAAQ,EAAEmD,qBAAS,CAACG,IAAI;EACxB/C,QAAQ,EAAE4C,qBAAS,CAACE;AACtB,CAAC;AAAA,IAAAE,QAAA,GAAAjG,OAAA,cA8PYD,KAAK","ignoreList":[]}
|
package/lib/mf/static.js
CHANGED
|
@@ -202,10 +202,14 @@ var Static = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
|
202
202
|
key: "componentDidMount",
|
|
203
203
|
value: function () {
|
|
204
204
|
var _componentDidMount = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
205
|
-
var ml;
|
|
205
|
+
var generation, ml;
|
|
206
206
|
return _regenerator["default"].wrap(function (_context) {
|
|
207
207
|
while (1) switch (_context.prev = _context.next) {
|
|
208
208
|
case 0:
|
|
209
|
+
// See the note in mf/input.jsx: a generation counter, not a boolean, so a
|
|
210
|
+
// StrictMode mount -> unmount -> mount on the same instance still ends up
|
|
211
|
+
// with exactly one field.
|
|
212
|
+
generation = this.mountGeneration = (this.mountGeneration || 0) + 1;
|
|
209
213
|
if (this.isInteractive()) {
|
|
210
214
|
_context.next = 2;
|
|
211
215
|
break;
|
|
@@ -213,14 +217,16 @@ var Static = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
|
213
217
|
_context.next = 1;
|
|
214
218
|
return (0, _mathliveInstance.loadMathLive)();
|
|
215
219
|
case 1:
|
|
216
|
-
this.
|
|
220
|
+
if (generation === this.mountGeneration) {
|
|
221
|
+
this.renderMarkup();
|
|
222
|
+
}
|
|
217
223
|
return _context.abrupt("return");
|
|
218
224
|
case 2:
|
|
219
225
|
_context.next = 3;
|
|
220
226
|
return (0, _mathliveInstance.loadMathLive)();
|
|
221
227
|
case 3:
|
|
222
228
|
ml = _context.sent;
|
|
223
|
-
if (!(!ml || !this.holderRef.current)) {
|
|
229
|
+
if (!(generation !== this.mountGeneration || !ml || !this.holderRef.current || this.mathField)) {
|
|
224
230
|
_context.next = 4;
|
|
225
231
|
break;
|
|
226
232
|
}
|
|
@@ -231,11 +237,16 @@ var Static = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
|
231
237
|
});
|
|
232
238
|
this.mathField.readOnly = true;
|
|
233
239
|
this.mathField.mathVirtualKeyboardPolicy = 'manual';
|
|
240
|
+
// Without this the spacebar does nothing: MathLive's mathModeSpace
|
|
241
|
+
// defaults to an empty string.
|
|
242
|
+
this.mathField.mathModeSpace = _mathliveInstance.MATH_MODE_SPACE;
|
|
234
243
|
this.mathField.value = (0, _latexBridge.toMathLive)(this.props.latex);
|
|
235
244
|
this.mathField.addEventListener('input', this.onPromptInput);
|
|
236
245
|
this.mathField.addEventListener('focusin', this.onPromptFocus);
|
|
237
246
|
this.mathField.addEventListener('keydown', this.onKeyDown);
|
|
238
|
-
|
|
247
|
+
|
|
248
|
+
// Belt and braces: drop anything a previous mount may have left behind.
|
|
249
|
+
this.holderRef.current.replaceChildren(this.mathField);
|
|
239
250
|
this.createLiveRegion();
|
|
240
251
|
case 5:
|
|
241
252
|
case "end":
|
|
@@ -263,6 +274,8 @@ var Static = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
|
263
274
|
}, {
|
|
264
275
|
key: "componentWillUnmount",
|
|
265
276
|
value: function componentWillUnmount() {
|
|
277
|
+
// Invalidate any mount still awaiting the MathLive load.
|
|
278
|
+
this.mountGeneration = (this.mountGeneration || 0) + 1;
|
|
266
279
|
if (this.mathField) {
|
|
267
280
|
this.mathField.removeEventListener('input', this.onPromptInput);
|
|
268
281
|
this.mathField.removeEventListener('focusin', this.onPromptFocus);
|
package/lib/mf/static.js.map
CHANGED
|
@@ -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","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","ml","wrap","_context","prev","isInteractive","loadMathLive","renderMarkup","abrupt","sent","current","MathfieldElement","macros","getMacros","readOnly","mathVirtualKeyboardPolicy","toMathLive","latex","addEventListener","onPromptInput","onPromptFocus","onKeyDown","createLiveRegion","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","removeEventListener","remove","removeLiveRegion","fieldIds","indexOf","latexToMarkup","setState","_this2","out","fromMathLive","getPromptValue","_this3","setPromptValue","get","_this4","map","focus","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 { loadMathLive, getMacros, latexToMarkup } from '../mathlive-instance';\nimport { toMathLive, fromMathLive, fieldIds } from '../latex-bridge';\nimport { placeholderStyles } 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 '& 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 if (!this.isInteractive()) {\n await loadMathLive();\n this.renderMarkup();\n return;\n }\n\n const ml = await loadMathLive();\n\n if (!ml || !this.holderRef.current) {\n return;\n }\n\n this.mathField = new ml.MathfieldElement({ macros: getMacros() });\n this.mathField.readOnly = true;\n this.mathField.mathVirtualKeyboardPolicy = 'manual';\n this.mathField.value = toMathLive(this.props.latex);\n\n this.mathField.addEventListener('input', this.onPromptInput);\n this.mathField.addEventListener('focusin', this.onPromptFocus);\n this.mathField.addEventListener('keydown', this.onKeyDown);\n\n this.holderRef.current.appendChild(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 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 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 focus() {\n this.mathField && this.mathField.focus();\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 //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EAAEoF,qBAAS,CAACG,IAAI;EAC/BvE,QAAQ,EAAEoE,qBAAS,CAACG;AACtB,CAAC;AAAA,IAAAvJ,gBAAA,aAVkBY,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","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","addEventListener","onPromptInput","onPromptFocus","onKeyDown","replaceChildren","createLiveRegion","stop","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","removeEventListener","remove","removeLiveRegion","fieldIds","indexOf","latexToMarkup","setState","_this2","out","fromMathLive","getPromptValue","_this3","setPromptValue","get","_this4","map","focus","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 { loadMathLive, getMacros, latexToMarkup, MATH_MODE_SPACE } from '../mathlive-instance';\nimport { toMathLive, fromMathLive, fieldIds } from '../latex-bridge';\nimport { placeholderStyles } 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 '& 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 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.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 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 focus() {\n this.mathField && this.mathField.focus();\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;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAAoD,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,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UAAC4I,SAAS,EAAEA,SAAU;UAACC,OAAO,EAAEA,OAAQ;UAACC,MAAM,EAAEA,MAAO;UAACC,GAAG,EAAE,IAAI,CAACpE;QAAU,CAAE,CAAC;MAChG;MAEA,oBACEtH,MAAA,YAAAyD,aAAA,CAACd,MAAM;QACL4I,SAAS,EAAEA,SAAU;QACrBC,OAAO,EAAEA,OAAQ;QACjBC,MAAM,EAAEA,MAAO;QACfC,GAAG,EAAE,IAAI,CAACpE;QACV;QAAA;QACAqE,uBAAuB,EAAE;UAAEC,MAAM,EAAElE;QAAO;MAAE,CAC7C,CAAC;IAEN;EAAC;AAAA,EA7UiCH,iBAAK,CAACsE,SAAS;AAAA,IAAAxJ,gBAAA,aAA9BY,MAAM,eACN;EACjBsG,KAAK,EAAEuC,qBAAS,CAACC,MAAM,CAACC,UAAU;EAClCT,SAAS,EAAEO,qBAAS,CAACC,MAAM;EAC3BP,OAAO,EAAEM,qBAAS,CAACG,IAAI;EACvBR,MAAM,EAAEK,qBAAS,CAACG,IAAI;EACtBrG,YAAY,EAAEkG,qBAAS,CAACG,IAAI;EAC5BtG,gBAAgB,EAAEmG,qBAAS,CAACG,IAAI;EAChC5F,eAAe,EAAEyF,qBAAS,CAACG,IAAI;EAC/B5E,QAAQ,EAAEyE,qBAAS,CAACG;AACtB,CAAC;AAAA,IAAA5J,gBAAA,aAVkBY,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.0.9
|
|
6
|
+
"version": "1.0.9",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@emotion/styled": "^11.14.1",
|
|
15
15
|
"@mui/icons-material": "^7.3.4",
|
|
16
16
|
"@mui/material": "^7.3.4",
|
|
17
|
-
"@pie-lib/render-ui": "^6.1.
|
|
17
|
+
"@pie-lib/render-ui": "^6.1.0",
|
|
18
18
|
"debug": "^4.1.1",
|
|
19
19
|
"lodash-es": "^4.17.23",
|
|
20
20
|
"mathlive": "^0.110.0",
|
|
@@ -27,6 +27,5 @@
|
|
|
27
27
|
"react": "^18.2.0",
|
|
28
28
|
"react-dom": "^18.2.0"
|
|
29
29
|
},
|
|
30
|
-
"scripts": {}
|
|
31
|
-
"gitHead": "a7883b3a8ec42e0ea2c8051dd0e9729daf2fac01"
|
|
30
|
+
"scripts": {}
|
|
32
31
|
}
|