mirror of
https://github.com/heyman/heynote.git
synced 2025-06-27 13:01:51 +02:00
add configuration of tab size
This commit is contained in:
parent
50f3cae372
commit
7fe5404304
@ -35,6 +35,7 @@ const schema = {
|
|||||||
"showInMenu": {type: "boolean", default: false},
|
"showInMenu": {type: "boolean", default: false},
|
||||||
"alwaysOnTop": {type: "boolean", default: false},
|
"alwaysOnTop": {type: "boolean", default: false},
|
||||||
"bracketClosing": {type: "boolean", default: false},
|
"bracketClosing": {type: "boolean", default: false},
|
||||||
|
"tabSize": {type: "integer", default: 4},
|
||||||
"defaultBlockLanguage": {type: "string"},
|
"defaultBlockLanguage": {type: "string"},
|
||||||
"defaultBlockLanguageAutoDetect": {type: "boolean"},
|
"defaultBlockLanguageAutoDetect": {type: "boolean"},
|
||||||
|
|
||||||
@ -72,6 +73,7 @@ const defaults = {
|
|||||||
showInMenu: false,
|
showInMenu: false,
|
||||||
alwaysOnTop: false,
|
alwaysOnTop: false,
|
||||||
bracketClosing: false,
|
bracketClosing: false,
|
||||||
|
tabSize: 4,
|
||||||
},
|
},
|
||||||
theme: "system",
|
theme: "system",
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
showInMenu: this.initialSettings.showInMenu,
|
showInMenu: this.initialSettings.showInMenu,
|
||||||
alwaysOnTop: this.initialSettings.alwaysOnTop,
|
alwaysOnTop: this.initialSettings.alwaysOnTop,
|
||||||
bracketClosing: this.initialSettings.bracketClosing,
|
bracketClosing: this.initialSettings.bracketClosing,
|
||||||
|
tabSize: this.initialSettings.tabSize || 4,
|
||||||
autoUpdate: this.initialSettings.autoUpdate,
|
autoUpdate: this.initialSettings.autoUpdate,
|
||||||
bufferPath: this.initialSettings.bufferPath,
|
bufferPath: this.initialSettings.bufferPath,
|
||||||
fontFamily: this.initialSettings.fontFamily || defaultFontFamily,
|
fontFamily: this.initialSettings.fontFamily || defaultFontFamily,
|
||||||
@ -102,6 +103,7 @@
|
|||||||
alwaysOnTop: this.alwaysOnTop,
|
alwaysOnTop: this.alwaysOnTop,
|
||||||
autoUpdate: this.autoUpdate,
|
autoUpdate: this.autoUpdate,
|
||||||
bracketClosing: this.bracketClosing,
|
bracketClosing: this.bracketClosing,
|
||||||
|
tabSize: this.tabSize,
|
||||||
bufferPath: this.bufferPath,
|
bufferPath: this.bufferPath,
|
||||||
fontFamily: this.fontFamily === defaultFontFamily ? undefined : this.fontFamily,
|
fontFamily: this.fontFamily === defaultFontFamily ? undefined : this.fontFamily,
|
||||||
fontSize: this.fontSize === defaultFontSize ? undefined : this.fontSize,
|
fontSize: this.fontSize === defaultFontSize ? undefined : this.fontSize,
|
||||||
@ -276,6 +278,19 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="entry">
|
||||||
|
<h2>Tab Size</h2>
|
||||||
|
<select v-model="tabSize" @change="updateSettings" class="tab-size">
|
||||||
|
<option
|
||||||
|
v-for="size in [1, 2, 3, 4, 5, 6, 7, 8]"
|
||||||
|
:key="size"
|
||||||
|
:selected="tabSize === size"
|
||||||
|
:value="size"
|
||||||
|
>{{ size }} {{ size === 1 ? 'space' : 'spaces' }}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="entry">
|
<div class="entry">
|
||||||
<h2>Default Block Language</h2>
|
<h2>Default Block Language</h2>
|
||||||
|
@ -51,6 +51,7 @@ export class HeynoteEditor {
|
|||||||
bracketClosing=false,
|
bracketClosing=false,
|
||||||
fontFamily,
|
fontFamily,
|
||||||
fontSize,
|
fontSize,
|
||||||
|
tabSize=4,
|
||||||
defaultBlockToken,
|
defaultBlockToken,
|
||||||
defaultBlockAutoDetect,
|
defaultBlockAutoDetect,
|
||||||
}) {
|
}) {
|
||||||
@ -63,6 +64,7 @@ export class HeynoteEditor {
|
|||||||
this.foldGutterCompartment = new Compartment
|
this.foldGutterCompartment = new Compartment
|
||||||
this.readOnlyCompartment = new Compartment
|
this.readOnlyCompartment = new Compartment
|
||||||
this.closeBracketsCompartment = new Compartment
|
this.closeBracketsCompartment = new Compartment
|
||||||
|
this.indentUnitCompartment = new Compartment
|
||||||
this.deselectOnCopy = keymap === "emacs"
|
this.deselectOnCopy = keymap === "emacs"
|
||||||
this.emacsMetaKey = emacsMetaKey
|
this.emacsMetaKey = emacsMetaKey
|
||||||
this.fontTheme = new Compartment
|
this.fontTheme = new Compartment
|
||||||
@ -91,7 +93,7 @@ export class HeynoteEditor {
|
|||||||
this.themeCompartment.of(theme === "dark" ? heynoteDark : heynoteLight),
|
this.themeCompartment.of(theme === "dark" ? heynoteDark : heynoteLight),
|
||||||
heynoteBase,
|
heynoteBase,
|
||||||
this.fontTheme.of(getFontTheme(fontFamily, fontSize)),
|
this.fontTheme.of(getFontTheme(fontFamily, fontSize)),
|
||||||
indentUnit.of(" "),
|
this.indentUnitCompartment.of(indentUnit.of(" ".repeat(tabSize))),
|
||||||
EditorView.scrollMargins.of(f => {
|
EditorView.scrollMargins.of(f => {
|
||||||
return {top: 80, bottom: 80}
|
return {top: 80, bottom: 80}
|
||||||
}),
|
}),
|
||||||
@ -417,6 +419,12 @@ export class HeynoteEditor {
|
|||||||
selectAll() {
|
selectAll() {
|
||||||
selectAll(this.view)
|
selectAll(this.view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTabSize(tabSize) {
|
||||||
|
this.view.dispatch({
|
||||||
|
effects: this.indentUnitCompartment.reconfigure(indentUnit.of(" ".repeat(tabSize)))
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ export const useEditorCacheStore = defineStore("editorCache", {
|
|||||||
bracketClosing: settingsStore.settings.bracketClosing,
|
bracketClosing: settingsStore.settings.bracketClosing,
|
||||||
fontFamily: settingsStore.settings.fontFamily,
|
fontFamily: settingsStore.settings.fontFamily,
|
||||||
fontSize: settingsStore.settings.fontSize,
|
fontSize: settingsStore.settings.fontSize,
|
||||||
|
tabSize: settingsStore.settings.tabSize,
|
||||||
defaultBlockToken: settingsStore.settings.defaultBlockLanguage,
|
defaultBlockToken: settingsStore.settings.defaultBlockLanguage,
|
||||||
defaultBlockAutoDetect: settingsStore.settings.defaultBlockLanguageAutoDetect,
|
defaultBlockAutoDetect: settingsStore.settings.defaultBlockLanguageAutoDetect,
|
||||||
})
|
})
|
||||||
@ -137,6 +138,9 @@ export const useEditorCacheStore = defineStore("editorCache", {
|
|||||||
case "fontSize":
|
case "fontSize":
|
||||||
editor.setFont(newSettings.fontFamily, newSettings.fontSize)
|
editor.setFont(newSettings.fontFamily, newSettings.fontSize)
|
||||||
break
|
break
|
||||||
|
case "tabSize":
|
||||||
|
editor.setTabSize(newSettings.tabSize)
|
||||||
|
break
|
||||||
case "defaultBlockLanguage":
|
case "defaultBlockLanguage":
|
||||||
case "defaultBlockLanguageAutoDetect":
|
case "defaultBlockLanguageAutoDetect":
|
||||||
editor.setDefaultBlockLanguage(newSettings.defaultBlockLanguage, newSettings.defaultBlockLanguageAutoDetect)
|
editor.setDefaultBlockLanguage(newSettings.defaultBlockLanguage, newSettings.defaultBlockLanguageAutoDetect)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user