Skip to content

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.

feat: add sheets-filter sync switch (#5797)

wpxp123456ea706af45376
diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.ts
index 7130cf5fe6..eb85cd0254 100644
--- a/packages/core/src/services/command/command.service.ts
+++ b/packages/core/src/services/command/command.service.ts
@@ -375,10 +375,11 @@ export class CommandService extends Disposable implements ICommandService {
};
const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
+ const _options = options ?? {};
- this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, options));
- const result = await this._execute<P, R>(command as ICommand<P, R>, params, options);
- this._commandExecutedListeners.forEach((listener) => listener(commandInfo, options));
+ this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
+ const result = await this._execute<P, R>(command as ICommand<P, R>, params, _options);
+ this._commandExecutedListeners.forEach((listener) => listener(commandInfo, _options));
stackItemDisposable.dispose();
@@ -425,10 +426,11 @@ export class CommandService extends Disposable implements ICommandService {
}
const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
+ const _options = options ?? {};
- this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, options));
- const result = this._syncExecute<P, R>(command as ICommand<P, R>, params, options);
- this._commandExecutedListeners.forEach((listener) => listener(commandInfo, options));
+ this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
+ const result = this._syncExecute<P, R>(command as ICommand<P, R>, params, _options);
+ this._commandExecutedListeners.forEach((listener) => listener(commandInfo, _options));
stackItemDisposable.dispose();
diff --git a/packages/sheets-filter-ui/src/locale/ca-ES.ts b/packages/sheets-filter-ui/src/locale/ca-ES.ts
index 0f6d2ca3cf..936218aaa1 100644
--- a/packages/sheets-filter-ui/src/locale/ca-ES.ts
+++ b/packages/sheets-filter-ui/src/locale/ca-ES.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: 'Novembre',
12: 'Desembre',
},
+ sync: {
+ title: 'El filtre és visible per a tothom',
+ statusTips: {
+ on: 'Un cop activat, tots els col·laboradors veuran els resultats del filtre',
+ off: 'Un cop desactivat, només tu veuràs els resultats del filtre',
+ },
+ switchTips: {
+ on: 'S’ha activat "El filtre és visible per a tothom", tots els col·laboradors veuran els resultats del filtre',
+ off: 'S’ha desactivat "El filtre és visible per a tothom", només tu veuràs els resultats del filtre',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/en-US.ts b/packages/sheets-filter-ui/src/locale/en-US.ts
index 76ba0650e3..42236e25e7 100644
--- a/packages/sheets-filter-ui/src/locale/en-US.ts
+++ b/packages/sheets-filter-ui/src/locale/en-US.ts
@@ -83,6 +83,17 @@ const locale = {
11: 'November',
12: 'December',
},
+ sync: {
+ title: 'Filter is visible to everyone',
+ statusTips: {
+ on: 'Once on, all collaborators will see the filter results',
+ off: 'Once off, only you will see the filter results',
+ },
+ switchTips: {
+ on: '"Filter is visible to everyone" is turned on, all collaborators will see the filter results',
+ off: '"Filter is visible to everyone" is turned off, only you will see the filter results',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/es-ES.ts b/packages/sheets-filter-ui/src/locale/es-ES.ts
index 0236fd4b3a..8a477c79e3 100644
--- a/packages/sheets-filter-ui/src/locale/es-ES.ts
+++ b/packages/sheets-filter-ui/src/locale/es-ES.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: 'Noviembre',
12: 'Diciembre',
},
+ sync: {
+ title: 'El filtro es visible para todos',
+ statusTips: {
+ on: 'Una vez activado, todos los colaboradores verán los resultados del filtro',
+ off: 'Una vez desactivado, solo tú verás los resultados del filtro',
+ },
+ switchTips: {
+ on: '"El filtro es visible para todos" está activado, todos los colaboradores verán los resultados del filtro',
+ off: '"El filtro es visible para todos" está desactivado, solo tú verás los resultados del filtro',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/fa-IR.ts b/packages/sheets-filter-ui/src/locale/fa-IR.ts
index 53c94b408b..8c8b3034b3 100644
--- a/packages/sheets-filter-ui/src/locale/fa-IR.ts
+++ b/packages/sheets-filter-ui/src/locale/fa-IR.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: 'نوامبر',
12: 'دسامبر',
},
+ sync: {
+ title: 'فیلتر برای همه قابل مشاهده است',
+ statusTips: {
+ on: 'پس از روشن شدن، همه همکاران نتایج فیلتر را مشاهده خواهند کرد',
+ off: 'پس از خاموش شدن، فقط شما نتایج فیلتر را مشاهده خواهید کرد',
+ },
+ switchTips: {
+ on: 'گزینه "فیلتر برای همه قابل مشاهده است" روشن است، همه همکاران نتایج فیلتر را مشاهده خواهند کرد',
+ off: 'گزینه "فیلتر برای همه قابل مشاهده است" خاموش است، فقط شما نتایج فیلتر را مشاهده خواهید کرد',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/fr-FR.ts b/packages/sheets-filter-ui/src/locale/fr-FR.ts
index 310a9c01f3..62e6b7d132 100644
--- a/packages/sheets-filter-ui/src/locale/fr-FR.ts
+++ b/packages/sheets-filter-ui/src/locale/fr-FR.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: 'Nov',
12: 'Déc',
},
+ sync: {
+ title: 'Le filtre est visible par tous',
+ statusTips: {
+ on: 'Une fois activé, tous les collaborateurs verront les résultats du filtre',
+ off: 'Une fois désactivé, seul vous verrez les résultats du filtre',
+ },
+ switchTips: {
+ on: '“Le filtre est visible par tous” est activé, tous les collaborateurs verront les résultats du filtre',
+ off: '“Le filtre est visible par tous” est désactivé, seul vous verrez les résultats du filtre',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/ko-KR.ts b/packages/sheets-filter-ui/src/locale/ko-KR.ts
index 1889a0a4bb..d947973433 100644
--- a/packages/sheets-filter-ui/src/locale/ko-KR.ts
+++ b/packages/sheets-filter-ui/src/locale/ko-KR.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: '11월',
12: '12월',
},
+ sync: {
+ title: '필터를 모든 사용자가 볼 수 있음',
+ statusTips: {
+ on: '활성화하면 모든 협업자가 필터 결과를 볼 수 있습니다.',
+ off: '비활성화하면 나만 필터 결과를 볼 수 있습니다.',
+ },
+ switchTips: {
+ on: '"필터를 모든 사용자가 볼 수 있음"이 활성화되어 모든 협업자가 필터 결과를 볼 수 있습니다.',
+ off: '"필터를 모든 사용자가 볼 수 있음"이 비활성화되어 나만 필터 결과를 볼 수 있습니다.',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/ru-RU.ts b/packages/sheets-filter-ui/src/locale/ru-RU.ts
index d4c897d0f8..0ca05d092d 100644
--- a/packages/sheets-filter-ui/src/locale/ru-RU.ts
+++ b/packages/sheets-filter-ui/src/locale/ru-RU.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: 'Ноябрь',
12: 'Декабрь',
},
+ sync: {
+ title: 'Фильтр виден всем',
+ statusTips: {
+ on: 'После включения все сотрудники увидят результаты фильтрации',
+ off: 'После отключения только вы увидите результаты фильтрации',
+ },
+ switchTips: {
+ on: 'Функция "Фильтр виден всем" включена, все сотрудники увидят результаты фильтрации',
+ off: 'Функция "Фильтр виден всем" отключена, только вы увидите результаты фильтрации',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/vi-VN.ts b/packages/sheets-filter-ui/src/locale/vi-VN.ts
index 5bb0094a53..6a720b8e91 100644
--- a/packages/sheets-filter-ui/src/locale/vi-VN.ts
+++ b/packages/sheets-filter-ui/src/locale/vi-VN.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: 'Tháng 11',
12: 'Tháng 12',
},
+ sync: {
+ title: 'Lọc cho tất cả mọi người đều thấy',
+ statusTips: {
+ on: 'Khi bật, tất cả cộng tác viên sẽ thấy kết quả lọc',
+ off: 'Khi tắt, chỉ bạn mới thấy kết quả lọc',
+ },
+ switchTips: {
+ on: 'Đã bật "Lọc cho tất cả mọi người đều thấy", tất cả cộng tác viên sẽ thấy kết quả lọc',
+ off: 'Đã tắt "Lọc cho tất cả mọi người đều thấy", chỉ bạn mới thấy kết quả lọc',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/zh-CN.ts b/packages/sheets-filter-ui/src/locale/zh-CN.ts
index da505d5ffb..912ce9ab82 100644
--- a/packages/sheets-filter-ui/src/locale/zh-CN.ts
+++ b/packages/sheets-filter-ui/src/locale/zh-CN.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: '11月',
12: '12月',
},
+ sync: {
+ title: '筛选对所有人可见',
+ statusTips: {
+ on: '开启后,所有协作者都将看到此次筛选结果',
+ off: '关闭后,仅你可见此次筛选结果',
+ },
+ switchTips: {
+ on: '已开启“筛选对所有人可见”,所有协作者都将看到此次筛选结果',
+ off: '已关闭“筛选对所有人可见”,仅你可见此次筛选结果',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/locale/zh-TW.ts b/packages/sheets-filter-ui/src/locale/zh-TW.ts
index 3180132fac..b8647362f6 100644
--- a/packages/sheets-filter-ui/src/locale/zh-TW.ts
+++ b/packages/sheets-filter-ui/src/locale/zh-TW.ts
@@ -85,6 +85,17 @@ const locale: typeof enUS = {
11: '11月',
12: '12月',
},
+ sync: {
+ title: '篩選對所有人可見',
+ statusTips: {
+ on: '開啟後,所有協作者都將看到此次篩選結果',
+ off: '關閉後,僅你可見此次篩選結果',
+ },
+ switchTips: {
+ on: '已開啟“篩選對所有人可見”,所有協作者都將看到此次篩選結果',
+ off: '已關閉“篩選對所有人可見”,僅你可見此次篩選結果',
+ },
+ },
},
};
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
index 05c8450439..7f6ae9f787 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
@@ -27,6 +27,7 @@ import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.ser
import { FilterByColor } from './SheetsFilterByColorsPanel';
import { FilterByCondition } from './SheetsFilterByConditionsPanel';
import { FilterByValue } from './SheetsFilterByValuesPanel';
+import { FilterSyncSwitch } from './SheetsFilterSyncSwitch';
/**
* This Filter Panel component is used to filter the data in the sheet.
@@ -105,6 +106,7 @@ export function FilterPanel() {
: (
<div className="univer-flex-1" />
)}
+ <FilterSyncSwitch />
<div
data-u-comp="sheets-filter-panel-footer"
className={`
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterSyncSwitch.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterSyncSwitch.tsx
new file mode 100644
index 0000000000..a36f6fefd9
--- /dev/null
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterSyncSwitch.tsx
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * 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 { LocaleService } from '@univerjs/core';
+import { MessageType, Switch, Tooltip } from '@univerjs/design';
+import { InfoIcon } from '@univerjs/icons';
+import { SheetsFilterSyncController } from '@univerjs/sheets-filter';
+import { IMessageService, useDependency, useObservable } from '@univerjs/ui';
+
+export function FilterSyncSwitch() {
+ const sheetsFilterSyncController = useDependency(SheetsFilterSyncController);
+ const visible = useObservable(sheetsFilterSyncController.visible$, undefined, true);
+ if (!visible) return null;
+
+ const localeService = useDependency(LocaleService);
+ const messageService = useDependency(IMessageService);
+ const enabled = useObservable(sheetsFilterSyncController.enabled$, undefined, true);
+
+ return (
+ <div
+ className={`
+ univer-mt-2 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-900
+ dark:univer-text-gray-200
+ `}
+ >
+ <div className="univer-flex univer-items-center univer-gap-1">
+ <span>{localeService.t('sheets-filter.sync.title')}</span>
+ <Tooltip
+ title={enabled
+ ? localeService.t('sheets-filter.sync.statusTips.off')
+ : localeService.t('sheets-filter.sync.statusTips.on')}
+ asChild
+ >
+ <InfoIcon />
+ </Tooltip>
+ </div>
+ <Switch
+ defaultChecked={enabled}
+ onChange={(checked) => {
+ const message = checked
+ ? localeService.t('sheets-filter.sync.switchTips.on')
+ : localeService.t('sheets-filter.sync.switchTips.off');
+ sheetsFilterSyncController.setEnabled(checked);
+ messageService.show({
+ content: message,
+ type: MessageType.Success,
+ duration: 2000,
+ });
+ }}
+ />
+ </div>
+ );
+}
diff --git a/packages/sheets-filter/src/controllers/config.schema.ts b/packages/sheets-filter/src/controllers/config.schema.ts
index f4c06cd01b..86b15c2e2d 100644
--- a/packages/sheets-filter/src/controllers/config.schema.ts
+++ b/packages/sheets-filter/src/controllers/config.schema.ts
@@ -19,6 +19,12 @@ export const SHEETS_FILTER_PLUGIN_CONFIG_KEY = 'sheets-filter.config';
export const configSymbol = Symbol(SHEETS_FILTER_PLUGIN_CONFIG_KEY);
export interface IUniverSheetsFilterConfig {
+ /**
+ * Whether to display the filter sync switch in the filter panel.
+ * This configuration can be used in a collaboration scenario to allow users to choose whether to enable filter synchronization.
+ * @default false
+ */
+ enableSyncSwitch?: boolean;
}
export const defaultPluginConfig: IUniverSheetsFilterConfig = {};
diff --git a/packages/sheets-filter/src/controllers/sheets-filter-sync.controller.ts b/packages/sheets-filter/src/controllers/sheets-filter-sync.controller.ts
new file mode 100644
index 0000000000..9e35015ca7
--- /dev/null
+++ b/packages/sheets-filter/src/controllers/sheets-filter-sync.controller.ts
@@ -0,0 +1,100 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * 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 type { IInsertColMutationParams, IMoveColumnsMutationParams, IRemoveColMutationParams } from '@univerjs/sheets';
+import type { IUniverSheetsFilterConfig } from './config.schema';
+import { Disposable, DisposableCollection, ICommandService, IConfigService, Inject, sequenceExecute } from '@univerjs/core';
+import { InsertColMutation, MoveColsMutation, RemoveColMutation } from '@univerjs/sheets';
+import { BehaviorSubject } from 'rxjs';
+import { ReCalcSheetsFilterMutation, SetSheetsFilterCriteriaMutation } from '../commands/mutations/sheets-filter.mutation';
+import { SHEETS_FILTER_PLUGIN_CONFIG_KEY } from './config.schema';
+import { SheetsFilterController } from './sheets-filter.controller';
+
+const sheetsFilterOnlyLocalMutationIds = [
+ SetSheetsFilterCriteriaMutation.id,
+ ReCalcSheetsFilterMutation.id,
+];
+
+const effectedByOnlyLocalMutationIds = [
+ InsertColMutation.id,
+ RemoveColMutation.id,
+ MoveColsMutation.id,
+];
+
+export class SheetsFilterSyncController extends Disposable {
+ private _d: DisposableCollection = new DisposableCollection();
+
+ private readonly _visible$ = new BehaviorSubject<boolean>(false);
+ readonly visible$ = this._visible$.asObservable();
+ get visible(): boolean { return this._visible$.getValue(); }
+
+ private readonly _enabled$ = new BehaviorSubject<boolean>(true);
+ readonly enabled$ = this._enabled$.asObservable();
+ get enabled(): boolean { return this._enabled$.getValue(); }
+
+ constructor(
+ @Inject(SheetsFilterController) private readonly _sheetsFilterController: SheetsFilterController,
+ @ICommandService protected readonly _commandService: ICommandService,
+ @IConfigService private readonly _configService: IConfigService
+ ) {
+ super();
+
+ const config = this._configService.getConfig<IUniverSheetsFilterConfig>(SHEETS_FILTER_PLUGIN_CONFIG_KEY);
+ if (config?.enableSyncSwitch) {
+ this._visible$.next(true);
+ }
+ }
+
+ setEnabled(enabled: boolean) {
+ this._enabled$.next(enabled);
+ if (enabled) {
+ this._d.dispose();
+ } else {
+ this._initOnlyLocalListener();
+ }
+ }
+
+ private _initOnlyLocalListener() {
+ this._d.add(
+ this._commandService.beforeCommandExecuted((commandInfo, options) => {
+ if (sheetsFilterOnlyLocalMutationIds.includes(commandInfo.id)) {
+ if (!options) options = {};
+ options.onlyLocal = true;
+ }
+ })
+ );
+
+ this._d.add(
+ this._commandService.onCommandExecuted((commandInfo, options) => {
+ if (effectedByOnlyLocalMutationIds.includes(commandInfo.id) && options?.fromCollab) {
+ if (commandInfo.id === InsertColMutation.id) {
+ const { range, unitId, subUnitId } = commandInfo.params as IInsertColMutationParams;
+ const { redos } = this._sheetsFilterController.handleInsertColCommand(range, unitId, subUnitId);
+ sequenceExecute(redos, this._commandService, options);
+ } else if (commandInfo.id === RemoveColMutation.id) {
+ const { range, unitId, subUnitId } = commandInfo.params as IRemoveColMutationParams;
+ const { redos } = this._sheetsFilterController.handleRemoveColCommand(range, unitId, subUnitId);
+ sequenceExecute(redos, this._commandService, options);
+ } else if (commandInfo.id === MoveColsMutation.id) {
+ const { sourceRange: fromRange, targetRange: toRange, unitId, subUnitId } = commandInfo.params as IMoveColumnsMutationParams;
+ const { redos } = this._sheetsFilterController.handleMoveColsCommand({ fromRange, toRange }, unitId, subUnitId);
+ sequenceExecute(redos, this._commandService, options);
+ }
+ }
+ })
+ );
+ }
+}
diff --git a/packages/sheets-filter/src/controllers/sheets-filter.controller.ts b/packages/sheets-filter/src/controllers/sheets-filter.controller.ts
index f9c59620a1..87c45fce67 100644
--- a/packages/sheets-filter/src/controllers/sheets-filter.controller.ts
+++ b/packages/sheets-filter/src/controllers/sheets-filter.controller.ts
@@ -128,11 +128,11 @@ export class SheetsFilterController extends Disposable {
const params = config.params as IInsertColCommandParams;
const _unitId = params.unitId || unitId;
const _subUnitId = params.subUnitId || subUnitId;
- return this._handleInsertColCommand(params, _unitId, _subUnitId);
+ return this.handleInsertColCommand(params.range, _unitId, _subUnitId);
}
case RemoveColCommand.id: {
const params = config.params as IRemoveColMutationParams;
- return this._handleRemoveColCommand(params, unitId, subUnitId);
+ return this.handleRemoveColCommand(params.range, unitId, subUnitId);
}
case RemoveRowCommand.id: {
const params = config.params as IRemoveRowsMutationParams;
@@ -140,7 +140,10 @@ export class SheetsFilterController extends Disposable {
}
case EffectRefRangId.MoveColsCommandId: {
const params = config.params as IMoveColsCommandParams;
- return this._handleMoveColsCommand(params, unitId, subUnitId);
+ return this.handleMoveColsCommand({
+ fromRange: params.fromRange,
+ toRange: params.toRange,
+ }, unitId, subUnitId);
}
case EffectRefRangId.MoveRowsCommandId: {
const params = config.params as IMoveRowsCommandParams;
@@ -183,14 +186,14 @@ export class SheetsFilterController extends Disposable {
};
}
- private _handleInsertColCommand(config: IInsertColCommandParams, unitId: string, subUnitId: string) {
+ handleInsertColCommand(range: IRange, unitId: string, subUnitId: string) {
const filterModel = this._sheetsFilterService.getFilterModel(unitId, subUnitId);
const filterRange = filterModel?.getRange() ?? null;
if (!filterModel || !filterRange) {
return this._handleNull();
}
const { startColumn, endColumn } = filterRange;
- const { startColumn: insertStartColumn, endColumn: insertEndColumn } = config.range;
+ const { startColumn: insertStartColumn, endColumn: insertEndColumn } = range;
const count = insertEndColumn - insertStartColumn + 1;
if (insertEndColumn > endColumn) {
@@ -224,7 +227,7 @@ export class SheetsFilterController extends Disposable {
const effected = filterColumn.filter((column) => column[0] >= anchor);
if (effected.length !== 0) {
const { newRange, oldRange } = this._moveCriteria(unitId, subUnitId, effected, count);
- redos.push(...newRange.redos, ...oldRange.redos);
+ redos.push(...oldRange.redos, ...newRange.redos);
undos.push(...newRange.undos, ...oldRange.undos);
}
@@ -268,14 +271,14 @@ export class SheetsFilterController extends Disposable {
};
}
- private _handleRemoveColCommand(config: IRemoveColMutationParams, unitId: string, subUnitId: string) {
+ handleRemoveColCommand(range: IRange, unitId: string, subUnitId: string) {
const filterModel = this._sheetsFilterService.getFilterModel(unitId, subUnitId);
const filterRange = filterModel?.getRange() ?? null;
if (!filterModel || !filterRange) {
return this._handleNull();
}
const { startColumn, endColumn } = filterRange;
- const { startColumn: removeStartColumn, endColumn: removeEndColumn } = config.range;
+ const { startColumn: removeStartColumn, endColumn: removeEndColumn } = range;
if (removeStartColumn > endColumn) {
return this._handleNull();
@@ -429,14 +432,13 @@ export class SheetsFilterController extends Disposable {
}
// eslint-disable-next-line max-lines-per-function
- private _handleMoveColsCommand(config: IMoveColsCommandParams, unitId: string, subUnitId: string) {
+ handleMoveColsCommand({ fromRange, toRange }: { fromRange: IRange; toRange: IRange }, unitId: string, subUnitId: string) {
const filterModel = this._sheetsFilterService.getFilterModel(unitId, subUnitId);
const filterRange = filterModel?.getRange() ?? null;
if (!filterModel || !filterRange) {
return this._handleNull();
}
const { startColumn, endColumn } = filterRange;
- const { fromRange, toRange } = config;
if ((fromRange.endColumn < startColumn && toRange.startColumn <= startColumn) || (
fromRange.startColumn > endColumn && toRange.endColumn > endColumn
)) {
diff --git a/packages/sheets-filter/src/index.ts b/packages/sheets-filter/src/index.ts
index cf8ee9d1b0..c86e17d847 100644
--- a/packages/sheets-filter/src/index.ts
+++ b/packages/sheets-filter/src/index.ts
@@ -34,6 +34,7 @@ export {
} from './commands/mutations/sheets-filter.mutation';
export { FILTER_MUTATIONS } from './common/const';
export type { IUniverSheetsFilterConfig } from './controllers/config.schema';
+export { SheetsFilterSyncController } from './controllers/sheets-filter-sync.controller';
export {
equals,
getCustomFilterFn,
diff --git a/packages/sheets-filter/src/plugin.ts b/packages/sheets-filter/src/plugin.ts
index 10cd85921b..6e73b6479b 100644
--- a/packages/sheets-filter/src/plugin.ts
+++ b/packages/sheets-filter/src/plugin.ts
@@ -22,6 +22,7 @@ import { defaultPluginConfig, SHEETS_FILTER_PLUGIN_CONFIG_KEY } from './controll
import { SheetsFilterController } from './controllers/sheets-filter.controller';
import { SheetsFilterFormulaService } from './services/sheet-filter-formula.service';
import { SHEET_FILTER_SNAPSHOT_ID, SheetsFilterService } from './services/sheet-filter.service';
+import { SheetsFilterSyncController } from './controllers/sheets-filter-sync.controller';
export class UniverSheetsFilterPlugin extends Plugin {
static override type = UniverInstanceType.UNIVER_SHEET;
@@ -48,6 +49,7 @@ export class UniverSheetsFilterPlugin extends Plugin {
[SheetsFilterFormulaService],
[SheetsFilterService],
[SheetsFilterController],
+ [SheetsFilterSyncController],
] as Dependency[]).forEach((d) => this._injector.add(d));
}
@@ -55,6 +57,7 @@ export class UniverSheetsFilterPlugin extends Plugin {
touchDependencies(this._injector, [
[SheetsFilterFormulaService],
[SheetsFilterController],
+ [SheetsFilterSyncController],
]);
}
}