Skip to content

Commit 6320c2a

Browse files
authored
fix: empty editor and required field (melishev#59)
Co-authored-by: Tunahan Tuna <[email protected]>
1 parent 7482bac commit 6320c2a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

admin/src/components/editorjs/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ const Editor = ({ onChange, name, value }) => {
5151
document.querySelector('[data-tool="image"]').remove()
5252
}}
5353
onChange={(api, newData) => {
54-
if (newData.blocks.length) {
55-
onChange({target: {name, value: JSON.stringify(newData)}});
54+
if (!newData.blocks.length) {
55+
newData = null;
56+
onChange({ target: { name, value: newData } });
57+
} else {
58+
onChange({ target: { name, value: JSON.stringify(newData) } });
5659
}
5760
}}
5861
tools={{...requiredTools, ...customTools, ...customImageTool}}

0 commit comments

Comments
 (0)