mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor: init package @affine/workspace (#1661)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user