mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
remove redundant ending new line when copying code block in read mode
This commit is contained in:
parent
ada7400306
commit
3b1d9e9cbf
@ -278,8 +278,19 @@ window.onwheel = function(e) {
|
|||||||
|
|
||||||
var skipScrollCheckRange = null;
|
var skipScrollCheckRange = null;
|
||||||
|
|
||||||
|
var VClipboardDataTextAttr = 'source-text';
|
||||||
|
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
new ClipboardJS('.vnote-copy-clipboard-btn');
|
new ClipboardJS('.vnote-copy-clipboard-btn', {
|
||||||
|
text: function(trigger) {
|
||||||
|
var t = trigger.getAttribute(VClipboardDataTextAttr);
|
||||||
|
if (t[t.length - 1] == '\n') {
|
||||||
|
return t.substring(0, t.length - 1);
|
||||||
|
} else {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.onscroll = function() {
|
window.onscroll = function() {
|
||||||
@ -1290,7 +1301,7 @@ var addCopyButtonToCodeBlock = function() {
|
|||||||
btn.classList.add('vnote-btn');
|
btn.classList.add('vnote-btn');
|
||||||
btn.classList.add('vnote-copy-clipboard-btn');
|
btn.classList.add('vnote-copy-clipboard-btn');
|
||||||
btn.setAttribute('type', 'button');
|
btn.setAttribute('type', 'button');
|
||||||
btn.setAttribute('data-clipboard-text', code.textContent);
|
btn.setAttribute(VClipboardDataTextAttr, code.textContent);
|
||||||
code.insertAdjacentElement('beforebegin', btn);
|
code.insertAdjacentElement('beforebegin', btn);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user