Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/draft-js-export-html/src/stateToHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type StyleMap = {[styleName: string]: RenderConfig};
type BlockStyleFn = (block: ContentBlock) => ?RenderConfig;
type EntityStyleFn = (entity: Entity) => ?RenderConfig;
type InlineStyleFn = (style: DraftInlineStyle) => ?RenderConfig;
type RenderBlockContentFn = (block: ContentBlock) => string;

type Options = {
inlineStyles?: StyleMap;
Expand All @@ -46,6 +47,7 @@ type Options = {
blockStyleFn?: BlockStyleFn;
entityStyleFn?: EntityStyleFn;
defaultBlockTag?: ?string;
renderBlockContentFn?: RenderBlockContentFn;
};

const {BOLD, CODE, ITALIC, STRIKETHROUGH, UNDERLINE} = INLINE_STYLE;
Expand Down Expand Up @@ -215,7 +217,7 @@ class MarkupGenerator {
}

processBlock() {
let {blockRenderers, defaultBlockTag} = this.options;
let {blockRenderers, defaultBlockTag, renderBlockContentFn} = this.options;
let block = this.blocks[this.currentBlock];
let blockType = block.getType();
let newWrapperTag = getWrapperTag(blockType);
Expand All @@ -242,7 +244,12 @@ class MarkupGenerator {
return;
}
this.writeStartTag(block, defaultBlockTag);
this.output.push(this.renderBlockContent(block));
let customRenderBlockContentOutput = renderBlockContentFn ? renderBlockContentFn(block) : null;
if (customRenderBlockContentOutput != null) {
this.output.push(customRenderBlockContentOutput);
} else {
this.output.push(this.renderBlockContent(block));
}
// Look ahead and see if we will nest list.
let nextBlock = this.getNextBlock();
if (
Expand Down