Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat: Intra-line double link interaction

xiaodong zuo33d8b551d4cb
diff --git a/libs/components/editor-plugins/src/menu/double-link-menu/Container.tsx b/libs/components/editor-plugins/src/menu/double-link-menu/Container.tsx
index 7294a909b7..147f154129 100644
--- a/libs/components/editor-plugins/src/menu/double-link-menu/Container.tsx
+++ b/libs/components/editor-plugins/src/menu/double-link-menu/Container.tsx
@@ -79,16 +79,12 @@ export const DoubleLinkMenuContainer = (
if (types && ['ArrowUp', 'ArrowDown'].includes(event.code)) {
event.preventDefault();
const isUpkey = event.code === 'ArrowUp';
- const indexBound = isUpkey ? types.length - 1 : 0;
if (!currentItem && types.length) {
- setCurrentItem(types[indexBound]);
+ setCurrentItem(types[isUpkey ? types.length - 1 : 0]);
}
if (currentItem) {
const idx = types.indexOf(currentItem);
- const needChange = isUpkey
- ? idx > indexBound
- : idx < indexBound;
- if (needChange) {
+ if (isUpkey ? idx > 0 : idx < types.length - 1) {
setNeedCheckIntoView(true);
setCurrentItem(types[isUpkey ? idx - 1 : idx + 1]);
}