<commit_before>import { css } from 'emotion';
import * as React from 'react';
import { editor, Uri } from 'monaco-editor';
import * as t from '../../page-schema.build';
import { SizedDiv } from '../../Components/SizedDiv';
interface EditorProps {
  value?: string;
  uri?: 'page.json';
  minimap?: boolean;
  language?: 'javascript' | 'css' | 'json';
  onChange?: (value: string) => void;
  onBlur?: (value: string) => void;
}
const overflowHide = css({
  overflow: 'hidden',
  width: '100%',
  height: '100%',
});
class SrcEditor extends React.Component<EditorProps> {
  private editor: editor.IStandaloneCodeEditor | null = null;
  private lastValue?: string = '';
  private outsideChange: boolean = false;
  private container: HTMLDivElement | null = null;

  static defaultProps = {
    language: 'javascript',
    minimap: false,
    onBlur: () => {},
    onChange: () => {},
  };
  constructor(props: EditorProps) {
    super(props);
  }
  shouldComponentUpdate(nextProps: EditorProps) {
    return (
      nextProps.value !== this.lastValue ||
      this.props.language !== nextProps.language
    );
  }
  componentDidUpdate(prevProps: EditorProps) {
    if (this.lastValue !== this.props.value) {
      this.lastValue = this.props.value;
      this.outsideChange = true;
      this.editor!.setValue(this.props.value!);
      this.outsideChange = false;
    }
    if (this.props.language !== prevProps.language) {
      import('monaco-editor').then(monaco => {
        monaco.editor.setModelLanguage(
          this.editor!.getModel(),
          this.props.language!,
        );
      });
    }
    this.editor!.layout();
  }
  componentDidMount() {
    this.lastValue = this.props.value;
    import('monaco-editor').then(monaco => {
      if (this.container != null) {
        monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
          validate: true,<commit_msg>Monaco editor, handle update without a string<commit_after>import { css } from 'emotion';
import * as React from 'react';
import { editor, Uri } from 'monaco-editor';
import * as t from '../../page-schema.build';
import { SizedDiv } from '../../Components/SizedDiv';
interface EditorProps {
  value?: string;
  uri?: 'page.json';
  minimap?: boolean;
  language?: 'javascript' | 'css' | 'json';
  onChange?: (value: string) => void;
  onBlur?: (value: string) => void;
}
const overflowHide = css({
  overflow: 'hidden',
  width: '100%',
  height: '100%',
});
class SrcEditor extends React.Component<EditorProps> {
  private editor: editor.IStandaloneCodeEditor | null = null;
  private lastValue?: string = '';
  private outsideChange: boolean = false;
  private container: HTMLDivElement | null = null;

  static defaultProps = {
    language: 'javascript',
    minimap: false,
    onBlur: () => {},
    onChange: () => {},
  };
  constructor(props: EditorProps) {
    super(props);
  }
  shouldComponentUpdate(nextProps: EditorProps) {
    return (
      nextProps.value !== this.lastValue ||
      this.props.language !== nextProps.language
    );
  }
  componentDidUpdate(prevProps: EditorProps) {
    if (this.lastValue !== this.props.value) {
      this.lastValue = this.props.value;
      this.outsideChange = true;
      if ('string' === typeof this.props.value) {
        this.editor!.setValue(this.props.value);
      } else {
        this.editor!.setValue('');
      }
      this.outsideChange = false;
    }
    if (this.props.language !== prevProps.language) {
      import('monaco-editor').then(monaco => {
        monaco.editor.setModelLanguage(
          this.editor!.getModel(),
          this.props.language!,
        );
      });
    }
    this.editor!.layout();
  }
  componentDidMount() {
    this.lastValue = this.props.value;
    import('monaco-editor').then(monaco => {
      if (this.container != null) {
        monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
          validate: true,
{'fraction_non_alphanumeric': 0.1550089674609275, 'fraction_numerical': 0.0030745580322828594, 'mean_word_length': 3.100840336134454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3834290', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1188, 'n_words': 253}