diff --git a/types/html-to-draftjs/html-to-draftjs-tests.ts b/types/html-to-draftjs/html-to-draftjs-tests.ts new file mode 100644 index 0000000000..967869b194 --- /dev/null +++ b/types/html-to-draftjs/html-to-draftjs-tests.ts @@ -0,0 +1,9 @@ +import htmlToDraft from 'html-to-draftjs'; +import { ContentBlock } from 'draft-js'; + +const blocksFromHtml = htmlToDraft('

test

'); + +// $ExpectType ContentBlock[] +const contentBlocks = blocksFromHtml.contentBlocks; +// $ExpectType any +const entityMap = blocksFromHtml.entityMap; diff --git a/types/html-to-draftjs/index.d.ts b/types/html-to-draftjs/index.d.ts new file mode 100644 index 0000000000..d6b176386a --- /dev/null +++ b/types/html-to-draftjs/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for html-to-draftjs 1.4 +// Project: https://github.com/jpuri/html-to-draftjs#readme +// Definitions by: Ivan Zverev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +import { ContentBlock, RawDraftEntity } from 'draft-js'; + +export default function htmlToDraft( + text: string, + customChunkRenderer?: ( + nodeName: string, node: HTMLElement + ) => RawDraftEntity | undefined, +): { + contentBlocks: ContentBlock[]; + entityMap?: any; +}; diff --git a/types/html-to-draftjs/tsconfig.json b/types/html-to-draftjs/tsconfig.json new file mode 100644 index 0000000000..53adaa3aa3 --- /dev/null +++ b/types/html-to-draftjs/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "html-to-draftjs-tests.ts" + ] +} diff --git a/types/html-to-draftjs/tslint.json b/types/html-to-draftjs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/html-to-draftjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }