melishev / strapi-plugin-react-editorjs

📝 Plugin for Strapi Headless CMS, hiding the standard WYSIWYG editor on Editor.js
https://www.npmjs.com/package/strapi-plugin-react-editorjs
MIT License
171 stars 79 forks source link

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

Open digitalextremist opened 2 years ago

digitalextremist commented 2 years ago

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.

icetea-hwng commented 2 years ago

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

james6b commented 2 years ago

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.

icetea-hwng commented 2 years ago

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

kgrosvenor commented 2 years ago

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 commented 2 years ago

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

kgrosvenor commented 2 years ago

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

TunahanTuna commented 2 years ago

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.

SalahAdDin commented 2 years ago

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?