add a new getHtmlFromFragment method that is used in the editor and in the stand-alone generateHtml helper

This commit is contained in:
Hans Pagel
2020-09-04 13:06:54 +02:00
parent 95fca8aa61
commit 8cee629e19
4 changed files with 23 additions and 29 deletions

View File

@@ -10,6 +10,7 @@ import getNodeAttrs from './utils/getNodeAttrs'
import getMarkAttrs from './utils/getMarkAttrs'
import removeElement from './utils/removeElement'
import getSchemaTypeByName from './utils/getSchemaTypeByName'
import getHtmlFromFragment from './utils/getHtmlFromFragment'
import ExtensionManager from './ExtensionManager'
import Extension from './Extension'
import Node from './Node'
@@ -357,14 +358,7 @@ export class Editor extends EventEmitter {
* Get the document as HTML.
*/
public html() {
const div = document.createElement('div')
const fragment = DOMSerializer
.fromSchema(this.schema)
.serializeFragment(this.state.doc.content)
div.appendChild(fragment)
return div.innerHTML
return getHtmlFromFragment(this.state.doc, this.schema)
}
/**