mirror of
https://github.com/heyman/heynote.git
synced 2025-07-17 14:35:07 +02:00
This is a work in progress revamp of the key binding system. It implements a system, built on top of CodeMirror's key binding system, for defining key bindings. The system uses a dumb "KeyShortcut" -> "Command" mapping with a set of default keys (which will be different if Heynote's Emacs mode is used) that can be overridden by user key bindings. The key bindings are *displayed* in the Settings, and it's possible to set user defined key bindings in Heynote's config file, but it's not yet possible to define custom key bindings in the UI. Previously we Heynote on a bunch of default key bindings from CodeMirror (some of which was not "block aware"). This is no longer the case, and because of this, it's quite likely that there are key bindings that was previously working that is now missing (if so, these can easily be added later).
91 lines
2.9 KiB
JavaScript
91 lines
2.9 KiB
JavaScript
import Store from "electron-store"
|
|
import { isMac } from "./detect-platform"
|
|
|
|
const isDev = !!process.env.VITE_DEV_SERVER_URL
|
|
|
|
const schema = {
|
|
additionalProperties: false,
|
|
|
|
windowConfig: {
|
|
type: "object",
|
|
properties: {
|
|
width: {type: "number"},
|
|
height: {type: "number"},
|
|
x: {type: "number"},
|
|
y: {type: "number"},
|
|
isMaximized: {type: "boolean"},
|
|
isFullScreen: {type: "boolean"},
|
|
},
|
|
additionalProperties: false,
|
|
},
|
|
|
|
settings: {
|
|
type: "object",
|
|
properties: {
|
|
"keymap": { "enum": ["default", "emacs"], default:"default" },
|
|
"emacsMetaKey": { "enum": [null, "alt", "meta"], default: null },
|
|
"keyBindings": {
|
|
"type": "object",
|
|
"propertyNames": {
|
|
"type": "string"
|
|
},
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
|
|
"showLineNumberGutter": {type: "boolean", default:true},
|
|
"showFoldGutter": {type: "boolean", default:true},
|
|
"autoUpdate": {type: "boolean", default: true},
|
|
"allowBetaVersions": {type: "boolean", default: false},
|
|
"enableGlobalHotkey": {type: "boolean", default: false},
|
|
"globalHotkey": {type: "string", default: "CmdOrCtrl+Shift+H"},
|
|
"bufferPath" : {type: "string", default: ""},
|
|
"showInDock": {type: "boolean", default: true},
|
|
"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
|
|
// future and have it apply to existing users
|
|
"fontFamily": {type: "string"},
|
|
"fontSize": {type: "integer"},
|
|
},
|
|
},
|
|
|
|
theme: {type: "string", default: "system"},
|
|
|
|
currency: {
|
|
type: "object",
|
|
properties: {
|
|
data: {type: "object"},
|
|
timeFetched: {type: "number"},
|
|
},
|
|
},
|
|
}
|
|
|
|
const defaults = {
|
|
settings: {
|
|
keymap: "default",
|
|
emacsMetaKey: isMac ? "meta" : "alt",
|
|
keyBindings: {},
|
|
showLineNumberGutter: true,
|
|
showFoldGutter: true,
|
|
autoUpdate: true,
|
|
allowBetaVersions: false,
|
|
enableGlobalHotkey: false,
|
|
globalHotkey: "CmdOrCtrl+Shift+H",
|
|
bufferPath: "",
|
|
showInDock: true,
|
|
showInMenu: false,
|
|
alwaysOnTop: false,
|
|
bracketClosing: false,
|
|
},
|
|
theme: "system",
|
|
}
|
|
|
|
export default new Store({schema, defaults, name: isDev ? "config-dev" : "config"})
|