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(util): handle null document input and optimize paragraph processing (#6385)
WEI ZHANG4195d436a29f
diff --git a/packages/thread-comment-ui/src/views/thread-comment-editor/util.ts b/packages/thread-comment-ui/src/views/thread-comment-editor/util.tsindex 55ba7ed201..c0b41431e8 100644--- a/packages/thread-comment-ui/src/views/thread-comment-editor/util.ts+++ b/packages/thread-comment-ui/src/views/thread-comment-editor/util.ts@@ -58,12 +58,14 @@ const transformDocument2TextNodesInParagraph = (doc: IDocumentBody) => {};export const transformDocument2TextNodes = (doc: IDocumentBody) => {+ if (!doc) {+ return [];+ }const { paragraphs = [] } = doc;- let lastIndex = 0;- return paragraphs.map((paragraph) => {+ return paragraphs.map((paragraph, index) => {+ const lastIndex = index === 0 ? 0 : paragraphs[index - 1].startIndex + 1;const body = getBodySlice(doc, lastIndex, paragraph.startIndex);- lastIndex = paragraph.startIndex + 1;return transformDocument2TextNodesInParagraph(body);});};