mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 22:37:04 +08:00
refactor(editor): cleanup dead code (#11893)
This commit is contained in:
@@ -1,14 +1,7 @@
|
|||||||
import { Container } from '@blocksuite/global/di';
|
import { Container } from '@blocksuite/global/di';
|
||||||
|
|
||||||
import {
|
|
||||||
registerBlockSpecs,
|
|
||||||
registerStoreSpecs,
|
|
||||||
} from '../../extensions/register';
|
|
||||||
import { testStoreExtensions } from './store';
|
import { testStoreExtensions } from './store';
|
||||||
|
|
||||||
registerStoreSpecs();
|
|
||||||
registerBlockSpecs();
|
|
||||||
|
|
||||||
export function getProvider() {
|
export function getProvider() {
|
||||||
const container = new Container();
|
const container = new Container();
|
||||||
const exts = testStoreExtensions;
|
const exts = testStoreExtensions;
|
||||||
|
|||||||
@@ -63,8 +63,6 @@ import { effects as widgetToolbarEffects } from '@blocksuite/affine-widget-toolb
|
|||||||
import { effects as dataViewEffects } from '@blocksuite/data-view/effects';
|
import { effects as dataViewEffects } from '@blocksuite/data-view/effects';
|
||||||
import { effects as stdEffects } from '@blocksuite/std/effects';
|
import { effects as stdEffects } from '@blocksuite/std/effects';
|
||||||
|
|
||||||
import { registerBlockSpecs } from './extensions';
|
|
||||||
|
|
||||||
export declare const _GLOBAL_:
|
export declare const _GLOBAL_:
|
||||||
| typeof stdEffects
|
| typeof stdEffects
|
||||||
| typeof dataViewEffects
|
| typeof dataViewEffects
|
||||||
@@ -113,7 +111,6 @@ export declare const _GLOBAL_:
|
|||||||
| typeof fragmentOutlineEffects;
|
| typeof fragmentOutlineEffects;
|
||||||
|
|
||||||
export function effects() {
|
export function effects() {
|
||||||
registerBlockSpecs();
|
|
||||||
stdEffects();
|
stdEffects();
|
||||||
|
|
||||||
dataViewEffects();
|
dataViewEffects();
|
||||||
|
|||||||
@@ -2,4 +2,3 @@ export * from './common';
|
|||||||
export * from './editor-specs';
|
export * from './editor-specs';
|
||||||
export * from './legacy-store';
|
export * from './legacy-store';
|
||||||
export * from './preview-specs';
|
export * from './preview-specs';
|
||||||
export * from './register';
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
import { SpecProvider } from '@blocksuite/affine-shared/utils';
|
|
||||||
|
|
||||||
import {
|
|
||||||
EdgelessEditorBlockSpecs,
|
|
||||||
PageEditorBlockSpecs,
|
|
||||||
} from './editor-specs.js';
|
|
||||||
import { StoreExtensions } from './legacy-store.js';
|
|
||||||
import {
|
|
||||||
PreviewEdgelessEditorBlockSpecs,
|
|
||||||
PreviewPageEditorBlockSpecs,
|
|
||||||
} from './preview-specs.js';
|
|
||||||
|
|
||||||
export function registerStoreSpecs() {
|
|
||||||
SpecProvider._.addSpec('store', StoreExtensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function registerBlockSpecs() {
|
|
||||||
SpecProvider._.addSpec('page', PageEditorBlockSpecs);
|
|
||||||
SpecProvider._.addSpec('edgeless', EdgelessEditorBlockSpecs);
|
|
||||||
SpecProvider._.addSpec('preview:page', PreviewPageEditorBlockSpecs);
|
|
||||||
SpecProvider._.addSpec('preview:edgeless', PreviewEdgelessEditorBlockSpecs);
|
|
||||||
}
|
|
||||||
@@ -20,7 +20,6 @@ export * from './print-to-pdf';
|
|||||||
export * from './reference';
|
export * from './reference';
|
||||||
export * from './reordering';
|
export * from './reordering';
|
||||||
export * from './signal';
|
export * from './signal';
|
||||||
export * from './spec';
|
|
||||||
export * from './string';
|
export * from './string';
|
||||||
export * from './title';
|
export * from './title';
|
||||||
export * from './url';
|
export * from './url';
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
export * from './spec-builder.js';
|
|
||||||
export * from './spec-provider.js';
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import type { ExtensionType } from '@blocksuite/store';
|
|
||||||
|
|
||||||
export class SpecBuilder {
|
|
||||||
private _value: ExtensionType[];
|
|
||||||
|
|
||||||
get value() {
|
|
||||||
return this._value;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(spec: ExtensionType[]) {
|
|
||||||
this._value = [...spec];
|
|
||||||
}
|
|
||||||
|
|
||||||
extend(extensions: ExtensionType[]) {
|
|
||||||
this._value = [...this._value, ...extensions];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
omit(target: ExtensionType) {
|
|
||||||
this._value = this._value.filter(extension => extension !== target);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasAll(target: ExtensionType[]) {
|
|
||||||
return target.every(t => this._value.includes(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
hasOneOf(target: ExtensionType[]) {
|
|
||||||
return target.some(t => this._value.includes(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
replace(target: ExtensionType[], newExtension: ExtensionType[]) {
|
|
||||||
this._value = [
|
|
||||||
...this._value.filter(extension => !target.includes(extension)),
|
|
||||||
...newExtension,
|
|
||||||
];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
import { BlockSuiteError } from '@blocksuite/global/exceptions';
|
|
||||||
import type { ExtensionType } from '@blocksuite/store';
|
|
||||||
|
|
||||||
import { SpecBuilder } from './spec-builder.js';
|
|
||||||
|
|
||||||
type SpecId =
|
|
||||||
| 'store'
|
|
||||||
| 'page'
|
|
||||||
| 'edgeless'
|
|
||||||
| 'preview:page'
|
|
||||||
| 'preview:edgeless';
|
|
||||||
|
|
||||||
export class SpecProvider {
|
|
||||||
static instance: SpecProvider;
|
|
||||||
|
|
||||||
private readonly specMap = new Map<SpecId, ExtensionType[]>();
|
|
||||||
|
|
||||||
private constructor() {}
|
|
||||||
|
|
||||||
static get _() {
|
|
||||||
if (!SpecProvider.instance) {
|
|
||||||
SpecProvider.instance = new SpecProvider();
|
|
||||||
}
|
|
||||||
return SpecProvider.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
addSpec(id: SpecId, spec: ExtensionType[]) {
|
|
||||||
if (!this.specMap.has(id)) {
|
|
||||||
this.specMap.set(id, spec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clearSpec(id: SpecId) {
|
|
||||||
this.specMap.delete(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
extendSpec(id: SpecId, newSpec: ExtensionType[]) {
|
|
||||||
const existingSpec = this.specMap.get(id);
|
|
||||||
if (!existingSpec) {
|
|
||||||
console.error(`Spec not found for ${id}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.specMap.set(id, [...existingSpec, ...newSpec]);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSpec(id: SpecId) {
|
|
||||||
const spec = this.specMap.get(id);
|
|
||||||
if (!spec) {
|
|
||||||
throw new BlockSuiteError(
|
|
||||||
BlockSuiteError.ErrorCode.ValueNotExists,
|
|
||||||
`Spec not found for ${id}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new SpecBuilder(spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
hasSpec(id: SpecId) {
|
|
||||||
return this.specMap.has(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
omitSpec(id: SpecId, targetSpec: ExtensionType) {
|
|
||||||
const existingSpec = this.specMap.get(id);
|
|
||||||
if (!existingSpec) {
|
|
||||||
console.error(`Spec not found for ${id}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.specMap.set(
|
|
||||||
id,
|
|
||||||
existingSpec.filter(spec => spec !== targetSpec)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
replaceSpec(id: SpecId, targetSpec: ExtensionType, newSpec: ExtensionType) {
|
|
||||||
const existingSpec = this.specMap.get(id);
|
|
||||||
if (!existingSpec) {
|
|
||||||
console.error(`Spec not found for ${id}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.specMap.set(
|
|
||||||
id,
|
|
||||||
existingSpec.map(spec => (spec === targetSpec ? newSpec : spec))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import '@toeverything/theme/style.css';
|
import '@toeverything/theme/style.css';
|
||||||
import '@toeverything/theme/fonts.css';
|
import '@toeverything/theme/fonts.css';
|
||||||
|
|
||||||
import { registerStoreSpecs } from '@blocksuite/affine/extensions';
|
|
||||||
import type { DocMode } from '@blocksuite/affine/model';
|
import type { DocMode } from '@blocksuite/affine/model';
|
||||||
import { AffineSchemas } from '@blocksuite/affine/schemas';
|
import { AffineSchemas } from '@blocksuite/affine/schemas';
|
||||||
import {
|
import {
|
||||||
@@ -24,8 +23,6 @@ import { TestAffineEditorContainer } from '../../index.js';
|
|||||||
import { getTestStoreManager } from '../../store.js';
|
import { getTestStoreManager } from '../../store.js';
|
||||||
import { getTestViewManager } from '../../view.js';
|
import { getTestViewManager } from '../../view.js';
|
||||||
|
|
||||||
// FIXME: used for test import/export
|
|
||||||
registerStoreSpecs();
|
|
||||||
const storeManager = getTestStoreManager();
|
const storeManager = getTestStoreManager();
|
||||||
const viewManager = getTestViewManager();
|
const viewManager = getTestViewManager();
|
||||||
effects();
|
effects();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import '../../style.css';
|
|||||||
|
|
||||||
import * as databaseBlocks from '@blocksuite/affine/blocks/database';
|
import * as databaseBlocks from '@blocksuite/affine/blocks/database';
|
||||||
import * as noteBlocks from '@blocksuite/affine/blocks/note';
|
import * as noteBlocks from '@blocksuite/affine/blocks/note';
|
||||||
import { registerStoreSpecs } from '@blocksuite/affine/extensions';
|
|
||||||
import * as globalUtils from '@blocksuite/affine/global/utils';
|
import * as globalUtils from '@blocksuite/affine/global/utils';
|
||||||
import * as services from '@blocksuite/affine/shared/services';
|
import * as services from '@blocksuite/affine/shared/services';
|
||||||
import * as blockStd from '@blocksuite/affine/std';
|
import * as blockStd from '@blocksuite/affine/std';
|
||||||
@@ -21,7 +20,6 @@ import {
|
|||||||
import { mountDefaultDocEditor } from './utils/setup-playground';
|
import { mountDefaultDocEditor } from './utils/setup-playground';
|
||||||
import { prepareTestApp } from './utils/test';
|
import { prepareTestApp } from './utils/test';
|
||||||
|
|
||||||
registerStoreSpecs();
|
|
||||||
itEffects();
|
itEffects();
|
||||||
const storeManager = getTestStoreManager();
|
const storeManager = getTestStoreManager();
|
||||||
commentEffects();
|
commentEffects();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import '@affine/core/bootstrap/browser';
|
import '@affine/core/bootstrap/browser';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
|
||||||
import '@affine/component/theme';
|
import '@affine/component/theme';
|
||||||
import '@affine/core/mobile/styles/mobile.css';
|
import '@affine/core/mobile/styles/mobile.css';
|
||||||
import './proxy';
|
import './proxy';
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import '@affine/core/bootstrap/electron';
|
import '@affine/core/bootstrap/electron';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
|
||||||
import '@affine/core/bootstrap/cleanup';
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import '@affine/component/theme';
|
import '@affine/component/theme';
|
||||||
import './global.css';
|
import './global.css';
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import '@affine/core/bootstrap/browser';
|
import '@affine/core/bootstrap/browser';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
|
||||||
import '@affine/core/bootstrap/cleanup';
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import './proxy';
|
import './proxy';
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import '@affine/core/bootstrap/browser';
|
import '@affine/core/bootstrap/browser';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
|
||||||
import '@affine/core/bootstrap/cleanup';
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import '@affine/component/theme';
|
import '@affine/component/theme';
|
||||||
import '@affine/core/mobile/styles/mobile.css';
|
import '@affine/core/mobile/styles/mobile.css';
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import '@affine/core/bootstrap/browser';
|
import '@affine/core/bootstrap/browser';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
|
||||||
import '@affine/core/bootstrap/cleanup';
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import '@affine/component/theme';
|
import '@affine/component/theme';
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { SpecProvider } from '@blocksuite/affine/shared/utils';
|
|
||||||
|
|
||||||
import { AIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-block';
|
import { AIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-block';
|
||||||
import { EdgelessAIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-edgeless-block';
|
import { EdgelessAIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-edgeless-block';
|
||||||
import { LitTranscriptionBlock } from './blocks/ai-chat-block/ai-transcription-block';
|
import { LitTranscriptionBlock } from './blocks/ai-chat-block/ai-transcription-block';
|
||||||
@@ -13,7 +11,6 @@ import {
|
|||||||
} from './blocks/ai-chat-block/components/chat-images';
|
} from './blocks/ai-chat-block/components/chat-images';
|
||||||
import { ImagePlaceholder } from './blocks/ai-chat-block/components/image-placeholder';
|
import { ImagePlaceholder } from './blocks/ai-chat-block/components/image-placeholder';
|
||||||
import { UserInfo } from './blocks/ai-chat-block/components/user-info';
|
import { UserInfo } from './blocks/ai-chat-block/components/user-info';
|
||||||
import { AIChatBlockSchemaExtension } from './blocks/ai-chat-block/model';
|
|
||||||
import { ChatPanel } from './chat-panel';
|
import { ChatPanel } from './chat-panel';
|
||||||
import { ActionWrapper } from './chat-panel/actions/action-wrapper';
|
import { ActionWrapper } from './chat-panel/actions/action-wrapper';
|
||||||
import { ActionImage } from './chat-panel/actions/image';
|
import { ActionImage } from './chat-panel/actions/image';
|
||||||
@@ -158,6 +155,4 @@ export function registerAIEffects() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
customElements.define('transcription-block', LitTranscriptionBlock);
|
customElements.define('transcription-block', LitTranscriptionBlock);
|
||||||
|
|
||||||
SpecProvider._.extendSpec('store', [AIChatBlockSchemaExtension]);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import { CodeBlockSpec } from '@blocksuite/affine/blocks/code';
|
|
||||||
import { ImageBlockSpec } from '@blocksuite/affine/blocks/image';
|
|
||||||
import { ParagraphBlockSpec } from '@blocksuite/affine/blocks/paragraph';
|
|
||||||
import {
|
|
||||||
EdgelessRootBlockSpec,
|
|
||||||
PageRootBlockSpec,
|
|
||||||
} from '@blocksuite/affine/blocks/root';
|
|
||||||
import type { SpecBuilder } from '@blocksuite/affine/shared/utils';
|
|
||||||
import type { FrameworkProvider } from '@toeverything/infra';
|
|
||||||
|
|
||||||
import { AIChatBlockSpec } from '../blocks';
|
|
||||||
import { AITranscriptionBlockSpec } from '../blocks/ai-chat-block/ai-transcription-block';
|
|
||||||
import { AICodeBlockSpec } from './ai-code';
|
|
||||||
import { createAIEdgelessRootBlockSpec } from './ai-edgeless-root';
|
|
||||||
import { AIImageBlockSpec } from './ai-image';
|
|
||||||
import { createAIPageRootBlockSpec } from './ai-page-root';
|
|
||||||
import { AIParagraphBlockSpec } from './ai-paragraph';
|
|
||||||
|
|
||||||
export function enableAIExtension(
|
|
||||||
specBuilder: SpecBuilder,
|
|
||||||
framework: FrameworkProvider,
|
|
||||||
enableAI: boolean
|
|
||||||
) {
|
|
||||||
if (!enableAI) return;
|
|
||||||
|
|
||||||
specBuilder.replace(CodeBlockSpec, AICodeBlockSpec);
|
|
||||||
specBuilder.replace(ImageBlockSpec, AIImageBlockSpec);
|
|
||||||
specBuilder.replace(ParagraphBlockSpec, AIParagraphBlockSpec);
|
|
||||||
|
|
||||||
if (specBuilder.hasAll(EdgelessRootBlockSpec)) {
|
|
||||||
const aiEdgeless = createAIEdgelessRootBlockSpec(framework);
|
|
||||||
specBuilder.replace(EdgelessRootBlockSpec, aiEdgeless);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (specBuilder.hasAll(PageRootBlockSpec)) {
|
|
||||||
const aiPage = createAIPageRootBlockSpec(framework);
|
|
||||||
specBuilder.replace(PageRootBlockSpec, aiPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
specBuilder.extend(AIChatBlockSpec);
|
|
||||||
specBuilder.extend(AITranscriptionBlockSpec);
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from './enable-ai';
|
|
||||||
@@ -3,7 +3,6 @@ export * from './actions';
|
|||||||
export { ChatPanel } from './chat-panel';
|
export { ChatPanel } from './chat-panel';
|
||||||
export * from './entries';
|
export * from './entries';
|
||||||
export * from './entries/edgeless/actions-config';
|
export * from './entries/edgeless/actions-config';
|
||||||
export * from './extensions';
|
|
||||||
export * from './messages';
|
export * from './messages';
|
||||||
export { AIChatBlockPeekViewTemplate } from './peek-view/chat-block-peek-view';
|
export { AIChatBlockPeekViewTemplate } from './peek-view/chat-block-peek-view';
|
||||||
export * from './provider';
|
export * from './provider';
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import type { SpecBuilder } from '@blocksuite/affine/shared/utils';
|
|
||||||
import { type FrameworkProvider } from '@toeverything/infra';
|
|
||||||
|
|
||||||
import { buildDocDisplayMetaExtension } from '../display-meta';
|
|
||||||
import { getEditorConfigExtension } from '../editor-config';
|
|
||||||
import { getFontConfigExtension } from '../font-config';
|
|
||||||
import { getTelemetryExtension } from '../telemetry';
|
|
||||||
import { getThemeExtension } from '../theme';
|
|
||||||
|
|
||||||
export function enableAffineExtension(
|
|
||||||
specBuilder: SpecBuilder,
|
|
||||||
framework: FrameworkProvider
|
|
||||||
): void {
|
|
||||||
specBuilder.extend(
|
|
||||||
[
|
|
||||||
getThemeExtension(framework),
|
|
||||||
getFontConfigExtension(),
|
|
||||||
getTelemetryExtension(),
|
|
||||||
getEditorConfigExtension(framework),
|
|
||||||
buildDocDisplayMetaExtension(framework),
|
|
||||||
].flat()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PeekViewService } from '@affine/core/modules/peek-view/services/peek-view';
|
|
||||||
import { AppThemeService } from '@affine/core/modules/theme';
|
import { AppThemeService } from '@affine/core/modules/theme';
|
||||||
import type { Container } from '@blocksuite/affine/global/di';
|
import type { Container } from '@blocksuite/affine/global/di';
|
||||||
import { ColorScheme } from '@blocksuite/affine/model';
|
import { ColorScheme } from '@blocksuite/affine/model';
|
||||||
@@ -9,24 +8,15 @@ import {
|
|||||||
import {
|
import {
|
||||||
createSignalFromObservable,
|
createSignalFromObservable,
|
||||||
type Signal,
|
type Signal,
|
||||||
SpecProvider,
|
|
||||||
} from '@blocksuite/affine/shared/utils';
|
} from '@blocksuite/affine/shared/utils';
|
||||||
import {
|
import {
|
||||||
type BlockStdScope,
|
type BlockStdScope,
|
||||||
LifeCycleWatcher,
|
LifeCycleWatcher,
|
||||||
StdIdentifier,
|
StdIdentifier,
|
||||||
} from '@blocksuite/affine/std';
|
} from '@blocksuite/affine/std';
|
||||||
import type { ExtensionType } from '@blocksuite/affine/store';
|
|
||||||
import type { FrameworkProvider } from '@toeverything/infra';
|
import type { FrameworkProvider } from '@toeverything/infra';
|
||||||
import type { Observable } from 'rxjs';
|
import type { Observable } from 'rxjs';
|
||||||
|
|
||||||
import { AIChatBlockSpec } from '../../ai/blocks';
|
|
||||||
import { AITranscriptionBlockSpec } from '../../ai/blocks/ai-chat-block/ai-transcription-block';
|
|
||||||
import { buildDocDisplayMetaExtension } from '../display-meta';
|
|
||||||
import { getFontConfigExtension } from '../font-config';
|
|
||||||
import { patchPeekViewService } from '../peek-view-service';
|
|
||||||
import { getThemeExtension } from '../theme';
|
|
||||||
|
|
||||||
export function getPagePreviewThemeExtension(framework: FrameworkProvider) {
|
export function getPagePreviewThemeExtension(framework: FrameworkProvider) {
|
||||||
class AffinePagePreviewThemeExtension
|
class AffinePagePreviewThemeExtension
|
||||||
extends LifeCycleWatcher
|
extends LifeCycleWatcher
|
||||||
@@ -81,38 +71,3 @@ export function getPagePreviewThemeExtension(framework: FrameworkProvider) {
|
|||||||
|
|
||||||
return AffinePagePreviewThemeExtension;
|
return AffinePagePreviewThemeExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fontConfig = getFontConfigExtension();
|
|
||||||
|
|
||||||
let _framework: FrameworkProvider;
|
|
||||||
let _previewExtensions: ExtensionType[];
|
|
||||||
export function enablePreviewExtension(framework: FrameworkProvider): void {
|
|
||||||
if (_framework === framework && _previewExtensions) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const specProvider = SpecProvider._;
|
|
||||||
|
|
||||||
if (_previewExtensions) {
|
|
||||||
_previewExtensions.forEach(extension => {
|
|
||||||
specProvider.omitSpec('preview:page', extension);
|
|
||||||
specProvider.omitSpec('preview:edgeless', extension);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_framework = framework;
|
|
||||||
const peekViewService = framework.get(PeekViewService);
|
|
||||||
|
|
||||||
_previewExtensions = [
|
|
||||||
...AIChatBlockSpec,
|
|
||||||
...AITranscriptionBlockSpec,
|
|
||||||
fontConfig,
|
|
||||||
getThemeExtension(framework),
|
|
||||||
getPagePreviewThemeExtension(framework),
|
|
||||||
buildDocDisplayMetaExtension(framework),
|
|
||||||
patchPeekViewService(peekViewService),
|
|
||||||
];
|
|
||||||
|
|
||||||
specProvider.extendSpec('preview:page', _previewExtensions);
|
|
||||||
specProvider.extendSpec('preview:edgeless', _previewExtensions);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export * from './entry/enable-affine';
|
|
||||||
export * from './entry/enable-mobile';
|
export * from './entry/enable-mobile';
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import { registerStoreSpecs } from '@blocksuite/affine/extensions';
|
|
||||||
|
|
||||||
registerStoreSpecs();
|
|
||||||
Reference in New Issue
Block a user