Skip to content

Commit

Permalink
improve prevent deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
lamtuanamc committed Nov 27, 2024
1 parent 8ebf69a commit 7971c85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ export const mergeBlocksCommand =
prevBlockInfo
);

const prevBlockIsImage = prevBlockInfo.blockNoteType === "image";
const isPrevFileBlock =
prevBlockInfo.blockNoteType === "image" ||
prevBlockInfo.blockNoteType === "file" ||
prevBlockInfo.blockNoteType === "audio";

if (!canMerge(bottomNestedBlockInfo, nextBlockInfo) && !prevBlockIsImage) {
if (!canMerge(bottomNestedBlockInfo, nextBlockInfo) && !isPrevFileBlock) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,12 @@ export const KeyboardShortcutsExtension = Extension.create<{
"inline*" &&
bottomBlock.blockContent.node.childCount === 0);

const isImageBlock = bottomBlock.blockNoteType === "image";
const isFileBlock =
bottomBlock.blockNoteType === "image" ||
bottomBlock.blockNoteType === "file" ||
bottomBlock.blockNoteType === "audio";

if (prevBlockNotTableAndNoContent && !isImageBlock) {
if (prevBlockNotTableAndNoContent && !isFileBlock) {
return chain()
.cut(
{
Expand Down

0 comments on commit 7971c85

Please sign in to comment.