refactor: ref page use AffineEditor
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
import type { KanbanCard } from '@toeverything/components/editor-core';
|
import type { KanbanCard } from '@toeverything/components/editor-core';
|
||||||
import {
|
import { RenderBlock, useKanban } from '@toeverything/components/editor-core';
|
||||||
RenderBlock,
|
|
||||||
useKanban,
|
|
||||||
useRefPage,
|
|
||||||
} from '@toeverything/components/editor-core';
|
|
||||||
import { PenIcon } from '@toeverything/components/icons';
|
import { PenIcon } from '@toeverything/components/icons';
|
||||||
import {
|
import {
|
||||||
IconButton,
|
IconButton,
|
||||||
@@ -12,6 +8,7 @@ import {
|
|||||||
} from '@toeverything/components/ui';
|
} from '@toeverything/components/ui';
|
||||||
import { useFlag } from '@toeverything/datasource/feature-flags';
|
import { useFlag } from '@toeverything/datasource/feature-flags';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { useRefPage } from './RefPage';
|
||||||
|
|
||||||
const CardContent = styled('div')({
|
const CardContent = styled('div')({
|
||||||
margin: '20px',
|
margin: '20px',
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import { AffineEditor } from '@toeverything/components/affine-editor';
|
||||||
|
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, useState } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { RenderBlock } from '../render-block';
|
|
||||||
|
|
||||||
const Dialog = styled('div')({
|
const Dialog = styled('div')({
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -30,7 +31,7 @@ const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => {
|
|||||||
onClick={closeSubPage}
|
onClick={closeSubPage}
|
||||||
>
|
>
|
||||||
<Dialog
|
<Dialog
|
||||||
onClick={e => {
|
onClick={(e: { stopPropagation: () => void }) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -43,9 +44,18 @@ const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ModalPage = ({ blockId }: { blockId: string | null }) => {
|
const ModalPage = ({ blockId }: { blockId: string | null }) => {
|
||||||
|
const { editor } = useEditor();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={!!blockId}>
|
<Modal open={!!blockId}>
|
||||||
{blockId && <RenderBlock blockId={blockId} />}
|
{blockId && (
|
||||||
|
<AffineEditor
|
||||||
|
workspace={editor.workspace}
|
||||||
|
rootBlockId={blockId}
|
||||||
|
scrollBlank={false}
|
||||||
|
isWhiteboard
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -16,4 +16,4 @@ export * from './utils';
|
|||||||
|
|
||||||
export * from './editor';
|
export * from './editor';
|
||||||
|
|
||||||
export { RefPageProvider, useRefPage } from './ref-page';
|
export { useEditor } from './Contexts';
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { Protocol } from '@toeverything/datasource/db-service';
|
|||||||
import { AsyncBlock } from '../editor';
|
import { AsyncBlock } from '../editor';
|
||||||
import { ComponentType, createContext, ReactNode, useContext } from 'react';
|
import { ComponentType, createContext, ReactNode, useContext } from 'react';
|
||||||
import { RecastBlock } from './types';
|
import { RecastBlock } from './types';
|
||||||
import { RefPageProvider } from '../ref-page';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the block supports RecastBlock
|
* Determine whether the block supports RecastBlock
|
||||||
@@ -48,7 +47,7 @@ export const RecastBlockProvider = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<RecastBlockContext.Provider value={block}>
|
<RecastBlockContext.Provider value={block}>
|
||||||
<RefPageProvider>{children}</RefPageProvider>
|
{children}
|
||||||
</RecastBlockContext.Provider>
|
</RecastBlockContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export { useRefPage, RefPageProvider } from './ModalPage';
|
|
||||||
Reference in New Issue
Block a user