JiHong88 / suneditor

Pure javascript based WYSIWYG html editor, with no dependencies.
http://suneditor.com
MIT License
1.77k stars 316 forks source link

fix(_cleanStyle): fix for when window.getComputedStyle(context.element.wysiwyg) does not contain style tag #1422

Closed KonstantinosAng closed 4 months ago

KonstantinosAng commented 4 months ago

fix for when window.getComputedStyle(context.element.wysiwyg) does not contain style tag

I have a .docx file that contains an element with a style tag mso-element that does not exist in the getComputedStyle resulting in this.wwComputedStyle[k] being undefined and calling replace on it breaks the editor content. My users were saving a react-hook-form and the editor contents were always empty.

I have attached the word document that breaks the editor. Try to Ctr + A and Ctrl + C, paste the contents in the editor and see the console.

v2.46.4

KonstantinosAng commented 4 months ago

@JiHong88 it doesn't let me add a reviewer so I thought I could tag you here