mirror of
https://github.com/katanemo/plano.git
synced 2026-06-02 14:35:14 +02:00
deploy: 15c6c62df0
This commit is contained in:
parent
25b7f56208
commit
4605c2696d
34 changed files with 51 additions and 2 deletions
18
_static/js/fix-copy.js
Executable file
18
_static/js/fix-copy.js
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
/* Fix: Prevent "Copy code" button label from appearing in clipboard content.
|
||||
*
|
||||
* sphinxawesome_theme inserts a copy button inside <pre> elements. When
|
||||
* clipboard.js selects all children of the <pre> to copy, the button's
|
||||
* sr-only text ("Copy code") is included in the selection. This listener
|
||||
* intercepts the copy event and strips that trailing label from the data
|
||||
* written to the clipboard.
|
||||
*/
|
||||
document.addEventListener('copy', function (e) {
|
||||
if (!e.clipboardData) { return; }
|
||||
var selection = window.getSelection();
|
||||
if (!selection) { return; }
|
||||
var text = selection.toString();
|
||||
var clean = text.replace(/\nCopy code\s*$/, '');
|
||||
if (clean === text) { return; }
|
||||
e.clipboardData.setData('text/plain', clean);
|
||||
e.preventDefault();
|
||||
}, true);
|
||||
Loading…
Add table
Add a link
Reference in a new issue