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.

fix(core): bidi links rendering issue (#5707)

Peng Xiaoe8a6b6ad5ed0
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
index aca1678c46..f0c0282fd1 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
@@ -15,6 +15,7 @@ import React, {
useEffect,
useMemo,
useRef,
+ useState,
} from 'react';
import { BlocksuiteEditorJournalDocTitle } from './journal-doc-title';
@@ -61,6 +62,8 @@ export const BlocksuiteDocEditor = forwardRef<
>(function BlocksuiteDocEditor({ page, customRenderers }, ref) {
const titleRef = useRef<DocTitle>(null);
const docRef = useRef<DocEditor | null>(null);
+ const [docPage, setDocPage] =
+ useState<HTMLElementTagNameMap['affine-doc-page']>();
const { isJournal } = useJournalInfoHelper(page.workspace, page.id);
const onDocRef = useCallback(
@@ -84,11 +87,15 @@ export const BlocksuiteDocEditor = forwardRef<
useEffect(() => {
// auto focus the title
setTimeout(() => {
+ const docPage = docRef.current?.querySelector('affine-doc-page');
+ if (docPage) {
+ setDocPage(docPage);
+ }
if (titleRef.current) {
const richText = titleRef.current.querySelector('rich-text');
richText?.inlineEditor?.focusEnd();
} else {
- docRef.current?.querySelector('affine-doc-page')?.focusFirstParagraph();
+ docPage?.focusFirstParagraph();
}
});
}, []);
@@ -110,7 +117,9 @@ export const BlocksuiteDocEditor = forwardRef<
specs={specs}
hasViewport={false}
/>
- <adapted.BiDirectionalLinkPanel page={page} />
+ {docPage ? (
+ <adapted.BiDirectionalLinkPanel page={page} docPageBlock={docPage} />
+ ) : null}
</div>
</div>
);