refactor!: next generation AFFiNE code structure (#1176)

This commit is contained in:
Himself65
2023-03-01 01:40:01 -06:00
committed by GitHub
parent 2dcccc772c
commit e0481d29ad
270 changed files with 8308 additions and 6829 deletions
+37 -4
View File
@@ -1,4 +1,37 @@
export * from './colors';
export { isDev } from './env';
export * from './tools';
export * from './useragent';
import { __unstableSchemas, builtInSchemas } from '@blocksuite/blocks/models';
import type { BlobOptionsGetter } from '@blocksuite/store';
import { BlockSuiteWorkspace } from '../shared';
export function stringToColour(str: string) {
str = str || 'affine';
let colour = '#';
let hash = 0;
// str to hash
for (
let i = 0;
i < str.length;
hash = str.charCodeAt(i++) + ((hash << 5) - hash)
);
// int/hash to hex
for (
let i = 0;
i < 3;
colour += ('00' + ((hash >> (i++ * 8)) & 0xff).toString(16)).slice(-2)
);
return colour;
}
export const createEmptyBlockSuiteWorkspace = (
room: string,
blobOptionsGetter?: BlobOptionsGetter
) => {
return new BlockSuiteWorkspace({
room,
blobOptionsGetter,
})
.register(builtInSchemas)
.register(__unstableSchemas);
};