@pie-element/ebsr 10.7.3-next.9 → 12.0.1-esmbeta.0
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/CHANGELOG.md +44 -0
- package/configure/CHANGELOG.md +16 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +4186 -0
- package/configure/node_modules/@pie-element/multiple-choice/LICENSE.md +5 -0
- package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
- package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
- package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +3332 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +202 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +248 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +597 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +2297 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +34 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +346 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +28 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +2993 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +2217 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +61 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +1332 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +1015 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js +1218 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js +324 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.js +3287 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/element.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.css +847 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.js +3017 -0
- package/configure/node_modules/@pie-element/multiple-choice/esm/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +427 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +252 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +388 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +108 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +469 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +48 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/controller.js +3472 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +86 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/element.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/index.html +21 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/index.js +2 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/manifest.json +10 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print-demo.js +124 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print.html +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/print.js +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/package.json +53 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.md +898 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js +262 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js +88 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js +181 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js +66 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js.map +1 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/package.json +44 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/__tests__/index.test.jsx +99 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/expander.jsx +61 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/index.jsx +98 -0
- package/configure/node_modules/@pie-lib/correct-answer-toggle/src/styles.js +61 -0
- package/configure/node_modules/@pie-lib/icons/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/icons/CHANGELOG.md +539 -0
- package/configure/node_modules/@pie-lib/icons/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/icons/esm/index.js +1153 -0
- package/configure/node_modules/@pie-lib/icons/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js +89 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js +153 -0
- package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-base.js +206 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-base.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-root.js +130 -0
- package/configure/node_modules/@pie-lib/icons/lib/icon-root.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js +92 -0
- package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/index.js +72 -0
- package/configure/node_modules/@pie-lib/icons/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js +229 -0
- package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js +145 -0
- package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js +183 -0
- package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js +82 -0
- package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js +206 -0
- package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/lib/sized.js +41 -0
- package/configure/node_modules/@pie-lib/icons/lib/sized.js.map +1 -0
- package/configure/node_modules/@pie-lib/icons/package.json +35 -0
- package/configure/node_modules/@pie-lib/icons/src/__tests__/index.test.js +3 -0
- package/configure/node_modules/@pie-lib/icons/src/correct-icon.jsx +64 -0
- package/configure/node_modules/@pie-lib/icons/src/correct-response-icon.jsx +121 -0
- package/configure/node_modules/@pie-lib/icons/src/icon-base.jsx +158 -0
- package/configure/node_modules/@pie-lib/icons/src/icon-root.jsx +76 -0
- package/configure/node_modules/@pie-lib/icons/src/incorrect-icon.jsx +61 -0
- package/configure/node_modules/@pie-lib/icons/src/index.js +19 -0
- package/configure/node_modules/@pie-lib/icons/src/instructions-icon.jsx +189 -0
- package/configure/node_modules/@pie-lib/icons/src/learn-more-icon.jsx +107 -0
- package/configure/node_modules/@pie-lib/icons/src/nothing-submitted-icon.jsx +130 -0
- package/configure/node_modules/@pie-lib/icons/src/partially-correct-icon.jsx +49 -0
- package/configure/node_modules/@pie-lib/icons/src/show-rationale-icon.jsx +152 -0
- package/configure/node_modules/@pie-lib/icons/src/sized.jsx +25 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +775 -0
- package/configure/node_modules/@pie-lib/math-rendering/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/esm/index.js +690 -0
- package/configure/node_modules/@pie-lib/math-rendering/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +38 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js +15 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +296 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +109 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +95 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +438 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/package.json +28 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/mml-to-latex.test.js +14 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/normalization.test.js +50 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/render-math.test.js +155 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/index.js +5 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mml-to-latex.js +2 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/__snapshots__/chtml.test.js.snap +9 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/chtml.test.js +104 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +220 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +387 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +1026 -0
- package/configure/node_modules/@pie-lib/render-ui/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/render-ui/esm/index.js +1616 -0
- package/configure/node_modules/@pie-lib/render-ui/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js +88 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js +9 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +135 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js +344 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +150 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js +27 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +74 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js +136 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +145 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +321 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +151 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js +122 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +181 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/package.json +40 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/html-and-math.test.js.snap +11 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/preview-prompt.test.jsx.snap +37 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/purpose.test.jsx.snap +42 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/readable.test.jsx.snap +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/response-indicators.test.jsx.snap +27 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/color.test.js +12 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-media.test.js +20 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-text.test.js +21 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/html-and-math.test.js +24 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/preview-prompt.test.jsx +56 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/purpose.test.jsx +47 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/readable.test.jsx +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/response-indicators.test.jsx +16 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/ui-layout.test.jsx +34 -0
- package/configure/node_modules/@pie-lib/render-ui/src/__tests__/withUndoReset.test.jsx +254 -0
- package/configure/node_modules/@pie-lib/render-ui/src/append-css-rules.js +51 -0
- package/configure/node_modules/@pie-lib/render-ui/src/assets/enableAudioAutoplayImage.js +1 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/__snapshots__/index.test.jsx.snap +18 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/index.test.jsx +13 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +64 -0
- package/configure/node_modules/@pie-lib/render-ui/src/color.js +121 -0
- package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +99 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-media.js +16 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +18 -0
- package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +21 -0
- package/configure/node_modules/@pie-lib/render-ui/src/index.js +35 -0
- package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +95 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +254 -0
- package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +17 -0
- package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
- package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
- package/configure/node_modules/@pie-lib/render-ui/src/ui-layout.jsx +66 -0
- package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +116 -0
- package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.md +410 -0
- package/configure/node_modules/@pie-lib/test-utils/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/test-utils/esm/index.js +39 -0
- package/configure/node_modules/@pie-lib/test-utils/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/test-utils/lib/index.js +40 -0
- package/configure/node_modules/@pie-lib/test-utils/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/test-utils/package.json +25 -0
- package/configure/node_modules/@pie-lib/test-utils/src/__tests__/index.test.js +45 -0
- package/configure/node_modules/@pie-lib/test-utils/src/index.js +18 -0
- package/configure/node_modules/@pie-lib/translator/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/translator/CHANGELOG.md +282 -0
- package/configure/node_modules/@pie-lib/translator/NEXT.CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-lib/translator/esm/index.js +257 -0
- package/configure/node_modules/@pie-lib/translator/esm/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/en.js +102 -0
- package/configure/node_modules/@pie-lib/translator/lib/en.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/es.js +102 -0
- package/configure/node_modules/@pie-lib/translator/lib/es.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/lib/index.js +69 -0
- package/configure/node_modules/@pie-lib/translator/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/translator/package.json +25 -0
- package/configure/node_modules/@pie-lib/translator/src/en.js +99 -0
- package/configure/node_modules/@pie-lib/translator/src/es.js +99 -0
- package/configure/node_modules/@pie-lib/translator/src/index.js +43 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +16 -0
- package/controller/package.json +3 -3
- package/esm/configure.js +38602 -0
- package/esm/configure.js.map +1 -0
- package/esm/controller.js +3358 -0
- package/esm/controller.js.map +1 -0
- package/esm/element.js +2203 -0
- package/esm/element.js.map +1 -0
- package/esm/package.json +4 -0
- package/esm/print.js +4090 -0
- package/esm/print.js.map +1 -0
- package/module/controller.js +4973 -2252
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +1 -1
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +24 -6
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { BracketTypes, wrapMath, unWrapMath } from '../normalization';
|
|
4
|
+
|
|
5
|
+
const log = debug('@pie-lib:math-rendering:test:normalization');
|
|
6
|
+
|
|
7
|
+
describe('normalization', () => {
|
|
8
|
+
describe('unWrapMath', () => {
|
|
9
|
+
const assertUnWrap = (html, expected, wrapType) => {
|
|
10
|
+
it(`innerHTML: ${html} is unWrapped to: ${expected} with wrapType: ${wrapType}`, () => {
|
|
11
|
+
const out = unWrapMath(html);
|
|
12
|
+
|
|
13
|
+
expect(out).toEqual({
|
|
14
|
+
unwrapped: expected,
|
|
15
|
+
wrapType: wrapType,
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
assertUnWrap('$$<$$', '<', BracketTypes.DOLLAR);
|
|
21
|
+
assertUnWrap('$<$', '<', BracketTypes.DOLLAR);
|
|
22
|
+
assertUnWrap('\\(<\\)', '<', BracketTypes.ROUND_BRACKETS);
|
|
23
|
+
assertUnWrap('\\[<\\]', '<', BracketTypes.ROUND_BRACKETS);
|
|
24
|
+
assertUnWrap('latex', 'latex', BracketTypes.ROUND_BRACKETS);
|
|
25
|
+
assertUnWrap('\\displaystyle foo', 'foo', BracketTypes.ROUND_BRACKETS);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('wrapMath', () => {
|
|
29
|
+
const assertWrap = (latex, expectedHtml, wrapper) => {
|
|
30
|
+
wrapper = wrapper || BracketTypes.ROUND_BRACKETS;
|
|
31
|
+
it(`${latex} is wrapped to: ${expectedHtml}`, () => {
|
|
32
|
+
const out = wrapMath(latex, wrapper);
|
|
33
|
+
|
|
34
|
+
log('out: ', out);
|
|
35
|
+
|
|
36
|
+
expect(out).toEqual(expectedHtml);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
assertWrap('latex', '\\(latex\\)', BracketTypes.ROUND_BRACKETS);
|
|
41
|
+
assertWrap('latex', '\\(latex\\)', BracketTypes.SQUARE_BRACKETS);
|
|
42
|
+
assertWrap('latex', '$latex$', BracketTypes.DOLLAR);
|
|
43
|
+
assertWrap('latex', '$latex$', BracketTypes.DOUBLE_DOLLAR);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Note that when this is converted to html it get's escaped - but that's an issue with the slate html-serializer.
|
|
47
|
+
*/
|
|
48
|
+
assertWrap('<', '\\(<\\)');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import renderMath, { fixMathElement } from '../render-math';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
|
|
6
|
+
jest.mock(
|
|
7
|
+
'mathjax-full/js/mathjax',
|
|
8
|
+
() => ({
|
|
9
|
+
mathjax: {
|
|
10
|
+
document: jest.fn().mockReturnThis(),
|
|
11
|
+
findMath: jest.fn().mockReturnThis(),
|
|
12
|
+
compile: jest.fn().mockReturnThis(),
|
|
13
|
+
getMetrics: jest.fn().mockReturnThis(),
|
|
14
|
+
typeset: jest.fn().mockReturnThis(),
|
|
15
|
+
updateDocument: jest.fn().mockReturnThis(),
|
|
16
|
+
clear: jest.fn().mockReturnThis(),
|
|
17
|
+
handlers: {
|
|
18
|
+
handlesDocument: jest.fn().mockReturnThis(),
|
|
19
|
+
},
|
|
20
|
+
handleRetriesFor: jest.fn().mockImplementation((callback) => callback()),
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
{
|
|
24
|
+
virtual: false,
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
jest.mock('mathjax-full/js/input/mathml', () => {
|
|
29
|
+
const mock = jest.fn().mockReturnThis();
|
|
30
|
+
mock.setMmlFactory = jest.fn();
|
|
31
|
+
return {
|
|
32
|
+
MathML: () => mock,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
jest.mock('mathjax-full/js/input/tex', () => ({
|
|
37
|
+
TeX: jest.fn(),
|
|
38
|
+
}));
|
|
39
|
+
jest.mock('mathjax-full/js/core/MmlTree/MmlFactory', () => {
|
|
40
|
+
const instance = {
|
|
41
|
+
setMmlFactory: jest.fn(),
|
|
42
|
+
defaultNodes: {},
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
MmlFactory: () => instance,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const mockMathInstance = {
|
|
50
|
+
document: jest.fn().mockReturnThis(),
|
|
51
|
+
findMath: jest.fn().mockReturnThis(),
|
|
52
|
+
compile: jest.fn().mockReturnThis(),
|
|
53
|
+
enrich: jest.fn().mockReturnThis(),
|
|
54
|
+
addMenu: jest.fn().mockReturnThis(),
|
|
55
|
+
attachSpeech: jest.fn().mockReturnThis(),
|
|
56
|
+
assistiveMml: jest.fn().mockReturnThis(),
|
|
57
|
+
getMetrics: jest.fn().mockReturnThis(),
|
|
58
|
+
typeset: jest.fn().mockReturnThis(),
|
|
59
|
+
updateDocument: jest.fn().mockReturnValue({
|
|
60
|
+
math: {
|
|
61
|
+
list: undefined,
|
|
62
|
+
},
|
|
63
|
+
clear: jest.fn().mockReturnThis(),
|
|
64
|
+
}),
|
|
65
|
+
clear: jest.fn().mockReturnThis(),
|
|
66
|
+
handlers: {
|
|
67
|
+
handlesDocument: jest.fn().mockReturnThis(),
|
|
68
|
+
},
|
|
69
|
+
handleRetriesFor: jest.fn().mockImplementation((callback) => callback()),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const mockHtml = {
|
|
73
|
+
findMath: jest.fn().mockReturnValue(mockMathInstance),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const mockEnrichHandlerInstance = {
|
|
77
|
+
create: jest.fn().mockImplementation(() => mockHtml),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
jest.mock('mathjax-full/js/a11y/semantic-enrich', () => {
|
|
81
|
+
return {
|
|
82
|
+
EnrichHandler: () => mockEnrichHandlerInstance,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
jest.mock('mathjax-full/js/a11y/assistive-mml', () => {
|
|
87
|
+
return {
|
|
88
|
+
AssistiveMmlHandler: () => {},
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
jest.mock('mathjax-full/js/ui/menu/MenuHandler', () => {
|
|
93
|
+
return {
|
|
94
|
+
MenuHandler: () => {},
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
jest.mock('mathjax-full/js/output/chtml', () => ({
|
|
99
|
+
CHTML: jest.fn(),
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
jest.mock('mathjax-full/js/adaptors/browserAdaptor', () => ({
|
|
103
|
+
browserAdaptor: jest.fn(),
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
jest.mock('mathjax-full/js/handlers/html', () => ({
|
|
107
|
+
RegisterHTMLHandler: jest.fn(),
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
jest.mock('mathjax-full/js/core/MmlTree/SerializedMmlVisitor', () => ({
|
|
111
|
+
SerializedMmlVisitor: jest.fn(),
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
describe('render-math', () => {
|
|
115
|
+
it('calls classFactory.create once', () => {
|
|
116
|
+
const div = document.createElement('div');
|
|
117
|
+
|
|
118
|
+
_.times(10).forEach((i) => renderMath(div));
|
|
119
|
+
|
|
120
|
+
expect(mockEnrichHandlerInstance.create).toHaveBeenCalledTimes(1);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('calls MathJax render', () => {
|
|
124
|
+
const div = document.createElement('div');
|
|
125
|
+
|
|
126
|
+
renderMath(div);
|
|
127
|
+
expect(mockEnrichHandlerInstance.create).toHaveBeenCalledTimes(1);
|
|
128
|
+
expect(mockHtml.findMath).toHaveBeenCalledWith({ elements: [div] });
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('call render math for an array of elements', () => {
|
|
132
|
+
const divOne = document.createElement('div');
|
|
133
|
+
const divTwo = document.createElement('div');
|
|
134
|
+
|
|
135
|
+
renderMath([divOne, divTwo]);
|
|
136
|
+
|
|
137
|
+
expect(mockEnrichHandlerInstance.create).toHaveBeenCalledTimes(1);
|
|
138
|
+
expect(mockHtml.findMath).toHaveBeenCalledWith({
|
|
139
|
+
elements: [divOne, divTwo],
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('wraps the math containing element the right way', () => {
|
|
144
|
+
const wrapper = mount(
|
|
145
|
+
<div>
|
|
146
|
+
<span data-latex="">{'420\\text{ cm}=4.2\\text{ meters}'}</span>
|
|
147
|
+
</div>,
|
|
148
|
+
);
|
|
149
|
+
const spanElem = wrapper.instance();
|
|
150
|
+
|
|
151
|
+
fixMathElement(spanElem);
|
|
152
|
+
|
|
153
|
+
expect(spanElem.textContent).toEqual('\\(420\\text{ cm}=4.2\\text{ meters}\\)');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`chtml implicit one row 1`] = `"<table><tr><td></td><td>1</td></tr></table>"`;
|
|
4
|
+
|
|
5
|
+
exports[`chtml one row 1`] = `"<table><tr><td></td><td>1</td></tr></table>"`;
|
|
6
|
+
|
|
7
|
+
exports[`chtml two rows 1`] = `"<table><tr><td></td><td>1</td></tr><tr><td></td><td>2</td></tr></table>"`;
|
|
8
|
+
|
|
9
|
+
exports[`chtml two rows with operator 1`] = `"<table><tr><td></td><td>1</td></tr><tr><td class=\\"inner\\">mo:+</td><td>2</td></tr></table>"`;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { getStackData, Line, Row, CHTMLmstack } from '../chtml';
|
|
2
|
+
// import { CHTMLWrapper, instance } from 'mathjax-full/js/output/chtml/Wrapper';
|
|
3
|
+
import { JSDOM } from 'jsdom';
|
|
4
|
+
|
|
5
|
+
jest.mock('mathjax-full/js/output/chtml/Wrapper', () => {
|
|
6
|
+
const instance = {
|
|
7
|
+
adaptor: {
|
|
8
|
+
document: {
|
|
9
|
+
createElement: jest.fn(),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
standardCHTMLnode: jest.fn(),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
instance,
|
|
17
|
+
CHTMLWrapper: class {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.adaptor = { document: { createElement: jest.fn() } };
|
|
20
|
+
this.document = {};
|
|
21
|
+
// return instance;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const node = (kind, extras) => ({ kind, childNodes: [], ...extras });
|
|
28
|
+
|
|
29
|
+
const textNode = (text) => node('text', { text, node: { kind: 'text', text } });
|
|
30
|
+
const mn = (text) => node('mn', { childNodes: [textNode(text)] });
|
|
31
|
+
const mo = (text) =>
|
|
32
|
+
node('mo', {
|
|
33
|
+
childNodes: [textNode(text)],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const mco = (text) => ({
|
|
37
|
+
...mo(text),
|
|
38
|
+
|
|
39
|
+
toCHTML: (n) => {
|
|
40
|
+
const t = `mo:${text}`;
|
|
41
|
+
n.textContent = t;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const msrow = (...childNodes) => node('msrow', { childNodes });
|
|
46
|
+
const mstack = (...rows) => node('mstack', { childNodes: rows });
|
|
47
|
+
const msline = () => node('msline');
|
|
48
|
+
describe('getStackData', () => {
|
|
49
|
+
it.each`
|
|
50
|
+
input | expected
|
|
51
|
+
${mstack(msrow(mo('+'), mn('111')))} | ${[new Row(['1', '1', '1'], mo('+'))]}
|
|
52
|
+
${mstack(msrow(mn('111')))} | ${[new Row(['1', '1', '1'])]}
|
|
53
|
+
${mstack(msrow(mn('1'), mn('1')))} | ${[new Row(['1', '1'])]}
|
|
54
|
+
${mstack(msrow(mn('1')), mn('1'))} | ${[new Row(['1']), new Row(['1'])]}
|
|
55
|
+
${mstack(msline())} | ${[new Line()]}
|
|
56
|
+
${mstack(mn('1'), msline(), msrow(mo('+'), mn('1')))} | ${[new Row(['1']), new Line(), new Row(['1'], mo('+'))]}
|
|
57
|
+
${mstack(mn('1'), mn('1'))} | ${[new Row(['1']), new Row(['1'])]}
|
|
58
|
+
`('$input => $expected', ({ input, expected }) => {
|
|
59
|
+
const d = getStackData(input);
|
|
60
|
+
// console.log('d:', d);
|
|
61
|
+
// console.log('e:', expected);
|
|
62
|
+
expect({ ...d }).toEqual({ ...expected });
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('Row', () => {
|
|
67
|
+
describe('pad', () => {
|
|
68
|
+
it.each`
|
|
69
|
+
cols | count | expected
|
|
70
|
+
${[]} | ${0} | ${[]}
|
|
71
|
+
${[1]} | ${1} | ${[1]}
|
|
72
|
+
${[1]} | ${2} | ${['__pad__', 1]}
|
|
73
|
+
${[1]} | ${3} | ${['__pad__', '__pad__', 1]}
|
|
74
|
+
`('pads to the right', ({ cols, count, expected }) => {
|
|
75
|
+
const r = new Row(cols);
|
|
76
|
+
const p = r.pad(count, 'right');
|
|
77
|
+
expect(p).toEqual(expected);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe.each`
|
|
83
|
+
label | tree
|
|
84
|
+
${'one row'} | ${[msrow(mn('1'))]}
|
|
85
|
+
${'implicit one row'} | ${[mn('1')]}
|
|
86
|
+
${'two rows'} | ${[msrow(mn('1')), msrow(mn('2'))]}
|
|
87
|
+
${'two rows with operator'} | ${[msrow(mn('1')), msrow(mco('+'), mn('2'))]}
|
|
88
|
+
`('chtml', ({ label, tree }) => {
|
|
89
|
+
let html;
|
|
90
|
+
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
const chtml = new CHTMLmstack({}, {});
|
|
93
|
+
const dom = new JSDOM(`<!DOCTYPE html><body></body>`);
|
|
94
|
+
chtml.standardCHTMLnode = (parent) => parent;
|
|
95
|
+
chtml.ce = dom.window.document.createElement.bind(dom.window.document);
|
|
96
|
+
chtml.childNodes = tree;
|
|
97
|
+
chtml.toCHTML(dom.window.document.body);
|
|
98
|
+
html = dom.window.document.body.innerHTML;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it(label, () => {
|
|
102
|
+
expect(html).toMatchSnapshot();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { CHTMLWrapper } from 'mathjax-full/js/output/chtml/Wrapper';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
|
|
4
|
+
const reduceText = (acc, n) => {
|
|
5
|
+
if (n.node && n.node.kind === 'text') {
|
|
6
|
+
acc += n.node.text;
|
|
7
|
+
}
|
|
8
|
+
return acc;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class Line {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.kind = 'line';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get columns() {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class Row {
|
|
22
|
+
constructor(columns, operator) {
|
|
23
|
+
this.kind = 'row';
|
|
24
|
+
this.operator = operator;
|
|
25
|
+
this.columns = columns;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
pad(count, direction = 'right') {
|
|
29
|
+
if (count < this.columns.length) {
|
|
30
|
+
throw new Error('no');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const diff = count - this.columns.length;
|
|
34
|
+
|
|
35
|
+
const padding = _.times(diff).map(() => '__pad__');
|
|
36
|
+
return direction === 'right' ? [...padding, ...this.columns] : [...this.columns, ...padding];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const mathNodeToCharArray = (mn) => {
|
|
41
|
+
const text = mn.childNodes.reduce(reduceText, '');
|
|
42
|
+
return text.split('');
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Convert child a column entry
|
|
47
|
+
* @param {*} child
|
|
48
|
+
* @return an array of column content
|
|
49
|
+
*/
|
|
50
|
+
const toColumnArray = (child) => {
|
|
51
|
+
if (!child || !child.kind) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (child.kind === 'msrow') {
|
|
56
|
+
throw new Error('msrow in msrow?');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (child.kind === 'mo') {
|
|
60
|
+
// We are going to treat this operator as a text array.
|
|
61
|
+
// It's probably going to be a decimal point
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.warn('mo that is not 1st node in msrow?');
|
|
64
|
+
return mathNodeToCharArray(child);
|
|
65
|
+
// throw new Error('mo must be first child of msrow');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (child.kind === 'mn') {
|
|
69
|
+
return mathNodeToCharArray(child);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (child.toCHTML) {
|
|
73
|
+
return child;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* convert mstack chtml childNodes into a Row
|
|
79
|
+
* @param child chtml child node of mstack
|
|
80
|
+
* @return Row | Line
|
|
81
|
+
*/
|
|
82
|
+
const rowStack = (child) => {
|
|
83
|
+
if (!child || !child.kind) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (child.kind === 'msrow') {
|
|
88
|
+
if (!child.childNodes || child.childNodes.length === 0) {
|
|
89
|
+
return new Row([]);
|
|
90
|
+
}
|
|
91
|
+
const f = _.first(child.childNodes);
|
|
92
|
+
const nodes = f && f.kind === 'mo' ? _.tail(child.childNodes) : child.childNodes;
|
|
93
|
+
|
|
94
|
+
const columns = _.flatten(nodes.map(toColumnArray));
|
|
95
|
+
|
|
96
|
+
return new Row(columns, f.kind === 'mo' ? f : undefined);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (child.kind === 'mn') {
|
|
100
|
+
const columns = mathNodeToCharArray(child);
|
|
101
|
+
return new Row(columns, undefined);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (child.kind === 'mo') {
|
|
105
|
+
// eslint-disable-next-line no-console
|
|
106
|
+
console.warn('mo on its own row?');
|
|
107
|
+
return new Row([], child);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (child.kind === 'msline') {
|
|
111
|
+
return new Line();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (child.toCHTML) {
|
|
115
|
+
return new Row([child]);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** convert MathJax chtml tree to Row[]
|
|
120
|
+
* @param mstack the root of the mathjax chtml tree
|
|
121
|
+
* @return Row[]
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
export const getStackData = (mstack) => {
|
|
125
|
+
if (!mstack || !mstack.childNodes) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
return _.compact(mstack.childNodes.map(rowStack));
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export class CHTMLmstack extends CHTMLWrapper {
|
|
132
|
+
constructor(factory, node, parent = null) {
|
|
133
|
+
super(factory, node, parent);
|
|
134
|
+
|
|
135
|
+
this.ce = this.adaptor.document.createElement.bind(this.adaptor.document);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
toCHTML(parent) {
|
|
139
|
+
const chtml = this.standardCHTMLnode(parent);
|
|
140
|
+
|
|
141
|
+
const stackData = getStackData(this);
|
|
142
|
+
|
|
143
|
+
// console.log('stackData', stackData);
|
|
144
|
+
const maxCols = stackData.reduce((acc, r) => {
|
|
145
|
+
if (r && r.columns.length > acc) {
|
|
146
|
+
acc = r.columns.length;
|
|
147
|
+
}
|
|
148
|
+
return acc;
|
|
149
|
+
}, 0);
|
|
150
|
+
|
|
151
|
+
const table = this.ce('table');
|
|
152
|
+
chtml.appendChild(table);
|
|
153
|
+
|
|
154
|
+
stackData.forEach((row) => {
|
|
155
|
+
const tr = this.ce('tr');
|
|
156
|
+
table.appendChild(tr);
|
|
157
|
+
|
|
158
|
+
if (row.kind === 'row') {
|
|
159
|
+
const td = this.ce('td');
|
|
160
|
+
tr.appendChild(td);
|
|
161
|
+
if (row.operator && row.operator.toCHTML) {
|
|
162
|
+
td.setAttribute('class', 'inner');
|
|
163
|
+
row.operator.toCHTML(td);
|
|
164
|
+
} else {
|
|
165
|
+
td.textContent = '';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// align right for now:
|
|
169
|
+
const cols = row.pad(maxCols, 'right');
|
|
170
|
+
cols.forEach((c) => {
|
|
171
|
+
const t = this.ce('td');
|
|
172
|
+
tr.appendChild(t);
|
|
173
|
+
if (c === '__pad__') {
|
|
174
|
+
t.textContent = '';
|
|
175
|
+
} else if (typeof c === 'string') {
|
|
176
|
+
t.textContent = c;
|
|
177
|
+
} else if (c.kind === 'none') {
|
|
178
|
+
t.textContent = '';
|
|
179
|
+
} else if (c.toCHTML) {
|
|
180
|
+
t.setAttribute('class', 'inner');
|
|
181
|
+
c.toCHTML(t);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
} else if (row.kind === 'line') {
|
|
185
|
+
const td = this.ce('td');
|
|
186
|
+
tr.appendChild(td);
|
|
187
|
+
td.setAttribute('colspan', maxCols + 1);
|
|
188
|
+
td.setAttribute('class', 'mjx-line');
|
|
189
|
+
td.textContent = '';
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
CHTMLmstack.styles = {
|
|
195
|
+
'mjx-mstack > table': {
|
|
196
|
+
'line-height': 'initial',
|
|
197
|
+
border: 'solid 0px red',
|
|
198
|
+
'border-spacing': '0em',
|
|
199
|
+
'border-collapse': 'separate',
|
|
200
|
+
},
|
|
201
|
+
'mjx-mstack > table > tr': {
|
|
202
|
+
'line-height': 'initial',
|
|
203
|
+
},
|
|
204
|
+
'mjx-mstack > table > tr > td': {
|
|
205
|
+
// padding: '1.2rem',
|
|
206
|
+
border: 'solid 0px blue',
|
|
207
|
+
'font-family': 'sans-serif',
|
|
208
|
+
'line-height': 'initial',
|
|
209
|
+
},
|
|
210
|
+
'mjx-mstack > table > tr > td.inner': {
|
|
211
|
+
'font-family': 'inherit',
|
|
212
|
+
},
|
|
213
|
+
'mjx-mstack > table > tr > .mjx-line': {
|
|
214
|
+
padding: 0,
|
|
215
|
+
'border-top': 'solid 1px black',
|
|
216
|
+
},
|
|
217
|
+
'.TEX-A': {
|
|
218
|
+
'font-family': 'MJXZERO, MJXTEX !important',
|
|
219
|
+
},
|
|
220
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CHTMLmstack } from './chtml';
|
|
2
|
+
import { MmlNone, MmlMsline, MmlMstack, MmlMsrow } from './mml';
|
|
3
|
+
|
|
4
|
+
export const chtmlNodes = {
|
|
5
|
+
mstack: CHTMLmstack,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const mmlNodes = {
|
|
9
|
+
mstack: MmlMstack,
|
|
10
|
+
msline: MmlMsline,
|
|
11
|
+
msrow: MmlMsrow,
|
|
12
|
+
none: MmlNone,
|
|
13
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbstractMmlNode } from 'mathjax-full/js/core/MmlTree/MmlNode';
|
|
2
|
+
|
|
3
|
+
export class MmlNone extends AbstractMmlNode {
|
|
4
|
+
get kind() {
|
|
5
|
+
return 'none';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class MmlMstack extends AbstractMmlNode {
|
|
10
|
+
get kind() {
|
|
11
|
+
return 'mstack';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class MmlMsrow extends AbstractMmlNode {
|
|
16
|
+
get kind() {
|
|
17
|
+
return 'msrow';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class MmlMsline extends AbstractMmlNode {
|
|
21
|
+
get kind() {
|
|
22
|
+
return 'msline';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const BracketTypes = {};
|
|
2
|
+
|
|
3
|
+
BracketTypes.ROUND_BRACKETS = 'round_brackets';
|
|
4
|
+
BracketTypes.SQUARE_BRACKETS = 'square_brackets';
|
|
5
|
+
BracketTypes.DOLLAR = 'dollar';
|
|
6
|
+
BracketTypes.DOUBLE_DOLLAR = 'double_dollar';
|
|
7
|
+
|
|
8
|
+
const PAIRS = {
|
|
9
|
+
[BracketTypes.ROUND_BRACKETS]: ['\\(', '\\)'],
|
|
10
|
+
[BracketTypes.SQUARE_BRACKETS]: ['\\[', '\\]'],
|
|
11
|
+
[BracketTypes.DOLLAR]: ['$', '$'],
|
|
12
|
+
[BracketTypes.DOUBLE_DOLLAR]: ['$$', '$$'],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const wrapMath = (content, wrapType) => {
|
|
16
|
+
if (wrapType === BracketTypes.SQUARE_BRACKETS) {
|
|
17
|
+
console.warn('\\[...\\] is not supported yet'); // eslint-disable-line
|
|
18
|
+
wrapType = BracketTypes.ROUND_BRACKETS;
|
|
19
|
+
}
|
|
20
|
+
if (wrapType === BracketTypes.DOUBLE_DOLLAR) {
|
|
21
|
+
console.warn('$$...$$ is not supported yet'); // eslint-disable-line
|
|
22
|
+
wrapType = BracketTypes.DOLLAR;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const [start, end] = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS];
|
|
26
|
+
return `${start}${content}${end}`;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const unWrapMath = (content) => {
|
|
30
|
+
const displayStyleIndex = content.indexOf('\\displaystyle');
|
|
31
|
+
if (displayStyleIndex !== -1) {
|
|
32
|
+
console.warn('\\displaystyle is not supported - removing'); // eslint-disable-line
|
|
33
|
+
content = content.replace('\\displaystyle', '').trim();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (content.startsWith('$$') && content.endsWith('$$')) {
|
|
37
|
+
console.warn('$$ syntax is not yet supported'); // eslint-disable-line
|
|
38
|
+
return {
|
|
39
|
+
unwrapped: content.substring(2, content.length - 2),
|
|
40
|
+
wrapType: BracketTypes.DOLLAR,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (content.startsWith('$') && content.endsWith('$')) {
|
|
44
|
+
return {
|
|
45
|
+
unwrapped: content.substring(1, content.length - 1),
|
|
46
|
+
wrapType: BracketTypes.DOLLAR,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (content.startsWith('\\[') && content.endsWith('\\]')) {
|
|
51
|
+
console.warn('\\[..\\] syntax is not yet supported'); // eslint-disable-line
|
|
52
|
+
return {
|
|
53
|
+
unwrapped: content.substring(2, content.length - 2),
|
|
54
|
+
wrapType: BracketTypes.ROUND_BRACKETS,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (content.startsWith('\\(') && content.endsWith('\\)')) {
|
|
59
|
+
return {
|
|
60
|
+
unwrapped: content.substring(2, content.length - 2),
|
|
61
|
+
wrapType: BracketTypes.ROUND_BRACKETS,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
unwrapped: content,
|
|
67
|
+
wrapType: BracketTypes.ROUND_BRACKETS,
|
|
68
|
+
};
|
|
69
|
+
};
|