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
592 B
20 lines
592 B
import 'dart:math'; |
|
|
|
import 'package:tuple/tuple.dart'; |
|
|
|
import '../models/documents/nodes/leaf.dart'; |
|
import '../widgets/controller.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'; |
|
}
|
|
|