Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear format failed when not change selections #2338

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { ICommandInfo, IDocumentBody, IDocumentData, IPosition, Nullable } from '@univerjs/core';
import type { ICommandInfo, IDocumentBody, IPosition, Nullable } from '@univerjs/core';
import {
DEFAULT_EMPTY_DOCUMENT_VALUE,
Disposable,
Expand Down Expand Up @@ -60,6 +60,7 @@ import { IEditorService, KeyCode, SetEditorResizeOperation } from '@univerjs/ui'
import { Inject } from '@wendellhu/redi';

import { filter } from 'rxjs';
import { ClearSelectionFormatCommand } from '@univerjs/sheets';
import { getEditorObject } from '../../basics/editor/get-editor-object';
import { SetCellEditVisibleOperation } from '../../commands/operations/cell-edit.operation';
import { ICellEditorManagerService } from '../../services/editor/cell-editor-manager.service';
Expand Down Expand Up @@ -520,7 +521,7 @@ export class StartEditController extends Disposable {
eventType === DeviceInputEventType.Keyboard ||
(eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange)
) {
const snapshot = Tools.deepClone(documentDataModel.getSnapshot()) as IDocumentData;
const snapshot = Tools.deepClone(documentDataModel.getSnapshot());
const documentViewModel = this._docViewModelManagerService.getViewModel(editorUnitId);

if (documentViewModel == null) {
Expand Down Expand Up @@ -677,6 +678,15 @@ export class StartEditController extends Disposable {
}
})
);

this.disposeWithMe(
// Use fix https://github.com/dream-num/univer/issues/1231.
this._commandService.onCommandExecuted((command: ICommandInfo) => {
if (command.id === ClearSelectionFormatCommand.id) {
this._editorBridgeService.refreshEditCellState();
}
})
);
}

private _setOpenForCurrent(unitId: Nullable<string>, sheetId: Nullable<string>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mu
*/
export const ClearSelectionFormatCommand: ICommand = {
id: 'sheet.command.clear-selection-format',

type: CommandType.COMMAND,

handler: async (accessor: IAccessor) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const commandService = accessor.get(ICommandService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface ISetRangeValuesCommandParams extends Partial<ISheetCommandShare
export const SetRangeValuesCommand: ICommand = {
id: 'sheet.command.set-range-values',
type: CommandType.COMMAND,
// eslint-disable-next-line max-lines-per-function
handler: (accessor: IAccessor, params: ISetRangeValuesCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, bo

type: CommandType.MUTATION,

// eslint-disable-next-line max-lines-per-function
handler: (accessor, params) => {
const { cellValue, subUnitId, unitId } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
Expand All @@ -172,6 +173,7 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, bo
const styles = workbook.getStyles();
const newValues = new ObjectMatrix(cellValue);

// eslint-disable-next-line complexity
newValues.forValue((row, col, newVal) => {
// clear all
if (!newVal) {
Expand Down
Loading