setBookmark method

TextMarker setBookmark(
  1. Position pos, {
  2. Element? widget,
  3. bool? insertLeft,
  4. bool? shared,
})

Inserts a bookmark, a handle that follows the text around it as it is being edited, at the given position. A bookmark has two methods find() and clear(). The first returns the current position of the bookmark, if it is still in the document, and the second explicitly removes the bookmark.

widget can be used to display a DOM node at the current location of the bookmark (analogous to the replacedWith option to markText). insertLeft: by default, text typed when the cursor is on top of the bookmark will end up to the right of the bookmark. Set this option to true to make it go to the left instead. 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 setBookmark(Position pos,
    {Element? widget, bool? insertLeft, bool? shared}) {
  var options = <String, dynamic>{};

  if (widget != null) options['widget'] = widget;
  if (insertLeft != null) options['insertLeft'] = insertLeft;
  if (shared != null) options['shared'] = shared;

  return TextMarker(callArgs('setBookmark', [pos.toProxy(), jsify(options)]));
}