This exposes a function sanitizeNode that can be applied to a document (or any node) before adding that document to the EditorState in order to sanitize it: i.e. make sure that two non-contiguous ranges don't have the same id as each other.
This behaviour has also been added to pasted input too through the transformPasted plugin prop, as this is another source of untrusted HTML.
One major change here is the little algorithm for finding inserted ranges. This was breaking paste behaviour both for this PR and there was another bug that would break noting that would occasionally happen when pasting a document back over itself (and potentially other edge cases). The previous version that used diffing wouldn't work when you were pasting something that looked the same as previous version so the ranges would not be correct in this case.
This exposes a function
sanitizeNode
that can be applied to a document (or any node) before adding that document to theEditorState
in order to sanitize it: i.e. make sure that two non-contiguous ranges don't have the same id as each other.This behaviour has also been added to pasted input too through the
transformPasted
plugin prop, as this is another source of untrusted HTML.One major change here is the little algorithm for finding inserted ranges. This was breaking paste behaviour both for this PR and there was another bug that would break noting that would occasionally happen when pasting a document back over itself (and potentially other edge cases). The previous version that used diffing wouldn't work when you were pasting something that looked the same as previous version so the ranges would not be correct in this case.