Skip to content

Commit

Permalink
fix: 2878 in pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Oct 16, 2024
1 parent bd87b95 commit bc6b2f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/docs-ui/src/controllers/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { Subscription } from 'rxjs';
import {
BaselineOffset,
BooleanNumber,
DOCS_ZEN_EDITOR_UNIT_ID_KEY,
DocumentFlavor,
HorizontalAlign,
ICommandService,
Expand Down Expand Up @@ -805,7 +806,7 @@ export function DocSwitchModeMenuItemFactory(accessor: IAccessor): IMenuButtonIt
type: MenuItemType.BUTTON,
icon: 'KeyboardSingle',
tooltip: 'toolbar.documentFlavor',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, undefined, DOCS_ZEN_EDITOR_UNIT_ID_KEY),
activated$: new Observable<boolean>((subscriber) => {
const subscription = commandService.onCommandExecuted((c) => {
if (c.id === SwitchDocModeCommand.id) {
Expand Down
6 changes: 5 additions & 1 deletion packages/ui/src/common/menu-hidden-observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { Observable } from 'rxjs';
export function getMenuHiddenObservable(
accessor: IAccessor,
targetUniverType: UniverInstanceType,
matchUnitId?: string
matchUnitId?: string,
needHideUnitId?: string
): Observable<boolean> {
const univerInstanceService = accessor.get(IUniverInstanceService);

Expand All @@ -33,6 +34,9 @@ export function getMenuHiddenObservable(
if (matchUnitId && matchUnitId !== unitId) {
return subscriber.next(true);
}
if (needHideUnitId && needHideUnitId === unitId) {
return subscriber.next(true);
}
const univerType = univerInstanceService.getUnitType(unitId);

subscriber.next(univerType !== targetUniverType);
Expand Down

0 comments on commit bc6b2f7

Please sign in to comment.