Skip to content

Commit

Permalink
fix(conditional-formatting): support single cell painter
Browse files Browse the repository at this point in the history
  • Loading branch information
Gggpound committed Sep 13, 2024
1 parent 5e29f22 commit 4505bf3
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
Expand Down
180 changes: 125 additions & 55 deletions packages/sheets-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,100 +14,170 @@
* 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 { 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,
SheetClipboardService,
} from './services/clipboard/clipboard.service';
export type { ICellDataWithSpanInfo, ICopyPastePayload, ISheetClipboardHook, ISheetDiscreteRangeLocation } from './services/clipboard/type';
export type { ICellDataWithSpanInfo, ISheetClipboardHook, ISheetDiscreteRangeLocation, ICopyPastePayload } 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 { SheetSkeletonManagerService, attachRangeWithCoord } from './services/sheet-skeleton-manager.service';
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 { 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 { type IBaseSheetBarProps } from './views/sheet-bar/sheet-bar-tabs/SheetBarItem';
export { RenderSheetFooter, RenderSheetHeader, RenderSheetContent } from './views/sheet-container/SheetContainer';
export { SheetBar } from './views/sheet-bar/SheetBar';
export { RenderSheetContent, RenderSheetFooter, RenderSheetHeader } from './views/sheet-container/SheetContainer';
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, FormatPainterStatus } 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 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';
// #endregion

0 comments on commit 4505bf3

Please sign in to comment.