mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
refactor(editor): extract mobile extension builder (#12239)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new mobile view extension that activates mobile-specific UI features based on the runtime environment. - Automatically enables mobile keyboard toolbar and linked document menu features in mobile contexts. - **Improvements** - Simplified code and paragraph block configurations on mobile, including disabling line numbers and adjusting placeholders. - Enhanced configuration chaining to include mobile-specific settings by default. - Improved extension registration flow with method chaining support. - **Refactor** - Removed deprecated mobile patch classes and configurations, consolidating mobile logic into dedicated extensions. - Streamlined mobile-related code for better maintainability and performance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -17,7 +17,7 @@ export type Context<Scope extends string> = {
|
||||
/** The scope this context is associated with */
|
||||
scope: Scope;
|
||||
/** Function to register one or more extensions */
|
||||
register(extensions: ExtensionType[] | ExtensionType): void;
|
||||
register(extensions: ExtensionType[] | ExtensionType): Context<Scope>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,11 +75,14 @@ export class ExtensionManager<Scope extends string> {
|
||||
|
||||
/** @internal */
|
||||
private readonly _getContextByScope = (scope: Scope): Context<Scope> => {
|
||||
return {
|
||||
const context: Context<Scope> = {
|
||||
scope,
|
||||
register: (extensions: ExtensionType[] | ExtensionType) =>
|
||||
this._registerToScope(scope, extensions),
|
||||
register: (extensions: ExtensionType[] | ExtensionType) => {
|
||||
this._registerToScope(scope, extensions);
|
||||
return context;
|
||||
},
|
||||
};
|
||||
return context;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user