Skip to content

Commit

Permalink
fix: code block (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme authored Jul 4, 2024
1 parent 74eba4e commit 9d8757b
Show file tree
Hide file tree
Showing 7 changed files with 2,553 additions and 18,408 deletions.
20,943 changes: 2,550 additions & 18,393 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
/>
<!-- KaTeX CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/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>
/**
解决公众号复制字体问题
Expand Down
2 changes: 1 addition & 1 deletion src/assets/scripts/renderers/wx-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>`;
};
Expand Down
3 changes: 1 addition & 2 deletions src/assets/scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ export function exportHTML() {
// 判断是否是包裹代码块的 code 元素
function isCode(element) {
return (

Check failure on line 287 in src/assets/scripts/util.js

View workflow job for this annotation

GitHub Actions / build-and-deploy

Replace `(⏎········element.tagName·===·`CODE`⏎······)` with `element.tagName·===·`CODE``
element.tagName === `CODE` &&
Array.from(element.classList).includes(`prettyprint`)
element.tagName === `CODE`
)
}

Expand Down
7 changes: 0 additions & 7 deletions src/components/CodemirrorEditor/EditorHeader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions src/views/CodemirrorEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ export default {
onEditorRefresh() {
this.codeThemeChanged(this.codeTheme)
this.editorRefresh()
setTimeout(() => window.PR.prettyPrint(), 0)
},
// 复制结束
endCopy() {
Expand Down Expand Up @@ -607,7 +606,6 @@ export default {
mounted() {
setTimeout(() => {
this.leftAndRightScroll()
window.PR.prettyPrint()
}, 300)
},
setup() {
Expand Down

0 comments on commit 9d8757b

Please sign in to comment.