strapi-plugin-react-editorjs icon indicating copy to clipboard operation
strapi-plugin-react-editorjs copied to clipboard

Value onChange event isn't updating when you paste blocks from one editor to another

Open kgrosvenor opened this issue 4 years ago • 4 comments

If you paste blocks from one strapi window to another and click save it doesnt reflect when you next load the content type, you can work around it by adding a few chars and removing them and then hitting save

kgrosvenor avatar Apr 20 '22 22:04 kgrosvenor

This resolves it in our case

onChange={(api, newData) => {
  if (newData.blocks.length) {
    onChange({target: {name, value: JSON.stringify(newData)}});
  } else {
    api.saver.save().then((res) => {
      onChange({target: {name, value: JSON.stringify(res)}});
    });
  }
}}

kgrosvenor avatar Apr 20 '22 23:04 kgrosvenor

@kgrosvenor Oh that's amazing, could you send a PR with your changes so we can include them in the package?

melishev avatar Apr 21 '22 10:04 melishev

I shall do this evening @melishev i brought this into our work project like mentioned but will move into this project also and create a PR

kgrosvenor avatar Apr 21 '22 10:04 kgrosvenor

I went with this in the end since its a same result mostly

onChange={(api) => {
  api.saver.save().then((res) => {
    onChange({target: {name, value: JSON.stringify(res)}});
  });
}}

kgrosvenor avatar Apr 21 '22 10:04 kgrosvenor