@univerjs/sheets-ui 0.4.0 → 0.4.1-nightly.202410201605
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +3 -3
- package/lib/es/index.js +1999 -1982
- package/lib/types/commands/commands/__tests__/create-selection-command-test-bed.d.ts +3 -3
- package/lib/types/commands/commands/set-selection.command.d.ts +4 -4
- package/lib/types/services/selection/base-selection-render.service.d.ts +13 -5
- package/lib/types/services/selection/mobile-selection-render.service.d.ts +0 -1
- package/lib/umd/index.js +3 -3
- package/package.json +11 -11
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -3,15 +3,15 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
5
|
import { DOCS_VIEW_KEY, getCanvasOffsetByEngine, IEditorService, NodePositionConvertToCursor, getLineBounding, DOC_VERTICAL_PADDING, SetInlineFormatBoldCommand, SetInlineFormatItalicCommand, SetInlineFormatUnderlineCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatFontSizeCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatTextColorCommand, TextEditor, SetInlineFormatCommand, BreakLineCommand, DeleteLeftCommand, DocSelectionRenderService, VIEWPORT_KEY, DOCS_COMPONENT_MAIN_LAYER_INDEX, MoveSelectionOperation, MoveCursorOperation, CoverContentCommand, IMEInputCommand, InsertCommand, IRangeSelectorService } from "@univerjs/docs-ui";
|
|
6
|
-
import { Inject, Injector, Disposable, CommandType, IUniverInstanceService, ICommandService, UniverInstanceType,
|
|
7
|
-
import { SpreadsheetSkeleton, IRenderManagerService,
|
|
8
|
-
import { getSheetCommandTarget, alignToMergedCellsBorders, getSelectionsService, getCellAtRowCol, SetSelectionsOperation, expandToContinuousRange, ScrollToCellOperation, IExclusiveRangeService, SheetsSelectionsService, RangeProtectionRuleModel, WorksheetProtectionRuleModel, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, WorkbookManageCollaboratorPermission,
|
|
9
|
-
import { BehaviorSubject, switchMap, of, combineLatest, map, startWith, merge, debounceTime, takeUntil, distinctUntilChanged,
|
|
6
|
+
import { Inject, Injector, Disposable, CommandType, IUniverInstanceService, ICommandService, UniverInstanceType, createInterceptorKey, RANGE_TYPE, makeCellToSelection, toDisposable, ColorKit, Tools, Quantity, createIdentifier, InterceptorManager, LocaleService, Direction, Rectangle, getReverseDirection, Workbook, FOCUSING_SHEET, IContextService, UserManagerService, FOCUSING_COMMON_DRAWINGS, IPermissionService, RxDisposable, ThemeService, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, CellValueType, CustomRangeType, PresetListType, VerticalAlign, HorizontalAlign, ObjectMatrix, isFormulaString, isFormulaId, numfmt, IUndoRedoService, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, Optional, DisposableCollection, sortRules, sequenceExecute, Dimension, ILogService, BorderStyleTypes, useDependency, createInternalEditorID, AbsoluteRefType, useObservable as useObservable$1, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor, WrapStrategy, BooleanNumber, IConfigService, nameCharacterCheck, debounce, FOCUSING_UNIVER_EDITOR, FOCUSING_FX_BAR_EDITOR, FOCUSING_EDITOR_INPUT_FORMULA, LRUMap, BaselineOffset, DataStreamTreeTokenType, skipParseTagNames, generateRandomId, DEFAULT_WORKSHEET_ROW_HEIGHT, ErrorService, extractPureTextFromCell, FontWeight, FontItalic, DEFAULT_STYLES, NilCommand, connectInjector, LocaleType, FOCUSING_EDITOR_BUT_HIDDEN, Range, cellToRange, convertBodyToHtml, handleStyleToString, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, isRealNum, InterceptorEffectEnum, fromEventSubject, IAuthzIoService, CustomCommandExecutionError, isICellData, splitIntoGrid, isValidRange, DependentOn, Plugin, registerDependencies, mergeOverrideWithDependencies, touchDependencies } from "@univerjs/core";
|
|
7
|
+
import { SpreadsheetSkeleton, IRenderManagerService, Rect, DashedRect, Group, TRANSFORM_CHANGE_OBSERVABLE_TYPE, cancelRequestFrame, requestNewFrame, FIX_ONE_PIXEL_BLUR_OFFSET, Layer, SHEET_VIEWPORT_KEY as SHEET_VIEWPORT_KEY$1, CURSOR_TYPE, Vector2, ScrollTimer, ScrollTimerType, PointerInput, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Spreadsheet, DeviceInputEventType, convertTextRotation, hasCJKText, ptToPixel, ScrollBar, fixLineWidthByScale, DEFAULT_PADDING_DATA, Shape, SheetExtension, RegularPolygon, SHEET_EXTENSION_PREFIX, SpreadsheetRowHeader, SpreadsheetColumnHeader, Viewport } from "@univerjs/engine-render";
|
|
8
|
+
import { getSheetCommandTarget, SELECTION_CONTROL_BORDER_BUFFER_COLOR, getNormalSelectionStyle, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, transformCellDataToSelectionData, alignToMergedCellsBorders, getSelectionsService, getCellAtRowCol, SetSelectionsOperation, expandToContinuousRange, ScrollToCellOperation, IExclusiveRangeService, SheetsSelectionsService, RangeProtectionRuleModel, WorksheetProtectionRuleModel, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, WorkbookManageCollaboratorPermission, IRefSelectionsService, SheetInterceptorService, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowAutoHeightMutation, SetRangeValuesCommand, SetWorksheetRowIsAutoHeightCommand, SetStyleCommand, SetRangeValuesMutation, generateNullCellValue, SetRangeValuesUndoMutationFactory, SetWorksheetActiveOperation, MoveRangeMutation, RemoveRowMutation, RemoveColMutation, InsertRowMutation, InsertColMutation, MoveRowsMutation, MoveColsMutation, SetWorksheetColWidthMutation, SetWorksheetRowHeightMutation, RemoveSheetMutation, RemoveMergeUndoMutationFactory, RemoveWorksheetMergeMutation, AddWorksheetMergeMutation, getAddMergeMutationRangeByType, AddMergeUndoMutationFactory, UnitAction, AddMergeRedoSelectionsOperationFactory, AddMergeUndoSelectionsOperationFactory, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, SetRowHiddenCommand, SetColHiddenCommand, SetBoldCommand, SetItalicCommand, SetUnderlineCommand, SetStrikeThroughCommand, SetFontSizeCommand, SetFontFamilyCommand, SetTextColorCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, AddWorksheetProtectionMutation, DeleteWorksheetProtectionMutation, SetWorksheetProtectionMutation, AddRangeProtectionMutation, DeleteRangeProtectionMutation, SetRangeProtectionMutation, RemoveRowCommand, RemoveColCommand, RemoveSheetCommand, SetFrozenMutationFactory, SetFrozenMutation, BorderStyleManagerService, InsertDefinedNameCommand, SetDefinedNameCommand, RemoveDefinedNameCommand, SetWorksheetShowCommand, WorksheetSetCellValuePermission, SetWorksheetOrderMutation, InsertSheetMutation, SetWorksheetNameMutation, SetWorksheetHideMutation, SetWorksheetActivateCommand, SetWorksheetNameCommand, SetWorksheetOrderCommand, WorkbookRenameSheetPermission, SetTabColorMutation, WorkbookCreateSheetPermission, InsertSheetCommand, getPrimaryForRange, WorksheetSetCellStylePermission, SetBorderBasicCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, ClearSelectionAllCommand, WorksheetDeleteColumnPermission, WorksheetDeleteRowPermission, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, InsertRowBeforeCommand, InsertRowAfterCommand, InsertColBeforeCommand, InsertColAfterCommand, WorksheetCopyPermission, ResetTextColorCommand, ResetBackgroundColorCommand, SetBackgroundColorCommand, SetHorizontalTextAlignCommand, SetVerticalTextAlignCommand, SetTextWrapCommand, SetTextRotationCommand, WorkbookCopyPermission, RangeProtectionPermissionViewPoint, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedRowsVisibleCommand, SetColHiddenMutation, SetColVisibleMutation, SetSelectedColsVisibleCommand, SetRowHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetColWidthCommand, MergeCellController, MERGE_CELL_INTERCEPTOR_CHECK, RemoveWorksheetMergeCommand, CopySheetCommand, SetTabColorCommand, SetWorksheetHideCommand, WorkbookDeleteSheetPermission, WorkbookHideSheetPermission, AddWorksheetMergeCommand as AddWorksheetMergeCommand$1, AddWorksheetMergeAllCommand as AddWorksheetMergeAllCommand$1, AddWorksheetMergeVerticalCommand as AddWorksheetMergeVerticalCommand$1, AddWorksheetMergeHorizontalCommand as AddWorksheetMergeHorizontalCommand$1, COMMAND_LISTENER_SKELETON_CHANGE, DISABLE_NORMAL_SELECTIONS, SelectionMoveType, convertSelectionDataToRange, RefRangeService, ToggleCellCheckboxCommand, MoveRangeCommand, MAX_CELL_PER_SHEET_KEY, INTERCEPTOR_POINT, WorksheetProtectionPointModel, RangeProtectionCache, getAllRangePermissionPoint, getAllWorksheetPermissionPointByPointPanel, defaultWorkbookPermissionPoints, getAllWorkbookPermissionPoint, getAllWorksheetPermissionPoint, defaultWorksheetPermissionPoint, WorksheetViewPermission, SetWorksheetPermissionPointsMutation, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, WorkbookMoveSheetPermission, MoveRowsCommand, MoveColsCommand, DeltaRowHeightCommand, DeltaColumnWidthCommand, SetFrozenCommand, InsertRowCommand, InsertColCommand, INumfmtService, AddRangeProtectionCommand as AddRangeProtectionCommand$1, DeleteRangeProtectionCommand, setEndForRange, SetWorksheetPermissionPointsCommand, COMMAND_LISTENER_VALUE_CHANGE, UniverSheetsPlugin, RefSelectionsService } from "@univerjs/sheets";
|
|
9
|
+
import { BehaviorSubject, Subject, switchMap, of, combineLatest, map, startWith, merge, debounceTime, takeUntil, distinctUntilChanged, mergeMap, EMPTY, Observable, combineLatestWith, filter, throttleTime, skip, Subscription, withLatestFrom } from "rxjs";
|
|
10
10
|
import { KeyCode, IConfirmService, ISidebarService, IDialogService, ComponentManager, IContextMenuService, useObservable, DISABLE_AUTO_FOCUS_KEY, ProgressBar, PLUGIN_CONFIG_KEY as PLUGIN_CONFIG_KEY$1, Menu as Menu$1, ContextMenuPosition, IMessageService, IClipboardInterfaceService, IMenuManagerService, ToolbarItem, DEFAULT_BACKGROUND_COLOR_RGB, DEFAULT_BACKGROUND_COLOR_RGBA, handleStringToStyle, textTrim, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, INotificationService, IPlatformService, CopyCommand, CutCommand, PasteCommand, MenuItemType, getMenuHiddenObservable, FONT_FAMILY_LIST, FONT_SIZE_LIST, RibbonStartGroup, ContextMenuGroup, MetaKeys, FontFamily, FontFamilyItem, FontSize, BuiltInUIPart, ILayoutService, IShortcutService, IUIPartsService, SetEditorResizeOperation, ICanvasPopupService, UniverMobileUIPlugin } from "@univerjs/ui";
|
|
11
11
|
import { DocSkeletonManagerService, SetTextSelectionsOperation, DocSelectionManagerService, RichTextEditingMutation } from "@univerjs/docs";
|
|
12
12
|
import React, { forwardRef, useRef, createElement, useState, useEffect, useMemo, useCallback, useLayoutEffect } from "react";
|
|
13
13
|
import { Dropdown, ColorPicker, Menu, MenuItem, InputNumber, Input, RadioGroup, Radio, Select, Button, Tooltip, Confirm, Slider, MessageType, Avatar, FormLayout, Switch } from "@univerjs/design";
|
|
14
|
-
import { IDefinedNamesService, IFunctionService, LexerTreeBuilder, operatorToken, isReferenceStrings, isReferenceStringWithEffectiveColumn, serializeRangeWithSheet, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_MATH, FUNCTION_NAMES_TEXT, sequenceNodeType, matchToken, deserializeRangeWithSheet, NullValueObject, serializeRange } from "@univerjs/engine-formula";
|
|
14
|
+
import { IDefinedNamesService, IFunctionService, LexerTreeBuilder, operatorToken, isReferenceStrings, isReferenceStringWithEffectiveColumn, serializeRangeWithSheet, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_MATH, FUNCTION_NAMES_TEXT, sequenceNodeType, matchToken, deserializeRangeWithSheet, NullValueObject, serializeRange, SetFormulaCalculationNotificationMutation } from "@univerjs/engine-formula";
|
|
15
15
|
import { filter as filter$1 } from "rxjs/operators";
|
|
16
16
|
import { ITelemetryService } from "@univerjs/telemetry";
|
|
17
17
|
var SheetsUIPart = /* @__PURE__ */ ((SheetsUIPart2) => (SheetsUIPart2.FILTER_PANEL_EMBED_POINT = "filter-panel-embed-point", SheetsUIPart2.SHEETS_FOOTER = "sheets-footer", SheetsUIPart2))(SheetsUIPart || {});
|
|
@@ -385,59 +385,7 @@ const SetScrollOperation = {
|
|
|
385
385
|
sheetViewStartColumn: 0
|
|
386
386
|
});
|
|
387
387
|
}, "handler")
|
|
388
|
-
}
|
|
389
|
-
var __defProp$T = Object.defineProperty, __getOwnPropDesc$T = Object.getOwnPropertyDescriptor, __decorateClass$T = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
390
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$T(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
391
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
392
|
-
return kind && result && __defProp$T(target, key, result), result;
|
|
393
|
-
}, "__decorateClass$T"), __decorateParam$T = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$T"), _a3;
|
|
394
|
-
let ShortcutExperienceService = (_a3 = class {
|
|
395
|
-
constructor(_univerInstanceService, _localeService) {
|
|
396
|
-
__publicField(this, "_current", null);
|
|
397
|
-
__publicField(this, "_shortcutParam", []);
|
|
398
|
-
this._univerInstanceService = _univerInstanceService, this._localeService = _localeService;
|
|
399
|
-
}
|
|
400
|
-
dispose() {
|
|
401
|
-
this._shortcutParam = [];
|
|
402
|
-
}
|
|
403
|
-
getCurrentBySearch(searchParm) {
|
|
404
|
-
return this._getCurrentBySearch(searchParm);
|
|
405
|
-
}
|
|
406
|
-
getCurrent() {
|
|
407
|
-
return this._getCurrentBySearch(this._current);
|
|
408
|
-
}
|
|
409
|
-
addOrUpdate(insertParam) {
|
|
410
|
-
const param = this._getCurrentBySearch({
|
|
411
|
-
unitId: insertParam.unitId,
|
|
412
|
-
sheetId: insertParam.sheetId,
|
|
413
|
-
keycode: insertParam.keycode
|
|
414
|
-
});
|
|
415
|
-
if (param != null) {
|
|
416
|
-
const index = this._shortcutParam.indexOf(param);
|
|
417
|
-
this._shortcutParam.splice(index, 1);
|
|
418
|
-
}
|
|
419
|
-
return this._shortcutParam.push(insertParam), param;
|
|
420
|
-
}
|
|
421
|
-
remove(searchParm) {
|
|
422
|
-
if (searchParm == null)
|
|
423
|
-
return;
|
|
424
|
-
const param = this._getCurrentBySearch(searchParm);
|
|
425
|
-
if (param == null)
|
|
426
|
-
return;
|
|
427
|
-
const index = this._shortcutParam.indexOf(param);
|
|
428
|
-
return this._shortcutParam.splice(index, 1)[0];
|
|
429
|
-
}
|
|
430
|
-
_getCurrentBySearch(searchParm) {
|
|
431
|
-
return searchParm == null ? void 0 : this._shortcutParam.find(
|
|
432
|
-
(param) => param.unitId === searchParm.unitId && param.sheetId === searchParm.sheetId && param.keycode === searchParm.keycode
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
}, __name(_a3, "ShortcutExperienceService"), _a3);
|
|
436
|
-
ShortcutExperienceService = __decorateClass$T([
|
|
437
|
-
__decorateParam$T(0, IUniverInstanceService),
|
|
438
|
-
__decorateParam$T(1, Inject(LocaleService))
|
|
439
|
-
], ShortcutExperienceService);
|
|
440
|
-
const _SelectAllService = class _SelectAllService extends Disposable {
|
|
388
|
+
}, _SelectAllService = class _SelectAllService extends Disposable {
|
|
441
389
|
constructor() {
|
|
442
390
|
super(...arguments);
|
|
443
391
|
__publicField(this, "rangesStack", []);
|
|
@@ -446,1319 +394,207 @@ const _SelectAllService = class _SelectAllService extends Disposable {
|
|
|
446
394
|
};
|
|
447
395
|
__name(_SelectAllService, "SelectAllService");
|
|
448
396
|
let SelectAllService = _SelectAllService;
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
next <= boundary.endRow ? (destRange.startRow = next, destRange.endRow = next) : isGoBack && (destRange.startRow = boundary.startRow, destRange.endRow = boundary.startRow, isFindNext && (destRange = findNextRange(destRange, Direction.RIGHT, worksheet, boundary, !1)));
|
|
469
|
-
break;
|
|
470
|
-
case Direction.LEFT:
|
|
471
|
-
for (next = startRange.startColumn - nextStep; next > -1 && !worksheet.getColVisible(next); )
|
|
472
|
-
next -= 1;
|
|
473
|
-
next >= boundary.startColumn ? (destRange.startColumn = next, destRange.endColumn = next) : isGoBack && (destRange.startColumn = boundary.endColumn, destRange.endColumn = boundary.endColumn, isFindNext && (destRange = findNextRange(destRange, Direction.UP, worksheet, boundary, !1)));
|
|
474
|
-
break;
|
|
475
|
-
case Direction.RIGHT:
|
|
476
|
-
for (next = startRange.endColumn + nextStep; next < worksheet.getColumnCount() && !worksheet.getColVisible(next); )
|
|
477
|
-
next += 1;
|
|
478
|
-
next <= boundary.endColumn ? (destRange.startColumn = next, destRange.endColumn = next) : isGoBack && (destRange.startColumn = boundary.startColumn, destRange.endColumn = boundary.startColumn, isFindNext && (destRange = findNextRange(destRange, Direction.DOWN, worksheet, boundary, !1)));
|
|
479
|
-
break;
|
|
397
|
+
const SHEET_ZOOM_RANGE = [10, 400], RANGE_SELECTOR_COMPONENT_KEY = "RANGE_SELECTOR_COMPONENT_KEY";
|
|
398
|
+
var SHEET_VIEW_KEY = /* @__PURE__ */ ((SHEET_VIEW_KEY2) => (SHEET_VIEW_KEY2.MAIN = "__SpreadsheetRender__", SHEET_VIEW_KEY2.ROW = "__SpreadsheetRowHeader__", SHEET_VIEW_KEY2.COLUMN = "__SpreadsheetColumnHeader__", SHEET_VIEW_KEY2.LEFT_TOP = "__SpreadsheetLeftTopPlaceholder__", SHEET_VIEW_KEY2))(SHEET_VIEW_KEY || {}), SHEET_VIEWPORT_KEY = /* @__PURE__ */ ((SHEET_VIEWPORT_KEY2) => (SHEET_VIEWPORT_KEY2.VIEW_MAIN = "viewMain", SHEET_VIEWPORT_KEY2.VIEW_MAIN_LEFT_TOP = "viewMainLeftTop", SHEET_VIEWPORT_KEY2.VIEW_MAIN_TOP = "viewMainTop", SHEET_VIEWPORT_KEY2.VIEW_MAIN_LEFT = "viewMainLeft", SHEET_VIEWPORT_KEY2.VIEW_ROW_TOP = "viewRowTop", SHEET_VIEWPORT_KEY2.VIEW_ROW_BOTTOM = "viewRowBottom", SHEET_VIEWPORT_KEY2.VIEW_COLUMN_LEFT = "viewColumnLeft", SHEET_VIEWPORT_KEY2.VIEW_COLUMN_RIGHT = "viewColumnRight", SHEET_VIEWPORT_KEY2.VIEW_LEFT_TOP = "viewLeftTop", SHEET_VIEWPORT_KEY2))(SHEET_VIEWPORT_KEY || {});
|
|
399
|
+
const SHEET_COMPONENT_MAIN_LAYER_INDEX = 0, SHEET_COMPONENT_SELECTION_LAYER_INDEX = 1, SHEET_COMPONENT_HEADER_LAYER_INDEX = 10, SHEET_COMPONENT_HEADER_SELECTION_LAYER_INDEX = 11, SHEET_COMPONENT_UNHIDE_LAYER_INDEX = 12, RANGE_MOVE_PERMISSION_CHECK = createInterceptorKey("rangeMovePermissionCheck"), RANGE_FILL_PERMISSION_CHECK = createInterceptorKey("rangeFillPermissionCheck");
|
|
400
|
+
var SELECTION_SHAPE_DEPTH = /* @__PURE__ */ ((SELECTION_SHAPE_DEPTH2) => (SELECTION_SHAPE_DEPTH2[SELECTION_SHAPE_DEPTH2.FORMULA_EDITOR_SHOW = 100] = "FORMULA_EDITOR_SHOW", SELECTION_SHAPE_DEPTH2[SELECTION_SHAPE_DEPTH2.MARK_SELECTION = 1e4] = "MARK_SELECTION", SELECTION_SHAPE_DEPTH2))(SELECTION_SHAPE_DEPTH || {});
|
|
401
|
+
const _SelectionRenderModel = class _SelectionRenderModel {
|
|
402
|
+
constructor() {
|
|
403
|
+
__publicField(this, "_startColumn", -1);
|
|
404
|
+
__publicField(this, "_startRow", -1);
|
|
405
|
+
__publicField(this, "_endColumn", -1);
|
|
406
|
+
__publicField(this, "_endRow", -1);
|
|
407
|
+
__publicField(this, "_startX", 0);
|
|
408
|
+
__publicField(this, "_startY", 0);
|
|
409
|
+
__publicField(this, "_endX", 0);
|
|
410
|
+
__publicField(this, "_endY", 0);
|
|
411
|
+
/**
|
|
412
|
+
* The highlight cell of a selection. aka: current cell
|
|
413
|
+
*/
|
|
414
|
+
__publicField(this, "_primary");
|
|
415
|
+
__publicField(this, "_rangeType", RANGE_TYPE.NORMAL);
|
|
480
416
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
__name(findNextRange, "findNextRange");
|
|
484
|
-
function findNextGapRange(startRange, direction, worksheet) {
|
|
485
|
-
const destRange = { ...startRange }, { startRow, startColumn, endRow, endColumn } = getEdgeOfRange(startRange, direction, worksheet);
|
|
486
|
-
let currentPositionHasValue = rangeHasValue(worksheet, startRow, startColumn, endRow, endColumn).hasValue, firstMove = !0, shouldContinue = !0;
|
|
487
|
-
for (; shouldContinue; ) {
|
|
488
|
-
if (Direction.UP === direction) {
|
|
489
|
-
let next = destRange.startRow - 1;
|
|
490
|
-
for (; next > -1 && !worksheet.getRowVisible(next); )
|
|
491
|
-
next -= 1;
|
|
492
|
-
if (next === -1) {
|
|
493
|
-
shouldContinue = !1;
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
497
|
-
worksheet,
|
|
498
|
-
next,
|
|
499
|
-
destRange.startColumn,
|
|
500
|
-
next,
|
|
501
|
-
destRange.endColumn
|
|
502
|
-
);
|
|
503
|
-
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
504
|
-
shouldContinue = !1;
|
|
505
|
-
break;
|
|
506
|
-
} else {
|
|
507
|
-
if (matrix.getLength() !== 0) {
|
|
508
|
-
let min = next;
|
|
509
|
-
matrix.forValue((row) => {
|
|
510
|
-
min = Math.min(row, min);
|
|
511
|
-
}), destRange.startRow = min;
|
|
512
|
-
} else
|
|
513
|
-
destRange.startRow = next;
|
|
514
|
-
if (destRange.endRow = destRange.startRow, !currentPositionHasValue && nextRangeHasValue) {
|
|
515
|
-
shouldContinue = !1;
|
|
516
|
-
break;
|
|
517
|
-
}
|
|
518
|
-
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
if (Direction.DOWN === direction) {
|
|
522
|
-
let next = destRange.endRow + 1;
|
|
523
|
-
for (; next < worksheet.getRowCount() && !worksheet.getRowVisible(next); )
|
|
524
|
-
next += 1;
|
|
525
|
-
if (next === worksheet.getRowCount()) {
|
|
526
|
-
shouldContinue = !1;
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
530
|
-
worksheet,
|
|
531
|
-
next,
|
|
532
|
-
destRange.startColumn,
|
|
533
|
-
next,
|
|
534
|
-
destRange.endColumn
|
|
535
|
-
);
|
|
536
|
-
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
537
|
-
shouldContinue = !1;
|
|
538
|
-
break;
|
|
539
|
-
} else {
|
|
540
|
-
if (matrix.getLength() !== 0) {
|
|
541
|
-
let max = next;
|
|
542
|
-
matrix.forValue((row, _, value) => {
|
|
543
|
-
max = Math.max(row + (value.rowSpan || 1) - 1, max);
|
|
544
|
-
}), destRange.endRow = max;
|
|
545
|
-
} else
|
|
546
|
-
destRange.endRow = next;
|
|
547
|
-
if (destRange.startRow = destRange.endRow, !currentPositionHasValue && nextRangeHasValue) {
|
|
548
|
-
shouldContinue = !1;
|
|
549
|
-
break;
|
|
550
|
-
}
|
|
551
|
-
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
if (Direction.LEFT === direction) {
|
|
555
|
-
let next = destRange.startColumn - 1;
|
|
556
|
-
for (; next > -1 && !worksheet.getColVisible(next); )
|
|
557
|
-
next -= 1;
|
|
558
|
-
if (next === -1) {
|
|
559
|
-
shouldContinue = !1;
|
|
560
|
-
break;
|
|
561
|
-
}
|
|
562
|
-
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
563
|
-
worksheet,
|
|
564
|
-
destRange.startRow,
|
|
565
|
-
next,
|
|
566
|
-
destRange.endRow,
|
|
567
|
-
next
|
|
568
|
-
);
|
|
569
|
-
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
570
|
-
shouldContinue = !1;
|
|
571
|
-
break;
|
|
572
|
-
} else {
|
|
573
|
-
if (matrix.getLength() !== 0) {
|
|
574
|
-
let min = next;
|
|
575
|
-
matrix.forValue((_, col) => {
|
|
576
|
-
min = Math.min(col, min);
|
|
577
|
-
}), destRange.startColumn = min;
|
|
578
|
-
} else
|
|
579
|
-
destRange.startColumn = next;
|
|
580
|
-
if (destRange.endColumn = destRange.startColumn, !currentPositionHasValue && nextRangeHasValue) {
|
|
581
|
-
shouldContinue = !1;
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
584
|
-
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
if (Direction.RIGHT === direction) {
|
|
588
|
-
let next = destRange.endColumn + 1;
|
|
589
|
-
for (; next < worksheet.getColumnCount() && !worksheet.getColVisible(next); )
|
|
590
|
-
next += 1;
|
|
591
|
-
if (next === worksheet.getColumnCount()) {
|
|
592
|
-
shouldContinue = !1;
|
|
593
|
-
break;
|
|
594
|
-
}
|
|
595
|
-
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
596
|
-
worksheet,
|
|
597
|
-
destRange.startRow,
|
|
598
|
-
next,
|
|
599
|
-
destRange.endRow,
|
|
600
|
-
next
|
|
601
|
-
);
|
|
602
|
-
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
603
|
-
shouldContinue = !1;
|
|
604
|
-
break;
|
|
605
|
-
} else {
|
|
606
|
-
if (matrix.getLength() !== 0) {
|
|
607
|
-
let max = next;
|
|
608
|
-
matrix.forValue((_, col, value) => {
|
|
609
|
-
max = Math.max(col + (value.colSpan || 1) - 1, max);
|
|
610
|
-
}), destRange.endColumn = max;
|
|
611
|
-
} else
|
|
612
|
-
destRange.endColumn = next;
|
|
613
|
-
if (destRange.startColumn = destRange.endColumn, !currentPositionHasValue && nextRangeHasValue) {
|
|
614
|
-
shouldContinue = !1;
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
417
|
+
get startColumn() {
|
|
418
|
+
return this._startColumn;
|
|
620
419
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
__name(findNextGapRange, "findNextGapRange");
|
|
624
|
-
function findNextRangeExpand(startRange, direction, worksheet) {
|
|
625
|
-
return findNextRange(startRange, direction, worksheet, void 0, !1, 1, !1);
|
|
626
|
-
}
|
|
627
|
-
__name(findNextRangeExpand, "findNextRangeExpand");
|
|
628
|
-
function expandToNextGapRange(startRange, direction, worksheet) {
|
|
629
|
-
const next = findNextGapRange(startRange, direction, worksheet);
|
|
630
|
-
return alignToMergedCellsBorders(Rectangle.union(next, startRange), worksheet, !0);
|
|
631
|
-
}
|
|
632
|
-
__name(expandToNextGapRange, "expandToNextGapRange");
|
|
633
|
-
function expandToNextCell(startRange, direction, worksheet) {
|
|
634
|
-
const next = findNextRangeExpand(startRange, direction, worksheet), destRange = {
|
|
635
|
-
startRow: Math.min(startRange.startRow, next.startRow),
|
|
636
|
-
startColumn: Math.min(startRange.startColumn, next.startColumn),
|
|
637
|
-
endRow: Math.max(startRange.endRow, next.endRow),
|
|
638
|
-
endColumn: Math.max(startRange.endColumn, next.endColumn)
|
|
639
|
-
};
|
|
640
|
-
return alignToMergedCellsBorders(Rectangle.union(startRange, destRange), worksheet);
|
|
641
|
-
}
|
|
642
|
-
__name(expandToNextCell, "expandToNextCell");
|
|
643
|
-
function shrinkToNextGapRange(startRange, anchorRange, direction, worksheet) {
|
|
644
|
-
const reversedDirection = getReverseDirection(direction), nextGap = findNextGapRange(getEdgeOfRange(startRange, reversedDirection, worksheet), direction, worksheet);
|
|
645
|
-
return direction === Direction.UP && nextGap.startRow <= startRange.startRow ? alignToMergedCellsBorders(
|
|
646
|
-
{ ...anchorRange, startColumn: startRange.startColumn, endColumn: startRange.endColumn },
|
|
647
|
-
worksheet,
|
|
648
|
-
!0
|
|
649
|
-
) : direction === Direction.DOWN && nextGap.endRow >= startRange.endRow ? alignToMergedCellsBorders(
|
|
650
|
-
{ ...anchorRange, startColumn: startRange.startColumn, endColumn: startRange.endColumn },
|
|
651
|
-
worksheet,
|
|
652
|
-
!0
|
|
653
|
-
) : direction === Direction.LEFT && nextGap.startColumn <= startRange.startColumn ? alignToMergedCellsBorders(
|
|
654
|
-
{ ...anchorRange, startRow: startRange.startRow, endRow: startRange.endRow },
|
|
655
|
-
worksheet,
|
|
656
|
-
!0
|
|
657
|
-
) : direction === Direction.RIGHT && nextGap.endColumn >= startRange.endColumn ? alignToMergedCellsBorders(
|
|
658
|
-
{ ...anchorRange, startRow: startRange.startRow, endRow: startRange.endRow },
|
|
659
|
-
worksheet,
|
|
660
|
-
!0
|
|
661
|
-
) : Rectangle.union(Rectangle.clone(anchorRange), nextGap);
|
|
662
|
-
}
|
|
663
|
-
__name(shrinkToNextGapRange, "shrinkToNextGapRange");
|
|
664
|
-
function shrinkToNextCell(startRange, direction, worksheet) {
|
|
665
|
-
const reversedDirection = getReverseDirection(direction), shrinkFromEdge = getEdgeOfRange(startRange, reversedDirection, worksheet), otherEdge = getEdgeOfRange(startRange, direction, worksheet), next = findNextRangeExpand(shrinkFromEdge, direction, worksheet);
|
|
666
|
-
return alignToMergedCellsBorders(Rectangle.union(otherEdge, next), worksheet, !1);
|
|
667
|
-
}
|
|
668
|
-
__name(shrinkToNextCell, "shrinkToNextCell");
|
|
669
|
-
function expandToWholeSheet(worksheet) {
|
|
670
|
-
return {
|
|
671
|
-
startRow: 0,
|
|
672
|
-
startColumn: 0,
|
|
673
|
-
endRow: worksheet.getRowCount() - 1,
|
|
674
|
-
endColumn: worksheet.getColumnCount() - 1,
|
|
675
|
-
rangeType: RANGE_TYPE.ALL
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
__name(expandToWholeSheet, "expandToWholeSheet");
|
|
679
|
-
function getEdgeOfRange(startRange, direction, worksheet) {
|
|
680
|
-
let destRange;
|
|
681
|
-
switch (direction) {
|
|
682
|
-
case Direction.UP:
|
|
683
|
-
destRange = {
|
|
684
|
-
startRow: startRange.startRow,
|
|
685
|
-
startColumn: startRange.startColumn,
|
|
686
|
-
endRow: startRange.startRow,
|
|
687
|
-
endColumn: startRange.endColumn,
|
|
688
|
-
rangeType: RANGE_TYPE.NORMAL
|
|
689
|
-
};
|
|
690
|
-
break;
|
|
691
|
-
case Direction.DOWN:
|
|
692
|
-
destRange = {
|
|
693
|
-
startRow: startRange.endRow,
|
|
694
|
-
startColumn: startRange.startColumn,
|
|
695
|
-
endRow: startRange.endRow,
|
|
696
|
-
endColumn: startRange.endColumn,
|
|
697
|
-
rangeType: RANGE_TYPE.NORMAL
|
|
698
|
-
};
|
|
699
|
-
break;
|
|
700
|
-
case Direction.LEFT:
|
|
701
|
-
destRange = {
|
|
702
|
-
startRow: startRange.startRow,
|
|
703
|
-
startColumn: startRange.startColumn,
|
|
704
|
-
endRow: startRange.endRow,
|
|
705
|
-
endColumn: startRange.startColumn,
|
|
706
|
-
rangeType: RANGE_TYPE.NORMAL
|
|
707
|
-
};
|
|
708
|
-
break;
|
|
709
|
-
case Direction.RIGHT:
|
|
710
|
-
destRange = {
|
|
711
|
-
startRow: startRange.startRow,
|
|
712
|
-
startColumn: startRange.endColumn,
|
|
713
|
-
endRow: startRange.endRow,
|
|
714
|
-
endColumn: startRange.endColumn,
|
|
715
|
-
rangeType: RANGE_TYPE.NORMAL
|
|
716
|
-
};
|
|
717
|
-
break;
|
|
718
|
-
default:
|
|
719
|
-
throw new Error("Invalid direction");
|
|
420
|
+
get startRow() {
|
|
421
|
+
return this._startRow;
|
|
720
422
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
__name(getEdgeOfRange, "getEdgeOfRange");
|
|
724
|
-
function rangeHasValue(worksheet, row, col, rowEnd, colEnd) {
|
|
725
|
-
let hasValue = !1;
|
|
726
|
-
const matrix = worksheet.getMatrixWithMergedCells(row, col, rowEnd, colEnd).forValue((_, __, value) => {
|
|
727
|
-
if (cellHasValue(value))
|
|
728
|
-
return hasValue = !0, !1;
|
|
729
|
-
});
|
|
730
|
-
return {
|
|
731
|
-
hasValue,
|
|
732
|
-
matrix
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
__name(rangeHasValue, "rangeHasValue");
|
|
736
|
-
function getStartRange(range, primary, direction) {
|
|
737
|
-
const ret = Rectangle.clone(range);
|
|
738
|
-
if (primary == null)
|
|
739
|
-
return ret;
|
|
740
|
-
switch (direction) {
|
|
741
|
-
case Direction.UP:
|
|
742
|
-
case Direction.DOWN:
|
|
743
|
-
ret.startColumn = ret.endColumn = primary.actualColumn;
|
|
744
|
-
break;
|
|
745
|
-
case Direction.LEFT:
|
|
746
|
-
case Direction.RIGHT:
|
|
747
|
-
ret.startRow = ret.endRow = primary.actualRow;
|
|
748
|
-
break;
|
|
423
|
+
get endColumn() {
|
|
424
|
+
return this._endColumn;
|
|
749
425
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
__name(getStartRange, "getStartRange");
|
|
753
|
-
function checkIfShrink(selection, direction, worksheet) {
|
|
754
|
-
const { primary, range } = selection, startRange = Rectangle.clone(range);
|
|
755
|
-
switch (direction) {
|
|
756
|
-
case Direction.UP:
|
|
757
|
-
case Direction.DOWN:
|
|
758
|
-
startRange.startRow = primary.startRow, startRange.endRow = primary.endRow;
|
|
759
|
-
break;
|
|
760
|
-
case Direction.LEFT:
|
|
761
|
-
case Direction.RIGHT:
|
|
762
|
-
startRange.startColumn = primary.startColumn, startRange.endColumn = primary.endColumn;
|
|
763
|
-
break;
|
|
426
|
+
get endRow() {
|
|
427
|
+
return this._endRow;
|
|
764
428
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
case Direction.DOWN:
|
|
768
|
-
return range.startRow < anchorRange.startRow;
|
|
769
|
-
case Direction.UP:
|
|
770
|
-
return range.endRow > anchorRange.endRow;
|
|
771
|
-
case Direction.LEFT:
|
|
772
|
-
return anchorRange.endColumn < range.endColumn;
|
|
773
|
-
case Direction.RIGHT:
|
|
774
|
-
return anchorRange.startColumn > range.startColumn;
|
|
429
|
+
get startX() {
|
|
430
|
+
return this._startX;
|
|
775
431
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
function isAllRowsCovered(allRowRanges, ranges) {
|
|
779
|
-
let start = allRowRanges[0].startRow, end = allRowRanges[0].endRow;
|
|
780
|
-
allRowRanges.forEach((range) => {
|
|
781
|
-
const { startRow, endRow } = range;
|
|
782
|
-
start = Math.min(start, startRow), end = Math.max(end, endRow);
|
|
783
|
-
});
|
|
784
|
-
const covered = new Array(end - start + 1).fill(!1);
|
|
785
|
-
return ranges.forEach((range) => {
|
|
786
|
-
const { startRow, endRow } = range;
|
|
787
|
-
for (let i = Math.max(startRow, start); i <= Math.min(endRow, end); i++)
|
|
788
|
-
covered[i - start] = !0;
|
|
789
|
-
}), allRowRanges.every((range) => {
|
|
790
|
-
const { startRow, endRow } = range;
|
|
791
|
-
for (let i = startRow; i <= endRow; i++)
|
|
792
|
-
if (!covered[i - start])
|
|
793
|
-
return !1;
|
|
794
|
-
return !0;
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
__name(isAllRowsCovered, "isAllRowsCovered");
|
|
798
|
-
function isAllColumnsCovered(allColumnRanges, ranges) {
|
|
799
|
-
let start = allColumnRanges[0].startColumn, end = allColumnRanges[0].endColumn;
|
|
800
|
-
allColumnRanges.forEach((range) => {
|
|
801
|
-
const { startColumn, endColumn } = range;
|
|
802
|
-
start = Math.min(start, startColumn), end = Math.max(end, endColumn);
|
|
803
|
-
});
|
|
804
|
-
const covered = new Array(end - start + 1).fill(!1);
|
|
805
|
-
return ranges.forEach((range) => {
|
|
806
|
-
const { startColumn, endColumn } = range;
|
|
807
|
-
for (let i = Math.max(startColumn, start); i <= Math.min(endColumn, end); i++)
|
|
808
|
-
covered[i - start] = !0;
|
|
809
|
-
}), allColumnRanges.every((range) => {
|
|
810
|
-
const { startColumn, endColumn } = range;
|
|
811
|
-
for (let i = startColumn; i <= endColumn; i++)
|
|
812
|
-
if (!covered[i - start])
|
|
813
|
-
return !1;
|
|
814
|
-
return !0;
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
__name(isAllColumnsCovered, "isAllColumnsCovered");
|
|
818
|
-
function getMergeableSelectionsByType(type, selections) {
|
|
819
|
-
return selections ? type === "mergeAll" ? selections.filter((selection) => !(selection.startRow === selection.endRow && selection.startColumn === selection.endColumn)) : type === "mergeVertical" ? selections.filter((selection) => selection.startRow !== selection.endRow) : type === "mergeHorizontal" ? selections.filter((selection) => selection.startColumn !== selection.endColumn) : selections : null;
|
|
820
|
-
}
|
|
821
|
-
__name(getMergeableSelectionsByType, "getMergeableSelectionsByType");
|
|
822
|
-
function cellHasValue(cell) {
|
|
823
|
-
return cell.v !== void 0 && cell.v !== null && cell.v !== "" || cell.p !== void 0;
|
|
824
|
-
}
|
|
825
|
-
__name(cellHasValue, "cellHasValue");
|
|
826
|
-
var JumpOver = /* @__PURE__ */ ((JumpOver2) => (JumpOver2[JumpOver2.moveStopeOne = 0] = "moveStopeOne", JumpOver2[JumpOver2.moveGap = 1] = "moveGap", JumpOver2[JumpOver2.moveStepPage = 2] = "moveStepPage", JumpOver2[JumpOver2.moveStepEnd = 3] = "moveStepEnd", JumpOver2))(JumpOver || {});
|
|
827
|
-
const MoveSelectionCommand = {
|
|
828
|
-
id: "sheet.command.move-selection",
|
|
829
|
-
type: CommandType.COMMAND,
|
|
830
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
831
|
-
if (!params)
|
|
832
|
-
return !1;
|
|
833
|
-
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
834
|
-
if (!target) return !1;
|
|
835
|
-
const { workbook, worksheet } = target, selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
836
|
-
if (!selection)
|
|
837
|
-
return !1;
|
|
838
|
-
const { direction, jumpOver } = params, { range, primary } = selection, startRange = getStartRange(range, primary, direction), next = jumpOver === 1 ? findNextGapRange(startRange, direction, worksheet) : findNextRange(startRange, direction, worksheet), destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
|
|
839
|
-
return Rectangle.equals(destRange, startRange) ? !1 : (accessor.get(ShortcutExperienceService).remove({
|
|
840
|
-
unitId: workbook.getUnitId(),
|
|
841
|
-
sheetId: worksheet.getSheetId(),
|
|
842
|
-
keycode: KeyCode.TAB
|
|
843
|
-
}), accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
844
|
-
unitId: workbook.getUnitId(),
|
|
845
|
-
subUnitId: worksheet.getSheetId(),
|
|
846
|
-
selections: [
|
|
847
|
-
{
|
|
848
|
-
range: Rectangle.clone(destRange),
|
|
849
|
-
primary: {
|
|
850
|
-
startRow: destRange.startRow,
|
|
851
|
-
startColumn: destRange.startColumn,
|
|
852
|
-
endRow: destRange.endRow,
|
|
853
|
-
endColumn: destRange.endColumn,
|
|
854
|
-
actualRow: next.startRow,
|
|
855
|
-
actualColumn: next.startColumn,
|
|
856
|
-
isMerged: destRange.isMerged,
|
|
857
|
-
isMergedMainCell: destRange.startRow === next.startRow && destRange.startColumn === next.startColumn
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
]
|
|
861
|
-
}));
|
|
862
|
-
}, "handler")
|
|
863
|
-
}, MoveSelectionEnterAndTabCommand = {
|
|
864
|
-
id: "sheet.command.move-selection-enter-tab",
|
|
865
|
-
type: CommandType.COMMAND,
|
|
866
|
-
// eslint-disable-next-line max-lines-per-function
|
|
867
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
868
|
-
if (!params)
|
|
869
|
-
return !1;
|
|
870
|
-
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
871
|
-
if (!target) return !1;
|
|
872
|
-
const { workbook, worksheet } = target, selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
873
|
-
if (!selection)
|
|
874
|
-
return !1;
|
|
875
|
-
const unitId = workbook.getUnitId(), sheetId = worksheet.getSheetId();
|
|
876
|
-
if (!selection)
|
|
877
|
-
return !1;
|
|
878
|
-
const { direction, keycode } = params, { range, primary } = selection;
|
|
879
|
-
let startRange = getStartRange(range, primary, direction);
|
|
880
|
-
const shortcutExperienceService = accessor.get(ShortcutExperienceService), shortcutExperienceParam = shortcutExperienceService.getCurrentBySearch({
|
|
881
|
-
unitId,
|
|
882
|
-
sheetId,
|
|
883
|
-
keycode: KeyCode.TAB
|
|
884
|
-
});
|
|
885
|
-
let resultRange;
|
|
886
|
-
const { startRow, endRow, startColumn, endColumn } = range;
|
|
887
|
-
if (Rectangle.equals(range, primary)) {
|
|
888
|
-
if (keycode === KeyCode.TAB)
|
|
889
|
-
shortcutExperienceParam == null && shortcutExperienceService.addOrUpdate({
|
|
890
|
-
unitId,
|
|
891
|
-
sheetId,
|
|
892
|
-
keycode: KeyCode.TAB,
|
|
893
|
-
selection
|
|
894
|
-
});
|
|
895
|
-
else {
|
|
896
|
-
const selectionRemain = shortcutExperienceParam == null ? void 0 : shortcutExperienceParam.selection;
|
|
897
|
-
if (selectionRemain != null) {
|
|
898
|
-
const { range: range2, primary: primary2 } = selectionRemain;
|
|
899
|
-
startRange = getStartRange(range2, primary2, direction);
|
|
900
|
-
}
|
|
901
|
-
shortcutExperienceService.remove({
|
|
902
|
-
unitId,
|
|
903
|
-
sheetId,
|
|
904
|
-
keycode: KeyCode.TAB
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
const next = findNextRange(startRange, direction, worksheet), destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
|
|
908
|
-
if (Rectangle.equals(destRange, startRange))
|
|
909
|
-
return !1;
|
|
910
|
-
resultRange = {
|
|
911
|
-
range: Rectangle.clone(destRange),
|
|
912
|
-
primary: {
|
|
913
|
-
startRow: destRange.startRow,
|
|
914
|
-
startColumn: destRange.startColumn,
|
|
915
|
-
endRow: destRange.endRow,
|
|
916
|
-
endColumn: destRange.endColumn,
|
|
917
|
-
actualRow: next.startRow,
|
|
918
|
-
actualColumn: next.startColumn,
|
|
919
|
-
isMerged: destRange.isMerged,
|
|
920
|
-
isMergedMainCell: destRange.startRow === next.startRow && destRange.startColumn === next.startColumn
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
} else {
|
|
924
|
-
shortcutExperienceService.remove({
|
|
925
|
-
unitId,
|
|
926
|
-
sheetId,
|
|
927
|
-
keycode: KeyCode.TAB
|
|
928
|
-
});
|
|
929
|
-
const newPrimary = Tools.deepClone(primary), next = findNextRange(
|
|
930
|
-
{
|
|
931
|
-
startRow: newPrimary.startRow,
|
|
932
|
-
startColumn: newPrimary.startColumn,
|
|
933
|
-
endRow: newPrimary.endRow,
|
|
934
|
-
endColumn: newPrimary.endColumn
|
|
935
|
-
},
|
|
936
|
-
direction,
|
|
937
|
-
worksheet,
|
|
938
|
-
{
|
|
939
|
-
startRow,
|
|
940
|
-
endRow,
|
|
941
|
-
startColumn,
|
|
942
|
-
endColumn
|
|
943
|
-
}
|
|
944
|
-
), destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
|
|
945
|
-
resultRange = {
|
|
946
|
-
range: Rectangle.clone(range),
|
|
947
|
-
primary: {
|
|
948
|
-
startRow: destRange.startRow,
|
|
949
|
-
startColumn: destRange.startColumn,
|
|
950
|
-
endRow: destRange.endRow,
|
|
951
|
-
endColumn: destRange.endColumn,
|
|
952
|
-
actualRow: next.startRow,
|
|
953
|
-
actualColumn: next.startColumn,
|
|
954
|
-
isMerged: destRange.isMerged,
|
|
955
|
-
isMergedMainCell: destRange.startRow === next.startRow && destRange.startColumn === next.startColumn
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
}
|
|
959
|
-
return accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
960
|
-
unitId,
|
|
961
|
-
subUnitId: sheetId,
|
|
962
|
-
selections: [resultRange]
|
|
963
|
-
});
|
|
964
|
-
}, "handler")
|
|
965
|
-
}, ExpandSelectionCommand = {
|
|
966
|
-
id: "sheet.command.expand-selection",
|
|
967
|
-
type: CommandType.COMMAND,
|
|
968
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
969
|
-
if (!params) return !1;
|
|
970
|
-
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
971
|
-
if (!target) return !1;
|
|
972
|
-
const { worksheet, unitId, subUnitId } = target, selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
973
|
-
if (!selection) return !1;
|
|
974
|
-
const { range: startRange, primary } = selection, { jumpOver, direction } = params, destRange = checkIfShrink(selection, direction, worksheet) ? jumpOver === 1 ? shrinkToNextGapRange(
|
|
975
|
-
startRange,
|
|
976
|
-
{ ...Rectangle.clone(primary), rangeType: RANGE_TYPE.NORMAL },
|
|
977
|
-
direction,
|
|
978
|
-
worksheet
|
|
979
|
-
) : shrinkToNextCell(startRange, direction, worksheet) : jumpOver === 1 ? expandToNextGapRange(startRange, direction, worksheet) : expandToNextCell(startRange, direction, worksheet);
|
|
980
|
-
return Rectangle.equals(destRange, startRange) ? !1 : accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
981
|
-
unitId,
|
|
982
|
-
subUnitId,
|
|
983
|
-
selections: [
|
|
984
|
-
{
|
|
985
|
-
range: destRange,
|
|
986
|
-
primary
|
|
987
|
-
// this remains unchanged
|
|
988
|
-
}
|
|
989
|
-
]
|
|
990
|
-
});
|
|
991
|
-
}, "handler")
|
|
992
|
-
}, SelectAllCommand = {
|
|
993
|
-
id: "sheet.command.select-all",
|
|
994
|
-
type: CommandType.COMMAND,
|
|
995
|
-
handler: /* @__PURE__ */ __name(async (accessor, params = { expandToGapFirst: !0, loop: !1 }) => {
|
|
996
|
-
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
997
|
-
if (!target) return !1;
|
|
998
|
-
const selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
999
|
-
if (!selection) return !1;
|
|
1000
|
-
const selectAllService = accessor.get(SelectAllService), { worksheet, unitId, subUnitId } = target, id = `${unitId}|${subUnitId}`;
|
|
1001
|
-
id !== selectAllService.selectedRangeWorksheet && (selectAllService.rangesStack = [], selectAllService.selectedRangeWorksheet = id);
|
|
1002
|
-
const maxRow = worksheet.getMaxRows(), maxCol = worksheet.getMaxColumns(), { expandToGapFirst, loop } = params, { range, primary } = selection, isWholeSheetSelected = range.endColumn === maxCol - 1 && range.endRow === maxRow - 1 && range.startRow === 0 && range.startColumn === 0;
|
|
1003
|
-
selectAllService.rangesStack.some((s) => Rectangle.equals(s, range)) || (selectAllService.rangesStack = [], selectAllService.rangesStack.push(range));
|
|
1004
|
-
let destRange;
|
|
1005
|
-
if (isWholeSheetSelected)
|
|
1006
|
-
if (loop) {
|
|
1007
|
-
if (selectAllService.rangesStack.findIndex((s) => Rectangle.equals(s, range)) !== selectAllService.rangesStack.length - 1)
|
|
1008
|
-
return !1;
|
|
1009
|
-
destRange = selectAllService.rangesStack[0];
|
|
1010
|
-
} else
|
|
1011
|
-
return !1;
|
|
1012
|
-
else expandToGapFirst ? (destRange = expandToContinuousRange(range, { left: !0, right: !0, up: !0, down: !0 }, worksheet), Rectangle.equals(destRange, range) && (destRange = expandToWholeSheet(worksheet))) : destRange = expandToWholeSheet(worksheet);
|
|
1013
|
-
return selectAllService.rangesStack.some((s) => Rectangle.equals(s, destRange)) || selectAllService.rangesStack.push(destRange), accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
1014
|
-
unitId,
|
|
1015
|
-
subUnitId,
|
|
1016
|
-
selections: [
|
|
1017
|
-
{
|
|
1018
|
-
range: destRange,
|
|
1019
|
-
primary
|
|
1020
|
-
// this remains unchanged
|
|
1021
|
-
}
|
|
1022
|
-
]
|
|
1023
|
-
});
|
|
1024
|
-
}, "handler")
|
|
1025
|
-
}, SHEET_ZOOM_RANGE = [10, 400], RANGE_SELECTOR_COMPONENT_KEY = "RANGE_SELECTOR_COMPONENT_KEY";
|
|
1026
|
-
var SHEET_VIEW_KEY = /* @__PURE__ */ ((SHEET_VIEW_KEY2) => (SHEET_VIEW_KEY2.MAIN = "__SpreadsheetRender__", SHEET_VIEW_KEY2.ROW = "__SpreadsheetRowHeader__", SHEET_VIEW_KEY2.COLUMN = "__SpreadsheetColumnHeader__", SHEET_VIEW_KEY2.LEFT_TOP = "__SpreadsheetLeftTopPlaceholder__", SHEET_VIEW_KEY2))(SHEET_VIEW_KEY || {}), SHEET_VIEWPORT_KEY = /* @__PURE__ */ ((SHEET_VIEWPORT_KEY2) => (SHEET_VIEWPORT_KEY2.VIEW_MAIN = "viewMain", SHEET_VIEWPORT_KEY2.VIEW_MAIN_LEFT_TOP = "viewMainLeftTop", SHEET_VIEWPORT_KEY2.VIEW_MAIN_TOP = "viewMainTop", SHEET_VIEWPORT_KEY2.VIEW_MAIN_LEFT = "viewMainLeft", SHEET_VIEWPORT_KEY2.VIEW_ROW_TOP = "viewRowTop", SHEET_VIEWPORT_KEY2.VIEW_ROW_BOTTOM = "viewRowBottom", SHEET_VIEWPORT_KEY2.VIEW_COLUMN_LEFT = "viewColumnLeft", SHEET_VIEWPORT_KEY2.VIEW_COLUMN_RIGHT = "viewColumnRight", SHEET_VIEWPORT_KEY2.VIEW_LEFT_TOP = "viewLeftTop", SHEET_VIEWPORT_KEY2))(SHEET_VIEWPORT_KEY || {});
|
|
1027
|
-
const SHEET_COMPONENT_MAIN_LAYER_INDEX = 0, SHEET_COMPONENT_SELECTION_LAYER_INDEX = 1, SHEET_COMPONENT_HEADER_LAYER_INDEX = 10, SHEET_COMPONENT_HEADER_SELECTION_LAYER_INDEX = 11, SHEET_COMPONENT_UNHIDE_LAYER_INDEX = 12;
|
|
1028
|
-
function isRenderManagerService(renderManagerService) {
|
|
1029
|
-
return typeof renderManagerService.isMainScene > "u";
|
|
1030
|
-
}
|
|
1031
|
-
__name(isRenderManagerService, "isRenderManagerService");
|
|
1032
|
-
function getSheetObject(univerInstanceService, renderManagerService) {
|
|
1033
|
-
const workbook = univerInstanceService instanceof Workbook ? univerInstanceService : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
1034
|
-
if (!workbook) return null;
|
|
1035
|
-
const unitId = workbook.getUnitId();
|
|
1036
|
-
let components, mainComponent, scene, engine;
|
|
1037
|
-
if (isRenderManagerService(renderManagerService)) {
|
|
1038
|
-
const currentRender = renderManagerService.getRenderById(unitId);
|
|
1039
|
-
if (currentRender == null) return null;
|
|
1040
|
-
components = currentRender.components, components = currentRender.components, mainComponent = currentRender.mainComponent, scene = currentRender.scene, engine = currentRender.engine;
|
|
1041
|
-
} else
|
|
1042
|
-
components = renderManagerService.components, mainComponent = renderManagerService.mainComponent, scene = renderManagerService.scene, engine = renderManagerService.engine;
|
|
1043
|
-
if (!components || !mainComponent) return null;
|
|
1044
|
-
const spreadsheet = mainComponent, spreadsheetRowHeader = components.get(SHEET_VIEW_KEY.ROW), spreadsheetColumnHeader = components.get(SHEET_VIEW_KEY.COLUMN), spreadsheetLeftTopPlaceholder = components.get(SHEET_VIEW_KEY.LEFT_TOP);
|
|
1045
|
-
return {
|
|
1046
|
-
spreadsheet,
|
|
1047
|
-
spreadsheetRowHeader,
|
|
1048
|
-
spreadsheetColumnHeader,
|
|
1049
|
-
spreadsheetLeftTopPlaceholder,
|
|
1050
|
-
scene,
|
|
1051
|
-
engine
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
__name(getSheetObject, "getSheetObject");
|
|
1055
|
-
function getCoordByCell(row, col, scene, skeleton) {
|
|
1056
|
-
const { startX, startY, endX, endY } = skeleton.getCellByIndex(row, col);
|
|
1057
|
-
return { startX, startY, endX, endY };
|
|
1058
|
-
}
|
|
1059
|
-
__name(getCoordByCell, "getCoordByCell");
|
|
1060
|
-
function getCoordByOffset(evtOffsetX, evtOffsetY, scene, skeleton, viewport, closeFirst) {
|
|
1061
|
-
const relativeCoords = scene.getRelativeToViewportCoord(Vector2.FromArray([evtOffsetX, evtOffsetY])), { x: newEvtOffsetX, y: newEvtOffsetY } = relativeCoords, scrollXY = scene.getVpScrollXYInfoByPosToVp(relativeCoords, viewport), { scaleX, scaleY } = scene.getAncestorScale(), moveActualSelection = skeleton.getCellPositionByOffset(
|
|
1062
|
-
newEvtOffsetX,
|
|
1063
|
-
newEvtOffsetY,
|
|
1064
|
-
scaleX,
|
|
1065
|
-
scaleY,
|
|
1066
|
-
scrollXY,
|
|
1067
|
-
closeFirst
|
|
1068
|
-
), { row, column } = moveActualSelection, startCell = skeleton.getNoMergeCellPositionByIndex(row, column), { startX, startY, endX, endY } = startCell;
|
|
1069
|
-
return {
|
|
1070
|
-
startX,
|
|
1071
|
-
startY,
|
|
1072
|
-
endX,
|
|
1073
|
-
endY,
|
|
1074
|
-
row,
|
|
1075
|
-
column
|
|
1076
|
-
};
|
|
1077
|
-
}
|
|
1078
|
-
__name(getCoordByOffset, "getCoordByOffset");
|
|
1079
|
-
function getTransformCoord(evtOffsetX, evtOffsetY, scene, skeleton) {
|
|
1080
|
-
const relativeCoords = scene.getRelativeToViewportCoord(Vector2.FromArray([evtOffsetX, evtOffsetY])), viewMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN), scrollXY = scene.getVpScrollXYInfoByPosToVp(relativeCoords, viewMain), { scaleX, scaleY } = scene.getAncestorScale(), { x: scrollX, y: scrollY } = scrollXY, offsetX = evtOffsetX / scaleX + scrollX, offsetY = evtOffsetY / scaleY + scrollY;
|
|
1081
|
-
return { x: offsetX, y: offsetY };
|
|
1082
|
-
}
|
|
1083
|
-
__name(getTransformCoord, "getTransformCoord");
|
|
1084
|
-
var __defProp$S = Object.defineProperty, __getOwnPropDesc$S = Object.getOwnPropertyDescriptor, __decorateClass$S = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1085
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$S(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1086
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1087
|
-
return kind && result && __defProp$S(target, key, result), result;
|
|
1088
|
-
}, "__decorateClass$S"), __decorateParam$S = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$S");
|
|
1089
|
-
const SHEET_NAVIGATION_COMMANDS$1 = [MoveSelectionCommand.id, MoveSelectionEnterAndTabCommand.id];
|
|
1090
|
-
var _a4;
|
|
1091
|
-
let SheetsScrollRenderController = (_a4 = class extends Disposable {
|
|
1092
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _contextService, _commandService, _renderManagerService, _scrollManagerService) {
|
|
1093
|
-
super(), this._context = _context, this._injector = _injector, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._contextService = _contextService, this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._scrollManagerService = _scrollManagerService, this._initCommandListener(), this._wheelEventListener(), this._scrollBarEventListener(), this._initSkeletonListener();
|
|
432
|
+
get startY() {
|
|
433
|
+
return this._startY;
|
|
1094
434
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
const bounding = this._getViewportBounding();
|
|
1098
|
-
if (range.rangeType === RANGE_TYPE.ROW ? (startColumn = 0, endColumn = 0) : range.rangeType === RANGE_TYPE.COLUMN && (startRow = 0, endRow = 0), bounding) {
|
|
1099
|
-
const row = bounding.startRow > endRow ? startRow : endRow, col = bounding.startColumn > endColumn ? startColumn : endColumn;
|
|
1100
|
-
return this._scrollToCell(row, col);
|
|
1101
|
-
} else
|
|
1102
|
-
return this._scrollToCell(startRow, startColumn);
|
|
435
|
+
get endX() {
|
|
436
|
+
return this._endX;
|
|
1103
437
|
}
|
|
1104
|
-
|
|
1105
|
-
this.
|
|
1106
|
-
if (SHEET_NAVIGATION_COMMANDS$1.includes(command.id))
|
|
1107
|
-
this._scrollToSelection();
|
|
1108
|
-
else if (command.id === ScrollToCellOperation.id) {
|
|
1109
|
-
const param = command.params;
|
|
1110
|
-
this.scrollToRange(param);
|
|
1111
|
-
} else if (command.id === ExpandSelectionCommand.id) {
|
|
1112
|
-
const param = command.params;
|
|
1113
|
-
this._scrollToSelectionForExpand(param);
|
|
1114
|
-
} else command.id === SetSelectionsOperation.id && command.params.reveal && this._scrollToSelection();
|
|
1115
|
-
}));
|
|
438
|
+
get endY() {
|
|
439
|
+
return this._endY;
|
|
1116
440
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
const selection = this._getSelectionsService().getCurrentLastSelection();
|
|
1120
|
-
if (selection == null)
|
|
1121
|
-
return;
|
|
1122
|
-
const { startRow, startColumn, endRow, endColumn } = selection.range, bounds = this._getViewportBounding();
|
|
1123
|
-
if (bounds == null)
|
|
1124
|
-
return;
|
|
1125
|
-
const { startRow: viewportStartRow, startColumn: viewportStartColumn, endRow: viewportEndRow, endColumn: viewportEndColumn } = bounds;
|
|
1126
|
-
let row = 0, column = 0;
|
|
1127
|
-
startRow > viewportStartRow ? row = endRow : endRow < viewportEndRow ? row = startRow : row = viewportStartRow, startColumn > viewportStartColumn ? column = endColumn : endColumn < viewportEndColumn ? column = startColumn : column = viewportStartColumn, param.direction === Direction.DOWN ? row = endRow : param.direction === Direction.UP ? row = startRow : param.direction === Direction.RIGHT ? column = endColumn : param.direction === Direction.LEFT && (column = startColumn), this._scrollToCell(row, column);
|
|
1128
|
-
}, 0);
|
|
441
|
+
get currentCell() {
|
|
442
|
+
return this._primary;
|
|
1129
443
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
const snapshot = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton.getWorksheetConfig();
|
|
1133
|
-
if (snapshot != null)
|
|
1134
|
-
return snapshot.freeze;
|
|
444
|
+
get rangeType() {
|
|
445
|
+
return this._rangeType;
|
|
1135
446
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
if (evt.inputIndex === PointerInput.MouseWheelX) {
|
|
1148
|
-
const scrollNum = Math.abs(evt.deltaX);
|
|
1149
|
-
offsetX = evt.deltaX > 0 ? scrollNum : -scrollNum, this._commandService.executeCommand(SetScrollRelativeCommand.id, { offsetX }), scene.getParent().classType === RENDER_CLASS_TYPE.SCENE_VIEWER ? isLimitedStore != null && isLimitedStore.isLimitedX || state.stopPropagation() : viewMain.isWheelPreventDefaultX ? evt.preventDefault() : isLimitedStore != null && isLimitedStore.isLimitedX || evt.preventDefault();
|
|
1150
|
-
}
|
|
1151
|
-
if (evt.inputIndex === PointerInput.MouseWheelY) {
|
|
1152
|
-
let scrollNum = Math.abs(evt.deltaY);
|
|
1153
|
-
evt.shiftKey ? (scrollNum *= 3, evt.deltaY > 0 ? offsetX = scrollNum : offsetX = -scrollNum, this._commandService.executeCommand(SetScrollRelativeCommand.id, { offsetX }), scene.getParent().classType === RENDER_CLASS_TYPE.SCENE_VIEWER ? isLimitedStore != null && isLimitedStore.isLimitedX || state.stopPropagation() : viewMain.isWheelPreventDefaultX ? evt.preventDefault() : isLimitedStore != null && isLimitedStore.isLimitedX || evt.preventDefault()) : (offsetY = evt.deltaY > 0 ? scrollNum : -scrollNum, this._commandService.executeCommand(SetScrollRelativeCommand.id, { offsetY }), scene.getParent().classType === RENDER_CLASS_TYPE.SCENE_VIEWER ? isLimitedStore != null && isLimitedStore.isLimitedY || state.stopPropagation() : viewMain.isWheelPreventDefaultY ? evt.preventDefault() : isLimitedStore != null && isLimitedStore.isLimitedY || evt.preventDefault());
|
|
1154
|
-
}
|
|
1155
|
-
this._context.scene.makeDirty(!0);
|
|
1156
|
-
})
|
|
1157
|
-
);
|
|
1158
|
-
}
|
|
1159
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1160
|
-
_scrollBarEventListener() {
|
|
1161
|
-
const { scene } = this._context;
|
|
1162
|
-
if (scene == null) return;
|
|
1163
|
-
const viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
1164
|
-
viewportMain && (this.disposeWithMe(
|
|
1165
|
-
toDisposable(
|
|
1166
|
-
this._scrollManagerService.rawScrollInfo$.subscribe((rawScrollInfo) => {
|
|
1167
|
-
var _a61;
|
|
1168
|
-
const skeleton = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton;
|
|
1169
|
-
if (!skeleton) return;
|
|
1170
|
-
if (rawScrollInfo == null) {
|
|
1171
|
-
viewportMain.scrollToViewportPos({
|
|
1172
|
-
viewportScrollX: 0,
|
|
1173
|
-
viewportScrollY: 0
|
|
1174
|
-
});
|
|
1175
|
-
return;
|
|
1176
|
-
}
|
|
1177
|
-
const { sheetViewStartRow, sheetViewStartColumn, offsetX, offsetY } = rawScrollInfo, { startX, startY } = skeleton.getCellByIndexWithNoHeader(
|
|
1178
|
-
sheetViewStartRow,
|
|
1179
|
-
sheetViewStartColumn
|
|
1180
|
-
), viewportScrollX = startX + offsetX, viewportScrollY = startY + offsetY;
|
|
1181
|
-
viewportMain.scrollToViewportPos({ viewportScrollX, viewportScrollY });
|
|
1182
|
-
})
|
|
1183
|
-
)
|
|
1184
|
-
), this.disposeWithMe(
|
|
1185
|
-
// set scrollInfo, the event is triggered in viewport@_scrollToScrollbarPos
|
|
1186
|
-
viewportMain.onScrollAfter$.subscribeEvent((scrollAfterParam) => {
|
|
1187
|
-
var _a61;
|
|
1188
|
-
const skeleton = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton;
|
|
1189
|
-
if (skeleton == null || scrollAfterParam.isTrigger === !1)
|
|
1190
|
-
return;
|
|
1191
|
-
const sheetObject = this._getSheetObject();
|
|
1192
|
-
if (skeleton == null || sheetObject == null)
|
|
1193
|
-
return;
|
|
1194
|
-
const { viewportScrollX, viewportScrollY, scrollX, scrollY } = scrollAfterParam, { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(
|
|
1195
|
-
viewportScrollX,
|
|
1196
|
-
viewportScrollY
|
|
1197
|
-
), scrollInfo = {
|
|
1198
|
-
sheetViewStartRow: row,
|
|
1199
|
-
sheetViewStartColumn: column,
|
|
1200
|
-
offsetX: columnOffset,
|
|
1201
|
-
offsetY: rowOffset
|
|
1202
|
-
};
|
|
1203
|
-
this._scrollManagerService.setScrollStateToCurrSheet(scrollInfo), this._scrollManagerService.validViewportScrollInfo$.next({
|
|
1204
|
-
...scrollInfo,
|
|
1205
|
-
viewportScrollX,
|
|
1206
|
-
viewportScrollY,
|
|
1207
|
-
scrollX,
|
|
1208
|
-
scrollY
|
|
1209
|
-
});
|
|
1210
|
-
})
|
|
1211
|
-
), this.disposeWithMe(
|
|
1212
|
-
// get scrollByBar event from viewport and exec ScrollCommand.id.
|
|
1213
|
-
viewportMain.onScrollByBar$.subscribeEvent((param) => {
|
|
1214
|
-
var _a61;
|
|
1215
|
-
const skeleton = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton;
|
|
1216
|
-
if (skeleton == null || param.isTrigger === !1)
|
|
1217
|
-
return;
|
|
1218
|
-
const sheetObject = this._getSheetObject();
|
|
1219
|
-
if (skeleton == null || sheetObject == null)
|
|
1220
|
-
return;
|
|
1221
|
-
const { viewportScrollX = 0, viewportScrollY = 0 } = param, freeze = this._getFreeze(), { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(
|
|
1222
|
-
viewportScrollX,
|
|
1223
|
-
viewportScrollY
|
|
1224
|
-
);
|
|
1225
|
-
this._commandService.executeCommand(ScrollCommand.id, {
|
|
1226
|
-
sheetViewStartRow: row + ((freeze == null ? void 0 : freeze.ySplit) || 0),
|
|
1227
|
-
sheetViewStartColumn: column + ((freeze == null ? void 0 : freeze.xSplit) || 0),
|
|
1228
|
-
offsetX: columnOffset,
|
|
1229
|
-
offsetY: rowOffset
|
|
1230
|
-
});
|
|
1231
|
-
})
|
|
1232
|
-
));
|
|
447
|
+
/**
|
|
448
|
+
* @deprecated, Duplicate with `Rectangle`
|
|
449
|
+
*/
|
|
450
|
+
isEqual(rangeWithCoord) {
|
|
451
|
+
const { startColumn, startRow, endColumn, endRow } = this, {
|
|
452
|
+
startColumn: newStartColumn,
|
|
453
|
+
startRow: newStartRow,
|
|
454
|
+
endColumn: newEndColumn,
|
|
455
|
+
endRow: newEndRow
|
|
456
|
+
} = rangeWithCoord;
|
|
457
|
+
return startColumn === newStartColumn && startRow === newStartRow && endColumn === newEndColumn && endRow === newEndRow;
|
|
1233
458
|
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
})
|
|
1246
|
-
));
|
|
459
|
+
/**
|
|
460
|
+
* @deprecated, Duplicate with `Rectangle`
|
|
461
|
+
*/
|
|
462
|
+
isInclude(rangeWithCoord) {
|
|
463
|
+
const { startColumn, startRow, endColumn, endRow } = this, {
|
|
464
|
+
startColumn: newStartColumn,
|
|
465
|
+
startRow: newStartRow,
|
|
466
|
+
endColumn: newEndColumn,
|
|
467
|
+
endRow: newEndRow
|
|
468
|
+
} = rangeWithCoord;
|
|
469
|
+
return !(newEndColumn < startColumn || newStartColumn > endColumn || newStartRow > endRow || newEndRow < startRow);
|
|
1247
470
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
return;
|
|
1252
|
-
const { unitId } = this._context, { skeleton } = param, scene = (_a61 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a61.scene;
|
|
1253
|
-
if (skeleton == null || scene == null)
|
|
1254
|
-
return;
|
|
1255
|
-
const { rowTotalHeight, columnTotalWidth, rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton, worksheet = this._context.unit.getActiveSheet();
|
|
1256
|
-
if (!worksheet) return;
|
|
1257
|
-
const zoomRatio = worksheet.getZoomRatio() || 1;
|
|
1258
|
-
scene == null || scene.setScaleValue(zoomRatio, zoomRatio), scene == null || scene.transformByState({
|
|
1259
|
-
width: rowHeaderWidthAndMarginLeft + columnTotalWidth,
|
|
1260
|
-
height: columnHeaderHeightAndMarginTop + rowTotalHeight
|
|
1261
|
-
});
|
|
471
|
+
highlightToSelection() {
|
|
472
|
+
if (this._primary)
|
|
473
|
+
return makeCellToSelection(this._primary);
|
|
1262
474
|
}
|
|
1263
|
-
|
|
1264
|
-
return
|
|
475
|
+
getRange() {
|
|
476
|
+
return {
|
|
477
|
+
startColumn: this._startColumn,
|
|
478
|
+
startRow: this._startRow,
|
|
479
|
+
endColumn: this._endColumn,
|
|
480
|
+
endRow: this._endRow,
|
|
481
|
+
startX: this._startX,
|
|
482
|
+
startY: this._startY,
|
|
483
|
+
endX: this._endX,
|
|
484
|
+
endY: this._endY,
|
|
485
|
+
rangeType: this.rangeType
|
|
486
|
+
};
|
|
1265
487
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
if (bounds == null)
|
|
1269
|
-
return !1;
|
|
1270
|
-
const {
|
|
1271
|
-
startRow: viewportStartRow,
|
|
1272
|
-
startColumn: viewportStartColumn,
|
|
1273
|
-
endRow: viewportEndRow,
|
|
1274
|
-
endColumn: viewportEndColumn
|
|
1275
|
-
} = bounds;
|
|
1276
|
-
let row = 0, column = 0;
|
|
1277
|
-
const { startRow, startColumn, endRow, endColumn } = range;
|
|
1278
|
-
startRow >= viewportStartRow && (row = endRow), endRow <= viewportEndRow && (row = startRow), startColumn >= viewportStartColumn && (column = endColumn), endColumn <= viewportEndColumn && (column = startColumn), this._scrollToCell(row, column);
|
|
488
|
+
getCell() {
|
|
489
|
+
return this._primary;
|
|
1279
490
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
if (!selection) return;
|
|
1283
|
-
const { startRow, startColumn, actualRow, actualColumn } = selection.primary, selectionStartRow = targetIsActualRowAndColumn ? actualRow : startRow, selectionStartColumn = targetIsActualRowAndColumn ? actualColumn : startColumn;
|
|
1284
|
-
this._scrollToCell(selectionStartRow, selectionStartColumn);
|
|
491
|
+
getRangeType() {
|
|
492
|
+
return this._rangeType;
|
|
1285
493
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
494
|
+
setRangeType(rangeType) {
|
|
495
|
+
this._rangeType = rangeType;
|
|
1288
496
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
const viewport = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
1295
|
-
if (viewport == null)
|
|
1296
|
-
return;
|
|
1297
|
-
const skeleton = (_b = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _b.skeleton;
|
|
1298
|
-
if (skeleton == null)
|
|
1299
|
-
return;
|
|
1300
|
-
const bounds = viewport.getBounding();
|
|
1301
|
-
return skeleton.getRowColumnSegmentByViewBound(bounds.viewBound);
|
|
497
|
+
getValue() {
|
|
498
|
+
return {
|
|
499
|
+
rangeWithCoord: this.getRange(),
|
|
500
|
+
primaryWithCoord: this._primary
|
|
501
|
+
};
|
|
1302
502
|
}
|
|
1303
|
-
|
|
1304
|
-
_scrollToCell(row, column) {
|
|
1305
|
-
var _a61, _b, _c, _d;
|
|
1306
|
-
const { rowHeightAccumulation, columnWidthAccumulation } = (_b = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton) != null ? _b : {};
|
|
1307
|
-
if (rowHeightAccumulation == null || columnWidthAccumulation == null) return !1;
|
|
1308
|
-
const scene = (_c = this._getSheetObject()) == null ? void 0 : _c.scene;
|
|
1309
|
-
if (scene == null) return !1;
|
|
1310
|
-
const viewport = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
1311
|
-
if (viewport == null || ((_d = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _d.skeleton) == null) return !1;
|
|
1312
|
-
const worksheet = this._context.unit.getActiveSheet();
|
|
1313
|
-
if (!worksheet) return !1;
|
|
1314
|
-
const {
|
|
1315
|
-
startColumn: freezeStartColumn,
|
|
1316
|
-
startRow: freezeStartRow,
|
|
1317
|
-
ySplit: freezeYSplit,
|
|
1318
|
-
xSplit: freezeXSplit
|
|
1319
|
-
} = worksheet.getFreeze(), bounds = this._getViewportBounding();
|
|
1320
|
-
if (bounds == null) return !1;
|
|
503
|
+
setValue(newSelectionRange, currentCell) {
|
|
1321
504
|
const {
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
break;
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
if (column >= freezeStartColumn && row >= freezeStartRow - freezeYSplit && (column <= viewportStartColumn && (startSheetViewColumn = column), column >= viewportEndColumn)) {
|
|
1337
|
-
const minColumnAccumulation = columnWidthAccumulation[column] - viewport.width;
|
|
1338
|
-
for (let c = viewportStartColumn; c <= column; c++)
|
|
1339
|
-
if (columnWidthAccumulation[c] >= minColumnAccumulation) {
|
|
1340
|
-
startSheetViewColumn = c + 1;
|
|
1341
|
-
break;
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
if (startSheetViewRow === void 0 && startSheetViewColumn === void 0) return !1;
|
|
1345
|
-
const { offsetX, offsetY } = this._scrollManagerService.getCurrentScrollState() || {};
|
|
1346
|
-
return startSheetViewRow = startSheetViewRow && Math.min(startSheetViewRow, row), startSheetViewColumn = startSheetViewColumn && Math.min(startSheetViewColumn, column), this._commandService.syncExecuteCommand(ScrollCommand.id, {
|
|
1347
|
-
sheetViewStartRow: startSheetViewRow,
|
|
1348
|
-
sheetViewStartColumn: startSheetViewColumn,
|
|
1349
|
-
offsetX: startSheetViewColumn === void 0 ? offsetX : 0,
|
|
1350
|
-
offsetY: startSheetViewRow === void 0 ? offsetY : 0
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1353
|
-
}, __name(_a4, "SheetsScrollRenderController"), _a4);
|
|
1354
|
-
SheetsScrollRenderController = __decorateClass$S([
|
|
1355
|
-
__decorateParam$S(1, Inject(Injector)),
|
|
1356
|
-
__decorateParam$S(2, Inject(SheetSkeletonManagerService)),
|
|
1357
|
-
__decorateParam$S(3, IContextService),
|
|
1358
|
-
__decorateParam$S(4, ICommandService),
|
|
1359
|
-
__decorateParam$S(5, IRenderManagerService),
|
|
1360
|
-
__decorateParam$S(6, Inject(SheetScrollManagerService))
|
|
1361
|
-
], SheetsScrollRenderController);
|
|
1362
|
-
function getActiveSheet$(univerInstanceService) {
|
|
1363
|
-
return univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => workbook ? workbook.activeSheet$.pipe(map((worksheet) => worksheet ? { workbook, worksheet } : null)) : of(null)));
|
|
1364
|
-
}
|
|
1365
|
-
__name(getActiveSheet$, "getActiveSheet$");
|
|
1366
|
-
function deriveStateFromActiveSheet$(univerInstanceService, defaultValue, callback) {
|
|
1367
|
-
return getActiveSheet$(univerInstanceService).pipe(switchMap((active) => active ? callback(active) : of(defaultValue)));
|
|
1368
|
-
}
|
|
1369
|
-
__name(deriveStateFromActiveSheet$, "deriveStateFromActiveSheet$");
|
|
1370
|
-
function getCurrentExclusiveRangeInterest$(accessor, disableGroupSet) {
|
|
1371
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), exclusiveRangeService = accessor.get(IExclusiveRangeService), selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
1372
|
-
return univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
|
|
1373
|
-
switchMap((workbook) => workbook ? combineLatest([selectionManagerService.selectionMoveEnd$, workbook.activeSheet$]).pipe(
|
|
1374
|
-
switchMap(([selections, worksheet]) => {
|
|
1375
|
-
if (!worksheet)
|
|
1376
|
-
return of(!1);
|
|
1377
|
-
if (selections.length === 0)
|
|
1378
|
-
return of(!1);
|
|
1379
|
-
const interestGroupIds = exclusiveRangeService.getInterestGroupId(selections);
|
|
1380
|
-
if (disableGroupSet) {
|
|
1381
|
-
const disableGroup = interestGroupIds.filter((groupId) => disableGroupSet.has(groupId));
|
|
1382
|
-
return of(disableGroup.length > 0);
|
|
1383
|
-
} else
|
|
1384
|
-
return of(interestGroupIds.length > 0);
|
|
1385
|
-
})
|
|
1386
|
-
) : of(!1))
|
|
1387
|
-
);
|
|
1388
|
-
}
|
|
1389
|
-
__name(getCurrentExclusiveRangeInterest$, "getCurrentExclusiveRangeInterest$");
|
|
1390
|
-
function getObservableWithExclusiveRange$(accessor, observable$, disableGroupSet) {
|
|
1391
|
-
return combineLatest([observable$, getCurrentExclusiveRangeInterest$(accessor, disableGroupSet)]).pipe(
|
|
1392
|
-
map(([observable, exclusiveRangeDisable]) => observable || exclusiveRangeDisable)
|
|
1393
|
-
);
|
|
1394
|
-
}
|
|
1395
|
-
__name(getObservableWithExclusiveRange$, "getObservableWithExclusiveRange$");
|
|
1396
|
-
function getCurrentRangeDisable$(accessor, permissionTypes = {}) {
|
|
1397
|
-
const workbook$ = accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), userManagerService = accessor.get(UserManagerService);
|
|
1398
|
-
return combineLatest([userManagerService.currentUser$, workbook$]).pipe(
|
|
1399
|
-
switchMap(([_, workbook]) => workbook ? workbook.activeSheet$.pipe(
|
|
1400
|
-
switchMap((worksheet) => {
|
|
1401
|
-
if (!worksheet)
|
|
1402
|
-
return of(!0);
|
|
1403
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), worksheetRuleModel = accessor.get(WorksheetProtectionRuleModel), focusedOnDrawing$ = accessor.get(IContextService).subscribeContextValue$(FOCUSING_COMMON_DRAWINGS).pipe(startWith(!1));
|
|
1404
|
-
return combineLatest([selectionManagerService.selectionMoveEnd$, focusedOnDrawing$]).pipe(
|
|
1405
|
-
switchMap(([selection, focusOnDrawings]) => {
|
|
1406
|
-
if (focusOnDrawings)
|
|
1407
|
-
return of(!0);
|
|
1408
|
-
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionService = accessor.get(IPermissionService), { workbookTypes = [WorkbookEditablePermission], worksheetTypes, rangeTypes } = permissionTypes, permissionIds = [];
|
|
1409
|
-
if (workbookTypes == null || workbookTypes.forEach((F) => {
|
|
1410
|
-
permissionIds.push(new F(unitId).id);
|
|
1411
|
-
}), worksheetTypes == null || worksheetTypes.forEach((F) => {
|
|
1412
|
-
permissionIds.push(new F(unitId, subUnitId).id);
|
|
1413
|
-
}), worksheetRuleModel.getRule(unitId, subUnitId))
|
|
1414
|
-
return permissionService.composePermission$(permissionIds).pipe(map((list) => list.some((item) => item.value === !1)));
|
|
1415
|
-
const selectionRanges = selection == null ? void 0 : selection.map((selection2) => selection2.range), rules = rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => selectionRanges == null ? void 0 : selectionRanges.some((range) => rule.ranges.some((ruleRange) => Rectangle.intersects(range, ruleRange))));
|
|
1416
|
-
return rangeTypes == null || rangeTypes.forEach((F) => {
|
|
1417
|
-
rules.forEach((rule) => {
|
|
1418
|
-
permissionIds.push(new F(unitId, subUnitId, rule.permissionId).id);
|
|
1419
|
-
});
|
|
1420
|
-
}), permissionService.composePermission$(permissionIds).pipe(map((list) => list.some((item) => item.value === !1)));
|
|
1421
|
-
})
|
|
1422
|
-
);
|
|
1423
|
-
})
|
|
1424
|
-
) : of(!0))
|
|
1425
|
-
);
|
|
1426
|
-
}
|
|
1427
|
-
__name(getCurrentRangeDisable$, "getCurrentRangeDisable$");
|
|
1428
|
-
function getBaseRangeMenuHidden$(accessor) {
|
|
1429
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService);
|
|
1430
|
-
return merge(selectionManagerService.selectionMoveEnd$, permissionService.permissionPointUpdate$.pipe(debounceTime(100))).pipe(
|
|
1431
|
-
map(() => {
|
|
1432
|
-
var _a61;
|
|
1433
|
-
const range = (_a61 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a61.range;
|
|
1434
|
-
if (!range) return !0;
|
|
1435
|
-
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
1436
|
-
if (!workbook || !worksheet)
|
|
1437
|
-
return !0;
|
|
1438
|
-
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionIds = [new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id];
|
|
1439
|
-
return rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(range, ruleRange))).forEach((rule) => {
|
|
1440
|
-
permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId).id);
|
|
1441
|
-
}), permissionService.composePermission(permissionIds).some((item) => item.value === !1);
|
|
1442
|
-
})
|
|
1443
|
-
);
|
|
1444
|
-
}
|
|
1445
|
-
__name(getBaseRangeMenuHidden$, "getBaseRangeMenuHidden$");
|
|
1446
|
-
function getDeleteMenuHidden$(accessor, type) {
|
|
1447
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService);
|
|
1448
|
-
return merge(selectionManagerService.selectionMoveEnd$, permissionService.permissionPointUpdate$.pipe(debounceTime(100))).pipe(
|
|
1449
|
-
map(() => {
|
|
1450
|
-
var _a61;
|
|
1451
|
-
const range = (_a61 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a61.range;
|
|
1452
|
-
if (!range) return !0;
|
|
1453
|
-
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
1454
|
-
if (!workbook || !worksheet)
|
|
1455
|
-
return !0;
|
|
1456
|
-
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionIds = [new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id], rowColRangeExpand = Tools.deepClone(range);
|
|
1457
|
-
return type === "row" ? (rowColRangeExpand.startColumn = 0, rowColRangeExpand.endColumn = worksheet.getColumnCount() - 1) : (rowColRangeExpand.startRow = 0, rowColRangeExpand.endRow = worksheet.getRowCount() - 1), rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(rowColRangeExpand, ruleRange))).forEach((rule) => {
|
|
1458
|
-
permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId).id);
|
|
1459
|
-
}), permissionService.composePermission(permissionIds).some((item) => item.value === !1);
|
|
1460
|
-
})
|
|
1461
|
-
);
|
|
1462
|
-
}
|
|
1463
|
-
__name(getDeleteMenuHidden$, "getDeleteMenuHidden$");
|
|
1464
|
-
function getCellMenuHidden$(accessor, type) {
|
|
1465
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService);
|
|
1466
|
-
return merge(selectionManagerService.selectionMoveEnd$, permissionService.permissionPointUpdate$.pipe(debounceTime(100))).pipe(
|
|
1467
|
-
map(() => {
|
|
1468
|
-
var _a61;
|
|
1469
|
-
const range = (_a61 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a61.range;
|
|
1470
|
-
if (!range) return !0;
|
|
1471
|
-
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
1472
|
-
if (!workbook || !worksheet)
|
|
1473
|
-
return !0;
|
|
1474
|
-
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionIds = [new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id], rowColRangeExpand = Tools.deepClone(range);
|
|
1475
|
-
return type === "row" ? rowColRangeExpand.endRow = worksheet.getRowCount() - 1 : rowColRangeExpand.endColumn = worksheet.getColumnCount() - 1, rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(rowColRangeExpand, ruleRange))).forEach((rule) => {
|
|
1476
|
-
permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId).id);
|
|
1477
|
-
}), permissionService.composePermission(permissionIds).some((item) => item.value === !1);
|
|
1478
|
-
})
|
|
1479
|
-
);
|
|
1480
|
-
}
|
|
1481
|
-
__name(getCellMenuHidden$, "getCellMenuHidden$");
|
|
1482
|
-
function getWorkbookPermissionDisable$(accessor, workbookPermissionTypes) {
|
|
1483
|
-
const workbook$ = accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), worksheetRuleModel = accessor.get(WorksheetProtectionRuleModel), selectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService), userManagerService = accessor.get(UserManagerService);
|
|
1484
|
-
return combineLatest([userManagerService.currentUser$, workbook$]).pipe(
|
|
1485
|
-
switchMap(([_user, workbook]) => workbook ? workbook.activeSheet$.pipe(
|
|
1486
|
-
switchMap((activeSheet) => {
|
|
1487
|
-
var _a61, _b;
|
|
1488
|
-
if (!activeSheet)
|
|
1489
|
-
return of(!0);
|
|
1490
|
-
const unitId = workbook.getUnitId(), workbookPermissionIds = [];
|
|
1491
|
-
workbookPermissionTypes.forEach((F) => workbookPermissionIds.push(new F(unitId).id));
|
|
1492
|
-
const workbookPermission$ = permissionService.composePermission$(workbookPermissionIds).pipe(map((list) => list.every((item) => item.value === !0))), workbookManageCollaboratorPermission$ = (_b = (_a61 = permissionService.getPermissionPoint$(new WorkbookManageCollaboratorPermission(unitId).id)) == null ? void 0 : _a61.pipe(map((permission) => permission.value))) != null ? _b : of(!1);
|
|
1493
|
-
return combineLatest([workbookPermission$, workbookManageCollaboratorPermission$]).pipe(
|
|
1494
|
-
map(([basePermission, manageable]) => {
|
|
1495
|
-
if (!basePermission)
|
|
1496
|
-
return !0;
|
|
1497
|
-
const subUnitId = activeSheet.getSheetId(), worksheetRule = worksheetRuleModel.getRule(unitId, subUnitId), worksheetRuleList = selectionRuleModel.getSubunitRuleList(unitId, subUnitId);
|
|
1498
|
-
return worksheetRule || worksheetRuleList.length ? !manageable : !1;
|
|
1499
|
-
})
|
|
1500
|
-
);
|
|
1501
|
-
})
|
|
1502
|
-
) : of(!0))
|
|
1503
|
-
);
|
|
1504
|
-
}
|
|
1505
|
-
__name(getWorkbookPermissionDisable$, "getWorkbookPermissionDisable$");
|
|
1506
|
-
var __defProp$R = Object.defineProperty, __getOwnPropDesc$R = Object.getOwnPropertyDescriptor, __decorateClass$R = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1507
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$R(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1508
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1509
|
-
return kind && result && __defProp$R(target, key, result), result;
|
|
1510
|
-
}, "__decorateClass$R"), __decorateParam$R = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$R");
|
|
1511
|
-
const SHEET_MAIN_CANVAS_ID = "univer-sheet-main-canvas";
|
|
1512
|
-
var _a5;
|
|
1513
|
-
let SheetsRenderService = (_a5 = class extends RxDisposable {
|
|
1514
|
-
constructor(_contextService, _instanceSrv, _renderManagerService) {
|
|
1515
|
-
super();
|
|
1516
|
-
__publicField(this, "_skeletonChangeMutations", /* @__PURE__ */ new Set());
|
|
1517
|
-
this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, Promise.resolve().then(() => this._init());
|
|
505
|
+
startColumn,
|
|
506
|
+
startRow,
|
|
507
|
+
endColumn,
|
|
508
|
+
endRow,
|
|
509
|
+
startX,
|
|
510
|
+
startY,
|
|
511
|
+
endX,
|
|
512
|
+
endY,
|
|
513
|
+
rangeType
|
|
514
|
+
} = newSelectionRange;
|
|
515
|
+
this._startColumn = startColumn, this._startRow = startRow, this._endColumn = endColumn, this._endRow = endRow, this._startX = startX, this._startY = startY, this._endX = endX, this._endY = endY, rangeType !== void 0 && (this._rangeType = rangeType), this.setCurrentCell(currentCell);
|
|
1518
516
|
}
|
|
1519
517
|
/**
|
|
1520
|
-
*
|
|
518
|
+
* Set primary cell.
|
|
1521
519
|
*
|
|
1522
|
-
* @
|
|
1523
|
-
* @
|
|
520
|
+
* TODO @lumixraku there are 3 concepts for same thing, primary and current and highlight, primary is better cuz selectionModel is using primary.
|
|
521
|
+
* @param currentCell
|
|
1524
522
|
*/
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
}) : (this._skeletonChangeMutations.add(mutationId), toDisposable(() => this._skeletonChangeMutations.delete(mutationId)));
|
|
523
|
+
setCurrentCell(currentCell) {
|
|
524
|
+
currentCell && (this._primary = currentCell);
|
|
1528
525
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
526
|
+
clearCurrentCell() {
|
|
527
|
+
this._primary = null;
|
|
1531
528
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
529
|
+
};
|
|
530
|
+
__name(_SelectionRenderModel, "SelectionRenderModel");
|
|
531
|
+
let SelectionRenderModel = _SelectionRenderModel;
|
|
532
|
+
var SELECTION_MANAGER_KEY = /* @__PURE__ */ ((SELECTION_MANAGER_KEY2) => (SELECTION_MANAGER_KEY2.Selection = "__SpreadsheetSelectionShape__", SELECTION_MANAGER_KEY2.top = "__SpreadsheetSelectionTopControl__", SELECTION_MANAGER_KEY2.bottom = "__SpreadsheetSelectionBottomControl__", SELECTION_MANAGER_KEY2.left = "__SpreadsheetSelectionShapeLeftControl__", SELECTION_MANAGER_KEY2.right = "__SpreadsheetSelectionShapeRightControl__", SELECTION_MANAGER_KEY2.backgroundTop = "__SpreadsheetSelectionBackgroundControlTop__", SELECTION_MANAGER_KEY2.backgroundMiddleLeft = "__SpreadsheetSelectionBackgroundControlMiddleLeft__", SELECTION_MANAGER_KEY2.backgroundMiddleRight = "__SpreadsheetSelectionBackgroundControlMiddleRight__", SELECTION_MANAGER_KEY2.backgroundBottom = "__SpreadsheetSelectionBackgroundControlBottom__", SELECTION_MANAGER_KEY2.fill = "__SpreadsheetSelectionFillControl__", SELECTION_MANAGER_KEY2.fillTopLeft = "__SpreadsheetSelectionFillControlTopLeft__", SELECTION_MANAGER_KEY2.fillBottomRight = "__SpreadsheetSelectionFillControlBottomRight__", SELECTION_MANAGER_KEY2.fillTopLeftInner = "__SpreadsheetSelectionFillControlTopLeftInner__", SELECTION_MANAGER_KEY2.fillBottomRightInner = "__SpreadsheetSelectionFillControlBottomRightInner__", SELECTION_MANAGER_KEY2.lineMain = "__SpreadsheetDragLineMainControl__", SELECTION_MANAGER_KEY2.lineContent = "__SpreadsheetDragLineContentControl__", SELECTION_MANAGER_KEY2.line = "__SpreadsheetDragLineControl__", SELECTION_MANAGER_KEY2.dash = "__SpreadsheetDragDashControl__", SELECTION_MANAGER_KEY2.rowHeaderBackground = "__SpreadSheetSelectionRowHeaderBackground__", SELECTION_MANAGER_KEY2.rowHeaderBorder = "__SpreadSheetSelectionRowHeaderBorder__", SELECTION_MANAGER_KEY2.rowHeaderGroup = "__SpreadSheetSelectionRowHeaderGroup__", SELECTION_MANAGER_KEY2.columnHeaderBackground = "__SpreadSheetSelectionColumnHeaderBackground__", SELECTION_MANAGER_KEY2.columnHeaderBorder = "__SpreadSheetSelectionColumnHeaderBorder__", SELECTION_MANAGER_KEY2.columnHeaderGroup = "__SpreadSheetSelectionColumnHeaderGroup__", SELECTION_MANAGER_KEY2.topLeftWidget = "__SpreadSheetSelectionTopLeftWidget__", SELECTION_MANAGER_KEY2.topCenterWidget = "__SpreadSheetSelectionTopCenterWidget__", SELECTION_MANAGER_KEY2.topRightWidget = "__SpreadSheetSelectionTopRightWidget__", SELECTION_MANAGER_KEY2.middleLeftWidget = "__SpreadSheetSelectionMiddleLeftWidget__", SELECTION_MANAGER_KEY2.middleRightWidget = "__SpreadSheetSelectionMiddleRightWidget__", SELECTION_MANAGER_KEY2.bottomLeftWidget = "__SpreadSheetSelectionBottomLeftWidget__", SELECTION_MANAGER_KEY2.bottomCenterWidget = "__SpreadSheetSelectionBottomCenterWidget__", SELECTION_MANAGER_KEY2.bottomRightWidget = "__SpreadSheetSelectionBottomRightWidget__", SELECTION_MANAGER_KEY2))(SELECTION_MANAGER_KEY || {});
|
|
533
|
+
const SELECTION_TITLE_HIGHLIGHT_ALPHA = 0.3, _SelectionControl = class _SelectionControl extends Disposable {
|
|
534
|
+
constructor(_scene, _zIndex, _themeService, _highlightHeader = !0, options) {
|
|
535
|
+
super();
|
|
536
|
+
__publicField(this, "_leftBorder");
|
|
537
|
+
__publicField(this, "_rightBorder");
|
|
538
|
+
__publicField(this, "_topBorder");
|
|
539
|
+
__publicField(this, "_bottomBorder");
|
|
540
|
+
__publicField(this, "_backgroundControlTop");
|
|
541
|
+
__publicField(this, "_backgroundControlBottom");
|
|
542
|
+
__publicField(this, "_backgroundControlMiddleLeft");
|
|
543
|
+
__publicField(this, "_backgroundControlMiddleRight");
|
|
544
|
+
__publicField(this, "_fillControl");
|
|
545
|
+
__publicField(this, "_selectionShapeGroup");
|
|
546
|
+
__publicField(this, "_rowHeaderBackground");
|
|
547
|
+
__publicField(this, "_rowHeaderBorder");
|
|
548
|
+
__publicField(this, "_rowHeaderGroup");
|
|
549
|
+
// private _rowHeaderHighlight!: Rect;
|
|
550
|
+
__publicField(this, "_columnHeaderBackground");
|
|
551
|
+
__publicField(this, "_columnHeaderBorder");
|
|
552
|
+
__publicField(this, "_columnHeaderGroup");
|
|
553
|
+
// private _columnHeaderHighlight!: Rect;
|
|
554
|
+
// for ref selection
|
|
555
|
+
__publicField(this, "_topLeftWidget");
|
|
556
|
+
__publicField(this, "_topCenterWidget");
|
|
557
|
+
__publicField(this, "_topRightWidget");
|
|
558
|
+
__publicField(this, "_middleLeftWidget");
|
|
559
|
+
__publicField(this, "_middleRightWidget");
|
|
560
|
+
__publicField(this, "_bottomLeftWidget");
|
|
561
|
+
__publicField(this, "_bottomCenterWidget");
|
|
562
|
+
__publicField(this, "_bottomRightWidget");
|
|
563
|
+
__publicField(this, "_dashedRect");
|
|
564
|
+
__publicField(this, "_selectionModel");
|
|
565
|
+
// why three style prop? what's diff between _selectionStyle & _currentStyle?
|
|
566
|
+
// protected _selectionStyle: Nullable<ISelectionStyle>;
|
|
567
|
+
__publicField(this, "_defaultStyle");
|
|
568
|
+
__publicField(this, "_currentStyle");
|
|
569
|
+
__publicField(this, "_rowHeaderWidth", 0);
|
|
570
|
+
__publicField(this, "_columnHeaderHeight", 0);
|
|
571
|
+
__publicField(this, "_widgetRects", []);
|
|
572
|
+
__publicField(this, "_dispose$", new BehaviorSubject(this));
|
|
573
|
+
__publicField(this, "dispose$", this._dispose$.asObservable());
|
|
574
|
+
/**
|
|
575
|
+
* eventSource: selectionShapeExtension selectionMoving$.next,
|
|
576
|
+
* Observer: prompt.controller
|
|
577
|
+
*/
|
|
578
|
+
__publicField(this, "selectionMoving$", new Subject());
|
|
579
|
+
__publicField(this, "selectionMoved$", new Subject());
|
|
580
|
+
__publicField(this, "selectionScaling$", new Subject());
|
|
581
|
+
__publicField(this, "selectionScaled$", new Subject());
|
|
582
|
+
__publicField(this, "selectionFilling$", new Subject());
|
|
583
|
+
__publicField(this, "_selectionFilled$", new Subject());
|
|
584
|
+
__publicField(this, "selectionFilled$", this._selectionFilled$.asObservable());
|
|
585
|
+
__publicField(this, "_isHelperSelection", !0);
|
|
586
|
+
__publicField(this, "_antLineOffset", 0);
|
|
587
|
+
__publicField(this, "_antRequestNewFrame", -1);
|
|
588
|
+
this._scene = _scene, this._zIndex = _zIndex, this._themeService = _themeService, this._highlightHeader = _highlightHeader, this._rowHeaderWidth = (options == null ? void 0 : options.rowHeaderWidth) || 0, this._columnHeaderHeight = (options == null ? void 0 : options.columnHeaderHeight) || 0, this._initialize();
|
|
1534
589
|
}
|
|
1535
|
-
|
|
1536
|
-
this.
|
|
1537
|
-
this._createRenderer(workbook);
|
|
1538
|
-
}), this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._createRenderer(workbook)), this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._disposeRenderer(workbook));
|
|
590
|
+
get zIndex() {
|
|
591
|
+
return this._zIndex;
|
|
1539
592
|
}
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
this._renderManagerService.created$.subscribe((renderer) => {
|
|
1543
|
-
renderer.unitId === unitId && renderer.engine.getCanvas().setId(SHEET_MAIN_CANVAS_ID);
|
|
1544
|
-
}), this._renderManagerService.createRender(unitId), this._renderManagerService.setCurrent(unitId);
|
|
593
|
+
get leftControl() {
|
|
594
|
+
return this._leftBorder;
|
|
1545
595
|
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
this._renderManagerService.removeRender(unitId);
|
|
1549
|
-
}
|
|
1550
|
-
_initContextListener() {
|
|
1551
|
-
this._contextService.subscribeContextValue$(RENDER_RAW_FORMULA_KEY).pipe(distinctUntilChanged(), takeUntil(this.dispose$)).subscribe(() => {
|
|
1552
|
-
this._renderManagerService.getRenderAll().forEach((renderer) => {
|
|
1553
|
-
renderer.mainComponent instanceof Spreadsheet && renderer.mainComponent.makeForceDirty(!0);
|
|
1554
|
-
});
|
|
1555
|
-
});
|
|
1556
|
-
}
|
|
1557
|
-
}, __name(_a5, "SheetsRenderService"), _a5);
|
|
1558
|
-
SheetsRenderService = __decorateClass$R([
|
|
1559
|
-
__decorateParam$R(0, IContextService),
|
|
1560
|
-
__decorateParam$R(1, IUniverInstanceService),
|
|
1561
|
-
__decorateParam$R(2, IRenderManagerService)
|
|
1562
|
-
], SheetsRenderService);
|
|
1563
|
-
const RANGE_MOVE_PERMISSION_CHECK = createInterceptorKey("rangeMovePermissionCheck"), RANGE_FILL_PERMISSION_CHECK = createInterceptorKey("rangeFillPermissionCheck");
|
|
1564
|
-
var SELECTION_SHAPE_DEPTH = /* @__PURE__ */ ((SELECTION_SHAPE_DEPTH2) => (SELECTION_SHAPE_DEPTH2[SELECTION_SHAPE_DEPTH2.FORMULA_EDITOR_SHOW = 100] = "FORMULA_EDITOR_SHOW", SELECTION_SHAPE_DEPTH2[SELECTION_SHAPE_DEPTH2.MARK_SELECTION = 1e4] = "MARK_SELECTION", SELECTION_SHAPE_DEPTH2))(SELECTION_SHAPE_DEPTH || {});
|
|
1565
|
-
const _SelectionRenderModel = class _SelectionRenderModel {
|
|
1566
|
-
constructor() {
|
|
1567
|
-
__publicField(this, "_startColumn", -1);
|
|
1568
|
-
__publicField(this, "_startRow", -1);
|
|
1569
|
-
__publicField(this, "_endColumn", -1);
|
|
1570
|
-
__publicField(this, "_endRow", -1);
|
|
1571
|
-
__publicField(this, "_startX", 0);
|
|
1572
|
-
__publicField(this, "_startY", 0);
|
|
1573
|
-
__publicField(this, "_endX", 0);
|
|
1574
|
-
__publicField(this, "_endY", 0);
|
|
1575
|
-
/**
|
|
1576
|
-
* The highlight cell of a selection. aka: current cell
|
|
1577
|
-
*/
|
|
1578
|
-
__publicField(this, "_primary");
|
|
1579
|
-
__publicField(this, "_rangeType", RANGE_TYPE.NORMAL);
|
|
1580
|
-
}
|
|
1581
|
-
get startColumn() {
|
|
1582
|
-
return this._startColumn;
|
|
1583
|
-
}
|
|
1584
|
-
get startRow() {
|
|
1585
|
-
return this._startRow;
|
|
1586
|
-
}
|
|
1587
|
-
get endColumn() {
|
|
1588
|
-
return this._endColumn;
|
|
1589
|
-
}
|
|
1590
|
-
get endRow() {
|
|
1591
|
-
return this._endRow;
|
|
1592
|
-
}
|
|
1593
|
-
get startX() {
|
|
1594
|
-
return this._startX;
|
|
1595
|
-
}
|
|
1596
|
-
get startY() {
|
|
1597
|
-
return this._startY;
|
|
1598
|
-
}
|
|
1599
|
-
get endX() {
|
|
1600
|
-
return this._endX;
|
|
1601
|
-
}
|
|
1602
|
-
get endY() {
|
|
1603
|
-
return this._endY;
|
|
1604
|
-
}
|
|
1605
|
-
get currentCell() {
|
|
1606
|
-
return this._primary;
|
|
1607
|
-
}
|
|
1608
|
-
get rangeType() {
|
|
1609
|
-
return this._rangeType;
|
|
1610
|
-
}
|
|
1611
|
-
/**
|
|
1612
|
-
* @deprecated, Duplicate with `Rectangle`
|
|
1613
|
-
*/
|
|
1614
|
-
isEqual(rangeWithCoord) {
|
|
1615
|
-
const { startColumn, startRow, endColumn, endRow } = this, {
|
|
1616
|
-
startColumn: newStartColumn,
|
|
1617
|
-
startRow: newStartRow,
|
|
1618
|
-
endColumn: newEndColumn,
|
|
1619
|
-
endRow: newEndRow
|
|
1620
|
-
} = rangeWithCoord;
|
|
1621
|
-
return startColumn === newStartColumn && startRow === newStartRow && endColumn === newEndColumn && endRow === newEndRow;
|
|
1622
|
-
}
|
|
1623
|
-
/**
|
|
1624
|
-
* @deprecated, Duplicate with `Rectangle`
|
|
1625
|
-
*/
|
|
1626
|
-
isInclude(rangeWithCoord) {
|
|
1627
|
-
const { startColumn, startRow, endColumn, endRow } = this, {
|
|
1628
|
-
startColumn: newStartColumn,
|
|
1629
|
-
startRow: newStartRow,
|
|
1630
|
-
endColumn: newEndColumn,
|
|
1631
|
-
endRow: newEndRow
|
|
1632
|
-
} = rangeWithCoord;
|
|
1633
|
-
return !(newEndColumn < startColumn || newStartColumn > endColumn || newStartRow > endRow || newEndRow < startRow);
|
|
1634
|
-
}
|
|
1635
|
-
highlightToSelection() {
|
|
1636
|
-
if (this._primary)
|
|
1637
|
-
return makeCellToSelection(this._primary);
|
|
1638
|
-
}
|
|
1639
|
-
getRange() {
|
|
1640
|
-
return {
|
|
1641
|
-
startColumn: this._startColumn,
|
|
1642
|
-
startRow: this._startRow,
|
|
1643
|
-
endColumn: this._endColumn,
|
|
1644
|
-
endRow: this._endRow,
|
|
1645
|
-
startX: this._startX,
|
|
1646
|
-
startY: this._startY,
|
|
1647
|
-
endX: this._endX,
|
|
1648
|
-
endY: this._endY,
|
|
1649
|
-
rangeType: this.rangeType
|
|
1650
|
-
};
|
|
1651
|
-
}
|
|
1652
|
-
getCell() {
|
|
1653
|
-
return this._primary;
|
|
1654
|
-
}
|
|
1655
|
-
getRangeType() {
|
|
1656
|
-
return this._rangeType;
|
|
1657
|
-
}
|
|
1658
|
-
setRangeType(rangeType) {
|
|
1659
|
-
this._rangeType = rangeType;
|
|
1660
|
-
}
|
|
1661
|
-
getValue() {
|
|
1662
|
-
return {
|
|
1663
|
-
rangeWithCoord: this.getRange(),
|
|
1664
|
-
primaryWithCoord: this._primary
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
1667
|
-
setValue(newSelectionRange, currentCell) {
|
|
1668
|
-
const {
|
|
1669
|
-
startColumn,
|
|
1670
|
-
startRow,
|
|
1671
|
-
endColumn,
|
|
1672
|
-
endRow,
|
|
1673
|
-
startX,
|
|
1674
|
-
startY,
|
|
1675
|
-
endX,
|
|
1676
|
-
endY,
|
|
1677
|
-
rangeType
|
|
1678
|
-
} = newSelectionRange;
|
|
1679
|
-
this._startColumn = startColumn, this._startRow = startRow, this._endColumn = endColumn, this._endRow = endRow, this._startX = startX, this._startY = startY, this._endX = endX, this._endY = endY, rangeType !== void 0 && (this._rangeType = rangeType), this.setCurrentCell(currentCell);
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* Set primary cell.
|
|
1683
|
-
*
|
|
1684
|
-
* TODO @lumixraku there are 3 concepts for same thing, primary and current and highlight, primary is better cuz selectionModel is using primary.
|
|
1685
|
-
* @param currentCell
|
|
1686
|
-
*/
|
|
1687
|
-
setCurrentCell(currentCell) {
|
|
1688
|
-
currentCell && (this._primary = currentCell);
|
|
1689
|
-
}
|
|
1690
|
-
clearCurrentCell() {
|
|
1691
|
-
this._primary = null;
|
|
1692
|
-
}
|
|
1693
|
-
};
|
|
1694
|
-
__name(_SelectionRenderModel, "SelectionRenderModel");
|
|
1695
|
-
let SelectionRenderModel = _SelectionRenderModel;
|
|
1696
|
-
var SELECTION_MANAGER_KEY = /* @__PURE__ */ ((SELECTION_MANAGER_KEY2) => (SELECTION_MANAGER_KEY2.Selection = "__SpreadsheetSelectionShape__", SELECTION_MANAGER_KEY2.top = "__SpreadsheetSelectionTopControl__", SELECTION_MANAGER_KEY2.bottom = "__SpreadsheetSelectionBottomControl__", SELECTION_MANAGER_KEY2.left = "__SpreadsheetSelectionShapeLeftControl__", SELECTION_MANAGER_KEY2.right = "__SpreadsheetSelectionShapeRightControl__", SELECTION_MANAGER_KEY2.backgroundTop = "__SpreadsheetSelectionBackgroundControlTop__", SELECTION_MANAGER_KEY2.backgroundMiddleLeft = "__SpreadsheetSelectionBackgroundControlMiddleLeft__", SELECTION_MANAGER_KEY2.backgroundMiddleRight = "__SpreadsheetSelectionBackgroundControlMiddleRight__", SELECTION_MANAGER_KEY2.backgroundBottom = "__SpreadsheetSelectionBackgroundControlBottom__", SELECTION_MANAGER_KEY2.fill = "__SpreadsheetSelectionFillControl__", SELECTION_MANAGER_KEY2.fillTopLeft = "__SpreadsheetSelectionFillControlTopLeft__", SELECTION_MANAGER_KEY2.fillBottomRight = "__SpreadsheetSelectionFillControlBottomRight__", SELECTION_MANAGER_KEY2.fillTopLeftInner = "__SpreadsheetSelectionFillControlTopLeftInner__", SELECTION_MANAGER_KEY2.fillBottomRightInner = "__SpreadsheetSelectionFillControlBottomRightInner__", SELECTION_MANAGER_KEY2.lineMain = "__SpreadsheetDragLineMainControl__", SELECTION_MANAGER_KEY2.lineContent = "__SpreadsheetDragLineContentControl__", SELECTION_MANAGER_KEY2.line = "__SpreadsheetDragLineControl__", SELECTION_MANAGER_KEY2.dash = "__SpreadsheetDragDashControl__", SELECTION_MANAGER_KEY2.rowHeaderBackground = "__SpreadSheetSelectionRowHeaderBackground__", SELECTION_MANAGER_KEY2.rowHeaderBorder = "__SpreadSheetSelectionRowHeaderBorder__", SELECTION_MANAGER_KEY2.rowHeaderGroup = "__SpreadSheetSelectionRowHeaderGroup__", SELECTION_MANAGER_KEY2.columnHeaderBackground = "__SpreadSheetSelectionColumnHeaderBackground__", SELECTION_MANAGER_KEY2.columnHeaderBorder = "__SpreadSheetSelectionColumnHeaderBorder__", SELECTION_MANAGER_KEY2.columnHeaderGroup = "__SpreadSheetSelectionColumnHeaderGroup__", SELECTION_MANAGER_KEY2.topLeftWidget = "__SpreadSheetSelectionTopLeftWidget__", SELECTION_MANAGER_KEY2.topCenterWidget = "__SpreadSheetSelectionTopCenterWidget__", SELECTION_MANAGER_KEY2.topRightWidget = "__SpreadSheetSelectionTopRightWidget__", SELECTION_MANAGER_KEY2.middleLeftWidget = "__SpreadSheetSelectionMiddleLeftWidget__", SELECTION_MANAGER_KEY2.middleRightWidget = "__SpreadSheetSelectionMiddleRightWidget__", SELECTION_MANAGER_KEY2.bottomLeftWidget = "__SpreadSheetSelectionBottomLeftWidget__", SELECTION_MANAGER_KEY2.bottomCenterWidget = "__SpreadSheetSelectionBottomCenterWidget__", SELECTION_MANAGER_KEY2.bottomRightWidget = "__SpreadSheetSelectionBottomRightWidget__", SELECTION_MANAGER_KEY2))(SELECTION_MANAGER_KEY || {});
|
|
1697
|
-
const SELECTION_TITLE_HIGHLIGHT_ALPHA = 0.3, _SelectionControl = class _SelectionControl extends Disposable {
|
|
1698
|
-
constructor(_scene, _zIndex, _themeService, _highlightHeader = !0, options) {
|
|
1699
|
-
super();
|
|
1700
|
-
__publicField(this, "_leftBorder");
|
|
1701
|
-
__publicField(this, "_rightBorder");
|
|
1702
|
-
__publicField(this, "_topBorder");
|
|
1703
|
-
__publicField(this, "_bottomBorder");
|
|
1704
|
-
__publicField(this, "_backgroundControlTop");
|
|
1705
|
-
__publicField(this, "_backgroundControlBottom");
|
|
1706
|
-
__publicField(this, "_backgroundControlMiddleLeft");
|
|
1707
|
-
__publicField(this, "_backgroundControlMiddleRight");
|
|
1708
|
-
__publicField(this, "_fillControl");
|
|
1709
|
-
__publicField(this, "_selectionShapeGroup");
|
|
1710
|
-
__publicField(this, "_rowHeaderBackground");
|
|
1711
|
-
__publicField(this, "_rowHeaderBorder");
|
|
1712
|
-
__publicField(this, "_rowHeaderGroup");
|
|
1713
|
-
// private _rowHeaderHighlight!: Rect;
|
|
1714
|
-
__publicField(this, "_columnHeaderBackground");
|
|
1715
|
-
__publicField(this, "_columnHeaderBorder");
|
|
1716
|
-
__publicField(this, "_columnHeaderGroup");
|
|
1717
|
-
// private _columnHeaderHighlight!: Rect;
|
|
1718
|
-
// for ref selection
|
|
1719
|
-
__publicField(this, "_topLeftWidget");
|
|
1720
|
-
__publicField(this, "_topCenterWidget");
|
|
1721
|
-
__publicField(this, "_topRightWidget");
|
|
1722
|
-
__publicField(this, "_middleLeftWidget");
|
|
1723
|
-
__publicField(this, "_middleRightWidget");
|
|
1724
|
-
__publicField(this, "_bottomLeftWidget");
|
|
1725
|
-
__publicField(this, "_bottomCenterWidget");
|
|
1726
|
-
__publicField(this, "_bottomRightWidget");
|
|
1727
|
-
__publicField(this, "_dashedRect");
|
|
1728
|
-
__publicField(this, "_selectionModel");
|
|
1729
|
-
// why three style prop? what's diff between _selectionStyle & _currentStyle?
|
|
1730
|
-
// protected _selectionStyle: Nullable<ISelectionStyle>;
|
|
1731
|
-
__publicField(this, "_defaultStyle");
|
|
1732
|
-
__publicField(this, "_currentStyle");
|
|
1733
|
-
__publicField(this, "_rowHeaderWidth", 0);
|
|
1734
|
-
__publicField(this, "_columnHeaderHeight", 0);
|
|
1735
|
-
__publicField(this, "_widgetRects", []);
|
|
1736
|
-
__publicField(this, "_dispose$", new BehaviorSubject(this));
|
|
1737
|
-
__publicField(this, "dispose$", this._dispose$.asObservable());
|
|
1738
|
-
/**
|
|
1739
|
-
* eventSource: selectionShapeExtension selectionMoving$.next,
|
|
1740
|
-
* Observer: prompt.controller
|
|
1741
|
-
*/
|
|
1742
|
-
__publicField(this, "selectionMoving$", new Subject());
|
|
1743
|
-
__publicField(this, "selectionMoved$", new Subject());
|
|
1744
|
-
__publicField(this, "selectionScaling$", new Subject());
|
|
1745
|
-
__publicField(this, "selectionScaled$", new Subject());
|
|
1746
|
-
__publicField(this, "selectionFilling$", new Subject());
|
|
1747
|
-
__publicField(this, "_selectionFilled$", new Subject());
|
|
1748
|
-
__publicField(this, "selectionFilled$", this._selectionFilled$.asObservable());
|
|
1749
|
-
__publicField(this, "_isHelperSelection", !0);
|
|
1750
|
-
__publicField(this, "_antLineOffset", 0);
|
|
1751
|
-
__publicField(this, "_antRequestNewFrame", -1);
|
|
1752
|
-
this._scene = _scene, this._zIndex = _zIndex, this._themeService = _themeService, this._highlightHeader = _highlightHeader, this._rowHeaderWidth = (options == null ? void 0 : options.rowHeaderWidth) || 0, this._columnHeaderHeight = (options == null ? void 0 : options.columnHeaderHeight) || 0, this._initialize();
|
|
1753
|
-
}
|
|
1754
|
-
get zIndex() {
|
|
1755
|
-
return this._zIndex;
|
|
1756
|
-
}
|
|
1757
|
-
get leftControl() {
|
|
1758
|
-
return this._leftBorder;
|
|
1759
|
-
}
|
|
1760
|
-
get rightControl() {
|
|
1761
|
-
return this._rightBorder;
|
|
596
|
+
get rightControl() {
|
|
597
|
+
return this._rightBorder;
|
|
1762
598
|
}
|
|
1763
599
|
get topControl() {
|
|
1764
600
|
return this._topBorder;
|
|
@@ -2677,663 +1513,1841 @@ const HELPER_SELECTION_TEMP_NAME = "__SpreadsheetHelperSelectionTempRect", SELEC
|
|
|
2677
1513
|
y: scrollTimer.scrollTimerType === ScrollTimerType.Y ? 0 : void 0
|
|
2678
1514
|
}), this._activeViewport = currentViewport);
|
|
2679
1515
|
}
|
|
2680
|
-
scrollTimer.scrolling(newMoveOffsetX, newMoveOffsetY, () => {
|
|
2681
|
-
this._fillMoving(newMoveOffsetX, newMoveOffsetY);
|
|
1516
|
+
scrollTimer.scrolling(newMoveOffsetX, newMoveOffsetY, () => {
|
|
1517
|
+
this._fillMoving(newMoveOffsetX, newMoveOffsetY);
|
|
1518
|
+
});
|
|
1519
|
+
}), this._scenePointerUpSub = scene.onPointerUp$.subscribeEvent(() => {
|
|
1520
|
+
var _a61, _b;
|
|
1521
|
+
(_a61 = this._helperSelection) == null || _a61.dispose();
|
|
1522
|
+
const scene2 = this._scene;
|
|
1523
|
+
scene2.resetCursor(), this._clearObserverEvent(), scene2.enableObjectsEvent(), (_b = this._scrollTimer) == null || _b.dispose(), this._control.refreshSelectionFilled(this._targetSelection), this._isInMergeState = !1, this._controlHandler((o, index) => {
|
|
1524
|
+
o.setProps({
|
|
1525
|
+
fill: this._fillControlColors[index]
|
|
1526
|
+
});
|
|
1527
|
+
}), this._fillControlColors = [];
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
_hasMergeInRange(startRow, startColumn, endRow, endColumn) {
|
|
1531
|
+
return this._skeleton.worksheet.getMergedCellRange(startRow, startColumn, endRow, endColumn).length > 0;
|
|
1532
|
+
}
|
|
1533
|
+
_swapPositions(startRow, startColumn, endRow, endColumn) {
|
|
1534
|
+
const finalStartRow = Math.min(startRow, endRow), finalStartColumn = Math.min(startColumn, endColumn), finalEndRow = Math.max(startRow, endRow), finalEndColumn = Math.max(startColumn, endColumn);
|
|
1535
|
+
return {
|
|
1536
|
+
startRow: finalStartRow,
|
|
1537
|
+
startColumn: finalStartColumn,
|
|
1538
|
+
endRow: finalEndRow,
|
|
1539
|
+
endColumn: finalEndColumn
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
_controlHandler(func) {
|
|
1543
|
+
const {
|
|
1544
|
+
leftControl,
|
|
1545
|
+
rightControl,
|
|
1546
|
+
topControl,
|
|
1547
|
+
bottomControl,
|
|
1548
|
+
backgroundControlTop,
|
|
1549
|
+
backgroundControlMiddleLeft,
|
|
1550
|
+
backgroundControlMiddleRight,
|
|
1551
|
+
backgroundControlBottom,
|
|
1552
|
+
fillControl
|
|
1553
|
+
} = this._control, objects = [
|
|
1554
|
+
leftControl,
|
|
1555
|
+
rightControl,
|
|
1556
|
+
topControl,
|
|
1557
|
+
bottomControl,
|
|
1558
|
+
backgroundControlTop,
|
|
1559
|
+
backgroundControlMiddleLeft,
|
|
1560
|
+
backgroundControlMiddleRight,
|
|
1561
|
+
backgroundControlBottom,
|
|
1562
|
+
fillControl
|
|
1563
|
+
];
|
|
1564
|
+
for (let i = 0, len = objects.length; i < len; i++) {
|
|
1565
|
+
const object = objects[i];
|
|
1566
|
+
func(object, i);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
_fillRuler(rowOrColumn, startRowOrColumn, endRowOrColumn, rowOrColumnLength, maxRowOrColumn) {
|
|
1570
|
+
let isLighten = !1;
|
|
1571
|
+
if (rowOrColumn < startRowOrColumn)
|
|
1572
|
+
if (this._isInMergeState && rowOrColumn < startRowOrColumn) {
|
|
1573
|
+
const current = startRowOrColumn - rowOrColumn, rangeRowCount = rowOrColumnLength + 1, step = Math.ceil(current / rangeRowCount);
|
|
1574
|
+
let newStartRow = startRowOrColumn - step * rangeRowCount;
|
|
1575
|
+
newStartRow < 0 && (newStartRow = startRowOrColumn - (step - 1) * rangeRowCount), startRowOrColumn = newStartRow;
|
|
1576
|
+
} else
|
|
1577
|
+
startRowOrColumn = rowOrColumn;
|
|
1578
|
+
else if (rowOrColumn >= startRowOrColumn && rowOrColumn <= endRowOrColumn)
|
|
1579
|
+
isLighten = !0, this._isInMergeState || (endRowOrColumn = rowOrColumn);
|
|
1580
|
+
else if (this._isInMergeState && rowOrColumn > endRowOrColumn) {
|
|
1581
|
+
const current = rowOrColumn - endRowOrColumn, rangeRowCount = rowOrColumnLength + 1, step = Math.ceil(current / rangeRowCount);
|
|
1582
|
+
let newEndRow = endRowOrColumn + step * rangeRowCount;
|
|
1583
|
+
newEndRow > maxRowOrColumn && (newEndRow = endRowOrColumn + (step - 1) * rangeRowCount), endRowOrColumn = newEndRow;
|
|
1584
|
+
} else
|
|
1585
|
+
endRowOrColumn = rowOrColumn;
|
|
1586
|
+
return {
|
|
1587
|
+
rowOrColumn,
|
|
1588
|
+
startRowOrColumn,
|
|
1589
|
+
endRowOrColumn,
|
|
1590
|
+
isLighten
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
_getScale() {
|
|
1594
|
+
const { scaleX, scaleY } = this._scene.getAncestorScale();
|
|
1595
|
+
return Math.max(scaleX, scaleY);
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
__name(_SelectionShapeExtension, "SelectionShapeExtension");
|
|
1599
|
+
let SelectionShapeExtension = _SelectionShapeExtension;
|
|
1600
|
+
function attachSelectionWithCoord(selection, skeleton) {
|
|
1601
|
+
const { range, primary, style } = selection;
|
|
1602
|
+
return {
|
|
1603
|
+
rangeWithCoord: attachRangeWithCoord(skeleton, range),
|
|
1604
|
+
primaryWithCoord: primary ? attachPrimaryWithCoord(primary, skeleton) : null,
|
|
1605
|
+
style
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
__name(attachSelectionWithCoord, "attachSelectionWithCoord");
|
|
1609
|
+
function attachPrimaryWithCoord(primary, skeleton) {
|
|
1610
|
+
const { actualRow, actualColumn, isMerged, isMergedMainCell, startRow, startColumn, endRow, endColumn } = primary, cellPosition = skeleton.getNoMergeCellPositionByIndex(actualRow, actualColumn), startCell = skeleton.getNoMergeCellPositionByIndex(startRow, startColumn), endCell = skeleton.getNoMergeCellPositionByIndex(endRow, endColumn);
|
|
1611
|
+
return {
|
|
1612
|
+
actualRow,
|
|
1613
|
+
actualColumn,
|
|
1614
|
+
isMerged,
|
|
1615
|
+
isMergedMainCell,
|
|
1616
|
+
startX: cellPosition.startX,
|
|
1617
|
+
startY: cellPosition.startY,
|
|
1618
|
+
endX: cellPosition.endX,
|
|
1619
|
+
endY: cellPosition.endY,
|
|
1620
|
+
mergeInfo: {
|
|
1621
|
+
startRow,
|
|
1622
|
+
startColumn,
|
|
1623
|
+
endRow,
|
|
1624
|
+
endColumn,
|
|
1625
|
+
startY: (startCell == null ? void 0 : startCell.startY) || 0,
|
|
1626
|
+
endY: (endCell == null ? void 0 : endCell.endY) || 0,
|
|
1627
|
+
startX: (startCell == null ? void 0 : startCell.startX) || 0,
|
|
1628
|
+
endX: (endCell == null ? void 0 : endCell.endX) || 0
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
__name(attachPrimaryWithCoord, "attachPrimaryWithCoord");
|
|
1633
|
+
const ISheetSelectionRenderService = createIdentifier("univer.sheet.selection-render-service"), _BaseSelectionRenderService = class _BaseSelectionRenderService extends Disposable {
|
|
1634
|
+
constructor(_injector, _themeService, _shortcutService, _sheetSkeletonManagerService) {
|
|
1635
|
+
super();
|
|
1636
|
+
__publicField(this, "_downObserver");
|
|
1637
|
+
__publicField(this, "_scenePointerMoveSub");
|
|
1638
|
+
__publicField(this, "_scenePointerUpSub");
|
|
1639
|
+
__publicField(this, "_controlFillConfig$", new BehaviorSubject(null));
|
|
1640
|
+
__publicField(this, "controlFillConfig$", this._controlFillConfig$.asObservable());
|
|
1641
|
+
__publicField(this, "_selectionControls", []);
|
|
1642
|
+
// sheetID:Controls
|
|
1643
|
+
__publicField(this, "_startRangeWhenPointerDown", {
|
|
1644
|
+
startY: 0,
|
|
1645
|
+
endY: 0,
|
|
1646
|
+
startX: 0,
|
|
1647
|
+
endX: 0,
|
|
1648
|
+
startRow: -1,
|
|
1649
|
+
endRow: -1,
|
|
1650
|
+
startColumn: -1,
|
|
1651
|
+
endColumn: -1
|
|
1652
|
+
});
|
|
1653
|
+
/**
|
|
1654
|
+
* the posX of viewport when the pointer down
|
|
1655
|
+
*/
|
|
1656
|
+
__publicField(this, "_startViewportPosX", 0);
|
|
1657
|
+
/**
|
|
1658
|
+
* the posY of viewport when the pointer down
|
|
1659
|
+
*/
|
|
1660
|
+
__publicField(this, "_startViewportPosY", 0);
|
|
1661
|
+
__publicField(this, "_scrollTimer");
|
|
1662
|
+
__publicField(this, "_cancelDownSubscription");
|
|
1663
|
+
__publicField(this, "_cancelUpSubscription");
|
|
1664
|
+
__publicField(this, "_skeleton");
|
|
1665
|
+
__publicField(this, "_scene");
|
|
1666
|
+
// The type of selector determines the type of data range and the highlighting style of the title bar
|
|
1667
|
+
__publicField(this, "_isHeaderHighlight", !0);
|
|
1668
|
+
// If true, the selector will respond to the range of merged cells and automatically extend the selected range. If false, it will ignore the merged cells.
|
|
1669
|
+
__publicField(this, "_shouldDetectMergedCells", !0);
|
|
1670
|
+
// The style of the selection area, including dashed lines, color, thickness, autofill, other points for modifying the range of the selection area, title highlighting, and so on, can all be customized.
|
|
1671
|
+
__publicField(this, "_selectionStyle");
|
|
1672
|
+
// #region ref range selection
|
|
1673
|
+
// we put the properties here for simplicity
|
|
1674
|
+
// Used in the formula selection feature, a new selection string is added by drawing a box with the mouse.
|
|
1675
|
+
__publicField(this, "_remainLastEnabled", !1);
|
|
1676
|
+
__publicField(this, "_skipLastEnabled", !1);
|
|
1677
|
+
__publicField(this, "_singleSelectionEnabled", !1);
|
|
1678
|
+
// #endregion
|
|
1679
|
+
/**
|
|
1680
|
+
* Mainly emit by pointerup (pointerup is handled in _onPointerdown)
|
|
1681
|
+
*/
|
|
1682
|
+
__publicField(this, "_selectionMoveEnd$", new BehaviorSubject([]));
|
|
1683
|
+
__publicField(this, "selectionMoveEnd$", this._selectionMoveEnd$.asObservable());
|
|
1684
|
+
__publicField(this, "_selectionMoving$", new Subject());
|
|
1685
|
+
__publicField(this, "selectionMoving$", this._selectionMoving$.asObservable());
|
|
1686
|
+
/**
|
|
1687
|
+
* Mainly emit by pointerdown
|
|
1688
|
+
*/
|
|
1689
|
+
__publicField(this, "_selectionMoveStart$", new Subject());
|
|
1690
|
+
__publicField(this, "selectionMoveStart$", this._selectionMoveStart$.asObservable());
|
|
1691
|
+
__publicField(this, "_selectionMoving", !1);
|
|
1692
|
+
__publicField(this, "_activeViewport");
|
|
1693
|
+
__publicField(this, "interceptor", new InterceptorManager({ RANGE_MOVE_PERMISSION_CHECK, RANGE_FILL_PERMISSION_CHECK }));
|
|
1694
|
+
__publicField(this, "_escapeShortcutDisposable", null);
|
|
1695
|
+
this._injector = _injector, this._themeService = _themeService, this._shortcutService = _shortcutService, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._resetSelectionStyle(), this._initMoving();
|
|
1696
|
+
}
|
|
1697
|
+
get selectionMoving() {
|
|
1698
|
+
return this._selectionMoving;
|
|
1699
|
+
}
|
|
1700
|
+
_initMoving() {
|
|
1701
|
+
this.disposeWithMe(this._selectionMoving$.subscribe(() => {
|
|
1702
|
+
this._selectionMoving = !0;
|
|
1703
|
+
})), this.disposeWithMe(this._selectionMoveEnd$.subscribe(() => {
|
|
1704
|
+
this._selectionMoving = !1;
|
|
1705
|
+
}));
|
|
1706
|
+
}
|
|
1707
|
+
_setSelectionStyle(style) {
|
|
1708
|
+
this._selectionStyle = style;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Reset this._selectionStyle to default normal selection style
|
|
1712
|
+
*/
|
|
1713
|
+
_resetSelectionStyle() {
|
|
1714
|
+
this._setSelectionStyle(getNormalSelectionStyle(this._themeService));
|
|
1715
|
+
}
|
|
1716
|
+
/** @deprecated This should not be provided by the selection render service. */
|
|
1717
|
+
getViewPort() {
|
|
1718
|
+
return this._activeViewport;
|
|
1719
|
+
}
|
|
1720
|
+
setSingleSelectionEnabled(enabled = !1) {
|
|
1721
|
+
this._singleSelectionEnabled = enabled;
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Add a selection in spreadsheet, create a new SelectionControl and then update this control by range derives from selection.
|
|
1725
|
+
* @param {ISelectionWithCoordAndStyle} selection
|
|
1726
|
+
*/
|
|
1727
|
+
_addSelectionControlBySelectionData(selection) {
|
|
1728
|
+
var _a61;
|
|
1729
|
+
const skeleton = this._skeleton, style = (_a61 = selection.style) != null ? _a61 : getNormalSelectionStyle(this._themeService), scene = this._scene;
|
|
1730
|
+
if (!scene || !skeleton)
|
|
1731
|
+
return;
|
|
1732
|
+
const { rangeWithCoord, primaryWithCoord } = selection, { rangeType } = rangeWithCoord, control = this.newSelectionControl(scene, rangeType || RANGE_TYPE.NORMAL, skeleton);
|
|
1733
|
+
new SelectionShapeExtension(control, skeleton, scene, this._themeService, this._injector, {
|
|
1734
|
+
selectionMoveEnd: /* @__PURE__ */ __name(() => {
|
|
1735
|
+
this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
|
|
1736
|
+
}, "selectionMoveEnd")
|
|
1737
|
+
});
|
|
1738
|
+
const { rowHeaderWidth, columnHeaderHeight } = skeleton;
|
|
1739
|
+
control.update(rangeWithCoord, rowHeaderWidth, columnHeaderHeight, style, primaryWithCoord);
|
|
1740
|
+
}
|
|
1741
|
+
newSelectionControl(scene, _rangeType, skeleton) {
|
|
1742
|
+
const zIndex = this.getSelectionControls().length, { rowHeaderWidth, columnHeaderHeight } = skeleton, control = new SelectionControl(scene, zIndex, this._themeService, this._isHeaderHighlight, {
|
|
1743
|
+
rowHeaderWidth,
|
|
1744
|
+
columnHeaderHeight
|
|
1745
|
+
});
|
|
1746
|
+
return this._selectionControls.push(control), control;
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Update the corresponding selectionControl based on selectionsData.
|
|
1750
|
+
* selectionData[i] syncs selectionControls[i]
|
|
1751
|
+
* @param selections
|
|
1752
|
+
*/
|
|
1753
|
+
updateControlForCurrentByRangeData(selections) {
|
|
1754
|
+
const selectionControls = this.getSelectionControls();
|
|
1755
|
+
if (!(!selectionControls || this._skeleton == null))
|
|
1756
|
+
for (let i = 0, len = selections.length; i < len; i++) {
|
|
1757
|
+
const { rangeWithCoord, primaryWithCoord } = selections[i], control = selectionControls[i];
|
|
1758
|
+
control && control.updateRange(rangeWithCoord, primaryWithCoord);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
refreshSelectionMoveStart() {
|
|
1762
|
+
this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
|
|
1763
|
+
}
|
|
1764
|
+
refreshSelectionMoveEnd() {
|
|
1765
|
+
this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
|
|
1766
|
+
}
|
|
1767
|
+
_changeRuntime(skeleton, scene, viewport) {
|
|
1768
|
+
this._skeleton = skeleton, this._scene = scene, this._activeViewport = viewport || (scene == null ? void 0 : scene.getViewports()[0]), scene.findLayerByZIndex(SHEET_COMPONENT_SELECTION_LAYER_INDEX) || scene.addLayer(new SelectionLayer(scene, [], SHEET_COMPONENT_SELECTION_LAYER_INDEX));
|
|
1769
|
+
}
|
|
1770
|
+
getSkeleton() {
|
|
1771
|
+
return this._skeleton;
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Generate selectionData from this._selectionControls.model .
|
|
1775
|
+
* @returns {ISelectionWithCoordAndStyle[]} {range, primary, style}[]
|
|
1776
|
+
*/
|
|
1777
|
+
getSelectionDataWithStyle() {
|
|
1778
|
+
const selectionControls = this._selectionControls, [unitId, sheetId] = this._skeleton.getLocation();
|
|
1779
|
+
return selectionControls.map((control) => {
|
|
1780
|
+
const v = control.getValue();
|
|
1781
|
+
return v.rangeWithCoord.sheetId = sheetId, v.rangeWithCoord.unitId = unitId, v;
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
getSelectionControls() {
|
|
1785
|
+
return this._selectionControls;
|
|
1786
|
+
}
|
|
1787
|
+
_clearSelectionControls() {
|
|
1788
|
+
const allSelectionControls = this._selectionControls;
|
|
1789
|
+
for (const control of allSelectionControls)
|
|
1790
|
+
control.dispose();
|
|
1791
|
+
this._selectionControls.length = 0;
|
|
1792
|
+
}
|
|
1793
|
+
_getFreeze() {
|
|
1794
|
+
var _a61;
|
|
1795
|
+
return (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton.getWorksheetConfig().freeze;
|
|
1796
|
+
}
|
|
1797
|
+
_getViewportByCell(row, column) {
|
|
1798
|
+
if (row === void 0 || column === void 0)
|
|
1799
|
+
return null;
|
|
1800
|
+
const freeze = this._getFreeze();
|
|
1801
|
+
if (!freeze || freeze.startRow <= 0 && freeze.startColumn <= 0)
|
|
1802
|
+
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
1803
|
+
if (row > freeze.startRow && column > freeze.startColumn)
|
|
1804
|
+
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
1805
|
+
if (row <= freeze.startRow && column <= freeze.startColumn)
|
|
1806
|
+
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP);
|
|
1807
|
+
if (row <= freeze.startRow && column > freeze.startColumn)
|
|
1808
|
+
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP);
|
|
1809
|
+
if (row > freeze.startRow && column <= freeze.startColumn)
|
|
1810
|
+
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT);
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Returns the selected range in the active sheet, or null if there is no active range. If multiple ranges are selected this method returns only the last selected range.
|
|
1814
|
+
*/
|
|
1815
|
+
getActiveRange() {
|
|
1816
|
+
const controls = this.getSelectionControls(), model = controls && controls[controls.length - 1].model;
|
|
1817
|
+
return model && {
|
|
1818
|
+
startRow: model.startRow,
|
|
1819
|
+
startColumn: model.startColumn,
|
|
1820
|
+
endRow: model.endRow,
|
|
1821
|
+
endColumn: model.endColumn
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* get active selection control
|
|
1826
|
+
* @returns T extends SelectionControl
|
|
1827
|
+
*/
|
|
1828
|
+
getActiveSelectionControl() {
|
|
1829
|
+
const controls = this.getSelectionControls();
|
|
1830
|
+
if (controls)
|
|
1831
|
+
return controls[controls.length - 1];
|
|
1832
|
+
}
|
|
1833
|
+
endSelection() {
|
|
1834
|
+
var _a61;
|
|
1835
|
+
this._clearUpdatingListeners(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()), (_a61 = this._escapeShortcutDisposable) == null || _a61.dispose(), this._escapeShortcutDisposable = null;
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Clear existed selections.
|
|
1839
|
+
*/
|
|
1840
|
+
_reset() {
|
|
1841
|
+
var _a61;
|
|
1842
|
+
this._clearSelectionControls(), (_a61 = this._downObserver) == null || _a61.unsubscribe(), this._downObserver = null;
|
|
1843
|
+
}
|
|
1844
|
+
resetAndEndSelection() {
|
|
1845
|
+
this.endSelection(), this._reset();
|
|
1846
|
+
}
|
|
1847
|
+
// TODO: @wzhudev: refactor the method to make it more readable
|
|
1848
|
+
/**
|
|
1849
|
+
* Handle pointer down event, then trigger selectionMoveStart$.
|
|
1850
|
+
* @param evt
|
|
1851
|
+
* @param _zIndex
|
|
1852
|
+
* @param rangeType
|
|
1853
|
+
* @param viewport
|
|
1854
|
+
* @param scrollTimerType
|
|
1855
|
+
*/
|
|
1856
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1857
|
+
_onPointerDown(evt, _zIndex = 0, rangeType = RANGE_TYPE.NORMAL, viewport, scrollTimerType = ScrollTimerType.ALL) {
|
|
1858
|
+
var _a61;
|
|
1859
|
+
this._shouldDetectMergedCells = rangeType === RANGE_TYPE.NORMAL;
|
|
1860
|
+
const skeleton = this._skeleton, scene = this._scene;
|
|
1861
|
+
if (!scene || !skeleton)
|
|
1862
|
+
return;
|
|
1863
|
+
viewport && (this._activeViewport = viewport);
|
|
1864
|
+
const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
1865
|
+
if (!viewportMain) return;
|
|
1866
|
+
const relativeCoords = scene.getRelativeToViewportCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
1867
|
+
let { x: viewportPosX, y: viewportPosY } = relativeCoords;
|
|
1868
|
+
this._startViewportPosX = viewportPosX, this._startViewportPosY = viewportPosY;
|
|
1869
|
+
const scrollXY = scene.getVpScrollXYInfoByPosToVp(relativeCoords), { scaleX, scaleY } = scene.getAncestorScale(), cursorCellRangeInfo = this._getCellRangeByCursorPosition(viewportPosX, viewportPosY, scaleX, scaleY, scrollXY);
|
|
1870
|
+
if (!cursorCellRangeInfo) return;
|
|
1871
|
+
const { rangeWithCoord: cursorCellRange, primaryWithCoord: primaryCursorCellRange } = cursorCellRangeInfo, cursorCellRangeWithRangeType = { ...cursorCellRange, rangeType };
|
|
1872
|
+
this._startRangeWhenPointerDown = { ...cursorCellRange, rangeType };
|
|
1873
|
+
let activeSelectionControl = this.getActiveSelectionControl();
|
|
1874
|
+
const curControls = this.getSelectionControls();
|
|
1875
|
+
for (const control of curControls) {
|
|
1876
|
+
if (evt.button === 2 && control.model.isInclude(cursorCellRangeWithRangeType)) {
|
|
1877
|
+
activeSelectionControl = control;
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
if (control.model.isEqual(cursorCellRangeWithRangeType)) {
|
|
1881
|
+
activeSelectionControl = control;
|
|
1882
|
+
break;
|
|
1883
|
+
}
|
|
1884
|
+
evt.shiftKey || control.clearHighlight();
|
|
1885
|
+
}
|
|
1886
|
+
this._checkClearPreviousControls(evt);
|
|
1887
|
+
const currentCell = activeSelectionControl == null ? void 0 : activeSelectionControl.model.currentCell, expandByShiftKey = evt.shiftKey && currentCell, remainLastEnable = this._remainLastEnabled && !evt.ctrlKey && !evt.shiftKey && !this._skipLastEnabled && !this._singleSelectionEnabled;
|
|
1888
|
+
expandByShiftKey && currentCell ? this._performSelectionByTwoCells(
|
|
1889
|
+
currentCell,
|
|
1890
|
+
cursorCellRangeWithRangeType,
|
|
1891
|
+
skeleton,
|
|
1892
|
+
rangeType,
|
|
1893
|
+
activeSelectionControl
|
|
1894
|
+
// Get updated in this method
|
|
1895
|
+
) : remainLastEnable && activeSelectionControl ? this._updateSelectionControlByRange(
|
|
1896
|
+
activeSelectionControl,
|
|
1897
|
+
cursorCellRangeWithRangeType,
|
|
1898
|
+
primaryCursorCellRange
|
|
1899
|
+
) : (activeSelectionControl = this.newSelectionControl(scene, rangeType, skeleton), this._updateSelectionControlByRange(
|
|
1900
|
+
activeSelectionControl,
|
|
1901
|
+
cursorCellRangeWithRangeType,
|
|
1902
|
+
primaryCursorCellRange
|
|
1903
|
+
)), this._selectionMoveStart$.next(this.getSelectionDataWithStyle()), scene.disableObjectsEvent(), this._clearUpdatingListeners(), this._addEndingListeners(), (_a61 = scene.getTransformer()) == null || _a61.clearSelectedObjects(), (rangeType === RANGE_TYPE.ROW || rangeType === RANGE_TYPE.COLUMN) && (rangeType === RANGE_TYPE.ROW ? viewportPosX = 0 : rangeType === RANGE_TYPE.COLUMN && (viewportPosY = 0), this._movingHandler(viewportPosX, viewportPosY, activeSelectionControl, rangeType)), this._setupPointerMoveListener(viewportMain, activeSelectionControl, rangeType, scrollTimerType, viewportPosX, viewportPosY), this._escapeShortcutDisposable = this._shortcutService.forceEscape(), this._scenePointerUpSub = scene.onPointerUp$.subscribeEvent(() => {
|
|
1904
|
+
var _a62;
|
|
1905
|
+
this._clearUpdatingListeners(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()), (_a62 = this._escapeShortcutDisposable) == null || _a62.dispose(), this._escapeShortcutDisposable = null;
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Init pointer move listener in each pointer down, unbind in each pointer up.
|
|
1910
|
+
* Both cell selections and row-column selections are supported by this method.
|
|
1911
|
+
* @param viewportMain
|
|
1912
|
+
* @param activeSelectionControl
|
|
1913
|
+
* @param rangeType
|
|
1914
|
+
* @param scrollTimerType
|
|
1915
|
+
* @param moveStartPosX
|
|
1916
|
+
* @param moveStartPosY
|
|
1917
|
+
*/
|
|
1918
|
+
// eslint-disable-next-line max-lines-per-function
|
|
1919
|
+
_setupPointerMoveListener(viewportMain, activeSelectionControl, rangeType, scrollTimerType = ScrollTimerType.ALL, moveStartPosX, moveStartPosY) {
|
|
1920
|
+
var _a61, _b;
|
|
1921
|
+
let xCrossTime = 0, yCrossTime = 0, lastX = moveStartPosX, lastY = moveStartPosY;
|
|
1922
|
+
this._scrollTimer = ScrollTimer.create(this._scene, scrollTimerType), this._scrollTimer.startScroll((_a61 = viewportMain == null ? void 0 : viewportMain.left) != null ? _a61 : 0, (_b = viewportMain == null ? void 0 : viewportMain.top) != null ? _b : 0, viewportMain);
|
|
1923
|
+
const scene = this._scene, startViewport = scene.getActiveViewportByCoord(Vector2.FromArray([moveStartPosX, moveStartPosY]));
|
|
1924
|
+
this._scenePointerMoveSub = scene.onPointerMove$.subscribeEvent((moveEvt) => {
|
|
1925
|
+
var _a62, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
1926
|
+
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt, { x: newMoveOffsetX, y: newMoveOffsetY } = scene.getRelativeToViewportCoord(Vector2.FromArray([moveOffsetX, moveOffsetY]));
|
|
1927
|
+
this._movingHandler(newMoveOffsetX, newMoveOffsetY, activeSelectionControl, rangeType);
|
|
1928
|
+
let scrollOffsetX = newMoveOffsetX, scrollOffsetY = newMoveOffsetY;
|
|
1929
|
+
const currentSelection = this.getActiveSelectionControl(), freeze = this._getFreeze(), selection = currentSelection == null ? void 0 : currentSelection.model, endViewport = (_a62 = scene.getActiveViewportByCoord(Vector2.FromArray([moveOffsetX, moveOffsetY]))) != null ? _a62 : this._getViewportByCell(selection == null ? void 0 : selection.endRow, selection == null ? void 0 : selection.endColumn);
|
|
1930
|
+
if ((/* @__PURE__ */ __name(() => {
|
|
1931
|
+
if (!startViewport || !endViewport || !viewportMain)
|
|
1932
|
+
return !1;
|
|
1933
|
+
const crossableViewports = [
|
|
1934
|
+
SHEET_VIEWPORT_KEY$1.VIEW_MAIN,
|
|
1935
|
+
SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP,
|
|
1936
|
+
SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP,
|
|
1937
|
+
SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT
|
|
1938
|
+
];
|
|
1939
|
+
return crossableViewports.includes(startViewport.viewportKey) && crossableViewports.includes(endViewport.viewportKey);
|
|
1940
|
+
}, "isCrossableViewports"))()) {
|
|
1941
|
+
if (!startViewport || !endViewport || !viewportMain)
|
|
1942
|
+
return !1;
|
|
1943
|
+
const isCrossingX = lastX < viewportMain.left && newMoveOffsetX > viewportMain.left || lastX > viewportMain.left && newMoveOffsetX < viewportMain.left, isCrossingY = lastY < viewportMain.top && newMoveOffsetY > viewportMain.top || lastY > viewportMain.top && newMoveOffsetY < viewportMain.top;
|
|
1944
|
+
isCrossingX && (xCrossTime += 1), isCrossingY && (yCrossTime += 1);
|
|
1945
|
+
const startKey = startViewport.viewportKey, endKey = endViewport.viewportKey;
|
|
1946
|
+
if (startKey === SHEET_VIEWPORT_KEY$1.VIEW_ROW_TOP)
|
|
1947
|
+
moveOffsetY < viewportMain.top && ((_b2 = selection == null ? void 0 : selection.endRow) != null ? _b2 : 0) < ((_c = freeze == null ? void 0 : freeze.startRow) != null ? _c : 0) ? scrollOffsetY = viewportMain.top : isCrossingY && yCrossTime % 2 === 1 && viewportMain.scrollToViewportPos({
|
|
1948
|
+
viewportScrollY: 0
|
|
1949
|
+
});
|
|
1950
|
+
else if (startKey === SHEET_VIEWPORT_KEY$1.VIEW_COLUMN_LEFT)
|
|
1951
|
+
moveOffsetX < viewportMain.left && ((_d = selection == null ? void 0 : selection.endColumn) != null ? _d : 0) < ((_e = freeze == null ? void 0 : freeze.startColumn) != null ? _e : 0) ? scrollOffsetX = viewportMain.left : isCrossingX && xCrossTime % 2 === 1 && viewportMain.scrollToViewportPos({
|
|
1952
|
+
viewportScrollX: 0
|
|
1953
|
+
});
|
|
1954
|
+
else if (startKey === endKey) {
|
|
1955
|
+
let disableX = !1, disableY = !1;
|
|
1956
|
+
startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP ? (disableX = !0, disableY = !0) : startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP ? disableY = !0 : startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT && (disableX = !0), ((_f = selection == null ? void 0 : selection.endRow) != null ? _f : 0) > ((_g = freeze == null ? void 0 : freeze.startRow) != null ? _g : 0) && (disableY = !1), ((_h = selection == null ? void 0 : selection.endColumn) != null ? _h : 0) > ((_i = freeze == null ? void 0 : freeze.startColumn) != null ? _i : 0) && (disableX = !1), disableX && (scrollOffsetX = viewportMain.left), disableY && (scrollOffsetY = viewportMain.top);
|
|
1957
|
+
} else {
|
|
1958
|
+
const startXY = {
|
|
1959
|
+
x: startViewport.scrollX,
|
|
1960
|
+
y: startViewport.scrollY
|
|
1961
|
+
}, endXY = {
|
|
1962
|
+
x: endViewport.scrollX,
|
|
1963
|
+
y: endViewport.scrollY
|
|
1964
|
+
}, shouldResetX = startXY.x !== endXY.x && isCrossingX && xCrossTime % 2 === 1, shouldResetY = startXY.y !== endXY.y && isCrossingY && yCrossTime % 2 === 1;
|
|
1965
|
+
(shouldResetX || shouldResetY) && (viewportMain.scrollToBarPos({
|
|
1966
|
+
x: shouldResetX ? startXY.x : void 0,
|
|
1967
|
+
y: shouldResetY ? startXY.y : void 0
|
|
1968
|
+
}), shouldResetX || (scrollOffsetX = viewportMain.left), shouldResetY || (scrollOffsetY = viewportMain.top)), (startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT || endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT) && (scrollOffsetX = viewportMain.left), (startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP || endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP) && (scrollOffsetY = viewportMain.top);
|
|
1969
|
+
}
|
|
1970
|
+
lastX = newMoveOffsetX, lastY = newMoveOffsetY;
|
|
1971
|
+
}
|
|
1972
|
+
this._scrollTimer.scrolling(scrollOffsetX, scrollOffsetY, () => {
|
|
1973
|
+
this._movingHandler(newMoveOffsetX, newMoveOffsetY, activeSelectionControl, rangeType);
|
|
1974
|
+
});
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
/** @deprecated Use the function `attachSelectionWithCoord` instead`. */
|
|
1978
|
+
attachSelectionWithCoord(selectionWithStyle) {
|
|
1979
|
+
return attachSelectionWithCoord(selectionWithStyle, this._skeleton);
|
|
1980
|
+
}
|
|
1981
|
+
/** @deprecated Use the function `attachPrimaryWithCoord` instead`. */
|
|
1982
|
+
attachPrimaryWithCoord(primary) {
|
|
1983
|
+
return attachPrimaryWithCoord(primary, this._skeleton);
|
|
1984
|
+
}
|
|
1985
|
+
getSelectionCellByPosition(x, y) {
|
|
1986
|
+
const scene = this._scene, skeleton = this._skeleton, scrollXY = scene.getViewportScrollXY(scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN)), { scaleX, scaleY } = scene.getAncestorScale();
|
|
1987
|
+
return skeleton.calculateCellIndexByPosition(
|
|
1988
|
+
x,
|
|
1989
|
+
y,
|
|
1990
|
+
scaleX,
|
|
1991
|
+
scaleY,
|
|
1992
|
+
scrollXY
|
|
1993
|
+
);
|
|
1994
|
+
}
|
|
1995
|
+
/**
|
|
1996
|
+
* When mousedown and mouseup need to go to the coordination and undo stack, when mousemove does not need to go to the coordination and undo stack
|
|
1997
|
+
*/
|
|
1998
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1999
|
+
_movingHandler(offsetX, offsetY, activeSelectionControl, rangeType) {
|
|
2000
|
+
var _a61, _b, _c, _d, _e;
|
|
2001
|
+
const skeleton = this._skeleton, scene = this._scene, [unitId, sheetId] = skeleton.getLocation(), currSelectionRange = {
|
|
2002
|
+
startRow: (_a61 = activeSelectionControl == null ? void 0 : activeSelectionControl.model.startRow) != null ? _a61 : -1,
|
|
2003
|
+
endRow: (_b = activeSelectionControl == null ? void 0 : activeSelectionControl.model.endRow) != null ? _b : -1,
|
|
2004
|
+
startColumn: (_c = activeSelectionControl == null ? void 0 : activeSelectionControl.model.startColumn) != null ? _c : -1,
|
|
2005
|
+
endColumn: (_d = activeSelectionControl == null ? void 0 : activeSelectionControl.model.endColumn) != null ? _d : -1,
|
|
2006
|
+
unitId,
|
|
2007
|
+
sheetId
|
|
2008
|
+
}, viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN), targetViewport = (_e = this._getViewportByCell(currSelectionRange.endRow, currSelectionRange.endColumn)) != null ? _e : viewportMain, scrollXY = scene.getVpScrollXYInfoByPosToVp(
|
|
2009
|
+
Vector2.FromArray([this._startViewportPosX, this._startViewportPosY]),
|
|
2010
|
+
targetViewport
|
|
2011
|
+
), { scaleX, scaleY } = scene.getAncestorScale();
|
|
2012
|
+
rangeType === RANGE_TYPE.ROW ? offsetX = Number.POSITIVE_INFINITY : rangeType === RANGE_TYPE.COLUMN && (offsetY = Number.POSITIVE_INFINITY);
|
|
2013
|
+
const cursorCellRangeInfo = this._getCellRangeByCursorPosition(offsetX, offsetY, scaleX, scaleY, scrollXY);
|
|
2014
|
+
if (!cursorCellRangeInfo)
|
|
2015
|
+
return;
|
|
2016
|
+
const { rangeWithCoord: cursorCellRange } = cursorCellRangeInfo, activeCellRange = this._startRangeWhenPointerDown;
|
|
2017
|
+
let newSelectionRange = {
|
|
2018
|
+
startRow: Math.min(cursorCellRange.startRow, activeCellRange.startRow),
|
|
2019
|
+
startColumn: Math.min(cursorCellRange.startColumn, activeCellRange.startColumn),
|
|
2020
|
+
endRow: Math.max(cursorCellRange.endRow, activeCellRange.endRow),
|
|
2021
|
+
endColumn: Math.max(cursorCellRange.endColumn, activeCellRange.endColumn)
|
|
2022
|
+
};
|
|
2023
|
+
if (this._shouldDetectMergedCells && (newSelectionRange = skeleton.getSelectionMergeBounding(newSelectionRange.startRow, newSelectionRange.startColumn, newSelectionRange.endRow, newSelectionRange.endColumn)), !newSelectionRange)
|
|
2024
|
+
return;
|
|
2025
|
+
const startCellXY = skeleton.getNoMergeCellPositionByIndex(newSelectionRange.startRow, newSelectionRange.startColumn), endCellXY = skeleton.getNoMergeCellPositionByIndex(newSelectionRange.endRow, newSelectionRange.endColumn), newSelectionRangeWithCoord = {
|
|
2026
|
+
startRow: newSelectionRange.startRow,
|
|
2027
|
+
startColumn: newSelectionRange.startColumn,
|
|
2028
|
+
endRow: newSelectionRange.endRow,
|
|
2029
|
+
endColumn: newSelectionRange.endColumn,
|
|
2030
|
+
unitId,
|
|
2031
|
+
sheetId,
|
|
2032
|
+
startY: (startCellXY == null ? void 0 : startCellXY.startY) || 0,
|
|
2033
|
+
endY: (endCellXY == null ? void 0 : endCellXY.endY) || 0,
|
|
2034
|
+
startX: (startCellXY == null ? void 0 : startCellXY.startX) || 0,
|
|
2035
|
+
endX: (endCellXY == null ? void 0 : endCellXY.endX) || 0
|
|
2036
|
+
}, rangeChanged = currSelectionRange.startRow !== newSelectionRange.startRow || currSelectionRange.startColumn !== newSelectionRange.startColumn || currSelectionRange.endRow !== newSelectionRange.endRow || currSelectionRange.endColumn !== newSelectionRange.endColumn;
|
|
2037
|
+
activeSelectionControl != null && rangeChanged && (this._updateSelectionControlByRange(activeSelectionControl, newSelectionRangeWithCoord), this._selectionMoving$.next(this.getSelectionDataWithStyle()));
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Update the selection control by range.
|
|
2041
|
+
* @param control
|
|
2042
|
+
* @param newSelectionRange
|
|
2043
|
+
* @param highlight
|
|
2044
|
+
*/
|
|
2045
|
+
_updateSelectionControlByRange(control, newSelectionRange, highlight) {
|
|
2046
|
+
control.updateRange(newSelectionRange, highlight);
|
|
2047
|
+
}
|
|
2048
|
+
_clearUpdatingListeners() {
|
|
2049
|
+
var _a61, _b, _c, _d, _e;
|
|
2050
|
+
this._scene.enableObjectsEvent(), (_a61 = this._scenePointerMoveSub) == null || _a61.unsubscribe(), this._scenePointerMoveSub = null, (_b = this._scenePointerUpSub) == null || _b.unsubscribe(), this._scenePointerUpSub = null, (_c = this._cancelDownSubscription) == null || _c.unsubscribe(), this._cancelDownSubscription = null, (_d = this._cancelUpSubscription) == null || _d.unsubscribe(), this._cancelUpSubscription = null, (_e = this._scrollTimer) == null || _e.dispose();
|
|
2051
|
+
}
|
|
2052
|
+
_addEndingListeners() {
|
|
2053
|
+
var _a61, _b, _c;
|
|
2054
|
+
const scene = this._scene, mainScene = (_a61 = scene.getEngine()) == null ? void 0 : _a61.activeScene;
|
|
2055
|
+
!mainScene || mainScene === scene || ((_b = this._cancelDownSubscription) == null || _b.unsubscribe(), this._cancelDownSubscription = null, (_c = this._cancelUpSubscription) == null || _c.unsubscribe(), this._cancelUpSubscription = null, this._cancelDownSubscription = mainScene.onPointerDown$.subscribeEvent(() => this._clearUpdatingListeners()), this._cancelUpSubscription = mainScene.onPointerUp$.subscribeEvent(() => this._clearUpdatingListeners()));
|
|
2056
|
+
}
|
|
2057
|
+
_getCellRangeByCursorPosition(offsetX, offsetY, scaleX, scaleY, scrollXY) {
|
|
2058
|
+
var _a61;
|
|
2059
|
+
if (this._shouldDetectMergedCells) {
|
|
2060
|
+
const primaryWithCoord2 = (_a61 = this._skeleton) == null ? void 0 : _a61.calculateCellIndexByPosition(
|
|
2061
|
+
offsetX,
|
|
2062
|
+
offsetY,
|
|
2063
|
+
scaleX,
|
|
2064
|
+
scaleY,
|
|
2065
|
+
scrollXY
|
|
2066
|
+
);
|
|
2067
|
+
if (!primaryWithCoord2) return;
|
|
2068
|
+
const rangeWithCoord2 = makeCellToSelection(primaryWithCoord2);
|
|
2069
|
+
return {
|
|
2070
|
+
primaryWithCoord: primaryWithCoord2,
|
|
2071
|
+
rangeWithCoord: rangeWithCoord2
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
const skeleton = this._skeleton;
|
|
2075
|
+
if (skeleton == null)
|
|
2076
|
+
return;
|
|
2077
|
+
const moveActualSelection = skeleton.getCellPositionByOffset(offsetX, offsetY, scaleX, scaleY, scrollXY), { row, column } = moveActualSelection, startCell = skeleton.getNoMergeCellPositionByIndex(row, column), { startX, startY, endX, endY } = startCell, rangeWithCoord = {
|
|
2078
|
+
startY,
|
|
2079
|
+
endY,
|
|
2080
|
+
startX,
|
|
2081
|
+
endX,
|
|
2082
|
+
startRow: row,
|
|
2083
|
+
endRow: row,
|
|
2084
|
+
startColumn: column,
|
|
2085
|
+
endColumn: column
|
|
2086
|
+
};
|
|
2087
|
+
return {
|
|
2088
|
+
primaryWithCoord: {
|
|
2089
|
+
actualRow: row,
|
|
2090
|
+
actualColumn: column,
|
|
2091
|
+
isMerged: !1,
|
|
2092
|
+
isMergedMainCell: !1,
|
|
2093
|
+
startY,
|
|
2094
|
+
endY,
|
|
2095
|
+
startX,
|
|
2096
|
+
endX,
|
|
2097
|
+
mergeInfo: rangeWithCoord
|
|
2098
|
+
},
|
|
2099
|
+
rangeWithCoord
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
_checkClearPreviousControls(evt) {
|
|
2103
|
+
this.getSelectionControls().length !== 0 && (!evt.ctrlKey && !evt.shiftKey && !this._remainLastEnabled || this._singleSelectionEnabled && !evt.shiftKey) && this._clearSelectionControls();
|
|
2104
|
+
}
|
|
2105
|
+
_performSelectionByTwoCells(currentCell, startSelectionRange, skeleton, rangeType, activeControl) {
|
|
2106
|
+
const { actualRow, actualColumn, mergeInfo: actualMergeInfo } = currentCell, newStartRow = Math.min(actualRow, startSelectionRange.startRow, actualMergeInfo.startRow), newEndRow = Math.max(actualRow, startSelectionRange.endRow, actualMergeInfo.endRow), newStartColumn = Math.min(actualColumn, startSelectionRange.startColumn, actualMergeInfo.startColumn), newEndColumn = Math.max(actualColumn, startSelectionRange.endColumn, actualMergeInfo.endColumn), bounding = skeleton.getMergeBounding(newStartRow, newStartColumn, newEndRow, newEndColumn), startCell = skeleton.getNoMergeCellPositionByIndex(bounding.startRow, bounding.startColumn), endCell = skeleton.getNoMergeCellPositionByIndex(bounding.endRow, bounding.endColumn), newSelectionRange = {
|
|
2107
|
+
startColumn: bounding.startColumn,
|
|
2108
|
+
startRow: bounding.startRow,
|
|
2109
|
+
endColumn: bounding.endColumn,
|
|
2110
|
+
endRow: bounding.endRow,
|
|
2111
|
+
startY: startCell.startY,
|
|
2112
|
+
endY: endCell.endY,
|
|
2113
|
+
startX: startCell.startX,
|
|
2114
|
+
endX: endCell.endX,
|
|
2115
|
+
rangeType
|
|
2116
|
+
}, activeCell = skeleton.getCellByIndex(actualRow, actualColumn);
|
|
2117
|
+
this._startRangeWhenPointerDown = {
|
|
2118
|
+
startColumn: activeCell.mergeInfo.startColumn,
|
|
2119
|
+
startRow: activeCell.mergeInfo.startRow,
|
|
2120
|
+
endColumn: activeCell.mergeInfo.endColumn,
|
|
2121
|
+
endRow: activeCell.mergeInfo.endRow,
|
|
2122
|
+
startY: activeCell.mergeInfo.startY || 0,
|
|
2123
|
+
endY: activeCell.mergeInfo.endY || 0,
|
|
2124
|
+
startX: activeCell.mergeInfo.startX || 0,
|
|
2125
|
+
endX: activeCell.mergeInfo.endX || 0,
|
|
2126
|
+
rangeType
|
|
2127
|
+
}, this._updateSelectionControlByRange(activeControl, newSelectionRange, currentCell);
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Reset all this.selectionControls by selectionsData.
|
|
2131
|
+
* @param selectionsData
|
|
2132
|
+
*/
|
|
2133
|
+
_refreshSelectionControl(selectionsData) {
|
|
2134
|
+
const selections = selectionsData.map((selectionWithStyle) => {
|
|
2135
|
+
const selectionData = attachSelectionWithCoord(selectionWithStyle, this._skeleton);
|
|
2136
|
+
return selectionData.style = getNormalSelectionStyle(this._themeService), selectionData;
|
|
2137
|
+
});
|
|
2138
|
+
this.updateControlForCurrentByRangeData(selections);
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
__name(_BaseSelectionRenderService, "BaseSelectionRenderService");
|
|
2142
|
+
let BaseSelectionRenderService = _BaseSelectionRenderService;
|
|
2143
|
+
function getAllSelection(skeleton) {
|
|
2144
|
+
return {
|
|
2145
|
+
range: {
|
|
2146
|
+
startRow: 0,
|
|
2147
|
+
startColumn: 0,
|
|
2148
|
+
endRow: skeleton.getRowCount() - 1,
|
|
2149
|
+
endColumn: skeleton.getColumnCount() - 1,
|
|
2150
|
+
rangeType: RANGE_TYPE.ALL
|
|
2151
|
+
},
|
|
2152
|
+
primary: getTopLeftSelection(skeleton).primary,
|
|
2153
|
+
style: null
|
|
2154
|
+
};
|
|
2155
|
+
}
|
|
2156
|
+
__name(getAllSelection, "getAllSelection");
|
|
2157
|
+
function getTopLeftSelection(skeleton) {
|
|
2158
|
+
const mergeData = skeleton.mergeData;
|
|
2159
|
+
return transformCellDataToSelectionData(0, 0, mergeData) || {
|
|
2160
|
+
range: {
|
|
2161
|
+
startRow: 0,
|
|
2162
|
+
startColumn: 0,
|
|
2163
|
+
endRow: 0,
|
|
2164
|
+
endColumn: 0
|
|
2165
|
+
},
|
|
2166
|
+
primary: {
|
|
2167
|
+
actualRow: 0,
|
|
2168
|
+
actualColumn: 0,
|
|
2169
|
+
startRow: 0,
|
|
2170
|
+
startColumn: 0,
|
|
2171
|
+
endRow: 0,
|
|
2172
|
+
endColumn: 0,
|
|
2173
|
+
isMerged: !1,
|
|
2174
|
+
isMergedMainCell: !1
|
|
2175
|
+
},
|
|
2176
|
+
style: null
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
__name(getTopLeftSelection, "getTopLeftSelection");
|
|
2180
|
+
var __defProp$T = Object.defineProperty, __getOwnPropDesc$T = Object.getOwnPropertyDescriptor, __decorateClass$T = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2181
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$T(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2182
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2183
|
+
return kind && result && __defProp$T(target, key, result), result;
|
|
2184
|
+
}, "__decorateClass$T"), __decorateParam$T = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$T"), _a3;
|
|
2185
|
+
let ShortcutExperienceService = (_a3 = class {
|
|
2186
|
+
constructor(_univerInstanceService, _localeService) {
|
|
2187
|
+
__publicField(this, "_current", null);
|
|
2188
|
+
__publicField(this, "_shortcutParam", []);
|
|
2189
|
+
this._univerInstanceService = _univerInstanceService, this._localeService = _localeService;
|
|
2190
|
+
}
|
|
2191
|
+
dispose() {
|
|
2192
|
+
this._shortcutParam = [];
|
|
2193
|
+
}
|
|
2194
|
+
getCurrentBySearch(searchParm) {
|
|
2195
|
+
return this._getCurrentBySearch(searchParm);
|
|
2196
|
+
}
|
|
2197
|
+
getCurrent() {
|
|
2198
|
+
return this._getCurrentBySearch(this._current);
|
|
2199
|
+
}
|
|
2200
|
+
addOrUpdate(insertParam) {
|
|
2201
|
+
const param = this._getCurrentBySearch({
|
|
2202
|
+
unitId: insertParam.unitId,
|
|
2203
|
+
sheetId: insertParam.sheetId,
|
|
2204
|
+
keycode: insertParam.keycode
|
|
2205
|
+
});
|
|
2206
|
+
if (param != null) {
|
|
2207
|
+
const index = this._shortcutParam.indexOf(param);
|
|
2208
|
+
this._shortcutParam.splice(index, 1);
|
|
2209
|
+
}
|
|
2210
|
+
return this._shortcutParam.push(insertParam), param;
|
|
2211
|
+
}
|
|
2212
|
+
remove(searchParm) {
|
|
2213
|
+
if (searchParm == null)
|
|
2214
|
+
return;
|
|
2215
|
+
const param = this._getCurrentBySearch(searchParm);
|
|
2216
|
+
if (param == null)
|
|
2217
|
+
return;
|
|
2218
|
+
const index = this._shortcutParam.indexOf(param);
|
|
2219
|
+
return this._shortcutParam.splice(index, 1)[0];
|
|
2220
|
+
}
|
|
2221
|
+
_getCurrentBySearch(searchParm) {
|
|
2222
|
+
return searchParm == null ? void 0 : this._shortcutParam.find(
|
|
2223
|
+
(param) => param.unitId === searchParm.unitId && param.sheetId === searchParm.sheetId && param.keycode === searchParm.keycode
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
}, __name(_a3, "ShortcutExperienceService"), _a3);
|
|
2227
|
+
ShortcutExperienceService = __decorateClass$T([
|
|
2228
|
+
__decorateParam$T(0, IUniverInstanceService),
|
|
2229
|
+
__decorateParam$T(1, Inject(LocaleService))
|
|
2230
|
+
], ShortcutExperienceService);
|
|
2231
|
+
var MergeType = /* @__PURE__ */ ((MergeType2) => (MergeType2.MergeAll = "mergeAll", MergeType2.MergeVertical = "mergeVertical", MergeType2.MergeHorizontal = "mergeHorizontal", MergeType2))(MergeType || {});
|
|
2232
|
+
function findNextRange(startRange, direction, worksheet, boundary, isFindNext = !0, nextStep = 1, isGoBack = !0) {
|
|
2233
|
+
let destRange = { ...startRange };
|
|
2234
|
+
boundary == null && (boundary = {
|
|
2235
|
+
startRow: 0,
|
|
2236
|
+
endRow: worksheet.getRowCount() - 1,
|
|
2237
|
+
startColumn: 0,
|
|
2238
|
+
endColumn: worksheet.getColumnCount() - 1
|
|
2239
|
+
});
|
|
2240
|
+
let next;
|
|
2241
|
+
switch (direction) {
|
|
2242
|
+
case Direction.UP:
|
|
2243
|
+
for (next = startRange.startRow - nextStep; next > -1 && !worksheet.getRowVisible(next); )
|
|
2244
|
+
next -= 1;
|
|
2245
|
+
next >= boundary.startRow ? (destRange.startRow = next, destRange.endRow = next) : isGoBack && (destRange.startRow = boundary.endRow, destRange.endRow = boundary.endRow, isFindNext && (destRange = findNextRange(destRange, Direction.LEFT, worksheet, boundary, !1)));
|
|
2246
|
+
break;
|
|
2247
|
+
case Direction.DOWN:
|
|
2248
|
+
for (next = startRange.endRow + nextStep; next < worksheet.getRowCount() && !worksheet.getRowVisible(next); )
|
|
2249
|
+
next += 1;
|
|
2250
|
+
next <= boundary.endRow ? (destRange.startRow = next, destRange.endRow = next) : isGoBack && (destRange.startRow = boundary.startRow, destRange.endRow = boundary.startRow, isFindNext && (destRange = findNextRange(destRange, Direction.RIGHT, worksheet, boundary, !1)));
|
|
2251
|
+
break;
|
|
2252
|
+
case Direction.LEFT:
|
|
2253
|
+
for (next = startRange.startColumn - nextStep; next > -1 && !worksheet.getColVisible(next); )
|
|
2254
|
+
next -= 1;
|
|
2255
|
+
next >= boundary.startColumn ? (destRange.startColumn = next, destRange.endColumn = next) : isGoBack && (destRange.startColumn = boundary.endColumn, destRange.endColumn = boundary.endColumn, isFindNext && (destRange = findNextRange(destRange, Direction.UP, worksheet, boundary, !1)));
|
|
2256
|
+
break;
|
|
2257
|
+
case Direction.RIGHT:
|
|
2258
|
+
for (next = startRange.endColumn + nextStep; next < worksheet.getColumnCount() && !worksheet.getColVisible(next); )
|
|
2259
|
+
next += 1;
|
|
2260
|
+
next <= boundary.endColumn ? (destRange.startColumn = next, destRange.endColumn = next) : isGoBack && (destRange.startColumn = boundary.startColumn, destRange.endColumn = boundary.startColumn, isFindNext && (destRange = findNextRange(destRange, Direction.DOWN, worksheet, boundary, !1)));
|
|
2261
|
+
break;
|
|
2262
|
+
}
|
|
2263
|
+
return destRange;
|
|
2264
|
+
}
|
|
2265
|
+
__name(findNextRange, "findNextRange");
|
|
2266
|
+
function findNextGapRange(startRange, direction, worksheet) {
|
|
2267
|
+
const destRange = { ...startRange }, { startRow, startColumn, endRow, endColumn } = getEdgeOfRange(startRange, direction, worksheet);
|
|
2268
|
+
let currentPositionHasValue = rangeHasValue(worksheet, startRow, startColumn, endRow, endColumn).hasValue, firstMove = !0, shouldContinue = !0;
|
|
2269
|
+
for (; shouldContinue; ) {
|
|
2270
|
+
if (Direction.UP === direction) {
|
|
2271
|
+
let next = destRange.startRow - 1;
|
|
2272
|
+
for (; next > -1 && !worksheet.getRowVisible(next); )
|
|
2273
|
+
next -= 1;
|
|
2274
|
+
if (next === -1) {
|
|
2275
|
+
shouldContinue = !1;
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
2279
|
+
worksheet,
|
|
2280
|
+
next,
|
|
2281
|
+
destRange.startColumn,
|
|
2282
|
+
next,
|
|
2283
|
+
destRange.endColumn
|
|
2284
|
+
);
|
|
2285
|
+
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
2286
|
+
shouldContinue = !1;
|
|
2287
|
+
break;
|
|
2288
|
+
} else {
|
|
2289
|
+
if (matrix.getLength() !== 0) {
|
|
2290
|
+
let min = next;
|
|
2291
|
+
matrix.forValue((row) => {
|
|
2292
|
+
min = Math.min(row, min);
|
|
2293
|
+
}), destRange.startRow = min;
|
|
2294
|
+
} else
|
|
2295
|
+
destRange.startRow = next;
|
|
2296
|
+
if (destRange.endRow = destRange.startRow, !currentPositionHasValue && nextRangeHasValue) {
|
|
2297
|
+
shouldContinue = !1;
|
|
2298
|
+
break;
|
|
2299
|
+
}
|
|
2300
|
+
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
if (Direction.DOWN === direction) {
|
|
2304
|
+
let next = destRange.endRow + 1;
|
|
2305
|
+
for (; next < worksheet.getRowCount() && !worksheet.getRowVisible(next); )
|
|
2306
|
+
next += 1;
|
|
2307
|
+
if (next === worksheet.getRowCount()) {
|
|
2308
|
+
shouldContinue = !1;
|
|
2309
|
+
break;
|
|
2310
|
+
}
|
|
2311
|
+
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
2312
|
+
worksheet,
|
|
2313
|
+
next,
|
|
2314
|
+
destRange.startColumn,
|
|
2315
|
+
next,
|
|
2316
|
+
destRange.endColumn
|
|
2317
|
+
);
|
|
2318
|
+
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
2319
|
+
shouldContinue = !1;
|
|
2320
|
+
break;
|
|
2321
|
+
} else {
|
|
2322
|
+
if (matrix.getLength() !== 0) {
|
|
2323
|
+
let max = next;
|
|
2324
|
+
matrix.forValue((row, _, value) => {
|
|
2325
|
+
max = Math.max(row + (value.rowSpan || 1) - 1, max);
|
|
2326
|
+
}), destRange.endRow = max;
|
|
2327
|
+
} else
|
|
2328
|
+
destRange.endRow = next;
|
|
2329
|
+
if (destRange.startRow = destRange.endRow, !currentPositionHasValue && nextRangeHasValue) {
|
|
2330
|
+
shouldContinue = !1;
|
|
2331
|
+
break;
|
|
2332
|
+
}
|
|
2333
|
+
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
if (Direction.LEFT === direction) {
|
|
2337
|
+
let next = destRange.startColumn - 1;
|
|
2338
|
+
for (; next > -1 && !worksheet.getColVisible(next); )
|
|
2339
|
+
next -= 1;
|
|
2340
|
+
if (next === -1) {
|
|
2341
|
+
shouldContinue = !1;
|
|
2342
|
+
break;
|
|
2343
|
+
}
|
|
2344
|
+
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
2345
|
+
worksheet,
|
|
2346
|
+
destRange.startRow,
|
|
2347
|
+
next,
|
|
2348
|
+
destRange.endRow,
|
|
2349
|
+
next
|
|
2350
|
+
);
|
|
2351
|
+
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
2352
|
+
shouldContinue = !1;
|
|
2353
|
+
break;
|
|
2354
|
+
} else {
|
|
2355
|
+
if (matrix.getLength() !== 0) {
|
|
2356
|
+
let min = next;
|
|
2357
|
+
matrix.forValue((_, col) => {
|
|
2358
|
+
min = Math.min(col, min);
|
|
2359
|
+
}), destRange.startColumn = min;
|
|
2360
|
+
} else
|
|
2361
|
+
destRange.startColumn = next;
|
|
2362
|
+
if (destRange.endColumn = destRange.startColumn, !currentPositionHasValue && nextRangeHasValue) {
|
|
2363
|
+
shouldContinue = !1;
|
|
2364
|
+
break;
|
|
2365
|
+
}
|
|
2366
|
+
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
if (Direction.RIGHT === direction) {
|
|
2370
|
+
let next = destRange.endColumn + 1;
|
|
2371
|
+
for (; next < worksheet.getColumnCount() && !worksheet.getColVisible(next); )
|
|
2372
|
+
next += 1;
|
|
2373
|
+
if (next === worksheet.getColumnCount()) {
|
|
2374
|
+
shouldContinue = !1;
|
|
2375
|
+
break;
|
|
2376
|
+
}
|
|
2377
|
+
const { hasValue: nextRangeHasValue, matrix } = rangeHasValue(
|
|
2378
|
+
worksheet,
|
|
2379
|
+
destRange.startRow,
|
|
2380
|
+
next,
|
|
2381
|
+
destRange.endRow,
|
|
2382
|
+
next
|
|
2383
|
+
);
|
|
2384
|
+
if (currentPositionHasValue && !nextRangeHasValue && !firstMove) {
|
|
2385
|
+
shouldContinue = !1;
|
|
2386
|
+
break;
|
|
2387
|
+
} else {
|
|
2388
|
+
if (matrix.getLength() !== 0) {
|
|
2389
|
+
let max = next;
|
|
2390
|
+
matrix.forValue((_, col, value) => {
|
|
2391
|
+
max = Math.max(col + (value.colSpan || 1) - 1, max);
|
|
2392
|
+
}), destRange.endColumn = max;
|
|
2393
|
+
} else
|
|
2394
|
+
destRange.endColumn = next;
|
|
2395
|
+
if (destRange.startColumn = destRange.endColumn, !currentPositionHasValue && nextRangeHasValue) {
|
|
2396
|
+
shouldContinue = !1;
|
|
2397
|
+
break;
|
|
2398
|
+
}
|
|
2399
|
+
currentPositionHasValue = nextRangeHasValue, firstMove = !1;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
return alignToMergedCellsBorders(destRange, worksheet, !0);
|
|
2404
|
+
}
|
|
2405
|
+
__name(findNextGapRange, "findNextGapRange");
|
|
2406
|
+
function findNextRangeExpand(startRange, direction, worksheet) {
|
|
2407
|
+
return findNextRange(startRange, direction, worksheet, void 0, !1, 1, !1);
|
|
2408
|
+
}
|
|
2409
|
+
__name(findNextRangeExpand, "findNextRangeExpand");
|
|
2410
|
+
function expandToNextGapRange(startRange, direction, worksheet) {
|
|
2411
|
+
const next = findNextGapRange(startRange, direction, worksheet);
|
|
2412
|
+
return alignToMergedCellsBorders(Rectangle.union(next, startRange), worksheet, !0);
|
|
2413
|
+
}
|
|
2414
|
+
__name(expandToNextGapRange, "expandToNextGapRange");
|
|
2415
|
+
function expandToNextCell(startRange, direction, worksheet) {
|
|
2416
|
+
const next = findNextRangeExpand(startRange, direction, worksheet), destRange = {
|
|
2417
|
+
startRow: Math.min(startRange.startRow, next.startRow),
|
|
2418
|
+
startColumn: Math.min(startRange.startColumn, next.startColumn),
|
|
2419
|
+
endRow: Math.max(startRange.endRow, next.endRow),
|
|
2420
|
+
endColumn: Math.max(startRange.endColumn, next.endColumn)
|
|
2421
|
+
};
|
|
2422
|
+
return alignToMergedCellsBorders(Rectangle.union(startRange, destRange), worksheet);
|
|
2423
|
+
}
|
|
2424
|
+
__name(expandToNextCell, "expandToNextCell");
|
|
2425
|
+
function shrinkToNextGapRange(startRange, anchorRange, direction, worksheet) {
|
|
2426
|
+
const reversedDirection = getReverseDirection(direction), nextGap = findNextGapRange(getEdgeOfRange(startRange, reversedDirection, worksheet), direction, worksheet);
|
|
2427
|
+
return direction === Direction.UP && nextGap.startRow <= startRange.startRow ? alignToMergedCellsBorders(
|
|
2428
|
+
{ ...anchorRange, startColumn: startRange.startColumn, endColumn: startRange.endColumn },
|
|
2429
|
+
worksheet,
|
|
2430
|
+
!0
|
|
2431
|
+
) : direction === Direction.DOWN && nextGap.endRow >= startRange.endRow ? alignToMergedCellsBorders(
|
|
2432
|
+
{ ...anchorRange, startColumn: startRange.startColumn, endColumn: startRange.endColumn },
|
|
2433
|
+
worksheet,
|
|
2434
|
+
!0
|
|
2435
|
+
) : direction === Direction.LEFT && nextGap.startColumn <= startRange.startColumn ? alignToMergedCellsBorders(
|
|
2436
|
+
{ ...anchorRange, startRow: startRange.startRow, endRow: startRange.endRow },
|
|
2437
|
+
worksheet,
|
|
2438
|
+
!0
|
|
2439
|
+
) : direction === Direction.RIGHT && nextGap.endColumn >= startRange.endColumn ? alignToMergedCellsBorders(
|
|
2440
|
+
{ ...anchorRange, startRow: startRange.startRow, endRow: startRange.endRow },
|
|
2441
|
+
worksheet,
|
|
2442
|
+
!0
|
|
2443
|
+
) : Rectangle.union(Rectangle.clone(anchorRange), nextGap);
|
|
2444
|
+
}
|
|
2445
|
+
__name(shrinkToNextGapRange, "shrinkToNextGapRange");
|
|
2446
|
+
function shrinkToNextCell(startRange, direction, worksheet) {
|
|
2447
|
+
const reversedDirection = getReverseDirection(direction), shrinkFromEdge = getEdgeOfRange(startRange, reversedDirection, worksheet), otherEdge = getEdgeOfRange(startRange, direction, worksheet), next = findNextRangeExpand(shrinkFromEdge, direction, worksheet);
|
|
2448
|
+
return alignToMergedCellsBorders(Rectangle.union(otherEdge, next), worksheet, !1);
|
|
2449
|
+
}
|
|
2450
|
+
__name(shrinkToNextCell, "shrinkToNextCell");
|
|
2451
|
+
function expandToWholeSheet(worksheet) {
|
|
2452
|
+
return {
|
|
2453
|
+
startRow: 0,
|
|
2454
|
+
startColumn: 0,
|
|
2455
|
+
endRow: worksheet.getRowCount() - 1,
|
|
2456
|
+
endColumn: worksheet.getColumnCount() - 1,
|
|
2457
|
+
rangeType: RANGE_TYPE.ALL
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
__name(expandToWholeSheet, "expandToWholeSheet");
|
|
2461
|
+
function getEdgeOfRange(startRange, direction, worksheet) {
|
|
2462
|
+
let destRange;
|
|
2463
|
+
switch (direction) {
|
|
2464
|
+
case Direction.UP:
|
|
2465
|
+
destRange = {
|
|
2466
|
+
startRow: startRange.startRow,
|
|
2467
|
+
startColumn: startRange.startColumn,
|
|
2468
|
+
endRow: startRange.startRow,
|
|
2469
|
+
endColumn: startRange.endColumn,
|
|
2470
|
+
rangeType: RANGE_TYPE.NORMAL
|
|
2471
|
+
};
|
|
2472
|
+
break;
|
|
2473
|
+
case Direction.DOWN:
|
|
2474
|
+
destRange = {
|
|
2475
|
+
startRow: startRange.endRow,
|
|
2476
|
+
startColumn: startRange.startColumn,
|
|
2477
|
+
endRow: startRange.endRow,
|
|
2478
|
+
endColumn: startRange.endColumn,
|
|
2479
|
+
rangeType: RANGE_TYPE.NORMAL
|
|
2480
|
+
};
|
|
2481
|
+
break;
|
|
2482
|
+
case Direction.LEFT:
|
|
2483
|
+
destRange = {
|
|
2484
|
+
startRow: startRange.startRow,
|
|
2485
|
+
startColumn: startRange.startColumn,
|
|
2486
|
+
endRow: startRange.endRow,
|
|
2487
|
+
endColumn: startRange.startColumn,
|
|
2488
|
+
rangeType: RANGE_TYPE.NORMAL
|
|
2489
|
+
};
|
|
2490
|
+
break;
|
|
2491
|
+
case Direction.RIGHT:
|
|
2492
|
+
destRange = {
|
|
2493
|
+
startRow: startRange.startRow,
|
|
2494
|
+
startColumn: startRange.endColumn,
|
|
2495
|
+
endRow: startRange.endRow,
|
|
2496
|
+
endColumn: startRange.endColumn,
|
|
2497
|
+
rangeType: RANGE_TYPE.NORMAL
|
|
2498
|
+
};
|
|
2499
|
+
break;
|
|
2500
|
+
default:
|
|
2501
|
+
throw new Error("Invalid direction");
|
|
2502
|
+
}
|
|
2503
|
+
return alignToMergedCellsBorders(destRange, worksheet, !1);
|
|
2504
|
+
}
|
|
2505
|
+
__name(getEdgeOfRange, "getEdgeOfRange");
|
|
2506
|
+
function rangeHasValue(worksheet, row, col, rowEnd, colEnd) {
|
|
2507
|
+
let hasValue = !1;
|
|
2508
|
+
const matrix = worksheet.getMatrixWithMergedCells(row, col, rowEnd, colEnd).forValue((_, __, value) => {
|
|
2509
|
+
if (cellHasValue(value))
|
|
2510
|
+
return hasValue = !0, !1;
|
|
2511
|
+
});
|
|
2512
|
+
return {
|
|
2513
|
+
hasValue,
|
|
2514
|
+
matrix
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
__name(rangeHasValue, "rangeHasValue");
|
|
2518
|
+
function getStartRange(range, primary, direction) {
|
|
2519
|
+
const ret = Rectangle.clone(range);
|
|
2520
|
+
if (primary == null)
|
|
2521
|
+
return ret;
|
|
2522
|
+
switch (direction) {
|
|
2523
|
+
case Direction.UP:
|
|
2524
|
+
case Direction.DOWN:
|
|
2525
|
+
ret.startColumn = ret.endColumn = primary.actualColumn;
|
|
2526
|
+
break;
|
|
2527
|
+
case Direction.LEFT:
|
|
2528
|
+
case Direction.RIGHT:
|
|
2529
|
+
ret.startRow = ret.endRow = primary.actualRow;
|
|
2530
|
+
break;
|
|
2531
|
+
}
|
|
2532
|
+
return ret;
|
|
2533
|
+
}
|
|
2534
|
+
__name(getStartRange, "getStartRange");
|
|
2535
|
+
function checkIfShrink(selection, direction, worksheet) {
|
|
2536
|
+
const { primary, range } = selection, startRange = Rectangle.clone(range);
|
|
2537
|
+
switch (direction) {
|
|
2538
|
+
case Direction.UP:
|
|
2539
|
+
case Direction.DOWN:
|
|
2540
|
+
startRange.startRow = primary.startRow, startRange.endRow = primary.endRow;
|
|
2541
|
+
break;
|
|
2542
|
+
case Direction.LEFT:
|
|
2543
|
+
case Direction.RIGHT:
|
|
2544
|
+
startRange.startColumn = primary.startColumn, startRange.endColumn = primary.endColumn;
|
|
2545
|
+
break;
|
|
2546
|
+
}
|
|
2547
|
+
const anchorRange = getEdgeOfRange(startRange, direction, worksheet);
|
|
2548
|
+
switch (direction) {
|
|
2549
|
+
case Direction.DOWN:
|
|
2550
|
+
return range.startRow < anchorRange.startRow;
|
|
2551
|
+
case Direction.UP:
|
|
2552
|
+
return range.endRow > anchorRange.endRow;
|
|
2553
|
+
case Direction.LEFT:
|
|
2554
|
+
return anchorRange.endColumn < range.endColumn;
|
|
2555
|
+
case Direction.RIGHT:
|
|
2556
|
+
return anchorRange.startColumn > range.startColumn;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
__name(checkIfShrink, "checkIfShrink");
|
|
2560
|
+
function isAllRowsCovered(allRowRanges, ranges) {
|
|
2561
|
+
let start = allRowRanges[0].startRow, end = allRowRanges[0].endRow;
|
|
2562
|
+
allRowRanges.forEach((range) => {
|
|
2563
|
+
const { startRow, endRow } = range;
|
|
2564
|
+
start = Math.min(start, startRow), end = Math.max(end, endRow);
|
|
2565
|
+
});
|
|
2566
|
+
const covered = new Array(end - start + 1).fill(!1);
|
|
2567
|
+
return ranges.forEach((range) => {
|
|
2568
|
+
const { startRow, endRow } = range;
|
|
2569
|
+
for (let i = Math.max(startRow, start); i <= Math.min(endRow, end); i++)
|
|
2570
|
+
covered[i - start] = !0;
|
|
2571
|
+
}), allRowRanges.every((range) => {
|
|
2572
|
+
const { startRow, endRow } = range;
|
|
2573
|
+
for (let i = startRow; i <= endRow; i++)
|
|
2574
|
+
if (!covered[i - start])
|
|
2575
|
+
return !1;
|
|
2576
|
+
return !0;
|
|
2577
|
+
});
|
|
2578
|
+
}
|
|
2579
|
+
__name(isAllRowsCovered, "isAllRowsCovered");
|
|
2580
|
+
function isAllColumnsCovered(allColumnRanges, ranges) {
|
|
2581
|
+
let start = allColumnRanges[0].startColumn, end = allColumnRanges[0].endColumn;
|
|
2582
|
+
allColumnRanges.forEach((range) => {
|
|
2583
|
+
const { startColumn, endColumn } = range;
|
|
2584
|
+
start = Math.min(start, startColumn), end = Math.max(end, endColumn);
|
|
2585
|
+
});
|
|
2586
|
+
const covered = new Array(end - start + 1).fill(!1);
|
|
2587
|
+
return ranges.forEach((range) => {
|
|
2588
|
+
const { startColumn, endColumn } = range;
|
|
2589
|
+
for (let i = Math.max(startColumn, start); i <= Math.min(endColumn, end); i++)
|
|
2590
|
+
covered[i - start] = !0;
|
|
2591
|
+
}), allColumnRanges.every((range) => {
|
|
2592
|
+
const { startColumn, endColumn } = range;
|
|
2593
|
+
for (let i = startColumn; i <= endColumn; i++)
|
|
2594
|
+
if (!covered[i - start])
|
|
2595
|
+
return !1;
|
|
2596
|
+
return !0;
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
__name(isAllColumnsCovered, "isAllColumnsCovered");
|
|
2600
|
+
function getMergeableSelectionsByType(type, selections) {
|
|
2601
|
+
return selections ? type === "mergeAll" ? selections.filter((selection) => !(selection.startRow === selection.endRow && selection.startColumn === selection.endColumn)) : type === "mergeVertical" ? selections.filter((selection) => selection.startRow !== selection.endRow) : type === "mergeHorizontal" ? selections.filter((selection) => selection.startColumn !== selection.endColumn) : selections : null;
|
|
2602
|
+
}
|
|
2603
|
+
__name(getMergeableSelectionsByType, "getMergeableSelectionsByType");
|
|
2604
|
+
function cellHasValue(cell) {
|
|
2605
|
+
return cell.v !== void 0 && cell.v !== null && cell.v !== "" || cell.p !== void 0;
|
|
2606
|
+
}
|
|
2607
|
+
__name(cellHasValue, "cellHasValue");
|
|
2608
|
+
var JumpOver = /* @__PURE__ */ ((JumpOver2) => (JumpOver2[JumpOver2.moveStopeOne = 0] = "moveStopeOne", JumpOver2[JumpOver2.moveGap = 1] = "moveGap", JumpOver2[JumpOver2.moveStepPage = 2] = "moveStepPage", JumpOver2[JumpOver2.moveStepEnd = 3] = "moveStepEnd", JumpOver2))(JumpOver || {});
|
|
2609
|
+
const MoveSelectionCommand = {
|
|
2610
|
+
id: "sheet.command.move-selection",
|
|
2611
|
+
type: CommandType.COMMAND,
|
|
2612
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2613
|
+
var _a61;
|
|
2614
|
+
if (!params)
|
|
2615
|
+
return !1;
|
|
2616
|
+
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
2617
|
+
if (!target) return !1;
|
|
2618
|
+
const { workbook, worksheet } = target, selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
2619
|
+
if (!selection)
|
|
2620
|
+
return !1;
|
|
2621
|
+
const { direction, jumpOver } = params, { range, primary } = selection, startRange = getStartRange(range, primary, direction), next = jumpOver === 1 ? findNextGapRange(startRange, direction, worksheet) : findNextRange(startRange, direction, worksheet), destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
|
|
2622
|
+
if (Rectangle.equals(destRange, startRange))
|
|
2623
|
+
return !1;
|
|
2624
|
+
const unitId = workbook.getUnitId();
|
|
2625
|
+
accessor.get(ShortcutExperienceService).remove({
|
|
2626
|
+
unitId,
|
|
2627
|
+
sheetId: worksheet.getSheetId(),
|
|
2628
|
+
keycode: KeyCode.TAB
|
|
2629
|
+
});
|
|
2630
|
+
const selections = [
|
|
2631
|
+
{
|
|
2632
|
+
range: Rectangle.clone(destRange),
|
|
2633
|
+
primary: {
|
|
2634
|
+
startRow: destRange.startRow,
|
|
2635
|
+
startColumn: destRange.startColumn,
|
|
2636
|
+
endRow: destRange.endRow,
|
|
2637
|
+
endColumn: destRange.endColumn,
|
|
2638
|
+
actualRow: next.startRow,
|
|
2639
|
+
actualColumn: next.startColumn,
|
|
2640
|
+
isMerged: destRange.isMerged,
|
|
2641
|
+
isMergedMainCell: destRange.startRow === next.startRow && destRange.startColumn === next.startColumn
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
], rs = accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
2645
|
+
unitId: workbook.getUnitId(),
|
|
2646
|
+
subUnitId: worksheet.getSheetId(),
|
|
2647
|
+
selections
|
|
2648
|
+
}), selectionService = (_a61 = accessor.get(IRenderManagerService).getRenderById(unitId)) == null ? void 0 : _a61.with(ISheetSelectionRenderService);
|
|
2649
|
+
return selectionService == null || selectionService.refreshSelectionMoveEnd(), rs;
|
|
2650
|
+
}, "handler")
|
|
2651
|
+
}, MoveSelectionEnterAndTabCommand = {
|
|
2652
|
+
id: "sheet.command.move-selection-enter-tab",
|
|
2653
|
+
type: CommandType.COMMAND,
|
|
2654
|
+
// eslint-disable-next-line max-lines-per-function
|
|
2655
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2656
|
+
var _a61;
|
|
2657
|
+
if (!params)
|
|
2658
|
+
return !1;
|
|
2659
|
+
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
2660
|
+
if (!target) return !1;
|
|
2661
|
+
const { workbook, worksheet } = target, selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
2662
|
+
if (!selection)
|
|
2663
|
+
return !1;
|
|
2664
|
+
const unitId = workbook.getUnitId(), sheetId = worksheet.getSheetId();
|
|
2665
|
+
if (!selection)
|
|
2666
|
+
return !1;
|
|
2667
|
+
const { direction, keycode } = params, { range, primary } = selection;
|
|
2668
|
+
let startRange = getStartRange(range, primary, direction);
|
|
2669
|
+
const shortcutExperienceService = accessor.get(ShortcutExperienceService), shortcutExperienceParam = shortcutExperienceService.getCurrentBySearch({
|
|
2670
|
+
unitId,
|
|
2671
|
+
sheetId,
|
|
2672
|
+
keycode: KeyCode.TAB
|
|
2673
|
+
});
|
|
2674
|
+
let resultRange;
|
|
2675
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
2676
|
+
if (Rectangle.equals(range, primary)) {
|
|
2677
|
+
if (keycode === KeyCode.TAB)
|
|
2678
|
+
shortcutExperienceParam == null && shortcutExperienceService.addOrUpdate({
|
|
2679
|
+
unitId,
|
|
2680
|
+
sheetId,
|
|
2681
|
+
keycode: KeyCode.TAB,
|
|
2682
|
+
selection
|
|
2683
|
+
});
|
|
2684
|
+
else {
|
|
2685
|
+
const selectionRemain = shortcutExperienceParam == null ? void 0 : shortcutExperienceParam.selection;
|
|
2686
|
+
if (selectionRemain != null) {
|
|
2687
|
+
const { range: range2, primary: primary2 } = selectionRemain;
|
|
2688
|
+
startRange = getStartRange(range2, primary2, direction);
|
|
2689
|
+
}
|
|
2690
|
+
shortcutExperienceService.remove({
|
|
2691
|
+
unitId,
|
|
2692
|
+
sheetId,
|
|
2693
|
+
keycode: KeyCode.TAB
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
const next = findNextRange(startRange, direction, worksheet), destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
|
|
2697
|
+
if (Rectangle.equals(destRange, startRange))
|
|
2698
|
+
return !1;
|
|
2699
|
+
resultRange = {
|
|
2700
|
+
range: Rectangle.clone(destRange),
|
|
2701
|
+
primary: {
|
|
2702
|
+
startRow: destRange.startRow,
|
|
2703
|
+
startColumn: destRange.startColumn,
|
|
2704
|
+
endRow: destRange.endRow,
|
|
2705
|
+
endColumn: destRange.endColumn,
|
|
2706
|
+
actualRow: next.startRow,
|
|
2707
|
+
actualColumn: next.startColumn,
|
|
2708
|
+
isMerged: destRange.isMerged,
|
|
2709
|
+
isMergedMainCell: destRange.startRow === next.startRow && destRange.startColumn === next.startColumn
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
} else {
|
|
2713
|
+
shortcutExperienceService.remove({
|
|
2714
|
+
unitId,
|
|
2715
|
+
sheetId,
|
|
2716
|
+
keycode: KeyCode.TAB
|
|
2682
2717
|
});
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
backgroundControlTop,
|
|
2713
|
-
backgroundControlMiddleLeft,
|
|
2714
|
-
backgroundControlMiddleRight,
|
|
2715
|
-
backgroundControlBottom,
|
|
2716
|
-
fillControl
|
|
2717
|
-
} = this._control, objects = [
|
|
2718
|
-
leftControl,
|
|
2719
|
-
rightControl,
|
|
2720
|
-
topControl,
|
|
2721
|
-
bottomControl,
|
|
2722
|
-
backgroundControlTop,
|
|
2723
|
-
backgroundControlMiddleLeft,
|
|
2724
|
-
backgroundControlMiddleRight,
|
|
2725
|
-
backgroundControlBottom,
|
|
2726
|
-
fillControl
|
|
2727
|
-
];
|
|
2728
|
-
for (let i = 0, len = objects.length; i < len; i++) {
|
|
2729
|
-
const object = objects[i];
|
|
2730
|
-
func(object, i);
|
|
2718
|
+
const newPrimary = Tools.deepClone(primary), next = findNextRange(
|
|
2719
|
+
{
|
|
2720
|
+
startRow: newPrimary.startRow,
|
|
2721
|
+
startColumn: newPrimary.startColumn,
|
|
2722
|
+
endRow: newPrimary.endRow,
|
|
2723
|
+
endColumn: newPrimary.endColumn
|
|
2724
|
+
},
|
|
2725
|
+
direction,
|
|
2726
|
+
worksheet,
|
|
2727
|
+
{
|
|
2728
|
+
startRow,
|
|
2729
|
+
endRow,
|
|
2730
|
+
startColumn,
|
|
2731
|
+
endColumn
|
|
2732
|
+
}
|
|
2733
|
+
), destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);
|
|
2734
|
+
resultRange = {
|
|
2735
|
+
range: Rectangle.clone(range),
|
|
2736
|
+
primary: {
|
|
2737
|
+
startRow: destRange.startRow,
|
|
2738
|
+
startColumn: destRange.startColumn,
|
|
2739
|
+
endRow: destRange.endRow,
|
|
2740
|
+
endColumn: destRange.endColumn,
|
|
2741
|
+
actualRow: next.startRow,
|
|
2742
|
+
actualColumn: next.startColumn,
|
|
2743
|
+
isMerged: destRange.isMerged,
|
|
2744
|
+
isMergedMainCell: destRange.startRow === next.startRow && destRange.startColumn === next.startColumn
|
|
2745
|
+
}
|
|
2746
|
+
};
|
|
2731
2747
|
}
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2748
|
+
const rs = accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
2749
|
+
unitId,
|
|
2750
|
+
subUnitId: sheetId,
|
|
2751
|
+
selections: [resultRange]
|
|
2752
|
+
}), selectionService = (_a61 = accessor.get(IRenderManagerService).getRenderById(unitId)) == null ? void 0 : _a61.with(ISheetSelectionRenderService);
|
|
2753
|
+
return selectionService == null || selectionService.refreshSelectionMoveEnd(), rs;
|
|
2754
|
+
}, "handler")
|
|
2755
|
+
}, ExpandSelectionCommand = {
|
|
2756
|
+
id: "sheet.command.expand-selection",
|
|
2757
|
+
type: CommandType.COMMAND,
|
|
2758
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2759
|
+
if (!params) return !1;
|
|
2760
|
+
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
2761
|
+
if (!target) return !1;
|
|
2762
|
+
const { worksheet, unitId, subUnitId } = target, selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
2763
|
+
if (!selection) return !1;
|
|
2764
|
+
const { range: startRange, primary } = selection, { jumpOver, direction } = params, destRange = checkIfShrink(selection, direction, worksheet) ? jumpOver === 1 ? shrinkToNextGapRange(
|
|
2765
|
+
startRange,
|
|
2766
|
+
{ ...Rectangle.clone(primary), rangeType: RANGE_TYPE.NORMAL },
|
|
2767
|
+
direction,
|
|
2768
|
+
worksheet
|
|
2769
|
+
) : shrinkToNextCell(startRange, direction, worksheet) : jumpOver === 1 ? expandToNextGapRange(startRange, direction, worksheet) : expandToNextCell(startRange, direction, worksheet);
|
|
2770
|
+
return Rectangle.equals(destRange, startRange) ? !1 : accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
2771
|
+
unitId,
|
|
2772
|
+
subUnitId,
|
|
2773
|
+
selections: [
|
|
2774
|
+
{
|
|
2775
|
+
range: destRange,
|
|
2776
|
+
primary
|
|
2777
|
+
// this remains unchanged
|
|
2778
|
+
}
|
|
2779
|
+
]
|
|
2780
|
+
});
|
|
2781
|
+
}, "handler")
|
|
2782
|
+
}, SelectAllCommand = {
|
|
2783
|
+
id: "sheet.command.select-all",
|
|
2784
|
+
type: CommandType.COMMAND,
|
|
2785
|
+
handler: /* @__PURE__ */ __name(async (accessor, params = { expandToGapFirst: !0, loop: !1 }) => {
|
|
2786
|
+
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
2787
|
+
if (!target) return !1;
|
|
2788
|
+
const selection = getSelectionsService(accessor).getCurrentLastSelection();
|
|
2789
|
+
if (!selection) return !1;
|
|
2790
|
+
const selectAllService = accessor.get(SelectAllService), { worksheet, unitId, subUnitId } = target, id = `${unitId}|${subUnitId}`;
|
|
2791
|
+
id !== selectAllService.selectedRangeWorksheet && (selectAllService.rangesStack = [], selectAllService.selectedRangeWorksheet = id);
|
|
2792
|
+
const maxRow = worksheet.getMaxRows(), maxCol = worksheet.getMaxColumns(), { expandToGapFirst, loop } = params, { range, primary } = selection, isWholeSheetSelected = range.endColumn === maxCol - 1 && range.endRow === maxRow - 1 && range.startRow === 0 && range.startColumn === 0;
|
|
2793
|
+
selectAllService.rangesStack.some((s) => Rectangle.equals(s, range)) || (selectAllService.rangesStack = [], selectAllService.rangesStack.push(range));
|
|
2794
|
+
let destRange;
|
|
2795
|
+
if (isWholeSheetSelected)
|
|
2796
|
+
if (loop) {
|
|
2797
|
+
if (selectAllService.rangesStack.findIndex((s) => Rectangle.equals(s, range)) !== selectAllService.rangesStack.length - 1)
|
|
2798
|
+
return !1;
|
|
2799
|
+
destRange = selectAllService.rangesStack[0];
|
|
2740
2800
|
} else
|
|
2741
|
-
|
|
2742
|
-
else
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
};
|
|
2756
|
-
}
|
|
2757
|
-
_getScale() {
|
|
2758
|
-
const { scaleX, scaleY } = this._scene.getAncestorScale();
|
|
2759
|
-
return Math.max(scaleX, scaleY);
|
|
2760
|
-
}
|
|
2801
|
+
return !1;
|
|
2802
|
+
else expandToGapFirst ? (destRange = expandToContinuousRange(range, { left: !0, right: !0, up: !0, down: !0 }, worksheet), Rectangle.equals(destRange, range) && (destRange = expandToWholeSheet(worksheet))) : destRange = expandToWholeSheet(worksheet);
|
|
2803
|
+
return selectAllService.rangesStack.some((s) => Rectangle.equals(s, destRange)) || selectAllService.rangesStack.push(destRange), accessor.get(ICommandService).executeCommand(SetSelectionsOperation.id, {
|
|
2804
|
+
unitId,
|
|
2805
|
+
subUnitId,
|
|
2806
|
+
selections: [
|
|
2807
|
+
{
|
|
2808
|
+
range: destRange,
|
|
2809
|
+
primary
|
|
2810
|
+
// this remains unchanged
|
|
2811
|
+
}
|
|
2812
|
+
]
|
|
2813
|
+
});
|
|
2814
|
+
}, "handler")
|
|
2761
2815
|
};
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2816
|
+
function isRenderManagerService(renderManagerService) {
|
|
2817
|
+
return typeof renderManagerService.isMainScene > "u";
|
|
2818
|
+
}
|
|
2819
|
+
__name(isRenderManagerService, "isRenderManagerService");
|
|
2820
|
+
function getSheetObject(univerInstanceService, renderManagerService) {
|
|
2821
|
+
const workbook = univerInstanceService instanceof Workbook ? univerInstanceService : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
2822
|
+
if (!workbook) return null;
|
|
2823
|
+
const unitId = workbook.getUnitId();
|
|
2824
|
+
let components, mainComponent, scene, engine;
|
|
2825
|
+
if (isRenderManagerService(renderManagerService)) {
|
|
2826
|
+
const currentRender = renderManagerService.getRenderById(unitId);
|
|
2827
|
+
if (currentRender == null) return null;
|
|
2828
|
+
components = currentRender.components, components = currentRender.components, mainComponent = currentRender.mainComponent, scene = currentRender.scene, engine = currentRender.engine;
|
|
2829
|
+
} else
|
|
2830
|
+
components = renderManagerService.components, mainComponent = renderManagerService.mainComponent, scene = renderManagerService.scene, engine = renderManagerService.engine;
|
|
2831
|
+
if (!components || !mainComponent) return null;
|
|
2832
|
+
const spreadsheet = mainComponent, spreadsheetRowHeader = components.get(SHEET_VIEW_KEY.ROW), spreadsheetColumnHeader = components.get(SHEET_VIEW_KEY.COLUMN), spreadsheetLeftTopPlaceholder = components.get(SHEET_VIEW_KEY.LEFT_TOP);
|
|
2766
2833
|
return {
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2834
|
+
spreadsheet,
|
|
2835
|
+
spreadsheetRowHeader,
|
|
2836
|
+
spreadsheetColumnHeader,
|
|
2837
|
+
spreadsheetLeftTopPlaceholder,
|
|
2838
|
+
scene,
|
|
2839
|
+
engine
|
|
2770
2840
|
};
|
|
2771
2841
|
}
|
|
2772
|
-
__name(
|
|
2773
|
-
function
|
|
2774
|
-
const {
|
|
2842
|
+
__name(getSheetObject, "getSheetObject");
|
|
2843
|
+
function getCoordByCell(row, col, scene, skeleton) {
|
|
2844
|
+
const { startX, startY, endX, endY } = skeleton.getCellByIndex(row, col);
|
|
2845
|
+
return { startX, startY, endX, endY };
|
|
2846
|
+
}
|
|
2847
|
+
__name(getCoordByCell, "getCoordByCell");
|
|
2848
|
+
function getCoordByOffset(evtOffsetX, evtOffsetY, scene, skeleton, viewport, closeFirst) {
|
|
2849
|
+
const relativeCoords = scene.getRelativeToViewportCoord(Vector2.FromArray([evtOffsetX, evtOffsetY])), { x: newEvtOffsetX, y: newEvtOffsetY } = relativeCoords, scrollXY = scene.getVpScrollXYInfoByPosToVp(relativeCoords, viewport), { scaleX, scaleY } = scene.getAncestorScale(), moveActualSelection = skeleton.getCellPositionByOffset(
|
|
2850
|
+
newEvtOffsetX,
|
|
2851
|
+
newEvtOffsetY,
|
|
2852
|
+
scaleX,
|
|
2853
|
+
scaleY,
|
|
2854
|
+
scrollXY,
|
|
2855
|
+
closeFirst
|
|
2856
|
+
), { row, column } = moveActualSelection, startCell = skeleton.getNoMergeCellPositionByIndex(row, column), { startX, startY, endX, endY } = startCell;
|
|
2775
2857
|
return {
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
endX: cellPosition.endX,
|
|
2783
|
-
endY: cellPosition.endY,
|
|
2784
|
-
mergeInfo: {
|
|
2785
|
-
startRow,
|
|
2786
|
-
startColumn,
|
|
2787
|
-
endRow,
|
|
2788
|
-
endColumn,
|
|
2789
|
-
startY: (startCell == null ? void 0 : startCell.startY) || 0,
|
|
2790
|
-
endY: (endCell == null ? void 0 : endCell.endY) || 0,
|
|
2791
|
-
startX: (startCell == null ? void 0 : startCell.startX) || 0,
|
|
2792
|
-
endX: (endCell == null ? void 0 : endCell.endX) || 0
|
|
2793
|
-
}
|
|
2858
|
+
startX,
|
|
2859
|
+
startY,
|
|
2860
|
+
endX,
|
|
2861
|
+
endY,
|
|
2862
|
+
row,
|
|
2863
|
+
column
|
|
2794
2864
|
};
|
|
2795
2865
|
}
|
|
2796
|
-
__name(
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
startRow: -1,
|
|
2813
|
-
endRow: -1,
|
|
2814
|
-
startColumn: -1,
|
|
2815
|
-
endColumn: -1
|
|
2816
|
-
});
|
|
2817
|
-
/**
|
|
2818
|
-
* the posX of viewport when the pointer down
|
|
2819
|
-
*/
|
|
2820
|
-
__publicField(this, "_startViewportPosX", 0);
|
|
2821
|
-
/**
|
|
2822
|
-
* the posY of viewport when the pointer down
|
|
2823
|
-
*/
|
|
2824
|
-
__publicField(this, "_startViewportPosY", 0);
|
|
2825
|
-
__publicField(this, "_scrollTimer");
|
|
2826
|
-
__publicField(this, "_cancelDownSubscription");
|
|
2827
|
-
__publicField(this, "_cancelUpSubscription");
|
|
2828
|
-
__publicField(this, "_skeleton");
|
|
2829
|
-
__publicField(this, "_scene");
|
|
2830
|
-
// The type of selector determines the type of data range and the highlighting style of the title bar
|
|
2831
|
-
__publicField(this, "_isHeaderHighlight", !0);
|
|
2832
|
-
// If true, the selector will respond to the range of merged cells and automatically extend the selected range. If false, it will ignore the merged cells.
|
|
2833
|
-
__publicField(this, "_shouldDetectMergedCells", !0);
|
|
2834
|
-
// The style of the selection area, including dashed lines, color, thickness, autofill, other points for modifying the range of the selection area, title highlighting, and so on, can all be customized.
|
|
2835
|
-
__publicField(this, "_selectionStyle");
|
|
2836
|
-
// #region ref range selection
|
|
2837
|
-
// we put the properties here for simplicity
|
|
2838
|
-
// Used in the formula selection feature, a new selection string is added by drawing a box with the mouse.
|
|
2839
|
-
__publicField(this, "_remainLastEnabled", !1);
|
|
2840
|
-
__publicField(this, "_skipLastEnabled", !1);
|
|
2841
|
-
__publicField(this, "_singleSelectionEnabled", !1);
|
|
2842
|
-
// #endregion
|
|
2843
|
-
__publicField(this, "_selectionMoveEnd$", new BehaviorSubject([]));
|
|
2844
|
-
__publicField(this, "selectionMoveEnd$", this._selectionMoveEnd$.asObservable());
|
|
2845
|
-
__publicField(this, "_selectionMoving$", new Subject());
|
|
2846
|
-
__publicField(this, "selectionMoving$", this._selectionMoving$.asObservable());
|
|
2847
|
-
__publicField(this, "_selectionMoveStart$", new Subject());
|
|
2848
|
-
__publicField(this, "selectionMoveStart$", this._selectionMoveStart$.asObservable());
|
|
2849
|
-
__publicField(this, "_selectionMoving", !1);
|
|
2850
|
-
__publicField(this, "_activeViewport");
|
|
2851
|
-
__publicField(this, "interceptor", new InterceptorManager({ RANGE_MOVE_PERMISSION_CHECK, RANGE_FILL_PERMISSION_CHECK }));
|
|
2852
|
-
__publicField(this, "_escapeShortcutDisposable", null);
|
|
2853
|
-
this._injector = _injector, this._themeService = _themeService, this._shortcutService = _shortcutService, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._resetSelectionStyle(), this._initMoving();
|
|
2854
|
-
}
|
|
2855
|
-
get selectionMoving() {
|
|
2856
|
-
return this._selectionMoving;
|
|
2857
|
-
}
|
|
2858
|
-
_initMoving() {
|
|
2859
|
-
this.disposeWithMe(this._selectionMoving$.subscribe(() => {
|
|
2860
|
-
this._selectionMoving = !0;
|
|
2861
|
-
})), this.disposeWithMe(this._selectionMoveEnd$.subscribe(() => {
|
|
2862
|
-
this._selectionMoving = !1;
|
|
2863
|
-
}));
|
|
2864
|
-
}
|
|
2865
|
-
_setSelectionStyle(style) {
|
|
2866
|
-
this._selectionStyle = style;
|
|
2867
|
-
}
|
|
2868
|
-
/**
|
|
2869
|
-
* Reset this._selectionStyle to default normal selection style
|
|
2870
|
-
*/
|
|
2871
|
-
_resetSelectionStyle() {
|
|
2872
|
-
this._setSelectionStyle(getNormalSelectionStyle(this._themeService));
|
|
2873
|
-
}
|
|
2874
|
-
/** @deprecated This should not be provided by the selection render service. */
|
|
2875
|
-
getViewPort() {
|
|
2876
|
-
return this._activeViewport;
|
|
2877
|
-
}
|
|
2878
|
-
setSingleSelectionEnabled(enabled = !1) {
|
|
2879
|
-
this._singleSelectionEnabled = enabled;
|
|
2880
|
-
}
|
|
2881
|
-
/**
|
|
2882
|
-
* Add a selection in spreadsheet, create a new SelectionControl and then update this control by range derives from selection.
|
|
2883
|
-
* @param {ISelectionWithCoordAndStyle} selection
|
|
2884
|
-
*/
|
|
2885
|
-
_addSelectionControlBySelectionData(selection) {
|
|
2886
|
-
var _a61;
|
|
2887
|
-
const skeleton = this._skeleton, style = (_a61 = selection.style) != null ? _a61 : getNormalSelectionStyle(this._themeService), scene = this._scene;
|
|
2888
|
-
if (!scene || !skeleton)
|
|
2889
|
-
return;
|
|
2890
|
-
const { rangeWithCoord, primaryWithCoord } = selection, { rangeType } = rangeWithCoord, control = this.newSelectionControl(scene, rangeType || RANGE_TYPE.NORMAL, skeleton);
|
|
2891
|
-
new SelectionShapeExtension(control, skeleton, scene, this._themeService, this._injector, {
|
|
2892
|
-
selectionMoveEnd: /* @__PURE__ */ __name(() => {
|
|
2893
|
-
this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
|
|
2894
|
-
}, "selectionMoveEnd")
|
|
2895
|
-
});
|
|
2896
|
-
const { rowHeaderWidth, columnHeaderHeight } = skeleton;
|
|
2897
|
-
control.update(rangeWithCoord, rowHeaderWidth, columnHeaderHeight, style, primaryWithCoord);
|
|
2898
|
-
}
|
|
2899
|
-
newSelectionControl(scene, _rangeType, skeleton) {
|
|
2900
|
-
const zIndex = this.getSelectionControls().length, { rowHeaderWidth, columnHeaderHeight } = skeleton, control = new SelectionControl(scene, zIndex, this._themeService, this._isHeaderHighlight, {
|
|
2901
|
-
rowHeaderWidth,
|
|
2902
|
-
columnHeaderHeight
|
|
2903
|
-
});
|
|
2904
|
-
return this._selectionControls.push(control), control;
|
|
2905
|
-
}
|
|
2906
|
-
/**
|
|
2907
|
-
* Update the corresponding selectionControl based on selectionsData.
|
|
2908
|
-
* selectionData[i] syncs selectionControls[i]
|
|
2909
|
-
* @param selections
|
|
2910
|
-
*/
|
|
2911
|
-
updateControlForCurrentByRangeData(selections) {
|
|
2912
|
-
const selectionControls = this.getSelectionControls();
|
|
2913
|
-
if (!(!selectionControls || this._skeleton == null))
|
|
2914
|
-
for (let i = 0, len = selections.length; i < len; i++) {
|
|
2915
|
-
const { rangeWithCoord, primaryWithCoord } = selections[i], control = selectionControls[i];
|
|
2916
|
-
control && control.updateRange(rangeWithCoord, primaryWithCoord);
|
|
2917
|
-
}
|
|
2918
|
-
}
|
|
2919
|
-
refreshSelectionMoveStart() {
|
|
2920
|
-
this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
|
|
2921
|
-
}
|
|
2922
|
-
refreshSelectionMoveEnd() {
|
|
2923
|
-
this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
|
|
2924
|
-
}
|
|
2925
|
-
_changeRuntime(skeleton, scene, viewport) {
|
|
2926
|
-
this._skeleton = skeleton, this._scene = scene, this._activeViewport = viewport || (scene == null ? void 0 : scene.getViewports()[0]), scene.findLayerByZIndex(SHEET_COMPONENT_SELECTION_LAYER_INDEX) || scene.addLayer(new SelectionLayer(scene, [], SHEET_COMPONENT_SELECTION_LAYER_INDEX));
|
|
2927
|
-
}
|
|
2928
|
-
getSkeleton() {
|
|
2929
|
-
return this._skeleton;
|
|
2930
|
-
}
|
|
2931
|
-
/**
|
|
2932
|
-
* Generate selectionData from this._selectionControls.model .
|
|
2933
|
-
* @returns {ISelectionWithCoordAndStyle[]} {range, primary, style}[]
|
|
2934
|
-
*/
|
|
2935
|
-
getSelectionDataWithStyle() {
|
|
2936
|
-
const selectionControls = this._selectionControls, [unitId, sheetId] = this._skeleton.getLocation();
|
|
2937
|
-
return selectionControls.map((control) => {
|
|
2938
|
-
const v = control.getValue();
|
|
2939
|
-
return v.rangeWithCoord.sheetId = sheetId, v.rangeWithCoord.unitId = unitId, v;
|
|
2940
|
-
});
|
|
2941
|
-
}
|
|
2942
|
-
getSelectionControls() {
|
|
2943
|
-
return this._selectionControls;
|
|
2944
|
-
}
|
|
2945
|
-
_clearSelectionControls() {
|
|
2946
|
-
const allSelectionControls = this._selectionControls;
|
|
2947
|
-
for (const control of allSelectionControls)
|
|
2948
|
-
control.dispose();
|
|
2949
|
-
this._selectionControls.length = 0;
|
|
2950
|
-
}
|
|
2951
|
-
_getFreeze() {
|
|
2952
|
-
var _a61;
|
|
2953
|
-
return (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton.getWorksheetConfig().freeze;
|
|
2954
|
-
}
|
|
2955
|
-
_getViewportByCell(row, column) {
|
|
2956
|
-
if (row === void 0 || column === void 0)
|
|
2957
|
-
return null;
|
|
2958
|
-
const freeze = this._getFreeze();
|
|
2959
|
-
if (!freeze || freeze.startRow <= 0 && freeze.startColumn <= 0)
|
|
2960
|
-
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
2961
|
-
if (row > freeze.startRow && column > freeze.startColumn)
|
|
2962
|
-
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
2963
|
-
if (row <= freeze.startRow && column <= freeze.startColumn)
|
|
2964
|
-
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP);
|
|
2965
|
-
if (row <= freeze.startRow && column > freeze.startColumn)
|
|
2966
|
-
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP);
|
|
2967
|
-
if (row > freeze.startRow && column <= freeze.startColumn)
|
|
2968
|
-
return this._scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT);
|
|
2969
|
-
}
|
|
2970
|
-
/**
|
|
2971
|
-
* Returns the selected range in the active sheet, or null if there is no active range. If multiple ranges are selected this method returns only the last selected range.
|
|
2972
|
-
*/
|
|
2973
|
-
getActiveRange() {
|
|
2974
|
-
const controls = this.getSelectionControls(), model = controls && controls[controls.length - 1].model;
|
|
2975
|
-
return model && {
|
|
2976
|
-
startRow: model.startRow,
|
|
2977
|
-
startColumn: model.startColumn,
|
|
2978
|
-
endRow: model.endRow,
|
|
2979
|
-
endColumn: model.endColumn
|
|
2980
|
-
};
|
|
2981
|
-
}
|
|
2982
|
-
/**
|
|
2983
|
-
* get active selection control
|
|
2984
|
-
* @returns T extends SelectionControl
|
|
2985
|
-
*/
|
|
2986
|
-
getActiveSelectionControl() {
|
|
2987
|
-
const controls = this.getSelectionControls();
|
|
2988
|
-
if (controls)
|
|
2989
|
-
return controls[controls.length - 1];
|
|
2866
|
+
__name(getCoordByOffset, "getCoordByOffset");
|
|
2867
|
+
function getTransformCoord(evtOffsetX, evtOffsetY, scene, skeleton) {
|
|
2868
|
+
const relativeCoords = scene.getRelativeToViewportCoord(Vector2.FromArray([evtOffsetX, evtOffsetY])), viewMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN), scrollXY = scene.getVpScrollXYInfoByPosToVp(relativeCoords, viewMain), { scaleX, scaleY } = scene.getAncestorScale(), { x: scrollX, y: scrollY } = scrollXY, offsetX = evtOffsetX / scaleX + scrollX, offsetY = evtOffsetY / scaleY + scrollY;
|
|
2869
|
+
return { x: offsetX, y: offsetY };
|
|
2870
|
+
}
|
|
2871
|
+
__name(getTransformCoord, "getTransformCoord");
|
|
2872
|
+
var __defProp$S = Object.defineProperty, __getOwnPropDesc$S = Object.getOwnPropertyDescriptor, __decorateClass$S = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2873
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$S(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2874
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2875
|
+
return kind && result && __defProp$S(target, key, result), result;
|
|
2876
|
+
}, "__decorateClass$S"), __decorateParam$S = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$S");
|
|
2877
|
+
const SHEET_NAVIGATION_COMMANDS$1 = [MoveSelectionCommand.id, MoveSelectionEnterAndTabCommand.id];
|
|
2878
|
+
var _a4;
|
|
2879
|
+
let SheetsScrollRenderController = (_a4 = class extends Disposable {
|
|
2880
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _contextService, _commandService, _renderManagerService, _scrollManagerService) {
|
|
2881
|
+
super(), this._context = _context, this._injector = _injector, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._contextService = _contextService, this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._scrollManagerService = _scrollManagerService, this._initCommandListener(), this._wheelEventListener(), this._scrollBarEventListener(), this._initSkeletonListener();
|
|
2990
2882
|
}
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2883
|
+
scrollToRange(range) {
|
|
2884
|
+
let { endRow, endColumn, startColumn, startRow } = range;
|
|
2885
|
+
const bounding = this._getViewportBounding();
|
|
2886
|
+
if (range.rangeType === RANGE_TYPE.ROW ? (startColumn = 0, endColumn = 0) : range.rangeType === RANGE_TYPE.COLUMN && (startRow = 0, endRow = 0), bounding) {
|
|
2887
|
+
const row = bounding.startRow > endRow ? startRow : endRow, col = bounding.startColumn > endColumn ? startColumn : endColumn;
|
|
2888
|
+
return this._scrollToCell(row, col);
|
|
2889
|
+
} else
|
|
2890
|
+
return this._scrollToCell(startRow, startColumn);
|
|
2994
2891
|
}
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
2892
|
+
_initCommandListener() {
|
|
2893
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2894
|
+
if (SHEET_NAVIGATION_COMMANDS$1.includes(command.id))
|
|
2895
|
+
this._scrollToSelection();
|
|
2896
|
+
else if (command.id === ScrollToCellOperation.id) {
|
|
2897
|
+
const param = command.params;
|
|
2898
|
+
this.scrollToRange(param);
|
|
2899
|
+
} else if (command.id === ExpandSelectionCommand.id) {
|
|
2900
|
+
const param = command.params;
|
|
2901
|
+
this._scrollToSelectionForExpand(param);
|
|
2902
|
+
} else command.id === SetSelectionsOperation.id && command.params.reveal && this._scrollToSelection();
|
|
2903
|
+
}));
|
|
3001
2904
|
}
|
|
3002
|
-
|
|
3003
|
-
|
|
2905
|
+
_scrollToSelectionForExpand(param) {
|
|
2906
|
+
setTimeout(() => {
|
|
2907
|
+
const selection = this._getSelectionsService().getCurrentLastSelection();
|
|
2908
|
+
if (selection == null)
|
|
2909
|
+
return;
|
|
2910
|
+
const { startRow, startColumn, endRow, endColumn } = selection.range, bounds = this._getViewportBounding();
|
|
2911
|
+
if (bounds == null)
|
|
2912
|
+
return;
|
|
2913
|
+
const { startRow: viewportStartRow, startColumn: viewportStartColumn, endRow: viewportEndRow, endColumn: viewportEndColumn } = bounds;
|
|
2914
|
+
let row = 0, column = 0;
|
|
2915
|
+
startRow > viewportStartRow ? row = endRow : endRow < viewportEndRow ? row = startRow : row = viewportStartRow, startColumn > viewportStartColumn ? column = endColumn : endColumn < viewportEndColumn ? column = startColumn : column = viewportStartColumn, param.direction === Direction.DOWN ? row = endRow : param.direction === Direction.UP ? row = startRow : param.direction === Direction.RIGHT ? column = endColumn : param.direction === Direction.LEFT && (column = startColumn), this._scrollToCell(row, column);
|
|
2916
|
+
}, 0);
|
|
3004
2917
|
}
|
|
3005
|
-
|
|
3006
|
-
/**
|
|
3007
|
-
*
|
|
3008
|
-
* @param evt component point event
|
|
3009
|
-
* @param style selection style, Styles for user-customized selectors
|
|
3010
|
-
* @param _zIndex Stacking order of the selection object
|
|
3011
|
-
* @param rangeType Determines whether the selection is made normally according to the range or by rows and columns
|
|
3012
|
-
*/
|
|
3013
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
3014
|
-
_onPointerDown(evt, _zIndex = 0, rangeType = RANGE_TYPE.NORMAL, viewport, scrollTimerType = ScrollTimerType.ALL) {
|
|
2918
|
+
_getFreeze() {
|
|
3015
2919
|
var _a61;
|
|
3016
|
-
this.
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
return;
|
|
3020
|
-
viewport && (this._activeViewport = viewport);
|
|
3021
|
-
const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
3022
|
-
if (!viewportMain) return;
|
|
3023
|
-
const relativeCoords = scene.getRelativeToViewportCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
3024
|
-
let { x: viewportPosX, y: viewportPosY } = relativeCoords;
|
|
3025
|
-
this._startViewportPosX = viewportPosX, this._startViewportPosY = viewportPosY;
|
|
3026
|
-
const scrollXY = scene.getVpScrollXYInfoByPosToVp(relativeCoords), { scaleX, scaleY } = scene.getAncestorScale(), cursorCellRangeInfo = this._getCellRangeByCursorPosition(viewportPosX, viewportPosY, scaleX, scaleY, scrollXY);
|
|
3027
|
-
if (!cursorCellRangeInfo) return;
|
|
3028
|
-
const { rangeWithCoord: cursorCellRange, primaryWithCoord: primaryCursorCellRange } = cursorCellRangeInfo, cursorCellRangeWithRangeType = { ...cursorCellRange, rangeType };
|
|
3029
|
-
this._startRangeWhenPointerDown = { ...cursorCellRange, rangeType };
|
|
3030
|
-
let activeSelectionControl = this.getActiveSelectionControl();
|
|
3031
|
-
const curControls = this.getSelectionControls();
|
|
3032
|
-
for (const control of curControls) {
|
|
3033
|
-
if (evt.button === 2 && control.model.isInclude(cursorCellRangeWithRangeType)) {
|
|
3034
|
-
activeSelectionControl = control;
|
|
3035
|
-
return;
|
|
3036
|
-
}
|
|
3037
|
-
if (control.model.isEqual(cursorCellRangeWithRangeType)) {
|
|
3038
|
-
activeSelectionControl = control;
|
|
3039
|
-
break;
|
|
3040
|
-
}
|
|
3041
|
-
evt.shiftKey || control.clearHighlight();
|
|
3042
|
-
}
|
|
3043
|
-
this._checkClearPreviousControls(evt);
|
|
3044
|
-
const currentCell = activeSelectionControl == null ? void 0 : activeSelectionControl.model.currentCell, expandByShiftKey = evt.shiftKey && currentCell, remainLastEnable = this._remainLastEnabled && !evt.ctrlKey && !evt.shiftKey && !this._skipLastEnabled && !this._singleSelectionEnabled;
|
|
3045
|
-
expandByShiftKey && currentCell ? this._performSelectionByTwoCells(
|
|
3046
|
-
currentCell,
|
|
3047
|
-
cursorCellRangeWithRangeType,
|
|
3048
|
-
skeleton,
|
|
3049
|
-
rangeType,
|
|
3050
|
-
activeSelectionControl
|
|
3051
|
-
// Get updated in this method
|
|
3052
|
-
) : remainLastEnable && activeSelectionControl ? this._updateSelectionControlByRange(
|
|
3053
|
-
activeSelectionControl,
|
|
3054
|
-
cursorCellRangeWithRangeType,
|
|
3055
|
-
primaryCursorCellRange
|
|
3056
|
-
) : (activeSelectionControl = this.newSelectionControl(scene, rangeType, skeleton), this._updateSelectionControlByRange(
|
|
3057
|
-
activeSelectionControl,
|
|
3058
|
-
cursorCellRangeWithRangeType,
|
|
3059
|
-
primaryCursorCellRange
|
|
3060
|
-
)), this._selectionMoveStart$.next(this.getSelectionDataWithStyle()), scene.disableObjectsEvent(), this._clearUpdatingListeners(), this._addEndingListeners(), (_a61 = scene.getTransformer()) == null || _a61.clearSelectedObjects(), (rangeType === RANGE_TYPE.ROW || rangeType === RANGE_TYPE.COLUMN) && (rangeType === RANGE_TYPE.ROW ? viewportPosX = 0 : rangeType === RANGE_TYPE.COLUMN && (viewportPosY = 0), this._movingHandler(viewportPosX, viewportPosY, activeSelectionControl, rangeType)), this._setupPointerMoveListener(viewportMain, activeSelectionControl, rangeType, scrollTimerType, viewportPosX, viewportPosY), this._escapeShortcutDisposable = this._shortcutService.forceEscape(), this._scenePointerUpSub = scene.onPointerUp$.subscribeEvent(() => {
|
|
3061
|
-
var _a62;
|
|
3062
|
-
this._clearUpdatingListeners(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()), (_a62 = this._escapeShortcutDisposable) == null || _a62.dispose(), this._escapeShortcutDisposable = null;
|
|
3063
|
-
});
|
|
2920
|
+
const snapshot = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton.getWorksheetConfig();
|
|
2921
|
+
if (snapshot != null)
|
|
2922
|
+
return snapshot.freeze;
|
|
3064
2923
|
}
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
this._scrollTimer = ScrollTimer.create(this._scene, scrollTimerType), this._scrollTimer.startScroll((_a61 = viewportMain == null ? void 0 : viewportMain.left) != null ? _a61 : 0, (_b = viewportMain == null ? void 0 : viewportMain.top) != null ? _b : 0, viewportMain);
|
|
3080
|
-
const scene = this._scene, startViewport = scene.getActiveViewportByCoord(Vector2.FromArray([moveStartPosX, moveStartPosY]));
|
|
3081
|
-
this._scenePointerMoveSub = scene.onPointerMove$.subscribeEvent((moveEvt) => {
|
|
3082
|
-
var _a62, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
3083
|
-
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt, { x: newMoveOffsetX, y: newMoveOffsetY } = scene.getRelativeToViewportCoord(Vector2.FromArray([moveOffsetX, moveOffsetY]));
|
|
3084
|
-
this._movingHandler(newMoveOffsetX, newMoveOffsetY, activeSelectionControl, rangeType);
|
|
3085
|
-
let scrollOffsetX = newMoveOffsetX, scrollOffsetY = newMoveOffsetY;
|
|
3086
|
-
const currentSelection = this.getActiveSelectionControl(), freeze = this._getFreeze(), selection = currentSelection == null ? void 0 : currentSelection.model, endViewport = (_a62 = scene.getActiveViewportByCoord(Vector2.FromArray([moveOffsetX, moveOffsetY]))) != null ? _a62 : this._getViewportByCell(selection == null ? void 0 : selection.endRow, selection == null ? void 0 : selection.endColumn);
|
|
3087
|
-
if ((/* @__PURE__ */ __name(() => {
|
|
3088
|
-
if (!startViewport || !endViewport || !viewportMain)
|
|
3089
|
-
return !1;
|
|
3090
|
-
const crossableViewports = [
|
|
3091
|
-
SHEET_VIEWPORT_KEY$1.VIEW_MAIN,
|
|
3092
|
-
SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP,
|
|
3093
|
-
SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP,
|
|
3094
|
-
SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT
|
|
3095
|
-
];
|
|
3096
|
-
return crossableViewports.includes(startViewport.viewportKey) && crossableViewports.includes(endViewport.viewportKey);
|
|
3097
|
-
}, "isCrossableViewports"))()) {
|
|
3098
|
-
if (!startViewport || !endViewport || !viewportMain)
|
|
3099
|
-
return !1;
|
|
3100
|
-
const isCrossingX = lastX < viewportMain.left && newMoveOffsetX > viewportMain.left || lastX > viewportMain.left && newMoveOffsetX < viewportMain.left, isCrossingY = lastY < viewportMain.top && newMoveOffsetY > viewportMain.top || lastY > viewportMain.top && newMoveOffsetY < viewportMain.top;
|
|
3101
|
-
isCrossingX && (xCrossTime += 1), isCrossingY && (yCrossTime += 1);
|
|
3102
|
-
const startKey = startViewport.viewportKey, endKey = endViewport.viewportKey;
|
|
3103
|
-
if (startKey === SHEET_VIEWPORT_KEY$1.VIEW_ROW_TOP)
|
|
3104
|
-
moveOffsetY < viewportMain.top && ((_b2 = selection == null ? void 0 : selection.endRow) != null ? _b2 : 0) < ((_c = freeze == null ? void 0 : freeze.startRow) != null ? _c : 0) ? scrollOffsetY = viewportMain.top : isCrossingY && yCrossTime % 2 === 1 && viewportMain.scrollToViewportPos({
|
|
3105
|
-
viewportScrollY: 0
|
|
3106
|
-
});
|
|
3107
|
-
else if (startKey === SHEET_VIEWPORT_KEY$1.VIEW_COLUMN_LEFT)
|
|
3108
|
-
moveOffsetX < viewportMain.left && ((_d = selection == null ? void 0 : selection.endColumn) != null ? _d : 0) < ((_e = freeze == null ? void 0 : freeze.startColumn) != null ? _e : 0) ? scrollOffsetX = viewportMain.left : isCrossingX && xCrossTime % 2 === 1 && viewportMain.scrollToViewportPos({
|
|
3109
|
-
viewportScrollX: 0
|
|
3110
|
-
});
|
|
3111
|
-
else if (startKey === endKey) {
|
|
3112
|
-
let disableX = !1, disableY = !1;
|
|
3113
|
-
startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP ? (disableX = !0, disableY = !0) : startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP ? disableY = !0 : startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT && (disableX = !0), ((_f = selection == null ? void 0 : selection.endRow) != null ? _f : 0) > ((_g = freeze == null ? void 0 : freeze.startRow) != null ? _g : 0) && (disableY = !1), ((_h = selection == null ? void 0 : selection.endColumn) != null ? _h : 0) > ((_i = freeze == null ? void 0 : freeze.startColumn) != null ? _i : 0) && (disableX = !1), disableX && (scrollOffsetX = viewportMain.left), disableY && (scrollOffsetY = viewportMain.top);
|
|
3114
|
-
} else {
|
|
3115
|
-
const startXY = {
|
|
3116
|
-
x: startViewport.scrollX,
|
|
3117
|
-
y: startViewport.scrollY
|
|
3118
|
-
}, endXY = {
|
|
3119
|
-
x: endViewport.scrollX,
|
|
3120
|
-
y: endViewport.scrollY
|
|
3121
|
-
}, shouldResetX = startXY.x !== endXY.x && isCrossingX && xCrossTime % 2 === 1, shouldResetY = startXY.y !== endXY.y && isCrossingY && yCrossTime % 2 === 1;
|
|
3122
|
-
(shouldResetX || shouldResetY) && (viewportMain.scrollToBarPos({
|
|
3123
|
-
x: shouldResetX ? startXY.x : void 0,
|
|
3124
|
-
y: shouldResetY ? startXY.y : void 0
|
|
3125
|
-
}), shouldResetX || (scrollOffsetX = viewportMain.left), shouldResetY || (scrollOffsetY = viewportMain.top)), (startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT || endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT) && (scrollOffsetX = viewportMain.left), (startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP || endKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_LEFT_TOP && startKey === SHEET_VIEWPORT_KEY$1.VIEW_MAIN_TOP) && (scrollOffsetY = viewportMain.top);
|
|
2924
|
+
_wheelEventListener() {
|
|
2925
|
+
const { scene } = this._context;
|
|
2926
|
+
if (!scene) return;
|
|
2927
|
+
const viewMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
2928
|
+
viewMain && this.disposeWithMe(
|
|
2929
|
+
// eslint-disable-next-line complexity
|
|
2930
|
+
scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
2931
|
+
if (evt.ctrlKey || !this._contextService.getContextValue(FOCUSING_SHEET))
|
|
2932
|
+
return;
|
|
2933
|
+
let offsetX = 0, offsetY = 0;
|
|
2934
|
+
const isLimitedStore = viewMain.limitedScroll();
|
|
2935
|
+
if (evt.inputIndex === PointerInput.MouseWheelX) {
|
|
2936
|
+
const scrollNum = Math.abs(evt.deltaX);
|
|
2937
|
+
offsetX = evt.deltaX > 0 ? scrollNum : -scrollNum, this._commandService.executeCommand(SetScrollRelativeCommand.id, { offsetX }), scene.getParent().classType === RENDER_CLASS_TYPE.SCENE_VIEWER ? isLimitedStore != null && isLimitedStore.isLimitedX || state.stopPropagation() : viewMain.isWheelPreventDefaultX ? evt.preventDefault() : isLimitedStore != null && isLimitedStore.isLimitedX || evt.preventDefault();
|
|
3126
2938
|
}
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
2939
|
+
if (evt.inputIndex === PointerInput.MouseWheelY) {
|
|
2940
|
+
let scrollNum = Math.abs(evt.deltaY);
|
|
2941
|
+
evt.shiftKey ? (scrollNum *= 3, evt.deltaY > 0 ? offsetX = scrollNum : offsetX = -scrollNum, this._commandService.executeCommand(SetScrollRelativeCommand.id, { offsetX }), scene.getParent().classType === RENDER_CLASS_TYPE.SCENE_VIEWER ? isLimitedStore != null && isLimitedStore.isLimitedX || state.stopPropagation() : viewMain.isWheelPreventDefaultX ? evt.preventDefault() : isLimitedStore != null && isLimitedStore.isLimitedX || evt.preventDefault()) : (offsetY = evt.deltaY > 0 ? scrollNum : -scrollNum, this._commandService.executeCommand(SetScrollRelativeCommand.id, { offsetY }), scene.getParent().classType === RENDER_CLASS_TYPE.SCENE_VIEWER ? isLimitedStore != null && isLimitedStore.isLimitedY || state.stopPropagation() : viewMain.isWheelPreventDefaultY ? evt.preventDefault() : isLimitedStore != null && isLimitedStore.isLimitedY || evt.preventDefault());
|
|
2942
|
+
}
|
|
2943
|
+
this._context.scene.makeDirty(!0);
|
|
2944
|
+
})
|
|
2945
|
+
);
|
|
2946
|
+
}
|
|
2947
|
+
// eslint-disable-next-line max-lines-per-function
|
|
2948
|
+
_scrollBarEventListener() {
|
|
2949
|
+
const { scene } = this._context;
|
|
2950
|
+
if (scene == null) return;
|
|
2951
|
+
const viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
2952
|
+
viewportMain && (this.disposeWithMe(
|
|
2953
|
+
toDisposable(
|
|
2954
|
+
this._scrollManagerService.rawScrollInfo$.subscribe((rawScrollInfo) => {
|
|
2955
|
+
var _a61;
|
|
2956
|
+
const skeleton = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton;
|
|
2957
|
+
if (!skeleton) return;
|
|
2958
|
+
if (rawScrollInfo == null) {
|
|
2959
|
+
viewportMain.scrollToViewportPos({
|
|
2960
|
+
viewportScrollX: 0,
|
|
2961
|
+
viewportScrollY: 0
|
|
2962
|
+
});
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
const { sheetViewStartRow, sheetViewStartColumn, offsetX, offsetY } = rawScrollInfo, { startX, startY } = skeleton.getCellByIndexWithNoHeader(
|
|
2966
|
+
sheetViewStartRow,
|
|
2967
|
+
sheetViewStartColumn
|
|
2968
|
+
), viewportScrollX = startX + offsetX, viewportScrollY = startY + offsetY;
|
|
2969
|
+
viewportMain.scrollToViewportPos({ viewportScrollX, viewportScrollY });
|
|
2970
|
+
})
|
|
2971
|
+
)
|
|
2972
|
+
), this.disposeWithMe(
|
|
2973
|
+
// set scrollInfo, the event is triggered in viewport@_scrollToScrollbarPos
|
|
2974
|
+
viewportMain.onScrollAfter$.subscribeEvent((scrollAfterParam) => {
|
|
2975
|
+
var _a61;
|
|
2976
|
+
const skeleton = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton;
|
|
2977
|
+
if (skeleton == null || scrollAfterParam.isTrigger === !1)
|
|
2978
|
+
return;
|
|
2979
|
+
const sheetObject = this._getSheetObject();
|
|
2980
|
+
if (skeleton == null || sheetObject == null)
|
|
2981
|
+
return;
|
|
2982
|
+
const { viewportScrollX, viewportScrollY, scrollX, scrollY } = scrollAfterParam, { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(
|
|
2983
|
+
viewportScrollX,
|
|
2984
|
+
viewportScrollY
|
|
2985
|
+
), scrollInfo = {
|
|
2986
|
+
sheetViewStartRow: row,
|
|
2987
|
+
sheetViewStartColumn: column,
|
|
2988
|
+
offsetX: columnOffset,
|
|
2989
|
+
offsetY: rowOffset
|
|
2990
|
+
};
|
|
2991
|
+
this._scrollManagerService.setScrollStateToCurrSheet(scrollInfo), this._scrollManagerService.validViewportScrollInfo$.next({
|
|
2992
|
+
...scrollInfo,
|
|
2993
|
+
viewportScrollX,
|
|
2994
|
+
viewportScrollY,
|
|
2995
|
+
scrollX,
|
|
2996
|
+
scrollY
|
|
2997
|
+
});
|
|
2998
|
+
})
|
|
2999
|
+
), this.disposeWithMe(
|
|
3000
|
+
// get scrollByBar event from viewport and exec ScrollCommand.id.
|
|
3001
|
+
viewportMain.onScrollByBar$.subscribeEvent((param) => {
|
|
3002
|
+
var _a61;
|
|
3003
|
+
const skeleton = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton;
|
|
3004
|
+
if (skeleton == null || param.isTrigger === !1)
|
|
3005
|
+
return;
|
|
3006
|
+
const sheetObject = this._getSheetObject();
|
|
3007
|
+
if (skeleton == null || sheetObject == null)
|
|
3008
|
+
return;
|
|
3009
|
+
const { viewportScrollX = 0, viewportScrollY = 0 } = param, freeze = this._getFreeze(), { row, column, rowOffset, columnOffset } = skeleton.getDecomposedOffset(
|
|
3010
|
+
viewportScrollX,
|
|
3011
|
+
viewportScrollY
|
|
3012
|
+
);
|
|
3013
|
+
this._commandService.executeCommand(ScrollCommand.id, {
|
|
3014
|
+
sheetViewStartRow: row + ((freeze == null ? void 0 : freeze.ySplit) || 0),
|
|
3015
|
+
sheetViewStartColumn: column + ((freeze == null ? void 0 : freeze.xSplit) || 0),
|
|
3016
|
+
offsetX: columnOffset,
|
|
3017
|
+
offsetY: rowOffset
|
|
3018
|
+
});
|
|
3019
|
+
})
|
|
3020
|
+
));
|
|
3021
|
+
}
|
|
3022
|
+
_initSkeletonListener() {
|
|
3023
|
+
this.disposeWithMe(toDisposable(
|
|
3024
|
+
this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe((param) => {
|
|
3025
|
+
if (param == null)
|
|
3026
|
+
return;
|
|
3027
|
+
const scrollParam = { unitId: param.unitId, sheetId: param.sheetId };
|
|
3028
|
+
this._scrollManagerService.setSearchParam(scrollParam);
|
|
3029
|
+
const sheetObject = this._getSheetObject();
|
|
3030
|
+
if (!sheetObject) return;
|
|
3031
|
+
const viewportMain = sheetObject.scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN), currScrollInfo = this._scrollManagerService.getScrollStateByParam(scrollParam), { viewportScrollX, viewportScrollY } = this._scrollManagerService.calcViewportScrollFromRowColOffset(currScrollInfo);
|
|
3032
|
+
viewportMain && (currScrollInfo ? (viewportMain.viewportScrollX = viewportScrollX, viewportMain.viewportScrollY = viewportScrollY) : (viewportMain.viewportScrollX = 0, viewportMain.viewportScrollY = 0), this._updateSceneSize(param));
|
|
3033
|
+
})
|
|
3034
|
+
));
|
|
3035
|
+
}
|
|
3036
|
+
_updateSceneSize(param) {
|
|
3037
|
+
var _a61;
|
|
3038
|
+
if (param == null)
|
|
3039
|
+
return;
|
|
3040
|
+
const { unitId } = this._context, { skeleton } = param, scene = (_a61 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a61.scene;
|
|
3041
|
+
if (skeleton == null || scene == null)
|
|
3042
|
+
return;
|
|
3043
|
+
const { rowTotalHeight, columnTotalWidth, rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton, worksheet = this._context.unit.getActiveSheet();
|
|
3044
|
+
if (!worksheet) return;
|
|
3045
|
+
const zoomRatio = worksheet.getZoomRatio() || 1;
|
|
3046
|
+
scene == null || scene.setScaleValue(zoomRatio, zoomRatio), scene == null || scene.transformByState({
|
|
3047
|
+
width: rowHeaderWidthAndMarginLeft + columnTotalWidth,
|
|
3048
|
+
height: columnHeaderHeightAndMarginTop + rowTotalHeight
|
|
3132
3049
|
});
|
|
3133
3050
|
}
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
return attachSelectionWithCoord(selectionWithStyle, this._skeleton);
|
|
3051
|
+
_getSheetObject() {
|
|
3052
|
+
return getSheetObject(this._context.unit, this._context);
|
|
3137
3053
|
}
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3054
|
+
_scrollToSelectionByDirection(range) {
|
|
3055
|
+
const bounds = this._getViewportBounding();
|
|
3056
|
+
if (bounds == null)
|
|
3057
|
+
return !1;
|
|
3058
|
+
const {
|
|
3059
|
+
startRow: viewportStartRow,
|
|
3060
|
+
startColumn: viewportStartColumn,
|
|
3061
|
+
endRow: viewportEndRow,
|
|
3062
|
+
endColumn: viewportEndColumn
|
|
3063
|
+
} = bounds;
|
|
3064
|
+
let row = 0, column = 0;
|
|
3065
|
+
const { startRow, startColumn, endRow, endColumn } = range;
|
|
3066
|
+
startRow >= viewportStartRow && (row = endRow), endRow <= viewportEndRow && (row = startRow), startColumn >= viewportStartColumn && (column = endColumn), endColumn <= viewportEndColumn && (column = startColumn), this._scrollToCell(row, column);
|
|
3141
3067
|
}
|
|
3142
|
-
|
|
3143
|
-
const
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
scaleX,
|
|
3148
|
-
scaleY,
|
|
3149
|
-
scrollXY
|
|
3150
|
-
);
|
|
3068
|
+
_scrollToSelection(targetIsActualRowAndColumn = !0) {
|
|
3069
|
+
const selection = this._getSelectionsService().getCurrentLastSelection();
|
|
3070
|
+
if (!selection) return;
|
|
3071
|
+
const { startRow, startColumn, actualRow, actualColumn } = selection.primary, selectionStartRow = targetIsActualRowAndColumn ? actualRow : startRow, selectionStartColumn = targetIsActualRowAndColumn ? actualColumn : startColumn;
|
|
3072
|
+
this._scrollToCell(selectionStartRow, selectionStartColumn);
|
|
3151
3073
|
}
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
startRow: (_a61 = activeSelectionControl == null ? void 0 : activeSelectionControl.model.startRow) != null ? _a61 : -1,
|
|
3160
|
-
endRow: (_b = activeSelectionControl == null ? void 0 : activeSelectionControl.model.endRow) != null ? _b : -1,
|
|
3161
|
-
startColumn: (_c = activeSelectionControl == null ? void 0 : activeSelectionControl.model.startColumn) != null ? _c : -1,
|
|
3162
|
-
endColumn: (_d = activeSelectionControl == null ? void 0 : activeSelectionControl.model.endColumn) != null ? _d : -1,
|
|
3163
|
-
unitId,
|
|
3164
|
-
sheetId
|
|
3165
|
-
}, viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN), targetViewport = (_e = this._getViewportByCell(currSelectionRange.endRow, currSelectionRange.endColumn)) != null ? _e : viewportMain, scrollXY = scene.getVpScrollXYInfoByPosToVp(
|
|
3166
|
-
Vector2.FromArray([this._startViewportPosX, this._startViewportPosY]),
|
|
3167
|
-
targetViewport
|
|
3168
|
-
), { scaleX, scaleY } = scene.getAncestorScale();
|
|
3169
|
-
rangeType === RANGE_TYPE.ROW ? offsetX = Number.POSITIVE_INFINITY : rangeType === RANGE_TYPE.COLUMN && (offsetY = Number.POSITIVE_INFINITY);
|
|
3170
|
-
const cursorCellRangeInfo = this._getCellRangeByCursorPosition(offsetX, offsetY, scaleX, scaleY, scrollXY);
|
|
3171
|
-
if (!cursorCellRangeInfo)
|
|
3074
|
+
_getSelectionsService() {
|
|
3075
|
+
return getSelectionsService(this._injector);
|
|
3076
|
+
}
|
|
3077
|
+
_getViewportBounding() {
|
|
3078
|
+
var _a61, _b;
|
|
3079
|
+
const scene = (_a61 = this._getSheetObject()) == null ? void 0 : _a61.scene;
|
|
3080
|
+
if (scene == null)
|
|
3172
3081
|
return;
|
|
3173
|
-
const
|
|
3174
|
-
|
|
3175
|
-
startRow: Math.min(cursorCellRange.startRow, activeCellRange.startRow),
|
|
3176
|
-
startColumn: Math.min(cursorCellRange.startColumn, activeCellRange.startColumn),
|
|
3177
|
-
endRow: Math.max(cursorCellRange.endRow, activeCellRange.endRow),
|
|
3178
|
-
endColumn: Math.max(cursorCellRange.endColumn, activeCellRange.endColumn)
|
|
3179
|
-
};
|
|
3180
|
-
if (this._shouldDetectMergedCells && (newSelectionRange = skeleton.getSelectionMergeBounding(newSelectionRange.startRow, newSelectionRange.startColumn, newSelectionRange.endRow, newSelectionRange.endColumn)), !newSelectionRange)
|
|
3082
|
+
const viewport = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
3083
|
+
if (viewport == null)
|
|
3181
3084
|
return;
|
|
3182
|
-
const
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3085
|
+
const skeleton = (_b = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _b.skeleton;
|
|
3086
|
+
if (skeleton == null)
|
|
3087
|
+
return;
|
|
3088
|
+
const bounds = viewport.getBounding();
|
|
3089
|
+
return skeleton.getRowColumnSegmentByViewBound(bounds.viewBound);
|
|
3090
|
+
}
|
|
3091
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
3092
|
+
_scrollToCell(row, column) {
|
|
3093
|
+
var _a61, _b, _c, _d;
|
|
3094
|
+
const { rowHeightAccumulation, columnWidthAccumulation } = (_b = (_a61 = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _a61.skeleton) != null ? _b : {};
|
|
3095
|
+
if (rowHeightAccumulation == null || columnWidthAccumulation == null) return !1;
|
|
3096
|
+
const scene = (_c = this._getSheetObject()) == null ? void 0 : _c.scene;
|
|
3097
|
+
if (scene == null) return !1;
|
|
3098
|
+
const viewport = scene.getViewport(SHEET_VIEWPORT_KEY$1.VIEW_MAIN);
|
|
3099
|
+
if (viewport == null || ((_d = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : _d.skeleton) == null) return !1;
|
|
3100
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
3101
|
+
if (!worksheet) return !1;
|
|
3102
|
+
const {
|
|
3103
|
+
startColumn: freezeStartColumn,
|
|
3104
|
+
startRow: freezeStartRow,
|
|
3105
|
+
ySplit: freezeYSplit,
|
|
3106
|
+
xSplit: freezeXSplit
|
|
3107
|
+
} = worksheet.getFreeze(), bounds = this._getViewportBounding();
|
|
3108
|
+
if (bounds == null) return !1;
|
|
3109
|
+
const {
|
|
3110
|
+
startRow: viewportStartRow,
|
|
3111
|
+
startColumn: viewportStartColumn,
|
|
3112
|
+
endRow: viewportEndRow,
|
|
3113
|
+
endColumn: viewportEndColumn
|
|
3114
|
+
} = bounds;
|
|
3115
|
+
let startSheetViewRow, startSheetViewColumn;
|
|
3116
|
+
if (row >= freezeStartRow && column >= freezeStartColumn - freezeXSplit && (row <= viewportStartRow && (startSheetViewRow = row), row >= viewportEndRow)) {
|
|
3117
|
+
const minRowAccumulation = rowHeightAccumulation[row] - viewport.height;
|
|
3118
|
+
for (let r2 = viewportStartRow; r2 <= row; r2++)
|
|
3119
|
+
if (rowHeightAccumulation[r2] >= minRowAccumulation) {
|
|
3120
|
+
startSheetViewRow = r2 + 1;
|
|
3121
|
+
break;
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
if (column >= freezeStartColumn && row >= freezeStartRow - freezeYSplit && (column <= viewportStartColumn && (startSheetViewColumn = column), column >= viewportEndColumn)) {
|
|
3125
|
+
const minColumnAccumulation = columnWidthAccumulation[column] - viewport.width;
|
|
3126
|
+
for (let c = viewportStartColumn; c <= column; c++)
|
|
3127
|
+
if (columnWidthAccumulation[c] >= minColumnAccumulation) {
|
|
3128
|
+
startSheetViewColumn = c + 1;
|
|
3129
|
+
break;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
if (startSheetViewRow === void 0 && startSheetViewColumn === void 0) return !1;
|
|
3133
|
+
const { offsetX, offsetY } = this._scrollManagerService.getCurrentScrollState() || {};
|
|
3134
|
+
return startSheetViewRow = startSheetViewRow && Math.min(startSheetViewRow, row), startSheetViewColumn = startSheetViewColumn && Math.min(startSheetViewColumn, column), this._commandService.syncExecuteCommand(ScrollCommand.id, {
|
|
3135
|
+
sheetViewStartRow: startSheetViewRow,
|
|
3136
|
+
sheetViewStartColumn: startSheetViewColumn,
|
|
3137
|
+
offsetX: startSheetViewColumn === void 0 ? offsetX : 0,
|
|
3138
|
+
offsetY: startSheetViewRow === void 0 ? offsetY : 0
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
}, __name(_a4, "SheetsScrollRenderController"), _a4);
|
|
3142
|
+
SheetsScrollRenderController = __decorateClass$S([
|
|
3143
|
+
__decorateParam$S(1, Inject(Injector)),
|
|
3144
|
+
__decorateParam$S(2, Inject(SheetSkeletonManagerService)),
|
|
3145
|
+
__decorateParam$S(3, IContextService),
|
|
3146
|
+
__decorateParam$S(4, ICommandService),
|
|
3147
|
+
__decorateParam$S(5, IRenderManagerService),
|
|
3148
|
+
__decorateParam$S(6, Inject(SheetScrollManagerService))
|
|
3149
|
+
], SheetsScrollRenderController);
|
|
3150
|
+
function getActiveSheet$(univerInstanceService) {
|
|
3151
|
+
return univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => workbook ? workbook.activeSheet$.pipe(map((worksheet) => worksheet ? { workbook, worksheet } : null)) : of(null)));
|
|
3152
|
+
}
|
|
3153
|
+
__name(getActiveSheet$, "getActiveSheet$");
|
|
3154
|
+
function deriveStateFromActiveSheet$(univerInstanceService, defaultValue, callback) {
|
|
3155
|
+
return getActiveSheet$(univerInstanceService).pipe(switchMap((active) => active ? callback(active) : of(defaultValue)));
|
|
3156
|
+
}
|
|
3157
|
+
__name(deriveStateFromActiveSheet$, "deriveStateFromActiveSheet$");
|
|
3158
|
+
function getCurrentExclusiveRangeInterest$(accessor, disableGroupSet) {
|
|
3159
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), exclusiveRangeService = accessor.get(IExclusiveRangeService), selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
3160
|
+
return univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
|
|
3161
|
+
switchMap((workbook) => workbook ? combineLatest([selectionManagerService.selectionMoveEnd$, workbook.activeSheet$]).pipe(
|
|
3162
|
+
switchMap(([selections, worksheet]) => {
|
|
3163
|
+
if (!worksheet)
|
|
3164
|
+
return of(!1);
|
|
3165
|
+
if (selections.length === 0)
|
|
3166
|
+
return of(!1);
|
|
3167
|
+
const interestGroupIds = exclusiveRangeService.getInterestGroupId(selections);
|
|
3168
|
+
if (disableGroupSet) {
|
|
3169
|
+
const disableGroup = interestGroupIds.filter((groupId) => disableGroupSet.has(groupId));
|
|
3170
|
+
return of(disableGroup.length > 0);
|
|
3171
|
+
} else
|
|
3172
|
+
return of(interestGroupIds.length > 0);
|
|
3173
|
+
})
|
|
3174
|
+
) : of(!1))
|
|
3175
|
+
);
|
|
3176
|
+
}
|
|
3177
|
+
__name(getCurrentExclusiveRangeInterest$, "getCurrentExclusiveRangeInterest$");
|
|
3178
|
+
function getObservableWithExclusiveRange$(accessor, observable$, disableGroupSet) {
|
|
3179
|
+
return combineLatest([observable$, getCurrentExclusiveRangeInterest$(accessor, disableGroupSet)]).pipe(
|
|
3180
|
+
map(([observable, exclusiveRangeDisable]) => observable || exclusiveRangeDisable)
|
|
3181
|
+
);
|
|
3182
|
+
}
|
|
3183
|
+
__name(getObservableWithExclusiveRange$, "getObservableWithExclusiveRange$");
|
|
3184
|
+
function getCurrentRangeDisable$(accessor, permissionTypes = {}) {
|
|
3185
|
+
const workbook$ = accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), userManagerService = accessor.get(UserManagerService);
|
|
3186
|
+
return combineLatest([userManagerService.currentUser$, workbook$]).pipe(
|
|
3187
|
+
switchMap(([_, workbook]) => workbook ? workbook.activeSheet$.pipe(
|
|
3188
|
+
switchMap((worksheet) => {
|
|
3189
|
+
if (!worksheet)
|
|
3190
|
+
return of(!0);
|
|
3191
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), worksheetRuleModel = accessor.get(WorksheetProtectionRuleModel), focusedOnDrawing$ = accessor.get(IContextService).subscribeContextValue$(FOCUSING_COMMON_DRAWINGS).pipe(startWith(!1));
|
|
3192
|
+
return combineLatest([selectionManagerService.selectionMoveEnd$, focusedOnDrawing$]).pipe(
|
|
3193
|
+
switchMap(([selection, focusOnDrawings]) => {
|
|
3194
|
+
if (focusOnDrawings)
|
|
3195
|
+
return of(!0);
|
|
3196
|
+
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionService = accessor.get(IPermissionService), { workbookTypes = [WorkbookEditablePermission], worksheetTypes, rangeTypes } = permissionTypes, permissionIds = [];
|
|
3197
|
+
if (workbookTypes == null || workbookTypes.forEach((F) => {
|
|
3198
|
+
permissionIds.push(new F(unitId).id);
|
|
3199
|
+
}), worksheetTypes == null || worksheetTypes.forEach((F) => {
|
|
3200
|
+
permissionIds.push(new F(unitId, subUnitId).id);
|
|
3201
|
+
}), worksheetRuleModel.getRule(unitId, subUnitId))
|
|
3202
|
+
return permissionService.composePermission$(permissionIds).pipe(map((list) => list.some((item) => item.value === !1)));
|
|
3203
|
+
const selectionRanges = selection == null ? void 0 : selection.map((selection2) => selection2.range), rules = rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => selectionRanges == null ? void 0 : selectionRanges.some((range) => rule.ranges.some((ruleRange) => Rectangle.intersects(range, ruleRange))));
|
|
3204
|
+
return rangeTypes == null || rangeTypes.forEach((F) => {
|
|
3205
|
+
rules.forEach((rule) => {
|
|
3206
|
+
permissionIds.push(new F(unitId, subUnitId, rule.permissionId).id);
|
|
3207
|
+
});
|
|
3208
|
+
}), permissionService.composePermission$(permissionIds).pipe(map((list) => list.some((item) => item.value === !1)));
|
|
3209
|
+
})
|
|
3210
|
+
);
|
|
3211
|
+
})
|
|
3212
|
+
) : of(!0))
|
|
3213
|
+
);
|
|
3214
|
+
}
|
|
3215
|
+
__name(getCurrentRangeDisable$, "getCurrentRangeDisable$");
|
|
3216
|
+
function getBaseRangeMenuHidden$(accessor) {
|
|
3217
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService);
|
|
3218
|
+
return merge(selectionManagerService.selectionMoveEnd$, permissionService.permissionPointUpdate$.pipe(debounceTime(100))).pipe(
|
|
3219
|
+
map(() => {
|
|
3220
|
+
var _a61;
|
|
3221
|
+
const range = (_a61 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a61.range;
|
|
3222
|
+
if (!range) return !0;
|
|
3223
|
+
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
3224
|
+
if (!workbook || !worksheet)
|
|
3225
|
+
return !0;
|
|
3226
|
+
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionIds = [new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id];
|
|
3227
|
+
return rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(range, ruleRange))).forEach((rule) => {
|
|
3228
|
+
permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId).id);
|
|
3229
|
+
}), permissionService.composePermission(permissionIds).some((item) => item.value === !1);
|
|
3230
|
+
})
|
|
3231
|
+
);
|
|
3232
|
+
}
|
|
3233
|
+
__name(getBaseRangeMenuHidden$, "getBaseRangeMenuHidden$");
|
|
3234
|
+
function getDeleteMenuHidden$(accessor, type) {
|
|
3235
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService);
|
|
3236
|
+
return merge(selectionManagerService.selectionMoveEnd$, permissionService.permissionPointUpdate$.pipe(debounceTime(100))).pipe(
|
|
3237
|
+
map(() => {
|
|
3238
|
+
var _a61;
|
|
3239
|
+
const range = (_a61 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a61.range;
|
|
3240
|
+
if (!range) return !0;
|
|
3241
|
+
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
3242
|
+
if (!workbook || !worksheet)
|
|
3243
|
+
return !0;
|
|
3244
|
+
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionIds = [new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id], rowColRangeExpand = Tools.deepClone(range);
|
|
3245
|
+
return type === "row" ? (rowColRangeExpand.startColumn = 0, rowColRangeExpand.endColumn = worksheet.getColumnCount() - 1) : (rowColRangeExpand.startRow = 0, rowColRangeExpand.endRow = worksheet.getRowCount() - 1), rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(rowColRangeExpand, ruleRange))).forEach((rule) => {
|
|
3246
|
+
permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId).id);
|
|
3247
|
+
}), permissionService.composePermission(permissionIds).some((item) => item.value === !1);
|
|
3248
|
+
})
|
|
3249
|
+
);
|
|
3250
|
+
}
|
|
3251
|
+
__name(getDeleteMenuHidden$, "getDeleteMenuHidden$");
|
|
3252
|
+
function getCellMenuHidden$(accessor, type) {
|
|
3253
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService);
|
|
3254
|
+
return merge(selectionManagerService.selectionMoveEnd$, permissionService.permissionPointUpdate$.pipe(debounceTime(100))).pipe(
|
|
3255
|
+
map(() => {
|
|
3256
|
+
var _a61;
|
|
3257
|
+
const range = (_a61 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a61.range;
|
|
3258
|
+
if (!range) return !0;
|
|
3259
|
+
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
3260
|
+
if (!workbook || !worksheet)
|
|
3261
|
+
return !0;
|
|
3262
|
+
const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), permissionIds = [new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id], rowColRangeExpand = Tools.deepClone(range);
|
|
3263
|
+
return type === "row" ? rowColRangeExpand.endRow = worksheet.getRowCount() - 1 : rowColRangeExpand.endColumn = worksheet.getColumnCount() - 1, rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(rowColRangeExpand, ruleRange))).forEach((rule) => {
|
|
3264
|
+
permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId).id);
|
|
3265
|
+
}), permissionService.composePermission(permissionIds).some((item) => item.value === !1);
|
|
3266
|
+
})
|
|
3267
|
+
);
|
|
3268
|
+
}
|
|
3269
|
+
__name(getCellMenuHidden$, "getCellMenuHidden$");
|
|
3270
|
+
function getWorkbookPermissionDisable$(accessor, workbookPermissionTypes) {
|
|
3271
|
+
const workbook$ = accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), worksheetRuleModel = accessor.get(WorksheetProtectionRuleModel), selectionRuleModel = accessor.get(RangeProtectionRuleModel), permissionService = accessor.get(IPermissionService), userManagerService = accessor.get(UserManagerService);
|
|
3272
|
+
return combineLatest([userManagerService.currentUser$, workbook$]).pipe(
|
|
3273
|
+
switchMap(([_user, workbook]) => workbook ? workbook.activeSheet$.pipe(
|
|
3274
|
+
switchMap((activeSheet) => {
|
|
3275
|
+
var _a61, _b;
|
|
3276
|
+
if (!activeSheet)
|
|
3277
|
+
return of(!0);
|
|
3278
|
+
const unitId = workbook.getUnitId(), workbookPermissionIds = [];
|
|
3279
|
+
workbookPermissionTypes.forEach((F) => workbookPermissionIds.push(new F(unitId).id));
|
|
3280
|
+
const workbookPermission$ = permissionService.composePermission$(workbookPermissionIds).pipe(map((list) => list.every((item) => item.value === !0))), workbookManageCollaboratorPermission$ = (_b = (_a61 = permissionService.getPermissionPoint$(new WorkbookManageCollaboratorPermission(unitId).id)) == null ? void 0 : _a61.pipe(map((permission) => permission.value))) != null ? _b : of(!1);
|
|
3281
|
+
return combineLatest([workbookPermission$, workbookManageCollaboratorPermission$]).pipe(
|
|
3282
|
+
map(([basePermission, manageable]) => {
|
|
3283
|
+
if (!basePermission)
|
|
3284
|
+
return !0;
|
|
3285
|
+
const subUnitId = activeSheet.getSheetId(), worksheetRule = worksheetRuleModel.getRule(unitId, subUnitId), worksheetRuleList = selectionRuleModel.getSubunitRuleList(unitId, subUnitId);
|
|
3286
|
+
return worksheetRule || worksheetRuleList.length ? !manageable : !1;
|
|
3287
|
+
})
|
|
3288
|
+
);
|
|
3289
|
+
})
|
|
3290
|
+
) : of(!0))
|
|
3291
|
+
);
|
|
3292
|
+
}
|
|
3293
|
+
__name(getWorkbookPermissionDisable$, "getWorkbookPermissionDisable$");
|
|
3294
|
+
var __defProp$R = Object.defineProperty, __getOwnPropDesc$R = Object.getOwnPropertyDescriptor, __decorateClass$R = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
3295
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$R(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
3296
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
3297
|
+
return kind && result && __defProp$R(target, key, result), result;
|
|
3298
|
+
}, "__decorateClass$R"), __decorateParam$R = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$R");
|
|
3299
|
+
const SHEET_MAIN_CANVAS_ID = "univer-sheet-main-canvas";
|
|
3300
|
+
var _a5;
|
|
3301
|
+
let SheetsRenderService = (_a5 = class extends RxDisposable {
|
|
3302
|
+
constructor(_contextService, _instanceSrv, _renderManagerService) {
|
|
3303
|
+
super();
|
|
3304
|
+
__publicField(this, "_skeletonChangeMutations", /* @__PURE__ */ new Set());
|
|
3305
|
+
this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, Promise.resolve().then(() => this._init());
|
|
3195
3306
|
}
|
|
3196
3307
|
/**
|
|
3197
|
-
*
|
|
3198
|
-
*
|
|
3199
|
-
* @param
|
|
3200
|
-
* @
|
|
3308
|
+
* Register a mutation id that will trigger the skeleton change.
|
|
3309
|
+
*
|
|
3310
|
+
* @param mutationId the id of the mutation
|
|
3311
|
+
* @returns a disposable to unregister the mutation
|
|
3201
3312
|
*/
|
|
3202
|
-
|
|
3203
|
-
|
|
3313
|
+
registerSkeletonChangingMutations(mutationId) {
|
|
3314
|
+
return this._skeletonChangeMutations.has(mutationId) ? toDisposable(() => {
|
|
3315
|
+
}) : (this._skeletonChangeMutations.add(mutationId), toDisposable(() => this._skeletonChangeMutations.delete(mutationId)));
|
|
3204
3316
|
}
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
this._scene.enableObjectsEvent(), (_a61 = this._scenePointerMoveSub) == null || _a61.unsubscribe(), this._scenePointerMoveSub = null, (_b = this._scenePointerUpSub) == null || _b.unsubscribe(), this._scenePointerUpSub = null, (_c = this._cancelDownSubscription) == null || _c.unsubscribe(), this._cancelDownSubscription = null, (_d = this._cancelUpSubscription) == null || _d.unsubscribe(), this._cancelUpSubscription = null, (_e = this._scrollTimer) == null || _e.dispose();
|
|
3317
|
+
checkMutationShouldTriggerRerender(id) {
|
|
3318
|
+
return this._skeletonChangeMutations.has(id);
|
|
3208
3319
|
}
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
const scene = this._scene, mainScene = (_a61 = scene.getEngine()) == null ? void 0 : _a61.activeScene;
|
|
3212
|
-
!mainScene || mainScene === scene || ((_b = this._cancelDownSubscription) == null || _b.unsubscribe(), this._cancelDownSubscription = null, (_c = this._cancelUpSubscription) == null || _c.unsubscribe(), this._cancelUpSubscription = null, this._cancelDownSubscription = mainScene.onPointerDown$.subscribeEvent(() => this._clearUpdatingListeners()), this._cancelUpSubscription = mainScene.onPointerUp$.subscribeEvent(() => this._clearUpdatingListeners()));
|
|
3320
|
+
_init() {
|
|
3321
|
+
this._initWorkbookListener(), this._initContextListener();
|
|
3213
3322
|
}
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
offsetX,
|
|
3219
|
-
offsetY,
|
|
3220
|
-
scaleX,
|
|
3221
|
-
scaleY,
|
|
3222
|
-
scrollXY
|
|
3223
|
-
);
|
|
3224
|
-
if (!primaryWithCoord2) return;
|
|
3225
|
-
const rangeWithCoord2 = makeCellToSelection(primaryWithCoord2);
|
|
3226
|
-
return {
|
|
3227
|
-
primaryWithCoord: primaryWithCoord2,
|
|
3228
|
-
rangeWithCoord: rangeWithCoord2
|
|
3229
|
-
};
|
|
3230
|
-
}
|
|
3231
|
-
const skeleton = this._skeleton;
|
|
3232
|
-
if (skeleton == null)
|
|
3233
|
-
return;
|
|
3234
|
-
const moveActualSelection = skeleton.getCellPositionByOffset(offsetX, offsetY, scaleX, scaleY, scrollXY), { row, column } = moveActualSelection, startCell = skeleton.getNoMergeCellPositionByIndex(row, column), { startX, startY, endX, endY } = startCell, rangeWithCoord = {
|
|
3235
|
-
startY,
|
|
3236
|
-
endY,
|
|
3237
|
-
startX,
|
|
3238
|
-
endX,
|
|
3239
|
-
startRow: row,
|
|
3240
|
-
endRow: row,
|
|
3241
|
-
startColumn: column,
|
|
3242
|
-
endColumn: column
|
|
3243
|
-
};
|
|
3244
|
-
return {
|
|
3245
|
-
primaryWithCoord: {
|
|
3246
|
-
actualRow: row,
|
|
3247
|
-
actualColumn: column,
|
|
3248
|
-
isMerged: !1,
|
|
3249
|
-
isMergedMainCell: !1,
|
|
3250
|
-
startY,
|
|
3251
|
-
endY,
|
|
3252
|
-
startX,
|
|
3253
|
-
endX,
|
|
3254
|
-
mergeInfo: rangeWithCoord
|
|
3255
|
-
},
|
|
3256
|
-
rangeWithCoord
|
|
3257
|
-
};
|
|
3323
|
+
_initWorkbookListener() {
|
|
3324
|
+
this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => {
|
|
3325
|
+
this._createRenderer(workbook);
|
|
3326
|
+
}), this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._createRenderer(workbook)), this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._disposeRenderer(workbook));
|
|
3258
3327
|
}
|
|
3259
|
-
|
|
3260
|
-
|
|
3328
|
+
_createRenderer(workbook) {
|
|
3329
|
+
const unitId = workbook.getUnitId();
|
|
3330
|
+
this._renderManagerService.created$.subscribe((renderer) => {
|
|
3331
|
+
renderer.unitId === unitId && renderer.engine.getCanvas().setId(SHEET_MAIN_CANVAS_ID);
|
|
3332
|
+
}), this._renderManagerService.createRender(unitId), this._renderManagerService.setCurrent(unitId);
|
|
3261
3333
|
}
|
|
3262
|
-
|
|
3263
|
-
const
|
|
3264
|
-
|
|
3265
|
-
startRow: bounding.startRow,
|
|
3266
|
-
endColumn: bounding.endColumn,
|
|
3267
|
-
endRow: bounding.endRow,
|
|
3268
|
-
startY: startCell.startY,
|
|
3269
|
-
endY: endCell.endY,
|
|
3270
|
-
startX: startCell.startX,
|
|
3271
|
-
endX: endCell.endX,
|
|
3272
|
-
rangeType
|
|
3273
|
-
}, activeCell = skeleton.getCellByIndex(actualRow, actualColumn);
|
|
3274
|
-
this._startRangeWhenPointerDown = {
|
|
3275
|
-
startColumn: activeCell.mergeInfo.startColumn,
|
|
3276
|
-
startRow: activeCell.mergeInfo.startRow,
|
|
3277
|
-
endColumn: activeCell.mergeInfo.endColumn,
|
|
3278
|
-
endRow: activeCell.mergeInfo.endRow,
|
|
3279
|
-
startY: activeCell.mergeInfo.startY || 0,
|
|
3280
|
-
endY: activeCell.mergeInfo.endY || 0,
|
|
3281
|
-
startX: activeCell.mergeInfo.startX || 0,
|
|
3282
|
-
endX: activeCell.mergeInfo.endX || 0,
|
|
3283
|
-
rangeType
|
|
3284
|
-
}, this._updateSelectionControlByRange(activeControl, newSelectionRange, currentCell);
|
|
3334
|
+
_disposeRenderer(workbook) {
|
|
3335
|
+
const unitId = workbook.getUnitId();
|
|
3336
|
+
this._renderManagerService.removeRender(unitId);
|
|
3285
3337
|
}
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
const selections = selectionsData.map((selectionWithStyle) => {
|
|
3292
|
-
const selectionData = attachSelectionWithCoord(selectionWithStyle, this._skeleton);
|
|
3293
|
-
return selectionData.style = getNormalSelectionStyle(this._themeService), selectionData;
|
|
3338
|
+
_initContextListener() {
|
|
3339
|
+
this._contextService.subscribeContextValue$(RENDER_RAW_FORMULA_KEY).pipe(distinctUntilChanged(), takeUntil(this.dispose$)).subscribe(() => {
|
|
3340
|
+
this._renderManagerService.getRenderAll().forEach((renderer) => {
|
|
3341
|
+
renderer.mainComponent instanceof Spreadsheet && renderer.mainComponent.makeForceDirty(!0);
|
|
3342
|
+
});
|
|
3294
3343
|
});
|
|
3295
|
-
this.updateControlForCurrentByRangeData(selections);
|
|
3296
3344
|
}
|
|
3297
|
-
};
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
startRow: 0,
|
|
3304
|
-
startColumn: 0,
|
|
3305
|
-
endRow: skeleton.getRowCount() - 1,
|
|
3306
|
-
endColumn: skeleton.getColumnCount() - 1,
|
|
3307
|
-
rangeType: RANGE_TYPE.ALL
|
|
3308
|
-
},
|
|
3309
|
-
primary: getTopLeftSelection(skeleton).primary,
|
|
3310
|
-
style: null
|
|
3311
|
-
};
|
|
3312
|
-
}
|
|
3313
|
-
__name(getAllSelection, "getAllSelection");
|
|
3314
|
-
function getTopLeftSelection(skeleton) {
|
|
3315
|
-
const mergeData = skeleton.mergeData;
|
|
3316
|
-
return transformCellDataToSelectionData(0, 0, mergeData) || {
|
|
3317
|
-
range: {
|
|
3318
|
-
startRow: 0,
|
|
3319
|
-
startColumn: 0,
|
|
3320
|
-
endRow: 0,
|
|
3321
|
-
endColumn: 0
|
|
3322
|
-
},
|
|
3323
|
-
primary: {
|
|
3324
|
-
actualRow: 0,
|
|
3325
|
-
actualColumn: 0,
|
|
3326
|
-
startRow: 0,
|
|
3327
|
-
startColumn: 0,
|
|
3328
|
-
endRow: 0,
|
|
3329
|
-
endColumn: 0,
|
|
3330
|
-
isMerged: !1,
|
|
3331
|
-
isMergedMainCell: !1
|
|
3332
|
-
},
|
|
3333
|
-
style: null
|
|
3334
|
-
};
|
|
3335
|
-
}
|
|
3336
|
-
__name(getTopLeftSelection, "getTopLeftSelection");
|
|
3345
|
+
}, __name(_a5, "SheetsRenderService"), _a5);
|
|
3346
|
+
SheetsRenderService = __decorateClass$R([
|
|
3347
|
+
__decorateParam$R(0, IContextService),
|
|
3348
|
+
__decorateParam$R(1, IUniverInstanceService),
|
|
3349
|
+
__decorateParam$R(2, IRenderManagerService)
|
|
3350
|
+
], SheetsRenderService);
|
|
3337
3351
|
var __defProp$Q = Object.defineProperty, __getOwnPropDesc$Q = Object.getOwnPropertyDescriptor, __decorateClass$Q = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
3338
3352
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$Q(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
3339
3353
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -6740,14 +6754,14 @@ const SetFormatPainterOperation = {
|
|
|
6740
6754
|
if (!selections)
|
|
6741
6755
|
return !1;
|
|
6742
6756
|
const currentSelection = selections[(selections == null ? void 0 : selections.length) - 1], { range } = currentSelection, scrollManagerService = accessor.get(IRenderManagerService).getRenderById(unitId).with(SheetScrollManagerService), { sheetViewStartRow = 0, sheetViewStartColumn = 0 } = scrollManagerService.getCurrentScrollState() || {};
|
|
6743
|
-
let startRow, startColumn,
|
|
6757
|
+
let startRow, startColumn, freezedRowCount, freezedColCount;
|
|
6744
6758
|
const { startRow: selectRow, startColumn: selectColumn, rangeType } = range;
|
|
6745
6759
|
if (rangeType === RANGE_TYPE.ROW || type === 1)
|
|
6746
|
-
startRow = selectRow,
|
|
6760
|
+
startRow = selectRow, freezedRowCount = selectRow - sheetViewStartRow, startColumn = -1, freezedColCount = 0;
|
|
6747
6761
|
else if (rangeType === RANGE_TYPE.COLUMN || type === 2)
|
|
6748
|
-
startRow = -1,
|
|
6762
|
+
startRow = -1, freezedRowCount = 0, startColumn = selectColumn, freezedColCount = selectColumn - sheetViewStartColumn;
|
|
6749
6763
|
else if (rangeType === RANGE_TYPE.NORMAL)
|
|
6750
|
-
startRow = selectRow,
|
|
6764
|
+
startRow = selectRow, freezedRowCount = selectRow - sheetViewStartRow, startColumn = selectColumn, freezedColCount = selectColumn - sheetViewStartColumn;
|
|
6751
6765
|
else
|
|
6752
6766
|
return !1;
|
|
6753
6767
|
const redoMutationParams = {
|
|
@@ -6755,8 +6769,8 @@ const SetFormatPainterOperation = {
|
|
|
6755
6769
|
subUnitId,
|
|
6756
6770
|
startRow,
|
|
6757
6771
|
startColumn,
|
|
6758
|
-
xSplit: startColumn > 0 ? Math.max(1,
|
|
6759
|
-
ySplit: startRow > 0 ? Math.max(1,
|
|
6772
|
+
xSplit: startColumn > 0 ? Math.max(1, freezedColCount) : freezedColCount,
|
|
6773
|
+
ySplit: startRow > 0 ? Math.max(1, freezedRowCount) : freezedRowCount
|
|
6760
6774
|
}, undoMutationParams = SetFrozenMutationFactory(accessor, redoMutationParams);
|
|
6761
6775
|
return commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams) && undoRedoService.pushUndoRedo({
|
|
6762
6776
|
unitID: unitId,
|
|
@@ -8043,7 +8057,7 @@ const ICellEditorManagerService = createIdentifier(
|
|
|
8043
8057
|
},
|
|
8044
8058
|
tableSource: {},
|
|
8045
8059
|
documentStyle: {
|
|
8046
|
-
documentFlavor: DocumentFlavor.
|
|
8060
|
+
documentFlavor: DocumentFlavor.UNSPECIFIED
|
|
8047
8061
|
}
|
|
8048
8062
|
};
|
|
8049
8063
|
return useEffect(() => {
|
|
@@ -8276,7 +8290,7 @@ function FormulaBar() {
|
|
|
8276
8290
|
width: Number.POSITIVE_INFINITY,
|
|
8277
8291
|
height: Number.POSITIVE_INFINITY
|
|
8278
8292
|
},
|
|
8279
|
-
documentFlavor: DocumentFlavor.
|
|
8293
|
+
documentFlavor: DocumentFlavor.UNSPECIFIED,
|
|
8280
8294
|
marginTop: 5,
|
|
8281
8295
|
marginBottom: 5,
|
|
8282
8296
|
marginRight: 0,
|
|
@@ -20879,14 +20893,18 @@ let EditorBridgeRenderController = (_a50 = class extends RxDisposable {
|
|
|
20879
20893
|
* @param d DisposableCollection
|
|
20880
20894
|
*/
|
|
20881
20895
|
_initialKeyboardListener(d) {
|
|
20882
|
-
|
|
20883
|
-
const
|
|
20884
|
-
|
|
20885
|
-
|
|
20886
|
-
|
|
20887
|
-
|
|
20888
|
-
|
|
20889
|
-
|
|
20896
|
+
let disposable = null;
|
|
20897
|
+
const addEvent = /* @__PURE__ */ __name((render22) => {
|
|
20898
|
+
const docSelectionRenderService = render22.with(DocSelectionRenderService);
|
|
20899
|
+
docSelectionRenderService && (disposable = toDisposable(docSelectionRenderService.onInputBefore$.subscribe((config) => {
|
|
20900
|
+
if (!this._isCurrentSheetFocused())
|
|
20901
|
+
return;
|
|
20902
|
+
const isFocusFormulaEditor = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR), isFocusSheets = this._contextService.getContextValue(FOCUSING_SHEET), unitId = render22.unitId;
|
|
20903
|
+
this._editorBridgeService.isVisible().visible || unitId && isFocusSheets && !isFocusFormulaEditor && this._editorService.isSheetEditor(unitId) && this._showEditorByKeyboard(config);
|
|
20904
|
+
})), d.add(disposable));
|
|
20905
|
+
}, "addEvent"), render2 = this._renderManagerService.getRenderById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
|
|
20906
|
+
render2 ? addEvent(render2) : this.disposeWithMe(this._renderManagerService.created$.pipe(filter((render22) => render22.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY)).subscribe((render22) => {
|
|
20907
|
+
disposable == null || disposable.dispose(), addEvent(render22);
|
|
20890
20908
|
}));
|
|
20891
20909
|
}
|
|
20892
20910
|
_commandExecutedListener(d) {
|
|
@@ -21590,7 +21608,7 @@ let SheetRenderController = (_a54 = class extends RxDisposable {
|
|
|
21590
21608
|
}
|
|
21591
21609
|
_markUnitDirty(unitId, command) {
|
|
21592
21610
|
const { mainComponent: spreadsheet, scene } = this._context;
|
|
21593
|
-
if (spreadsheet && spreadsheet.makeDirty(), scene.makeDirty(), !command.params) return;
|
|
21611
|
+
if (command.id === SetFormulaCalculationNotificationMutation.id && command.params.stageInfo != null || (spreadsheet && spreadsheet.makeDirty(), scene.makeDirty(), !command.params)) return;
|
|
21594
21612
|
const cmdParams = command.params, viewports = this._spreadsheetViewports(scene);
|
|
21595
21613
|
if (command.id === SetRangeValuesMutation.id && cmdParams.cellValue) {
|
|
21596
21614
|
const dirtyRange = this._cellValueToRange(cmdParams.cellValue), dirtyBounds = this._rangeToBounds([dirtyRange]);
|
|
@@ -22751,7 +22769,6 @@ let MobileSheetsSelectionRenderService = (_a59 = class extends BaseSelectionRend
|
|
|
22751
22769
|
* new selection control for mobile do one more thing: bind event for two control points.
|
|
22752
22770
|
* @param scene
|
|
22753
22771
|
* @param rangeType
|
|
22754
|
-
* @returns
|
|
22755
22772
|
*/
|
|
22756
22773
|
newSelectionControl(scene, rangeType) {
|
|
22757
22774
|
const selectionControls = this.getSelectionControls(), control = new MobileSelectionControl(scene, selectionControls.length, this._isHeaderHighlight, this._themeService, rangeType);
|