Skip to content

Commit

Permalink
Update TypeScript definitions (#122)
Browse files Browse the repository at this point in the history
* Update TypeScript definitions

* Add typings tests
  • Loading branch information
Santiago V authored and sstur committed Dec 21, 2018
1 parent fe6eb98 commit 4e2f620
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ res = stateToHTML(state, {
},
},
});
res = stateToHTML(state, {
defaultBlockTag: 'div',
});
res = stateToHTML(state, {
entityStyleFn: (entity) => {
if (entity.getType() === 'FOO') {
return {
element: 'div',
style: { color: 'red' }
};
}
}
})
5 changes: 3 additions & 2 deletions packages/draft-js-export-html/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
declare module 'draft-js-export-html' {
import draftjs = require("draft-js");

type BlockStyleFn = (block: draftjs.ContentBlock) => RenderConfig;
type EntityStyleFn = (entity: draftjs.EntityInstance) => RenderConfig;
type BlockStyleFn = (block: draftjs.ContentBlock) => RenderConfig|undefined;
type EntityStyleFn = (entity: draftjs.EntityInstance) => RenderConfig|undefined;
type BlockRenderer = (block: draftjs.ContentBlock) => string;
type RenderConfig = {
element?: string;
Expand All @@ -13,6 +13,7 @@ declare module 'draft-js-export-html' {
};

export interface Options {
defaultBlockTag?: string;
inlineStyles?: { [styleName: string]: RenderConfig };
blockRenderers?: { [blockType: string]: BlockRenderer };
blockStyleFn?: BlockStyleFn;
Expand Down

0 comments on commit 4e2f620

Please sign in to comment.