@pie-lib/editable-html 7.17.4-next.373 → 7.17.4-next.417
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/lib/editor.js +147 -109
- package/lib/editor.js.map +1 -1
- package/lib/index.js +30 -42
- package/lib/index.js.map +1 -1
- package/lib/plugins/characters/custom-popover.js +8 -11
- package/lib/plugins/characters/custom-popover.js.map +1 -1
- package/lib/plugins/characters/index.js +14 -19
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +24 -4
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/image/component.js +65 -54
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +65 -27
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +47 -12
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +8 -12
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +6 -15
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +2 -2
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +8 -8
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +15 -20
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +26 -41
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +15 -25
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +22 -35
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +24 -37
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +8 -8
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +5 -5
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +5 -5
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +2 -2
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +5 -5
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +2 -2
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +9 -9
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +11 -11
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +25 -36
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +5 -5
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +2 -2
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +18 -30
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +5 -5
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +25 -43
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +30 -49
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/serialization.js +2 -2
- package/lib/serialization.js.map +1 -1
- package/package.json +3 -3
- package/src/editor.jsx +55 -37
- package/src/plugins/characters/index.jsx +7 -0
- package/src/plugins/characters/utils.js +8 -4
- package/src/plugins/image/component.jsx +49 -20
- package/src/plugins/image/image-toolbar.jsx +37 -2
- package/src/plugins/image/index.jsx +38 -9
package/lib/editor.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
@@ -19,6 +21,24 @@ Object.defineProperty(exports, "DEFAULT_PLUGINS", {
|
|
|
19
21
|
});
|
|
20
22
|
exports.serialization = exports["default"] = exports.Editor = void 0;
|
|
21
23
|
|
|
24
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
25
|
+
|
|
26
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
27
|
+
|
|
28
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
29
|
+
|
|
30
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
31
|
+
|
|
32
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
33
|
+
|
|
34
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
35
|
+
|
|
36
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
37
|
+
|
|
38
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
39
|
+
|
|
40
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
41
|
+
|
|
22
42
|
var _slateReact = require("slate-react");
|
|
23
43
|
|
|
24
44
|
var _slatePropTypes = _interopRequireDefault(require("slate-prop-types"));
|
|
@@ -49,33 +69,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
49
69
|
|
|
50
70
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
51
71
|
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
55
|
-
|
|
56
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
57
|
-
|
|
58
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
59
|
-
|
|
60
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
61
|
-
|
|
62
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
63
|
-
|
|
64
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
65
|
-
|
|
66
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
67
|
-
|
|
68
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
72
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
69
73
|
|
|
70
74
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
71
75
|
|
|
72
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
73
|
-
|
|
74
76
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
75
77
|
|
|
76
|
-
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) {
|
|
77
|
-
|
|
78
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
78
|
+
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; }
|
|
79
79
|
|
|
80
80
|
var log = (0, _debug["default"])('editable-html:editor');
|
|
81
81
|
var defaultToolbarOpts = {
|
|
@@ -90,25 +90,27 @@ var defaultResponseAreaProps = {
|
|
|
90
90
|
respAreaToolbar: function respAreaToolbar() {},
|
|
91
91
|
onHandleAreaChange: function onHandleAreaChange() {}
|
|
92
92
|
};
|
|
93
|
-
var defaultLanguageCharactersProps = [
|
|
93
|
+
var defaultLanguageCharactersProps = [{
|
|
94
|
+
language: 'spanish'
|
|
95
|
+
}, {
|
|
96
|
+
language: 'special'
|
|
97
|
+
}];
|
|
94
98
|
|
|
95
99
|
var createToolbarOpts = function createToolbarOpts(toolbarOpts) {
|
|
96
100
|
return _objectSpread(_objectSpread({}, defaultToolbarOpts), toolbarOpts);
|
|
97
101
|
};
|
|
98
102
|
|
|
99
103
|
var Editor = /*#__PURE__*/function (_React$Component) {
|
|
100
|
-
|
|
104
|
+
(0, _inherits2["default"])(Editor, _React$Component);
|
|
101
105
|
|
|
102
106
|
var _super = _createSuper(Editor);
|
|
103
107
|
|
|
104
108
|
function Editor(_props) {
|
|
105
109
|
var _this;
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
(0, _classCallCheck2["default"])(this, Editor);
|
|
109
112
|
_this = _super.call(this, _props);
|
|
110
|
-
|
|
111
|
-
_defineProperty(_assertThisInitialized(_this), "handlePlugins", function (props) {
|
|
113
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handlePlugins", function (props) {
|
|
112
114
|
var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
|
|
113
115
|
|
|
114
116
|
_this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, {
|
|
@@ -205,8 +207,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
205
207
|
}
|
|
206
208
|
});
|
|
207
209
|
});
|
|
208
|
-
|
|
209
|
-
_defineProperty(_assertThisInitialized(_this), "onPluginBlur", function (e) {
|
|
210
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginBlur", function (e) {
|
|
210
211
|
log('[onPluginBlur]', e && e.relatedTarget);
|
|
211
212
|
var target = e && e.relatedTarget;
|
|
212
213
|
var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
|
|
@@ -218,8 +219,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
218
219
|
_this.resetValue();
|
|
219
220
|
});
|
|
220
221
|
});
|
|
221
|
-
|
|
222
|
-
_defineProperty(_assertThisInitialized(_this), "onPluginFocus", function (e) {
|
|
222
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginFocus", function (e) {
|
|
223
223
|
log('[onPluginFocus]', e && e.target);
|
|
224
224
|
var target = e && e.target;
|
|
225
225
|
|
|
@@ -240,8 +240,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
240
240
|
|
|
241
241
|
_this.stashValue();
|
|
242
242
|
});
|
|
243
|
-
|
|
244
|
-
_defineProperty(_assertThisInitialized(_this), "onMathClick", function (node) {
|
|
243
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMathClick", function (node) {
|
|
245
244
|
_this.editor.change(function (c) {
|
|
246
245
|
return c.collapseToStartOf(node);
|
|
247
246
|
});
|
|
@@ -250,8 +249,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
250
249
|
selectedNode: node
|
|
251
250
|
});
|
|
252
251
|
});
|
|
253
|
-
|
|
254
|
-
_defineProperty(_assertThisInitialized(_this), "onEditingDone", function () {
|
|
252
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditingDone", function () {
|
|
255
253
|
log('[onEditingDone]');
|
|
256
254
|
|
|
257
255
|
_this.setState({
|
|
@@ -263,8 +261,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
263
261
|
|
|
264
262
|
_this.props.onChange(_this.state.value, true);
|
|
265
263
|
});
|
|
266
|
-
|
|
267
|
-
_defineProperty(_assertThisInitialized(_this), "handleBlur", function (resolve) {
|
|
264
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (resolve) {
|
|
268
265
|
var nonEmpty = _this.props.nonEmpty;
|
|
269
266
|
var doneOn = _this.state.toolbarOpts.doneOn;
|
|
270
267
|
|
|
@@ -291,8 +288,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
291
288
|
}
|
|
292
289
|
}
|
|
293
290
|
});
|
|
294
|
-
|
|
295
|
-
_defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
|
|
291
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (event) {
|
|
296
292
|
log('[onBlur]');
|
|
297
293
|
var target = event.relatedTarget;
|
|
298
294
|
var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
|
|
@@ -300,13 +296,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
300
296
|
return new Promise(function (resolve) {
|
|
301
297
|
_this.setState({
|
|
302
298
|
focusedNode: node
|
|
303
|
-
}, _this.handleBlur.bind(
|
|
299
|
+
}, _this.handleBlur.bind((0, _assertThisInitialized2["default"])(_this), resolve));
|
|
304
300
|
|
|
305
301
|
_this.props.onBlur(event);
|
|
306
302
|
});
|
|
307
303
|
});
|
|
308
|
-
|
|
309
|
-
_defineProperty(_assertThisInitialized(_this), "handleDomBlur", function (e) {
|
|
304
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDomBlur", function (e) {
|
|
310
305
|
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
311
306
|
setTimeout(function () {
|
|
312
307
|
if (!_this.wrapperRef) {
|
|
@@ -325,8 +320,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
325
320
|
}
|
|
326
321
|
}, 50);
|
|
327
322
|
});
|
|
328
|
-
|
|
329
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
|
|
323
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
|
|
330
324
|
return new Promise(function (resolve) {
|
|
331
325
|
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
332
326
|
log('[onFocus]', document.activeElement);
|
|
@@ -372,8 +366,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
372
366
|
resolve();
|
|
373
367
|
});
|
|
374
368
|
});
|
|
375
|
-
|
|
376
|
-
_defineProperty(_assertThisInitialized(_this), "stashValue", function () {
|
|
369
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stashValue", function () {
|
|
377
370
|
log('[stashValue]');
|
|
378
371
|
|
|
379
372
|
if (!_this.state.stashedValue) {
|
|
@@ -382,8 +375,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
382
375
|
});
|
|
383
376
|
}
|
|
384
377
|
});
|
|
385
|
-
|
|
386
|
-
_defineProperty(_assertThisInitialized(_this), "resetValue", function (force) {
|
|
378
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetValue", function (force) {
|
|
387
379
|
var _this$state = _this.state,
|
|
388
380
|
value = _this$state.value,
|
|
389
381
|
focusedNode = _this$state.focusedNode;
|
|
@@ -417,8 +409,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
417
409
|
return Promise.resolve({});
|
|
418
410
|
}
|
|
419
411
|
});
|
|
420
|
-
|
|
421
|
-
_defineProperty(_assertThisInitialized(_this), "onChange", function (change, done) {
|
|
412
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (change, done) {
|
|
422
413
|
log('[onChange]');
|
|
423
414
|
var value = change.value;
|
|
424
415
|
var charactersLimit = _this.props.charactersLimit;
|
|
@@ -437,8 +428,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
437
428
|
}
|
|
438
429
|
});
|
|
439
430
|
});
|
|
440
|
-
|
|
441
|
-
_defineProperty(_assertThisInitialized(_this), "valueToSize", function (v) {
|
|
431
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "valueToSize", function (v) {
|
|
442
432
|
if (!v) {
|
|
443
433
|
return;
|
|
444
434
|
}
|
|
@@ -460,8 +450,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
460
450
|
|
|
461
451
|
return;
|
|
462
452
|
});
|
|
463
|
-
|
|
464
|
-
_defineProperty(_assertThisInitialized(_this), "validateNode", function (node) {
|
|
453
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "validateNode", function (node) {
|
|
465
454
|
if (node.object !== 'block') return;
|
|
466
455
|
var last = node.nodes.last();
|
|
467
456
|
if (!last) return;
|
|
@@ -474,8 +463,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
474
463
|
log('[validateNode] parent:', parent, p);
|
|
475
464
|
return undefined;
|
|
476
465
|
});
|
|
477
|
-
|
|
478
|
-
_defineProperty(_assertThisInitialized(_this), "changeData", function (key, data) {
|
|
466
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (key, data) {
|
|
479
467
|
log('[changeData]. .. ', key, data);
|
|
480
468
|
/**
|
|
481
469
|
* HACK ALERT: We should be calling setState here and storing the change data:
|
|
@@ -494,53 +482,85 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
494
482
|
data: data
|
|
495
483
|
};
|
|
496
484
|
});
|
|
497
|
-
|
|
498
|
-
_defineProperty(_assertThisInitialized(_this), "focus", function (pos, node) {
|
|
485
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (pos, node) {
|
|
499
486
|
var position = pos || 'end';
|
|
500
487
|
|
|
501
488
|
_this.props.focus(position, node);
|
|
502
489
|
});
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
return
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
490
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDropPaste", /*#__PURE__*/function () {
|
|
491
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(event, change, dropContext) {
|
|
492
|
+
var editor, transfer, file, src, inline, range, ch;
|
|
493
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
494
|
+
while (1) {
|
|
495
|
+
switch (_context.prev = _context.next) {
|
|
496
|
+
case 0:
|
|
497
|
+
if (_this.props.imageSupport) {
|
|
498
|
+
_context.next = 2;
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return _context.abrupt("return");
|
|
503
|
+
|
|
504
|
+
case 2:
|
|
505
|
+
editor = change.editor;
|
|
506
|
+
transfer = (0, _slateReact.getEventTransfer)(event);
|
|
507
|
+
file = transfer.files[0];
|
|
508
|
+
|
|
509
|
+
if (!(file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png')) {
|
|
510
|
+
_context.next = 20;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
_context.prev = 6;
|
|
515
|
+
log('[onDropPaste]');
|
|
516
|
+
_context.next = 10;
|
|
517
|
+
return (0, serialization.getBase64)(file);
|
|
518
|
+
|
|
519
|
+
case 10:
|
|
520
|
+
src = _context.sent;
|
|
521
|
+
inline = _slate.Inline.create({
|
|
522
|
+
type: 'image',
|
|
523
|
+
isVoid: true,
|
|
524
|
+
data: {
|
|
525
|
+
loading: false,
|
|
526
|
+
src: src
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
if (dropContext) {
|
|
531
|
+
_this.focus();
|
|
532
|
+
} else {
|
|
533
|
+
range = (0, _slateReact.getEventRange)(event, editor);
|
|
534
|
+
|
|
535
|
+
if (range) {
|
|
536
|
+
change.select(range);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
ch = change.insertInline(inline);
|
|
541
|
+
|
|
542
|
+
_this.onChange(ch);
|
|
543
|
+
|
|
544
|
+
_context.next = 20;
|
|
545
|
+
break;
|
|
546
|
+
|
|
547
|
+
case 17:
|
|
548
|
+
_context.prev = 17;
|
|
549
|
+
_context.t0 = _context["catch"](6);
|
|
550
|
+
log('[onDropPaste] error: ', _context.t0);
|
|
551
|
+
|
|
552
|
+
case 20:
|
|
553
|
+
case "end":
|
|
554
|
+
return _context.stop();
|
|
532
555
|
}
|
|
533
556
|
}
|
|
557
|
+
}, _callee, null, [[6, 17]]);
|
|
558
|
+
}));
|
|
534
559
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return log('[onDropPaste] error: ', err);
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
|
|
560
|
+
return function (_x, _x2, _x3) {
|
|
561
|
+
return _ref.apply(this, arguments);
|
|
562
|
+
};
|
|
563
|
+
}());
|
|
544
564
|
_this.state = {
|
|
545
565
|
value: _props.value,
|
|
546
566
|
toolbarOpts: createToolbarOpts(_props.toolbarOpts)
|
|
@@ -555,7 +575,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
555
575
|
return _this;
|
|
556
576
|
}
|
|
557
577
|
|
|
558
|
-
|
|
578
|
+
(0, _createClass2["default"])(Editor, [{
|
|
559
579
|
key: "componentDidMount",
|
|
560
580
|
value: function componentDidMount() {
|
|
561
581
|
var _this2 = this;
|
|
@@ -661,10 +681,10 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
661
681
|
toolbarOpts = _this$state2.toolbarOpts;
|
|
662
682
|
log('[render] value: ', value);
|
|
663
683
|
var sizeStyle = this.buildSizeStyle();
|
|
664
|
-
var names = (0, _classnames["default"])((_classNames = {},
|
|
684
|
+
var names = (0, _classnames["default"])((_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.withBg, highlightShape), (0, _defineProperty2["default"])(_classNames, classes.toolbarOnTop, toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'), _classNames), className);
|
|
665
685
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
666
|
-
ref: function ref(
|
|
667
|
-
return _this3.wrapperRef =
|
|
686
|
+
ref: function ref(_ref2) {
|
|
687
|
+
return _this3.wrapperRef = _ref2;
|
|
668
688
|
},
|
|
669
689
|
style: {
|
|
670
690
|
width: sizeStyle.width
|
|
@@ -715,14 +735,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
715
735
|
}));
|
|
716
736
|
}
|
|
717
737
|
}]);
|
|
718
|
-
|
|
719
738
|
return Editor;
|
|
720
739
|
}(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
|
|
721
740
|
|
|
722
741
|
|
|
723
742
|
exports.Editor = Editor;
|
|
724
|
-
|
|
725
|
-
_defineProperty(Editor, "propTypes", {
|
|
743
|
+
(0, _defineProperty2["default"])(Editor, "propTypes", {
|
|
726
744
|
autoFocus: _propTypes["default"].bool,
|
|
727
745
|
editorRef: _propTypes["default"].func.isRequired,
|
|
728
746
|
onRef: _propTypes["default"].func.isRequired,
|
|
@@ -775,8 +793,7 @@ _defineProperty(Editor, "propTypes", {
|
|
|
775
793
|
maxImageWidth: _propTypes["default"].number,
|
|
776
794
|
maxImageHeight: _propTypes["default"].number
|
|
777
795
|
});
|
|
778
|
-
|
|
779
|
-
_defineProperty(Editor, "defaultProps", {
|
|
796
|
+
(0, _defineProperty2["default"])(Editor, "defaultProps", {
|
|
780
797
|
disableUnderline: true,
|
|
781
798
|
onFocus: function onFocus() {},
|
|
782
799
|
onBlur: function onBlur() {},
|
|
@@ -785,7 +802,6 @@ _defineProperty(Editor, "defaultProps", {
|
|
|
785
802
|
responseAreaProps: defaultResponseAreaProps,
|
|
786
803
|
languageCharactersProps: defaultLanguageCharactersProps
|
|
787
804
|
});
|
|
788
|
-
|
|
789
805
|
var styles = {
|
|
790
806
|
withBg: {
|
|
791
807
|
backgroundColor: 'rgba(0,0,0,0.06)'
|
|
@@ -812,7 +828,29 @@ var styles = {
|
|
|
812
828
|
},
|
|
813
829
|
'& table:not([border="1"]) td, th': {
|
|
814
830
|
border: '1px solid #dfe2e5'
|
|
815
|
-
}
|
|
831
|
+
},
|
|
832
|
+
'& .RawMathPreview-root-143 *': {
|
|
833
|
+
fontFamily: 'MJXZERO, MJXTEX !important'
|
|
834
|
+
},
|
|
835
|
+
'& .mq-math-mode var, .mq-math-mode i, .mq-math-mode i.mq-font': {
|
|
836
|
+
fontFamily: 'MJXZERO, MJXTEX-I !important'
|
|
837
|
+
},
|
|
838
|
+
'& .mq-math-mode .mq-sqrt-stem': {
|
|
839
|
+
borderTop: '0.07em solid',
|
|
840
|
+
marginLeft: '-1.5px',
|
|
841
|
+
marginTop: '-2px !important',
|
|
842
|
+
paddingTop: '5px !important'
|
|
843
|
+
},
|
|
844
|
+
'& .mq-supsub ': {
|
|
845
|
+
fontSize: '70.7%'
|
|
846
|
+
},
|
|
847
|
+
'& .mq-math-mode .mq-supsub.mq-sup-only': {
|
|
848
|
+
verticalAlign: '-0.1em !important',
|
|
849
|
+
'& .mq-sup': {
|
|
850
|
+
marginBottom: '0px !important'
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
'-webkit-font-smoothing': 'antialiased !important'
|
|
816
854
|
},
|
|
817
855
|
toolbarOnTop: {
|
|
818
856
|
marginTop: '45px'
|