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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheets-drawing-ui): float-dom delete icon note hide after deleted & note resize issue (#5158)
ZhangWei8520a1fbfd1f
diff --git a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.pngindex a9389860d6..415e0ade68 100644Binary files a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png and b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.pngindex 2d9e6d0fbe..a5f6791490 100644Binary files a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.pngindex 981bcbc61e..b4db561d1d 100644Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.pngindex 0a58486fc7..8aef79e987 100644Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png differdiff --git a/examples/scripts/generate-html.ts b/examples/scripts/generate-html.tsindex 6cfa0ce0ff..48c3a876c8 100644--- a/examples/scripts/generate-html.ts+++ b/examples/scripts/generate-html.ts@@ -47,6 +47,7 @@ const indexTemplate = `<!doctype html>body {height: 100%;margin: 0;+ font-family: Arial;}</style>${ESBUILD_SCRIPT}</head>diff --git a/packages/sheets-data-validation-ui/src/views/components/formula-input/CustomFormulaInput.tsx b/packages/sheets-data-validation-ui/src/views/components/formula-input/CustomFormulaInput.tsxindex 2b9215930d..20407bd3ee 100644--- a/packages/sheets-data-validation-ui/src/views/components/formula-input/CustomFormulaInput.tsx+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/CustomFormulaInput.tsx@@ -16,6 +16,7 @@import type { IFormulaInputProps } from '@univerjs/data-validation';import type { IFormulaEditorRef } from '@univerjs/sheets-formula-ui';+import { FormLayout } from '@univerjs/design';import { FormulaEditor } from '@univerjs/sheets-formula-ui';import { useSidebarClick } from '@univerjs/ui';import { useRef, useState } from 'react';@@ -32,35 +33,36 @@ export function CustomFormulaInput(props: IFormulaInputProps) {});return (- <FormulaEditor- ref={formulaEditorRef}- className={`- univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg- univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-pt-2- univer-transition-colors- [&>div:first-child]:univer-px-2.5- [&>div]:univer-h-5 [&>div]:univer-ring-transparent- dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white- hover:univer-border-primary-600- `}- initValue={value?.formula1 ?? '=' as any}- unitId={unitId}- subUnitId={subUnitId}- isFocus={isFocusFormulaEditor}- errorText={formula1Res}- isSupportAcrossSheet- onChange={(newValue) => {- const newFormula = (newValue ?? '').trim();- if (newFormula === value?.formula1) {- return;- }+ <FormLayout error={formula1Res}>+ <FormulaEditor+ ref={formulaEditorRef}+ className={`+ univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg+ univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-pt-2+ univer-transition-colors+ [&>div:first-child]:univer-px-2.5+ [&>div]:univer-h-5 [&>div]:univer-ring-transparent+ dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white+ hover:univer-border-primary-600+ `}+ initValue={value?.formula1 ?? '=' as any}+ unitId={unitId}+ subUnitId={subUnitId}+ isFocus={isFocusFormulaEditor}+ isSupportAcrossSheet+ onChange={(newValue) => {+ const newFormula = (newValue ?? '').trim();+ if (newFormula === value?.formula1) {+ return;+ }- onChange?.({- ...value,- formula1: newFormula,- });- }}- onFocus={() => isFocusFormulaEditorSet(true)}- />+ onChange?.({+ ...value,+ formula1: newFormula,+ });+ }}+ onFocus={() => isFocusFormulaEditorSet(true)}+ />+ </FormLayout>);}diff --git a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.tsindex b713783057..a66a4c1de2 100644--- a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts+++ b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts@@ -487,6 +487,7 @@ export class SheetCanvasFloatDomManagerService extends Disposable {const rectShape = scene.getObject(rectShapeKey);if (rectShape?.oKey) {transformer.clearControlByIds([rectShape?.oKey]);+ scene.getTransformer()?.clearSelectedObjects();}});})diff --git a/packages/sheets-note-ui/src/views/note.tsx b/packages/sheets-note-ui/src/views/note.tsxindex 9681720553..5ee4505c21 100644--- a/packages/sheets-note-ui/src/views/note.tsx+++ b/packages/sheets-note-ui/src/views/note.tsx@@ -119,7 +119,7 @@ export const SheetsNote = (props: { popup: IPopup<{ location: ISheetLocationBaseref={textareaRef}data-u-comp="note-textarea"className={clsx(`- univer-resize-both univer-ml-px univer-rounded univer-border univer-border-solid univer-border-gray-200+ univer-resize-both univer-ml-px univer-rounded-md univer-border univer-border-solid univer-border-gray-200univer-bg-white univer-p-2 univer-text-gray-900 univer-shadowdark:univer-border-gray-600 dark:univer-bg-gray-800 dark:univer-text-whitefocus:univer-outline-nonediff --git a/packages/sheets-ui/src/services/cell-popup-manager.service.ts b/packages/sheets-ui/src/services/cell-popup-manager.service.tsindex fb59c3f0a0..0eafae3069 100644--- a/packages/sheets-ui/src/services/cell-popup-manager.service.ts+++ b/packages/sheets-ui/src/services/cell-popup-manager.service.ts@@ -112,6 +112,7 @@ export class CellPopupManagerService extends Disposable {direction,},noPushMinimumGap: true,+ autoRelayout: false,},unitId,subUnitIddiff --git a/packages/thread-comment-ui/src/views/thread-comment-tree/index.tsx b/packages/thread-comment-ui/src/views/thread-comment-tree/index.tsxindex 8824448bab..8ba02aea36 100644--- a/packages/thread-comment-ui/src/views/thread-comment-tree/index.tsx+++ b/packages/thread-comment-ui/src/views/thread-comment-tree/index.tsx@@ -345,7 +345,7 @@ export const ThreadCommentTree = (props: IThreadCommentTreeProps) => {<divclassName={clsx(`- univer-relative univer-box-border univer-rounded-lg univer-border univer-border-solid+ univer-relative univer-box-border univer-rounded-md univer-border univer-border-soliduniver-border-gray-200 univer-bg-white univer-p-4`,full ? 'univer-w-full' : 'univer-w-[278px]',diff --git a/packages/ui/src/views/components/popup/RectPopup.tsx b/packages/ui/src/views/components/popup/RectPopup.tsxindex d2a43aca8c..cfd2f5139f 100644--- a/packages/ui/src/views/components/popup/RectPopup.tsx+++ b/packages/ui/src/views/components/popup/RectPopup.tsx@@ -86,6 +86,8 @@ export interface IRectPopupProps {maskZIndex?: number;onMaskClick?: () => void;noPushMinimumGap?: boolean;++ autoRelayout?: boolean;}export interface IPopupLayoutInfo extends Pick<IRectPopupProps, 'direction'> {@@ -133,7 +135,9 @@ function calcPopupPosition(layout: IPopupLayoutInfo): { top: number; left: numbe} else {// If the popup element exceed the visible area. We should "push" it back.horizontalStyle = (startX + width) > containerWidth- ? { left: Math.max(endX - width, minLeft) } // on left+ ? Math.max(endX - width, minLeft) < PUSHING_MINIMUM_GAP+ ? { left: Math.min(startX, maxLeft) }+ : { left: Math.max(endX - width, minLeft) } // on left: { left: Math.min(startX, maxLeft) }; // on right}@@ -167,7 +171,9 @@ function calcPopupPosition(layout: IPopupLayoutInfo): { top: number; left: numbe} else {// If the popup element exceed the visible area. We should "push" it back.verticalStyle = ((startY + height) > containerHeight)- ? { top: Math.max(endY - height, minTop) } // on top+ ? Math.max(endY - height, minTop) < PUSHING_MINIMUM_GAP+ ? { top: Math.min(startY, maxTop) }+ : { top: Math.max(endY - height, minTop) } // on top: { top: Math.min(startY, maxTop) }; // on bottom}@@ -193,6 +199,7 @@ function RectPopup(props: IRectPopupProps) {maskZIndex = 100,onMaskClick,noPushMinimumGap,+ autoRelayout = true,} = props;const nodeRef = useRef<HTMLElement>(null);const clickOtherFn = useEvent(onClickOutside ?? (() => { /* empty */ }));@@ -207,7 +214,7 @@ function RectPopup(props: IRectPopupProps) {const uiConfig = configService.getConfig(UI_PLUGIN_CONFIG_KEY) as IUniverUIConfig;const popupRootId = uiConfig?.popupRootId ?? 'univer-popup-portal';- function updatePosition(position: IAbsolutePosition) {+ const updatePosition = useEvent((position: IAbsolutePosition) => {requestAnimationFrame(() => {if (!nodeRef.current) return;@@ -230,12 +237,13 @@ function RectPopup(props: IRectPopupProps) {nodeRef.current.style.top = `${positionRef.current.top}px`;nodeRef.current.style.left = `${positionRef.current.left}px`;});- }+ });useEffect(() => {let observer: ResizeObserver | null;if (nodeRef.current) {observer = new ResizeObserver(() => {+ if (!autoRelayout) return;if (!anchorRectRef.current) return;updatePosition(anchorRectRef.current);});@@ -246,7 +254,7 @@ function RectPopup(props: IRectPopupProps) {return () => {observer?.disconnect();};- }, [nodeRef.current]);+ }, [nodeRef.current, autoRelayout]);useEffect(() => {const anchorRectSub = anchorRect$.subscribe((anchorRect) => {