How to use the @remirror/core-utils.isDOMNode function in @remirror/core-utils

To help you get started, we’ve selected a few @remirror/core-utils 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 ifiokjr / remirror / @remirror / react-node-view / src / react-node-view.tsx View on Github external
public createDomRef(): HTMLElement {
    const { toDOM } = this.node.type.spec;

    if (toDOM) {
      const domSpec = toDOM(this.node);
      if (isString(domSpec)) {
        return document.createElement(domSpec);
      }

      if (isDOMNode(domSpec)) {
        if (!isElementDOMNode(domSpec)) {
          throw new Error('Invalid HTML Element provided in the DOM Spec');
        }
        return domSpec;
      }

      // Use the outer element string to render the dom node
      return document.createElement(domSpec[0]);
    }
    return this.node.isInline ? document.createElement('span') : document.createElement('div');
  }
github ifiokjr / remirror / @remirror / react-node-view / src / react-node-view.tsx View on Github external
public setDomAttrs(node: ProsemirrorNode, element: HTMLElement) {
    const { toDOM } = this.node.type.spec;
    if (toDOM) {
      const domSpec = toDOM(node);

      if (isString(domSpec) || isDOMNode(domSpec)) {
        return;
      }

      const attrs = domSpec[1];

      if (isPlainObject(attrs)) {
        keys(attrs).forEach(attr => {
          element.setAttribute(attr, String(attrs[attr]));
        });

        return;
      }
    }

    keys(node.attrs).forEach(attr => {
      element.setAttribute(attr, node.attrs[attr]);