Releases: springload/draftjs_exporter
Releases · springload/draftjs_exporter
v0.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
Noneinrender. - Add support for
lxmlas a DOM backing engine, withpip 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']toprops['block']['type']. - Move
ConfigExceptiontodraftjs_exporter.error.
Removed
- Remove
DOM.get_childrenmethod. - Remove
DOM.pretty_printmethod. - Remove automatic conversion from
classNameprop toclass.
Fixed
- Stop rendering decorators when there is no text to decorate.
- Remove extra HTML serialisation steps.
How to upgrade
# 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'}]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_mapdoes not define anelementfor the style. - Add support for any props on
style_map. - Automatically convert
styleprop from a dict of camelCase properties to a string, on all elements (ifstyleis already a string, it will be output as is). - Support components (
renderfunction returningcreate_elementnodes) 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
preblock type. - Support components (
renderfunction returningcreate_elementnodes) inblock_map, for bothelementandwrapper.
Removed
- Remove array-style block element and wrapper declarations (
['ul'],['ul', {'class': 'bullet-list'}]). - Remove
DOM.create_text_nodemethod.
Changed
- Replace array-style mapping declarations of block element and wrapper props with
propsandwrapper_propsattributes (dictionaries of props). - Moved and renamed
BlockExceptiontoConfigException. - Replace
style_mapconfig format to the one of theblock_map. - Move internal
camel_to_dashmethod toDOMfor official use. - Change ordering of inline styles - now using alphabetical ordering of style key instead of tag name.
STRIKETHROUGHstyles in default style map now map tostag.UNDERLINEstyles in default style map now map toutag.- By default,
code-blockblocks are now rendered inside a combination ofpreandcodetags. - For entities, directly pass
datadict 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.
*ngForwill 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
brelements.
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
hrrendering to be done with entities instead of block types. Instead of having aTOKENentity rendering asNullinside ahorizontal-ruleblock rendering ashr, we now have aHORIZONTAL_RULEentitiy rendering asHRinside anatomicblock rendering asfragment.
Removed
- Remove custom block type
pullquote