mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 04:26:23 +08:00
4bd43a698c
[BS-2427](https://linear.app/affine-design/issue/BS-2427/移除-bookmark-block-service) [BS-2418](https://linear.app/affine-design/issue/BS-2418/linkpreviewer-重构成插件)
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import {
|
|
EmbedGithubBlockSchema,
|
|
type EmbedGithubModel,
|
|
EmbedGithubStyles,
|
|
} from '@blocksuite/affine-model';
|
|
import {
|
|
EmbedOptionProvider,
|
|
LinkPreviewerService,
|
|
} from '@blocksuite/affine-shared/services';
|
|
import { BlockService } from '@blocksuite/block-std';
|
|
|
|
import { githubUrlRegex } from './embed-github-model.js';
|
|
import { queryEmbedGithubApiData, queryEmbedGithubData } from './utils.js';
|
|
|
|
export class EmbedGithubBlockService extends BlockService {
|
|
static override readonly flavour = EmbedGithubBlockSchema.model.flavour;
|
|
|
|
queryApiData = (embedGithubModel: EmbedGithubModel, signal?: AbortSignal) => {
|
|
return queryEmbedGithubApiData(embedGithubModel, signal);
|
|
};
|
|
|
|
queryUrlData = (embedGithubModel: EmbedGithubModel, signal?: AbortSignal) => {
|
|
return queryEmbedGithubData(
|
|
embedGithubModel,
|
|
this.doc.get(LinkPreviewerService),
|
|
signal
|
|
);
|
|
};
|
|
|
|
override mounted() {
|
|
super.mounted();
|
|
|
|
this.std.get(EmbedOptionProvider).registerEmbedBlockOptions({
|
|
flavour: this.flavour,
|
|
urlRegex: githubUrlRegex,
|
|
styles: EmbedGithubStyles,
|
|
viewType: 'card',
|
|
});
|
|
}
|
|
}
|