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(sheet): copy&paste clip cell (#2773)

waterhydroxylaf845a253e0c
diff --git a/packages/core/src/shared/common.ts b/packages/core/src/shared/common.ts
index 5320faff71..0435da4d21 100644
--- a/packages/core/src/shared/common.ts
+++ b/packages/core/src/shared/common.ts
@@ -361,7 +361,7 @@ export function handleStyleToString(style: IStyleData, isCell: boolean = false)
'tb',
() => {
if (style.tb === WrapStrategy.CLIP) {
- str += 'white-space: clip; ';
+ str += 'white-space: nowrap; overflow-x: hidden; ';
} else if (style.tb === WrapStrategy.WRAP) {
str += 'white-space: normal;';
}
diff --git a/packages/ui/src/utils/cell.ts b/packages/ui/src/utils/cell.ts
index 7ccca7f2f9..cd8f943738 100644
--- a/packages/ui/src/utils/cell.ts
+++ b/packages/ui/src/utils/cell.ts
@@ -382,18 +382,20 @@ export function handleStringToStyle($dom?: HTMLElement, cssStyle: string = '') {
}
}
- // wrap text
- if (key === 'overflow-wrap' || key === 'word-wrap') {
- if (value === 'break-word') {
- styleList.tb = 3;
- }
- } else if (key === 'text-overflow') {
- if (value === 'clip') {
- styleList.tb = 2;
- }
- } else if (key === 'text-break') {
- if (value === 'overflow') {
- styleList.tb = 1;
+ // wrap text (`white-space` property has a higher priority.)
+ if (styleList.tb !== 1) {
+ if (key === 'overflow-wrap' || key === 'word-wrap') {
+ if (value === 'break-word') {
+ styleList.tb = 3;
+ }
+ } else if (key === 'text-overflow') {
+ if (value === 'clip') {
+ styleList.tb = 2;
+ }
+ } else if (key === 'text-break') {
+ if (value === 'overflow') {
+ styleList.tb = 1;
+ }
}
}