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.

fix(sheets-data-validation): data validation validator empty ranges & comment active issue & sheet-hyper-link autofill (#3003)

zhangw3271885ad1a4
diff --git a/packages/sheets-data-validation/src/locale/en-US.ts b/packages/sheets-data-validation/src/locale/en-US.ts
index 7a2b9cf0f7..070b49d976 100644
--- a/packages/sheets-data-validation/src/locale/en-US.ts
+++ b/packages/sheets-data-validation/src/locale/en-US.ts
@@ -52,6 +52,7 @@ const locale: typeof zhCN = {
rejectInput: 'Reject input',
messageInfo: 'Helper message',
showInfo: 'Show help text for a selected cell',
+ rangeError: 'Ranges are not legal',
},
operators: {
between: 'between',
diff --git a/packages/sheets-data-validation/src/locale/ru-RU.ts b/packages/sheets-data-validation/src/locale/ru-RU.ts
index 6c31aa46b8..f80b0a823d 100644
--- a/packages/sheets-data-validation/src/locale/ru-RU.ts
+++ b/packages/sheets-data-validation/src/locale/ru-RU.ts
@@ -39,6 +39,7 @@ const locale: typeof zhCN = {
removeAll: 'Удалить все',
add: 'добавить правило',
range: 'Диапазоны',
+ rangeError: 'Диапазоны не являются законными',
type: 'Тип',
options: 'Дополнительные параметры',
operator: 'Оператор',
diff --git a/packages/sheets-data-validation/src/locale/vi-VN.ts b/packages/sheets-data-validation/src/locale/vi-VN.ts
index 1265e0fab3..5bbf37867d 100644
--- a/packages/sheets-data-validation/src/locale/vi-VN.ts
+++ b/packages/sheets-data-validation/src/locale/vi-VN.ts
@@ -39,6 +39,7 @@ const locale: typeof zhCN = {
removeAll: 'Xóa tất cả',
add: 'Tạo quy tắc mới',
range: 'Phạm vi áp dụng',
+ rangeError: 'Phạm vi không hợp pháp',
type: 'Loại điều kiện',
options: 'Cài đặt nâng cao',
operator: 'Dữ liệu',
diff --git a/packages/sheets-data-validation/src/locale/zh-CN.ts b/packages/sheets-data-validation/src/locale/zh-CN.ts
index 8bf1f4df96..5f0652a35f 100644
--- a/packages/sheets-data-validation/src/locale/zh-CN.ts
+++ b/packages/sheets-data-validation/src/locale/zh-CN.ts
@@ -37,6 +37,7 @@ const locale = {
removeAll: '全部删除',
add: '新建规则',
range: '应用范围',
+ rangeError: '请输入合法的应用范围',
type: '条件类型',
options: '高级设置',
operator: '数据',
diff --git a/packages/sheets-data-validation/src/locale/zh-TW.ts b/packages/sheets-data-validation/src/locale/zh-TW.ts
index 88747f505d..f3da9dbe20 100644
--- a/packages/sheets-data-validation/src/locale/zh-TW.ts
+++ b/packages/sheets-data-validation/src/locale/zh-TW.ts
@@ -39,6 +39,7 @@ const locale: typeof zhCN = {
removeAll: '全部刪除',
add: '新建規則',
range: '應用範圍',
+ rangeError: '應用範圍不合法',
type: '條件型別',
options: '進階設定',
operator: '資料',
diff --git a/packages/sheets-data-validation/src/views/detail/index.tsx b/packages/sheets-data-validation/src/views/detail/index.tsx
index 2deffe2a7d..3f1609ab97 100644
--- a/packages/sheets-data-validation/src/views/detail/index.tsx
+++ b/packages/sheets-data-validation/src/views/detail/index.tsx
@@ -81,6 +81,9 @@ export function DataValidationDetail() {
const isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT.includes(localRule.operator) : false;
const handleOk = () => {
+ if (!localRule.ranges.length) {
+ return;
+ }
if (validator.validatorFormula(localRule, unitId, subUnitId).success) {
dataValidationPanelService.setActiveRule(null);
} else {
@@ -209,7 +212,10 @@ export function DataValidationDetail() {
};
return (
<div>
- <FormLayout label={localeService.t('dataValidation.panel.range')}>
+ <FormLayout
+ label={localeService.t('dataValidation.panel.range')}
+ error={!localRule.ranges.length ? localeService.t('dataValidation.panel.rangeError') : ''}
+ >
<RangeSelector
key={key}
className={styles.dataValidationDetailFormItem}
diff --git a/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.ts
index 8a54fbbb81..3c2d31d78c 100644
--- a/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.ts
+++ b/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.ts
@@ -78,62 +78,60 @@ export class SheetsHyperLinkAutoFillController extends Disposable {
);
const { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn);
const link = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, sourceRow, sourceCol);
- if (link) {
- const targetPositionRange = Rectangle.getPositionRange(
- {
- startRow: row,
- startColumn: col,
- endColumn: col,
- endRow: row,
+ const targetPositionRange = Rectangle.getPositionRange(
+ {
+ startRow: row,
+ startColumn: col,
+ endColumn: col,
+ endRow: row,
+ },
+ targetRange
+ );
+ const { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
+ const id = Tools.generateRandomId();
+ const currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
+ if (currentLink) {
+ redos.push({
+ id: RemoveHyperLinkMutation.id,
+ params: {
+ unitId,
+ subUnitId,
+ id: currentLink.id,
},
- targetRange
- );
- const { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
- const id = Tools.generateRandomId();
- const currentLink = this._hyperLinkModel.getHyperLinkByLocation(unitId, subUnitId, targetRow, targetCol);
- if (currentLink) {
- redos.push({
- id: RemoveHyperLinkMutation.id,
- params: {
- unitId,
- subUnitId,
- id: currentLink.id,
- },
- });
- }
- if (APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) {
- redos.push({
- id: AddHyperLinkMutation.id,
- params: {
- unitId,
- subUnitId,
- link: {
- ...link,
- id,
- row: targetRow,
- column: targetCol,
- },
- },
- });
- undos.push({
- id: RemoveHyperLinkMutation.id,
- params: {
- unitId,
- subUnitId,
+ });
+ }
+ if ((APPLY_TYPE.COPY === applyType || APPLY_TYPE.SERIES === applyType) && link) {
+ redos.push({
+ id: AddHyperLinkMutation.id,
+ params: {
+ unitId,
+ subUnitId,
+ link: {
+ ...link,
id,
+ row: targetRow,
+ column: targetCol,
},
- });
- }
- if (currentLink) {
- undos.push({
- id: AddHyperLinkMutation.id,
- params: {
- unitId,
- subUnitId,
- link: currentLink,
- },
- });
- }
+ },
+ });
+ undos.push({
+ id: RemoveHyperLinkMutation.id,
+ params: {
+ unitId,
+ subUnitId,
+ id,
+ },
+ });
+ }
+ if (currentLink) {
+ undos.push({
+ id: AddHyperLinkMutation.id,
+ params: {
+ unitId,
+ subUnitId,
+ link: currentLink,
+ },
+ });
}
});
});
diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
index cbc2ec9bba..4c988d19ac 100644
--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
@@ -92,6 +92,9 @@ export class SheetsThreadCommentController extends Disposable {
if ((type === SelectionMoveType.MOVE_END || type === undefined) && selections[0]?.primary) {
const range = selections[0].range;
if (range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) {
+ if (this._threadCommentPanelService.activeCommentId) {
+ this._commandService.executeCommand(SetActiveCommentOperation.id);
+ }
return;
}
const row = selections[0].primary.actualRow;
diff --git a/packages/ui/src/services/editor/editor.service.ts b/packages/ui/src/services/editor/editor.service.ts
index 9c07b1748a..8f23999e03 100644
--- a/packages/ui/src/services/editor/editor.service.ts
+++ b/packages/ui/src/services/editor/editor.service.ts
@@ -433,7 +433,7 @@ export class EditorService extends Disposable implements IEditorService, IDispos
editor.setFocus(true);
- // this._contextService.setContextValue(EDITOR_ACTIVATED, true);
+ this._contextService.setContextValue(EDITOR_ACTIVATED, true);
this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, true);
this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, editor.isSingle());