redactorredactor.js

Cannot read property 'replace' of undefined in Redactor


Redactor I have version 2.11

I am using VueJs and Ruby on Rails.

I am getting the following error inside the replaceToParagraph method:

Cannot read property 'replace' of undefined

The issue looks to be happening on this line:

var blockHtml = blockElem.innerHTML.replace(/<br\s?\/?>/gi, '');

On further inspection, I can recreate this error only in Chrome after adding text, then a horizontal line/rule and then pressing the enter key.

I also believe this has been fixed in version 3 but I don't think I can update to version 3 due to some dependencies on plugins. any way around it in version 2?


Solution

  • This is a Redactor 2 bug, 2.11 in our case.

    As I said, we can't update the Redactor version due to some dependencies, I don't know for sure but updating the version might have fixed this.