@pie-lib/editable-html 8.0.0 → 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.
Files changed (69) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/lib/editor.js +127 -69
  3. package/lib/editor.js.map +1 -1
  4. package/lib/index.js +30 -42
  5. package/lib/index.js.map +1 -1
  6. package/lib/plugins/characters/custom-popover.js +8 -11
  7. package/lib/plugins/characters/custom-popover.js.map +1 -1
  8. package/lib/plugins/characters/index.js +8 -18
  9. package/lib/plugins/characters/index.js.map +1 -1
  10. package/lib/plugins/image/component.js +31 -49
  11. package/lib/plugins/image/component.js.map +1 -1
  12. package/lib/plugins/image/image-toolbar.js +16 -27
  13. package/lib/plugins/image/image-toolbar.js.map +1 -1
  14. package/lib/plugins/image/index.js +5 -5
  15. package/lib/plugins/image/index.js.map +1 -1
  16. package/lib/plugins/image/insert-image-handler.js +8 -12
  17. package/lib/plugins/image/insert-image-handler.js.map +1 -1
  18. package/lib/plugins/index.js +6 -15
  19. package/lib/plugins/index.js.map +1 -1
  20. package/lib/plugins/list/index.js +2 -2
  21. package/lib/plugins/list/index.js.map +1 -1
  22. package/lib/plugins/math/index.js +8 -8
  23. package/lib/plugins/math/index.js.map +1 -1
  24. package/lib/plugins/media/index.js +15 -20
  25. package/lib/plugins/media/index.js.map +1 -1
  26. package/lib/plugins/media/media-dialog.js +26 -41
  27. package/lib/plugins/media/media-dialog.js.map +1 -1
  28. package/lib/plugins/media/media-toolbar.js +15 -25
  29. package/lib/plugins/media/media-toolbar.js.map +1 -1
  30. package/lib/plugins/media/media-wrapper.js +22 -35
  31. package/lib/plugins/media/media-wrapper.js.map +1 -1
  32. package/lib/plugins/respArea/drag-in-the-blank/choice.js +24 -37
  33. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
  34. package/lib/plugins/respArea/drag-in-the-blank/index.js +8 -8
  35. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
  36. package/lib/plugins/respArea/explicit-constructed-response/index.js +5 -5
  37. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
  38. package/lib/plugins/respArea/icons/index.js +5 -5
  39. package/lib/plugins/respArea/icons/index.js.map +1 -1
  40. package/lib/plugins/respArea/index.js +2 -2
  41. package/lib/plugins/respArea/index.js.map +1 -1
  42. package/lib/plugins/respArea/inline-dropdown/index.js +5 -5
  43. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
  44. package/lib/plugins/respArea/utils.js +2 -2
  45. package/lib/plugins/respArea/utils.js.map +1 -1
  46. package/lib/plugins/table/icons/index.js +9 -9
  47. package/lib/plugins/table/icons/index.js.map +1 -1
  48. package/lib/plugins/table/index.js +11 -11
  49. package/lib/plugins/table/index.js.map +1 -1
  50. package/lib/plugins/table/table-toolbar.js +25 -36
  51. package/lib/plugins/table/table-toolbar.js.map +1 -1
  52. package/lib/plugins/toolbar/default-toolbar.js +5 -5
  53. package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
  54. package/lib/plugins/toolbar/done-button.js +2 -2
  55. package/lib/plugins/toolbar/done-button.js.map +1 -1
  56. package/lib/plugins/toolbar/editor-and-toolbar.js +18 -30
  57. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
  58. package/lib/plugins/toolbar/index.js +5 -5
  59. package/lib/plugins/toolbar/index.js.map +1 -1
  60. package/lib/plugins/toolbar/toolbar-buttons.js +25 -43
  61. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
  62. package/lib/plugins/toolbar/toolbar.js +40 -52
  63. package/lib/plugins/toolbar/toolbar.js.map +1 -1
  64. package/lib/serialization.js +20 -3
  65. package/lib/serialization.js.map +1 -1
  66. package/package.json +2 -2
  67. package/src/editor.jsx +55 -9
  68. package/src/plugins/toolbar/toolbar.jsx +9 -2
  69. package/src/serialization.jsx +9 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
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
+
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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * running locally does not work ([e2fbb74](https://github.com/pie-framework/pie-lib/commit/e2fbb74c79bbb2ad6e9af447af51687391d89ad3))
23
+ * **editable-html:** fix image remove ([0f446b3](https://github.com/pie-framework/pie-lib/commit/0f446b38d93fec1548b9ff5c73cc48f2f10d9397))
24
+
25
+
26
+
27
+
28
+
29
+ # [8.1.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.0.0...@pie-lib/editable-html@8.1.0) (2022-06-27)
30
+
31
+
32
+ ### Features
33
+
34
+ * **editable-html:** allow drop & paste images PD-581 ([f7ec0d4](https://github.com/pie-framework/pie-lib/commit/f7ec0d4578ededc095422356471fb5e9f2b29af9))
35
+
36
+
37
+
38
+
39
+
6
40
  # [8.0.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.22.6...@pie-lib/editable-html@8.0.0) (2022-06-27)
7
41
 
8
42
 
package/lib/editor.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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) { _defineProperty(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; }
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 = {
@@ -97,18 +97,16 @@ var createToolbarOpts = function createToolbarOpts(toolbarOpts) {
97
97
  };
98
98
 
99
99
  var Editor = /*#__PURE__*/function (_React$Component) {
100
- _inherits(Editor, _React$Component);
100
+ (0, _inherits2["default"])(Editor, _React$Component);
101
101
 
102
102
  var _super = _createSuper(Editor);
103
103
 
104
104
  function Editor(_props) {
105
105
  var _this;
106
106
 
107
- _classCallCheck(this, Editor);
108
-
107
+ (0, _classCallCheck2["default"])(this, Editor);
109
108
  _this = _super.call(this, _props);
110
-
111
- _defineProperty(_assertThisInitialized(_this), "handlePlugins", function (props) {
109
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handlePlugins", function (props) {
112
110
  var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
113
111
 
114
112
  _this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, {
@@ -205,8 +203,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
205
203
  }
206
204
  });
207
205
  });
208
-
209
- _defineProperty(_assertThisInitialized(_this), "onPluginBlur", function (e) {
206
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginBlur", function (e) {
210
207
  log('[onPluginBlur]', e && e.relatedTarget);
211
208
  var target = e && e.relatedTarget;
212
209
  var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
@@ -218,8 +215,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
218
215
  _this.resetValue();
219
216
  });
220
217
  });
221
-
222
- _defineProperty(_assertThisInitialized(_this), "onPluginFocus", function (e) {
218
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginFocus", function (e) {
223
219
  log('[onPluginFocus]', e && e.target);
224
220
  var target = e && e.target;
225
221
 
@@ -240,8 +236,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
240
236
 
241
237
  _this.stashValue();
242
238
  });
243
-
244
- _defineProperty(_assertThisInitialized(_this), "onMathClick", function (node) {
239
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMathClick", function (node) {
245
240
  _this.editor.change(function (c) {
246
241
  return c.collapseToStartOf(node);
247
242
  });
@@ -250,8 +245,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
250
245
  selectedNode: node
251
246
  });
252
247
  });
253
-
254
- _defineProperty(_assertThisInitialized(_this), "onEditingDone", function () {
248
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditingDone", function () {
255
249
  log('[onEditingDone]');
256
250
 
257
251
  _this.setState({
@@ -263,8 +257,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
263
257
 
264
258
  _this.props.onChange(_this.state.value, true);
265
259
  });
266
-
267
- _defineProperty(_assertThisInitialized(_this), "handleBlur", function (resolve) {
260
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (resolve) {
268
261
  var nonEmpty = _this.props.nonEmpty;
269
262
  var doneOn = _this.state.toolbarOpts.doneOn;
270
263
 
@@ -291,8 +284,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
291
284
  }
292
285
  }
293
286
  });
294
-
295
- _defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
287
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (event) {
296
288
  log('[onBlur]');
297
289
  var target = event.relatedTarget;
298
290
  var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
@@ -300,13 +292,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
300
292
  return new Promise(function (resolve) {
301
293
  _this.setState({
302
294
  focusedNode: node
303
- }, _this.handleBlur.bind(_assertThisInitialized(_this), resolve));
295
+ }, _this.handleBlur.bind((0, _assertThisInitialized2["default"])(_this), resolve));
304
296
 
305
297
  _this.props.onBlur(event);
306
298
  });
307
299
  });
308
-
309
- _defineProperty(_assertThisInitialized(_this), "handleDomBlur", function (e) {
300
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDomBlur", function (e) {
310
301
  var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
311
302
  setTimeout(function () {
312
303
  if (!_this.wrapperRef) {
@@ -325,8 +316,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
325
316
  }
326
317
  }, 50);
327
318
  });
328
-
329
- _defineProperty(_assertThisInitialized(_this), "onFocus", function () {
319
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
330
320
  return new Promise(function (resolve) {
331
321
  var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
332
322
  log('[onFocus]', document.activeElement);
@@ -372,8 +362,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
372
362
  resolve();
373
363
  });
374
364
  });
375
-
376
- _defineProperty(_assertThisInitialized(_this), "stashValue", function () {
365
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stashValue", function () {
377
366
  log('[stashValue]');
378
367
 
379
368
  if (!_this.state.stashedValue) {
@@ -382,8 +371,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
382
371
  });
383
372
  }
384
373
  });
385
-
386
- _defineProperty(_assertThisInitialized(_this), "resetValue", function (force) {
374
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetValue", function (force) {
387
375
  var _this$state = _this.state,
388
376
  value = _this$state.value,
389
377
  focusedNode = _this$state.focusedNode;
@@ -417,8 +405,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
417
405
  return Promise.resolve({});
418
406
  }
419
407
  });
420
-
421
- _defineProperty(_assertThisInitialized(_this), "onChange", function (change, done) {
408
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (change, done) {
422
409
  log('[onChange]');
423
410
  var value = change.value;
424
411
  var charactersLimit = _this.props.charactersLimit;
@@ -437,8 +424,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
437
424
  }
438
425
  });
439
426
  });
440
-
441
- _defineProperty(_assertThisInitialized(_this), "valueToSize", function (v) {
427
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "valueToSize", function (v) {
442
428
  if (!v) {
443
429
  return;
444
430
  }
@@ -460,8 +446,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
460
446
 
461
447
  return;
462
448
  });
463
-
464
- _defineProperty(_assertThisInitialized(_this), "validateNode", function (node) {
449
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "validateNode", function (node) {
465
450
  if (node.object !== 'block') return;
466
451
  var last = node.nodes.last();
467
452
  if (!last) return;
@@ -474,8 +459,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
474
459
  log('[validateNode] parent:', parent, p);
475
460
  return undefined;
476
461
  });
477
-
478
- _defineProperty(_assertThisInitialized(_this), "changeData", function (key, data) {
462
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (key, data) {
479
463
  log('[changeData]. .. ', key, data);
480
464
  /**
481
465
  * HACK ALERT: We should be calling setState here and storing the change data:
@@ -494,13 +478,85 @@ var Editor = /*#__PURE__*/function (_React$Component) {
494
478
  data: data
495
479
  };
496
480
  });
497
-
498
- _defineProperty(_assertThisInitialized(_this), "focus", function (pos, node) {
481
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (pos, node) {
499
482
  var position = pos || 'end';
500
483
 
501
484
  _this.props.focus(position, node);
502
485
  });
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) {
490
+ while (1) {
491
+ switch (_context.prev = _context.next) {
492
+ case 0:
493
+ if (_this.props.imageSupport) {
494
+ _context.next = 2;
495
+ break;
496
+ }
497
+
498
+ return _context.abrupt("return");
499
+
500
+ case 2:
501
+ editor = change.editor;
502
+ transfer = (0, _slateReact.getEventTransfer)(event);
503
+ file = transfer.files[0];
504
+
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
+ }
534
+ }
535
+
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:
549
+ case "end":
550
+ return _context.stop();
551
+ }
552
+ }
553
+ }, _callee, null, [[6, 17]]);
554
+ }));
503
555
 
556
+ return function (_x, _x2, _x3) {
557
+ return _ref.apply(this, arguments);
558
+ };
559
+ }());
504
560
  _this.state = {
505
561
  value: _props.value,
506
562
  toolbarOpts: createToolbarOpts(_props.toolbarOpts)
@@ -515,7 +571,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
515
571
  return _this;
516
572
  }
517
573
 
518
- _createClass(Editor, [{
574
+ (0, _createClass2["default"])(Editor, [{
519
575
  key: "componentDidMount",
520
576
  value: function componentDidMount() {
521
577
  var _this2 = this;
@@ -621,10 +677,10 @@ var Editor = /*#__PURE__*/function (_React$Component) {
621
677
  toolbarOpts = _this$state2.toolbarOpts;
622
678
  log('[render] value: ', value);
623
679
  var sizeStyle = this.buildSizeStyle();
624
- var names = (0, _classnames["default"])((_classNames = {}, _defineProperty(_classNames, classes.withBg, highlightShape), _defineProperty(_classNames, classes.toolbarOnTop, toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'), _classNames), className);
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);
625
681
  return /*#__PURE__*/_react["default"].createElement("div", {
626
- ref: function ref(_ref) {
627
- return _this3.wrapperRef = _ref;
682
+ ref: function ref(_ref2) {
683
+ return _this3.wrapperRef = _ref2;
628
684
  },
629
685
  style: {
630
686
  width: sizeStyle.width
@@ -650,6 +706,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
650
706
  onKeyDown: onKeyDown,
651
707
  onChange: this.onChange,
652
708
  onBlur: this.onBlur,
709
+ onDrop: function onDrop(event, editor) {
710
+ return _this3.onDropPaste(event, editor, true);
711
+ },
712
+ onPaste: function onPaste(event, editor) {
713
+ return _this3.onDropPaste(event, editor);
714
+ },
653
715
  onFocus: this.onFocus,
654
716
  onEditingDone: this.onEditingDone,
655
717
  focusedNode: focusedNode,
@@ -669,14 +731,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
669
731
  }));
670
732
  }
671
733
  }]);
672
-
673
734
  return Editor;
674
735
  }(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
675
736
 
676
737
 
677
738
  exports.Editor = Editor;
678
-
679
- _defineProperty(Editor, "propTypes", {
739
+ (0, _defineProperty2["default"])(Editor, "propTypes", {
680
740
  autoFocus: _propTypes["default"].bool,
681
741
  editorRef: _propTypes["default"].func.isRequired,
682
742
  onRef: _propTypes["default"].func.isRequired,
@@ -729,8 +789,7 @@ _defineProperty(Editor, "propTypes", {
729
789
  maxImageWidth: _propTypes["default"].number,
730
790
  maxImageHeight: _propTypes["default"].number
731
791
  });
732
-
733
- _defineProperty(Editor, "defaultProps", {
792
+ (0, _defineProperty2["default"])(Editor, "defaultProps", {
734
793
  disableUnderline: true,
735
794
  onFocus: function onFocus() {},
736
795
  onBlur: function onBlur() {},
@@ -739,7 +798,6 @@ _defineProperty(Editor, "defaultProps", {
739
798
  responseAreaProps: defaultResponseAreaProps,
740
799
  languageCharactersProps: defaultLanguageCharactersProps
741
800
  });
742
-
743
801
  var styles = {
744
802
  withBg: {
745
803
  backgroundColor: 'rgba(0,0,0,0.06)'