diff --git a/electron/config.js b/electron/config.js index 7c443ead..f3ecd97d 100644 --- a/electron/config.js +++ b/electron/config.js @@ -35,6 +35,8 @@ const schema = { "showInMenu": {type: "boolean", default: false}, "alwaysOnTop": {type: "boolean", default: false}, "bracketClosing": {type: "boolean", default: false}, + "defaultBlockLanguage": {type: "string"}, + "defaultBlockLanguageAutoDetect": {type: "boolean"}, // when default font settings are used, fontFamily and fontSize is not specified in the // settings file, so that it's possible for us to change the default settings in the diff --git a/src/components/App.vue b/src/components/App.vue index 4f400bc7..08234d50 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -122,6 +122,8 @@ :bracketClosing="settings.bracketClosing" :fontFamily="settings.fontFamily" :fontSize="settings.fontSize" + :defaultBlockLanguage="settings.defaultBlockLanguage || 'text'" + :defaultBlockLanguageAutoDetect="settings.defaultBlockLanguageAutoDetect === undefined ? true : settings.defaultBlockLanguageAutoDetect" class="editor" ref="editor" @openLanguageSelector="openLanguageSelector" diff --git a/src/components/Editor.vue b/src/components/Editor.vue index 7171a805..b3bc9389 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -29,6 +29,8 @@ }, fontFamily: String, fontSize: Number, + defaultBlockLanguage: String, + defaultBlockLanguageAutoDetect: Boolean, }, components: {}, @@ -78,6 +80,7 @@ }) window._heynote_editor = this.editor window.document.addEventListener("currenciesLoaded", this.onCurrenciesLoaded) + this.editor.setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect) // set up buffer change listener window.heynote.buffer.onChangeCallback((event, content) => { @@ -145,12 +148,18 @@ fontSize() { this.editor.setFont(this.fontFamily, this.fontSize) }, + defaultBlockLanguage() { + this.editor.setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect) + }, + defaultBlockLanguageAutoDetect() { + this.editor.setDefaultBlockLanguage(this.defaultBlockLanguage, this.defaultBlockLanguageAutoDetect) + }, }, methods: { setLanguage(language) { if (language === "auto") { - this.editor.setCurrentLanguage("text", true) + this.editor.setCurrentLanguage(null, true) } else { this.editor.setCurrentLanguage(language, false) } diff --git a/src/components/settings/Settings.vue b/src/components/settings/Settings.vue index 42c9ee6f..57d98e95 100644 --- a/src/components/settings/Settings.vue +++ b/src/components/settings/Settings.vue @@ -1,10 +1,14 @@