@pie-lib/editable-html 9.2.6-next.4 → 9.2.7
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 +16 -0
- package/lib/editor.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +1 -1
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js.map +1 -1
- package/package.json +6 -6
- package/playground/image/data.js +20 -20
- package/playground/image/index.html +20 -22
- package/playground/image/index.jsx +7 -12
- package/playground/index.html +23 -25
- package/playground/mathquill/index.html +20 -23
- package/playground/mathquill/index.jsx +7 -18
- package/playground/prod-test/index.html +20 -24
- package/playground/prod-test/index.jsx +2 -5
- package/playground/schema-override/data.js +10 -10
- package/playground/schema-override/image-plugin.jsx +3 -3
- package/playground/schema-override/index.html +19 -21
- package/playground/schema-override/index.jsx +12 -12
- package/playground/serialization/data.js +10 -10
- package/playground/serialization/image-plugin.jsx +3 -3
- package/playground/serialization/index.html +20 -22
- package/playground/table-examples.html +8 -5
- package/playground/webpack.config.js +10 -10
- package/src/editor.jsx +77 -101
- package/src/index.jsx +11 -18
- package/src/parse-html.js +1 -1
- package/src/plugins/characters/custom-popper.js +7 -7
- package/src/plugins/characters/index.jsx +19 -25
- package/src/plugins/characters/utils.js +81 -81
- package/src/plugins/image/alt-dialog.jsx +3 -3
- package/src/plugins/image/component.jsx +42 -46
- package/src/plugins/image/image-toolbar.jsx +14 -26
- package/src/plugins/image/index.jsx +21 -23
- package/src/plugins/index.jsx +10 -12
- package/src/plugins/list/index.jsx +10 -10
- package/src/plugins/math/index.jsx +28 -31
- package/src/plugins/media/index.jsx +21 -21
- package/src/plugins/media/media-dialog.js +60 -86
- package/src/plugins/media/media-toolbar.jsx +6 -6
- package/src/plugins/media/media-wrapper.jsx +6 -6
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +19 -21
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +10 -12
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +5 -5
- package/src/plugins/respArea/icons/index.jsx +8 -8
- package/src/plugins/respArea/index.jsx +21 -31
- package/src/plugins/respArea/inline-dropdown/index.jsx +6 -6
- package/src/plugins/respArea/utils.jsx +12 -12
- package/src/plugins/table/icons/index.jsx +11 -17
- package/src/plugins/table/index.jsx +43 -49
- package/src/plugins/table/table-toolbar.jsx +8 -13
- package/src/plugins/toolbar/default-toolbar.jsx +11 -19
- package/src/plugins/toolbar/done-button.jsx +4 -4
- package/src/plugins/toolbar/editor-and-toolbar.jsx +39 -47
- package/src/plugins/toolbar/index.jsx +2 -2
- package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
- package/src/plugins/toolbar/toolbar.jsx +34 -47
- package/src/plugins/utils.js +4 -5
- package/src/serialization.jsx +32 -32
|
@@ -13,25 +13,25 @@ const log = debug('@pie-lib:editable-html:plugins:math');
|
|
|
13
13
|
const TEXT_NODE = 3;
|
|
14
14
|
|
|
15
15
|
function generateAdditionalKeys(keyData = []) {
|
|
16
|
-
return keyData.map(key => ({
|
|
16
|
+
return keyData.map((key) => ({
|
|
17
17
|
name: key,
|
|
18
18
|
latex: key,
|
|
19
19
|
write: key,
|
|
20
|
-
label: key
|
|
20
|
+
label: key,
|
|
21
21
|
}));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const CustomToolbarComp = React.memo(
|
|
25
|
-
props => {
|
|
25
|
+
(props) => {
|
|
26
26
|
const { node, value, onFocus, onBlur, onClick } = props;
|
|
27
27
|
const { pluginProps } = props || {};
|
|
28
28
|
const { math } = pluginProps || {};
|
|
29
29
|
const { keypadMode, customKeys, controlledKeypadMode = true } = math || {};
|
|
30
30
|
|
|
31
|
-
const onDone = latex => {
|
|
31
|
+
const onDone = (latex) => {
|
|
32
32
|
const update = {
|
|
33
33
|
...node.data.toObject(),
|
|
34
|
-
latex
|
|
34
|
+
latex,
|
|
35
35
|
};
|
|
36
36
|
const change = value.change().setNodeByKey(node.key, { data: update });
|
|
37
37
|
|
|
@@ -42,10 +42,10 @@ export const CustomToolbarComp = React.memo(
|
|
|
42
42
|
props.onToolbarDone(change, false);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const onChange = latex => {
|
|
45
|
+
const onChange = (latex) => {
|
|
46
46
|
const update = {
|
|
47
47
|
...node.data.toObject(),
|
|
48
|
-
latex
|
|
48
|
+
latex,
|
|
49
49
|
};
|
|
50
50
|
const change = value.change().setNodeByKey(node.key, { data: update });
|
|
51
51
|
log('call onToolbarChange:', change);
|
|
@@ -73,16 +73,14 @@ export const CustomToolbarComp = React.memo(
|
|
|
73
73
|
const { node, pluginProps: { math: { keypadMode, controlledKeypadMode } = {} } = {} } = prev;
|
|
74
74
|
const {
|
|
75
75
|
node: nodeNext,
|
|
76
|
-
pluginProps: {
|
|
77
|
-
math: { keypadMode: keypadModeNext, controlledKeypadMode: controlledKeypadModeNext } = {}
|
|
78
|
-
} = {}
|
|
76
|
+
pluginProps: { math: { keypadMode: keypadModeNext, controlledKeypadMode: controlledKeypadModeNext } = {} } = {},
|
|
79
77
|
} = next;
|
|
80
78
|
const keypadModeChanged = keypadMode !== keypadModeNext;
|
|
81
79
|
const controlledKeypadModeChanged = controlledKeypadMode !== controlledKeypadModeNext;
|
|
82
80
|
|
|
83
81
|
const equal = node.equals(nodeNext);
|
|
84
82
|
return equal && !keypadModeChanged && !controlledKeypadModeChanged;
|
|
85
|
-
}
|
|
83
|
+
},
|
|
86
84
|
);
|
|
87
85
|
|
|
88
86
|
CustomToolbarComp.propTypes = {
|
|
@@ -92,7 +90,7 @@ CustomToolbarComp.propTypes = {
|
|
|
92
90
|
onDataChange: PropTypes.func,
|
|
93
91
|
onFocus: PropTypes.func,
|
|
94
92
|
onClick: PropTypes.func,
|
|
95
|
-
onBlur: PropTypes.func
|
|
93
|
+
onBlur: PropTypes.func,
|
|
96
94
|
};
|
|
97
95
|
|
|
98
96
|
export default function MathPlugin() {
|
|
@@ -106,7 +104,7 @@ export default function MathPlugin() {
|
|
|
106
104
|
const change = value.change().insertInline(math);
|
|
107
105
|
onChange(change);
|
|
108
106
|
},
|
|
109
|
-
supports: node => node && node.object === 'inline' && node.type === 'math',
|
|
107
|
+
supports: (node) => node && node.object === 'inline' && node.type === 'math',
|
|
110
108
|
/**
|
|
111
109
|
* Return a react component function
|
|
112
110
|
* @param node {Slate.Node}
|
|
@@ -114,22 +112,22 @@ export default function MathPlugin() {
|
|
|
114
112
|
* @param onDone {(change?: Slate.Change, finishEditing :boolea) => void} - a function to call once the toolbar
|
|
115
113
|
* has made any changes, call with the node.key and a data object.
|
|
116
114
|
*/
|
|
117
|
-
CustomToolbarComp
|
|
115
|
+
CustomToolbarComp,
|
|
118
116
|
},
|
|
119
117
|
schema: {
|
|
120
|
-
document: { match: [{ type: 'math' }] }
|
|
118
|
+
document: { match: [{ type: 'math' }] },
|
|
121
119
|
},
|
|
122
120
|
|
|
123
121
|
pluginStyles: (node, parentNode, p) => {
|
|
124
122
|
if (p) {
|
|
125
123
|
return {
|
|
126
124
|
position: 'absolute',
|
|
127
|
-
top: 'initial'
|
|
125
|
+
top: 'initial',
|
|
128
126
|
};
|
|
129
127
|
}
|
|
130
128
|
},
|
|
131
129
|
|
|
132
|
-
renderNode: props => {
|
|
130
|
+
renderNode: (props) => {
|
|
133
131
|
if (props.node.type === 'math') {
|
|
134
132
|
log('[renderNode]: data:', props.node.data);
|
|
135
133
|
return <MathPreview {...props} />;
|
|
@@ -143,7 +141,7 @@ export default function MathPlugin() {
|
|
|
143
141
|
|
|
144
142
|
return <span {...props.attributes} dangerouslySetInnerHTML={{ __html: html }} />;
|
|
145
143
|
}
|
|
146
|
-
}
|
|
144
|
+
},
|
|
147
145
|
};
|
|
148
146
|
}
|
|
149
147
|
|
|
@@ -158,17 +156,17 @@ export const inlineMath = () =>
|
|
|
158
156
|
type: 'math',
|
|
159
157
|
isVoid: true,
|
|
160
158
|
data: {
|
|
161
|
-
latex: ''
|
|
162
|
-
}
|
|
159
|
+
latex: '',
|
|
160
|
+
},
|
|
163
161
|
});
|
|
164
162
|
|
|
165
|
-
const htmlDecode = input => {
|
|
163
|
+
const htmlDecode = (input) => {
|
|
166
164
|
const doc = new DOMParser().parseFromString(input, 'text/html');
|
|
167
165
|
|
|
168
166
|
return doc.documentElement.textContent;
|
|
169
167
|
};
|
|
170
168
|
|
|
171
|
-
const getTagName = el => {
|
|
169
|
+
const getTagName = (el) => {
|
|
172
170
|
return ((el && el.tagName) || '').toLowerCase();
|
|
173
171
|
};
|
|
174
172
|
|
|
@@ -179,7 +177,7 @@ const getTagName = el => {
|
|
|
179
177
|
* @param input
|
|
180
178
|
* @returns {*}
|
|
181
179
|
*/
|
|
182
|
-
const lessThanHandling = input => {
|
|
180
|
+
const lessThanHandling = (input) => {
|
|
183
181
|
const arrowSplit = input.split('<');
|
|
184
182
|
|
|
185
183
|
// if we don't have at least 2 characters there's no point in checking
|
|
@@ -191,7 +189,7 @@ const lessThanHandling = input => {
|
|
|
191
189
|
/div - closing of a HTML tag
|
|
192
190
|
br/> - beginning and closing of a html TAG
|
|
193
191
|
*/
|
|
194
|
-
if (part.match(/<[a-zA-Z/][\s\S]*>/
|
|
192
|
+
if (part.match(/<[a-zA-Z/][\s\S]*>/gi)) {
|
|
195
193
|
return `${st}${st ? '<' : ''}${part}`;
|
|
196
194
|
}
|
|
197
195
|
|
|
@@ -212,8 +210,7 @@ export const serialization = {
|
|
|
212
210
|
* an inline child and the block is of type block
|
|
213
211
|
* This is for legacy content only since our math rendering is valid for the core slate rules
|
|
214
212
|
*/
|
|
215
|
-
const hasMathChild =
|
|
216
|
-
BLOCK_TAGS[tagName] && el.childNodes.length === 1 && getTagName(el.firstChild) === 'math';
|
|
213
|
+
const hasMathChild = BLOCK_TAGS[tagName] && el.childNodes.length === 1 && getTagName(el.firstChild) === 'math';
|
|
217
214
|
log('[deserialize] name: ', tagName);
|
|
218
215
|
|
|
219
216
|
/**
|
|
@@ -227,8 +224,8 @@ export const serialization = {
|
|
|
227
224
|
isVoid: true,
|
|
228
225
|
type: 'mathml',
|
|
229
226
|
data: {
|
|
230
|
-
html: newHtml
|
|
231
|
-
}
|
|
227
|
+
html: newHtml,
|
|
228
|
+
},
|
|
232
229
|
};
|
|
233
230
|
}
|
|
234
231
|
|
|
@@ -253,8 +250,8 @@ export const serialization = {
|
|
|
253
250
|
nodes: [],
|
|
254
251
|
data: {
|
|
255
252
|
latex: unwrapped,
|
|
256
|
-
wrapper: wrapType
|
|
257
|
-
}
|
|
253
|
+
wrapper: wrapType,
|
|
254
|
+
},
|
|
258
255
|
};
|
|
259
256
|
}
|
|
260
257
|
},
|
|
@@ -279,5 +276,5 @@ export const serialization = {
|
|
|
279
276
|
|
|
280
277
|
return <span data-type="mathml" dangerouslySetInnerHTML={{ __html: html }} />;
|
|
281
278
|
}
|
|
282
|
-
}
|
|
279
|
+
},
|
|
283
280
|
};
|
|
@@ -14,10 +14,10 @@ const log = debug('@pie-lib:editable-html:plugins:image');
|
|
|
14
14
|
const removeDialogs = () => {
|
|
15
15
|
const prevDialogs = document.querySelectorAll('.insert-media-dialog');
|
|
16
16
|
|
|
17
|
-
prevDialogs.forEach(s => s.remove());
|
|
17
|
+
prevDialogs.forEach((s) => s.remove());
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const insertDialog = props => {
|
|
20
|
+
export const insertDialog = (props) => {
|
|
21
21
|
const newEl = document.createElement('div');
|
|
22
22
|
const { type, callback, opts, ...rest } = props;
|
|
23
23
|
const initialBodyOverflow = document.body.style.overflow;
|
|
@@ -67,8 +67,8 @@ export default function MediaPlugin(type, opts) {
|
|
|
67
67
|
starts: undefined,
|
|
68
68
|
src: undefined,
|
|
69
69
|
url: undefined,
|
|
70
|
-
width: undefined
|
|
71
|
-
}
|
|
70
|
+
width: undefined,
|
|
71
|
+
},
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
const change = value.change().insertInline(inline);
|
|
@@ -77,7 +77,7 @@ export default function MediaPlugin(type, opts) {
|
|
|
77
77
|
type,
|
|
78
78
|
opts,
|
|
79
79
|
callback: (val, data) => {
|
|
80
|
-
const nodeIsThere = change.value.document.findDescendant(d => d.key === inline.key);
|
|
80
|
+
const nodeIsThere = change.value.document.findDescendant((d) => d.key === inline.key);
|
|
81
81
|
|
|
82
82
|
if (nodeIsThere) {
|
|
83
83
|
if (!val) {
|
|
@@ -90,10 +90,10 @@ export default function MediaPlugin(type, opts) {
|
|
|
90
90
|
} else {
|
|
91
91
|
opts.focus();
|
|
92
92
|
}
|
|
93
|
-
}
|
|
93
|
+
},
|
|
94
94
|
});
|
|
95
95
|
},
|
|
96
|
-
supports: node => node.object === 'inline' && node.type === type
|
|
96
|
+
supports: (node) => node.object === 'inline' && node.type === type,
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
return {
|
|
@@ -116,8 +116,8 @@ export default function MediaPlugin(type, opts) {
|
|
|
116
116
|
const c = change.setNodeByKey(key, {
|
|
117
117
|
data: {
|
|
118
118
|
...jsonData,
|
|
119
|
-
editing: true
|
|
120
|
-
}
|
|
119
|
+
editing: true,
|
|
120
|
+
},
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
opts.onChange(c, () => {
|
|
@@ -130,7 +130,7 @@ export default function MediaPlugin(type, opts) {
|
|
|
130
130
|
const { key } = node;
|
|
131
131
|
|
|
132
132
|
const nodeIsThere = change.value.document.findDescendant(
|
|
133
|
-
d => d.type === type && d.data.get('editing')
|
|
133
|
+
(d) => d.type === type && d.data.get('editing'),
|
|
134
134
|
);
|
|
135
135
|
|
|
136
136
|
if (nodeIsThere && val) {
|
|
@@ -139,7 +139,7 @@ export default function MediaPlugin(type, opts) {
|
|
|
139
139
|
} else {
|
|
140
140
|
opts.focus();
|
|
141
141
|
}
|
|
142
|
-
}
|
|
142
|
+
},
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
};
|
|
@@ -186,14 +186,14 @@ export default function MediaPlugin(type, opts) {
|
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
188
|
},
|
|
189
|
-
normalizeNode: node => {
|
|
189
|
+
normalizeNode: (node) => {
|
|
190
190
|
const textNodeMap = {};
|
|
191
191
|
const updateNodesArray = [];
|
|
192
192
|
let index = 0;
|
|
193
193
|
|
|
194
194
|
if (node.object !== 'document') return;
|
|
195
195
|
|
|
196
|
-
node.findDescendant(d => {
|
|
196
|
+
node.findDescendant((d) => {
|
|
197
197
|
if (d.object === 'text') {
|
|
198
198
|
textNodeMap[index] = d;
|
|
199
199
|
}
|
|
@@ -211,12 +211,12 @@ export default function MediaPlugin(type, opts) {
|
|
|
211
211
|
|
|
212
212
|
if (!updateNodesArray.length) return;
|
|
213
213
|
|
|
214
|
-
return change => {
|
|
214
|
+
return (change) => {
|
|
215
215
|
change.withoutNormalization(() => {
|
|
216
|
-
updateNodesArray.forEach(n => change.insertTextByKey(n.key, 0, ' '));
|
|
216
|
+
updateNodesArray.forEach((n) => change.insertTextByKey(n.key, 0, ' '));
|
|
217
217
|
});
|
|
218
218
|
};
|
|
219
|
-
}
|
|
219
|
+
},
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -256,8 +256,8 @@ export const serialization = {
|
|
|
256
256
|
starts,
|
|
257
257
|
title,
|
|
258
258
|
width,
|
|
259
|
-
url
|
|
260
|
-
}
|
|
259
|
+
url,
|
|
260
|
+
},
|
|
261
261
|
};
|
|
262
262
|
log('return object: ', out);
|
|
263
263
|
return out;
|
|
@@ -294,11 +294,11 @@ export const serialization = {
|
|
|
294
294
|
'data-ends': ends,
|
|
295
295
|
'data-starts': starts,
|
|
296
296
|
'data-title': title,
|
|
297
|
-
'data-url': url
|
|
297
|
+
'data-url': url,
|
|
298
298
|
};
|
|
299
299
|
const props = {
|
|
300
300
|
...style,
|
|
301
|
-
src
|
|
301
|
+
src,
|
|
302
302
|
};
|
|
303
303
|
|
|
304
304
|
if (tag === 'audio') {
|
|
@@ -320,5 +320,5 @@ export const serialization = {
|
|
|
320
320
|
{...props}
|
|
321
321
|
/>
|
|
322
322
|
);
|
|
323
|
-
}
|
|
323
|
+
},
|
|
324
324
|
};
|