springload / draftjs_exporter

Convert Draft.js ContentState to HTML
https://www.draftail.org/blog/2018/03/13/rethinking-rich-text-pipelines-with-draft-js
MIT License
83 stars 21 forks source link

Add new "string_compat" engine for maximum output stability #138

Closed thibaudcolas closed 2 years ago

thibaudcolas commented 2 years ago

This introduces a new string_compat / draftjs_exporter.engines.string_compat.DOMStringCompat engine, which is a copy of the existing string engine with two changes added for backwards compatibility:

Both of those changes were introduced in v4.0.0, I think they make complete sense for projects using the exporter since, but they do change the output. It’s important for the output to be as stable as possible in a lot of scenarios, so I made sure to document how to preserve the output back then.

Rethinking this a bit, I think it makes a lot of sense to actually have built-in support for this, so people for whom output stability is more important than speed have this kind of guarantee. It’s also nicer to maintain as a copy of the code in the same branch rather than backporting speedups to older versions indefinitely.

I had also considered adding those exact options to the string engine directly, but decided no to in the end – if there are more such compatibility changes needed in the future, I think it would be nicer for the two engines to be able to diverge as much as possible, rather than have the same code paths with different configuration.