Skip to content

Commit

Permalink
Merge pull request #29 from li-xiaoqing/dev
Browse files Browse the repository at this point in the history
perf: 增加输入框focus逻辑,修复mathjax问题
  • Loading branch information
li-xiaoqing authored May 12, 2020
2 parents b5a1bbd + d350af9 commit b54bada
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "perfect-markdown",
"version": "1.0.19",
"version": "1.0.20",
"main": "src/index.js",
"files": [
"lib",
Expand Down
12 changes: 9 additions & 3 deletions src/views/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
v-show="showTextarea"
:class="[editorIsSplit? 'split': 'one', 'markdown-input']"
@scroll="editOnScroll"
@click="textareaFocus"
ref="inputEdit"
>
<auto-textarea ref="autoTextarea" v-model="localValue"></auto-textarea>
Expand Down Expand Up @@ -293,9 +294,11 @@ export default {
if (this.plugins.mathjax) {
setTimeout(() => {
// todos: split MathJax render
window.MathJax && window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub, document.getElementsByClassName('copy-html'), () => {
const copy = document.getElementsByClassName('copy-html')[0].innerHTML
document.getElementsByClassName('markdown-render')[0].innerHTML = copy
const copyDom = document.getElementsByClassName('copy-html')
const renderDom = document.getElementsByClassName('markdown-render')
window.MathJax && window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub, copyDom, () => {
const copy = copyDom[0] && copyDom[0].innerHTML
renderDom[0] && (renderDom[0].innerHTML = copy)
}])
}, 200)
// todos: split transform the code latex => mathajx
Expand Down Expand Up @@ -341,6 +344,9 @@ export default {
},
editOnScroll(e) {
scrollLink(e, this)
},
textareaFocus() {
this.$refs['autoTextarea'].$refs['textarea'].focus()
}
},
watch: {
Expand Down

0 comments on commit b54bada

Please sign in to comment.