diff --git a/dist/draft-convert.js b/dist/draft-convert.js index f7ff15c..c5673db 100644 --- a/dist/draft-convert.js +++ b/dist/draft-convert.js @@ -1758,7 +1758,7 @@ return /******/ (function(modules) { // webpackBootstrap "babel-preset-es2015": "^6.6.0", "babel-preset-react": "^6.5.0", "cross-env": "^3.1.4", - "draft-js": "latest", + "draft-js": "appcues/draft-js", "eslint": "3.12.0", "eslint-config-hubspot": "^7.0.0", "eslint-plugin-react": "6.8.0", diff --git a/dist/draft-convert.min.js b/dist/draft-convert.min.js index c69743e..38b40c8 100644 --- a/dist/draft-convert.min.js +++ b/dist/draft-convert.min.js @@ -1 +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.__version=t.parseHTML=t.convertFromHTML=t.convertToHTML=void 0;var l=n(14),i=r(l),o=n(13),a=r(o),u=n(8),s=r(u),f=n(23);t.convertToHTML=i.default,t.convertFromHTML=a.default,t.parseHTML=s.default,t.__version=f.version},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=function(e,t,n,r,l,i,o,a){if(!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,l,i,o,a],f=0;u=new Error(t.replace(/%s/g,function(){return s[f++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}};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 f.default.renderToStaticMarkup(e);var t=f.default.renderToStaticMarkup(u.default.cloneElement(e,{},"\r")).split("\r");return(0,o.default)(t.length>1,"convertToHTML: Element of type "+e.type+" must render children"),(0,o.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 i=n(2),o=r(i),a=n(1),u=r(a),s=n(5),f=r(s),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 s.default.isValidElement(e)&&s.default.Children.count(e.props.children)>0}function i(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(s.default.isValidElement(e)){if(l(e))return d.default.renderToStaticMarkup(e);var n=(0,p.default)(e);if(null!==t){var r=n.start,i=n.end;return r+t+i}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 o=e.start,u=e.end;return o+t+u}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var o=n(2),a=r(o),u=n(1),s=r(u),f=n(5),d=r(f),c=n(4),p=r(c)},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,i){var o=r-n,a=t+n<=e.offset;if(a)return Object.assign({},e,{offset:e.offset+o});var u=t>=e.offset&&t+n<=e.offset+e.length;if(u)return Object.assign({},e,{length:e.length+o});var s=e.offset>=t&&e.offset+e.length<=t+n&&l>0;if(s)return Object.assign({},e,{offset:e.offset+l});var f=e.offsett&&l>0;if(f)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&&i>0;return d?[Object.assign({},e,{offset:e.offset+l,length:t+n-e.offset}),Object.assign({},e,{offset:t+n+l+i,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}}Object.defineProperty(t,"__esModule",{value:!0});var l=n(9),i=r(l),o=n(3),a=r(o),u=n(7),s=r(u),f=n(20),d=r(f),c=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]:c,r=e.text,l=n;if(n.__isMiddleware&&(l=n(c)),Object.prototype.hasOwnProperty.call(e,"entityRanges")&&e.entityRanges.length>0){for(var o=e.entityRanges.sort(a.default),u=e.inlineStyleRanges,f=function(e){var n=o[e],a=t[n.key],f=r.substr(n.offset,n.length),c=l(a,f),p=(0,s.default)(c,f)||f,v=(0,d.default)(c,"start"),h=(0,d.default)(c,"end"),m=function(t,r){return r>e||Object.prototype.hasOwnProperty.call(t,"style")?(0,i.default)(t,n.offset,n.length,p.length,v,h):t},b=function(e){return e.reduce(function(e,t,n){var r=m(t,n);return Array.isArray(r)?e.concat(r):e.concat([r])},[])};o=b(o),u=b(u),r=r.substring(0,n.offset)+p+r.substring(n.offset+n.length)},p=0;p=t.offset&&e=t.offset+t.length;return n&&r},x=function(e,t){var n=t.offset+t.length,r=e.offset+e.length;return n-r},M=function(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:j;(0,i.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,s.default)((0,a.default)(t),(0,a.default)(h.default));for(var r="",l=[],o=e.inlineStyleRanges.sort(p.default),u=0;u2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,b.Map)();return n===!0?{text:"\r",inlines:[(0,b.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:r,depth:Math.max(0,Math.min(E,t))}],isNewline:!0}:{text:"\n",inlines:[(0,b.OrderedSet)()],entities:new Array(1),blocks:[]}}function a(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,b.Map)();return{text:"\r",inlines:[(0,b.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:n,depth:Math.max(0,Math.min(E,t))}]}}function u(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 s(e,t,n){return u(e,n)}function f(e,t,n){var r=L[e];if(r)n=n.add(r).toOrderedSet();else if(t instanceof HTMLElement){var l=t;n=n.withMutations(function(e){"bold"===l.style.fontWeight&&e.add("BOLD"),"italic"===l.style.fontStyle&&e.add("ITALIC"),"underline"===l.style.textDecoration&&e.add("UNDERLINE"),"line-through"===l.style.textDecoration&&e.add("STRIKETHROUGH")}).toOrderedSet()}return n}function d(e,t){return f(e,t,(0,b.OrderedSet)())}function c(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t.text.slice(0,1),l=e.text.slice(-1),i="\r"===l&&"\r"===r,o="\r"!==e.text&&"\r"!==t.text,a="\r"===e.text&&!e.isNewline&&t.isNewline;if(i&&(o||a)&&(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===j||"\n"===t.text)return e;r!==j&&"\n"!==r||(t.text=t.text.slice(1),t.inlines.shift(),t.entities.shift())}var u=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:u}}function p(e){return R.some(function(t){return e.indexOf("<"+t)!==-1})}function v(e,t,n,r,s,d,p,h,m,y,g,x){var M=e.nodeName.toLowerCase(),_=!1,E="unstyled";if("#text"===M){var k=e.textContent;if(""===k.trim()&&null===r)return l();if(""===k.trim()&&"code-block"!==r)return i(x);"code-block"!==r&&(k=k.replace(w,j));var T=Array(k.length).fill(x),S=0,R=m(k).sort(O.default);return R.forEach(function(e){var t=e.entity,n=e.offset,r=e.length,l=e.result,i=n+S;null!==l&&void 0!==l||(l=k.substr(i,r));var o=k.split("");o.splice.bind(o,i,r).apply(o,l.split("")),k=o.join(""),T.splice.bind(T,i,r).apply(T,Array(l.length).fill(t)),S+=l.length-r}),{text:k,inlines:Array(k.length).fill(t),entities:T,blocks:[]}}if("br"===M){var L=r;return null===L?o("unstyled",d,!0):o(L||"unstyled",d,g.flat)}var P=l(),H=null;t=f(M,e,t),t=p(M,e,t),"ul"!==M&&"ol"!==M||(n&&(d+=1),n=M,r=null);var D=y(M,e,n,r),C=void 0,I=void 0;if(D===!1)return l();if(D=D||{},"string"==typeof D?(C=D,I=(0,b.Map)()):(C="string"==typeof D?D:D.type,I=D.data?(0,b.Map)(D.data):(0,b.Map)()),r||s.indexOf(M)===-1&&!C)if(!n||"ordered-list-item"!==r&&"unordered-list-item"!==r||"li"!==M)r&&"atomic"!==r&&"atomic"===C&&(r=C,_=!0,P=o(C,d,!0,I));else{var A=u(M,n);P=a(A,d),r=A,_=!0,E="ul"===n?"unordered-list-item":"ordered-list-item"}else P=a(C||u(M,n),d,I),r=C||u(M,n),_=!0;var N=e.firstChild;null!=N||!x||"atomic"!==C&&"atomic"!==r||(N=document.createTextNode("a")),null!=N&&(M=N.nodeName.toLowerCase());for(var q=null;N;){q=h(M,N),H=v(N,t,n,r,s,d,p,h,m,y,g,q||x),P=c(P,H,g.flat);var B=N.nextSibling;if(B&&s.indexOf(M)>=0&&r){var V=y(M,N,n,r),U=void 0,G=void 0;V!==!1&&(V=V||{},"string"==typeof V?(U=V,G=(0,b.Map)()):(U=V.type||u(M,n),G=V.data?(0,b.Map)(V.data):(0,b.Map)()),P=c(P,o(U,d,g.flat,G),g.flat))}B&&(M=B.nodeName.toLowerCase()),N=B}return _&&(P=c(P,a(E,d,(0,b.Map)()),g.flat)),P}function h(e,t,n,r,l,i,o){e=e.trim().replace(k,"").replace(T,j);var a=o(e);if(!a)return null;var u=p(e)?R.concat(["div"]):["div"],s=v(a,(0,b.OrderedSet)(),"ul",null,u,-1,t,n,r,l,i);return 0===s.text.indexOf("\r")&&(s={text:s.text.slice(1),inlines:s.inlines.slice(1),entities:s.entities.slice(1),blocks:s.blocks}),"\r"===s.text.slice(-1)&&(s.text=s.text.slice(0,-1),s.inlines=s.inlines.slice(0,-1),s.entities=s.entities.slice(0,-1),s.blocks.pop()),0===s.blocks.length&&s.blocks.push({type:"unstyled",data:(0,b.Map)(),depth:0}),s.text.split("\r").length===s.blocks.length+1&&s.blocks.unshift({type:"unstyled",data:(0,b.Map)(),depth:0}),s}function m(e,t,n,r,l,i,o){var a=h(e,t,n,r,l,i,o);if(null==a)return[];var u=0;return a.text.split("\r").map(function(e,t){e=N(e);var n=u+e.length,r=A(a).inlines.slice(u,n),l=A(a).entities.slice(u,n),i=(0,b.List)(r.map(function(e,t){var n={style:e,entity:null};return l[t]&&(n.entity=l[t]),y.CharacterMetadata.create(n)}));return u=n+1,new y.ContentBlock({key:(0,y.genKey)(),type:A(a).blocks[t].type,data:A(a).blocks[t].data,depth:A(a).blocks[t].depth,text:e,characterList:i})})}Object.defineProperty(t,"__esModule",{value:!0});var b=n(24),y=n(10),g=n(8),x=r(g),M=n(3),O=r(M),_=" ",j=" ",E=4,k=new RegExp("\r","g"),w=new RegExp("\n","g"),T=new RegExp(_,"g"),S=new RegExp("\r","g"),R=["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre"],L={b:"BOLD",code:"CODE",del:"STRIKETHROUGH",em:"ITALIC",i:"ITALIC",s:"STRIKETHROUGH",strike:"STRIKETHROUGH",strong:"BOLD",u:"UNDERLINE"},P=function(e,t){return e&&e.__isMiddleware===!0?e(t):e},H=function(e,t,n){},D=function(e,t,n){return n},C=function(e,t){},I=function(e){return[]},A=function(e){if(null!=e)return e;throw new Error("Got unexpected null or undefined")},N=function(e){return e.replace(S,"")},q=function(e){var t=e.htmlToStyle,n=void 0===t?D:t,r=e.htmlToEntity,l=void 0===r?C:r,i=e.textToEntity,o=void 0===i?I:i,a=e.htmlToBlock,u=void 0===a?H:a;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]:x.default;return y.ContentState.createFromBlockArray(m(e,P(n,d),P(l,C),P(o,I),P(u,s),t,r))}};t.default=function(){return arguments.length>=1&&"string"==typeof(arguments.length<=0?void 0:arguments[0])?q({}).apply(void 0,arguments):q.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),i=r(l),o=n(1),a=r(o),u=n(5),s=r(u),f=n(10),d=n(17),c=r(d),p=n(11),v=r(p),h=n(12),m=r(h),b=n(6),y=r(b),g=n(18),x=r(g),M=n(19),O=r(M),_=n(21),j=r(_),E=n(15),k=r(E),w=["ordered-list-item","unordered-list-item"],T=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,o=e.entityToHTML,u=void 0===o?T:o;return function(e){(0,i.default)(null!==e&&void 0!==e,"Expected contentState to be non-null");var t=void 0;t=l.__isMiddleware===!0?l((0,x.default)(k.default)):(0,y.default)((0,x.default)(l),(0,x.default)(k.default));var r=(0,f.convertToRaw)(e),o=[],d=r.blocks.map(function(e){var l=e.type,i=e.depth,f="",d="";if(w.indexOf(l)===-1)f=o.reduceRight(function(e,n){return e+(0,j.default)(t(n)).nestEnd},""),o=[];else for(;i+1!==o.length||l!==o[i].type;)if(i+1===o.length){var p=o[i];f+=(0,j.default)(t(p)).nestEnd,d+=(0,j.default)(t(e)).nestStart,o[i]=e}else if(i+1":">",'"':""","'":"'","`":"`","\n":"
"};t.default=function(e){for(var t=e.text,n=e.entityRanges.sort(a.default),r=e.inlineStyleRanges.sort(a.default),l="",o=function(e){var o=t[e];if(void 0!==u[o]){var a=u[o],s=l.length;l+=a;var f=function(e){return(0,i.default)(e,s,o.length,a.length,0,0)};n=n.map(f),r=r.map(f)}else l+=o},s=0;s0}function i(e){return(0,a.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),s.default.isValidElement(e)?l(e)?d.default.renderToStaticMarkup(e):(0,p.default)(e):Object.prototype.hasOwnProperty.call(e,"element")&&s.default.isValidElement(e.element)?Object.assign({},e,(0,p.default)(e.element)):((0,a.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=i;var o=n(2),a=r(o),u=n(1),s=r(u),f=n(5),d=r(f),c=n(4),p=r(c)},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},i=n(1),o=r(i),a=n(4),u=r(a);t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"start";return o.default.isValidElement(e)&&0===o.default.Children.count(e.props.children)?(0,u.default)(e)[t].length:"object"===("undefined"==typeof e?"undefined":l(e))&&e[t]?e[t].length:0}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if((0,o.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),u.default.isValidElement(e.nest)){var t=(0,f.default)(e.nest),n=t.start,r=t.end;return Object.assign({},e,{nestStart:n,nestEnd:r})}return(0,o.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 i=n(2),o=r(i),a=n(1),u=r(a),s=n(4),f=r(s)},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={name:"draft-convert",version:"1.4.6",description:"Extensibly serialize & deserialize Draft.js ContentState",main:"lib/index.js",repository:"HubSpot/draft-convert",scripts:{build:"npm run build:commonjs && npm run build:umd && npm run build:umd:min","build:commonjs":"cross-env BABEL_ENV=commonjs babel src --out-dir lib","build:umd":"webpack --config webpack.config.development.js ./src/index.js ./dist/draft-convert.js","build:umd:min":"webpack --config webpack.config.production.js ./src/index.js ./dist/draft-convert.min.js",jest:"jest","jest-debug":"node --debug-brk --inspect ./node_modules/.bin/jest -i","test-once":"npm run jest",test:"npm run jest","test:karma":"karma start test/karma.config.js","test-once:karma":"karma start test/karma.config.js --single-run",clean:"rimraf ./dist && rimraf ./lib","build-and-test":"npm run clean && npm run build && npm run test-once",lint:"eslint src/ test/",prepublish:"npm run build-and-test"},files:["dist","lib"],keywords:["draft","draftjs","draft-convert","convert"],author:"bbriggs@hubspot.com",license:"Apache-2.0",peerDependencies:{"draft-js":">=0.7.0",react:"^15.0.2","react-dom":"^15.0.2"},dependencies:{immutable:"~3.7.4",invariant:"^2.2.1"},devDependencies:{"babel-cli":"^6.10.1","babel-core":"^6.7.7","babel-eslint":"^7.1.1","babel-jest":"^18.0.0","babel-loader":"^6.2.4","babel-preset-es2015":"^6.6.0","babel-preset-react":"^6.5.0","cross-env":"^3.1.4","draft-js":"latest",eslint:"3.12.0","eslint-config-hubspot":"^7.0.0","eslint-plugin-react":"6.8.0",jasmine:"^2.2.0",jest:"^18.1.0","json-loader":"^0.5.4",karma:"^0.13.22","karma-chrome-launcher":"^0.2.3","karma-jasmine":"^0.3.8","karma-webpack":"^1.7.0",react:"^15.4.2","react-dom":"^15.4.2",rimraf:"2.5.4",webpack:"^1.13.0"},jest:{testRegex:"/test/spec/.*\\.js$"}}},function(e,t){e.exports=r}])}); \ No newline at end of file +!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.__version=t.parseHTML=t.convertFromHTML=t.convertToHTML=void 0;var l=n(14),i=r(l),o=n(13),a=r(o),u=n(8),s=r(u),f=n(23);t.convertToHTML=i.default,t.convertFromHTML=a.default,t.parseHTML=s.default,t.__version=f.version},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=function(e,t,n,r,l,i,o,a){if(!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,l,i,o,a],f=0;u=new Error(t.replace(/%s/g,function(){return s[f++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}};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 f.default.renderToStaticMarkup(e);var t=f.default.renderToStaticMarkup(u.default.cloneElement(e,{},"\r")).split("\r");return(0,o.default)(t.length>1,"convertToHTML: Element of type "+e.type+" must render children"),(0,o.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 i=n(2),o=r(i),a=n(1),u=r(a),s=n(5),f=r(s),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 s.default.isValidElement(e)&&s.default.Children.count(e.props.children)>0}function i(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(s.default.isValidElement(e)){if(l(e))return d.default.renderToStaticMarkup(e);var n=(0,p.default)(e);if(null!==t){var r=n.start,i=n.end;return r+t+i}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 o=e.start,u=e.end;return o+t+u}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var o=n(2),a=r(o),u=n(1),s=r(u),f=n(5),d=r(f),c=n(4),p=r(c)},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,i){var o=r-n,a=t+n<=e.offset;if(a)return Object.assign({},e,{offset:e.offset+o});var u=t>=e.offset&&t+n<=e.offset+e.length;if(u)return Object.assign({},e,{length:e.length+o});var s=e.offset>=t&&e.offset+e.length<=t+n&&l>0;if(s)return Object.assign({},e,{offset:e.offset+l});var f=e.offsett&&l>0;if(f)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&&i>0;return d?[Object.assign({},e,{offset:e.offset+l,length:t+n-e.offset}),Object.assign({},e,{offset:t+n+l+i,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}}Object.defineProperty(t,"__esModule",{value:!0});var l=n(9),i=r(l),o=n(3),a=r(o),u=n(7),s=r(u),f=n(20),d=r(f),c=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]:c,r=e.text,l=n;if(n.__isMiddleware&&(l=n(c)),Object.prototype.hasOwnProperty.call(e,"entityRanges")&&e.entityRanges.length>0){for(var o=e.entityRanges.sort(a.default),u=e.inlineStyleRanges,f=function(e){var n=o[e],a=t[n.key],f=r.substr(n.offset,n.length),c=l(a,f),p=(0,s.default)(c,f)||f,v=(0,d.default)(c,"start"),h=(0,d.default)(c,"end"),m=function(t,r){return r>e||Object.prototype.hasOwnProperty.call(t,"style")?(0,i.default)(t,n.offset,n.length,p.length,v,h):t},b=function(e){return e.reduce(function(e,t,n){var r=m(t,n);return Array.isArray(r)?e.concat(r):e.concat([r])},[])};o=b(o),u=b(u),r=r.substring(0,n.offset)+p+r.substring(n.offset+n.length)},p=0;p=t.offset&&e=t.offset+t.length;return n&&r},x=function(e,t){var n=t.offset+t.length,r=e.offset+e.length;return n-r},M=function(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:j;(0,i.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,s.default)((0,a.default)(t),(0,a.default)(h.default));for(var r="",l=[],o=e.inlineStyleRanges.sort(p.default),u=0;u2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,b.Map)();return n===!0?{text:"\r",inlines:[(0,b.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:r,depth:Math.max(0,Math.min(E,t))}],isNewline:!0}:{text:"\n",inlines:[(0,b.OrderedSet)()],entities:new Array(1),blocks:[]}}function a(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,b.Map)();return{text:"\r",inlines:[(0,b.OrderedSet)()],entities:new Array(1),blocks:[{type:e,data:n,depth:Math.max(0,Math.min(E,t))}]}}function u(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 s(e,t,n){return u(e,n)}function f(e,t,n){var r=L[e];if(r)n=n.add(r).toOrderedSet();else if(t instanceof HTMLElement){var l=t;n=n.withMutations(function(e){"bold"===l.style.fontWeight&&e.add("BOLD"),"italic"===l.style.fontStyle&&e.add("ITALIC"),"underline"===l.style.textDecoration&&e.add("UNDERLINE"),"line-through"===l.style.textDecoration&&e.add("STRIKETHROUGH")}).toOrderedSet()}return n}function d(e,t){return f(e,t,(0,b.OrderedSet)())}function c(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t.text.slice(0,1),l=e.text.slice(-1),i="\r"===l&&"\r"===r,o="\r"!==e.text&&"\r"!==t.text,a="\r"===e.text&&!e.isNewline&&t.isNewline;if(i&&(o||a)&&(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===j||"\n"===t.text)return e;r!==j&&"\n"!==r||(t.text=t.text.slice(1),t.inlines.shift(),t.entities.shift())}var u=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:u}}function p(e){return R.some(function(t){return e.indexOf("<"+t)!==-1})}function v(e,t,n,r,s,d,p,h,m,y,g,x){var M=e.nodeName.toLowerCase(),_=!1,E="unstyled";if("#text"===M){var k=e.textContent;if(""===k.trim()&&null===r)return l();if(""===k.trim()&&"code-block"!==r)return i(x);"code-block"!==r&&(k=k.replace(w,j));var T=Array(k.length).fill(x),S=0,R=m(k).sort(O.default);return R.forEach(function(e){var t=e.entity,n=e.offset,r=e.length,l=e.result,i=n+S;null!==l&&void 0!==l||(l=k.substr(i,r));var o=k.split("");o.splice.bind(o,i,r).apply(o,l.split("")),k=o.join(""),T.splice.bind(T,i,r).apply(T,Array(l.length).fill(t)),S+=l.length-r}),{text:k,inlines:Array(k.length).fill(t),entities:T,blocks:[]}}if("br"===M){var L=r;return null===L?o("unstyled",d,!0):o(L||"unstyled",d,g.flat)}var P=l(),H=null;t=f(M,e,t),t=p(M,e,t),"ul"!==M&&"ol"!==M||(n&&(d+=1),n=M,r=null);var D=y(M,e,n,r),C=void 0,I=void 0;if(D===!1)return l();if(D=D||{},"string"==typeof D?(C=D,I=(0,b.Map)()):(C="string"==typeof D?D:D.type,I=D.data?(0,b.Map)(D.data):(0,b.Map)()),r||s.indexOf(M)===-1&&!C)if(!n||"ordered-list-item"!==r&&"unordered-list-item"!==r||"li"!==M)r&&"atomic"!==r&&"atomic"===C&&(r=C,_=!0,P=o(C,d,!0,I));else{var A=u(M,n);P=a(A,d),r=A,_=!0,E="ul"===n?"unordered-list-item":"ordered-list-item"}else P=a(C||u(M,n),d,I),r=C||u(M,n),_=!0;var N=e.firstChild;null!=N||!x||"atomic"!==C&&"atomic"!==r||(N=document.createTextNode("a")),null!=N&&(M=N.nodeName.toLowerCase());for(var q=null;N;){q=h(M,N),H=v(N,t,n,r,s,d,p,h,m,y,g,q||x),P=c(P,H,g.flat);var B=N.nextSibling;if(B&&s.indexOf(M)>=0&&r){var V=y(M,N,n,r),U=void 0,G=void 0;V!==!1&&(V=V||{},"string"==typeof V?(U=V,G=(0,b.Map)()):(U=V.type||u(M,n),G=V.data?(0,b.Map)(V.data):(0,b.Map)()),P=c(P,o(U,d,g.flat,G),g.flat))}B&&(M=B.nodeName.toLowerCase()),N=B}return _&&(P=c(P,a(E,d,(0,b.Map)()),g.flat)),P}function h(e,t,n,r,l,i,o){e=e.trim().replace(k,"").replace(T,j);var a=o(e);if(!a)return null;var u=p(e)?R.concat(["div"]):["div"],s=v(a,(0,b.OrderedSet)(),"ul",null,u,-1,t,n,r,l,i);return 0===s.text.indexOf("\r")&&(s={text:s.text.slice(1),inlines:s.inlines.slice(1),entities:s.entities.slice(1),blocks:s.blocks}),"\r"===s.text.slice(-1)&&(s.text=s.text.slice(0,-1),s.inlines=s.inlines.slice(0,-1),s.entities=s.entities.slice(0,-1),s.blocks.pop()),0===s.blocks.length&&s.blocks.push({type:"unstyled",data:(0,b.Map)(),depth:0}),s.text.split("\r").length===s.blocks.length+1&&s.blocks.unshift({type:"unstyled",data:(0,b.Map)(),depth:0}),s}function m(e,t,n,r,l,i,o){var a=h(e,t,n,r,l,i,o);if(null==a)return[];var u=0;return a.text.split("\r").map(function(e,t){e=N(e);var n=u+e.length,r=A(a).inlines.slice(u,n),l=A(a).entities.slice(u,n),i=(0,b.List)(r.map(function(e,t){var n={style:e,entity:null};return l[t]&&(n.entity=l[t]),y.CharacterMetadata.create(n)}));return u=n+1,new y.ContentBlock({key:(0,y.genKey)(),type:A(a).blocks[t].type,data:A(a).blocks[t].data,depth:A(a).blocks[t].depth,text:e,characterList:i})})}Object.defineProperty(t,"__esModule",{value:!0});var b=n(24),y=n(10),g=n(8),x=r(g),M=n(3),O=r(M),_=" ",j=" ",E=4,k=new RegExp("\r","g"),w=new RegExp("\n","g"),T=new RegExp(_,"g"),S=new RegExp("\r","g"),R=["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre"],L={b:"BOLD",code:"CODE",del:"STRIKETHROUGH",em:"ITALIC",i:"ITALIC",s:"STRIKETHROUGH",strike:"STRIKETHROUGH",strong:"BOLD",u:"UNDERLINE"},P=function(e,t){return e&&e.__isMiddleware===!0?e(t):e},H=function(e,t,n){},D=function(e,t,n){return n},C=function(e,t){},I=function(e){return[]},A=function(e){if(null!=e)return e;throw new Error("Got unexpected null or undefined")},N=function(e){return e.replace(S,"")},q=function(e){var t=e.htmlToStyle,n=void 0===t?D:t,r=e.htmlToEntity,l=void 0===r?C:r,i=e.textToEntity,o=void 0===i?I:i,a=e.htmlToBlock,u=void 0===a?H:a;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]:x.default;return y.ContentState.createFromBlockArray(m(e,P(n,d),P(l,C),P(o,I),P(u,s),t,r))}};t.default=function(){return arguments.length>=1&&"string"==typeof(arguments.length<=0?void 0:arguments[0])?q({}).apply(void 0,arguments):q.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),i=r(l),o=n(1),a=r(o),u=n(5),s=r(u),f=n(10),d=n(17),c=r(d),p=n(11),v=r(p),h=n(12),m=r(h),b=n(6),y=r(b),g=n(18),x=r(g),M=n(19),O=r(M),_=n(21),j=r(_),E=n(15),k=r(E),w=["ordered-list-item","unordered-list-item"],T=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,o=e.entityToHTML,u=void 0===o?T:o;return function(e){(0,i.default)(null!==e&&void 0!==e,"Expected contentState to be non-null");var t=void 0;t=l.__isMiddleware===!0?l((0,x.default)(k.default)):(0,y.default)((0,x.default)(l),(0,x.default)(k.default));var r=(0,f.convertToRaw)(e),o=[],d=r.blocks.map(function(e){var l=e.type,i=e.depth,f="",d="";if(w.indexOf(l)===-1)f=o.reduceRight(function(e,n){return e+(0,j.default)(t(n)).nestEnd},""),o=[];else for(;i+1!==o.length||l!==o[i].type;)if(i+1===o.length){var p=o[i];f+=(0,j.default)(t(p)).nestEnd,d+=(0,j.default)(t(e)).nestStart,o[i]=e}else if(i+1":">",'"':""","'":"'","`":"`","\n":"
"};t.default=function(e){for(var t=e.text,n=e.entityRanges.sort(a.default),r=e.inlineStyleRanges.sort(a.default),l="",o=function(e){var o=t[e];if(void 0!==u[o]){var a=u[o],s=l.length;l+=a;var f=function(e){return(0,i.default)(e,s,o.length,a.length,0,0)};n=n.map(f),r=r.map(f)}else l+=o},s=0;s0}function i(e){return(0,a.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),s.default.isValidElement(e)?l(e)?d.default.renderToStaticMarkup(e):(0,p.default)(e):Object.prototype.hasOwnProperty.call(e,"element")&&s.default.isValidElement(e.element)?Object.assign({},e,(0,p.default)(e.element)):((0,a.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=i;var o=n(2),a=r(o),u=n(1),s=r(u),f=n(5),d=r(f),c=n(4),p=r(c)},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},i=n(1),o=r(i),a=n(4),u=r(a);t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"start";return o.default.isValidElement(e)&&0===o.default.Children.count(e.props.children)?(0,u.default)(e)[t].length:"object"===("undefined"==typeof e?"undefined":l(e))&&e[t]?e[t].length:0}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function l(e){if((0,o.default)(null!==e&&void 0!==e,"Expected block HTML value to be non-null"),u.default.isValidElement(e.nest)){var t=(0,f.default)(e.nest),n=t.start,r=t.end;return Object.assign({},e,{nestStart:n,nestEnd:r})}return(0,o.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 i=n(2),o=r(i),a=n(1),u=r(a),s=n(4),f=r(s)},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={name:"draft-convert",version:"1.4.6",description:"Extensibly serialize & deserialize Draft.js ContentState",main:"lib/index.js",repository:"HubSpot/draft-convert",scripts:{build:"npm run build:commonjs && npm run build:umd && npm run build:umd:min","build:commonjs":"cross-env BABEL_ENV=commonjs babel src --out-dir lib","build:umd":"webpack --config webpack.config.development.js ./src/index.js ./dist/draft-convert.js","build:umd:min":"webpack --config webpack.config.production.js ./src/index.js ./dist/draft-convert.min.js",jest:"jest","jest-debug":"node --debug-brk --inspect ./node_modules/.bin/jest -i","test-once":"npm run jest",test:"npm run jest","test:karma":"karma start test/karma.config.js","test-once:karma":"karma start test/karma.config.js --single-run",clean:"rimraf ./dist && rimraf ./lib","build-and-test":"npm run clean && npm run build && npm run test-once",lint:"eslint src/ test/",prepublish:"npm run build-and-test"},files:["dist","lib"],keywords:["draft","draftjs","draft-convert","convert"],author:"bbriggs@hubspot.com",license:"Apache-2.0",peerDependencies:{"draft-js":">=0.7.0",react:"^15.0.2","react-dom":"^15.0.2"},dependencies:{immutable:"~3.7.4",invariant:"^2.2.1"},devDependencies:{"babel-cli":"^6.10.1","babel-core":"^6.7.7","babel-eslint":"^7.1.1","babel-jest":"^18.0.0","babel-loader":"^6.2.4","babel-preset-es2015":"^6.6.0","babel-preset-react":"^6.5.0","cross-env":"^3.1.4","draft-js":"appcues/draft-js",eslint:"3.12.0","eslint-config-hubspot":"^7.0.0","eslint-plugin-react":"6.8.0",jasmine:"^2.2.0",jest:"^18.1.0","json-loader":"^0.5.4",karma:"^0.13.22","karma-chrome-launcher":"^0.2.3","karma-jasmine":"^0.3.8","karma-webpack":"^1.7.0",react:"^15.4.2","react-dom":"^15.4.2",rimraf:"2.5.4",webpack:"^1.13.0"},jest:{testRegex:"/test/spec/.*\\.js$"}}},function(e,t){e.exports=r}])}); \ No newline at end of file diff --git a/package.json b/package.json index 6d9148a..8b607d4 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "babel-preset-es2015": "^6.6.0", "babel-preset-react": "^6.5.0", "cross-env": "^3.1.4", - "draft-js": "latest", + "draft-js": "appcues/draft-js", "eslint": "3.12.0", "eslint-config-hubspot": "^7.0.0", "eslint-plugin-react": "6.8.0",