Skip to content

Releases: springload/draftjs_exporter

v0.8.1

06 Apr 02:22
Compare
Choose a tag to compare

Fixed

  • Fix KeyError when the content state is empty.

v0.8.0

03 Apr 22:37
Compare
Choose a tag to compare

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:
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

# 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)

v0.7.0

16 Feb 14:47
Compare
Choose a tag to compare

Added

  • Add support for decorators thanks to @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).

v0.6.2

18 Jan 19:56
Compare
Choose a tag to compare

Added

  • Add profiling tooling thanks to @su27 (#31).
  • Add more common entity types in constants (#34).

Fixed

  • Stop mutating entity data when rendering entities (#36).

v0.6.1

21 Dec 00:26
Compare
Choose a tag to compare

Added

  • Automatically convert line breaks to br elements.

v0.6.0

19 Dec 09:31
Compare
Choose a tag to compare

This release is likely to be a breaking change. It is not released as such because the exporter has not reached 1.0 yet.

Changed

  • Change hr rendering to be done with entities instead of block types. Instead of having a TOKEN entity rendering as Null inside a horizontal-rule block rendering as hr, we now have a HORIZONTAL_RULE entitiy rendering as HR inside an atomic block rendering as fragment.

Removed

  • Remove custom block type pullquote