heynote/electron/config.js
Joshua Blum f532c7939b
Add bufferPath to config, support bufferPath symlink (#27)
* Add bufferPath to config, support bufferPath symlink

* defaultPath before checking realpath

* Move code for retrieving buffer path into its own file

* Do the realpathSync() call for the whole final file path, to allow the buffer file to be a symlink

---------

Co-authored-by: Jonatan Heyman <jonatan@heyman.info>
2023-12-23 11:17:13 +01:00

61 lines
1.7 KiB
JavaScript

import Store from "electron-store"
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 },
"showLineNumberGutter": {type: "boolean", default:true},
"showFoldGutter": {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: ""},
},
},
theme: {type: "string", default: "system"},
currency: {
type: "object",
properties: {
data: {type: "object"},
timeFetched: {type: "number"},
},
},
}
const defaults = {
settings: {
keymap: "default",
emacsMetaKey: "meta",
showLineNumberGutter: true,
showFoldGutter: true,
allowBetaVersions: false,
enableGlobalHotkey: false,
globalHotkey: "CmdOrCtrl+Shift+H",
bufferPath: "",
},
theme: "system",
}
export default new Store({schema, defaults, name: isDev ? "config-dev" : "config"})