dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
544 B
20 lines
544 B
3 years ago
|
import 'dart:math';
|
||
|
|
||
|
import 'package:tuple/tuple.dart';
|
||
|
|
||
|
import '../../flutter_quill.dart';
|
||
|
|
||
|
Tuple2<int, Embed> getEmbedNode(QuillController controller, int offset) {
|
||
|
var offset = controller.selection.start;
|
||
|
var imageNode = controller.queryNode(offset);
|
||
|
if (imageNode == null || !(imageNode is Embed)) {
|
||
|
offset = max(0, offset - 1);
|
||
|
imageNode = controller.queryNode(offset);
|
||
|
}
|
||
|
if (imageNode != null && imageNode is Embed) {
|
||
|
return Tuple2(offset, imageNode);
|
||
|
}
|
||
|
|
||
|
return throw 'Embed node not found by offset $offset';
|
||
|
}
|