Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: code block #310

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -284,9 +284,8 @@

// 判断是否是包裹代码块的 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-preview

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
Loading