@pie-lib/editable-html 11.18.6-esmbeta.0 → 11.19.0-mui-update.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 +37 -0
- package/lib/block-tags.js +2 -3
- package/lib/block-tags.js.map +1 -1
- package/lib/constants.js +3 -6
- package/lib/constants.js.map +1 -1
- package/lib/editor.js +302 -450
- package/lib/editor.js.map +1 -1
- package/lib/index.js +19 -77
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js +7 -7
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +24 -44
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +9 -60
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +3 -6
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/css/icons/index.js +13 -25
- package/lib/plugins/css/icons/index.js.map +1 -1
- package/lib/plugins/css/index.js +22 -88
- package/lib/plugins/css/index.js.map +1 -1
- package/lib/plugins/customPlugin/index.js +10 -26
- package/lib/plugins/customPlugin/index.js.map +1 -1
- package/lib/plugins/html/icons/index.js +14 -26
- package/lib/plugins/html/icons/index.js.map +1 -1
- package/lib/plugins/html/index.js +4 -13
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js +20 -49
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +119 -190
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +44 -86
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +6 -46
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +10 -31
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +44 -106
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +27 -73
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +64 -116
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +23 -81
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +192 -307
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +40 -65
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +20 -49
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/rendering/index.js +5 -15
- package/lib/plugins/rendering/index.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +175 -249
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +39 -29
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -10
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +22 -45
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +5 -59
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +2 -10
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/math-templated/index.js +92 -109
- package/lib/plugins/respArea/math-templated/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +8 -40
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/CustomTablePlugin.js +24 -41
- package/lib/plugins/table/CustomTablePlugin.js.map +1 -1
- package/lib/plugins/table/icons/index.js +19 -35
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +41 -118
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +37 -87
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/textAlign/icons/index.js +18 -64
- package/lib/plugins/textAlign/icons/index.js.map +1 -1
- package/lib/plugins/textAlign/index.js +1 -6
- package/lib/plugins/textAlign/index.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +30 -79
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +16 -34
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +174 -201
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +0 -5
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +57 -107
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +95 -161
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +5 -25
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +44 -150
- package/lib/serialization.js.map +1 -1
- package/lib/shared/alert-dialog.js +23 -42
- package/lib/theme.js +1 -2
- package/lib/theme.js.map +1 -1
- package/package.json +15 -21
- package/src/__tests__/utils.js +1 -1
- package/src/editor.jsx +110 -108
- package/src/plugins/characters/custom-popper.js +20 -25
- package/src/plugins/css/icons/index.jsx +11 -13
- package/src/plugins/css/index.jsx +3 -5
- package/src/plugins/html/icons/index.jsx +12 -14
- package/src/plugins/image/alt-dialog.jsx +9 -8
- package/src/plugins/image/component.jsx +67 -87
- package/src/plugins/image/image-toolbar.jsx +26 -26
- package/src/plugins/image/index.jsx +1 -1
- package/src/plugins/index.jsx +10 -10
- package/src/plugins/math/index.jsx +1 -1
- package/src/plugins/media/index.jsx +2 -2
- package/src/plugins/media/media-dialog.js +65 -76
- package/src/plugins/media/media-toolbar.jsx +32 -33
- package/src/plugins/media/media-wrapper.jsx +10 -13
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +193 -180
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +58 -22
- package/src/plugins/respArea/icons/index.jsx +16 -16
- package/src/plugins/respArea/math-templated/index.jsx +88 -89
- package/src/plugins/respArea/utils.jsx +1 -1
- package/src/plugins/table/icons/index.jsx +14 -16
- package/src/plugins/table/index.jsx +27 -19
- package/src/plugins/table/table-toolbar.jsx +17 -19
- package/src/plugins/textAlign/icons/index.jsx +3 -3
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +1 -1
- package/src/plugins/toolbar/__tests__/toolbar.test.jsx +1 -1
- package/src/plugins/toolbar/default-toolbar.jsx +18 -21
- package/src/plugins/toolbar/done-button.jsx +16 -22
- package/src/plugins/toolbar/editor-and-toolbar.jsx +134 -157
- package/src/plugins/toolbar/toolbar-buttons.jsx +29 -46
- package/src/plugins/toolbar/toolbar.jsx +60 -78
- package/esm/index.js +0 -111560
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
|
@@ -1,45 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.CustomToolbarComp = void 0;
|
|
9
8
|
exports["default"] = MathPlugin;
|
|
10
9
|
exports.serialization = exports.inlineMath = void 0;
|
|
11
|
-
|
|
12
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _Functions = _interopRequireDefault(require("@material-ui/icons/Functions"));
|
|
17
|
-
|
|
12
|
+
var _Functions = _interopRequireDefault(require("@mui/icons-material/Functions"));
|
|
18
13
|
var _slate = require("slate");
|
|
19
|
-
|
|
20
14
|
var _mathToolbar = require("@pie-lib/math-toolbar");
|
|
21
|
-
|
|
22
15
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
23
|
-
|
|
24
16
|
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
17
|
var _debug = _interopRequireDefault(require("debug"));
|
|
27
|
-
|
|
28
18
|
var _slatePropTypes = _interopRequireDefault(require("slate-prop-types"));
|
|
29
|
-
|
|
30
19
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
-
|
|
32
20
|
var _blockTags = require("../../block-tags");
|
|
33
|
-
|
|
34
21
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
39
|
-
|
|
22
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
40
24
|
var log = (0, _debug["default"])('@pie-lib:editable-html:plugins:math');
|
|
41
25
|
var TEXT_NODE = 3;
|
|
42
|
-
|
|
43
26
|
function generateAdditionalKeys() {
|
|
44
27
|
var keyData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
45
28
|
return keyData.map(function (key) {
|
|
@@ -50,33 +33,28 @@ function generateAdditionalKeys() {
|
|
|
50
33
|
label: key
|
|
51
34
|
};
|
|
52
35
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
36
|
+
}
|
|
55
37
|
|
|
56
|
-
|
|
38
|
+
// eslint-disable-next-line react/display-name
|
|
39
|
+
var CustomToolbarComp = exports.CustomToolbarComp = /*#__PURE__*/_react["default"].memo(function (props) {
|
|
57
40
|
var node = props.node,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
41
|
+
value = props.value,
|
|
42
|
+
onFocus = props.onFocus,
|
|
43
|
+
onBlur = props.onBlur,
|
|
44
|
+
onClick = props.onClick;
|
|
63
45
|
var _ref = props || {},
|
|
64
|
-
|
|
65
|
-
|
|
46
|
+
pluginProps = _ref.pluginProps;
|
|
66
47
|
var _ref2 = pluginProps || {},
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
math = _ref2.math;
|
|
69
49
|
var _ref3 = math || {},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
keypadMode = _ref3.keypadMode,
|
|
51
|
+
customKeys = _ref3.customKeys,
|
|
52
|
+
_ref3$controlledKeypa = _ref3.controlledKeypadMode,
|
|
53
|
+
controlledKeypadMode = _ref3$controlledKeypa === void 0 ? true : _ref3$controlledKeypa;
|
|
75
54
|
var onDone = function onDone(latex) {
|
|
76
55
|
var update = _objectSpread(_objectSpread({}, node.data.toObject()), {}, {
|
|
77
56
|
latex: latex
|
|
78
57
|
});
|
|
79
|
-
|
|
80
58
|
var change = value.change().setNodeByKey(node.key, {
|
|
81
59
|
data: update
|
|
82
60
|
});
|
|
@@ -84,19 +62,16 @@ var CustomToolbarComp = /*#__PURE__*/_react["default"].memo(function (props) {
|
|
|
84
62
|
change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);
|
|
85
63
|
props.onToolbarDone(change, false);
|
|
86
64
|
};
|
|
87
|
-
|
|
88
65
|
var onChange = function onChange(latex) {
|
|
89
66
|
var update = _objectSpread(_objectSpread({}, node.data.toObject()), {}, {
|
|
90
67
|
latex: latex
|
|
91
68
|
});
|
|
92
|
-
|
|
93
69
|
var change = value.change().setNodeByKey(node.key, {
|
|
94
70
|
data: update
|
|
95
71
|
});
|
|
96
72
|
log('call onToolbarChange:', change);
|
|
97
73
|
props.onDataChange(node.key, update);
|
|
98
74
|
};
|
|
99
|
-
|
|
100
75
|
var latex = node.data.get('latex');
|
|
101
76
|
return /*#__PURE__*/_react["default"].createElement(_mathToolbar.MathToolbar, {
|
|
102
77
|
autoFocus: true,
|
|
@@ -112,26 +87,24 @@ var CustomToolbarComp = /*#__PURE__*/_react["default"].memo(function (props) {
|
|
|
112
87
|
});
|
|
113
88
|
}, function (prev, next) {
|
|
114
89
|
var node = prev.node,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
90
|
+
_prev$pluginProps = prev.pluginProps,
|
|
91
|
+
_prev$pluginProps2 = _prev$pluginProps === void 0 ? {} : _prev$pluginProps,
|
|
92
|
+
_prev$pluginProps2$ma = _prev$pluginProps2.math,
|
|
93
|
+
_prev$pluginProps2$ma2 = _prev$pluginProps2$ma === void 0 ? {} : _prev$pluginProps2$ma,
|
|
94
|
+
keypadMode = _prev$pluginProps2$ma2.keypadMode,
|
|
95
|
+
controlledKeypadMode = _prev$pluginProps2$ma2.controlledKeypadMode;
|
|
121
96
|
var nodeNext = next.node,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
97
|
+
_next$pluginProps = next.pluginProps,
|
|
98
|
+
_next$pluginProps2 = _next$pluginProps === void 0 ? {} : _next$pluginProps,
|
|
99
|
+
_next$pluginProps2$ma = _next$pluginProps2.math,
|
|
100
|
+
_next$pluginProps2$ma2 = _next$pluginProps2$ma === void 0 ? {} : _next$pluginProps2$ma,
|
|
101
|
+
keypadModeNext = _next$pluginProps2$ma2.keypadMode,
|
|
102
|
+
controlledKeypadModeNext = _next$pluginProps2$ma2.controlledKeypadMode;
|
|
128
103
|
var keypadModeChanged = keypadMode !== keypadModeNext;
|
|
129
104
|
var controlledKeypadModeChanged = controlledKeypadMode !== controlledKeypadModeNext;
|
|
130
105
|
var equal = node.equals(nodeNext);
|
|
131
106
|
return equal && !keypadModeChanged && !controlledKeypadModeChanged;
|
|
132
107
|
});
|
|
133
|
-
|
|
134
|
-
exports.CustomToolbarComp = CustomToolbarComp;
|
|
135
108
|
CustomToolbarComp.propTypes = {
|
|
136
109
|
node: _slatePropTypes["default"].node.isRequired,
|
|
137
110
|
value: _slatePropTypes["default"].value,
|
|
@@ -141,7 +114,6 @@ CustomToolbarComp.propTypes = {
|
|
|
141
114
|
onClick: _propTypes["default"].func,
|
|
142
115
|
onBlur: _propTypes["default"].func
|
|
143
116
|
};
|
|
144
|
-
|
|
145
117
|
function MathPlugin(opts) {
|
|
146
118
|
MathPlugin.mathMlOptions = {
|
|
147
119
|
mmlOutput: opts.mmlOutput,
|
|
@@ -161,7 +133,6 @@ function MathPlugin(opts) {
|
|
|
161
133
|
supports: function supports(node) {
|
|
162
134
|
return node && node.object === 'inline' && node.type === 'math';
|
|
163
135
|
},
|
|
164
|
-
|
|
165
136
|
/**
|
|
166
137
|
* Return a react component function
|
|
167
138
|
* @param node {Slate.Node}
|
|
@@ -191,11 +162,10 @@ function MathPlugin(opts) {
|
|
|
191
162
|
log('[renderNode]: data:', props.node.data);
|
|
192
163
|
return /*#__PURE__*/_react["default"].createElement(_mathToolbar.MathPreview, props);
|
|
193
164
|
}
|
|
165
|
+
|
|
194
166
|
/**
|
|
195
167
|
* Here for rendering mathml content
|
|
196
168
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
169
|
if (props.node.type === 'mathml') {
|
|
200
170
|
var html = props.node.data.get('html');
|
|
201
171
|
return /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({}, props.attributes, {
|
|
@@ -207,7 +177,6 @@ function MathPlugin(opts) {
|
|
|
207
177
|
}
|
|
208
178
|
};
|
|
209
179
|
}
|
|
210
|
-
|
|
211
180
|
MathPlugin.ROUND_BRACKETS = 'round_brackets';
|
|
212
181
|
MathPlugin.SQUARE_BRACKETS = 'square_brackets';
|
|
213
182
|
MathPlugin.DOLLAR = 'dollar';
|
|
@@ -217,8 +186,7 @@ MathPlugin.propTypes = {
|
|
|
217
186
|
attributes: _propTypes["default"].object,
|
|
218
187
|
node: _slatePropTypes["default"].node
|
|
219
188
|
};
|
|
220
|
-
|
|
221
|
-
var inlineMath = function inlineMath() {
|
|
189
|
+
var inlineMath = exports.inlineMath = function inlineMath() {
|
|
222
190
|
return _slate.Inline.create({
|
|
223
191
|
object: 'inline',
|
|
224
192
|
type: 'math',
|
|
@@ -228,17 +196,14 @@ var inlineMath = function inlineMath() {
|
|
|
228
196
|
}
|
|
229
197
|
});
|
|
230
198
|
};
|
|
231
|
-
|
|
232
|
-
exports.inlineMath = inlineMath;
|
|
233
|
-
|
|
234
199
|
var htmlDecode = function htmlDecode(input) {
|
|
235
200
|
var doc = new DOMParser().parseFromString(input, 'text/html');
|
|
236
201
|
return doc.documentElement.textContent;
|
|
237
202
|
};
|
|
238
|
-
|
|
239
203
|
var getTagName = function getTagName(el) {
|
|
240
204
|
return (el && el.tagName || '').toLowerCase();
|
|
241
205
|
};
|
|
206
|
+
|
|
242
207
|
/**
|
|
243
208
|
* Makes sure that strings that contain stuff like:
|
|
244
209
|
* x<y are not transformed into x by the DOMParser because it thinks
|
|
@@ -246,8 +211,6 @@ var getTagName = function getTagName(el) {
|
|
|
246
211
|
* @param input
|
|
247
212
|
* @returns {*}
|
|
248
213
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
214
|
var arrowHandlingCase = function arrowHandlingCase(input) {
|
|
252
215
|
/*
|
|
253
216
|
If we have a < character followed by a letter
|
|
@@ -255,47 +218,50 @@ var arrowHandlingCase = function arrowHandlingCase(input) {
|
|
|
255
218
|
*/
|
|
256
219
|
return input.replace(/<([a-zA-Z]*)/g, '<$1');
|
|
257
220
|
};
|
|
258
|
-
|
|
259
221
|
function replaceLeftRight(latexInput) {
|
|
260
222
|
// for some reason, mmlToLatex parses () incorrectly - or at least in a way that our interpreter can not use them
|
|
261
223
|
// Replace '\\left.' and '\\right.' with an empty string
|
|
262
224
|
return latexInput.replace(/\\left\.\s*|\\right\.\s*/g, '');
|
|
263
225
|
}
|
|
264
|
-
|
|
265
226
|
var convertLatexToMathMl = function convertLatexToMathMl(_ref4) {
|
|
266
227
|
var latex = _ref4.latex,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
228
|
+
decoded = _ref4.decoded,
|
|
229
|
+
wrapper = _ref4.wrapper;
|
|
270
230
|
var removeEmptyMos = function removeEmptyMos(mmlFromLatex) {
|
|
271
231
|
// Regular expression to match <mo>⁡</mo> and <mo ...>⁡</mo>, which get added when using log with base
|
|
272
232
|
// not sure why they get added, but they add an extra space which is not needed
|
|
273
|
-
var regex = /<mo(?: [^>]*)?>⁡<\/mo>/g;
|
|
233
|
+
var regex = /<mo(?: [^>]*)?>⁡<\/mo>/g;
|
|
274
234
|
|
|
235
|
+
// Replace all occurrences of the matched patterns
|
|
275
236
|
return mmlFromLatex.replace(regex, '');
|
|
276
237
|
};
|
|
277
|
-
|
|
278
238
|
var handled = arrowHandlingCase(decoded);
|
|
279
|
-
var latexToConvert = "<span data-latex=\"\" data-raw=\"".concat(handled, "\">").concat((0, _mathRendering.wrapMath)(handled, wrapper), "</span>");
|
|
239
|
+
var latexToConvert = "<span data-latex=\"\" data-raw=\"".concat(handled, "\">").concat((0, _mathRendering.wrapMath)(handled, wrapper), "</span>");
|
|
280
240
|
|
|
241
|
+
// use math rendering (MathJax) to convert latex to mathMl
|
|
281
242
|
var mathMlFromLatex = (0, _mathRendering.renderMath)(latexToConvert, {
|
|
282
243
|
skipWaitForMathRenderingLib: true
|
|
283
|
-
});
|
|
244
|
+
});
|
|
284
245
|
|
|
246
|
+
// if renderMath returned the exact same string that we sent, it just means that the conversion could not be done
|
|
285
247
|
var conversionDidNotWork = (0, _isEqual["default"])(latexToConvert, mathMlFromLatex);
|
|
286
|
-
mathMlFromLatex = removeEmptyMos(mathMlFromLatex);
|
|
248
|
+
mathMlFromLatex = removeEmptyMos(mathMlFromLatex);
|
|
287
249
|
|
|
288
|
-
|
|
250
|
+
// we convert resulted mathml to latex to check if the resulted mathMl can be converted back to latex if user wants to edit it later
|
|
251
|
+
var latexFromMathMl = mathMlFromLatex ? (0, _mathRendering.mmlToLatex)(mathMlFromLatex) : '';
|
|
289
252
|
|
|
253
|
+
// we need to remove all the spaces from the latex to be able to compare it
|
|
290
254
|
var strippedL = latex.replace(/\s/g, '');
|
|
291
|
-
var strippedNewL = latexFromMathMl.replace(/\s/g, '');
|
|
292
|
-
// if it does, we can safely convert it to mathml
|
|
255
|
+
var strippedNewL = latexFromMathMl.replace(/\s/g, '');
|
|
293
256
|
|
|
257
|
+
// we check if the latex keeps his form after being converted to mathml and back to latex
|
|
258
|
+
// if it does, we can safely convert it to mathml
|
|
294
259
|
if (!(0, _isEqual["default"])(strippedL, strippedNewL)) {
|
|
295
|
-
var correctedLatex = replaceLeftRight(latexFromMathMl);
|
|
260
|
+
var correctedLatex = replaceLeftRight(latexFromMathMl);
|
|
261
|
+
|
|
262
|
+
// As George requested in PD-3167, I will set the new mathML anyway, and also log differences
|
|
296
263
|
// if it doesn't, we keep the latex version
|
|
297
264
|
// eslint-disable-next-line no-console
|
|
298
|
-
|
|
299
265
|
console.log('This latex can not be safely converted to mathml so we will keep the latex version!!!', {
|
|
300
266
|
initialLatex: latex,
|
|
301
267
|
newLatex: latexFromMathMl,
|
|
@@ -304,22 +270,20 @@ var convertLatexToMathMl = function convertLatexToMathMl(_ref4) {
|
|
|
304
270
|
conversionDidNotWork: conversionDidNotWork
|
|
305
271
|
});
|
|
306
272
|
}
|
|
307
|
-
|
|
308
273
|
return {
|
|
309
274
|
mathMlFromLatex: mathMlFromLatex,
|
|
310
275
|
conversionDidNotWork: conversionDidNotWork
|
|
311
276
|
};
|
|
312
277
|
};
|
|
313
|
-
|
|
314
278
|
var convertMathMlToLatex = function convertMathMlToLatex(mathMl) {
|
|
315
279
|
var htmlWithRemovedSpaces = mathMl.replaceAll(' ', ' ');
|
|
316
280
|
var htmlToUse = (0, _mathRendering.mmlToLatex)(htmlWithRemovedSpaces);
|
|
317
|
-
var latex = htmlDecode(htmlToUse);
|
|
281
|
+
var latex = htmlDecode(htmlToUse);
|
|
318
282
|
|
|
283
|
+
// todo fix this in mathml-to-latex
|
|
319
284
|
return replaceLeftRight(latex);
|
|
320
285
|
};
|
|
321
|
-
|
|
322
|
-
var serialization = {
|
|
286
|
+
var serialization = exports.serialization = {
|
|
323
287
|
deserialize: function deserialize(el) {
|
|
324
288
|
var tagName = getTagName(el);
|
|
325
289
|
/**
|
|
@@ -329,21 +293,18 @@ var serialization = {
|
|
|
329
293
|
* an inline child and the block is of type block
|
|
330
294
|
* This is for legacy content only since our math rendering is valid for the core slate rules
|
|
331
295
|
*/
|
|
332
|
-
|
|
333
296
|
var hasMathChild = _blockTags.BLOCK_TAGS[tagName] && el.childNodes.length === 1 && getTagName(el.firstChild) === 'math';
|
|
334
297
|
log('[deserialize] name: ', tagName);
|
|
298
|
+
|
|
335
299
|
/**
|
|
336
300
|
* This is here in order to be able to render mathml content
|
|
337
301
|
*/
|
|
338
|
-
|
|
339
302
|
if (tagName === 'math' || el.dataset && el.dataset.type === 'mathml' || hasMathChild) {
|
|
340
303
|
var mathMl = hasMathChild ? el.innerHTML : el.outerHTML;
|
|
341
|
-
|
|
342
304
|
if (MathPlugin.mathMlOptions.mmlEditing) {
|
|
343
305
|
var _unWrapMath = (0, _mathRendering.unWrapMath)(convertMathMlToLatex(mathMl)),
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
306
|
+
unwrapped = _unWrapMath.unwrapped,
|
|
307
|
+
wrapType = _unWrapMath.wrapType;
|
|
347
308
|
return {
|
|
348
309
|
object: 'inline',
|
|
349
310
|
type: 'math',
|
|
@@ -355,7 +316,6 @@ var serialization = {
|
|
|
355
316
|
}
|
|
356
317
|
};
|
|
357
318
|
}
|
|
358
|
-
|
|
359
319
|
return {
|
|
360
320
|
object: 'inline',
|
|
361
321
|
isVoid: true,
|
|
@@ -365,24 +325,18 @@ var serialization = {
|
|
|
365
325
|
}
|
|
366
326
|
};
|
|
367
327
|
}
|
|
368
|
-
|
|
369
328
|
if (el.nodeType === TEXT_NODE) {
|
|
370
329
|
return;
|
|
371
330
|
}
|
|
372
|
-
|
|
373
331
|
if (tagName !== 'span') {
|
|
374
332
|
return;
|
|
375
333
|
}
|
|
376
|
-
|
|
377
334
|
var hasLatex = el.hasAttribute('data-latex') || el.hasAttribute('latex');
|
|
378
|
-
|
|
379
335
|
if (hasLatex) {
|
|
380
336
|
var latex = htmlDecode(el.innerHTML);
|
|
381
|
-
|
|
382
337
|
var _unWrapMath2 = (0, _mathRendering.unWrapMath)(latex),
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
338
|
+
_unwrapped = _unWrapMath2.unwrapped,
|
|
339
|
+
_wrapType = _unWrapMath2.wrapType;
|
|
386
340
|
log('[deserialize]: noBrackets: ', _unwrapped, _wrapType);
|
|
387
341
|
return {
|
|
388
342
|
object: 'inline',
|
|
@@ -402,16 +356,14 @@ var serialization = {
|
|
|
402
356
|
var wrapper = object.data.get('wrapper');
|
|
403
357
|
var decoded = htmlDecode(arrowHandlingCase(latex));
|
|
404
358
|
log('[serialize] latex: ', latex);
|
|
405
|
-
|
|
406
359
|
if (MathPlugin.mathMlOptions.mmlOutput) {
|
|
407
360
|
var _convertLatexToMathMl = convertLatexToMathMl({
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
361
|
+
latex: latex,
|
|
362
|
+
decoded: decoded,
|
|
363
|
+
wrapper: wrapper
|
|
364
|
+
}),
|
|
365
|
+
mathMlFromLatex = _convertLatexToMathMl.mathMlFromLatex,
|
|
366
|
+
conversionDidNotWork = _convertLatexToMathMl.conversionDidNotWork;
|
|
415
367
|
if (conversionDidNotWork) {
|
|
416
368
|
// this means we could not convert latex to mathMl, so just return the latex version,
|
|
417
369
|
// same as we would do if mmlOutput would not be enabled
|
|
@@ -420,7 +372,6 @@ var serialization = {
|
|
|
420
372
|
"data-raw": decoded
|
|
421
373
|
}, (0, _mathRendering.wrapMath)(decoded, wrapper));
|
|
422
374
|
}
|
|
423
|
-
|
|
424
375
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
425
376
|
"data-type": "mathml",
|
|
426
377
|
dangerouslySetInnerHTML: {
|
|
@@ -428,17 +379,15 @@ var serialization = {
|
|
|
428
379
|
}
|
|
429
380
|
});
|
|
430
381
|
}
|
|
431
|
-
|
|
432
382
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
433
383
|
"data-latex": "",
|
|
434
384
|
"data-raw": decoded
|
|
435
385
|
}, (0, _mathRendering.wrapMath)(decoded, wrapper));
|
|
436
386
|
}
|
|
387
|
+
|
|
437
388
|
/**
|
|
438
389
|
* Here for rendering mathml content
|
|
439
390
|
*/
|
|
440
|
-
|
|
441
|
-
|
|
442
391
|
if (object.type === 'mathml') {
|
|
443
392
|
var html = object.data.get('html');
|
|
444
393
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
@@ -450,5 +399,4 @@ var serialization = {
|
|
|
450
399
|
}
|
|
451
400
|
}
|
|
452
401
|
};
|
|
453
|
-
exports.serialization = serialization;
|
|
454
402
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/math/index.jsx"],"names":["log","TEXT_NODE","generateAdditionalKeys","keyData","map","key","name","latex","write","label","CustomToolbarComp","React","memo","props","node","value","onFocus","onBlur","onClick","pluginProps","math","keypadMode","customKeys","controlledKeypadMode","onDone","update","data","toObject","change","setNodeByKey","nextText","document","getNextText","moveFocusTo","moveAnchorTo","onToolbarDone","onChange","onDataChange","get","prev","next","nodeNext","keypadModeNext","controlledKeypadModeNext","keypadModeChanged","controlledKeypadModeChanged","equal","equals","propTypes","SlatePropTypes","isRequired","PropTypes","func","MathPlugin","opts","mathMlOptions","mmlOutput","mmlEditing","toolbar","ariaLabel","icon","inlineMath","insertInline","supports","object","type","schema","match","pluginStyles","parentNode","p","position","top","renderNode","html","attributes","__html","ROUND_BRACKETS","SQUARE_BRACKETS","DOLLAR","DOUBLE_DOLLAR","Inline","create","isVoid","htmlDecode","input","doc","DOMParser","parseFromString","documentElement","textContent","getTagName","el","tagName","toLowerCase","arrowHandlingCase","replace","replaceLeftRight","latexInput","convertLatexToMathMl","decoded","wrapper","removeEmptyMos","mmlFromLatex","regex","handled","latexToConvert","mathMlFromLatex","skipWaitForMathRenderingLib","conversionDidNotWork","latexFromMathMl","strippedL","strippedNewL","correctedLatex","console","initialLatex","newLatex","mathML","convertMathMlToLatex","mathMl","htmlWithRemovedSpaces","replaceAll","htmlToUse","serialization","deserialize","hasMathChild","BLOCK_TAGS","childNodes","length","firstChild","dataset","innerHTML","outerHTML","unwrapped","wrapType","nodes","nodeType","hasLatex","hasAttribute","serialize"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,qCAAN,CAAZ;AAEA,IAAMC,SAAS,GAAG,CAAlB;;AAEA,SAASC,sBAAT,GAA8C;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AAC5C,SAAOA,OAAO,CAACC,GAAR,CAAY,UAACC,GAAD;AAAA,WAAU;AAC3BC,MAAAA,IAAI,EAAED,GADqB;AAE3BE,MAAAA,KAAK,EAAEF,GAF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UT;AAA9B,aACG,6BAASA,OAAT,EAAkBC,OAAlB,CADH,CADF;AAKD;;AAED,4BAAO;AAAM,uBAAU,QAAhB;AAAyB,UAAA,uBAAuB,EAAE;AAAEzB,YAAAA,MAAM,EAAE+B;AAAV;AAAlD,UAAP;AACD;;AAED,0BACE;AAAM,sBAAW,EAAjB;AAAoB,oBAAUP;AAA9B,SACG,6BAASA,OAAT,EAAkBC,OAAlB,CADH,CADF;AAKD;AAED;AACJ;AACA;;;AACI,QAAIrC,MAAM,CAACC,IAAP,KAAgB,QAApB,EAA8B;AAC5B,UAAMS,IAAI,GAAGV,MAAM,CAACtC,IAAP,CAAYY,GAAZ,CAAgB,MAAhB,CAAb;AAEA,0BAAO;AAAM,qBAAU,QAAhB;AAAyB,QAAA,uBAAuB,EAAE;AAAEsC,UAAAA,MAAM,EAAEF;AAAV;AAAlD,QAAP;AACD;AACF;AA7G0B,CAAtB","sourcesContent":["import Functions from '@material-ui/icons/Functions';\nimport { Inline } from 'slate';\nimport { MathPreview, MathToolbar } from '@pie-lib/math-toolbar';\nimport { wrapMath, unWrapMath, mmlToLatex, renderMath } from '@pie-lib/math-rendering';\nimport React from 'react';\nimport debug from 'debug';\nimport SlatePropTypes from 'slate-prop-types';\nimport PropTypes from 'prop-types';\n\nimport { BLOCK_TAGS } from '../../block-tags';\nimport isEqual from 'lodash/isEqual';\n\nconst log = debug('@pie-lib:editable-html:plugins:math');\n\nconst TEXT_NODE = 3;\n\nfunction generateAdditionalKeys(keyData = []) {\n return keyData.map((key) => ({\n name: key,\n latex: key,\n write: key,\n label: key,\n }));\n}\n\n// eslint-disable-next-line react/display-name\nexport const CustomToolbarComp = React.memo(\n (props) => {\n const { node, value, onFocus, onBlur, onClick } = props;\n const { pluginProps } = props || {};\n const { math } = pluginProps || {};\n const { keypadMode, customKeys, controlledKeypadMode = true } = math || {};\n\n const onDone = (latex) => {\n const update = {\n ...node.data.toObject(),\n latex,\n };\n\n const change = value.change().setNodeByKey(node.key, { data: update });\n\n const nextText = value.document.getNextText(node.key);\n\n change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);\n\n props.onToolbarDone(change, false);\n };\n\n const onChange = (latex) => {\n const update = {\n ...node.data.toObject(),\n latex,\n };\n const change = value.change().setNodeByKey(node.key, { data: update });\n log('call onToolbarChange:', change);\n props.onDataChange(node.key, update);\n };\n\n const latex = node.data.get('latex');\n\n return (\n <MathToolbar\n autoFocus\n additionalKeys={generateAdditionalKeys(customKeys)}\n latex={latex}\n onChange={onChange}\n onDone={onDone}\n onBlur={onBlur}\n onFocus={onFocus}\n onClick={onClick}\n keypadMode={keypadMode}\n controlledKeypadMode={controlledKeypadMode}\n />\n );\n },\n (prev, next) => {\n const { node, pluginProps: { math: { keypadMode, controlledKeypadMode } = {} } = {} } = prev;\n const {\n node: nodeNext,\n pluginProps: { math: { keypadMode: keypadModeNext, controlledKeypadMode: controlledKeypadModeNext } = {} } = {},\n } = next;\n const keypadModeChanged = keypadMode !== keypadModeNext;\n const controlledKeypadModeChanged = controlledKeypadMode !== controlledKeypadModeNext;\n\n const equal = node.equals(nodeNext);\n return equal && !keypadModeChanged && !controlledKeypadModeChanged;\n },\n);\n\nCustomToolbarComp.propTypes = {\n node: SlatePropTypes.node.isRequired,\n value: SlatePropTypes.value,\n onToolbarDone: PropTypes.func,\n onDataChange: PropTypes.func,\n onFocus: PropTypes.func,\n onClick: PropTypes.func,\n onBlur: PropTypes.func,\n};\n\nexport default function MathPlugin(opts) {\n MathPlugin.mathMlOptions = {\n mmlOutput: opts.mmlOutput,\n mmlEditing: opts.mmlEditing,\n };\n\n return {\n name: 'math',\n toolbar: {\n ariaLabel: 'Math Toolbar',\n icon: <Functions />,\n onClick: (value, onChange) => {\n log('[insertMath]');\n const math = inlineMath();\n const change = value.change().insertInline(math);\n onChange(change);\n },\n supports: (node) => node && node.object === 'inline' && node.type === 'math',\n /**\n * Return a react component function\n * @param node {Slate.Node}\n * @param value {Slate.Value}\n * @param onDone {(change?: Slate.Change, finishEditing :boolea) => void} - a function to call once the toolbar\n * has made any changes, call with the node.key and a data object.\n */\n CustomToolbarComp,\n },\n schema: {\n document: { match: [{ type: 'math' }] },\n },\n\n pluginStyles: (node, parentNode, p) => {\n if (p) {\n return {\n position: 'absolute',\n top: 'initial',\n };\n }\n },\n\n renderNode: (props) => {\n if (props.node.type === 'math') {\n log('[renderNode]: data:', props.node.data);\n return <MathPreview {...props} />;\n }\n\n /**\n * Here for rendering mathml content\n */\n if (props.node.type === 'mathml') {\n const html = props.node.data.get('html');\n\n return <span {...props.attributes} dangerouslySetInnerHTML={{ __html: html }} />;\n }\n },\n };\n}\n\nMathPlugin.ROUND_BRACKETS = 'round_brackets';\nMathPlugin.SQUARE_BRACKETS = 'square_brackets';\nMathPlugin.DOLLAR = 'dollar';\nMathPlugin.DOUBLE_DOLLAR = 'double_dollar';\nMathPlugin.mathMlOptions = {};\n\nMathPlugin.propTypes = {\n attributes: PropTypes.object,\n node: SlatePropTypes.node,\n};\n\nexport const inlineMath = () =>\n Inline.create({\n object: 'inline',\n type: 'math',\n isVoid: true,\n data: {\n latex: '',\n },\n });\n\nconst htmlDecode = (input) => {\n const doc = new DOMParser().parseFromString(input, 'text/html');\n\n return doc.documentElement.textContent;\n};\n\nconst getTagName = (el) => {\n return ((el && el.tagName) || '').toLowerCase();\n};\n\n/**\n * Makes sure that strings that contain stuff like:\n * x<y are not transformed into x by the DOMParser because it thinks\n * that <y is the start of a dom element tag\n * @param input\n * @returns {*}\n */\nconst arrowHandlingCase = (input) => {\n /*\n If we have a < character followed by a letter\n we make sure to replace it with a < sign instead\n */\n return input.replace(/<([a-zA-Z]*)/g, '<$1');\n};\n\nfunction replaceLeftRight(latexInput) {\n // for some reason, mmlToLatex parses () incorrectly - or at least in a way that our interpreter can not use them\n // Replace '\\\\left.' and '\\\\right.' with an empty string\n return latexInput.replace(/\\\\left\\.\\s*|\\\\right\\.\\s*/g, '');\n}\n\nconst convertLatexToMathMl = ({ latex, decoded, wrapper }) => {\n const removeEmptyMos = (mmlFromLatex) => {\n // Regular expression to match <mo>⁡</mo> and <mo ...>⁡</mo>, which get added when using log with base\n // not sure why they get added, but they add an extra space which is not needed\n const regex = /<mo(?: [^>]*)?>⁡<\\/mo>/g;\n\n // Replace all occurrences of the matched patterns\n return mmlFromLatex.replace(regex, '');\n };\n const handled = arrowHandlingCase(decoded);\n\n const latexToConvert = `<span data-latex=\"\" data-raw=\"${handled}\">${wrapMath(handled, wrapper)}</span>`;\n\n // use math rendering (MathJax) to convert latex to mathMl\n let mathMlFromLatex = renderMath(latexToConvert, {\n skipWaitForMathRenderingLib: true,\n });\n\n // if renderMath returned the exact same string that we sent, it just means that the conversion could not be done\n const conversionDidNotWork = isEqual(latexToConvert, mathMlFromLatex);\n\n mathMlFromLatex = removeEmptyMos(mathMlFromLatex);\n\n // we convert resulted mathml to latex to check if the resulted mathMl can be converted back to latex if user wants to edit it later\n const latexFromMathMl = mathMlFromLatex ? mmlToLatex(mathMlFromLatex) : '';\n\n // we need to remove all the spaces from the latex to be able to compare it\n const strippedL = latex.replace(/\\s/g, '');\n const strippedNewL = latexFromMathMl.replace(/\\s/g, '');\n\n // we check if the latex keeps his form after being converted to mathml and back to latex\n // if it does, we can safely convert it to mathml\n if (!isEqual(strippedL, strippedNewL)) {\n const correctedLatex = replaceLeftRight(latexFromMathMl);\n\n // As George requested in PD-3167, I will set the new mathML anyway, and also log differences\n // if it doesn't, we keep the latex version\n // eslint-disable-next-line no-console\n console.log('This latex can not be safely converted to mathml so we will keep the latex version!!!', {\n initialLatex: latex,\n newLatex: latexFromMathMl,\n correctedLatex,\n mathML: mathMlFromLatex,\n conversionDidNotWork,\n });\n }\n\n return { mathMlFromLatex, conversionDidNotWork };\n};\n\nconst convertMathMlToLatex = (mathMl) => {\n const htmlWithRemovedSpaces = mathMl.replaceAll(' ', ' ');\n const htmlToUse = mmlToLatex(htmlWithRemovedSpaces);\n const latex = htmlDecode(htmlToUse);\n\n // todo fix this in mathml-to-latex\n return replaceLeftRight(latex);\n};\n\nexport const serialization = {\n deserialize(el) {\n const tagName = getTagName(el);\n /**\n * This is used for when there's a wrapper over the mathml element.\n * Because of this slate rule: \"Only allow block nodes or inline and text nodes in blocks.\"\n * The element that contains only the mathml is removed (along with the math) because it has\n * an inline child and the block is of type block\n * This is for legacy content only since our math rendering is valid for the core slate rules\n */\n const hasMathChild = BLOCK_TAGS[tagName] && el.childNodes.length === 1 && getTagName(el.firstChild) === 'math';\n log('[deserialize] name: ', tagName);\n\n /**\n * This is here in order to be able to render mathml content\n */\n if (tagName === 'math' || (el.dataset && el.dataset.type === 'mathml') || hasMathChild) {\n const mathMl = hasMathChild ? el.innerHTML : el.outerHTML;\n\n if (MathPlugin.mathMlOptions.mmlEditing) {\n const { unwrapped, wrapType } = unWrapMath(convertMathMlToLatex(mathMl));\n\n return {\n object: 'inline',\n type: 'math',\n isVoid: true,\n nodes: [],\n data: {\n latex: unwrapped,\n wrapper: wrapType,\n },\n };\n }\n\n return {\n object: 'inline',\n isVoid: true,\n type: 'mathml',\n data: {\n html: mathMl,\n },\n };\n }\n\n if (el.nodeType === TEXT_NODE) {\n return;\n }\n\n if (tagName !== 'span') {\n return;\n }\n\n const hasLatex = el.hasAttribute('data-latex') || el.hasAttribute('latex');\n\n if (hasLatex) {\n const latex = htmlDecode(el.innerHTML);\n const { unwrapped, wrapType } = unWrapMath(latex);\n log('[deserialize]: noBrackets: ', unwrapped, wrapType);\n return {\n object: 'inline',\n type: 'math',\n isVoid: true,\n nodes: [],\n data: {\n latex: unwrapped,\n wrapper: wrapType,\n },\n };\n }\n },\n serialize(object) {\n if (object.type === 'math') {\n const latex = object.data.get('latex');\n const wrapper = object.data.get('wrapper');\n const decoded = htmlDecode(arrowHandlingCase(latex));\n\n log('[serialize] latex: ', latex);\n\n if (MathPlugin.mathMlOptions.mmlOutput) {\n const { mathMlFromLatex, conversionDidNotWork } = convertLatexToMathMl({ latex, decoded, wrapper });\n\n if (conversionDidNotWork) {\n // this means we could not convert latex to mathMl, so just return the latex version,\n // same as we would do if mmlOutput would not be enabled\n return (\n <span data-latex=\"\" data-raw={decoded}>\n {wrapMath(decoded, wrapper)}\n </span>\n );\n }\n\n return <span data-type=\"mathml\" dangerouslySetInnerHTML={{ __html: mathMlFromLatex }} />;\n }\n\n return (\n <span data-latex=\"\" data-raw={decoded}>\n {wrapMath(decoded, wrapper)}\n </span>\n );\n }\n\n /**\n * Here for rendering mathml content\n */\n if (object.type === 'mathml') {\n const html = object.data.get('html');\n\n return <span data-type=\"mathml\" dangerouslySetInnerHTML={{ __html: html }} />;\n }\n },\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Functions","_interopRequireDefault","require","_slate","_mathToolbar","_mathRendering","_react","_debug","_slatePropTypes","_propTypes","_blockTags","_isEqual","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","log","debug","TEXT_NODE","generateAdditionalKeys","keyData","undefined","map","key","name","latex","write","label","CustomToolbarComp","exports","React","memo","props","node","value","onFocus","onBlur","onClick","_ref","pluginProps","_ref2","math","_ref3","keypadMode","customKeys","_ref3$controlledKeypa","controlledKeypadMode","onDone","update","data","toObject","change","setNodeByKey","nextText","document","getNextText","moveFocusTo","moveAnchorTo","onToolbarDone","onChange","onDataChange","get","createElement","MathToolbar","autoFocus","additionalKeys","prev","next","_prev$pluginProps","_prev$pluginProps2","_prev$pluginProps2$ma","_prev$pluginProps2$ma2","nodeNext","_next$pluginProps","_next$pluginProps2","_next$pluginProps2$ma","_next$pluginProps2$ma2","keypadModeNext","controlledKeypadModeNext","keypadModeChanged","controlledKeypadModeChanged","equal","equals","propTypes","SlatePropTypes","isRequired","PropTypes","func","MathPlugin","opts","mathMlOptions","mmlOutput","mmlEditing","toolbar","ariaLabel","icon","inlineMath","insertInline","supports","object","type","schema","match","pluginStyles","parentNode","p","position","top","renderNode","MathPreview","html","_extends2","attributes","dangerouslySetInnerHTML","__html","ROUND_BRACKETS","SQUARE_BRACKETS","DOLLAR","DOUBLE_DOLLAR","Inline","create","isVoid","htmlDecode","input","doc","DOMParser","parseFromString","documentElement","textContent","getTagName","el","tagName","toLowerCase","arrowHandlingCase","replace","replaceLeftRight","latexInput","convertLatexToMathMl","_ref4","decoded","wrapper","removeEmptyMos","mmlFromLatex","regex","handled","latexToConvert","concat","wrapMath","mathMlFromLatex","renderMath","skipWaitForMathRenderingLib","conversionDidNotWork","isEqual","latexFromMathMl","mmlToLatex","strippedL","strippedNewL","correctedLatex","console","initialLatex","newLatex","mathML","convertMathMlToLatex","mathMl","htmlWithRemovedSpaces","replaceAll","htmlToUse","serialization","deserialize","hasMathChild","BLOCK_TAGS","childNodes","firstChild","dataset","innerHTML","outerHTML","_unWrapMath","unWrapMath","unwrapped","wrapType","nodes","nodeType","hasLatex","hasAttribute","_unWrapMath2","serialize","_convertLatexToMathMl"],"sources":["../../../src/plugins/math/index.jsx"],"sourcesContent":["import Functions from '@mui/icons-material/Functions';\nimport { Inline } from 'slate';\nimport { MathPreview, MathToolbar } from '@pie-lib/math-toolbar';\nimport { wrapMath, unWrapMath, mmlToLatex, renderMath } from '@pie-lib/math-rendering';\nimport React from 'react';\nimport debug from 'debug';\nimport SlatePropTypes from 'slate-prop-types';\nimport PropTypes from 'prop-types';\n\nimport { BLOCK_TAGS } from '../../block-tags';\nimport isEqual from 'lodash/isEqual';\n\nconst log = debug('@pie-lib:editable-html:plugins:math');\n\nconst TEXT_NODE = 3;\n\nfunction generateAdditionalKeys(keyData = []) {\n return keyData.map((key) => ({\n name: key,\n latex: key,\n write: key,\n label: key,\n }));\n}\n\n// eslint-disable-next-line react/display-name\nexport const CustomToolbarComp = React.memo(\n (props) => {\n const { node, value, onFocus, onBlur, onClick } = props;\n const { pluginProps } = props || {};\n const { math } = pluginProps || {};\n const { keypadMode, customKeys, controlledKeypadMode = true } = math || {};\n\n const onDone = (latex) => {\n const update = {\n ...node.data.toObject(),\n latex,\n };\n\n const change = value.change().setNodeByKey(node.key, { data: update });\n\n const nextText = value.document.getNextText(node.key);\n\n change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);\n\n props.onToolbarDone(change, false);\n };\n\n const onChange = (latex) => {\n const update = {\n ...node.data.toObject(),\n latex,\n };\n const change = value.change().setNodeByKey(node.key, { data: update });\n log('call onToolbarChange:', change);\n props.onDataChange(node.key, update);\n };\n\n const latex = node.data.get('latex');\n\n return (\n <MathToolbar\n autoFocus\n additionalKeys={generateAdditionalKeys(customKeys)}\n latex={latex}\n onChange={onChange}\n onDone={onDone}\n onBlur={onBlur}\n onFocus={onFocus}\n onClick={onClick}\n keypadMode={keypadMode}\n controlledKeypadMode={controlledKeypadMode}\n />\n );\n },\n (prev, next) => {\n const { node, pluginProps: { math: { keypadMode, controlledKeypadMode } = {} } = {} } = prev;\n const {\n node: nodeNext,\n pluginProps: { math: { keypadMode: keypadModeNext, controlledKeypadMode: controlledKeypadModeNext } = {} } = {},\n } = next;\n const keypadModeChanged = keypadMode !== keypadModeNext;\n const controlledKeypadModeChanged = controlledKeypadMode !== controlledKeypadModeNext;\n\n const equal = node.equals(nodeNext);\n return equal && !keypadModeChanged && !controlledKeypadModeChanged;\n },\n);\n\nCustomToolbarComp.propTypes = {\n node: SlatePropTypes.node.isRequired,\n value: SlatePropTypes.value,\n onToolbarDone: PropTypes.func,\n onDataChange: PropTypes.func,\n onFocus: PropTypes.func,\n onClick: PropTypes.func,\n onBlur: PropTypes.func,\n};\n\nexport default function MathPlugin(opts) {\n MathPlugin.mathMlOptions = {\n mmlOutput: opts.mmlOutput,\n mmlEditing: opts.mmlEditing,\n };\n\n return {\n name: 'math',\n toolbar: {\n ariaLabel: 'Math Toolbar',\n icon: <Functions />,\n onClick: (value, onChange) => {\n log('[insertMath]');\n const math = inlineMath();\n const change = value.change().insertInline(math);\n onChange(change);\n },\n supports: (node) => node && node.object === 'inline' && node.type === 'math',\n /**\n * Return a react component function\n * @param node {Slate.Node}\n * @param value {Slate.Value}\n * @param onDone {(change?: Slate.Change, finishEditing :boolea) => void} - a function to call once the toolbar\n * has made any changes, call with the node.key and a data object.\n */\n CustomToolbarComp,\n },\n schema: {\n document: { match: [{ type: 'math' }] },\n },\n\n pluginStyles: (node, parentNode, p) => {\n if (p) {\n return {\n position: 'absolute',\n top: 'initial',\n };\n }\n },\n\n renderNode: (props) => {\n if (props.node.type === 'math') {\n log('[renderNode]: data:', props.node.data);\n return <MathPreview {...props} />;\n }\n\n /**\n * Here for rendering mathml content\n */\n if (props.node.type === 'mathml') {\n const html = props.node.data.get('html');\n\n return <span {...props.attributes} dangerouslySetInnerHTML={{ __html: html }} />;\n }\n },\n };\n}\n\nMathPlugin.ROUND_BRACKETS = 'round_brackets';\nMathPlugin.SQUARE_BRACKETS = 'square_brackets';\nMathPlugin.DOLLAR = 'dollar';\nMathPlugin.DOUBLE_DOLLAR = 'double_dollar';\nMathPlugin.mathMlOptions = {};\n\nMathPlugin.propTypes = {\n attributes: PropTypes.object,\n node: SlatePropTypes.node,\n};\n\nexport const inlineMath = () =>\n Inline.create({\n object: 'inline',\n type: 'math',\n isVoid: true,\n data: {\n latex: '',\n },\n });\n\nconst htmlDecode = (input) => {\n const doc = new DOMParser().parseFromString(input, 'text/html');\n\n return doc.documentElement.textContent;\n};\n\nconst getTagName = (el) => {\n return ((el && el.tagName) || '').toLowerCase();\n};\n\n/**\n * Makes sure that strings that contain stuff like:\n * x<y are not transformed into x by the DOMParser because it thinks\n * that <y is the start of a dom element tag\n * @param input\n * @returns {*}\n */\nconst arrowHandlingCase = (input) => {\n /*\n If we have a < character followed by a letter\n we make sure to replace it with a < sign instead\n */\n return input.replace(/<([a-zA-Z]*)/g, '<$1');\n};\n\nfunction replaceLeftRight(latexInput) {\n // for some reason, mmlToLatex parses () incorrectly - or at least in a way that our interpreter can not use them\n // Replace '\\\\left.' and '\\\\right.' with an empty string\n return latexInput.replace(/\\\\left\\.\\s*|\\\\right\\.\\s*/g, '');\n}\n\nconst convertLatexToMathMl = ({ latex, decoded, wrapper }) => {\n const removeEmptyMos = (mmlFromLatex) => {\n // Regular expression to match <mo>⁡</mo> and <mo ...>⁡</mo>, which get added when using log with base\n // not sure why they get added, but they add an extra space which is not needed\n const regex = /<mo(?: [^>]*)?>⁡<\\/mo>/g;\n\n // Replace all occurrences of the matched patterns\n return mmlFromLatex.replace(regex, '');\n };\n const handled = arrowHandlingCase(decoded);\n\n const latexToConvert = `<span data-latex=\"\" data-raw=\"${handled}\">${wrapMath(handled, wrapper)}</span>`;\n\n // use math rendering (MathJax) to convert latex to mathMl\n let mathMlFromLatex = renderMath(latexToConvert, {\n skipWaitForMathRenderingLib: true,\n });\n\n // if renderMath returned the exact same string that we sent, it just means that the conversion could not be done\n const conversionDidNotWork = isEqual(latexToConvert, mathMlFromLatex);\n\n mathMlFromLatex = removeEmptyMos(mathMlFromLatex);\n\n // we convert resulted mathml to latex to check if the resulted mathMl can be converted back to latex if user wants to edit it later\n const latexFromMathMl = mathMlFromLatex ? mmlToLatex(mathMlFromLatex) : '';\n\n // we need to remove all the spaces from the latex to be able to compare it\n const strippedL = latex.replace(/\\s/g, '');\n const strippedNewL = latexFromMathMl.replace(/\\s/g, '');\n\n // we check if the latex keeps his form after being converted to mathml and back to latex\n // if it does, we can safely convert it to mathml\n if (!isEqual(strippedL, strippedNewL)) {\n const correctedLatex = replaceLeftRight(latexFromMathMl);\n\n // As George requested in PD-3167, I will set the new mathML anyway, and also log differences\n // if it doesn't, we keep the latex version\n // eslint-disable-next-line no-console\n console.log('This latex can not be safely converted to mathml so we will keep the latex version!!!', {\n initialLatex: latex,\n newLatex: latexFromMathMl,\n correctedLatex,\n mathML: mathMlFromLatex,\n conversionDidNotWork,\n });\n }\n\n return { mathMlFromLatex, conversionDidNotWork };\n};\n\nconst convertMathMlToLatex = (mathMl) => {\n const htmlWithRemovedSpaces = mathMl.replaceAll(' ', ' ');\n const htmlToUse = mmlToLatex(htmlWithRemovedSpaces);\n const latex = htmlDecode(htmlToUse);\n\n // todo fix this in mathml-to-latex\n return replaceLeftRight(latex);\n};\n\nexport const serialization = {\n deserialize(el) {\n const tagName = getTagName(el);\n /**\n * This is used for when there's a wrapper over the mathml element.\n * Because of this slate rule: \"Only allow block nodes or inline and text nodes in blocks.\"\n * The element that contains only the mathml is removed (along with the math) because it has\n * an inline child and the block is of type block\n * This is for legacy content only since our math rendering is valid for the core slate rules\n */\n const hasMathChild = BLOCK_TAGS[tagName] && el.childNodes.length === 1 && getTagName(el.firstChild) === 'math';\n log('[deserialize] name: ', tagName);\n\n /**\n * This is here in order to be able to render mathml content\n */\n if (tagName === 'math' || (el.dataset && el.dataset.type === 'mathml') || hasMathChild) {\n const mathMl = hasMathChild ? el.innerHTML : el.outerHTML;\n\n if (MathPlugin.mathMlOptions.mmlEditing) {\n const { unwrapped, wrapType } = unWrapMath(convertMathMlToLatex(mathMl));\n\n return {\n object: 'inline',\n type: 'math',\n isVoid: true,\n nodes: [],\n data: {\n latex: unwrapped,\n wrapper: wrapType,\n },\n };\n }\n\n return {\n object: 'inline',\n isVoid: true,\n type: 'mathml',\n data: {\n html: mathMl,\n },\n };\n }\n\n if (el.nodeType === TEXT_NODE) {\n return;\n }\n\n if (tagName !== 'span') {\n return;\n }\n\n const hasLatex = el.hasAttribute('data-latex') || el.hasAttribute('latex');\n\n if (hasLatex) {\n const latex = htmlDecode(el.innerHTML);\n const { unwrapped, wrapType } = unWrapMath(latex);\n log('[deserialize]: noBrackets: ', unwrapped, wrapType);\n return {\n object: 'inline',\n type: 'math',\n isVoid: true,\n nodes: [],\n data: {\n latex: unwrapped,\n wrapper: wrapType,\n },\n };\n }\n },\n serialize(object) {\n if (object.type === 'math') {\n const latex = object.data.get('latex');\n const wrapper = object.data.get('wrapper');\n const decoded = htmlDecode(arrowHandlingCase(latex));\n\n log('[serialize] latex: ', latex);\n\n if (MathPlugin.mathMlOptions.mmlOutput) {\n const { mathMlFromLatex, conversionDidNotWork } = convertLatexToMathMl({ latex, decoded, wrapper });\n\n if (conversionDidNotWork) {\n // this means we could not convert latex to mathMl, so just return the latex version,\n // same as we would do if mmlOutput would not be enabled\n return (\n <span data-latex=\"\" data-raw={decoded}>\n {wrapMath(decoded, wrapper)}\n </span>\n );\n }\n\n return <span data-type=\"mathml\" dangerouslySetInnerHTML={{ __html: mathMlFromLatex }} />;\n }\n\n return (\n <span data-latex=\"\" data-raw={decoded}>\n {wrapMath(decoded, wrapper)}\n </span>\n );\n }\n\n /**\n * Here for rendering mathml content\n */\n if (object.type === 'mathml') {\n const html = object.data.get('html');\n\n return <span data-type=\"mathml\" dangerouslySetInnerHTML={{ __html: html }} />;\n }\n },\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,eAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,UAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAV,sBAAA,CAAAC,OAAA;AAAqC,SAAAU,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,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