insertHtml method

void insertHtml(
  1. String html
)

Inserts HTML at the current cursor position. Parses the HTML and inserts the resulting text content.

Implementation

void insertHtml(String html) {
  if (processInputHtml) {
    html = _processInput(html);
  }

  final parsed = _parser.parse(html);
  final blockIndex = _editorWidgetState?.focusedBlockIndex ?? 0;
  final offset = _editorWidgetState?.cursorOffset ?? 0;

  if (parsed.blocks.isNotEmpty) {
    final info = focusedTableInfo;
    if (info != null) {
      _documentController.insertCellParsedDocument(
          info.blockIndex, info.row, info.col, offset, parsed);
    } else {
      _documentController.insertParsedDocument(blockIndex, offset, parsed);
    }
    _editorWidgetState?.rebuild();
  }
}