jodit / jodit-react

React wrapper for Jodit
MIT License
358 stars 120 forks source link

Switching to source mode changes editor value #56

Open miestr opened 4 years ago

miestr commented 4 years ago

When switching to source mode (the first time), the value of the editor is changed:

  1. The html tag surrounding the content is stripped
  2. Some new line characters (\n) are added

Whereas the first issue is a disaster, because html wrapper contains information relevant for backend. The second issues is also nasty, but is fixable.

How to reproduce: init JoditEditor with value f.e. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"><head><style>body{font-family:"Verlag Office",Verdana,Sans-serif; font-size: 14px;}</style></head> <body> <h2>hello</h2>/body></html> Switch to source mode, console.log the value of the editor. Result: tag is removed.

miestr commented 4 years ago

Update: the value is broken on initialisation of the JoditEditor component. The following line of JoditEditor.js:267 sets the value: textArea.current.value = value; The value provided still contains the html tag, but the textArea.current.value not any more