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