export type ICodeEditor = monaco.editor.ICodeEditor;

export type CodeEditorChangeEvent = {
  readonly code: string;
  readonly changes: monaco.editor.IModelContentChangedEvent['changes'];
  readonly eol: monaco.editor.IModelContentChangedEvent['eol'];
  readonly versionId: monaco.editor.IModelContentChangedEvent['versionId'];
  readonly isUndoing: monaco.editor.IModelContentChangedEvent['isUndoing'];
  readonly isRedoing: monaco.editor.IModelContentChangedEvent['isRedoing'];
  readonly isFlush: monaco.editor.IModelContentChangedEvent['isFlush'];
};
export type CodeEditorChangeEventHandler = (e: CodeEditorChangeEvent) => void;

/**
 * Configuration options for the code editor.
 */
export type CodeEditorLanguage = 'typescript' | 'javascript' | 'json';
export type CodeEditorTheme = 'DARK' | 'LIGHT';

export type CodeEditorOptions = {
  /**
   * IEditorConstructionOptions
   * https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditorconstructionoptions.html
   */
  selectOnLineNumbers: boolean;
  fontSize: number;
  fontFamily?: string;
  readOnly?: boolean;

  /**
   * ITextModelUpdateOptions
   * https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.itextmodelupdateoptions.html
   */
  tabSize: number;

  /**
   * ReactMonacoEditorProps
   */
  theme: CodeEditorTheme;
  language: CodeEditorLanguage;

  /**
   * Language definitions.
   */
  javascriptDefaults?: CodeEditorLanguageDefaults;
  typescriptDefaults?: CodeEditorLanguageDefaults;
};

export type CodeEditorLanguageDefaults = {
  types: string[];
};
