fix: code block (#310)

This commit is contained in:
Libin YANG 2024-07-04 19:08:58 +08:00 committed by GitHub
parent 74eba4e5fa
commit 9d8757bd39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 2553 additions and 18408 deletions

20943
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,6 @@
"minio": "7.0.33",
"node-fetch": "^3.2.10",
"pinia": "^2.1.6",
"prettify": "^0.1.7",
"qiniu-js": "^3.4.1",
"uuid": "^8.3.2",
"vue": "^2.7.14"

View File

@ -30,8 +30,7 @@
/>
<!-- KaTeX CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css" integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/prettify/r298/prettify.min.js"></script>
<style>
/**
解决公众号复制字体问题

View File

@ -145,7 +145,7 @@ class WxRenderer {
return `<pre class="hljs code__pre" ${getStyles(
"code_pre"
)}><code class="prettyprint language-${lang}" ${getStyles(
)}><code class="language-${lang}" ${getStyles(
"code"
)}>${text}</code></pre>`;
};

View File

@ -285,8 +285,7 @@ export function exportHTML() {
// 判断是否是包裹代码块的 code 元素
function isCode(element) {
return (
element.tagName === `CODE` &&
Array.from(element.classList).includes(`prettyprint`)
element.tagName === `CODE`
)
}

View File

@ -397,13 +397,6 @@ export default {
)
// position translateY
.replace(/top:(.*?)em/g, `transform: translateY($1em)`)
if (this.isMacCodeBlock) {
clipboardDiv.innerHTML = clipboardDiv.innerHTML.replaceAll(
/(<code class="prettyprint[^>]*)(style=")/g,
`$1style="font-family: Menlo, 'Operator Mono', Consolas, Monaco, monospace;`
)
}
clipboardDiv.focus()
window.getSelection().removeAllRanges()
let range = document.createRange()

View File

@ -440,7 +440,6 @@ export default {
onEditorRefresh() {
this.codeThemeChanged(this.codeTheme)
this.editorRefresh()
setTimeout(() => window.PR.prettyPrint(), 0)
},
//
endCopy() {
@ -607,7 +606,6 @@ export default {
mounted() {
setTimeout(() => {
this.leftAndRightScroll()
window.PR.prettyPrint()
}, 300)
},
setup() {