mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
feat: add @affine/bookmark-block plugin (#2618)
This commit is contained in:
@@ -16,14 +16,6 @@ import {
|
||||
blockSuiteEditorHeaderStyle,
|
||||
blockSuiteEditorStyle,
|
||||
} from './index.css';
|
||||
import { bookmarkPlugin } from './plugins/bookmark';
|
||||
|
||||
export type EditorPlugin = {
|
||||
flavour: string;
|
||||
onInit?: (page: Page, editor: Readonly<EditorContainer>) => void;
|
||||
onLoad?: (page: Page, editor: EditorContainer) => () => void;
|
||||
render?: (props: { page: Page }) => ReactElement | null;
|
||||
};
|
||||
|
||||
export type EditorProps = {
|
||||
page: Page;
|
||||
@@ -50,9 +42,6 @@ const ImagePreviewModal = lazy(() =>
|
||||
}))
|
||||
);
|
||||
|
||||
// todo(himself65): plugin-infra should support this
|
||||
const plugins = [bookmarkPlugin];
|
||||
|
||||
const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
|
||||
const { onLoad, page, mode, style, onInit } = props;
|
||||
const JotaiEditorContainer = useAtomValue(
|
||||
@@ -77,9 +66,6 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
|
||||
editor.page = page;
|
||||
if (page.root === null) {
|
||||
onInit(page, editor);
|
||||
plugins.forEach(plugin => {
|
||||
plugin.onInit?.(page, editor);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [editor, page, onInit]);
|
||||
@@ -88,7 +74,6 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
|
||||
if (editor.page && onLoad) {
|
||||
const disposes = [] as ((() => void) | undefined)[];
|
||||
disposes.push(onLoad?.(page, editor));
|
||||
disposes.push(...plugins.map(plugin => plugin.onLoad?.(page, editor)));
|
||||
return () => {
|
||||
disposes
|
||||
.filter((dispose): dispose is () => void => !!dispose)
|
||||
@@ -201,12 +186,6 @@ export const BlockSuiteEditor = memo(function BlockSuiteEditor(
|
||||
)}
|
||||
</Suspense>
|
||||
)}
|
||||
{plugins.map(plugin => {
|
||||
const Renderer = plugin.render;
|
||||
return Renderer ? (
|
||||
<Renderer page={props.page} key={plugin.flavour} />
|
||||
) : null;
|
||||
})}
|
||||
</ErrorBoundary>
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user