Fix block numbering and switching with arrow keys (#258)

This commit is contained in:
Evan Simkowitz
2024-08-21 17:43:11 -07:00
committed by GitHub
parent dedfc31344
commit d5140129cd
11 changed files with 108 additions and 111 deletions
+1 -3
View File
@@ -255,16 +255,14 @@
}
&.is-layoutmode .block-mask-inner {
margin-top: 35px; // TODO fix this magic
background-color: rgba(0, 0, 0, 0.5);
height: calc(100% - 35px);
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
.bignum {
margin-top: -15%;
font-size: 60px;
font-weight: bold;
opacity: 0.7;
+3 -7
View File
@@ -202,13 +202,9 @@ function BlockNum({ blockId }: { blockId: string }) {
const tabId = jotai.useAtomValue(atoms.activeTabId);
const tabAtom = WOS.getWaveObjectAtom<Tab>(WOS.makeORef("tab", tabId));
const layoutModel = useLayoutModel(tabAtom);
for (let idx = 0; idx < layoutModel.leafs.length; idx++) {
const leaf = layoutModel.leafs[idx];
if (leaf?.data?.blockId == blockId) {
return String(idx + 1);
}
}
return null;
const leafsOrdered = jotai.useAtomValue(layoutModel.leafsOrdered);
const index = React.useMemo(() => leafsOrdered.findIndex((leaf) => leaf.data?.blockId == blockId), [leafsOrdered]);
return index !== -1 ? index + 1 : null;
}
const BlockMask = ({ blockId, preview, isFocused }: { blockId: string; preview: boolean; isFocused: boolean }) => {