Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

draft-convert

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draft-convert - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

13

dist/draft-convert.js

@@ -1186,3 +1186,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
// Be ABSOLUTELY SURE that the dom builder you pass hare won't execute

@@ -1192,3 +1192,3 @@ // arbitrary code in whatever environment you're running this in. For an

var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder);
var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey);
if (chunk == null) {

@@ -1214,3 +1214,3 @@ return [];

return new _draftJs.ContentBlock({
key: (0, _draftJs.genKey)(),
key: generateKey(),
type: nullthrows(chunk).blocks[blockIndex].type,

@@ -1239,2 +1239,3 @@ data: nullthrows(chunk).blocks[blockIndex].data,

var DOMBuilder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _parseHTML2.default;
var generateKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _draftJs.genKey;

@@ -1285,3 +1286,3 @@ var contentState = _draftJs.ContentState.createFromText('');

var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder);
var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder, generateKey);

@@ -1359,4 +1360,2 @@ var blockMap = _draftJs.BlockMapBuilder.createFromArray(contentBlocks);

// import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
var NESTED_BLOCK_TYPES = ['ordered-list-item', 'unordered-list-item'];
var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {

@@ -1395,3 +1394,3 @@ return originalText;

if (NESTED_BLOCK_TYPES.indexOf(type) === -1) {
if (!getBlockHTML(block).nest) {
// this block can't be nested, so reset all nesting if necessary

@@ -1398,0 +1397,0 @@ closeNestTags = listStack.reduceRight(function (string, nestedBlock) {

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOMServer"),require("Draft"),require("Immutable")):"function"==typeof define&&define.amd?define(["React","ReactDOMServer","Draft","Immutable"],t):"object"==typeof exports?exports.DraftConvert=t(require("React"),require("ReactDOMServer"),require("Draft"),require("Immutable")):e.DraftConvert=t(e.React,e.ReactDOMServer,e.Draft,e.Immutable)}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var l=n[r]={exports:{},id:r,loaded:!1};return e[r].call(l.exports,l,l.exports,t),l.loaded=!0,l.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.parseHTML=t.convertFromHTML=t.convertToHTML=void 0;var l=n(14),o=r(l),u=n(13),i=r(u),a=n(8),f=r(a);t.convertToHTML=o.default,t.convertFromHTML=i.default,t.parseHTML=f.default},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=function(e,t,n,r,l,o,u,i){if(!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[n,r,l,o,u,i],c=0;a=new Error(t.replace(/%s/g,function(){return f[c++]})),a.name="Invariant Violation"}throw a.framesToPop=1,a}};e.exports=r},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return e.offset===t.offset?t.length-e.length:e.offset-t.offset}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(d.indexOf(e.type)!==-1)return c.default.renderToStaticMarkup(e);var t=c.default.renderToStaticMarkup(a.default.cloneElement(e,{},"\r")).split("\r");return(0,u.default)(t.length>1,"convertToHTML: Element of type "+e.type+" must render children"),(0,u.default)(t.length<3,"convertToHTML: Element of type "+e.type+" cannot use carriage return character"),{start:t[0],end:t[1]}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var o=n(2),u=r(o),i=n(1),a=r(i),f=n(5),c=r(f),d=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]},function(e,n){e.exports=t},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(){var n=e.apply(void 0,arguments);return void 0!==n&&null!==n?n:t.apply(void 0,arguments)}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){return c.default.isValidElement(e)&&c.default.Children.count(e.props.children)>0}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(void 0===e||null===e)return e;if("string"==typeof e)return e;if(c.default.isValidElement(e)){if(l(e))return s.default.renderToStaticMarkup(e);var n=(0,y.default)(e);if(null!==t&&"object"===("undefined"==typeof n?"undefined":u(n))){var r=n.start,o=n.end;return r+t+o}return n}if((0,a.default)(Object.prototype.hasOwnProperty.call(e,"start")&&Object.prototype.hasOwnProperty.call(e,"end"),"convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags"),null!==t){var i=e.start,f=e.end;return i+t+f}return e}Object.defineProperty(t,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=o;var i=n(2),a=r(i),f=n(1),c=r(f),d=n(5),s=r(d),p=n(4),y=r(p)},function(e,t){"use strict";function n(e){var t=void 0;if("undefined"!=typeof DOMParser){var n=new DOMParser;t=n.parseFromString(e,"text/html"),null!==t&&null!==t.body||(t=r(e))}else t=r(e);return t.body}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var r=function(e){var t=document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,t}},function(e,t){"use strict";function n(e,t,n,r,l,o){var u=r-n,i=t+n<=e.offset;if(i)return Object.assign({},e,{offset:e.offset+u});var a=t>=e.offset&&t+n<=e.offset+e.length;if(a)return Object.assign({},e,{length:e.length+u});var f=e.offset>=t&&e.offset+e.length<=t+n&&l>0;if(f)return Object.assign({},e,{offset:e.offset+l});var c=e.offset<t&&e.offset+e.length<=t+n&&e.offset+e.length>t&&l>0;if(c)return[Object.assign({},e,{length:t-e.offset}),Object.assign({},e,{offset:t+l,length:e.offset-t+e.length})];var d=e.offset>=t&&e.offset+e.length>t+n&&t+n>e.offset&&o>0;return d?[Object.assign({},e,{offset:e.offset+l,length:t+n-e.offset}),Object.assign({},e,{offset:t+n+l+o,length:e.offset+e.length-(t+n)})]:e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t){e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=n(9),u=r(o),i=n(3),a=r(i),f=n(7),c=r(f),d=n(20),s=r(d),p=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments[1]);return e};t.default=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p,r=[].concat(l(e.text)),o=n;if(n.__isMiddleware&&(o=n(p)),Object.prototype.hasOwnProperty.call(e,"entityRanges")&&e.entityRanges.length>0){for(var i=e.entityRanges.sort(a.default),f=e.inlineStyleRanges,d=function(e){var n=i[e],a=t[n.key],d=r.slice(n.offset,n.offset+n.length).join(""),p=o(a,d),y=[].concat(l((0,c.default)(p,d)||d)),v=(0,s.default)(p,"start"),h=(0,s.default)(p,"end"),m=function(t,r){return r>e||Object.prototype.hasOwnProperty.call(t,"style")?(0,u.default)(t,n.offset,n.length,y.length,v,h):t},g=function(e){return e.reduce(function(e,t,n){var r=m(t,n);return Array.isArray(r)?e.concat(r):e.concat([r])},[])};i=g(i),f=g(f),r=[].concat(l(r.slice(0,n.offset)),l(y),l(r.slice(n.offset+n.length)))},y=0;y<i.length;y++)d(y);return Object.assign({},e,{text:r.join(""),inlineStyleRanges:f,entityRanges:i})}return e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),u=r(o),i=n(22),a=r(i),f=n(6),c=r(f),d=n(7),s=r(d),p=n(3),y=r(p),v=n(16),h=r(v),m=function(e,t){return e.filter(function(e){return!t.some(function(t){return t.style===e.style})})},g=function(e,t){return t.reduceRight(function(e,t){var n=e[e.length-1];return(0,u.default)(n.style===t.style,"Style "+n.style+" to be removed doesn't match expected "+t.style),e.slice(0,-1)},e)},b=function(e,t){return t.filter(function(t){return e>=t.offset&&e<t.offset+t.length})},M=function(e,t){var n=e.offset<=t.offset,r=e.offset+e.length>=t.offset+t.length;return n&&r},E=function(e,t){var n=t.offset+t.length,r=e.offset+e.length;return n-r},x=function(e,t){for(var n=0;n<e.length;){if(!t.every(M.bind(null,e[n])))return e.slice(n);n++}return[]},O=function(e,t,n){return t+(0,s.default)(e(n.style)).start},_=function(e,t,n){return(0,s.default)(e(n.style)).end+t},T=function(e){return function(t){return e(t)}};T.__isMiddleware=!0,t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T;(0,u.default)(null!==e&&void 0!==e,"Expected raw block to be non-null");var n=void 0;n=t.__isMiddleware===!0?t(h.default):(0,c.default)((0,a.default)(t),(0,a.default)(h.default));for(var r="",o=[],i=e.inlineStyleRanges.sort(y.default),f=[].concat(l(e.text)),d=0;d<f.length;d++){var p=b(d,i),v=m(o,p),M=m(p,o),j=m(o,v),w=x(j,M),S=w.concat(M).sort(E),k=S.reduce(O.bind(null,n),""),R=v.concat(w).reduce(_.bind(null,n),"");r+=R+k+f[d],o=g(o,w.concat(v)),o=o.concat(S),(0,u.default)(o.length===p.length,"Character "+d+": "+(o.length-p.length)+" styles left on stack that should no longer be there")}return r=o.reduceRight(function(e,t){return e+(0,s.default)(n(t.style)).end},r)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(){return{text:"",inlines:[],entities:[],blocks:[]}}function o(e){var t=new Array(1);return e&&(t[0]=e),{text:T,inlines:[(0,g.OrderedSet)()],entities:t,blocks:[]}}function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,g.Map)();return n===!0?{text:"\r",inlines:[(0,g.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:r,depth:Math.max(0,Math.min(j,t))}],isNewline:!0}:{text:"\n",inlines:[(0,g.OrderedSet)()],entities:new Array(1),blocks:[]}}function i(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,g.Map)();return{text:"\r",inlines:[(0,g.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:n,depth:Math.max(0,Math.min(j,t))}]}}function a(e,t){switch(e){case"h1":return"header-one";case"h2":return"header-two";case"h3":return"header-three";case"h4":return"header-four";case"h5":return"header-five";case"h6":return"header-six";case"li":return"ol"===t?"ordered-list-item":"unordered-list-item";case"blockquote":return"blockquote";case"pre":return"code-block";case"div":case"p":return"unstyled";default:return null}}function f(e,t,n){return a(e,n)}function c(e,t,n){var r=P[e];return r?n=n.add(r).toOrderedSet():t instanceof HTMLElement&&!function(){var e=t;n=n.withMutations(function(t){"bold"===e.style.fontWeight&&t.add("BOLD"),"italic"===e.style.fontStyle&&t.add("ITALIC"),"underline"===e.style.textDecoration&&t.add("UNDERLINE"),"line-through"===e.style.textDecoration&&t.add("STRIKETHROUGH")}).toOrderedSet()}(),n}function d(e,t){return c(e,t,(0,g.OrderedSet)())}function s(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t.text.slice(0,1),l=e.text.slice(-1),o="\r"===l&&"\r"===r,u="\r"!==e.text&&"\r"!==t.text,i="\r"===e.text&&!e.isNewline&&t.isNewline;if(o&&(u||i)&&(e.text=e.text.slice(0,-1),e.inlines.pop(),e.entities.pop(),e.blocks.pop()),"\r"===e.text.slice(-1)&&n===!0){if(t.text===T||"\n"===t.text)return e;r!==T&&"\n"!==r||(t.text=t.text.slice(1),t.inlines.shift(),t.entities.shift())}var a=0===e.text.length&&t.isNewline;return{text:e.text+t.text,inlines:e.inlines.concat(t.inlines),entities:e.entities.concat(t.entities),blocks:e.blocks.concat(t.blocks),isNewline:a}}function p(e){return L.some(function(t){return e.indexOf("<"+t)!==-1})}function y(e,t,n,r,f,d,p,v,h,b,M,E,x,_,j,w){var k=e.nodeName.toLowerCase(),R=!1,L="unstyled";if("#text"===k){var P=function(){var n=e.textContent;if(""===n.trim()&&null===r)return{v:l()};if(""===n.trim()&&"code-block"!==r)return{v:o(w)};"code-block"!==r&&(n=n.replace(S,T));var u=Array(n.length).fill(w),i=0,a=h(n,M,E,x,_).sort(O.default);return a.forEach(function(e){var t=e.entity,r=e.offset,l=e.length,o=e.result,a=r+i;null!==o&&void 0!==o||(o=n.substr(a,l));var f=n.split("");f.splice.bind(f,a,l).apply(f,o.split("")),n=f.join(""),u.splice.bind(u,a,l).apply(u,Array(o.length).fill(t)),i+=o.length-l}),{v:{text:n,inlines:Array(n.length).fill(t),entities:u,blocks:[]}}}();if("object"===("undefined"==typeof P?"undefined":m(P)))return P.v}if("br"===k){var D=r;return null===D?u("unstyled",d,!0):u(D||"unstyled",d,j.flat)}var A=l(),H=null;t=c(k,e,t),t=p(k,e,t),"ul"!==k&&"ol"!==k||(n&&(d+=1),n=k,r=null);var C=b(k,e,n,r),I=void 0,N=void 0;if(C===!1)return l();if(C=C||{},"string"==typeof C?(I=C,N=(0,g.Map)()):(I="string"==typeof C?C:C.type,N=C.data?(0,g.Map)(C.data):(0,g.Map)()),r||f.indexOf(k)===-1&&!I)if(!n||"ordered-list-item"!==r&&"unordered-list-item"!==r||"li"!==k)r&&"atomic"!==r&&"atomic"===I&&(r=I,R=!0,A=u(I,d,!0,N));else{var q=a(k,n);A=i(q,d),r=q,R=!0,L="ul"===n?"unordered-list-item":"ordered-list-item"}else A=i(I||a(k,n),d,N),r=I||a(k,n),R=!0;var V=e.firstChild;null!=V||!w||"atomic"!==I&&"atomic"!==r||(V=document.createTextNode("a")),null!=V&&(k=V.nodeName.toLowerCase());for(var B=null;V;){B=v(k,V,M,E,x,_),H=y(V,t,n,r,f,d,p,v,h,b,M,E,x,_,j,B||w),A=s(A,H,j.flat);var U=V.nextSibling;if(U&&f.indexOf(k)>=0&&r){var K=b(k,V,n,r),F=void 0,G=void 0;K!==!1&&(K=K||{},"string"==typeof K?(F=K,G=(0,g.Map)()):(F=K.type||a(k,n),G=K.data?(0,g.Map)(K.data):(0,g.Map)()),A=s(A,u(F,d,j.flat,G),j.flat))}U&&(k=U.nodeName.toLowerCase()),V=U}return R&&(A=s(A,i(L,d,(0,g.Map)()),j.flat)),A}function v(e,t,n,r,l,o,u,i,a,f,c){e=e.trim().replace(w,"").replace(k,T);var d=c(e);if(!d)return null;var s=p(e)?L.concat(["div"]):["div"],v=y(d,(0,g.OrderedSet)(),"ul",null,s,-1,t,n,r,l,o,u,i,a,f);return 0===v.text.indexOf("\r")&&(v={text:v.text.slice(1),inlines:v.inlines.slice(1),entities:v.entities.slice(1),blocks:v.blocks}),"\r"===v.text.slice(-1)&&(v.text=v.text.slice(0,-1),v.inlines=v.inlines.slice(0,-1),v.entities=v.entities.slice(0,-1),v.blocks.pop()),0===v.blocks.length&&v.blocks.push({type:"unstyled",data:(0,g.Map)(),depth:0}),v.text.split("\r").length===v.blocks.length+1&&v.blocks.unshift({type:"unstyled",data:(0,g.Map)(),depth:0}),v}function h(e,t,n,r,l,o,u,i,a,f,c){var d=v(e,t,n,r,l,o,u,i,a,f,c);if(null==d)return[];var s=0;return d.text.split("\r").map(function(e,t){e=q(e);var n=s+e.length,r=N(d).inlines.slice(s,n),l=N(d).entities.slice(s,n),o=(0,g.List)(r.map(function(e,t){var n={style:e,entity:null};return l[t]&&(n.entity=l[t]),b.CharacterMetadata.create(n)}));return s=n+1,new b.ContentBlock({key:(0,b.genKey)(),type:N(d).blocks[t].type,data:N(d).blocks[t].data,depth:N(d).blocks[t].depth,text:e,characterList:o})})}Object.defineProperty(t,"__esModule",{value:!0});var m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g=n(23),b=n(10),M=n(8),E=r(M),x=n(3),O=r(x),_="&nbsp;",T=" ",j=4,w=new RegExp("\r","g"),S=new RegExp("\n","g"),k=new RegExp(_,"g"),R=new RegExp("\r","g"),L=["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre"],P={b:"BOLD",code:"CODE",del:"STRIKETHROUGH",em:"ITALIC",i:"ITALIC",s:"STRIKETHROUGH",strike:"STRIKETHROUGH",strong:"BOLD",u:"UNDERLINE"},D=function(e,t){return e&&e.__isMiddleware===!0?e(t):e},A=function(e,t,n){},H=function(e,t,n){return n},C=function(e,t){},I=function(e){return[]},N=function(e){if(null!=e)return e;throw new Error("Got unexpected null or undefined")},q=function(e){return e.replace(R,"")},V=function(e){var t=e.htmlToStyle,n=void 0===t?H:t,r=e.htmlToEntity,l=void 0===r?C:r,o=e.textToEntity,u=void 0===o?I:o,i=e.htmlToBlock,a=void 0===i?A:i;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{flat:!1},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:E.default,o=b.ContentState.createFromText(""),i=function(){if(o.createEntity){var e;return o=(e=o).createEntity.apply(e,arguments),o.getLastCreatedEntityKey()}return b.Entity.create.apply(b.Entity,arguments)},c=function(){if(o.getEntity){var e;return(e=o).getEntity.apply(e,arguments)}return b.Entity.get.apply(b.Entity,arguments)},s=function(){if(o.mergeEntityData){var e;return void(o=(e=o).mergeEntityData.apply(e,arguments))}b.Entity.mergeData.apply(b.Entity,arguments)},p=function(){if(o.replaceEntityData){var e;return void(o=(e=o).replaceEntityData.apply(e,arguments))}b.Entity.replaceData.apply(b.Entity,arguments)},y=h(e,D(n,d),D(l,C),D(u,I),D(a,f),i,c,s,p,t,r),v=b.BlockMapBuilder.createFromArray(y);return o.set("blockMap",v)}};t.default=function(){return arguments.length>=1&&"string"==typeof(arguments.length<=0?void 0:arguments[0])?V({}).apply(void 0,arguments):V.apply(void 0,arguments)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var l=n(2),o=r(l),u=n(1),i=r(u),a=n(5),f=r(a),c=n(10),d=n(17),s=r(d),p=n(11),y=r(p),v=n(12),h=r(v),m=n(6),g=r(m),b=n(18),M=r(b),E=n(19),x=r(E),O=n(21),_=r(O),T=n(15),j=r(T),w=["ordered-list-item","unordered-list-item"],S=function(e,t){return t},k=function(e){var t=e.styleToHTML,n=void 0===t?{}:t,r=e.blockToHTML,l=void 0===r?{}:r,u=e.entityToHTML,a=void 0===u?S:u;return function(e){(0,o.default)(null!==e&&void 0!==e,"Expected contentState to be non-null");var t=void 0;t=l.__isMiddleware===!0?l((0,M.default)(j.default)):(0,g.default)((0,M.default)(l),(0,M.default)(j.default));var r=(0,c.convertToRaw)(e),u=[],d=r.blocks.map(function(e){var l=e.type,o=e.depth,c="",d="";if(w.indexOf(l)===-1)c=u.reduceRight(function(e,n){return e+(0,_.default)(t(n)).nestEnd},""),u=[];else for(;o+1!==u.length||l!==u[o].type;)if(o+1===u.length){var p=u[o];c+=(0,_.default)(t(p)).nestEnd,d+=(0,_.default)(t(e)).nestStart,u[o]=e}else if(o+1<u.length){var v=u[u.length-1];c+=(0,_.default)(t(v)).nestEnd,u=u.slice(0,-1)}else d+=(0,_.default)(t(e)).nestStart,u.push(e);var m=(0,h.default)((0,y.default)((0,s.default)(e),r.entityMap,a),n),g=(0,x.default)(t(e)),b=void 0;return b="string"==typeof g?g:g.start+m+g.end,0===m.length&&Object.prototype.hasOwnProperty.call(g,"empty")&&(b=i.default.isValidElement(g.empty)?f.default.renderToStaticMarkup(g.empty):g.empty),c+d+b}).join("");return d=u.reduce(function(e,n){return e+(0,_.default)(t(n)).nestEnd},d)}};t.default=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return 1===t.length&&Object.prototype.hasOwnProperty.call(t[0],"_map")&&null!=t[0].getBlockMap?k({}).apply(void 0,t):k.apply(void 0,t)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var l=n(1),o=r(l);t.default={unstyled:o.default.createElement("p",null),paragraph:o.default.createElement("p",null),"header-one":o.default.createElement("h1",null),"header-two":o.default.createElement("h2",null),"header-three":o.default.createElement("h3",null),"header-four":o.default.createElement("h4",null),"header-five":o.default.createElement("h5",null),"header-six":o.default.createElement("h6",null),blockquote:o.default.createElement("blockquote",null),"unordered-list-item":{element:o.default.createElement("li",null),nest:o.default.createElement("ul",null)},"ordered-list-item":{element:o.default.createElement("li",null),nest:o.default.createElement("ol",null)},media:o.default.createElement("figure",null)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){switch(e){case"BOLD":return u.default.createElement("strong",null);case"ITALIC":return u.default.createElement("em",null);case"UNDERLINE":return u.default.createElement("u",null);case"CODE":return u.default.createElement("code",null);default:return{start:"",end:""}}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var o=n(1),u=r(o)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=n(9),u=r(o),i=n(3),a=r(i),f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;","\n":"<br/>"};t.default=function(e){for(var t=[].concat(l(e.text)),n=e.entityRanges.sort(a.default),r=e.inlineStyleRanges.sort(a.default),o="",i=function(e){var l=t[e];void 0!==f[l]?!function(){var e=f[l],t=o.length;o+=e;var i=function(n){return(0,u.default)(n,t,l.length,e.length,0,0)};n=n.map(i),r=r.map(i)}():o+=l},c=0;c<t.length;c++)i(c);return Object.assign({},e,{text:o,inlineStyleRanges:r,entityRanges:n})}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t){return"function"==typeof e?e(t):e[t.type]}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){return f.default.isValidElement(e)&&f.default.Children.count(e.props.children)>0}function o(e){return(0,i.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),"string"==typeof e?e:f.default.isValidElement(e)?l(e)?d.default.renderToStaticMarkup(e):(0,p.default)(e):Object.prototype.hasOwnProperty.call(e,"element")&&f.default.isValidElement(e.element)?Object.assign({},e,(0,p.default)(e.element)):((0,i.default)(Object.prototype.hasOwnProperty.call(e,"start")&&Object.prototype.hasOwnProperty.call(e,"end"),"convertToHTML: received block information without either a ReactElement or an object with start/end tags"),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var u=n(2),i=r(u),a=n(1),f=r(a),c=n(5),d=r(c),s=n(4),p=r(s)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=n(1),u=r(o),i=n(4),a=r(i),f=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"start";if(u.default.isValidElement(t)){var r=(0,a.default)(t);if("string"==typeof r)return 0;var o=r[n].length,i=u.default.Children.toArray(t.props.children)[0];return o+(i&&u.default.isValidElement(i)?e(i,n):0)}return"object"===("undefined"==typeof t?"undefined":l(t))&&t[n]?t[n].length:0};t.default=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if((0,u.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),a.default.isValidElement(e.nest)){var t=(0,c.default)(e.nest),n=t.start,r=t.end;return Object.assign({},e,{nestStart:n,nestEnd:r})}return(0,u.default)(Object.prototype.hasOwnProperty.call(e,"nestStart")&&Object.prototype.hasOwnProperty.call(e,"nestEnd"),"convertToHTML: received block information without either a ReactElement or an object with start/end tags"),e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var o=n(2),u=r(o),i=n(1),a=r(i),f=n(4),c=r(f)},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t){return"function"==typeof e?e(t):e[t]}}},function(e,t){e.exports=r}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOMServer"),require("Draft"),require("Immutable")):"function"==typeof define&&define.amd?define(["React","ReactDOMServer","Draft","Immutable"],t):"object"==typeof exports?exports.DraftConvert=t(require("React"),require("ReactDOMServer"),require("Draft"),require("Immutable")):e.DraftConvert=t(e.React,e.ReactDOMServer,e.Draft,e.Immutable)}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var l=n[r]={exports:{},id:r,loaded:!1};return e[r].call(l.exports,l,l.exports,t),l.loaded=!0,l.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.parseHTML=t.convertFromHTML=t.convertToHTML=void 0;var l=n(14),o=r(l),u=n(13),i=r(u),a=n(8),f=r(a);t.convertToHTML=o.default,t.convertFromHTML=i.default,t.parseHTML=f.default},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=function(e,t,n,r,l,o,u,i){if(!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[n,r,l,o,u,i],c=0;a=new Error(t.replace(/%s/g,function(){return f[c++]})),a.name="Invariant Violation"}throw a.framesToPop=1,a}};e.exports=r},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return e.offset===t.offset?t.length-e.length:e.offset-t.offset}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(d.indexOf(e.type)!==-1)return c.default.renderToStaticMarkup(e);var t=c.default.renderToStaticMarkup(a.default.cloneElement(e,{},"\r")).split("\r");return(0,u.default)(t.length>1,"convertToHTML: Element of type "+e.type+" must render children"),(0,u.default)(t.length<3,"convertToHTML: Element of type "+e.type+" cannot use carriage return character"),{start:t[0],end:t[1]}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var o=n(2),u=r(o),i=n(1),a=r(i),f=n(5),c=r(f),d=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]},function(e,n){e.exports=t},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(){var n=e.apply(void 0,arguments);return void 0!==n&&null!==n?n:t.apply(void 0,arguments)}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){return c.default.isValidElement(e)&&c.default.Children.count(e.props.children)>0}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(void 0===e||null===e)return e;if("string"==typeof e)return e;if(c.default.isValidElement(e)){if(l(e))return s.default.renderToStaticMarkup(e);var n=(0,y.default)(e);if(null!==t&&"object"===("undefined"==typeof n?"undefined":u(n))){var r=n.start,o=n.end;return r+t+o}return n}if((0,a.default)(Object.prototype.hasOwnProperty.call(e,"start")&&Object.prototype.hasOwnProperty.call(e,"end"),"convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags"),null!==t){var i=e.start,f=e.end;return i+t+f}return e}Object.defineProperty(t,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=o;var i=n(2),a=r(i),f=n(1),c=r(f),d=n(5),s=r(d),p=n(4),y=r(p)},function(e,t){"use strict";function n(e){var t=void 0;if("undefined"!=typeof DOMParser){var n=new DOMParser;t=n.parseFromString(e,"text/html"),null!==t&&null!==t.body||(t=r(e))}else t=r(e);return t.body}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var r=function(e){var t=document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,t}},function(e,t){"use strict";function n(e,t,n,r,l,o){var u=r-n,i=t+n<=e.offset;if(i)return Object.assign({},e,{offset:e.offset+u});var a=t>=e.offset&&t+n<=e.offset+e.length;if(a)return Object.assign({},e,{length:e.length+u});var f=e.offset>=t&&e.offset+e.length<=t+n&&l>0;if(f)return Object.assign({},e,{offset:e.offset+l});var c=e.offset<t&&e.offset+e.length<=t+n&&e.offset+e.length>t&&l>0;if(c)return[Object.assign({},e,{length:t-e.offset}),Object.assign({},e,{offset:t+l,length:e.offset-t+e.length})];var d=e.offset>=t&&e.offset+e.length>t+n&&t+n>e.offset&&o>0;return d?[Object.assign({},e,{offset:e.offset+l,length:t+n-e.offset}),Object.assign({},e,{offset:t+n+l+o,length:e.offset+e.length-(t+n)})]:e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t){e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=n(9),u=r(o),i=n(3),a=r(i),f=n(7),c=r(f),d=n(20),s=r(d),p=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments[1]);return e};t.default=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p,r=[].concat(l(e.text)),o=n;if(n.__isMiddleware&&(o=n(p)),Object.prototype.hasOwnProperty.call(e,"entityRanges")&&e.entityRanges.length>0){for(var i=e.entityRanges.sort(a.default),f=e.inlineStyleRanges,d=function(e){var n=i[e],a=t[n.key],d=r.slice(n.offset,n.offset+n.length).join(""),p=o(a,d),y=[].concat(l((0,c.default)(p,d)||d)),v=(0,s.default)(p,"start"),h=(0,s.default)(p,"end"),g=function(t,r){return r>e||Object.prototype.hasOwnProperty.call(t,"style")?(0,u.default)(t,n.offset,n.length,y.length,v,h):t},m=function(e){return e.reduce(function(e,t,n){var r=g(t,n);return Array.isArray(r)?e.concat(r):e.concat([r])},[])};i=m(i),f=m(f),r=[].concat(l(r.slice(0,n.offset)),l(y),l(r.slice(n.offset+n.length)))},y=0;y<i.length;y++)d(y);return Object.assign({},e,{text:r.join(""),inlineStyleRanges:f,entityRanges:i})}return e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),u=r(o),i=n(22),a=r(i),f=n(6),c=r(f),d=n(7),s=r(d),p=n(3),y=r(p),v=n(16),h=r(v),g=function(e,t){return e.filter(function(e){return!t.some(function(t){return t.style===e.style})})},m=function(e,t){return t.reduceRight(function(e,t){var n=e[e.length-1];return(0,u.default)(n.style===t.style,"Style "+n.style+" to be removed doesn't match expected "+t.style),e.slice(0,-1)},e)},b=function(e,t){return t.filter(function(t){return e>=t.offset&&e<t.offset+t.length})},M=function(e,t){var n=e.offset<=t.offset,r=e.offset+e.length>=t.offset+t.length;return n&&r},E=function(e,t){var n=t.offset+t.length,r=e.offset+e.length;return n-r},x=function(e,t){for(var n=0;n<e.length;){if(!t.every(M.bind(null,e[n])))return e.slice(n);n++}return[]},O=function(e,t,n){return t+(0,s.default)(e(n.style)).start},_=function(e,t,n){return(0,s.default)(e(n.style)).end+t},T=function(e){return function(t){return e(t)}};T.__isMiddleware=!0,t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T;(0,u.default)(null!==e&&void 0!==e,"Expected raw block to be non-null");var n=void 0;n=t.__isMiddleware===!0?t(h.default):(0,c.default)((0,a.default)(t),(0,a.default)(h.default));for(var r="",o=[],i=e.inlineStyleRanges.sort(y.default),f=[].concat(l(e.text)),d=0;d<f.length;d++){var p=b(d,i),v=g(o,p),M=g(p,o),j=g(o,v),w=x(j,M),S=w.concat(M).sort(E),k=S.reduce(O.bind(null,n),""),R=v.concat(w).reduce(_.bind(null,n),"");r+=R+k+f[d],o=m(o,w.concat(v)),o=o.concat(S),(0,u.default)(o.length===p.length,"Character "+d+": "+(o.length-p.length)+" styles left on stack that should no longer be there")}return r=o.reduceRight(function(e,t){return e+(0,s.default)(n(t.style)).end},r)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(){return{text:"",inlines:[],entities:[],blocks:[]}}function o(e){var t=new Array(1);return e&&(t[0]=e),{text:T,inlines:[(0,m.OrderedSet)()],entities:t,blocks:[]}}function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,m.Map)();return n===!0?{text:"\r",inlines:[(0,m.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:r,depth:Math.max(0,Math.min(j,t))}],isNewline:!0}:{text:"\n",inlines:[(0,m.OrderedSet)()],entities:new Array(1),blocks:[]}}function i(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,m.Map)();return{text:"\r",inlines:[(0,m.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:n,depth:Math.max(0,Math.min(j,t))}]}}function a(e,t){switch(e){case"h1":return"header-one";case"h2":return"header-two";case"h3":return"header-three";case"h4":return"header-four";case"h5":return"header-five";case"h6":return"header-six";case"li":return"ol"===t?"ordered-list-item":"unordered-list-item";case"blockquote":return"blockquote";case"pre":return"code-block";case"div":case"p":return"unstyled";default:return null}}function f(e,t,n){return a(e,n)}function c(e,t,n){var r=P[e];return r?n=n.add(r).toOrderedSet():t instanceof HTMLElement&&!function(){var e=t;n=n.withMutations(function(t){"bold"===e.style.fontWeight&&t.add("BOLD"),"italic"===e.style.fontStyle&&t.add("ITALIC"),"underline"===e.style.textDecoration&&t.add("UNDERLINE"),"line-through"===e.style.textDecoration&&t.add("STRIKETHROUGH")}).toOrderedSet()}(),n}function d(e,t){return c(e,t,(0,m.OrderedSet)())}function s(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t.text.slice(0,1),l=e.text.slice(-1),o="\r"===l&&"\r"===r,u="\r"!==e.text&&"\r"!==t.text,i="\r"===e.text&&!e.isNewline&&t.isNewline;if(o&&(u||i)&&(e.text=e.text.slice(0,-1),e.inlines.pop(),e.entities.pop(),e.blocks.pop()),"\r"===e.text.slice(-1)&&n===!0){if(t.text===T||"\n"===t.text)return e;r!==T&&"\n"!==r||(t.text=t.text.slice(1),t.inlines.shift(),t.entities.shift())}var a=0===e.text.length&&t.isNewline;return{text:e.text+t.text,inlines:e.inlines.concat(t.inlines),entities:e.entities.concat(t.entities),blocks:e.blocks.concat(t.blocks),isNewline:a}}function p(e){return L.some(function(t){return e.indexOf("<"+t)!==-1})}function y(e,t,n,r,f,d,p,v,h,b,M,E,x,_,j,w){var k=e.nodeName.toLowerCase(),R=!1,L="unstyled";if("#text"===k){var P=function(){var n=e.textContent;if(""===n.trim()&&null===r)return{v:l()};if(""===n.trim()&&"code-block"!==r)return{v:o(w)};"code-block"!==r&&(n=n.replace(S,T));var u=Array(n.length).fill(w),i=0,a=h(n,M,E,x,_).sort(O.default);return a.forEach(function(e){var t=e.entity,r=e.offset,l=e.length,o=e.result,a=r+i;null!==o&&void 0!==o||(o=n.substr(a,l));var f=n.split("");f.splice.bind(f,a,l).apply(f,o.split("")),n=f.join(""),u.splice.bind(u,a,l).apply(u,Array(o.length).fill(t)),i+=o.length-l}),{v:{text:n,inlines:Array(n.length).fill(t),entities:u,blocks:[]}}}();if("object"===("undefined"==typeof P?"undefined":g(P)))return P.v}if("br"===k){var D=r;return null===D?u("unstyled",d,!0):u(D||"unstyled",d,j.flat)}var A=l(),H=null;t=c(k,e,t),t=p(k,e,t),"ul"!==k&&"ol"!==k||(n&&(d+=1),n=k,r=null);var C=b(k,e,n,r),I=void 0,N=void 0;if(C===!1)return l();if(C=C||{},"string"==typeof C?(I=C,N=(0,m.Map)()):(I="string"==typeof C?C:C.type,N=C.data?(0,m.Map)(C.data):(0,m.Map)()),r||f.indexOf(k)===-1&&!I)if(!n||"ordered-list-item"!==r&&"unordered-list-item"!==r||"li"!==k)r&&"atomic"!==r&&"atomic"===I&&(r=I,R=!0,A=u(I,d,!0,N));else{var q=a(k,n);A=i(q,d),r=q,R=!0,L="ul"===n?"unordered-list-item":"ordered-list-item"}else A=i(I||a(k,n),d,N),r=I||a(k,n),R=!0;var V=e.firstChild;null!=V||!w||"atomic"!==I&&"atomic"!==r||(V=document.createTextNode("a")),null!=V&&(k=V.nodeName.toLowerCase());for(var B=null;V;){B=v(k,V,M,E,x,_),H=y(V,t,n,r,f,d,p,v,h,b,M,E,x,_,j,B||w),A=s(A,H,j.flat);var U=V.nextSibling;if(U&&f.indexOf(k)>=0&&r){var K=b(k,V,n,r),F=void 0,G=void 0;K!==!1&&(K=K||{},"string"==typeof K?(F=K,G=(0,m.Map)()):(F=K.type||a(k,n),G=K.data?(0,m.Map)(K.data):(0,m.Map)()),A=s(A,u(F,d,j.flat,G),j.flat))}U&&(k=U.nodeName.toLowerCase()),V=U}return R&&(A=s(A,i(L,d,(0,m.Map)()),j.flat)),A}function v(e,t,n,r,l,o,u,i,a,f,c){e=e.trim().replace(w,"").replace(k,T);var d=c(e);if(!d)return null;var s=p(e)?L.concat(["div"]):["div"],v=y(d,(0,m.OrderedSet)(),"ul",null,s,-1,t,n,r,l,o,u,i,a,f);return 0===v.text.indexOf("\r")&&(v={text:v.text.slice(1),inlines:v.inlines.slice(1),entities:v.entities.slice(1),blocks:v.blocks}),"\r"===v.text.slice(-1)&&(v.text=v.text.slice(0,-1),v.inlines=v.inlines.slice(0,-1),v.entities=v.entities.slice(0,-1),v.blocks.pop()),0===v.blocks.length&&v.blocks.push({type:"unstyled",data:(0,m.Map)(),depth:0}),v.text.split("\r").length===v.blocks.length+1&&v.blocks.unshift({type:"unstyled",data:(0,m.Map)(),depth:0}),v}function h(e,t,n,r,l,o,u,i,a,f,c,d){var s=v(e,t,n,r,l,o,u,i,a,f,c,d);if(null==s)return[];var p=0;return s.text.split("\r").map(function(e,t){e=q(e);var n=p+e.length,r=N(s).inlines.slice(p,n),l=N(s).entities.slice(p,n),o=(0,m.List)(r.map(function(e,t){var n={style:e,entity:null};return l[t]&&(n.entity=l[t]),b.CharacterMetadata.create(n)}));return p=n+1,new b.ContentBlock({key:d(),type:N(s).blocks[t].type,data:N(s).blocks[t].data,depth:N(s).blocks[t].depth,text:e,characterList:o})})}Object.defineProperty(t,"__esModule",{value:!0});var g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m=n(23),b=n(10),M=n(8),E=r(M),x=n(3),O=r(x),_="&nbsp;",T=" ",j=4,w=new RegExp("\r","g"),S=new RegExp("\n","g"),k=new RegExp(_,"g"),R=new RegExp("\r","g"),L=["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre"],P={b:"BOLD",code:"CODE",del:"STRIKETHROUGH",em:"ITALIC",i:"ITALIC",s:"STRIKETHROUGH",strike:"STRIKETHROUGH",strong:"BOLD",u:"UNDERLINE"},D=function(e,t){return e&&e.__isMiddleware===!0?e(t):e},A=function(e,t,n){},H=function(e,t,n){return n},C=function(e,t){},I=function(e){return[]},N=function(e){if(null!=e)return e;throw new Error("Got unexpected null or undefined")},q=function(e){return e.replace(R,"")},V=function(e){var t=e.htmlToStyle,n=void 0===t?H:t,r=e.htmlToEntity,l=void 0===r?C:r,o=e.textToEntity,u=void 0===o?I:o,i=e.htmlToBlock,a=void 0===i?A:i;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{flat:!1},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:E.default,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:b.genKey,i=b.ContentState.createFromText(""),c=function(){if(i.createEntity){var e;return i=(e=i).createEntity.apply(e,arguments),i.getLastCreatedEntityKey()}return b.Entity.create.apply(b.Entity,arguments)},s=function(){if(i.getEntity){var e;return(e=i).getEntity.apply(e,arguments)}return b.Entity.get.apply(b.Entity,arguments)},p=function(){if(i.mergeEntityData){var e;return void(i=(e=i).mergeEntityData.apply(e,arguments))}b.Entity.mergeData.apply(b.Entity,arguments)},y=function(){if(i.replaceEntityData){var e;return void(i=(e=i).replaceEntityData.apply(e,arguments))}b.Entity.replaceData.apply(b.Entity,arguments)},v=h(e,D(n,d),D(l,C),D(u,I),D(a,f),c,s,p,y,t,r,o),g=b.BlockMapBuilder.createFromArray(v);return i.set("blockMap",g)}};t.default=function(){return arguments.length>=1&&"string"==typeof(arguments.length<=0?void 0:arguments[0])?V({}).apply(void 0,arguments):V.apply(void 0,arguments)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var l=n(2),o=r(l),u=n(1),i=r(u),a=n(5),f=r(a),c=n(10),d=n(17),s=r(d),p=n(11),y=r(p),v=n(12),h=r(v),g=n(6),m=r(g),b=n(18),M=r(b),E=n(19),x=r(E),O=n(21),_=r(O),T=n(15),j=r(T),w=function(e,t){return t},S=function(e){var t=e.styleToHTML,n=void 0===t?{}:t,r=e.blockToHTML,l=void 0===r?{}:r,u=e.entityToHTML,a=void 0===u?w:u;return function(e){(0,o.default)(null!==e&&void 0!==e,"Expected contentState to be non-null");var t=void 0;t=l.__isMiddleware===!0?l((0,M.default)(j.default)):(0,m.default)((0,M.default)(l),(0,M.default)(j.default));var r=(0,c.convertToRaw)(e),u=[],d=r.blocks.map(function(e){var l=e.type,o=e.depth,c="",d="";if(t(e).nest)for(;o+1!==u.length||l!==u[o].type;)if(o+1===u.length){var p=u[o];c+=(0,_.default)(t(p)).nestEnd,d+=(0,_.default)(t(e)).nestStart,u[o]=e}else if(o+1<u.length){var v=u[u.length-1];c+=(0,_.default)(t(v)).nestEnd,u=u.slice(0,-1)}else d+=(0,_.default)(t(e)).nestStart,u.push(e);else c=u.reduceRight(function(e,n){return e+(0,_.default)(t(n)).nestEnd},""),u=[];var g=(0,h.default)((0,y.default)((0,s.default)(e),r.entityMap,a),n),m=(0,x.default)(t(e)),b=void 0;return b="string"==typeof m?m:m.start+g+m.end,0===g.length&&Object.prototype.hasOwnProperty.call(m,"empty")&&(b=i.default.isValidElement(m.empty)?f.default.renderToStaticMarkup(m.empty):m.empty),c+d+b}).join("");return d=u.reduce(function(e,n){return e+(0,_.default)(t(n)).nestEnd},d)}};t.default=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return 1===t.length&&Object.prototype.hasOwnProperty.call(t[0],"_map")&&null!=t[0].getBlockMap?S({}).apply(void 0,t):S.apply(void 0,t)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var l=n(1),o=r(l);t.default={unstyled:o.default.createElement("p",null),paragraph:o.default.createElement("p",null),"header-one":o.default.createElement("h1",null),"header-two":o.default.createElement("h2",null),"header-three":o.default.createElement("h3",null),"header-four":o.default.createElement("h4",null),"header-five":o.default.createElement("h5",null),"header-six":o.default.createElement("h6",null),blockquote:o.default.createElement("blockquote",null),"unordered-list-item":{element:o.default.createElement("li",null),nest:o.default.createElement("ul",null)},"ordered-list-item":{element:o.default.createElement("li",null),nest:o.default.createElement("ol",null)},media:o.default.createElement("figure",null)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){switch(e){case"BOLD":return u.default.createElement("strong",null);case"ITALIC":return u.default.createElement("em",null);case"UNDERLINE":return u.default.createElement("u",null);case"CODE":return u.default.createElement("code",null);default:return{start:"",end:""}}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var o=n(1),u=r(o)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=n(9),u=r(o),i=n(3),a=r(i),f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;","\n":"<br/>"};t.default=function(e){for(var t=[].concat(l(e.text)),n=e.entityRanges.sort(a.default),r=e.inlineStyleRanges.sort(a.default),o="",i=function(e){var l=t[e];void 0!==f[l]?!function(){var e=f[l],t=o.length;o+=e;var i=function(n){return(0,u.default)(n,t,l.length,e.length,0,0)};n=n.map(i),r=r.map(i)}():o+=l},c=0;c<t.length;c++)i(c);return Object.assign({},e,{text:o,inlineStyleRanges:r,entityRanges:n})}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t){return"function"==typeof e?e(t):e[t.type]}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){return f.default.isValidElement(e)&&f.default.Children.count(e.props.children)>0}function o(e){return(0,i.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),"string"==typeof e?e:f.default.isValidElement(e)?l(e)?d.default.renderToStaticMarkup(e):(0,p.default)(e):Object.prototype.hasOwnProperty.call(e,"element")&&f.default.isValidElement(e.element)?Object.assign({},e,(0,p.default)(e.element)):((0,i.default)(Object.prototype.hasOwnProperty.call(e,"start")&&Object.prototype.hasOwnProperty.call(e,"end"),"convertToHTML: received block information without either a ReactElement or an object with start/end tags"),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var u=n(2),i=r(u),a=n(1),f=r(a),c=n(5),d=r(c),s=n(4),p=r(s)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=n(1),u=r(o),i=n(4),a=r(i),f=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"start";if(u.default.isValidElement(t)){var r=(0,a.default)(t);if("string"==typeof r)return 0;var o=r[n].length,i=u.default.Children.toArray(t.props.children)[0];return o+(i&&u.default.isValidElement(i)?e(i,n):0)}return"object"===("undefined"==typeof t?"undefined":l(t))&&t[n]?t[n].length:0};t.default=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if((0,u.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),a.default.isValidElement(e.nest)){var t=(0,c.default)(e.nest),n=t.start,r=t.end;return Object.assign({},e,{nestStart:n,nestEnd:r})}return(0,u.default)(Object.prototype.hasOwnProperty.call(e,"nestStart")&&Object.prototype.hasOwnProperty.call(e,"nestEnd"),"convertToHTML: received block information without either a ReactElement or an object with start/end tags"),e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var o=n(2),u=r(o),i=n(1),a=r(i),f=n(4),c=r(f)},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t){return"function"==typeof e?e(t):e[t]}}},function(e,t){e.exports=r}])});

@@ -516,3 +516,3 @@ 'use strict';

function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
// Be ABSOLUTELY SURE that the dom builder you pass hare won't execute

@@ -522,3 +522,3 @@ // arbitrary code in whatever environment you're running this in. For an

var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder);
var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey);
if (chunk == null) {

@@ -544,3 +544,3 @@ return [];

return new _draftJs.ContentBlock({
key: (0, _draftJs.genKey)(),
key: generateKey(),
type: nullthrows(chunk).blocks[blockIndex].type,

@@ -569,2 +569,3 @@ data: nullthrows(chunk).blocks[blockIndex].data,

var DOMBuilder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _parseHTML2.default;
var generateKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _draftJs.genKey;

@@ -615,3 +616,3 @@ var contentState = _draftJs.ContentState.createFromText('');

var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder);
var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder, generateKey);

@@ -618,0 +619,0 @@ var blockMap = _draftJs.BlockMapBuilder.createFromArray(contentBlocks);

@@ -56,4 +56,2 @@ 'use strict';

// import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
var NESTED_BLOCK_TYPES = ['ordered-list-item', 'unordered-list-item'];
var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {

@@ -92,3 +90,3 @@ return originalText;

if (NESTED_BLOCK_TYPES.indexOf(type) === -1) {
if (!getBlockHTML(block).nest) {
// this block can't be nested, so reset all nesting if necessary

@@ -95,0 +93,0 @@ closeNestTags = listStack.reduceRight(function (string, nestedBlock) {

{
"name": "draft-convert",
"version": "2.0.2",
"version": "2.1.0",
"description": "Extensibly serialize & deserialize Draft.js ContentState",

@@ -22,2 +22,3 @@ "main": "lib/index.js",

"lint": "eslint src/ test/",
"prepare": "npm run build-and-test",
"prepublish": "npm run lint && npm run build-and-test"

@@ -24,0 +25,0 @@ },

@@ -160,3 +160,3 @@ # **draft-convert**

```javascript
type HTMLConverter = (html: string, {flat: ?boolean}, DOMBuilder: ?Function) => ContentState
type HTMLConverter = (html: string, {flat: ?boolean}, DOMBuilder: ?Function, generateKey: ?Function) => ContentState

@@ -163,0 +163,0 @@ type EntityKey = string

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc