mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
chore: bump version (#1618)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
import type { EditorContainer } from '@blocksuite/editor';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
import { assertEquals, assertExists, Generator } from '@blocksuite/store';
|
||||
import { Generator } from '@blocksuite/store';
|
||||
import type React from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useCallback, useRef } from 'react';
|
||||
|
||||
import { createEmptyBlockSuiteWorkspace } from '../../../utils';
|
||||
import { BlockSuiteEditor } from '../../blocksuite/block-suite-editor';
|
||||
@@ -14,41 +14,21 @@ const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
|
||||
Generator.AutoIncrement
|
||||
);
|
||||
|
||||
blockSuiteWorkspace.createPage('page0');
|
||||
const page = blockSuiteWorkspace.createPage('page0');
|
||||
|
||||
const Editor: React.FC<{
|
||||
onInit: (page: Page, editor: Readonly<EditorContainer>) => void;
|
||||
testType: 'empty' | 'importMarkdown';
|
||||
}> = ({ onInit, testType }) => {
|
||||
const page = blockSuiteWorkspace.getPage('page0');
|
||||
const [, rerender] = useState(false);
|
||||
const onceRef = useRef(false);
|
||||
if (!onceRef.current) {
|
||||
if (testType === 'importMarkdown') {
|
||||
if (page) {
|
||||
page.workspace.meta.setPageMeta(page.id, {
|
||||
init: true,
|
||||
});
|
||||
} else {
|
||||
blockSuiteWorkspace.slots.pageAdded.on(id => {
|
||||
const page = blockSuiteWorkspace.getPage(id);
|
||||
assertExists(page);
|
||||
assertEquals(id, 'page0');
|
||||
page.workspace.meta.setPageMeta(page.id, {
|
||||
init: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
page.workspace.meta.setPageMeta(page.id, {
|
||||
init: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const cb = () => rerender(v => !v);
|
||||
const dispose = blockSuiteWorkspace.slots.pageAdded.on(cb);
|
||||
return () => {
|
||||
dispose.dispose();
|
||||
};
|
||||
}, []);
|
||||
const onLoad = useCallback((page: Page, editor: EditorContainer) => {
|
||||
// @ts-ignore
|
||||
globalThis.page = page;
|
||||
|
||||
Reference in New Issue
Block a user