@pie-lib/editable-html 7.17.4-next.371 → 7.17.4-next.414
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/editor.js +116 -110
- package/lib/editor.js.map +1 -1
- package/lib/index.js +30 -42
- package/lib/index.js.map +1 -1
- package/lib/plugins/characters/custom-popover.js +8 -11
- package/lib/plugins/characters/custom-popover.js.map +1 -1
- package/lib/plugins/characters/index.js +8 -18
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/image/component.js +65 -54
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +65 -27
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +47 -12
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +8 -12
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +6 -15
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +2 -2
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +8 -8
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +15 -20
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +26 -41
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +15 -25
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +22 -35
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +24 -37
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +8 -8
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +5 -5
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +5 -5
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +2 -2
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +5 -5
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +2 -2
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +9 -9
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +11 -11
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +25 -36
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +5 -5
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +2 -2
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +18 -30
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +5 -5
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +25 -43
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +30 -49
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/serialization.js +2 -2
- package/lib/serialization.js.map +1 -1
- package/package.json +5 -5
- package/src/editor.jsx +48 -25
- package/src/plugins/image/component.jsx +49 -20
- package/src/plugins/image/image-toolbar.jsx +37 -2
- package/src/plugins/image/index.jsx +38 -9
package/lib/editor.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
@@ -19,6 +21,24 @@ Object.defineProperty(exports, "DEFAULT_PLUGINS", {
|
|
|
19
21
|
});
|
|
20
22
|
exports.serialization = exports["default"] = exports.Editor = void 0;
|
|
21
23
|
|
|
24
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
25
|
+
|
|
26
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
27
|
+
|
|
28
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
29
|
+
|
|
30
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
31
|
+
|
|
32
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
33
|
+
|
|
34
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
35
|
+
|
|
36
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
37
|
+
|
|
38
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
39
|
+
|
|
40
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
41
|
+
|
|
22
42
|
var _slateReact = require("slate-react");
|
|
23
43
|
|
|
24
44
|
var _slatePropTypes = _interopRequireDefault(require("slate-prop-types"));
|
|
@@ -49,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
|
|
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) {
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
486
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDropPaste", /*#__PURE__*/function () {
|
|
487
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(event, change, dropContext) {
|
|
488
|
+
var editor, transfer, file, src, inline, range, ch;
|
|
489
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
514
490
|
while (1) {
|
|
515
491
|
switch (_context.prev = _context.next) {
|
|
516
492
|
case 0:
|
|
@@ -526,49 +502,61 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
526
502
|
transfer = (0, _slateReact.getEventTransfer)(event);
|
|
527
503
|
file = transfer.files[0];
|
|
528
504
|
|
|
529
|
-
if (file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png') {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
var inline = _slate.Inline.create({
|
|
533
|
-
type: 'image',
|
|
534
|
-
isVoid: true,
|
|
535
|
-
data: {
|
|
536
|
-
loading: false,
|
|
537
|
-
src: src
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
if (dropContext) {
|
|
542
|
-
_this.focus();
|
|
543
|
-
} else {
|
|
544
|
-
var range = (0, _slateReact.getEventRange)(event, editor);
|
|
545
|
-
|
|
546
|
-
if (range) {
|
|
547
|
-
change.select(range);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
var ch = change.insertInline(inline);
|
|
552
|
-
|
|
553
|
-
_this.onChange(ch);
|
|
554
|
-
})["catch"](function (err) {
|
|
555
|
-
return log('[onDropPaste] error: ', err);
|
|
556
|
-
});
|
|
505
|
+
if (!(file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png')) {
|
|
506
|
+
_context.next = 20;
|
|
507
|
+
break;
|
|
557
508
|
}
|
|
558
509
|
|
|
559
|
-
|
|
510
|
+
_context.prev = 6;
|
|
511
|
+
log('[onDropPaste]');
|
|
512
|
+
_context.next = 10;
|
|
513
|
+
return (0, serialization.getBase64)(file);
|
|
514
|
+
|
|
515
|
+
case 10:
|
|
516
|
+
src = _context.sent;
|
|
517
|
+
inline = _slate.Inline.create({
|
|
518
|
+
type: 'image',
|
|
519
|
+
isVoid: true,
|
|
520
|
+
data: {
|
|
521
|
+
loading: false,
|
|
522
|
+
src: src
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
if (dropContext) {
|
|
527
|
+
_this.focus();
|
|
528
|
+
} else {
|
|
529
|
+
range = (0, _slateReact.getEventRange)(event, editor);
|
|
530
|
+
|
|
531
|
+
if (range) {
|
|
532
|
+
change.select(range);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
ch = change.insertInline(inline);
|
|
537
|
+
|
|
538
|
+
_this.onChange(ch);
|
|
539
|
+
|
|
540
|
+
_context.next = 20;
|
|
541
|
+
break;
|
|
542
|
+
|
|
543
|
+
case 17:
|
|
544
|
+
_context.prev = 17;
|
|
545
|
+
_context.t0 = _context["catch"](6);
|
|
546
|
+
log('[onDropPaste] error: ', _context.t0);
|
|
547
|
+
|
|
548
|
+
case 20:
|
|
560
549
|
case "end":
|
|
561
550
|
return _context.stop();
|
|
562
551
|
}
|
|
563
552
|
}
|
|
564
|
-
}, _callee);
|
|
553
|
+
}, _callee, null, [[6, 17]]);
|
|
565
554
|
}));
|
|
566
555
|
|
|
567
556
|
return function (_x, _x2, _x3) {
|
|
568
557
|
return _ref.apply(this, arguments);
|
|
569
558
|
};
|
|
570
559
|
}());
|
|
571
|
-
|
|
572
560
|
_this.state = {
|
|
573
561
|
value: _props.value,
|
|
574
562
|
toolbarOpts: createToolbarOpts(_props.toolbarOpts)
|
|
@@ -583,7 +571,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
583
571
|
return _this;
|
|
584
572
|
}
|
|
585
573
|
|
|
586
|
-
|
|
574
|
+
(0, _createClass2["default"])(Editor, [{
|
|
587
575
|
key: "componentDidMount",
|
|
588
576
|
value: function componentDidMount() {
|
|
589
577
|
var _this2 = this;
|
|
@@ -689,7 +677,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
689
677
|
toolbarOpts = _this$state2.toolbarOpts;
|
|
690
678
|
log('[render] value: ', value);
|
|
691
679
|
var sizeStyle = this.buildSizeStyle();
|
|
692
|
-
var names = (0, _classnames["default"])((_classNames = {},
|
|
680
|
+
var names = (0, _classnames["default"])((_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.withBg, highlightShape), (0, _defineProperty2["default"])(_classNames, classes.toolbarOnTop, toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'), _classNames), className);
|
|
693
681
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
694
682
|
ref: function ref(_ref2) {
|
|
695
683
|
return _this3.wrapperRef = _ref2;
|
|
@@ -743,14 +731,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
743
731
|
}));
|
|
744
732
|
}
|
|
745
733
|
}]);
|
|
746
|
-
|
|
747
734
|
return Editor;
|
|
748
735
|
}(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
|
|
749
736
|
|
|
750
737
|
|
|
751
738
|
exports.Editor = Editor;
|
|
752
|
-
|
|
753
|
-
_defineProperty(Editor, "propTypes", {
|
|
739
|
+
(0, _defineProperty2["default"])(Editor, "propTypes", {
|
|
754
740
|
autoFocus: _propTypes["default"].bool,
|
|
755
741
|
editorRef: _propTypes["default"].func.isRequired,
|
|
756
742
|
onRef: _propTypes["default"].func.isRequired,
|
|
@@ -803,8 +789,7 @@ _defineProperty(Editor, "propTypes", {
|
|
|
803
789
|
maxImageWidth: _propTypes["default"].number,
|
|
804
790
|
maxImageHeight: _propTypes["default"].number
|
|
805
791
|
});
|
|
806
|
-
|
|
807
|
-
_defineProperty(Editor, "defaultProps", {
|
|
792
|
+
(0, _defineProperty2["default"])(Editor, "defaultProps", {
|
|
808
793
|
disableUnderline: true,
|
|
809
794
|
onFocus: function onFocus() {},
|
|
810
795
|
onBlur: function onBlur() {},
|
|
@@ -813,7 +798,6 @@ _defineProperty(Editor, "defaultProps", {
|
|
|
813
798
|
responseAreaProps: defaultResponseAreaProps,
|
|
814
799
|
languageCharactersProps: defaultLanguageCharactersProps
|
|
815
800
|
});
|
|
816
|
-
|
|
817
801
|
var styles = {
|
|
818
802
|
withBg: {
|
|
819
803
|
backgroundColor: 'rgba(0,0,0,0.06)'
|
|
@@ -840,7 +824,29 @@ var styles = {
|
|
|
840
824
|
},
|
|
841
825
|
'& table:not([border="1"]) td, th': {
|
|
842
826
|
border: '1px solid #dfe2e5'
|
|
843
|
-
}
|
|
827
|
+
},
|
|
828
|
+
'& .RawMathPreview-root-143 *': {
|
|
829
|
+
fontFamily: 'MJXZERO, MJXTEX !important'
|
|
830
|
+
},
|
|
831
|
+
'& .mq-math-mode var, .mq-math-mode i, .mq-math-mode i.mq-font': {
|
|
832
|
+
fontFamily: 'MJXZERO, MJXTEX-I !important'
|
|
833
|
+
},
|
|
834
|
+
'& .mq-math-mode .mq-sqrt-stem': {
|
|
835
|
+
borderTop: '0.07em solid',
|
|
836
|
+
marginLeft: '-1.5px',
|
|
837
|
+
marginTop: '-2px !important',
|
|
838
|
+
paddingTop: '5px !important'
|
|
839
|
+
},
|
|
840
|
+
'& .mq-supsub ': {
|
|
841
|
+
fontSize: '70.7%'
|
|
842
|
+
},
|
|
843
|
+
'& .mq-math-mode .mq-supsub.mq-sup-only': {
|
|
844
|
+
verticalAlign: '-0.1em !important',
|
|
845
|
+
'& .mq-sup': {
|
|
846
|
+
marginBottom: '0px !important'
|
|
847
|
+
}
|
|
848
|
+
},
|
|
849
|
+
'-webkit-font-smoothing': 'antialiased !important'
|
|
844
850
|
},
|
|
845
851
|
toolbarOnTop: {
|
|
846
852
|
marginTop: '45px'
|