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
|
* add allowed chars in RouteParameterSlugify and CodeSlugify
|
||||||
### Fixed
|
### Fixed
|
||||||
* fix creation of new element when a menu is edited
|
* fix creation of new element when a menu is edited
|
||||||
|
* fix editorjs error when the textarea is empty
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
## [1.14.0] - 2022-04-20
|
## [1.14.0] - 2022-04-20
|
||||||
|
|
|
@ -147,9 +147,24 @@ const doInitEditor = () => {
|
||||||
editorContainer.attr('id', id)
|
editorContainer.attr('id', id)
|
||||||
element.hide()
|
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({
|
const editor = new EditorJS(buildConfiguration({
|
||||||
holder: id,
|
holder: id,
|
||||||
data: JSON.parse(element.val()),
|
data: data,
|
||||||
onReady: () => {
|
onReady: () => {
|
||||||
ready = true
|
ready = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue