highlightingFor function

String? highlightingFor(
  1. EditorState state,
  2. List<Tag> tags, [
  3. NodeType? scope
])

Returns the CSS classes (if any) that the highlighters active in the state would assign to the given style tags and (optional) language scope.

Implementation

String? highlightingFor(
  EditorState state,
  List<Tag> tags, [
  NodeType? scope,
]) {
  final highlighters = getHighlighters(state);
  String? result;
  if (highlighters != null) {
    for (final highlighter in highlighters) {
      if (highlighter.scope == null || (scope != null && highlighter.scope!(scope))) {
        final cls = highlighter.style(tags);
        if (cls != null) {
          result = result != null ? '$result $cls' : cls;
        }
      }
    }
  }
  return result;
}