mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
refactor(editor): job should not rely on doc collection directly (#9488)
This commit is contained in:
@@ -4,10 +4,10 @@ import type {
|
||||
BaseAdapter,
|
||||
BlockSnapshot,
|
||||
Doc,
|
||||
Job,
|
||||
JobMiddleware,
|
||||
Slice,
|
||||
} from '@blocksuite/store';
|
||||
import { Job } from '@blocksuite/store';
|
||||
import DOMPurify from 'dompurify';
|
||||
import type { RootContentMap } from 'hast';
|
||||
import * as lz from 'lz-string';
|
||||
@@ -286,10 +286,7 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
}
|
||||
|
||||
private _getJob() {
|
||||
return new Job({
|
||||
middlewares: this._jobMiddlewares,
|
||||
collection: this.std.collection,
|
||||
});
|
||||
return this.std.getJob(this._jobMiddlewares);
|
||||
}
|
||||
|
||||
readFromClipboard(clipboardData: DataTransfer) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ServiceProvider } from '@blocksuite/global/di';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import type { Doc } from '@blocksuite/store';
|
||||
import { type Doc, Job, type JobMiddleware } from '@blocksuite/store';
|
||||
|
||||
import { Clipboard } from '../clipboard/index.js';
|
||||
import { CommandManager } from '../command/index.js';
|
||||
@@ -168,6 +168,19 @@ export class BlockStdScope {
|
||||
return this.getOptional(BlockViewIdentifier(flavour));
|
||||
}
|
||||
|
||||
getJob(middlewares: JobMiddleware[] = []) {
|
||||
return new Job({
|
||||
schema: this.collection.schema,
|
||||
blobCRUD: this.collection.blobSync,
|
||||
docCRUD: {
|
||||
create: (id: string) => this.collection.createDoc({ id }),
|
||||
get: (id: string) => this.collection.getDoc(id),
|
||||
delete: (id: string) => this.collection.removeDoc(id),
|
||||
},
|
||||
middlewares,
|
||||
});
|
||||
}
|
||||
|
||||
mount() {
|
||||
this._lifeCycleWatchers.forEach(watcher => {
|
||||
watcher.mounted.call(watcher);
|
||||
|
||||
Reference in New Issue
Block a user