Get an added block

This example shows how to get instance of inserted block in the editor. Click add (+) icon on the toolbar, paste some block and see the result in the browser console.


<!-- element -->
<textarea id="entry">...</textarea>

<!-- call -->
let app = Redactor('#entry', {
    subscribe: {
        'block.add': function(event) {
            let instance = event.get('inserted');
            if (instance.isType('text')) {
                let $block = instance.getBlock();

                // example of manipulation of a block
                $block.html('My text');

                // set caret to the end
                let caret ='caret');
                caret.set($block, 'end')