@pie-lib/editable-html 8.1.1 → 8.1.2
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 +11 -0
- package/lib/editor.js +93 -107
- 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 +8 -18
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/image/component.js +31 -49
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +16 -27
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +5 -5
- 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 +2 -2
- package/src/editor.jsx +23 -23
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.1.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.1.1...@pie-lib/editable-html@8.1.2) (2022-06-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* running locally does not work ([ce2d09a](https://github.com/pie-framework/pie-lib/commit/ce2d09a3556937aea4a1c8075a2dbc7c1131fd5f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [8.1.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.1.0...@pie-lib/editable-html@8.1.1) (2022-06-28)
|
|
7
18
|
|
|
8
19
|
|
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,37 +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 asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
55
|
-
|
|
56
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
57
|
-
|
|
58
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
59
|
-
|
|
60
|
-
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); } }
|
|
61
|
-
|
|
62
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
63
|
-
|
|
64
|
-
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); }
|
|
65
|
-
|
|
66
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
67
|
-
|
|
68
|
-
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); }; }
|
|
69
|
-
|
|
70
|
-
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); }
|
|
71
|
-
|
|
72
|
-
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); }; }
|
|
73
73
|
|
|
74
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; } }
|
|
75
75
|
|
|
76
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
77
|
-
|
|
78
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; }
|
|
79
77
|
|
|
80
|
-
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) {
|
|
81
|
-
|
|
82
|
-
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; }
|
|
83
79
|
|
|
84
80
|
var log = (0, _debug["default"])('editable-html:editor');
|
|
85
81
|
var defaultToolbarOpts = {
|
|
@@ -101,18 +97,16 @@ var createToolbarOpts = function createToolbarOpts(toolbarOpts) {
|
|
|
101
97
|
};
|
|
102
98
|
|
|
103
99
|
var Editor = /*#__PURE__*/function (_React$Component) {
|
|
104
|
-
|
|
100
|
+
(0, _inherits2["default"])(Editor, _React$Component);
|
|
105
101
|
|
|
106
102
|
var _super = _createSuper(Editor);
|
|
107
103
|
|
|
108
104
|
function Editor(_props) {
|
|
109
105
|
var _this;
|
|
110
106
|
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
(0, _classCallCheck2["default"])(this, Editor);
|
|
113
108
|
_this = _super.call(this, _props);
|
|
114
|
-
|
|
115
|
-
_defineProperty(_assertThisInitialized(_this), "handlePlugins", function (props) {
|
|
109
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handlePlugins", function (props) {
|
|
116
110
|
var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
|
|
117
111
|
|
|
118
112
|
_this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, {
|
|
@@ -209,8 +203,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
209
203
|
}
|
|
210
204
|
});
|
|
211
205
|
});
|
|
212
|
-
|
|
213
|
-
_defineProperty(_assertThisInitialized(_this), "onPluginBlur", function (e) {
|
|
206
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginBlur", function (e) {
|
|
214
207
|
log('[onPluginBlur]', e && e.relatedTarget);
|
|
215
208
|
var target = e && e.relatedTarget;
|
|
216
209
|
var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
|
|
@@ -222,8 +215,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
222
215
|
_this.resetValue();
|
|
223
216
|
});
|
|
224
217
|
});
|
|
225
|
-
|
|
226
|
-
_defineProperty(_assertThisInitialized(_this), "onPluginFocus", function (e) {
|
|
218
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginFocus", function (e) {
|
|
227
219
|
log('[onPluginFocus]', e && e.target);
|
|
228
220
|
var target = e && e.target;
|
|
229
221
|
|
|
@@ -244,8 +236,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
244
236
|
|
|
245
237
|
_this.stashValue();
|
|
246
238
|
});
|
|
247
|
-
|
|
248
|
-
_defineProperty(_assertThisInitialized(_this), "onMathClick", function (node) {
|
|
239
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMathClick", function (node) {
|
|
249
240
|
_this.editor.change(function (c) {
|
|
250
241
|
return c.collapseToStartOf(node);
|
|
251
242
|
});
|
|
@@ -254,8 +245,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
254
245
|
selectedNode: node
|
|
255
246
|
});
|
|
256
247
|
});
|
|
257
|
-
|
|
258
|
-
_defineProperty(_assertThisInitialized(_this), "onEditingDone", function () {
|
|
248
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditingDone", function () {
|
|
259
249
|
log('[onEditingDone]');
|
|
260
250
|
|
|
261
251
|
_this.setState({
|
|
@@ -267,8 +257,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
267
257
|
|
|
268
258
|
_this.props.onChange(_this.state.value, true);
|
|
269
259
|
});
|
|
270
|
-
|
|
271
|
-
_defineProperty(_assertThisInitialized(_this), "handleBlur", function (resolve) {
|
|
260
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (resolve) {
|
|
272
261
|
var nonEmpty = _this.props.nonEmpty;
|
|
273
262
|
var doneOn = _this.state.toolbarOpts.doneOn;
|
|
274
263
|
|
|
@@ -295,8 +284,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
295
284
|
}
|
|
296
285
|
}
|
|
297
286
|
});
|
|
298
|
-
|
|
299
|
-
_defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
|
|
287
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (event) {
|
|
300
288
|
log('[onBlur]');
|
|
301
289
|
var target = event.relatedTarget;
|
|
302
290
|
var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
|
|
@@ -304,13 +292,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
304
292
|
return new Promise(function (resolve) {
|
|
305
293
|
_this.setState({
|
|
306
294
|
focusedNode: node
|
|
307
|
-
}, _this.handleBlur.bind(
|
|
295
|
+
}, _this.handleBlur.bind((0, _assertThisInitialized2["default"])(_this), resolve));
|
|
308
296
|
|
|
309
297
|
_this.props.onBlur(event);
|
|
310
298
|
});
|
|
311
299
|
});
|
|
312
|
-
|
|
313
|
-
_defineProperty(_assertThisInitialized(_this), "handleDomBlur", function (e) {
|
|
300
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDomBlur", function (e) {
|
|
314
301
|
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
315
302
|
setTimeout(function () {
|
|
316
303
|
if (!_this.wrapperRef) {
|
|
@@ -329,8 +316,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
329
316
|
}
|
|
330
317
|
}, 50);
|
|
331
318
|
});
|
|
332
|
-
|
|
333
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
|
|
319
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
|
|
334
320
|
return new Promise(function (resolve) {
|
|
335
321
|
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
336
322
|
log('[onFocus]', document.activeElement);
|
|
@@ -376,8 +362,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
376
362
|
resolve();
|
|
377
363
|
});
|
|
378
364
|
});
|
|
379
|
-
|
|
380
|
-
_defineProperty(_assertThisInitialized(_this), "stashValue", function () {
|
|
365
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stashValue", function () {
|
|
381
366
|
log('[stashValue]');
|
|
382
367
|
|
|
383
368
|
if (!_this.state.stashedValue) {
|
|
@@ -386,8 +371,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
386
371
|
});
|
|
387
372
|
}
|
|
388
373
|
});
|
|
389
|
-
|
|
390
|
-
_defineProperty(_assertThisInitialized(_this), "resetValue", function (force) {
|
|
374
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetValue", function (force) {
|
|
391
375
|
var _this$state = _this.state,
|
|
392
376
|
value = _this$state.value,
|
|
393
377
|
focusedNode = _this$state.focusedNode;
|
|
@@ -421,8 +405,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
421
405
|
return Promise.resolve({});
|
|
422
406
|
}
|
|
423
407
|
});
|
|
424
|
-
|
|
425
|
-
_defineProperty(_assertThisInitialized(_this), "onChange", function (change, done) {
|
|
408
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (change, done) {
|
|
426
409
|
log('[onChange]');
|
|
427
410
|
var value = change.value;
|
|
428
411
|
var charactersLimit = _this.props.charactersLimit;
|
|
@@ -441,8 +424,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
441
424
|
}
|
|
442
425
|
});
|
|
443
426
|
});
|
|
444
|
-
|
|
445
|
-
_defineProperty(_assertThisInitialized(_this), "valueToSize", function (v) {
|
|
427
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "valueToSize", function (v) {
|
|
446
428
|
if (!v) {
|
|
447
429
|
return;
|
|
448
430
|
}
|
|
@@ -464,8 +446,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
464
446
|
|
|
465
447
|
return;
|
|
466
448
|
});
|
|
467
|
-
|
|
468
|
-
_defineProperty(_assertThisInitialized(_this), "validateNode", function (node) {
|
|
449
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "validateNode", function (node) {
|
|
469
450
|
if (node.object !== 'block') return;
|
|
470
451
|
var last = node.nodes.last();
|
|
471
452
|
if (!last) return;
|
|
@@ -478,8 +459,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
478
459
|
log('[validateNode] parent:', parent, p);
|
|
479
460
|
return undefined;
|
|
480
461
|
});
|
|
481
|
-
|
|
482
|
-
_defineProperty(_assertThisInitialized(_this), "changeData", function (key, data) {
|
|
462
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (key, data) {
|
|
483
463
|
log('[changeData]. .. ', key, data);
|
|
484
464
|
/**
|
|
485
465
|
* HACK ALERT: We should be calling setState here and storing the change data:
|
|
@@ -498,17 +478,15 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
498
478
|
data: data
|
|
499
479
|
};
|
|
500
480
|
});
|
|
501
|
-
|
|
502
|
-
_defineProperty(_assertThisInitialized(_this), "focus", function (pos, node) {
|
|
481
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (pos, node) {
|
|
503
482
|
var position = pos || 'end';
|
|
504
483
|
|
|
505
484
|
_this.props.focus(position, node);
|
|
506
485
|
});
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
486
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDropPaste", /*#__PURE__*/function () {
|
|
487
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(event, change, dropContext) {
|
|
488
|
+
var editor, transfer, file, src, inline, range, ch;
|
|
489
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
512
490
|
while (1) {
|
|
513
491
|
switch (_context.prev = _context.next) {
|
|
514
492
|
case 0:
|
|
@@ -524,49 +502,61 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
524
502
|
transfer = (0, _slateReact.getEventTransfer)(event);
|
|
525
503
|
file = transfer.files[0];
|
|
526
504
|
|
|
527
|
-
if (file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png') {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
505
|
+
if (!(file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png')) {
|
|
506
|
+
_context.next = 20;
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
_context.prev = 6;
|
|
511
|
+
log('[onDropPaste]');
|
|
512
|
+
_context.next = 10;
|
|
513
|
+
return (0, serialization.getBase64)(file);
|
|
514
|
+
|
|
515
|
+
case 10:
|
|
516
|
+
src = _context.sent;
|
|
517
|
+
inline = _slate.Inline.create({
|
|
518
|
+
type: 'image',
|
|
519
|
+
isVoid: true,
|
|
520
|
+
data: {
|
|
521
|
+
loading: false,
|
|
522
|
+
src: src
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
if (dropContext) {
|
|
527
|
+
_this.focus();
|
|
528
|
+
} else {
|
|
529
|
+
range = (0, _slateReact.getEventRange)(event, editor);
|
|
530
|
+
|
|
531
|
+
if (range) {
|
|
532
|
+
change.select(range);
|
|
533
|
+
}
|
|
555
534
|
}
|
|
556
535
|
|
|
557
|
-
|
|
536
|
+
ch = change.insertInline(inline);
|
|
537
|
+
|
|
538
|
+
_this.onChange(ch);
|
|
539
|
+
|
|
540
|
+
_context.next = 20;
|
|
541
|
+
break;
|
|
542
|
+
|
|
543
|
+
case 17:
|
|
544
|
+
_context.prev = 17;
|
|
545
|
+
_context.t0 = _context["catch"](6);
|
|
546
|
+
log('[onDropPaste] error: ', _context.t0);
|
|
547
|
+
|
|
548
|
+
case 20:
|
|
558
549
|
case "end":
|
|
559
550
|
return _context.stop();
|
|
560
551
|
}
|
|
561
552
|
}
|
|
562
|
-
}, _callee);
|
|
553
|
+
}, _callee, null, [[6, 17]]);
|
|
563
554
|
}));
|
|
564
555
|
|
|
565
556
|
return function (_x, _x2, _x3) {
|
|
566
557
|
return _ref.apply(this, arguments);
|
|
567
558
|
};
|
|
568
559
|
}());
|
|
569
|
-
|
|
570
560
|
_this.state = {
|
|
571
561
|
value: _props.value,
|
|
572
562
|
toolbarOpts: createToolbarOpts(_props.toolbarOpts)
|
|
@@ -581,7 +571,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
581
571
|
return _this;
|
|
582
572
|
}
|
|
583
573
|
|
|
584
|
-
|
|
574
|
+
(0, _createClass2["default"])(Editor, [{
|
|
585
575
|
key: "componentDidMount",
|
|
586
576
|
value: function componentDidMount() {
|
|
587
577
|
var _this2 = this;
|
|
@@ -687,7 +677,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
687
677
|
toolbarOpts = _this$state2.toolbarOpts;
|
|
688
678
|
log('[render] value: ', value);
|
|
689
679
|
var sizeStyle = this.buildSizeStyle();
|
|
690
|
-
var names = (0, _classnames["default"])((_classNames = {},
|
|
680
|
+
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);
|
|
691
681
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
692
682
|
ref: function ref(_ref2) {
|
|
693
683
|
return _this3.wrapperRef = _ref2;
|
|
@@ -741,14 +731,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
741
731
|
}));
|
|
742
732
|
}
|
|
743
733
|
}]);
|
|
744
|
-
|
|
745
734
|
return Editor;
|
|
746
735
|
}(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
|
|
747
736
|
|
|
748
737
|
|
|
749
738
|
exports.Editor = Editor;
|
|
750
|
-
|
|
751
|
-
_defineProperty(Editor, "propTypes", {
|
|
739
|
+
(0, _defineProperty2["default"])(Editor, "propTypes", {
|
|
752
740
|
autoFocus: _propTypes["default"].bool,
|
|
753
741
|
editorRef: _propTypes["default"].func.isRequired,
|
|
754
742
|
onRef: _propTypes["default"].func.isRequired,
|
|
@@ -801,8 +789,7 @@ _defineProperty(Editor, "propTypes", {
|
|
|
801
789
|
maxImageWidth: _propTypes["default"].number,
|
|
802
790
|
maxImageHeight: _propTypes["default"].number
|
|
803
791
|
});
|
|
804
|
-
|
|
805
|
-
_defineProperty(Editor, "defaultProps", {
|
|
792
|
+
(0, _defineProperty2["default"])(Editor, "defaultProps", {
|
|
806
793
|
disableUnderline: true,
|
|
807
794
|
onFocus: function onFocus() {},
|
|
808
795
|
onBlur: function onBlur() {},
|
|
@@ -811,7 +798,6 @@ _defineProperty(Editor, "defaultProps", {
|
|
|
811
798
|
responseAreaProps: defaultResponseAreaProps,
|
|
812
799
|
languageCharactersProps: defaultLanguageCharactersProps
|
|
813
800
|
});
|
|
814
|
-
|
|
815
801
|
var styles = {
|
|
816
802
|
withBg: {
|
|
817
803
|
backgroundColor: 'rgba(0,0,0,0.06)'
|