Skip to content

Commit

Permalink
chore: each block maintain its own adapter extension
Browse files Browse the repository at this point in the history
  • Loading branch information
donteatfriedrice committed Dec 20, 2024
1 parent 30200ff commit 03dd354
Show file tree
Hide file tree
Showing 43 changed files with 264 additions and 264 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { EmbedFigmaBlockHtmlAdapterExtension } from './html.js';
import { EmbedFigmaMarkdownAdapterExtension } from './markdown.js';
import { EmbedFigmaBlockPlainTextAdapterExtension } from './plain-text.js';

export const EmbedFigmaBlockAdapterExtensions: ExtensionType[] = [
EmbedFigmaBlockHtmlAdapterExtension,
EmbedFigmaMarkdownAdapterExtension,
EmbedFigmaBlockPlainTextAdapterExtension,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { EmbedFigmaBlockAdapterExtensions } from './adapters/extension.js';
import { EmbedFigmaBlockService } from './embed-figma-service.js';

export const EmbedFigmaBlockSpec: ExtensionType[] = [
Expand All @@ -15,4 +16,5 @@ export const EmbedFigmaBlockSpec: ExtensionType[] = [
? literal`affine-embed-edgeless-figma-block`
: literal`affine-embed-figma-block`;
}),
];
EmbedFigmaBlockAdapterExtensions,
].flat();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { EmbedGithubBlockHtmlAdapterExtension } from './html.js';
import { EmbedGithubMarkdownAdapterExtension } from './markdown.js';
import { EmbedGithubBlockPlainTextAdapterExtension } from './plain-text.js';

export const EmbedGithubBlockAdapterExtensions: ExtensionType[] = [
EmbedGithubBlockHtmlAdapterExtension,
EmbedGithubMarkdownAdapterExtension,
EmbedGithubBlockPlainTextAdapterExtension,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { EmbedGithubBlockAdapterExtensions } from './adapters/extension.js';
import { EmbedGithubBlockService } from './embed-github-service.js';

export const EmbedGithubBlockSpec: ExtensionType[] = [
Expand All @@ -15,4 +16,5 @@ export const EmbedGithubBlockSpec: ExtensionType[] = [
? literal`affine-embed-edgeless-github-block`
: literal`affine-embed-github-block`;
}),
];
EmbedGithubBlockAdapterExtensions,
].flat();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { EmbedLinkedDocHtmlAdapterExtension } from './html.js';
import { EmbedLinkedDocMarkdownAdapterExtension } from './markdown.js';
import { EmbedLinkedDocBlockPlainTextAdapterExtension } from './plain-text.js';

export const EmbedLinkedDocBlockAdapterExtensions: ExtensionType[] = [
EmbedLinkedDocHtmlAdapterExtension,
EmbedLinkedDocMarkdownAdapterExtension,
EmbedLinkedDocBlockPlainTextAdapterExtension,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { EmbedLinkedDocBlockAdapterExtensions } from './adapters/extension.js';
import { commands } from './commands/index.js';

export const EmbedLinkedDocBlockSpec: ExtensionType[] = [
Expand All @@ -14,4 +15,5 @@ export const EmbedLinkedDocBlockSpec: ExtensionType[] = [
? literal`affine-embed-edgeless-linked-doc-block`
: literal`affine-embed-linked-doc-block`;
}),
];
EmbedLinkedDocBlockAdapterExtensions,
].flat();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { EmbedLoomBlockHtmlAdapterExtension } from './html.js';
import { EmbedLoomMarkdownAdapterExtension } from './markdown.js';
import { EmbedLoomBlockPlainTextAdapterExtension } from './plain-text.js';

export const EmbedLoomBlockAdapterExtensions: ExtensionType[] = [
EmbedLoomBlockHtmlAdapterExtension,
EmbedLoomMarkdownAdapterExtension,
EmbedLoomBlockPlainTextAdapterExtension,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { EmbedLoomBlockAdapterExtensions } from './adapters/extension.js';
import { EmbedLoomBlockService } from './embed-loom-service.js';

export const EmbedLoomBlockSpec: ExtensionType[] = [
Expand All @@ -15,4 +16,5 @@ export const EmbedLoomBlockSpec: ExtensionType[] = [
? literal`affine-embed-edgeless-loom-block`
: literal`affine-embed-loom-block`;
}),
];
EmbedLoomBlockAdapterExtensions,
].flat();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { EmbedSyncedDocBlockHtmlAdapterExtension } from './html.js';
import { EmbedSyncedDocBlockMarkdownAdapterExtension } from './markdown.js';
import { EmbedSyncedDocBlockPlainTextAdapterExtension } from './plain-text.js';

export const EmbedSyncedDocBlockAdapterExtensions: ExtensionType[] = [
EmbedSyncedDocBlockHtmlAdapterExtension,
EmbedSyncedDocBlockMarkdownAdapterExtension,
EmbedSyncedDocBlockPlainTextAdapterExtension,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { EmbedSyncedDocBlockAdapterExtensions } from './adapters/extension.js';
import { EmbedSyncedDocBlockService } from './embed-synced-doc-service.js';

export const EmbedSyncedDocBlockSpec: ExtensionType[] = [
Expand All @@ -15,4 +16,5 @@ export const EmbedSyncedDocBlockSpec: ExtensionType[] = [
? literal`affine-embed-edgeless-synced-doc-block`
: literal`affine-embed-synced-doc-block`;
}),
];
EmbedSyncedDocBlockAdapterExtensions,
].flat();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { EmbedYoutubeBlockHtmlAdapterExtension } from './html.js';
import { EmbedYoutubeMarkdownAdapterExtension } from './markdown.js';
import { EmbedYoutubeBlockPlainTextAdapterExtension } from './plain-text.js';

export const EmbedYoutubeBlockAdapterExtensions: ExtensionType[] = [
EmbedYoutubeBlockHtmlAdapterExtension,
EmbedYoutubeMarkdownAdapterExtension,
EmbedYoutubeBlockPlainTextAdapterExtension,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { EmbedYoutubeBlockAdapterExtensions } from './adapters/extension.js';
import { EmbedYoutubeBlockService } from './embed-youtube-service.js';

export const EmbedYoutubeBlockSpec: ExtensionType[] = [
Expand All @@ -15,4 +16,5 @@ export const EmbedYoutubeBlockSpec: ExtensionType[] = [
? literal`affine-embed-edgeless-youtube-block`
: literal`affine-embed-youtube-block`;
}),
];
EmbedYoutubeBlockAdapterExtensions,
].flat();
13 changes: 13 additions & 0 deletions blocksuite/affine/block-list/src/adapters/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { ListBlockHtmlAdapterExtension } from './html.js';
import { ListBlockMarkdownAdapterExtension } from './markdown.js';
import { ListBlockNotionHtmlAdapterExtension } from './notion-html.js';
import { ListBlockPlainTextAdapterExtension } from './plain-text.js';

export const ListBlockAdapterExtensions: ExtensionType[] = [
ListBlockHtmlAdapterExtension,
ListBlockMarkdownAdapterExtension,
ListBlockPlainTextAdapterExtension,
ListBlockNotionHtmlAdapterExtension,
];
4 changes: 3 additions & 1 deletion blocksuite/affine/block-list/src/list-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { ListBlockAdapterExtensions } from './adapters/extension.js';
import { commands } from './commands/index.js';
import { ListKeymapExtension, ListTextKeymapExtension } from './list-keymap.js';
import { ListBlockService, ListDragHandleOption } from './list-service.js';
Expand All @@ -18,4 +19,5 @@ export const ListBlockSpec: ExtensionType[] = [
ListKeymapExtension,
ListTextKeymapExtension,
ListDragHandleOption,
];
ListBlockAdapterExtensions,
].flat();
13 changes: 13 additions & 0 deletions blocksuite/affine/block-paragraph/src/adapters/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { ParagraphBlockHtmlAdapterExtension } from './html.js';
import { ParagraphBlockMarkdownAdapterExtension } from './markdown.js';
import { ParagraphBlockNotionHtmlAdapterExtension } from './notion-html.js';
import { ParagraphBlockPlainTextAdapterExtension } from './plain-text.js';

export const ParagraphBlockAdapterExtensions: ExtensionType[] = [
ParagraphBlockHtmlAdapterExtension,
ParagraphBlockMarkdownAdapterExtension,
ParagraphBlockPlainTextAdapterExtension,
ParagraphBlockNotionHtmlAdapterExtension,
];
4 changes: 3 additions & 1 deletion blocksuite/affine/block-paragraph/src/paragraph-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@blocksuite/block-std';
import { literal } from 'lit/static-html.js';

import { ParagraphBlockAdapterExtensions } from './adapters/extension.js';
import { commands } from './commands/index.js';
import { ParagraphDragHandleOption } from './paragraph-drag-extension.js';
import {
Expand All @@ -22,4 +23,5 @@ export const ParagraphBlockSpec: ExtensionType[] = [
ParagraphTextKeymapExtension,
ParagraphKeymapExtension,
ParagraphDragHandleOption,
];
ParagraphBlockAdapterExtensions,
].flat();
2 changes: 0 additions & 2 deletions blocksuite/affine/block-surface/src/adapters/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SurfaceBlockHtmlAdapterExtension } from './html-adapter/html.js';
import {
EdgelessSurfaceBlockMarkdownAdapterExtension,
SurfaceBlockMarkdownAdapterExtension,
Expand All @@ -11,7 +10,6 @@ import {
export const SurfaceBlockAdapterExtensions = [
SurfaceBlockPlainTextAdapterExtension,
SurfaceBlockMarkdownAdapterExtension,
SurfaceBlockHtmlAdapterExtension,
];

export const EdgelessSurfaceBlockAdapterExtensions = [
Expand Down
11 changes: 0 additions & 11 deletions blocksuite/blocks/src/_common/adapters/extension.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import type { ExtensionType } from '@blocksuite/block-std';

import { AttachmentAdapterFactoryExtension } from './attachment.js';
import { BlockHtmlAdapterExtensions } from './html-adapter/block-matcher.js';
import { HtmlAdapterFactoryExtension } from './html-adapter/html.js';
import { ImageAdapterFactoryExtension } from './image.js';
import { BlockMarkdownAdapterExtensions } from './markdown/block-matcher.js';
import { MarkdownAdapterFactoryExtension } from './markdown/markdown.js';
import { MixTextAdapterFactoryExtension } from './mix-text.js';
import { BlockNotionHtmlAdapterExtensions } from './notion-html/block-matcher.js';
import { NotionHtmlAdapterFactoryExtension } from './notion-html/notion-html.js';
import { NotionTextAdapterFactoryExtension } from './notion-text.js';
import { BlockPlainTextAdapterExtensions } from './plain-text/block-matcher.js';
import { PlainTextAdapterFactoryExtension } from './plain-text/plain-text.js';

export const AdapterFactoryExtensions: ExtensionType[] = [
Expand All @@ -23,10 +19,3 @@ export const AdapterFactoryExtensions: ExtensionType[] = [
NotionHtmlAdapterFactoryExtension,
MixTextAdapterFactoryExtension,
];

export const BlockAdapterMatcherExtensions: ExtensionType[] = [
BlockPlainTextAdapterExtensions,
BlockMarkdownAdapterExtensions,
BlockHtmlAdapterExtensions,
BlockNotionHtmlAdapterExtensions,
].flat();
Original file line number Diff line number Diff line change
@@ -1,51 +1,20 @@
import {
EmbedFigmaBlockHtmlAdapterExtension,
embedFigmaBlockHtmlAdapterMatcher,
EmbedGithubBlockHtmlAdapterExtension,
embedGithubBlockHtmlAdapterMatcher,
embedLinkedDocBlockHtmlAdapterMatcher,
EmbedLinkedDocHtmlAdapterExtension,
EmbedLoomBlockHtmlAdapterExtension,
embedLoomBlockHtmlAdapterMatcher,
EmbedSyncedDocBlockHtmlAdapterExtension,
embedSyncedDocBlockHtmlAdapterMatcher,
EmbedYoutubeBlockHtmlAdapterExtension,
embedYoutubeBlockHtmlAdapterMatcher,
} from '@blocksuite/affine-block-embed';
import {
ListBlockHtmlAdapterExtension,
listBlockHtmlAdapterMatcher,
} from '@blocksuite/affine-block-list';
import {
ParagraphBlockHtmlAdapterExtension,
paragraphBlockHtmlAdapterMatcher,
} from '@blocksuite/affine-block-paragraph';
import type { ExtensionType } from '@blocksuite/block-std';
import { listBlockHtmlAdapterMatcher } from '@blocksuite/affine-block-list';
import { paragraphBlockHtmlAdapterMatcher } from '@blocksuite/affine-block-paragraph';

import {
BookmarkBlockHtmlAdapterExtension,
bookmarkBlockHtmlAdapterMatcher,
} from '../../../bookmark-block/adapters/html.js';
import {
CodeBlockHtmlAdapterExtension,
codeBlockHtmlAdapterMatcher,
} from '../../../code-block/adapters/html.js';
import {
DatabaseBlockHtmlAdapterExtension,
databaseBlockHtmlAdapterMatcher,
} from '../../../database-block/adapters/html.js';
import {
DividerBlockHtmlAdapterExtension,
dividerBlockHtmlAdapterMatcher,
} from '../../../divider-block/adapters/html.js';
import {
ImageBlockHtmlAdapterExtension,
imageBlockHtmlAdapterMatcher,
} from '../../../image-block/adapters/html.js';
import {
RootBlockHtmlAdapterExtension,
rootBlockHtmlAdapterMatcher,
} from '../../../root-block/adapters/html.js';
import { bookmarkBlockHtmlAdapterMatcher } from '../../../bookmark-block/adapters/html.js';
import { codeBlockHtmlAdapterMatcher } from '../../../code-block/adapters/html.js';
import { databaseBlockHtmlAdapterMatcher } from '../../../database-block/adapters/html.js';
import { dividerBlockHtmlAdapterMatcher } from '../../../divider-block/adapters/html.js';
import { imageBlockHtmlAdapterMatcher } from '../../../image-block/adapters/html.js';
import { rootBlockHtmlAdapterMatcher } from '../../../root-block/adapters/html.js';

export const defaultBlockHtmlAdapterMatchers = [
listBlockHtmlAdapterMatcher,
Expand All @@ -63,20 +32,3 @@ export const defaultBlockHtmlAdapterMatchers = [
embedLinkedDocBlockHtmlAdapterMatcher,
embedSyncedDocBlockHtmlAdapterMatcher,
];

export const BlockHtmlAdapterExtensions: ExtensionType[] = [
ListBlockHtmlAdapterExtension,
ParagraphBlockHtmlAdapterExtension,
CodeBlockHtmlAdapterExtension,
DividerBlockHtmlAdapterExtension,
ImageBlockHtmlAdapterExtension,
RootBlockHtmlAdapterExtension,
EmbedYoutubeBlockHtmlAdapterExtension,
EmbedFigmaBlockHtmlAdapterExtension,
EmbedLoomBlockHtmlAdapterExtension,
EmbedGithubBlockHtmlAdapterExtension,
BookmarkBlockHtmlAdapterExtension,
DatabaseBlockHtmlAdapterExtension,
EmbedLinkedDocHtmlAdapterExtension,
EmbedSyncedDocBlockHtmlAdapterExtension,
];
5 changes: 1 addition & 4 deletions blocksuite/blocks/src/_common/adapters/html-adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export {
BlockHtmlAdapterExtensions,
defaultBlockHtmlAdapterMatchers,
} from './block-matcher.js';
export { defaultBlockHtmlAdapterMatchers } from './block-matcher.js';
export {
HtmlAdapter,
HtmlAdapterFactoryExtension,
Expand Down
1 change: 1 addition & 0 deletions blocksuite/blocks/src/_common/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './attachment.js';
export * from './extension.js';
export * from './html-adapter/html.js';
export * from './image.js';
export * from './markdown/index.js';
Expand Down
Loading

0 comments on commit 03dd354

Please sign in to comment.