visitElementAfter method

  1. @override
void visitElementAfter(
  1. Element element
)

Called when an Element has been reached, after its children have been visited.

Will not be called if visitElementBefore returns false.

Implementation

@override
void visitElementAfter(md.Element element) {
  final tag = element.tag;

  if (_isEmbedElement(element)) {
    _delta.insert(_toEmbeddable(element).toJson());
  }

  if (tag == 'br') {
    _delta.insert('\n');
  }

  // exit block with new line
  // hr need to be followed by new line
  _insertNewLineAfterElementIfNeeded(element);

  if (tag == 'blockquote') {
    _isInBlockQuote = false;
  }

  if (tag == 'pre') {
    _isInCodeblock = false;
  }

  if (tag == 'li') {
    _listItemIndent--;
  }

  if (_haveBlockAttrs(element)) {
    _activeBlockAttributes.removeLast();
  }

  if (_haveInlineAttrs(element)) {
    _activeInlineAttributes.removeLast();
  }

  if (_currentBlockTag == tag) {
    _currentBlockTag = null;
  }
  _lastTag = tag;
}