fix bacakspace in group first block

This commit is contained in:
DiamondThree
2022-08-04 17:59:34 +08:00
parent 511afe63d9
commit f490ad497b
2 changed files with 10 additions and 29 deletions

View File

@@ -143,13 +143,13 @@ export const ImageView: FC<ImageView> = ({ block, editor }) => {
type: 'link',
});
};
const handle_click = (e: React.MouseEvent<HTMLDivElement>) => {
const handle_click = async (e: React.MouseEvent<HTMLDivElement>) => {
//TODO clear active selection
// document.getElementsByTagName('body')[0].click();
e.stopPropagation();
e.nativeEvent.stopPropagation();
editor.selectionManager.setSelectedNodesIds([block.id]);
editor.selectionManager.activeNodeByNodeId(block.id);
await editor.selectionManager.setSelectedNodesIds([block.id]);
await editor.selectionManager.activeNodeByNodeId(block.id, 'end');
};
const down_file = () => {
if (down_ref) {

View File

@@ -99,7 +99,7 @@ export const TextView: FC<CreateTextView> = ({
if (!parentBlock) {
return false;
}
let preParent = await parentBlock.previousSibling();
if (Protocol.Block.Type.group === parentBlock.type) {
const children = await block.children();
const preNode = await block.physicallyPerviousSibling();
@@ -129,34 +129,15 @@ export const TextView: FC<CreateTextView> = ({
'start'
);
if (block.blockProvider.isEmpty()) {
block.remove();
}
}
return true;
} else {
// TODO remove timing problem
const prevGroupBlock = await parentBlock.previousSibling();
if (!prevGroupBlock) {
const childrenBlock = await parentBlock.children();
if (childrenBlock.length) {
if (children.length) {
await parentBlock.append(...children);
}
await block.remove();
return true;
let parentChild = await parentBlock.children();
if (!parentChild.length) {
await editor.selectionManager.setSelectedNodesIds(
[preParent.id]
);
}
}
parentBlock.remove();
return true;
}
if (prevGroupBlock.type !== Protocol.Block.Type.group) {
unwrapGroup(parentBlock);
return true;
}
mergeGroup(prevGroupBlock, parentBlock);
return true;
}
}