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

20941
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -31,7 +31,6 @@
<!-- KaTeX CSS --> <!-- 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"> <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> <style>
/** /**
解决公众号复制字体问题 解决公众号复制字体问题

View File

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

View File

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

View File

@ -397,13 +397,6 @@ export default {
) )
// position translateY // position translateY
.replace(/top:(.*?)em/g, `transform: translateY($1em)`) .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() clipboardDiv.focus()
window.getSelection().removeAllRanges() window.getSelection().removeAllRanges()
let range = document.createRange() let range = document.createRange()

View File

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