diff --git a/package-lock.json b/package-lock.json index 4c4eac7..dccde00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "perfect-markdown", - "version": "1.0.19", + "version": "1.0.20", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 39bc846..418dc99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perfect-markdown", - "version": "1.0.19", + "version": "1.0.20", "main": "src/index.js", "files": [ "lib", diff --git a/src/views/editor.vue b/src/views/editor.vue index e930bbe..04de0a3 100644 --- a/src/views/editor.vue +++ b/src/views/editor.vue @@ -31,6 +31,7 @@ v-show="showTextarea" :class="[editorIsSplit? 'split': 'one', 'markdown-input']" @scroll="editOnScroll" + @click="textareaFocus" ref="inputEdit" > @@ -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 @@ -341,6 +344,9 @@ export default { }, editOnScroll(e) { scrollLink(e, this) + }, + textareaFocus() { + this.$refs['autoTextarea'].$refs['textarea'].focus() } }, watch: {