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

Emptying editor does not allow "Save" and leaves artifacts.

Open digitalextremist opened this issue 3 years ago • 8 comments

If an editor field is used once, it cannot be returned to NULL or "".

If all content is deleted from the field, Save does not light up. And if edits are made elsewhere to bring up Save, that empty field does not save. The text from the prior state will still be there, rather than "" or NULL.

The only way to empty a field is to directly edit the database.

digitalextremist avatar May 21 '22 00:05 digitalextremist

I got the same issue, if i remove everything, the last block will be kept Original image Remove everything image Press save and reload image Some times i will keep line 1, sometime it will keep more

icetea-hwng avatar Jun 17 '22 11:06 icetea-hwng

Dunno if this will solve all the issues mentioned above, but I got it to save in an empty state by removing if (newData.blocks.length) {} from admin/src/components/editorjs (line 54 in my fork of the repo). Not entirely sure why that if statement is there to begin with, but hope this helps someone.

james6b avatar Jun 21 '22 23:06 james6b

Dunno if this will solve all the issues mentioned above, but I got it to save in an empty state by removing if (newData.blocks.length) {} from admin/src/components/editorjs (line 54 in my fork of the repo). Not entirely sure why that if statement is there to begin with, but hope this helps someone.

Thanks,

I found this PR can fix the issue https://github.com/melishev/strapi-plugin-react-editorjs/pull/41

icetea-hwng avatar Jun 27 '22 03:06 icetea-hwng

Hey i already fixed this in my PR. Please merge it, im already using in production :)

https://github.com/melishev/strapi-plugin-react-editorjs/pull/41

kgrosvenor avatar Jul 17 '22 21:07 kgrosvenor

I thought the check for blocks was not needed, just forward the change event and resave

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

For more info test the PR info for the following usecase

  • Can you save if you have content then remove it all, then resave?

kgrosvenor avatar Jul 17 '22 21:07 kgrosvenor

@melishev Could you accept this PR, ill have some time soon to complete dark mode

kgrosvenor avatar Jul 17 '22 21:07 kgrosvenor

#41 this branch really works but it needed a minor fix.

If the text field is a required field, it should have given a "required field" warning when the text is deleted.

#59 With the fix I made here, we can overcome this problem without any problems.

TunahanTuna avatar Aug 18 '22 10:08 TunahanTuna

#41 this branch really works but it needed a minor fix.

If the text field is a required field, it should have given a "required field" warning when the text is deleted.

#59 With the fix I made here, we can overcome this problem without any problems.

Any advance on this?

SalahAdDin avatar Oct 08 '22 22:10 SalahAdDin