Skip to content

Commit

Permalink
Propagate settings changes to all cached Editor instances (and not ju…
Browse files Browse the repository at this point in the history
…st the active one)
  • Loading branch information
heyman committed Aug 4, 2024
1 parent 60b5c91 commit 45fd167
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,60 @@
},
theme(newTheme) {
toRaw(this.editor).setTheme(newTheme)
this.eachEditor(editor => {
editor.setTheme(newTheme)
})
},
keymap() {
toRaw(this.editor).setKeymap(this.keymap, this.emacsMetaKey)
this.eachEditor(editor => {
editor.setKeymap(this.keymap, this.emacsMetaKey)
})
},
emacsMetaKey() {
toRaw(this.editor).setKeymap(this.keymap, this.emacsMetaKey)
this.eachEditor(editor => {
editor.setKeymap(this.keymap, this.emacsMetaKey)
})
},
showLineNumberGutter(show) {
toRaw(this.editor).setLineNumberGutter(show)
this.eachEditor(editor => {
editor.setLineNumberGutter(show)
})
},
showFoldGutter(show) {
toRaw(this.editor).setFoldGutter(show)
this.eachEditor(editor => {
editor.setFoldGutter(show)
})
},
bracketClosing(value) {
toRaw(this.editor).setBracketClosing(value)
this.eachEditor(editor => {
editor.setBracketClosing(value)
})
},
fontFamily() {
toRaw(this.editor).setFont(this.fontFamily, this.fontSize)
this.eachEditor(editor => {
editor.setFont(this.fontFamily, this.fontSize)
})
},
fontSize() {
toRaw(this.editor).setFont(this.fontFamily, this.fontSize)
this.eachEditor(editor => {
editor.setFont(this.fontFamily, this.fontSize)
})
},
defaultBlockLanguage() {
toRaw(this.editor).setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect)
this.eachEditor(editor => {
editor.setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect)
})
},
defaultBlockLanguageAutoDetect() {
toRaw(this.editor).setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect)
this.eachEditor(editor => {
editor.setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect)
})
},
},
Expand Down Expand Up @@ -225,6 +245,10 @@
focus() {
toRaw(this.editor).focus()
},
eachEditor(fn) {
Object.values(toRaw(this.editorCache).cache).forEach(fn)
},
},
}
</script>
Expand Down

0 comments on commit 45fd167

Please sign in to comment.