setContent method

void setContent(
  1. String markdown
)

Replace the document content from markdown.

Implementation

void setContent(String markdown) {
  final document = markdown.isNotEmpty
      ? markdownToDocument(normaliseMarkdownTables(markdown))
      : Document.blank(withInitialText: true);

  _scrollController?.dispose();
  _scrollController = null;

  setState(() {
    _editorState.dispose();
    _editorState = EditorState(document: document);
    _editorState.editable = widget.editable;
    _editorState.transactionStream.listen((_) {
      widget.onChanged?.call(toMarkdown());
    });
  });
}