@finos/legend-code-editor
Version:
Legend shared advanced application components and building blocks
70 lines • 2.86 kB
TypeScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { editor as monacoEditorAPI } from 'monaco-editor';
export type CodeEditorPosition = {
lineNumber: number;
column: number;
};
/**
* Get the text value with LF line ending.
* This is needed since if there are CR `\r` characters in the text input
* (e.g. users of Windows doing copy/paste)
* the default mode of `monaco-editor` is `TextDefined` which means if the text
* contains CR character(s), it will automatically be treated as CRLF. As such, we want
* an utility method to extract the text value with line ending option LF
* to force omission of CR characters
* See https://github.com/finos/legend-studio/issues/608
*/
export declare const getCodeEditorValue: (editor: monacoEditorAPI.IStandaloneCodeEditor) => string;
export declare const getBaseCodeEditorOptions: () => monacoEditorAPI.IStandaloneEditorConstructionOptions;
export declare const moveCursorToPosition: (editor: monacoEditorAPI.ICodeEditor, position: CodeEditorPosition) => void;
export declare const setErrorMarkers: (editorModel: monacoEditorAPI.ITextModel, errors: {
message: string;
startLineNumber: number;
startColumn: number;
endLineNumber: number;
endColumn: number;
}[], ownerId?: string) => void;
export declare const setWarningMarkers: (editorModel: monacoEditorAPI.ITextModel, warnings: {
message: string;
startLineNumber: number;
startColumn: number;
endLineNumber: number;
endColumn: number;
}[], ownerId?: string) => void;
export declare const clearMarkers: (ownerId?: string) => void;
/**
* This method eliminates CR '\r' character(s) in the provided text value.
*/
export declare const normalizeLineEnding: (val: string) => string;
export declare const resetLineNumberGutterWidth: (editor: monacoEditorAPI.ICodeEditor) => void;
export declare const configureCodeEditor: (fontFamily: string, onError: (error: Error) => void) => Promise<void>;
export declare enum CODE_EDITOR_LANGUAGE {
TEXT = "plaintext",
PURE = "pure",
JSON = "json",
JAVA = "java",
MARKDOWN = "markdown",
SQL = "sql",
XML = "xml",
YAML = "yaml",
GRAPHQL = "graphql"
}
export type CompletionItem = {
completion: string;
display: string;
};
//# sourceMappingURL=CodeEditorUtils.d.ts.map