Skip to content

I can't update a block of text after it's creation #1680

@MarcoZucc

Description

@MarcoZucc

I have a problem when I try to update a block of text after its creation, this is my code:

`$(document).ready(function(){

	var text_to_insert = [
        {
            "type" : "paragraph",
            "data" : {
                "text" : "Initial text abcd"
            }
        }];

var text_to_insert_afeter_ceckbox = [    
        {
            "type" : "paragraph",
            "data" : {
                "text" : "ABCD after ceckbo"
            }
        }];

var editor_IT = new EditorJS({

  holder : 'box_with_text',
  tools: {
     table: {
          class: Table,
          inlineToolbar: true,
          shortcut: 'CMD+ALT+T',
        },
  },
  data: {
  blocks: testo
       
  },
  onReady: function(){
   
      },
  onChange: function() {
        console.log('something changed');  
     //save function;
    
   },
    minHeight : 0
});


        $('input[type="checkbox"]').click(function(){
            if($(this).is(":checked")){
                console.log("Checkbox is checked.");
				editor_IT.blocks.insert(text_to_insert_afeter_ceckbox);
				
            }
            else if($(this).is(":not(:checked)")){
                console.log("Checkbox is unchecked.");
				editor_IT.blocks.insert(text_to_insert);
				
            }
        });

		
    });`

I tried to update the block of text using:

editor_IT.blocks.insert(text_to_insert);

But don’t wok
The aim would be is:

  1. create a block of text with "acbd" for example

  2. If user check or uncheck the checkbox I’m going to update the text in the editor area.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions