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: cross selection failed (#4226)
lumixcbc58ea94a58
diff --git a/packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsx b/packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsxindex 407c1a91fc..b5fbf23a74 100644--- a/packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsx+++ b/packages-experimental/uniui/src/views/uni-toolbar/UniFormulaBar.tsx@@ -96,6 +96,7 @@ export function FormulaBar() {worksheetProtectionRuleModel.ruleChange$,rangeProtectionRuleModel.ruleChange$,selectionManager.selectionMoveEnd$,+ selectionManager.selectionSet$,workbook.activeSheet$).pipe(switchMap(() => {@@ -207,13 +208,13 @@ export function FormulaBar() {<div className={styles.uniFormulaBox}><TextEditorid={DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY}- isSheetEditor={true}+ isSheetEditorresizeCallBack={resizeCallBack}- cancelDefaultResizeListener={true}+ cancelDefaultResizeListeneronContextMenu={(e) => e.preventDefault()}className={clsx(styles.uniFormulaInput, styles.formulaContent)}snapshot={INITIAL_SNAPSHOT}- isSingle={true}+ isSingle/><div className={clsx(styles.formulaIcon, { [styles.formulaIconDisable]: disable })}><spandiff --git a/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.ts b/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.tsindex d244fb9d41..ea1f6cb769 100644--- a/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.ts+++ b/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.ts@@ -14,17 +14,17 @@* limitations under the License.*/-import { merge, Observable } from 'rxjs';-import type { IMenuSelectorItem } from '@univerjs/ui';import type { IAccessor, Workbook } from '@univerjs/core';-import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';-import { checkRangesEditablePermission, RangeProtectionPermissionEditPoint, SetWorksheetActiveOperation, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';--import { debounceTime } from 'rxjs/operators';+import type { IMenuSelectorItem } from '@univerjs/ui';import { ICommandService, IUniverInstanceService, Rectangle, UniverInstanceType } from '@univerjs/core';+import { checkRangesEditablePermission, RangeProtectionPermissionEditPoint, SetWorksheetActiveOperation, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';import { AddConditionalRuleMutation, ConditionalFormattingRuleModel, DeleteConditionalRuleMutation, MoveConditionalRuleMutation, SetConditionalRuleMutation } from '@univerjs/sheets-conditional-formatting';import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';+import { merge, Observable } from 'rxjs';++import { debounceTime } from 'rxjs/operators';import { CF_MENU_OPERATION, OpenConditionalFormattingOperator } from '../commands/operations/open-conditional-formatting-panel';const commandList = [@@ -85,6 +85,7 @@ export const FactoryManageConditionalFormattingRule = (accessor: IAccessor): IMeconst clearRangeEnable$ = new Observable<boolean>((subscriber) => merge(selectionManagerService.selectionMoveEnd$,+ selectionManagerService.selectionSet$,new Observable<null>((commandSubscribe) => {const disposable = commandService.onCommandExecuted((commandInfo) => {const { id, params } = commandInfo;@@ -164,4 +165,3 @@ export const FactoryManageConditionalFormattingRule = (accessor: IAccessor): IMedisabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),} as IMenuSelectorItem;};-diff --git a/packages/sheets-crosshair-highlight/src/views/widgets/crosshair-highlight.render-controller.ts b/packages/sheets-crosshair-highlight/src/views/widgets/crosshair-highlight.render-controller.tsindex d291b8971e..e3a4967a11 100644--- a/packages/sheets-crosshair-highlight/src/views/widgets/crosshair-highlight.render-controller.ts+++ b/packages/sheets-crosshair-highlight/src/views/widgets/crosshair-highlight.render-controller.ts@@ -15,16 +15,16 @@*/import type { IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';-import { ColorKit, Disposable, IContextService, Inject, RANGE_TYPE } from '@univerjs/core';-import type { IRenderContext, IRenderModule, Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';-import { getCoordByCell, SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import type { ISelectionWithStyle } from '@univerjs/sheets';+import { ColorKit, Disposable, IContextService, Inject, RANGE_TYPE } from '@univerjs/core';import { DISABLE_NORMAL_SELECTIONS, IRefSelectionsService, SheetsSelectionsService } from '@univerjs/sheets';+import { getCoordByCell, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { combineLatest, map, merge, startWith, tap } from 'rxjs';import { SHEETS_CROSSHAIR_HIGHLIGHT_Z_INDEX } from '../../const';-import { CrossHairRangeCollection } from '../../util';import { SheetsCrosshairHighlightService } from '../../services/crosshair.service';+import { CrossHairRangeCollection } from '../../util';import { SheetCrossHairHighlightShape } from './crosshair-highlight-shape';export class SheetCrosshairHighlightRenderController extends Disposable implements IRenderModule {@@ -80,12 +80,14 @@ export class SheetCrosshairHighlightRenderController extends Disposable implementhis._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,+ this._sheetsSelectionsService.selectionSet$,workbook.activeSheet$.pipe(map(() => this._sheetsSelectionsService.getCurrentSelections()))),merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,+ this._sheetsSelectionsService.selectionSet$,workbook.activeSheet$.pipe(map(() => this._refSelectionsService.getCurrentSelections()))),]).subscribe(([normalSelDisabled, _, enabled, _color, normalSelections, refSelection]) => {diff --git a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts b/packages/sheets-formula-ui/src/controllers/prompt.controller.tsindex 1e2af01479..a53306082a 100644--- a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/prompt.controller.ts@@ -446,7 +446,7 @@ export class PromptController extends Disposable {d.dispose();if (selections.length === 0) return;- // Theme color should be set when SelectionControl is created, it's too late to set theme color at selecitonEnd(pointerup).+ // Theme color should be set when SelectionControl is created, it's too late to set theme color at selection End(pointerup).// The logic below has been moved to syncToEditor.// this._allSelectionRenderServices.forEach((r) => this._updateRefSelectionStyle(r, this._isSelectionMovingRefSelections));const docID = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)?.getUnitId() || '';@@ -1072,8 +1072,10 @@ export class PromptController extends Disposable {// if (lastRange) {// selectionWithStyle.push(lastRange);// }++ // why use sheetId not currSheetId ???if (selectionWithStyle.length) {- this._refSelectionsService.setSelections(unitId, currSheetId, selectionWithStyle, SelectionMoveType.ONLY_SET);+ this._refSelectionsService.setSelections(unitId, sheetId, selectionWithStyle, SelectionMoveType.ONLY_SET);}}diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.tsindex 3c331f9349..c390d4733c 100644--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts@@ -63,9 +63,9 @@ import { getEditorObject } from '../../basics/editor/get-editor-object';import { MoveSelectionCommand, MoveSelectionEnterAndTabCommand } from '../../commands/commands/set-selection.command';import { SetCellEditVisibleArrowOperation, SetCellEditVisibleWithF2Operation } from '../../commands/operations/cell-edit.operation';import { ScrollToRangeOperation } from '../../commands/operations/scroll-to-range.operation';+import { IEditorBridgeService } from '../../services/editor-bridge.service';import { ICellEditorManagerService } from '../../services/editor/cell-editor-manager.service';import { SheetCellEditorResizeService } from '../../services/editor/cell-editor-resize.service';-import { IEditorBridgeService } from '../../services/editor-bridge.service';import { MOVE_SELECTION_KEYCODE_LIST } from '../shortcuts/editor.shortcut';import { extractStringFromForceString, isForceString } from '../utils/cell-tools';import { normalizeString } from '../utils/char-tools';diff --git a/packages/sheets-ui/src/controllers/render-controllers/editor-bridge.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/editor-bridge.render-controller.tsindex 57ff736878..6ffe1e4d6c 100644--- a/packages/sheets-ui/src/controllers/render-controllers/editor-bridge.render-controller.ts+++ b/packages/sheets-ui/src/controllers/render-controllers/editor-bridge.render-controller.ts@@ -86,6 +86,7 @@ export class EditorBridgeRenderController extends RxDisposable implements IRendeprivate _initSelectionChangeListener(d: DisposableCollection) {d.add(merge(this._selectionManagerService.selectionMoveEnd$,+ this._selectionManagerService.selectionSet$,this._selectionManagerService.selectionMoveStart$).subscribe((params) => this._updateEditorPosition(params)));}diff --git a/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts b/packages/sheets-ui/src/services/mark-selection/mark-selection.service.tsindex af528fa67e..af267cfa5f 100644--- a/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts+++ b/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts@@ -47,7 +47,7 @@ export const IMarkSelectionService = createIdentifier<IMarkSelectionService>('un/*** For copy and cut selection.* also for selection when hover on conditional format items in the cf panel on the right.- * but hover on panel if data validation, uses another method to draw selection.+ * NOT FOR hovering on panel in data validation.*/export class MarkSelectionService extends Disposable implements IMarkSelectionService {private _shapeMap: Map<string, IMarkSelectionInfo> = new Map();diff --git a/packages/sheets-ui/src/services/selection/base-selection-render.service.ts b/packages/sheets-ui/src/services/selection/base-selection-render.service.tsindex 6055eca236..c2a4695c09 100644--- a/packages/sheets-ui/src/services/selection/base-selection-render.service.ts+++ b/packages/sheets-ui/src/services/selection/base-selection-render.service.ts@@ -440,7 +440,6 @@ export class BaseSelectionRenderService extends Disposable implements ISheetSele* @param moveStartPosX* @param moveStartPosY*/-protected _setupPointerMoveListener(viewportMain: Nullable<Viewport>,activeSelectionControl: SelectionControl,diff --git a/packages/sheets/src/services/selections/selection.service.ts b/packages/sheets/src/services/selections/selection.service.tsindex 4f4e52cfd8..1ba4920279 100644--- a/packages/sheets/src/services/selections/selection.service.ts+++ b/packages/sheets/src/services/selections/selection.service.ts@@ -128,7 +128,8 @@ export class SheetsSelectionsService extends RxDisposable {): void {if (typeof unitIdOrSelections === 'string' && typeof worksheetIdOrType === 'string') {const unitId = unitIdOrSelections as string;- this._ensureWorkbookSelection(unitId).setSelections(+ const selectionModel = this.getWorkbookSelections(unitId);+ selectionModel.setSelections(worksheetIdOrType,selectionDatas || [],type ?? SelectionMoveType.ONLY_SET