Draftjs-exporter

Latest version: v5.0.0

Safety actively analyzes 629811 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 6

1.0.0

> This release is functionally identical to the previous one, `v0.9.0`.

The project has reached a high-enough level of stability to be used in production, and breaking changes will now be reflected via major version changes.

0.9.0

Added

- Add configuration options to determine handling of missing blocks 52.
- Add configuration options to determine handling of missing styles.
- Add configuration options to determine handling of missing entities.
- Block components now have access to the block type via `props['block']['type']`.
- Entity components now have access to the entity type via `props['entity']['type']`.
- Composite decorators now have access to the current block depth and data via `props['block']['depth']`, `props['block']['data']`.
- Allow discarding component children by returning `None` in `render`.
- Add support for `lxml` as a DOM backing engine, with `pip install draftjs_exporter[lxml]` pip extra.
- Add support for custom DOM backing engines.
- Add support for None content state in HTML.render 67.

Changed

- For composite decorators, the block type has moved from `props['block_type']` to `props['block']['type']`.
- Move `ConfigException` to `draftjs_exporter.error`.

Removed

- Remove `DOM.get_children` method.
- Remove `DOM.pretty_print` method.
- Remove automatic conversion from `className` prop to `class`.

Fixed

- Stop rendering decorators when there is no text to decorate.
- Remove extra HTML serialisation steps.

How to upgrade

diff
Change composite decorators block type access
- props['block_type']
+ props['block']['type']
Stop using DOM.get_children directly.
- DOM.get_children()
Stop using DOM.pretty_print directly.
- DOM.pretty_print()
Move `ConfigException` to `draftjs_exporter.error`.
- from draftjs_exporter.options import ConfigException
+ from draftjs_exporter.error import ConfigException
Remove automatic conversion from `className` prop to `class` attribute.
- BLOCK_TYPES.BLOCKQUOTE: ['blockquote', {'className': 'c-pullquote'}]
+ BLOCK_TYPES.BLOCKQUOTE: ['blockquote', {'class': 'c-pullquote'}]

0.8.1

Fixed

- Fix KeyError when the content state is empty.

0.8.0

Added

- Add simplified block mapping format: `BLOCK_TYPES.HEADER_TWO: 'h2'`.
- Raise exception when `style_map` does not define an `element` for the style.
- Add support for any props on `style_map`.
- Automatically convert `style` prop from a dict of camelCase properties to a string, on all elements (if `style` is already a string, it will be output as is).
- Support components (`render` function returning `create_element` nodes) in `style_map`.
- Add more defaults in the style map:

python
BOLD = 'strong'
CODE = 'code'
ITALIC = 'em'
UNDERLINE = 'u'
STRIKETHROUGH = 's'
SUPERSCRIPT = 'sup'
SUBSCRIPT = 'sub'
MARK = 'mark'
QUOTATION = 'q'
SMALL = 'small'
SAMPLE = 'samp'
INSERT = 'ins'
DELETE = 'del'
KEYBOARD = 'kbd'


- Add new `pre` block type.
- Support components (`render` function returning `create_element` nodes) in `block_map`, for both `element` and `wrapper`.

Removed

- Remove array-style block element and wrapper declarations (`['ul']`, `['ul', {'class': 'bullet-list'}]`).
- Remove `DOM.create_text_node` method.

Changed

- Replace array-style mapping declarations of block element and wrapper props with `props` and `wrapper_props` attributes (dictionaries of props).
- Moved and renamed `BlockException` to `ConfigException`.
- Replace `style_map` config format to the one of the `block_map`.
- Move internal `camel_to_dash` method to `DOM` for official use.
- Change ordering of inline styles - now using alphabetical ordering of style key instead of tag name.
- `STRIKETHROUGH` styles in default style map now map to `s` tag.
- `UNDERLINE` styles in default style map now map to `u` tag.
- By default, `code-block` blocks are now rendered inside a combination of `pre` and `code` tags.
- For entities, directly pass `data` dict as props instead of whole entity map declaration.

Fixed

- Fix block ordering with block components and wrapper. Fix 55.

How to upgrade

diff
Change element-only block declarations:
- BLOCK_TYPES.HEADER_TWO: {'element': 'h2'},
+ BLOCK_TYPES.HEADER_TWO: 'h2',
Change array-style block declarations:
- BLOCK_TYPES.BLOCKQUOTE: ['blockquote', {'class': 'c-pullquote'}]
+ BLOCK_TYPES.BLOCKQUOTE: {'element': 'blockquote', 'props': {'class': 'c-pullquote'}}
Change block wrapper declarations:
- 'wrapper': ['ul', {'class': 'bullet-list'}],
+ 'wrapper': 'ul',
+ 'wrapper_props': {'class': 'bullet-list'},
Change location and name of exceptions:
- from draftjs_exporter.wrapper_state import BlockException
+ from draftjs_exporter.options import ConfigException
Change element-only style declarations:
- 'KBD': {'element': 'kbd'},
+ 'KBD': 'kbd',
Change object-style style declarations:
- 'HIGHLIGHT': {'element': 'strong', 'textDecoration': 'underline'},
+ 'HIGHLIGHT': {'element': 'strong', 'props': {'style': {'textDecoration': 'underline'}}},
Create custom STRIKETHROUGH styles:
+ 'STRIKETHROUGH': {'element': 'span', 'props': {'style': {'textDecoration': 'line-through'}}},
Create custom UNDERLINE styles:
+ 'UNDERLINE': {'element': 'span', 'props': {'style': {'textDecoration': 'underline'}}},
New camel_to_dash location:
- from draftjs_exporter.style_state import camel_to_dash
- camel_to_dash()
+ from draftjs_exporter.dom import DOM
+ DOM.camel_to_dash()
New default rendering for code-block:
- BLOCK_TYPES.CODE: 'pre',
+ BLOCK_TYPES.CODE: lambda props: DOM.create_element('pre', {}, DOM.create_element('code', {}, props['children'])),
Use the new pre block to produce the previous result, or override the default for code-block.
+ BLOCK_TYPES.PRE: 'pre',
Entities now receive the content of `data` directly, instead of the whole entity:
def render(self, props):
- data = props.get('data', {})
link_props = {
- 'href': data['url'],
+ 'href': props['url'],
}
Remove wrapping around text items.
- DOM.create_text_node(text)
+ text
Remove fragment calls.
- DOM.create_document_fragment()
+ DOM.create_element()
Remove text getters and setters. This is not supported anymore.
- DOM.get_text_content(elt)
- DOM.set_text_content(elt, text)

0.7.0

Added

- Add support for decorators thanks to [su27](https://github.com/su27) (#16, 17).
- Add support for configurable decorators and entities.
- Add support for decorators and entities in function form.

Changed

- Stop lowercasing HTML attributes. `*ngFor` will now be exported as `*ngFor`.

Removed

- Drop Python 3.3 support (likely still runs fine, but tests are not ran on it).

0.6.2

Added

- Add profiling tooling thanks to [su27](https://github.com/su27) (#31).
- Add more common entity types in constants (34).

Fixed

- Stop mutating entity data when rendering entities (36).

Page 4 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.