mirror of
https://github.com/dream-num/univer.git
synced 2026-09-24 15:32:18 +08:00
fix(copy): fix copy id (#6469)
This commit is contained in:
+1
-1
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user