mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
add user setting for sticky scroll
This commit is contained in:
parent
292a9ae1e5
commit
e1a19a0b80
@ -82,10 +82,16 @@ const minimapEnabledAtom = atom((get) => {
|
||||
return settings["editor:minimapenabled"] ?? false;
|
||||
});
|
||||
|
||||
const stickyScrollEnabledAtom = atom((get) => {
|
||||
const settings = get(atoms.settingsAtom);
|
||||
return settings["editor:stickyscrollenabled"] ?? 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 stickyScrollEnabled = useAtomValue(stickyScrollEnabledAtom);
|
||||
const theme = "wave-theme-dark";
|
||||
|
||||
React.useEffect(() => {
|
||||
@ -112,8 +118,9 @@ export function CodeEditor({ text, language, filename, onChange, onMount }: Code
|
||||
const editorOpts = useMemo(() => {
|
||||
const opts = defaultEditorOptions();
|
||||
opts.minimap.enabled = minimapEnabled;
|
||||
opts.stickyScroll.enabled = stickyScrollEnabled;
|
||||
return opts;
|
||||
}, [minimapEnabled]);
|
||||
}, [minimapEnabled, stickyScrollEnabled]);
|
||||
|
||||
return (
|
||||
<div className="code-editor-wrapper">
|
||||
|
1
frontend/types/gotypes.d.ts
vendored
1
frontend/types/gotypes.d.ts
vendored
@ -396,6 +396,7 @@ declare global {
|
||||
"term:fontfamily"?: string;
|
||||
"term:disablewebgl"?: boolean;
|
||||
"editor:minimapenabled"?: boolean;
|
||||
"editor:stickyscrollenabled"?: boolean;
|
||||
"web:*"?: boolean;
|
||||
"web:openlinksinternally"?: boolean;
|
||||
"blockheader:*"?: boolean;
|
||||
|
@ -20,6 +20,7 @@ const (
|
||||
ConfigKey_TermDisableWebGl = "term:disablewebgl"
|
||||
|
||||
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
|
||||
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"
|
||||
|
||||
ConfigKey_WebClear = "web:*"
|
||||
ConfigKey_WebOpenLinksInternally = "web:openlinksinternally"
|
||||
|
@ -52,6 +52,7 @@ type SettingsType struct {
|
||||
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
|
||||
|
||||
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
|
||||
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`
|
||||
|
||||
WebClear bool `json:"web:*,omitempty"`
|
||||
WebOpenLinksInternally bool `json:"web:openlinksinternally,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user