mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
feat(editor): add sidebar service (#9761)
This commit is contained in:
@@ -13,5 +13,6 @@ export * from './open-doc-config';
|
||||
export * from './page-viewport-service';
|
||||
export * from './parse-url-service';
|
||||
export * from './quick-search-service';
|
||||
export * from './sidebar-service';
|
||||
export * from './telemetry-service';
|
||||
export * from './theme-service';
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { createIdentifier } from '@blocksuite/global/di';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
export interface SidebarService {
|
||||
open: (tabId?: string) => void;
|
||||
close: () => void;
|
||||
getTabIds: () => string[];
|
||||
}
|
||||
|
||||
export const SidebarExtensionIdentifier = createIdentifier<SidebarService>(
|
||||
'AffineSidebarExtension'
|
||||
);
|
||||
|
||||
export const SidebarExtension = (service: SidebarService): ExtensionType => ({
|
||||
setup: di => {
|
||||
di.addImpl(SidebarExtensionIdentifier, () => service);
|
||||
},
|
||||
});
|
||||
@@ -64,6 +64,7 @@ import {
|
||||
patchPeekViewService,
|
||||
patchQuickSearchService,
|
||||
patchReferenceRenderer,
|
||||
patchSideBarService,
|
||||
type ReferenceReactRenderer,
|
||||
} from './specs/custom/spec-patchers';
|
||||
import { createEdgelessModeSpecs } from './specs/edgeless';
|
||||
@@ -167,6 +168,7 @@ const usePatchSpecs = (mode: DocMode) => {
|
||||
patched = patched.concat(patchParseDocUrlExtension(framework));
|
||||
patched = patched.concat(patchGenerateDocUrlExtension(framework));
|
||||
patched = patched.concat(patchQuickSearchService(framework));
|
||||
patched = patched.concat(patchSideBarService(framework));
|
||||
if (BUILD_CONFIG.isMobileEdition) {
|
||||
patched = patched.concat(patchForMobile());
|
||||
}
|
||||
|
||||
+19
@@ -24,6 +24,7 @@ import {
|
||||
} from '@affine/core/modules/quicksearch';
|
||||
import { ExternalLinksQuickSearchSession } from '@affine/core/modules/quicksearch/impls/external-links';
|
||||
import { JournalsQuickSearchSession } from '@affine/core/modules/quicksearch/impls/journals';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { I18n } from '@affine/i18n';
|
||||
@@ -61,6 +62,7 @@ import {
|
||||
PeekViewExtension,
|
||||
QuickSearchExtension,
|
||||
ReferenceNodeConfigExtension,
|
||||
SidebarExtension,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { Bound } from '@blocksuite/affine/global/utils';
|
||||
import {
|
||||
@@ -665,3 +667,20 @@ export function patchForEdgelessNoteConfig(
|
||||
reactToLit(<EdgelessNoteHeader note={note} />),
|
||||
});
|
||||
}
|
||||
|
||||
export function patchSideBarService(framework: FrameworkProvider) {
|
||||
const { workbench } = framework.get(WorkbenchService);
|
||||
|
||||
return SidebarExtension({
|
||||
open: (tabId?: string) => {
|
||||
workbench.openSidebar();
|
||||
workbench.activeView$.value.activeSidebarTab(tabId ?? null);
|
||||
},
|
||||
close: () => {
|
||||
workbench.closeSidebar();
|
||||
},
|
||||
getTabIds: () => {
|
||||
return workbench.activeView$.value.sidebarTabs$.value.map(tab => tab.id);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user