From d75990d059e4ae4b3faea1928c259de812655cab Mon Sep 17 00:00:00 2001 From: gggpound Date: Thu, 12 Sep 2024 21:22:52 +0800 Subject: [PATCH 1/3] style: code lint --- packages/core/src/shared/rectangle.ts | 4 +- packages/sheets-ui/src/index.ts | 180 ++++++------------ .../sheets-ui/src/services/clipboard/utils.ts | 46 ++--- 3 files changed, 80 insertions(+), 150 deletions(-) diff --git a/packages/core/src/shared/rectangle.ts b/packages/core/src/shared/rectangle.ts index 38b87ee8837..2b05d12fd9f 100644 --- a/packages/core/src/shared/rectangle.ts +++ b/packages/core/src/shared/rectangle.ts @@ -227,8 +227,8 @@ export class Rectangle { ...(absoluteRange || {}), startRow: absoluteRange ? ([AbsoluteRefType.ROW, AbsoluteRefType.ALL].includes(absoluteRange.startAbsoluteRefType || 0) ? absoluteRange.startRow : relativeRange.startRow + originRange.startRow) : (relativeRange.startRow + originRange.startRow), endRow: absoluteRange ? ([AbsoluteRefType.ROW, AbsoluteRefType.ALL].includes(absoluteRange.endAbsoluteRefType || 0) ? absoluteRange.endRow : relativeRange.endRow + relativeRange.startRow + originRange.startRow) : (relativeRange.endRow + relativeRange.startRow + originRange.startRow), - startColumn: absoluteRange ? ([AbsoluteRefType.COLUMN, AbsoluteRefType.ALL].includes(absoluteRange.startAbsoluteRefType || 0) ? absoluteRange.startColumn : relativeRange.startColumn + originRange.startColumn) : relativeRange.startColumn + originRange.startColumn, - endColumn: absoluteRange ? ([AbsoluteRefType.COLUMN, AbsoluteRefType.ALL].includes(absoluteRange.endAbsoluteRefType || 0) ? absoluteRange.endColumn : relativeRange.endColumn + relativeRange.startColumn + originRange.startColumn) : relativeRange.endColumn + relativeRange.startColumn + originRange.startColumn, + startColumn: absoluteRange ? ([AbsoluteRefType.COLUMN, AbsoluteRefType.ALL].includes(absoluteRange.startAbsoluteRefType || 0) ? absoluteRange.startColumn : relativeRange.startColumn + originRange.startColumn) : (relativeRange.startColumn + originRange.startColumn), + endColumn: absoluteRange ? ([AbsoluteRefType.COLUMN, AbsoluteRefType.ALL].includes(absoluteRange.endAbsoluteRefType || 0) ? absoluteRange.endColumn : relativeRange.endColumn + relativeRange.startColumn + originRange.startColumn) : (relativeRange.endColumn + relativeRange.startColumn + originRange.startColumn), }) as IRange; }; diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.ts index d4ba6132082..05249faf2c6 100644 --- a/packages/sheets-ui/src/index.ts +++ b/packages/sheets-ui/src/index.ts @@ -14,170 +14,100 @@ * limitations under the License. */ -export { SheetsUIPart } from './consts/ui-name'; -export { SHEET_UI_PLUGIN_NAME } from './consts/plugin-name'; export { getEditorObject } from './basics/editor/get-editor-object'; -export { SheetsScrollRenderController } from './controllers/render-controllers/scroll.render-controller'; -export { deriveStateFromActiveSheet$, getCurrentRangeDisable$, getObservableWithExclusiveRange$, getCurrentExclusiveRangeInterest$ } from './controllers/menu/menu-util'; -export { SheetsRenderService } from './services/sheets-render.service'; -export { getCustomRangePosition, calculateDocSkeletonRects, getEditingCustomRangePosition } from './services/utils/doc-skeleton-util'; export { SHEET_VIEWPORT_KEY as VIEWPORT_KEY } from './common/keys'; +export { SHEET_VIEW_KEY } from './common/keys'; +export { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from './components/font-family/interface'; +export { FONT_SIZE_COMPONENT } from './components/font-size/interface'; +export { useActiveWorkbook, useActiveWorksheet, useWorkbooks } from './components/hook'; +export { SHEET_UI_PLUGIN_NAME } from './consts/plugin-name'; +export { SheetsUIPart } from './consts/ui-name'; export { AutoFillController } from './controllers/auto-fill.controller'; +export { AFFECT_LAYOUT_STYLES, AutoHeightController } from './controllers/auto-height.controller'; export { CellCustomRenderController } from './controllers/cell-custom-render.controller'; -export { SheetUIController } from './controllers/sheet-ui.controller'; +export { DragRenderController } from './controllers/drag-render.controller'; +export { FormulaEditorController } from './controllers/editor/formula-editor.controller'; +export { HoverRenderController } from './controllers/hover-render.controller'; +export { menuSchema } from './controllers/menu.schema'; export { PASTE_SPECIAL_MENU_ID } from './controllers/menu/menu'; +export { SheetMenuPosition } from './controllers/menu/menu'; +export { deriveStateFromActiveSheet$, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getObservableWithExclusiveRange$ } from './controllers/menu/menu-util'; +export { SheetPermissionInitController } from './controllers/permission/sheet-permission-init.controller'; +export { SheetPermissionInterceptorBaseController } from './controllers/permission/sheet-permission-interceptor-base.controller'; +export { HeaderFreezeRenderController } from './controllers/render-controllers/freeze.render-controller'; +export { HeaderMoveRenderController } from './controllers/render-controllers/header-move.render-controller'; +export { HeaderResizeRenderController } from './controllers/render-controllers/header-resize.render-controller'; +export { SheetsScrollRenderController } from './controllers/render-controllers/scroll.render-controller'; +export { SheetRenderController } from './controllers/render-controllers/sheet.render-controller'; +export { SheetUIController } from './controllers/sheet-ui.controller'; export { whenFormulaEditorActivated } from './controllers/shortcuts/utils'; +export { whenSheetEditorFocused } from './controllers/shortcuts/utils'; +export { StatusBarController } from './controllers/status-bar.controller'; export { getCoordByCell, getCoordByOffset, getSheetObject, getTransformCoord, } from './controllers/utils/component-tools'; +export type { IDiscreteRange } from './controllers/utils/range-tools'; +export { rangeToDiscreteRange, virtualizeDiscreteRanges } from './controllers/utils/range-tools'; export { matchedSelectionByRowColIndex as checkInHeaderRanges } from './controllers/utils/selections-tools'; -export { useActiveWorkbook, useActiveWorksheet, useWorkbooks } from './components/hook'; -export { whenSheetEditorFocused } from './controllers/shortcuts/utils'; -export type { IEditorBridgeServiceParam } from './services/editor-bridge.service'; +export { useHighlightRange } from './hooks/useHighlightRange'; +export { UniverSheetsMobileUIPlugin } from './mobile-sheets-ui-plugin'; export { AutoFillService, IAutoFillService } from './services/auto-fill/auto-fill.service'; export { getAutoFillRepeatRange } from './services/auto-fill/tools'; export type { ICopyDataPiece, ISheetAutoFillHook } from './services/auto-fill/type'; export { APPLY_TYPE, DATA_TYPE, type IAutoFillRule } from './services/auto-fill/type'; export { type ICopyDataInTypeIndexInfo } from './services/auto-fill/type'; + +export type { IAutoFillLocation } from './services/auto-fill/type'; +export { type ICanvasPopup, SheetCanvasPopManagerService } from './services/canvas-pop-manager.service'; + +export { CellAlertManagerService, CellAlertType, type ICellAlert } from './services/cell-alert-manager.service'; + +// #region - all commands + export { ISheetClipboardService, PREDEFINED_HOOK_NAME, SheetClipboardService, } from './services/clipboard/clipboard.service'; -export type { ICellDataWithSpanInfo, ISheetClipboardHook, ISheetDiscreteRangeLocation, ICopyPastePayload } from './services/clipboard/type'; +export type { ICellDataWithSpanInfo, ICopyPastePayload, ISheetClipboardHook, ISheetDiscreteRangeLocation } from './services/clipboard/type'; export { COPY_TYPE } from './services/clipboard/type'; export { getRepeatRange } from './services/clipboard/utils'; +export { mergeSetRangeValues } from './services/clipboard/utils'; +export { DragManagerService } from './services/drag-manager.service'; +export { type IDragCellPosition } from './services/drag-manager.service'; export { CellEditorManagerService, ICellEditorManagerService } from './services/editor/cell-editor-manager.service'; export { IFormulaEditorManagerService } from './services/editor/formula-editor-manager.service'; +export type { IEditorBridgeServiceParam } from './services/editor-bridge.service'; export { EditorBridgeService, IEditorBridgeService, type IEditorBridgeServiceVisibleParam, } from './services/editor-bridge.service'; +export { FormatPainterStatus, IFormatPainterService } from './services/format-painter/format-painter.service'; +export type { IFormatPainterBeforeApplyHookParams, IFormatPainterHook } from './services/format-painter/format-painter.service'; +export { HoverManagerService } from './services/hover-manager.service'; +export { type IHoverCellPosition } from './services/hover-manager.service'; export { MarkSelectionService } from './services/mark-selection/mark-selection.service'; export { IMarkSelectionService } from './services/mark-selection/mark-selection.service'; -export { SheetSelectionRenderService } from './services/selection/selection-render.service'; +export { SheetPrintInterceptorService } from './services/print-interceptor.service'; export { getAllSelection, getTopLeftSelection } from './services/selection/base-selection-render.service'; export { BaseSelectionRenderService, ISheetSelectionRenderService } from './services/selection/base-selection-render.service'; + +export { SELECTION_SHAPE_DEPTH } from './services/selection/const'; +export { SheetSelectionRenderService } from './services/selection/selection-render.service'; export { SelectionControl as SelectionShape } from './services/selection/selection-shape'; +export { attachPrimaryWithCoord, attachSelectionWithCoord } from './services/selection/util'; export type { ISheetSkeletonManagerParam } from './services/sheet-skeleton-manager.service'; -export { SheetSkeletonManagerService, attachRangeWithCoord } from './services/sheet-skeleton-manager.service'; +export { attachRangeWithCoord, SheetSkeletonManagerService } from './services/sheet-skeleton-manager.service'; +export { SheetsRenderService } from './services/sheets-render.service'; +export { calculateDocSkeletonRects, getCustomRangePosition, getEditingCustomRangePosition } from './services/utils/doc-skeleton-util'; export { UniverSheetsUIPlugin } from './sheets-ui-plugin'; -export { SheetRenderController } from './controllers/render-controllers/sheet.render-controller'; -export { HoverManagerService } from './services/hover-manager.service'; -export { DragManagerService } from './services/drag-manager.service'; -export { CellAlertManagerService, CellAlertType, type ICellAlert } from './services/cell-alert-manager.service'; -export { HoverRenderController } from './controllers/hover-render.controller'; -export { DragRenderController } from './controllers/drag-render.controller'; -export { SHEET_VIEW_KEY } from './common/keys'; -export { SheetCanvasPopManagerService, type ICanvasPopup } from './services/canvas-pop-manager.service'; -export { mergeSetRangeValues } from './services/clipboard/utils'; -export type { IAutoFillLocation } from './services/auto-fill/type'; -export type { IDiscreteRange } from './controllers/utils/range-tools'; -export { virtualizeDiscreteRanges, rangeToDiscreteRange } from './controllers/utils/range-tools'; -export { type IHoverCellPosition } from './services/hover-manager.service'; -export { AutoHeightController, AFFECT_LAYOUT_STYLES } from './controllers/auto-height.controller'; -export { type IDragCellPosition } from './services/drag-manager.service'; -export { SheetMenuPosition } from './controllers/menu/menu'; -export { useHighlightRange } from './hooks/useHighlightRange'; -export { HeaderMoveRenderController } from './controllers/render-controllers/header-move.render-controller'; -export { HeaderResizeRenderController } from './controllers/render-controllers/header-resize.render-controller'; -export { HeaderFreezeRenderController } from './controllers/render-controllers/freeze.render-controller'; -export { FormulaEditorController } from './controllers/editor/formula-editor.controller'; -export { StatusBarController } from './controllers/status-bar.controller'; -export { SheetPermissionInterceptorBaseController } from './controllers/permission/sheet-permission-interceptor-base.controller'; -export type { IRangeProtectionRenderCellData } from './views/permission/extensions/range-protection.render'; -export { RenderSheetFooter, RenderSheetHeader, RenderSheetContent } from './views/sheet-container/SheetContainer'; -export { SheetBar } from './views/sheet-bar/SheetBar'; -export { SheetPrintInterceptorService } from './services/print-interceptor.service'; -export { UniverSheetsMobileUIPlugin } from './mobile-sheets-ui-plugin'; export { MobileSheetBar } from './views/mobile/sheet-bar/MobileSheetBar'; -export { SheetPermissionInitController } from './controllers/permission/sheet-permission-init.controller'; - -export { IFormatPainterService } from './services/format-painter/format-painter.service'; -export type { IFormatPainterBeforeApplyHookParams, IFormatPainterHook } from './services/format-painter/format-painter.service'; - -export { menuSchema } from './controllers/menu.schema'; - -// #region - all commands - -export { AddWorksheetMergeCommand, AddWorksheetMergeAllCommand, AddWorksheetMergeVerticalCommand, AddWorksheetMergeHorizontalCommand } from './commands/commands/add-worksheet-merge.command'; -export { AutoFillCommand, AutoClearContentCommand } from './commands/commands/auto-fill.command'; -export { - SheetCopyCommand, - SheetCutCommand, - SheetPasteCommand, - SheetPasteValueCommand, - SheetPasteShortKeyCommand, - SheetPasteColWidthCommand, - SheetPasteFormatCommand, - SheetPasteBesidesBorderCommand, - type ISheetPasteParams, -} from './commands/commands/clipboard.command'; -export { DeleteRangeMoveLeftConfirmCommand } from './commands/commands/delete-range-move-left-confirm.command'; -export { DeleteRangeMoveUpConfirmCommand } from './commands/commands/delete-range-move-up-confirm.command'; -export { HideRowConfirmCommand, HideColConfirmCommand } from './commands/commands/hide-row-col-confirm.command'; -export { - SetRangeBoldCommand, - SetRangeItalicCommand, - SetRangeUnderlineCommand, - SetRangeStrickThroughCommand, - SetRangeSubscriptCommand, - SetRangeSuperscriptCommand, - SetRangeFontSizeCommand, - SetRangeFontFamilyCommand, - SetRangeTextColorCommand, -} from './commands/commands/inline-format.command'; -export { InsertRangeMoveDownConfirmCommand } from './commands/commands/insert-range-move-down-confirm.command'; -export { InsertRangeMoveRightConfirmCommand } from './commands/commands/insert-range-move-right-confirm.command'; -export { - AddRangeProtectionFromToolbarCommand, - AddRangeProtectionFromContextMenuCommand, - ViewSheetPermissionFromContextMenuCommand, - AddRangeProtectionFromSheetBarCommand, - ViewSheetPermissionFromSheetBarCommand, - AddRangeProtectionCommand, - DeleteRangeSelectionCommand, - SetRangeProtectionCommand, - DeleteRangeProtectionFromContextMenuCommand, - SetRangeProtectionFromContextMenuCommand, - SetProtectionCommand, -} from './commands/commands/range-protection.command'; -export { RefillCommand } from './commands/commands/refill.command'; -export { RemoveRowConfirmCommand, RemoveColConfirmCommand } from './commands/commands/remove-row-col-confirm.command'; -export { RemoveSheetConfirmCommand } from './commands/commands/remove-sheet-confirm.command'; -export { SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand, ApplyFormatPainterCommand } from './commands/commands/set-format-painter.command'; -export { SetSelectionFrozenCommand, SetRowFrozenCommand, SetColumnFrozenCommand, CancelFrozenCommand } from './commands/commands/set-frozen.command'; -export { - ResetScrollCommand, - ScrollCommand, - ScrollToCellCommand, - SetScrollRelativeCommand, - type IScrollCommandParams, - type IScrollToCellCommandParams, - type ISetScrollRelativeCommandParams, -} from './commands/commands/set-scroll.command'; -export { JumpOver, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, ExpandSelectionCommand, SelectAllCommand } from './commands/commands/set-selection.command'; -export { ChangeZoomRatioCommand, SetZoomRatioCommand } from './commands/commands/set-zoom-ratio.command'; -export { ShowMenuListCommand } from './commands/commands/unhide.command'; -export { AddWorksheetProtectionCommand, DeleteWorksheetProtectionCommand, SetWorksheetProtectionCommand, DeleteWorksheetProtectionFormSheetBarCommand, ChangeSheetProtectionFromSheetBarCommand } from './commands/commands/worksheet-protection.command'; - -export { SetActivateCellEditOperation } from './commands/operations/activate-cell-edit.operation'; -export { SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation, SetCellEditVisibleArrowOperation } from './commands/operations/cell-edit.operation'; -export { RenameSheetOperation } from './commands/operations/rename-sheet.operation'; -export { ScrollToRangeOperation } from './commands/operations/scroll-to-range.operation'; -export { SetScrollOperation } from './commands/operations/scroll.operation'; -export { SetFormatPainterOperation } from './commands/operations/set-format-painter.operation'; -export { SetZoomRatioOperation } from './commands/operations/set-zoom-ratio.operation'; -export { SheetPermissionOpenDialogOperation } from './commands/operations/sheet-permission-open-dialog.operation'; -export { SheetPermissionOpenPanelOperation } from './commands/operations/sheet-permission-open-panel.operation'; -export { SidebarDefinedNameOperation } from './commands/operations/sidebar-defined-name.operation'; +export type { IRangeProtectionRenderCellData } from './views/permission/extensions/range-protection.render'; export { type IBaseSheetBarProps } from './views/sheet-bar/sheet-bar-tabs/SheetBarItem'; -export { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from './components/font-family/interface'; -export { FONT_SIZE_COMPONENT } from './components/font-size/interface'; -export { attachSelectionWithCoord, attachPrimaryWithCoord } from './services/selection/util'; -export { SELECTION_SHAPE_DEPTH } from './services/selection/const'; +export { SheetBar } from './views/sheet-bar/SheetBar'; +export { RenderSheetContent, RenderSheetFooter, RenderSheetHeader } from './views/sheet-container/SheetContainer'; // #endregion diff --git a/packages/sheets-ui/src/services/clipboard/utils.ts b/packages/sheets-ui/src/services/clipboard/utils.ts index 064b50c4a46..b2b03e26f5d 100644 --- a/packages/sheets-ui/src/services/clipboard/utils.ts +++ b/packages/sheets-ui/src/services/clipboard/utils.ts @@ -15,32 +15,32 @@ */ import { ObjectMatrix } from '@univerjs/core'; +import { SetRangeValuesMutation } from '@univerjs/sheets'; import type { ICellData, IMutationInfo, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core'; import type { ISetRangeValuesMutationParams } from '@univerjs/sheets'; -import { SetRangeValuesMutation } from '@univerjs/sheets'; import type { IDiscreteRange } from '../../controllers/utils/range-tools'; /** * * * @param {IRange} sourceRange - * @param {IRange} targetRang + * @param {IRange} targetRange * @param {boolean} [isStrictMode] if is true,the remainder of the row and column must all be 0 to be repeated * @return {*} */ -export const getRepeatRange = (sourceRange: IRange, targetRang: IRange, isStrictMode = false) => { +export const getRepeatRange = (sourceRange: IRange, targetRange: IRange, isStrictMode = false) => { const getRowLength = (range: IRange) => range.endRow - range.startRow + 1; const getColLength = (range: IRange) => range.endColumn - range.startColumn + 1; - const rowMod = getRowLength(targetRang) % getRowLength(sourceRange); - const colMod = getColLength(targetRang) % getColLength(sourceRange); + const rowMod = getRowLength(targetRange) % getRowLength(sourceRange); + const colMod = getColLength(targetRange) % getColLength(sourceRange); const repeatRelativeRange: IRange = { startRow: 0, endRow: getRowLength(sourceRange) - 1, startColumn: 0, endColumn: getColLength(sourceRange) - 1, }; - const repeatRow = Math.floor(getRowLength(targetRang) / getRowLength(sourceRange)); - const repeatCol = Math.floor(getColLength(targetRang) / getColLength(sourceRange)); + const repeatRow = Math.floor(getRowLength(targetRange) / getRowLength(sourceRange)); + const repeatCol = Math.floor(getColLength(targetRange) / getColLength(sourceRange)); const repeatList: Array<{ startRange: IRange; repeatRelativeRange: IRange }> = []; if (!rowMod && !colMod) { for (let countRow = 1; countRow <= repeatRow; countRow++) { @@ -48,10 +48,10 @@ export const getRepeatRange = (sourceRange: IRange, targetRang: IRange, isStrict const row = getRowLength(sourceRange) * (countRow - 1); const col = getColLength(sourceRange) * (countCol - 1); const startRange: IRange = { - startRow: row + targetRang.startRow, - endRow: row + targetRang.startRow, - startColumn: col + targetRang.startColumn, - endColumn: col + targetRang.startColumn, + startRow: row + targetRange.startRow, + endRow: row + targetRange.startRow, + startColumn: col + targetRange.startColumn, + endColumn: col + targetRange.startColumn, }; repeatList.push({ repeatRelativeRange, startRange }); @@ -62,10 +62,10 @@ export const getRepeatRange = (sourceRange: IRange, targetRang: IRange, isStrict const row = getRowLength(sourceRange) * (countRow - 1); const col = 0; const startRange: IRange = { - startRow: row + targetRang.startRow, - endRow: row + targetRang.startRow, - startColumn: col + targetRang.startColumn, - endColumn: col + targetRang.startColumn, + startRow: row + targetRange.startRow, + endRow: row + targetRange.startRow, + startColumn: col + targetRange.startColumn, + endColumn: col + targetRange.startColumn, }; repeatList.push({ repeatRelativeRange, startRange }); @@ -75,20 +75,20 @@ export const getRepeatRange = (sourceRange: IRange, targetRang: IRange, isStrict const row = 0; const col = getColLength(sourceRange) * (countCol - 1); const startRange: IRange = { - startRow: row + targetRang.startRow, - endRow: row + targetRang.startRow, - startColumn: col + targetRang.startColumn, - endColumn: col + targetRang.startColumn, + startRow: row + targetRange.startRow, + endRow: row + targetRange.startRow, + startColumn: col + targetRange.startColumn, + endColumn: col + targetRange.startColumn, }; repeatList.push({ repeatRelativeRange, startRange }); } } else { const startRange: IRange = { - startRow: targetRang.startRow, - endRow: targetRang.startRow, - startColumn: targetRang.startColumn, - endColumn: targetRang.startColumn, + startRow: targetRange.startRow, + endRow: targetRange.startRow, + startColumn: targetRange.startColumn, + endColumn: targetRange.startColumn, }; repeatList.push({ startRange, repeatRelativeRange }); } From 5e29f22e37a796aac1db0aec4875951e39605758 Mon Sep 17 00:00:00 2001 From: gggpound Date: Thu, 12 Sep 2024 21:23:29 +0800 Subject: [PATCH 2/3] feat(conditional-formatting): support formatting painter --- .../src/controllers/cf.painter.controller.ts | 310 ++++++++++++++++++ .../src/plugin.ts | 22 +- 2 files changed, 322 insertions(+), 10 deletions(-) create mode 100644 packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts new file mode 100644 index 00000000000..6c34f1b8065 --- /dev/null +++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts @@ -0,0 +1,310 @@ +/** + * Copyright 2023-present DreamNum Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Disposable, Inject, Injector, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle, Range, Rectangle, Tools, UniverInstanceType } from '@univerjs/core'; +import { createTopMatrixFromMatrix, findAllRectangle, SheetsSelectionsService } from '@univerjs/sheets'; +import { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, ConditionalFormattingRuleModel, ConditionalFormattingViewModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN } from '@univerjs/sheets-conditional-formatting'; +import { FormatPainterStatus, IFormatPainterService } from '@univerjs/sheets-ui'; +import type { IMutationInfo, IRange, Nullable, Workbook } from '@univerjs/core'; +import type { IAddConditionalRuleMutationParams, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting'; +import type { IFormatPainterHook } from '@univerjs/sheets-ui'; + +const repeatByRange = (sourceRange: IRange, targetRange: IRange) => { + const getRowLength = (range: IRange) => range.endRow - range.startRow + 1; + const getColLength = (range: IRange) => range.endColumn - range.startColumn + 1; + const rowMod = getRowLength(targetRange) % getRowLength(sourceRange); + const colMod = getColLength(targetRange) % getColLength(sourceRange); + const repeatRow = Math.floor(getRowLength(targetRange) / getRowLength(sourceRange)); + const repeatCol = Math.floor(getColLength(targetRange) / getColLength(sourceRange)); + const repeatList: Array<{ startRange: IRange; repeatRelativeRange: IRange }> = []; + const repeatRelativeRange: IRange = { + startRow: 0, + endRow: getRowLength(sourceRange) - 1, + startColumn: 0, + endColumn: getColLength(sourceRange) - 1, + }; + + for (let countRow = 0; countRow < (repeatRow + (rowMod ? 0.1 : 0)); countRow++) { + for (let countCol = 0; countCol < (repeatCol + (colMod ? 0.1 : 0)); countCol++) { + const row = getRowLength(sourceRange) * (countRow); + const col = getColLength(sourceRange) * (countCol); + const startRange: IRange = { + startRow: row + targetRange.startRow, + endRow: row + targetRange.startRow, + startColumn: col + targetRange.startColumn, + endColumn: col + targetRange.startColumn, + }; + let _repeatRelativeRange = repeatRelativeRange; + if (countRow === repeatRow && rowMod) { + _repeatRelativeRange = { ..._repeatRelativeRange }; + _repeatRelativeRange.endRow = _repeatRelativeRange.endRow - (getRowLength(sourceRange) - rowMod); + } + if (countCol === repeatCol && colMod) { + _repeatRelativeRange = { ..._repeatRelativeRange }; + _repeatRelativeRange.endColumn = _repeatRelativeRange.endColumn - (getColLength(sourceRange) - colMod); + } + repeatList.push({ repeatRelativeRange: _repeatRelativeRange, startRange }); + } + } + return repeatList; +}; + +@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingPainterController) +export class ConditionalFormattingPainterController extends Disposable { + private _painterConfig: Nullable<{ unitId: string; subUnitId: string; range: IRange }> = null; + constructor( + @Inject(Injector) private _injector: Injector, + @Inject(IUniverInstanceService) private _univerInstanceService: IUniverInstanceService, + @Inject(IFormatPainterService) private _formatPainterService: IFormatPainterService, + @Inject(SheetsSelectionsService) private _sheetsSelectionsService: SheetsSelectionsService, + @Inject(ConditionalFormattingRuleModel) private _conditionalFormattingRuleModel: ConditionalFormattingRuleModel, + + @Inject(ConditionalFormattingViewModel) private _conditionalFormattingViewModel: ConditionalFormattingViewModel + + ) { + super(); + + this._initFormattingPainter(); + } + + // eslint-disable-next-line max-lines-per-function + private _initFormattingPainter() { + const noopReturnFunc = () => ({ redos: [], undos: [] }); + // eslint-disable-next-line max-lines-per-function + const loopFunc = ( + sourceStartCell: { row: number; col: number }, + targetStartCell: { row: number; col: number }, + relativeRange: IRange, + matrixMap: Map>, + config: { + targetUnitId: string; + targetSubUnitId: string; + } + ) => { + const { unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig!; + const { targetUnitId, targetSubUnitId } = config; + + const sourceRange = { + startRow: sourceStartCell.row, + startColumn: sourceStartCell.col, + endColumn: sourceStartCell.col, + endRow: sourceStartCell.row, + }; + const targetRange = { + startRow: targetStartCell.row, + startColumn: targetStartCell.col, + endColumn: targetStartCell.col, + endRow: targetStartCell.row, + }; + + Range.foreach(relativeRange, (row, col) => { + const sourcePositionRange = Rectangle.getPositionRange( + { + startRow: row, + startColumn: col, + endColumn: col, + endRow: row, + }, + sourceRange + ); + const targetPositionRange = Rectangle.getPositionRange( + { + startRow: row, + startColumn: col, + endColumn: col, + endRow: row, + }, + targetRange + ); + + const sourceCellCf = this._conditionalFormattingViewModel.getCellCf( + sourceUnitId, + sourceSubUnitId, + sourcePositionRange.startRow, + sourcePositionRange.startColumn + ); + + const targetCellCf = this._conditionalFormattingViewModel.getCellCf( + targetUnitId, + targetSubUnitId, + targetPositionRange.startRow, + targetPositionRange.startColumn + ); + + if (targetCellCf) { + targetCellCf.cfList.forEach((cf) => { + let matrix = matrixMap.get(cf.cfId); + if (!matrixMap.get(cf.cfId)) { + const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cf.cfId); + if (!rule) { + return; + } + matrix = new ObjectMatrix(); + rule.ranges.forEach((range) => { + Range.foreach(range, (row, col) => { + matrix!.setValue(row, col, 1); + }); + }); + matrixMap.set(cf.cfId, matrix); + } + matrix!.realDeleteValue(targetPositionRange.startRow, targetPositionRange.startColumn); + }); + } + + if (sourceCellCf) { + sourceCellCf.cfList.forEach((cf) => { + const matrix = matrixMap.get(cf.cfId); + matrix && matrix.setValue(targetPositionRange.startRow, targetPositionRange.startColumn, 1); + }); + } + }); + }; + + const generalApplyFunc = (targetUnitId: string, targetSubUnitId: string, targetRange: IRange) => { + const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig!; + const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId; + const matrixMap: Map> = new Map(); + + const redos: IMutationInfo[] = []; + const undos: IMutationInfo[] = []; + if (!targetUnitId || !targetSubUnitId || !sourceUnitId || !sourceSubUnitId) { + return noopReturnFunc(); + } + const ruleList = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId) ?? []; + ruleList?.forEach((rule) => { + const { ranges, cfId } = rule; + if (ranges.some((range) => Rectangle.intersects(sourceRange, range))) { + const matrix = new ObjectMatrix<1>(); + if (!isSkipSheet) { + ranges.forEach((range) => { + Range.foreach(range, (row, col) => { + matrix.setValue(row, col, 1); + }); + }); + } + matrixMap.set(cfId, matrix); + } + }); + + const sourceStartCell = { + row: sourceRange.startRow, + col: sourceRange.startColumn, + }; + + const repeats = repeatByRange(sourceRange, targetRange); + + repeats.forEach((repeat) => { + loopFunc(sourceStartCell, { row: repeat.startRange.startRow, col: repeat.startRange.startColumn }, repeat.repeatRelativeRange, matrixMap, { targetUnitId, targetSubUnitId }); + }); + + matrixMap.forEach((item, cfId) => { + if (!isSkipSheet) { + const rule = this._conditionalFormattingRuleModel.getRule(sourceUnitId, sourceSubUnitId, cfId); + if (!rule) { + return; + } + const ranges = findAllRectangle(createTopMatrixFromMatrix(item)); + if (ranges.length) { + const params: ISetConditionalRuleMutationParams = { + unitId: sourceUnitId, subUnitId: sourceSubUnitId, rule: { ...rule, ranges }, + }; + redos.push({ id: SetConditionalRuleMutation.id, params }); + undos.push(...setConditionalRuleMutationUndoFactory(this._injector, params)); + } else { + const params: IDeleteConditionalRuleMutationParams = { + unitId: sourceUnitId, subUnitId: sourceSubUnitId, cfId: rule.cfId, + }; + redos.push({ id: DeleteConditionalRuleMutation.id, params }); + undos.push(...DeleteConditionalRuleMutationUndoFactory(this._injector, params)); + } + } else { + const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cfId); + const ranges = findAllRectangle(createTopMatrixFromMatrix(item)); + if (!rule) { + if (ranges.length) { + const sourceRule = this._conditionalFormattingRuleModel.getRule(sourceUnitId, sourceSubUnitId, cfId); + if (sourceRule) { + const params: IAddConditionalRuleMutationParams = { + unitId: targetUnitId, + subUnitId: targetSubUnitId, + rule: { + ...Tools.deepClone(sourceRule), + cfId: this._conditionalFormattingRuleModel.createCfId(targetUnitId, targetSubUnitId), + ranges, + }, + }; + redos.push({ id: AddConditionalRuleMutation.id, params }); + undos.push(AddConditionalRuleMutationUndoFactory(this._injector, params)); + } + } + } else { + if (ranges.length) { + const params: ISetConditionalRuleMutationParams = { + unitId: targetUnitId, subUnitId: targetSubUnitId, rule: { ...rule, ranges }, + }; + redos.push({ id: SetConditionalRuleMutation.id, params }); + undos.push(...setConditionalRuleMutationUndoFactory(this._injector, params)); + } else { + const params: IDeleteConditionalRuleMutationParams = { + unitId: targetUnitId, subUnitId: targetSubUnitId, cfId: rule.cfId, + }; + redos.push({ id: DeleteConditionalRuleMutation.id, params }); + undos.push(...DeleteConditionalRuleMutationUndoFactory(this._injector, params)); + } + } + } + }); + return { + undos, + redos, + }; + }; + + const hook: IFormatPainterHook = { + id: SHEET_CONDITIONAL_FORMATTING_PLUGIN, + onStatusChange: (status) => { + switch (status) { + case FormatPainterStatus.INFINITE: + case FormatPainterStatus.ONCE: { + const unitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)?.getUnitId(); + const subUnitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)?.getActiveSheet()?.getSheetId(); + const selection = this._sheetsSelectionsService.getCurrentLastSelection(); + const range = selection?.range; + if (unitId && subUnitId && range) { + this._painterConfig = { unitId, subUnitId, range }; + } + break; + } + case FormatPainterStatus.OFF: { + this._painterConfig = null; + break; + } + } + }, + onApply: (unitId, subUnitId, targetRange) => { + if (this._painterConfig) { + return generalApplyFunc(unitId, subUnitId, targetRange); + } + return { + redos: [], + undos: [], + }; + }, + }; + + this._formatPainterService.addHook(hook); + } +} diff --git a/packages/sheets-conditional-formatting-ui/src/plugin.ts b/packages/sheets-conditional-formatting-ui/src/plugin.ts index b03572f5cb8..39e350bb271 100644 --- a/packages/sheets-conditional-formatting-ui/src/plugin.ts +++ b/packages/sheets-conditional-formatting-ui/src/plugin.ts @@ -25,6 +25,7 @@ import { } from '@univerjs/core'; import { SHEET_CONDITIONAL_FORMATTING_PLUGIN, UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting'; import { AddAverageCfCommand } from './commands/commands/add-average-cf.command'; +import { AddCfCommand } from './commands/commands/add-cf.command'; import { AddColorScaleConditionalRuleCommand } from './commands/commands/add-color-scale-cf.command'; import { AddDataBarConditionalRuleCommand } from './commands/commands/add-data-bar-cf.command'; import { AddDuplicateValuesCfCommand } from './commands/commands/add-duplicate-values-cf.command'; @@ -35,24 +36,24 @@ import { AddTimePeriodCfCommand } from './commands/commands/add-time-period-cf.c import { AddUniqueValuesCfCommand } from './commands/commands/add-unique-values-cf.command'; import { ClearRangeCfCommand } from './commands/commands/clear-range-cf.command'; import { ClearWorksheetCfCommand } from './commands/commands/clear-worksheet-cf.command'; -import { OpenConditionalFormattingOperator } from './commands/operations/open-conditional-formatting-panel'; import { DeleteCfCommand } from './commands/commands/delete-cf.command'; -import { SetCfCommand } from './commands/commands/set-cf.command'; import { MoveCfCommand } from './commands/commands/move-cf.command'; -import { AddCfCommand } from './commands/commands/add-cf.command'; +import { SetCfCommand } from './commands/commands/set-cf.command'; +import { OpenConditionalFormattingOperator } from './commands/operations/open-conditional-formatting-panel'; -import { SheetsCfRenderController } from './controllers/cf.render.controller'; -import { ConditionalFormattingCopyPasteController } from './controllers/cf.copy-paste.controller'; import { ConditionalFormattingAutoFillController } from './controllers/cf.auto-fill.controller'; +import { ConditionalFormattingClearController } from './controllers/cf.clear.controller'; +import { ConditionalFormattingCopyPasteController } from './controllers/cf.copy-paste.controller'; +import { ConditionalFormattingEditorController } from './controllers/cf.editor.controller'; +import { ConditionalFormattingI18nController } from './controllers/cf.i18n.controller'; import { ConditionalFormattingMenuController } from './controllers/cf.menu.controller'; +import { ConditionalFormattingPainterController } from './controllers/cf.painter.controller'; import { ConditionalFormattingPanelController } from './controllers/cf.panel.controller'; -import { ConditionalFormattingI18nController } from './controllers/cf.i18n.controller'; -import { SheetsCfRefRangeController } from './controllers/cf.ref-range.controller'; -import { ConditionalFormattingEditorController } from './controllers/cf.editor.controller'; -import { ConditionalFormattingClearController } from './controllers/cf.clear.controller'; import { ConditionalFormattingPermissionController } from './controllers/cf.permission.controller'; -import type { IUniverSheetsConditionalFormattingUIConfig } from './controllers/config.schema'; +import { SheetsCfRefRangeController } from './controllers/cf.ref-range.controller'; +import { SheetsCfRenderController } from './controllers/cf.render.controller'; import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema'; +import type { IUniverSheetsConditionalFormattingUIConfig } from './controllers/config.schema'; @DependentOn(UniverSheetsConditionalFormattingPlugin) export class UniverSheetsConditionalFormattingUIPlugin extends Plugin { @@ -86,6 +87,7 @@ export class UniverSheetsConditionalFormattingUIPlugin extends Plugin { this._injector.add([ConditionalFormattingI18nController]); this._injector.add([ConditionalFormattingEditorController]); this._injector.add([ConditionalFormattingClearController]); + this._injector.add([ConditionalFormattingPainterController]); } private _initCommand() { From 1c5c49532ef402b243b7c9fa7ab106747cba97f4 Mon Sep 17 00:00:00 2001 From: gggpound Date: Fri, 13 Sep 2024 15:03:10 +0800 Subject: [PATCH 3/3] fix(conditional-formatting): support single cell painter --- .../src/controllers/cf.painter.controller.ts | 13 +- packages/sheets-ui/src/index.ts | 177 ++++++++++++------ 2 files changed, 136 insertions(+), 54 deletions(-) diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts index 6c34f1b8065..57045fb29b7 100644 --- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts +++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts @@ -36,6 +36,17 @@ const repeatByRange = (sourceRange: IRange, targetRange: IRange) => { startColumn: 0, endColumn: getColLength(sourceRange) - 1, }; + // If the target area is a single cell, copy the entire source area. + if (getRowLength(targetRange) === 1 && getColLength(targetRange) === 1) { + const startRange: IRange = { + startRow: targetRange.startRow, + endRow: targetRange.startRow, + startColumn: targetRange.startColumn, + endColumn: targetRange.startColumn, + }; + repeatList.push({ repeatRelativeRange, startRange }); + return repeatList; + } for (let countRow = 0; countRow < (repeatRow + (rowMod ? 0.1 : 0)); countRow++) { for (let countCol = 0; countCol < (repeatCol + (colMod ? 0.1 : 0)); countCol++) { @@ -172,7 +183,7 @@ export class ConditionalFormattingPainterController extends Disposable { } }); }; - + // eslint-disable-next-line max-lines-per-function const generalApplyFunc = (targetUnitId: string, targetSubUnitId: string, targetRange: IRange) => { const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig!; const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId; diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.ts index 05249faf2c6..b1e95633a82 100644 --- a/packages/sheets-ui/src/index.ts +++ b/packages/sheets-ui/src/index.ts @@ -14,59 +14,36 @@ * limitations under the License. */ +/* eslint-disable perfectionist/sort-exports */ + +export { SheetsUIPart } from './consts/ui-name'; +export { SHEET_UI_PLUGIN_NAME } from './consts/plugin-name'; export { getEditorObject } from './basics/editor/get-editor-object'; +export { SheetsScrollRenderController } from './controllers/render-controllers/scroll.render-controller'; +export { deriveStateFromActiveSheet$, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getObservableWithExclusiveRange$ } from './controllers/menu/menu-util'; +export { SheetsRenderService } from './services/sheets-render.service'; +export { calculateDocSkeletonRects, getCustomRangePosition, getEditingCustomRangePosition } from './services/utils/doc-skeleton-util'; export { SHEET_VIEWPORT_KEY as VIEWPORT_KEY } from './common/keys'; -export { SHEET_VIEW_KEY } from './common/keys'; -export { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from './components/font-family/interface'; -export { FONT_SIZE_COMPONENT } from './components/font-size/interface'; -export { useActiveWorkbook, useActiveWorksheet, useWorkbooks } from './components/hook'; -export { SHEET_UI_PLUGIN_NAME } from './consts/plugin-name'; -export { SheetsUIPart } from './consts/ui-name'; export { AutoFillController } from './controllers/auto-fill.controller'; -export { AFFECT_LAYOUT_STYLES, AutoHeightController } from './controllers/auto-height.controller'; export { CellCustomRenderController } from './controllers/cell-custom-render.controller'; -export { DragRenderController } from './controllers/drag-render.controller'; -export { FormulaEditorController } from './controllers/editor/formula-editor.controller'; -export { HoverRenderController } from './controllers/hover-render.controller'; -export { menuSchema } from './controllers/menu.schema'; -export { PASTE_SPECIAL_MENU_ID } from './controllers/menu/menu'; -export { SheetMenuPosition } from './controllers/menu/menu'; -export { deriveStateFromActiveSheet$, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getObservableWithExclusiveRange$ } from './controllers/menu/menu-util'; -export { SheetPermissionInitController } from './controllers/permission/sheet-permission-init.controller'; -export { SheetPermissionInterceptorBaseController } from './controllers/permission/sheet-permission-interceptor-base.controller'; -export { HeaderFreezeRenderController } from './controllers/render-controllers/freeze.render-controller'; -export { HeaderMoveRenderController } from './controllers/render-controllers/header-move.render-controller'; -export { HeaderResizeRenderController } from './controllers/render-controllers/header-resize.render-controller'; -export { SheetsScrollRenderController } from './controllers/render-controllers/scroll.render-controller'; -export { SheetRenderController } from './controllers/render-controllers/sheet.render-controller'; export { SheetUIController } from './controllers/sheet-ui.controller'; +export { PASTE_SPECIAL_MENU_ID } from './controllers/menu/menu'; export { whenFormulaEditorActivated } from './controllers/shortcuts/utils'; -export { whenSheetEditorFocused } from './controllers/shortcuts/utils'; -export { StatusBarController } from './controllers/status-bar.controller'; export { getCoordByCell, getCoordByOffset, getSheetObject, getTransformCoord, } from './controllers/utils/component-tools'; -export type { IDiscreteRange } from './controllers/utils/range-tools'; -export { rangeToDiscreteRange, virtualizeDiscreteRanges } from './controllers/utils/range-tools'; export { matchedSelectionByRowColIndex as checkInHeaderRanges } from './controllers/utils/selections-tools'; -export { useHighlightRange } from './hooks/useHighlightRange'; -export { UniverSheetsMobileUIPlugin } from './mobile-sheets-ui-plugin'; +export { useActiveWorkbook, useActiveWorksheet, useWorkbooks } from './components/hook'; +export { whenSheetEditorFocused } from './controllers/shortcuts/utils'; +export type { IEditorBridgeServiceParam } from './services/editor-bridge.service'; export { AutoFillService, IAutoFillService } from './services/auto-fill/auto-fill.service'; export { getAutoFillRepeatRange } from './services/auto-fill/tools'; export type { ICopyDataPiece, ISheetAutoFillHook } from './services/auto-fill/type'; export { APPLY_TYPE, DATA_TYPE, type IAutoFillRule } from './services/auto-fill/type'; export { type ICopyDataInTypeIndexInfo } from './services/auto-fill/type'; - -export type { IAutoFillLocation } from './services/auto-fill/type'; -export { type ICanvasPopup, SheetCanvasPopManagerService } from './services/canvas-pop-manager.service'; - -export { CellAlertManagerService, CellAlertType, type ICellAlert } from './services/cell-alert-manager.service'; - -// #region - all commands - export { ISheetClipboardService, PREDEFINED_HOOK_NAME, @@ -75,39 +52,133 @@ export { export type { ICellDataWithSpanInfo, ICopyPastePayload, ISheetClipboardHook, ISheetDiscreteRangeLocation } from './services/clipboard/type'; export { COPY_TYPE } from './services/clipboard/type'; export { getRepeatRange } from './services/clipboard/utils'; -export { mergeSetRangeValues } from './services/clipboard/utils'; -export { DragManagerService } from './services/drag-manager.service'; -export { type IDragCellPosition } from './services/drag-manager.service'; export { CellEditorManagerService, ICellEditorManagerService } from './services/editor/cell-editor-manager.service'; export { IFormulaEditorManagerService } from './services/editor/formula-editor-manager.service'; -export type { IEditorBridgeServiceParam } from './services/editor-bridge.service'; export { EditorBridgeService, IEditorBridgeService, type IEditorBridgeServiceVisibleParam, } from './services/editor-bridge.service'; -export { FormatPainterStatus, IFormatPainterService } from './services/format-painter/format-painter.service'; -export type { IFormatPainterBeforeApplyHookParams, IFormatPainterHook } from './services/format-painter/format-painter.service'; -export { HoverManagerService } from './services/hover-manager.service'; -export { type IHoverCellPosition } from './services/hover-manager.service'; export { MarkSelectionService } from './services/mark-selection/mark-selection.service'; export { IMarkSelectionService } from './services/mark-selection/mark-selection.service'; -export { SheetPrintInterceptorService } from './services/print-interceptor.service'; +export { SheetSelectionRenderService } from './services/selection/selection-render.service'; export { getAllSelection, getTopLeftSelection } from './services/selection/base-selection-render.service'; export { BaseSelectionRenderService, ISheetSelectionRenderService } from './services/selection/base-selection-render.service'; - -export { SELECTION_SHAPE_DEPTH } from './services/selection/const'; -export { SheetSelectionRenderService } from './services/selection/selection-render.service'; export { SelectionControl as SelectionShape } from './services/selection/selection-shape'; -export { attachPrimaryWithCoord, attachSelectionWithCoord } from './services/selection/util'; export type { ISheetSkeletonManagerParam } from './services/sheet-skeleton-manager.service'; export { attachRangeWithCoord, SheetSkeletonManagerService } from './services/sheet-skeleton-manager.service'; -export { SheetsRenderService } from './services/sheets-render.service'; -export { calculateDocSkeletonRects, getCustomRangePosition, getEditingCustomRangePosition } from './services/utils/doc-skeleton-util'; export { UniverSheetsUIPlugin } from './sheets-ui-plugin'; -export { MobileSheetBar } from './views/mobile/sheet-bar/MobileSheetBar'; +export { SheetRenderController } from './controllers/render-controllers/sheet.render-controller'; +export { HoverManagerService } from './services/hover-manager.service'; +export { DragManagerService } from './services/drag-manager.service'; +export { CellAlertManagerService, CellAlertType, type ICellAlert } from './services/cell-alert-manager.service'; +export { HoverRenderController } from './controllers/hover-render.controller'; +export { DragRenderController } from './controllers/drag-render.controller'; +export { SHEET_VIEW_KEY } from './common/keys'; +export { type ICanvasPopup, SheetCanvasPopManagerService } from './services/canvas-pop-manager.service'; +export { mergeSetRangeValues } from './services/clipboard/utils'; +export type { IAutoFillLocation } from './services/auto-fill/type'; +export type { IDiscreteRange } from './controllers/utils/range-tools'; +export { rangeToDiscreteRange, virtualizeDiscreteRanges } from './controllers/utils/range-tools'; +export { type IHoverCellPosition } from './services/hover-manager.service'; +export { AFFECT_LAYOUT_STYLES, AutoHeightController } from './controllers/auto-height.controller'; +export { type IDragCellPosition } from './services/drag-manager.service'; +export { SheetMenuPosition } from './controllers/menu/menu'; +export { useHighlightRange } from './hooks/useHighlightRange'; +export { HeaderMoveRenderController } from './controllers/render-controllers/header-move.render-controller'; +export { HeaderResizeRenderController } from './controllers/render-controllers/header-resize.render-controller'; +export { HeaderFreezeRenderController } from './controllers/render-controllers/freeze.render-controller'; +export { FormulaEditorController } from './controllers/editor/formula-editor.controller'; +export { StatusBarController } from './controllers/status-bar.controller'; +export { SheetPermissionInterceptorBaseController } from './controllers/permission/sheet-permission-interceptor-base.controller'; export type { IRangeProtectionRenderCellData } from './views/permission/extensions/range-protection.render'; -export { type IBaseSheetBarProps } from './views/sheet-bar/sheet-bar-tabs/SheetBarItem'; -export { SheetBar } from './views/sheet-bar/SheetBar'; export { RenderSheetContent, RenderSheetFooter, RenderSheetHeader } from './views/sheet-container/SheetContainer'; +export { SheetBar } from './views/sheet-bar/SheetBar'; +export { SheetPrintInterceptorService } from './services/print-interceptor.service'; +export { UniverSheetsMobileUIPlugin } from './mobile-sheets-ui-plugin'; +export { MobileSheetBar } from './views/mobile/sheet-bar/MobileSheetBar'; +export { SheetPermissionInitController } from './controllers/permission/sheet-permission-init.controller'; + +export { FormatPainterStatus, IFormatPainterService } from './services/format-painter/format-painter.service'; +export type { IFormatPainterBeforeApplyHookParams, IFormatPainterHook } from './services/format-painter/format-painter.service'; + +export { menuSchema } from './controllers/menu.schema'; + +// #region - all commands +export { AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeVerticalCommand } from './commands/commands/add-worksheet-merge.command'; +export { AutoClearContentCommand, AutoFillCommand } from './commands/commands/auto-fill.command'; +export { + type ISheetPasteParams, + SheetCopyCommand, + SheetCutCommand, + SheetPasteBesidesBorderCommand, + SheetPasteColWidthCommand, + SheetPasteCommand, + SheetPasteFormatCommand, + SheetPasteShortKeyCommand, + SheetPasteValueCommand, +} from './commands/commands/clipboard.command'; +export { DeleteRangeMoveLeftConfirmCommand } from './commands/commands/delete-range-move-left-confirm.command'; +export { DeleteRangeMoveUpConfirmCommand } from './commands/commands/delete-range-move-up-confirm.command'; +export { HideColConfirmCommand, HideRowConfirmCommand } from './commands/commands/hide-row-col-confirm.command'; +export { + SetRangeBoldCommand, + SetRangeFontFamilyCommand, + SetRangeFontSizeCommand, + SetRangeItalicCommand, + SetRangeStrickThroughCommand, + SetRangeSubscriptCommand, + SetRangeSuperscriptCommand, + SetRangeTextColorCommand, + SetRangeUnderlineCommand, +} from './commands/commands/inline-format.command'; +export { InsertRangeMoveDownConfirmCommand } from './commands/commands/insert-range-move-down-confirm.command'; +export { InsertRangeMoveRightConfirmCommand } from './commands/commands/insert-range-move-right-confirm.command'; +export { + AddRangeProtectionCommand, + AddRangeProtectionFromContextMenuCommand, + AddRangeProtectionFromSheetBarCommand, + AddRangeProtectionFromToolbarCommand, + DeleteRangeProtectionFromContextMenuCommand, + DeleteRangeSelectionCommand, + SetProtectionCommand, + SetRangeProtectionCommand, + SetRangeProtectionFromContextMenuCommand, + ViewSheetPermissionFromContextMenuCommand, + ViewSheetPermissionFromSheetBarCommand, +} from './commands/commands/range-protection.command'; +export { RefillCommand } from './commands/commands/refill.command'; +export { RemoveColConfirmCommand, RemoveRowConfirmCommand } from './commands/commands/remove-row-col-confirm.command'; +export { RemoveSheetConfirmCommand } from './commands/commands/remove-sheet-confirm.command'; +export { ApplyFormatPainterCommand, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand } from './commands/commands/set-format-painter.command'; +export { CancelFrozenCommand, SetColumnFrozenCommand, SetRowFrozenCommand, SetSelectionFrozenCommand } from './commands/commands/set-frozen.command'; +export { + type IScrollCommandParams, + type IScrollToCellCommandParams, + type ISetScrollRelativeCommandParams, + ResetScrollCommand, + ScrollCommand, + ScrollToCellCommand, + SetScrollRelativeCommand, +} from './commands/commands/set-scroll.command'; +export { ExpandSelectionCommand, JumpOver, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, SelectAllCommand } from './commands/commands/set-selection.command'; +export { ChangeZoomRatioCommand, SetZoomRatioCommand } from './commands/commands/set-zoom-ratio.command'; +export { ShowMenuListCommand } from './commands/commands/unhide.command'; +export { AddWorksheetProtectionCommand, ChangeSheetProtectionFromSheetBarCommand, DeleteWorksheetProtectionCommand, DeleteWorksheetProtectionFormSheetBarCommand, SetWorksheetProtectionCommand } from './commands/commands/worksheet-protection.command'; + +export { SetActivateCellEditOperation } from './commands/operations/activate-cell-edit.operation'; +export { SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation } from './commands/operations/cell-edit.operation'; +export { RenameSheetOperation } from './commands/operations/rename-sheet.operation'; +export { ScrollToRangeOperation } from './commands/operations/scroll-to-range.operation'; +export { SetScrollOperation } from './commands/operations/scroll.operation'; +export { SetFormatPainterOperation } from './commands/operations/set-format-painter.operation'; +export { SetZoomRatioOperation } from './commands/operations/set-zoom-ratio.operation'; +export { SheetPermissionOpenDialogOperation } from './commands/operations/sheet-permission-open-dialog.operation'; +export { SheetPermissionOpenPanelOperation } from './commands/operations/sheet-permission-open-panel.operation'; +export { SidebarDefinedNameOperation } from './commands/operations/sidebar-defined-name.operation'; +export { type IBaseSheetBarProps } from './views/sheet-bar/sheet-bar-tabs/SheetBarItem'; +export { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from './components/font-family/interface'; +export { FONT_SIZE_COMPONENT } from './components/font-size/interface'; +export { attachPrimaryWithCoord, attachSelectionWithCoord } from './services/selection/util'; +export { SELECTION_SHAPE_DEPTH } from './services/selection/const'; // #endregion