mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 23:56:36 +08:00
6f9dfcc3c1
Co-authored-by: codert <codert.sn@gmail.com>
42 lines
1001 B
TypeScript
42 lines
1001 B
TypeScript
import type { PluginContext } from '@affine/sdk/entry';
|
|
import { registerTOCComponents } from '@blocksuite/blocks';
|
|
import { createElement } from 'react';
|
|
import { createRoot } from 'react-dom/client';
|
|
|
|
import { HeaderItem } from './app';
|
|
|
|
export const entry = (context: PluginContext) => {
|
|
console.log('register outline');
|
|
|
|
context.register('headerItem', div => {
|
|
registerTOCComponents(components => {
|
|
for (const compName in components) {
|
|
if (window.customElements.get(compName)) continue;
|
|
|
|
window.customElements.define(
|
|
compName,
|
|
components[compName as keyof typeof components]
|
|
);
|
|
}
|
|
});
|
|
|
|
div.style.height = '100%';
|
|
|
|
const root = createRoot(div);
|
|
root.render(
|
|
createElement(
|
|
context.utils.PluginProvider,
|
|
{},
|
|
createElement(HeaderItem, {
|
|
Provider: context.utils.PluginProvider,
|
|
})
|
|
)
|
|
);
|
|
return () => {
|
|
root.unmount();
|
|
};
|
|
});
|
|
|
|
return () => {};
|
|
};
|