@pie-lib/editable-html 9.5.13 → 10.0.0-beta.1
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 +0 -302
- package/lib/components.js +116 -0
- package/lib/components.js.map +1 -0
- package/lib/editor.js +418 -103
- package/lib/editor.js.map +1 -1
- package/lib/index.js +101 -155
- package/lib/index.js.map +1 -1
- package/lib/new-serialization.js +320 -0
- package/lib/new-serialization.js.map +1 -0
- package/lib/old-serialization.js +330 -0
- package/lib/parse-html.js +1 -1
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +1 -1
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +21 -19
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +1 -1
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/hotKeys/index.js +67 -0
- package/lib/plugins/hotKeys/index.js.map +1 -0
- package/lib/plugins/image/alt-dialog.js +1 -6
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +70 -53
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +7 -9
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +83 -27
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +72 -33
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +23 -41
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +64 -100
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +86 -60
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +202 -132
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +17 -16
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +3 -3
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +21 -58
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +3 -3
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +3 -2
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -2
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +13 -15
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +87 -53
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +4 -3
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +17 -20
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +1 -1
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +381 -212
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +5 -6
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +55 -11
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +1 -1
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +186 -232
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +1 -2
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +253 -239
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +27 -2
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +1 -1
- package/lib/serialization.js.map +1 -1
- package/lib/slate-editor.js +302 -0
- package/lib/test-serializer.js +189 -0
- package/lib/test-serializer.js.map +1 -0
- package/lib/theme.js +1 -1
- package/lib/theme.js.map +1 -1
- package/package.json +18 -14
- package/playground/image/data.js +20 -20
- package/playground/image/index.html +22 -20
- package/playground/image/index.jsx +12 -10
- package/playground/index.html +25 -23
- package/playground/mathquill/index.html +23 -20
- package/playground/mathquill/index.jsx +18 -22
- package/playground/prod-test/index.html +24 -20
- package/playground/prod-test/index.jsx +5 -3
- package/playground/schema-override/data.js +10 -10
- package/playground/schema-override/image-plugin.jsx +3 -4
- package/playground/schema-override/index.html +21 -19
- package/playground/schema-override/index.jsx +13 -14
- package/playground/serialization/data.js +10 -10
- package/playground/serialization/image-plugin.jsx +3 -4
- package/playground/serialization/index.html +22 -20
- package/playground/table-examples.html +5 -8
- package/playground/webpack.config.js +10 -10
- package/src/components.js +135 -0
- package/src/editor.jsx +478 -141
- package/src/index.jsx +71 -95
- package/src/new-serialization.jsx +291 -0
- package/src/parse-html.js +1 -1
- package/src/plugins/characters/custom-popper.js +7 -7
- package/src/plugins/characters/index.jsx +33 -34
- package/src/plugins/characters/utils.js +81 -81
- package/src/plugins/hotKeys/index.js +54 -0
- package/src/plugins/image/alt-dialog.jsx +4 -5
- package/src/plugins/image/component.jsx +106 -89
- package/src/plugins/image/image-toolbar.jsx +27 -19
- package/src/plugins/image/index.jsx +75 -43
- package/src/plugins/image/insert-image-handler.js +62 -27
- package/src/plugins/index.jsx +23 -41
- package/src/plugins/list/index.jsx +70 -95
- package/src/plugins/math/index.jsx +102 -82
- package/src/plugins/media/index.jsx +159 -124
- package/src/plugins/media/media-dialog.js +98 -71
- package/src/plugins/media/media-toolbar.jsx +8 -8
- package/src/plugins/media/media-wrapper.jsx +29 -30
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +21 -19
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +14 -11
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +7 -6
- package/src/plugins/respArea/icons/index.jsx +11 -14
- package/src/plugins/respArea/index.jsx +92 -52
- package/src/plugins/respArea/inline-dropdown/index.jsx +9 -8
- package/src/plugins/respArea/utils.jsx +26 -35
- package/src/plugins/table/icons/index.jsx +17 -11
- package/src/plugins/table/index.jsx +288 -231
- package/src/plugins/table/table-toolbar.jsx +15 -11
- package/src/plugins/toolbar/default-toolbar.jsx +65 -19
- package/src/plugins/toolbar/done-button.jsx +4 -4
- package/src/plugins/toolbar/editor-and-toolbar.jsx +150 -145
- package/src/plugins/toolbar/index.jsx +2 -3
- package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
- package/src/plugins/toolbar/toolbar.jsx +244 -221
- package/src/plugins/utils.js +21 -4
- package/src/serialization.jsx +32 -32
- package/src/test-serializer.js +139 -0
- package/src/test-serializer.js.rej +20 -0
package/src/serialization.jsx
CHANGED
|
@@ -30,7 +30,7 @@ export const BLOCK_TAGS = {
|
|
|
30
30
|
h3: 'heading-three',
|
|
31
31
|
h4: 'heading-four',
|
|
32
32
|
h5: 'heading-five',
|
|
33
|
-
h6: 'heading-six'
|
|
33
|
+
h6: 'heading-six'
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -45,10 +45,10 @@ const MARK_TAGS = {
|
|
|
45
45
|
u: 'underline',
|
|
46
46
|
s: 'strikethrough',
|
|
47
47
|
code: 'code',
|
|
48
|
-
strong: 'bold'
|
|
48
|
+
strong: 'bold'
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export const parseStyleString =
|
|
51
|
+
export const parseStyleString = s => {
|
|
52
52
|
const regex = /([\w-]*)\s*:\s*([^;]*)/g;
|
|
53
53
|
let match;
|
|
54
54
|
const result = {};
|
|
@@ -58,18 +58,18 @@ export const parseStyleString = (s) => {
|
|
|
58
58
|
return result;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
export const getBase64 =
|
|
61
|
+
export const getBase64 = file => {
|
|
62
62
|
return new Promise((resolve, reject) => {
|
|
63
63
|
const reader = new FileReader();
|
|
64
64
|
reader.readAsDataURL(file);
|
|
65
65
|
reader.onload = () => resolve(reader.result);
|
|
66
|
-
reader.onerror =
|
|
66
|
+
reader.onerror = error => reject(error);
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export const reactAttributes =
|
|
70
|
+
export const reactAttributes = o => toStyleObject(o, { camelize: true, addUnits: false });
|
|
71
71
|
|
|
72
|
-
const attributesToMap =
|
|
72
|
+
const attributesToMap = el => (acc, attribute) => {
|
|
73
73
|
const value = el.getAttribute(attribute);
|
|
74
74
|
if (value) {
|
|
75
75
|
if (attribute === 'style') {
|
|
@@ -113,7 +113,7 @@ const blocks = {
|
|
|
113
113
|
* Here for rendering styles for all block elements
|
|
114
114
|
*/
|
|
115
115
|
data: { attributes: attributes.reduce(attributesToMap(el), {}) },
|
|
116
|
-
nodes: next(el.childNodes)
|
|
116
|
+
nodes: next(el.childNodes)
|
|
117
117
|
};
|
|
118
118
|
},
|
|
119
119
|
serialize: (object, children) => {
|
|
@@ -131,7 +131,7 @@ const blocks = {
|
|
|
131
131
|
return <Tag {...jsonData.attributes}>{children}</Tag>;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
}
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
const marks = {
|
|
@@ -142,7 +142,7 @@ const marks = {
|
|
|
142
142
|
return {
|
|
143
143
|
object: 'mark',
|
|
144
144
|
type: mark,
|
|
145
|
-
nodes: next(el.childNodes)
|
|
145
|
+
nodes: next(el.childNodes)
|
|
146
146
|
};
|
|
147
147
|
},
|
|
148
148
|
serialize(object, children) {
|
|
@@ -154,10 +154,10 @@ const marks = {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
}
|
|
157
|
+
}
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
const findPreviousText =
|
|
160
|
+
const findPreviousText = el => {
|
|
161
161
|
if (el.nodeName === '#text') {
|
|
162
162
|
return el;
|
|
163
163
|
}
|
|
@@ -182,9 +182,9 @@ export const TEXT_RULE = {
|
|
|
182
182
|
leaves: [
|
|
183
183
|
{
|
|
184
184
|
object: 'leaf',
|
|
185
|
-
text: '\n'
|
|
186
|
-
}
|
|
187
|
-
]
|
|
185
|
+
text: '\n'
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -197,9 +197,9 @@ export const TEXT_RULE = {
|
|
|
197
197
|
leaves: [
|
|
198
198
|
{
|
|
199
199
|
object: 'leaf',
|
|
200
|
-
text: el.nodeValue
|
|
201
|
-
}
|
|
202
|
-
]
|
|
200
|
+
text: el.nodeValue
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
},
|
|
@@ -212,7 +212,7 @@ export const TEXT_RULE = {
|
|
|
212
212
|
return array;
|
|
213
213
|
}, []);
|
|
214
214
|
}
|
|
215
|
-
}
|
|
215
|
+
}
|
|
216
216
|
};
|
|
217
217
|
|
|
218
218
|
const RULES = [
|
|
@@ -224,7 +224,7 @@ const RULES = [
|
|
|
224
224
|
responseAreaSerialization,
|
|
225
225
|
TEXT_RULE,
|
|
226
226
|
blocks,
|
|
227
|
-
marks
|
|
227
|
+
marks
|
|
228
228
|
];
|
|
229
229
|
|
|
230
230
|
function allWhitespace(node) {
|
|
@@ -235,7 +235,7 @@ function allWhitespace(node) {
|
|
|
235
235
|
function defaultParseHtml(html) {
|
|
236
236
|
if (typeof DOMParser === 'undefined') {
|
|
237
237
|
throw new Error(
|
|
238
|
-
'The native `DOMParser` global which the `Html` serializer uses by default is not present in this environment. You must supply the `options.parseHtml` function instead.'
|
|
238
|
+
'The native `DOMParser` global which the `Html` serializer uses by default is not present in this environment. You must supply the `options.parseHtml` function instead.'
|
|
239
239
|
);
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -259,14 +259,14 @@ function defaultParseHtml(html) {
|
|
|
259
259
|
const parseHtml =
|
|
260
260
|
typeof window === 'undefined'
|
|
261
261
|
? () => ({
|
|
262
|
-
childNodes: []
|
|
262
|
+
childNodes: []
|
|
263
263
|
})
|
|
264
264
|
: defaultParseHtml;
|
|
265
265
|
|
|
266
266
|
const serializer = new Html({
|
|
267
267
|
defaultBlock: 'div',
|
|
268
268
|
rules: RULES,
|
|
269
|
-
parseHtml
|
|
269
|
+
parseHtml
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
const _extends =
|
|
@@ -320,7 +320,7 @@ serializer.deserialize = function deserialize(html) {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
const block = _extends({ object: 'block', data: {}, isVoid: false }, defaultBlock, {
|
|
323
|
-
nodes: [node]
|
|
323
|
+
nodes: [node]
|
|
324
324
|
});
|
|
325
325
|
|
|
326
326
|
memo.push(block);
|
|
@@ -330,8 +330,8 @@ serializer.deserialize = function deserialize(html) {
|
|
|
330
330
|
if (nodes.length === 0) {
|
|
331
331
|
nodes = [
|
|
332
332
|
_extends({ object: 'block', data: {}, isVoid: false }, defaultBlock, {
|
|
333
|
-
nodes: [{ object: 'text', leaves: [{ object: 'leaf', text: '', marks: [] }] }]
|
|
334
|
-
})
|
|
333
|
+
nodes: [{ object: 'text', leaves: [{ object: 'leaf', text: '', marks: [] }] }]
|
|
334
|
+
})
|
|
335
335
|
];
|
|
336
336
|
}
|
|
337
337
|
|
|
@@ -340,11 +340,11 @@ serializer.deserialize = function deserialize(html) {
|
|
|
340
340
|
document: {
|
|
341
341
|
object: 'document',
|
|
342
342
|
data: {},
|
|
343
|
-
nodes: nodes
|
|
343
|
+
nodes: nodes
|
|
344
344
|
},
|
|
345
345
|
schema: {
|
|
346
|
-
rules: []
|
|
347
|
-
}
|
|
346
|
+
rules: []
|
|
347
|
+
}
|
|
348
348
|
};
|
|
349
349
|
|
|
350
350
|
let i;
|
|
@@ -352,7 +352,7 @@ serializer.deserialize = function deserialize(html) {
|
|
|
352
352
|
for (i = 0; i < 3000; i++) {
|
|
353
353
|
json.schema.rules.push({
|
|
354
354
|
match: { object: 'document' },
|
|
355
|
-
nodes: [{ match: { object: 'block' } }]
|
|
355
|
+
nodes: [{ match: { object: 'block' } }]
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
|
|
@@ -365,7 +365,7 @@ serializer.deserialize = function deserialize(html) {
|
|
|
365
365
|
return null;
|
|
366
366
|
};
|
|
367
367
|
|
|
368
|
-
export const htmlToValue =
|
|
368
|
+
export const htmlToValue = html => {
|
|
369
369
|
try {
|
|
370
370
|
return serializer.deserialize(html);
|
|
371
371
|
} catch (e) {
|
|
@@ -374,7 +374,7 @@ export const htmlToValue = (html) => {
|
|
|
374
374
|
}
|
|
375
375
|
};
|
|
376
376
|
|
|
377
|
-
export const valueToHtml =
|
|
377
|
+
export const valueToHtml = value => serializer.serialize(value);
|
|
378
378
|
|
|
379
379
|
/**
|
|
380
380
|
*
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactServer from 'react-dom/server';
|
|
3
|
+
import escapeHtml from 'escape-html';
|
|
4
|
+
import { Text } from 'slate';
|
|
5
|
+
import { jsx } from 'slate-hyperscript';
|
|
6
|
+
|
|
7
|
+
class Html {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
this.defaultBlock = props.defaultBlock;
|
|
10
|
+
this.parseHtml = props.parseHtml;
|
|
11
|
+
this.rules = props.rules;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
serializeEls = node => {
|
|
15
|
+
if (Text.isText(node)) {
|
|
16
|
+
let string = escapeHtml(node.text);
|
|
17
|
+
if (node.bold) {
|
|
18
|
+
string = <strong>{string}</strong>;
|
|
19
|
+
}
|
|
20
|
+
return string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let children = (node.children || []).map(n => this.serializeEls(n));
|
|
24
|
+
|
|
25
|
+
const correctRule = this.rules.reduce((res, rule) => {
|
|
26
|
+
return res || rule.serialize(node, children);
|
|
27
|
+
}, null);
|
|
28
|
+
|
|
29
|
+
if (correctRule) {
|
|
30
|
+
return correctRule;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
switch (node.type) {
|
|
34
|
+
case 'quote':
|
|
35
|
+
return (
|
|
36
|
+
<blockquote>
|
|
37
|
+
<p>{children}</p>
|
|
38
|
+
</blockquote>
|
|
39
|
+
);
|
|
40
|
+
case 'paragraph':
|
|
41
|
+
return <p>{children}</p>;
|
|
42
|
+
case 'link':
|
|
43
|
+
return <a href={escapeHtml(node.url)}>{children}</a>;
|
|
44
|
+
default:
|
|
45
|
+
return children;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
serialize = node => {
|
|
50
|
+
const deserialized = this.serializeEls(node);
|
|
51
|
+
const html = ReactServer.renderToStaticMarkup(React.createElement(
|
|
52
|
+
'body',
|
|
53
|
+
null,
|
|
54
|
+
deserialized
|
|
55
|
+
));
|
|
56
|
+
const inner = html.slice(6, -7);
|
|
57
|
+
return inner;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
deserialize = html => {
|
|
61
|
+
let body = this.parseHtml(html);
|
|
62
|
+
|
|
63
|
+
if (!body.firstChild || body.firstChild.nodeType === Node.TEXT_NODE) {
|
|
64
|
+
body = this.parseHtml(`<p>${html}</p>`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this.deserializeEls(body);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
deserializeEls = (element, markAttributes = {}) => {
|
|
71
|
+
if (element.nodeType === Node.TEXT_NODE) {
|
|
72
|
+
return jsx('text', markAttributes, element.textContent);
|
|
73
|
+
} else if (element.nodeType !== Node.ELEMENT_NODE) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const nodeAttributes = { ...markAttributes };
|
|
78
|
+
|
|
79
|
+
// define attributes for text nodes
|
|
80
|
+
if (element.nodeName === 'STRONG') {
|
|
81
|
+
nodeAttributes.bold = true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const nextFn = nodes => {
|
|
85
|
+
const childNodes = Array.from(nodes);
|
|
86
|
+
const children = Array.from(childNodes)
|
|
87
|
+
.map(node => this.deserializeEls(node, nodeAttributes))
|
|
88
|
+
.flat();
|
|
89
|
+
|
|
90
|
+
if (children.length === 0) {
|
|
91
|
+
children.push(jsx('text', nodeAttributes, ''));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return children;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const correctRule = this.rules.reduce((res, rule) => {
|
|
98
|
+
return res || rule.deserialize(element, nextFn);
|
|
99
|
+
}, null);
|
|
100
|
+
|
|
101
|
+
if (correctRule) {
|
|
102
|
+
return correctRule;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const childNodes = Array.from(element.childNodes);
|
|
106
|
+
const children = Array.from(childNodes)
|
|
107
|
+
.map(node => this.deserializeEls(node, nodeAttributes))
|
|
108
|
+
.flat();
|
|
109
|
+
|
|
110
|
+
if (children.length === 0) {
|
|
111
|
+
children.push(jsx('text', nodeAttributes, ''));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
switch (element.nodeName) {
|
|
115
|
+
case 'TABLE':
|
|
116
|
+
return jsx('element', { type: 'table' }, children);
|
|
117
|
+
case 'TBODY':
|
|
118
|
+
return jsx('element', { type: 'tbody' }, children);
|
|
119
|
+
case 'TR':
|
|
120
|
+
return jsx('element', { type: 'tr' }, children);
|
|
121
|
+
case 'TD':
|
|
122
|
+
return jsx('element', { type: 'td' }, children);
|
|
123
|
+
case 'BODY':
|
|
124
|
+
return jsx('fragment', {}, children);
|
|
125
|
+
case 'BR':
|
|
126
|
+
return '\n';
|
|
127
|
+
case 'BLOCKQUOTE':
|
|
128
|
+
return jsx('element', { type: 'quote' }, children);
|
|
129
|
+
case 'P':
|
|
130
|
+
return jsx('element', { type: 'paragraph' }, children);
|
|
131
|
+
case 'A':
|
|
132
|
+
return jsx('element', { type: 'link', url: element.getAttribute('href') }, children);
|
|
133
|
+
default:
|
|
134
|
+
return children;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export default Html;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
diff a/packages/editable-html/src/test-serializer.js b/packages/editable-html/src/test-serializer.js (rejected hunks)
|
|
2
|
+
@@ -4 +4 @@ import { jsx } from 'slate-hyperscript';
|
|
3
|
+
-import { unWrapMath } from "@pie-lib/math-rendering";
|
|
4
|
+
+import { unWrapMath } from '@pie-lib/math-rendering';
|
|
5
|
+
@@ -82,4 +82,11 @@ class Html {
|
|
6
|
+
- return jsx('element', { type: 'math', data: {
|
|
7
|
+
- latex: unwrapped,
|
|
8
|
+
- wrapper: wrapType
|
|
9
|
+
- } }, children);
|
|
10
|
+
+ return jsx(
|
|
11
|
+
+ 'element',
|
|
12
|
+
+ {
|
|
13
|
+
+ type: 'math',
|
|
14
|
+
+ data: {
|
|
15
|
+
+ latex: unwrapped,
|
|
16
|
+
+ wrapper: wrapType
|
|
17
|
+
+ }
|
|
18
|
+
+ },
|
|
19
|
+
+ children
|
|
20
|
+
+ );
|