({
htmlToStyle = defaultHTMLToStyle,
htmlToEntity = defaultHTMLToEntity,
textToEntity = defaultTextToEntity,
htmlToBlock = defaultHTMLToBlock,
})
| 673 | } |
| 674 | |
| 675 | const convertFromHTML = ({ |
| 676 | htmlToStyle = defaultHTMLToStyle, |
| 677 | htmlToEntity = defaultHTMLToEntity, |
| 678 | textToEntity = defaultTextToEntity, |
| 679 | htmlToBlock = defaultHTMLToBlock, |
| 680 | }) => ( |
| 681 | html, |
| 682 | options = { |
| 683 | flat: false, |
| 684 | }, |
| 685 | DOMBuilder = getSafeBodyFromHTML, |
| 686 | generateKey = genKey |
| 687 | ) => { |
| 688 | let contentState = ContentState.createFromText(''); |
| 689 | const createEntityWithContentState = (...args) => { |
| 690 | if (contentState.createEntity) { |
| 691 | contentState = contentState.createEntity(...args); |
| 692 | return contentState.getLastCreatedEntityKey(); |
| 693 | } |
| 694 | |
| 695 | return Entity.create(...args); |
| 696 | }; |
| 697 | |
| 698 | const getEntityWithContentState = (...args) => { |
| 699 | if (contentState.getEntity) { |
| 700 | return contentState.getEntity(...args); |
| 701 | } |
| 702 | |
| 703 | return Entity.get(...args); |
| 704 | }; |
| 705 | |
| 706 | const mergeEntityDataWithContentState = (...args) => { |
| 707 | if (contentState.mergeEntityData) { |
| 708 | contentState = contentState.mergeEntityData(...args); |
| 709 | return; |
| 710 | } |
| 711 | |
| 712 | Entity.mergeData(...args); |
| 713 | }; |
| 714 | |
| 715 | const replaceEntityDataWithContentState = (...args) => { |
| 716 | if (contentState.replaceEntityData) { |
| 717 | contentState = contentState.replaceEntityData(...args); |
| 718 | return; |
| 719 | } |
| 720 | |
| 721 | Entity.replaceData(...args); |
| 722 | }; |
| 723 | |
| 724 | const contentBlocks = convertFromHTMLtoContentBlocks( |
| 725 | html, |
| 726 | handleMiddleware(htmlToStyle, baseProcessInlineTag), |
| 727 | handleMiddleware(htmlToEntity, defaultHTMLToEntity), |
| 728 | handleMiddleware(textToEntity, defaultTextToEntity), |
| 729 | handleMiddleware(htmlToBlock, baseCheckBlockType), |
| 730 | createEntityWithContentState, |
| 731 | getEntityWithContentState, |
| 732 | mergeEntityDataWithContentState, |
no test coverage detected
searching dependent graphs…