mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-04 18:59:08 +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;
|
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) {
|
export function CodeEditor({ text, language, filename, onChange, onMount }: CodeEditorProps) {
|
||||||
const divRef = useRef<HTMLDivElement>(null);
|
const divRef = useRef<HTMLDivElement>(null);
|
||||||
const unmountRef = useRef<() => void>(null);
|
const unmountRef = useRef<() => void>(null);
|
||||||
const minimapEnabled = useAtomValue(minimapEnabledAtom);
|
const minimapEnabled = useAtomValue(minimapEnabledAtom);
|
||||||
|
const stickyScrollEnabled = useAtomValue(stickyScrollEnabledAtom);
|
||||||
const theme = "wave-theme-dark";
|
const theme = "wave-theme-dark";
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@ -112,8 +118,9 @@ export function CodeEditor({ text, language, filename, onChange, onMount }: Code
|
|||||||
const editorOpts = useMemo(() => {
|
const editorOpts = useMemo(() => {
|
||||||
const opts = defaultEditorOptions();
|
const opts = defaultEditorOptions();
|
||||||
opts.minimap.enabled = minimapEnabled;
|
opts.minimap.enabled = minimapEnabled;
|
||||||
|
opts.stickyScroll.enabled = stickyScrollEnabled;
|
||||||
return opts;
|
return opts;
|
||||||
}, [minimapEnabled]);
|
}, [minimapEnabled, stickyScrollEnabled]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="code-editor-wrapper">
|
<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:fontfamily"?: string;
|
||||||
"term:disablewebgl"?: boolean;
|
"term:disablewebgl"?: boolean;
|
||||||
"editor:minimapenabled"?: boolean;
|
"editor:minimapenabled"?: boolean;
|
||||||
|
"editor:stickyscrollenabled"?: boolean;
|
||||||
"web:*"?: boolean;
|
"web:*"?: boolean;
|
||||||
"web:openlinksinternally"?: boolean;
|
"web:openlinksinternally"?: boolean;
|
||||||
"blockheader:*"?: boolean;
|
"blockheader:*"?: boolean;
|
||||||
|
@ -20,6 +20,7 @@ const (
|
|||||||
ConfigKey_TermDisableWebGl = "term:disablewebgl"
|
ConfigKey_TermDisableWebGl = "term:disablewebgl"
|
||||||
|
|
||||||
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
|
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
|
||||||
|
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"
|
||||||
|
|
||||||
ConfigKey_WebClear = "web:*"
|
ConfigKey_WebClear = "web:*"
|
||||||
ConfigKey_WebOpenLinksInternally = "web:openlinksinternally"
|
ConfigKey_WebOpenLinksInternally = "web:openlinksinternally"
|
||||||
|
@ -52,6 +52,7 @@ type SettingsType struct {
|
|||||||
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
|
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
|
||||||
|
|
||||||
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
|
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
|
||||||
|
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`
|
||||||
|
|
||||||
WebClear bool `json:"web:*,omitempty"`
|
WebClear bool `json:"web:*,omitempty"`
|
||||||
WebOpenLinksInternally bool `json:"web:openlinksinternally,omitempty"`
|
WebOpenLinksInternally bool `json:"web:openlinksinternally,omitempty"`
|
||||||
|
Loading…
Reference in New Issue
Block a user