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: show full cell editor (#1079)
Ran Luo2cd18b952d94
diff --git a/packages/sheets-ui/src/commands/commands/set-scroll.command.ts b/packages/sheets-ui/src/commands/commands/set-scroll.command.tsindex d49b3c6d29..638facd891 100644--- a/packages/sheets-ui/src/commands/commands/set-scroll.command.ts+++ b/packages/sheets-ui/src/commands/commands/set-scroll.command.ts@@ -110,7 +110,7 @@ export const ScrollCommand: ICommand<IScrollCommandParams> = {};/**- * This command is reset the scroll position of the current view to 0 ,0+ * This command is reset the scroll position of the current view to 0, 0*/export const RestScrollCommand: ICommand<{}> = {id: 'sheet.command.scroll-view-reset',diff --git a/packages/sheets-ui/src/commands/operations/scroll.operation.ts b/packages/sheets-ui/src/commands/operations/scroll.operation.tsindex aba8cf5985..46bd1db2e1 100644--- a/packages/sheets-ui/src/commands/operations/scroll.operation.ts+++ b/packages/sheets-ui/src/commands/operations/scroll.operation.ts@@ -22,21 +22,26 @@ import { ScrollManagerService } from '../../services/scroll-manager.service';export const SetScrollOperation: IOperation<IScrollManagerInsertParam> = {id: 'sheet.operation.set-scroll',+type: CommandType.OPERATION,+handler: (accessor, params) => {- if (!params) {+ if (params == null) {return false;}+const scrollManagerService = accessor.get(ScrollManagerService);const currentService = accessor.get(IUniverInstanceService);const workbook = currentService.getUniverSheetInstance(params!.unitId);const worksheet = workbook!.getSheetBySheetId(params!.sheetId);const { xSplit, ySplit } = worksheet!.getConfig().freeze;+scrollManagerService.addOrReplaceByParam({...params,sheetViewStartRow: params.sheetViewStartRow - ySplit,sheetViewStartColumn: params.sheetViewStartColumn - xSplit,});+return true;},};diff --git a/packages/sheets-ui/src/controllers/navigation/navigation.controller.ts b/packages/sheets-ui/src/controllers/navigation/navigation.controller.tsindex 325e71c1be..0e5cbbbcba 100644--- a/packages/sheets-ui/src/controllers/navigation/navigation.controller.ts+++ b/packages/sheets-ui/src/controllers/navigation/navigation.controller.ts@@ -17,7 +17,6 @@import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';import { Inject } from '@wendellhu/redi';-import type { IMoveSelectionCommandParams } from '../../commands/commands/set-selection.command';import { MoveSelectionCommand, MoveSelectionEnterAndTabCommand } from '../../commands/commands/set-selection.command';import { ScrollController } from '../scroll.controller';@@ -34,8 +33,7 @@ export class SheetNavigationController extends Disposable {this.disposeWithMe(this._commandService.onCommandExecuted((command) => {if (SHEET_NAVIGATION_COMMANDS.includes(command.id)) {- const params = command.params as IMoveSelectionCommandParams;- this._scrollController.scrollToVisible(params.direction);+ this._scrollController.scrollToVisible();}}));diff --git a/packages/sheets-ui/src/controllers/scroll.controller.ts b/packages/sheets-ui/src/controllers/scroll.controller.tsindex 5b2fed1834..156f0b5b20 100644--- a/packages/sheets-ui/src/controllers/scroll.controller.ts+++ b/packages/sheets-ui/src/controllers/scroll.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { Direction, IWorksheetData } from '@univerjs/core';+import type { IWorksheetData } from '@univerjs/core';import {Disposable,ICommandService,@@ -49,116 +49,29 @@ export class ScrollController extends Disposable {this._initialize();}- override dispose(): void {- super.dispose();- }-- private _initialize() {- this._scrollEventBinding();- this._scrollSubscribeBinding();- this._skeletonListener();- }-- private _getFreeze() {- const config: IWorksheetData | undefined = this._sheetSkeletonManagerService- .getCurrent()- ?.skeleton.getWorksheetConfig();-- if (config == null) {- return;- }-- return config.freeze;- }-- private _scrollEventBinding() {- const scene = this._getSheetObject()?.scene;- if (scene == null) {- return;- }-- const viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);- this.disposeWithMe(- toDisposable(- viewportMain?.onScrollAfterObserver.add((param) => {- const skeleton = this._sheetSkeletonManagerService.getCurrent()?.skeleton;- if (skeleton == null || param.isTrigger === false) {- return;- }-- const sheetObject = this._getSheetObject();- if (skeleton == null || sheetObject == null) {- return;- }-- const { actualScrollX = 0, actualScrollY = 0 } = param;-- // according to the actual scroll position, the most suitable row, column and offset combination is recalculated.- const { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(- actualScrollX,- actualScrollY- );-- // update scroll infos in scroll manager service- this._scrollManagerService.addOrReplaceNoRefresh({- sheetViewStartRow: row,- sheetViewStartColumn: column,- offsetX: columnOffset,- offsetY: rowOffset,- });- })- )- );- this.disposeWithMe(- toDisposable(- viewportMain?.onScrollByBarObserver.add((param) => {- const skeleton = this._sheetSkeletonManagerService.getCurrent()?.skeleton;- if (skeleton == null || param.isTrigger === false) {- return;- }-- const sheetObject = this._getSheetObject();- if (skeleton == null || sheetObject == null) {- return;- }- const { actualScrollX = 0, actualScrollY = 0 } = param;-- const freeze = this._getFreeze();-- // according to the actual scroll position, the most suitable row, column and offset combination is recalculated.- const { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(- actualScrollX,- actualScrollY- );-- this._commandService.executeCommand(ScrollCommand.id, {- sheetViewStartRow: row + (freeze?.ySplit || 0),- sheetViewStartColumn: column + (freeze?.xSplit || 0),- offsetX: columnOffset,- offsetY: rowOffset,- });- })- )- );- }-- scrollToVisible(direction: Direction) {+ scrollToVisible(targetIsActualRowAndColumn = true) {let startSheetViewRow;let startSheetViewColumn;const selection = this._selectionManagerService.getLast();if (selection == null) {return;}- const { actualRow: selectionStartRow, actualColumn: selectionStartColumn } = selection.primary;++ const { startRow, startColumn, actualRow, actualColumn } = selection.primary;+ const selectionStartRow = targetIsActualRowAndColumn ? actualRow : startRow;+ const selectionStartColumn = targetIsActualRowAndColumn ? actualColumn : startColumn;const { rowHeightAccumulation, columnWidthAccumulation } =this._sheetSkeletonManagerService.getCurrent()?.skeleton ?? {};+if (rowHeightAccumulation == null || columnWidthAccumulation == null) {return;}+const scene = this._getSheetObject()?.scene;if (scene == null) {return;}+const viewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);if (viewport == null) {return;@@ -182,6 +95,7 @@ export class ScrollController extends Disposable {if (skeleton == null) {return;}+const {startRow: viewportStartRow,startColumn: viewportStartColumn,@@ -231,6 +145,7 @@ export class ScrollController extends Disposable {}const { sheetViewStartColumn, sheetViewStartRow, offsetX, offsetY } =this._scrollManagerService.getCurrentScroll() || {};+this._commandService.executeCommand(ScrollCommand.id, {sheetViewStartRow: startSheetViewRow ?? sheetViewStartRow,sheetViewStartColumn: startSheetViewColumn ?? sheetViewStartColumn,@@ -239,6 +154,99 @@ export class ScrollController extends Disposable {});}+ override dispose(): void {+ super.dispose();+ }++ private _initialize() {+ this._scrollEventBinding();+ this._scrollSubscribeBinding();+ this._skeletonListener();+ }++ private _getFreeze() {+ const config: IWorksheetData | undefined = this._sheetSkeletonManagerService+ .getCurrent()+ ?.skeleton.getWorksheetConfig();++ if (config == null) {+ return;+ }++ return config.freeze;+ }++ private _scrollEventBinding() {+ const scene = this._getSheetObject()?.scene;+ if (scene == null) {+ return;+ }++ const viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);+ this.disposeWithMe(+ toDisposable(+ viewportMain?.onScrollAfterObserver.add((param) => {+ const skeleton = this._sheetSkeletonManagerService.getCurrent()?.skeleton;+ if (skeleton == null || param.isTrigger === false) {+ return;+ }++ const sheetObject = this._getSheetObject();+ if (skeleton == null || sheetObject == null) {+ return;+ }++ const { actualScrollX = 0, actualScrollY = 0 } = param;++ // according to the actual scroll position, the most suitable row, column and offset combination is recalculated.+ const { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(+ actualScrollX,+ actualScrollY+ );++ // update scroll infos in scroll manager service+ this._scrollManagerService.addOrReplaceNoRefresh({+ sheetViewStartRow: row,+ sheetViewStartColumn: column,+ offsetX: columnOffset,+ offsetY: rowOffset,+ });+ })+ )+ );+ this.disposeWithMe(+ toDisposable(+ viewportMain?.onScrollByBarObserver.add((param) => {+ const skeleton = this._sheetSkeletonManagerService.getCurrent()?.skeleton;+ if (skeleton == null || param.isTrigger === false) {+ return;+ }++ const sheetObject = this._getSheetObject();+ if (skeleton == null || sheetObject == null) {+ return;+ }+ const { actualScrollX = 0, actualScrollY = 0 } = param;++ const freeze = this._getFreeze();++ // according to the actual scroll position, the most suitable row, column and offset combination is recalculated.+ const { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(+ actualScrollX,+ actualScrollY+ );++ this._commandService.executeCommand(ScrollCommand.id, {+ sheetViewStartRow: row + (freeze?.ySplit || 0),+ sheetViewStartColumn: column + (freeze?.xSplit || 0),+ offsetX: columnOffset,+ offsetY: rowOffset,+ });+ })+ )+ );+ }+// scroll command -> scroll manager service -> scrollInfo$ -> viewport scroll APIprivate _scrollSubscribeBinding() {this.disposeWithMe(diff --git a/packages/sheets-ui/src/controllers/selection.controller.ts b/packages/sheets-ui/src/controllers/selection.controller.tsindex 06124ed314..e1344edc73 100644--- a/packages/sheets-ui/src/controllers/selection.controller.ts+++ b/packages/sheets-ui/src/controllers/selection.controller.ts@@ -44,6 +44,7 @@ import { SetZoomRatioOperation } from '../commands/operations/set-zoom-ratio.opeimport { VIEWPORT_KEY } from '../common/keys';import { ISelectionRenderService } from '../services/selection/selection-render.service';import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';+import { ScrollController } from './scroll.controller';import type { ISheetObjectParam } from './utils/component-tools';import { getSheetObject } from './utils/component-tools';@@ -57,7 +58,8 @@ export class SelectionController extends Disposable {@ISelectionRenderServiceprivate readonly _selectionRenderService: ISelectionRenderService,@Inject(SelectionManagerService) private readonly _selectionManagerService: SelectionManagerService,- @Inject(ThemeService) private readonly _themeService: ThemeService+ @Inject(ThemeService) private readonly _themeService: ThemeService,+ @Inject(ScrollController) private readonly _scrollController: ScrollController) {super();@@ -259,6 +261,8 @@ export class SelectionController extends Disposable {this._selectionRenderService.selectionMoveEnd$.subscribe((params) => {this._move(params, SelectionMoveType.MOVE_END);++ this._scrollController.scrollToVisible(false);});}