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: bugs in format painter #677

Merged
merged 7 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: range mark conflicts between format-painter and clipboard
  • Loading branch information
yuhongz committed Dec 8, 2023
commit 25e3aba49f66904b9dc5edf22179b069d9b665b2
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard
await this._clipboardInterfaceService.write(plain, html);

// 9. mark the copy range
this._markSelectionService.removeAllShapes();

const style = this._selectionManagerService.createCopyPasteSelection();
if (this._copyMarkId) {
this._markSelectionService.removeShape(this._copyMarkId);
}
this._copyMarkId = this._markSelectionService.addShape({ ...selection, style });

// tell hooks to clean up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ export class FormatPainterService extends Disposable implements IFormatPainterSe
}

private _updateRangeMark(status: FormatPainterStatus) {
if (this._markId) {
this._markSelectionService.removeShape(this._markId);
this._markId = null;
}
this._markSelectionService.removeAllShapes();
this._markId = null;

if (status !== FormatPainterStatus.OFF) {
const selection = this._selectionManagerService.getLast();
if (selection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ICommandInfo } from '@univerjs/core';
import { Disposable, ICommandService, IUniverInstanceService, ThemeService, Tools } from '@univerjs/core';
import { IRenderManagerService } from '@univerjs/engine-render';
import type { ISelectionWithStyle } from '@univerjs/sheets';
import { SelectionManagerService, SetWorksheetActivateMutation } from '@univerjs/sheets';
import { SelectionManagerService, SetRangeValuesMutation, SetWorksheetActivateMutation } from '@univerjs/sheets';
import { createIdentifier, Inject } from '@wendellhu/redi';

import { SetCellEditVisibleOperation } from '../../commands/operations/cell-edit.operation';
Expand Down Expand Up @@ -100,7 +100,7 @@ export class MarkSelectionService extends Disposable implements IMarkSelectionSe
}

private _addRemoveListener() {
const removeCommands = [SetCellEditVisibleOperation.id];
const removeCommands = [SetCellEditVisibleOperation.id, SetRangeValuesMutation.id];
this.disposeWithMe(
this._commandService.onCommandExecuted((command: ICommandInfo) => {
if (removeCommands.includes(command.id)) {
Expand Down