Skip to content

Commit

Permalink
fix(editor): debounce updating reader content from editor content
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Nov 7, 2023
1 parent eea91d2 commit 736f80f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/mixins/editorMixin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import debounce from 'debounce'
import { mapGetters, mapMutations } from 'vuex'
import linkHandlerMixin from '../mixins/linkHandlerMixin.js'
import PageInfoBar from '../components/Page/PageInfoBar.vue'
Expand Down Expand Up @@ -97,8 +98,7 @@ export default {
this.done('editor')
},
onUpdate: ({ markdown }) => {
this.editorContent = markdown
this.reader?.setContent(this.editorContent)
this.updateEditorContent(markdown)
},
onOutlineToggle: (visible) => {
this.toggleOutlineFromEditor(visible)
Expand All @@ -107,6 +107,11 @@ export default {
: null
},

updateEditorContent: debounce(function(markdown) {
this.editorContent = markdown
this.reader?.setContent(this.editorContent)
}, 200),

focusEditor() {
this.editor?.focus()
},
Expand Down

0 comments on commit 736f80f

Please sign in to comment.