|
4 | 4 |
|
5 | 5 | ## Unreleased |
6 | 6 |
|
| 7 | +## [v4.0.0](https://github.com/springload/draftjs_exporter/releases/tag/v4.0.0) |
| 8 | + |
| 9 | +This release contains breaking changes. **Be sure to check out the "how to upgrade" section below.** |
| 10 | + |
| 11 | +### Removed |
| 12 | + |
| 13 | +- Remove support for Python 3.5 ([#129](https://github.com/springload/draftjs_exporter/pull/129)) |
| 14 | +- Remove HTML attributes alphabetical sorting of default string engine ([#129](https://github.com/springload/draftjs_exporter/pull/129)) |
| 15 | +- Disable single and double quotes escaping outside of attributes for string engine ([#129](https://github.com/springload/draftjs_exporter/pull/129)) |
| 16 | +- Stop sorting inline styles alphabetically ([#129](https://github.com/springload/draftjs_exporter/pull/129)) |
| 17 | + |
| 18 | +### How to upgrade |
| 19 | + |
| 20 | +#### Python 3.5 support |
| 21 | + |
| 22 | +Do not upgrade to this version if you are using the exporter in Python 3.5. Please keep using [v3.0.1](https://github.com/springload/draftjs_exporter/tree/v3.0.1) of the exporter. |
| 23 | + |
| 24 | +#### HTML attributes sorting |
| 25 | + |
| 26 | +The default `string` engine no longer sorts attributes alphabetically by name in its output HTML. This makes it possible to control the order as needed, wherever attributes can be specified: |
| 27 | + |
| 28 | +```python |
| 29 | +def image(props): |
| 30 | + return DOM.create_element('img', { |
| 31 | + 'src': props.get('src'), |
| 32 | + 'width': props.get('width'), |
| 33 | + 'height': props.get('height'), |
| 34 | + 'alt': props.get('alt'), |
| 35 | + }) |
| 36 | +``` |
| 37 | + |
| 38 | +If you relied on this behavior, you can either reorder your `props` / `wrapper_props` / `create_element` calls as needed, or subclass the built-in `string` engine and override its `render_attrs` method to add back the `attrs.sort`: |
| 39 | + |
| 40 | +```python |
| 41 | + @staticmethod |
| 42 | + def render_attrs(attr: Attr) -> str: |
| 43 | + attrs = [f' {k}="{escape(v)}"' for k, v in attr.items()] |
| 44 | + attrs.sort() |
| 45 | + return "".join(attrs) |
| 46 | +``` |
| 47 | + |
| 48 | +### HTML quotes escaping |
| 49 | + |
| 50 | +The default `string` engine no longer escapes single and double quotes in HTML content (it still escapes quotes inside attributes). If you relied on this behavior, subclass the built-in `string` engine and override its `render_children` method to add back `quote=True`: |
| 51 | + |
| 52 | +```python |
| 53 | + @staticmethod |
| 54 | + def render_children(children: Sequence[Union[HTML, Elt]]) -> HTML: |
| 55 | + return "".join( |
| 56 | + [ |
| 57 | + DOMString.render(c) |
| 58 | + if isinstance(c, Elt) |
| 59 | + else escape(c, quote=True) |
| 60 | + for c in children |
| 61 | + ] |
| 62 | + ) |
| 63 | +``` |
| 64 | + |
| 65 | +### Inline styles sorting |
| 66 | + |
| 67 | +The exporter supports passing the `style` attribute as a dictionary with JS attributes for style properties, and will automatically convert it to a string. The properties are no longer sorted alphabetically – it’s now possible to reorder the dictionary’s keys to change the order. |
| 68 | + |
| 69 | +If you relied on this behavior, either reorder the keys as needed, or pass the `style` as a string (with CSS properties syntax). |
| 70 | + |
7 | 71 | ## [v3.0.1](https://github.com/springload/draftjs_exporter/releases/tag/v3.0.1) |
8 | 72 |
|
9 | 73 | ### Added |
|
0 commit comments