mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
feat: init affine blob storage (#2045)
This commit is contained in:
@@ -31,7 +31,10 @@ function initPage(page: Page): void {
|
||||
page.resetHistory();
|
||||
}
|
||||
|
||||
const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace('test-workspace');
|
||||
const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
|
||||
'test-workspace',
|
||||
WorkspaceFlavour.LOCAL
|
||||
);
|
||||
|
||||
initPage(blockSuiteWorkspace.createPage('page0'));
|
||||
initPage(blockSuiteWorkspace.createPage('page1'));
|
||||
|
||||
@@ -21,7 +21,6 @@ export default {
|
||||
|
||||
const basicBlockSuiteWorkspace = new Workspace({
|
||||
id: 'blocksuite-local',
|
||||
blobOptionsGetter: (_: string) => undefined,
|
||||
});
|
||||
|
||||
basicBlockSuiteWorkspace.meta.setName('Hello World');
|
||||
@@ -46,19 +45,17 @@ Basic.args = {
|
||||
|
||||
const avatarBlockSuiteWorkspace = new Workspace({
|
||||
id: 'blocksuite-local',
|
||||
blobOptionsGetter: (_: string) => undefined,
|
||||
});
|
||||
|
||||
avatarBlockSuiteWorkspace.meta.setName('Hello World');
|
||||
avatarBlockSuiteWorkspace.blobs.then(async blobs => {
|
||||
if (blobs) {
|
||||
const buffer = await (
|
||||
await fetch(new URL('@affine-test/fixtures/smile.png', import.meta.url))
|
||||
).arrayBuffer();
|
||||
const id = await blobs.set(new Blob([buffer], { type: 'image/png' }));
|
||||
fetch(new URL('@affine-test/fixtures/smile.png', import.meta.url))
|
||||
.then(res => res.arrayBuffer())
|
||||
.then(async buffer => {
|
||||
const id = await avatarBlockSuiteWorkspace.blobs.set(
|
||||
new Blob([buffer], { type: 'image/png' })
|
||||
);
|
||||
avatarBlockSuiteWorkspace.meta.setAvatar(id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const BlobExample: StoryFn<WorkspaceAvatarProps> = props => {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user