@exlg/mod-code-block-ex
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -1,1 +0,1 @@ | ||
"use strict";(()=>{var l=runtime.storage,m={c:"C",cpp:"C++",pascal:"Pascal",python:"Python",java:"Java",javascript:"JavaScript",php:"PHP",latex:"LaTeX"},f=a=>{let e=utils.match(/\/record\/.*/),u=i=>{var t;let o="undefined";if(e)return utils.processXSS($($(".value.lfe-caption")[0]).text());let c=i.attr("data-rendered-lang");return c?o=c:(t=i.attr("class"))==null||t.split(" ").forEach(s=>{s.startsWith("language-")&&(o=s.slice(9))}),m[o]};a.attr("exlg-copy-code-block",""),a.each((i,o,c=$(o))=>{if(o.parentNode){let n=$(o.parentNode);if(n.hasClass("mp-preview-content")||n.hasClass("mp-preview-area"))return}let t=e?c.siblings(".copy-btn"):$('<div class="exlg-copy">复制</div>').on("click",()=>{if(t.text()==="复制"){try{utils.setClipboard(c.text())}catch(n){t.text("复制失败").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),800),error("复制到剪贴板失败,错误信息: ",n);return}t.text("复制成功").toggleClass("exlg-copied"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").css("color","#52c41a"),800)}}),s=c.children("code"),r=l.get("copy_code_font");r&&s.css("font-family",r),s.hasClass("hljs")||s.addClass("hljs").css("background",l.get("cb_background_color")),t.addClass(`exlg-copy-${l.get("copy_code_position")}`);let g=u(s),d=g?l.get("code_block_title").replace("{lang}",g):l.get("code_block_title_nolang"),p=e?$(".lfe-h3").text(d):$(`<h3 class="exlg-code-title" style="/*width: 100%;*/">${d}</h3>`);l.get("beautify_code_block")&&p.addClass("exlg-beautified-cbex"),e||c.before(p.append(t))})};utils.addHookSelector("pre:has(> code:not(.cm-s-default)):not([exlg-copy-code-block])",({hookedNodes:a})=>{a.forEach(e=>{e.nodeType===e.ELEMENT_NODE&&f($(e))})});})(); | ||
"use strict";(()=>{var l=runtime.storage,m={c:"C",cpp:"C++",pascal:"Pascal",python:"Python",java:"Java",javascript:"JavaScript",php:"PHP",latex:"LaTeX"},f=a=>{let e=utils.match(/\/record\/.*/),u=i=>{var t;let o="undefined";if(e)return utils.processXSS($($(".value.lfe-caption")[0]).text());let c=i.attr("data-rendered-lang");return c?o=c:(t=i.attr("class"))==null||t.split(" ").forEach(s=>{s.startsWith("language-")&&(o=s.slice(9))}),m[o]};a.attr("exlg-copy-code-block",""),a.each((i,o,c=$(o))=>{if(o.parentNode){let n=$(o.parentNode);if(n.hasClass("mp-preview-content")||n.hasClass("mp-preview-area"))return}let t=e?c.siblings(".copy-btn"):$('<div class="exlg-copy">复制</div>').on("click",()=>{if(t.text()==="复制"){try{utils.setClipboard(c.text())}catch(n){t.text("复制失败").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),800),error("复制到剪贴板失败,错误信息: ",n);return}t.text("复制成功").toggleClass("exlg-copied"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").css("color","#52c41a"),800)}}),s=c.children("code"),r=l.get("copy_code_font");r&&s.css("font-family",r),s.hasClass("hljs")||s.addClass("hljs").css("background",l.get("cb_background_color")),t.addClass(`exlg-copy-${l.get("copy_code_position")}`);let g=u(s),d=g?l.get("code_block_title").replace("{lang}",g):l.get("code_block_title_nolang"),p=e?$(".lfe-h3").text(d):$(`<h3 class="exlg-code-title" style="/*width: 100%;*/">${d}</h3>`);l.get("beautify_code_block")&&!e&&p.addClass("exlg-beautified-cbex"),e||c.before(p.append(t))})};utils.addHookSelector("pre:has(> code:not(.cm-s-default)):not([exlg-copy-code-block])",({hookedNodes:a})=>{a.forEach(e=>{e.nodeType===e.ELEMENT_NODE&&f($(e))})});})(); |
@@ -1,2 +0,2 @@ | ||
define({"schema":{"uid":27,"refs":{"1":{"type":"const","meta":{"description":"左对齐"},"value":"left"},"3":{"type":"const","meta":{"description":"右对齐"},"value":"right"},"6":{"type":"union","meta":{"default":"right","description":"复制按钮对齐方式"},"list":[1,3]},"9":{"type":"boolean","meta":{"default":true,"description":"代码块美化"}},"12":{"type":"string","meta":{"default":"源代码 - {lang}","description":"自定义代码块标题 - 限定语言"}},"15":{"type":"string","meta":{"default":"源代码","description":"自定义代码块标题 - 默认"}},"18":{"type":"string","meta":{"default":"'Fira Code', 'Fira Mono', 'Consolas'","description":"代码块字体"}},"21":{"type":"string","meta":{"default":"white","description":"代码块背景色 (配合其他美化插件)"}},"26":{"type":"number","meta":{"default":-1,"min":-1,"max":100,"description":"代码块最大显示行数"}},"27":{"type":"object","meta":{"default":{}},"dict":{"copy_code_position":6,"beautify_code_block":9,"code_block_title":12,"code_block_title_nolang":15,"copy_code_font":18,"cb_background_color":21,"max_show_lines":26}}}},"entry":()=>{"use strict";(()=>{var l=runtime.storage,m={c:"C",cpp:"C++",pascal:"Pascal",python:"Python",java:"Java",javascript:"JavaScript",php:"PHP",latex:"LaTeX"},f=a=>{let e=utils.match(/\/record\/.*/),u=i=>{var t;let o="undefined";if(e)return utils.processXSS($($(".value.lfe-caption")[0]).text());let c=i.attr("data-rendered-lang");return c?o=c:(t=i.attr("class"))==null||t.split(" ").forEach(s=>{s.startsWith("language-")&&(o=s.slice(9))}),m[o]};a.attr("exlg-copy-code-block",""),a.each((i,o,c=$(o))=>{if(o.parentNode){let n=$(o.parentNode);if(n.hasClass("mp-preview-content")||n.hasClass("mp-preview-area"))return}let t=e?c.siblings(".copy-btn"):$('<div class="exlg-copy">复制</div>').on("click",()=>{if(t.text()==="复制"){try{utils.setClipboard(c.text())}catch(n){t.text("复制失败").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),800),error("复制到剪贴板失败,错误信息: ",n);return}t.text("复制成功").toggleClass("exlg-copied"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").css("color","#52c41a"),800)}}),s=c.children("code"),r=l.get("copy_code_font");r&&s.css("font-family",r),s.hasClass("hljs")||s.addClass("hljs").css("background",l.get("cb_background_color")),t.addClass(`exlg-copy-${l.get("copy_code_position")}`);let g=u(s),d=g?l.get("code_block_title").replace("{lang}",g):l.get("code_block_title_nolang"),p=e?$(".lfe-h3").text(d):$(`<h3 class="exlg-code-title" style="/*width: 100%;*/">${d}</h3>`);l.get("beautify_code_block")&&p.addClass("exlg-beautified-cbex"),e||c.before(p.append(t))})};utils.addHookSelector("pre:has(> code:not(.cm-s-default)):not([exlg-copy-code-block])",({hookedNodes:a})=>{a.forEach(e=>{e.nodeType===e.ELEMENT_NODE&&f($(e))})});})(); | ||
define({"schema":{"uid":27,"refs":{"1":{"type":"const","meta":{"description":"左对齐"},"value":"left"},"3":{"type":"const","meta":{"description":"右对齐"},"value":"right"},"6":{"type":"union","meta":{"default":"right","description":"复制按钮对齐方式"},"list":[1,3]},"9":{"type":"boolean","meta":{"default":true,"description":"代码块美化"}},"12":{"type":"string","meta":{"default":"源代码 - {lang}","description":"自定义代码块标题 - 限定语言"}},"15":{"type":"string","meta":{"default":"源代码","description":"自定义代码块标题 - 默认"}},"18":{"type":"string","meta":{"default":"'Fira Code', 'Fira Mono', 'Consolas'","description":"代码块字体"}},"21":{"type":"string","meta":{"default":"white","description":"代码块背景色 (配合其他美化插件)"}},"26":{"type":"number","meta":{"default":-1,"min":-1,"max":100,"description":"代码块最大显示行数"}},"27":{"type":"object","meta":{"default":{}},"dict":{"copy_code_position":6,"beautify_code_block":9,"code_block_title":12,"code_block_title_nolang":15,"copy_code_font":18,"cb_background_color":21,"max_show_lines":26}}}},"entry":()=>{"use strict";(()=>{var l=runtime.storage,m={c:"C",cpp:"C++",pascal:"Pascal",python:"Python",java:"Java",javascript:"JavaScript",php:"PHP",latex:"LaTeX"},f=a=>{let e=utils.match(/\/record\/.*/),u=i=>{var t;let o="undefined";if(e)return utils.processXSS($($(".value.lfe-caption")[0]).text());let c=i.attr("data-rendered-lang");return c?o=c:(t=i.attr("class"))==null||t.split(" ").forEach(s=>{s.startsWith("language-")&&(o=s.slice(9))}),m[o]};a.attr("exlg-copy-code-block",""),a.each((i,o,c=$(o))=>{if(o.parentNode){let n=$(o.parentNode);if(n.hasClass("mp-preview-content")||n.hasClass("mp-preview-area"))return}let t=e?c.siblings(".copy-btn"):$('<div class="exlg-copy">复制</div>').on("click",()=>{if(t.text()==="复制"){try{utils.setClipboard(c.text())}catch(n){t.text("复制失败").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").toggleClass("exlg-copied-fail"),800),error("复制到剪贴板失败,错误信息: ",n);return}t.text("复制成功").toggleClass("exlg-copied"),setTimeout(()=>t.text("复制").toggleClass("exlg-copied").css("color","#52c41a"),800)}}),s=c.children("code"),r=l.get("copy_code_font");r&&s.css("font-family",r),s.hasClass("hljs")||s.addClass("hljs").css("background",l.get("cb_background_color")),t.addClass(`exlg-copy-${l.get("copy_code_position")}`);let g=u(s),d=g?l.get("code_block_title").replace("{lang}",g):l.get("code_block_title_nolang"),p=e?$(".lfe-h3").text(d):$(`<h3 class="exlg-code-title" style="/*width: 100%;*/">${d}</h3>`);l.get("beautify_code_block")&&!e&&p.addClass("exlg-beautified-cbex"),e||c.before(p.append(t))})};utils.addHookSelector("pre:has(> code:not(.cm-s-default)):not([exlg-copy-code-block])",({hookedNodes:a})=>{a.forEach(e=>{e.nodeType===e.ELEMENT_NODE&&f($(e))})});})(); | ||
},"style":".exlg-copy{position:relative;display:inline-block;border:1px solid #3498db;border-radius:3px;background-color:#3498db00;color:#3498db;font-family:-apple-system,BlinkMacSystemFont,San Francisco,Helvetica Neue,Noto Sans,Noto Sans CJK SC,Noto Sans CJK,Source Han Sans,PingFang SC,Segoe UI,Microsoft YaHei,sans-serif;flex:none;outline:0;cursor:pointer;font-weight:400;line-height:1.5;text-align:center;vertical-align:middle;background:0 0;font-size:12px;padding:0 5px;margin-left:1px}.exlg-copy-right{float:right}.exlg-copy:hover{background-color:#3498db1a}div.exlg-copied{background-color:#3498dbe6!important;color:#fff!important}div.exlg-copied.exlg-copied-fail{background-color:#db3434e6!important;color:#fff!important}.copy-btn{font-size:.8em;padding:0 5px}.lfe-form-sz-middle{font-size:.875em;padding:.313em 1em}.exlg-code-title{margin:0;font-family:inherit;font-size:1.125em;color:inherit}h3.exlg-code-title.exlg-beautified-cbex{margin-bottom:0!important;padding:.4rem .6rem .4rem 2rem;background-color:#eee;font-weight:700;border-top-left-radius:5px;border-top-right-radius:5px;padding-top:8px;margin-top:10px;box-shadow:0 2px 2px #00000024,0 1px 5px #0000001f,0 3px 1px -2px #0003}h3.exlg-code-title.exlg-beautified-cbex+pre[exlg-copy-code-block]{margin-top:0;border-bottom-left-radius:5px;border-bottom-right-radius:5px;border:1px solid #eee;box-shadow:0 2px 2px #00000024,0 1px 5px #0000001f,0 3px 1px -2px #0003;background-color:#fafafa}h3.exlg-code-title.exlg-beautified-cbex+pre>code.hljs[class]{font-family:Fira Code,Consolas,monospace;background:white;padding:.5em}h3.exlg-code-title.exlg-beautified-cbex>div.exlg-copy{color:#6c757d;border:0px solid #3498db;margin-left:1px;font-size:0;transition:background-color .3s;background-image:url(\"data:image/svg+xml;utf8,<svg class='icon' style='width: 1em;height: 1em;vertical-align: middle;fill: rgb(108, 117, 125);overflow: hidden;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2669'><path d='M661.333333 234.666667A64 64 0 0 1 725.333333 298.666667v597.333333a64 64 0 0 1-64 64h-469.333333A64 64 0 0 1 128 896V298.666667a64 64 0 0 1 64-64z m-21.333333 85.333333H213.333333v554.666667h426.666667v-554.666667z m191.829333-256a64 64 0 0 1 63.744 57.856l0.256 6.144v575.701333a42.666667 42.666667 0 0 1-85.034666 4.992l-0.298667-4.992V149.333333H384a42.666667 42.666667 0 0 1-42.368-37.674666L341.333333 106.666667a42.666667 42.666667 0 0 1 37.674667-42.368L384 64h447.829333z' p-id='2670'></path></svg>\");height:20px;width:20px;padding:0}h3.exlg-code-title.exlg-beautified-cbex>div.exlg-copy:hover{background-color:#6c757d1a}h3.exlg-code-title.exlg-beautified-cbex>div.exlg-copied[class]{background-color:#6c757d00!important;background-image:url(\"data:image/svg+xml;utf8,<svg class='icon' style='width: 1em;height: 1em;vertical-align: middle;fill: rgb(70, 160, 240);overflow: hidden;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2669'><path d='M661.333333 234.666667A64 64 0 0 1 725.333333 298.666667v597.333333a64 64 0 0 1-64 64h-469.333333A64 64 0 0 1 128 896V298.666667a64 64 0 0 1 64-64z m-21.333333 85.333333H213.333333v554.666667h426.666667v-554.666667z m191.829333-256a64 64 0 0 1 63.744 57.856l0.256 6.144v575.701333a42.666667 42.666667 0 0 1-85.034666 4.992l-0.298667-4.992V149.333333H384a42.666667 42.666667 0 0 1-42.368-37.674666L341.333333 106.666667a42.666667 42.666667 0 0 1 37.674667-42.368L384 64h447.829333z' p-id='2670'></path></svg>\")}h3.exlg-code-title.exlg-beautified-cbex>div.exlg-copied[class]:hover{background-color:#6c757d4d!important}h3.exlg-code-title.exlg-beautified-cbex>div.exlg-copied.exlg-copied-fail[class]{background-color:#6c757d00!important;background-image:url(\"data:image/svg+xml;utf8,<svg class='icon' style='width: 1em;height: 1em;vertical-align: middle;fill: rgb(219, 52, 52);overflow: hidden;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2669'><path d='M661.333333 234.666667A64 64 0 0 1 725.333333 298.666667v597.333333a64 64 0 0 1-64 64h-469.333333A64 64 0 0 1 128 896V298.666667a64 64 0 0 1 64-64z m-21.333333 85.333333H213.333333v554.666667h426.666667v-554.666667z m191.829333-256a64 64 0 0 1 63.744 57.856l0.256 6.144v575.701333a42.666667 42.666667 0 0 1-85.034666 4.992l-0.298667-4.992V149.333333H384a42.666667 42.666667 0 0 1-42.368-37.674666L341.333333 106.666667a42.666667 42.666667 0 0 1 37.674667-42.368L384 64h447.829333z' p-id='2670'></path></svg>\")}h3.exlg-code-title.exlg-beautified-cbex>div.exlg-copied.exlg-copied-fail[class]:hover{background-color:#6c757d4d!important}\n"}) |
@@ -5,4 +5,4 @@ { | ||
"description": "代码块优化", | ||
"author": "Cyanogenaq", | ||
"version": "1.0.4", | ||
"author": "Cyanogenaq & minstdfx", | ||
"version": "1.0.5", | ||
"main": "src/index.ts", | ||
@@ -14,7 +14,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@exlg/core": "^1.7.0" | ||
"@exlg/core": "^1.8.1" | ||
}, | ||
"devDependencies": { | ||
"@exlg/cli-mod": "^1.5.0", | ||
"schemastery": "^3.4.3" | ||
"schemastery": "^3.14.3", | ||
"@exlg/cli-mod": "^1.5.3" | ||
}, | ||
@@ -21,0 +21,0 @@ "exlgDependencies": { |
@@ -83,3 +83,3 @@ import '@exlg/core/types/module-entry' | ||
const $title = isRecord ? $('.lfe-h3').text(title_text) : $(`<h3 class="exlg-code-title" style="/*width: 100%;*/">${title_text}</h3>`) | ||
if (sto.get('beautify_code_block')) $title.addClass('exlg-beautified-cbex') | ||
if (sto.get('beautify_code_block') && !isRecord) $title.addClass('exlg-beautified-cbex') | ||
if (!isRecord) $pre.before($title.append($btn)) | ||
@@ -86,0 +86,0 @@ }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61937
309
Updated@exlg/core@^1.8.1