mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 15:26:59 +08:00
chore(infra): remove blocksuite from infra (#9353)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
export * from './app-config-storage';
|
||||
export * from './atom';
|
||||
export * from './framework';
|
||||
export * from './initialization';
|
||||
export * from './livedata';
|
||||
export * from './orm';
|
||||
export * from './storage';
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import type { SurfaceBlockProps } from '@blocksuite/affine/block-std/gfx';
|
||||
import {
|
||||
NoteDisplayMode,
|
||||
type NoteProps,
|
||||
type ParagraphProps,
|
||||
type RootBlockProps,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { type Doc, Text } from '@blocksuite/affine/store';
|
||||
|
||||
export interface DocProps {
|
||||
page?: Partial<RootBlockProps>;
|
||||
surface?: Partial<SurfaceBlockProps>;
|
||||
note?: Partial<NoteProps>;
|
||||
paragraph?: Partial<ParagraphProps>;
|
||||
}
|
||||
|
||||
export function initEmptyDoc(doc: Doc, title?: string) {
|
||||
doc.load(() => {
|
||||
initDocFromProps(doc, {
|
||||
page: {
|
||||
title: new Text(title),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function initDocFromProps(doc: Doc, props?: DocProps) {
|
||||
doc.load(() => {
|
||||
const pageBlockId = doc.addBlock(
|
||||
'affine:page',
|
||||
props?.page || { title: new Text('') }
|
||||
);
|
||||
doc.addBlock('affine:surface' as never, props?.surface || {}, pageBlockId);
|
||||
const noteBlockId = doc.addBlock(
|
||||
'affine:note',
|
||||
{
|
||||
...props?.note,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
},
|
||||
pageBlockId
|
||||
);
|
||||
doc.addBlock('affine:paragraph', props?.paragraph || {}, noteBlockId);
|
||||
doc.history.clear();
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { Slot } from '@blocksuite/affine/global/utils';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
import { difference } from 'lodash-es';
|
||||
|
||||
import { LiveData } from '../../livedata';
|
||||
@@ -32,13 +32,19 @@ export interface BlobStatus {
|
||||
export class BlobEngine {
|
||||
readonly name = 'blob-engine';
|
||||
readonly readonly = this.local.readonly;
|
||||
readonly event = new EventEmitter2();
|
||||
|
||||
private abort: AbortController | null = null;
|
||||
|
||||
readonly isStorageOverCapacity$ = new LiveData(false);
|
||||
|
||||
singleBlobSizeLimit: number = 100 * 1024 * 1024;
|
||||
onAbortLargeBlob = new Slot<Blob>();
|
||||
onAbortLargeBlob = (callback: (blob: Blob) => void) => {
|
||||
this.event.on('abort-large-blob', callback);
|
||||
return () => {
|
||||
this.event.off('abort-large-blob', callback);
|
||||
};
|
||||
};
|
||||
|
||||
constructor(
|
||||
private readonly local: BlobStorage,
|
||||
@@ -153,7 +159,7 @@ export class BlobEngine {
|
||||
}
|
||||
|
||||
if (value.size > this.singleBlobSizeLimit) {
|
||||
this.onAbortLargeBlob.emit(value);
|
||||
this.event.emit('abort-large-blob', value);
|
||||
logger.error('blob over limit, abort set');
|
||||
return key;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user