Open matsjoyce opened 3 years ago
Thanks for reporting this. I think this is a good start, but it would also require logic changes on the Elm side as well. Currently, if characterDataMutations are passed to Elm, the elm logic will skip validation. This could cause the vdom to crash in some cases if the browser removed a node but the validation didn't catch it. Perhaps we could experiment with first applying the character data mutations, then doing the validation if there are other mutations; maybe with 2 different events or with an extra parameter on the current editorchange event.
For the time being, I have fixed this be performing a String.replace "\n" ""
on the initial HTML, since newlines aren't currently significant. However, that workaround won't work if code blocks are in use, since newlines inside pre
are significant.
If you have a document like (
span
is just a mark):Backspace doesn't work on Chrome. This is because the backspace deletes the last
h
, and then turns the\n
into a<br>
which causes https://github.com/mweiss/elm-rte-toolkit/blob/master/js/elmEditor.js#L327 to reject the event and rerender, since themutationsList
includes achildList
mutation:Is there anything wrong with changing
characterDataMutations
to:Or does something more specific need to be done? I haven't noticed any issues, but my testing has not been particularly thorough.