Skip to content

Commit be2a7e6

Browse files
authored
Release v4.0.0 (#131)
1 parent e3015cf commit be2a7e6

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

CHANGELOG.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,70 @@
44
55
## Unreleased
66

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+
771
## [v3.0.1](https://github.com/springload/draftjs_exporter/releases/tag/v3.0.1)
872

973
### Added

draftjs_exporter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = "draftjs_exporter"
2-
__version__ = "3.0.1"
2+
__version__ = "4.0.0"
33
__author__ = "Springload"
44
__license__ = "MIT"
55
__copyright__ = "Copyright 2016-present Springload"

0 commit comments

Comments
 (0)