mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Monaco editor refactoring (#4225)
* monaco editor refactoring Signed-off-by: Roman <ixrock@gmail.com> * clean up / responding to comments Signed-off-by: Roman <ixrock@gmail.com> * move custom monaco themes to own folder Signed-off-by: Roman <ixrock@gmail.com> * fix lint Signed-off-by: Roman <ixrock@gmail.com> * removed unused rules from webpack's config (renderer) Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
0ae4dfbeab
commit
368e2d9a00
44 files changed
+817
-520
No files matched your search
@@ -23,8 +23,6 @@ import { SearchStore } from "../search-store";
|
||||
import { Console } from "console";
|
||||
import { stdout, stderr } from "process";
|
||||
|
||||
jest.mock("react-monaco-editor", () => null);
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "/foo",
|
||||
|
||||
@@ -24,7 +24,7 @@ import path from "path";
|
||||
import os from "os";
|
||||
import { ThemeStore } from "../../renderer/theme.store";
|
||||
import { getAppVersion, ObservableToggleSet } from "../utils";
|
||||
import type { monaco } from "react-monaco-editor";
|
||||
import type { editor } from "monaco-editor";
|
||||
import merge from "lodash/merge";
|
||||
import { SemVer } from "semver";
|
||||
|
||||
@@ -32,20 +32,19 @@ export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
|
||||
filePath: string;
|
||||
}
|
||||
|
||||
export interface KubeconfigSyncValue { }
|
||||
|
||||
export interface EditorConfiguration {
|
||||
miniMap?: monaco.editor.IEditorMinimapOptions;
|
||||
lineNumbers?: monaco.editor.LineNumbersType;
|
||||
tabSize?: number;
|
||||
export interface KubeconfigSyncValue {
|
||||
}
|
||||
|
||||
export type EditorConfiguration = Pick<editor.IStandaloneEditorConstructionOptions,
|
||||
"minimap" | "tabSize" | "lineNumbers">;
|
||||
|
||||
export const defaultEditorConfig: EditorConfiguration = {
|
||||
lineNumbers: "on",
|
||||
miniMap: {
|
||||
enabled: true,
|
||||
},
|
||||
tabSize: 2,
|
||||
lineNumbers: "on",
|
||||
minimap: {
|
||||
enabled: true,
|
||||
side: "right",
|
||||
},
|
||||
};
|
||||
|
||||
interface PreferenceDescription<T, R = T> {
|
||||
|
||||
@@ -21,18 +21,16 @@
|
||||
|
||||
import { app, ipcMain } from "electron";
|
||||
import semver, { SemVer } from "semver";
|
||||
import { action, computed, observable, reaction, makeObservable } from "mobx";
|
||||
import { action, computed, makeObservable, observable, reaction } from "mobx";
|
||||
import { BaseStore } from "../base-store";
|
||||
import migrations from "../../migrations/user-store";
|
||||
import migrations, { fileNameMigration } from "../../migrations/user-store";
|
||||
import { getAppVersion } from "../utils/app-version";
|
||||
import { kubeConfigDefaultPath } from "../kube-helpers";
|
||||
import { appEventBus } from "../event-bus";
|
||||
import path from "path";
|
||||
import { fileNameMigration } from "../../migrations/user-store";
|
||||
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
||||
import { DESCRIPTORS, KubeconfigSyncValue, UserPreferencesModel, EditorConfiguration } from "./preferences-helpers";
|
||||
import { DESCRIPTORS, EditorConfiguration, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
|
||||
import logger from "../../main/logger";
|
||||
import type { monaco } from "react-monaco-editor";
|
||||
import { AppPaths } from "../app-paths";
|
||||
|
||||
export interface UserStoreModel {
|
||||
@@ -92,7 +90,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
/**
|
||||
* Monaco editor configs
|
||||
*/
|
||||
@observable editorConfiguration:EditorConfiguration = { tabSize: null, miniMap: null, lineNumbers: null };
|
||||
@observable editorConfiguration: EditorConfiguration;
|
||||
|
||||
/**
|
||||
* The set of file/folder paths to be synced
|
||||
@@ -129,28 +127,6 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
});
|
||||
}
|
||||
|
||||
// Returns monaco editor options for selected editor type (the place, where a particular instance of the editor is mounted)
|
||||
getEditorOptions(): monaco.editor.IStandaloneEditorConstructionOptions {
|
||||
return {
|
||||
automaticLayout: true,
|
||||
tabSize: this.editorConfiguration.tabSize,
|
||||
minimap: this.editorConfiguration.miniMap,
|
||||
lineNumbers: this.editorConfiguration.lineNumbers,
|
||||
};
|
||||
}
|
||||
|
||||
setEditorLineNumbers(lineNumbers: monaco.editor.LineNumbersType) {
|
||||
this.editorConfiguration.lineNumbers = lineNumbers;
|
||||
}
|
||||
|
||||
setEditorTabSize(tabSize: number) {
|
||||
this.editorConfiguration.tabSize = tabSize;
|
||||
}
|
||||
|
||||
enableEditorMinimap(miniMap: boolean ) {
|
||||
this.editorConfiguration.miniMap.enabled = miniMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a column (by ID) for a table (by ID) is configured to be hidden
|
||||
* @param tableId The ID of the table to be checked against
|
||||
|
||||
Reference in new issue
Block a user