_addImgNode()

in src/model/encoding/convertFromHTMLToContentBlocks.js [611:641]


  _addImgNode(node: Node, style: DraftInlineStyle) {
    if (!isHTMLImageElement(node)) {
      return;
    }
    const image: HTMLImageElement = (node: any);
    const entityConfig: {[string]: string} = {};

    imgAttr.forEach(attr => {
      const imageAttribute = image.getAttribute(attr);
      if (imageAttribute) {
        entityConfig[attr] = imageAttribute;
      }
    });

    this.contentState = this.contentState.createEntity(
      'IMAGE',
      'IMMUTABLE',
      entityConfig,
    );
    this.currentEntity = this.contentState.getLastCreatedEntityKey();

    // The child text node cannot just have a space or return as content (since
    // we strip those out)
    const alt = image.getAttribute('alt');
    if (allowPastingAltText && alt != null && alt.length > 0) {
      this._appendText(alt, style);
    } else {
      this._appendText('\ud83d\udcf7', style);
    }
    this.currentEntity = null;
  }