UNPKG

@kui-shell/plugin-client-common

Version:

Kui plugin that offers stylesheets

62 lines (61 loc) 2.27 kB
import React from 'react'; import { IDisposable, editor as Monaco } from 'monaco-editor'; import type { File } from '@kui-shell/plugin-bash-like/fs'; import type { REPL, EditableSpec, StringContent, ToolbarText, ToolbarProps, MultiModalResponse } from '@kui-shell/core'; import { Options as MonacoOptions } from './lib/defaults'; import '../../../../web/scss/components/Editor/Editor.scss'; export declare function isFile(file: File | MultiModalResponse): file is File; type Props = MonacoOptions & ToolbarProps & { tabUUID: string; repl: REPL; content: StringContent & Partial<EditableSpec>; response: File | MultiModalResponse; /** Use a light theme? Default: false */ light?: boolean; /** Size height to fit? */ sizeToFit?: boolean; }; interface State { content: Props['content']; editor: Monaco.ICodeEditor; wrapper: HTMLDivElement; subscription?: IDisposable; toolbarText?: ToolbarText; catastrophicError: Error; cleaners: (() => void)[]; } export default class Editor extends React.PureComponent<Props, State> { constructor(props: Props); static getDerivedStateFromError(error: Error): { catastrophicError: Error; }; componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void; /** * ToolbarText for a clean editor, i.e. no changes have been made * since last save. * */ private static allClean; /** * ToolbarText to indicate error saving. * */ private static error; /** Called whenever we have proposed (props,state); we derive a new State */ static getDerivedStateFromProps(props: Props, state: State): Partial<State>; /** Called when this component is no longer attached to the document */ componentWillUnmount(): void; /** Called when we no longer need the monaco-editor instance */ private destroyMonaco; private static isClearable; private static onChange; /** Handle Toolbar registrations */ private static subscribeToChanges; private static extractValue; private static reinitMonaco; private static isReadOnly; /** Called when we have a ready wrapper (monaco's init requires an wrapper */ private static initMonaco; render(): JSX.Element; } export {};