mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
feat: update blocksuite version
This commit is contained in:
@@ -6,7 +6,7 @@ export const Editor = () => {
|
||||
const { editor } = useEditor();
|
||||
const ref = useRef<any>();
|
||||
useEffect(() => {
|
||||
if (editor && ref.current?.space.id !== editor?.space.id) {
|
||||
if (editor && ref.current?.page.id !== editor?.page.id) {
|
||||
ref.current?.remove();
|
||||
ref.current = editor;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { EditorContainer } from '@blocksuite/editor';
|
||||
import { BlockSchema, createEditor } from '@blocksuite/editor';
|
||||
import { useEffect } from 'react';
|
||||
import pkg from '../../../package.json';
|
||||
import { createWebsocketDocProvider, Store } from '@blocksuite/store';
|
||||
import { createWebsocketDocProvider, Workspace } from '@blocksuite/store';
|
||||
|
||||
const getEditorParams = () => {
|
||||
const providers = [];
|
||||
@@ -27,11 +27,11 @@ const InitialEditor = ({
|
||||
setEditor: (editor: EditorContainer) => void;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
const store = new Store({
|
||||
const store = new Workspace({
|
||||
...getEditorParams(),
|
||||
});
|
||||
const space = store.createSpace('page0').register(BlockSchema);
|
||||
const editor = createEditor(space);
|
||||
const page = store.createPage('page0').register(BlockSchema);
|
||||
const editor = createEditor(page);
|
||||
|
||||
setEditor(editor);
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@ import { EditorContainer } from '@blocksuite/editor';
|
||||
import exampleMarkdown from '@/providers/editor-provider/example-markdown';
|
||||
|
||||
export const initDefaultContent = (editor: EditorContainer) => {
|
||||
const { space } = editor;
|
||||
const pageId = space.addBlock({
|
||||
const { page } = editor;
|
||||
const pageId = page.addBlock({
|
||||
flavour: 'affine:page',
|
||||
title: 'Welcome to the AFFiNE Alpha',
|
||||
});
|
||||
const groupId = space.addBlock({ flavour: 'affine:group' }, pageId);
|
||||
const groupId = page.addBlock({ flavour: 'affine:group' }, pageId);
|
||||
editor.clipboard.importMarkdown(exampleMarkdown, `${groupId}`);
|
||||
space.resetHistory();
|
||||
page.resetHistory();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user