mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-21 21:32:13 +01:00
Add user setting for the editor minimap (#321)
This commit is contained in:
parent
2cc0fdc999
commit
74612c7e62
@ -359,7 +359,9 @@ function handleWSEventMessage(msg: WSEventType) {
|
||||
return;
|
||||
}
|
||||
if (msg.eventtype == "config") {
|
||||
globalStore.set(atoms.fullConfigAtom, (msg.data as WatcherUpdate).fullconfig);
|
||||
const fullConfig = (msg.data as WatcherUpdate).fullconfig;
|
||||
console.log("fullConfig", fullConfig);
|
||||
globalStore.set(atoms.fullConfigAtom, fullConfig);
|
||||
return;
|
||||
}
|
||||
if (msg.eventtype == "userinput") {
|
||||
|
@ -1,10 +1,12 @@
|
||||
// Copyright 2024, Command Line Inc.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { atoms } from "@/app/store/global";
|
||||
import loader from "@monaco-editor/loader";
|
||||
import { Editor, Monaco } from "@monaco-editor/react";
|
||||
import { atom, useAtomValue } from "jotai";
|
||||
import type * as MonacoTypes from "monaco-editor/esm/vs/editor/editor.api";
|
||||
import React, { useRef } from "react";
|
||||
import React, { useMemo, useRef } from "react";
|
||||
import "./codeeditor.less";
|
||||
|
||||
// there is a global monaco variable (TODO get the correct TS type)
|
||||
@ -71,9 +73,16 @@ interface CodeEditorProps {
|
||||
onMount?: (monacoPtr: MonacoTypes.editor.IStandaloneCodeEditor, monaco: Monaco) => () => void;
|
||||
}
|
||||
|
||||
const minimapEnabledAtom = atom((get) => {
|
||||
const settings = get(atoms.settingsAtom);
|
||||
console.log("settings", settings);
|
||||
return settings["editor:minimapenabled"] ?? false;
|
||||
});
|
||||
|
||||
export function CodeEditor({ text, language, filename, onChange, onMount }: CodeEditorProps) {
|
||||
const divRef = useRef<HTMLDivElement>(null);
|
||||
const unmountRef = useRef<() => void>(null);
|
||||
const minimapEnabled = useAtomValue(minimapEnabledAtom);
|
||||
const theme = "wave-theme-dark";
|
||||
|
||||
React.useEffect(() => {
|
||||
@ -97,7 +106,12 @@ export function CodeEditor({ text, language, filename, onChange, onMount }: Code
|
||||
}
|
||||
}
|
||||
|
||||
const editorOpts = defaultEditorOptions();
|
||||
const editorOpts = useMemo(() => {
|
||||
const opts = defaultEditorOptions();
|
||||
console.log("minimapEnabled", minimapEnabled);
|
||||
opts.minimap.enabled = minimapEnabled;
|
||||
return opts;
|
||||
}, [minimapEnabled]);
|
||||
|
||||
return (
|
||||
<div className="code-editor-wrapper">
|
||||
|
1
frontend/types/gotypes.d.ts
vendored
1
frontend/types/gotypes.d.ts
vendored
@ -395,6 +395,7 @@ declare global {
|
||||
"term:fontsize"?: number;
|
||||
"term:fontfamily"?: string;
|
||||
"term:disablewebgl"?: boolean;
|
||||
"editor:minimapenabled"?: boolean;
|
||||
"web:*"?: boolean;
|
||||
"web:openlinksinternally"?: boolean;
|
||||
"blockheader:*"?: boolean;
|
||||
|
@ -4,5 +4,6 @@
|
||||
"ai:timeoutms": 10000,
|
||||
"autoupdate:enabled": true,
|
||||
"autoupdate:installonquit": true,
|
||||
"autoupdate:intervalms": 3600000
|
||||
"autoupdate:intervalms": 3600000,
|
||||
"editor:minimapenabled": true
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ const (
|
||||
ConfigKey_TermFontFamily = "term:fontfamily"
|
||||
ConfigKey_TermDisableWebGl = "term:disablewebgl"
|
||||
|
||||
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
|
||||
|
||||
ConfigKey_WebClear = "web:*"
|
||||
ConfigKey_WebOpenLinksInternally = "web:openlinksinternally"
|
||||
|
||||
|
@ -51,6 +51,8 @@ type SettingsType struct {
|
||||
TermFontFamily string `json:"term:fontfamily,omitempty"`
|
||||
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
|
||||
|
||||
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
|
||||
|
||||
WebClear bool `json:"web:*,omitempty"`
|
||||
WebOpenLinksInternally bool `json:"web:openlinksinternally,omitempty"`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user