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(copy): fix copy id (#6469)
wpxp123456bf75a44faf68
diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.tsindex c48264148b..bfa1054e5c 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.ts@@ -150,7 +150,7 @@ describe('Test clipboard', () => {})).toBeTruthy();const { html, copyId } = sheetClipboardService.generateCopyContent('test', 'sheet1', selection.range)!;- const result = `<google data-copy-id="${copyId}"-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none"><colgroup><col width="88" /></colgroup>+ const result = `<google-sheets-html-origin><table data-copy-id="${copyId}" xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none"><colgroup><col width="88" /></colgroup><tbody><tr style="height: 24px;"><td style="font-size: 20pt; color: #ff0000; border-bottom: 0.5pt solid #000000; border-top: 0.5pt solid #000000; border-right: 0.5pt solid #000000; border-left: 0.5pt solid #000000; ">1</td></tr><tr style="height: 24px;"><td style="font-size: 20pt; color: #ff0000; border-bottom: 0.5pt solid #000000; border-top: 0.5pt solid #000000; border-right: 0.5pt solid #000000; border-left: 0.5pt solid #000000; ">2</td></tr><tr style="height: 24px;"><td style="font-size: 20pt; color: #ff0000; border-bottom: 0.5pt solid #000000; border-top: 0.5pt solid #000000; border-right: 0.5pt solid #000000; border-left: 0.5pt solid #000000; ">3</td></tr><tr style="height: 24px;"><td style="font-size: 20pt; color: #ff0000; border-bottom: 0.5pt solid #000000; border-top: 0.5pt solid #000000; border-right: 0.5pt solid #000000; border-left: 0.5pt solid #000000; ">4</td></tr></tbody></table>`;expect(html).toBe(result);});diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.tsindex e07689a8cf..ab4cbb8c7d 100644--- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts@@ -495,11 +495,9 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard}// convert matrix to html- let html = this._usmToHtml.convert(matrix, discreteRange, hooks);-- const plain = getMatrixPlainText(plainMatrix);const copyId = genId();- html = html.replace(/(<[a-z]+)/, (_p0, p1) => `${p1} data-copy-id="${copyId}"`);+ const html = this._usmToHtml.convert(matrix, discreteRange, hooks, copyId);+ const plain = getMatrixPlainText(plainMatrix);return {copyId,diff --git a/packages/sheets-ui/src/services/clipboard/usm-to-html/convertor.ts b/packages/sheets-ui/src/services/clipboard/usm-to-html/convertor.tsindex 2264428daf..62041135df 100644--- a/packages/sheets-ui/src/services/clipboard/usm-to-html/convertor.ts+++ b/packages/sheets-ui/src/services/clipboard/usm-to-html/convertor.ts@@ -121,7 +121,8 @@ export class USMToHtmlService {}>,range: IDiscreteRange,- hooks: ISheetClipboardHook[]+ hooks: ISheetClipboardHook[],+ copyId?: string): string {const { cols, rows } = range;if (!cols.length) {@@ -135,7 +136,7 @@ export class USMToHtmlService {rowContents.push(getRowContent(row, cols, hooks, matrix, mergeSet));});- const html = `<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${colStyles}+ const html = `<google-sheets-html-origin><table data-copy-id="${copyId}" xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${colStyles}<tbody>${rowContents.join('')}</tbody></table>`;return html;}