refactor(editor): use extension level config (#12110)

Closes: BS-3396

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

- **New Features**
  - Introduced structured and validated configuration options for database and linked document views, allowing for more flexible and reliable customization.
  - Enhanced view manager to conditionally enable AI-related paragraph placeholders and database/linked document extensions based on configuration.
- **Chores**
  - Updated dependencies to include the latest version of the Zod validation library.
  - Simplified and consolidated internal configuration and registration logic for AI and widget-related extensions.
- **Refactor**
  - Streamlined configuration types and removed unused or redundant configuration utilities to improve maintainability.
  - Improved robustness of linked widget configuration retrieval to handle optional service availability gracefully.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Saul-Mirone
2025-05-04 13:53:25 +00:00
parent a23112c12a
commit f3b5c36cf7
11 changed files with 156 additions and 118 deletions

View File

@@ -46,10 +46,7 @@ import { computed, signal } from '@preact/signals-core';
import { css, html, nothing, unsafeCSS } from 'lit';
import { popSideDetail } from './components/layout.js';
import {
DatabaseConfigExtension,
type DatabaseOptionsConfig,
} from './config.js';
import { DatabaseConfigExtension } from './config.js';
import { HostContextKey } from './context/host-context.js';
import { DatabaseBlockDataSource } from './data-source.js';
import { BlockRenderer } from './detail-panel/block-renderer.js';
@@ -57,6 +54,7 @@ import { NoteRenderer } from './detail-panel/note-renderer.js';
import { DatabaseSelection } from './selection.js';
import { currentViewStorage } from './utils/current-view.js';
import { getSingleDocIdFromText } from './utils/title-doc.js';
import type { DatabaseViewExtensionOptions } from './view';
export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBlockModel> {
static override styles = css`
@@ -345,7 +343,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
return this._dataSource;
}
get optionsConfig(): DatabaseOptionsConfig {
get optionsConfig(): DatabaseViewExtensionOptions {
return {
configure: (_model, options) => options,
...this.std.getOptional(DatabaseConfigExtension.identifier),