• Naveen

    (@naveen17797)


    I am trying to highlight all the selected blocks in the gutenberg, i could get a list of blocks using this

    wp.data.select("core/block-editor").getMultiSelectedBlocks();

    and i could loop through all the blocks to apply the highlighting tag, the problem i am currently facing is i cannot use applyformat method because the block doesnt have the richtextelement instance stored inside it.

    From this tutorial in the wordpress i could see that the format is applied by creating the format object with applyformat and changing the block html with onChange method, i am trying to do the same, but the problem is i dont have the richtext element usually passed through props.value ( in the wp tutorial) and no way to access the onChange method, and i tried to use update block to update the original content like this,

    wp.data.dispatch("core/block-editor").updateBlock(block.clientId, {originalContent: content});,

    it didnt work either. What is the proper way to do this?

    • This topic was modified 5 years ago by Naveen.
    • This topic was modified 5 years ago by Naveen.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to apply highlighting to multiple blocks in block editor?’ is closed to new replies.