From f7fe5aec93a96b6c3a0e7cbc22dbc3be66c56ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E8=BF=90=E5=A4=A9?= Date: Fri, 23 Feb 2024 17:02:37 +0800 Subject: [PATCH] fix: console error when pressing delete key in the paragraph before a database (#6285) --- .../components/rich-text/rich-text-operations.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/blocks/src/_common/components/rich-text/rich-text-operations.ts b/packages/blocks/src/_common/components/rich-text/rich-text-operations.ts index 7f006b7a1968..875691546f08 100644 --- a/packages/blocks/src/_common/components/rich-text/rich-text-operations.ts +++ b/packages/blocks/src/_common/components/rich-text/rich-text-operations.ts @@ -23,6 +23,7 @@ import { focusTitle, } from '../../../_common/utils/selection.js'; import type { ListBlockModel } from '../../../list-block/index.js'; +import type { Flavour } from '../../../models.js'; import type { PageBlockModel } from '../../../page-block/index.js'; import type { ExtendedModel } from '../../types.js'; @@ -861,6 +862,20 @@ function handleParagraphBlockForwardDelete( // TODO return false; } else { + const ignoreForwardDeleteFlavourList: Flavour[] = [ + 'affine:database', + 'affine:image', + 'affine:code', + 'affine:attachment', + ]; + + if ( + nextSibling && + matchFlavours(nextSibling, ignoreForwardDeleteFlavourList) + ) { + return true; + } + return ( handleParagraphOrList(page, model, nextSibling, firstChild) || handleEmbedDividerCode(nextSibling, firstChild)