Releases: springload/draftjs_exporter
Releases · springload/draftjs_exporter
v0.8.1
Fixed
- Fix KeyError when the content state is empty.
v0.8.0
Added
- Add simplified block mapping format:
BLOCK_TYPES.HEADER_TWO: 'h2'
. - Raise exception when
style_map
does not define anelement
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 (ifstyle
is already a string, it will be output as is). - Support components (
render
function returningcreate_element
nodes) instyle_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 returningcreate_element
nodes) inblock_map
, for bothelement
andwrapper
.
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
andwrapper_props
attributes (dictionaries of props). - Moved and renamed
BlockException
toConfigException
. - Replace
style_map
config format to the one of theblock_map
. - Move internal
camel_to_dash
method toDOM
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 tos
tag.UNDERLINE
styles in default style map now map tou
tag.- By default,
code-block
blocks are now rendered inside a combination ofpre
andcode
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
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
v0.6.1
Added
- Automatically convert line breaks to
br
elements.
v0.6.0
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 aTOKEN
entity rendering asNull
inside ahorizontal-rule
block rendering ashr
, we now have aHORIZONTAL_RULE
entitiy rendering asHR
inside anatomic
block rendering asfragment
.
Removed
- Remove custom block type
pullquote