I am getting below error when I call the create function on the editor.
editor.min.js:formatted:8487 Uncaught TypeError: Cannot read property 'replace' of undefined
at Object.convertContentsForEditor (editor.min.js:formatted:8487)
at Object._initWysiwygArea (editor.min.js:formatted:8825)
at Object._init (editor.min.js:formatted:8793)
at A (editor.min.js:formatted:10225)
at Object.create (editor.min.js:formatted:10279)
at Object.
If I move to the previous release, things were perfectly fine. Is there any change that I am supposed to do with this new release?
Hi, Can you show me the editor's define code?
And also show me value of the target textarea.
Below is the code I am trying to execute.
let imageEditor = SUNEDITOR.create("imageContainer",{
mode: "balloon-always",
resizingBar: false,
showPathLabel: false,
display: "inline",
tabDisable: false,
placeholder: "Enter the image here",
buttonList: [
[
"image",
"removeFormat"
]
],
});
imageEditor.setContents("");
The error appears on the create function.
There is no value in the target textarea. In fact, there is no textarea inside the #imageContainer at the time of create function call.
Not sure what changed in this release, since the same code was working fine so far.
Um.. what tested browser?
Using Google Chrome.
Can you check this code?
imageEditor.core.context.element.originElement
Gives below error:
Uncaught TypeError: Cannot read property 'core' of null
Current code is below:
this.convertContentsForEditor(context.element.originElement.value);
convertContentsForEditor: function (contents) {
contents = contents.replace(....)
}
I think contents is undefined.
And context.element.originElement is the target <textarea>
Before the editor is initialized it is bound to be undefined. I believe the _convertContentsForEditor_ should only be executed if _contents_ is not undefined.
The "value" attribute of "textarea" cannot be "undefined".
There will be something wrong.
The error is not reproduced.
Show me the HTML (target textarea) code as well.
OS is Windows or Mac?
<div id="imageContainer"></div>
I was using a div to create the editors so far. Seemed to work perfectly fine. But now it seems that I'll need to change it to textarea.
I am using Mac.
The target element should use only the textarea
Hmm.. Is there a difference in using the target element div and textarea?
Up until 2.30.0 div was working fine. In the new release (2.30.1), things broke.
I have not used a single textarea so far.
Defined as using only textarea and developed the editor.
If you used the save() function, an error would have occurred.
It's not difficult to allow div possible, so I will consider.
Converting all the div to textarea seems to do the trick for now.
Thanks @JiHong88 :)
Most helpful comment
Converting all the
divtotextareaseems to do the trick for now.Thanks @JiHong88 :)