33import os
44import re
55from pstats import Stats
6+ from typing import cast
67
78import memray
89from markov_draftjs import get_content_sample
910
1011from draftjs_exporter .constants import BLOCK_TYPES , ENTITY_TYPES
1112from draftjs_exporter .defaults import BLOCK_MAP , STYLE_MAP
1213from draftjs_exporter .dom import DOM
13- from draftjs_exporter .html import HTML
14- from draftjs_exporter .types import Element , Props
14+ from draftjs_exporter .html import HTML , ExporterConfig
15+ from draftjs_exporter .types import ContentState , Element , Props
1516from example import br , entity_fallback , image , list_item , ordered_list
1617
1718
@@ -34,27 +35,25 @@ def block_fallback(props: Props) -> Element:
3435 return DOM .create_element ("div" , {}, props ["children" ])
3536
3637
37- config = {
38- "block_map" : dict (
39- BLOCK_MAP ,
40- ** {
41- BLOCK_TYPES .HEADER_TWO : "h2" ,
42- BLOCK_TYPES .HEADER_THREE : {
43- "element" : "h3" ,
44- "props" : {"class" : "u-text-center" },
45- },
46- BLOCK_TYPES .UNORDERED_LIST_ITEM : {
47- "element" : "li" ,
48- "wrapper" : "ul" ,
49- "wrapper_props" : {"class" : "bullet-list" },
50- },
51- BLOCK_TYPES .ORDERED_LIST_ITEM : {
52- "element" : list_item ,
53- "wrapper" : ordered_list ,
54- },
55- BLOCK_TYPES .FALLBACK : block_fallback ,
38+ config : ExporterConfig = {
39+ "block_map" : {
40+ ** BLOCK_MAP ,
41+ BLOCK_TYPES .HEADER_TWO : "h2" ,
42+ BLOCK_TYPES .HEADER_THREE : {
43+ "element" : "h3" ,
44+ "props" : {"class" : "u-text-center" },
5645 },
57- ),
46+ BLOCK_TYPES .UNORDERED_LIST_ITEM : {
47+ "element" : "li" ,
48+ "wrapper" : "ul" ,
49+ "wrapper_props" : {"class" : "bullet-list" },
50+ },
51+ BLOCK_TYPES .ORDERED_LIST_ITEM : {
52+ "element" : list_item ,
53+ "wrapper" : ordered_list ,
54+ },
55+ BLOCK_TYPES .FALLBACK : block_fallback ,
56+ },
5857 "style_map" : STYLE_MAP ,
5958 "entity_decorators" : {
6059 ENTITY_TYPES .IMAGE : image ,
@@ -70,7 +69,8 @@ def block_fallback(props: Props) -> Element:
7069
7170exporter = HTML (config )
7271
73- content_states = get_content_sample ()
72+ # markov_draftjs has slightly different type declarations.
73+ content_states = cast (list [ContentState ], get_content_sample ())
7474
7575BENCHMARK_RUNS = int (os .environ .get ("BENCHMARK_RUNS" , 1 ))
7676
0 commit comments