Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheets-ui): recover float-dom delete menu & focusing when zen-editor mount (#3426)
zhangw2bf1177ac967
diff --git a/packages/docs-ui/src/services/clipboard/clipboard.service.ts b/packages/docs-ui/src/services/clipboard/clipboard.service.tsindex 444f7d4c25..992ff7edf0 100644--- a/packages/docs-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/docs-ui/src/services/clipboard/clipboard.service.ts@@ -465,8 +465,9 @@ export class DocClipboardService extends Disposable implements IDocClipboardServ}if (end !== dataStream.length - 1) {- loopParagraph(dataStream.length - 1, false);+ loopParagraph(dataStream.length, false);}+return {dataStream: newDataStream,paragraphs,diff --git a/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts b/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.tsindex 87e58e214a..0baf745676 100644--- a/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import type { IDisposable, Nullable, Workbook } from '@univerjs/core';import { connectInjector, FOCUSING_COMMON_DRAWINGS, IContextService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';-import type { BaseObject, Scene } from '@univerjs/engine-render';-import { IRenderManagerService } from '@univerjs/engine-render';+import { DrawingTypeEnum, IDrawingManagerService } from '@univerjs/drawing';import { COMPONENT_IMAGE_POPUP_MENU, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation } from '@univerjs/drawing-ui';+import { IRenderManagerService } from '@univerjs/engine-render';import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';-import { takeUntil } from 'rxjs';-import { DrawingTypeEnum, IDrawingManagerService } from '@univerjs/drawing';import { BuiltInUIPart, IUIPartsService } from '@univerjs/ui';+import { takeUntil } from 'rxjs';+import type { IDisposable, Nullable, Workbook } from '@univerjs/core';+import type { BaseObject, Scene } from '@univerjs/engine-render';import { RemoveSheetDrawingCommand } from '../commands/commands/remove-sheet-drawing.command';import { EditSheetDrawingOperation } from '../commands/operations/edit-sheet-drawing.operation';@@ -120,16 +120,13 @@ export class DrawingPopupMenuController extends RxDisposable {}const { unitId, subUnitId, drawingId, drawingType } = drawingParam;- if (drawingType === DrawingTypeEnum.DRAWING_DOM) {- return;- }singletonPopupDisposer?.dispose();singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {componentKey: COMPONENT_IMAGE_POPUP_MENU,direction: 'horizontal',offset: [2, 0],extraProps: {- menuItems: this._getImageMenuItems(unitId, subUnitId, drawingId),+ menuItems: this._getImageMenuItems(unitId, subUnitId, drawingId, drawingType),},}));@@ -155,14 +152,14 @@ export class DrawingPopupMenuController extends RxDisposable {);}- private _getImageMenuItems(unitId: string, subUnitId: string, drawingId: string) {+ private _getImageMenuItems(unitId: string, subUnitId: string, drawingId: string, drawingType: number) {return [{label: 'image-popup.edit',index: 0,commandId: EditSheetDrawingOperation.id,commandParams: { unitId, subUnitId, drawingId },- disable: false,+ disable: drawingType === DrawingTypeEnum.DRAWING_DOM,},{label: 'image-popup.delete',@@ -176,14 +173,14 @@ export class DrawingPopupMenuController extends RxDisposable {index: 2,commandId: OpenImageCropOperation.id,commandParams: { unitId, subUnitId, drawingId },- disable: false,+ disable: drawingType === DrawingTypeEnum.DRAWING_DOM,},{label: 'image-popup.reset',index: 3,commandId: ImageResetSizeOperation.id,commandParams: [{ unitId, subUnitId, drawingId }],- disable: false,+ disable: drawingType === DrawingTypeEnum.DRAWING_DOM,},];}diff --git a/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/popup.controller.tsindex 798b039a27..14a9f3f136 100644--- a/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts@@ -14,13 +14,10 @@* limitations under the License.*/-import type { Nullable } from '@univerjs/core';import { CustomRangeType, Disposable, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, ICommandService, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, Rectangle } from '@univerjs/core';-import { HoverManagerService, HoverRenderController, IEditorBridgeService, SheetPermissionInterceptorBaseController, SheetSkeletonManagerService } from '@univerjs/sheets-ui';-import type { Subscription } from 'rxjs';-import { debounceTime, map, mergeMap, Observable } from 'rxjs';+import { DocSelectionManagerService } from '@univerjs/docs';+import { DocEventManagerService } from '@univerjs/docs-ui';import { IRenderManagerService } from '@univerjs/engine-render';-import type { ISheetLocationBase } from '@univerjs/sheets';import {ClearSelectionAllCommand,ClearSelectionContentCommand,@@ -35,9 +32,12 @@ import {WorksheetInsertHyperlinkPermission,WorksheetViewPermission,} from '@univerjs/sheets';-import { DocEventManagerService } from '@univerjs/docs-ui';+import { HoverManagerService, HoverRenderController, IEditorBridgeService, SheetPermissionInterceptorBaseController, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { IZenZoneService } from '@univerjs/ui';-import { DocSelectionManagerService } from '@univerjs/docs';+import { debounceTime, map, mergeMap, Observable } from 'rxjs';+import type { Nullable } from '@univerjs/core';+import type { ISheetLocationBase } from '@univerjs/sheets';+import type { Subscription } from 'rxjs';import { SheetsHyperLinkPopupService } from '../services/popup.service';import { HyperLinkEditSourceType } from '../types/enums/edit-source';@@ -271,11 +271,9 @@ export class SheetsHyperLinkPopupController extends Disposable {private _initTextSelectionListener() {this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe((selection) => {- if (!selection || selection.unitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY) {- return;+ if (selection && selection.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY) {+ this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);}-- this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);}));}diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.tsindex d06650fb71..5ad13ec5ee 100644--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts@@ -280,7 +280,7 @@ export class EditingRenderController extends Disposable implements IRenderModuleconst docSelectionRenderManager = this._renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)?.with(DocSelectionRenderService);if (docSelectionRenderManager) {- docSelectionRenderManager.activate(HIDDEN_EDITOR_POSITION, HIDDEN_EDITOR_POSITION);+ docSelectionRenderManager.activate(HIDDEN_EDITOR_POSITION, HIDDEN_EDITOR_POSITION, !document.activeElement || document.activeElement.classList.contains('univer-editor'));}}));}diff --git a/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts b/packages/sheets-zen-editor/src/controllers/zen-editor.controller.tsindex 3996d40f8a..72e97650aa 100644--- a/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts+++ b/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts@@ -34,7 +34,7 @@ import {DocSkeletonManagerService,RichTextEditingMutation,} from '@univerjs/docs';-import { VIEWPORT_KEY as DOC_VIEWPORT_KEY, getDocObject } from '@univerjs/docs-ui';+import { VIEWPORT_KEY as DOC_VIEWPORT_KEY, DocSelectionRenderService, getDocObject } from '@univerjs/docs-ui';import { DeviceInputEventType, IRenderManagerService } from '@univerjs/engine-render';import { getEditorObject, IEditorBridgeService } from '@univerjs/sheets-ui';import { IZenZoneService } from '@univerjs/ui';@@ -164,6 +164,10 @@ export class ZenEditorController extends RxDisposable {this._univerInstanceService.focusUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY);this._univerInstanceService.setCurrentUnitForType(DOCS_ZEN_EDITOR_UNIT_ID_KEY);+ const docSelectionRenderService = this._renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)?.with(DocSelectionRenderService);+ if (docSelectionRenderService) {+ docSelectionRenderService.focus();+ }const visibleState = this._editorBridgeService.isVisible();if (visibleState.visible === false) {diff --git a/packages/ui/src/services/zen-zone/desktop-zen-zone.service.ts b/packages/ui/src/services/zen-zone/desktop-zen-zone.service.tsindex 16ea8ea5f7..2bda38c29d 100644--- a/packages/ui/src/services/zen-zone/desktop-zen-zone.service.ts+++ b/packages/ui/src/services/zen-zone/desktop-zen-zone.service.ts@@ -16,8 +16,8 @@import { toDisposable } from '@univerjs/core';import { type IDisposable, Inject } from '@univerjs/core';-import type { ForwardRefExoticComponent } from 'react';import { BehaviorSubject, Subject } from 'rxjs';+import type { ForwardRefExoticComponent } from 'react';import { ComponentManager } from '../../common/component-manager';import type { IZenZoneService } from './zen-zone.service';@@ -34,6 +34,10 @@ export class DesktopZenZoneService implements IZenZoneService {return this._visible;}+ get temporaryHidden() {+ return this._temporaryHidden$.getValue();+ }+constructor(@Inject(ComponentManager) private readonly _componentManager: ComponentManager) {// super}diff --git a/packages/ui/src/services/zen-zone/zen-zone.service.ts b/packages/ui/src/services/zen-zone/zen-zone.service.tsindex 46457622c3..14790be3b7 100644--- a/packages/ui/src/services/zen-zone/zen-zone.service.ts+++ b/packages/ui/src/services/zen-zone/zen-zone.service.ts@@ -14,8 +14,8 @@* limitations under the License.*/-import type { IDisposable } from '@univerjs/core';import { createIdentifier } from '@univerjs/core';+import type { IDisposable } from '@univerjs/core';import type { Observable, Subject } from 'rxjs';export const IZenZoneService = createIdentifier<IZenZoneService>('univer.zen-zone-service');@@ -26,6 +26,7 @@ export interface IZenZoneService {readonly temporaryHidden$: Observable<boolean>;readonly visible: boolean;+ readonly temporaryHidden: boolean;set(key: string, component: any): IDisposable;