Skip to content

Commit 28f0e37

Browse files
committed
Don't return a table if there is auxiliary text with it
1 parent b2fde14 commit 28f0e37

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/paste-markdown-table.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ function tableMarkdown(node: Element): string {
8585
function parseTable(html: string): HTMLElement | null {
8686
const el = document.createElement('div')
8787
el.innerHTML = html
88-
return el.querySelector('table')
88+
89+
const table = el.querySelector('table')
90+
table?.remove()
91+
92+
// Reject tables that have extra text around them.
93+
if (el?.textContent?.trim()) {
94+
return null
95+
}
96+
97+
return table
8998
}
9099

91100
function getTable(transfer: DataTransfer): HTMLElement | null {

0 commit comments

Comments
 (0)