getEmbedNode function

OffsetValue<Embed> getEmbedNode(
  1. QuillController controller,
  2. int offset
)

Implementation

OffsetValue<Embed> getEmbedNode(QuillController controller, int offset) {
  var offset = controller.selection.start;
  var embedNode = controller.queryNode(offset);
  if (embedNode == null || embedNode is! Embed) {
    offset = max(0, offset - 1);
    embedNode = controller.queryNode(offset);
  }
  if (embedNode != null && embedNode is Embed) {
    return OffsetValue(offset, embedNode);
  }

  return throw 'Embed node not found by offset $offset';
}