fleather
fleather copied to clipboard
Is it possible to get the position of an embed I have found using DeltaIterator?
Is your feature request related to a problem? Please describe. Is it possible to get the position of an embed I have found using DeltaIterator? I want to search through my document, see if there is an embed that matches a String key, and if it does, I want to adjust the title parameter of that embed. The problem is, how do I then replace this embed? I think I have to use replaceText but I am getting lots of errors doing that.
Describe the solution you'd like A way to replace/adjust the embed using the way below, or a different method.
Describe alternatives you've considered
analyseDocForEmbed(context) {
String embedToAdjust = embeddableNoteIDOpened;
final DeltaIterator iterator = DeltaIterator(controller.document.toDelta());
while (iterator.hasNext) {
final Operation operation = iterator.next();
if (operation.data is Map) {
Map<dynamic, dynamic> data = operation.data as Map<dynamic, dynamic>;
if (data["noteID"] == embedToAdjust){
data["title"] = "New Title";
//adjust/replace embed here
}
}
}
}