markText method

TextMarker markText(
  1. Position from,
  2. Position to, {
  3. String? className,
  4. bool? inclusiveLeft,
  5. bool? inclusiveRight,
  6. bool? atomic,
  7. bool? collapsed,
  8. bool? clearOnEnter,
  9. bool? clearWhenEmpty,
  10. Element? replacedWith,
  11. bool? handleMouseEvents,
  12. bool? readOnly,
  13. bool? addToHistory,
  14. String? startStyle,
  15. String? endStyle,
  16. String? css,
  17. String? title,
  18. bool? shared,
})

Can be used to mark a range of text with a specific CSS class name.

className: assigns a CSS class to the marked stretch of text. inclusiveLeft: determines whether text inserted on the left of the marker will end up inside or outside of it. inclusiveRight: like inclusiveLeft, but for the right side. atomic: atomic ranges act as a single unit when cursor movement is concerned — i.e. it is impossible to place the cursor inside of them. In atomic ranges, inclusiveLeft and inclusiveRight have a different meaning — they will prevent the cursor from being placed respectively directly before and directly after the range. collapsed: collapsed ranges do not show up in the display. Setting a range to be collapsed will automatically make it atomic. clearOnEnter: when enabled, will cause the mark to clear itself whenever the cursor enters its range. This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them. The "clear" event fired on the range handle can be used to be notified when this happens. clearWhenEmpty: determines whether the mark is automatically cleared when it becomes empty. Default is true. replacedWith: use a given node to display this range. Implies both collapsed and atomic. The given DOM node must be an inline element (as opposed to a block element). handleMouseEvents: when replacedWith is given, this determines whether the editor will capture mouse and drag events occurring in this widget. Default is false — the events will be left alone for the default browser handler, or specific handlers on the widget, to capture. readOnly: a read-only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document. Note: adding a read-only span currently clears the undo history of the editor, because existing undo events being partially nullified by read-only spans would corrupt the history (in the current implementation). addToHistory: when set to true (default is false), adding this marker will create an event in the undo history that can be individually undone (clearing the marker). startStyle: can be used to specify an extra CSS class to be applied to the leftmost span that is part of the marker. endStyle: equivalent to startStyle, but for the rightmost span. css a string of CSS to be applied to the covered text. For example "color: #fe3". title: when given, will give the nodes created for this span a HTML title attribute with the given value. shared: when the target document is linked to other documents, you can set shared to true to make the marker appear in all documents. By default, a marker appears only in its target document.

Implementation

TextMarker markText(Position from, Position to,
    {String? className,
    bool? inclusiveLeft,
    bool? inclusiveRight,
    bool? atomic,
    bool? collapsed,
    bool? clearOnEnter,
    bool? clearWhenEmpty,
    Element? replacedWith,
    bool? handleMouseEvents,
    bool? readOnly,
    bool? addToHistory,
    String? startStyle,
    String? endStyle,
    String? css,
    String? title,
    bool? shared}) {
  var options = <String, dynamic>{};

  if (className != null) options['className'] = className;
  if (inclusiveLeft != null) options['inclusiveLeft'] = inclusiveLeft;
  if (inclusiveRight != null) options['inclusiveRight'] = inclusiveRight;
  if (atomic != null) options['atomic'] = atomic;
  if (collapsed != null) options['collapsed'] = collapsed;
  if (clearOnEnter != null) options['clearOnEnter'] = clearOnEnter;
  if (clearWhenEmpty != null) options['clearWhenEmpty'] = clearWhenEmpty;
  if (replacedWith != null) options['replacedWith'] = replacedWith;
  if (handleMouseEvents != null) {
    options['handleMouseEvents'] = handleMouseEvents;
  }
  if (readOnly != null) options['readOnly'] = readOnly;
  if (addToHistory != null) options['addToHistory'] = addToHistory;
  if (startStyle != null) options['startStyle'] = startStyle;
  if (endStyle != null) options['endStyle'] = endStyle;
  if (css != null) options['css'] = css;
  if (title != null) options['title'] = title;
  if (shared != null) options['shared'] = shared;

  return TextMarker(
      callArgs('markText', [from.toProxy(), to.toProxy(), jsify(options)]));
}