mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Optimize the position of copy-button (#508)
This commit is contained in:
parent
d932e308d4
commit
c7c13fdd6c
@ -18,7 +18,7 @@ hexo.extend.helper.register('next_config', function() {
|
|||||||
version : this.next_version,
|
version : this.next_version,
|
||||||
exturl : theme.exturl,
|
exturl : theme.exturl,
|
||||||
sidebar : theme.sidebar,
|
sidebar : theme.sidebar,
|
||||||
copycode : theme.codeblock.copy_button.enable,
|
copycode : theme.codeblock.copy_button,
|
||||||
bookmark : theme.bookmark,
|
bookmark : theme.bookmark,
|
||||||
mediumzoom: theme.mediumzoom,
|
mediumzoom: theme.mediumzoom,
|
||||||
lazyload : theme.lazyload,
|
lazyload : theme.lazyload,
|
||||||
|
|||||||
@ -2,6 +2,12 @@
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
figure.highlight {
|
||||||
|
.table-container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.copy-btn {
|
.copy-btn {
|
||||||
color: $black-dim;
|
color: $black-dim;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
@ -45,13 +45,13 @@ NexT.boot.refresh = function() {
|
|||||||
CONFIG.pangu && window.pangu.spacingPage();
|
CONFIG.pangu && window.pangu.spacingPage();
|
||||||
|
|
||||||
CONFIG.exturl && NexT.utils.registerExtURL();
|
CONFIG.exturl && NexT.utils.registerExtURL();
|
||||||
|
NexT.utils.wrapTableWithBox();
|
||||||
NexT.utils.registerCopyCode();
|
NexT.utils.registerCopyCode();
|
||||||
NexT.utils.registerTabsTag();
|
NexT.utils.registerTabsTag();
|
||||||
NexT.utils.registerActiveMenuItem();
|
NexT.utils.registerActiveMenuItem();
|
||||||
NexT.utils.registerLangSelect();
|
NexT.utils.registerLangSelect();
|
||||||
NexT.utils.registerSidebarTOC();
|
NexT.utils.registerSidebarTOC();
|
||||||
NexT.utils.registerPostReward();
|
NexT.utils.registerPostReward();
|
||||||
NexT.utils.wrapTableWithBox();
|
|
||||||
NexT.utils.registerVideoIframe();
|
NexT.utils.registerVideoIframe();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -51,8 +51,10 @@ NexT.utils = {
|
|||||||
span.classList.replace(name, `hljs-${name}`);
|
span.classList.replace(name, `hljs-${name}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (!CONFIG.copycode) return;
|
if (!CONFIG.copycode.enable) return;
|
||||||
element.insertAdjacentHTML('beforeend', '<div class="copy-btn"><i class="fa fa-copy fa-fw"></i></div>');
|
let target = element;
|
||||||
|
if (CONFIG.copycode.style !== 'mac') target = element.querySelector('.table-container') || element;
|
||||||
|
target.insertAdjacentHTML('beforeend', '<div class="copy-btn"><i class="fa fa-copy fa-fw"></i></div>');
|
||||||
const button = element.querySelector('.copy-btn');
|
const button = element.querySelector('.copy-btn');
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
const lines = element.querySelector('.code') || element.querySelector('code');
|
const lines = element.querySelector('.code') || element.querySelector('code');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user