refactor: init package @affine/workspace (#1661)

This commit is contained in:
Himself65
2023-03-23 11:17:38 -05:00
committed by GitHub
parent 84d27e939d
commit 69721f2a61
44 changed files with 952 additions and 236 deletions

View File

@@ -1,8 +1,3 @@
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import type { BlobOptionsGetter, Generator } from '@blocksuite/store';
import { BlockSuiteWorkspace } from '../shared';
export function stringToColour(str: string) {
str = str || 'affine';
let colour = '#';
@@ -23,24 +18,3 @@ export function stringToColour(str: string) {
return colour;
}
const hashMap = new Map<string, BlockSuiteWorkspace>();
export const createEmptyBlockSuiteWorkspace = (
id: string,
blobOptionsGetter?: BlobOptionsGetter,
idGenerator?: Generator
): BlockSuiteWorkspace => {
if (hashMap.has(id)) {
return hashMap.get(id) as BlockSuiteWorkspace;
}
const workspace = new BlockSuiteWorkspace({
id,
isSSR: typeof window === 'undefined',
blobOptionsGetter,
idGenerator,
})
.register(AffineSchemas)
.register(__unstableSchemas);
hashMap.set(id, workspace);
return workspace;
};