feat: add block suite editor sample

This commit is contained in:
lawvs
2022-10-12 12:16:54 +08:00
parent 2f0c76ff0e
commit 56196a5bb3
2 changed files with 36 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import type { EditorContainer } from '@blocksuite/editor';
import '@blocksuite/blocks';
import '@blocksuite/editor';
import '@blocksuite/blocks/style';
export const Editor = () => {
return (
<div>
Editor
<editor-container />
</div>
);
};
declare global {
interface HTMLElementTagNameMap {
'editor-container': EditorContainer;
}
namespace JSX {
interface IntrinsicElements {
// TODO fix type error
'editor-container': any; // EditorContainer
}
}
}
export default Editor;
+8
View File
@@ -1,5 +1,7 @@
import type { NextPage } from 'next'; import type { NextPage } from 'next';
import dynamic from 'next/dynamic';
import { styled, useTheme } from '@/styles'; import { styled, useTheme } from '@/styles';
import '@/components/simple-counter'; import '@/components/simple-counter';
const Button = styled('div')(({ theme }) => { const Button = styled('div')(({ theme }) => {
@@ -8,6 +10,11 @@ const Button = styled('div')(({ theme }) => {
}; };
}); });
const DynamicEditor = dynamic(() => import('../components/editor'), {
loading: () => <div>Loading...</div>,
ssr: false,
});
const Home: NextPage = () => { const Home: NextPage = () => {
const { changeMode, mode } = useTheme(); const { changeMode, mode } = useTheme();
return ( return (
@@ -36,6 +43,7 @@ const Home: NextPage = () => {
> >
auto auto
</button> </button>
<DynamicEditor />
</div> </div>
); );
}; };