@pie-lib/editable-html 8.1.1 → 9.0.1

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 (76) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/lib/editor.js +104 -110
  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 +14 -19
  9. package/lib/plugins/characters/index.js.map +1 -1
  10. package/lib/plugins/characters/utils.js +24 -4
  11. package/lib/plugins/characters/utils.js.map +1 -1
  12. package/lib/plugins/image/component.js +65 -54
  13. package/lib/plugins/image/component.js.map +1 -1
  14. package/lib/plugins/image/image-toolbar.js +65 -27
  15. package/lib/plugins/image/image-toolbar.js.map +1 -1
  16. package/lib/plugins/image/index.js +47 -12
  17. package/lib/plugins/image/index.js.map +1 -1
  18. package/lib/plugins/image/insert-image-handler.js +8 -12
  19. package/lib/plugins/image/insert-image-handler.js.map +1 -1
  20. package/lib/plugins/index.js +6 -15
  21. package/lib/plugins/index.js.map +1 -1
  22. package/lib/plugins/list/index.js +2 -2
  23. package/lib/plugins/list/index.js.map +1 -1
  24. package/lib/plugins/math/index.js +8 -8
  25. package/lib/plugins/math/index.js.map +1 -1
  26. package/lib/plugins/media/index.js +15 -20
  27. package/lib/plugins/media/index.js.map +1 -1
  28. package/lib/plugins/media/media-dialog.js +26 -41
  29. package/lib/plugins/media/media-dialog.js.map +1 -1
  30. package/lib/plugins/media/media-toolbar.js +15 -25
  31. package/lib/plugins/media/media-toolbar.js.map +1 -1
  32. package/lib/plugins/media/media-wrapper.js +22 -35
  33. package/lib/plugins/media/media-wrapper.js.map +1 -1
  34. package/lib/plugins/respArea/drag-in-the-blank/choice.js +24 -37
  35. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
  36. package/lib/plugins/respArea/drag-in-the-blank/index.js +8 -8
  37. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
  38. package/lib/plugins/respArea/explicit-constructed-response/index.js +5 -5
  39. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
  40. package/lib/plugins/respArea/icons/index.js +5 -5
  41. package/lib/plugins/respArea/icons/index.js.map +1 -1
  42. package/lib/plugins/respArea/index.js +7 -2
  43. package/lib/plugins/respArea/index.js.map +1 -1
  44. package/lib/plugins/respArea/inline-dropdown/index.js +5 -5
  45. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
  46. package/lib/plugins/respArea/utils.js +2 -2
  47. package/lib/plugins/respArea/utils.js.map +1 -1
  48. package/lib/plugins/table/icons/index.js +9 -9
  49. package/lib/plugins/table/icons/index.js.map +1 -1
  50. package/lib/plugins/table/index.js +15 -13
  51. package/lib/plugins/table/index.js.map +1 -1
  52. package/lib/plugins/table/table-toolbar.js +25 -36
  53. package/lib/plugins/table/table-toolbar.js.map +1 -1
  54. package/lib/plugins/toolbar/default-toolbar.js +5 -5
  55. package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
  56. package/lib/plugins/toolbar/done-button.js +2 -2
  57. package/lib/plugins/toolbar/done-button.js.map +1 -1
  58. package/lib/plugins/toolbar/editor-and-toolbar.js +18 -30
  59. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
  60. package/lib/plugins/toolbar/index.js +5 -5
  61. package/lib/plugins/toolbar/index.js.map +1 -1
  62. package/lib/plugins/toolbar/toolbar-buttons.js +25 -43
  63. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
  64. package/lib/plugins/toolbar/toolbar.js +30 -49
  65. package/lib/plugins/toolbar/toolbar.js.map +1 -1
  66. package/lib/serialization.js +2 -2
  67. package/lib/serialization.js.map +1 -1
  68. package/package.json +5 -5
  69. package/src/editor.jsx +33 -38
  70. package/src/plugins/characters/index.jsx +7 -0
  71. package/src/plugins/characters/utils.js +8 -4
  72. package/src/plugins/image/component.jsx +49 -20
  73. package/src/plugins/image/image-toolbar.jsx +38 -2
  74. package/src/plugins/image/index.jsx +38 -9
  75. package/src/plugins/respArea/index.jsx +5 -0
  76. package/src/plugins/table/index.jsx +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,62 @@
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
+ ## [9.0.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@9.0.0...@pie-lib/editable-html@9.0.1) (2022-07-18)
7
+
8
+
9
+ ### Reverts
10
+
11
+ * Revert "feat(editable-html): Make editable-html style inline with mathjax: font, radical, exponential, italicize variables PD-1521" ([c07213c](https://github.com/pie-framework/pie-lib/commit/c07213c627609a47089f9cfec1e16366fc5dcfd3))
12
+
13
+
14
+
15
+
16
+
17
+ # [9.0.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.1.2...@pie-lib/editable-html@9.0.0) (2022-07-18)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **editable-html:** add another sanity checks ([d872981](https://github.com/pie-framework/pie-lib/commit/d87298124408b55d75d42598c0272294a0881043))
23
+ * **editable-html:** add sanity check for drop / paste file - sentry ([d27d252](https://github.com/pie-framework/pie-lib/commit/d27d2522d0567333e0af1ce49a3793ebc44ef032))
24
+ * **editable-html:** add sanity check in respArea - toolbar ([1e4c9f2](https://github.com/pie-framework/pie-lib/commit/1e4c9f21be612409deee08cca6790f019f5d01d3))
25
+ * **editable-html:** potential fix - sanity check for node key in table - sentry ([f417c72](https://github.com/pie-framework/pie-lib/commit/f417c724c49e50e8c3c514b46b42f5d410da2942))
26
+ * code tweaks ([a390dcb](https://github.com/pie-framework/pie-lib/commit/a390dcbe22e9d37776b91071ec1502bbad59ff2a))
27
+ * duplicate image issue ([924a4df](https://github.com/pie-framework/pie-lib/commit/924a4df45cf9f1601704dd48c2a757dd02e2e7a3))
28
+ * tests ([41caca9](https://github.com/pie-framework/pie-lib/commit/41caca9855aa8099f5cb7286cc6660dd20d5c622))
29
+
30
+
31
+ ### Features
32
+
33
+ * **characters:** special character accents span 2 rows, added border for visibility [PD-1462] ([c60b0bc](https://github.com/pie-framework/pie-lib/commit/c60b0bc8ff45cc01f53bc752fd5dd64da623f6be))
34
+ * **editable-html:** add image alignment buttons ([a076a41](https://github.com/pie-framework/pie-lib/commit/a076a4193c82dc552bd21de7a8f928d8481e73e6))
35
+ * **editable-html:** BREAKING CHANGE add image alignment buttons in image toolbar PD-1802 ([bcb59e5](https://github.com/pie-framework/pie-lib/commit/bcb59e5737fe61560fac8de01276baf187888048))
36
+ * **editable-html:** image resize functionality PD-1801. BREAKING CHANGE removed percent buttons from image toolbar ([1d5c33d](https://github.com/pie-framework/pie-lib/commit/1d5c33d4bcd224fa1b38310d7f0f21fba0888f12))
37
+ * **editable-html:** Make editable-html style inline with mathjax: font, radical, exponential, italicize variables PD-1521 ([20752ad](https://github.com/pie-framework/pie-lib/commit/20752ad453880da881bc0a2880c6ef9a10b9589d))
38
+ * **editable-html, render-ui:** wrap up PD-1802 ([e10babf](https://github.com/pie-framework/pie-lib/commit/e10babf2e80aed67c856e9e021e37072e3df33fb))
39
+ * **editor:** added insert spanish and special characters as default [PD-1883] ([26655ec](https://github.com/pie-framework/pie-lib/commit/26655ec87cb4b8a82357e88b62faad3fdc7c296a))
40
+
41
+
42
+ ### BREAKING CHANGES
43
+
44
+ * **editable-html:** Added new buttons in image toolbar.
45
+ The buttons control image horizontal alignment.
46
+
47
+
48
+
49
+
50
+
51
+ ## [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)
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * running locally does not work ([ce2d09a](https://github.com/pie-framework/pie-lib/commit/ce2d09a3556937aea4a1c8075a2dbc7c1131fd5f))
57
+
58
+
59
+
60
+
61
+
6
62
  ## [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
63
 
8
64
 
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,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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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) { _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; }
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 = {
@@ -94,25 +90,27 @@ var defaultResponseAreaProps = {
94
90
  respAreaToolbar: function respAreaToolbar() {},
95
91
  onHandleAreaChange: function onHandleAreaChange() {}
96
92
  };
97
- var defaultLanguageCharactersProps = [];
93
+ var defaultLanguageCharactersProps = [{
94
+ language: 'spanish'
95
+ }, {
96
+ language: 'special'
97
+ }];
98
98
 
99
99
  var createToolbarOpts = function createToolbarOpts(toolbarOpts) {
100
100
  return _objectSpread(_objectSpread({}, defaultToolbarOpts), toolbarOpts);
101
101
  };
102
102
 
103
103
  var Editor = /*#__PURE__*/function (_React$Component) {
104
- _inherits(Editor, _React$Component);
104
+ (0, _inherits2["default"])(Editor, _React$Component);
105
105
 
106
106
  var _super = _createSuper(Editor);
107
107
 
108
108
  function Editor(_props) {
109
109
  var _this;
110
110
 
111
- _classCallCheck(this, Editor);
112
-
111
+ (0, _classCallCheck2["default"])(this, Editor);
113
112
  _this = _super.call(this, _props);
114
-
115
- _defineProperty(_assertThisInitialized(_this), "handlePlugins", function (props) {
113
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handlePlugins", function (props) {
116
114
  var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
117
115
 
118
116
  _this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, {
@@ -150,6 +148,8 @@ var Editor = /*#__PURE__*/function (_React$Component) {
150
148
  disableUnderline: props.disableUnderline,
151
149
  autoWidth: props.autoWidthToolbar,
152
150
  onDone: function onDone() {
151
+ var _this$state$value$sta, _this$state$value$sta2;
152
+
153
153
  var nonEmpty = props.nonEmpty;
154
154
  log('[onDone]');
155
155
 
@@ -160,7 +160,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
160
160
 
161
161
  _this.editor.blur();
162
162
 
163
- if (nonEmpty && _this.state.value.startText.text.length === 0) {
163
+ if (nonEmpty && ((_this$state$value$sta = _this.state.value.startText) === null || _this$state$value$sta === void 0 ? void 0 : (_this$state$value$sta2 = _this$state$value$sta.text) === null || _this$state$value$sta2 === void 0 ? void 0 : _this$state$value$sta2.length) === 0) {
164
164
  _this.resetValue(true).then(function () {
165
165
  _this.onEditingDone();
166
166
  });
@@ -209,8 +209,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
209
209
  }
210
210
  });
211
211
  });
212
-
213
- _defineProperty(_assertThisInitialized(_this), "onPluginBlur", function (e) {
212
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginBlur", function (e) {
214
213
  log('[onPluginBlur]', e && e.relatedTarget);
215
214
  var target = e && e.relatedTarget;
216
215
  var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
@@ -222,8 +221,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
222
221
  _this.resetValue();
223
222
  });
224
223
  });
225
-
226
- _defineProperty(_assertThisInitialized(_this), "onPluginFocus", function (e) {
224
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginFocus", function (e) {
227
225
  log('[onPluginFocus]', e && e.target);
228
226
  var target = e && e.target;
229
227
 
@@ -244,8 +242,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
244
242
 
245
243
  _this.stashValue();
246
244
  });
247
-
248
- _defineProperty(_assertThisInitialized(_this), "onMathClick", function (node) {
245
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMathClick", function (node) {
249
246
  _this.editor.change(function (c) {
250
247
  return c.collapseToStartOf(node);
251
248
  });
@@ -254,8 +251,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
254
251
  selectedNode: node
255
252
  });
256
253
  });
257
-
258
- _defineProperty(_assertThisInitialized(_this), "onEditingDone", function () {
254
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditingDone", function () {
259
255
  log('[onEditingDone]');
260
256
 
261
257
  _this.setState({
@@ -267,8 +263,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
267
263
 
268
264
  _this.props.onChange(_this.state.value, true);
269
265
  });
270
-
271
- _defineProperty(_assertThisInitialized(_this), "handleBlur", function (resolve) {
266
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (resolve) {
272
267
  var nonEmpty = _this.props.nonEmpty;
273
268
  var doneOn = _this.state.toolbarOpts.doneOn;
274
269
 
@@ -282,7 +277,9 @@ var Editor = /*#__PURE__*/function (_React$Component) {
282
277
  }
283
278
 
284
279
  if (doneOn === 'blur') {
285
- if (nonEmpty && _this.state.value.startText.text.length === 0) {
280
+ var _this$state$value$sta3, _this$state$value$sta4;
281
+
282
+ if (nonEmpty && ((_this$state$value$sta3 = _this.state.value.startText) === null || _this$state$value$sta3 === void 0 ? void 0 : (_this$state$value$sta4 = _this$state$value$sta3.text) === null || _this$state$value$sta4 === void 0 ? void 0 : _this$state$value$sta4.length) === 0) {
286
283
  _this.resetValue(true).then(function () {
287
284
  _this.onEditingDone();
288
285
 
@@ -295,8 +292,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
295
292
  }
296
293
  }
297
294
  });
298
-
299
- _defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
295
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (event) {
300
296
  log('[onBlur]');
301
297
  var target = event.relatedTarget;
302
298
  var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
@@ -304,13 +300,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
304
300
  return new Promise(function (resolve) {
305
301
  _this.setState({
306
302
  focusedNode: node
307
- }, _this.handleBlur.bind(_assertThisInitialized(_this), resolve));
303
+ }, _this.handleBlur.bind((0, _assertThisInitialized2["default"])(_this), resolve));
308
304
 
309
305
  _this.props.onBlur(event);
310
306
  });
311
307
  });
312
-
313
- _defineProperty(_assertThisInitialized(_this), "handleDomBlur", function (e) {
308
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDomBlur", function (e) {
314
309
  var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
315
310
  setTimeout(function () {
316
311
  if (!_this.wrapperRef) {
@@ -329,8 +324,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
329
324
  }
330
325
  }, 50);
331
326
  });
332
-
333
- _defineProperty(_assertThisInitialized(_this), "onFocus", function () {
327
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
334
328
  return new Promise(function (resolve) {
335
329
  var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
336
330
  log('[onFocus]', document.activeElement);
@@ -376,8 +370,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
376
370
  resolve();
377
371
  });
378
372
  });
379
-
380
- _defineProperty(_assertThisInitialized(_this), "stashValue", function () {
373
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stashValue", function () {
381
374
  log('[stashValue]');
382
375
 
383
376
  if (!_this.state.stashedValue) {
@@ -386,8 +379,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
386
379
  });
387
380
  }
388
381
  });
389
-
390
- _defineProperty(_assertThisInitialized(_this), "resetValue", function (force) {
382
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetValue", function (force) {
391
383
  var _this$state = _this.state,
392
384
  value = _this$state.value,
393
385
  focusedNode = _this$state.focusedNode;
@@ -421,8 +413,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
421
413
  return Promise.resolve({});
422
414
  }
423
415
  });
424
-
425
- _defineProperty(_assertThisInitialized(_this), "onChange", function (change, done) {
416
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (change, done) {
426
417
  log('[onChange]');
427
418
  var value = change.value;
428
419
  var charactersLimit = _this.props.charactersLimit;
@@ -441,8 +432,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
441
432
  }
442
433
  });
443
434
  });
444
-
445
- _defineProperty(_assertThisInitialized(_this), "valueToSize", function (v) {
435
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "valueToSize", function (v) {
446
436
  if (!v) {
447
437
  return;
448
438
  }
@@ -464,8 +454,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
464
454
 
465
455
  return;
466
456
  });
467
-
468
- _defineProperty(_assertThisInitialized(_this), "validateNode", function (node) {
457
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "validateNode", function (node) {
469
458
  if (node.object !== 'block') return;
470
459
  var last = node.nodes.last();
471
460
  if (!last) return;
@@ -478,8 +467,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
478
467
  log('[validateNode] parent:', parent, p);
479
468
  return undefined;
480
469
  });
481
-
482
- _defineProperty(_assertThisInitialized(_this), "changeData", function (key, data) {
470
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (key, data) {
483
471
  log('[changeData]. .. ', key, data);
484
472
  /**
485
473
  * HACK ALERT: We should be calling setState here and storing the change data:
@@ -498,17 +486,15 @@ var Editor = /*#__PURE__*/function (_React$Component) {
498
486
  data: data
499
487
  };
500
488
  });
501
-
502
- _defineProperty(_assertThisInitialized(_this), "focus", function (pos, node) {
489
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (pos, node) {
503
490
  var position = pos || 'end';
504
491
 
505
492
  _this.props.focus(position, node);
506
493
  });
507
-
508
- _defineProperty(_assertThisInitialized(_this), "onDropPaste", /*#__PURE__*/function () {
509
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(event, change, dropContext) {
510
- var editor, transfer, file;
511
- return regeneratorRuntime.wrap(function _callee$(_context) {
494
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDropPaste", /*#__PURE__*/function () {
495
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(event, change, dropContext) {
496
+ var editor, transfer, file, src, inline, range, ch;
497
+ return _regenerator["default"].wrap(function _callee$(_context) {
512
498
  while (1) {
513
499
  switch (_context.prev = _context.next) {
514
500
  case 0:
@@ -524,49 +510,61 @@ var Editor = /*#__PURE__*/function (_React$Component) {
524
510
  transfer = (0, _slateReact.getEventTransfer)(event);
525
511
  file = transfer.files[0];
526
512
 
527
- if (file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png') {
528
- log('[onDropPaste]');
529
- (0, serialization.getBase64)(file).then(function (src) {
530
- var inline = _slate.Inline.create({
531
- type: 'image',
532
- isVoid: true,
533
- data: {
534
- loading: false,
535
- src: src
536
- }
537
- });
538
-
539
- if (dropContext) {
540
- _this.focus();
541
- } else {
542
- var range = (0, _slateReact.getEventRange)(event, editor);
543
-
544
- if (range) {
545
- change.select(range);
546
- }
547
- }
548
-
549
- var ch = change.insertInline(inline);
550
-
551
- _this.onChange(ch);
552
- })["catch"](function (err) {
553
- return log('[onDropPaste] error: ', err);
554
- });
513
+ if (!(file && file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png')) {
514
+ _context.next = 20;
515
+ break;
516
+ }
517
+
518
+ _context.prev = 6;
519
+ log('[onDropPaste]');
520
+ _context.next = 10;
521
+ return (0, serialization.getBase64)(file);
522
+
523
+ case 10:
524
+ src = _context.sent;
525
+ inline = _slate.Inline.create({
526
+ type: 'image',
527
+ isVoid: true,
528
+ data: {
529
+ loading: false,
530
+ src: src
531
+ }
532
+ });
533
+
534
+ if (dropContext) {
535
+ _this.focus();
536
+ } else {
537
+ range = (0, _slateReact.getEventRange)(event, editor);
538
+
539
+ if (range) {
540
+ change.select(range);
541
+ }
555
542
  }
556
543
 
557
- case 6:
544
+ ch = change.insertInline(inline);
545
+
546
+ _this.onChange(ch);
547
+
548
+ _context.next = 20;
549
+ break;
550
+
551
+ case 17:
552
+ _context.prev = 17;
553
+ _context.t0 = _context["catch"](6);
554
+ log('[onDropPaste] error: ', _context.t0);
555
+
556
+ case 20:
558
557
  case "end":
559
558
  return _context.stop();
560
559
  }
561
560
  }
562
- }, _callee);
561
+ }, _callee, null, [[6, 17]]);
563
562
  }));
564
563
 
565
564
  return function (_x, _x2, _x3) {
566
565
  return _ref.apply(this, arguments);
567
566
  };
568
567
  }());
569
-
570
568
  _this.state = {
571
569
  value: _props.value,
572
570
  toolbarOpts: createToolbarOpts(_props.toolbarOpts)
@@ -581,7 +579,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
581
579
  return _this;
582
580
  }
583
581
 
584
- _createClass(Editor, [{
582
+ (0, _createClass2["default"])(Editor, [{
585
583
  key: "componentDidMount",
586
584
  value: function componentDidMount() {
587
585
  var _this2 = this;
@@ -687,7 +685,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
687
685
  toolbarOpts = _this$state2.toolbarOpts;
688
686
  log('[render] value: ', value);
689
687
  var sizeStyle = this.buildSizeStyle();
690
- var names = (0, _classnames["default"])((_classNames = {}, _defineProperty(_classNames, classes.withBg, highlightShape), _defineProperty(_classNames, classes.toolbarOnTop, toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'), _classNames), className);
688
+ 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
689
  return /*#__PURE__*/_react["default"].createElement("div", {
692
690
  ref: function ref(_ref2) {
693
691
  return _this3.wrapperRef = _ref2;
@@ -741,14 +739,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
741
739
  }));
742
740
  }
743
741
  }]);
744
-
745
742
  return Editor;
746
743
  }(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
747
744
 
748
745
 
749
746
  exports.Editor = Editor;
750
-
751
- _defineProperty(Editor, "propTypes", {
747
+ (0, _defineProperty2["default"])(Editor, "propTypes", {
752
748
  autoFocus: _propTypes["default"].bool,
753
749
  editorRef: _propTypes["default"].func.isRequired,
754
750
  onRef: _propTypes["default"].func.isRequired,
@@ -801,8 +797,7 @@ _defineProperty(Editor, "propTypes", {
801
797
  maxImageWidth: _propTypes["default"].number,
802
798
  maxImageHeight: _propTypes["default"].number
803
799
  });
804
-
805
- _defineProperty(Editor, "defaultProps", {
800
+ (0, _defineProperty2["default"])(Editor, "defaultProps", {
806
801
  disableUnderline: true,
807
802
  onFocus: function onFocus() {},
808
803
  onBlur: function onBlur() {},
@@ -811,7 +806,6 @@ _defineProperty(Editor, "defaultProps", {
811
806
  responseAreaProps: defaultResponseAreaProps,
812
807
  languageCharactersProps: defaultLanguageCharactersProps
813
808
  });
814
-
815
809
  var styles = {
816
810
  withBg: {
817
811
  backgroundColor: 'rgba(0,0,0,0.06)'