Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/super-editor/src/core/helpers/createDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
* @param editor Editor
* @returns Document.
*/
export function createDocument(converter, schema, editor) {

export function createDocument(converter, schema, editor, { check = false } = {}) {
const documentData = converter.getSchema(editor);

if (documentData) {
return schema.nodeFromJSON(documentData);
const documentNode = schema.nodeFromJSON(documentData);

// for testing
if (check) {
documentNode.check();
}

return documentNode;
}

return schema.topNodeType.createAndFill();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SuperConverter {
{ name: 'w:spacing', type: 'lineHeight', mark: 'textStyle', property: 'lineHeight' },
{ name: 'link', type: 'link', mark: 'link', property: 'href' },
{ name: 'w:highlight', type: 'highlight', mark: 'highlight', property: 'color' },
{ name: 'w:shd', type: 'highlight', mark: 'highlight', property: 'color'}
// { name: 'w:shd', type: 'highlight', mark: 'highlight', property: 'color'}
Comment thread
harbournick marked this conversation as resolved.
];

static propertyTypes = Object.freeze({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const handleAnnotationNode = (params) => {
fieldColor,
multipleImage: isMultipleImage === 'true',
};

if (!attrs.fieldId || !attrs.displayLabel) {
Comment thread
harbournick marked this conversation as resolved.
return { nodes: [], consumed: 0 };
}

let result = {
type: 'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function handleListNodes(
// Spacers in the XML and need to be appended to the last item.
if (item.elements && !hasTextNode(item.elements)) {
const n = handleStandardNode({ ...params, nodes: [item] }).nodes[0];
parsedListItems[parsedListItems.length - 1]?.content.push(n);
if (n) parsedListItems[parsedListItems.length - 1]?.content.push(n);
Comment thread
harbournick marked this conversation as resolved.
item.seen = true;
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const handleStandardNode = (params) => {
const node = nodes[0];
const { name } = node;
const { attributes, elements, marks = [] } = parseProperties(node, docx);

if (name === 'w:sdt') {
Comment thread
harbournick marked this conversation as resolved.
return { nodes: [], consumed: 0 };
}

// Formatting only nodes
if (isPropertiesElement(node)) {
Expand Down