Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(numfmt): support copy paste (#655)
Gpound.liu7b5ae36ee8d9
diff --git a/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.ts b/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.tsindex 73de71f40e..7f326c3845 100644--- a/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.ts+++ b/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.ts@@ -7,7 +7,6 @@ import { DialogOperation } from '../commands/operations/dialog.operation';import { LocaleOperation } from '../commands/operations/locale.operation';import { MessageOperation } from '../commands/operations/message.operation';import { NotificationOperation } from '../commands/operations/notification.operation';-import { NumfmtOperation } from '../commands/operations/numfmt.operations';import { SetEditable } from '../commands/operations/set.editable.operation';import { SidebarOperation } from '../commands/operations/sidebar.operation';import { ThemeOperation } from '../commands/operations/theme.operation';@@ -17,7 +16,6 @@ import {LocaleMenuItemFactory,MessageMenuItemFactory,NotificationMenuItemFactory,- NumfmtMenuItemFactory,SetEditableMenuItemFactory,SidebarMenuItemFactory,ThemeMenuItemFactory,@@ -41,7 +39,6 @@ export class DebuggerController extends Disposable {MessageOperation,SidebarOperation,SetEditable,- NumfmtOperation,].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));}@@ -51,7 +48,6 @@ export class DebuggerController extends Disposable {ThemeMenuItemFactory,NotificationMenuItemFactory,MessageMenuItemFactory,- NumfmtMenuItemFactory,DialogMenuItemFactory,ConfirmMenuItemFactory,SidebarMenuItemFactory,diff --git a/examples/sheets/src/sheets-plugin-debugger/controllers/menu.ts b/examples/sheets/src/sheets-plugin-debugger/controllers/menu.tsindex b75d1d88f5..f49fbff556 100644--- a/examples/sheets/src/sheets-plugin-debugger/controllers/menu.ts+++ b/examples/sheets/src/sheets-plugin-debugger/controllers/menu.ts@@ -9,7 +9,6 @@ import { DialogOperation } from '../commands/operations/dialog.operation';import { LocaleOperation } from '../commands/operations/locale.operation';import { MessageOperation } from '../commands/operations/message.operation';import { NotificationOperation } from '../commands/operations/notification.operation';-import { NumfmtOperation } from '../commands/operations/numfmt.operations';import { SetEditable } from '../commands/operations/set.editable.operation';import { SidebarOperation } from '../commands/operations/sidebar.operation';import { ThemeOperation } from '../commands/operations/theme.operation';@@ -153,39 +152,19 @@ export function SidebarMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {export function SetEditableMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {return {id: SetEditable.id,- title: 'Editable',- tooltip: 'Editable',+ title: 'debugger.editable',+ tooltip: 'debugger.editable',type: MenuItemType.SELECTOR,positions: [MenuPosition.TOOLBAR_OTHERS],selections: [{- label: 'univer',+ label: 'changeUniverEditable',value: 'univer',},{- label: 'sheet',+ label: 'changeSheetEditable',value: 'sheet',},],};}--export function NumfmtMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {- return {- id: NumfmtOperation.id,- title: 'Numfmt',- tooltip: 'Numfmt',- type: MenuItemType.SELECTOR,- positions: [MenuPosition.TOOLBAR_OTHERS],- selections: [- {- label: 'Open numfmt',- value: 'open',- },- {- label: 'Close numfmt',- value: 'close',- },- ],- };-}diff --git a/examples/sheets/src/sheets-plugin-debugger/locale/en-US.ts b/examples/sheets/src/sheets-plugin-debugger/locale/en-US.tsindex 192daaed0e..bd20541881 100644--- a/examples/sheets/src/sheets-plugin-debugger/locale/en-US.ts+++ b/examples/sheets/src/sheets-plugin-debugger/locale/en-US.ts@@ -7,5 +7,6 @@ export default {dialog: 'Dialog',confirm: 'Confirm',sidebar: 'Sidebar',+ editable: 'Editable',},};diff --git a/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.ts b/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.tsindex 8be7ae49aa..52bfc3f209 100644--- a/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.ts+++ b/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.ts@@ -7,5 +7,6 @@ export default {dialog: '对话框',confirm: '确认框',sidebar: '侧边栏',+ editable: '编辑权限',},};diff --git a/packages/sheets-numfmt/src/base/const/MENU-OPTIONS.ts b/packages/sheets-numfmt/src/base/const/MENU-OPTIONS.tsnew file mode 100644index 0000000000..3a9872179d--- /dev/null+++ b/packages/sheets-numfmt/src/base/const/MENU-OPTIONS.ts@@ -0,0 +1,54 @@+export const MENU_OPTIONS: Array<{ label: string; pattern: string | null } | '|'> = [+ {+ label: 'sheet.numfmt.general',+ pattern: null,+ },+ {+ label: 'sheet.numfmt.text',+ pattern: '@@@',+ },+ '|',+ {+ label: 'sheet.numfmt.number',+ pattern: '0',+ },+ '|',+ {+ label: 'sheet.numfmt.accounting',+ pattern: '"¥" #,##0.00_);[Red]("¥"#,##0.00)',+ },+ {+ label: 'sheet.numfmt.financialValue',+ pattern: '#,##0.00;[Red]#,##0.00',+ },+ {+ label: 'sheet.numfmt.currency',+ pattern: '"¥"#,##0.00_);[Red]("¥"#,##0.00)',+ },+ {+ label: 'sheet.numfmt.roundingCurrency',+ pattern: '"¥"#,##0;[Red]"¥"#,##0',+ },+ '|',+ {+ label: 'sheet.numfmt.date',+ pattern: 'yyyy-mm-dd;@',+ },+ {+ label: 'sheet.numfmt.time',+ pattern: 'am/pm h":"mm":"ss',+ },+ {+ label: 'sheet.numfmt.dateTime',+ pattern: 'yyyy-m-d am/pm h:mm',+ },+ {+ label: 'sheet.numfmt.timeDuration',+ pattern: 'h:mm:ss',+ },+ '|',+ {+ label: 'sheet.numfmt.moreFmt',+ pattern: '',+ },+];diff --git a/packages/sheets-numfmt/src/components/index.tsx b/packages/sheets-numfmt/src/components/index.tsxindex 8632952f1f..c6cb9c076d 100644--- a/packages/sheets-numfmt/src/components/index.tsx+++ b/packages/sheets-numfmt/src/components/index.tsx@@ -28,7 +28,6 @@ export const SheetNumfmtPanel: FC<ISheetNumfmtPanelProps> = (props) => {const getCurrentPattern = useRef<() => string | null>(() => '');const t = localeService.t;const nextTick = useNextTick();- const pattern = useRef('');const typeOptions = useMemo(() =>[@@ -66,19 +65,19 @@ export const SheetNumfmtPanel: FC<ISheetNumfmtPanelProps> = (props) => {};const handleChange = (v: string) => {- pattern.current = v;props.onChange({ type: 'change', value: v });};const handleConfirm = () => {- const currency = getCurrencyType(pattern.current);+ const pattern = getCurrentPattern.current() || '';+ const currency = getCurrencyType(pattern);if (currency) {mark(currency);}- props.onChange({ type: 'confirm', value: pattern.current });+ props.onChange({ type: 'confirm', value: pattern });};const handleCancel = () => {- props.onChange({ type: 'cancel', value: pattern.current });+ props.onChange({ type: 'cancel', value: '' });};const subProps: IBusinessComponentProps = {diff --git a/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsx b/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsxindex d824ede99d..416e1df931 100644--- a/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsx+++ b/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsx@@ -1,16 +1,78 @@import './index.less';-import { MoreDownSingle } from '@univerjs/icons';+import { ICommandService, LocaleService, Range } from '@univerjs/core';+import numfmt from '@univerjs/engine-numfmt';+import type { FormatType } from '@univerjs/sheets';+import { SelectionManagerService } from '@univerjs/sheets';+import { useDependency } from '@wendellhu/redi/react-bindings';import React from 'react';+import { MENU_OPTIONS } from '../../base/const/MENU-OPTIONS';+import { SetNumfmtCommand } from '../../commands/commands/set.numfmt.command';+import { OpenNumfmtPanelOperator } from '../../commands/operators/open.numfmt.panel.operator';+import { getPatternType } from '../../utils/pattern';+export const MoreNumfmtType = (props: { value?: string }) => {- const value = props.value ?? '常规';+ const localeService = useDependency(LocaleService);+ const value = props.value ?? localeService.t('sheet.numfmt.general');+ return <span className="more-numfmt-type">{value}</span>;+};++export const Options = () => {+ const commandService = useDependency(ICommandService);+ const localeService = useDependency(LocaleService);++ const selectionManagerService = useDependency(SelectionManagerService);+ const setNumfmt = (pattern: string | null) => {+ const selection = selectionManagerService.getLast();+ if (!selection) {+ return;+ }+ const range = selection.range;+ const values: Array<{ row: number; col: number; pattern?: string; type?: FormatType }> = [];+ Range.foreach(range, (row, col) => {+ if (pattern) {+ values.push({ row, col, pattern, type: getPatternType(pattern) });+ } else {+ values.push({ row, col });+ }+ });+ commandService.executeCommand(SetNumfmtCommand.id, { values });+ };+ const handleOnclick = (index: number) => {+ if (index === 0) {+ setNumfmt(null);+ } else if (index === MENU_OPTIONS.length - 1) {+ commandService.executeCommand(OpenNumfmtPanelOperator.id);+ } else {+ const item = MENU_OPTIONS[index] as { pattern: string };+ item.pattern && setNumfmt(item.pattern);+ }+ };++ const defaultValue = 1220;+return (- <span className="more-numfmt-type">- {value}- <div className="icon">- <MoreDownSingle />- </div>- </span>+ <div className="more-numfmt-type-options">+ {MENU_OPTIONS.map((item, index) => {+ if (item === '|') {+ return <div key={index} className="line m-t-4" onClick={(e) => e.stopPropagation()} />;+ }+ return (+ <div+ className="option-item m-t-4"+ key={index}+ onClick={() => {+ handleOnclick(index);+ }}+ >+ <div>{localeService.t(item.label)}</div>+ <div className="m-l-26">+ {item.pattern ? numfmt.format(item.pattern || '', defaultValue, { locale: 'zh-CN' }) : ''}+ </div>+ </div>+ );+ })}+ </div>);};diff --git a/packages/sheets-numfmt/src/components/more-numfmt-type/index.less b/packages/sheets-numfmt/src/components/more-numfmt-type/index.lessindex a1e7063a5d..f7c8960923 100644--- a/packages/sheets-numfmt/src/components/more-numfmt-type/index.less+++ b/packages/sheets-numfmt/src/components/more-numfmt-type/index.less@@ -7,7 +7,7 @@font-size: 13px;color: var(--black);- .icon{+ .icon {display: flex;align-items: center;@@ -18,3 +18,35 @@color: rgb(var(--grey-400));}}++.more-numfmt-type-options {+ .line {+ width: 100%;+ height: 1px;+ background-color: rgb(var(--grey-200));+ }++ .m-t-4 {+ margin-top: 4px;+ }++ .option-item {+ display: flex;+ align-items: center;+ justify-content: space-between;++ height: 28px;+ padding: 0 8px;++ font-size: 13px;+ }++ .option-item:hover {+ background-color: rgb(var(--grey-100));+ border-radius: var(--border-radius-base);+ }++ .m-l-26 {+ margin-left: 26px;+ }+}\ No newline at end of filediff --git a/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsx b/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsxindex 0a5810012c..5ddd9d7406 100644--- a/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsx+++ b/packages/sheets-numfmt/src/components/thousandth-percentile/index.tsx@@ -1,4 +1,6 @@+import { LocaleService } from '@univerjs/core';import { InputNumber, SelectList } from '@univerjs/design';+import { useDependency } from '@wendellhu/redi/react-bindings';import type { FC } from 'react';import React, { useMemo, useState } from 'react';@@ -15,6 +17,8 @@ export const isThousandthPercentilePanel = (pattern: string) =>getNumberFormatOptions().some((item) => isPatternEqualWithoutDecimal(item.value, pattern));export const ThousandthPercentilePanel: FC<IBusinessComponentProps> = (props) => {+ const localeService = useDependency(LocaleService);+const options = useMemo(getNumberFormatOptions, []);const [decimal, decimalSet] = useState(() => getDecimalFromPattern(props.defaultPattern || '', 0));@@ -27,32 +31,35 @@ export const ThousandthPercentilePanel: FC<IBusinessComponentProps> = (props) =>const isInputDisable = useMemo(() => !isPatternHasDecimal(suffix), [suffix]);+ const handleDecimalChange = (decimal: number | null) => {+ decimalSet(decimal || 0);+ props.onChange(setPatternDecimal(suffix, Number(decimal || 0)));+ };const handleClick = (v: string) => {decimalSet(getDecimalFromPattern(v, 0));suffixSet(v);+ props.onChange(v);};props.action.current = () => pattern;return (<div>- <div className="m-t-16 label">小数位数</div>+ <div className="m-t-16 label">{localeService.t('sheet.numfmt.decimalLength')}</div><div className="m-t-8"><InputNumberdisabled={isInputDisable}value={decimal}max={20}min={0}- onChange={(value) => decimalSet(value || 0)}+ onChange={handleDecimalChange}/></div>- <div className="m-t-16 label"> 负数类型</div>+ <div className="m-t-16 label"> {localeService.t('sheet.numfmt.negType')}</div><div className="m-t-8"><SelectList onChange={handleClick} options={options} value={suffix} /></div>- <div className="describe m-t-14">- 数值格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。- </div>+ <div className="describe m-t-14">{localeService.t('sheet.numfmt.thousandthPercentileDes')}</div></div>);};diff --git a/packages/sheets-numfmt/src/controllers/numfmt.auto-fill.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.auto-fill.controller.tsnew file mode 100644index 0000000000..d55ab8bac9--- /dev/null+++ b/packages/sheets-numfmt/src/controllers/numfmt.auto-fill.controller.ts@@ -0,0 +1,138 @@+import type { IMutationInfo, IRange } from '@univerjs/core';+import { Disposable, IUniverInstanceService, LifecycleStages, OnLifecycle, Range, Rectangle } from '@univerjs/core';+import type { ISetNumfmtMutationParams } from '@univerjs/sheets';+import { factorySetNumfmtUndoMutation, INumfmtService, SetNumfmtMutation } from '@univerjs/sheets';+import type { IAutoFillHook } from '@univerjs/sheets-ui';+import { APPLY_TYPE, getAutoFillRepeatRange, IAutoFillService } from '@univerjs/sheets-ui';+import { Inject, Injector } from '@wendellhu/redi';++import { SHEET_NUMFMT_PLUGIN } from '../base/const/PLUGIN_NAME';++@OnLifecycle(LifecycleStages.Rendered, NumfmtAutoFillController)+export class NumfmtAutoFillController extends Disposable {+ constructor(+ @Inject(Injector) private _injector: Injector,+ @Inject(IUniverInstanceService) private _univerInstanceService: IUniverInstanceService,+ @Inject(INumfmtService) private _numfmtService: INumfmtService,+ @Inject(IAutoFillService) private _autoFillService: IAutoFillService+ ) {+ super();++ this._initAutoFill();+ }++ private _initAutoFill() {+ const noopReturnFunc = () => ({ redos: [], undos: [] });+ const loopFunc = (+ sourceStartCell: { row: number; col: number },+ targetStartCell: { row: number; col: number },+ relativeRange: IRange+ ) => {+ const workbookId = this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const worksheetId = this._univerInstanceService+ .getCurrentUniverSheetInstance()+ .getActiveSheet()+ .getSheetId();+ 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,+ };++ const values: ISetNumfmtMutationParams['values'] = [];++ Range.foreach(relativeRange, (row, col) => {+ const sourcePositionRange = Rectangle.getPositionRange(+ {+ startRow: row,+ startColumn: col,+ endColumn: col,+ endRow: row,+ },+ sourceRange+ );+ const oldNumfmtValue = this._numfmtService.getValue(+ workbookId,+ worksheetId,+ sourcePositionRange.startRow,+ sourcePositionRange.startColumn+ );+ if (oldNumfmtValue) {+ const targetPositionRange = Rectangle.getPositionRange(+ {+ startRow: row,+ startColumn: col,+ endColumn: col,+ endRow: row,+ },+ targetRange+ );+ values.push({+ pattern: oldNumfmtValue.pattern,+ type: oldNumfmtValue.type,+ row: targetPositionRange.startRow,+ col: targetPositionRange.startColumn,+ });+ }+ });+ if (values.length) {+ const redo: IMutationInfo<ISetNumfmtMutationParams> = {+ id: SetNumfmtMutation.id,+ params: {+ values,+ workbookId,+ worksheetId,+ },+ };+ const undo = {+ id: SetNumfmtMutation.id,+ params: {+ values: factorySetNumfmtUndoMutation(this._injector, redo.params),+ workbookId,+ worksheetId,+ },+ };+ return {+ redos: [redo],+ undos: [undo],+ };+ }+ return { redos: [], undos: [] };+ };+ const generalApplyFunc = (sourceRange: IRange, targetRange: IRange) => {+ const totalUndos: IMutationInfo[] = [];+ const totalRedos: IMutationInfo[] = [];+ const sourceStartCell = {+ row: sourceRange.startRow,+ col: sourceRange.startColumn,+ };+ const repeats = getAutoFillRepeatRange(sourceRange, targetRange);+ repeats.forEach((repeat) => {+ const { undos, redos } = loopFunc(sourceStartCell, repeat.repeatStartCell, repeat.relativeRange);+ totalUndos.push(...undos);+ totalRedos.push(...redos);+ });+ return {+ undos: totalUndos,+ redos: totalRedos,+ };+ };+ const hook: IAutoFillHook = {+ hookName: SHEET_NUMFMT_PLUGIN,+ hook: {+ [APPLY_TYPE.COPY]: generalApplyFunc,+ [APPLY_TYPE.NO_FORMAT]: noopReturnFunc,+ [APPLY_TYPE.ONLY_FORMAT]: generalApplyFunc,+ [APPLY_TYPE.SERIES]: generalApplyFunc,+ },+ };+ this.disposeWithMe(this._autoFillService.addHook(hook));+ }+}diff --git a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.controller.tsindex 391c7edcc6..519ffb9ec1 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.controller.ts@@ -1,4 +1,4 @@-import type { ICellData, IMutationInfo, IRange } from '@univerjs/core';+import type { ICellData, IRange } from '@univerjs/core';import {CellValueType,Disposable,@@ -11,7 +11,6 @@ import {ObjectMatrix,OnLifecycle,Range,- Rectangle,ThemeService,toDisposable,} from '@univerjs/core';@@ -27,8 +26,7 @@ import {SetNumfmtMutation,SheetInterceptorService,} from '@univerjs/sheets';-import type { IAutoFillHook } from '@univerjs/sheets-ui';-import { APPLY_TYPE, getRepeatRange, IAutoFillService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { ComponentManager, IMenuService, ISidebarService } from '@univerjs/ui';import { Inject, Injector } from '@wendellhu/redi';import { combineLatest, merge, Observable } from 'rxjs';@@ -71,8 +69,7 @@ export class NumfmtController extends Disposable implements INumfmtController {@Inject(ComponentManager) private _componentManager: ComponentManager,@Inject(IMenuService) private _menuService: IMenuService,@Inject(ISidebarService) private _sidebarService: ISidebarService,- @Inject(LocaleService) private _localeService: LocaleService,- @Inject(IAutoFillService) private _autoFillService: IAutoFillService+ @Inject(LocaleService) private _localeService: LocaleService) {super();this._initInterceptorCommands();@@ -83,7 +80,6 @@ export class NumfmtController extends Disposable implements INumfmtController {this._initMenu();this._initInterceptorCellContent();this._initLocal();- this._initAutoFill();}openPanel = () => {@@ -159,121 +155,6 @@ export class NumfmtController extends Disposable implements INumfmtController {});};- private _initAutoFill() {- const noopReturnFunc = () => ({ redos: [], undos: [] });- const loopFunc = (- sourceStartCell: { row: number; col: number },- targetStartCell: { row: number; col: number },- relativeRange: IRange- ) => {- const workbookId = this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = this._univerInstanceService- .getCurrentUniverSheetInstance()- .getActiveSheet()- .getSheetId();- 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,- };-- const values: ISetNumfmtMutationParams['values'] = [];-- Range.foreach(relativeRange, (row, col) => {- const sourcePositionRange = Rectangle.getPositionRange(- {- startRow: row,- startColumn: col,- endColumn: col,- endRow: row,- },- sourceRange- );- const oldNumfmtValue = this._numfmtService.getValue(- workbookId,- worksheetId,- sourcePositionRange.startRow,- sourcePositionRange.startColumn- );- if (oldNumfmtValue) {- const targetPositionRange = Rectangle.getPositionRange(- {- startRow: row,- startColumn: col,- endColumn: col,- endRow: row,- },- targetRange- );- values.push({- pattern: oldNumfmtValue.pattern,- type: oldNumfmtValue.type,- row: targetPositionRange.startRow,- col: targetPositionRange.startColumn,- });- }- });- if (values.length) {- const redo: IMutationInfo<ISetNumfmtMutationParams> = {- id: SetNumfmtMutation.id,- params: {- values,- workbookId,- worksheetId,- },- };- const undo = {- id: SetNumfmtMutation.id,- params: {- values: factorySetNumfmtUndoMutation(this._injector, redo.params),- workbookId,- worksheetId,- },- };- return {- redos: [redo],- undos: [undo],- };- }- return { redos: [], undos: [] };- };- const generalApplyFunc = (sourceRange: IRange, targetRange: IRange) => {- const totalUndos: IMutationInfo[] = [];- const totalRedos: IMutationInfo[] = [];- const sourceStartCell = {- row: sourceRange.startRow,- col: sourceRange.startColumn,- };- const repeats = getRepeatRange(sourceRange, targetRange);- repeats.forEach((repeat) => {- const { undos, redos } = loopFunc(sourceStartCell, repeat.repeatStartCell, repeat.relativeRange);- totalUndos.push(...undos);- totalRedos.push(...redos);- });- return {- undos: totalUndos,- redos: totalRedos,- };- };- const hook: IAutoFillHook = {- hookName: SHEET_NUMFMT_PLUGIN,- hook: {- [APPLY_TYPE.COPY]: generalApplyFunc,- [APPLY_TYPE.NO_FORMAT]: noopReturnFunc,- [APPLY_TYPE.ONLY_FORMAT]: generalApplyFunc,- [APPLY_TYPE.SERIES]: generalApplyFunc,- },- };- this.disposeWithMe(this._autoFillService.addHook(hook));- }-private _initCommands() {[AddDecimalCommand,@@ -517,7 +398,7 @@ export class NumfmtController extends Disposable implements INumfmtController {t: CellValueType.STRING,};}- return next();+ return next(cell);},}));diff --git a/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.tsindex 5ee3cb3337..9798577028 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.ts@@ -10,7 +10,7 @@ import {} from '@univerjs/core';import type { FormatType, ISetNumfmtMutationParams } from '@univerjs/sheets';import { factorySetNumfmtUndoMutation, INumfmtService, SetNumfmtMutation } from '@univerjs/sheets';-import { COPY_TYPE, ISheetClipboardService } from '@univerjs/sheets-ui';+import { COPY_TYPE, getRepeatRange, ISheetClipboardService } from '@univerjs/sheets-ui';import { Inject, Injector } from '@wendellhu/redi';@OnLifecycle(LifecycleStages.Rendered, NumfmtCopyPasteController)@@ -88,11 +88,18 @@ export class NumfmtCopyPasteController extends Disposable {const sheet = workbook.getActiveSheet();const workbookId = workbook.getUnitId();const worksheetId = sheet.getSheetId();-- if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf()) {+ if (copyInfo.copyType === COPY_TYPE.CUT) {+ // This do not need to deal with clipping.+ // move range had handle this case .+ // to see numfmt.ref-range.controller.ts+ this._copyInfo = null;+ return { redos: [], undos: [] };+ }+ if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange) {return { redos: [], undos: [] };}+ const repeatRange = getRepeatRange(copyInfo.copyRange, pastedRange, true);const redos: ISetNumfmtMutationParams = { workbookId, worksheetId, values: [] };// Clears the destination area data format@@ -101,43 +108,26 @@ export class NumfmtCopyPasteController extends Disposable {});// Set up according to the data collected. This will overlap with the cleanup, but that's okay- this._copyInfo.matrix.forValue((row, col, value) => {- const range = Rectangle.getPositionRange(- {- startRow: row,- endRow: row,- startColumn: col,- endColumn: col,- },- pastedRange- );- redos.values.push({- row: range.startRow,- col: range.startColumn,- pattern: value.pattern,- type: value.type,- });- });-- // If is clipping, need to clear the data format of the original area- if (copyInfo.copyType === COPY_TYPE.CUT && copyInfo.copyRange) {- this._copyInfo.matrix.forValue((row, col) => {- const range = Rectangle.getPositionRange(- {- startRow: row,- endRow: row,- startColumn: col,- endColumn: col,- },- copyInfo.copyRange!- );- redos.values.unshift({- row: range.startRow,- col: range.startColumn,+ repeatRange.forEach((item) => {+ this._copyInfo &&+ this._copyInfo.matrix.forValue((row, col, value) => {+ const range = Rectangle.getPositionRange(+ {+ startRow: row,+ endRow: row,+ startColumn: col,+ endColumn: col,+ },+ item.startRange+ );+ redos.values.push({+ row: range.startRow,+ col: range.startColumn,+ pattern: value.pattern,+ type: value.type,+ });});- });- this._copyInfo = null;- }+ });const undos: ISetNumfmtMutationParams = factorySetNumfmtUndoMutation(this._injector, redos);diff --git a/packages/sheets-numfmt/src/locale/en-US.ts b/packages/sheets-numfmt/src/locale/en-US.tsindex ffd7fb390b..d99476d031 100644--- a/packages/sheets-numfmt/src/locale/en-US.ts+++ b/packages/sheets-numfmt/src/locale/en-US.ts@@ -1,4 +1,4 @@-export const zhCn = {+export const enUs = {sheet: {numfmt: {title: '数据格式',@@ -7,12 +7,20 @@ export const zhCn = {confirm: '确认',general: '常规',accounting: '会计',+ text: '文本',+ number: '数值',currency: '货币',date: '日期',+ time: '时间',thousandthPercentile: '千分位符',preview: '示例',+ dateTime: '日期时间',decimalLength: '小数位数',currencyType: '货币类型',+ moreFmt: '更多格式',+ financialValue: '财务数值',+ roundingCurrency: '货币取整',+ timeDuration: '持续时间',currencyDes: '货币格式用于表示一般货币数值。会计格式可以对一列数值进行小数点对齐',accountingDes: '会计数字格式可对一列数值进行货币符号和小数点对齐',dateType: '日期类型',@@ -20,6 +28,8 @@ export const zhCn = {negType: '负数类型',generalDes: '常规格式不包含任何特定的数字格式。',thousandthPercentileDes: '千分位符格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。',+ addDecimal: '增加小数位',+ subtractDecimal: '减少小数位',},},};diff --git a/packages/sheets-numfmt/src/locale/zh-CN.ts b/packages/sheets-numfmt/src/locale/zh-CN.tsindex ffd7fb390b..e22b0a82dd 100644--- a/packages/sheets-numfmt/src/locale/zh-CN.ts+++ b/packages/sheets-numfmt/src/locale/zh-CN.ts@@ -7,12 +7,20 @@ export const zhCn = {confirm: '确认',general: '常规',accounting: '会计',+ text: '文本',+ number: '数值',currency: '货币',date: '日期',+ time: '时间',thousandthPercentile: '千分位符',preview: '示例',+ dateTime: '日期时间',decimalLength: '小数位数',currencyType: '货币类型',+ moreFmt: '更多格式',+ financialValue: '财务数值',+ roundingCurrency: '货币取整',+ timeDuration: '持续时间',currencyDes: '货币格式用于表示一般货币数值。会计格式可以对一列数值进行小数点对齐',accountingDes: '会计数字格式可对一列数值进行货币符号和小数点对齐',dateType: '日期类型',@@ -20,6 +28,8 @@ export const zhCn = {negType: '负数类型',generalDes: '常规格式不包含任何特定的数字格式。',thousandthPercentileDes: '千分位符格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。',+ addDecimal: '增加小数位',+ subtractDecimal: '减少小数位',},},};diff --git a/packages/sheets-numfmt/src/menu/menu.ts b/packages/sheets-numfmt/src/menu/menu.tsindex aa5fd2e495..e958c9b52b 100644--- a/packages/sheets-numfmt/src/menu/menu.ts+++ b/packages/sheets-numfmt/src/menu/menu.ts@@ -1,20 +1,18 @@-import { IUniverInstanceService } from '@univerjs/core';+import { ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';import { AddDigitsSingle, MoreDownSingle, ReduceDigitsSingle, RmbSingle } from '@univerjs/icons';-import { INumfmtService, SelectionManagerService } from '@univerjs/sheets';-import type { ComponentManager, IMenuButtonItem } from '@univerjs/ui';+import { INumfmtService, SelectionManagerService, SetNumfmtMutation } from '@univerjs/sheets';+import type { ComponentManager, IMenuSelectorItem } from '@univerjs/ui';import { MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';import type { IAccessor } from '@wendellhu/redi';-import { Observable } from 'rxjs';+import { merge, Observable } from 'rxjs';+import { MENU_OPTIONS } from '../base/const/MENU-OPTIONS';import { AddDecimalCommand } from '../commands/commands/add.decimal.command';import { SetCurrencyCommand } from '../commands/commands/set.currency.command';import { SubtractDecimalCommand } from '../commands/commands/subtract.decimal.command';import { OpenNumfmtPanelOperator } from '../commands/operators/open.numfmt.panel.operator';-import { isAccountingPanel } from '../components/accounting';-import { isCurrencyPanel } from '../components/currency';-import { isDatePanel } from '../components/date';-import { MoreNumfmtType } from '../components/more-numfmt-type/MoreNumfmtType';-import { isThousandthPercentilePanel } from '../components/thousandth-percentile';+import { MoreNumfmtType, Options } from '../components/more-numfmt-type/MoreNumfmtType';+import { isPatternEqualWithoutDecimal } from '../utils/decimal';export const CurrencyMenuItem = (componentManager: ComponentManager) => {const iconKey = 'icon-rmbSingle';@@ -23,8 +21,8 @@ export const CurrencyMenuItem = (componentManager: ComponentManager) => {return () => ({icon: iconKey,id: SetCurrencyCommand.id,- title: 'numfmt.menu.currency',- tooltip: 'numfmt.menu.currency',+ title: 'sheet.numfmt.currency',+ tooltip: 'sheet.numfmt.currency',type: MenuItemType.BUTTON,group: MenuGroup.TOOLBAR_FORMULAS_INSERT,positions: [MenuPosition.TOOLBAR_START],@@ -37,8 +35,8 @@ export const AddDecimalMenuItem = (componentManager: ComponentManager) => {return () => ({icon: iconKey,id: AddDecimalCommand.id,- title: 'numfmt.menu.add.decimal',- tooltip: 'numfmt.menu.add.decimal',+ title: 'sheet.numfmt.addDecimal',+ tooltip: 'sheet.numfmt.addDecimal',type: MenuItemType.BUTTON,positions: [MenuPosition.TOOLBAR_START],group: MenuGroup.TOOLBAR_FORMULAS_INSERT,@@ -50,8 +48,8 @@ export const SubtractDecimalMenuItem = (componentManager: ComponentManager) => {return () => ({icon: iconKey,id: SubtractDecimalCommand.id,- title: 'numfmt.menu.subtract.decimal',- tooltip: 'numfmt.menu.subtract.decimal',+ title: 'sheet.numfmt.subtractDecimal',+ tooltip: 'sheet.numfmt.subtractDecimal',type: MenuItemType.BUTTON,group: MenuGroup.TOOLBAR_FORMULAS_INSERT,positions: [MenuPosition.TOOLBAR_START],@@ -59,13 +57,32 @@ export const SubtractDecimalMenuItem = (componentManager: ComponentManager) => {};export const FactoryOtherMenuItem = (componentManager: ComponentManager) => {- componentManager.register('sheet.numfmt.moreNumfmtType', MoreNumfmtType);+ const moreTypeKey = 'sheet.numfmt.moreNumfmtType';+ const optionsKey = 'sheet.numfmt.moreNumfmtType.options';++ componentManager.register(moreTypeKey, MoreNumfmtType);+ componentManager.register(optionsKey, Options);+return (_accessor: IAccessor) => {const numfmtService = _accessor.get(INumfmtService);const univerInstanceService = _accessor.get(IUniverInstanceService);+ const commandService = _accessor.get(ICommandService);+ const localeService = _accessor.get(LocaleService);+const selectionManagerService = _accessor.get(SelectionManagerService);const value$ = new Observable((subscribe) =>- selectionManagerService.selectionInfo$.subscribe((selections) => {+ merge(+ selectionManagerService.selectionInfo$,+ new Observable<null>((commandSubscribe) => {+ const disposable = commandService.onCommandExecuted((commandInfo) => {+ if (commandInfo.id === SetNumfmtMutation.id) {+ commandSubscribe.next(null);+ }+ });+ return () => disposable.dispose();+ })+ ).subscribe(() => {+ const selections = selectionManagerService.getSelections();if (selections && selections[0]) {const workbook = univerInstanceService.getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();@@ -73,23 +90,15 @@ export const FactoryOtherMenuItem = (componentManager: ComponentManager) => {const row = range.startRow;const col = range.startColumn;const numfmtValue = numfmtService.getValue(workbook.getUnitId(), worksheet.getSheetId(), row, col);- let value: string = '常规';+ let value: string = localeService.t('sheet.numfmt.general');if (numfmtValue) {const pattern = numfmtValue.pattern;- if (isAccountingPanel(pattern)) {- value = '会计';- }-- if (isCurrencyPanel(pattern)) {- value = '货币';- }-- if (isDatePanel(pattern)) {- value = '日期';- }- if (isThousandthPercentilePanel(pattern)) {- value = '千分位';+ const item = MENU_OPTIONS.filter((item) => typeof item === 'object' && item.pattern).find(+ (item) => isPatternEqualWithoutDecimal(pattern, (item as { pattern: string }).pattern)+ );+ if (item && typeof item === 'object' && item.pattern) {+ value = localeService.t(item.label);}}subscribe.next(value);@@ -98,14 +107,21 @@ export const FactoryOtherMenuItem = (componentManager: ComponentManager) => {);return {// icon: 'MoreDownSingle',- label: 'sheet.numfmt.moreNumfmtType',+ label: moreTypeKey,id: OpenNumfmtPanelOperator.id,- // title: 'numfmt.menu.preview',- tooltip: 'numfmt.menu.preview',- type: MenuItemType.BUTTON,+ tooltip: 'sheet.numfmt.title',+ type: MenuItemType.SELECTOR,group: MenuGroup.TOOLBAR_FORMULAS_INSERT,positions: [MenuPosition.TOOLBAR_START],+ selections: [+ {+ label: {+ name: optionsKey,+ hoverable: false,+ },+ },+ ],value$,- } as IMenuButtonItem;+ } as IMenuSelectorItem;};};diff --git a/packages/sheets-numfmt/src/numfmt-plugin.ts b/packages/sheets-numfmt/src/numfmt-plugin.tsindex 1a37c9999f..969c40b4cc 100644--- a/packages/sheets-numfmt/src/numfmt-plugin.ts+++ b/packages/sheets-numfmt/src/numfmt-plugin.ts@@ -2,6 +2,7 @@ import { Plugin, PluginType } from '@univerjs/core';import { Inject, Injector } from '@wendellhu/redi';import { SHEET_NUMFMT_PLUGIN } from './base/const/PLUGIN_NAME';+import { NumfmtAutoFillController } from './controllers/numfmt.auto-fill.controller';import { NumfmtController } from './controllers/numfmt.controller';import { NumfmtCopyPasteController } from './controllers/numfmt.copy-paste.controller';import { NumfmtEditorController } from './controllers/numfmt.editor.controller';@@ -27,5 +28,6 @@ export class NumfmtPlugin extends Plugin {this._injector.add([NumfmtRefRangeController]);this._injector.add([NumfmtSheetController]);this._injector.add([NumfmtCopyPasteController]);+ this._injector.add([NumfmtAutoFillController]);}}diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.tsindex 807ac2e244..562101518c 100644--- a/packages/sheets-ui/src/index.ts+++ b/packages/sheets-ui/src/index.ts@@ -19,7 +19,7 @@ export {getTransformCoord,} from './controllers/utils/component-tools';export { AutoFillService, IAutoFillService } from './services/auto-fill/auto-fill.service';-export { getRepeatRange } from './services/auto-fill/tools';+export { getAutoFillRepeatRange } from './services/auto-fill/tools';export type { IAutoFillHook, ICopyDataPiece } 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';@@ -28,6 +28,7 @@ export { SheetClipboardService } from './services/clipboard/clipboard.service';export { type ISheetClipboardHook } from './services/clipboard/type';export { type ICellDataWithSpanInfo } from './services/clipboard/type';export { COPY_TYPE } from './services/clipboard/type';+export { getRepeatRange } from './services/clipboard/utils';export { CellEditorManagerService, ICellEditorManagerService } from './services/editor/cell-editor-manager.service';export { IFormulaEditorManagerService } from './services/editor/formula-editor-manager.service';export {diff --git a/packages/sheets-ui/src/services/auto-fill/tools.ts b/packages/sheets-ui/src/services/auto-fill/tools.tsindex 217d13d244..b19505fe1f 100644--- a/packages/sheets-ui/src/services/auto-fill/tools.ts+++ b/packages/sheets-ui/src/services/auto-fill/tools.ts@@ -614,7 +614,7 @@ export function fillLoopSeries(data: Array<Nullable<ICellData>>, len: number, streturn applyData;}-export function getRepeatRange(sourceRange: IRange, targetRange: IRange) {+export function getAutoFillRepeatRange(sourceRange: IRange, targetRange: IRange) {const repeats: Array<{repeatStartCell: { col: number; row: number };relativeRange: IRange;diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/utils.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/utils.spec.tsnew file mode 100644index 0000000000..6b13cf0ef9--- /dev/null+++ b/packages/sheets-ui/src/services/clipboard/__tests__/utils.spec.ts@@ -0,0 +1,120 @@+import type { IRange } from '@univerjs/core';+import { describe, expect, it } from 'vitest';++import { getRepeatRange } from '../utils';++describe('test getRepeatRange', () => {+ it('repeat row 2 times', () => {+ const originRange: IRange = { startRow: 3, endRow: 4, startColumn: 1, endColumn: 1 };+ const targetRange: IRange = { startRow: 6, endRow: 9, startColumn: 1, endColumn: 1 };+ const result = getRepeatRange(originRange, targetRange);+ expect(result).toEqual([+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 1, endColumn: 1 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 0 },+ },+ {+ startRange: { startRow: 8, endRow: 8, startColumn: 1, endColumn: 1 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 0 },+ },+ ]);+ });++ it('repeat col 2 times', () => {+ const originRange: IRange = { startRow: 1, endRow: 1, startColumn: 3, endColumn: 4 };+ const targetRange: IRange = { startRow: 1, endRow: 1, startColumn: 6, endColumn: 9 };+ const result = getRepeatRange(originRange, targetRange);+ expect(result).toEqual([+ {+ startRange: { startRow: 1, endRow: 1, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 0, startColumn: 0, endColumn: 1 },+ },+ {+ startRange: { startRow: 1, endRow: 1, startColumn: 8, endColumn: 8 },+ repeatRelativeRange: { startRow: 0, endRow: 0, startColumn: 0, endColumn: 1 },+ },+ ]);+ });++ it('repeat col 2 times and repeat row 2 times', () => {+ const originRange: IRange = { startRow: 3, endRow: 4, startColumn: 3, endColumn: 4 };+ const targetRange: IRange = { startRow: 6, endRow: 9, startColumn: 6, endColumn: 9 };+ const result = getRepeatRange(originRange, targetRange);+ expect(result).toEqual([+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 8, endColumn: 8 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ {+ startRange: { startRow: 8, endRow: 8, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ {+ startRange: { startRow: 8, endRow: 8, startColumn: 8, endColumn: 8 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ ]);+ });++ it('the target row mod origin row is not 0', () => {+ const originRange: IRange = { startRow: 3, endRow: 4, startColumn: 3, endColumn: 4 };+ const targetRange: IRange = { startRow: 6, endRow: 10, startColumn: 6, endColumn: 9 };+ const result = getRepeatRange(originRange, targetRange);+ expect(result).toEqual([+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 8, endColumn: 8 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ ]);+ const result2 = getRepeatRange(originRange, targetRange, true);+ expect(result2).toEqual([+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ ]);+ });++ it('the target col mod origin col is not 0', () => {+ const originRange: IRange = { startRow: 3, endRow: 4, startColumn: 3, endColumn: 4 };+ const targetRange: IRange = { startRow: 6, endRow: 9, startColumn: 6, endColumn: 10 };+ const result = getRepeatRange(originRange, targetRange);+ expect(result).toEqual([+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ {+ startRange: { startRow: 8, endRow: 8, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ ]);+ const result2 = getRepeatRange(originRange, targetRange, true);+ expect(result2).toEqual([+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ ]);+ });++ it('the target range is cell', () => {+ const originRange: IRange = { startRow: 3, endRow: 4, startColumn: 3, endColumn: 4 };+ const targetRange: IRange = { startRow: 6, endRow: 6, startColumn: 6, endColumn: 6 };+ const result = getRepeatRange(originRange, targetRange);+ expect(result).toEqual([+ {+ startRange: { startRow: 6, endRow: 6, startColumn: 6, endColumn: 6 },+ repeatRelativeRange: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 1 },+ },+ ]);+ });+});diff --git a/packages/sheets-ui/src/services/clipboard/utils.ts b/packages/sheets-ui/src/services/clipboard/utils.tsnew file mode 100644index 0000000000..6a72010ea2--- /dev/null+++ b/packages/sheets-ui/src/services/clipboard/utils.ts@@ -0,0 +1,76 @@+import type { IRange } from '@univerjs/core';++/**+ *+ *+ * @param {IRange} sourceRange+ * @param {IRange} targetRang+ * @param {boolean} [isStrictMode=false] 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) => {+ 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 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 repeatList: Array<{ startRange: IRange; repeatRelativeRange: IRange }> = [];+ if (!rowMod && !colMod) {+ for (let countRow = 1; countRow <= repeatRow; countRow++) {+ for (let countCol = 1; countCol <= repeatCol; countCol++) {+ 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,+ };++ repeatList.push({ repeatRelativeRange, startRange });+ }+ }+ } else if (!rowMod && colMod && !isStrictMode) {+ for (let countRow = 1; countRow <= repeatRow; countRow++) {+ 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,+ };++ repeatList.push({ repeatRelativeRange, startRange });+ }+ } else if (rowMod && !colMod && !isStrictMode) {+ for (let countCol = 1; countCol <= repeatCol; countCol++) {+ 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,+ };++ repeatList.push({ repeatRelativeRange, startRange });+ }+ } else {+ const startRange: IRange = {+ startRow: targetRang.startRow,+ endRow: targetRang.startRow,+ startColumn: targetRang.startColumn,+ endColumn: targetRang.startColumn,+ };+ repeatList.push({ startRange, repeatRelativeRange });+ }+ return repeatList;+};