fix editorjs error when the textarea is empty
This commit is contained in:
parent
f3d5b0380d
commit
734a51891d
|
@ -4,6 +4,7 @@
|
|||
* add allowed chars in RouteParameterSlugify and CodeSlugify
|
||||
### Fixed
|
||||
* fix creation of new element when a menu is edited
|
||||
* fix editorjs error when the textarea is empty
|
||||
### Changed
|
||||
|
||||
## [1.14.0] - 2022-04-20
|
||||
|
|
|
@ -147,9 +147,24 @@ const doInitEditor = () => {
|
|||
editorContainer.attr('id', id)
|
||||
element.hide()
|
||||
|
||||
let data = []
|
||||
|
||||
try {
|
||||
const value = JSON.parse(element.val())
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
data = value
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (!Array.isArray(data)) {
|
||||
data = []
|
||||
}
|
||||
|
||||
const editor = new EditorJS(buildConfiguration({
|
||||
holder: id,
|
||||
data: JSON.parse(element.val()),
|
||||
data: data,
|
||||
onReady: () => {
|
||||
ready = true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue