refactor: image preview plugin (#3457)

This commit is contained in:
Alex Yang
2023-07-29 00:18:28 -07:00
committed by GitHub
parent be3909370e
commit 52809a2783
18 changed files with 129 additions and 45 deletions

View 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
};
};