How to use the monaco-editor.Uri function in monaco-editor

To help you get started, we’ve selected a few monaco-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reactide / reactide / renderer / components / TextEditor.js View on Github external
// This is needed because the content for the file might have been modified externally
      // Use `pushEditOperations` instead of `setValue` or `applyEdits` to preserve undo stack
      model.pushEditOperations(
        [],
        [
          {
            range: model.getFullModelRange(),
            text: value,
          },
        ]
      );
    } else {
      model = monaco.editor.createModel(
        value,
        this._getLanguage(this.props.path),
        new monaco.Uri().with({ path })
      );
      model.updateOptions({
        tabSize: 2,
        insertSpaces: true,
      });
    }
    this.editor.setModel(model);
    return model;
  };
github reactide / reactide / release-builds / Reactide-darwin-x64 / Reactide.app / Contents / Resources / app / renderer / components / TextEditor.js View on Github external
// This is needed because the content for the file might have been modified externally
      // Use `pushEditOperations` instead of `setValue` or `applyEdits` to preserve undo stack
      model.pushEditOperations(
        [],
        [
          {
            range: model.getFullModelRange(),
            text: value,
          },
        ]
      );
    } else {
      model = monaco.editor.createModel(
        value,
        this._getLanguage(this.props.path),
        new monaco.Uri().with({ path }),
        
      );
      model.updateOptions({
        tabSize: 2,
        insertSpaces: true,
      });
    }
    this.editor.setModel(model);
    return model;
  };
github gitlabhq / gitlabhq / spec / javascripts / editor / editor_lite_spec.js View on Github external
describe('Base editor', () => {
  let editorEl;
  let editor;
  const blobContent = 'Foo Bar';
  const blobPath = 'test.md';
  const uri = new Uri('gitlab', false, blobPath);
  const fakeModel = { foo: 'bar' };

  beforeEach(() => {
    setFixtures('<div data-editor-loading="" id="editor"></div>');
    editorEl = document.getElementById('editor');
    editor = new Editor();
  });

  afterEach(() =&gt; {
    editor.dispose();
    editorEl.remove();
  });

  it('initializes Editor with basic properties', () =&gt; {
    expect(editor).toBeDefined();
    expect(editor.editorEl).toBe(null);
github gitlabhq / gitlabhq / app / assets / javascripts / ide / lib / common / model.js View on Github external
this.disposable = new Disposable();
    this.file = file;
    this.head = head;
    this.content = file.content !== '' || file.deleted ? file.content : file.raw;
    this.options = { ...defaultModelOptions };

    this.disposable.add(
      (this.originalModel = monacoEditor.createModel(
        head ? head.content : this.file.raw,
        undefined,
        new Uri('gitlab', false, `original/${this.path}`),
      )),
      (this.model = monacoEditor.createModel(
        this.content,
        undefined,
        new Uri('gitlab', false, this.path),
      )),
    );
    if (this.file.mrChange) {
      this.disposable.add(
        (this.baseModel = monacoEditor.createModel(
          this.file.baseRaw,
          undefined,
          new Uri('gitlab', false, `target/${this.path}`),
        )),
      );
    }

    this.events = new Set();

    this.updateContent = this.updateContent.bind(this);
    this.updateNewContent = this.updateNewContent.bind(this);
github gitlabhq / gitlabhq / app / assets / javascripts / ide / lib / common / model.js View on Github external
head ? head.content : this.file.raw,
        undefined,
        new Uri('gitlab', false, `original/${this.path}`),
      )),
      (this.model = monacoEditor.createModel(
        this.content,
        undefined,
        new Uri('gitlab', false, this.path),
      )),
    );
    if (this.file.mrChange) {
      this.disposable.add(
        (this.baseModel = monacoEditor.createModel(
          this.file.baseRaw,
          undefined,
          new Uri('gitlab', false, `target/${this.path}`),
        )),
      );
    }

    this.events = new Set();

    this.updateContent = this.updateContent.bind(this);
    this.updateNewContent = this.updateNewContent.bind(this);
    this.dispose = this.dispose.bind(this);

    eventHub.$on(`editor.update.model.dispose.${this.file.key}`, this.dispose);
    eventHub.$on(`editor.update.model.content.${this.file.key}`, this.updateContent);
    eventHub.$on(`editor.update.model.new.content.${this.file.key}`, this.updateNewContent);
  }