Merge pull request #174 from toeverything/fix-left-menu

fix(plugin): hide left menu when block change
This commit is contained in:
DarkSky authored and GitHub committed 2022-08-10 19:18:56 +08:00
commit a5a8b32a25
2 files changed
+14

No files matched your search

@@ -168,6 +168,12 @@ export const GroupMenu = function ({ editor, hooks }: GroupMenuProps) {
useEffect(() => {
setShowMenu(false);
if (groupBlock) {
const unobserve = groupBlock.onUpdate(() => setGroupBlock(null));
return unobserve;
}
return undefined;
}, [groupBlock]);
return (
@@ -184,6 +184,14 @@ export const LeftMenuDraggable: FC<LeftMenuProps> = props => {
return () => sub.unsubscribe();
}, [blockInfo, editor]);
useEffect(() => {
if (block?.block != null) {
const unobserve = block.block.onUpdate(() => setBlock(undefined));
return unobserve;
}
return undefined;
}, [block?.block]);
useEffect(() => {
const sub = lineInfo.subscribe(data => {
if (data == null) {