fix: backspace with root id
This commit is contained in:
@@ -2,13 +2,11 @@ import { useState } from 'react';
|
|||||||
|
|
||||||
import { CustomText, TextProps } from '@toeverything/components/common';
|
import { CustomText, TextProps } from '@toeverything/components/common';
|
||||||
import {
|
import {
|
||||||
mergeGroup,
|
BlockPendantProvider,
|
||||||
RenderBlockChildren,
|
RenderBlockChildren,
|
||||||
splitGroup,
|
splitGroup,
|
||||||
supportChildren,
|
supportChildren,
|
||||||
unwrapGroup,
|
|
||||||
useOnSelect,
|
useOnSelect,
|
||||||
BlockPendantProvider,
|
|
||||||
} from '@toeverything/components/editor-core';
|
} from '@toeverything/components/editor-core';
|
||||||
import { styled } from '@toeverything/components/ui';
|
import { styled } from '@toeverything/components/ui';
|
||||||
import { Protocol } from '@toeverything/datasource/db-service';
|
import { Protocol } from '@toeverything/datasource/db-service';
|
||||||
@@ -95,13 +93,21 @@ export const TextView = ({
|
|||||||
await block.setType('text');
|
await block.setType('text');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (editor.getRootBlockId() === block.id) {
|
||||||
|
// Can not delete
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const parentBlock = await block.parent();
|
const parentBlock = await block.parent();
|
||||||
|
|
||||||
if (!parentBlock) {
|
if (!parentBlock) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const preParent = await parentBlock.previousSibling();
|
const preParent = await parentBlock.previousSibling();
|
||||||
if (Protocol.Block.Type.group === parentBlock.type) {
|
if (
|
||||||
|
Protocol.Block.Type.group === parentBlock.type ||
|
||||||
|
editor.getRootBlockId() === parentBlock.id
|
||||||
|
) {
|
||||||
const children = await block.children();
|
const children = await block.children();
|
||||||
const preNode = await block.physicallyPerviousSibling();
|
const preNode = await block.physicallyPerviousSibling();
|
||||||
// FIXME support children do not means has textBlock
|
// FIXME support children do not means has textBlock
|
||||||
|
|||||||
Reference in New Issue
Block a user