Describe the bug
The html editor does not recognize content when copy/pasting from MS Word. We noticed this bug in production.
This is due to content from MS Word having a specific class attribute:
The console is throwing the following error:
Uncaught TypeError: Cannot read properties of null (reading 'length')
The regex /<p>/g tested in the match function does not handle p tag having a class attribute and the match function is returning null if no matches are found (doc).
Therefore this.content.match(/<p>/g).length is throwing an error.
Proposed solution
Locally we can solve the issue by checking first that this.content.match(/<p>/g) is thruthy
Environment
Describe the bug The html editor does not recognize content when copy/pasting from MS Word. We noticed this bug in production. This is due to content from MS Word having a specific class attribute: The console is throwing the following error:
The code throwing the error is the following (in ai-admin-jqadm/js/components/html-editor.js, line 50):
The regex
/<p>/g
tested in the match function does not handle p tag having a class attribute and the match function is returningnull
if no matches are found (doc). Thereforethis.content.match(/<p>/g).length
is throwing an error.Proposed solution Locally we can solve the issue by checking first that
this.content.match(/<p>/g)
is thruthy