mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-28 12:19:27 +08:00
fix: empty ref page
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
import { useEditor } from '@toeverything/components/editor-core';
|
import { useEditor } from '@toeverything/components/editor-core';
|
||||||
import { MuiBackdrop, styled, useTheme } from '@toeverything/components/ui';
|
import { MuiBackdrop, styled, useTheme } from '@toeverything/components/ui';
|
||||||
import { createContext, ReactNode, useContext, useState } from 'react';
|
import {
|
||||||
|
createContext,
|
||||||
|
ReactNode,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
|
|
||||||
const Dialog = styled('div')({
|
const Dialog = styled('div')({
|
||||||
@@ -11,7 +18,7 @@ const Dialog = styled('div')({
|
|||||||
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)',
|
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)',
|
||||||
borderRadius: '10px',
|
borderRadius: '10px',
|
||||||
padding: '72px 120px',
|
padding: '72px 120px',
|
||||||
overflow: 'scroll',
|
overflowY: 'auto',
|
||||||
});
|
});
|
||||||
|
|
||||||
const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => {
|
const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => {
|
||||||
@@ -48,13 +55,20 @@ const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => {
|
|||||||
|
|
||||||
const ModalPage = ({ blockId }: { blockId: string | null }) => {
|
const ModalPage = ({ blockId }: { blockId: string | null }) => {
|
||||||
const { editor, editorElement } = useEditor();
|
const { editor, editorElement } = useEditor();
|
||||||
|
const editorRef = useRef<typeof editor>(null);
|
||||||
|
|
||||||
const AffineEditor = editorElement as any;
|
const AffineEditor = editorElement as any;
|
||||||
|
|
||||||
|
// Active block after modal open
|
||||||
|
useEffect(() => {
|
||||||
|
editorRef.current?.selectionManager.activeNodeByNodeId(blockId);
|
||||||
|
}, [blockId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={!!blockId}>
|
<Modal open={!!blockId}>
|
||||||
{blockId && (
|
{blockId && (
|
||||||
<AffineEditor
|
<AffineEditor
|
||||||
|
ref={editorRef}
|
||||||
workspace={editor.workspace}
|
workspace={editor.workspace}
|
||||||
rootBlockId={blockId}
|
rootBlockId={blockId}
|
||||||
scrollBlank={false}
|
scrollBlank={false}
|
||||||
|
|||||||
Reference in New Issue
Block a user