@pie-lib/editable-html 7.17.3-next.38 → 7.17.4-next.105

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.json CHANGED
@@ -3143,5 +3143,65 @@
3143
3143
  "committerDate": "2021-07-30 11:06:51 +0300",
3144
3144
  "isTagged": true,
3145
3145
  "tag": "@pie-lib/editable-html@7.17.2"
3146
+ },
3147
+ {
3148
+ "type": "fix",
3149
+ "scope": "editor",
3150
+ "subject": "made sure that if the editor loses focus, the onBlur function is called no matter what [PD-1126]",
3151
+ "merge": null,
3152
+ "header": "fix(editor): made sure that if the editor loses focus, the onBlur function is called no matter what [PD-1126]",
3153
+ "body": null,
3154
+ "footer": null,
3155
+ "notes": [],
3156
+ "hash": "906046c3176d86934a40b0e22c0a4a0166714f4a",
3157
+ "gitTags": "",
3158
+ "committerDate": "2021-08-12 13:40:51 +0300",
3159
+ "isTagged": true,
3160
+ "tag": "@pie-lib/editable-html@7.17.3"
3161
+ },
3162
+ {
3163
+ "type": "fix",
3164
+ "scope": "editor",
3165
+ "subject": "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]",
3166
+ "merge": null,
3167
+ "header": "fix(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]",
3168
+ "body": null,
3169
+ "footer": null,
3170
+ "notes": [],
3171
+ "hash": "e74f00a7949ab1ab993fb618d087f6156ab0e67f",
3172
+ "gitTags": " (origin/fix/editable-html-dom-blur)",
3173
+ "committerDate": "2021-09-20 11:10:47 +0300",
3174
+ "isTagged": true,
3175
+ "tag": "@pie-lib/editable-html@7.17.8"
3176
+ },
3177
+ {
3178
+ "type": "fix",
3179
+ "scope": "editor",
3180
+ "subject": "used dom refs in order to check if the editor is still in focus [PD-1126]",
3181
+ "merge": null,
3182
+ "header": "fix(editor): used dom refs in order to check if the editor is still in focus [PD-1126]",
3183
+ "body": null,
3184
+ "footer": null,
3185
+ "notes": [],
3186
+ "hash": "99e0f72de5a208c5760723bad4698b9115ac80e7",
3187
+ "gitTags": " (origin/fix/editable-html-dom-blur-query-fix)",
3188
+ "committerDate": "2021-09-20 13:43:11 +0300",
3189
+ "isTagged": true,
3190
+ "tag": "@pie-lib/editable-html@7.17.9"
3191
+ },
3192
+ {
3193
+ "type": "fix",
3194
+ "scope": "serialization",
3195
+ "subject": "made sure that units are not added to numbered values when they are encountered [PD-722]",
3196
+ "merge": null,
3197
+ "header": "fix(serialization): made sure that units are not added to numbered values when they are encountered [PD-722]",
3198
+ "body": null,
3199
+ "footer": null,
3200
+ "notes": [],
3201
+ "hash": "8d229cf92ce1cf68db194d281803a79c03141d8a",
3202
+ "gitTags": " (origin/fix/PD-722-no-unit-adding)",
3203
+ "committerDate": "2021-09-27 15:01:05 +0300",
3204
+ "isTagged": true,
3205
+ "tag": "@pie-lib/editable-html@7.17.10"
3146
3206
  }
3147
3207
  ]
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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.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
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **editor:** made sure that if the editor loses focus, the onBlur function is called no matter what [PD-1126] ([906046c](https://github.com/pie-framework/pie-lib/commit/906046c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.17.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.17.1...@pie-lib/editable-html@7.17.2) (2021-08-04)
7
18
 
8
19
 
@@ -28,254 +39,143 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
28
39
 
29
40
  # [7.17.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.19...@pie-lib/editable-html@7.17.0) (2021-07-23)
30
41
 
31
-
32
42
  ### Bug Fixes
33
43
 
34
- * **editable-html:** add refs for editors, fix propTypes warnings for PD-1230 ([c6e3a2a](https://github.com/pie-framework/pie-lib/commit/c6e3a2a))
35
- * **editable-html:** Updated serialization PD-859 ([5f30897](https://github.com/pie-framework/pie-lib/commit/5f30897))
36
-
44
+ - **editable-html:** add refs for editors, fix propTypes warnings for PD-1230 ([c6e3a2a](https://github.com/pie-framework/pie-lib/commit/c6e3a2a))
45
+ - **editable-html:** Updated serialization PD-859 ([5f30897](https://github.com/pie-framework/pie-lib/commit/5f30897))
37
46
 
38
47
  ### Features
39
48
 
40
- * **editable-html:** add prop that allows editable-html fields to be validated PD-601 ([2fe2b9b](https://github.com/pie-framework/pie-lib/commit/2fe2b9b))
41
-
42
-
43
-
44
-
49
+ - **editable-html:** add prop that allows editable-html fields to be validated PD-601 ([2fe2b9b](https://github.com/pie-framework/pie-lib/commit/2fe2b9b))
45
50
 
46
51
  ## [7.16.19](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.17...@pie-lib/editable-html@7.16.19) (2021-06-25)
47
52
 
48
53
  **Note:** Version bump only for package @pie-lib/editable-html
49
54
 
50
-
51
-
52
-
53
-
54
55
  ## [7.16.17](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.16...@pie-lib/editable-html@7.16.17) (2021-06-25)
55
56
 
56
-
57
57
  ### Bug Fixes
58
58
 
59
- * **editable-html:** Fixed error checking makes it difficult to type a URL - PD-1082 ([42c5ad3](https://github.com/pie-framework/pie-lib/commit/42c5ad3))
60
- * **editable-html:** insert video should not accept audio and vice versa PD-832 ([4e1e0a3](https://github.com/pie-framework/pie-lib/commit/4e1e0a3))
61
- * **editable-html:** remove green checkmark next to the delete button on the toolbar PD-1125 ([b2cb463](https://github.com/pie-framework/pie-lib/commit/b2cb463))
62
- * **editable-html:** Text edits will remain when resize window - PD-356 ([c06caaf](https://github.com/pie-framework/pie-lib/commit/c06caaf))
63
- * **inline-dropdown:** Called onBlur on editable-html - PD-294 ([437ef1d](https://github.com/pie-framework/pie-lib/commit/437ef1d))
64
- * **multi-trait-rubric:** Added right and left alignment for the toolbar ([f3def8b](https://github.com/pie-framework/pie-lib/commit/f3def8b))
65
- * **table:** made sure table block is not the latest node in the document [PD-341] ([90bb47a](https://github.com/pie-framework/pie-lib/commit/90bb47a))
66
-
67
-
68
-
69
-
59
+ - **editable-html:** Fixed error checking makes it difficult to type a URL - PD-1082 ([42c5ad3](https://github.com/pie-framework/pie-lib/commit/42c5ad3))
60
+ - **editable-html:** insert video should not accept audio and vice versa PD-832 ([4e1e0a3](https://github.com/pie-framework/pie-lib/commit/4e1e0a3))
61
+ - **editable-html:** remove green checkmark next to the delete button on the toolbar PD-1125 ([b2cb463](https://github.com/pie-framework/pie-lib/commit/b2cb463))
62
+ - **editable-html:** Text edits will remain when resize window - PD-356 ([c06caaf](https://github.com/pie-framework/pie-lib/commit/c06caaf))
63
+ - **inline-dropdown:** Called onBlur on editable-html - PD-294 ([437ef1d](https://github.com/pie-framework/pie-lib/commit/437ef1d))
64
+ - **multi-trait-rubric:** Added right and left alignment for the toolbar ([f3def8b](https://github.com/pie-framework/pie-lib/commit/f3def8b))
65
+ - **table:** made sure table block is not the latest node in the document [PD-341](<[90bb47a](https://github.com/pie-framework/pie-lib/commit/90bb47a)>)
70
66
 
71
67
  ## [7.16.16](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.15...@pie-lib/editable-html@7.16.16) (2021-04-06)
72
68
 
73
69
  **Note:** Version bump only for package @pie-lib/editable-html
74
70
 
75
-
76
-
77
-
78
-
79
71
  ## [7.16.15](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.14...@pie-lib/editable-html@7.16.15) (2021-04-02)
80
72
 
81
73
  **Note:** Version bump only for package @pie-lib/editable-html
82
74
 
83
-
84
-
85
-
86
-
87
75
  ## [7.16.14](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.13...@pie-lib/editable-html@7.16.14) (2021-03-22)
88
76
 
89
-
90
77
  ### Bug Fixes
91
78
 
92
- * **editable-html:** custom key fix for math keypad - PD-388 ([adba7f0](https://github.com/pie-framework/pie-lib/commit/adba7f0))
93
-
94
-
95
-
96
-
79
+ - **editable-html:** custom key fix for math keypad - PD-388 ([adba7f0](https://github.com/pie-framework/pie-lib/commit/adba7f0))
97
80
 
98
81
  ## [7.16.13](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.12...@pie-lib/editable-html@7.16.13) (2021-03-15)
99
82
 
100
83
  **Note:** Version bump only for package @pie-lib/editable-html
101
84
 
102
-
103
-
104
-
105
-
106
85
  ## [7.16.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.11...@pie-lib/editable-html@7.16.12) (2021-03-03)
107
86
 
108
87
  **Note:** Version bump only for package @pie-lib/editable-html
109
88
 
110
-
111
-
112
-
113
-
114
89
  ## [7.16.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.10...@pie-lib/editable-html@7.16.11) (2021-03-02)
115
90
 
116
91
  **Note:** Version bump only for package @pie-lib/editable-html
117
92
 
118
-
119
-
120
-
121
-
122
93
  ## [7.16.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.9...@pie-lib/editable-html@7.16.10) (2021-03-01)
123
94
 
124
95
  **Note:** Version bump only for package @pie-lib/editable-html
125
96
 
126
-
127
-
128
-
129
-
130
97
  ## [7.16.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.8...@pie-lib/editable-html@7.16.9) (2021-03-01)
131
98
 
132
-
133
99
  ### Bug Fixes
134
100
 
135
- * **editable-html:** add delete button for response area PD-778 ([234ba06](https://github.com/pie-framework/pie-lib/commit/234ba06))
136
- * **editable-html:** add min and max height to fix PD-694 ([955db39](https://github.com/pie-framework/pie-lib/commit/955db39))
137
-
138
-
139
-
140
-
101
+ - **editable-html:** add delete button for response area PD-778 ([234ba06](https://github.com/pie-framework/pie-lib/commit/234ba06))
102
+ - **editable-html:** add min and max height to fix PD-694 ([955db39](https://github.com/pie-framework/pie-lib/commit/955db39))
141
103
 
142
104
  ## [7.16.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.7...@pie-lib/editable-html@7.16.8) (2021-02-15)
143
105
 
144
-
145
106
  ### Bug Fixes
146
107
 
147
- * demo ([affa119](https://github.com/pie-framework/pie-lib/commit/affa119))
148
-
149
-
150
-
151
-
108
+ - demo ([affa119](https://github.com/pie-framework/pie-lib/commit/affa119))
152
109
 
153
110
  ## [7.16.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.5...@pie-lib/editable-html@7.16.7) (2021-02-15)
154
111
 
155
112
  **Note:** Version bump only for package @pie-lib/editable-html
156
113
 
157
-
158
-
159
-
160
-
161
114
  ## [7.16.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.4...@pie-lib/editable-html@7.16.5) (2021-02-15)
162
115
 
163
116
  **Note:** Version bump only for package @pie-lib/editable-html
164
117
 
165
-
166
-
167
-
168
-
169
118
  ## [7.16.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.3...@pie-lib/editable-html@7.16.4) (2021-02-04)
170
119
 
171
120
  **Note:** Version bump only for package @pie-lib/editable-html
172
121
 
173
-
174
-
175
-
176
-
177
122
  ## [7.16.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.2...@pie-lib/editable-html@7.16.3) (2021-02-01)
178
123
 
179
124
  **Note:** Version bump only for package @pie-lib/editable-html
180
125
 
181
-
182
-
183
-
184
-
185
126
  ## [7.16.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.1...@pie-lib/editable-html@7.16.2) (2021-01-28)
186
127
 
187
128
  **Note:** Version bump only for package @pie-lib/editable-html
188
129
 
189
-
190
-
191
-
192
-
193
130
  ## [7.16.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.16.0...@pie-lib/editable-html@7.16.1) (2021-01-28)
194
131
 
195
132
  **Note:** Version bump only for package @pie-lib/editable-html
196
133
 
197
-
198
-
199
-
200
-
201
134
  # [7.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.15.0...@pie-lib/editable-html@7.16.0) (2021-01-25)
202
135
 
203
-
204
136
  ### Features
205
137
 
206
- * **editable-html:** remove Code plugin - PD-463 ([d830231](https://github.com/pie-framework/pie-lib/commit/d830231))
207
-
208
-
209
-
210
-
138
+ - **editable-html:** remove Code plugin - PD-463 ([d830231](https://github.com/pie-framework/pie-lib/commit/d830231))
211
139
 
212
140
  # [7.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.14.1...@pie-lib/editable-html@7.15.0) (2021-01-11)
213
141
 
214
-
215
142
  ### Bug Fixes
216
143
 
217
- * Added fix for text wrapping into next line and also font style is overrided by parent styling ([60ff10f](https://github.com/pie-framework/pie-lib/commit/60ff10f))
218
- * Due to resize of window, editor text gets reverted to previous state value. PD-356 ([c710829](https://github.com/pie-framework/pie-lib/commit/c710829))
219
- * Due to resize of window, editor text gets reverted to previous state value. PD-356 ([9f6b988](https://github.com/pie-framework/pie-lib/commit/9f6b988))
220
-
144
+ - Added fix for text wrapping into next line and also font style is overrided by parent styling ([60ff10f](https://github.com/pie-framework/pie-lib/commit/60ff10f))
145
+ - Due to resize of window, editor text gets reverted to previous state value. PD-356 ([c710829](https://github.com/pie-framework/pie-lib/commit/c710829))
146
+ - Due to resize of window, editor text gets reverted to previous state value. PD-356 ([9f6b988](https://github.com/pie-framework/pie-lib/commit/9f6b988))
221
147
 
222
148
  ### Features
223
149
 
224
- * **editable-html:** add better math keypad support - PD-355 ([bc4e586](https://github.com/pie-framework/pie-lib/commit/bc4e586))
225
-
226
-
227
-
228
-
150
+ - **editable-html:** add better math keypad support - PD-355 ([bc4e586](https://github.com/pie-framework/pie-lib/commit/bc4e586))
229
151
 
230
152
  ## [7.14.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.14.0...@pie-lib/editable-html@7.14.1) (2020-11-09)
231
153
 
232
154
  **Note:** Version bump only for package @pie-lib/editable-html
233
155
 
234
-
235
-
236
-
237
-
238
156
  # [7.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.13.5...@pie-lib/editable-html@7.14.0) (2020-11-07)
239
157
 
240
-
241
158
  ### Features
242
159
 
243
- * **media:** fixed design and some warnings ([df7d84d](https://github.com/pie-framework/pie-lib/commit/df7d84d))
244
- * **media:** implemented editing functionality plus some error some more handlng ([66732a3](https://github.com/pie-framework/pie-lib/commit/66732a3))
245
- * **media:** implemented some error handling and fixed a couple of bugs with inserting the media embed [pd501] ([1616ba2](https://github.com/pie-framework/pie-lib/commit/1616ba2))
246
- * **media:** made sure width and height are used, and toolbar is relative positioned ([9061067](https://github.com/pie-framework/pie-lib/commit/9061067))
247
-
248
-
249
-
250
-
160
+ - **media:** fixed design and some warnings ([df7d84d](https://github.com/pie-framework/pie-lib/commit/df7d84d))
161
+ - **media:** implemented editing functionality plus some error some more handlng ([66732a3](https://github.com/pie-framework/pie-lib/commit/66732a3))
162
+ - **media:** implemented some error handling and fixed a couple of bugs with inserting the media embed [pd501](<[1616ba2](https://github.com/pie-framework/pie-lib/commit/1616ba2)>)
163
+ - **media:** made sure width and height are used, and toolbar is relative positioned ([9061067](https://github.com/pie-framework/pie-lib/commit/9061067))
251
164
 
252
165
  ## [7.13.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.13.4...@pie-lib/editable-html@7.13.5) (2020-10-30)
253
166
 
254
-
255
167
  ### Bug Fixes
256
168
 
257
- * missing dependency ([86b18d2](https://github.com/pie-framework/pie-lib/commit/86b18d2))
258
-
259
-
260
-
261
-
169
+ - missing dependency ([86b18d2](https://github.com/pie-framework/pie-lib/commit/86b18d2))
262
170
 
263
171
  ## [7.13.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.13.3...@pie-lib/editable-html@7.13.4) (2020-10-28)
264
172
 
265
173
  **Note:** Version bump only for package @pie-lib/editable-html
266
174
 
267
-
268
-
269
-
270
-
271
175
  ## [7.13.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.13.2...@pie-lib/editable-html@7.13.3) (2020-10-26)
272
176
 
273
177
  **Note:** Version bump only for package @pie-lib/editable-html
274
178
 
275
-
276
-
277
-
278
-
279
179
  ## [7.13.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html@7.13.1...@pie-lib/editable-html@7.13.2) (2020-10-26)
280
180
 
281
181
  **Note:** Version bump only for package @pie-lib/editable-html
package/lib/editor.js CHANGED
@@ -196,6 +196,26 @@ function (_React$Component) {
196
196
  });
197
197
  });
198
198
 
199
+ _defineProperty(_assertThisInitialized(_this), "handleDomBlur", function (e) {
200
+ var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
201
+ setTimeout(function () {
202
+ if (!_this.wrapperRef) {
203
+ return;
204
+ }
205
+
206
+ var editorElement = !editorDOM || document.activeElement.closest("[class*=\"".concat(editorDOM.className, "\"]"));
207
+ var toolbarElement = !_this.toolbarRef || document.activeElement.closest("[class*=\"".concat(_this.toolbarRef.className, "\"]"));
208
+
209
+ var isInCurrentComponent = _this.wrapperRef.contains(editorElement) || _this.wrapperRef.contains(toolbarElement);
210
+
211
+ if (!isInCurrentComponent) {
212
+ editorDOM.removeEventListener('blur', _this.handleDomBlur);
213
+
214
+ _this.onBlur(e);
215
+ }
216
+ }, 50);
217
+ });
218
+
199
219
  _defineProperty(_assertThisInitialized(_this), "onFocus", function () {
200
220
  return new Promise(function (resolve) {
201
221
  var editorDOM = document.querySelector("[data-key=\"".concat(_this.state.value.document.key, "\"]"));
@@ -231,13 +251,8 @@ function (_React$Component) {
231
251
 
232
252
 
233
253
  if (editorDOM === document.activeElement) {
234
- var handleDomBlur = function handleDomBlur(e) {
235
- editorDOM.removeEventListener('blur', handleDomBlur);
236
-
237
- _this.onBlur(e);
238
- };
239
-
240
- editorDOM.addEventListener('blur', handleDomBlur);
254
+ editorDOM.removeEventListener('blur', _this.handleDomBlur);
255
+ editorDOM.addEventListener('blur', _this.handleDomBlur);
241
256
  }
242
257
 
243
258
  _this.stashValue();
@@ -350,9 +365,10 @@ function (_React$Component) {
350
365
  * HACK ALERT: We should be calling setState here and storing the change data:
351
366
  *
352
367
  * <code>this.setState({changeData: { key, data}})</code>
353
- * However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no more changes get through.
354
- * The issues seem to be related to the promises in onBlur/onFocus. But removing these brings it's own problems.
355
- * A major clean up is planned for this component so I've decided to temporarily settle on this hack rather than spend more time on this.
368
+ * However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no
369
+ * more changes get through. The issues seem to be related to the promises in onBlur/onFocus. But removing these
370
+ * brings it's own problems. A major clean up is planned for this component so I've decided to temporarily settle
371
+ * on this hack rather than spend more time on this.
356
372
  */
357
373
  // Uncomment this line to see the bug described above.
358
374
  // this.setState({changeData: {key, data}})
@@ -578,6 +594,11 @@ function (_React$Component) {
578
594
  ref: function ref(r) {
579
595
  return _this3.editor = r && _this3.props.editorRef(r);
580
596
  },
597
+ toolbarRef: function toolbarRef(r) {
598
+ if (r) {
599
+ _this3.toolbarRef = r;
600
+ }
601
+ },
581
602
  value: value,
582
603
  focus: this.focus,
583
604
  onKeyDown: onKeyDown,
@@ -674,7 +695,7 @@ var styles = {
674
695
  color: _renderUi.color.text(),
675
696
  backgroundColor: _renderUi.color.background()
676
697
  },
677
- '& tr': {
698
+ '& table:not([border="1"]) tr': {
678
699
  borderTop: '1px solid #dfe2e5' // TODO perhaps secondary color for background, for now disable
679
700
  // '&:nth-child(2n)': {
680
701
  // backgroundColor: '#f6f8fa'
@@ -682,9 +703,11 @@ var styles = {
682
703
 
683
704
  },
684
705
  '& td, th': {
685
- border: '1px solid #dfe2e5',
686
706
  padding: '.6em 1em',
687
707
  textAlign: 'center'
708
+ },
709
+ '& table:not([border="1"]) td, th': {
710
+ border: '1px solid #dfe2e5'
688
711
  }
689
712
  },
690
713
  toolbarOnTop: {
package/lib/editor.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/editor.jsx"],"names":["log","defaultToolbarOpts","position","alignment","alwaysVisible","showDone","doneOn","createToolbarOpts","toolbarOpts","Editor","props","e","relatedTarget","target","node","state","value","setState","focusedNode","resetValue","stashedValue","stashValue","editor","change","c","collapseToStartOf","selectedNode","onChange","resolve","nonEmpty","toolbarInFocus","blur","startText","text","length","then","onEditingDone","event","Promise","handleBlur","bind","onBlur","editorDOM","document","querySelector","key","activeElement","__TEMPORARY_CHANGE_DATA","data","domEl","setNodeByKey","handleDomBlur","removeEventListener","addEventListener","onFocus","force","stopReset","plugins","reduce","s","p","isFocused","toObject","newValue","Value","fromJSON","toJSON","setTimeout","done","v","endsWith","undefined","parseInt","isNaN","object","last","nodes","type","parent","getParent","Block","pos","focus","onResize","activePlugins","math","onClick","onMathClick","onPluginFocus","onPluginBlur","image","onDelete","imageSupport","src","insertImageRequested","getHandler","handler","add","toolbar","disableUnderline","autoWidth","autoWidthToolbar","onDone","table","responseArea","responseAreaProps","options","respAreaToolbar","media","createChange","onRef","window","autoFocus","nextProps","newToolbarOpts","equals","width","minHeight","height","maxHeight","valueToSize","disabled","highlightShape","classes","className","placeholder","pluginProps","onKeyDown","sizeStyle","buildSizeStyle","names","withBg","toolbarOnTop","ref","wrapperRef","r","slateEditor","editorRef","normalize","changeData","React","Component","PropTypes","bool","func","isRequired","SlateTypes","oneOfType","string","number","any","shape","oneOf","arrayOf","values","allValid","every","ALL_PLUGINS","includes","Error","join","styles","backgroundColor","fontFamily","tableLayout","borderCollapse","color","background","borderTop","border","padding","textAlign","marginTop"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,GA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YG,IAAZ,CAAiB,GAAjB,CAA/D,OAFF;AAID,GAPc,CAxCE;AAgDjBpC,EAAAA,SAAS,EAAEkB,sBAAUM;AAhDJ,C;;gBADR3I,M,kBAoDW;AACpB0F,EAAAA,gBAAgB,EAAE,IADE;AAEpB7C,EAAAA,OAAO,EAAE,mBAAM,CAAE,CAFG;AAGpBb,EAAAA,MAAM,EAAE,kBAAM,CAAE,CAHI;AAIpBjC,EAAAA,WAAW,EAAEP,kBAJO;AAKpB8H,EAAAA,SAAS,EAAE,qBAAM,CAAE;AALC,C;;AAkdxB,IAAMkC,MAAM,GAAG;AACb9B,EAAAA,MAAM,EAAE;AACN+B,IAAAA,eAAe,EAAE;AADX,GADK;AAIb1B,EAAAA,WAAW,EAAE;AACX2B,IAAAA,UAAU,EAAE,oBADD;AAGX,eAAW;AACTC,MAAAA,WAAW,EAAE,OADJ;AAEThD,MAAAA,KAAK,EAAE,MAFE;AAGTiD,MAAAA,cAAc,EAAE,UAHP;AAITC,MAAAA,KAAK,EAAEA,gBAAMrI,IAAN,EAJE;AAKTiI,MAAAA,eAAe,EAAEI,gBAAMC,UAAN;AALR,KAHA;AAUX,YAAQ;AACNC,MAAAA,SAAS,EAAE,mBADL,CAEN;AACA;AACA;AACA;;AALM,KAVG;AAiBX,gBAAY;AACVC,MAAAA,MAAM,EAAE,mBADE;AAEVC,MAAAA,OAAO,EAAE,UAFC;AAGVC,MAAAA,SAAS,EAAE;AAHD;AAjBD,GAJA;AA2BbvC,EAAAA,YAAY,EAAE;AACZwC,IAAAA,SAAS,EAAE;AADC;AA3BD,CAAf;;eAgCe,wBAAWX,MAAX,EAAmBxJ,MAAnB,C","sourcesContent":["import { Editor as SlateEditor, findNode } from 'slate-react';\nimport SlateTypes from 'slate-prop-types';\n\nimport isEqual from 'lodash/isEqual';\nimport * as serialization from './serialization';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport { Value, Block } from 'slate';\nimport { buildPlugins, ALL_PLUGINS, DEFAULT_PLUGINS } from './plugins';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\n\nexport { ALL_PLUGINS, DEFAULT_PLUGINS, serialization };\n\nconst log = debug('editable-html:editor');\n\nconst defaultToolbarOpts = {\n position: 'bottom',\n alignment: 'left',\n alwaysVisible: false,\n showDone: true,\n doneOn: 'blur'\n};\n\nconst createToolbarOpts = toolbarOpts => {\n return {\n ...defaultToolbarOpts,\n ...toolbarOpts\n };\n};\n\nexport class Editor extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n editorRef: PropTypes.func.isRequired,\n onRef: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onKeyDown: PropTypes.func,\n focus: PropTypes.func.isRequired,\n value: SlateTypes.value.isRequired,\n imageSupport: PropTypes.object,\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classes: PropTypes.object.isRequired,\n highlightShape: PropTypes.bool,\n disabled: PropTypes.bool,\n nonEmpty: PropTypes.bool,\n disableUnderline: PropTypes.bool,\n autoWidthToolbar: PropTypes.bool,\n pluginProps: PropTypes.any,\n placeholder: PropTypes.string,\n responseAreaProps: PropTypes.shape({\n type: PropTypes.oneOf([\n 'explicit-constructed-response',\n 'inline-dropdown',\n 'drag-in-the-blank'\n ]),\n options: PropTypes.object,\n respAreaToolbar: PropTypes.func,\n onDelete: PropTypes.func\n }),\n toolbarOpts: PropTypes.shape({\n position: PropTypes.oneOf(['bottom', 'top']),\n alignment: PropTypes.oneOf(['left', 'right']),\n alwaysVisible: PropTypes.bool,\n showDone: PropTypes.bool,\n doneOn: PropTypes.string\n }),\n activePlugins: PropTypes.arrayOf(values => {\n const allValid = values.every(v => ALL_PLUGINS.includes(v));\n\n return (\n !allValid &&\n new Error(`Invalid values: ${values}, values must be one of [${ALL_PLUGINS.join(',')}]`)\n );\n }),\n className: PropTypes.string\n };\n\n static defaultProps = {\n disableUnderline: true,\n onFocus: () => {},\n onBlur: () => {},\n toolbarOpts: defaultToolbarOpts,\n onKeyDown: () => {}\n };\n\n constructor(props) {\n super(props);\n this.state = {\n value: props.value,\n toolbarOpts: createToolbarOpts(props.toolbarOpts)\n };\n\n this.onResize = () => {\n props.onChange(this.state.value, true);\n };\n\n this.plugins = buildPlugins(props.activePlugins, {\n math: {\n onClick: this.onMathClick,\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur\n },\n image: {\n onDelete:\n this.props.imageSupport &&\n this.props.imageSupport.delete &&\n ((src, done) => {\n this.props.imageSupport.delete(src, e => {\n done(e, this.state.value);\n });\n }),\n insertImageRequested:\n this.props.imageSupport &&\n (getHandler => {\n /**\n * The handler is the object through which the outer context\n * communicates file upload events like: fileChosen, cancel, progress\n */\n const handler = getHandler(() => this.state.value);\n this.props.imageSupport.add(handler);\n }),\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur\n },\n toolbar: {\n /**\n * To minimize converting html -> state -> html\n * We only emit markup once 'done' is clicked.\n */\n disableUnderline: props.disableUnderline,\n autoWidth: props.autoWidthToolbar,\n onDone: () => {\n const { nonEmpty } = this.props;\n\n log('[onDone]');\n this.setState({ toolbarInFocus: false, focusedNode: null });\n this.editor.blur();\n\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n });\n } else {\n this.onEditingDone();\n }\n }\n },\n table: {\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n responseArea: {\n type: props.responseAreaProps && props.responseAreaProps.type,\n options: props.responseAreaProps && props.responseAreaProps.options,\n respAreaToolbar: props.responseAreaProps && props.responseAreaProps.respAreaToolbar,\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n media: {\n focus: this.focus,\n createChange: () => this.state.value.change(),\n onChange: this.onChange\n }\n });\n }\n\n componentDidMount() {\n // onRef is needed to get the ref of the component because we export it using withStyles\n this.props.onRef(this);\n\n window.addEventListener('resize', this.onResize);\n\n if (this.editor && this.props.autoFocus) {\n Promise.resolve().then(() => {\n if (this.editor) {\n const editorDOM = document.querySelector(\n `[data-key=\"${this.editor.value.document.key}\"]`\n );\n\n this.editor.focus();\n\n if (editorDOM) {\n editorDOM.focus();\n }\n }\n });\n }\n }\n\n componentWillReceiveProps(nextProps) {\n const { toolbarOpts } = this.state;\n const newToolbarOpts = createToolbarOpts(nextProps.toolbarOpts);\n\n if (!isEqual(newToolbarOpts, toolbarOpts)) {\n this.setState({\n toolbarOpts: newToolbarOpts\n });\n }\n }\n\n onPluginBlur = e => {\n log('[onPluginBlur]', e && e.relatedTarget);\n const target = e && e.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n log('[onPluginBlur] node: ', node);\n this.setState({ focusedNode: node }, () => {\n this.resetValue();\n });\n };\n\n onPluginFocus = e => {\n log('[onPluginFocus]', e && e.target);\n const target = e && e.target;\n if (target) {\n const node = findNode(target, this.state.value);\n log('[onPluginFocus] node: ', node);\n\n const stashedValue = this.state.stashedValue || this.state.value;\n this.setState({ focusedNode: node, stashedValue });\n } else {\n this.setState({ focusedNode: null });\n }\n this.stashValue();\n };\n\n onMathClick = node => {\n this.editor.change(c => c.collapseToStartOf(node));\n this.setState({ selectedNode: node });\n };\n\n onEditingDone = () => {\n log('[onEditingDone]');\n this.setState({ stashedValue: null, focusedNode: null });\n log('[onEditingDone] value: ', this.state.value);\n this.props.onChange(this.state.value, true);\n };\n\n /**\n * Remove onResize event listener\n */\n componentWillUnmount() {\n window.removeEventListener('resize', this.onResize);\n }\n\n // Allowing time for onChange to take effect if it is called\n handleBlur = resolve => {\n const { nonEmpty } = this.props;\n const {\n toolbarOpts: { doneOn }\n } = this.state;\n\n this.setState({ toolbarInFocus: false, focusedNode: null });\n\n if (this.editor) {\n this.editor.blur();\n }\n\n if (doneOn === 'blur') {\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n resolve();\n });\n } else {\n this.onEditingDone();\n resolve();\n }\n }\n };\n\n onBlur = event => {\n log('[onBlur]');\n const target = event.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n\n log('[onBlur] node: ', node);\n\n return new Promise(resolve => {\n this.setState({ focusedNode: node }, this.handleBlur.bind(this, resolve));\n this.props.onBlur(event);\n });\n };\n\n /*\n * Needs to be wrapped otherwise it causes issues because of race conditions\n * Known issue for slatejs. See: https://github.com/ianstormtaylor/slate/issues/2097\n * Using timeout I wasn't able to test this\n *\n * Note: The use of promises has been causing issues with MathQuill\n * */\n onFocus = () =>\n new Promise(resolve => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n log('[onFocus]', document.activeElement);\n\n /**\n * This is a temporary hack - @see changeData below for some more information.\n */\n if (this.__TEMPORARY_CHANGE_DATA) {\n const { key, data } = this.__TEMPORARY_CHANGE_DATA;\n const domEl = document.querySelector(`[data-key=\"${key}\"]`);\n\n if (domEl) {\n let change = this.state.value.change().setNodeByKey(key, { data });\n\n this.setState({ value: change.value }, () => {\n this.__TEMPORARY_CHANGE_DATA = null;\n });\n }\n }\n\n /**\n * This is needed just in case the browser decides to make the editor\n * lose focus without triggering the onBlur event (can happen in a few cases).\n * This will also trigger onBlur if the user clicks outside of the page when the editor\n * is focused.\n */\n if (editorDOM === document.activeElement) {\n const handleDomBlur = e => {\n editorDOM.removeEventListener('blur', handleDomBlur);\n this.onBlur(e);\n };\n\n editorDOM.addEventListener('blur', handleDomBlur);\n }\n\n this.stashValue();\n this.props.onFocus();\n\n resolve();\n });\n\n stashValue = () => {\n log('[stashValue]');\n if (!this.state.stashedValue) {\n this.setState({ stashedValue: this.state.value });\n }\n };\n\n /**\n * Reset the value if the user didn't click done.\n */\n resetValue = force => {\n const { value, focusedNode } = this.state;\n\n const stopReset = this.plugins.reduce((s, p) => {\n return s || (p.stopReset && p.stopReset(this.state.value));\n }, false);\n\n log('[resetValue]', value.isFocused, focusedNode, 'stopReset: ', stopReset);\n if ((this.state.stashedValue && !value.isFocused && !focusedNode && !stopReset) || force) {\n log('[resetValue] resetting...');\n log('stashed', this.state.stashedValue.document.toObject());\n log('current', this.state.value.document.toObject());\n\n const newValue = Value.fromJSON(this.state.stashedValue.toJSON());\n\n log('newValue: ', newValue.document);\n return new Promise(resolve => {\n setTimeout(() => {\n this.setState({ value: newValue, stashedValue: null }, () => {\n log('value now: ', this.state.value.document.toJSON());\n resolve();\n });\n }, 50);\n });\n } else {\n return Promise.resolve({});\n }\n };\n\n onChange = (change, done) => {\n log('[onChange]');\n this.setState({ value: change.value }, () => {\n log('[onChange], call done()');\n\n if (done) {\n done();\n }\n });\n };\n\n UNSAFE_componentWillReceiveProps(props) {\n if (!props.value.document.equals(this.props.value.document)) {\n this.setState({\n focus: false,\n value: props.value\n });\n }\n }\n\n valueToSize = v => {\n if (!v) {\n return;\n }\n\n if (typeof v === 'string') {\n if (v.endsWith('%')) {\n return undefined;\n } else if (v.endsWith('px') || v.endsWith('vh') || v.endsWith('vw')) {\n return v;\n } else {\n const value = parseInt(v, 10);\n return isNaN(value) ? value : `${value}px`;\n }\n }\n if (typeof v === 'number') {\n return `${v}px`;\n }\n\n return;\n };\n\n buildSizeStyle() {\n const { width, minHeight, height, maxHeight } = this.props;\n\n return {\n width: this.valueToSize(width),\n height: this.valueToSize(height),\n minHeight: this.valueToSize(minHeight),\n maxHeight: this.valueToSize(maxHeight)\n };\n }\n\n validateNode = node => {\n if (node.object !== 'block') return;\n\n const last = node.nodes.last();\n if (!last) return;\n\n if (last.type !== 'image') return;\n\n log('[validateNode] last is image..');\n\n const parent = last.getParent(last.key);\n const p = Block.getParent(last.key);\n log('[validateNode] parent:', parent, p);\n\n return undefined;\n };\n\n changeData = (key, data) => {\n log('[changeData]. .. ', key, data);\n\n /**\n * HACK ALERT: We should be calling setState here and storing the change data:\n *\n * <code>this.setState({changeData: { key, data}})</code>\n * However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no more changes get through.\n * The issues seem to be related to the promises in onBlur/onFocus. But removing these brings it's own problems.\n * A major clean up is planned for this component so I've decided to temporarily settle on this hack rather than spend more time on this.\n */\n\n // Uncomment this line to see the bug described above.\n // this.setState({changeData: {key, data}})\n\n this.__TEMPORARY_CHANGE_DATA = { key, data };\n };\n\n focus = (pos, node) => {\n const position = pos || 'end';\n\n this.props.focus(position, node);\n };\n\n render() {\n const {\n disabled,\n highlightShape,\n classes,\n className,\n placeholder,\n pluginProps,\n onKeyDown\n } = this.props;\n const { value, focusedNode, toolbarOpts } = this.state;\n\n log('[render] value: ', value);\n const sizeStyle = this.buildSizeStyle();\n const names = classNames(\n {\n [classes.withBg]: highlightShape,\n [classes.toolbarOnTop]: toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'\n },\n className\n );\n\n return (\n <div\n ref={ref => (this.wrapperRef = ref)}\n style={{ width: sizeStyle.width }}\n className={names}\n >\n <SlateEditor\n plugins={this.plugins}\n innerRef={r => {\n if (r) {\n this.slateEditor = r;\n }\n }}\n ref={r => (this.editor = r && this.props.editorRef(r))}\n value={value}\n focus={this.focus}\n onKeyDown={onKeyDown}\n onChange={this.onChange}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n onEditingDone={this.onEditingDone}\n focusedNode={focusedNode}\n normalize={this.normalize}\n readOnly={disabled}\n className={classes.slateEditor}\n style={{\n minHeight: sizeStyle.minHeight,\n height: sizeStyle.height,\n maxHeight: sizeStyle.maxHeight\n }}\n pluginProps={pluginProps}\n toolbarOpts={toolbarOpts}\n placeholder={placeholder}\n onDataChange={this.changeData}\n />\n </div>\n );\n }\n}\n\n// TODO color - hardcoded gray background and keypad colors will need to change too\nconst styles = {\n withBg: {\n backgroundColor: 'rgba(0,0,0,0.06)'\n },\n slateEditor: {\n fontFamily: 'Roboto, sans-serif',\n\n '& table': {\n tableLayout: 'fixed',\n width: '100%',\n borderCollapse: 'collapse',\n color: color.text(),\n backgroundColor: color.background()\n },\n '& tr': {\n borderTop: '1px solid #dfe2e5'\n // TODO perhaps secondary color for background, for now disable\n // '&:nth-child(2n)': {\n // backgroundColor: '#f6f8fa'\n // }\n },\n '& td, th': {\n border: '1px solid #dfe2e5',\n padding: '.6em 1em',\n textAlign: 'center'\n }\n },\n toolbarOnTop: {\n marginTop: '45px'\n }\n};\n\nexport default withStyles(styles)(Editor);\n"],"file":"editor.js"}
1
+ {"version":3,"sources":["../src/editor.jsx"],"names":["log","defaultToolbarOpts","position","alignment","alwaysVisible","showDone","doneOn","createToolbarOpts","toolbarOpts","Editor","props","e","relatedTarget","target","node","state","value","setState","focusedNode","resetValue","stashedValue","stashValue","editor","change","c","collapseToStartOf","selectedNode","onChange","resolve","nonEmpty","toolbarInFocus","blur","startText","text","length","then","onEditingDone","event","Promise","handleBlur","bind","onBlur","editorDOM","document","querySelector","key","setTimeout","wrapperRef","editorElement","activeElement","closest","className","toolbarElement","toolbarRef","isInCurrentComponent","contains","removeEventListener","handleDomBlur","__TEMPORARY_CHANGE_DATA","data","domEl","setNodeByKey","addEventListener","onFocus","force","stopReset","plugins","reduce","s","p","isFocused","toObject","newValue","Value","fromJSON","toJSON","done","v","endsWith","undefined","parseInt","isNaN","object","last","nodes","type","parent","getParent","Block","pos","focus","onResize","activePlugins","math","onClick","onMathClick","onPluginFocus","onPluginBlur","image","onDelete","imageSupport","src","insertImageRequested","getHandler","handler","add","toolbar","disableUnderline","autoWidth","autoWidthToolbar","onDone","table","responseArea","responseAreaProps","options","respAreaToolbar","media","createChange","onRef","window","autoFocus","nextProps","newToolbarOpts","equals","width","minHeight","height","maxHeight","valueToSize","disabled","highlightShape","classes","placeholder","pluginProps","onKeyDown","sizeStyle","buildSizeStyle","names","withBg","toolbarOnTop","ref","r","slateEditor","editorRef","normalize","changeData","React","Component","PropTypes","bool","func","isRequired","SlateTypes","oneOfType","string","number","any","shape","oneOf","arrayOf","values","allValid","every","ALL_PLUGINS","includes","Error","join","styles","backgroundColor","fontFamily","tableLayout","borderCollapse","color","background","borderTop","padding","textAlign","border","marginTop"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,GAAG,GAAG,uBAAM,sBAAN,CAAZ;AAEA,IAAMC,kBAAkB,GAAG;AACzBC,EAAAA,QAAQ,EAAE,QADe;AAEzBC,EAAAA,SAAS,EAAE,MAFc;AAGzBC,EAAAA,aAAa,EAAE,KAHU;AAIzBC,EAAAA,QAAQ,EAAE,IAJe;AAKzBC,EAAAA,MAAM,EAAE;AALiB,CAA3B;;AAQA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAAAC,WAAW,EAAI;AACvC,2BACKP,kBADL,MAEKO,WAFL;AAID,CALD;;IAOaC,M;;;;;AA4DX,kBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,gFAAMA,KAAN;;AADiB,mEA+HJ,UAAAC,CAAC,EAAI;AAClBX,MAAAA,GAAG,CAAC,gBAAD,EAAmBW,CAAC,IAAIA,CAAC,CAACC,aAA1B,CAAH;AACA,UAAMC,MAAM,GAAGF,CAAC,IAAIA,CAAC,CAACC,aAAtB;AAEA,UAAME,IAAI,GAAGD,MAAM,GAAG,0BAASA,MAAT,EAAiB,MAAKE,KAAL,CAAWC,KAA5B,CAAH,GAAwC,IAA3D;AACAhB,MAAAA,GAAG,CAAC,uBAAD,EAA0Bc,IAA1B,CAAH;;AACA,YAAKG,QAAL,CAAc;AAAEC,QAAAA,WAAW,EAAEJ;AAAf,OAAd,EAAq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6BL,MAA7B,sCAA+DG,qBAAYG,IAAZ,CAAiB,GAAjB,CAA/D,OAFF;AAID,GAPc,CAxCE;AAgDjBnH,EAAAA,SAAS,EAAEiG,sBAAUM;AAhDJ,C;;gBADRjJ,M,kBAoDW;AACpBkG,EAAAA,gBAAgB,EAAE,IADE;AAEpB5C,EAAAA,OAAO,EAAE,mBAAM,CAAE,CAFG;AAGpBtB,EAAAA,MAAM,EAAE,kBAAM,CAAE,CAHI;AAIpBjC,EAAAA,WAAW,EAAEP,kBAJO;AAKpBqI,EAAAA,SAAS,EAAE,qBAAM,CAAE;AALC,C;;AA0exB,IAAMiC,MAAM,GAAG;AACb7B,EAAAA,MAAM,EAAE;AACN8B,IAAAA,eAAe,EAAE;AADX,GADK;AAIb1B,EAAAA,WAAW,EAAE;AACX2B,IAAAA,UAAU,EAAE,oBADD;AAGX,eAAW;AACTC,MAAAA,WAAW,EAAE,OADJ;AAET9C,MAAAA,KAAK,EAAE,MAFE;AAGT+C,MAAAA,cAAc,EAAE,UAHP;AAITC,MAAAA,KAAK,EAAEA,gBAAM3I,IAAN,EAJE;AAKTuI,MAAAA,eAAe,EAAEI,gBAAMC,UAAN;AALR,KAHA;AAUX,oCAAgC;AAC9BC,MAAAA,SAAS,EAAE,mBADmB,CAE9B;AACA;AACA;AACA;;AAL8B,KAVrB;AAiBX,gBAAY;AACVC,MAAAA,OAAO,EAAE,UADC;AAEVC,MAAAA,SAAS,EAAE;AAFD,KAjBD;AAqBX,wCAAoC;AAClCC,MAAAA,MAAM,EAAE;AAD0B;AArBzB,GAJA;AA6BbtC,EAAAA,YAAY,EAAE;AACZuC,IAAAA,SAAS,EAAE;AADC;AA7BD,CAAf;;eAkCe,wBAAWX,MAAX,EAAmB9J,MAAnB,C","sourcesContent":["import { Editor as SlateEditor, findNode } from 'slate-react';\nimport SlateTypes from 'slate-prop-types';\n\nimport isEqual from 'lodash/isEqual';\nimport * as serialization from './serialization';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport { Value, Block } from 'slate';\nimport { buildPlugins, ALL_PLUGINS, DEFAULT_PLUGINS } from './plugins';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\n\nexport { ALL_PLUGINS, DEFAULT_PLUGINS, serialization };\n\nconst log = debug('editable-html:editor');\n\nconst defaultToolbarOpts = {\n position: 'bottom',\n alignment: 'left',\n alwaysVisible: false,\n showDone: true,\n doneOn: 'blur'\n};\n\nconst createToolbarOpts = toolbarOpts => {\n return {\n ...defaultToolbarOpts,\n ...toolbarOpts\n };\n};\n\nexport class Editor extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n editorRef: PropTypes.func.isRequired,\n onRef: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onKeyDown: PropTypes.func,\n focus: PropTypes.func.isRequired,\n value: SlateTypes.value.isRequired,\n imageSupport: PropTypes.object,\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classes: PropTypes.object.isRequired,\n highlightShape: PropTypes.bool,\n disabled: PropTypes.bool,\n nonEmpty: PropTypes.bool,\n disableUnderline: PropTypes.bool,\n autoWidthToolbar: PropTypes.bool,\n pluginProps: PropTypes.any,\n placeholder: PropTypes.string,\n responseAreaProps: PropTypes.shape({\n type: PropTypes.oneOf([\n 'explicit-constructed-response',\n 'inline-dropdown',\n 'drag-in-the-blank'\n ]),\n options: PropTypes.object,\n respAreaToolbar: PropTypes.func,\n onDelete: PropTypes.func\n }),\n toolbarOpts: PropTypes.shape({\n position: PropTypes.oneOf(['bottom', 'top']),\n alignment: PropTypes.oneOf(['left', 'right']),\n alwaysVisible: PropTypes.bool,\n showDone: PropTypes.bool,\n doneOn: PropTypes.string\n }),\n activePlugins: PropTypes.arrayOf(values => {\n const allValid = values.every(v => ALL_PLUGINS.includes(v));\n\n return (\n !allValid &&\n new Error(`Invalid values: ${values}, values must be one of [${ALL_PLUGINS.join(',')}]`)\n );\n }),\n className: PropTypes.string\n };\n\n static defaultProps = {\n disableUnderline: true,\n onFocus: () => {},\n onBlur: () => {},\n toolbarOpts: defaultToolbarOpts,\n onKeyDown: () => {}\n };\n\n constructor(props) {\n super(props);\n this.state = {\n value: props.value,\n toolbarOpts: createToolbarOpts(props.toolbarOpts)\n };\n\n this.onResize = () => {\n props.onChange(this.state.value, true);\n };\n\n this.plugins = buildPlugins(props.activePlugins, {\n math: {\n onClick: this.onMathClick,\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur\n },\n image: {\n onDelete:\n this.props.imageSupport &&\n this.props.imageSupport.delete &&\n ((src, done) => {\n this.props.imageSupport.delete(src, e => {\n done(e, this.state.value);\n });\n }),\n insertImageRequested:\n this.props.imageSupport &&\n (getHandler => {\n /**\n * The handler is the object through which the outer context\n * communicates file upload events like: fileChosen, cancel, progress\n */\n const handler = getHandler(() => this.state.value);\n this.props.imageSupport.add(handler);\n }),\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur\n },\n toolbar: {\n /**\n * To minimize converting html -> state -> html\n * We only emit markup once 'done' is clicked.\n */\n disableUnderline: props.disableUnderline,\n autoWidth: props.autoWidthToolbar,\n onDone: () => {\n const { nonEmpty } = this.props;\n\n log('[onDone]');\n this.setState({ toolbarInFocus: false, focusedNode: null });\n this.editor.blur();\n\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n });\n } else {\n this.onEditingDone();\n }\n }\n },\n table: {\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n responseArea: {\n type: props.responseAreaProps && props.responseAreaProps.type,\n options: props.responseAreaProps && props.responseAreaProps.options,\n respAreaToolbar: props.responseAreaProps && props.responseAreaProps.respAreaToolbar,\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n }\n },\n media: {\n focus: this.focus,\n createChange: () => this.state.value.change(),\n onChange: this.onChange\n }\n });\n }\n\n componentDidMount() {\n // onRef is needed to get the ref of the component because we export it using withStyles\n this.props.onRef(this);\n\n window.addEventListener('resize', this.onResize);\n\n if (this.editor && this.props.autoFocus) {\n Promise.resolve().then(() => {\n if (this.editor) {\n const editorDOM = document.querySelector(\n `[data-key=\"${this.editor.value.document.key}\"]`\n );\n\n this.editor.focus();\n\n if (editorDOM) {\n editorDOM.focus();\n }\n }\n });\n }\n }\n\n componentWillReceiveProps(nextProps) {\n const { toolbarOpts } = this.state;\n const newToolbarOpts = createToolbarOpts(nextProps.toolbarOpts);\n\n if (!isEqual(newToolbarOpts, toolbarOpts)) {\n this.setState({\n toolbarOpts: newToolbarOpts\n });\n }\n }\n\n onPluginBlur = e => {\n log('[onPluginBlur]', e && e.relatedTarget);\n const target = e && e.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n log('[onPluginBlur] node: ', node);\n this.setState({ focusedNode: node }, () => {\n this.resetValue();\n });\n };\n\n onPluginFocus = e => {\n log('[onPluginFocus]', e && e.target);\n const target = e && e.target;\n if (target) {\n const node = findNode(target, this.state.value);\n log('[onPluginFocus] node: ', node);\n\n const stashedValue = this.state.stashedValue || this.state.value;\n this.setState({ focusedNode: node, stashedValue });\n } else {\n this.setState({ focusedNode: null });\n }\n this.stashValue();\n };\n\n onMathClick = node => {\n this.editor.change(c => c.collapseToStartOf(node));\n this.setState({ selectedNode: node });\n };\n\n onEditingDone = () => {\n log('[onEditingDone]');\n this.setState({ stashedValue: null, focusedNode: null });\n log('[onEditingDone] value: ', this.state.value);\n this.props.onChange(this.state.value, true);\n };\n\n /**\n * Remove onResize event listener\n */\n componentWillUnmount() {\n window.removeEventListener('resize', this.onResize);\n }\n\n // Allowing time for onChange to take effect if it is called\n handleBlur = resolve => {\n const { nonEmpty } = this.props;\n const {\n toolbarOpts: { doneOn }\n } = this.state;\n\n this.setState({ toolbarInFocus: false, focusedNode: null });\n\n if (this.editor) {\n this.editor.blur();\n }\n\n if (doneOn === 'blur') {\n if (nonEmpty && this.state.value.startText.text.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n resolve();\n });\n } else {\n this.onEditingDone();\n resolve();\n }\n }\n };\n\n onBlur = event => {\n log('[onBlur]');\n const target = event.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n\n log('[onBlur] node: ', node);\n\n return new Promise(resolve => {\n this.setState({ focusedNode: node }, this.handleBlur.bind(this, resolve));\n this.props.onBlur(event);\n });\n };\n\n handleDomBlur = e => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n setTimeout(() => {\n if (!this.wrapperRef) {\n return;\n }\n\n const editorElement =\n !editorDOM || document.activeElement.closest(`[class*=\"${editorDOM.className}\"]`);\n const toolbarElement =\n !this.toolbarRef || document.activeElement.closest(`[class*=\"${this.toolbarRef.className}\"]`);\n const isInCurrentComponent =\n this.wrapperRef.contains(editorElement) || this.wrapperRef.contains(toolbarElement);\n\n if (!isInCurrentComponent) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n this.onBlur(e);\n }\n }, 50);\n };\n\n /*\n * Needs to be wrapped otherwise it causes issues because of race conditions\n * Known issue for slatejs. See: https://github.com/ianstormtaylor/slate/issues/2097\n * Using timeout I wasn't able to test this\n *\n * Note: The use of promises has been causing issues with MathQuill\n * */\n onFocus = () =>\n new Promise(resolve => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n log('[onFocus]', document.activeElement);\n\n /**\n * This is a temporary hack - @see changeData below for some more information.\n */\n if (this.__TEMPORARY_CHANGE_DATA) {\n const { key, data } = this.__TEMPORARY_CHANGE_DATA;\n const domEl = document.querySelector(`[data-key=\"${key}\"]`);\n\n if (domEl) {\n let change = this.state.value.change().setNodeByKey(key, { data });\n\n this.setState({ value: change.value }, () => {\n this.__TEMPORARY_CHANGE_DATA = null;\n });\n }\n }\n\n /**\n * This is needed just in case the browser decides to make the editor\n * lose focus without triggering the onBlur event (can happen in a few cases).\n * This will also trigger onBlur if the user clicks outside of the page when the editor\n * is focused.\n */\n if (editorDOM === document.activeElement) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n editorDOM.addEventListener('blur', this.handleDomBlur);\n }\n\n this.stashValue();\n this.props.onFocus();\n\n resolve();\n });\n\n stashValue = () => {\n log('[stashValue]');\n if (!this.state.stashedValue) {\n this.setState({ stashedValue: this.state.value });\n }\n };\n\n /**\n * Reset the value if the user didn't click done.\n */\n resetValue = force => {\n const { value, focusedNode } = this.state;\n\n const stopReset = this.plugins.reduce((s, p) => {\n return s || (p.stopReset && p.stopReset(this.state.value));\n }, false);\n\n log('[resetValue]', value.isFocused, focusedNode, 'stopReset: ', stopReset);\n if ((this.state.stashedValue && !value.isFocused && !focusedNode && !stopReset) || force) {\n log('[resetValue] resetting...');\n log('stashed', this.state.stashedValue.document.toObject());\n log('current', this.state.value.document.toObject());\n\n const newValue = Value.fromJSON(this.state.stashedValue.toJSON());\n\n log('newValue: ', newValue.document);\n return new Promise(resolve => {\n setTimeout(() => {\n this.setState({ value: newValue, stashedValue: null }, () => {\n log('value now: ', this.state.value.document.toJSON());\n resolve();\n });\n }, 50);\n });\n } else {\n return Promise.resolve({});\n }\n };\n\n onChange = (change, done) => {\n log('[onChange]');\n this.setState({ value: change.value }, () => {\n log('[onChange], call done()');\n\n if (done) {\n done();\n }\n });\n };\n\n UNSAFE_componentWillReceiveProps(props) {\n if (!props.value.document.equals(this.props.value.document)) {\n this.setState({\n focus: false,\n value: props.value\n });\n }\n }\n\n valueToSize = v => {\n if (!v) {\n return;\n }\n\n if (typeof v === 'string') {\n if (v.endsWith('%')) {\n return undefined;\n } else if (v.endsWith('px') || v.endsWith('vh') || v.endsWith('vw')) {\n return v;\n } else {\n const value = parseInt(v, 10);\n return isNaN(value) ? value : `${value}px`;\n }\n }\n if (typeof v === 'number') {\n return `${v}px`;\n }\n\n return;\n };\n\n buildSizeStyle() {\n const { width, minHeight, height, maxHeight } = this.props;\n\n return {\n width: this.valueToSize(width),\n height: this.valueToSize(height),\n minHeight: this.valueToSize(minHeight),\n maxHeight: this.valueToSize(maxHeight)\n };\n }\n\n validateNode = node => {\n if (node.object !== 'block') return;\n\n const last = node.nodes.last();\n if (!last) return;\n\n if (last.type !== 'image') return;\n\n log('[validateNode] last is image..');\n\n const parent = last.getParent(last.key);\n const p = Block.getParent(last.key);\n log('[validateNode] parent:', parent, p);\n\n return undefined;\n };\n\n changeData = (key, data) => {\n log('[changeData]. .. ', key, data);\n\n /**\n * HACK ALERT: We should be calling setState here and storing the change data:\n *\n * <code>this.setState({changeData: { key, data}})</code>\n * However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no\n * more changes get through. The issues seem to be related to the promises in onBlur/onFocus. But removing these\n * brings it's own problems. A major clean up is planned for this component so I've decided to temporarily settle\n * on this hack rather than spend more time on this.\n */\n\n // Uncomment this line to see the bug described above.\n // this.setState({changeData: {key, data}})\n\n this.__TEMPORARY_CHANGE_DATA = { key, data };\n };\n\n focus = (pos, node) => {\n const position = pos || 'end';\n\n this.props.focus(position, node);\n };\n\n render() {\n const {\n disabled,\n highlightShape,\n classes,\n className,\n placeholder,\n pluginProps,\n onKeyDown\n } = this.props;\n const { value, focusedNode, toolbarOpts } = this.state;\n\n log('[render] value: ', value);\n const sizeStyle = this.buildSizeStyle();\n const names = classNames(\n {\n [classes.withBg]: highlightShape,\n [classes.toolbarOnTop]: toolbarOpts.alwaysVisible && toolbarOpts.position === 'top'\n },\n className\n );\n\n return (\n <div\n ref={ref => (this.wrapperRef = ref)}\n style={{ width: sizeStyle.width }}\n className={names}\n >\n <SlateEditor\n plugins={this.plugins}\n innerRef={r => {\n if (r) {\n this.slateEditor = r;\n }\n }}\n ref={r => (this.editor = r && this.props.editorRef(r))}\n toolbarRef={r => {\n if (r) {\n this.toolbarRef = r;\n }\n }}\n value={value}\n focus={this.focus}\n onKeyDown={onKeyDown}\n onChange={this.onChange}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n onEditingDone={this.onEditingDone}\n focusedNode={focusedNode}\n normalize={this.normalize}\n readOnly={disabled}\n className={classes.slateEditor}\n style={{\n minHeight: sizeStyle.minHeight,\n height: sizeStyle.height,\n maxHeight: sizeStyle.maxHeight\n }}\n pluginProps={pluginProps}\n toolbarOpts={toolbarOpts}\n placeholder={placeholder}\n onDataChange={this.changeData}\n />\n </div>\n );\n }\n}\n\n// TODO color - hardcoded gray background and keypad colors will need to change too\nconst styles = {\n withBg: {\n backgroundColor: 'rgba(0,0,0,0.06)'\n },\n slateEditor: {\n fontFamily: 'Roboto, sans-serif',\n\n '& table': {\n tableLayout: 'fixed',\n width: '100%',\n borderCollapse: 'collapse',\n color: color.text(),\n backgroundColor: color.background()\n },\n '& table:not([border=\"1\"]) tr': {\n borderTop: '1px solid #dfe2e5'\n // TODO perhaps secondary color for background, for now disable\n // '&:nth-child(2n)': {\n // backgroundColor: '#f6f8fa'\n // }\n },\n '& td, th': {\n padding: '.6em 1em',\n textAlign: 'center'\n },\n '& table:not([border=\"1\"]) td, th': {\n border: '1px solid #dfe2e5'\n }\n },\n toolbarOnTop: {\n marginTop: '45px'\n }\n};\n\nexport default withStyles(styles)(Editor);\n"],"file":"editor.js"}