refactor(editor): config the extension provider directly (#12252)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
	- Added new export paths to improve module accessibility for foundation store and view components.
	- Introduced new extension points for telemetry, font configuration, link preview cache, and peek view services in the view extension foundation.

- **Improvements**
	- Enhanced flexibility by allowing optional configuration of placeholders in paragraph view extensions.
	- Switched to runtime schema validation for font configuration, increasing reliability.
	- Streamlined service registration for peek view providers.

- **Refactor**
	- Centralized and simplified extension management by removing redundant extension files and consolidating setup logic.
	- Updated internal integration of telemetry, font, and peek view services for improved maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Saul-Mirone
2025-05-13 11:09:21 +00:00
parent 39942a0d04
commit 4ebeb530e0
13 changed files with 126 additions and 96 deletions

View File

@@ -1,11 +1,14 @@
import { FontFamily, FontStyle, FontWeight } from '@blocksuite/affine-model';
import { z } from 'zod';
export interface FontConfig {
font: string;
weight: string;
url: string;
style: string;
}
export const fontConfigSchema = z.object({
font: z.string(),
weight: z.string(),
url: z.string(),
style: z.string(),
});
export type FontConfig = z.infer<typeof fontConfigSchema>;
export const AffineCanvasTextFonts: FontConfig[] = [
// Inter, https://fonts.cdnfonts.com/css/inter?styles=29139,29134,29135,29136,29140,29141

View File

@@ -1,4 +1,5 @@
import { createIdentifier } from '@blocksuite/global/di';
import type { ExtensionType } from '@blocksuite/store';
import type { OutDatabaseAllEvents } from './database.js';
import type { LinkToolbarEvents } from './link.js';
@@ -46,3 +47,13 @@ export interface TelemetryService {
export const TelemetryProvider = createIdentifier<TelemetryService>(
'AffineTelemetryService'
);
export const TelemetryExtension = (
service: TelemetryService
): ExtensionType => {
return {
setup: di => {
di.override(TelemetryProvider, () => service);
},
};
};