monaco editor implemented right

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2021-09-29 14:08:27 +03:00
1 parent b41f923931
commit 92766e71e4
27 files changed
+265 -501

No files matched your search

+4 -4
View File
@@ -24,7 +24,7 @@ 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 type * as monaco from "monaco-editor";
import merge from "lodash/merge";
export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
@@ -34,9 +34,9 @@ export interface KubeconfigSyncEntry extends KubeconfigSyncValue {
export interface KubeconfigSyncValue { }
export interface EditorConfiguration {
miniMap?: monaco.editor.IEditorMinimapOptions;
lineNumbers?: monaco.editor.LineNumbersType;
tabSize?: number;
miniMap: monaco.editor.IEditorMinimapOptions;
lineNumbers: monaco.editor.LineNumbersType;
tabSize: number;
}
export const defaultEditorConfig: EditorConfiguration = {
+4 -28
View File
@@ -21,18 +21,16 @@
import { app } from "electron";
import 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 { defaultEditorConfig, DESCRIPTORS, EditorConfiguration, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
import logger from "../../main/logger";
import type { monaco } from "react-monaco-editor";
import { getPath } from "../utils/getPath";
export interface UserStoreModel {
@@ -86,7 +84,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
/**
* Monaco editor configs
*/
@observable editorConfiguration:EditorConfiguration = {tabSize: null, miniMap: null, lineNumbers: null};
@observable editorConfiguration: EditorConfiguration = defaultEditorConfig;
/**
* The set of file/folder paths to be synced
@@ -119,28 +117,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