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.

fix: fx editor cursor (#915)

Ran Luocb7c9239d5fd
diff --git a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts
index 4198c4a202..459013e9a0 100644
--- a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts
@@ -77,6 +77,7 @@ export class FormulaEditorController extends RxDisposable {
this._commandExecutedListener();
this._syncEditorSize();
this._listenFxBtnClick();
+ this._listenFoldBtnClick();
this._renderManagerService.currentRender$.pipe(takeUntil(this.dispose$)).subscribe((unitId) => {
if (unitId !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) {
@@ -157,6 +158,12 @@ export class FormulaEditorController extends RxDisposable {
});
}
+ private _listenFoldBtnClick() {
+ this._formulaEditorManagerService.foldBtnStatus$.pipe(takeUntil(this.dispose$)).subscribe(() => {
+ this._textSelectionManagerService.refreshSelection();
+ });
+ }
+
private _initialMain(unitId: string) {
const formulaEditorDocObject = this._renderManagerService.getRenderById(unitId);
if (formulaEditorDocObject == null) {
@@ -395,9 +402,16 @@ export class FormulaEditorController extends RxDisposable {
let scrollBar = viewportMain?.getScrollBar() as Nullable<ScrollBar>;
+ scene.transformByState({
+ width,
+ height: actualHeight,
+ });
+
+ mainComponent?.resize(width, actualHeight);
+
if (actualHeight > height) {
if (scrollBar == null) {
- viewportMain && new ScrollBar(viewportMain, { enableHorizontal: false });
+ viewportMain && new ScrollBar(viewportMain, { enableHorizontal: false, barSize: 8 });
} else {
viewportMain?.resetSizeAndScrollBar();
}
@@ -406,12 +420,5 @@ export class FormulaEditorController extends RxDisposable {
viewportMain?.scrollTo({ x: 0, y: 0 });
viewportMain?.getScrollBar()?.dispose();
}
-
- scene.transformByState({
- width,
- height: actualHeight,
- });
-
- mainComponent?.resize(width, actualHeight);
}
}
diff --git a/packages/sheets-ui/src/services/editor/formula-editor-manager.service.ts b/packages/sheets-ui/src/services/editor/formula-editor-manager.service.ts
index b99562d587..e5ba23a92b 100644
--- a/packages/sheets-ui/src/services/editor/formula-editor-manager.service.ts
+++ b/packages/sheets-ui/src/services/editor/formula-editor-manager.service.ts
@@ -24,6 +24,7 @@ export interface IFormulaEditorManagerService {
position$: Observable<Nullable<DOMRect>>;
focus$: Observable<boolean>;
fxBtnClick$: Observable<boolean>;
+ foldBtnStatus$: Observable<boolean>;
dispose(): void;
setPosition(param: DOMRect): void;
getPosition(): Readonly<Nullable<DOMRect>>;
@@ -44,6 +45,9 @@ export class FormulaEditorManagerService implements IDisposable {
private readonly _fxBtnClick$ = new BehaviorSubject<boolean>(false);
readonly fxBtnClick$ = this._fxBtnClick$.asObservable();
+ private readonly _foldBtnStatus$ = new BehaviorSubject<boolean>(false);
+ readonly foldBtnStatus$ = this._foldBtnStatus$.asObservable();
+
dispose(): void {
this._position$.complete();
this._focus$.complete();
@@ -70,6 +74,10 @@ export class FormulaEditorManagerService implements IDisposable {
this._fxBtnClick$.next(params);
}
+ handleFoldBtnClick(params: boolean) {
+ this._foldBtnStatus$.next(params);
+ }
+
private _refresh(param: DOMRect): void {
this._position$.next(param);
}
diff --git a/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx b/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx
index d17692778c..5dad9c85c8 100644
--- a/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx
+++ b/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx
@@ -31,11 +31,6 @@ enum ArrowDirection {
Up,
}
-interface IFormulaState {
- iconStyle: string;
- arrowDirection: ArrowDirection;
-}
-
export function FormulaBar() {
const [iconStyle, setIconStyle] = useState<string>(styles.formulaGrey);
const [arrowDirection, setArrowDirection] = useState<ArrowDirection>(ArrowDirection.Down);
@@ -85,6 +80,11 @@ export function FormulaBar() {
function handleArrowClick() {
setArrowDirection(arrowDirection === ArrowDirection.Down ? ArrowDirection.Up : ArrowDirection.Down);
+
+ const ANIMATION_DURATION = 150;
+ setTimeout(() => {
+ formulaEditorManagerService.handleFoldBtnClick(arrowDirection === ArrowDirection.Up);
+ }, ANIMATION_DURATION);
}
function handleCloseBtnClick() {