Propagate settings changes to all cached Editor instances (and not just the active one)

This commit is contained in:
Jonatan Heyman 2024-08-04 17:42:53 +02:00
parent 60b5c910a9
commit 45fd167f6d

View File

@ -95,40 +95,60 @@
}, },
theme(newTheme) { theme(newTheme) {
toRaw(this.editor).setTheme(newTheme) this.eachEditor(editor => {
editor.setTheme(newTheme)
})
}, },
keymap() { keymap() {
toRaw(this.editor).setKeymap(this.keymap, this.emacsMetaKey) this.eachEditor(editor => {
editor.setKeymap(this.keymap, this.emacsMetaKey)
})
}, },
emacsMetaKey() { emacsMetaKey() {
toRaw(this.editor).setKeymap(this.keymap, this.emacsMetaKey) this.eachEditor(editor => {
editor.setKeymap(this.keymap, this.emacsMetaKey)
})
}, },
showLineNumberGutter(show) { showLineNumberGutter(show) {
toRaw(this.editor).setLineNumberGutter(show) this.eachEditor(editor => {
editor.setLineNumberGutter(show)
})
}, },
showFoldGutter(show) { showFoldGutter(show) {
toRaw(this.editor).setFoldGutter(show) this.eachEditor(editor => {
editor.setFoldGutter(show)
})
}, },
bracketClosing(value) { bracketClosing(value) {
toRaw(this.editor).setBracketClosing(value) this.eachEditor(editor => {
editor.setBracketClosing(value)
})
}, },
fontFamily() { fontFamily() {
toRaw(this.editor).setFont(this.fontFamily, this.fontSize) this.eachEditor(editor => {
editor.setFont(this.fontFamily, this.fontSize)
})
}, },
fontSize() { fontSize() {
toRaw(this.editor).setFont(this.fontFamily, this.fontSize) this.eachEditor(editor => {
editor.setFont(this.fontFamily, this.fontSize)
})
}, },
defaultBlockLanguage() { defaultBlockLanguage() {
toRaw(this.editor).setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect) this.eachEditor(editor => {
editor.setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect)
})
}, },
defaultBlockLanguageAutoDetect() { defaultBlockLanguageAutoDetect() {
toRaw(this.editor).setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect) this.eachEditor(editor => {
editor.setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect)
})
}, },
}, },
@ -225,6 +245,10 @@
focus() { focus() {
toRaw(this.editor).focus() toRaw(this.editor).focus()
}, },
eachEditor(fn) {
Object.values(toRaw(this.editorCache).cache).forEach(fn)
},
}, },
} }
</script> </script>