Skip to content

Commit

Permalink
fix(YfmTable): revert serialization logic for yfm-table row and cell (#…
Browse files Browse the repository at this point in the history
…380)

For some broken cases, were prosemirror document contains rows with cells without outer table and tbody
  • Loading branch information
d3m1d0v authored Sep 25, 2024
1 parent ec44f7a commit 5d0e931
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/extensions/yfm/YfmTable/YfmTableSpecs/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,27 @@ export const serializerTokens: Record<YfmTableNode, SerializerNodeToken> = {
});
},

[YfmTableNode.Row]: (_state, node) => {
throw new Error(`Should not serialize ${node.type.name} node via serialize-token`);
[YfmTableNode.Row]: (state, node) => {
console.warn(`Should not serialize ${node.type.name} node via serialize-token`);

state.write('||');
state.ensureNewLine();
state.write('\n');
state.renderContent(node);
state.write('||');
state.ensureNewLine();
},

[YfmTableNode.Cell]: (_state, node) => {
throw new Error(`Should not serialize ${node.type.name} node via serialize-token`);
[YfmTableNode.Cell]: (state, node, parent) => {
console.warn(`Should not serialize ${node.type.name} node via serialize-token`);

state.renderContent(node);

const isLastCellInRow = parent.lastChild === node;
if (!isLastCellInRow) {
state.write('|');
state.ensureNewLine();
state.write('\n');
}
},
};

0 comments on commit 5d0e931

Please sign in to comment.