Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

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

Open
digitalextremist opened this issue May 21, 2022 · 8 comments
Open

Comments

@digitalextremist
Copy link

digitalextremist commented May 21, 2022

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
Copy link

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
Copy link

james6b commented Jun 21, 2022

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
Copy link

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
#41

@kgrosvenor
Copy link

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

#41

@kgrosvenor
Copy link

kgrosvenor commented Jul 17, 2022

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
Copy link

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

@TunahanTuna
Copy link
Contributor

#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
Copy link

#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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants