register method

void register()

Registers the Word Counter and starts notifying about updates to word and character count.

Implementation

void register() {
  if (isRunning) {
    return;
  }

  isRunning = true;
  _documentCounters = _countersFromNode(editorState.document.root);
  if (editorState.selection?.isCollapsed ?? false) {
    _recountOnSelectionUpdate();
  }

  if (documentCounters != _emptyCounters ||
      selectionCounters != _emptyCounters) {
    notifyListeners();
  }

  _streamSubscription = editorState.transactionStream.listen(_onDocUpdate);
  editorState.selectionNotifier.addListener(_onSelUpdate);
}