submit method

void submit(
  1. QuillController controller
)

Implementation

void submit(QuillController controller) {
  var index = controller.selection.start;
  var length = controller.selection.end - index;
  final linkValue = _getLinkAttributeValue(controller);

  if (linkValue != null) {
    // text should be the link's corresponding text, not selection
    final leaf = controller.document.querySegmentLeafNode(index).leaf;
    if (leaf != null) {
      final range = getLinkRange(leaf);
      index = range.start;
      length = range.end - range.start;
    }
  }
  controller
    ..replaceText(index, length, text, null)
    ..formatText(index, text.length, LinkAttribute(link));
}