How to use the mobiledoc-kit/utils/to-range function in mobiledoc-kit

To help you get started, we’ve selected a few mobiledoc-kit 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 bustle / mobiledoc-kit / src / js / editor / post.js View on Github external
setRange(range) {
    range = toRange(range);

    // TODO validate that the range is valid
    // (does not contain marked-for-removal head or tail sections?)
    this._range = range;
    this.scheduleAfterRender(this._renderRange, true);
  }
github bustle / mobiledoc-kit / src / js / editor / editor.js View on Github external
selectRange(range) {
    range = toRange(range);

    this.cursor.selectRange(range);
    this.range = range;
  }
github bustle / mobiledoc-kit / src / js / editor / post.js View on Github external
toggleSection(sectionTagName, range=this._range) {
    range = toRange(range);

    sectionTagName = normalizeTagName(sectionTagName);
    let { post } = this.editor;
    let nextRange = range;

    let everySectionHasTagName = true;
    post.walkMarkerableSections(range, section => {
      if (!this._isSameSectionType(section, sectionTagName)) {
        everySectionHasTagName = false;
      }
    });

    let tagName = everySectionHasTagName ? 'p' : sectionTagName;
    let firstChanged;
    post.walkMarkerableSections(range, section => {
      let changedSection = this.changeSectionTagName(section, tagName);