fleather icon indicating copy to clipboard operation
fleather copied to clipboard

Is it possible to get the position of an embed I have found using DeltaIterator?

Open nialljawad96 opened this issue 1 year ago • 0 comments

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

       }

      }
    }
  }

nialljawad96 avatar Jan 27 '24 11:01 nialljawad96