mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace Ace Editor with monaco (#2949)
Signed-off-by: Pavel Ashevskii <pashevskii@mirantis.com> Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
1 parent
0ac4b9de3f
commit
e4c393244a
38 files changed
+485
-347
No files matched your search
@@ -24,6 +24,8 @@ import path from "path";
|
||||
import os from "os";
|
||||
import { ThemeStore } from "../../renderer/theme.store";
|
||||
import { ObservableToggleSet } from "../utils";
|
||||
import type {monaco} from "react-monaco-editor";
|
||||
import merge from "lodash/merge";
|
||||
|
||||
export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
||||
filePath: string;
|
||||
@@ -31,6 +33,20 @@ export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
||||
|
||||
export interface KubeconfigSyncValue { }
|
||||
|
||||
export interface EditorConfiguration {
|
||||
miniMap?: monaco.editor.IEditorMinimapOptions;
|
||||
lineNumbers?: monaco.editor.LineNumbersType;
|
||||
tabSize?: number;
|
||||
}
|
||||
|
||||
export const defaultEditorConfig: EditorConfiguration = {
|
||||
lineNumbers: "on",
|
||||
miniMap: {
|
||||
enabled: true
|
||||
},
|
||||
tabSize: 2
|
||||
};
|
||||
|
||||
interface PreferenceDescription<T, R = T> {
|
||||
fromStore(val: T | undefined): R;
|
||||
toStore(val: R): T | undefined;
|
||||
@@ -222,6 +238,15 @@ const syncKubeconfigEntries: PreferenceDescription<KubeconfigSyncEntry[], Map<st
|
||||
},
|
||||
};
|
||||
|
||||
const editorConfiguration: PreferenceDescription<EditorConfiguration, EditorConfiguration> = {
|
||||
fromStore(val) {
|
||||
return merge(defaultEditorConfig, val);
|
||||
},
|
||||
toStore(val) {
|
||||
return val;
|
||||
},
|
||||
};
|
||||
|
||||
type PreferencesModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<infer T, any> ? T : never;
|
||||
type UserStoreModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<any, infer T> ? T : never;
|
||||
|
||||
@@ -248,4 +273,5 @@ export const DESCRIPTORS = {
|
||||
openAtLogin,
|
||||
hiddenTableColumns,
|
||||
syncKubeconfigEntries,
|
||||
editorConfiguration,
|
||||
};
|
||||
Reference in new issue
Block a user