refactor(editor): rename job to transformer (#9639)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { DEFAULT_IMAGE_PROXY_ENDPOINT } from '@blocksuite/affine-shared/consts';
|
||||
import type { JobMiddleware } from '@blocksuite/store';
|
||||
import type { TransformerMiddleware } from '@blocksuite/store';
|
||||
|
||||
export const customImageProxyMiddleware = (
|
||||
imageProxyURL: string
|
||||
): JobMiddleware => {
|
||||
): TransformerMiddleware => {
|
||||
return ({ adapterConfigs }) => {
|
||||
adapterConfigs.set('imageProxy', imageProxyURL);
|
||||
};
|
||||
|
||||
@@ -12,11 +12,11 @@ import {
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotPayload,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type ToBlockSnapshotPayload,
|
||||
type ToDocSnapshotPayload,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import { AdapterFactoryIdentifier } from './types/adapter';
|
||||
@@ -132,7 +132,7 @@ export const AttachmentAdapterFactoryIdentifier =
|
||||
export const AttachmentAdapterFactoryExtension: ExtensionType = {
|
||||
setup: di => {
|
||||
di.addImpl(AttachmentAdapterFactoryIdentifier, () => ({
|
||||
get: (job: Job) => new AttachmentAdapter(job),
|
||||
get: (job: Transformer) => new AttachmentAdapter(job),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,11 +14,11 @@ import {
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotPayload,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type ToBlockSnapshotPayload,
|
||||
type ToDocSnapshotPayload,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
import type { Root } from 'hast';
|
||||
import rehypeParse from 'rehype-parse';
|
||||
@@ -172,7 +172,7 @@ export class HtmlAdapter extends BaseAdapter<Html> {
|
||||
|
||||
readonly blockMatchers: BlockHtmlAdapterMatcher[];
|
||||
|
||||
constructor(job: Job, provider: ServiceProvider) {
|
||||
constructor(job: Transformer, provider: ServiceProvider) {
|
||||
super(job);
|
||||
const blockMatchers = Array.from(
|
||||
provider.getAll(BlockHtmlAdapterMatcherIdentifier).values()
|
||||
|
||||
@@ -12,11 +12,11 @@ import {
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotPayload,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type ToBlockSnapshotPayload,
|
||||
type ToDocSnapshotPayload,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import { AdapterFactoryIdentifier } from './types/adapter';
|
||||
@@ -123,7 +123,7 @@ export const ImageAdapterFactoryIdentifier = AdapterFactoryIdentifier('Image');
|
||||
export const ImageAdapterFactoryExtension: ExtensionType = {
|
||||
setup: di => {
|
||||
di.addImpl(ImageAdapterFactoryIdentifier, () => ({
|
||||
get: (job: Job) => new ImageAdapter(job),
|
||||
get: (job: Transformer) => new ImageAdapter(job),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,11 +14,11 @@ import {
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotPayload,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type ToBlockSnapshotPayload,
|
||||
type ToDocSnapshotPayload,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
import type { Root } from 'mdast';
|
||||
import remarkMath from 'remark-math';
|
||||
@@ -171,7 +171,7 @@ export class MarkdownAdapter extends BaseAdapter<Markdown> {
|
||||
readonly blockMatchers: BlockMarkdownAdapterMatcher[];
|
||||
|
||||
constructor(
|
||||
job: Job,
|
||||
job: Transformer,
|
||||
readonly provider: ServiceProvider
|
||||
) {
|
||||
super(job);
|
||||
@@ -456,7 +456,7 @@ export const MarkdownAdapterFactoryIdentifier =
|
||||
export const MarkdownAdapterFactoryExtension: ExtensionType = {
|
||||
setup: di => {
|
||||
di.addImpl(MarkdownAdapterFactoryIdentifier, provider => ({
|
||||
get: (job: Job) => new MarkdownAdapter(job, provider),
|
||||
get: (job: Transformer) => new MarkdownAdapter(job, provider),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
import type {
|
||||
BlockSnapshot,
|
||||
DraftModel,
|
||||
JobMiddleware,
|
||||
JobSlots,
|
||||
TransformerMiddleware,
|
||||
TransformerSlots,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import { matchFlavours } from '../../utils';
|
||||
@@ -33,7 +33,7 @@ const handlePoint = (
|
||||
model.text?.sliceToDelta(index, length + index);
|
||||
};
|
||||
|
||||
const sliceText = (slots: JobSlots, std: EditorHost['std']) => {
|
||||
const sliceText = (slots: TransformerSlots, std: EditorHost['std']) => {
|
||||
slots.afterExport.on(payload => {
|
||||
if (payload.type === 'block') {
|
||||
const snapshot = payload.snapshot;
|
||||
@@ -52,7 +52,7 @@ const sliceText = (slots: JobSlots, std: EditorHost['std']) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const copyMiddleware = (std: BlockStdScope): JobMiddleware => {
|
||||
export const copyMiddleware = (std: BlockStdScope): TransformerMiddleware => {
|
||||
return ({ slots }) => {
|
||||
sliceText(slots, std);
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ import {
|
||||
type BlockSnapshot,
|
||||
type DeltaOperation,
|
||||
fromJSON,
|
||||
type JobMiddleware,
|
||||
type SliceSnapshot,
|
||||
type Text,
|
||||
type TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
@@ -505,7 +505,9 @@ function flatNote(snapshot: SliceSnapshot) {
|
||||
}
|
||||
}
|
||||
|
||||
export const pasteMiddleware = (std: EditorHost['std']): JobMiddleware => {
|
||||
export const pasteMiddleware = (
|
||||
std: EditorHost['std']
|
||||
): TransformerMiddleware => {
|
||||
return ({ slots }) => {
|
||||
let tr: PasteTr | undefined;
|
||||
slots.beforeImport.on(payload => {
|
||||
|
||||
@@ -15,11 +15,11 @@ import {
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotPayload,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type ToBlockSnapshotPayload,
|
||||
type ToDocSnapshotPayload,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import { MarkdownAdapter } from './markdown/markdown';
|
||||
@@ -37,7 +37,7 @@ type MixTextToSliceSnapshotPayload = {
|
||||
export class MixTextAdapter extends BaseAdapter<MixText> {
|
||||
private readonly _markdownAdapter: MarkdownAdapter;
|
||||
|
||||
constructor(job: Job, provider: ServiceProvider) {
|
||||
constructor(job: Transformer, provider: ServiceProvider) {
|
||||
super(job);
|
||||
this._markdownAdapter = new MarkdownAdapter(job, provider);
|
||||
}
|
||||
@@ -354,7 +354,7 @@ export const MixTextAdapterFactoryIdentifier =
|
||||
export const MixTextAdapterFactoryExtension: ExtensionType = {
|
||||
setup: di => {
|
||||
di.addImpl(MixTextAdapterFactoryIdentifier, provider => ({
|
||||
get: (job: Job) => new MixTextAdapter(job, provider),
|
||||
get: (job: Transformer) => new MixTextAdapter(job, provider),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,9 +14,9 @@ import {
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotPayload,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
import rehypeParse from 'rehype-parse';
|
||||
import { unified } from 'unified';
|
||||
@@ -115,7 +115,7 @@ export class NotionHtmlAdapter extends BaseAdapter<NotionHtml> {
|
||||
|
||||
readonly blockMatchers: BlockNotionHtmlAdapterMatcher[];
|
||||
|
||||
constructor(job: Job, provider: ServiceProvider) {
|
||||
constructor(job: Transformer, provider: ServiceProvider) {
|
||||
super(job);
|
||||
const blockMatchers = Array.from(
|
||||
provider.getAll(BlockNotionHtmlAdapterMatcherIdentifier).values()
|
||||
@@ -294,7 +294,7 @@ export const NotionHtmlAdapterFactoryIdentifier =
|
||||
export const NotionHtmlAdapterFactoryExtension: ExtensionType = {
|
||||
setup: di => {
|
||||
di.addImpl(NotionHtmlAdapterFactoryIdentifier, provider => ({
|
||||
get: (job: Job) => new NotionHtmlAdapter(job, provider),
|
||||
get: (job: Transformer) => new NotionHtmlAdapter(job, provider),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,9 +10,9 @@ import {
|
||||
type FromBlockSnapshotResult,
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import type { AffineTextAttributes } from '../types';
|
||||
@@ -164,7 +164,7 @@ export const NotionTextAdapterFactoryIdentifier =
|
||||
export const NotionTextAdapterFactoryExtension: ExtensionType = {
|
||||
setup: di => {
|
||||
di.addImpl(NotionTextAdapterFactoryIdentifier, () => ({
|
||||
get: (job: Job) => new NotionTextAdapter(job),
|
||||
get: (job: Transformer) => new NotionTextAdapter(job),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,11 +14,11 @@ import {
|
||||
type FromDocSnapshotResult,
|
||||
type FromSliceSnapshotPayload,
|
||||
type FromSliceSnapshotResult,
|
||||
type Job,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
type ToBlockSnapshotPayload,
|
||||
type ToDocSnapshotPayload,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
@@ -50,7 +50,7 @@ export class PlainTextAdapter extends BaseAdapter<PlainText> {
|
||||
readonly blockMatchers: BlockPlainTextAdapterMatcher[];
|
||||
|
||||
constructor(
|
||||
job: Job,
|
||||
job: Transformer,
|
||||
readonly provider: ServiceProvider
|
||||
) {
|
||||
super(job);
|
||||
@@ -321,7 +321,7 @@ export const PlainTextAdapterFactoryIdentifier =
|
||||
export const PlainTextAdapterFactoryExtension: ExtensionType = {
|
||||
setup: di => {
|
||||
di.addImpl(PlainTextAdapterFactoryIdentifier, provider => ({
|
||||
get: (job: Job) => new PlainTextAdapter(job, provider),
|
||||
get: (job: Transformer) => new PlainTextAdapter(job, provider),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
type BaseAdapter,
|
||||
type BlockSnapshot,
|
||||
BlockSnapshotSchema,
|
||||
type Job,
|
||||
type NodeProps,
|
||||
type Transformer,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import type { AffineTextAttributes } from '../../types/index.js';
|
||||
@@ -35,7 +35,7 @@ export type AdapterContext<
|
||||
walker: ASTWalker<ONode, TNode>;
|
||||
walkerContext: ASTWalkerContext<TNode>;
|
||||
configs: Map<string, string>;
|
||||
job: Job;
|
||||
job: Transformer;
|
||||
deltaConverter: TConverter;
|
||||
textBuffer: TextBuffer;
|
||||
provider?: ServiceProvider;
|
||||
@@ -174,7 +174,7 @@ export type ASTToDeltaMatcher<AST> = {
|
||||
|
||||
export type AdapterFactory = {
|
||||
// TODO(@chen): Make it return the specific adapter type
|
||||
get: (job: Job) => BaseAdapter;
|
||||
get: (job: Transformer) => BaseAdapter;
|
||||
};
|
||||
|
||||
export const AdapterFactoryIdentifier =
|
||||
|
||||
@@ -36,7 +36,7 @@ export class DNDAPIExtension extends Extension {
|
||||
const { docId, flavour = 'affine:embed-linked-doc', blockId } = options;
|
||||
|
||||
const slice = Slice.fromModels(this.std.store, []);
|
||||
const job = this.std.getJob();
|
||||
const job = this.std.getTransformer();
|
||||
const snapshot = job.sliceToSnapshot(slice);
|
||||
if (!snapshot) {
|
||||
console.error('Failed to convert slice to snapshot');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||
import type { JobMiddleware } from '@blocksuite/store';
|
||||
import type { TransformerMiddleware } from '@blocksuite/store';
|
||||
|
||||
export const newIdCrossDoc =
|
||||
(std: BlockStdScope): JobMiddleware =>
|
||||
(std: BlockStdScope): TransformerMiddleware =>
|
||||
({ slots }) => {
|
||||
let samePage = false;
|
||||
slots.beforeImport.on(payload => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { correctNumberedListsOrderToPrev } from '@blocksuite/affine-block-list';
|
||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||
import type { JobMiddleware } from '@blocksuite/store';
|
||||
import type { TransformerMiddleware } from '@blocksuite/store';
|
||||
|
||||
export const reorderList =
|
||||
(std: BlockStdScope): JobMiddleware =>
|
||||
(std: BlockStdScope): TransformerMiddleware =>
|
||||
({ slots }) => {
|
||||
slots.afterImport.on(payload => {
|
||||
if (payload.type === 'block') {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||
import type { JobMiddleware } from '@blocksuite/store';
|
||||
import type { TransformerMiddleware } from '@blocksuite/store';
|
||||
|
||||
export const surfaceRefToEmbed =
|
||||
(std: BlockStdScope): JobMiddleware =>
|
||||
(std: BlockStdScope): TransformerMiddleware =>
|
||||
({ slots }) => {
|
||||
let pageId: string | null = null;
|
||||
slots.beforeImport.on(payload => {
|
||||
|
||||
@@ -545,7 +545,7 @@ export class DragEventWatcher {
|
||||
|
||||
private _getJob() {
|
||||
const std = this._std;
|
||||
return std.getJob([
|
||||
return std.getTransformer([
|
||||
newIdCrossDoc(std),
|
||||
reorderList(std),
|
||||
surfaceRefToEmbed(std),
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Container } from '@blocksuite/global/di';
|
||||
import type {
|
||||
BlockSnapshot,
|
||||
DocSnapshot,
|
||||
JobMiddleware,
|
||||
TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
import { AssetsManager, MemoryBlobCRUD } from '@blocksuite/store';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
@@ -1514,7 +1514,7 @@ describe('snapshot to html', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const middleware: JobMiddleware = ({ adapterConfigs }) => {
|
||||
const middleware: TransformerMiddleware = ({ adapterConfigs }) => {
|
||||
adapterConfigs.set('title:4T5ObMgEIMII-4Bexyta1', 'Test Doc');
|
||||
adapterConfigs.set('docLinkBaseUrl', 'https://example.com');
|
||||
};
|
||||
|
||||
@@ -4,8 +4,8 @@ import { Container } from '@blocksuite/global/di';
|
||||
import type {
|
||||
BlockSnapshot,
|
||||
DocSnapshot,
|
||||
JobMiddleware,
|
||||
SliceSnapshot,
|
||||
TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
import { AssetsManager, MemoryBlobCRUD } from '@blocksuite/store';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
@@ -1931,7 +1931,7 @@ hhh
|
||||
|
||||
hhh
|
||||
`;
|
||||
const middleware: JobMiddleware = ({ adapterConfigs }) => {
|
||||
const middleware: TransformerMiddleware = ({ adapterConfigs }) => {
|
||||
adapterConfigs.set('title:deadbeef', 'test');
|
||||
adapterConfigs.set('docLinkBaseUrl', 'https://example.com');
|
||||
};
|
||||
@@ -3847,7 +3847,7 @@ hhh
|
||||
},
|
||||
],
|
||||
};
|
||||
const middleware: JobMiddleware = ({ adapterConfigs }) => {
|
||||
const middleware: TransformerMiddleware = ({ adapterConfigs }) => {
|
||||
adapterConfigs.set('docLinkBaseUrl', 'https://example.com');
|
||||
};
|
||||
const mdAdapter = new MarkdownAdapter(createJob([middleware]), provider);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Container } from '@blocksuite/global/di';
|
||||
import type {
|
||||
BlockSnapshot,
|
||||
DocSnapshot,
|
||||
JobMiddleware,
|
||||
TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
@@ -573,7 +573,7 @@ describe('snapshot to plain text', () => {
|
||||
},
|
||||
],
|
||||
};
|
||||
const middleware: JobMiddleware = ({ adapterConfigs }) => {
|
||||
const middleware: TransformerMiddleware = ({ adapterConfigs }) => {
|
||||
adapterConfigs.set('title:deadbeef', 'test');
|
||||
adapterConfigs.set('docLinkBaseUrl', 'https://example.com');
|
||||
};
|
||||
@@ -756,7 +756,7 @@ describe('snapshot to plain text', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const middleware: JobMiddleware = ({ adapterConfigs }) => {
|
||||
const middleware: TransformerMiddleware = ({ adapterConfigs }) => {
|
||||
adapterConfigs.set('title:4T5ObMgEIMII-4Bexyta1', 'test');
|
||||
adapterConfigs.set('docLinkBaseUrl', 'https://example.com');
|
||||
};
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
|
||||
import { Job, type JobMiddleware, Schema } from '@blocksuite/store';
|
||||
import {
|
||||
Schema,
|
||||
Transformer,
|
||||
type TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
import { TestWorkspace } from '@blocksuite/store/test';
|
||||
|
||||
import { defaultImageProxyMiddleware } from '../../_common/transformers/middlewares.js';
|
||||
@@ -17,7 +21,7 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export function createJob(middlewares?: JobMiddleware[]) {
|
||||
export function createJob(middlewares?: TransformerMiddleware[]) {
|
||||
window.happyDOM.settings.fetch.disableSameOriginPolicy = true;
|
||||
const testMiddlewares = middlewares ?? [];
|
||||
testMiddlewares.push(defaultImageProxyMiddleware);
|
||||
@@ -25,7 +29,7 @@ export function createJob(middlewares?: JobMiddleware[]) {
|
||||
const docCollection = new TestWorkspace({ schema });
|
||||
docCollection.storeExtensions = [FeatureFlagService];
|
||||
docCollection.meta.initialize();
|
||||
return new Job({
|
||||
return new Transformer({
|
||||
schema,
|
||||
blobCRUD: docCollection.blobSync,
|
||||
middlewares: testMiddlewares,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { HtmlAdapter } from '@blocksuite/affine-shared/adapters';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
import { sha } from '@blocksuite/global/utils';
|
||||
import type { Store, Workspace } from '@blocksuite/store';
|
||||
import { extMimeMap, Job } from '@blocksuite/store';
|
||||
import { extMimeMap, Transformer } from '@blocksuite/store';
|
||||
|
||||
import { defaultBlockHtmlAdapterMatchers } from '../adapters/html/block-matcher.js';
|
||||
import { htmlInlineToDeltaMatchers } from '../adapters/html/delta-converter/html-inline.js';
|
||||
@@ -44,7 +44,7 @@ const provider = container.provider();
|
||||
* @returns A Promise that resolves when the export is complete.
|
||||
*/
|
||||
async function exportDoc(doc: Store) {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: doc.schema,
|
||||
blobCRUD: doc.blobSync,
|
||||
docCRUD: {
|
||||
@@ -99,7 +99,7 @@ async function importHTMLToDoc({
|
||||
html,
|
||||
fileName,
|
||||
}: ImportHTMLToDocOptions) {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
@@ -161,7 +161,7 @@ async function importHTMLZip({ collection, imported }: ImportHTMLZipOptions) {
|
||||
await Promise.all(
|
||||
htmlBlobs.map(async ([fileName, blob]) => {
|
||||
const fileNameWithoutExt = fileName.replace(/\.[^/.]+$/, '');
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Container } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { assertExists, sha } from '@blocksuite/global/utils';
|
||||
import type { Store, Workspace } from '@blocksuite/store';
|
||||
import { extMimeMap, Job } from '@blocksuite/store';
|
||||
import { extMimeMap, Transformer } from '@blocksuite/store';
|
||||
|
||||
import { defaultBlockMarkdownAdapterMatchers } from '../adapters/index.js';
|
||||
import { inlineDeltaToMarkdownAdapterMatchers } from '../adapters/markdown/delta-converter/inline-delta.js';
|
||||
@@ -50,7 +50,7 @@ type ImportMarkdownZipOptions = {
|
||||
* @returns A Promise that resolves when the export is complete
|
||||
*/
|
||||
async function exportDoc(doc: Store) {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: doc.schema,
|
||||
blobCRUD: doc.blobSync,
|
||||
docCRUD: {
|
||||
@@ -109,7 +109,7 @@ async function importMarkdownToBlock({
|
||||
markdown,
|
||||
blockId,
|
||||
}: ImportMarkdownToBlockOptions) {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: doc.schema,
|
||||
blobCRUD: doc.blobSync,
|
||||
docCRUD: {
|
||||
@@ -154,7 +154,7 @@ async function importMarkdownToDoc({
|
||||
markdown,
|
||||
fileName,
|
||||
}: ImportMarkdownToDocOptions) {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
@@ -218,7 +218,7 @@ async function importMarkdownZip({
|
||||
await Promise.all(
|
||||
markdownBlobs.map(async ([fileName, blob]) => {
|
||||
const fileNameWithoutExt = fileName.replace(/\.[^/.]+$/, '');
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -8,10 +8,14 @@ import type {
|
||||
} from '@blocksuite/affine-model';
|
||||
import { DEFAULT_IMAGE_PROXY_ENDPOINT } from '@blocksuite/affine-shared/consts';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { DeltaOperation, DocMeta, JobMiddleware } from '@blocksuite/store';
|
||||
import type {
|
||||
DeltaOperation,
|
||||
DocMeta,
|
||||
TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
export const replaceIdMiddleware =
|
||||
(idGenerator: () => string): JobMiddleware =>
|
||||
(idGenerator: () => string): TransformerMiddleware =>
|
||||
({ slots, docCRUD }) => {
|
||||
const idMap = new Map<string, string>();
|
||||
slots.afterImport.on(payload => {
|
||||
@@ -202,7 +206,7 @@ export const replaceIdMiddleware =
|
||||
|
||||
export const customImageProxyMiddleware = (
|
||||
imageProxyURL: string
|
||||
): JobMiddleware => {
|
||||
): TransformerMiddleware => {
|
||||
return ({ adapterConfigs }) => {
|
||||
adapterConfigs.set('imageProxy', imageProxyURL);
|
||||
};
|
||||
@@ -211,7 +215,7 @@ export const customImageProxyMiddleware = (
|
||||
const customDocLinkBaseUrlMiddleware = (
|
||||
baseUrl: string,
|
||||
collectionId: string
|
||||
): JobMiddleware => {
|
||||
): TransformerMiddleware => {
|
||||
return ({ adapterConfigs }) => {
|
||||
const docLinkBaseUrl = baseUrl
|
||||
? `${baseUrl}/workspace/${collectionId}`
|
||||
@@ -221,7 +225,7 @@ const customDocLinkBaseUrlMiddleware = (
|
||||
};
|
||||
|
||||
export const titleMiddleware =
|
||||
(metas: DocMeta[]): JobMiddleware =>
|
||||
(metas: DocMeta[]): TransformerMiddleware =>
|
||||
({ slots, adapterConfigs }) => {
|
||||
slots.beforeExport.on(() => {
|
||||
for (const meta of metas) {
|
||||
@@ -273,13 +277,13 @@ export const defaultImageProxyMiddleware =
|
||||
defaultImageProxyMiddlewarBuilder.get();
|
||||
|
||||
export const embedSyncedDocMiddleware =
|
||||
(type: 'content'): JobMiddleware =>
|
||||
(type: 'content'): TransformerMiddleware =>
|
||||
({ adapterConfigs }) => {
|
||||
adapterConfigs.set('embedSyncedDocExportType', type);
|
||||
};
|
||||
|
||||
export const fileNameMiddleware =
|
||||
(fileName?: string): JobMiddleware =>
|
||||
(fileName?: string): TransformerMiddleware =>
|
||||
({ slots }) => {
|
||||
slots.beforeImport.on(payload => {
|
||||
if (payload.type !== 'page') {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
import { sha } from '@blocksuite/global/utils';
|
||||
import { extMimeMap, Job, type Workspace } from '@blocksuite/store';
|
||||
import { extMimeMap, Transformer, type Workspace } from '@blocksuite/store';
|
||||
|
||||
import { defaultBlockNotionHtmlAdapterMatchers } from '../adapters/notion-html/block-matcher.js';
|
||||
import { notionHtmlInlineToDeltaMatchers } from '../adapters/notion-html/delta-converter/html-inline.js';
|
||||
@@ -117,7 +117,7 @@ async function importNotionZip({
|
||||
pendingAssets.set(key, new File([blob], fileName, { type: mime }));
|
||||
}
|
||||
const pagePromises = Array.from(pagePaths).map(async path => {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { sha } from '@blocksuite/global/utils';
|
||||
import type { DocSnapshot, Store, Workspace } from '@blocksuite/store';
|
||||
import { extMimeMap, getAssetName, Job } from '@blocksuite/store';
|
||||
import { extMimeMap, getAssetName, Transformer } from '@blocksuite/store';
|
||||
|
||||
import { download, Unzip, Zip } from '../transformers/utils.js';
|
||||
import { replaceIdMiddleware, titleMiddleware } from './middlewares.js';
|
||||
|
||||
async function exportDocs(collection: Workspace, docs: Store[]) {
|
||||
const zip = new Zip();
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
@@ -77,7 +77,7 @@ async function importDocs(collection: Workspace, imported: Blob) {
|
||||
}
|
||||
}
|
||||
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -58,8 +58,8 @@ import {
|
||||
type BlockSnapshot,
|
||||
BlockSnapshotSchema,
|
||||
fromJSON,
|
||||
Job,
|
||||
type SliceSnapshot,
|
||||
Transformer,
|
||||
} from '@blocksuite/store';
|
||||
import DOMPurify from 'dompurify';
|
||||
import * as Y from 'yjs';
|
||||
@@ -369,7 +369,7 @@ export class EdgelessClipboardController extends PageClipboard {
|
||||
if (mayBeSurfaceDataJson !== undefined) {
|
||||
const elementsRawData = JSON.parse(mayBeSurfaceDataJson);
|
||||
const { snapshot, blobs } = elementsRawData;
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: this.std.workspace.schema,
|
||||
blobCRUD: this.std.workspace.blobSync,
|
||||
docCRUD: {
|
||||
@@ -1373,7 +1373,7 @@ export async function prepareClipboardData(
|
||||
selectedAll: BlockSuite.EdgelessModel[],
|
||||
std: BlockStdScope
|
||||
) {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: std.workspace.schema,
|
||||
blobCRUD: std.workspace.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -15,8 +15,8 @@ import {
|
||||
type BlockSnapshot,
|
||||
type DocSnapshot,
|
||||
DocSnapshotSchema,
|
||||
Job,
|
||||
type SnapshotNode,
|
||||
Transformer,
|
||||
} from '@blocksuite/store';
|
||||
import type * as Y from 'yjs';
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ export class TemplateJob {
|
||||
|
||||
private _template: DocSnapshot | null = null;
|
||||
|
||||
job: Job;
|
||||
job: Transformer;
|
||||
|
||||
model: SurfaceBlockModel;
|
||||
|
||||
@@ -90,7 +90,7 @@ export class TemplateJob {
|
||||
type: TemplateType;
|
||||
|
||||
constructor({ model, type, middlewares }: TemplateJobConfig) {
|
||||
this.job = new Job({
|
||||
this.job = new Transformer({
|
||||
schema: model.doc.workspace.schema,
|
||||
blobCRUD: model.doc.workspace.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
isGfxGroupCompatibleModel,
|
||||
type SerializedElement,
|
||||
} from '@blocksuite/block-std/gfx';
|
||||
import { type BlockSnapshot, Job } from '@blocksuite/store';
|
||||
import { type BlockSnapshot, Transformer } from '@blocksuite/store';
|
||||
|
||||
/**
|
||||
* return all elements in the tree of the elements
|
||||
@@ -39,7 +39,7 @@ export function getSortedCloneElements(elements: GfxModel[]) {
|
||||
|
||||
export function prepareCloneData(elements: GfxModel[], std: BlockStdScope) {
|
||||
elements = sortEdgelessElements(elements);
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: std.workspace.schema,
|
||||
blobCRUD: std.workspace.blobSync,
|
||||
docCRUD: {
|
||||
@@ -58,7 +58,7 @@ export function prepareCloneData(elements: GfxModel[], std: BlockStdScope) {
|
||||
export function serializeElement(
|
||||
element: GfxModel,
|
||||
elements: GfxModel[],
|
||||
job: Job
|
||||
job: Transformer
|
||||
) {
|
||||
if (element instanceof GfxBlockElementModel) {
|
||||
const snapshot = job.blockToSnapshot(element);
|
||||
|
||||
@@ -3,10 +3,10 @@ import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import type {
|
||||
BaseAdapter,
|
||||
BlockSnapshot,
|
||||
Job,
|
||||
JobMiddleware,
|
||||
Slice,
|
||||
Store,
|
||||
Transformer,
|
||||
TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
import DOMPurify from 'dompurify';
|
||||
import type { RootContentMap } from 'hast';
|
||||
@@ -17,8 +17,8 @@ import { unified } from 'unified';
|
||||
import { LifeCycleWatcher } from '../extension/index.js';
|
||||
|
||||
type AdapterConstructor<T extends BaseAdapter> =
|
||||
| { new (job: Job): T }
|
||||
| (new (job: Job, provider: ServiceProvider) => T);
|
||||
| { new (job: Transformer): T }
|
||||
| (new (job: Transformer, provider: ServiceProvider) => T);
|
||||
|
||||
type AdapterMap = Map<
|
||||
string,
|
||||
@@ -155,7 +155,7 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
return null;
|
||||
};
|
||||
|
||||
private _jobMiddlewares: JobMiddleware[] = [];
|
||||
private _jobMiddlewares: TransformerMiddleware[] = [];
|
||||
|
||||
copy = async (slice: Slice) => {
|
||||
return this.copySlice(slice);
|
||||
@@ -257,11 +257,11 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
this._adapterMap.delete(mimeType);
|
||||
};
|
||||
|
||||
unuse = (middleware: JobMiddleware) => {
|
||||
unuse = (middleware: TransformerMiddleware) => {
|
||||
this._jobMiddlewares = this._jobMiddlewares.filter(m => m !== middleware);
|
||||
};
|
||||
|
||||
use = (middleware: JobMiddleware) => {
|
||||
use = (middleware: TransformerMiddleware) => {
|
||||
this._jobMiddlewares.push(middleware);
|
||||
};
|
||||
|
||||
@@ -285,7 +285,7 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
}
|
||||
|
||||
private _getJob() {
|
||||
return this.std.getJob(this._jobMiddlewares);
|
||||
return this.std.getTransformer(this._jobMiddlewares);
|
||||
}
|
||||
|
||||
readFromClipboard(clipboardData: DataTransfer) {
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Container, type ServiceProvider } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import {
|
||||
type ExtensionType,
|
||||
Job,
|
||||
type JobMiddleware,
|
||||
type Store,
|
||||
StoreSelectionExtension,
|
||||
Transformer,
|
||||
type TransformerMiddleware,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
import { Clipboard } from '../clipboard/index.js';
|
||||
@@ -161,8 +161,8 @@ export class BlockStdScope {
|
||||
return this.getOptional(BlockViewIdentifier(flavour));
|
||||
}
|
||||
|
||||
getJob(middlewares: JobMiddleware[] = []) {
|
||||
return new Job({
|
||||
getTransformer(middlewares: TransformerMiddleware[] = []) {
|
||||
return new Transformer({
|
||||
schema: this.workspace.schema,
|
||||
blobCRUD: this.workspace.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { BlockSuiteError } from '@blocksuite/global/exceptions';
|
||||
|
||||
import type { DraftModel, Store } from '../model/index.js';
|
||||
import type { AssetsManager } from '../transformer/assets.js';
|
||||
import type { Job, Slice } from '../transformer/index.js';
|
||||
import type { Slice, Transformer } from '../transformer/index.js';
|
||||
import type {
|
||||
BlockSnapshot,
|
||||
DocSnapshot,
|
||||
@@ -62,13 +62,13 @@ export function wrapFakeNote(snapshot: SliceSnapshot) {
|
||||
}
|
||||
|
||||
export abstract class BaseAdapter<AdapterTarget = unknown> {
|
||||
job: Job;
|
||||
job: Transformer;
|
||||
|
||||
get configs() {
|
||||
return this.job.adapterConfigs;
|
||||
}
|
||||
|
||||
constructor(job: Job) {
|
||||
constructor(job: Transformer) {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
|
||||
import type { BlobCRUD } from './type.js';
|
||||
import type { BlobCRUD } from './type';
|
||||
|
||||
type AssetsManagerConfig = {
|
||||
blob: BlobCRUD;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { BlockModel } from '../model/block/block-model.js';
|
||||
import type { DraftModel } from '../model/block/draft.js';
|
||||
import type { BlockModel } from '../model/block/block-model';
|
||||
import type { DraftModel } from '../model/block/draft';
|
||||
import {
|
||||
type InternalPrimitives,
|
||||
internalPrimitives,
|
||||
} from '../model/block/zod.js';
|
||||
import type { AssetsManager } from './assets.js';
|
||||
import { fromJSON, toJSON } from './json.js';
|
||||
import type { BlockSnapshot } from './type.js';
|
||||
} from '../model/block/zod';
|
||||
import type { AssetsManager } from './assets';
|
||||
import { fromJSON, toJSON } from './json';
|
||||
import type { BlockSnapshot } from './type';
|
||||
|
||||
export type BlockSnapshotLeaf = Pick<
|
||||
BlockSnapshot,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export * from './assets.js';
|
||||
export * from './base.js';
|
||||
export * from './job.js';
|
||||
export * from './json.js';
|
||||
export * from './middleware.js';
|
||||
export * from './slice.js';
|
||||
export * from './type.js';
|
||||
export * from './assets';
|
||||
export * from './base';
|
||||
export * from './json';
|
||||
export * from './middleware';
|
||||
export * from './slice';
|
||||
export * from './transformer';
|
||||
export * from './type';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NATIVE_UNIQ_IDENTIFIER, TEXT_UNIQ_IDENTIFIER } from '../consts.js';
|
||||
import { Boxed } from '../reactive/boxed.js';
|
||||
import { isPureObject } from '../reactive/index.js';
|
||||
import { Text } from '../reactive/text.js';
|
||||
import { NATIVE_UNIQ_IDENTIFIER, TEXT_UNIQ_IDENTIFIER } from '../consts';
|
||||
import { Boxed } from '../reactive/boxed';
|
||||
import { isPureObject } from '../reactive/index';
|
||||
import { Text } from '../reactive/text';
|
||||
|
||||
export function toJSON(value: unknown): unknown {
|
||||
if (value instanceof Boxed) {
|
||||
|
||||
@@ -71,18 +71,20 @@ export type FinalPayload =
|
||||
type: 'info';
|
||||
};
|
||||
|
||||
export type JobSlots = {
|
||||
export type TransformerSlots = {
|
||||
beforeImport: Slot<BeforeImportPayload>;
|
||||
afterImport: Slot<FinalPayload>;
|
||||
beforeExport: Slot<BeforeExportPayload>;
|
||||
afterExport: Slot<FinalPayload>;
|
||||
};
|
||||
|
||||
type JobMiddlewareOptions = {
|
||||
type TransformerMiddlewareOptions = {
|
||||
assetsManager: AssetsManager;
|
||||
slots: JobSlots;
|
||||
slots: TransformerSlots;
|
||||
docCRUD: DocCRUD;
|
||||
adapterConfigs: Map<string, string>;
|
||||
};
|
||||
|
||||
export type JobMiddleware = (options: JobMiddlewareOptions) => void;
|
||||
export type TransformerMiddleware = (
|
||||
options: TransformerMiddlewareOptions
|
||||
) => void;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { DraftModel, Store } from '../model/index.js';
|
||||
import type { DraftModel, Store } from '../model/index';
|
||||
|
||||
type SliceData = {
|
||||
content: DraftModel[];
|
||||
|
||||
@@ -14,8 +14,8 @@ import type {
|
||||
BeforeExportPayload,
|
||||
BeforeImportPayload,
|
||||
FinalPayload,
|
||||
JobMiddleware,
|
||||
JobSlots,
|
||||
TransformerMiddleware,
|
||||
TransformerSlots,
|
||||
} from './middleware.js';
|
||||
import { Slice } from './slice.js';
|
||||
import type {
|
||||
@@ -31,11 +31,11 @@ import {
|
||||
SliceSnapshotSchema,
|
||||
} from './type.js';
|
||||
|
||||
export type JobConfig = {
|
||||
export type TransformerOptions = {
|
||||
schema: Schema;
|
||||
blobCRUD: BlobCRUD;
|
||||
docCRUD: DocCRUD;
|
||||
middlewares?: JobMiddleware[];
|
||||
middlewares?: TransformerMiddleware[];
|
||||
};
|
||||
|
||||
interface FlatSnapshot {
|
||||
@@ -53,7 +53,7 @@ interface DraftBlockTreeNode {
|
||||
// The number of blocks to insert in one batch
|
||||
const BATCH_SIZE = 100;
|
||||
|
||||
export class Job {
|
||||
export class Transformer {
|
||||
private readonly _adapterConfigs = new Map<string, string>();
|
||||
|
||||
private readonly _assetsManager: AssetsManager;
|
||||
@@ -62,7 +62,7 @@ export class Job {
|
||||
|
||||
private readonly _docCRUD: DocCRUD;
|
||||
|
||||
private readonly _slots: JobSlots = {
|
||||
private readonly _slots: TransformerSlots = {
|
||||
beforeImport: new Slot<BeforeImportPayload>(),
|
||||
afterImport: new Slot<FinalPayload>(),
|
||||
beforeExport: new Slot<BeforeExportPayload>(),
|
||||
@@ -338,7 +338,12 @@ export class Job {
|
||||
return this._docCRUD;
|
||||
}
|
||||
|
||||
constructor({ blobCRUD, schema, docCRUD, middlewares = [] }: JobConfig) {
|
||||
constructor({
|
||||
blobCRUD,
|
||||
schema,
|
||||
docCRUD,
|
||||
middlewares = [],
|
||||
}: TransformerOptions) {
|
||||
this._assetsManager = new AssetsManager({ blob: blobCRUD });
|
||||
this._schema = schema;
|
||||
this._docCRUD = docCRUD;
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { Store } from '../model/store/store.js';
|
||||
import type { DocMeta, DocsPropertiesMeta } from '../model/workspace-meta.js';
|
||||
import type { Store } from '../model/store/store';
|
||||
import type { DocMeta, DocsPropertiesMeta } from '../model/workspace-meta';
|
||||
|
||||
export type BlockSnapshot = {
|
||||
type: 'block';
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from '@blocksuite/blocks';
|
||||
import { WithDisposable } from '@blocksuite/global/utils';
|
||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import { type DocSnapshot, Job } from '@blocksuite/store';
|
||||
import { type DocSnapshot, Transformer } from '@blocksuite/store';
|
||||
import { effect } from '@preact/signals-core';
|
||||
import type SlTabPanel from '@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js';
|
||||
import { css, html, type PropertyValues } from 'lit';
|
||||
@@ -101,7 +101,7 @@ export class AdaptersPanel extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
|
||||
private _createJob() {
|
||||
return new Job({
|
||||
return new Transformer({
|
||||
schema: this.doc.collection.schema,
|
||||
blobCRUD: this.doc.collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -50,7 +50,7 @@ import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import type { SerializedXYWH } from '@blocksuite/global/utils';
|
||||
import type { DeltaInsert } from '@blocksuite/inline/types';
|
||||
import { AffineEditorContainer, type CommentPanel } from '@blocksuite/presets';
|
||||
import { Job, Text, type Workspace } from '@blocksuite/store';
|
||||
import { Text, Transformer, type Workspace } from '@blocksuite/store';
|
||||
import type { SlDropdown } from '@shoelace-style/shoelace';
|
||||
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js';
|
||||
import { css, html } from 'lit';
|
||||
@@ -241,7 +241,7 @@ export class StarterDebugMenu extends ShadowlessElement {
|
||||
|
||||
private async _exportFile(config: AdapterConfig) {
|
||||
const doc = this.editor.doc;
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: this.collection.schema,
|
||||
blobCRUD: this.collection.blobSync,
|
||||
docCRUD: {
|
||||
@@ -442,7 +442,7 @@ export class StarterDebugMenu extends ShadowlessElement {
|
||||
multiple: false,
|
||||
});
|
||||
if (!file) return;
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: this.collection.schema,
|
||||
blobCRUD: this.collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
4
blocksuite/playground/apps/env.d.ts
vendored
4
blocksuite/playground/apps/env.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
import type { EditorHost } from '@blocksuite/block-std';
|
||||
import type { TestUtils } from '@blocksuite/blocks';
|
||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import type { BlockSchema, Blocks, Workspace, Job } from '@blocksuite/store';
|
||||
import type { BlockSchema, Blocks, Workspace, Transformer } from '@blocksuite/store';
|
||||
import type { z } from 'zod';
|
||||
import type * as Y from 'yjs';
|
||||
|
||||
@@ -17,7 +17,7 @@ declare global {
|
||||
doc: Blocks;
|
||||
collection: Workspace;
|
||||
blockSchemas: z.infer<typeof BlockSchema>[];
|
||||
job: Job;
|
||||
job: Transformer;
|
||||
Y: typeof Y;
|
||||
std: typeof std;
|
||||
testUtils: TestUtils;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AffineSchemas, SpecProvider, TestUtils } from '@blocksuite/blocks';
|
||||
import type { BlockSuiteFlags } from '@blocksuite/global/types';
|
||||
import { Job, nanoid, Schema } from '@blocksuite/store';
|
||||
import { nanoid, Schema, Transformer } from '@blocksuite/store';
|
||||
import {
|
||||
createAutoIncrementIdGenerator,
|
||||
type DocCollectionOptions,
|
||||
@@ -81,7 +81,7 @@ export function createStarterDocCollection() {
|
||||
// debug info
|
||||
window.collection = collection;
|
||||
window.blockSchemas = AffineSchemas;
|
||||
window.job = new Job({
|
||||
window.job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { replaceIdMiddleware } from '@blocksuite/blocks';
|
||||
import { type DocSnapshot, Job, type Workspace } from '@blocksuite/store';
|
||||
import {
|
||||
type DocSnapshot,
|
||||
Transformer,
|
||||
type Workspace,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
export async function importFromSnapshot(
|
||||
collection: Workspace,
|
||||
snapshot: DocSnapshot
|
||||
) {
|
||||
const job = new Job({
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { effects as blocksEffects } from '@blocksuite/blocks/effects';
|
||||
import type { Job, Store } from '@blocksuite/store';
|
||||
import type { Store, Transformer } from '@blocksuite/store';
|
||||
|
||||
import { effects } from '../../effects.js';
|
||||
|
||||
@@ -113,11 +113,11 @@ declare global {
|
||||
const editor: AffineEditorContainer;
|
||||
const doc: Store;
|
||||
const collection: TestWorkspace;
|
||||
const job: Job;
|
||||
const job: Transformer;
|
||||
interface Window {
|
||||
editor: AffineEditorContainer;
|
||||
doc: Store;
|
||||
job: Job;
|
||||
job: Transformer;
|
||||
collection: TestWorkspace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,12 @@ import type {
|
||||
} from '@blocksuite/block-std';
|
||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import type { StarterDebugMenu } from '@playground/apps/_common/components/starter-debug-menu.js';
|
||||
import type { BlockModel, Blocks, Job, Workspace } from '@store/index.js';
|
||||
import type {
|
||||
BlockModel,
|
||||
Blocks,
|
||||
Transformer,
|
||||
Workspace,
|
||||
} from '@store/index.js';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -43,6 +48,6 @@ declare global {
|
||||
editor: AffineEditorContainer;
|
||||
host: EditorHost;
|
||||
testUtils: TestUtils;
|
||||
job: Job;
|
||||
job: Transformer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user