Skip to content

Releases: springload/draftjs_exporter

v5.0.0

03 Apr 21:58
Compare
Choose a tag to compare

Added

  • Add tentative support for Python 3.11.
  • Add new "string_compat" engine for maximum output stability, with identical output to its first release. To use it, set the engine property to 'engine': DOM.STRING_COMPAT, (#138).

Removed

  • Remove support for Python 3.6.

How to upgrade

Python 3.6 support

Python 3.6 is no longer supported, as it has reached its end of life. For projects needing Python 3.6, please keep using v4.1.2 of the exporter.

v4.1.2

29 Mar 11:33
Compare
Choose a tag to compare

Changed

  • Add tentative support for Python 3.10.
  • Stop using extras_require for development-only dependencies.

v4.1.1

25 Aug 08:27
Compare
Choose a tag to compare

Changed

  • Add support for Python 3.9 (#134).
  • Update html5lib upper bound, now defined as html5lib>=0.999,<2, to ensure compatibility with Python 3.10 (#134).

v4.1.0

05 Jul 23:53
Compare
Choose a tag to compare

Added

v4.0.0

17 May 20:05
be2a7e6
Compare
Choose a tag to compare

This release contains breaking changes. Be sure to check out the "how to upgrade" section below.

Removed

  • Remove support for Python 3.5 (#129)
  • Remove HTML attributes alphabetical sorting of default string engine (#129)
  • Disable single and double quotes escaping outside of attributes for string engine (#129)
  • Stop sorting inline styles alphabetically (#129)

How to upgrade

Python 3.5 support

Do not upgrade to this version if you are using the exporter in Python 3.5. Please keep using v3.0.1 of the exporter.

HTML attributes sorting

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:

def image(props):
    return DOM.create_element('img', {
        'src': props.get('src'),
        'width': props.get('width'),
        'height': props.get('height'),
        'alt': props.get('alt'),
    })

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:

    @staticmethod
    def render_attrs(attr: Attr) -> str:
        attrs = [f' {k}="{escape(v)}"' for k, v in attr.items()]
        attrs.sort()
        return "".join(attrs)

HTML quotes escaping

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:

    @staticmethod
    def render_children(children: Sequence[Union[HTML, Elt]]) -> HTML:
        return "".join(
            [
                DOMString.render(c)
                if isinstance(c, Elt)
                else escape(c, quote=True)
                for c in children
            ]
        )

Inline styles sorting

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.

If you relied on this behavior, either reorder the keys as needed, or pass the style as a string (with CSS properties syntax).

v3.0.1

16 May 20:20
df9340d
Compare
Choose a tag to compare

Added

  • Add Typing :: Typed trove classifier to the package.

Changed

  • Small performance improvements (1.5x faster) for blocks that do not have inline styles, and configurations that only use \n -> <br/> composite decorators. (#127)

v3.0.0

01 Jan 19:39
158771e
Compare
Choose a tag to compare

This release contains breaking changes. Be sure to check out the "how to upgrade" section below.

Changed

  • Remove support for Python 2.7 and 3.4 (#111, #120).
  • Add support for Python 3.8.
  • Small performance improvements by using lists’ mutable .sort() instead of sorted(), which is a bit faster. (±2% faster) (#120).

Added

  • Add PEP-484 type annotations for the project’s public APIs (#101, #123).
  • Add PEP-561 metadata so the exporter’s type annotations can be read by type checkers (#101, #123).
  • Give entity rendering components access to the current block, blocks list, mutability, and key as entity_range.key (#91, #124).

How to upgrade

Python 2.7 and 3.4 support

Do not upgrade to this version if you are using the exporter in Python 2.7 or 3.4. Please keep using v2.1.7 of the exporter.

PEP-484 type annotations

If you are using the exporter in a codebase using type annotations and a type checker, there is a chance the annotations added in this release will create conflicts with your project’s annotations – if there are discrepancies between the expected input/output of the exporter, or in the configuration. In this case you may need to update your project’s type annotations or stubs to match the expected types of the exporter’s public API.

If you believe there is a problem with how the public API is typed, please open a new issue.

v2.1.7

26 Sep 21:17
56b795a
Compare
Choose a tag to compare

Changed

  • Minor performance improvements (10% speed-up, 30% lower memory consumption) by adding Python __slots__ and implementing other optimisations.

v2.1.6

28 May 00:52
4c33bb2
Compare
Choose a tag to compare

Changed

  • Assume same block defaults as Draft.js would when attributes are missing: depth = 0, type = unstyled, no entities, no styles (#110, thanks to @tpict).
  • Minor performance improvements for text-only blocks (#112).

v2.1.5

20 Nov 16:12
1e391a4
Compare
Choose a tag to compare

Changed

  • Minor performance improvements (8% speed-up, 20% lower memory consumption) (#108)

Fixed

  • Fix export bug with adjacent entities - the exporter moved their contents outside of the entities' markup (#106, #107). Thanks to @ericpai for reporting this.