Skip to content

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.

feat(thread-comment): didn't show tips on merge-cell comment (#3819)

zhangw65cb1c5a8b36
diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.ts
index 5f5558d645..b6e41c27c8 100644
--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.ts
+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.ts
@@ -17,11 +17,12 @@
import type { Nullable, Workbook } from '@univerjs/core';
import type { ISelectionWithStyle } from '@univerjs/sheets';
import type { IDeleteCommentMutationParams } from '@univerjs/thread-comment';
-import { Disposable, ICommandService, Inject, IUniverInstanceService, RANGE_TYPE, UniverInstanceType } from '@univerjs/core';
+import { Disposable, ICommandService, Inject, IUniverInstanceService, RANGE_TYPE, Rectangle, UniverInstanceType } from '@univerjs/core';
import { singleReferenceToGrid } from '@univerjs/engine-formula';
+import { IRenderManagerService } from '@univerjs/engine-render';
import { RangeProtectionPermissionViewPoint, SetWorksheetActiveOperation, SheetsSelectionsService, WorkbookCommentPermission, WorksheetViewPermission } from '@univerjs/sheets';
import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
-import { IEditorBridgeService, IMarkSelectionService, ScrollToRangeOperation, SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
+import { IEditorBridgeService, IMarkSelectionService, ScrollToRangeOperation, SheetPermissionInterceptorBaseController, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import { DeleteCommentMutation } from '@univerjs/thread-comment';
import { SetActiveCommentOperation, ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
import { debounceTime } from 'rxjs';
@@ -47,7 +48,8 @@ export class SheetsThreadCommentPopupController extends Disposable {
@Inject(SheetPermissionInterceptorBaseController) private readonly _sheetPermissionInterceptorBaseController: SheetPermissionInterceptorBaseController,
@IMarkSelectionService private readonly _markSelectionService: IMarkSelectionService,
@Inject(SheetsSelectionsService) private readonly _sheetSelectionService: SheetsSelectionsService,
- @IEditorBridgeService private readonly _editorBridgeService: IEditorBridgeService
+ @IEditorBridgeService private readonly _editorBridgeService: IEditorBridgeService,
+ @IRenderManagerService private readonly _renderManagerService: IRenderManagerService
) {
super();
@@ -60,19 +62,27 @@ export class SheetsThreadCommentPopupController extends Disposable {
private _handleSelectionChange(selections: ISelectionWithStyle[], unitId: string, subUnitId: string) {
const range = selections[0]?.range;
+ const render = this._renderManagerService.getRenderById(unitId);
+ const skeleton = render?.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)?.skeleton;
+ if (!skeleton) {
+ return;
+ }
+
if (!range) {
return;
}
+ const actualCell = skeleton.getCellByIndex(range.startRow, range.startColumn);
+
const rangeType = range.rangeType ?? RANGE_TYPE.NORMAL;
- if (rangeType !== RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) {
+ if ((rangeType !== RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && Rectangle.equals(actualCell.mergeInfo, range))) {
if (this._threadCommentPanelService.activeCommentId) {
this._commandService.executeCommand(SetActiveCommentOperation.id);
}
return;
}
- const row = range.startRow;
- const col = range.startColumn;
+ const row = actualCell.actualRow;
+ const col = actualCell.actualColumn;
if (!this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col)) {
if (this._threadCommentPanelService.activeCommentId) {
this._commandService.executeCommand(SetActiveCommentOperation.id);
diff --git a/packages/sheets-ui/src/common/utils.ts b/packages/sheets-ui/src/common/utils.ts
index 55aa9cbd2b..f21e672cee 100644
--- a/packages/sheets-ui/src/common/utils.ts
+++ b/packages/sheets-ui/src/common/utils.ts
@@ -265,14 +265,13 @@ export function getHoverCellPosition(currentRender: IRender, workbook: Workbook,
});
const actualCell = skeleton.getCellByIndex(actualRow, actualCol);
- const originCell = skeleton.getCellByIndex(cellIndex.row, cellIndex.col);
const originLocation = {
unitId,
subUnitId: sheetId,
workbook,
worksheet,
- row: originCell.actualRow,
- col: originCell.actualColumn,
+ row: actualCell.actualRow,
+ col: actualCell.actualColumn,
};
const location: ISheetLocation = getCellRealRange(workbook, worksheet, skeleton, actualRow, actualCol);