@pie-element/ebsr 6.6.3-next.1097 → 6.6.3-next.1137
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/configure/node_modules/@pie-lib/config-ui/CHANGELOG.json +1677 -0
- package/configure/node_modules/@pie-lib/config-ui/CHANGELOG.md +1743 -0
- package/configure/node_modules/@pie-lib/config-ui/LICENSE.md +5 -0
- package/configure/node_modules/@pie-lib/config-ui/README.md +12 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/alert-dialog.js +44 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/alert-dialog.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/checkbox.js +86 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/checkbox.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/choice-configuration/feedback-menu.js +164 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/choice-configuration/feedback-menu.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/choice-configuration/index.js +398 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/choice-configuration/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/choice-utils.js +54 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/choice-utils.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/feedback-config/feedback-selector.js +185 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/feedback-config/feedback-selector.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/feedback-config/group.js +75 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/feedback-config/group.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/feedback-config/index.js +178 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/feedback-config/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/form-section.js +46 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/form-section.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/help.js +145 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/help.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/index.js +216 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/input.js +139 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/input.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/inputs.js +131 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/inputs.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/langs.js +179 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/langs.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/config-layout.js +101 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/config-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/index.js +24 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/layout-contents.js +105 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/layout-contents.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/settings-box.js +87 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/layout/settings-box.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/mui-box/index.js +79 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/mui-box/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/number-text-field-custom.js +364 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/number-text-field-custom.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/number-text-field.js +265 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/number-text-field.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/radio-with-label.js +41 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/radio-with-label.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/display-size.js +77 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/display-size.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/index.js +130 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/panel.js +412 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/panel.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/settings-radio-label.js +43 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/settings-radio-label.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/toggle.js +56 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/settings/toggle.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/tabs/index.js +106 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/tabs/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/tags-input/index.js +198 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/tags-input/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/two-choice.js +180 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/two-choice.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/with-stateful-model.js +84 -0
- package/configure/node_modules/@pie-lib/config-ui/lib/with-stateful-model.js.map +1 -0
- package/configure/node_modules/@pie-lib/config-ui/package.json +30 -0
- package/configure/node_modules/@pie-lib/config-ui/src/alert-dialog.jsx +43 -0
- package/configure/node_modules/@pie-lib/config-ui/src/checkbox.jsx +63 -0
- package/configure/node_modules/@pie-lib/config-ui/src/choice-configuration/feedback-menu.jsx +103 -0
- package/configure/node_modules/@pie-lib/config-ui/src/choice-configuration/index.jsx +319 -0
- package/configure/node_modules/@pie-lib/config-ui/src/choice-utils.js +30 -0
- package/configure/node_modules/@pie-lib/config-ui/src/feedback-config/feedback-selector.jsx +116 -0
- package/configure/node_modules/@pie-lib/config-ui/src/feedback-config/group.jsx +54 -0
- package/configure/node_modules/@pie-lib/config-ui/src/feedback-config/index.jsx +98 -0
- package/configure/node_modules/@pie-lib/config-ui/src/form-section.jsx +23 -0
- package/configure/node_modules/@pie-lib/config-ui/src/help.jsx +88 -0
- package/configure/node_modules/@pie-lib/config-ui/src/index.js +58 -0
- package/configure/node_modules/@pie-lib/config-ui/src/input.jsx +72 -0
- package/configure/node_modules/@pie-lib/config-ui/src/inputs.jsx +96 -0
- package/configure/node_modules/@pie-lib/config-ui/src/langs.jsx +122 -0
- package/configure/node_modules/@pie-lib/config-ui/src/layout/config-layout.jsx +64 -0
- package/configure/node_modules/@pie-lib/config-ui/src/layout/index.js +4 -0
- package/configure/node_modules/@pie-lib/config-ui/src/layout/layout-contents.jsx +60 -0
- package/configure/node_modules/@pie-lib/config-ui/src/layout/settings-box.jsx +31 -0
- package/configure/node_modules/@pie-lib/config-ui/src/mui-box/index.jsx +64 -0
- package/configure/node_modules/@pie-lib/config-ui/src/number-text-field-custom.jsx +276 -0
- package/configure/node_modules/@pie-lib/config-ui/src/number-text-field.jsx +196 -0
- package/configure/node_modules/@pie-lib/config-ui/src/radio-with-label.jsx +18 -0
- package/configure/node_modules/@pie-lib/config-ui/src/settings/display-size.jsx +52 -0
- package/configure/node_modules/@pie-lib/config-ui/src/settings/index.js +75 -0
- package/configure/node_modules/@pie-lib/config-ui/src/settings/panel.jsx +297 -0
- package/configure/node_modules/@pie-lib/config-ui/src/settings/settings-radio-label.jsx +20 -0
- package/configure/node_modules/@pie-lib/config-ui/src/settings/toggle.jsx +31 -0
- package/configure/node_modules/@pie-lib/config-ui/src/tabs/index.jsx +51 -0
- package/configure/node_modules/@pie-lib/config-ui/src/tags-input/index.jsx +121 -0
- package/configure/node_modules/@pie-lib/config-ui/src/two-choice.jsx +94 -0
- package/configure/node_modules/@pie-lib/config-ui/src/with-stateful-model.jsx +36 -0
- package/configure/node_modules/@pie-lib/editable-html/CHANGELOG.json +3327 -0
- package/configure/node_modules/@pie-lib/editable-html/CHANGELOG.md +1759 -0
- package/configure/node_modules/@pie-lib/editable-html/LICENSE.md +5 -0
- package/configure/node_modules/@pie-lib/editable-html/README.md +45 -0
- package/configure/node_modules/@pie-lib/editable-html/deploy.sh +16 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/editor.js +893 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/editor.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/index.js +226 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/parse-html.js +16 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/parse-html.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/characters/custom-popover.js +70 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/characters/custom-popover.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/characters/index.js +266 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/characters/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/characters/utils.js +382 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/characters/utils.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/alt-dialog.js +119 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/alt-dialog.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/component.js +424 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/component.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/image-toolbar.js +175 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/image-toolbar.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/index.js +261 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/insert-image-handler.js +135 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/image/insert-image-handler.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/index.js +141 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/list/index.js +204 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/list/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/math/index.js +347 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/math/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/index.js +339 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/media-dialog.js +434 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/media-dialog.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/media-toolbar.js +99 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/media-toolbar.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/media-wrapper.js +93 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/media/media-wrapper.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/drag-in-the-blank/choice.js +251 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/drag-in-the-blank/index.js +97 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/explicit-constructed-response/index.js +54 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/icons/index.js +93 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/icons/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/index.js +293 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/inline-dropdown/index.js +70 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/inline-dropdown/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/utils.js +110 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/respArea/utils.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/table/icons/index.js +69 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/table/icons/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/table/index.js +499 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/table/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/table/table-toolbar.js +158 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/table/table-toolbar.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/default-toolbar.js +132 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/default-toolbar.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/done-button.js +50 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/done-button.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/editor-and-toolbar.js +263 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/index.js +32 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/toolbar-buttons.js +161 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/toolbar-buttons.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/toolbar.js +346 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/toolbar/toolbar.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/utils.js +62 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/plugins/utils.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/serialization.js +428 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/serialization.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/theme.js +9 -0
- package/configure/node_modules/@pie-lib/editable-html/lib/theme.js.map +1 -0
- package/configure/node_modules/@pie-lib/editable-html/package.json +52 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/image/data.js +59 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/image/index.html +24 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/image/index.jsx +83 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/index.html +27 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/mathquill/index.html +25 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/mathquill/index.jsx +151 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/package.json +15 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/prod-test/index.html +26 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/prod-test/index.jsx +30 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/schema-override/data.js +29 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/schema-override/image-plugin.jsx +40 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/schema-override/index.html +23 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/schema-override/index.jsx +96 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/serialization/data.js +29 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/serialization/image-plugin.jsx +40 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/serialization/index.html +24 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/serialization/index.jsx +12 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/static.json +3 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/table-examples.html +67 -0
- package/configure/node_modules/@pie-lib/editable-html/playground/webpack.config.js +42 -0
- package/configure/node_modules/@pie-lib/editable-html/src/editor.jsx +749 -0
- package/configure/node_modules/@pie-lib/editable-html/src/index.jsx +145 -0
- package/configure/node_modules/@pie-lib/editable-html/src/parse-html.js +8 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/README.md +27 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/characters/custom-popover.js +45 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/characters/index.jsx +244 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/characters/utils.js +448 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/image/alt-dialog.jsx +69 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/image/component.jsx +349 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/image/image-toolbar.jsx +108 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/image/index.jsx +218 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/image/insert-image-handler.js +93 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/index.jsx +115 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/list/index.jsx +175 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/math/index.jsx +283 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/media/index.jsx +284 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/media/media-dialog.js +372 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/media/media-toolbar.jsx +53 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/media/media-wrapper.jsx +43 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/respArea/drag-in-the-blank/choice.jsx +187 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/respArea/drag-in-the-blank/index.jsx +78 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/respArea/explicit-constructed-response/index.jsx +45 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/respArea/icons/index.jsx +68 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/respArea/index.jsx +263 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/respArea/inline-dropdown/index.jsx +63 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/respArea/utils.jsx +77 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/table/icons/index.jsx +59 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/table/index.jsx +439 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/table/table-toolbar.jsx +104 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/toolbar/default-toolbar.jsx +111 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/toolbar/done-button.jsx +36 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/toolbar/editor-and-toolbar.jsx +225 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/toolbar/index.jsx +21 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/toolbar/toolbar-buttons.jsx +97 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/toolbar/toolbar.jsx +323 -0
- package/configure/node_modules/@pie-lib/editable-html/src/plugins/utils.js +32 -0
- package/configure/node_modules/@pie-lib/editable-html/src/serialization.jsx +385 -0
- package/configure/node_modules/@pie-lib/editable-html/src/theme.js +1 -0
- package/configure/node_modules/@pie-lib/editable-html/static.json +1 -0
- package/configure/package.json +1 -1
- package/package.json +3 -3
package/configure/node_modules/@pie-lib/editable-html/src/plugins/image/insert-image-handler.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Data } from 'slate';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
|
|
4
|
+
const log = debug('@pie-lib:editable-html:image:insert-image-handler');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Handles user selection, insertion (or cancellation) of an image into the editor.
|
|
8
|
+
* @param {Block} placeholderBlock - a block that has been added to the editor as a place holder for the image
|
|
9
|
+
* @param {Function} getValue - a function to return the value of the editor
|
|
10
|
+
* @param {Function} onChange - callback to notify changes applied by the handler
|
|
11
|
+
*/
|
|
12
|
+
class InsertImageHandler {
|
|
13
|
+
constructor(placeholderBlock, getValue, onChange) {
|
|
14
|
+
this.placeholderBlock = placeholderBlock;
|
|
15
|
+
this.getValue = getValue;
|
|
16
|
+
this.onChange = onChange;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getPlaceholderInDocument(value) {
|
|
20
|
+
const { document } = value;
|
|
21
|
+
const directChild = document.getChild(this.placeholderBlock.key);
|
|
22
|
+
|
|
23
|
+
if (directChild) {
|
|
24
|
+
return directChild;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const child = document.getDescendant(this.placeholderBlock.key);
|
|
28
|
+
|
|
29
|
+
if (child) {
|
|
30
|
+
return child;
|
|
31
|
+
} else {
|
|
32
|
+
//eslint-disable-next-line
|
|
33
|
+
throw new Error("insert-image: Can't find placeholder!");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
cancel() {
|
|
38
|
+
log('insert cancelled');
|
|
39
|
+
const c = this.getValue()
|
|
40
|
+
.change()
|
|
41
|
+
.removeNodeByKey(this.placeholderBlock.key);
|
|
42
|
+
this.onChange(c);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
done(err, src) {
|
|
46
|
+
log('done: err:', err);
|
|
47
|
+
if (err) {
|
|
48
|
+
//eslint-disable-next-line
|
|
49
|
+
console.log(err);
|
|
50
|
+
} else {
|
|
51
|
+
const value = this.getValue();
|
|
52
|
+
const child = this.getPlaceholderInDocument(value);
|
|
53
|
+
const data = child.data.merge(Data.create({ loaded: true, src, percent: 100 }));
|
|
54
|
+
|
|
55
|
+
const change = value.change().setNodeByKey(this.placeholderBlock.key, { data });
|
|
56
|
+
this.onChange(change);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Notify handler that the user chose a file - will create a change with a preview in the editor.
|
|
62
|
+
*
|
|
63
|
+
* @param {File} file - the file that the user chose using a file input.
|
|
64
|
+
*/
|
|
65
|
+
fileChosen(file) {
|
|
66
|
+
if (!file) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
log('[fileChosen] file: ', file);
|
|
71
|
+
const reader = new FileReader();
|
|
72
|
+
reader.onload = () => {
|
|
73
|
+
const value = this.getValue();
|
|
74
|
+
const dataURL = reader.result;
|
|
75
|
+
const child = this.getPlaceholderInDocument(value);
|
|
76
|
+
const data = child.data.set('src', dataURL);
|
|
77
|
+
const change = value.change().setNodeByKey(this.placeholderBlock.key, { data });
|
|
78
|
+
this.onChange(change);
|
|
79
|
+
};
|
|
80
|
+
reader.readAsDataURL(file);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
progress(percent, bytes, total) {
|
|
84
|
+
log('progress: ', percent, bytes, total);
|
|
85
|
+
const value = this.getValue();
|
|
86
|
+
const child = this.getPlaceholderInDocument(value);
|
|
87
|
+
const data = child.data.set('percent', percent);
|
|
88
|
+
const change = value.change().setNodeByKey(this.placeholderBlock.key, { data });
|
|
89
|
+
this.onChange(change);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default InsertImageHandler;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import Bold from '@material-ui/icons/FormatBold';
|
|
2
|
+
// import Code from '@material-ui/icons/Code';
|
|
3
|
+
import BulletedListIcon from '@material-ui/icons/FormatListBulleted';
|
|
4
|
+
import NumberedListIcon from '@material-ui/icons/FormatListNumbered';
|
|
5
|
+
import ImagePlugin from './image';
|
|
6
|
+
import MediaPlugin from './media';
|
|
7
|
+
import CharactersPlugin from './characters';
|
|
8
|
+
import Italic from '@material-ui/icons/FormatItalic';
|
|
9
|
+
import MathPlugin from './math';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import Strikethrough from '@material-ui/icons/FormatStrikethrough';
|
|
12
|
+
import ToolbarPlugin from './toolbar';
|
|
13
|
+
import Underline from '@material-ui/icons/FormatUnderlined';
|
|
14
|
+
import compact from 'lodash/compact';
|
|
15
|
+
import SoftBreakPlugin from 'slate-soft-break';
|
|
16
|
+
import debug from 'debug';
|
|
17
|
+
import List from './list';
|
|
18
|
+
import TablePlugin from './table';
|
|
19
|
+
import RespAreaPlugin from './respArea';
|
|
20
|
+
|
|
21
|
+
const log = debug('@pie-lib:editable-html:plugins');
|
|
22
|
+
|
|
23
|
+
function MarkHotkey(options) {
|
|
24
|
+
const { type, key, icon, tag } = options;
|
|
25
|
+
|
|
26
|
+
// Return our "plugin" object, containing the `onKeyDown` handler.
|
|
27
|
+
return {
|
|
28
|
+
toolbar: {
|
|
29
|
+
isMark: true,
|
|
30
|
+
type,
|
|
31
|
+
icon,
|
|
32
|
+
onToggle: change => {
|
|
33
|
+
log('[onToggleMark] type: ', type);
|
|
34
|
+
return change.toggleMark(type);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
renderMark(props) {
|
|
38
|
+
if (props.mark.type === type) {
|
|
39
|
+
const K = tag || type;
|
|
40
|
+
return <K>{props.children}</K>;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
onKeyDown(event, change) {
|
|
44
|
+
// Check that the key pressed matches our `key` option.
|
|
45
|
+
if (!event.metaKey || event.key != key) return;
|
|
46
|
+
|
|
47
|
+
// Prevent the default characters from being inserted.
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
|
|
50
|
+
// Toggle the mark `type`.
|
|
51
|
+
change.toggleMark(type);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const ALL_PLUGINS = [
|
|
58
|
+
'bold',
|
|
59
|
+
// 'code',
|
|
60
|
+
'italic',
|
|
61
|
+
'underline',
|
|
62
|
+
'strikethrough',
|
|
63
|
+
'bulleted-list',
|
|
64
|
+
'numbered-list',
|
|
65
|
+
'image',
|
|
66
|
+
'math',
|
|
67
|
+
'languageCharacters',
|
|
68
|
+
'table',
|
|
69
|
+
'video',
|
|
70
|
+
'audio',
|
|
71
|
+
'responseArea'
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
export const DEFAULT_PLUGINS = ALL_PLUGINS.filter(plug => plug !== 'responseArea');
|
|
75
|
+
|
|
76
|
+
export const buildPlugins = (activePlugins, opts) => {
|
|
77
|
+
log('[buildPlugins] opts: ', opts);
|
|
78
|
+
|
|
79
|
+
activePlugins = activePlugins || DEFAULT_PLUGINS;
|
|
80
|
+
|
|
81
|
+
const addIf = (key, p) => activePlugins.includes(key) && p;
|
|
82
|
+
const imagePlugin = opts.image && opts.image.onDelete && ImagePlugin(opts.image);
|
|
83
|
+
const mathPlugin = MathPlugin(opts.math);
|
|
84
|
+
const respAreaPlugin =
|
|
85
|
+
opts.responseArea &&
|
|
86
|
+
opts.responseArea.type &&
|
|
87
|
+
RespAreaPlugin(opts.responseArea, compact([mathPlugin]));
|
|
88
|
+
|
|
89
|
+
return compact([
|
|
90
|
+
addIf('table', TablePlugin(opts.table, compact([imagePlugin, mathPlugin, respAreaPlugin]))),
|
|
91
|
+
addIf('bold', MarkHotkey({ key: 'b', type: 'bold', icon: <Bold />, tag: 'strong' })),
|
|
92
|
+
// addIf('code', MarkHotkey({ key: '`', type: 'code', icon: <Code /> })),
|
|
93
|
+
addIf('italic', MarkHotkey({ key: 'i', type: 'italic', icon: <Italic />, tag: 'em' })),
|
|
94
|
+
addIf(
|
|
95
|
+
'strikethrough',
|
|
96
|
+
MarkHotkey({
|
|
97
|
+
key: '~',
|
|
98
|
+
type: 'strikethrough',
|
|
99
|
+
icon: <Strikethrough />,
|
|
100
|
+
tag: 'del'
|
|
101
|
+
})
|
|
102
|
+
),
|
|
103
|
+
addIf('underline', MarkHotkey({ key: 'u', type: 'underline', icon: <Underline />, tag: 'u' })),
|
|
104
|
+
addIf('image', imagePlugin),
|
|
105
|
+
addIf('video', MediaPlugin('video', opts.media)),
|
|
106
|
+
addIf('audio', MediaPlugin('audio', opts.media)),
|
|
107
|
+
addIf('math', mathPlugin),
|
|
108
|
+
...opts.languageCharacters.map(config => addIf('languageCharacters', CharactersPlugin(config))),
|
|
109
|
+
addIf('bulleted-list', List({ key: 'l', type: 'ul_list', icon: <BulletedListIcon /> })),
|
|
110
|
+
addIf('numbered-list', List({ key: 'n', type: 'ol_list', icon: <NumberedListIcon /> })),
|
|
111
|
+
ToolbarPlugin(opts.toolbar),
|
|
112
|
+
SoftBreakPlugin({ shift: true }),
|
|
113
|
+
addIf('responseArea', respAreaPlugin)
|
|
114
|
+
]);
|
|
115
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Data } from 'slate';
|
|
3
|
+
import Immutable from 'immutable';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import EditList from 'slate-edit-list';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
|
|
8
|
+
const log = debug('@pie-lib:editable-html:plugins:list');
|
|
9
|
+
|
|
10
|
+
const b = (type, next, childNodes) => ({
|
|
11
|
+
object: 'block',
|
|
12
|
+
type,
|
|
13
|
+
nodes: next(childNodes)
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const serialization = {
|
|
17
|
+
deserialize(el, next) {
|
|
18
|
+
const name = el.tagName.toLowerCase();
|
|
19
|
+
|
|
20
|
+
if (name === 'li') {
|
|
21
|
+
return b('list_item', next, el.childNodes);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (name === 'ul') {
|
|
25
|
+
return b('ul_list', next, el.children.length ? Array.from(el.children) : el.childNodes);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (name === 'ol') {
|
|
29
|
+
return b('ol_list', next, el.children.length ? Array.from(el.children) : el.childNodes);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
serialize(object, children) {
|
|
33
|
+
if (object.object !== 'block') return;
|
|
34
|
+
|
|
35
|
+
if (object.type === 'list_item') {
|
|
36
|
+
return <li>{children}</li>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (object.type === 'ul_list') {
|
|
40
|
+
return <ul>{children}</ul>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (object.type === 'ol_list') {
|
|
44
|
+
return <ol>{children}</ol>;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const createEditList = () => {
|
|
50
|
+
const core = EditList({
|
|
51
|
+
typeDefault: 'span'
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// fix outdated schema
|
|
55
|
+
if (core.schema && core.schema.blocks) {
|
|
56
|
+
Object.keys(core.schema.blocks).forEach(key => {
|
|
57
|
+
const block = core.schema.blocks[key];
|
|
58
|
+
|
|
59
|
+
if (block.parent) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
block.nodes[0] = { type: block.nodes[0].types[0] };
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* This override of the core.changes.wrapInList is needed because the version
|
|
69
|
+
* of immutable that we have does not support getting the element at a specific
|
|
70
|
+
* index with a square bracket (list[0]). We have to use the list.get function instead
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns the highest list of blocks that cover the current selection
|
|
75
|
+
*/
|
|
76
|
+
const getHighestSelectedBlocks = value => {
|
|
77
|
+
const range = value.selection;
|
|
78
|
+
const document = value.document;
|
|
79
|
+
|
|
80
|
+
const startBlock = document.getClosestBlock(range.startKey);
|
|
81
|
+
const endBlock = document.getClosestBlock(range.endKey);
|
|
82
|
+
|
|
83
|
+
if (startBlock === endBlock) {
|
|
84
|
+
return Immutable.List([startBlock]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const ancestor = document.getCommonAncestor(startBlock.key, endBlock.key);
|
|
88
|
+
const startPath = ancestor.getPath(startBlock.key);
|
|
89
|
+
const endPath = ancestor.getPath(endBlock.key);
|
|
90
|
+
|
|
91
|
+
return ancestor.nodes.slice(startPath.get(0), endPath.get(0) + 1);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Wrap the blocks in the current selection in a new list. Selected
|
|
96
|
+
* lists are merged together.
|
|
97
|
+
*/
|
|
98
|
+
core.changes.wrapInList = function(change, type, data) {
|
|
99
|
+
const selectedBlocks = getHighestSelectedBlocks(change.value);
|
|
100
|
+
|
|
101
|
+
// Wrap in container
|
|
102
|
+
change.wrapBlock({ type: type, data: Data.create(data) }, { normalize: false });
|
|
103
|
+
|
|
104
|
+
// Wrap in list items
|
|
105
|
+
selectedBlocks.forEach(function(node) {
|
|
106
|
+
if (core.utils.isList(node)) {
|
|
107
|
+
// Merge its items with the created list
|
|
108
|
+
node.nodes.forEach(function(_ref) {
|
|
109
|
+
const key = _ref.key;
|
|
110
|
+
return change.unwrapNodeByKey(key, { normalize: false });
|
|
111
|
+
});
|
|
112
|
+
} else if (node.type !== 'list_item') {
|
|
113
|
+
change.wrapBlockByKey(node.key, 'list_item', {
|
|
114
|
+
normalize: false
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return change.normalize();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return core;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default options => {
|
|
126
|
+
const { type, icon } = options;
|
|
127
|
+
|
|
128
|
+
const core = createEditList();
|
|
129
|
+
|
|
130
|
+
// eslint-disable-next-line react/display-name
|
|
131
|
+
core.renderNode = props => {
|
|
132
|
+
const { node, attributes, children } = props;
|
|
133
|
+
|
|
134
|
+
switch (node.type) {
|
|
135
|
+
case 'ul_list':
|
|
136
|
+
return <ul {...attributes}>{children}</ul>;
|
|
137
|
+
case 'ol_list':
|
|
138
|
+
return <ol {...attributes}>{children}</ol>;
|
|
139
|
+
case 'list_item':
|
|
140
|
+
return <li {...attributes}>{children}</li>;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
core.toolbar = {
|
|
145
|
+
isMark: false,
|
|
146
|
+
type,
|
|
147
|
+
icon,
|
|
148
|
+
isActive: (value, type) => {
|
|
149
|
+
if (!core.utils.isSelectionInList(value)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const current = core.utils.getCurrentList(value);
|
|
153
|
+
return current ? current.type === type : false;
|
|
154
|
+
},
|
|
155
|
+
onClick: (value, onChange) => {
|
|
156
|
+
log('[onClick]', value);
|
|
157
|
+
const inList = core.utils.isSelectionInList(value);
|
|
158
|
+
if (inList) {
|
|
159
|
+
const change = value.change().call(core.changes.unwrapList);
|
|
160
|
+
onChange(change);
|
|
161
|
+
} else {
|
|
162
|
+
const change = value.change().call(core.changes.wrapInList, type);
|
|
163
|
+
onChange(change);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
core.renderNode.propTypes = {
|
|
169
|
+
node: PropTypes.object,
|
|
170
|
+
attributes: PropTypes.object,
|
|
171
|
+
children: PropTypes.func
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return core;
|
|
175
|
+
};
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import Functions from '@material-ui/icons/Functions';
|
|
2
|
+
import { Inline } from 'slate';
|
|
3
|
+
import { MathPreview, MathToolbar } from '@pie-lib/math-toolbar';
|
|
4
|
+
import { wrapMath, unWrapMath } from '@pie-lib/math-rendering';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
import SlatePropTypes from 'slate-prop-types';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
|
|
10
|
+
import { BLOCK_TAGS } from '../../serialization';
|
|
11
|
+
const log = debug('@pie-lib:editable-html:plugins:math');
|
|
12
|
+
|
|
13
|
+
const TEXT_NODE = 3;
|
|
14
|
+
|
|
15
|
+
function generateAdditionalKeys(keyData = []) {
|
|
16
|
+
return keyData.map(key => ({
|
|
17
|
+
name: key,
|
|
18
|
+
latex: key,
|
|
19
|
+
write: key,
|
|
20
|
+
label: key
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const CustomToolbarComp = React.memo(
|
|
25
|
+
props => {
|
|
26
|
+
const { node, value, onFocus, onBlur, onClick } = props;
|
|
27
|
+
const { pluginProps } = props || {};
|
|
28
|
+
const { math } = pluginProps || {};
|
|
29
|
+
const { keypadMode, customKeys, controlledKeypadMode = true } = math || {};
|
|
30
|
+
|
|
31
|
+
const onDone = latex => {
|
|
32
|
+
const update = {
|
|
33
|
+
...node.data.toObject(),
|
|
34
|
+
latex
|
|
35
|
+
};
|
|
36
|
+
const change = value.change().setNodeByKey(node.key, { data: update });
|
|
37
|
+
|
|
38
|
+
const nextText = value.document.getNextText(node.key);
|
|
39
|
+
|
|
40
|
+
change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);
|
|
41
|
+
|
|
42
|
+
props.onToolbarDone(change, false);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const onChange = latex => {
|
|
46
|
+
const update = {
|
|
47
|
+
...node.data.toObject(),
|
|
48
|
+
latex
|
|
49
|
+
};
|
|
50
|
+
const change = value.change().setNodeByKey(node.key, { data: update });
|
|
51
|
+
log('call onToolbarChange:', change);
|
|
52
|
+
props.onDataChange(node.key, update);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const latex = node.data.get('latex');
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<MathToolbar
|
|
59
|
+
autoFocus
|
|
60
|
+
additionalKeys={generateAdditionalKeys(customKeys)}
|
|
61
|
+
latex={latex}
|
|
62
|
+
onChange={onChange}
|
|
63
|
+
onDone={onDone}
|
|
64
|
+
onBlur={onBlur}
|
|
65
|
+
onFocus={onFocus}
|
|
66
|
+
onClick={onClick}
|
|
67
|
+
keypadMode={keypadMode}
|
|
68
|
+
controlledKeypadMode={controlledKeypadMode}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
(prev, next) => {
|
|
73
|
+
const { node, pluginProps: { math: { keypadMode, controlledKeypadMode } = {} } = {} } = prev;
|
|
74
|
+
const {
|
|
75
|
+
node: nodeNext,
|
|
76
|
+
pluginProps: {
|
|
77
|
+
math: { keypadMode: keypadModeNext, controlledKeypadMode: controlledKeypadModeNext } = {}
|
|
78
|
+
} = {}
|
|
79
|
+
} = next;
|
|
80
|
+
const keypadModeChanged = keypadMode !== keypadModeNext;
|
|
81
|
+
const controlledKeypadModeChanged = controlledKeypadMode !== controlledKeypadModeNext;
|
|
82
|
+
|
|
83
|
+
const equal = node.equals(nodeNext);
|
|
84
|
+
return equal && !keypadModeChanged && !controlledKeypadModeChanged;
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
CustomToolbarComp.propTypes = {
|
|
89
|
+
node: SlatePropTypes.node.isRequired,
|
|
90
|
+
value: SlatePropTypes.value,
|
|
91
|
+
onToolbarDone: PropTypes.func,
|
|
92
|
+
onDataChange: PropTypes.func,
|
|
93
|
+
onFocus: PropTypes.func,
|
|
94
|
+
onClick: PropTypes.func,
|
|
95
|
+
onBlur: PropTypes.func
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default function MathPlugin() {
|
|
99
|
+
return {
|
|
100
|
+
name: 'math',
|
|
101
|
+
toolbar: {
|
|
102
|
+
icon: <Functions />,
|
|
103
|
+
onClick: (value, onChange) => {
|
|
104
|
+
log('[insertMath]');
|
|
105
|
+
const math = inlineMath();
|
|
106
|
+
const change = value.change().insertInline(math);
|
|
107
|
+
onChange(change);
|
|
108
|
+
},
|
|
109
|
+
supports: node => node && node.object === 'inline' && node.type === 'math',
|
|
110
|
+
/**
|
|
111
|
+
* Return a react component function
|
|
112
|
+
* @param node {Slate.Node}
|
|
113
|
+
* @param value {Slate.Value}
|
|
114
|
+
* @param onDone {(change?: Slate.Change, finishEditing :boolea) => void} - a function to call once the toolbar
|
|
115
|
+
* has made any changes, call with the node.key and a data object.
|
|
116
|
+
*/
|
|
117
|
+
CustomToolbarComp
|
|
118
|
+
},
|
|
119
|
+
schema: {
|
|
120
|
+
document: { match: [{ type: 'math' }] }
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
pluginStyles: (node, parentNode, p) => {
|
|
124
|
+
if (p) {
|
|
125
|
+
return {
|
|
126
|
+
position: 'absolute',
|
|
127
|
+
top: 'initial'
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
renderNode: props => {
|
|
133
|
+
if (props.node.type === 'math') {
|
|
134
|
+
log('[renderNode]: data:', props.node.data);
|
|
135
|
+
return <MathPreview {...props} />;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Here for rendering mathml content
|
|
140
|
+
*/
|
|
141
|
+
if (props.node.type === 'mathml') {
|
|
142
|
+
const html = props.node.data.get('html');
|
|
143
|
+
|
|
144
|
+
return <span {...props.attributes} dangerouslySetInnerHTML={{ __html: html }} />;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
MathPlugin.ROUND_BRACKETS = 'round_brackets';
|
|
151
|
+
MathPlugin.SQUARE_BRACKETS = 'square_brackets';
|
|
152
|
+
MathPlugin.DOLLAR = 'dollar';
|
|
153
|
+
MathPlugin.DOUBLE_DOLLAR = 'double_dollar';
|
|
154
|
+
|
|
155
|
+
export const inlineMath = () =>
|
|
156
|
+
Inline.create({
|
|
157
|
+
object: 'inline',
|
|
158
|
+
type: 'math',
|
|
159
|
+
isVoid: true,
|
|
160
|
+
data: {
|
|
161
|
+
latex: ''
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const htmlDecode = input => {
|
|
166
|
+
const doc = new DOMParser().parseFromString(input, 'text/html');
|
|
167
|
+
|
|
168
|
+
return doc.documentElement.textContent;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const getTagName = el => {
|
|
172
|
+
return ((el && el.tagName) || '').toLowerCase();
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Makes sure that strings that contain stuff like:
|
|
177
|
+
* x<y are not transformed into x by the DOMParser because it thinks
|
|
178
|
+
* that <y is the start of a dom element tag
|
|
179
|
+
* @param input
|
|
180
|
+
* @returns {*}
|
|
181
|
+
*/
|
|
182
|
+
const lessThanHandling = input => {
|
|
183
|
+
const arrowSplit = input.split('<');
|
|
184
|
+
|
|
185
|
+
// if we don't have at least 2 characters there's no point in checking
|
|
186
|
+
if (input.length > 2) {
|
|
187
|
+
return arrowSplit.reduce((st, part) => {
|
|
188
|
+
/*
|
|
189
|
+
We check if this element resulted is:
|
|
190
|
+
div - continuation of a beginning of a HTML element
|
|
191
|
+
/div - closing of a HTML tag
|
|
192
|
+
br/> - beginning and closing of a html TAG
|
|
193
|
+
*/
|
|
194
|
+
if (part.match(/<[a-zA-Z/][\s\S]*>/ig)) {
|
|
195
|
+
return `${st}${st ? '<' : ''}${part}`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return `${st}${st ? '<' : ''}${part}`;
|
|
199
|
+
}, '');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return input;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export const serialization = {
|
|
206
|
+
deserialize(el) {
|
|
207
|
+
const tagName = getTagName(el);
|
|
208
|
+
/**
|
|
209
|
+
* This is used for when there's a wrapper over the mathml element.
|
|
210
|
+
* Because of this slate rule: "Only allow block nodes or inline and text nodes in blocks."
|
|
211
|
+
* The element that contains only the mathml is removed (along with the math) because it has
|
|
212
|
+
* an inline child and the block is of type block
|
|
213
|
+
* This is for legacy content only since our math rendering is valid for the core slate rules
|
|
214
|
+
*/
|
|
215
|
+
const hasMathChild =
|
|
216
|
+
BLOCK_TAGS[tagName] && el.childNodes.length === 1 && getTagName(el.firstChild) === 'math';
|
|
217
|
+
log('[deserialize] name: ', tagName);
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* This is here in order to be able to render mathml content
|
|
221
|
+
*/
|
|
222
|
+
if (tagName === 'math' || (el.dataset && el.dataset.type === 'mathml') || hasMathChild) {
|
|
223
|
+
const newHtml = hasMathChild ? el.innerHTML : el.outerHTML;
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
object: 'inline',
|
|
227
|
+
isVoid: true,
|
|
228
|
+
type: 'mathml',
|
|
229
|
+
data: {
|
|
230
|
+
html: newHtml
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (el.nodeType === TEXT_NODE) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (tagName !== 'span') {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const hasLatex = el.hasAttribute('data-latex') || el.hasAttribute('latex');
|
|
244
|
+
|
|
245
|
+
if (hasLatex) {
|
|
246
|
+
const latex = htmlDecode(el.innerHTML);
|
|
247
|
+
const { unwrapped, wrapType } = unWrapMath(latex);
|
|
248
|
+
log('[deserialize]: noBrackets: ', unwrapped, wrapType);
|
|
249
|
+
return {
|
|
250
|
+
object: 'inline',
|
|
251
|
+
type: 'math',
|
|
252
|
+
isVoid: true,
|
|
253
|
+
nodes: [],
|
|
254
|
+
data: {
|
|
255
|
+
latex: unwrapped,
|
|
256
|
+
wrapper: wrapType
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
serialize(object) {
|
|
262
|
+
if (object.type === 'math') {
|
|
263
|
+
const l = object.data.get('latex');
|
|
264
|
+
const wrapper = object.data.get('wrapper');
|
|
265
|
+
log('[serialize] latex: ', l);
|
|
266
|
+
const decoded = htmlDecode(lessThanHandling(l));
|
|
267
|
+
return (
|
|
268
|
+
<span data-latex="" data-raw={decoded}>
|
|
269
|
+
{wrapMath(decoded, wrapper)}
|
|
270
|
+
</span>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Here for rendering mathml content
|
|
276
|
+
*/
|
|
277
|
+
if (object.type === 'mathml') {
|
|
278
|
+
const html = object.data.get('html');
|
|
279
|
+
|
|
280
|
+
return <span data-type="mathml" dangerouslySetInnerHTML={{ __html: html }} />;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|