mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-16 13:57:02 +08:00
refactor: image preview plugin (#3457)
This commit is contained in:
18
plugins/image-preview/src/index.ts
Normal file
18
plugins/image-preview/src/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { PluginContext } from '@toeverything/plugin-infra/entry';
|
||||
import { createElement } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
import { App } from './app';
|
||||
|
||||
export const entry = (context: PluginContext) => {
|
||||
context.register('editor', (div, editor) => {
|
||||
const root = createRoot(div);
|
||||
root.render(createElement(App, { page: editor.page }));
|
||||
return () => {
|
||||
root.unmount();
|
||||
};
|
||||
});
|
||||
return () => {
|
||||
// do nothing
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user