mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 09:36:17 +08:00
feat(toc): add scroll active item
This commit is contained in:
@@ -16,8 +16,8 @@ import {
|
||||
getContentByAsyncBlocks,
|
||||
getPageTOC,
|
||||
} from './toc-util';
|
||||
import './toc.css';
|
||||
import type { ListenerMap, TOCType } from './types';
|
||||
|
||||
const StyledTOCItem = styled('a')<{ type?: string; isActive?: boolean }>(
|
||||
({ type, isActive }) => {
|
||||
const common = {
|
||||
@@ -168,6 +168,11 @@ export const TOC = () => {
|
||||
|
||||
const onClick = async (blockId?: string) => {
|
||||
setActiveBlockId(blockId);
|
||||
const block = await editor.getBlockById(blockId);
|
||||
block.dom.classList.add('toc-scroll-item');
|
||||
setTimeout(() => {
|
||||
block.dom.classList.remove('toc-scroll-item');
|
||||
}, 1000);
|
||||
await editor.scrollManager.scrollIntoViewByBlockId(blockId);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
.toc-scroll-item {
|
||||
animation: blinker 1s linear;
|
||||
animation-delay: 1s;
|
||||
}
|
||||
|
||||
@keyframes blinker {
|
||||
0% {
|
||||
background: rgba(152, 172, 189, 0.1);
|
||||
}
|
||||
100% {
|
||||
background: rgba(152, 172, 189, 0.1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user