vue-medium-editor: Error in event handler when creating anchor links
When I use regular toolbar buttons it formats the text correctly without an error. However, when I use the anchor popup, load in a link then confirm I get the following error:
[Vue warn]: Error in event handler for "edit": "TypeError: Cannot read property 'innerHTML' of undefined"
This is the code I am using as a method:
processEditOperation (operation) {
this.text = operation.event.srcElement.innerHTML
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (8 by maintainers)
I found a fix that seems to work for now. What I’ve noticed is that the
eventproperty is an empty object when we are trying to insert a link. So it makes sense that the error happens: that it could not find theinnerHtml.But the
apiproperty is not empty and it leads to theinnerHTMLproperty. Below is what I’ve done for theapplyTextEdit(). I’ve clicked all the buttons and the buttons still work along with the anchor button.This is helpful. We should reference this in the readme.
So what happens when you click ‘save link’ is that a few different events are triggered. The event that we listen to in the
vue-medium-editorbridge is theeditableInputevent.Apparently, when you click ‘save link’ some of the information is lost and unlike the
keyupevent it does not triggereditableInputwith the correct data in the arguments. In the playground you might use your browser debugger to set a breakpoint on that line and check if that is the case. If so, the error should be traced back.I will not invest any further time doing the research but if you need any hints or have any question or your app comes closer to 1.0 feel free to reach out.
I wanted to give you more but I had a call coming in right at this second 😃 Did not plan to leave you alone on that one.
You can use this here to trigger the
editableContentevent. https://github.com/yabwe/medium-editor/blob/master/API.md#triggername-data-editableBut I just tried this out and I can not get the result I expected.
We will have to dig through the medium editor source code.