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

Commit

Permalink
fix: empty editor and required field (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: Tunahan Tuna <mustafatunahantuna@outlook.com>
  • Loading branch information
TunahanTuna and TunahanTuna committed Sep 2, 2022
1 parent 7482bac commit 6320c2a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions admin/src/components/editorjs/index.js
Expand Up @@ -51,8 +51,11 @@ const Editor = ({ onChange, name, value }) => {
document.querySelector('[data-tool="image"]').remove()
}}
onChange={(api, newData) => {
if (newData.blocks.length) {
onChange({target: {name, value: JSON.stringify(newData)}});
if (!newData.blocks.length) {
newData = null;
onChange({ target: { name, value: newData } });
} else {
onChange({ target: { name, value: JSON.stringify(newData) } });
}
}}
tools={{...requiredTools, ...customTools, ...customImageTool}}
Expand Down

0 comments on commit 6320c2a

Please sign in to comment.