fix(editor): extra line breaks and spaces when parsing table from html (#10190)

close: BS-2562, BS-2569
This commit is contained in:
zzj3720
2025-02-14 12:13:00 +00:00
parent 35aec95022
commit b6f8027e1b
4 changed files with 4 additions and 4 deletions

View File

@@ -41,7 +41,7 @@ export const tableBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = {
}, },
'children' 'children'
); );
walkerContext.skipChildren(); walkerContext.skipAllChildren();
} }
}, },
leave: (o, context) => { leave: (o, context) => {

View File

@@ -35,7 +35,7 @@ export const tableBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher = {
}, },
'children' 'children'
); );
walkerContext.skipChildren(); walkerContext.skipAllChildren();
} }
}, },
leave: (o, context) => { leave: (o, context) => {

View File

@@ -91,7 +91,7 @@ export const processTable = (
}; };
const getTextFromElement = (element: ElementContent): string => { const getTextFromElement = (element: ElementContent): string => {
if (element.type === 'text') { if (element.type === 'text') {
return element.value; return element.value.trim();
} }
if (element.type === 'element') { if (element.type === 'element') {
return element.children.map(child => getTextFromElement(child)).join(''); return element.children.map(child => getTextFromElement(child)).join('');

View File

@@ -39,7 +39,7 @@ export interface TableBlockPropsSerialized {
} }
export class TableBlockModel extends BlockModel<TableBlockProps> {} export class TableBlockModel extends BlockModel<TableBlockProps> {}
export const TableModelFlavour = 'affine:table-test1-flavour'; export const TableModelFlavour = 'affine:table';
export const TableBlockSchema = defineBlockSchema({ export const TableBlockSchema = defineBlockSchema({
flavour: TableModelFlavour, flavour: TableModelFlavour,
props: (): TableBlockProps => ({ props: (): TableBlockProps => ({