Skip to content

Commit

Permalink
fix(page): do not assert on parent (#6500)
Browse files Browse the repository at this point in the history
  • Loading branch information
fourdim committed Mar 19, 2024
1 parent 5545f41 commit b48b0e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions packages/blocks/src/_common/adapters/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,10 +1021,11 @@ export class HtmlAdapter extends BaseAdapter<Html> {
}
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' &&
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/_common/adapters/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ export class MarkdownAdapter extends BaseAdapter<Markdown> {
: 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')
Expand Down
7 changes: 4 additions & 3 deletions packages/blocks/src/_common/adapters/notion-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,11 @@ export class NotionHtmlAdapter extends BaseAdapter<NotionHtml> {
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' &&
Expand Down

0 comments on commit b48b0e2

Please sign in to comment.