diff --git a/packages/blocks/src/_common/adapters/html.ts b/packages/blocks/src/_common/adapters/html.ts index d2296d3ea715..b74a0ca03fbe 100644 --- a/packages/blocks/src/_common/adapters/html.ts +++ b/packages/blocks/src/_common/adapters/html.ts @@ -1021,10 +1021,11 @@ export class HtmlAdapter extends BaseAdapter { } case 'p': { if ( - o.parent!.type === 'element' && - o.parent!.children.length > o.index! + 1 + o.parent && + o.parent.type === 'element' && + o.parent.children.length > o.index! + 1 ) { - const next = o.parent!.children[o.index! + 1]; + const next = o.parent.children[o.index! + 1]; if ( next.type === 'element' && next.tagName === 'div' && diff --git a/packages/blocks/src/_common/adapters/markdown.ts b/packages/blocks/src/_common/adapters/markdown.ts index 8c831792941a..0e1325fb1e05 100644 --- a/packages/blocks/src/_common/adapters/markdown.ts +++ b/packages/blocks/src/_common/adapters/markdown.ts @@ -651,7 +651,7 @@ export class MarkdownAdapter extends BaseAdapter { : undefined) ) { context.closeNode(); - const nextONode = o.parent!.children[o.index! + 1]; + const nextONode = o.parent?.children[o.index! + 1]; if ( !nextONode || (nextONode && nextONode.flavour !== 'affine:list') diff --git a/packages/blocks/src/_common/adapters/notion-html.ts b/packages/blocks/src/_common/adapters/notion-html.ts index 973709a36d82..e77e5a09c411 100644 --- a/packages/blocks/src/_common/adapters/notion-html.ts +++ b/packages/blocks/src/_common/adapters/notion-html.ts @@ -821,10 +821,11 @@ export class NotionHtmlAdapter extends BaseAdapter { break; } if ( - o.parent!.type === 'element' && - o.parent!.children.length > o.index! + 1 + o.parent && + o.parent.type === 'element' && + o.parent.children.length > o.index! + 1 ) { - const next = o.parent!.children[o.index! + 1]; + const next = o.parent.children[o.index! + 1]; if ( next.type === 'element' && next.tagName === 'div' &&