From c7c13fdd6cca583f60cb7a3b4f76efd5bf4e6d45 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Sun, 22 May 2022 01:57:50 +0800 Subject: [PATCH] Optimize the position of copy-button (#508) --- scripts/helpers/next-config.js | 2 +- source/css/_common/scaffolding/highlight/copy-code.styl | 6 ++++++ source/js/next-boot.js | 2 +- source/js/utils.js | 6 ++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/helpers/next-config.js b/scripts/helpers/next-config.js index b1973d6..25c28a3 100644 --- a/scripts/helpers/next-config.js +++ b/scripts/helpers/next-config.js @@ -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, diff --git a/source/css/_common/scaffolding/highlight/copy-code.styl b/source/css/_common/scaffolding/highlight/copy-code.styl index 1b0651e..a787b84 100644 --- a/source/css/_common/scaffolding/highlight/copy-code.styl +++ b/source/css/_common/scaffolding/highlight/copy-code.styl @@ -2,6 +2,12 @@ opacity: 1; } +figure.highlight { + .table-container { + position: relative; + } +} + .copy-btn { color: $black-dim; cursor: pointer; diff --git a/source/js/next-boot.js b/source/js/next-boot.js index 6262daa..1225fd2 100644 --- a/source/js/next-boot.js +++ b/source/js/next-boot.js @@ -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(); }; diff --git a/source/js/utils.js b/source/js/utils.js index 0a0665b..9920825 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -51,8 +51,10 @@ NexT.utils = { span.classList.replace(name, `hljs-${name}`); }); }); - if (!CONFIG.copycode) return; - element.insertAdjacentHTML('beforeend', '