def __init__(self, config: Optional[Config] = None) -> None: if config is None: config = {} self.composite_decorators = config.get("composite_decorators", []) self.entity_options = Options.map_entities( config.get("entity_decorators", {})) self.block_options = Options.map_blocks( config.get("block_map", BLOCK_MAP)) self.style_options = Options.map_styles( config.get("style_map", STYLE_MAP)) DOM.use(config.get("engine", DOM.STRING))
def __init__(self, config=None): if config is None: config = {} self.composite_decorators = config.get('composite_decorators', []) self.has_decorators = len(self.composite_decorators) > 0 self.entity_options = Options.map_entities( config.get('entity_decorators', {})) self.block_options = Options.map_blocks( config.get('block_map', BLOCK_MAP)) self.style_options = Options.map_styles( config.get('style_map', STYLE_MAP)) DOM.use(config.get('engine', DOM.STRING))
def setUp(self): DOM.use(DOM.STRING) self.wrapper_state = WrapperState( Options.map_blocks({ 'header-one': 'h1', 'unstyled': 'div', 'atomic': lambda props: props['children'], 'ignore': None, 'blockquote': blockquote, 'ordered-list-item': { 'element': list_item, 'wrapper': ordered_list }, }), [])
def test_element_for_data(self): blocks = [ { 'key': '5s7g9', 'text': 'test', 'type': 'unstyled', 'depth': 0, 'inlineStyleRanges': [], 'entityRanges': [], }, ] def unstyled(props): self.assertEqual(props['blocks'], blocks) self.assertEqual(props['block'], blocks[0]) WrapperState(Options.map_blocks({'unstyled': unstyled}), blocks).element_for(blocks[0], 'test')
def setUp(self): DOM.use(DOM.STRING) self.wrapper_state = WrapperState( Options.map_blocks( { "header-one": "h1", "unstyled": "div", "atomic": lambda props: props["children"], "ignore": None, "blockquote": blockquote, "ordered-list-item": { "element": list_item, "wrapper": ordered_list, }, } ), [], )
def test_element_for_data(self): blocks = [ { "key": "5s7g9", "text": "test", "type": "unstyled", "depth": 0, "inlineStyleRanges": [], "entityRanges": [], } ] def unstyled(props): self.assertEqual(props["blocks"], blocks) self.assertEqual(props["block"], blocks[0]) WrapperState( Options.map_blocks({"unstyled": unstyled}), blocks ).element_for(blocks[0], "test")