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: paste rich text with br should keep line break (#4670)

ybzky535a2a91e94e
diff --git a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts
index 58cfead04f..59e1f90fd0 100644
--- a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts
+++ b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts
@@ -447,6 +447,12 @@ export class HtmlToUSMService {
}
} else if (node.nodeType === Node.COMMENT_NODE || node.nodeName === 'STYLE') {
continue;
+ } else if (node.nodeName.toLowerCase() === 'br') {
+ if (!doc.paragraphs) {
+ doc.paragraphs = [];
+ }
+ doc.paragraphs.push({ startIndex: doc.dataStream.length });
+ doc.dataStream += '\r';
} else if (node.nodeType === Node.ELEMENT_NODE) {
const currentNodeStyle = this._getStyle(node as HTMLElement, styleStr);
const parentStyles = parent ? styleCache.get(parent) : {};