mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-18 12:41:39 +03:00
Merge pull request #92 from toeverything/bugfix/Backspace-block-in-group
fix bacakspace in group first block
This commit is contained in:
commit
eb4589cbe0
@ -143,13 +143,13 @@ export const ImageView: FC<ImageView> = ({ block, editor }) => {
|
|||||||
type: 'link',
|
type: 'link',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const handle_click = (e: React.MouseEvent<HTMLDivElement>) => {
|
const handle_click = async (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
//TODO clear active selection
|
//TODO clear active selection
|
||||||
// document.getElementsByTagName('body')[0].click();
|
// document.getElementsByTagName('body')[0].click();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.nativeEvent.stopPropagation();
|
e.nativeEvent.stopPropagation();
|
||||||
editor.selectionManager.setSelectedNodesIds([block.id]);
|
await editor.selectionManager.setSelectedNodesIds([block.id]);
|
||||||
editor.selectionManager.activeNodeByNodeId(block.id);
|
await editor.selectionManager.activeNodeByNodeId(block.id, 'end');
|
||||||
};
|
};
|
||||||
const down_file = () => {
|
const down_file = () => {
|
||||||
if (down_ref) {
|
if (down_ref) {
|
||||||
|
@ -99,7 +99,7 @@ export const TextView: FC<CreateTextView> = ({
|
|||||||
if (!parentBlock) {
|
if (!parentBlock) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const preParent = await parentBlock.previousSibling();
|
||||||
if (Protocol.Block.Type.group === parentBlock.type) {
|
if (Protocol.Block.Type.group === parentBlock.type) {
|
||||||
const children = await block.children();
|
const children = await block.children();
|
||||||
const preNode = await block.physicallyPerviousSibling();
|
const preNode = await block.physicallyPerviousSibling();
|
||||||
@ -129,34 +129,19 @@ export const TextView: FC<CreateTextView> = ({
|
|||||||
'start'
|
'start'
|
||||||
);
|
);
|
||||||
if (block.blockProvider.isEmpty()) {
|
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();
|
await block.remove();
|
||||||
return true;
|
const parentChild = await parentBlock.children();
|
||||||
|
if (
|
||||||
|
parentBlock.type ===
|
||||||
|
Protocol.Block.Type.group &&
|
||||||
|
!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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user