@pie-lib/editable-html 11.4.0 → 11.5.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 +13 -65
- package/package.json +8 -7
- package/src/editor.jsx +2 -2
- package/src/plugins/media/media-dialog.js +1 -1
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +1 -1
- package/src/plugins/toolbar/editor-and-toolbar.jsx +1 -1
- package/lib/block-tags.js +0 -25
- package/lib/block-tags.js.map +0 -1
- package/lib/constants.js +0 -16
- package/lib/constants.js.map +0 -1
- package/lib/editor.js +0 -1355
- package/lib/editor.js.map +0 -1
- package/lib/index.js +0 -269
- package/lib/index.js.map +0 -1
- package/lib/parse-html.js +0 -16
- package/lib/parse-html.js.map +0 -1
- package/lib/plugins/characters/custom-popper.js +0 -73
- package/lib/plugins/characters/custom-popper.js.map +0 -1
- package/lib/plugins/characters/index.js +0 -305
- package/lib/plugins/characters/index.js.map +0 -1
- package/lib/plugins/characters/utils.js +0 -381
- package/lib/plugins/characters/utils.js.map +0 -1
- package/lib/plugins/css/icons/index.js +0 -37
- package/lib/plugins/css/icons/index.js.map +0 -1
- package/lib/plugins/css/index.js +0 -397
- package/lib/plugins/css/index.js.map +0 -1
- package/lib/plugins/customPlugin/index.js +0 -114
- package/lib/plugins/customPlugin/index.js.map +0 -1
- package/lib/plugins/html/icons/index.js +0 -38
- package/lib/plugins/html/icons/index.js.map +0 -1
- package/lib/plugins/html/index.js +0 -80
- package/lib/plugins/html/index.js.map +0 -1
- package/lib/plugins/image/alt-dialog.js +0 -129
- package/lib/plugins/image/alt-dialog.js.map +0 -1
- package/lib/plugins/image/component.js +0 -419
- package/lib/plugins/image/component.js.map +0 -1
- package/lib/plugins/image/image-toolbar.js +0 -177
- package/lib/plugins/image/image-toolbar.js.map +0 -1
- package/lib/plugins/image/index.js +0 -263
- package/lib/plugins/image/index.js.map +0 -1
- package/lib/plugins/image/insert-image-handler.js +0 -161
- package/lib/plugins/image/insert-image-handler.js.map +0 -1
- package/lib/plugins/index.js +0 -402
- package/lib/plugins/index.js.map +0 -1
- package/lib/plugins/list/index.js +0 -334
- package/lib/plugins/list/index.js.map +0 -1
- package/lib/plugins/math/index.js +0 -454
- package/lib/plugins/math/index.js.map +0 -1
- package/lib/plugins/media/index.js +0 -387
- package/lib/plugins/media/index.js.map +0 -1
- package/lib/plugins/media/media-dialog.js +0 -709
- package/lib/plugins/media/media-dialog.js.map +0 -1
- package/lib/plugins/media/media-toolbar.js +0 -101
- package/lib/plugins/media/media-toolbar.js.map +0 -1
- package/lib/plugins/media/media-wrapper.js +0 -93
- package/lib/plugins/media/media-wrapper.js.map +0 -1
- package/lib/plugins/rendering/index.js +0 -46
- package/lib/plugins/rendering/index.js.map +0 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +0 -254
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +0 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +0 -97
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +0 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +0 -57
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +0 -1
- package/lib/plugins/respArea/icons/index.js +0 -95
- package/lib/plugins/respArea/icons/index.js.map +0 -1
- package/lib/plugins/respArea/index.js +0 -341
- package/lib/plugins/respArea/index.js.map +0 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +0 -75
- package/lib/plugins/respArea/inline-dropdown/index.js.map +0 -1
- package/lib/plugins/respArea/math-templated/index.js +0 -130
- package/lib/plugins/respArea/math-templated/index.js.map +0 -1
- package/lib/plugins/respArea/utils.js +0 -125
- package/lib/plugins/respArea/utils.js.map +0 -1
- package/lib/plugins/table/CustomTablePlugin.js +0 -133
- package/lib/plugins/table/CustomTablePlugin.js.map +0 -1
- package/lib/plugins/table/icons/index.js +0 -69
- package/lib/plugins/table/icons/index.js.map +0 -1
- package/lib/plugins/table/index.js +0 -483
- package/lib/plugins/table/index.js.map +0 -1
- package/lib/plugins/table/table-toolbar.js +0 -187
- package/lib/plugins/table/table-toolbar.js.map +0 -1
- package/lib/plugins/textAlign/icons/index.js +0 -226
- package/lib/plugins/textAlign/icons/index.js.map +0 -1
- package/lib/plugins/textAlign/index.js +0 -34
- package/lib/plugins/textAlign/index.js.map +0 -1
- package/lib/plugins/toolbar/default-toolbar.js +0 -229
- package/lib/plugins/toolbar/default-toolbar.js.map +0 -1
- package/lib/plugins/toolbar/done-button.js +0 -53
- package/lib/plugins/toolbar/done-button.js.map +0 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +0 -286
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +0 -1
- package/lib/plugins/toolbar/index.js +0 -34
- package/lib/plugins/toolbar/index.js.map +0 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +0 -194
- package/lib/plugins/toolbar/toolbar-buttons.js.map +0 -1
- package/lib/plugins/toolbar/toolbar.js +0 -376
- package/lib/plugins/toolbar/toolbar.js.map +0 -1
- package/lib/plugins/utils.js +0 -62
- package/lib/plugins/utils.js.map +0 -1
- package/lib/serialization.js +0 -677
- package/lib/serialization.js.map +0 -1
- package/lib/shared/alert-dialog.js +0 -75
- package/lib/shared/index.js +0 -136
- package/lib/theme.js +0 -9
- package/lib/theme.js.map +0 -1
package/lib/editor.js
DELETED
|
@@ -1,1355 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(exports, "ALL_PLUGINS", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _plugins.ALL_PLUGINS;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, "DEFAULT_PLUGINS", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
return _plugins.DEFAULT_PLUGINS;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
exports.serialization = exports["default"] = exports.Editor = void 0;
|
|
23
|
-
|
|
24
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
25
|
-
|
|
26
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
27
|
-
|
|
28
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
29
|
-
|
|
30
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
31
|
-
|
|
32
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
33
|
-
|
|
34
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
35
|
-
|
|
36
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
37
|
-
|
|
38
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
39
|
-
|
|
40
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
41
|
-
|
|
42
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
43
|
-
|
|
44
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
45
|
-
|
|
46
|
-
var _react = _interopRequireDefault(require("react"));
|
|
47
|
-
|
|
48
|
-
var _slateReact = require("slate-react");
|
|
49
|
-
|
|
50
|
-
var _slatePropTypes = _interopRequireDefault(require("slate-prop-types"));
|
|
51
|
-
|
|
52
|
-
var _slate = require("slate");
|
|
53
|
-
|
|
54
|
-
var _slatePlainSerializer = _interopRequireDefault(require("slate-plain-serializer"));
|
|
55
|
-
|
|
56
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
57
|
-
|
|
58
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
59
|
-
|
|
60
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
61
|
-
|
|
62
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
63
|
-
|
|
64
|
-
var _styles = require("@material-ui/core/styles");
|
|
65
|
-
|
|
66
|
-
var _index = require("./shared/index");
|
|
67
|
-
|
|
68
|
-
var _alertDialog = _interopRequireDefault(require("./shared/alert-dialog"));
|
|
69
|
-
|
|
70
|
-
var serialization = _interopRequireWildcard(require("./serialization"));
|
|
71
|
-
|
|
72
|
-
exports.serialization = serialization;
|
|
73
|
-
|
|
74
|
-
var _insertImageHandler = _interopRequireDefault(require("./plugins/image/insert-image-handler"));
|
|
75
|
-
|
|
76
|
-
var _plugins = require("./plugins");
|
|
77
|
-
|
|
78
|
-
var _excluded = ["customPlugins", "showParagraphs", "separateParagraphs"];
|
|
79
|
-
|
|
80
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
81
|
-
|
|
82
|
-
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; }
|
|
83
|
-
|
|
84
|
-
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); }; }
|
|
85
|
-
|
|
86
|
-
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; } }
|
|
87
|
-
|
|
88
|
-
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; }
|
|
89
|
-
|
|
90
|
-
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; }
|
|
91
|
-
|
|
92
|
-
var log = (0, _debug["default"])('editable-html:editor');
|
|
93
|
-
var defaultToolbarOpts = {
|
|
94
|
-
position: 'bottom',
|
|
95
|
-
alignment: 'left',
|
|
96
|
-
alwaysVisible: false,
|
|
97
|
-
showDone: true,
|
|
98
|
-
doneOn: 'blur'
|
|
99
|
-
};
|
|
100
|
-
var defaultResponseAreaProps = {
|
|
101
|
-
options: {},
|
|
102
|
-
respAreaToolbar: function respAreaToolbar() {},
|
|
103
|
-
onHandleAreaChange: function onHandleAreaChange() {}
|
|
104
|
-
};
|
|
105
|
-
var defaultLanguageCharactersProps = [];
|
|
106
|
-
|
|
107
|
-
var createToolbarOpts = function createToolbarOpts(toolbarOpts, error, isHtmlMode) {
|
|
108
|
-
return _objectSpread(_objectSpread(_objectSpread({}, defaultToolbarOpts), toolbarOpts), {}, {
|
|
109
|
-
error: error,
|
|
110
|
-
isHtmlMode: isHtmlMode
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* The maximum number of characters the editor can support
|
|
115
|
-
* @type {number}
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
var MAX_CHARACTERS_LIMIT = 1000000;
|
|
120
|
-
|
|
121
|
-
var Editor = /*#__PURE__*/function (_React$Component) {
|
|
122
|
-
(0, _inherits2["default"])(Editor, _React$Component);
|
|
123
|
-
|
|
124
|
-
var _super = _createSuper(Editor);
|
|
125
|
-
|
|
126
|
-
function Editor(_props) {
|
|
127
|
-
var _this;
|
|
128
|
-
|
|
129
|
-
(0, _classCallCheck2["default"])(this, Editor);
|
|
130
|
-
_this = _super.call(this, _props);
|
|
131
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setKeypadInteraction", function (interacted) {
|
|
132
|
-
_this.keypadInteractionDetected = interacted;
|
|
133
|
-
});
|
|
134
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDialog", function (open) {
|
|
135
|
-
var extraDialogProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
136
|
-
var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
137
|
-
|
|
138
|
-
_this.setState({
|
|
139
|
-
dialog: _objectSpread({
|
|
140
|
-
open: open
|
|
141
|
-
}, extraDialogProps)
|
|
142
|
-
}, callback);
|
|
143
|
-
});
|
|
144
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "toggleHtmlMode", function () {
|
|
145
|
-
_this.setState(function (prevState) {
|
|
146
|
-
return {
|
|
147
|
-
isHtmlMode: !prevState.isHtmlMode,
|
|
148
|
-
isEditedInHtmlMode: false
|
|
149
|
-
};
|
|
150
|
-
}, function () {
|
|
151
|
-
var error = _this.props.error;
|
|
152
|
-
var toolbarOpts = _this.state.toolbarOpts;
|
|
153
|
-
var newToolbarOpts = createToolbarOpts(toolbarOpts, error, _this.state.isHtmlMode);
|
|
154
|
-
|
|
155
|
-
_this.setState({
|
|
156
|
-
toolbarOpts: newToolbarOpts
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handlePlugins", function (props) {
|
|
161
|
-
var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
|
|
162
|
-
|
|
163
|
-
var htmlPluginOpts = {
|
|
164
|
-
currentValue: _this.props.value,
|
|
165
|
-
isHtmlMode: _this.state.isHtmlMode,
|
|
166
|
-
isEditedInHtmlMode: _this.state.isEditedInHtmlMode,
|
|
167
|
-
toggleHtmlMode: _this.toggleHtmlMode,
|
|
168
|
-
handleAlertDialog: _this.handleDialog
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
var _ref = props.pluginProps || {},
|
|
172
|
-
customPlugins = _ref.customPlugins;
|
|
173
|
-
|
|
174
|
-
customPlugins = customPlugins || [];
|
|
175
|
-
_this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, customPlugins, {
|
|
176
|
-
math: _objectSpread({
|
|
177
|
-
onClick: _this.onMathClick,
|
|
178
|
-
onFocus: _this.onPluginFocus,
|
|
179
|
-
onBlur: _this.onPluginBlur
|
|
180
|
-
}, props.mathMlOptions),
|
|
181
|
-
textAlign: {
|
|
182
|
-
getValue: function getValue() {
|
|
183
|
-
return _this.state.value;
|
|
184
|
-
},
|
|
185
|
-
onChange: _this.onChange
|
|
186
|
-
},
|
|
187
|
-
html: htmlPluginOpts,
|
|
188
|
-
extraCSSRules: props.extraCSSRules || {},
|
|
189
|
-
image: {
|
|
190
|
-
disableImageAlignmentButtons: props.disableImageAlignmentButtons,
|
|
191
|
-
onDelete: props.imageSupport && props.imageSupport["delete"] && function (node, done) {
|
|
192
|
-
var src = node.data.get('src');
|
|
193
|
-
props.imageSupport["delete"](src, function (e) {
|
|
194
|
-
var newPendingImages = _this.state.pendingImages.filter(function (img) {
|
|
195
|
-
return img.key !== node.key;
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
var oldScheduled = _this.state.scheduled;
|
|
199
|
-
var newState = {
|
|
200
|
-
pendingImages: newPendingImages,
|
|
201
|
-
scheduled: oldScheduled && newPendingImages.length === 0 ? false : oldScheduled
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
_this.setState(newState, function () {
|
|
205
|
-
return done(e, _this.state.value);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
},
|
|
209
|
-
insertImageRequested: props.imageSupport && function (addedImage, getHandler) {
|
|
210
|
-
var pendingImages = _this.state.pendingImages;
|
|
211
|
-
|
|
212
|
-
var onFinish = function onFinish(result) {
|
|
213
|
-
var cb;
|
|
214
|
-
|
|
215
|
-
if (_this.state.scheduled && result) {
|
|
216
|
-
// finish editing only on success
|
|
217
|
-
cb = _this.onEditingDone.bind((0, _assertThisInitialized2["default"])(_this));
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
var newPendingImages = _this.state.pendingImages.filter(function (img) {
|
|
221
|
-
return img.key !== addedImage.key;
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
var newState = {
|
|
225
|
-
pendingImages: newPendingImages
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
if (newPendingImages.length === 0) {
|
|
229
|
-
newState.scheduled = false;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
_this.setState(newState, cb);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
var callback = function callback() {
|
|
236
|
-
/**
|
|
237
|
-
* The handler is the object through which the outer context
|
|
238
|
-
* communicates file upload events like: fileChosen, cancel, progress
|
|
239
|
-
*/
|
|
240
|
-
var handler = getHandler(onFinish, function () {
|
|
241
|
-
return _this.state.value;
|
|
242
|
-
});
|
|
243
|
-
props.imageSupport.add(handler);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
_this.setState({
|
|
247
|
-
pendingImages: [].concat((0, _toConsumableArray2["default"])(pendingImages), [addedImage])
|
|
248
|
-
}, callback);
|
|
249
|
-
},
|
|
250
|
-
onFocus: _this.onPluginFocus,
|
|
251
|
-
onBlur: _this.onPluginBlur,
|
|
252
|
-
maxImageWidth: props.maxImageWidth,
|
|
253
|
-
maxImageHeight: props.maxImageHeight
|
|
254
|
-
},
|
|
255
|
-
toolbar: {
|
|
256
|
-
/**
|
|
257
|
-
* To minimize converting html -> state -> html
|
|
258
|
-
* We only emit markup once 'done' is clicked.
|
|
259
|
-
*/
|
|
260
|
-
disableScrollbar: !!props.disableScrollbar,
|
|
261
|
-
disableUnderline: props.disableUnderline,
|
|
262
|
-
autoWidth: props.autoWidthToolbar,
|
|
263
|
-
onDone: function onDone() {
|
|
264
|
-
var _this$state$value$sta, _this$state$value$sta2;
|
|
265
|
-
|
|
266
|
-
var nonEmpty = props.nonEmpty;
|
|
267
|
-
log('[onDone]');
|
|
268
|
-
|
|
269
|
-
_this.setState({
|
|
270
|
-
toolbarInFocus: false,
|
|
271
|
-
focusedNode: null,
|
|
272
|
-
focusToolbar: false
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
_this.editor.blur();
|
|
276
|
-
|
|
277
|
-
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) {
|
|
278
|
-
_this.resetValue(true).then(function () {
|
|
279
|
-
_this.onEditingDone();
|
|
280
|
-
});
|
|
281
|
-
} else {
|
|
282
|
-
_this.onEditingDone();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
table: {
|
|
287
|
-
onFocus: function onFocus() {
|
|
288
|
-
log('[table:onFocus]...');
|
|
289
|
-
|
|
290
|
-
_this.onPluginFocus();
|
|
291
|
-
},
|
|
292
|
-
onBlur: function onBlur() {
|
|
293
|
-
log('[table:onBlur]...');
|
|
294
|
-
|
|
295
|
-
_this.onPluginBlur();
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
responseArea: {
|
|
299
|
-
type: normalizedResponseAreaProps.type,
|
|
300
|
-
options: normalizedResponseAreaProps.options,
|
|
301
|
-
maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,
|
|
302
|
-
respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,
|
|
303
|
-
onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,
|
|
304
|
-
error: normalizedResponseAreaProps.error,
|
|
305
|
-
onFocus: function onFocus() {
|
|
306
|
-
log('[table:onFocus]...');
|
|
307
|
-
|
|
308
|
-
_this.onPluginFocus();
|
|
309
|
-
},
|
|
310
|
-
onBlur: function onBlur() {
|
|
311
|
-
log('[table:onBlur]...');
|
|
312
|
-
|
|
313
|
-
_this.onPluginBlur();
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
languageCharacters: props.languageCharactersProps,
|
|
317
|
-
keyPadCharacterRef: _this.keyPadCharacterRef,
|
|
318
|
-
setKeypadInteraction: _this.setKeypadInteraction,
|
|
319
|
-
media: {
|
|
320
|
-
focus: _this.focus,
|
|
321
|
-
createChange: function createChange() {
|
|
322
|
-
return _this.state.value.change();
|
|
323
|
-
},
|
|
324
|
-
onChange: _this.onChange,
|
|
325
|
-
uploadSoundSupport: props.uploadSoundSupport
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
if (props.mathMlOptions.mmlOutput || props.mathMlOptions.mmlEditing) {
|
|
330
|
-
_this.props.runSerializationOnMarkup();
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginBlur", function (e) {
|
|
334
|
-
log('[onPluginBlur]', e && e.relatedTarget);
|
|
335
|
-
var target = e && e.relatedTarget;
|
|
336
|
-
var node = target ? (0, _slateReact.findNode)(target, _this.state.value) : null;
|
|
337
|
-
log('[onPluginBlur] node: ', node);
|
|
338
|
-
|
|
339
|
-
_this.setState({
|
|
340
|
-
focusedNode: node
|
|
341
|
-
}, function () {
|
|
342
|
-
_this.resetValue();
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPluginFocus", function (e) {
|
|
346
|
-
log('[onPluginFocus]', e && e.target);
|
|
347
|
-
var target = e && e.target;
|
|
348
|
-
|
|
349
|
-
if (target) {
|
|
350
|
-
var node = (0, _slateReact.findNode)(target, _this.state.value);
|
|
351
|
-
log('[onPluginFocus] node: ', node);
|
|
352
|
-
var stashedValue = _this.state.stashedValue || _this.state.value;
|
|
353
|
-
|
|
354
|
-
_this.setState({
|
|
355
|
-
focusedNode: node,
|
|
356
|
-
stashedValue: stashedValue
|
|
357
|
-
});
|
|
358
|
-
} else {
|
|
359
|
-
_this.setState({
|
|
360
|
-
focusedNode: null
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
_this.stashValue();
|
|
365
|
-
});
|
|
366
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMathClick", function (node) {
|
|
367
|
-
_this.editor.change(function (c) {
|
|
368
|
-
return c.collapseToStartOf(node);
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
_this.setState({
|
|
372
|
-
selectedNode: node
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditingDone", function () {
|
|
376
|
-
var _this$state = _this.state,
|
|
377
|
-
isHtmlMode = _this$state.isHtmlMode,
|
|
378
|
-
dialog = _this$state.dialog,
|
|
379
|
-
value = _this$state.value,
|
|
380
|
-
pendingImages = _this$state.pendingImages; // Handling HTML mode and dialog state
|
|
381
|
-
|
|
382
|
-
if (isHtmlMode) {
|
|
383
|
-
// Early return if HTML mode is enabled
|
|
384
|
-
if (dialog !== null && dialog !== void 0 && dialog.open) return;
|
|
385
|
-
var currentValue = (0, serialization.htmlToValue)(value.document.text);
|
|
386
|
-
|
|
387
|
-
var previewText = _this.renderHtmlPreviewContent();
|
|
388
|
-
|
|
389
|
-
_this.openHtmlModeConfirmationDialog(currentValue, previewText);
|
|
390
|
-
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (pendingImages.length) {
|
|
395
|
-
// schedule image processing
|
|
396
|
-
_this.setState({
|
|
397
|
-
scheduled: true
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
return;
|
|
401
|
-
} // Finalizing editing
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
log('[onEditingDone]');
|
|
405
|
-
|
|
406
|
-
_this.setState({
|
|
407
|
-
pendingImages: [],
|
|
408
|
-
stashedValue: null,
|
|
409
|
-
focusedNode: null
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
log('[onEditingDone] value: ', _this.state.value);
|
|
413
|
-
|
|
414
|
-
_this.props.onChange(_this.state.value, true);
|
|
415
|
-
});
|
|
416
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderHtmlPreviewContent", function () {
|
|
417
|
-
var classes = _this.props.classes;
|
|
418
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
419
|
-
ref: function ref(_ref2) {
|
|
420
|
-
return _this.elementRef = _ref2;
|
|
421
|
-
}
|
|
422
|
-
}, /*#__PURE__*/_react["default"].createElement("div", null, "Preview of Edited Html:"), /*#__PURE__*/_react["default"].createElement(_index.PreviewPrompt, {
|
|
423
|
-
defaultClassName: classes.previewText,
|
|
424
|
-
prompt: _this.state.value.document.text
|
|
425
|
-
}), /*#__PURE__*/_react["default"].createElement("div", null, "Would you like to save these changes ?"));
|
|
426
|
-
});
|
|
427
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "openHtmlModeConfirmationDialog", function (currentValue, previewText) {
|
|
428
|
-
_this.setState({
|
|
429
|
-
dialog: {
|
|
430
|
-
open: true,
|
|
431
|
-
title: 'Content Preview & Save',
|
|
432
|
-
text: previewText,
|
|
433
|
-
onConfirmText: 'Save changes',
|
|
434
|
-
onCloseText: 'Continue editing',
|
|
435
|
-
onConfirm: function onConfirm() {
|
|
436
|
-
_this.handleHtmlModeSaveConfirmation(currentValue);
|
|
437
|
-
},
|
|
438
|
-
onClose: _this.htmlModeContinueEditing
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleHtmlModeSaveConfirmation", function (currentValue) {
|
|
443
|
-
_this.setState({
|
|
444
|
-
value: currentValue
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
_this.props.onChange(currentValue, true);
|
|
448
|
-
|
|
449
|
-
_this.handleDialog(false);
|
|
450
|
-
|
|
451
|
-
_this.toggleHtmlMode();
|
|
452
|
-
});
|
|
453
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "htmlModeContinueEditing", function () {
|
|
454
|
-
_this.handleDialog(false);
|
|
455
|
-
});
|
|
456
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (resolve) {
|
|
457
|
-
var nonEmpty = _this.props.nonEmpty;
|
|
458
|
-
var doneOn = _this.state.toolbarOpts.doneOn;
|
|
459
|
-
|
|
460
|
-
_this.setState({
|
|
461
|
-
toolbarInFocus: false,
|
|
462
|
-
focusedNode: null
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
if (_this.editor) {
|
|
466
|
-
_this.editor.blur();
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
if (doneOn === 'blur') {
|
|
470
|
-
var _this$state$value$sta3, _this$state$value$sta4;
|
|
471
|
-
|
|
472
|
-
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) {
|
|
473
|
-
_this.resetValue(true).then(function () {
|
|
474
|
-
_this.onEditingDone();
|
|
475
|
-
|
|
476
|
-
resolve();
|
|
477
|
-
});
|
|
478
|
-
} else {
|
|
479
|
-
_this.onEditingDone();
|
|
480
|
-
|
|
481
|
-
resolve();
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (event) {
|
|
486
|
-
var _this$doneButtonRef$c;
|
|
487
|
-
|
|
488
|
-
log('[onBlur]');
|
|
489
|
-
var relatedTarget = event.relatedTarget;
|
|
490
|
-
var toolbarElement = _this.toolbarRef && (relatedTarget === null || relatedTarget === void 0 ? void 0 : relatedTarget.closest("[class*=\"".concat(_this.toolbarRef.className, "\"]"))); // Check if relatedTarget is a done button
|
|
491
|
-
|
|
492
|
-
var isRawDoneButton = _this.doneButtonRef && (relatedTarget === null || relatedTarget === void 0 ? void 0 : relatedTarget.closest("[class*=\"".concat((_this$doneButtonRef$c = _this.doneButtonRef.current) === null || _this$doneButtonRef$c === void 0 ? void 0 : _this$doneButtonRef$c.className, "\"]"))); // Skip onBlur handling if relatedTarget is a button from the KeyPad characters
|
|
493
|
-
|
|
494
|
-
_this.skipBlurHandling = _this.keypadInteractionDetected && relatedTarget !== null;
|
|
495
|
-
|
|
496
|
-
if (toolbarElement && !isRawDoneButton && !_this.state.focusToolbar) {
|
|
497
|
-
_this.setState({
|
|
498
|
-
focusToolbar: true
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
var node = relatedTarget ? (0, _slateReact.findNode)(relatedTarget, _this.state.value) : null;
|
|
503
|
-
log('[onBlur] node: ', node);
|
|
504
|
-
return new Promise(function (resolve) {
|
|
505
|
-
if (!_this.skipBlurHandling) {
|
|
506
|
-
_this.setKeypadInteraction(false);
|
|
507
|
-
|
|
508
|
-
_this.setState({
|
|
509
|
-
preBlurValue: _this.state.value,
|
|
510
|
-
focusedNode: !node ? null : node
|
|
511
|
-
}, _this.handleBlur.bind((0, _assertThisInitialized2["default"])(_this), resolve));
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
_this.props.onBlur(event);
|
|
515
|
-
});
|
|
516
|
-
});
|
|
517
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDomBlur", function (e) {
|
|
518
|
-
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
519
|
-
setTimeout(function () {
|
|
520
|
-
var stateValue = _this.state.value;
|
|
521
|
-
|
|
522
|
-
if (!_this.wrapperRef) {
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
var editorElement = !editorDOM || document.activeElement.closest("[class*=\"".concat(editorDOM.className, "\"]"));
|
|
527
|
-
var toolbarElement = !_this.toolbarRef || document.activeElement.closest("[class*=\"".concat(_this.toolbarRef.className, "\"]"));
|
|
528
|
-
|
|
529
|
-
var isInCurrentComponent = _this.wrapperRef.contains(editorElement) || _this.wrapperRef.contains(toolbarElement);
|
|
530
|
-
|
|
531
|
-
if (!isInCurrentComponent) {
|
|
532
|
-
editorDOM.removeEventListener('blur', _this.handleDomBlur);
|
|
533
|
-
|
|
534
|
-
if (stateValue.isFocused) {
|
|
535
|
-
_this.onBlur(e);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}, 50);
|
|
539
|
-
});
|
|
540
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function (event, change) {
|
|
541
|
-
return new Promise(function (resolve) {
|
|
542
|
-
var _navigator;
|
|
543
|
-
|
|
544
|
-
var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
|
|
545
|
-
var isTouchDevice = typeof window !== 'undefined' && ('ontouchstart' in window || ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.maxTouchPoints) > 0);
|
|
546
|
-
log('[onFocus]', document.activeElement);
|
|
547
|
-
|
|
548
|
-
if (_this.keypadInteractionDetected && _this.__TEMPORARY_CHANGE_DATA) {
|
|
549
|
-
_this.__TEMPORARY_CHANGE_DATA = null;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* This is a temporary hack - @see changeData below for some more information.
|
|
553
|
-
*/
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
if (_this.__TEMPORARY_CHANGE_DATA) {
|
|
557
|
-
var _this$__TEMPORARY_CHA = _this.__TEMPORARY_CHANGE_DATA,
|
|
558
|
-
key = _this$__TEMPORARY_CHA.key,
|
|
559
|
-
data = _this$__TEMPORARY_CHA.data;
|
|
560
|
-
var domEl = document.querySelector("[data-key=\"".concat(key, "\"]"));
|
|
561
|
-
|
|
562
|
-
if (domEl) {
|
|
563
|
-
var _change = _this.state.value.change().setNodeByKey(key, {
|
|
564
|
-
data: data
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
_this.setState({
|
|
568
|
-
value: _change.value
|
|
569
|
-
}, function () {
|
|
570
|
-
_this.__TEMPORARY_CHANGE_DATA = null;
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* This is needed just in case the browser decides to make the editor
|
|
576
|
-
* lose focus without triggering the onBlur event (can happen in a few cases).
|
|
577
|
-
* This will also trigger onBlur if the user clicks outside of the page when the editor
|
|
578
|
-
* is focused.
|
|
579
|
-
*/
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (editorDOM === document.activeElement) {
|
|
583
|
-
editorDOM.removeEventListener('blur', _this.handleDomBlur);
|
|
584
|
-
editorDOM.addEventListener('blur', _this.handleDomBlur);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
_this.stashValue();
|
|
588
|
-
|
|
589
|
-
_this.props.onFocus(); // Added for accessibility: Ensures the editor gains focus when tabbed to for improved keyboard navigation
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
var shouldFocusEditor = !_this.keypadInteractionDetected && !isTouchDevice;
|
|
593
|
-
|
|
594
|
-
if (shouldFocusEditor) {
|
|
595
|
-
change === null || change === void 0 ? void 0 : change.focus();
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
resolve();
|
|
599
|
-
});
|
|
600
|
-
});
|
|
601
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stashValue", function () {
|
|
602
|
-
log('[stashValue]');
|
|
603
|
-
|
|
604
|
-
if (!_this.state.stashedValue) {
|
|
605
|
-
_this.setState({
|
|
606
|
-
stashedValue: _this.state.value
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetValue", function (force) {
|
|
611
|
-
var _this$state2 = _this.state,
|
|
612
|
-
value = _this$state2.value,
|
|
613
|
-
focusedNode = _this$state2.focusedNode;
|
|
614
|
-
|
|
615
|
-
var stopReset = _this.plugins.reduce(function (s, p) {
|
|
616
|
-
return s || p.stopReset && p.stopReset(_this.state.value);
|
|
617
|
-
}, false);
|
|
618
|
-
|
|
619
|
-
log('[resetValue]', value.isFocused, focusedNode, 'stopReset: ', stopReset);
|
|
620
|
-
|
|
621
|
-
if (_this.state.stashedValue && !value.isFocused && !focusedNode && !stopReset || force) {
|
|
622
|
-
log('[resetValue] resetting...');
|
|
623
|
-
log('stashed', _this.state.stashedValue.document.toObject());
|
|
624
|
-
log('current', _this.state.value.document.toObject());
|
|
625
|
-
|
|
626
|
-
var newValue = _slate.Value.fromJSON(_this.state.stashedValue.toJSON());
|
|
627
|
-
|
|
628
|
-
log('newValue: ', newValue.document);
|
|
629
|
-
return new Promise(function (resolve) {
|
|
630
|
-
setTimeout(function () {
|
|
631
|
-
_this.setState({
|
|
632
|
-
value: newValue,
|
|
633
|
-
stashedValue: null
|
|
634
|
-
}, function () {
|
|
635
|
-
log('value now: ', _this.state.value.document.toJSON());
|
|
636
|
-
resolve();
|
|
637
|
-
});
|
|
638
|
-
}, 50);
|
|
639
|
-
});
|
|
640
|
-
} else {
|
|
641
|
-
return Promise.resolve({});
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (change, done) {
|
|
645
|
-
log('[onChange]');
|
|
646
|
-
window.me = (0, _assertThisInitialized2["default"])(_this);
|
|
647
|
-
var value = change.value;
|
|
648
|
-
var charactersLimit = _this.props.charactersLimit;
|
|
649
|
-
var limit = charactersLimit;
|
|
650
|
-
|
|
651
|
-
if (!limit || limit > MAX_CHARACTERS_LIMIT) {
|
|
652
|
-
limit = MAX_CHARACTERS_LIMIT;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
if (value && value.document && value.document.text && value.document.text.length > limit) {
|
|
656
|
-
return;
|
|
657
|
-
} // Mark the editor as edited when in HTML mode and its content has changed.
|
|
658
|
-
// This status will later be used to decide whether to prompt a warning to the user when exiting HTML mode.
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
var isEditedInHtmlMode = !_this.state.isHtmlMode ? false : _this.state.value.document.text !== value.document.text ? true : _this.state.isEditedInHtmlMode;
|
|
662
|
-
|
|
663
|
-
if (isEditedInHtmlMode != _this.state.isEditedInHtmlMode) {
|
|
664
|
-
_this.handlePlugins(_this.props);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
_this.setState({
|
|
668
|
-
value: value,
|
|
669
|
-
isEditedInHtmlMode: isEditedInHtmlMode
|
|
670
|
-
}, function () {
|
|
671
|
-
log('[onChange], call done()');
|
|
672
|
-
|
|
673
|
-
if (done) {
|
|
674
|
-
done();
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
});
|
|
678
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getFocusedValue", function () {
|
|
679
|
-
if (_this.state.value.isFocused) {
|
|
680
|
-
return _this.state.value;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
return _this.state.preBlurValue;
|
|
684
|
-
});
|
|
685
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "valueToSize", function (v) {
|
|
686
|
-
if (!v) {
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
var calcRegex = /^calc\((.*)\)$/;
|
|
691
|
-
|
|
692
|
-
if (typeof v === 'string') {
|
|
693
|
-
if (v.endsWith('%')) {
|
|
694
|
-
return undefined;
|
|
695
|
-
} else if (v.endsWith('px') || v.endsWith('vh') || v.endsWith('vw') || v.endsWith('ch') || v.endsWith('em') || v.match(calcRegex)) {
|
|
696
|
-
return v;
|
|
697
|
-
} else {
|
|
698
|
-
var value = parseInt(v, 10);
|
|
699
|
-
return isNaN(value) ? value : "".concat(value, "px");
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
if (typeof v === 'number') {
|
|
704
|
-
return "".concat(v, "px");
|
|
705
|
-
}
|
|
706
|
-
});
|
|
707
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "validateNode", function (node) {
|
|
708
|
-
if (node.object !== 'block') return;
|
|
709
|
-
var last = node.nodes.last();
|
|
710
|
-
if (!last) return;
|
|
711
|
-
if (last.type !== 'image') return;
|
|
712
|
-
log('[validateNode] last is image..');
|
|
713
|
-
var parent = last.getParent(last.key);
|
|
714
|
-
|
|
715
|
-
var p = _slate.Block.getParent(last.key);
|
|
716
|
-
|
|
717
|
-
log('[validateNode] parent:', parent, p);
|
|
718
|
-
return undefined;
|
|
719
|
-
});
|
|
720
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (key, data) {
|
|
721
|
-
log('[changeData]. .. ', key, data);
|
|
722
|
-
/**
|
|
723
|
-
* HACK ALERT: We should be calling setState here and storing the change data:
|
|
724
|
-
*
|
|
725
|
-
* <code>this.setState({changeData: { key, data}})</code>
|
|
726
|
-
* However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no
|
|
727
|
-
* more changes get through. The issues seem to be related to the promises in onBlur/onFocus. But removing these
|
|
728
|
-
* brings it's own problems. A major clean up is planned for this component so I've decided to temporarily settle
|
|
729
|
-
* on this hack rather than spend more time on this.
|
|
730
|
-
*/
|
|
731
|
-
// Uncomment this line to see the bug described above.
|
|
732
|
-
// this.setState({changeData: {key, data}})
|
|
733
|
-
|
|
734
|
-
_this.__TEMPORARY_CHANGE_DATA = {
|
|
735
|
-
key: key,
|
|
736
|
-
data: data
|
|
737
|
-
};
|
|
738
|
-
});
|
|
739
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (pos, node) {
|
|
740
|
-
var position = pos || 'end';
|
|
741
|
-
|
|
742
|
-
_this.props.focus(position, node);
|
|
743
|
-
});
|
|
744
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDropPaste", /*#__PURE__*/function () {
|
|
745
|
-
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(event, change, dropContext) {
|
|
746
|
-
var editor, transfer, file, type, fragment, text, src, inline, range, ch, handler, _change$value, _document, selection, startBlock, defaultBlock, defaultMarks, frag;
|
|
747
|
-
|
|
748
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
749
|
-
while (1) {
|
|
750
|
-
switch (_context.prev = _context.next) {
|
|
751
|
-
case 0:
|
|
752
|
-
editor = change.editor;
|
|
753
|
-
transfer = (0, _slateReact.getEventTransfer)(event);
|
|
754
|
-
file = transfer.files && transfer.files[0];
|
|
755
|
-
type = transfer.type;
|
|
756
|
-
fragment = transfer.fragment;
|
|
757
|
-
text = transfer.text;
|
|
758
|
-
|
|
759
|
-
if (!(file && (file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png'))) {
|
|
760
|
-
_context.next = 28;
|
|
761
|
-
break;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
if (_this.props.imageSupport) {
|
|
765
|
-
_context.next = 9;
|
|
766
|
-
break;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
return _context.abrupt("return");
|
|
770
|
-
|
|
771
|
-
case 9:
|
|
772
|
-
_context.prev = 9;
|
|
773
|
-
log('[onDropPaste]');
|
|
774
|
-
_context.next = 13;
|
|
775
|
-
return (0, serialization.getBase64)(file);
|
|
776
|
-
|
|
777
|
-
case 13:
|
|
778
|
-
src = _context.sent;
|
|
779
|
-
inline = _slate.Inline.create({
|
|
780
|
-
type: 'image',
|
|
781
|
-
isVoid: true,
|
|
782
|
-
data: {
|
|
783
|
-
loading: false,
|
|
784
|
-
src: src
|
|
785
|
-
}
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
if (dropContext) {
|
|
789
|
-
_this.focus();
|
|
790
|
-
} else {
|
|
791
|
-
range = (0, _slateReact.getEventRange)(event, editor);
|
|
792
|
-
|
|
793
|
-
if (range) {
|
|
794
|
-
change.select(range);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
ch = change.insertInline(inline);
|
|
799
|
-
|
|
800
|
-
_this.onChange(ch);
|
|
801
|
-
|
|
802
|
-
handler = new _insertImageHandler["default"](inline, function () {}, function () {
|
|
803
|
-
return _this.state.value;
|
|
804
|
-
}, _this.onChange, true);
|
|
805
|
-
handler.fileChosen(file);
|
|
806
|
-
|
|
807
|
-
_this.props.imageSupport.add(handler);
|
|
808
|
-
|
|
809
|
-
_context.next = 26;
|
|
810
|
-
break;
|
|
811
|
-
|
|
812
|
-
case 23:
|
|
813
|
-
_context.prev = 23;
|
|
814
|
-
_context.t0 = _context["catch"](9);
|
|
815
|
-
log('[onDropPaste] error: ', _context.t0);
|
|
816
|
-
|
|
817
|
-
case 26:
|
|
818
|
-
_context.next = 42;
|
|
819
|
-
break;
|
|
820
|
-
|
|
821
|
-
case 28:
|
|
822
|
-
if (!(type === 'fragment')) {
|
|
823
|
-
_context.next = 32;
|
|
824
|
-
break;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
change.insertFragment(fragment);
|
|
828
|
-
_context.next = 42;
|
|
829
|
-
break;
|
|
830
|
-
|
|
831
|
-
case 32:
|
|
832
|
-
if (!(type === 'text' || type === 'html')) {
|
|
833
|
-
_context.next = 42;
|
|
834
|
-
break;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
if (text) {
|
|
838
|
-
_context.next = 35;
|
|
839
|
-
break;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
return _context.abrupt("return");
|
|
843
|
-
|
|
844
|
-
case 35:
|
|
845
|
-
_change$value = change.value, _document = _change$value.document, selection = _change$value.selection, startBlock = _change$value.startBlock;
|
|
846
|
-
|
|
847
|
-
if (!startBlock.isVoid) {
|
|
848
|
-
_context.next = 38;
|
|
849
|
-
break;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
return _context.abrupt("return");
|
|
853
|
-
|
|
854
|
-
case 38:
|
|
855
|
-
defaultBlock = startBlock;
|
|
856
|
-
defaultMarks = _document.getInsertMarksAtRange(selection);
|
|
857
|
-
frag = _slatePlainSerializer["default"].deserialize(text, {
|
|
858
|
-
defaultBlock: defaultBlock,
|
|
859
|
-
defaultMarks: defaultMarks
|
|
860
|
-
}).document;
|
|
861
|
-
change.insertFragment(frag);
|
|
862
|
-
|
|
863
|
-
case 42:
|
|
864
|
-
case "end":
|
|
865
|
-
return _context.stop();
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}, _callee, null, [[9, 23]]);
|
|
869
|
-
}));
|
|
870
|
-
|
|
871
|
-
return function (_x, _x2, _x3) {
|
|
872
|
-
return _ref3.apply(this, arguments);
|
|
873
|
-
};
|
|
874
|
-
}());
|
|
875
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderPlaceholder", function (props) {
|
|
876
|
-
var editor = props.editor;
|
|
877
|
-
var document = editor.value.document;
|
|
878
|
-
|
|
879
|
-
if (!editor.props.placeholder || document.text !== '' || document.nodes.size !== 1 || !document.isEmpty) {
|
|
880
|
-
return false;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
884
|
-
contentEditable: false,
|
|
885
|
-
style: {
|
|
886
|
-
display: 'inline-block',
|
|
887
|
-
width: 'fit-content',
|
|
888
|
-
// for centering the placeholder if text-align is set to center
|
|
889
|
-
maxWidth: '100%',
|
|
890
|
-
whiteSpace: 'nowrap',
|
|
891
|
-
opacity: '0.33',
|
|
892
|
-
pointerEvents: 'none',
|
|
893
|
-
userSelect: 'none'
|
|
894
|
-
}
|
|
895
|
-
}, editor.props.placeholder);
|
|
896
|
-
});
|
|
897
|
-
_this.state = {
|
|
898
|
-
value: _props.value,
|
|
899
|
-
toolbarOpts: createToolbarOpts(_props.toolbarOpts, _props.error),
|
|
900
|
-
pendingImages: [],
|
|
901
|
-
isHtmlMode: false,
|
|
902
|
-
isEditedInHtmlMode: false,
|
|
903
|
-
focusToolbar: false,
|
|
904
|
-
dialog: {
|
|
905
|
-
open: false
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
_this.keyPadCharacterRef = /*#__PURE__*/_react["default"].createRef();
|
|
909
|
-
_this.doneButtonRef = /*#__PURE__*/_react["default"].createRef();
|
|
910
|
-
_this.keypadInteractionDetected = false;
|
|
911
|
-
_this.toggleHtmlMode = _this.toggleHtmlMode.bind((0, _assertThisInitialized2["default"])(_this));
|
|
912
|
-
_this.handleToolbarFocus = _this.handleToolbarFocus.bind((0, _assertThisInitialized2["default"])(_this));
|
|
913
|
-
_this.handleToolbarBlur = _this.handleToolbarBlur.bind((0, _assertThisInitialized2["default"])(_this));
|
|
914
|
-
|
|
915
|
-
_this.onResize = function () {
|
|
916
|
-
if (!_this.state.isHtmlMode && _props.onChange) {
|
|
917
|
-
_props.onChange(_this.state.value, true);
|
|
918
|
-
}
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
_this.handlePlugins(_this.props);
|
|
922
|
-
|
|
923
|
-
return _this;
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
(0, _createClass2["default"])(Editor, [{
|
|
927
|
-
key: "handleToolbarFocus",
|
|
928
|
-
value: function handleToolbarFocus() {
|
|
929
|
-
if (this.state.focusToolbar) {
|
|
930
|
-
return;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
this.setState({
|
|
934
|
-
focusToolbar: true
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
}, {
|
|
938
|
-
key: "handleToolbarBlur",
|
|
939
|
-
value: function handleToolbarBlur() {
|
|
940
|
-
var _this2 = this;
|
|
941
|
-
|
|
942
|
-
setTimeout(function () {
|
|
943
|
-
if (!_this2.toolbarContainsFocus()) {
|
|
944
|
-
_this2.setState({
|
|
945
|
-
focusToolbar: false
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
}, 0);
|
|
949
|
-
}
|
|
950
|
-
}, {
|
|
951
|
-
key: "toolbarContainsFocus",
|
|
952
|
-
value: function toolbarContainsFocus() {
|
|
953
|
-
if (!this.toolbarRef) return false;
|
|
954
|
-
var toolbarElement = this.toolbarRef;
|
|
955
|
-
var activeElement = document.activeElement;
|
|
956
|
-
return toolbarElement && toolbarElement.contains(activeElement);
|
|
957
|
-
}
|
|
958
|
-
}, {
|
|
959
|
-
key: "componentDidMount",
|
|
960
|
-
value: function componentDidMount() {
|
|
961
|
-
var _this$props$className,
|
|
962
|
-
_this3 = this;
|
|
963
|
-
|
|
964
|
-
// onRef is needed to get the ref of the component because we export it using withStyles
|
|
965
|
-
this.props.onRef(this);
|
|
966
|
-
window.addEventListener('resize', this.onResize);
|
|
967
|
-
var isResponseAreaEditor = (_this$props$className = this.props.className) === null || _this$props$className === void 0 ? void 0 : _this$props$className.includes('response-area-editor');
|
|
968
|
-
|
|
969
|
-
if (isResponseAreaEditor && this.editor) {
|
|
970
|
-
var responseAreaEditor = document.querySelector("[data-key=\"".concat(this.editor.value.document.key, "\"]"));
|
|
971
|
-
|
|
972
|
-
if (responseAreaEditor) {
|
|
973
|
-
responseAreaEditor.setAttribute('aria-label', 'Answer');
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
if (this.editor && this.props.autoFocus) {
|
|
978
|
-
Promise.resolve().then(function () {
|
|
979
|
-
if (_this3.editor) {
|
|
980
|
-
var editorDOM = document.querySelector("[data-key=\"".concat(_this3.editor.value.document.key, "\"]"));
|
|
981
|
-
|
|
982
|
-
_this3.editor.focus();
|
|
983
|
-
|
|
984
|
-
if (editorDOM) {
|
|
985
|
-
editorDOM.focus();
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
}, {
|
|
992
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
993
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
994
|
-
var _nextProps$value, _nextProps$value$docu, _this$props$value;
|
|
995
|
-
|
|
996
|
-
var _this$state3 = this.state,
|
|
997
|
-
isHtmlMode = _this$state3.isHtmlMode,
|
|
998
|
-
toolbarOpts = _this$state3.toolbarOpts;
|
|
999
|
-
var newToolbarOpts = createToolbarOpts(nextProps.toolbarOpts, nextProps.error, isHtmlMode);
|
|
1000
|
-
|
|
1001
|
-
if (!(0, _isEqual["default"])(newToolbarOpts, toolbarOpts)) {
|
|
1002
|
-
this.setState({
|
|
1003
|
-
toolbarOpts: newToolbarOpts
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
var differentCharacterProps = !(0, _isEqual["default"])(nextProps.languageCharactersProps, this.props.languageCharactersProps);
|
|
1008
|
-
var differentMathMlProps = !(0, _isEqual["default"])(nextProps.mathMlOptions, this.props.mathMlOptions);
|
|
1009
|
-
var differentImageMaxDimensionsProps = !(0, _isEqual["default"])(nextProps.maxImageWidth, this.props.maxImageWidth) || !(0, _isEqual["default"])(nextProps.maxImageHeight, this.props.maxImageHeight);
|
|
1010
|
-
|
|
1011
|
-
if (differentCharacterProps || differentMathMlProps || differentImageMaxDimensionsProps) {
|
|
1012
|
-
this.handlePlugins(nextProps);
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
if (!((_nextProps$value = nextProps.value) !== null && _nextProps$value !== void 0 && (_nextProps$value$docu = _nextProps$value.document) !== null && _nextProps$value$docu !== void 0 && _nextProps$value$docu.equals((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.document))) {
|
|
1016
|
-
this.setState({
|
|
1017
|
-
focus: false,
|
|
1018
|
-
value: nextProps.value
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}, {
|
|
1023
|
-
key: "componentDidUpdate",
|
|
1024
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
1025
|
-
// The cursor is on a zero width element and when that is placed near void elements, it is not visible
|
|
1026
|
-
// so we increase the width to at least 2px in order for the user to see it
|
|
1027
|
-
// Trigger plugins and finish editing if:
|
|
1028
|
-
// 1. The 'isHtmlMode' state has been toggled.
|
|
1029
|
-
// 2. We're currently in 'isHtmlMode' and the editor value has been modified.
|
|
1030
|
-
if (this.state.isHtmlMode !== prevState.isHtmlMode || this.state.isHtmlMode && !prevState.isEditedInHtmlMode && this.state.isEditedInHtmlMode) {
|
|
1031
|
-
this.handlePlugins(this.props);
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
var zeroWidthEls = document.querySelectorAll('[data-slate-zero-width="z"]');
|
|
1035
|
-
Array.from(zeroWidthEls).forEach(function (el) {
|
|
1036
|
-
el.style.minWidth = '2px';
|
|
1037
|
-
el.style.display = 'inline-block';
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
}, {
|
|
1041
|
-
key: "componentWillUnmount",
|
|
1042
|
-
value:
|
|
1043
|
-
/**
|
|
1044
|
-
* Remove onResize event listener
|
|
1045
|
-
*/
|
|
1046
|
-
function componentWillUnmount() {
|
|
1047
|
-
window.removeEventListener('resize', this.onResize);
|
|
1048
|
-
} // Allowing time for onChange to take effect if it is called
|
|
1049
|
-
|
|
1050
|
-
}, {
|
|
1051
|
-
key: "buildSizeStyle",
|
|
1052
|
-
value: function buildSizeStyle() {
|
|
1053
|
-
var _this$props = this.props,
|
|
1054
|
-
minWidth = _this$props.minWidth,
|
|
1055
|
-
width = _this$props.width,
|
|
1056
|
-
maxWidth = _this$props.maxWidth,
|
|
1057
|
-
minHeight = _this$props.minHeight,
|
|
1058
|
-
height = _this$props.height,
|
|
1059
|
-
maxHeight = _this$props.maxHeight;
|
|
1060
|
-
return {
|
|
1061
|
-
width: this.valueToSize(width),
|
|
1062
|
-
minWidth: this.valueToSize(minWidth),
|
|
1063
|
-
maxWidth: this.valueToSize(maxWidth),
|
|
1064
|
-
height: this.valueToSize(height),
|
|
1065
|
-
minHeight: this.valueToSize(minHeight),
|
|
1066
|
-
maxHeight: this.valueToSize(maxHeight)
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
}, {
|
|
1070
|
-
key: "render",
|
|
1071
|
-
value: function render() {
|
|
1072
|
-
var _classNames,
|
|
1073
|
-
_this4 = this,
|
|
1074
|
-
_value$document,
|
|
1075
|
-
_classNames2;
|
|
1076
|
-
|
|
1077
|
-
var _this$props2 = this.props,
|
|
1078
|
-
disabled = _this$props2.disabled,
|
|
1079
|
-
spellCheck = _this$props2.spellCheck,
|
|
1080
|
-
highlightShape = _this$props2.highlightShape,
|
|
1081
|
-
classes = _this$props2.classes,
|
|
1082
|
-
className = _this$props2.className,
|
|
1083
|
-
isEditor = _this$props2.isEditor,
|
|
1084
|
-
placeholder = _this$props2.placeholder,
|
|
1085
|
-
pluginProps = _this$props2.pluginProps,
|
|
1086
|
-
onKeyDown = _this$props2.onKeyDown; // We don't want to send customPlugins to slate.
|
|
1087
|
-
// Not sure if they would do any harm, but I think it's better to not send them.
|
|
1088
|
-
// We use custom plugins to be able to add custom buttons
|
|
1089
|
-
// eslint-disable-next-line no-unused-vars
|
|
1090
|
-
|
|
1091
|
-
var _ref4 = pluginProps || {},
|
|
1092
|
-
customPlugins = _ref4.customPlugins,
|
|
1093
|
-
showParagraphs = _ref4.showParagraphs,
|
|
1094
|
-
separateParagraphs = _ref4.separateParagraphs,
|
|
1095
|
-
otherPluginProps = (0, _objectWithoutProperties2["default"])(_ref4, _excluded);
|
|
1096
|
-
|
|
1097
|
-
var _this$state4 = this.state,
|
|
1098
|
-
value = _this$state4.value,
|
|
1099
|
-
focusedNode = _this$state4.focusedNode,
|
|
1100
|
-
toolbarOpts = _this$state4.toolbarOpts,
|
|
1101
|
-
dialog = _this$state4.dialog,
|
|
1102
|
-
scheduled = _this$state4.scheduled;
|
|
1103
|
-
log('[render] value: ', value);
|
|
1104
|
-
var sizeStyle = this.buildSizeStyle();
|
|
1105
|
-
var names = (0, _classnames["default"])((_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.withBg, highlightShape), (0, _defineProperty2["default"])(_classNames, classes.toolbarOnTop, toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'), (0, _defineProperty2["default"])(_classNames, classes.scheduled, scheduled), _classNames), className);
|
|
1106
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
1107
|
-
ref: function ref(_ref5) {
|
|
1108
|
-
return _this4.wrapperRef = _ref5;
|
|
1109
|
-
},
|
|
1110
|
-
style: {
|
|
1111
|
-
width: sizeStyle.width,
|
|
1112
|
-
minWidth: sizeStyle.minWidth,
|
|
1113
|
-
maxWidth: sizeStyle.maxWidth
|
|
1114
|
-
},
|
|
1115
|
-
className: names,
|
|
1116
|
-
id: "editor-".concat(value === null || value === void 0 ? void 0 : (_value$document = value.document) === null || _value$document === void 0 ? void 0 : _value$document.key)
|
|
1117
|
-
}, scheduled && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1118
|
-
className: classes.uploading
|
|
1119
|
-
}, "Uploading image and then saving..."), /*#__PURE__*/_react["default"].createElement(_slateReact.Editor, {
|
|
1120
|
-
plugins: this.plugins,
|
|
1121
|
-
innerRef: function innerRef(r) {
|
|
1122
|
-
if (r) {
|
|
1123
|
-
_this4.slateEditor = r;
|
|
1124
|
-
}
|
|
1125
|
-
},
|
|
1126
|
-
ref: function ref(r) {
|
|
1127
|
-
return _this4.editor = r && _this4.props.editorRef(r);
|
|
1128
|
-
},
|
|
1129
|
-
toolbarRef: function toolbarRef(r) {
|
|
1130
|
-
if (r) {
|
|
1131
|
-
_this4.toolbarRef = r;
|
|
1132
|
-
}
|
|
1133
|
-
},
|
|
1134
|
-
doneButtonRef: this.doneButtonRef,
|
|
1135
|
-
value: value,
|
|
1136
|
-
focusToolbar: this.state.focusToolbar,
|
|
1137
|
-
onToolbarFocus: this.handleToolbarFocus,
|
|
1138
|
-
onToolbarBlur: this.handleToolbarBlur,
|
|
1139
|
-
focus: this.focus,
|
|
1140
|
-
onKeyDown: onKeyDown,
|
|
1141
|
-
onChange: this.onChange,
|
|
1142
|
-
getFocusedValue: this.getFocusedValue,
|
|
1143
|
-
onBlur: this.onBlur,
|
|
1144
|
-
onDrop: function onDrop(event, editor) {
|
|
1145
|
-
return _this4.onDropPaste(event, editor, true);
|
|
1146
|
-
},
|
|
1147
|
-
onPaste: function onPaste(event, editor) {
|
|
1148
|
-
return _this4.onDropPaste(event, editor);
|
|
1149
|
-
},
|
|
1150
|
-
onFocus: this.onFocus,
|
|
1151
|
-
onEditingDone: this.onEditingDone,
|
|
1152
|
-
focusedNode: focusedNode,
|
|
1153
|
-
normalize: this.normalize,
|
|
1154
|
-
readOnly: disabled,
|
|
1155
|
-
spellCheck: spellCheck,
|
|
1156
|
-
autoCorrect: spellCheck,
|
|
1157
|
-
className: (0, _classnames["default"])((_classNames2 = {}, (0, _defineProperty2["default"])(_classNames2, classes.noPadding, toolbarOpts === null || toolbarOpts === void 0 ? void 0 : toolbarOpts.noPadding), (0, _defineProperty2["default"])(_classNames2, classes.showParagraph, showParagraphs && !showParagraphs.disabled), (0, _defineProperty2["default"])(_classNames2, classes.separateParagraph, separateParagraphs && !separateParagraphs.disabled), _classNames2), classes.slateEditor),
|
|
1158
|
-
style: {
|
|
1159
|
-
minHeight: sizeStyle.minHeight,
|
|
1160
|
-
height: sizeStyle.height,
|
|
1161
|
-
maxHeight: sizeStyle.maxHeight
|
|
1162
|
-
},
|
|
1163
|
-
pluginProps: otherPluginProps,
|
|
1164
|
-
toolbarOpts: toolbarOpts,
|
|
1165
|
-
placeholder: placeholder,
|
|
1166
|
-
renderPlaceholder: this.renderPlaceholder,
|
|
1167
|
-
onDataChange: this.changeData
|
|
1168
|
-
}), /*#__PURE__*/_react["default"].createElement(_alertDialog["default"], {
|
|
1169
|
-
open: dialog.open,
|
|
1170
|
-
title: dialog.title,
|
|
1171
|
-
text: dialog.text,
|
|
1172
|
-
onClose: dialog.onClose,
|
|
1173
|
-
onConfirm: dialog.onConfirm,
|
|
1174
|
-
onConfirmText: dialog.onConfirmText,
|
|
1175
|
-
onCloseText: dialog.onCloseText
|
|
1176
|
-
}));
|
|
1177
|
-
}
|
|
1178
|
-
}]);
|
|
1179
|
-
return Editor;
|
|
1180
|
-
}(_react["default"].Component); // TODO color - hardcoded gray background and keypad colors will need to change too
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
exports.Editor = Editor;
|
|
1184
|
-
(0, _defineProperty2["default"])(Editor, "propTypes", {
|
|
1185
|
-
autoFocus: _propTypes["default"].bool,
|
|
1186
|
-
editorRef: _propTypes["default"].func.isRequired,
|
|
1187
|
-
error: _propTypes["default"].any,
|
|
1188
|
-
onRef: _propTypes["default"].func.isRequired,
|
|
1189
|
-
onChange: _propTypes["default"].func.isRequired,
|
|
1190
|
-
onFocus: _propTypes["default"].func,
|
|
1191
|
-
onBlur: _propTypes["default"].func,
|
|
1192
|
-
onKeyDown: _propTypes["default"].func,
|
|
1193
|
-
focus: _propTypes["default"].func.isRequired,
|
|
1194
|
-
value: _slatePropTypes["default"].value.isRequired,
|
|
1195
|
-
imageSupport: _propTypes["default"].object,
|
|
1196
|
-
mathMlOptions: _propTypes["default"].shape({
|
|
1197
|
-
mmlOutput: _propTypes["default"].bool,
|
|
1198
|
-
mmlEditing: _propTypes["default"].bool
|
|
1199
|
-
}),
|
|
1200
|
-
disableImageAlignmentButtons: _propTypes["default"].bool,
|
|
1201
|
-
uploadSoundSupport: _propTypes["default"].shape({
|
|
1202
|
-
add: _propTypes["default"].func,
|
|
1203
|
-
"delete": _propTypes["default"].func
|
|
1204
|
-
}),
|
|
1205
|
-
charactersLimit: _propTypes["default"].number,
|
|
1206
|
-
width: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
1207
|
-
minWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
1208
|
-
maxWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
1209
|
-
height: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
1210
|
-
minHeight: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
1211
|
-
maxHeight: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
1212
|
-
classes: _propTypes["default"].object.isRequired,
|
|
1213
|
-
highlightShape: _propTypes["default"].bool,
|
|
1214
|
-
disabled: _propTypes["default"].bool,
|
|
1215
|
-
spellCheck: _propTypes["default"].bool,
|
|
1216
|
-
nonEmpty: _propTypes["default"].bool,
|
|
1217
|
-
disableScrollbar: _propTypes["default"].bool,
|
|
1218
|
-
disableUnderline: _propTypes["default"].bool,
|
|
1219
|
-
autoWidthToolbar: _propTypes["default"].bool,
|
|
1220
|
-
pluginProps: _propTypes["default"].any,
|
|
1221
|
-
// customPlugins should be inside pluginProps (a property inside pluginProps)
|
|
1222
|
-
// customPlugins: PropTypes.arrayOf(
|
|
1223
|
-
// PropTypes.shape({
|
|
1224
|
-
// event: PropTypes.string,
|
|
1225
|
-
// icon: PropTypes.string,
|
|
1226
|
-
// iconType: PropTypes.string,
|
|
1227
|
-
// iconAlt: PropTypes.string
|
|
1228
|
-
// }),
|
|
1229
|
-
// ),
|
|
1230
|
-
placeholder: _propTypes["default"].string,
|
|
1231
|
-
isEditor: _propTypes["default"].bool,
|
|
1232
|
-
responseAreaProps: _propTypes["default"].shape({
|
|
1233
|
-
type: _propTypes["default"].oneOf(['explicit-constructed-response', 'inline-dropdown', 'drag-in-the-blank', 'math-templated']),
|
|
1234
|
-
options: _propTypes["default"].object,
|
|
1235
|
-
respAreaToolbar: _propTypes["default"].func,
|
|
1236
|
-
onHandleAreaChange: _propTypes["default"].func,
|
|
1237
|
-
maxResponseAreas: _propTypes["default"].number,
|
|
1238
|
-
error: _propTypes["default"].any
|
|
1239
|
-
}),
|
|
1240
|
-
extraCSSRules: _propTypes["default"].shape({
|
|
1241
|
-
names: _propTypes["default"].arrayOf(_propTypes["default"].string),
|
|
1242
|
-
rules: _propTypes["default"].string
|
|
1243
|
-
}),
|
|
1244
|
-
languageCharactersProps: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
1245
|
-
language: _propTypes["default"].string,
|
|
1246
|
-
characterIcon: _propTypes["default"].string,
|
|
1247
|
-
characters: _propTypes["default"].arrayOf(_propTypes["default"].arrayOf(_propTypes["default"].string))
|
|
1248
|
-
})),
|
|
1249
|
-
runSerializationOnMarkup: _propTypes["default"].func,
|
|
1250
|
-
toolbarOpts: _propTypes["default"].shape({
|
|
1251
|
-
position: _propTypes["default"].oneOf(['bottom', 'top']),
|
|
1252
|
-
alignment: _propTypes["default"].oneOf(['left', 'right']),
|
|
1253
|
-
alwaysVisible: _propTypes["default"].bool,
|
|
1254
|
-
showDone: _propTypes["default"].bool,
|
|
1255
|
-
doneOn: _propTypes["default"].string,
|
|
1256
|
-
minWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])
|
|
1257
|
-
}),
|
|
1258
|
-
activePlugins: _propTypes["default"].arrayOf(function (values) {
|
|
1259
|
-
var allValid = values.every(function (v) {
|
|
1260
|
-
return _plugins.ALL_PLUGINS.includes(v);
|
|
1261
|
-
});
|
|
1262
|
-
return !allValid && new Error("Invalid values: ".concat(values, ", values must be one of [").concat(_plugins.ALL_PLUGINS.join(','), "]"));
|
|
1263
|
-
}),
|
|
1264
|
-
className: _propTypes["default"].string,
|
|
1265
|
-
maxImageWidth: _propTypes["default"].number,
|
|
1266
|
-
maxImageHeight: _propTypes["default"].number
|
|
1267
|
-
});
|
|
1268
|
-
(0, _defineProperty2["default"])(Editor, "defaultProps", {
|
|
1269
|
-
disableUnderline: true,
|
|
1270
|
-
onFocus: function onFocus() {},
|
|
1271
|
-
onBlur: function onBlur() {},
|
|
1272
|
-
onKeyDown: function onKeyDown() {},
|
|
1273
|
-
runSerializationOnMarkup: function runSerializationOnMarkup() {},
|
|
1274
|
-
mathMlOptions: {
|
|
1275
|
-
mmlOutput: false,
|
|
1276
|
-
mmlEditing: false
|
|
1277
|
-
},
|
|
1278
|
-
toolbarOpts: defaultToolbarOpts,
|
|
1279
|
-
responseAreaProps: defaultResponseAreaProps,
|
|
1280
|
-
languageCharactersProps: defaultLanguageCharactersProps,
|
|
1281
|
-
extraCSSRules: null,
|
|
1282
|
-
isEditor: false
|
|
1283
|
-
});
|
|
1284
|
-
var styles = {
|
|
1285
|
-
withBg: {
|
|
1286
|
-
backgroundColor: 'rgba(0,0,0,0.06)'
|
|
1287
|
-
},
|
|
1288
|
-
scheduled: {
|
|
1289
|
-
opacity: 0.5,
|
|
1290
|
-
pointerEvents: 'none',
|
|
1291
|
-
position: 'relative'
|
|
1292
|
-
},
|
|
1293
|
-
uploading: {
|
|
1294
|
-
position: 'absolute',
|
|
1295
|
-
top: '50%',
|
|
1296
|
-
left: '50%',
|
|
1297
|
-
transform: 'translate(-50%, -50%)'
|
|
1298
|
-
},
|
|
1299
|
-
slateEditor: {
|
|
1300
|
-
fontFamily: 'Roboto, sans-serif',
|
|
1301
|
-
'& table': {
|
|
1302
|
-
tableLayout: 'fixed',
|
|
1303
|
-
width: '100%',
|
|
1304
|
-
borderCollapse: 'collapse',
|
|
1305
|
-
color: _index.color.text(),
|
|
1306
|
-
backgroundColor: _index.color.background()
|
|
1307
|
-
},
|
|
1308
|
-
'& table:not([border="1"]) tr': {
|
|
1309
|
-
borderTop: '1px solid #dfe2e5' // TODO perhaps secondary color for background, for now disable
|
|
1310
|
-
// '&:nth-child(2n)': {
|
|
1311
|
-
// backgroundColor: '#f6f8fa'
|
|
1312
|
-
// }
|
|
1313
|
-
|
|
1314
|
-
},
|
|
1315
|
-
'& td, th': {
|
|
1316
|
-
padding: '.6em 1em',
|
|
1317
|
-
textAlign: 'center'
|
|
1318
|
-
},
|
|
1319
|
-
'& table:not([border="1"]) td, th': {
|
|
1320
|
-
border: '1px solid #dfe2e5'
|
|
1321
|
-
}
|
|
1322
|
-
},
|
|
1323
|
-
showParagraph: {
|
|
1324
|
-
// a div that has a div after it
|
|
1325
|
-
'& > div:has(+ div)::after': {
|
|
1326
|
-
display: 'block',
|
|
1327
|
-
content: '"¶"',
|
|
1328
|
-
fontSize: '1em',
|
|
1329
|
-
color: '#146EB3'
|
|
1330
|
-
}
|
|
1331
|
-
},
|
|
1332
|
-
separateParagraph: {
|
|
1333
|
-
// a div that has a div after it
|
|
1334
|
-
'& > div:has(+ div)': {
|
|
1335
|
-
marginBottom: '1em'
|
|
1336
|
-
}
|
|
1337
|
-
},
|
|
1338
|
-
toolbarOnTop: {
|
|
1339
|
-
marginTop: '45px'
|
|
1340
|
-
},
|
|
1341
|
-
noPadding: {
|
|
1342
|
-
padding: '0 !important'
|
|
1343
|
-
},
|
|
1344
|
-
previewText: {
|
|
1345
|
-
marginBottom: '36px',
|
|
1346
|
-
marginTop: '6px',
|
|
1347
|
-
padding: '20px',
|
|
1348
|
-
backgroundColor: 'rgba(0,0,0,0.06)'
|
|
1349
|
-
}
|
|
1350
|
-
};
|
|
1351
|
-
|
|
1352
|
-
var _default = (0, _styles.withStyles)(styles)(Editor);
|
|
1353
|
-
|
|
1354
|
-
exports["default"] = _default;
|
|
1355
|
-
//# sourceMappingURL=editor.js.map
|