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: formular confirm error #2318

Merged
merged 5 commits into from
Jun 2, 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 @@ -17,7 +17,6 @@
import type { ICommandInfo, Nullable, Workbook } from '@univerjs/core';
import { checkForSubstrings, Disposable, ICommandService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
import { Inject } from '@wendellhu/redi';

import { IRenderManagerService, ITextSelectionRenderManager, ScrollBar } from '@univerjs/engine-render';
import type { IRichTextEditingMutationParams } from '@univerjs/docs';
import { CoverContentCommand, DocSkeletonManagerService, RichTextEditingMutation, VIEWPORT_KEY } from '@univerjs/docs';
Expand Down Expand Up @@ -265,7 +264,7 @@ export class DocEditorBridgeController extends Disposable {
}

/**
* Listen to document edits to refresh the size of the normula editor.
* Listen to document edits to refresh the size of the formula editor.
*/
private _commandExecutedListener() {
const updateCommandList = [RichTextEditingMutation.id, SetEditorResizeOperation.id];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ export class PromptController extends Disposable {
this.disposeWithMe(
toDisposable(
this._textSelectionManagerService.textSelection$.subscribe((params) => {
if (params?.unitId == null
) {
if (params?.unitId == null) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ export class EndEditController extends Disposable {
this._cursorStateListener();
}

// eslint-disable-next-line max-lines-per-function
private _initialExitInput() {
this.disposeWithMe(
// eslint-disable-next-line max-lines-per-function
this._editorBridgeService.visible$.subscribe(async (param) => {
const { visible, keycode, eventType } = param;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ export class StartEditController extends Disposable {
const { skeleton } = docParam;

this._fitTextSize(position, canvasOffset, skeleton, documentLayoutObject, scaleX, scaleY);

// move selection
// move selection
if (
eventType === DeviceInputEventType.Keyboard ||
(eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange)
Expand All @@ -535,7 +534,7 @@ export class StartEditController extends Disposable {

document.makeDirty();

// @JOCS, Why calculate here?
// @JOCS, Why calculate here?
if (keycode === KeyCode.BACKSPACE || eventType === DeviceInputEventType.Dblclick) {
skeleton.calculate();
this._editorBridgeService.changeEditorDirty(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

/* eslint-disable complexity */
/* eslint-disable max-lines-per-function */

import type {
IInterceptor,
IRange,
Expand Down Expand Up @@ -307,7 +310,7 @@ export class SelectionRenderService implements ISelectionRenderService {

const skeleton = this._skeleton;

let style = data.style;
let { style } = data;

if (style == null) {
style = getNormalSelectionStyle(this._themeService);
Expand All @@ -321,6 +324,7 @@ export class SelectionRenderService implements ISelectionRenderService {

const control = new SelectionShape(scene, currentControls.length, this._isHeaderHighlight, this._themeService);

// eslint-disable-next-line no-new
new SelectionShapeExtension(control, skeleton, scene, this._themeService, this._injector);

const { rowHeaderWidth, columnHeaderHeight } = skeleton;
Expand All @@ -336,12 +340,6 @@ export class SelectionRenderService implements ISelectionRenderService {
currentControls.push(control);
}

/**
* update selection
* @param selectionRange
* @param curCellRange
* @returns
*/
updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]) {
const currentControls = this.getCurrentControls();
if (!currentControls) {
Expand Down Expand Up @@ -538,7 +536,6 @@ export class SelectionRenderService implements ISelectionRenderService {
* @param zIndex Stacking order of the selection object
* @param rangeType Determines whether the selection is made normally according to the range or by rows and columns
*/
// eslint-disable-next-line max-lines-per-function, complexity
eventTrigger(
evt: IPointerEvent | IMouseEvent,
zIndex = 0,
Expand Down Expand Up @@ -786,7 +783,6 @@ export class SelectionRenderService implements ISelectionRenderService {
let lastX = newEvtOffsetX;
let lastY = newEvtOffsetY;

// eslint-disable-next-line max-lines-per-function, complexity
this._moveObserver = scene.onPointerMoveObserver.add((moveEvt: IPointerEvent | IMouseEvent) => {
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;

Expand Down Expand Up @@ -1045,8 +1041,6 @@ export class SelectionRenderService implements ISelectionRenderService {
/**
* When mousedown and mouseup need to go to the coordination and undo stack, when mousemove does not need to go to the coordination and undo stack
*/

// eslint-disable-next-line max-lines-per-function
private _moving(
moveOffsetX: number,
moveOffsetY: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function DefinedName({ disable }: { disable: boolean }) {
return () => {
subscription.unsubscribe();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // Empty dependency array means this effect runs once on mount and clean up on unmount

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
cellEditorManagerService.setRect({ left, top, width, height });
}
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // Empty dependency array means this effect runs once on mount and clean up on unmount

useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export function FormulaBar() {
}
}
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const INITIAL_SNAPSHOT = {
Expand Down Expand Up @@ -154,6 +155,7 @@ export function FormulaBar() {
}, ANIMATION_DURATION);
}

// Handle click the "×" button.
function handleCloseBtnClick() {
const visibleState = editorBridgeService.isVisible();
if (visibleState.visible) {
Expand All @@ -165,6 +167,7 @@ export function FormulaBar() {
}
}

// Handle click the "√" button.
function handleConfirmBtnClick() {
const visibleState = editorBridgeService.isVisible();
if (visibleState.visible) {
Expand Down
11 changes: 10 additions & 1 deletion packages/sheets/src/services/selection-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,22 @@ export class SelectionManagerService implements IDisposable {
}

changePluginNoRefresh(pluginName: string) {
if (this._currentSelection == null) {
if (this._currentSelection == null || this._currentSelection.pluginName === pluginName) {
return;
}

// Fetch the old selections.
const selections = this.getSelectionDatasByParam(this._currentSelection);

this._currentSelection = {
pluginName,
unitId: this._currentSelection?.unitId,
sheetId: this._currentSelection?.sheetId,
};

if (selections != null) {
this.add([]);
}
}

reset() {
Expand Down Expand Up @@ -217,6 +225,7 @@ export class SelectionManagerService implements IDisposable {
if (this._currentSelection == null) {
return;
}

this._addByParam({
...this._currentSelection,
selectionDatas,
Expand Down
Loading