@pie-lib/editable-html 8.1.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/lib/editor.js +84 -81
- 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 +14 -19
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +24 -4
- package/lib/plugins/characters/utils.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 +7 -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 +15 -13
- 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 +40 -52
- 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 +31 -6
- package/src/plugins/characters/index.jsx +7 -0
- package/src/plugins/characters/utils.js +8 -4
- package/src/plugins/image/component.jsx +49 -20
- package/src/plugins/image/image-toolbar.jsx +38 -2
- package/src/plugins/image/index.jsx +38 -9
- package/src/plugins/respArea/index.jsx +5 -0
- package/src/plugins/table/index.jsx +3 -3
- package/src/plugins/toolbar/toolbar.jsx +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,63 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [9.0.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.1.2...@pie-lib/editable-html@9.0.0) (2022-07-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **editable-html:** add another sanity checks ([d872981](https://github.com/pie-framework/pie-lib/commit/d87298124408b55d75d42598c0272294a0881043))
|
|
12
|
+
* **editable-html:** add sanity check for drop / paste file - sentry ([d27d252](https://github.com/pie-framework/pie-lib/commit/d27d2522d0567333e0af1ce49a3793ebc44ef032))
|
|
13
|
+
* **editable-html:** add sanity check in respArea - toolbar ([1e4c9f2](https://github.com/pie-framework/pie-lib/commit/1e4c9f21be612409deee08cca6790f019f5d01d3))
|
|
14
|
+
* **editable-html:** potential fix - sanity check for node key in table - sentry ([f417c72](https://github.com/pie-framework/pie-lib/commit/f417c724c49e50e8c3c514b46b42f5d410da2942))
|
|
15
|
+
* code tweaks ([a390dcb](https://github.com/pie-framework/pie-lib/commit/a390dcbe22e9d37776b91071ec1502bbad59ff2a))
|
|
16
|
+
* duplicate image issue ([924a4df](https://github.com/pie-framework/pie-lib/commit/924a4df45cf9f1601704dd48c2a757dd02e2e7a3))
|
|
17
|
+
* tests ([41caca9](https://github.com/pie-framework/pie-lib/commit/41caca9855aa8099f5cb7286cc6660dd20d5c622))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **characters:** special character accents span 2 rows, added border for visibility [PD-1462] ([c60b0bc](https://github.com/pie-framework/pie-lib/commit/c60b0bc8ff45cc01f53bc752fd5dd64da623f6be))
|
|
23
|
+
* **editable-html:** add image alignment buttons ([a076a41](https://github.com/pie-framework/pie-lib/commit/a076a4193c82dc552bd21de7a8f928d8481e73e6))
|
|
24
|
+
* **editable-html:** BREAKING CHANGE add image alignment buttons in image toolbar PD-1802 ([bcb59e5](https://github.com/pie-framework/pie-lib/commit/bcb59e5737fe61560fac8de01276baf187888048))
|
|
25
|
+
* **editable-html:** image resize functionality PD-1801. BREAKING CHANGE removed percent buttons from image toolbar ([1d5c33d](https://github.com/pie-framework/pie-lib/commit/1d5c33d4bcd224fa1b38310d7f0f21fba0888f12))
|
|
26
|
+
* **editable-html:** Make editable-html style inline with mathjax: font, radical, exponential, italicize variables PD-1521 ([20752ad](https://github.com/pie-framework/pie-lib/commit/20752ad453880da881bc0a2880c6ef9a10b9589d))
|
|
27
|
+
* **editable-html, render-ui:** wrap up PD-1802 ([e10babf](https://github.com/pie-framework/pie-lib/commit/e10babf2e80aed67c856e9e021e37072e3df33fb))
|
|
28
|
+
* **editor:** added insert spanish and special characters as default [PD-1883] ([26655ec](https://github.com/pie-framework/pie-lib/commit/26655ec87cb4b8a82357e88b62faad3fdc7c296a))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### BREAKING CHANGES
|
|
32
|
+
|
|
33
|
+
* **editable-html:** Added new buttons in image toolbar.
|
|
34
|
+
The buttons control image horizontal alignment.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [8.1.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.1.1...@pie-lib/editable-html@8.1.2) (2022-06-28)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* running locally does not work ([ce2d09a](https://github.com/pie-framework/pie-lib/commit/ce2d09a3556937aea4a1c8075a2dbc7c1131fd5f))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## [8.1.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.1.0...@pie-lib/editable-html@8.1.1) (2022-06-28)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
|
|
56
|
+
* running locally does not work ([e2fbb74](https://github.com/pie-framework/pie-lib/commit/e2fbb74c79bbb2ad6e9af447af51687391d89ad3))
|
|
57
|
+
* **editable-html:** fix image remove ([0f446b3](https://github.com/pie-framework/pie-lib/commit/0f446b38d93fec1548b9ff5c73cc48f2f10d9397))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
6
63
|
# [8.1.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@8.0.0...@pie-lib/editable-html@8.1.0) (2022-06-27)
|
|
7
64
|
|
|
8
65
|
|
package/lib/editor.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
@@ -19,6 +21,24 @@ Object.defineProperty(exports, "DEFAULT_PLUGINS", {
|
|
|
19
21
|
});
|
|
20
22
|
exports.serialization = exports["default"] = exports.Editor = void 0;
|
|
21
23
|
|
|
24
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
25
|
+
|
|
26
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
27
|
+
|
|
28
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
29
|
+
|
|
30
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
31
|
+
|
|
32
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
33
|
+
|
|
34
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
35
|
+
|
|
36
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
37
|
+
|
|
38
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
39
|
+
|
|
40
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
41
|
+
|
|
22
42
|
var _slateReact = require("slate-react");
|
|
23
43
|
|
|
24
44
|
var _slatePropTypes = _interopRequireDefault(require("slate-prop-types"));
|
|
@@ -49,37 +69,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
49
69
|
|
|
50
70
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
51
71
|
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
55
|
-
|
|
56
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
57
|
-
|
|
58
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
59
|
-
|
|
60
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
61
|
-
|
|
62
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
63
|
-
|
|
64
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
65
|
-
|
|
66
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
67
|
-
|
|
68
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
69
|
-
|
|
70
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
71
|
-
|
|
72
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
72
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
73
73
|
|
|
74
74
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
75
75
|
|
|
76
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
77
|
-
|
|
78
76
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
79
77
|
|
|
80
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
81
|
-
|
|
82
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
78
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
83
79
|
|
|
84
80
|
var log = (0, _debug["default"])('editable-html:editor');
|
|
85
81
|
var defaultToolbarOpts = {
|
|
@@ -94,25 +90,27 @@ var defaultResponseAreaProps = {
|
|
|
94
90
|
respAreaToolbar: function respAreaToolbar() {},
|
|
95
91
|
onHandleAreaChange: function onHandleAreaChange() {}
|
|
96
92
|
};
|
|
97
|
-
var defaultLanguageCharactersProps = [
|
|
93
|
+
var defaultLanguageCharactersProps = [{
|
|
94
|
+
language: 'spanish'
|
|
95
|
+
}, {
|
|
96
|
+
language: 'special'
|
|
97
|
+
}];
|
|
98
98
|
|
|
99
99
|
var createToolbarOpts = function createToolbarOpts(toolbarOpts) {
|
|
100
100
|
return _objectSpread(_objectSpread({}, defaultToolbarOpts), toolbarOpts);
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
var Editor = /*#__PURE__*/function (_React$Component) {
|
|
104
|
-
|
|
104
|
+
(0, _inherits2["default"])(Editor, _React$Component);
|
|
105
105
|
|
|
106
106
|
var _super = _createSuper(Editor);
|
|
107
107
|
|
|
108
108
|
function Editor(_props) {
|
|
109
109
|
var _this;
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
(0, _classCallCheck2["default"])(this, Editor);
|
|
113
112
|
_this = _super.call(this, _props);
|
|
114
|
-
|
|
115
|
-
_defineProperty(_assertThisInitialized(_this), "handlePlugins", function (props) {
|
|
113
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handlePlugins", function (props) {
|
|
116
114
|
var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
|
|
117
115
|
|
|
118
116
|
_this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, {
|
|
@@ -150,6 +148,8 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
150
148
|
disableUnderline: props.disableUnderline,
|
|
151
149
|
autoWidth: props.autoWidthToolbar,
|
|
152
150
|
onDone: function onDone() {
|
|
151
|
+
var _this$state$value$sta, _this$state$value$sta2;
|
|
152
|
+
|
|
153
153
|
var nonEmpty = props.nonEmpty;
|
|
154
154
|
log('[onDone]');
|
|
155
155
|
|
|
@@ -160,7 +160,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
160
160
|
|
|
161
161
|
_this.editor.blur();
|
|
162
162
|
|
|
163
|
-
if (nonEmpty && _this.state.value.startText.text.length === 0) {
|
|
163
|
+
if (nonEmpty && ((_this$state$value$sta = _this.state.value.startText) === null || _this$state$value$sta === void 0 ? void 0 : (_this$state$value$sta2 = _this$state$value$sta.text) === null || _this$state$value$sta2 === void 0 ? void 0 : _this$state$value$sta2.length) === 0) {
|
|
164
164
|
_this.resetValue(true).then(function () {
|
|
165
165
|
_this.onEditingDone();
|
|
166
166
|
});
|
|
@@ -209,8 +209,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
211
|
});
|
|
212
|
-
|
|
213
|
-
_defineProperty(_assertThisInitialized(_this), "onPluginBlur", function (e) {
|
|
212
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginBlur", function (e) {
|
|
214
213
|
log('[onPluginBlur]', e && e.relatedTarget);
|
|
215
214
|
var target = e && e.relatedTarget;
|
|
216
215
|
var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
|
|
@@ -222,8 +221,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
222
221
|
_this.resetValue();
|
|
223
222
|
});
|
|
224
223
|
});
|
|
225
|
-
|
|
226
|
-
_defineProperty(_assertThisInitialized(_this), "onPluginFocus", function (e) {
|
|
224
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginFocus", function (e) {
|
|
227
225
|
log('[onPluginFocus]', e && e.target);
|
|
228
226
|
var target = e && e.target;
|
|
229
227
|
|
|
@@ -244,8 +242,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
244
242
|
|
|
245
243
|
_this.stashValue();
|
|
246
244
|
});
|
|
247
|
-
|
|
248
|
-
_defineProperty(_assertThisInitialized(_this), "onMathClick", function (node) {
|
|
245
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMathClick", function (node) {
|
|
249
246
|
_this.editor.change(function (c) {
|
|
250
247
|
return c.collapseToStartOf(node);
|
|
251
248
|
});
|
|
@@ -254,8 +251,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
254
251
|
selectedNode: node
|
|
255
252
|
});
|
|
256
253
|
});
|
|
257
|
-
|
|
258
|
-
_defineProperty(_assertThisInitialized(_this), "onEditingDone", function () {
|
|
254
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditingDone", function () {
|
|
259
255
|
log('[onEditingDone]');
|
|
260
256
|
|
|
261
257
|
_this.setState({
|
|
@@ -267,8 +263,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
267
263
|
|
|
268
264
|
_this.props.onChange(_this.state.value, true);
|
|
269
265
|
});
|
|
270
|
-
|
|
271
|
-
_defineProperty(_assertThisInitialized(_this), "handleBlur", function (resolve) {
|
|
266
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (resolve) {
|
|
272
267
|
var nonEmpty = _this.props.nonEmpty;
|
|
273
268
|
var doneOn = _this.state.toolbarOpts.doneOn;
|
|
274
269
|
|
|
@@ -282,7 +277,9 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
282
277
|
}
|
|
283
278
|
|
|
284
279
|
if (doneOn === 'blur') {
|
|
285
|
-
|
|
280
|
+
var _this$state$value$sta3, _this$state$value$sta4;
|
|
281
|
+
|
|
282
|
+
if (nonEmpty && ((_this$state$value$sta3 = _this.state.value.startText) === null || _this$state$value$sta3 === void 0 ? void 0 : (_this$state$value$sta4 = _this$state$value$sta3.text) === null || _this$state$value$sta4 === void 0 ? void 0 : _this$state$value$sta4.length) === 0) {
|
|
286
283
|
_this.resetValue(true).then(function () {
|
|
287
284
|
_this.onEditingDone();
|
|
288
285
|
|
|
@@ -295,8 +292,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
295
292
|
}
|
|
296
293
|
}
|
|
297
294
|
});
|
|
298
|
-
|
|
299
|
-
_defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
|
|
295
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (event) {
|
|
300
296
|
log('[onBlur]');
|
|
301
297
|
var target = event.relatedTarget;
|
|
302
298
|
var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
|
|
@@ -304,13 +300,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
304
300
|
return new Promise(function (resolve) {
|
|
305
301
|
_this.setState({
|
|
306
302
|
focusedNode: node
|
|
307
|
-
}, _this.handleBlur.bind(
|
|
303
|
+
}, _this.handleBlur.bind((0, _assertThisInitialized2["default"])(_this), resolve));
|
|
308
304
|
|
|
309
305
|
_this.props.onBlur(event);
|
|
310
306
|
});
|
|
311
307
|
});
|
|
312
|
-
|
|
313
|
-
_defineProperty(_assertThisInitialized(_this), "handleDomBlur", function (e) {
|
|
308
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDomBlur", function (e) {
|
|
314
309
|
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
315
310
|
setTimeout(function () {
|
|
316
311
|
if (!_this.wrapperRef) {
|
|
@@ -329,8 +324,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
329
324
|
}
|
|
330
325
|
}, 50);
|
|
331
326
|
});
|
|
332
|
-
|
|
333
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
|
|
327
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
|
|
334
328
|
return new Promise(function (resolve) {
|
|
335
329
|
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
336
330
|
log('[onFocus]', document.activeElement);
|
|
@@ -376,8 +370,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
376
370
|
resolve();
|
|
377
371
|
});
|
|
378
372
|
});
|
|
379
|
-
|
|
380
|
-
_defineProperty(_assertThisInitialized(_this), "stashValue", function () {
|
|
373
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stashValue", function () {
|
|
381
374
|
log('[stashValue]');
|
|
382
375
|
|
|
383
376
|
if (!_this.state.stashedValue) {
|
|
@@ -386,8 +379,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
386
379
|
});
|
|
387
380
|
}
|
|
388
381
|
});
|
|
389
|
-
|
|
390
|
-
_defineProperty(_assertThisInitialized(_this), "resetValue", function (force) {
|
|
382
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetValue", function (force) {
|
|
391
383
|
var _this$state = _this.state,
|
|
392
384
|
value = _this$state.value,
|
|
393
385
|
focusedNode = _this$state.focusedNode;
|
|
@@ -421,8 +413,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
421
413
|
return Promise.resolve({});
|
|
422
414
|
}
|
|
423
415
|
});
|
|
424
|
-
|
|
425
|
-
_defineProperty(_assertThisInitialized(_this), "onChange", function (change, done) {
|
|
416
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (change, done) {
|
|
426
417
|
log('[onChange]');
|
|
427
418
|
var value = change.value;
|
|
428
419
|
var charactersLimit = _this.props.charactersLimit;
|
|
@@ -441,8 +432,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
441
432
|
}
|
|
442
433
|
});
|
|
443
434
|
});
|
|
444
|
-
|
|
445
|
-
_defineProperty(_assertThisInitialized(_this), "valueToSize", function (v) {
|
|
435
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "valueToSize", function (v) {
|
|
446
436
|
if (!v) {
|
|
447
437
|
return;
|
|
448
438
|
}
|
|
@@ -464,8 +454,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
464
454
|
|
|
465
455
|
return;
|
|
466
456
|
});
|
|
467
|
-
|
|
468
|
-
_defineProperty(_assertThisInitialized(_this), "validateNode", function (node) {
|
|
457
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "validateNode", function (node) {
|
|
469
458
|
if (node.object !== 'block') return;
|
|
470
459
|
var last = node.nodes.last();
|
|
471
460
|
if (!last) return;
|
|
@@ -478,8 +467,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
478
467
|
log('[validateNode] parent:', parent, p);
|
|
479
468
|
return undefined;
|
|
480
469
|
});
|
|
481
|
-
|
|
482
|
-
_defineProperty(_assertThisInitialized(_this), "changeData", function (key, data) {
|
|
470
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (key, data) {
|
|
483
471
|
log('[changeData]. .. ', key, data);
|
|
484
472
|
/**
|
|
485
473
|
* HACK ALERT: We should be calling setState here and storing the change data:
|
|
@@ -498,17 +486,15 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
498
486
|
data: data
|
|
499
487
|
};
|
|
500
488
|
});
|
|
501
|
-
|
|
502
|
-
_defineProperty(_assertThisInitialized(_this), "focus", function (pos, node) {
|
|
489
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (pos, node) {
|
|
503
490
|
var position = pos || 'end';
|
|
504
491
|
|
|
505
492
|
_this.props.focus(position, node);
|
|
506
493
|
});
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(event, change, dropContext) {
|
|
494
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDropPaste", /*#__PURE__*/function () {
|
|
495
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(event, change, dropContext) {
|
|
510
496
|
var editor, transfer, file, src, inline, range, ch;
|
|
511
|
-
return
|
|
497
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
512
498
|
while (1) {
|
|
513
499
|
switch (_context.prev = _context.next) {
|
|
514
500
|
case 0:
|
|
@@ -524,7 +510,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
524
510
|
transfer = (0, _slateReact.getEventTransfer)(event);
|
|
525
511
|
file = transfer.files[0];
|
|
526
512
|
|
|
527
|
-
if (!(file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png')) {
|
|
513
|
+
if (!(file && file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png')) {
|
|
528
514
|
_context.next = 20;
|
|
529
515
|
break;
|
|
530
516
|
}
|
|
@@ -579,7 +565,6 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
579
565
|
return _ref.apply(this, arguments);
|
|
580
566
|
};
|
|
581
567
|
}());
|
|
582
|
-
|
|
583
568
|
_this.state = {
|
|
584
569
|
value: _props.value,
|
|
585
570
|
toolbarOpts: createToolbarOpts(_props.toolbarOpts)
|
|
@@ -594,7 +579,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
594
579
|
return _this;
|
|
595
580
|
}
|
|
596
581
|
|
|
597
|
-
|
|
582
|
+
(0, _createClass2["default"])(Editor, [{
|
|
598
583
|
key: "componentDidMount",
|
|
599
584
|
value: function componentDidMount() {
|
|
600
585
|
var _this2 = this;
|
|
@@ -700,7 +685,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
700
685
|
toolbarOpts = _this$state2.toolbarOpts;
|
|
701
686
|
log('[render] value: ', value);
|
|
702
687
|
var sizeStyle = this.buildSizeStyle();
|
|
703
|
-
var names = (0, _classnames["default"])((_classNames = {},
|
|
688
|
+
var names = (0, _classnames["default"])((_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.withBg, highlightShape), (0, _defineProperty2["default"])(_classNames, classes.toolbarOnTop, toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'), _classNames), className);
|
|
704
689
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
705
690
|
ref: function ref(_ref2) {
|
|
706
691
|
return _this3.wrapperRef = _ref2;
|
|
@@ -754,14 +739,12 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
754
739
|
}));
|
|
755
740
|
}
|
|
756
741
|
}]);
|
|
757
|
-
|
|
758
742
|
return Editor;
|
|
759
743
|
}(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
|
|
760
744
|
|
|
761
745
|
|
|
762
746
|
exports.Editor = Editor;
|
|
763
|
-
|
|
764
|
-
_defineProperty(Editor, "propTypes", {
|
|
747
|
+
(0, _defineProperty2["default"])(Editor, "propTypes", {
|
|
765
748
|
autoFocus: _propTypes["default"].bool,
|
|
766
749
|
editorRef: _propTypes["default"].func.isRequired,
|
|
767
750
|
onRef: _propTypes["default"].func.isRequired,
|
|
@@ -814,8 +797,7 @@ _defineProperty(Editor, "propTypes", {
|
|
|
814
797
|
maxImageWidth: _propTypes["default"].number,
|
|
815
798
|
maxImageHeight: _propTypes["default"].number
|
|
816
799
|
});
|
|
817
|
-
|
|
818
|
-
_defineProperty(Editor, "defaultProps", {
|
|
800
|
+
(0, _defineProperty2["default"])(Editor, "defaultProps", {
|
|
819
801
|
disableUnderline: true,
|
|
820
802
|
onFocus: function onFocus() {},
|
|
821
803
|
onBlur: function onBlur() {},
|
|
@@ -824,7 +806,6 @@ _defineProperty(Editor, "defaultProps", {
|
|
|
824
806
|
responseAreaProps: defaultResponseAreaProps,
|
|
825
807
|
languageCharactersProps: defaultLanguageCharactersProps
|
|
826
808
|
});
|
|
827
|
-
|
|
828
809
|
var styles = {
|
|
829
810
|
withBg: {
|
|
830
811
|
backgroundColor: 'rgba(0,0,0,0.06)'
|
|
@@ -851,7 +832,29 @@ var styles = {
|
|
|
851
832
|
},
|
|
852
833
|
'& table:not([border="1"]) td, th': {
|
|
853
834
|
border: '1px solid #dfe2e5'
|
|
854
|
-
}
|
|
835
|
+
},
|
|
836
|
+
'& .RawMathPreview-root-143 *': {
|
|
837
|
+
fontFamily: 'MJXZERO, MJXTEX !important'
|
|
838
|
+
},
|
|
839
|
+
'& .mq-math-mode var, .mq-math-mode i, .mq-math-mode i.mq-font': {
|
|
840
|
+
fontFamily: 'MJXZERO, MJXTEX-I !important'
|
|
841
|
+
},
|
|
842
|
+
'& .mq-math-mode .mq-sqrt-stem': {
|
|
843
|
+
borderTop: '0.07em solid',
|
|
844
|
+
marginLeft: '-1.5px',
|
|
845
|
+
marginTop: '-2px !important',
|
|
846
|
+
paddingTop: '5px !important'
|
|
847
|
+
},
|
|
848
|
+
'& .mq-supsub ': {
|
|
849
|
+
fontSize: '70.7%'
|
|
850
|
+
},
|
|
851
|
+
'& .mq-math-mode .mq-supsub.mq-sup-only': {
|
|
852
|
+
verticalAlign: '-0.1em !important',
|
|
853
|
+
'& .mq-sup': {
|
|
854
|
+
marginBottom: '0px !important'
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
'-webkit-font-smoothing': 'antialiased !important'
|
|
855
858
|
},
|
|
856
859
|
toolbarOnTop: {
|
|
857
860
|
marginTop: '45px'
|