@seafile/sea-email-editor 0.0.8 → 0.0.9
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.
|
@@ -145,7 +145,7 @@ const formatElementNodes = nodes => {
|
|
|
145
145
|
return nodes;
|
|
146
146
|
};
|
|
147
147
|
const deserializeHtml = html => {
|
|
148
|
-
const parsed = new DOMParser().parseFromString(html, 'text/html');
|
|
148
|
+
const parsed = new DOMParser().parseFromString(html.replace('\n\n', '').replace('\n ', ''), 'text/html');
|
|
149
149
|
const fragment = parsed.body;
|
|
150
150
|
const children = Array.from(fragment.childNodes);
|
|
151
151
|
let nodes = [];
|
|
@@ -18,18 +18,22 @@ const listRule = (element, parseChild) => {
|
|
|
18
18
|
parentElement
|
|
19
19
|
} = element;
|
|
20
20
|
if (nodeName === 'UL') {
|
|
21
|
+
let children = parseChild(childNodes);
|
|
22
|
+
children = children.filter(child => child.type === 'list_item');
|
|
21
23
|
const node = {
|
|
22
24
|
id: _slugid.default.nice(),
|
|
23
25
|
type: _constants.UNORDERED_LIST,
|
|
24
|
-
children
|
|
26
|
+
children
|
|
25
27
|
};
|
|
26
28
|
return (0, _helper.mergeElementOther2SlateNode)(element, node);
|
|
27
29
|
}
|
|
28
30
|
if (nodeName === 'OL') {
|
|
31
|
+
let children = parseChild(childNodes);
|
|
32
|
+
children = children.filter(child => child.type === 'list_item');
|
|
29
33
|
const node = {
|
|
30
34
|
id: _slugid.default.nice(),
|
|
31
35
|
type: _constants.ORDERED_LIST,
|
|
32
|
-
children
|
|
36
|
+
children
|
|
33
37
|
};
|
|
34
38
|
return (0, _helper.mergeElementOther2SlateNode)(element, node);
|
|
35
39
|
}
|
|
@@ -14,11 +14,12 @@ const tableRule = (element, parseChild) => {
|
|
|
14
14
|
childNodes
|
|
15
15
|
} = element;
|
|
16
16
|
if (nodeName === 'TABLE') {
|
|
17
|
+
const children = parseChild(childNodes);
|
|
17
18
|
const node = {
|
|
18
19
|
id: _slugid.default.nice(),
|
|
19
20
|
type: _constants.TABLE,
|
|
20
21
|
align: [],
|
|
21
|
-
children:
|
|
22
|
+
children: children.filter(child => child.type === 'table_row')
|
|
22
23
|
};
|
|
23
24
|
return (0, _helper.mergeElementOther2SlateNode)(element, node);
|
|
24
25
|
}
|
|
@@ -30,10 +31,11 @@ const tableRule = (element, parseChild) => {
|
|
|
30
31
|
const children = Array.from(childNodes);
|
|
31
32
|
const hasTdOrTh = children.some(item => item.nodeName === 'TH' || item.nodeName === 'TD');
|
|
32
33
|
if (!hasTdOrTh) return;
|
|
34
|
+
const trChildren = parseChild(childNodes);
|
|
33
35
|
const node = {
|
|
34
36
|
id: _slugid.default.nice(),
|
|
35
37
|
type: _constants.TABLE_ROW,
|
|
36
|
-
children:
|
|
38
|
+
children: trChildren.filter(trChild => trChild.type === 'table_cell')
|
|
37
39
|
};
|
|
38
40
|
return (0, _helper.mergeElementOther2SlateNode)(element, node);
|
|
39
41
|
}
|
|
@@ -41,7 +43,7 @@ const tableRule = (element, parseChild) => {
|
|
|
41
43
|
const children = Array.from(childNodes);
|
|
42
44
|
const cellChildren = children.length > 0 ? children.flatMap(child => {
|
|
43
45
|
// Replace paragraph node with text node
|
|
44
|
-
if (child.nodeName === 'P') {
|
|
46
|
+
if (child.nodeName === 'P' || child.nodeName === 'DIV') {
|
|
45
47
|
const textContent = Array.from(child.childNodes).map(child => child.textContent).join('');
|
|
46
48
|
const node = {
|
|
47
49
|
id: _slugid.default.nice(),
|