Skip to content

Commit 741c337

Browse files
authored
Merge pull request #431 from Harbour-Enterprises/artem-HAR-9246
HAR-9246 - handle import issues
2 parents 9d16178 + baf8007 commit 741c337

5 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/super-editor/src/core/helpers/createDocument.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55
* @param editor Editor
66
* @returns Document.
77
*/
8-
export function createDocument(converter, schema, editor) {
8+
9+
export function createDocument(converter, schema, editor, { check = false } = {}) {
910
const documentData = converter.getSchema(editor);
1011

1112
if (documentData) {
12-
return schema.nodeFromJSON(documentData);
13+
const documentNode = schema.nodeFromJSON(documentData);
14+
15+
// for testing
16+
if (check) {
17+
documentNode.check();
18+
}
19+
20+
return documentNode;
1321
}
1422

1523
return schema.topNodeType.createAndFill();

packages/super-editor/src/core/super-converter/SuperConverter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SuperConverter {
5353
{ name: 'w:spacing', type: 'lineHeight', mark: 'textStyle', property: 'lineHeight' },
5454
{ name: 'link', type: 'link', mark: 'link', property: 'href' },
5555
{ name: 'w:highlight', type: 'highlight', mark: 'highlight', property: 'color' },
56-
{ name: 'w:shd', type: 'highlight', mark: 'highlight', property: 'color'}
56+
// { name: 'w:shd', type: 'highlight', mark: 'highlight', property: 'color'}
5757
];
5858

5959
static propertyTypes = Object.freeze({

packages/super-editor/src/core/super-converter/v2/importer/annotationImporter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export const handleAnnotationNode = (params) => {
3535
fieldColor,
3636
multipleImage: isMultipleImage === 'true',
3737
};
38+
39+
if (!attrs.fieldId || !attrs.displayLabel) {
40+
return { nodes: [], consumed: 0 };
41+
}
3842

3943
let result = {
4044
type: 'text',

packages/super-editor/src/core/super-converter/v2/importer/listImporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function handleListNodes(
110110
// Spacers in the XML and need to be appended to the last item.
111111
if (item.elements && !hasTextNode(item.elements)) {
112112
const n = handleStandardNode({ ...params, nodes: [item] }).nodes[0];
113-
parsedListItems[parsedListItems.length - 1]?.content.push(n);
113+
if (n) parsedListItems[parsedListItems.length - 1]?.content.push(n);
114114
item.seen = true;
115115
continue;
116116
}

packages/super-editor/src/core/super-converter/v2/importer/standardNodeImporter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export const handleStandardNode = (params) => {
1313
const node = nodes[0];
1414
const { name } = node;
1515
const { attributes, elements, marks = [] } = parseProperties(node, docx);
16+
17+
if (name === 'w:sdt') {
18+
return { nodes: [], consumed: 0 };
19+
}
1620

1721
// Formatting only nodes
1822
if (isPropertiesElement(node)) {

0 commit comments

Comments
 (0)