@pie-lib/editable-html 7.17.4-next.369 → 7.17.4-next.406

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/lib/editor.js +49 -78
  2. package/lib/editor.js.map +1 -1
  3. package/lib/index.js +30 -42
  4. package/lib/index.js.map +1 -1
  5. package/lib/plugins/characters/custom-popover.js +8 -11
  6. package/lib/plugins/characters/custom-popover.js.map +1 -1
  7. package/lib/plugins/characters/index.js +8 -18
  8. package/lib/plugins/characters/index.js.map +1 -1
  9. package/lib/plugins/image/component.js +65 -54
  10. package/lib/plugins/image/component.js.map +1 -1
  11. package/lib/plugins/image/image-toolbar.js +65 -27
  12. package/lib/plugins/image/image-toolbar.js.map +1 -1
  13. package/lib/plugins/image/index.js +47 -12
  14. package/lib/plugins/image/index.js.map +1 -1
  15. package/lib/plugins/image/insert-image-handler.js +8 -12
  16. package/lib/plugins/image/insert-image-handler.js.map +1 -1
  17. package/lib/plugins/index.js +6 -15
  18. package/lib/plugins/index.js.map +1 -1
  19. package/lib/plugins/list/index.js +2 -2
  20. package/lib/plugins/list/index.js.map +1 -1
  21. package/lib/plugins/math/index.js +8 -8
  22. package/lib/plugins/math/index.js.map +1 -1
  23. package/lib/plugins/media/index.js +15 -20
  24. package/lib/plugins/media/index.js.map +1 -1
  25. package/lib/plugins/media/media-dialog.js +26 -41
  26. package/lib/plugins/media/media-dialog.js.map +1 -1
  27. package/lib/plugins/media/media-toolbar.js +15 -25
  28. package/lib/plugins/media/media-toolbar.js.map +1 -1
  29. package/lib/plugins/media/media-wrapper.js +22 -35
  30. package/lib/plugins/media/media-wrapper.js.map +1 -1
  31. package/lib/plugins/respArea/drag-in-the-blank/choice.js +24 -37
  32. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
  33. package/lib/plugins/respArea/drag-in-the-blank/index.js +8 -8
  34. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
  35. package/lib/plugins/respArea/explicit-constructed-response/index.js +5 -5
  36. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
  37. package/lib/plugins/respArea/icons/index.js +5 -5
  38. package/lib/plugins/respArea/icons/index.js.map +1 -1
  39. package/lib/plugins/respArea/index.js +2 -2
  40. package/lib/plugins/respArea/index.js.map +1 -1
  41. package/lib/plugins/respArea/inline-dropdown/index.js +5 -5
  42. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
  43. package/lib/plugins/respArea/utils.js +2 -2
  44. package/lib/plugins/respArea/utils.js.map +1 -1
  45. package/lib/plugins/table/icons/index.js +9 -9
  46. package/lib/plugins/table/icons/index.js.map +1 -1
  47. package/lib/plugins/table/index.js +11 -11
  48. package/lib/plugins/table/index.js.map +1 -1
  49. package/lib/plugins/table/table-toolbar.js +25 -36
  50. package/lib/plugins/table/table-toolbar.js.map +1 -1
  51. package/lib/plugins/toolbar/default-toolbar.js +5 -5
  52. package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
  53. package/lib/plugins/toolbar/done-button.js +2 -2
  54. package/lib/plugins/toolbar/done-button.js.map +1 -1
  55. package/lib/plugins/toolbar/editor-and-toolbar.js +18 -30
  56. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
  57. package/lib/plugins/toolbar/index.js +5 -5
  58. package/lib/plugins/toolbar/index.js.map +1 -1
  59. package/lib/plugins/toolbar/toolbar-buttons.js +25 -43
  60. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
  61. package/lib/plugins/toolbar/toolbar.js +30 -49
  62. package/lib/plugins/toolbar/toolbar.js.map +1 -1
  63. package/lib/serialization.js +2 -2
  64. package/lib/serialization.js.map +1 -1
  65. package/package.json +3 -3
  66. package/src/editor.jsx +13 -6
  67. package/src/plugins/image/component.jsx +49 -20
  68. package/src/plugins/image/image-toolbar.jsx +37 -2
  69. package/src/plugins/image/index.jsx +38 -9
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,39 +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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
55
-
56
- 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); } }
57
-
58
- 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); }); }; }
59
-
60
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
61
-
62
- 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); } }
63
-
64
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
65
-
66
- 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); }
67
-
68
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
69
-
70
- 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); }; }
71
-
72
- 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); }
73
-
74
- 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); }; }
75
73
 
76
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; } }
77
75
 
78
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
79
-
80
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; }
81
77
 
82
- 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; }
83
-
84
- 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; }
85
79
 
86
80
  var log = (0, _debug["default"])('editable-html:editor');
87
81
  var defaultToolbarOpts = {
@@ -103,18 +97,16 @@ var createToolbarOpts = function createToolbarOpts(toolbarOpts) {
103
97
  };
104
98
 
105
99
  var Editor = /*#__PURE__*/function (_React$Component) {
106
- _inherits(Editor, _React$Component);
100
+ (0, _inherits2["default"])(Editor, _React$Component);
107
101
 
108
102
  var _super = _createSuper(Editor);
109
103
 
110
104
  function Editor(_props) {
111
105
  var _this;
112
106
 
113
- _classCallCheck(this, Editor);
114
-
107
+ (0, _classCallCheck2["default"])(this, Editor);
115
108
  _this = _super.call(this, _props);
116
-
117
- _defineProperty(_assertThisInitialized(_this), "handlePlugins", function (props) {
109
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handlePlugins", function (props) {
118
110
  var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
119
111
 
120
112
  _this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, {
@@ -211,8 +203,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
211
203
  }
212
204
  });
213
205
  });
214
-
215
- _defineProperty(_assertThisInitialized(_this), "onPluginBlur", function (e) {
206
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginBlur", function (e) {
216
207
  log('[onPluginBlur]', e && e.relatedTarget);
217
208
  var target = e && e.relatedTarget;
218
209
  var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
@@ -224,8 +215,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
224
215
  _this.resetValue();
225
216
  });
226
217
  });
227
-
228
- _defineProperty(_assertThisInitialized(_this), "onPluginFocus", function (e) {
218
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginFocus", function (e) {
229
219
  log('[onPluginFocus]', e && e.target);
230
220
  var target = e && e.target;
231
221
 
@@ -246,8 +236,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
246
236
 
247
237
  _this.stashValue();
248
238
  });
249
-
250
- _defineProperty(_assertThisInitialized(_this), "onMathClick", function (node) {
239
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMathClick", function (node) {
251
240
  _this.editor.change(function (c) {
252
241
  return c.collapseToStartOf(node);
253
242
  });
@@ -256,8 +245,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
256
245
  selectedNode: node
257
246
  });
258
247
  });
259
-
260
- _defineProperty(_assertThisInitialized(_this), "onEditingDone", function () {
248
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditingDone", function () {
261
249
  log('[onEditingDone]');
262
250
 
263
251
  _this.setState({
@@ -269,8 +257,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
269
257
 
270
258
  _this.props.onChange(_this.state.value, true);
271
259
  });
272
-
273
- _defineProperty(_assertThisInitialized(_this), "handleBlur", function (resolve) {
260
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (resolve) {
274
261
  var nonEmpty = _this.props.nonEmpty;
275
262
  var doneOn = _this.state.toolbarOpts.doneOn;
276
263
 
@@ -297,8 +284,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
297
284
  }
298
285
  }
299
286
  });
300
-
301
- _defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
287
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (event) {
302
288
  log('[onBlur]');
303
289
  var target = event.relatedTarget;
304
290
  var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
@@ -306,13 +292,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
306
292
  return new Promise(function (resolve) {
307
293
  _this.setState({
308
294
  focusedNode: node
309
- }, _this.handleBlur.bind(_assertThisInitialized(_this), resolve));
295
+ }, _this.handleBlur.bind((0, _assertThisInitialized2["default"])(_this), resolve));
310
296
 
311
297
  _this.props.onBlur(event);
312
298
  });
313
299
  });
314
-
315
- _defineProperty(_assertThisInitialized(_this), "handleDomBlur", function (e) {
300
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDomBlur", function (e) {
316
301
  var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
317
302
  setTimeout(function () {
318
303
  if (!_this.wrapperRef) {
@@ -331,8 +316,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
331
316
  }
332
317
  }, 50);
333
318
  });
334
-
335
- _defineProperty(_assertThisInitialized(_this), "onFocus", function () {
319
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
336
320
  return new Promise(function (resolve) {
337
321
  var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
338
322
  log('[onFocus]', document.activeElement);
@@ -378,8 +362,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
378
362
  resolve();
379
363
  });
380
364
  });
381
-
382
- _defineProperty(_assertThisInitialized(_this), "stashValue", function () {
365
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stashValue", function () {
383
366
  log('[stashValue]');
384
367
 
385
368
  if (!_this.state.stashedValue) {
@@ -388,8 +371,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
388
371
  });
389
372
  }
390
373
  });
391
-
392
- _defineProperty(_assertThisInitialized(_this), "resetValue", function (force) {
374
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetValue", function (force) {
393
375
  var _this$state = _this.state,
394
376
  value = _this$state.value,
395
377
  focusedNode = _this$state.focusedNode;
@@ -423,8 +405,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
423
405
  return Promise.resolve({});
424
406
  }
425
407
  });
426
-
427
- _defineProperty(_assertThisInitialized(_this), "onChange", function (change, done) {
408
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (change, done) {
428
409
  log('[onChange]');
429
410
  var value = change.value;
430
411
  var charactersLimit = _this.props.charactersLimit;
@@ -443,8 +424,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
443
424
  }
444
425
  });
445
426
  });
446
-
447
- _defineProperty(_assertThisInitialized(_this), "valueToSize", function (v) {
427
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "valueToSize", function (v) {
448
428
  if (!v) {
449
429
  return;
450
430
  }
@@ -466,8 +446,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
466
446
 
467
447
  return;
468
448
  });
469
-
470
- _defineProperty(_assertThisInitialized(_this), "validateNode", function (node) {
449
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "validateNode", function (node) {
471
450
  if (node.object !== 'block') return;
472
451
  var last = node.nodes.last();
473
452
  if (!last) return;
@@ -480,8 +459,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
480
459
  log('[validateNode] parent:', parent, p);
481
460
  return undefined;
482
461
  });
483
-
484
- _defineProperty(_assertThisInitialized(_this), "changeData", function (key, data) {
462
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (key, data) {
485
463
  log('[changeData]. .. ', key, data);
486
464
  /**
487
465
  * HACK ALERT: We should be calling setState here and storing the change data:
@@ -500,17 +478,15 @@ var Editor = /*#__PURE__*/function (_React$Component) {
500
478
  data: data
501
479
  };
502
480
  });
503
-
504
- _defineProperty(_assertThisInitialized(_this), "focus", function (pos, node) {
481
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (pos, node) {
505
482
  var position = pos || 'end';
506
483
 
507
484
  _this.props.focus(position, node);
508
485
  });
509
-
510
- _defineProperty(_assertThisInitialized(_this), "onDropPaste", /*#__PURE__*/function () {
511
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event, change, dropContext) {
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) {
512
488
  var editor, transfer, file, src, inline, range, ch;
513
- return _regeneratorRuntime().wrap(function _callee$(_context) {
489
+ return _regenerator["default"].wrap(function _callee$(_context) {
514
490
  while (1) {
515
491
  switch (_context.prev = _context.next) {
516
492
  case 0:
@@ -581,7 +557,6 @@ var Editor = /*#__PURE__*/function (_React$Component) {
581
557
  return _ref.apply(this, arguments);
582
558
  };
583
559
  }());
584
-
585
560
  _this.state = {
586
561
  value: _props.value,
587
562
  toolbarOpts: createToolbarOpts(_props.toolbarOpts)
@@ -596,7 +571,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
596
571
  return _this;
597
572
  }
598
573
 
599
- _createClass(Editor, [{
574
+ (0, _createClass2["default"])(Editor, [{
600
575
  key: "componentDidMount",
601
576
  value: function componentDidMount() {
602
577
  var _this2 = this;
@@ -702,7 +677,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
702
677
  toolbarOpts = _this$state2.toolbarOpts;
703
678
  log('[render] value: ', value);
704
679
  var sizeStyle = this.buildSizeStyle();
705
- 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);
706
681
  return /*#__PURE__*/_react["default"].createElement("div", {
707
682
  ref: function ref(_ref2) {
708
683
  return _this3.wrapperRef = _ref2;
@@ -756,14 +731,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
756
731
  }));
757
732
  }
758
733
  }]);
759
-
760
734
  return Editor;
761
735
  }(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
762
736
 
763
737
 
764
738
  exports.Editor = Editor;
765
-
766
- _defineProperty(Editor, "propTypes", {
739
+ (0, _defineProperty2["default"])(Editor, "propTypes", {
767
740
  autoFocus: _propTypes["default"].bool,
768
741
  editorRef: _propTypes["default"].func.isRequired,
769
742
  onRef: _propTypes["default"].func.isRequired,
@@ -816,8 +789,7 @@ _defineProperty(Editor, "propTypes", {
816
789
  maxImageWidth: _propTypes["default"].number,
817
790
  maxImageHeight: _propTypes["default"].number
818
791
  });
819
-
820
- _defineProperty(Editor, "defaultProps", {
792
+ (0, _defineProperty2["default"])(Editor, "defaultProps", {
821
793
  disableUnderline: true,
822
794
  onFocus: function onFocus() {},
823
795
  onBlur: function onBlur() {},
@@ -826,7 +798,6 @@ _defineProperty(Editor, "defaultProps", {
826
798
  responseAreaProps: defaultResponseAreaProps,
827
799
  languageCharactersProps: defaultLanguageCharactersProps
828
800
  });
829
-
830
801
  var styles = {
831
802
  withBg: {
832
803
  backgroundColor: 'rgba(0,0,0,0.06)'
package/lib/editor.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","names":["log","debug","defaultToolbarOpts","position","alignment","alwaysVisible","showDone","doneOn","defaultResponseAreaProps","options","respAreaToolbar","onHandleAreaChange","defaultLanguageCharactersProps","createToolbarOpts","toolbarOpts","Editor","props","normalizedResponseAreaProps","responseAreaProps","plugins","buildPlugins","activePlugins","math","onClick","onMathClick","onFocus","onPluginFocus","onBlur","onPluginBlur","image","onDelete","imageSupport","src","done","e","state","value","insertImageRequested","getHandler","handler","add","maxImageWidth","maxImageHeight","toolbar","disableUnderline","autoWidth","autoWidthToolbar","onDone","nonEmpty","setState","toolbarInFocus","focusedNode","editor","blur","startText","text","length","resetValue","then","onEditingDone","table","responseArea","type","maxResponseAreas","error","languageCharacters","languageCharactersProps","media","focus","createChange","change","onChange","relatedTarget","target","node","findNode","stashedValue","stashValue","c","collapseToStartOf","selectedNode","resolve","event","Promise","handleBlur","bind","editorDOM","document","querySelector","key","setTimeout","wrapperRef","editorElement","activeElement","closest","className","toolbarElement","toolbarRef","isInCurrentComponent","contains","removeEventListener","handleDomBlur","__TEMPORARY_CHANGE_DATA","data","domEl","setNodeByKey","addEventListener","force","stopReset","reduce","s","p","isFocused","toObject","newValue","Value","fromJSON","toJSON","charactersLimit","v","endsWith","undefined","parseInt","isNaN","object","last","nodes","parent","getParent","Block","pos","dropContext","transfer","getEventTransfer","file","files","getBase64","inline","Inline","create","isVoid","loading","range","getEventRange","select","ch","insertInline","onResize","handlePlugins","onRef","window","autoFocus","nextProps","newToolbarOpts","isEqual","zeroWidthEls","querySelectorAll","Array","from","forEach","el","style","minWidth","display","equals","width","minHeight","height","maxHeight","valueToSize","disabled","spellCheck","highlightShape","classes","placeholder","pluginProps","onKeyDown","sizeStyle","buildSizeStyle","names","classNames","withBg","toolbarOnTop","ref","r","slateEditor","editorRef","onDropPaste","normalize","changeData","React","Component","PropTypes","bool","func","isRequired","SlateTypes","number","oneOfType","string","any","shape","oneOf","arrayOf","language","characterIcon","characters","values","allValid","every","ALL_PLUGINS","includes","Error","join","styles","backgroundColor","fontFamily","tableLayout","borderCollapse","color","background","borderTop","padding","textAlign","border","marginTop","withStyles"],"sources":["../src/editor.jsx"],"sourcesContent":["import { Editor as SlateEditor, findNode, getEventRange, getEventTransfer } from 'slate-react';\nimport SlateTypes from 'slate-prop-types';\n\nimport isEqual from 'lodash/isEqual';\nimport * as serialization from './serialization';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport { Value, Block, Inline } from 'slate';\nimport { buildPlugins, ALL_PLUGINS, DEFAULT_PLUGINS } from './plugins';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\nimport { getBase64 } from './serialization';\n\nexport { ALL_PLUGINS, DEFAULT_PLUGINS, serialization };\n\nconst log = debug('editable-html:editor');\n\nconst defaultToolbarOpts = {\n position: 'bottom',\n alignment: 'left',\n alwaysVisible: false,\n showDone: true,\n doneOn: 'blur'\n};\n\nconst defaultResponseAreaProps = {\n options: {},\n respAreaToolbar: () => {},\n onHandleAreaChange: () => {}\n};\n\nconst defaultLanguageCharactersProps = [];\n\nconst createToolbarOpts = toolbarOpts => {\n return {\n ...defaultToolbarOpts,\n ...toolbarOpts\n };\n};\n\nexport class Editor extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n editorRef: PropTypes.func.isRequired,\n onRef: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onKeyDown: PropTypes.func,\n focus: PropTypes.func.isRequired,\n value: SlateTypes.value.isRequired,\n imageSupport: PropTypes.object,\n charactersLimit: PropTypes.number,\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classes: PropTypes.object.isRequired,\n highlightShape: PropTypes.bool,\n disabled: PropTypes.bool,\n spellCheck: PropTypes.bool,\n nonEmpty: PropTypes.bool,\n disableUnderline: PropTypes.bool,\n autoWidthToolbar: PropTypes.bool,\n pluginProps: PropTypes.any,\n placeholder: PropTypes.string,\n responseAreaProps: PropTypes.shape({\n type: PropTypes.oneOf([\n 'explicit-constructed-response',\n 'inline-dropdown',\n 'drag-in-the-blank'\n ]),\n options: PropTypes.object,\n respAreaToolbar: PropTypes.func,\n onHandleAreaChange: PropTypes.func\n }),\n languageCharactersProps: PropTypes.arrayOf(\n PropTypes.shape({\n language: PropTypes.string,\n characterIcon: PropTypes.string,\n characters: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string))\n })\n ),\n toolbarOpts: PropTypes.shape({\n position: PropTypes.oneOf(['bottom', 'top']),\n alignment: PropTypes.oneOf(['left', 'right']),\n alwaysVisible: PropTypes.bool,\n showDone: PropTypes.bool,\n doneOn: PropTypes.string\n }),\n activePlugins: PropTypes.arrayOf(values => {\n const allValid = values.every(v => ALL_PLUGINS.includes(v));\n\n return (\n !allValid &&\n new Error(`Invalid values: ${values}, values must be one of [${ALL_PLUGINS.join(',')}]`)\n );\n }),\n className: PropTypes.string,\n maxImageWidth: PropTypes.number,\n maxImageHeight: PropTypes.number\n };\n\n static defaultProps = {\n disableUnderline: true,\n onFocus: () => {},\n onBlur: () => {},\n onKeyDown: () => {},\n toolbarOpts: defaultToolbarOpts,\n responseAreaProps: defaultResponseAreaProps,\n languageCharactersProps: defaultLanguageCharactersProps\n };\n\n constructor(props) {\n super(props);\n this.state = {\n value: props.value,\n toolbarOpts: createToolbarOpts(props.toolbarOpts)\n };\n\n this.onResize = () => {\n props.onChange(this.state.value, true);\n };\n\n this.handlePlugins(this.props);\n }\n\n handlePlugins = props => {\n const normalizedResponseAreaProps = {\n ...defaultResponseAreaProps,\n ...props.responseAreaProps\n };\n\n this.plugins = buildPlugins(props.activePlugins, {\n math: {\n onClick: this.onMathClick,\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur\n },\n image: {\n onDelete:\n props.imageSupport &&\n props.imageSupport.delete &&\n ((src, done) => {\n props.imageSupport.delete(src, e => {\n done(e, this.state.value);\n });\n }),\n insertImageRequested:\n props.imageSupport &&\n (getHandler => {\n /**\n * The handler is the object through which the outer context\n * communicates file upload events like: fileChosen, cancel, progress\n */\n const handler = getHandler(() => this.state.value);\n props.imageSupport.add(handler);\n }),\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur,\n maxImageWidth: this.props.maxImageWidth,\n maxImageHeight: this.props.maxImageHeight\n },\n toolbar: {\n /**\n * To minimize converting html -> state -> html\n * We only emit markup once 'done' is clicked.\n */\n disableUnderline: props.disableUnderline,\n autoWidth: props.autoWidthToolbar,\n onDone: () => {\n const { nonEmpty } = props;\n\n log('[onDone]');\n this.setState({ toolbarInFocus: false, focusedNode: null });\n this.editor.blur();\n\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n });\n } else {\n this.onEditingDone();\n }\n }\n },\n table: {\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n responseArea: {\n type: normalizedResponseAreaProps.type,\n options: normalizedResponseAreaProps.options,\n maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,\n respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,\n onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,\n error: normalizedResponseAreaProps.error,\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n languageCharacters: props.languageCharactersProps,\n media: {\n focus: this.focus,\n createChange: () => this.state.value.change(),\n onChange: this.onChange\n }\n });\n };\n\n componentDidMount() {\n // onRef is needed to get the ref of the component because we export it using withStyles\n this.props.onRef(this);\n\n window.addEventListener('resize', this.onResize);\n\n if (this.editor && this.props.autoFocus) {\n Promise.resolve().then(() => {\n if (this.editor) {\n const editorDOM = document.querySelector(\n `[data-key=\"${this.editor.value.document.key}\"]`\n );\n\n this.editor.focus();\n\n if (editorDOM) {\n editorDOM.focus();\n }\n }\n });\n }\n }\n\n componentWillReceiveProps(nextProps) {\n const { toolbarOpts } = this.state;\n const newToolbarOpts = createToolbarOpts(nextProps.toolbarOpts);\n\n if (!isEqual(newToolbarOpts, toolbarOpts)) {\n this.setState({\n toolbarOpts: newToolbarOpts\n });\n }\n\n if (!isEqual(nextProps.languageCharactersProps, this.props.languageCharactersProps)) {\n this.handlePlugins(nextProps);\n }\n }\n\n componentDidUpdate() {\n // The cursor is on a zero width element and when that is placed near void elements, it is not visible\n // so we increase the width to at least 2px in order for the user to see it\n const zeroWidthEls = document.querySelectorAll('[data-slate-zero-width=\"z\"]');\n\n Array.from(zeroWidthEls).forEach(el => {\n el.style.minWidth = '2px';\n el.style.display = 'inline-block';\n });\n }\n\n onPluginBlur = e => {\n log('[onPluginBlur]', e && e.relatedTarget);\n const target = e && e.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n log('[onPluginBlur] node: ', node);\n this.setState({ focusedNode: node }, () => {\n this.resetValue();\n });\n };\n\n onPluginFocus = e => {\n log('[onPluginFocus]', e && e.target);\n const target = e && e.target;\n if (target) {\n const node = findNode(target, this.state.value);\n log('[onPluginFocus] node: ', node);\n\n const stashedValue = this.state.stashedValue || this.state.value;\n this.setState({ focusedNode: node, stashedValue });\n } else {\n this.setState({ focusedNode: null });\n }\n this.stashValue();\n };\n\n onMathClick = node => {\n this.editor.change(c => c.collapseToStartOf(node));\n this.setState({ selectedNode: node });\n };\n\n onEditingDone = () => {\n log('[onEditingDone]');\n this.setState({ stashedValue: null, focusedNode: null });\n log('[onEditingDone] value: ', this.state.value);\n this.props.onChange(this.state.value, true);\n };\n\n /**\n * Remove onResize event listener\n */\n componentWillUnmount() {\n window.removeEventListener('resize', this.onResize);\n }\n\n // Allowing time for onChange to take effect if it is called\n handleBlur = resolve => {\n const { nonEmpty } = this.props;\n const {\n toolbarOpts: { doneOn }\n } = this.state;\n\n this.setState({ toolbarInFocus: false, focusedNode: null });\n\n if (this.editor) {\n this.editor.blur();\n }\n\n if (doneOn === 'blur') {\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n resolve();\n });\n } else {\n this.onEditingDone();\n resolve();\n }\n }\n };\n\n onBlur = event => {\n log('[onBlur]');\n const target = event.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n\n log('[onBlur] node: ', node);\n\n return new Promise(resolve => {\n this.setState({ focusedNode: node }, this.handleBlur.bind(this, resolve));\n this.props.onBlur(event);\n });\n };\n\n handleDomBlur = e => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n setTimeout(() => {\n if (!this.wrapperRef) {\n return;\n }\n\n const editorElement =\n !editorDOM || document.activeElement.closest(`[class*=\"${editorDOM.className}\"]`);\n const toolbarElement =\n !this.toolbarRef ||\n document.activeElement.closest(`[class*=\"${this.toolbarRef.className}\"]`);\n const isInCurrentComponent =\n this.wrapperRef.contains(editorElement) || this.wrapperRef.contains(toolbarElement);\n\n if (!isInCurrentComponent) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n this.onBlur(e);\n }\n }, 50);\n };\n\n /*\n * Needs to be wrapped otherwise it causes issues because of race conditions\n * Known issue for slatejs. See: https://github.com/ianstormtaylor/slate/issues/2097\n * Using timeout I wasn't able to test this\n *\n * Note: The use of promises has been causing issues with MathQuill\n * */\n onFocus = () =>\n new Promise(resolve => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n log('[onFocus]', document.activeElement);\n\n /**\n * This is a temporary hack - @see changeData below for some more information.\n */\n if (this.__TEMPORARY_CHANGE_DATA) {\n const { key, data } = this.__TEMPORARY_CHANGE_DATA;\n const domEl = document.querySelector(`[data-key=\"${key}\"]`);\n\n if (domEl) {\n let change = this.state.value.change().setNodeByKey(key, { data });\n\n this.setState({ value: change.value }, () => {\n this.__TEMPORARY_CHANGE_DATA = null;\n });\n }\n }\n\n /**\n * This is needed just in case the browser decides to make the editor\n * lose focus without triggering the onBlur event (can happen in a few cases).\n * This will also trigger onBlur if the user clicks outside of the page when the editor\n * is focused.\n */\n if (editorDOM === document.activeElement) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n editorDOM.addEventListener('blur', this.handleDomBlur);\n }\n\n this.stashValue();\n this.props.onFocus();\n\n resolve();\n });\n\n stashValue = () => {\n log('[stashValue]');\n if (!this.state.stashedValue) {\n this.setState({ stashedValue: this.state.value });\n }\n };\n\n /**\n * Reset the value if the user didn't click done.\n */\n resetValue = force => {\n const { value, focusedNode } = this.state;\n\n const stopReset = this.plugins.reduce((s, p) => {\n return s || (p.stopReset && p.stopReset(this.state.value));\n }, false);\n\n log('[resetValue]', value.isFocused, focusedNode, 'stopReset: ', stopReset);\n if ((this.state.stashedValue && !value.isFocused && !focusedNode && !stopReset) || force) {\n log('[resetValue] resetting...');\n log('stashed', this.state.stashedValue.document.toObject());\n log('current', this.state.value.document.toObject());\n\n const newValue = Value.fromJSON(this.state.stashedValue.toJSON());\n\n log('newValue: ', newValue.document);\n return new Promise(resolve => {\n setTimeout(() => {\n this.setState({ value: newValue, stashedValue: null }, () => {\n log('value now: ', this.state.value.document.toJSON());\n resolve();\n });\n }, 50);\n });\n } else {\n return Promise.resolve({});\n }\n };\n\n onChange = (change, done) => {\n log('[onChange]');\n\n const { value } = change;\n const { charactersLimit } = this.props;\n\n if (\n value &&\n value.document &&\n value.document.text &&\n value.document.text.length > charactersLimit\n ) {\n return;\n }\n\n this.setState({ value }, () => {\n log('[onChange], call done()');\n\n if (done) {\n done();\n }\n });\n };\n\n UNSAFE_componentWillReceiveProps(props) {\n if (!props.value.document.equals(this.props.value.document)) {\n this.setState({\n focus: false,\n value: props.value\n });\n }\n }\n\n valueToSize = v => {\n if (!v) {\n return;\n }\n\n if (typeof v === 'string') {\n if (v.endsWith('%')) {\n return undefined;\n } else if (v.endsWith('px') || v.endsWith('vh') || v.endsWith('vw')) {\n return v;\n } else {\n const value = parseInt(v, 10);\n return isNaN(value) ? value : `${value}px`;\n }\n }\n if (typeof v === 'number') {\n return `${v}px`;\n }\n\n return;\n };\n\n buildSizeStyle() {\n const { width, minHeight, height, maxHeight } = this.props;\n\n return {\n width: this.valueToSize(width),\n height: this.valueToSize(height),\n minHeight: this.valueToSize(minHeight),\n maxHeight: this.valueToSize(maxHeight)\n };\n }\n\n validateNode = node => {\n if (node.object !== 'block') return;\n\n const last = node.nodes.last();\n if (!last) return;\n\n if (last.type !== 'image') return;\n\n log('[validateNode] last is image..');\n\n const parent = last.getParent(last.key);\n const p = Block.getParent(last.key);\n log('[validateNode] parent:', parent, p);\n\n return undefined;\n };\n\n changeData = (key, data) => {\n log('[changeData]. .. ', key, data);\n\n /**\n * HACK ALERT: We should be calling setState here and storing the change data:\n *\n * <code>this.setState({changeData: { key, data}})</code>\n * However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no\n * more changes get through. The issues seem to be related to the promises in onBlur/onFocus. But removing these\n * brings it's own problems. A major clean up is planned for this component so I've decided to temporarily settle\n * on this hack rather than spend more time on this.\n */\n\n // Uncomment this line to see the bug described above.\n // this.setState({changeData: {key, data}})\n\n this.__TEMPORARY_CHANGE_DATA = { key, data };\n };\n\n focus = (pos, node) => {\n const position = pos || 'end';\n\n this.props.focus(position, node);\n };\n\n onDropPaste = async (event, change, dropContext) => {\n if (!this.props.imageSupport) {\n return;\n }\n const editor = change.editor;\n const transfer = getEventTransfer(event);\n const file = transfer.files[0];\n\n if (file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png') {\n try {\n log('[onDropPaste]');\n const src = await getBase64(file);\n const inline = Inline.create({\n type: 'image',\n isVoid: true,\n data: {\n loading: false,\n src\n }\n });\n if (dropContext) {\n this.focus();\n } else {\n const range = getEventRange(event, editor);\n if (range) {\n change.select(range);\n }\n }\n const ch = change.insertInline(inline);\n this.onChange(ch);\n } catch (err) {\n log('[onDropPaste] error: ', err);\n }\n }\n };\n\n render() {\n const {\n disabled,\n spellCheck,\n highlightShape,\n classes,\n className,\n placeholder,\n pluginProps,\n onKeyDown\n } = this.props;\n\n const { value, focusedNode, toolbarOpts } = this.state;\n\n log('[render] value: ', value);\n const sizeStyle = this.buildSizeStyle();\n const names = classNames(\n {\n [classes.withBg]: highlightShape,\n [classes.toolbarOnTop]: toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'\n },\n className\n );\n\n return (\n <div\n ref={ref => (this.wrapperRef = ref)}\n style={{ width: sizeStyle.width }}\n className={names}\n >\n <SlateEditor\n plugins={this.plugins}\n innerRef={r => {\n if (r) {\n this.slateEditor = r;\n }\n }}\n ref={r => (this.editor = r && this.props.editorRef(r))}\n toolbarRef={r => {\n if (r) {\n this.toolbarRef = r;\n }\n }}\n value={value}\n focus={this.focus}\n onKeyDown={onKeyDown}\n onChange={this.onChange}\n onBlur={this.onBlur}\n onDrop={(event, editor) => this.onDropPaste(event, editor, true)}\n onPaste={(event, editor) => this.onDropPaste(event, editor)}\n onFocus={this.onFocus}\n onEditingDone={this.onEditingDone}\n focusedNode={focusedNode}\n normalize={this.normalize}\n readOnly={disabled}\n spellCheck={spellCheck}\n className={classes.slateEditor}\n style={{\n minHeight: sizeStyle.minHeight,\n height: sizeStyle.height,\n maxHeight: sizeStyle.maxHeight\n }}\n pluginProps={pluginProps}\n toolbarOpts={toolbarOpts}\n placeholder={placeholder}\n onDataChange={this.changeData}\n />\n </div>\n );\n }\n}\n\n// TODO color - hardcoded gray background and keypad colors will need to change too\nconst styles = {\n withBg: {\n backgroundColor: 'rgba(0,0,0,0.06)'\n },\n slateEditor: {\n fontFamily: 'Roboto, sans-serif',\n\n '& table': {\n tableLayout: 'fixed',\n width: '100%',\n borderCollapse: 'collapse',\n color: color.text(),\n backgroundColor: color.background()\n },\n '& table:not([border=\"1\"]) tr': {\n borderTop: '1px solid #dfe2e5'\n // TODO perhaps secondary color for background, for now disable\n // '&:nth-child(2n)': {\n // backgroundColor: '#f6f8fa'\n // }\n },\n '& td, th': {\n padding: '.6em 1em',\n textAlign: 'center'\n },\n '& table:not([border=\"1\"]) td, th': {\n border: '1px solid #dfe2e5'\n }\n },\n toolbarOnTop: {\n marginTop: '45px'\n }\n};\n\nexport default withStyles(styles)(Editor);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;+CAXA,oJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAMA,GAAG,GAAG,IAAAC,iBAAA,EAAM,sBAAN,CAAZ;AAEA,IAAMC,kBAAkB,GAAG;EACzBC,QAAQ,EAAE,QADe;EAEzBC,SAAS,EAAE,MAFc;EAGzBC,aAAa,EAAE,KAHU;EAIzBC,QAAQ,EAAE,IAJe;EAKzBC,MAAM,EAAE;AALiB,CAA3B;AAQA,IAAMC,wBAAwB,GAAG;EAC/BC,OAAO,EAAE,EADsB;EAE/BC,eAAe,EAAE,2BAAM,CAAE,CAFM;EAG/BC,kBAAkB,EAAE,8BAAM,CAAE;AAHG,CAAjC;AAMA,IAAMC,8BAA8B,GAAG,EAAvC;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAAAC,WAAW,EAAI;EACvC,uCACKZ,kBADL,GAEKY,WAFL;AAID,CALD;;IAOaC,M;;;;;EAyEX,gBAAYC,MAAZ,EAAmB;IAAA;;IAAA;;IACjB,0BAAMA,MAAN;;IADiB,gEAcH,UAAAA,KAAK,EAAI;MACvB,IAAMC,2BAA2B,mCAC5BT,wBAD4B,GAE5BQ,KAAK,CAACE,iBAFsB,CAAjC;;MAKA,MAAKC,OAAL,GAAe,IAAAC,qBAAA,EAAaJ,KAAK,CAACK,aAAnB,EAAkC;QAC/CC,IAAI,EAAE;UACJC,OAAO,EAAE,MAAKC,WADV;UAEJC,OAAO,EAAE,MAAKC,aAFV;UAGJC,MAAM,EAAE,MAAKC;QAHT,CADyC;QAM/CC,KAAK,EAAE;UACLC,QAAQ,EACNd,KAAK,CAACe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2BAA6BL,MAA7B,sCAA+DG,oBAAA,CAAYG,IAAZ,CAAiB,GAAjB,CAA/D,OAFF;EAID,CAPc,CAjDE;EAyDjBtH,SAAS,EAAEiG,qBAAA,CAAUO,MAzDJ;EA0DjB9J,aAAa,EAAEuJ,qBAAA,CAAUK,MA1DR;EA2DjB3J,cAAc,EAAEsJ,qBAAA,CAAUK;AA3DT,C;;gBADRtL,M,kBA+DW;EACpB6B,gBAAgB,EAAE,IADE;EAEpBnB,OAAO,EAAE,mBAAM,CAAE,CAFG;EAGpBE,MAAM,EAAE,kBAAM,CAAE,CAHI;EAIpBqJ,SAAS,EAAE,qBAAM,CAAE,CAJC;EAKpBlK,WAAW,EAAEZ,kBALO;EAMpBgB,iBAAiB,EAAEV,wBANC;EAOpB0D,uBAAuB,EAAEtD;AAPL,C;;AAikBxB,IAAM0M,MAAM,GAAG;EACbjC,MAAM,EAAE;IACNkC,eAAe,EAAE;EADX,CADK;EAIb9B,WAAW,EAAE;IACX+B,UAAU,EAAE,oBADD;IAGX,WAAW;MACTC,WAAW,EAAE,OADJ;MAETpD,KAAK,EAAE,MAFE;MAGTqD,cAAc,EAAE,UAHP;MAITC,KAAK,EAAEA,eAAA,CAAMpK,IAAN,EAJE;MAKTgK,eAAe,EAAEI,eAAA,CAAMC,UAAN;IALR,CAHA;IAUX,gCAAgC;MAC9BC,SAAS,EAAE,mBADmB,CAE9B;MACA;MACA;MACA;;IAL8B,CAVrB;IAiBX,YAAY;MACVC,OAAO,EAAE,UADC;MAEVC,SAAS,EAAE;IAFD,CAjBD;IAqBX,oCAAoC;MAClCC,MAAM,EAAE;IAD0B;EArBzB,CAJA;EA6Bb1C,YAAY,EAAE;IACZ2C,SAAS,EAAE;EADC;AA7BD,CAAf;;eAkCe,IAAAC,kBAAA,EAAWZ,MAAX,EAAmBvM,MAAnB,C"}
1
+ {"version":3,"file":"editor.js","names":["log","debug","defaultToolbarOpts","position","alignment","alwaysVisible","showDone","doneOn","defaultResponseAreaProps","options","respAreaToolbar","onHandleAreaChange","defaultLanguageCharactersProps","createToolbarOpts","toolbarOpts","Editor","props","normalizedResponseAreaProps","responseAreaProps","plugins","buildPlugins","activePlugins","math","onClick","onMathClick","onFocus","onPluginFocus","onBlur","onPluginBlur","image","onDelete","imageSupport","src","done","e","state","value","insertImageRequested","getHandler","handler","add","maxImageWidth","maxImageHeight","toolbar","disableUnderline","autoWidth","autoWidthToolbar","onDone","nonEmpty","setState","toolbarInFocus","focusedNode","editor","blur","startText","text","length","resetValue","then","onEditingDone","table","responseArea","type","maxResponseAreas","error","languageCharacters","languageCharactersProps","media","focus","createChange","change","onChange","relatedTarget","target","node","findNode","stashedValue","stashValue","c","collapseToStartOf","selectedNode","resolve","event","Promise","handleBlur","bind","editorDOM","document","querySelector","key","setTimeout","wrapperRef","editorElement","activeElement","closest","className","toolbarElement","toolbarRef","isInCurrentComponent","contains","removeEventListener","handleDomBlur","__TEMPORARY_CHANGE_DATA","data","domEl","setNodeByKey","addEventListener","force","stopReset","reduce","s","p","isFocused","toObject","newValue","Value","fromJSON","toJSON","charactersLimit","v","endsWith","undefined","parseInt","isNaN","object","last","nodes","parent","getParent","Block","pos","dropContext","transfer","getEventTransfer","file","files","getBase64","inline","Inline","create","isVoid","loading","range","getEventRange","select","ch","insertInline","onResize","handlePlugins","onRef","window","autoFocus","nextProps","newToolbarOpts","isEqual","zeroWidthEls","querySelectorAll","Array","from","forEach","el","style","minWidth","display","equals","width","minHeight","height","maxHeight","valueToSize","disabled","spellCheck","highlightShape","classes","placeholder","pluginProps","onKeyDown","sizeStyle","buildSizeStyle","names","classNames","withBg","toolbarOnTop","ref","r","slateEditor","editorRef","onDropPaste","normalize","changeData","React","Component","PropTypes","bool","func","isRequired","SlateTypes","number","oneOfType","string","any","shape","oneOf","arrayOf","language","characterIcon","characters","values","allValid","every","ALL_PLUGINS","includes","Error","join","styles","backgroundColor","fontFamily","tableLayout","borderCollapse","color","background","borderTop","padding","textAlign","border","marginTop","withStyles"],"sources":["../src/editor.jsx"],"sourcesContent":["import { Editor as SlateEditor, findNode, getEventRange, getEventTransfer } from 'slate-react';\nimport SlateTypes from 'slate-prop-types';\n\nimport isEqual from 'lodash/isEqual';\nimport * as serialization from './serialization';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport { Value, Block, Inline } from 'slate';\nimport { buildPlugins, ALL_PLUGINS, DEFAULT_PLUGINS } from './plugins';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\nimport { getBase64 } from './serialization';\n\nexport { ALL_PLUGINS, DEFAULT_PLUGINS, serialization };\n\nconst log = debug('editable-html:editor');\n\nconst defaultToolbarOpts = {\n position: 'bottom',\n alignment: 'left',\n alwaysVisible: false,\n showDone: true,\n doneOn: 'blur'\n};\n\nconst defaultResponseAreaProps = {\n options: {},\n respAreaToolbar: () => {\n },\n onHandleAreaChange: () => {\n }\n};\n\nconst defaultLanguageCharactersProps = [];\n\nconst createToolbarOpts = toolbarOpts => {\n return {\n ...defaultToolbarOpts,\n ...toolbarOpts\n };\n};\n\nexport class Editor extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n editorRef: PropTypes.func.isRequired,\n onRef: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onKeyDown: PropTypes.func,\n focus: PropTypes.func.isRequired,\n value: SlateTypes.value.isRequired,\n imageSupport: PropTypes.object,\n charactersLimit: PropTypes.number,\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classes: PropTypes.object.isRequired,\n highlightShape: PropTypes.bool,\n disabled: PropTypes.bool,\n spellCheck: PropTypes.bool,\n nonEmpty: PropTypes.bool,\n disableUnderline: PropTypes.bool,\n autoWidthToolbar: PropTypes.bool,\n pluginProps: PropTypes.any,\n placeholder: PropTypes.string,\n responseAreaProps: PropTypes.shape({\n type: PropTypes.oneOf([\n 'explicit-constructed-response',\n 'inline-dropdown',\n 'drag-in-the-blank'\n ]),\n options: PropTypes.object,\n respAreaToolbar: PropTypes.func,\n onHandleAreaChange: PropTypes.func\n }),\n languageCharactersProps: PropTypes.arrayOf(\n PropTypes.shape({\n language: PropTypes.string,\n characterIcon: PropTypes.string,\n characters: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string))\n })\n ),\n toolbarOpts: PropTypes.shape({\n position: PropTypes.oneOf(['bottom', 'top']),\n alignment: PropTypes.oneOf(['left', 'right']),\n alwaysVisible: PropTypes.bool,\n showDone: PropTypes.bool,\n doneOn: PropTypes.string\n }),\n activePlugins: PropTypes.arrayOf(values => {\n const allValid = values.every(v => ALL_PLUGINS.includes(v));\n\n return (\n !allValid &&\n new Error(`Invalid values: ${values}, values must be one of [${ALL_PLUGINS.join(',')}]`)\n );\n }),\n className: PropTypes.string,\n maxImageWidth: PropTypes.number,\n maxImageHeight: PropTypes.number,\n };\n\n static defaultProps = {\n disableUnderline: true,\n onFocus: () => {\n },\n onBlur: () => {\n },\n onKeyDown: () => {\n },\n toolbarOpts: defaultToolbarOpts,\n responseAreaProps: defaultResponseAreaProps,\n languageCharactersProps: defaultLanguageCharactersProps\n };\n\n constructor(props) {\n super(props);\n this.state = {\n value: props.value,\n toolbarOpts: createToolbarOpts(props.toolbarOpts)\n };\n\n this.onResize = () => {\n props.onChange(this.state.value, true);\n };\n\n this.handlePlugins(this.props);\n }\n\n handlePlugins = props => {\n const normalizedResponseAreaProps = {\n ...defaultResponseAreaProps,\n ...props.responseAreaProps\n };\n\n this.plugins = buildPlugins(props.activePlugins, {\n math: {\n onClick: this.onMathClick,\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur\n },\n image: {\n onDelete:\n props.imageSupport &&\n props.imageSupport.delete &&\n ((src, done) => {\n props.imageSupport.delete(src, e => {\n done(e, this.state.value);\n });\n }),\n insertImageRequested:\n props.imageSupport &&\n (getHandler => {\n /**\n * The handler is the object through which the outer context\n * communicates file upload events like: fileChosen, cancel, progress\n */\n const handler = getHandler(() => this.state.value);\n props.imageSupport.add(handler);\n }),\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur,\n maxImageWidth: this.props.maxImageWidth,\n maxImageHeight: this.props.maxImageHeight\n },\n toolbar: {\n /**\n * To minimize converting html -> state -> html\n * We only emit markup once 'done' is clicked.\n */\n disableUnderline: props.disableUnderline,\n autoWidth: props.autoWidthToolbar,\n onDone: () => {\n const { nonEmpty } = props;\n\n log('[onDone]');\n this.setState({ toolbarInFocus: false, focusedNode: null });\n this.editor.blur();\n\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n });\n } else {\n this.onEditingDone();\n }\n }\n },\n table: {\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n responseArea: {\n type: normalizedResponseAreaProps.type,\n options: normalizedResponseAreaProps.options,\n maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,\n respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,\n onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,\n error: normalizedResponseAreaProps.error,\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n languageCharacters: props.languageCharactersProps,\n media: {\n focus: this.focus,\n createChange: () => this.state.value.change(),\n onChange: this.onChange\n }\n });\n };\n\n componentDidMount() {\n // onRef is needed to get the ref of the component because we export it using withStyles\n this.props.onRef(this);\n\n window.addEventListener('resize', this.onResize);\n\n if (this.editor && this.props.autoFocus) {\n Promise.resolve().then(() => {\n if (this.editor) {\n const editorDOM = document.querySelector(\n `[data-key=\"${this.editor.value.document.key}\"]`\n );\n\n this.editor.focus();\n\n if (editorDOM) {\n editorDOM.focus();\n }\n }\n });\n }\n }\n\n componentWillReceiveProps(nextProps) {\n const { toolbarOpts } = this.state;\n const newToolbarOpts = createToolbarOpts(nextProps.toolbarOpts);\n\n if (!isEqual(newToolbarOpts, toolbarOpts)) {\n this.setState({\n toolbarOpts: newToolbarOpts\n });\n }\n\n if (!isEqual(nextProps.languageCharactersProps, this.props.languageCharactersProps)) {\n this.handlePlugins(nextProps);\n }\n }\n\n componentDidUpdate() {\n // The cursor is on a zero width element and when that is placed near void elements, it is not visible\n // so we increase the width to at least 2px in order for the user to see it\n const zeroWidthEls = document.querySelectorAll('[data-slate-zero-width=\"z\"]');\n\n Array.from(zeroWidthEls).forEach(el => {\n el.style.minWidth = '2px';\n el.style.display = 'inline-block';\n });\n }\n\n onPluginBlur = e => {\n log('[onPluginBlur]', e && e.relatedTarget);\n const target = e && e.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n log('[onPluginBlur] node: ', node);\n this.setState({ focusedNode: node }, () => {\n this.resetValue();\n });\n };\n\n onPluginFocus = e => {\n log('[onPluginFocus]', e && e.target);\n const target = e && e.target;\n if (target) {\n const node = findNode(target, this.state.value);\n log('[onPluginFocus] node: ', node);\n\n const stashedValue = this.state.stashedValue || this.state.value;\n this.setState({ focusedNode: node, stashedValue });\n } else {\n this.setState({ focusedNode: null });\n }\n this.stashValue();\n };\n\n onMathClick = node => {\n this.editor.change(c => c.collapseToStartOf(node));\n this.setState({ selectedNode: node });\n };\n\n onEditingDone = () => {\n log('[onEditingDone]');\n this.setState({ stashedValue: null, focusedNode: null });\n log('[onEditingDone] value: ', this.state.value);\n this.props.onChange(this.state.value, true);\n };\n\n /**\n * Remove onResize event listener\n */\n componentWillUnmount() {\n window.removeEventListener('resize', this.onResize);\n }\n\n // Allowing time for onChange to take effect if it is called\n handleBlur = resolve => {\n const { nonEmpty } = this.props;\n const {\n toolbarOpts: { doneOn }\n } = this.state;\n\n this.setState({ toolbarInFocus: false, focusedNode: null });\n\n if (this.editor) {\n this.editor.blur();\n }\n\n if (doneOn === 'blur') {\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n resolve();\n });\n } else {\n this.onEditingDone();\n resolve();\n }\n }\n };\n\n onBlur = event => {\n log('[onBlur]');\n const target = event.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n\n log('[onBlur] node: ', node);\n\n return new Promise(resolve => {\n this.setState({ focusedNode: node }, this.handleBlur.bind(this, resolve));\n this.props.onBlur(event);\n });\n };\n\n handleDomBlur = e => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n setTimeout(() => {\n if (!this.wrapperRef) {\n return;\n }\n\n const editorElement =\n !editorDOM || document.activeElement.closest(`[class*=\"${editorDOM.className}\"]`);\n const toolbarElement =\n !this.toolbarRef ||\n document.activeElement.closest(`[class*=\"${this.toolbarRef.className}\"]`);\n const isInCurrentComponent =\n this.wrapperRef.contains(editorElement) || this.wrapperRef.contains(toolbarElement);\n\n if (!isInCurrentComponent) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n this.onBlur(e);\n }\n }, 50);\n };\n\n /*\n * Needs to be wrapped otherwise it causes issues because of race conditions\n * Known issue for slatejs. See: https://github.com/ianstormtaylor/slate/issues/2097\n * Using timeout I wasn't able to test this\n *\n * Note: The use of promises has been causing issues with MathQuill\n * */\n onFocus = () =>\n new Promise(resolve => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n log('[onFocus]', document.activeElement);\n\n /**\n * This is a temporary hack - @see changeData below for some more information.\n */\n if (this.__TEMPORARY_CHANGE_DATA) {\n const { key, data } = this.__TEMPORARY_CHANGE_DATA;\n const domEl = document.querySelector(`[data-key=\"${key}\"]`);\n\n if (domEl) {\n let change = this.state.value.change().setNodeByKey(key, { data });\n\n this.setState({ value: change.value }, () => {\n this.__TEMPORARY_CHANGE_DATA = null;\n });\n }\n }\n\n /**\n * This is needed just in case the browser decides to make the editor\n * lose focus without triggering the onBlur event (can happen in a few cases).\n * This will also trigger onBlur if the user clicks outside of the page when the editor\n * is focused.\n */\n if (editorDOM === document.activeElement) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n editorDOM.addEventListener('blur', this.handleDomBlur);\n }\n\n this.stashValue();\n this.props.onFocus();\n\n resolve();\n });\n\n stashValue = () => {\n log('[stashValue]');\n if (!this.state.stashedValue) {\n this.setState({ stashedValue: this.state.value });\n }\n };\n\n /**\n * Reset the value if the user didn't click done.\n */\n resetValue = force => {\n const { value, focusedNode } = this.state;\n\n const stopReset = this.plugins.reduce((s, p) => {\n return s || (p.stopReset && p.stopReset(this.state.value));\n }, false);\n\n log('[resetValue]', value.isFocused, focusedNode, 'stopReset: ', stopReset);\n if ((this.state.stashedValue && !value.isFocused && !focusedNode && !stopReset) || force) {\n log('[resetValue] resetting...');\n log('stashed', this.state.stashedValue.document.toObject());\n log('current', this.state.value.document.toObject());\n\n const newValue = Value.fromJSON(this.state.stashedValue.toJSON());\n\n log('newValue: ', newValue.document);\n return new Promise(resolve => {\n setTimeout(() => {\n this.setState({ value: newValue, stashedValue: null }, () => {\n log('value now: ', this.state.value.document.toJSON());\n resolve();\n });\n }, 50);\n });\n } else {\n return Promise.resolve({});\n }\n };\n\n onChange = (change, done) => {\n log('[onChange]');\n\n const { value } = change;\n const { charactersLimit } = this.props;\n\n if (\n value &&\n value.document &&\n value.document.text &&\n value.document.text.length > charactersLimit\n ) {\n return;\n }\n\n this.setState({ value }, () => {\n log('[onChange], call done()');\n\n if (done) {\n done();\n }\n });\n };\n\n UNSAFE_componentWillReceiveProps(props) {\n if (!props.value.document.equals(this.props.value.document)) {\n this.setState({\n focus: false,\n value: props.value\n });\n }\n }\n\n valueToSize = v => {\n if (!v) {\n return;\n }\n\n if (typeof v === 'string') {\n if (v.endsWith('%')) {\n return undefined;\n } else if (v.endsWith('px') || v.endsWith('vh') || v.endsWith('vw')) {\n return v;\n } else {\n const value = parseInt(v, 10);\n return isNaN(value) ? value : `${value}px`;\n }\n }\n if (typeof v === 'number') {\n return `${v}px`;\n }\n\n return;\n };\n\n buildSizeStyle() {\n const { width, minHeight, height, maxHeight } = this.props;\n\n return {\n width: this.valueToSize(width),\n height: this.valueToSize(height),\n minHeight: this.valueToSize(minHeight),\n maxHeight: this.valueToSize(maxHeight)\n };\n }\n\n validateNode = node => {\n if (node.object !== 'block') return;\n\n const last = node.nodes.last();\n if (!last) return;\n\n if (last.type !== 'image') return;\n\n log('[validateNode] last is image..');\n\n const parent = last.getParent(last.key);\n const p = Block.getParent(last.key);\n log('[validateNode] parent:', parent, p);\n\n return undefined;\n };\n\n changeData = (key, data) => {\n log('[changeData]. .. ', key, data);\n\n /**\n * HACK ALERT: We should be calling setState here and storing the change data:\n *\n * <code>this.setState({changeData: { key, data}})</code>\n * However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no\n * more changes get through. The issues seem to be related to the promises in onBlur/onFocus. But removing these\n * brings it's own problems. A major clean up is planned for this component so I've decided to temporarily settle\n * on this hack rather than spend more time on this.\n */\n\n // Uncomment this line to see the bug described above.\n // this.setState({changeData: {key, data}})\n\n this.__TEMPORARY_CHANGE_DATA = { key, data };\n };\n\n focus = (pos, node) => {\n const position = pos || 'end';\n\n this.props.focus(position, node);\n };\n\n onDropPaste = async (event, change, dropContext) => {\n if (!this.props.imageSupport) {\n return;\n }\n const editor = change.editor;\n const transfer = getEventTransfer(event);\n const file = transfer.files[0];\n\n if (file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png') {\n try {\n log('[onDropPaste]');\n const src = await getBase64(file);\n const inline = Inline.create({\n type: 'image',\n isVoid: true,\n data: {\n loading: false,\n src\n }\n });\n\n if (dropContext) {\n this.focus();\n } else {\n const range = getEventRange(event, editor);\n if (range) {\n change.select(range);\n }\n }\n\n const ch = change.insertInline(inline);\n this.onChange(ch);\n } catch (err) {\n log('[onDropPaste] error: ', err);\n }\n }\n };\n\n render() {\n const {\n disabled,\n spellCheck,\n highlightShape,\n classes,\n className,\n placeholder,\n pluginProps,\n onKeyDown\n } = this.props;\n\n const { value, focusedNode, toolbarOpts } = this.state;\n\n log('[render] value: ', value);\n const sizeStyle = this.buildSizeStyle();\n const names = classNames(\n {\n [classes.withBg]: highlightShape,\n [classes.toolbarOnTop]: toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'\n },\n className\n );\n\n return (\n <div\n ref={ref => (this.wrapperRef = ref)}\n style={{ width: sizeStyle.width }}\n className={names}\n >\n <SlateEditor\n plugins={this.plugins}\n innerRef={r => {\n if (r) {\n this.slateEditor = r;\n }\n }}\n ref={r => (this.editor = r && this.props.editorRef(r))}\n toolbarRef={r => {\n if (r) {\n this.toolbarRef = r;\n }\n }}\n value={value}\n focus={this.focus}\n onKeyDown={onKeyDown}\n onChange={this.onChange}\n onBlur={this.onBlur}\n onDrop={(event, editor) => this.onDropPaste(event, editor, true)}\n onPaste={(event, editor) => this.onDropPaste(event, editor)}\n onFocus={this.onFocus}\n onEditingDone={this.onEditingDone}\n focusedNode={focusedNode}\n normalize={this.normalize}\n readOnly={disabled}\n spellCheck={spellCheck}\n className={classes.slateEditor}\n style={{\n minHeight: sizeStyle.minHeight,\n height: sizeStyle.height,\n maxHeight: sizeStyle.maxHeight\n }}\n pluginProps={pluginProps}\n toolbarOpts={toolbarOpts}\n placeholder={placeholder}\n onDataChange={this.changeData}\n />\n </div>\n );\n }\n}\n\n// TODO color - hardcoded gray background and keypad colors will need to change too\nconst styles = {\n withBg: {\n backgroundColor: 'rgba(0,0,0,0.06)'\n },\n slateEditor: {\n fontFamily: 'Roboto, sans-serif',\n\n '& table': {\n tableLayout: 'fixed',\n width: '100%',\n borderCollapse: 'collapse',\n color: color.text(),\n backgroundColor: color.background()\n },\n '& table:not([border=\"1\"]) tr': {\n borderTop: '1px solid #dfe2e5'\n // TODO perhaps secondary color for background, for now disable\n // '&:nth-child(2n)': {\n // backgroundColor: '#f6f8fa'\n // }\n },\n '& td, th': {\n padding: '.6em 1em',\n textAlign: 'center'\n },\n '& table:not([border=\"1\"]) td, th': {\n border: '1px solid #dfe2e5'\n }\n },\n toolbarOnTop: {\n marginTop: '45px'\n }\n};\n\nexport default withStyles(styles)(Editor);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAKA,IAAMA,GAAG,GAAG,IAAAC,iBAAA,EAAM,sBAAN,CAAZ;AAEA,IAAMC,kBAAkB,GAAG;EACzBC,QAAQ,EAAE,QADe;EAEzBC,SAAS,EAAE,MAFc;EAGzBC,aAAa,EAAE,KAHU;EAIzBC,QAAQ,EAAE,IAJe;EAKzBC,MAAM,EAAE;AALiB,CAA3B;AAQA,IAAMC,wBAAwB,GAAG;EAC/BC,OAAO,EAAE,EADsB;EAE/BC,eAAe,EAAE,2BAAM,CACtB,CAH8B;EAI/BC,kBAAkB,EAAE,8BAAM,CACzB;AAL8B,CAAjC;AAQA,IAAMC,8BAA8B,GAAG,EAAvC;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAAAC,WAAW,EAAI;EACvC,uCACKZ,kBADL,GAEKY,WAFL;AAID,CALD;;IAOaC,M;;;;;EA4EX,gBAAYC,MAAZ,EAAmB;IAAA;;IAAA;IACjB,0BAAMA,MAAN;IADiB,kGAcH,UAAAA,KAAK,EAAI;MACvB,IAAMC,2BAA2B,mCAC5BT,wBAD4B,GAE5BQ,KAAK,CAACE,iBAFsB,CAAjC;;MAKA,MAAKC,OAAL,GAAe,IAAAC,qBAAA,EAAaJ,KAAK,CAACK,aAAnB,EAAkC;QAC/CC,IAAI,EAAE;UACJC,OAAO,EAAE,MAAKC,WADV;UAEJC,OAAO,EAAE,MAAKC,aAFV;UAGJC,MAAM,EAAE,MAA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