@pie-lib/editable-html 7.17.4-next.308 → 7.17.4-next.333
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 +286 -0
- package/lib/editor.js +122 -99
- package/lib/editor.js.map +1 -1
- package/lib/plugins/characters/custom-popover.js +73 -0
- package/lib/plugins/characters/custom-popover.js.map +1 -0
- package/lib/plugins/characters/index.js +271 -0
- package/lib/plugins/characters/index.js.map +1 -0
- package/lib/plugins/characters/utils.js +362 -0
- package/lib/plugins/characters/utils.js.map +1 -0
- package/lib/plugins/index.js +19 -4
- package/lib/plugins/index.js.map +1 -1
- package/package.json +5 -5
- package/src/editor.jsx +46 -13
- package/src/plugins/characters/custom-popover.js +45 -0
- package/src/plugins/characters/index.jsx +237 -0
- package/src/plugins/characters/utils.js +444 -0
- package/src/plugins/index.jsx +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,292 @@
|
|
|
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
|
+
## [7.22.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.22.4...@pie-lib/editable-html@7.22.5) (2022-05-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [7.22.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.22.3...@pie-lib/editable-html@7.22.4) (2022-05-24)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [7.22.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.22.2...@pie-lib/editable-html@7.22.3) (2022-05-10)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [7.22.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.22.1...@pie-lib/editable-html@7.22.2) (2022-05-09)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [7.22.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.22.0...@pie-lib/editable-html@7.22.1) (2022-05-03)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# [7.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.21.0...@pie-lib/editable-html@7.22.0) (2022-05-03)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* use error as a function ([c767c8b](https://github.com/pie-framework/pie-lib/commit/c767c8bdc5ace6006e86862704a26095fa4b16f6))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Features
|
|
55
|
+
|
|
56
|
+
* PD-1707 ([9762d1f](https://github.com/pie-framework/pie-lib/commit/9762d1f4ac1bd615db4f03dfd06809010213052d))
|
|
57
|
+
* PD-1707 show validation errors in ecr ([bb7e95c](https://github.com/pie-framework/pie-lib/commit/bb7e95c824ae802452720856ad1117aa21c5766f))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# [7.21.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.20.0...@pie-lib/editable-html@7.21.0) (2022-04-28)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* **editable-html:** disabled add response area button when maxResponseArea value is reached PD-1699 ([9c28e5b](https://github.com/pie-framework/pie-lib/commit/9c28e5b1702995a497e8528038a1b9e71b72c84f))
|
|
69
|
+
* **editable-html:** PD-1707 add validation ui/ux to responses areas in ecr ([7381c58](https://github.com/pie-framework/pie-lib/commit/7381c581e9f1099f48f8cfbe307f23dbd8776773))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# [7.20.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.19.3...@pie-lib/editable-html@7.20.0) (2022-04-12)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Bug Fixes
|
|
79
|
+
|
|
80
|
+
* **editable-html:** Removed overflow property that prevent body content from scrolling after closing dialog PD-1659 ([da2dc24](https://github.com/pie-framework/pie-lib/commit/da2dc2421448fa56d83369a043d864a568b1f886))
|
|
81
|
+
* **list:** fixed list in list issues [PD-1229] ([46dcec0](https://github.com/pie-framework/pie-lib/commit/46dcec0e20fc2d09969c45fd75426f647931ec08))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### Features
|
|
85
|
+
|
|
86
|
+
* **config-ui, editable-html:** add ui/ux validation for choices and editable html fields ([d40148f](https://github.com/pie-framework/pie-lib/commit/d40148f0f4b1232ce1506867a7424aa56e26c5ec))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## [7.19.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.19.2...@pie-lib/editable-html@7.19.3) (2022-03-21)
|
|
93
|
+
|
|
94
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## [7.19.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.19.1...@pie-lib/editable-html@7.19.2) (2022-03-08)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Bug Fixes
|
|
104
|
+
|
|
105
|
+
* **editable-html:** Added default values for responseAreaProps ([b49a919](https://github.com/pie-framework/pie-lib/commit/b49a919b4d5e336cb2a82e4e7926d72372369d3c))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## [7.19.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.19.0...@pie-lib/editable-html@7.19.1) (2022-03-07)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
### Bug Fixes
|
|
115
|
+
|
|
116
|
+
* **editable-html:** Called onHandleAreaChange only for delete ([ad1c8aa](https://github.com/pie-framework/pie-lib/commit/ad1c8aa83eef71bd8201cb55ec21513c008f77a6))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# [7.19.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.18.0...@pie-lib/editable-html@7.19.0) (2022-03-07)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
### Features
|
|
126
|
+
|
|
127
|
+
* **editor:** added func callback property, called when the resp area els nr is changed in the markup [PD-1592] ([d35feee](https://github.com/pie-framework/pie-lib/commit/d35feee5c68c13375963aa5cad25b2ef6ffc39f3))
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# [7.18.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.19...@pie-lib/editable-html@7.18.0) (2022-02-21)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### Bug Fixes
|
|
137
|
+
|
|
138
|
+
* **editable-html:** fix style for table rendering PD-1459 ([7c139b5](https://github.com/pie-framework/pie-lib/commit/7c139b5))
|
|
139
|
+
* **editable-html:** Insert button from video/audio modal can't be pressed if the URL is empty PD-1488 ([6c7c1f6](https://github.com/pie-framework/pie-lib/commit/6c7c1f6))
|
|
140
|
+
* **editor:** made sure space is added after table even when there is a div wrapper [PD-1614] ([5aa8bd1](https://github.com/pie-framework/pie-lib/commit/5aa8bd1))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### Features
|
|
144
|
+
|
|
145
|
+
* **editable-html:** drag-in-the-blank visually indicate when response area is selected, hide non-applicable tools PD-1383 ([a3b7d08](https://github.com/pie-framework/pie-lib/commit/a3b7d08))
|
|
146
|
+
* **editor:** made sure cursor is visible before and after custom void elements [PD-1474] ([189ee2d](https://github.com/pie-framework/pie-lib/commit/189ee2d))
|
|
147
|
+
* **editor:** made sure x<y is not removed from the math latex [PD-1475] ([ea94ad0](https://github.com/pie-framework/pie-lib/commit/ea94ad0))
|
|
148
|
+
* **table:** made sure default border is 1 for tables [PD-1459] ([e8bd0d7](https://github.com/pie-framework/pie-lib/commit/e8bd0d7))
|
|
149
|
+
* **table:** made sure focus is switched to first cell of the table when adding one [PD-1455] ([907c230](https://github.com/pie-framework/pie-lib/commit/907c230))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## [7.17.19](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.18...@pie-lib/editable-html@7.17.19) (2022-02-21)
|
|
156
|
+
|
|
157
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
## [7.17.18](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.17...@pie-lib/editable-html@7.17.18) (2022-02-04)
|
|
164
|
+
|
|
165
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
## [7.17.17](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.16...@pie-lib/editable-html@7.17.17) (2022-02-03)
|
|
172
|
+
|
|
173
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
## [7.17.16](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.15...@pie-lib/editable-html@7.17.16) (2022-01-24)
|
|
180
|
+
|
|
181
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## [7.17.15](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.14...@pie-lib/editable-html@7.17.15) (2022-01-10)
|
|
188
|
+
|
|
189
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
## [7.17.14](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.13...@pie-lib/editable-html@7.17.14) (2021-12-22)
|
|
196
|
+
|
|
197
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
## [7.17.13](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.12...@pie-lib/editable-html@7.17.13) (2021-12-13)
|
|
204
|
+
|
|
205
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
## [7.17.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.11...@pie-lib/editable-html@7.17.12) (2021-11-29)
|
|
212
|
+
|
|
213
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
## [7.17.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.10...@pie-lib/editable-html@7.17.11) (2021-10-04)
|
|
220
|
+
|
|
221
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
## [7.17.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.9...@pie-lib/editable-html@7.17.10) (2021-10-04)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
### Bug Fixes
|
|
231
|
+
|
|
232
|
+
* **serialization:** made sure that units are not added to numbered values when they are encountered [PD-722] ([8d229cf](https://github.com/pie-framework/pie-lib/commit/8d229cf))
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
## [7.17.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.8...@pie-lib/editable-html@7.17.9) (2021-09-20)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
### Bug Fixes
|
|
242
|
+
|
|
243
|
+
* **editor:** used dom refs in order to check if the editor is still in focus [PD-1126] ([99e0f72](https://github.com/pie-framework/pie-lib/commit/99e0f72))
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
## [7.17.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.7...@pie-lib/editable-html@7.17.8) (2021-09-20)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
### Bug Fixes
|
|
253
|
+
|
|
254
|
+
* **editor:** made sure that if the editor loses focus, the onBlur function is called only if the focus is still not inside the dom element [PD-1126] ([e74f00a](https://github.com/pie-framework/pie-lib/commit/e74f00a))
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
## [7.17.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.6...@pie-lib/editable-html@7.17.7) (2021-09-20)
|
|
261
|
+
|
|
262
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
## [7.17.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.5...@pie-lib/editable-html@7.17.6) (2021-09-16)
|
|
269
|
+
|
|
270
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
## [7.17.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.4...@pie-lib/editable-html@7.17.5) (2021-09-08)
|
|
277
|
+
|
|
278
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
## [7.17.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.3...@pie-lib/editable-html@7.17.4) (2021-09-08)
|
|
285
|
+
|
|
286
|
+
**Note:** Version bump only for package @pie-lib/editable-html
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
6
292
|
## [7.17.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.2...@pie-lib/editable-html@7.17.3) (2021-08-30)
|
|
7
293
|
|
|
8
294
|
|
package/lib/editor.js
CHANGED
|
@@ -90,6 +90,7 @@ var defaultResponseAreaProps = {
|
|
|
90
90
|
respAreaToolbar: function respAreaToolbar() {},
|
|
91
91
|
onHandleAreaChange: function onHandleAreaChange() {}
|
|
92
92
|
};
|
|
93
|
+
var defaultLanguageCharactersProps = [];
|
|
93
94
|
|
|
94
95
|
var createToolbarOpts = function createToolbarOpts(toolbarOpts) {
|
|
95
96
|
return _objectSpread(_objectSpread({}, defaultToolbarOpts), toolbarOpts);
|
|
@@ -100,12 +101,108 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
100
101
|
|
|
101
102
|
var _super = _createSuper(Editor);
|
|
102
103
|
|
|
103
|
-
function Editor(
|
|
104
|
+
function Editor(_props) {
|
|
104
105
|
var _this;
|
|
105
106
|
|
|
106
107
|
_classCallCheck(this, Editor);
|
|
107
108
|
|
|
108
|
-
_this = _super.call(this,
|
|
109
|
+
_this = _super.call(this, _props);
|
|
110
|
+
|
|
111
|
+
_defineProperty(_assertThisInitialized(_this), "handlePlugins", function (props) {
|
|
112
|
+
var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
|
|
113
|
+
|
|
114
|
+
_this.plugins = (0, _plugins.buildPlugins)(props.activePlugins, {
|
|
115
|
+
math: {
|
|
116
|
+
onClick: _this.onMathClick,
|
|
117
|
+
onFocus: _this.onPluginFocus,
|
|
118
|
+
onBlur: _this.onPluginBlur
|
|
119
|
+
},
|
|
120
|
+
image: {
|
|
121
|
+
onDelete: props.imageSupport && props.imageSupport["delete"] && function (src, done) {
|
|
122
|
+
props.imageSupport["delete"](src, function (e) {
|
|
123
|
+
done(e, _this.state.value);
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
insertImageRequested: props.imageSupport && function (getHandler) {
|
|
127
|
+
/**
|
|
128
|
+
* The handler is the object through which the outer context
|
|
129
|
+
* communicates file upload events like: fileChosen, cancel, progress
|
|
130
|
+
*/
|
|
131
|
+
var handler = getHandler(function () {
|
|
132
|
+
return _this.state.value;
|
|
133
|
+
});
|
|
134
|
+
props.imageSupport.add(handler);
|
|
135
|
+
},
|
|
136
|
+
onFocus: _this.onPluginFocus,
|
|
137
|
+
onBlur: _this.onPluginBlur
|
|
138
|
+
},
|
|
139
|
+
toolbar: {
|
|
140
|
+
/**
|
|
141
|
+
* To minimize converting html -> state -> html
|
|
142
|
+
* We only emit markup once 'done' is clicked.
|
|
143
|
+
*/
|
|
144
|
+
disableUnderline: props.disableUnderline,
|
|
145
|
+
autoWidth: props.autoWidthToolbar,
|
|
146
|
+
onDone: function onDone() {
|
|
147
|
+
var nonEmpty = props.nonEmpty;
|
|
148
|
+
log('[onDone]');
|
|
149
|
+
|
|
150
|
+
_this.setState({
|
|
151
|
+
toolbarInFocus: false,
|
|
152
|
+
focusedNode: null
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
_this.editor.blur();
|
|
156
|
+
|
|
157
|
+
if (nonEmpty && _this.state.value.startText.text.length === 0) {
|
|
158
|
+
_this.resetValue(true).then(function () {
|
|
159
|
+
_this.onEditingDone();
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
_this.onEditingDone();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
table: {
|
|
167
|
+
onFocus: function onFocus() {
|
|
168
|
+
log('[table:onFocus]...');
|
|
169
|
+
|
|
170
|
+
_this.onPluginFocus();
|
|
171
|
+
},
|
|
172
|
+
onBlur: function onBlur() {
|
|
173
|
+
log('[table:onBlur]...');
|
|
174
|
+
|
|
175
|
+
_this.onPluginBlur();
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
responseArea: {
|
|
179
|
+
type: normalizedResponseAreaProps.type,
|
|
180
|
+
options: normalizedResponseAreaProps.options,
|
|
181
|
+
maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,
|
|
182
|
+
respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,
|
|
183
|
+
onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,
|
|
184
|
+
error: normalizedResponseAreaProps.error,
|
|
185
|
+
onFocus: function onFocus() {
|
|
186
|
+
log('[table:onFocus]...');
|
|
187
|
+
|
|
188
|
+
_this.onPluginFocus();
|
|
189
|
+
},
|
|
190
|
+
onBlur: function onBlur() {
|
|
191
|
+
log('[table:onBlur]...');
|
|
192
|
+
|
|
193
|
+
_this.onPluginBlur();
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
languageCharacters: props.languageCharactersProps,
|
|
197
|
+
media: {
|
|
198
|
+
focus: _this.focus,
|
|
199
|
+
createChange: function createChange() {
|
|
200
|
+
return _this.state.value.change();
|
|
201
|
+
},
|
|
202
|
+
onChange: _this.onChange
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
109
206
|
|
|
110
207
|
_defineProperty(_assertThisInitialized(_this), "onPluginBlur", function (e) {
|
|
111
208
|
log('[onPluginBlur]', e && e.relatedTarget);
|
|
@@ -321,9 +418,15 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
321
418
|
|
|
322
419
|
_defineProperty(_assertThisInitialized(_this), "onChange", function (change, done) {
|
|
323
420
|
log('[onChange]');
|
|
421
|
+
var value = change.value;
|
|
422
|
+
var charactersLimit = _this.props.charactersLimit;
|
|
423
|
+
|
|
424
|
+
if (value && value.document && value.document.text && value.document.text.length > charactersLimit) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
324
427
|
|
|
325
428
|
_this.setState({
|
|
326
|
-
value:
|
|
429
|
+
value: value
|
|
327
430
|
}, function () {
|
|
328
431
|
log('[onChange], call done()');
|
|
329
432
|
|
|
@@ -397,107 +500,16 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
397
500
|
});
|
|
398
501
|
|
|
399
502
|
_this.state = {
|
|
400
|
-
value:
|
|
401
|
-
toolbarOpts: createToolbarOpts(
|
|
503
|
+
value: _props.value,
|
|
504
|
+
toolbarOpts: createToolbarOpts(_props.toolbarOpts)
|
|
402
505
|
};
|
|
403
506
|
|
|
404
|
-
var normalizedResponseAreaProps = _objectSpread(_objectSpread({}, defaultResponseAreaProps), props.responseAreaProps);
|
|
405
|
-
|
|
406
507
|
_this.onResize = function () {
|
|
407
|
-
|
|
508
|
+
_props.onChange(_this.state.value, true);
|
|
408
509
|
};
|
|
409
510
|
|
|
410
|
-
_this.
|
|
411
|
-
math: {
|
|
412
|
-
onClick: _this.onMathClick,
|
|
413
|
-
onFocus: _this.onPluginFocus,
|
|
414
|
-
onBlur: _this.onPluginBlur
|
|
415
|
-
},
|
|
416
|
-
image: {
|
|
417
|
-
onDelete: _this.props.imageSupport && _this.props.imageSupport["delete"] && function (src, done) {
|
|
418
|
-
_this.props.imageSupport["delete"](src, function (e) {
|
|
419
|
-
done(e, _this.state.value);
|
|
420
|
-
});
|
|
421
|
-
},
|
|
422
|
-
insertImageRequested: _this.props.imageSupport && function (getHandler) {
|
|
423
|
-
/**
|
|
424
|
-
* The handler is the object through which the outer context
|
|
425
|
-
* communicates file upload events like: fileChosen, cancel, progress
|
|
426
|
-
*/
|
|
427
|
-
var handler = getHandler(function () {
|
|
428
|
-
return _this.state.value;
|
|
429
|
-
});
|
|
511
|
+
_this.handlePlugins(_this.props);
|
|
430
512
|
|
|
431
|
-
_this.props.imageSupport.add(handler);
|
|
432
|
-
},
|
|
433
|
-
onFocus: _this.onPluginFocus,
|
|
434
|
-
onBlur: _this.onPluginBlur
|
|
435
|
-
},
|
|
436
|
-
toolbar: {
|
|
437
|
-
/**
|
|
438
|
-
* To minimize converting html -> state -> html
|
|
439
|
-
* We only emit markup once 'done' is clicked.
|
|
440
|
-
*/
|
|
441
|
-
disableUnderline: props.disableUnderline,
|
|
442
|
-
autoWidth: props.autoWidthToolbar,
|
|
443
|
-
onDone: function onDone() {
|
|
444
|
-
var nonEmpty = _this.props.nonEmpty;
|
|
445
|
-
log('[onDone]');
|
|
446
|
-
|
|
447
|
-
_this.setState({
|
|
448
|
-
toolbarInFocus: false,
|
|
449
|
-
focusedNode: null
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
_this.editor.blur();
|
|
453
|
-
|
|
454
|
-
if (nonEmpty && _this.state.value.startText.text.length === 0) {
|
|
455
|
-
_this.resetValue(true).then(function () {
|
|
456
|
-
_this.onEditingDone();
|
|
457
|
-
});
|
|
458
|
-
} else {
|
|
459
|
-
_this.onEditingDone();
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
table: {
|
|
464
|
-
onFocus: function onFocus() {
|
|
465
|
-
log('[table:onFocus]...');
|
|
466
|
-
|
|
467
|
-
_this.onPluginFocus();
|
|
468
|
-
},
|
|
469
|
-
onBlur: function onBlur() {
|
|
470
|
-
log('[table:onBlur]...');
|
|
471
|
-
|
|
472
|
-
_this.onPluginBlur();
|
|
473
|
-
}
|
|
474
|
-
},
|
|
475
|
-
responseArea: {
|
|
476
|
-
type: normalizedResponseAreaProps.type,
|
|
477
|
-
options: normalizedResponseAreaProps.options,
|
|
478
|
-
maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,
|
|
479
|
-
respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,
|
|
480
|
-
onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,
|
|
481
|
-
error: normalizedResponseAreaProps.error,
|
|
482
|
-
onFocus: function onFocus() {
|
|
483
|
-
log('[table:onFocus]...');
|
|
484
|
-
|
|
485
|
-
_this.onPluginFocus();
|
|
486
|
-
},
|
|
487
|
-
onBlur: function onBlur() {
|
|
488
|
-
log('[table:onBlur]...');
|
|
489
|
-
|
|
490
|
-
_this.onPluginBlur();
|
|
491
|
-
}
|
|
492
|
-
},
|
|
493
|
-
media: {
|
|
494
|
-
focus: _this.focus,
|
|
495
|
-
createChange: function createChange() {
|
|
496
|
-
return _this.state.value.change();
|
|
497
|
-
},
|
|
498
|
-
onChange: _this.onChange
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
513
|
return _this;
|
|
502
514
|
}
|
|
503
515
|
|
|
@@ -535,6 +547,10 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
535
547
|
toolbarOpts: newToolbarOpts
|
|
536
548
|
});
|
|
537
549
|
}
|
|
550
|
+
|
|
551
|
+
if (!(0, _isEqual["default"])(nextProps.languageCharactersProps, this.props.languageCharactersProps)) {
|
|
552
|
+
this.handlePlugins(nextProps);
|
|
553
|
+
}
|
|
538
554
|
}
|
|
539
555
|
}, {
|
|
540
556
|
key: "componentDidUpdate",
|
|
@@ -669,6 +685,7 @@ _defineProperty(Editor, "propTypes", {
|
|
|
669
685
|
focus: _propTypes["default"].func.isRequired,
|
|
670
686
|
value: _slatePropTypes["default"].value.isRequired,
|
|
671
687
|
imageSupport: _propTypes["default"].object,
|
|
688
|
+
charactersLimit: _propTypes["default"].number,
|
|
672
689
|
width: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
673
690
|
height: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
674
691
|
minHeight: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
@@ -688,6 +705,11 @@ _defineProperty(Editor, "propTypes", {
|
|
|
688
705
|
respAreaToolbar: _propTypes["default"].func,
|
|
689
706
|
onHandleAreaChange: _propTypes["default"].func
|
|
690
707
|
}),
|
|
708
|
+
languageCharactersProps: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
709
|
+
language: _propTypes["default"].string,
|
|
710
|
+
characterIcon: _propTypes["default"].string,
|
|
711
|
+
characters: _propTypes["default"].arrayOf(_propTypes["default"].arrayOf(_propTypes["default"].string))
|
|
712
|
+
})),
|
|
691
713
|
toolbarOpts: _propTypes["default"].shape({
|
|
692
714
|
position: _propTypes["default"].oneOf(['bottom', 'top']),
|
|
693
715
|
alignment: _propTypes["default"].oneOf(['left', 'right']),
|
|
@@ -710,7 +732,8 @@ _defineProperty(Editor, "defaultProps", {
|
|
|
710
732
|
onBlur: function onBlur() {},
|
|
711
733
|
onKeyDown: function onKeyDown() {},
|
|
712
734
|
toolbarOpts: defaultToolbarOpts,
|
|
713
|
-
responseAreaProps: defaultResponseAreaProps
|
|
735
|
+
responseAreaProps: defaultResponseAreaProps,
|
|
736
|
+
languageCharactersProps: defaultLanguageCharactersProps
|
|
714
737
|
});
|
|
715
738
|
|
|
716
739
|
var styles = {
|