mirror of
https://github.com/welpo/tabi.git
synced 2026-05-14 10:07:34 +02:00
Avoid copying code line numbers
the copy code button would include line numbers, which is not good. This change removes them from the copied text by removing elements with the `.giallo-ln` class.
This commit is contained in:
parent
17029f02b1
commit
e7360f31f2
1 changed files with 7 additions and 1 deletions
|
|
@ -27,7 +27,13 @@ const copyCodeAndChangeIcon = async (copyDiv, block) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNonTableCode = (block) => {
|
const getNonTableCode = (block) => {
|
||||||
return [...block.querySelectorAll('code')].map((code) => code.textContent).join('');
|
return [...block.querySelectorAll('code')]
|
||||||
|
.map((code) => {
|
||||||
|
const clone = code.cloneNode(true);
|
||||||
|
clone.querySelectorAll('.giallo-ln').forEach(el => el.remove());
|
||||||
|
return clone.textContent;
|
||||||
|
})
|
||||||
|
.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTableCode = (block) => {
|
const getTableCode = (block) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue