Skip to content

Commit acb153a

Browse files
committed
fix(web): preserve citation text in html table copy
1 parent fb8b094 commit acb153a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎apps/web/src/markdown-clipboard.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,13 @@ describe("copying a table as HTML", () => {
507507
td("run:<br>if&nbsp;x:<br>&nbsp;&nbsp;&nbsp;&nbsp;y&nbsp;&nbsp;=&nbsp;&nbsp;1<br><br>end"),
508508
);
509509
expect(content(new FakeText("1\u00a0000 EUR"))).toBe(td("1&nbsp;000 EUR"));
510+
expect(
511+
content(
512+
new FakeElement("BUTTON", [], {
513+
"data-markdown-copy": "[source](https://example.com)",
514+
}).append(new FakeText("source")),
515+
),
516+
).toBe(td("source"));
510517
});
511518

512519
it("keeps a right-to-left table's direction and puts headers on its start side", () => {

‎apps/web/src/markdown-clipboard.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ function collectHtmlCellText(node: Node, parts: string[], preformatted: boolean)
438438
}
439439
if (child.nodeType !== Node.ELEMENT_NODE) continue;
440440
const element = child as Element;
441-
if (isSkippedElement(element)) continue;
441+
if (isSkippedElement(element) && !element.hasAttribute("data-markdown-copy")) continue;
442442
if (element.hasAttribute("data-markdown-math")) {
443443
parts.push(element.getAttribute("data-markdown-copy")?.trim() ?? "");
444444
continue;

0 commit comments

Comments
 (0)