How to use the mobiledoc-kit/utils/array-utils.forEach 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 / parsers / section.js View on Github external
parseElementNode(element) {
    let { state } = this;

    const markups = this._markupsFromElement(element);
    if (markups.length && state.text.length && state.section.isMarkerable) {
      this._createMarker();
    }
    state.markups.push(...markups);

    forEach(element.childNodes, (node) => {
      this.parseNode(node);
    });

    if (markups.length && state.text.length && state.section.isMarkerable) {
      // create the marker started for this node
      this._createMarker();
    }

    // pop the current markups from the stack
    state.markups.splice(-markups.length, markups.length);
  }
github gazooka / GhostInAzureWebApp / node_modules / @tryghost / mobiledoc-kit / src / js / parsers / section.js View on Github external
parseElementNode(element) {
    let { state } = this;

    const markups = this._markupsFromElement(element);
    if (markups.length && state.text.length && state.section.isMarkerable) {
      this._createMarker();
    }
    state.markups.push(...markups);

    forEach(element.childNodes, (node) => {
      this.parseNode(node);
    });

    if (markups.length && state.text.length && state.section.isMarkerable) {
      // create the marker started for this node
      this._createMarker();
    }

    // pop the current markups from the stack
    state.markups.splice(-markups.length, markups.length);
  }
github gazooka / GhostInAzureWebApp / node_modules / @tryghost / mobiledoc-kit / src / js / parsers / section.js View on Github external
// section-creating elements
        if (this.state.section.isMarkerable && !this.state.text && this.state.section.markers.length === 0) {
          this.state.section = null;
        } else {
          this._closeCurrentSection();
        }

        this._updateStateFromElement(node);
      }

      if (this.state.section.isListSection) {
        // ensure the list section is closed and added to the sections list.
        // _closeCurrentSection handles pushing list items onto the list section
        this._closeCurrentSection();

        forEach(node.childNodes, (node) => {
          this.parseNode(node);
        });
        return;
      }
    }

    switch (node.nodeType) {
      case NODE_TYPES.TEXT:
        this.parseTextNode(node);
        break;
      case NODE_TYPES.ELEMENT:
        this.parseElementNode(node);
        break;
    }
  }
github bustle / mobiledoc-kit / tests / helpers / dom.js View on Github external
function walkDOMUntil(topNode, conditionFn=() => {}) {
  if (!topNode) { throw new Error('Cannot call walkDOMUntil without a node'); }
  let stack = [topNode];
  let currentElement;

  while (stack.length) {
    currentElement = stack.pop();

    if (conditionFn(currentElement)) {
      return currentElement;
    }

    forEach(currentElement.childNodes, el => stack.push(el));
  }
}
github bustle / mobiledoc-kit / src / js / editor / event-manager.js View on Github external
_trigger(context, type, event) {
    forEach(
      filter(this._listeners, ([_context, _type]) => {
        return _context === context && _type === type;
      }),
      ([context,, listener]) => {
        listener.call(context, event);
      }
    );
  }
github bustle / mobiledoc-kit / src / js / renderers / editor-dom.js View on Github external
function validateCards(cards=[]) {
  forEach(cards, card => {
    assert(
      `Card "${card.name}" must define type "dom", has: "${card.type}"`,
      card.type === 'dom'
    );
    assert(
      `Card "${card.name}" must define \`render\` method`,
      !!card.render
    );
  });
  return cards;
}
github bustle / mobiledoc-kit / src / js / renderers / editor-dom.js View on Github external
function validateAtoms(atoms=[]) {
  forEach(atoms, atom => {
    assert(
      `Atom "${atom.name}" must define type "dom", has: "${atom.type}"`,
      atom.type === 'dom'
    );
    assert(
      `Atom "${atom.name}" must define \`render\` method`,
      !!atom.render
    );
  });
  return atoms;
}