This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DefaultParse = HtmlSerializer.parseHtml; | |
HtmlSerializer.parseHtml = html => { | |
const tree = DefaultParse.apply(HtmlSerializer, [html]); | |
const collapse = require('collapse-whitespace'); | |
collapse(tree); | |
// ensure that no DIVs contain both element children and text node children. This is | |
// not allowed by Slate's core schema: blocks must contain inlines and text OR blocks. | |
// https://docs.slatejs.org/guides/data-model#documents-and-nodes | |
const treeWalker = document.createTreeWalker(tree, NodeFilter.SHOW_ELEMENT, { |