mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 13:29:44 +02:00
fix(editor): avoid accessing editor.view during initial render in link preview
EditorLinkPreview's useRef initializer accessed editor.view?.dom which throws when the editor view is not yet mounted (Tiptap uses a Proxy that rejects property access before mount). Defer the contextElement assignment to the selectionUpdate callback where the view is guaranteed to exist.
This commit is contained in:
@@ -156,9 +156,10 @@ function EditorLinkPreview({ editor }: { editor: Editor }) {
|
||||
|
||||
const close = useCallback(() => setVisible(false), []);
|
||||
|
||||
// Avoid accessing editor.view during initial render — it may not be mounted yet.
|
||||
const virtualRef = useRef({
|
||||
getBoundingClientRect: () => new DOMRect(),
|
||||
contextElement: editor.view?.dom,
|
||||
contextElement: undefined as Element | undefined,
|
||||
});
|
||||
|
||||
const { refs, floatingStyles, isPositioned, update } = useFloating({
|
||||
|
||||
Reference in New Issue
Block a user