From 99dc099939fee0c7c110ef4f06e016356aae92df Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Wed, 24 Jul 2024 14:05:13 +0800 Subject: [PATCH] :pencil: Docs(ignore): rename function initHighlight to initCodeWrapper --- assets/js/theme.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/assets/js/theme.js b/assets/js/theme.js index ce1a3e9b..d92c7e24 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -362,8 +362,12 @@ class FixIt { } } - initHighlight() { + /** + * init code wrapper + */ + initCodeWrapper() { if (!this.config.code) { + this.initCopyCode(); return } // if markup.highlight.lineNumbersInTable set to false @@ -385,6 +389,7 @@ class FixIt { this.util.forEach(document.querySelectorAll('.highlight > .chroma:not([data-init])'), ($chroma) => { $chroma.dataset.init = 'true'; if ($chroma.parentElement.classList.contains('no-header')) { + this.initCopyCode($chroma); return; } const $codeElements = $chroma.querySelectorAll('pre.chroma > code'); @@ -481,6 +486,15 @@ class FixIt { }); } + /** + * init simple copy code when there is no code header + * https://github.com/github/clipboard-copy-element + * @param {ELement} singleCode single code block + */ + initCopyCode(singleCode) { + // TODO + } + /** * init table of contents */ @@ -976,7 +990,7 @@ class FixIt { this.initTwemoji(); this.initDetails(); this.initLightGallery(); - this.initHighlight(); + this.initCodeWrapper(); this.initTable(); this.initMath(); this.initMermaid(); @@ -994,7 +1008,7 @@ class FixIt { this.initTwemoji($content); this.initDetails($content); this.initLightGallery(); - this.initHighlight(); + this.initCodeWrapper(); this.initTable($content); this.initMath($content); this.initMermaid(); @@ -1215,7 +1229,7 @@ class FixIt { this.initTwemoji(); this.initDetails(); this.initLightGallery(); - this.initHighlight(); + this.initCodeWrapper(); this.initTable(); this.initMath(); this.initMermaid();