How to use the codemirror.signal function in codemirror

To help you get started, we’ve selected a few codemirror 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 prose / prose / test / spec / vendor / codemirror.js View on Github external
cm.setValue(str);
    expect(cm.getValue()).eql(str);
    expect(cm.isClean()).not.ok;

    // blur event
    var i = 0;
    cm.on('blur', function () {
      i += 1;
      expect(i === 1).ok;
    });
    cm.on('focus', function () {
      i += 1;
      expect(i === 2).ok;
      done();
    });
    CodeMirror.signal(cm, 'blur');
    CodeMirror.signal(cm, 'focus');
  });
github prisma-labs / graphql-playground / packages / graphql-playground-react / src / components / Playground / QueryEditor.tsx View on Github external
componentDidUpdate(prevProps) {
    const CodeMirror = require('codemirror')

    // Ensure the changes caused by this update are not interpretted as
    // user-input changes which could otherwise result in an infinite
    // event loop.

    this.ignoreChangeEvent = true
    if (this.props.schema !== prevProps.schema) {
      this.editor.options.lint.schema = this.props.schema
      this.editor.options.hintOptions.schema = this.props.schema
      this.editor.options.info.schema = this.props.schema
      this.editor.options.jump.schema = this.props.schema
      CodeMirror.signal(this.editor, 'change', this.editor)
    }
    if (
      this.props.value !== prevProps.value &&
      this.props.value !== this.cachedValue
    ) {
      this.cachedValue = this.props.value
      this.editor.setValue(this.props.value)
    }
    this.ignoreChangeEvent = false

    setTimeout(() => {
      if (this.props.sessionId !== prevProps.sessionId) {
        if (this.props.scrollTop) {
          this.scrollTo(this.props.scrollTop)
        }
      }
github circlecell / jsoncompare.com / frontend / js / editor-init / validate-extension.js View on Github external
CodeMirror.defineExtension('validate', function validate() {
    const code = this.getValue();
    let lineMatches;

    try {
        JSON.parse(code);
        this.notify('SUCCESS', 'Valid JSON');
        CodeMirror.signal(CodeMirror, 'validate', this);
    } catch (_e) {
        try {
            jsonlint.parse(code);
            this.notify('SUCCESS', 'Valid JSON');
            CodeMirror.signal(CodeMirror, 'validate', this);
        } catch (e) {
            // retrieve line number from error
            lineMatches = e.message.match(/line ([0-9]*)/);

            if (lineMatches && lineMatches.length > 1) {
                this.highlightErrorLine(+lineMatches[1] - 1);
            }

            this.notify('ERROR', e);

            CodeMirror.signal(CodeMirror, 'errorvalidate', this);
github CSG4 / super-graphiql / packages / super-graphiql-react / dist / components / QueryEditor.js View on Github external
value: function componentDidUpdate(prevProps) {
      var CodeMirror = require("codemirror");

      // Ensure the changes caused by this update are not interpretted as
      // user-input changes which could otherwise result in an infinite
      // event loop.
      this.ignoreChangeEvent = true;
      if (this.props.schema !== prevProps.schema) {
        this.editor.options.lint.schema = this.props.schema;
        this.editor.options.hintOptions.schema = this.props.schema;
        this.editor.options.info.schema = this.props.schema;
        this.editor.options.jump.schema = this.props.schema;
        CodeMirror.signal(this.editor, "change", this.editor);
      }
      if (this.props.value !== prevProps.value && this.props.value !== this.cachedValue) {
        this.cachedValue = this.props.value;
        this.editor.setValue(this.props.value);
      }
      this.ignoreChangeEvent = false;
    }
  }, {
github graphql / graphiql / packages / graphiql / src / components / VariableEditor.js View on Github external
componentDidUpdate(prevProps) {
    const CodeMirror = require('codemirror');

    // Ensure the changes caused by this update are not interpretted as
    // user-input changes which could otherwise result in an infinite
    // event loop.
    this.ignoreChangeEvent = true;
    if (this.props.variableToType !== prevProps.variableToType) {
      this.editor.options.lint.variableToType = this.props.variableToType;
      this.editor.options.hintOptions.variableToType = this.props.variableToType;
      CodeMirror.signal(this.editor, 'change', this.editor);
    }
    if (
      this.props.value !== prevProps.value &&
      this.props.value !== this.cachedValue
    ) {
      const thisValue = this.props.value || '';
      this.cachedValue = thisValue;
      this.editor.setValue(thisValue);
    }
    this.ignoreChangeEvent = false;
  }
github 1stdibs / recess / src / Editor.js View on Github external
componentDidUpdate(prevProps) {
        const CodeMirror = require('codemirror');

        // Ensure the changes caused by this update are not interpretted as
        // user-input changes which could otherwise result in an infinite
        // event loop.
        this.ignoreChangeEvent = true;
        if (this.props.autoCompleteData !== prevProps.autoCompleteData) {
            // this.editor.options.lint.autoCompleteData = this.props.autoCompleteData;
            this.editor.options.hintOptions.variableToType = getVariableToType(
                this.props.autoCompleteData
            );
            CodeMirror.signal(this.editor, 'change', this.editor);
        }
        if (this.props.value !== prevProps.value && this.props.value !== this.cachedValue) {
            const thisValue = this.props.value || '';
            this.cachedValue = thisValue;
            this.editor.setValue(thisValue);
        }
        this.ignoreChangeEvent = false;
    }
github nteract / nteract / packages / editor / src / index.tsx View on Github external
goLineDownOrEmit(editor: Editor & Doc): void {
    const cursor: Position = editor.getCursor();
    const lastLineNumber: number = editor.lastLine();
    const lastLine: string = editor.getLine(lastLineNumber);
    if (
      cursor.line === lastLineNumber &&
      cursor.ch === lastLine.length &&
      !editor.somethingSelected()
    ) {
      CodeMirror.signal(editor, "bottomBoundary");
    } else {
      editor.execCommand("goLineDown");
    }
  }
github laobubu / HyperMD / src / addon / doc-info.ts View on Github external
private _diffAndApply(data: DocInfoLike) {
    for (let k in data) {
      if (!isEqual(data[k], this[k])) {
        CodeMirror.signal(this.cm, "docInfoChange", k, data[k])
        this[k] = data[k]

        if (k === 'footnotes') {
          let footnoteDict: this['footnoteDict'] = this.footnoteDict = {}
          for (let node of data[k]) {
            let name = node.name.toLowerCase()
            if (name in footnoteDict) footnoteDict[name].push(node)
            else footnoteDict[name] = [node]
          }
        }
      }
    }
  }
}
github ibericode / mailchimp-for-wordpress / assets / browserify / admin / form-editor / form-editor.js View on Github external
window.addEventListener('load', function() {
        CodeMirror.signal(editor, "change");
    });
github prisma-labs / graphql-playground / packages / graphql-playground-react / src / components / Playground / SchemaExplorer / SDLEditor.tsx View on Github external
const initialScroll = this.editor.getScrollInfo()
      this.cachedValue =
        getSDL(
          this.props.schema,
          this.props.settings['schema.disableComments'],
        ) || ''
      this.editor.setValue(
        getSDL(
          this.props.schema,
          this.props.settings['schema.disableComments'],
        ),
      )
      if (this.props.isPollingSchema) {
        this.editor.scrollTo(initialScroll.left, initialScroll.top)
      }
      CodeMirror.signal(this.editor, 'change', this.editor)
    }
    if (this.props.width !== prevProps.width) {
      this.editor.refresh()
    }
    if (
      this.props.settings['schema.disableComments'] !==
      prevProps.settings['schema.disableComments']
    ) {
      this.editor.refresh()
    }
  }