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.

chore: add keydown event to remove ant line (#5569)

ybzky2f790626da96
diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts
index 5c2c8819cd..42ca6fc940 100644
--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts
+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts
@@ -175,6 +175,12 @@ export class SheetClipboardController extends RxDisposable {
this._commandService.executeCommand(SheetPasteShortKeyCommand.id, { htmlContent, textContent, files });
});
+
+ docSelectionRenderService?.onKeydown$.subscribe((event) => {
+ if ((event.event as KeyboardEvent).key === 'Escape') {
+ this._sheetClipboardService.removeMarkSelection();
+ }
+ });
};
// docSelectionRenderService would init before clipboardService controller when creating a univer.
diff --git a/packages/sheets/src/facade/f-permission.ts b/packages/sheets/src/facade/f-permission.ts
index 9ef7245684..5d74ce5aa8 100644
--- a/packages/sheets/src/facade/f-permission.ts
+++ b/packages/sheets/src/facade/f-permission.ts
@@ -18,7 +18,7 @@ import type { RangePermissionPointConstructor, WorkbookPermissionPointConstructo
import type { ISetWorksheetPermissionPointsMutationParams } from '@univerjs/sheets';
import type { Observable } from 'rxjs';
import type { FRange } from './f-range';
-import { generateRandomId, IAuthzIoService, ICommandService, Inject, Injector, IPermissionService, Rectangle } from '@univerjs/core';
+import { cellToRange, generateRandomId, IAuthzIoService, ICommandService, Inject, Injector, IPermissionService, Rectangle } from '@univerjs/core';
import { FBase } from '@univerjs/core/facade';
import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, DeleteRangeProtectionMutation, DeleteWorksheetProtectionMutation, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, PermissionPointsDefinitions, RangeProtectionRuleModel, SetRangeProtectionMutation, SetWorksheetPermissionPointsMutation, UnitObject, WorkbookEditablePermission, WorksheetEditPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';
@@ -445,4 +445,23 @@ export class FPermission extends FBase {
});
}
}
+
+ getPermissionInfoWithCell(unitId: string, subUnitId: string, row: number, column: number): {
+ permissionId: string;
+ ruleId: string;
+ } | undefined {
+ const cellRange = cellToRange(row, column);
+ const overlapRule = this._rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).find((rule) => {
+ const ranges = rule.ranges;
+ return ranges.some((range) => {
+ return Rectangle.intersects(cellRange, range);
+ });
+ });
+ if (overlapRule) {
+ return {
+ permissionId: overlapRule.permissionId,
+ ruleId: overlapRule.id,
+ };
+ }
+ }
}