wix-rich-content-viewer
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -1,3 +0,3 @@ | ||
"use strict";function _interopDefault(ex){return ex&&"object"==typeof ex&&"default"in ex?ex.default:ex}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=_interopDefault(require("@babel/runtime/helpers/extends")),_objectWithoutPropertiesLoose=_interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")),React=require("react"),React__default=_interopDefault(React),PropTypes=_interopDefault(require("prop-types")),classNames=_interopDefault(require("classnames")),isFunction=_interopDefault(require("lodash/isFunction")),wixRichContentCommon=require("wix-rich-content-common"),_inheritsLoose=_interopDefault(require("@babel/runtime/helpers/inheritsLoose")),styles={fontElementMap:"rich-content-viewer_fontElementMap__2536P",pluginContainerReadOnly:"rich-content-viewer_pluginContainerReadOnly__2CvYQ",pluginContainer:"rich-content-viewer_pluginContainer__1sQKR",panelContainer:"rich-content-viewer_panelContainer__1iKfr",wrapper:"rich-content-viewer_wrapper__kcuBq",flex:"rich-content-viewer_flex__32v4L",focused:"rich-content-viewer_focused__2QANw",noOutline:"rich-content-viewer_noOutline__rG7tY",visuallyHidden:"rich-content-viewer_visuallyHidden__1BlbC",hasFocus:"rich-content-viewer_hasFocus__3xWzX",overlay:"rich-content-viewer_overlay__32lvd",hidden:"rich-content-viewer_hidden__2hq23",pluginContainerMobile:"rich-content-viewer_pluginContainerMobile__13mNb",alignLeft:"rich-content-viewer_alignLeft__2k0o0",textWrapNowrap:"rich-content-viewer_textWrapNowrap__3MdB6",alignCenter:"rich-content-viewer_alignCenter__Slk8p",alignRight:"rich-content-viewer_alignRight__1MOUB",sizeFullWidth:"rich-content-viewer_sizeFullWidth__3ciQ2",sizeContent:"rich-content-viewer_sizeContent__1hD8w",sizeSmall:"rich-content-viewer_sizeSmall__3Q43X",sizeSmallCenter:"rich-content-viewer_sizeSmallCenter__1jZaq",isImage:"rich-content-viewer_isImage__3m3_b",anchor:"rich-content-viewer_anchor__i8Flr",desktop:"rich-content-viewer_desktop__uatYj",editor:"rich-content-viewer_editor__kaqlz",android:"rich-content-viewer_android__18id9",atomic:"rich-content-viewer_atomic__q2uC4",toolbar:"rich-content-viewer_toolbar__3HztD",block:"rich-content-viewer_block__Rhs1S",elementSpacing:"rich-content-viewer_elementSpacing__208Ie",blockStyleSpacing:"rich-content-viewer_blockStyleSpacing__1J-OE",text:"rich-content-viewer_text__XzvDs rich-content-viewer_elementSpacing__208Ie",left:"rich-content-viewer_left__2p1aK",center:"rich-content-viewer_center__ujPQ6",right:"rich-content-viewer_right__2KAc8",justify:"rich-content-viewer_justify__1iXso",quote:"rich-content-viewer_quote__3jY04 rich-content-viewer_blockStyleSpacing__1J-OE",headerOne:"rich-content-viewer_headerOne__1EKGD rich-content-viewer_elementSpacing__208Ie",headerTwo:"rich-content-viewer_headerTwo__3f-vr rich-content-viewer_elementSpacing__208Ie",headerThree:"rich-content-viewer_headerThree__3tkn1 rich-content-viewer_elementSpacing__208Ie",indent:"rich-content-viewer_indent__2RESO rich-content-viewer_elementSpacing__208Ie",orderedList:"rich-content-viewer_orderedList__3_0WU rich-content-viewer_elementSpacing__208Ie",unorderedList:"rich-content-viewer_unorderedList__1BJwx rich-content-viewer_elementSpacing__208Ie",code:"rich-content-viewer_code__sEtbn rich-content-viewer_blockStyleSpacing__1J-OE",codeBlock:"rich-content-viewer_codeBlock__3I8mR rich-content-viewer_blockStyleSpacing__1J-OE",normalText:"rich-content-viewer_normalText__1b-JN",preview:"rich-content-viewer_preview__1ppsP"};function unwrapExports(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";return parts.length>1&&(result=parts[0]+"@",string=parts[1]),result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter<length;)(value=string.charCodeAt(counter++))>=55296&&value<=56319&&counter<length?56320==(64512&(extra=string.charCodeAt(counter++)))?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return value>65535&&(output+=stringFromCharCode((value-=65536)>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function basicToDigit(codePoint){return codePoint-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;index>=inputLength&&error("invalid-input"),((digit=basicToDigit(input.charCodeAt(index++)))>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,!(digit<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)w>floor(maxInt/(baseMinusT=base-t))&&error("overflow"),w*=baseMinusT;bias=adapt(i-oldi,out=output.length+1,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(inputLength=(input=ucs2decode(input)).length,n=initialN,delta=0,bias=initialBias,j=0;j<inputLength;++j)(currentValue=input[j])<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)(currentValue=input[j])>=n&¤tValue<m&&(m=currentValue);for(m-n>floor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if((currentValue=input[j])<n&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;!(q<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}var version="1.4.1",ucs2={decode:ucs2decode,encode:ucs2encode},punycode={version:version,ucs2:ucs2,toASCII:toASCII,toUnicode:toUnicode,encode:encode,decode:decode},punycode$1=Object.freeze({decode:decode,encode:encode,toUnicode:toUnicode,toASCII:toASCII,version:version,ucs2:ucs2,default:punycode}),arrayEqual=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(arr1,arr2){if(arr1.length!==arr2.length)return!1;for(var i=0;i++;i<arr1.length)if(arr1[i]!==arr2[i])return!1;return!0}});unwrapExports(arrayEqual);var ContentNode_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var obj,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_arrayEqual2=(obj=arrayEqual)&&obj.__esModule?obj:{default:obj};var ContentNode=function(){function ContentNode(props){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentNode),this.content=props.content||[],this.start=void 0!==props.start?props.start:null,this.end=void 0!==props.end?props.end:null,this.entity=void 0!==props.entity?props.entity:null,this.decorator=void 0!==props.decorator?props.decorator:null,this.decoratorProps=props.decoratorProps||null,this.decoratedText=void 0!==props.decoratedText?props.decoratedText:null,this.contentState=props.contentState,this.style=props.style||null,this.styles=props.styles||null,this.block=props.block||{}}return _createClass(ContentNode,[{key:"getCurrentContent",value:function(){return this.content[this.content.length-1]}},{key:"addToCurrentContent",value:function(string){this.content[this.content.length-1]=this.content[this.content.length-1]+string}},{key:"handleFlatPush",value:function(string,stack){var current=this.getCurrentContent();if(current instanceof ContentNode&&(0,_arrayEqual2.default)(stack,current.styles))current.addToCurrentContent(string);else{var newNode=new ContentNode({styles:[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(stack)),content:[string]});this.content.push(newNode)}}},{key:"pushContent",value:function(string){var stack=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],flat=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!stack||stack.length<1)return"string"==typeof string&&"string"==typeof this.getCurrentContent()?this.addToCurrentContent(string):this.content.push(string),this;if(flat)return this.handleFlatPush(string,stack),this;var arr,_stack=(arr=stack,Array.isArray(arr)?arr:Array.from(arr)),head=_stack[0],rest=_stack.slice(1),current=this.getCurrentContent();if(current instanceof ContentNode&¤t.style===head)current.pushContent(string,rest,flat);else{var newNode=new ContentNode({style:head});newNode.pushContent(string,rest,flat),this.content.push(newNode)}return this}}]),ContentNode}();exports.default=ContentNode});unwrapExports(ContentNode_1);var _punycode=punycode$1&&punycode||punycode$1,RawParser_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_punycode2=_interopRequireDefault(_punycode),_ContentNode2=_interopRequireDefault(ContentNode_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}var getString=function(array,from,to){return _punycode2.default.ucs2.encode(array.slice(from,to))};function addIndexes(indexes,ranges){return ranges.forEach(function(range){indexes.push(range.offset),indexes.push(range.offset+range.length)}),indexes}var RawParser=function(){function RawParser(_ref){var _ref$flat=_ref.flat,flat=void 0!==_ref$flat&&_ref$flat;!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,RawParser),this.flat=flat}return _createClass(RawParser,[{key:"relevantStyles",value:function(offset){return this.ranges.filter(function(range){return offset>=range.offset&&offset<range.offset+range.length}).map(function(style){return style.style})}},{key:"nodeIterator",value:function(node,start,end){var _this=this,indexes=this.relevantIndexes.slice(this.relevantIndexes.indexOf(start),this.relevantIndexes.indexOf(end));return indexes.forEach(function(index,key){var characterStyles=_this.relevantStyles(index),distance=indexes[key+1]?indexes[key+1]-index:1,text=getString(_this.textArray,index,index+distance);node.pushContent(text,characterStyles,_this.flat),!indexes[key+1]&&index<end&&node.pushContent(getString(_this.textArray,index+1,end),_this.relevantStyles(end-1),_this.flat)}),node}},{key:"parse",value:function(block){var _this2=this,text=block.text,ranges=block.inlineStyleRanges,entityRanges=block.entityRanges,_block$decoratorRange=block.decoratorRanges,decoratorRanges=void 0===_block$decoratorRange?[]:_block$decoratorRange;this.textArray=_punycode2.default.ucs2.decode(text),this.ranges=ranges,this.iterator=0,this.relevantIndexes=function(text,inlineRanges){var entityRanges=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],decoratorRanges=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],relevantIndexes=[];return relevantIndexes=addIndexes(relevantIndexes,inlineRanges),relevantIndexes=addIndexes(relevantIndexes,entityRanges),(relevantIndexes=addIndexes(relevantIndexes,decoratorRanges)).push(0),relevantIndexes.push(text.length),relevantIndexes.filter(function(value,index,self){return self.indexOf(value)===index}).sort(function(aa,bb){return aa-bb})}(text,ranges,entityRanges,decoratorRanges);var parsedNodes=function(entityRanges){var decoratorRanges=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],textArray=arguments[2],block=arguments[3],lastIndex=0,mergedRanges=[].concat(_toConsumableArray(entityRanges),_toConsumableArray(decoratorRanges)).sort(function(a,b){return a.offset-b.offset}),nodes=[];return mergedRanges.length<1?(nodes.push(new _ContentNode2.default({block:block,start:0,end:textArray.length})),nodes):(mergedRanges.forEach(function(range){range.offset>lastIndex&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:range.offset})),nodes.push(new _ContentNode2.default({block:block,entity:range.key,decorator:range.component,decoratorProps:range.decoratorProps,decoratedText:range.component?getString(textArray,range.offset,range.offset+range.length):void 0,start:range.offset,end:range.offset+range.length,contentState:range.contentState})),lastIndex=range.offset+range.length}),lastIndex<textArray.length&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:textArray.length})),nodes)}(entityRanges,decoratorRanges,this.textArray,block).map(function(node){return _this2.nodeIterator(node,node.start,node.end)});return new _ContentNode2.default({block:block,content:parsedNodes})}}]),RawParser}();exports.default=RawParser});unwrapExports(RawParser_1);var createStyleRenderer_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(wrapper,stylesMap){return function(children,styleArray,params){var style=function(styleArray,stylesMap){return styleArray.map(function(style){return stylesMap[style]}).reduce(function(prev,next){var mergedStyles={};if(void 0!==next){var key="text-decoration"in next?"text-decoration":"textDecoration";next[key]!==prev[key]&&(mergedStyles[key]=[prev[key],next[key]].join(" ").trim())}return Object.assign(prev,next,mergedStyles)},{})}(styleArray,stylesMap);return wrapper(Object.assign({},{children:children},params,{style:style}))}}});unwrapExports(createStyleRenderer_1);var warn_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(msg){"production"!==process.env.NODE_ENV&&console.warn("Redraft: "+msg)}});unwrapExports(warn_1);var checkCleanup_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(block,prevType,_ref2){var cleanup=_ref2.cleanup;return!(!cleanup||function(block,options){return text=block.text,!(options.trim?!text.trim():!text)||!(!block.data||!Object.keys(block.data).length)||!(!block.entityRanges||!block.entityRanges.length);var text}(block,cleanup)||cleanup.after&&"all"!==cleanup.after&&-1===cleanup.after.indexOf(prevType)||(!cleanup.except||-1!==cleanup.except.indexOf(block.type))&&(!cleanup.types||"all"!==cleanup.types&&-1===cleanup.types.indexOf(block.type)))}});unwrapExports(checkCleanup_1);var getKeyGenerator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(){var key=0;return function(){var current=key;return key+=1,current}}});unwrapExports(getKeyGenerator_1);var checkJoin_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(input,options){return Array.isArray(input)&&options.joinOutput?input.join(""):input}});unwrapExports(checkJoin_1);var pushString_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(string,array,index){var tempArray=array;return array[index]?tempArray[index]+=string:tempArray[index]=string,tempArray}});unwrapExports(pushString_1);var defaultOptions_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default={joinOutput:!1,cleanup:{after:["atomic"],types:["unstyled"],trim:!1,split:!0}}});unwrapExports(defaultOptions_1);var CompositeDecorator=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var CompositeDraftDecorator=function(){function CompositeDraftDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,CompositeDraftDecorator),this.decorators=decorators.slice()}return _createClass(CompositeDraftDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,ii){var counter=0;(0,decorator.strategy)(block,function(start,end){(function(decorations,start,end){for(var ii=start;ii<end;ii++)if(null!=decorations[ii])return!1;return!0})(decorations,start,end)&&(function(targetArr,start,end,componentKey){for(var ii=start;ii<end;ii++)targetArr[ii]=componentKey}(decorations,start,end,ii+"."+counter),counter++)},contentState)}),decorations}},{key:"getComponentForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].component}},{key:"getPropsForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].props}}]),CompositeDraftDecorator}();exports.default=CompositeDraftDecorator});unwrapExports(CompositeDecorator);var MultiDecorator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var MultiDecorator=function(){function MultiDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,MultiDecorator),this.decorators=decorators}return _createClass(MultiDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=new Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,i){decorator.getDecorations(block,contentState).forEach(function(key,offset){key&&(decorations[offset]=i+"-"+key)})}),decorations}},{key:"getComponentForKey",value:function(key){return this.getDecoratorForKey(key).getComponentForKey(MultiDecorator.getInnerKey(key))}},{key:"getPropsForKey",value:function(key){return this.getDecoratorForKey(key).getPropsForKey(MultiDecorator.getInnerKey(key))}},{key:"getDecoratorForKey",value:function(key){var parts=key.split("-"),index=Number(parts[0]);return this.decorators[index]}}],[{key:"getInnerKey",value:function(key){return key.split("-").slice(1).join("-")}}]),MultiDecorator}();exports.default=MultiDecorator});unwrapExports(MultiDecorator_1);var stubContentBlock_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var ContentBlockStub=function(){function ContentBlockStub(block){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentBlockStub),Object.assign(this,block)}return _createClass(ContentBlockStub,[{key:"get",value:function(name){return this[name]}},{key:"getText",value:function(){return this.text}},{key:"getType",value:function(){return this.type}},{key:"getKey",value:function(){return this.key}},{key:"getLength",value:function(){return this.text.length}},{key:"getDepth",value:function(){return this.depth}},{key:"getData",value:function(){return this.data}}]),ContentBlockStub}();exports.default=function(block){return new ContentBlockStub(block)}});unwrapExports(stubContentBlock_1);var withDecorators_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _CompositeDecorator2=_interopRequireDefault(CompositeDecorator),_MultiDecorator2=_interopRequireDefault(MultiDecorator_1),_stubContentBlock2=_interopRequireDefault(stubContentBlock_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var decoratorIsCustom=function(decorator){return"function"==typeof decorator.getDecorations&&"function"==typeof decorator.getComponentForKey&&"function"==typeof decorator.getPropsForKey},resolveDecorators=function(decorators){var compositeDecorator=new _CompositeDecorator2.default(decorators.filter(function(decorator){return!decoratorIsCustom(decorator)})),customDecorators=decorators.filter(function(decorator){return decoratorIsCustom(decorator)}),decor=[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(customDecorators),[compositeDecorator]);return new _MultiDecorator2.default(decor)};exports.default=function(raw,decorators,options){var contentState=options.convertFromRaw&&options.convertFromRaw(raw);return raw.blocks.map(function(block){return function(block,decorators,contentState,_ref){var createContentBlock=_ref.createContentBlock,decoratorRanges=[],decorator=resolveDecorators(decorators),contentBlock=createContentBlock?createContentBlock(block):(0,_stubContentBlock2.default)(block),decorations=decorator.getDecorations(contentBlock,contentState),offset=0;return decorations.forEach(function(key,index){if(key){var nextIndex=index+1,next=decorations[nextIndex];next&&next===key||(decoratorRanges.push({offset:offset,length:nextIndex-offset,component:decorator.getComponentForKey(key),decoratorProps:decorator.getPropsForKey(key)||{},contentState:contentState}),offset=nextIndex)}else offset+=1}),Object.assign({},block,{decoratorRanges:decoratorRanges})}(block,decorators,contentState,options||{})})}});unwrapExports(withDecorators_1);var render_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.render=exports.renderNode=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_warn2=_interopRequireDefault(warn_1),_checkCleanup2=_interopRequireDefault(checkCleanup_1),_getKeyGenerator2=_interopRequireDefault(getKeyGenerator_1),_checkJoin2=_interopRequireDefault(checkJoin_1),_pushString2=_interopRequireDefault(pushString_1),_defaultOptions2=_interopRequireDefault(defaultOptions_1),_withDecorators2=_interopRequireDefault(withDecorators_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var renderNode=exports.renderNode=function renderNode(node,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator){if(node.styles&&styleRenderers)return styleRenderers((0,_checkJoin2.default)(node.content,options),node.styles,{key:keyGenerator()});var children=[],index=0;if(node.content.forEach(function(part){"string"==typeof part?children=(0,_pushString2.default)(part,children,index):(children[index+=1]=renderNode(part,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator),index+=1)}),node.style&&inlineRenderers[node.style])return inlineRenderers[node.style]((0,_checkJoin2.default)(children,options),{key:keyGenerator()});if(null!==node.entity){var entity=entityMap[node.entity];if(entity&&entityRenderers[entity.type])return entityRenderers[entity.type]((0,_checkJoin2.default)(children,options),entity.data,{key:node.entity})}if(null!==node.decorator){var decoratorOffsetKey=[node.block.key,node.start,0].join(".");return node.decorator(Object.assign({children:(0,_checkJoin2.default)(children,options),decoratedText:node.decoratedText,contentState:node.contentState,entityKey:node.entity,offsetKey:decoratorOffsetKey,key:decoratorOffsetKey},node.decoratorProps))}return children},renderGroup=function(group,blockRenderers,rendered,params){var type=params.prevType,depth=params.prevDepth,keys=params.prevKeys,data=params.prevData;0!==group.length&&(blockRenderers[type]?rendered.push(blockRenderers[type](group,{depth:depth,keys:keys,data:data})):rendered.push(group))};exports.render=function(raw){var renderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!raw||!Array.isArray(raw.blocks))return(0,_warn2.default)("invalid raw object"),null;if(!raw.blocks.length)return null;var inlineRenderers=renderers.inline,blockRenderers=renderers.blocks,entityRenderers=renderers.entities,stylesRenderer=renderers.styles,decorators=renderers.decorators;return function renderBlocks(blocks){var inlineRenderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},blockRenderers=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},entityRenderers=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},stylesRenderer=arguments[4],entityMap=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},userOptions=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},options=Object.assign({},_defaultOptions2.default,userOptions),rendered=[],group=[],prevType=null,prevDepth=0,prevKeys=[],prevData=[],splitGroup=!1,Parser=new _RawParser2.default({flat:!!stylesRenderer});return blocks.forEach(function(block){if((0,_checkCleanup2.default)(block,prevType,options))!0===options.cleanup.split&&(splitGroup=!0);else{var node=Parser.parse(block),renderedNode=renderNode(node,inlineRenderers,entityRenderers,stylesRenderer,entityMap,options,(0,_getKeyGenerator2.default)());if((prevType&&prevType!==block.type||splitGroup)&&(renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),prevData=[],prevKeys=[],group=[],splitGroup=!1),block.children){var children=renderBlocks(block.children,inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,entityMap,options);renderedNode.push(children)}group.push(renderedNode),prevType=block.type,prevDepth=block.depth,prevKeys.push(block.key),prevData.push(block.data)}}),renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),(0,_checkJoin2.default)(rendered,options)}(function(blocks){var group=[],depthStack=[],prevDepth=0,unwind=function(targetDepth){var i=prevDepth-targetDepth;for(depthStack.length<i&&(i=depthStack.length);i>0;i-=1){var tmp=group;(group=depthStack.pop())[group.length-1].children=tmp}};return blocks.forEach(function(block){prevDepth<block.depth?(depthStack.push(group),group=[]):prevDepth>block.depth&&unwind(block.depth),prevDepth=block.depth,group.push(block)}),0!==prevDepth&&unwind(0),group}(decorators?(0,_withDecorators2.default)(raw,decorators,options):raw.blocks),inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,raw.entityMap,options)}});unwrapExports(render_1);var render_2=render_1.render,render_3=render_1.renderNode,lib=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompositeDecorator=exports.renderNode=exports.RawParser=exports.createStylesRenderer=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_createStyleRenderer2=_interopRequireDefault(createStyleRenderer_1),_CompositeDecorator2=_interopRequireDefault(CompositeDecorator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.createStylesRenderer=_createStyleRenderer2.default,exports.RawParser=_RawParser2.default,exports.renderNode=render_1.renderNode,exports.CompositeDecorator=_CompositeDecorator2.default,exports.default=render_1.render}),redraft=unwrapExports(lib),lib_1=lib.CompositeDecorator,lib_2=lib.renderNode,lib_3=lib.RawParser,lib_4=lib.createStylesRenderer,renderLink=function(componentData,anchorTarget,relValue){if(componentData.config&&componentData.config.link){var _componentData$config=componentData.config.link,url=_componentData$config.url,target=_componentData$config.target,rel=_componentData$config.rel;return React__default.createElement("a",{target:target||anchorTarget||"_self",rel:rel||relValue||"noopener",href:wixRichContentCommon.normalizeUrl(url),className:styles.anchor})}return null},AtomicBlock=function(_ref){var type=_ref.type,typeMap=_ref.typeMap,componentData=_ref.componentData,children=_ref.children,theme=_ref.theme,isMobile=_ref.isMobile,anchorTarget=_ref.anchorTarget,relValue=_ref.relValue,props=_objectWithoutPropertiesLoose(_ref,["type","typeMap","componentData","children","theme","isMobile","anchorTarget","relValue"]),mergedStyles=wixRichContentCommon.mergeStyles({theme:theme,styles:styles}),_typeMap$type=typeMap[type],Component=_typeMap$type.component,elementType=_typeMap$type.elementType,_ref2=typeMap[type].classNameStrategies||{},size=_ref2.size,alignment=_ref2.alignment,textWrap=_ref2.textWrap,container=_ref2.container;if(Component){if("inline"!==elementType){var _classNames,containerClassNames=classNames(mergedStyles.pluginContainerReadOnly,((_classNames={})[mergedStyles.pluginContainerMobile]=isMobile,_classNames),isFunction(alignment)?alignment(componentData,theme,styles,isMobile):wixRichContentCommon.alignmentClassName(componentData,theme,styles,isMobile),isFunction(size)?size(componentData,theme,styles,isMobile):wixRichContentCommon.sizeClassName(componentData,theme,styles,isMobile),isFunction(textWrap)?textWrap(componentData,theme,styles,isMobile):wixRichContentCommon.textWrapClassName(componentData,theme,styles,isMobile));return React__default.createElement("div",{className:containerClassNames},isFunction(container)?React__default.createElement("div",{className:container(theme)},React__default.createElement(Component,_extends({componentData:componentData,theme:theme},props),children)):React__default.createElement(Component,_extends({componentData:componentData,theme:theme},props),children),renderLink(componentData,anchorTarget,relValue))}return React__default.createElement(Component,_extends({componentData:componentData,theme:theme},props)," ",children," ")}return null};AtomicBlock.propTypes={type:PropTypes.string.isRequired,componentData:PropTypes.object.isRequired,typeMap:PropTypes.object,children:PropTypes.node,theme:PropTypes.object,isMobile:PropTypes.bool,anchorTarget:PropTypes.string,relValue:PropTypes.string};var getPluginsViewer=function(typeMap,pluginProps){var res={};return Object.keys(typeMap).forEach(function(type){res[type]=function(children,entity,_ref3){var key=_ref3.key;return React__default.createElement(AtomicBlock,_extends({typeMap:typeMap,type:type,key:key,componentData:entity},pluginProps),children)}}),res},List=function(_ref){var ordered=_ref.ordered,children=_ref.children;return ordered?React__default.createElement("ol",null,children):React__default.createElement("ul",null,children)};List.propTypes={ordered:PropTypes.bool,children:PropTypes.node.isRequired};var getStrategyByStyle=function(style){return function(contentBlock,callback){contentBlock&&contentBlock.inlineStyleRanges&&contentBlock.inlineStyleRanges.filter(function(range){return range.style===style}).forEach(function(_ref){var offset=_ref.offset,length=_ref.length;return callback(offset,offset+length)})}},withTextAlignment=function(element,blockProps,mergedStyles){var data=(blockProps||[]).data,dataEntry=data.length>0?data[0]:{},alignmentClass=dataEntry.textAlignment?dataEntry.textAlignment:"left",elementProps=_extends({},element.props,{className:element.props.className?classNames(element.props.className,mergedStyles[alignmentClass]):mergedStyles[alignmentClass]});return React__default.cloneElement(element,elementProps,element.props.children)},getInline=function(mergedStyles){return{BOLD:function(children,_ref2){var key=_ref2.key;return React__default.createElement("strong",{key:key},children)},ITALIC:function(children,_ref3){var key=_ref3.key;return React__default.createElement("em",{key:key},children)},UNDERLINE:function(children,_ref4){var key=_ref4.key;return React__default.createElement("u",{key:key},children)},CODE:function(children,_ref5){var key=_ref5.key;return React__default.createElement("span",{key:key,className:mergedStyles.code},children)}}},getList=function(ordered,mergedStyles){return function(children,blockProps){var fixedChildren=children.map(function(child){return child.length?child:[" "]}),className=ordered?"ordered":"unordered";return React__default.createElement(List,{key:blockProps.keys[0],keys:blockProps.keys,depth:blockProps.depth,ordered:ordered},fixedChildren.map(function(child,i){var dataEntry=blockProps.data.length>i?[blockProps.data[i]]:[{}];return withTextAlignment(React__default.createElement("li",{className:mergedStyles[className+"List"],key:blockProps.keys[i]},React__default.createElement("div",null,child)),_extends({},blockProps,{data:dataEntry}),mergedStyles)}))}},getBlocks=function(mergedStyles){return{unstyled:function(children,blockProps){return withTextAlignment(React__default.createElement("p",{key:blockProps.keys[0]},React__default.createElement("div",null,children)),blockProps,mergedStyles)},blockquote:function(children,blockProps){return withTextAlignment(React__default.createElement("blockquote",{className:mergedStyles.quote,key:blockProps.keys[0]},React__default.createElement("div",null,children)),blockProps,mergedStyles)},"header-two":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h2",{className:mergedStyles.headerTwo,key:blockProps.keys[i]},child),blockProps,mergedStyles)})},"header-three":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h3",{className:mergedStyles.headerThree,key:blockProps.keys[i]},child),blockProps,mergedStyles)})},"code-block":function(children,blockProps){return withTextAlignment(React__default.createElement("pre",{key:blockProps.keys[0],className:mergedStyles.codeBlock},children),blockProps,mergedStyles)},"unordered-list-item":getList(!1,mergedStyles),"ordered-list-item":getList(!0,mergedStyles)}},getEntities=function(typeMap,pluginProps){return _extends({},getPluginsViewer(typeMap,pluginProps))},combineTypeMappers=function(mappers){return mappers&&mappers.length&&!mappers.some(function(resolver){return"function"!=typeof resolver})?mappers.reduce(function(map,mapper){return Object.assign(map,mapper())},{}):(console.error("typeMappers is expected to be a function array"),{})},isEmptyRaw=function(raw){return!raw||!raw.blocks||1===raw.blocks.length&&""===raw.blocks[0].text},options={cleanup:{after:"all",types:"all",split:!0}},Preview=function(_ref6){var raw=_ref6.raw,typeMappers=_ref6.typeMappers,theme=_ref6.theme,isMobile=_ref6.isMobile,decorators=_ref6.decorators,anchorTarget=_ref6.anchorTarget,relValue=_ref6.relValue,mergedStyles=wixRichContentCommon.mergeStyles({styles:styles,theme:theme}),isEmpty=isEmptyRaw(raw),typeMap=combineTypeMappers(typeMappers),combinedDecorators=decorators.concat(wixRichContentCommon.createInlineStyleDecorators(getStrategyByStyle,mergedStyles));return React__default.createElement("div",{className:mergedStyles.preview},isEmpty&&React__default.createElement("div",null,"There is nothing to render..."),!isEmpty&&redraft(raw,{inline:getInline(mergedStyles),blocks:getBlocks(mergedStyles),entities:getEntities(typeMap,{theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue}),decorators:combinedDecorators},options))};Preview.propTypes={raw:PropTypes.shape({blocks:PropTypes.array.isRequired,entityMap:PropTypes.object.isRequired}).isRequired,typeMappers:PropTypes.arrayOf(PropTypes.func),theme:PropTypes.object,isMobile:PropTypes.bool,decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),anchorTarget:PropTypes.string,relValue:PropTypes.string};var RichContentViewer=function(_Component){function RichContentViewer(props){var _this;return(_this=_Component.call(this,props)||this).getInitialState=function(initialState){return initialState?wixRichContentCommon.normalizeInitialState(initialState,{anchorTarget:_this.props.anchorTarget,relValue:_this.props.relValue}):{}},_this.state={raw:_this.getInitialState(props.initialState)},_this.styles=wixRichContentCommon.mergeStyles({styles:styles,theme:props.theme}),_this}_inheritsLoose(RichContentViewer,_Component);var _proto=RichContentViewer.prototype;return _proto.componentWillReceiveProps=function(nextProps){this.props.initialState!==nextProps.initialState&&this.setState({raw:this.getInitialState(nextProps.initialState)})},_proto.render=function(){var _classNames,styles$$1=this.styles,_this$props=this.props,theme=_this$props.theme,isMobile=_this$props.isMobile,typeMappers=_this$props.typeMappers,decorators=_this$props.decorators,anchorTarget=_this$props.anchorTarget,relValue=_this$props.relValue,wrapperClassName=classNames(styles$$1.wrapper,((_classNames={})[styles$$1.desktop]=!this.props.platform||"desktop"===this.props.platform,_classNames));return React__default.createElement("div",{className:wrapperClassName},React__default.createElement("div",{className:styles$$1.editor},React__default.createElement(Preview,{raw:this.state.raw,decorators:decorators,typeMappers:typeMappers,theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue})),React__default.createElement(wixRichContentCommon.AccessibilityListener,{isMobile:isMobile}))},RichContentViewer}(React.Component);RichContentViewer.propTypes={initialState:PropTypes.object,isMobile:PropTypes.bool,helpers:PropTypes.object,platform:PropTypes.string,typeMappers:PropTypes.arrayOf(PropTypes.func),decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),theme:PropTypes.object,anchorTarget:PropTypes.string,relValue:PropTypes.string},RichContentViewer.defaultProps={theme:{},decorators:[],typeMappers:[]},exports.RichContentViewer=RichContentViewer; | ||
"use strict";function _interopDefault(ex){return ex&&"object"==typeof ex&&"default"in ex?ex.default:ex}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=_interopDefault(require("@babel/runtime/helpers/extends")),_objectWithoutPropertiesLoose=_interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")),React=require("react"),React__default=_interopDefault(React),PropTypes=_interopDefault(require("prop-types")),classNames=_interopDefault(require("classnames")),isFunction=_interopDefault(require("lodash/isFunction")),wixRichContentCommon=require("wix-rich-content-common"),_inheritsLoose=_interopDefault(require("@babel/runtime/helpers/inheritsLoose")),styles={fontElementMap:"rich-content-viewer_fontElementMap__2536P",pluginContainerReadOnly:"rich-content-viewer_pluginContainerReadOnly__2CvYQ",pluginContainer:"rich-content-viewer_pluginContainer__1sQKR",panelContainer:"rich-content-viewer_panelContainer__1iKfr",wrapper:"rich-content-viewer_wrapper__kcuBq",flex:"rich-content-viewer_flex__32v4L",focused:"rich-content-viewer_focused__2QANw",noOutline:"rich-content-viewer_noOutline__rG7tY",visuallyHidden:"rich-content-viewer_visuallyHidden__1BlbC",hasFocus:"rich-content-viewer_hasFocus__3xWzX",overlay:"rich-content-viewer_overlay__32lvd",hidden:"rich-content-viewer_hidden__2hq23",pluginContainerMobile:"rich-content-viewer_pluginContainerMobile__13mNb",alignLeft:"rich-content-viewer_alignLeft__2k0o0",textWrapNowrap:"rich-content-viewer_textWrapNowrap__3MdB6",alignCenter:"rich-content-viewer_alignCenter__Slk8p",alignRight:"rich-content-viewer_alignRight__1MOUB",sizeFullWidth:"rich-content-viewer_sizeFullWidth__3ciQ2",sizeContent:"rich-content-viewer_sizeContent__1hD8w",sizeSmall:"rich-content-viewer_sizeSmall__3Q43X",sizeSmallCenter:"rich-content-viewer_sizeSmallCenter__1jZaq",isImage:"rich-content-viewer_isImage__3m3_b",anchor:"rich-content-viewer_anchor__i8Flr",desktop:"rich-content-viewer_desktop__uatYj",editor:"rich-content-viewer_editor__kaqlz",android:"rich-content-viewer_android__18id9",atomic:"rich-content-viewer_atomic__q2uC4",toolbar:"rich-content-viewer_toolbar__3HztD",block:"rich-content-viewer_block__Rhs1S",elementSpacing:"rich-content-viewer_elementSpacing__208Ie",blockStyleSpacing:"rich-content-viewer_blockStyleSpacing__1J-OE",text:"rich-content-viewer_text__XzvDs rich-content-viewer_elementSpacing__208Ie",left:"rich-content-viewer_left__2p1aK",center:"rich-content-viewer_center__ujPQ6",right:"rich-content-viewer_right__2KAc8",justify:"rich-content-viewer_justify__1iXso",quote:"rich-content-viewer_quote__3jY04 rich-content-viewer_blockStyleSpacing__1J-OE",headerOne:"rich-content-viewer_headerOne__1EKGD rich-content-viewer_elementSpacing__208Ie",headerTwo:"rich-content-viewer_headerTwo__3f-vr rich-content-viewer_elementSpacing__208Ie",headerThree:"rich-content-viewer_headerThree__3tkn1 rich-content-viewer_elementSpacing__208Ie",indent:"rich-content-viewer_indent__2RESO rich-content-viewer_elementSpacing__208Ie",orderedList:"rich-content-viewer_orderedList__3_0WU rich-content-viewer_elementSpacing__208Ie",unorderedList:"rich-content-viewer_unorderedList__1BJwx rich-content-viewer_elementSpacing__208Ie",code:"rich-content-viewer_code__sEtbn rich-content-viewer_blockStyleSpacing__1J-OE",codeBlock:"rich-content-viewer_codeBlock__3I8mR rich-content-viewer_blockStyleSpacing__1J-OE",normalText:"rich-content-viewer_normalText__1b-JN",preview:"rich-content-viewer_preview__1ppsP"};function unwrapExports(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";return parts.length>1&&(result=parts[0]+"@",string=parts[1]),result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter<length;)(value=string.charCodeAt(counter++))>=55296&&value<=56319&&counter<length?56320==(64512&(extra=string.charCodeAt(counter++)))?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return value>65535&&(output+=stringFromCharCode((value-=65536)>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function basicToDigit(codePoint){return codePoint-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;index>=inputLength&&error("invalid-input"),((digit=basicToDigit(input.charCodeAt(index++)))>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,!(digit<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)w>floor(maxInt/(baseMinusT=base-t))&&error("overflow"),w*=baseMinusT;bias=adapt(i-oldi,out=output.length+1,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(inputLength=(input=ucs2decode(input)).length,n=initialN,delta=0,bias=initialBias,j=0;j<inputLength;++j)(currentValue=input[j])<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)(currentValue=input[j])>=n&¤tValue<m&&(m=currentValue);for(m-n>floor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if((currentValue=input[j])<n&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;!(q<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}var version="1.4.1",ucs2={decode:ucs2decode,encode:ucs2encode},punycode={version:version,ucs2:ucs2,toASCII:toASCII,toUnicode:toUnicode,encode:encode,decode:decode},punycode$1=Object.freeze({decode:decode,encode:encode,toUnicode:toUnicode,toASCII:toASCII,version:version,ucs2:ucs2,default:punycode}),arrayEqual=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(arr1,arr2){if(arr1.length!==arr2.length)return!1;for(var i=0;i++;i<arr1.length)if(arr1[i]!==arr2[i])return!1;return!0}});unwrapExports(arrayEqual);var ContentNode_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var obj,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_arrayEqual2=(obj=arrayEqual)&&obj.__esModule?obj:{default:obj};var ContentNode=function(){function ContentNode(props){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentNode),this.content=props.content||[],this.start=void 0!==props.start?props.start:null,this.end=void 0!==props.end?props.end:null,this.entity=void 0!==props.entity?props.entity:null,this.decorator=void 0!==props.decorator?props.decorator:null,this.decoratorProps=props.decoratorProps||null,this.decoratedText=void 0!==props.decoratedText?props.decoratedText:null,this.contentState=props.contentState,this.style=props.style||null,this.styles=props.styles||null,this.block=props.block||{}}return _createClass(ContentNode,[{key:"getCurrentContent",value:function(){return this.content[this.content.length-1]}},{key:"addToCurrentContent",value:function(string){this.content[this.content.length-1]=this.content[this.content.length-1]+string}},{key:"handleFlatPush",value:function(string,stack){var current=this.getCurrentContent();if(current instanceof ContentNode&&(0,_arrayEqual2.default)(stack,current.styles))current.addToCurrentContent(string);else{var newNode=new ContentNode({styles:[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(stack)),content:[string]});this.content.push(newNode)}}},{key:"pushContent",value:function(string){var stack=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],flat=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!stack||stack.length<1)return"string"==typeof string&&"string"==typeof this.getCurrentContent()?this.addToCurrentContent(string):this.content.push(string),this;if(flat)return this.handleFlatPush(string,stack),this;var arr,_stack=(arr=stack,Array.isArray(arr)?arr:Array.from(arr)),head=_stack[0],rest=_stack.slice(1),current=this.getCurrentContent();if(current instanceof ContentNode&¤t.style===head)current.pushContent(string,rest,flat);else{var newNode=new ContentNode({style:head});newNode.pushContent(string,rest,flat),this.content.push(newNode)}return this}}]),ContentNode}();exports.default=ContentNode});unwrapExports(ContentNode_1);var _punycode=punycode$1&&punycode||punycode$1,RawParser_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_punycode2=_interopRequireDefault(_punycode),_ContentNode2=_interopRequireDefault(ContentNode_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}var getString=function(array,from,to){return _punycode2.default.ucs2.encode(array.slice(from,to))};function addIndexes(indexes,ranges){return ranges.forEach(function(range){indexes.push(range.offset),indexes.push(range.offset+range.length)}),indexes}var RawParser=function(){function RawParser(_ref){var _ref$flat=_ref.flat,flat=void 0!==_ref$flat&&_ref$flat;!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,RawParser),this.flat=flat}return _createClass(RawParser,[{key:"relevantStyles",value:function(offset){return this.ranges.filter(function(range){return offset>=range.offset&&offset<range.offset+range.length}).map(function(style){return style.style})}},{key:"nodeIterator",value:function(node,start,end){var _this=this,indexes=this.relevantIndexes.slice(this.relevantIndexes.indexOf(start),this.relevantIndexes.indexOf(end));return indexes.forEach(function(index,key){var characterStyles=_this.relevantStyles(index),distance=indexes[key+1]?indexes[key+1]-index:1,text=getString(_this.textArray,index,index+distance);node.pushContent(text,characterStyles,_this.flat),!indexes[key+1]&&index<end&&node.pushContent(getString(_this.textArray,index+1,end),_this.relevantStyles(end-1),_this.flat)}),node}},{key:"parse",value:function(block){var _this2=this,text=block.text,ranges=block.inlineStyleRanges,entityRanges=block.entityRanges,_block$decoratorRange=block.decoratorRanges,decoratorRanges=void 0===_block$decoratorRange?[]:_block$decoratorRange;this.textArray=_punycode2.default.ucs2.decode(text),this.ranges=ranges,this.iterator=0,this.relevantIndexes=function(text,inlineRanges){var entityRanges=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],decoratorRanges=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],relevantIndexes=[];return relevantIndexes=addIndexes(relevantIndexes,inlineRanges),relevantIndexes=addIndexes(relevantIndexes,entityRanges),(relevantIndexes=addIndexes(relevantIndexes,decoratorRanges)).push(0),relevantIndexes.push(text.length),relevantIndexes.filter(function(value,index,self){return self.indexOf(value)===index}).sort(function(aa,bb){return aa-bb})}(text,ranges,entityRanges,decoratorRanges);var parsedNodes=function(entityRanges){var decoratorRanges=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],textArray=arguments[2],block=arguments[3],lastIndex=0,mergedRanges=[].concat(_toConsumableArray(entityRanges),_toConsumableArray(decoratorRanges)).sort(function(a,b){return a.offset-b.offset}),nodes=[];return mergedRanges.length<1?(nodes.push(new _ContentNode2.default({block:block,start:0,end:textArray.length})),nodes):(mergedRanges.forEach(function(range){range.offset>lastIndex&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:range.offset})),nodes.push(new _ContentNode2.default({block:block,entity:range.key,decorator:range.component,decoratorProps:range.decoratorProps,decoratedText:range.component?getString(textArray,range.offset,range.offset+range.length):void 0,start:range.offset,end:range.offset+range.length,contentState:range.contentState})),lastIndex=range.offset+range.length}),lastIndex<textArray.length&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:textArray.length})),nodes)}(entityRanges,decoratorRanges,this.textArray,block).map(function(node){return _this2.nodeIterator(node,node.start,node.end)});return new _ContentNode2.default({block:block,content:parsedNodes})}}]),RawParser}();exports.default=RawParser});unwrapExports(RawParser_1);var createStyleRenderer_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(wrapper,stylesMap){return function(children,styleArray,params){var style=function(styleArray,stylesMap){return styleArray.map(function(style){return stylesMap[style]}).reduce(function(prev,next){var mergedStyles={};if(void 0!==next){var key="text-decoration"in next?"text-decoration":"textDecoration";next[key]!==prev[key]&&(mergedStyles[key]=[prev[key],next[key]].join(" ").trim())}return Object.assign(prev,next,mergedStyles)},{})}(styleArray,stylesMap);return wrapper(Object.assign({},{children:children},params,{style:style}))}}});unwrapExports(createStyleRenderer_1);var warn_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(msg){"production"!==process.env.NODE_ENV&&console.warn("Redraft: "+msg)}});unwrapExports(warn_1);var checkCleanup_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(block,prevType,_ref2){var cleanup=_ref2.cleanup;return!(!cleanup||function(block,options){return text=block.text,!(options.trim?!text.trim():!text)||!(!block.data||!Object.keys(block.data).length)||!(!block.entityRanges||!block.entityRanges.length);var text}(block,cleanup)||cleanup.after&&"all"!==cleanup.after&&-1===cleanup.after.indexOf(prevType)||(!cleanup.except||-1!==cleanup.except.indexOf(block.type))&&(!cleanup.types||"all"!==cleanup.types&&-1===cleanup.types.indexOf(block.type)))}});unwrapExports(checkCleanup_1);var getKeyGenerator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(){var key=0;return function(){var current=key;return key+=1,current}}});unwrapExports(getKeyGenerator_1);var checkJoin_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(input,options){return Array.isArray(input)&&options.joinOutput?input.join(""):input}});unwrapExports(checkJoin_1);var pushString_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(string,array,index){var tempArray=array;return array[index]?tempArray[index]+=string:tempArray[index]=string,tempArray}});unwrapExports(pushString_1);var defaultOptions_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default={joinOutput:!1,cleanup:{after:["atomic"],types:["unstyled"],trim:!1,split:!0}}});unwrapExports(defaultOptions_1);var CompositeDecorator=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var CompositeDraftDecorator=function(){function CompositeDraftDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,CompositeDraftDecorator),this.decorators=decorators.slice()}return _createClass(CompositeDraftDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,ii){var counter=0;(0,decorator.strategy)(block,function(start,end){(function(decorations,start,end){for(var ii=start;ii<end;ii++)if(null!=decorations[ii])return!1;return!0})(decorations,start,end)&&(function(targetArr,start,end,componentKey){for(var ii=start;ii<end;ii++)targetArr[ii]=componentKey}(decorations,start,end,ii+"."+counter),counter++)},contentState)}),decorations}},{key:"getComponentForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].component}},{key:"getPropsForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].props}}]),CompositeDraftDecorator}();exports.default=CompositeDraftDecorator});unwrapExports(CompositeDecorator);var MultiDecorator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var MultiDecorator=function(){function MultiDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,MultiDecorator),this.decorators=decorators}return _createClass(MultiDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=new Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,i){decorator.getDecorations(block,contentState).forEach(function(key,offset){key&&(decorations[offset]=i+"-"+key)})}),decorations}},{key:"getComponentForKey",value:function(key){return this.getDecoratorForKey(key).getComponentForKey(MultiDecorator.getInnerKey(key))}},{key:"getPropsForKey",value:function(key){return this.getDecoratorForKey(key).getPropsForKey(MultiDecorator.getInnerKey(key))}},{key:"getDecoratorForKey",value:function(key){var parts=key.split("-"),index=Number(parts[0]);return this.decorators[index]}}],[{key:"getInnerKey",value:function(key){return key.split("-").slice(1).join("-")}}]),MultiDecorator}();exports.default=MultiDecorator});unwrapExports(MultiDecorator_1);var stubContentBlock_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var ContentBlockStub=function(){function ContentBlockStub(block){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentBlockStub),Object.assign(this,block)}return _createClass(ContentBlockStub,[{key:"get",value:function(name){return this[name]}},{key:"getText",value:function(){return this.text}},{key:"getType",value:function(){return this.type}},{key:"getKey",value:function(){return this.key}},{key:"getLength",value:function(){return this.text.length}},{key:"getDepth",value:function(){return this.depth}},{key:"getData",value:function(){return this.data}}]),ContentBlockStub}();exports.default=function(block){return new ContentBlockStub(block)}});unwrapExports(stubContentBlock_1);var withDecorators_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _CompositeDecorator2=_interopRequireDefault(CompositeDecorator),_MultiDecorator2=_interopRequireDefault(MultiDecorator_1),_stubContentBlock2=_interopRequireDefault(stubContentBlock_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var decoratorIsCustom=function(decorator){return"function"==typeof decorator.getDecorations&&"function"==typeof decorator.getComponentForKey&&"function"==typeof decorator.getPropsForKey},resolveDecorators=function(decorators){var compositeDecorator=new _CompositeDecorator2.default(decorators.filter(function(decorator){return!decoratorIsCustom(decorator)})),customDecorators=decorators.filter(function(decorator){return decoratorIsCustom(decorator)}),decor=[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(customDecorators),[compositeDecorator]);return new _MultiDecorator2.default(decor)};exports.default=function(raw,decorators,options){var contentState=options.convertFromRaw&&options.convertFromRaw(raw);return raw.blocks.map(function(block){return function(block,decorators,contentState,_ref){var createContentBlock=_ref.createContentBlock,decoratorRanges=[],decorator=resolveDecorators(decorators),contentBlock=createContentBlock?createContentBlock(block):(0,_stubContentBlock2.default)(block),decorations=decorator.getDecorations(contentBlock,contentState),offset=0;return decorations.forEach(function(key,index){if(key){var nextIndex=index+1,next=decorations[nextIndex];next&&next===key||(decoratorRanges.push({offset:offset,length:nextIndex-offset,component:decorator.getComponentForKey(key),decoratorProps:decorator.getPropsForKey(key)||{},contentState:contentState}),offset=nextIndex)}else offset+=1}),Object.assign({},block,{decoratorRanges:decoratorRanges})}(block,decorators,contentState,options||{})})}});unwrapExports(withDecorators_1);var render_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.render=exports.renderNode=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_warn2=_interopRequireDefault(warn_1),_checkCleanup2=_interopRequireDefault(checkCleanup_1),_getKeyGenerator2=_interopRequireDefault(getKeyGenerator_1),_checkJoin2=_interopRequireDefault(checkJoin_1),_pushString2=_interopRequireDefault(pushString_1),_defaultOptions2=_interopRequireDefault(defaultOptions_1),_withDecorators2=_interopRequireDefault(withDecorators_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var renderNode=exports.renderNode=function renderNode(node,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator){if(node.styles&&styleRenderers)return styleRenderers((0,_checkJoin2.default)(node.content,options),node.styles,{key:keyGenerator()});var children=[],index=0;if(node.content.forEach(function(part){"string"==typeof part?children=(0,_pushString2.default)(part,children,index):(children[index+=1]=renderNode(part,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator),index+=1)}),node.style&&inlineRenderers[node.style])return inlineRenderers[node.style]((0,_checkJoin2.default)(children,options),{key:keyGenerator()});if(null!==node.entity){var entity=entityMap[node.entity];if(entity&&entityRenderers[entity.type])return entityRenderers[entity.type]((0,_checkJoin2.default)(children,options),entity.data,{key:node.entity})}if(null!==node.decorator){var decoratorOffsetKey=[node.block.key,node.start,0].join(".");return node.decorator(Object.assign({children:(0,_checkJoin2.default)(children,options),decoratedText:node.decoratedText,contentState:node.contentState,entityKey:node.entity,offsetKey:decoratorOffsetKey,key:decoratorOffsetKey},node.decoratorProps))}return children},renderGroup=function(group,blockRenderers,rendered,params){var type=params.prevType,depth=params.prevDepth,keys=params.prevKeys,data=params.prevData;0!==group.length&&(blockRenderers[type]?rendered.push(blockRenderers[type](group,{depth:depth,keys:keys,data:data})):rendered.push(group))};exports.render=function(raw){var renderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!raw||!Array.isArray(raw.blocks))return(0,_warn2.default)("invalid raw object"),null;if(!raw.blocks.length)return null;var inlineRenderers=renderers.inline,blockRenderers=renderers.blocks,entityRenderers=renderers.entities,stylesRenderer=renderers.styles,decorators=renderers.decorators;return function renderBlocks(blocks){var inlineRenderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},blockRenderers=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},entityRenderers=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},stylesRenderer=arguments[4],entityMap=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},userOptions=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},options=Object.assign({},_defaultOptions2.default,userOptions),rendered=[],group=[],prevType=null,prevDepth=0,prevKeys=[],prevData=[],splitGroup=!1,Parser=new _RawParser2.default({flat:!!stylesRenderer});return blocks.forEach(function(block){if((0,_checkCleanup2.default)(block,prevType,options))!0===options.cleanup.split&&(splitGroup=!0);else{var node=Parser.parse(block),renderedNode=renderNode(node,inlineRenderers,entityRenderers,stylesRenderer,entityMap,options,(0,_getKeyGenerator2.default)());if((prevType&&prevType!==block.type||splitGroup)&&(renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),prevData=[],prevKeys=[],group=[],splitGroup=!1),block.children){var children=renderBlocks(block.children,inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,entityMap,options);renderedNode.push(children)}group.push(renderedNode),prevType=block.type,prevDepth=block.depth,prevKeys.push(block.key),prevData.push(block.data)}}),renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),(0,_checkJoin2.default)(rendered,options)}(function(blocks){var group=[],depthStack=[],prevDepth=0,unwind=function(targetDepth){var i=prevDepth-targetDepth;for(depthStack.length<i&&(i=depthStack.length);i>0;i-=1){var tmp=group;(group=depthStack.pop())[group.length-1].children=tmp}};return blocks.forEach(function(block){prevDepth<block.depth?(depthStack.push(group),group=[]):prevDepth>block.depth&&unwind(block.depth),prevDepth=block.depth,group.push(block)}),0!==prevDepth&&unwind(0),group}(decorators?(0,_withDecorators2.default)(raw,decorators,options):raw.blocks),inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,raw.entityMap,options)}});unwrapExports(render_1);var render_2=render_1.render,render_3=render_1.renderNode,lib=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompositeDecorator=exports.renderNode=exports.RawParser=exports.createStylesRenderer=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_createStyleRenderer2=_interopRequireDefault(createStyleRenderer_1),_CompositeDecorator2=_interopRequireDefault(CompositeDecorator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.createStylesRenderer=_createStyleRenderer2.default,exports.RawParser=_RawParser2.default,exports.renderNode=render_1.renderNode,exports.CompositeDecorator=_CompositeDecorator2.default,exports.default=render_1.render}),redraft=unwrapExports(lib),lib_1=lib.CompositeDecorator,lib_2=lib.renderNode,lib_3=lib.RawParser,lib_4=lib.createStylesRenderer,renderLink=function(componentData,anchorTarget,relValue){if(componentData.config&&componentData.config.link){var _componentData$config=componentData.config.link,url=_componentData$config.url,target=_componentData$config.target,rel=_componentData$config.rel;return React__default.createElement("a",{target:target||anchorTarget||"_self",rel:rel||relValue||"noopener",href:wixRichContentCommon.normalizeUrl(url),className:styles.anchor})}return null},AtomicBlock=function(_ref){var type=_ref.type,typeMap=_ref.typeMap,componentData=_ref.componentData,children=_ref.children,theme=_ref.theme,isMobile=_ref.isMobile,anchorTarget=_ref.anchorTarget,relValue=_ref.relValue,config=_ref.config,props=_objectWithoutPropertiesLoose(_ref,["type","typeMap","componentData","children","theme","isMobile","anchorTarget","relValue","config"]),mergedStyles=wixRichContentCommon.mergeStyles({theme:theme,styles:styles}),_typeMap$type=typeMap[type],Component=_typeMap$type.component,elementType=_typeMap$type.elementType,_ref2=typeMap[type].classNameStrategies||{},size=_ref2.size,alignment=_ref2.alignment,textWrap=_ref2.textWrap,container=_ref2.container,settings=config&&config[type]||{};if(Component){if("inline"!==elementType){var _classNames,containerClassNames=classNames(mergedStyles.pluginContainerReadOnly,((_classNames={})[mergedStyles.pluginContainerMobile]=isMobile,_classNames),isFunction(alignment)?alignment(componentData,theme,styles,isMobile):wixRichContentCommon.alignmentClassName(componentData,theme,styles,isMobile),isFunction(size)?size(componentData,theme,styles,isMobile):wixRichContentCommon.sizeClassName(componentData,theme,styles,isMobile),isFunction(textWrap)?textWrap(componentData,theme,styles,isMobile):wixRichContentCommon.textWrapClassName(componentData,theme,styles,isMobile));return React__default.createElement("div",{className:containerClassNames},isFunction(container)?React__default.createElement("div",{className:container(theme)},React__default.createElement(Component,_extends({componentData:componentData,theme:theme,settings:settings},props),children)):React__default.createElement(Component,_extends({componentData:componentData,theme:theme,settings:settings},props),children),renderLink(componentData,anchorTarget,relValue))}return React__default.createElement(Component,_extends({componentData:componentData,theme:theme,settings:settings},props)," ",children," ")}return null};AtomicBlock.propTypes={type:PropTypes.string.isRequired,componentData:PropTypes.object.isRequired,typeMap:PropTypes.object,children:PropTypes.node,theme:PropTypes.object,isMobile:PropTypes.bool,anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object};var getPluginsViewer=function(typeMap,pluginProps){var res={};return Object.keys(typeMap).forEach(function(type){res[type]=function(children,entity,_ref3){var key=_ref3.key;return React__default.createElement(AtomicBlock,_extends({typeMap:typeMap,type:type,key:key,componentData:entity},pluginProps),children)}}),res},List=function(_ref){var ordered=_ref.ordered,children=_ref.children;return ordered?React__default.createElement("ol",null,children):React__default.createElement("ul",null,children)};List.propTypes={ordered:PropTypes.bool,children:PropTypes.node.isRequired};var getStrategyByStyle=function(style){return function(contentBlock,callback){contentBlock&&contentBlock.inlineStyleRanges&&contentBlock.inlineStyleRanges.filter(function(range){return range.style===style}).forEach(function(_ref){var offset=_ref.offset,length=_ref.length;return callback(offset,offset+length)})}},withTextAlignment=function(element,data,mergedStyles){var alignmentClass=data.textAlignment?data.textAlignment:"left",elementProps=_extends({},element.props,{className:element.props.className?classNames(element.props.className,mergedStyles[alignmentClass]):mergedStyles[alignmentClass]});return React__default.cloneElement(element,elementProps,element.props.children)},getInline=function(mergedStyles){return{BOLD:function(children,_ref){var key=_ref.key;return React__default.createElement("strong",{key:key},children)},ITALIC:function(children,_ref2){var key=_ref2.key;return React__default.createElement("em",{key:key},children)},UNDERLINE:function(children,_ref3){var key=_ref3.key;return React__default.createElement("u",{key:key},children)},CODE:function(children,_ref4){var key=_ref4.key;return React__default.createElement("span",{key:key,className:mergedStyles.code},children)}}},getList=function(ordered,mergedStyles){return function(children,blockProps){var fixedChildren=children.map(function(child){return child.length?child:[" "]}),className=ordered?"ordered":"unordered";return React__default.createElement(List,{key:blockProps.keys[0],keys:blockProps.keys,depth:blockProps.depth,ordered:ordered},fixedChildren.map(function(child,i){var dataEntry=blockProps.data.length>i?blockProps.data[i]:{};return withTextAlignment(React__default.createElement("li",{className:mergedStyles[className+"List"],key:blockProps.keys[i]},React__default.createElement("div",null,child)),dataEntry,mergedStyles)}))}},getBlocks=function(mergedStyles){return{unstyled:function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("div",{key:blockProps.keys[i]},React__default.createElement("div",null,child)),blockProps.data[i],mergedStyles)})},blockquote:function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("blockquote",{className:mergedStyles.quote,key:blockProps.keys[i]},React__default.createElement("div",null,child)),blockProps.data[i],mergedStyles)})},"header-two":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h2",{className:mergedStyles.headerTwo,key:blockProps.keys[i]},child),blockProps.data[i],mergedStyles)})},"header-three":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h3",{className:mergedStyles.headerThree,key:blockProps.keys[i]},child),blockProps.data[i],mergedStyles)})},"code-block":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("pre",{key:blockProps.keys[i],className:mergedStyles.codeBlock},child),blockProps.data[i],mergedStyles)})},"unordered-list-item":getList(!1,mergedStyles),"ordered-list-item":getList(!0,mergedStyles)}},getEntities=function(typeMap,pluginProps){return _extends({},getPluginsViewer(typeMap,pluginProps))},combineTypeMappers=function(mappers){return mappers&&mappers.length&&!mappers.some(function(resolver){return"function"!=typeof resolver})?mappers.reduce(function(map,mapper){return Object.assign(map,mapper())},{}):(console.warn("typeMappers is expected to be a function array"),{})},isEmptyRaw=function(raw){return!raw||!raw.blocks||1===raw.blocks.length&&""===raw.blocks[0].text},options={cleanup:{after:"all",types:"all",split:!0}},Preview=function(_ref5){var raw=_ref5.raw,typeMappers=_ref5.typeMappers,theme=_ref5.theme,isMobile=_ref5.isMobile,decorators=_ref5.decorators,anchorTarget=_ref5.anchorTarget,relValue=_ref5.relValue,config=_ref5.config,mergedStyles=wixRichContentCommon.mergeStyles({styles:styles,theme:theme}),isEmpty=isEmptyRaw(raw),typeMap=combineTypeMappers(typeMappers),combinedDecorators=decorators.concat(wixRichContentCommon.createInlineStyleDecorators(getStrategyByStyle,mergedStyles));return React__default.createElement("div",{className:mergedStyles.preview},isEmpty&&React__default.createElement("div",null,"There is nothing to render..."),!isEmpty&&redraft(raw,{inline:getInline(mergedStyles),blocks:getBlocks(mergedStyles),entities:getEntities(typeMap,{theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue,config:config}),decorators:combinedDecorators},options))};Preview.propTypes={raw:PropTypes.shape({blocks:PropTypes.array.isRequired,entityMap:PropTypes.object.isRequired}).isRequired,typeMappers:PropTypes.arrayOf(PropTypes.func),theme:PropTypes.object,isMobile:PropTypes.bool,decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object};var RichContentViewer=function(_Component){function RichContentViewer(props){var _this;return(_this=_Component.call(this,props)||this).getInitialState=function(initialState){return initialState?wixRichContentCommon.normalizeInitialState(initialState,{anchorTarget:_this.props.anchorTarget,relValue:_this.props.relValue}):{}},_this.state={raw:_this.getInitialState(props.initialState)},_this.styles=wixRichContentCommon.mergeStyles({styles:styles,theme:props.theme}),_this}_inheritsLoose(RichContentViewer,_Component);var _proto=RichContentViewer.prototype;return _proto.componentWillReceiveProps=function(nextProps){this.props.initialState!==nextProps.initialState&&this.setState({raw:this.getInitialState(nextProps.initialState)})},_proto.render=function(){var _classNames,styles$$1=this.styles,_this$props=this.props,theme=_this$props.theme,isMobile=_this$props.isMobile,typeMappers=_this$props.typeMappers,decorators=_this$props.decorators,anchorTarget=_this$props.anchorTarget,relValue=_this$props.relValue,config=_this$props.config,wrapperClassName=classNames(styles$$1.wrapper,((_classNames={})[styles$$1.desktop]=!this.props.platform||"desktop"===this.props.platform,_classNames));return React__default.createElement("div",{className:wrapperClassName},React__default.createElement("div",{className:styles$$1.editor},React__default.createElement(Preview,{raw:this.state.raw,decorators:decorators,typeMappers:typeMappers,config:config,theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue})),React__default.createElement(wixRichContentCommon.AccessibilityListener,{isMobile:isMobile}))},RichContentViewer}(React.Component);RichContentViewer.propTypes={initialState:PropTypes.object,isMobile:PropTypes.bool,helpers:PropTypes.object,platform:PropTypes.string,typeMappers:PropTypes.arrayOf(PropTypes.func),decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),theme:PropTypes.object,anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object},RichContentViewer.defaultProps={theme:{},decorators:[],typeMappers:[]},exports.RichContentViewer=RichContentViewer; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=module.cjs.js.map |
@@ -1,3 +0,3 @@ | ||
import _extends from"@babel/runtime/helpers/extends";import _objectWithoutPropertiesLoose from"@babel/runtime/helpers/objectWithoutPropertiesLoose";import React,{Component}from"react";import PropTypes from"prop-types";import classNames from"classnames";import isFunction from"lodash/isFunction";import{sizeClassName,alignmentClassName,textWrapClassName,mergeStyles,normalizeUrl,createInlineStyleDecorators,AccessibilityListener,normalizeInitialState}from"wix-rich-content-common";import _inheritsLoose from"@babel/runtime/helpers/inheritsLoose";var styles={fontElementMap:"rich-content-viewer_fontElementMap__2536P",pluginContainerReadOnly:"rich-content-viewer_pluginContainerReadOnly__2CvYQ",pluginContainer:"rich-content-viewer_pluginContainer__1sQKR",panelContainer:"rich-content-viewer_panelContainer__1iKfr",wrapper:"rich-content-viewer_wrapper__kcuBq",flex:"rich-content-viewer_flex__32v4L",focused:"rich-content-viewer_focused__2QANw",noOutline:"rich-content-viewer_noOutline__rG7tY",visuallyHidden:"rich-content-viewer_visuallyHidden__1BlbC",hasFocus:"rich-content-viewer_hasFocus__3xWzX",overlay:"rich-content-viewer_overlay__32lvd",hidden:"rich-content-viewer_hidden__2hq23",pluginContainerMobile:"rich-content-viewer_pluginContainerMobile__13mNb",alignLeft:"rich-content-viewer_alignLeft__2k0o0",textWrapNowrap:"rich-content-viewer_textWrapNowrap__3MdB6",alignCenter:"rich-content-viewer_alignCenter__Slk8p",alignRight:"rich-content-viewer_alignRight__1MOUB",sizeFullWidth:"rich-content-viewer_sizeFullWidth__3ciQ2",sizeContent:"rich-content-viewer_sizeContent__1hD8w",sizeSmall:"rich-content-viewer_sizeSmall__3Q43X",sizeSmallCenter:"rich-content-viewer_sizeSmallCenter__1jZaq",isImage:"rich-content-viewer_isImage__3m3_b",anchor:"rich-content-viewer_anchor__i8Flr",desktop:"rich-content-viewer_desktop__uatYj",editor:"rich-content-viewer_editor__kaqlz",android:"rich-content-viewer_android__18id9",atomic:"rich-content-viewer_atomic__q2uC4",toolbar:"rich-content-viewer_toolbar__3HztD",block:"rich-content-viewer_block__Rhs1S",elementSpacing:"rich-content-viewer_elementSpacing__208Ie",blockStyleSpacing:"rich-content-viewer_blockStyleSpacing__1J-OE",text:"rich-content-viewer_text__XzvDs rich-content-viewer_elementSpacing__208Ie",left:"rich-content-viewer_left__2p1aK",center:"rich-content-viewer_center__ujPQ6",right:"rich-content-viewer_right__2KAc8",justify:"rich-content-viewer_justify__1iXso",quote:"rich-content-viewer_quote__3jY04 rich-content-viewer_blockStyleSpacing__1J-OE",headerOne:"rich-content-viewer_headerOne__1EKGD rich-content-viewer_elementSpacing__208Ie",headerTwo:"rich-content-viewer_headerTwo__3f-vr rich-content-viewer_elementSpacing__208Ie",headerThree:"rich-content-viewer_headerThree__3tkn1 rich-content-viewer_elementSpacing__208Ie",indent:"rich-content-viewer_indent__2RESO rich-content-viewer_elementSpacing__208Ie",orderedList:"rich-content-viewer_orderedList__3_0WU rich-content-viewer_elementSpacing__208Ie",unorderedList:"rich-content-viewer_unorderedList__1BJwx rich-content-viewer_elementSpacing__208Ie",code:"rich-content-viewer_code__sEtbn rich-content-viewer_blockStyleSpacing__1J-OE",codeBlock:"rich-content-viewer_codeBlock__3I8mR rich-content-viewer_blockStyleSpacing__1J-OE",normalText:"rich-content-viewer_normalText__1b-JN",preview:"rich-content-viewer_preview__1ppsP"};function unwrapExports(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";return parts.length>1&&(result=parts[0]+"@",string=parts[1]),result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter<length;)(value=string.charCodeAt(counter++))>=55296&&value<=56319&&counter<length?56320==(64512&(extra=string.charCodeAt(counter++)))?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return value>65535&&(output+=stringFromCharCode((value-=65536)>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function basicToDigit(codePoint){return codePoint-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;index>=inputLength&&error("invalid-input"),((digit=basicToDigit(input.charCodeAt(index++)))>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,!(digit<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)w>floor(maxInt/(baseMinusT=base-t))&&error("overflow"),w*=baseMinusT;bias=adapt(i-oldi,out=output.length+1,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(inputLength=(input=ucs2decode(input)).length,n=initialN,delta=0,bias=initialBias,j=0;j<inputLength;++j)(currentValue=input[j])<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)(currentValue=input[j])>=n&¤tValue<m&&(m=currentValue);for(m-n>floor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if((currentValue=input[j])<n&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;!(q<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}var version="1.4.1",ucs2={decode:ucs2decode,encode:ucs2encode},punycode={version:version,ucs2:ucs2,toASCII:toASCII,toUnicode:toUnicode,encode:encode,decode:decode},punycode$1=Object.freeze({decode:decode,encode:encode,toUnicode:toUnicode,toASCII:toASCII,version:version,ucs2:ucs2,default:punycode}),arrayEqual=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(arr1,arr2){if(arr1.length!==arr2.length)return!1;for(var i=0;i++;i<arr1.length)if(arr1[i]!==arr2[i])return!1;return!0}});unwrapExports(arrayEqual);var ContentNode_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var obj,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_arrayEqual2=(obj=arrayEqual)&&obj.__esModule?obj:{default:obj};var ContentNode=function(){function ContentNode(props){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentNode),this.content=props.content||[],this.start=void 0!==props.start?props.start:null,this.end=void 0!==props.end?props.end:null,this.entity=void 0!==props.entity?props.entity:null,this.decorator=void 0!==props.decorator?props.decorator:null,this.decoratorProps=props.decoratorProps||null,this.decoratedText=void 0!==props.decoratedText?props.decoratedText:null,this.contentState=props.contentState,this.style=props.style||null,this.styles=props.styles||null,this.block=props.block||{}}return _createClass(ContentNode,[{key:"getCurrentContent",value:function(){return this.content[this.content.length-1]}},{key:"addToCurrentContent",value:function(string){this.content[this.content.length-1]=this.content[this.content.length-1]+string}},{key:"handleFlatPush",value:function(string,stack){var current=this.getCurrentContent();if(current instanceof ContentNode&&(0,_arrayEqual2.default)(stack,current.styles))current.addToCurrentContent(string);else{var newNode=new ContentNode({styles:[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(stack)),content:[string]});this.content.push(newNode)}}},{key:"pushContent",value:function(string){var stack=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],flat=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!stack||stack.length<1)return"string"==typeof string&&"string"==typeof this.getCurrentContent()?this.addToCurrentContent(string):this.content.push(string),this;if(flat)return this.handleFlatPush(string,stack),this;var arr,_stack=(arr=stack,Array.isArray(arr)?arr:Array.from(arr)),head=_stack[0],rest=_stack.slice(1),current=this.getCurrentContent();if(current instanceof ContentNode&¤t.style===head)current.pushContent(string,rest,flat);else{var newNode=new ContentNode({style:head});newNode.pushContent(string,rest,flat),this.content.push(newNode)}return this}}]),ContentNode}();exports.default=ContentNode});unwrapExports(ContentNode_1);var _punycode=punycode$1&&punycode||punycode$1,RawParser_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_punycode2=_interopRequireDefault(_punycode),_ContentNode2=_interopRequireDefault(ContentNode_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}var getString=function(array,from,to){return _punycode2.default.ucs2.encode(array.slice(from,to))};function addIndexes(indexes,ranges){return ranges.forEach(function(range){indexes.push(range.offset),indexes.push(range.offset+range.length)}),indexes}var RawParser=function(){function RawParser(_ref){var _ref$flat=_ref.flat,flat=void 0!==_ref$flat&&_ref$flat;!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,RawParser),this.flat=flat}return _createClass(RawParser,[{key:"relevantStyles",value:function(offset){return this.ranges.filter(function(range){return offset>=range.offset&&offset<range.offset+range.length}).map(function(style){return style.style})}},{key:"nodeIterator",value:function(node,start,end){var _this=this,indexes=this.relevantIndexes.slice(this.relevantIndexes.indexOf(start),this.relevantIndexes.indexOf(end));return indexes.forEach(function(index,key){var characterStyles=_this.relevantStyles(index),distance=indexes[key+1]?indexes[key+1]-index:1,text=getString(_this.textArray,index,index+distance);node.pushContent(text,characterStyles,_this.flat),!indexes[key+1]&&index<end&&node.pushContent(getString(_this.textArray,index+1,end),_this.relevantStyles(end-1),_this.flat)}),node}},{key:"parse",value:function(block){var _this2=this,text=block.text,ranges=block.inlineStyleRanges,entityRanges=block.entityRanges,_block$decoratorRange=block.decoratorRanges,decoratorRanges=void 0===_block$decoratorRange?[]:_block$decoratorRange;this.textArray=_punycode2.default.ucs2.decode(text),this.ranges=ranges,this.iterator=0,this.relevantIndexes=function(text,inlineRanges){var entityRanges=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],decoratorRanges=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],relevantIndexes=[];return relevantIndexes=addIndexes(relevantIndexes,inlineRanges),relevantIndexes=addIndexes(relevantIndexes,entityRanges),(relevantIndexes=addIndexes(relevantIndexes,decoratorRanges)).push(0),relevantIndexes.push(text.length),relevantIndexes.filter(function(value,index,self){return self.indexOf(value)===index}).sort(function(aa,bb){return aa-bb})}(text,ranges,entityRanges,decoratorRanges);var parsedNodes=function(entityRanges){var decoratorRanges=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],textArray=arguments[2],block=arguments[3],lastIndex=0,mergedRanges=[].concat(_toConsumableArray(entityRanges),_toConsumableArray(decoratorRanges)).sort(function(a,b){return a.offset-b.offset}),nodes=[];return mergedRanges.length<1?(nodes.push(new _ContentNode2.default({block:block,start:0,end:textArray.length})),nodes):(mergedRanges.forEach(function(range){range.offset>lastIndex&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:range.offset})),nodes.push(new _ContentNode2.default({block:block,entity:range.key,decorator:range.component,decoratorProps:range.decoratorProps,decoratedText:range.component?getString(textArray,range.offset,range.offset+range.length):void 0,start:range.offset,end:range.offset+range.length,contentState:range.contentState})),lastIndex=range.offset+range.length}),lastIndex<textArray.length&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:textArray.length})),nodes)}(entityRanges,decoratorRanges,this.textArray,block).map(function(node){return _this2.nodeIterator(node,node.start,node.end)});return new _ContentNode2.default({block:block,content:parsedNodes})}}]),RawParser}();exports.default=RawParser});unwrapExports(RawParser_1);var createStyleRenderer_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(wrapper,stylesMap){return function(children,styleArray,params){var style=function(styleArray,stylesMap){return styleArray.map(function(style){return stylesMap[style]}).reduce(function(prev,next){var mergedStyles={};if(void 0!==next){var key="text-decoration"in next?"text-decoration":"textDecoration";next[key]!==prev[key]&&(mergedStyles[key]=[prev[key],next[key]].join(" ").trim())}return Object.assign(prev,next,mergedStyles)},{})}(styleArray,stylesMap);return wrapper(Object.assign({},{children:children},params,{style:style}))}}});unwrapExports(createStyleRenderer_1);var warn_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(msg){"production"!==process.env.NODE_ENV&&console.warn("Redraft: "+msg)}});unwrapExports(warn_1);var checkCleanup_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(block,prevType,_ref2){var cleanup=_ref2.cleanup;return!(!cleanup||function(block,options){return text=block.text,!(options.trim?!text.trim():!text)||!(!block.data||!Object.keys(block.data).length)||!(!block.entityRanges||!block.entityRanges.length);var text}(block,cleanup)||cleanup.after&&"all"!==cleanup.after&&-1===cleanup.after.indexOf(prevType)||(!cleanup.except||-1!==cleanup.except.indexOf(block.type))&&(!cleanup.types||"all"!==cleanup.types&&-1===cleanup.types.indexOf(block.type)))}});unwrapExports(checkCleanup_1);var getKeyGenerator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(){var key=0;return function(){var current=key;return key+=1,current}}});unwrapExports(getKeyGenerator_1);var checkJoin_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(input,options){return Array.isArray(input)&&options.joinOutput?input.join(""):input}});unwrapExports(checkJoin_1);var pushString_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(string,array,index){var tempArray=array;return array[index]?tempArray[index]+=string:tempArray[index]=string,tempArray}});unwrapExports(pushString_1);var defaultOptions_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default={joinOutput:!1,cleanup:{after:["atomic"],types:["unstyled"],trim:!1,split:!0}}});unwrapExports(defaultOptions_1);var CompositeDecorator=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var CompositeDraftDecorator=function(){function CompositeDraftDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,CompositeDraftDecorator),this.decorators=decorators.slice()}return _createClass(CompositeDraftDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,ii){var counter=0;(0,decorator.strategy)(block,function(start,end){(function(decorations,start,end){for(var ii=start;ii<end;ii++)if(null!=decorations[ii])return!1;return!0})(decorations,start,end)&&(function(targetArr,start,end,componentKey){for(var ii=start;ii<end;ii++)targetArr[ii]=componentKey}(decorations,start,end,ii+"."+counter),counter++)},contentState)}),decorations}},{key:"getComponentForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].component}},{key:"getPropsForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].props}}]),CompositeDraftDecorator}();exports.default=CompositeDraftDecorator});unwrapExports(CompositeDecorator);var MultiDecorator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var MultiDecorator=function(){function MultiDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,MultiDecorator),this.decorators=decorators}return _createClass(MultiDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=new Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,i){decorator.getDecorations(block,contentState).forEach(function(key,offset){key&&(decorations[offset]=i+"-"+key)})}),decorations}},{key:"getComponentForKey",value:function(key){return this.getDecoratorForKey(key).getComponentForKey(MultiDecorator.getInnerKey(key))}},{key:"getPropsForKey",value:function(key){return this.getDecoratorForKey(key).getPropsForKey(MultiDecorator.getInnerKey(key))}},{key:"getDecoratorForKey",value:function(key){var parts=key.split("-"),index=Number(parts[0]);return this.decorators[index]}}],[{key:"getInnerKey",value:function(key){return key.split("-").slice(1).join("-")}}]),MultiDecorator}();exports.default=MultiDecorator});unwrapExports(MultiDecorator_1);var stubContentBlock_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var ContentBlockStub=function(){function ContentBlockStub(block){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentBlockStub),Object.assign(this,block)}return _createClass(ContentBlockStub,[{key:"get",value:function(name){return this[name]}},{key:"getText",value:function(){return this.text}},{key:"getType",value:function(){return this.type}},{key:"getKey",value:function(){return this.key}},{key:"getLength",value:function(){return this.text.length}},{key:"getDepth",value:function(){return this.depth}},{key:"getData",value:function(){return this.data}}]),ContentBlockStub}();exports.default=function(block){return new ContentBlockStub(block)}});unwrapExports(stubContentBlock_1);var withDecorators_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _CompositeDecorator2=_interopRequireDefault(CompositeDecorator),_MultiDecorator2=_interopRequireDefault(MultiDecorator_1),_stubContentBlock2=_interopRequireDefault(stubContentBlock_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var decoratorIsCustom=function(decorator){return"function"==typeof decorator.getDecorations&&"function"==typeof decorator.getComponentForKey&&"function"==typeof decorator.getPropsForKey},resolveDecorators=function(decorators){var compositeDecorator=new _CompositeDecorator2.default(decorators.filter(function(decorator){return!decoratorIsCustom(decorator)})),customDecorators=decorators.filter(function(decorator){return decoratorIsCustom(decorator)}),decor=[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(customDecorators),[compositeDecorator]);return new _MultiDecorator2.default(decor)};exports.default=function(raw,decorators,options){var contentState=options.convertFromRaw&&options.convertFromRaw(raw);return raw.blocks.map(function(block){return function(block,decorators,contentState,_ref){var createContentBlock=_ref.createContentBlock,decoratorRanges=[],decorator=resolveDecorators(decorators),contentBlock=createContentBlock?createContentBlock(block):(0,_stubContentBlock2.default)(block),decorations=decorator.getDecorations(contentBlock,contentState),offset=0;return decorations.forEach(function(key,index){if(key){var nextIndex=index+1,next=decorations[nextIndex];next&&next===key||(decoratorRanges.push({offset:offset,length:nextIndex-offset,component:decorator.getComponentForKey(key),decoratorProps:decorator.getPropsForKey(key)||{},contentState:contentState}),offset=nextIndex)}else offset+=1}),Object.assign({},block,{decoratorRanges:decoratorRanges})}(block,decorators,contentState,options||{})})}});unwrapExports(withDecorators_1);var render_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.render=exports.renderNode=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_warn2=_interopRequireDefault(warn_1),_checkCleanup2=_interopRequireDefault(checkCleanup_1),_getKeyGenerator2=_interopRequireDefault(getKeyGenerator_1),_checkJoin2=_interopRequireDefault(checkJoin_1),_pushString2=_interopRequireDefault(pushString_1),_defaultOptions2=_interopRequireDefault(defaultOptions_1),_withDecorators2=_interopRequireDefault(withDecorators_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var renderNode=exports.renderNode=function renderNode(node,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator){if(node.styles&&styleRenderers)return styleRenderers((0,_checkJoin2.default)(node.content,options),node.styles,{key:keyGenerator()});var children=[],index=0;if(node.content.forEach(function(part){"string"==typeof part?children=(0,_pushString2.default)(part,children,index):(children[index+=1]=renderNode(part,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator),index+=1)}),node.style&&inlineRenderers[node.style])return inlineRenderers[node.style]((0,_checkJoin2.default)(children,options),{key:keyGenerator()});if(null!==node.entity){var entity=entityMap[node.entity];if(entity&&entityRenderers[entity.type])return entityRenderers[entity.type]((0,_checkJoin2.default)(children,options),entity.data,{key:node.entity})}if(null!==node.decorator){var decoratorOffsetKey=[node.block.key,node.start,0].join(".");return node.decorator(Object.assign({children:(0,_checkJoin2.default)(children,options),decoratedText:node.decoratedText,contentState:node.contentState,entityKey:node.entity,offsetKey:decoratorOffsetKey,key:decoratorOffsetKey},node.decoratorProps))}return children},renderGroup=function(group,blockRenderers,rendered,params){var type=params.prevType,depth=params.prevDepth,keys=params.prevKeys,data=params.prevData;0!==group.length&&(blockRenderers[type]?rendered.push(blockRenderers[type](group,{depth:depth,keys:keys,data:data})):rendered.push(group))};exports.render=function(raw){var renderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!raw||!Array.isArray(raw.blocks))return(0,_warn2.default)("invalid raw object"),null;if(!raw.blocks.length)return null;var inlineRenderers=renderers.inline,blockRenderers=renderers.blocks,entityRenderers=renderers.entities,stylesRenderer=renderers.styles,decorators=renderers.decorators;return function renderBlocks(blocks){var inlineRenderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},blockRenderers=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},entityRenderers=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},stylesRenderer=arguments[4],entityMap=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},userOptions=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},options=Object.assign({},_defaultOptions2.default,userOptions),rendered=[],group=[],prevType=null,prevDepth=0,prevKeys=[],prevData=[],splitGroup=!1,Parser=new _RawParser2.default({flat:!!stylesRenderer});return blocks.forEach(function(block){if((0,_checkCleanup2.default)(block,prevType,options))!0===options.cleanup.split&&(splitGroup=!0);else{var node=Parser.parse(block),renderedNode=renderNode(node,inlineRenderers,entityRenderers,stylesRenderer,entityMap,options,(0,_getKeyGenerator2.default)());if((prevType&&prevType!==block.type||splitGroup)&&(renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),prevData=[],prevKeys=[],group=[],splitGroup=!1),block.children){var children=renderBlocks(block.children,inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,entityMap,options);renderedNode.push(children)}group.push(renderedNode),prevType=block.type,prevDepth=block.depth,prevKeys.push(block.key),prevData.push(block.data)}}),renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),(0,_checkJoin2.default)(rendered,options)}(function(blocks){var group=[],depthStack=[],prevDepth=0,unwind=function(targetDepth){var i=prevDepth-targetDepth;for(depthStack.length<i&&(i=depthStack.length);i>0;i-=1){var tmp=group;(group=depthStack.pop())[group.length-1].children=tmp}};return blocks.forEach(function(block){prevDepth<block.depth?(depthStack.push(group),group=[]):prevDepth>block.depth&&unwind(block.depth),prevDepth=block.depth,group.push(block)}),0!==prevDepth&&unwind(0),group}(decorators?(0,_withDecorators2.default)(raw,decorators,options):raw.blocks),inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,raw.entityMap,options)}});unwrapExports(render_1);var render_2=render_1.render,render_3=render_1.renderNode,lib=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompositeDecorator=exports.renderNode=exports.RawParser=exports.createStylesRenderer=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_createStyleRenderer2=_interopRequireDefault(createStyleRenderer_1),_CompositeDecorator2=_interopRequireDefault(CompositeDecorator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.createStylesRenderer=_createStyleRenderer2.default,exports.RawParser=_RawParser2.default,exports.renderNode=render_1.renderNode,exports.CompositeDecorator=_CompositeDecorator2.default,exports.default=render_1.render}),redraft=unwrapExports(lib),lib_1=lib.CompositeDecorator,lib_2=lib.renderNode,lib_3=lib.RawParser,lib_4=lib.createStylesRenderer,renderLink=function(componentData,anchorTarget,relValue){if(componentData.config&&componentData.config.link){var _componentData$config=componentData.config.link,url=_componentData$config.url,target=_componentData$config.target,rel=_componentData$config.rel;return React.createElement("a",{target:target||anchorTarget||"_self",rel:rel||relValue||"noopener",href:normalizeUrl(url),className:styles.anchor})}return null},AtomicBlock=function(_ref){var type=_ref.type,typeMap=_ref.typeMap,componentData=_ref.componentData,children=_ref.children,theme=_ref.theme,isMobile=_ref.isMobile,anchorTarget=_ref.anchorTarget,relValue=_ref.relValue,props=_objectWithoutPropertiesLoose(_ref,["type","typeMap","componentData","children","theme","isMobile","anchorTarget","relValue"]),mergedStyles=mergeStyles({theme:theme,styles:styles}),_typeMap$type=typeMap[type],Component$$1=_typeMap$type.component,elementType=_typeMap$type.elementType,_ref2=typeMap[type].classNameStrategies||{},size=_ref2.size,alignment=_ref2.alignment,textWrap=_ref2.textWrap,container=_ref2.container;if(Component$$1){if("inline"!==elementType){var _classNames,containerClassNames=classNames(mergedStyles.pluginContainerReadOnly,((_classNames={})[mergedStyles.pluginContainerMobile]=isMobile,_classNames),isFunction(alignment)?alignment(componentData,theme,styles,isMobile):alignmentClassName(componentData,theme,styles,isMobile),isFunction(size)?size(componentData,theme,styles,isMobile):sizeClassName(componentData,theme,styles,isMobile),isFunction(textWrap)?textWrap(componentData,theme,styles,isMobile):textWrapClassName(componentData,theme,styles,isMobile));return React.createElement("div",{className:containerClassNames},isFunction(container)?React.createElement("div",{className:container(theme)},React.createElement(Component$$1,_extends({componentData:componentData,theme:theme},props),children)):React.createElement(Component$$1,_extends({componentData:componentData,theme:theme},props),children),renderLink(componentData,anchorTarget,relValue))}return React.createElement(Component$$1,_extends({componentData:componentData,theme:theme},props)," ",children," ")}return null};AtomicBlock.propTypes={type:PropTypes.string.isRequired,componentData:PropTypes.object.isRequired,typeMap:PropTypes.object,children:PropTypes.node,theme:PropTypes.object,isMobile:PropTypes.bool,anchorTarget:PropTypes.string,relValue:PropTypes.string};var getPluginsViewer=function(typeMap,pluginProps){var res={};return Object.keys(typeMap).forEach(function(type){res[type]=function(children,entity,_ref3){var key=_ref3.key;return React.createElement(AtomicBlock,_extends({typeMap:typeMap,type:type,key:key,componentData:entity},pluginProps),children)}}),res},List=function(_ref){var ordered=_ref.ordered,children=_ref.children;return ordered?React.createElement("ol",null,children):React.createElement("ul",null,children)};List.propTypes={ordered:PropTypes.bool,children:PropTypes.node.isRequired};var getStrategyByStyle=function(style){return function(contentBlock,callback){contentBlock&&contentBlock.inlineStyleRanges&&contentBlock.inlineStyleRanges.filter(function(range){return range.style===style}).forEach(function(_ref){var offset=_ref.offset,length=_ref.length;return callback(offset,offset+length)})}},withTextAlignment=function(element,blockProps,mergedStyles){var data=(blockProps||[]).data,dataEntry=data.length>0?data[0]:{},alignmentClass=dataEntry.textAlignment?dataEntry.textAlignment:"left",elementProps=_extends({},element.props,{className:element.props.className?classNames(element.props.className,mergedStyles[alignmentClass]):mergedStyles[alignmentClass]});return React.cloneElement(element,elementProps,element.props.children)},getInline=function(mergedStyles){return{BOLD:function(children,_ref2){var key=_ref2.key;return React.createElement("strong",{key:key},children)},ITALIC:function(children,_ref3){var key=_ref3.key;return React.createElement("em",{key:key},children)},UNDERLINE:function(children,_ref4){var key=_ref4.key;return React.createElement("u",{key:key},children)},CODE:function(children,_ref5){var key=_ref5.key;return React.createElement("span",{key:key,className:mergedStyles.code},children)}}},getList=function(ordered,mergedStyles){return function(children,blockProps){var fixedChildren=children.map(function(child){return child.length?child:[" "]}),className=ordered?"ordered":"unordered";return React.createElement(List,{key:blockProps.keys[0],keys:blockProps.keys,depth:blockProps.depth,ordered:ordered},fixedChildren.map(function(child,i){var dataEntry=blockProps.data.length>i?[blockProps.data[i]]:[{}];return withTextAlignment(React.createElement("li",{className:mergedStyles[className+"List"],key:blockProps.keys[i]},React.createElement("div",null,child)),_extends({},blockProps,{data:dataEntry}),mergedStyles)}))}},getBlocks=function(mergedStyles){return{unstyled:function(children,blockProps){return withTextAlignment(React.createElement("p",{key:blockProps.keys[0]},React.createElement("div",null,children)),blockProps,mergedStyles)},blockquote:function(children,blockProps){return withTextAlignment(React.createElement("blockquote",{className:mergedStyles.quote,key:blockProps.keys[0]},React.createElement("div",null,children)),blockProps,mergedStyles)},"header-two":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React.createElement("h2",{className:mergedStyles.headerTwo,key:blockProps.keys[i]},child),blockProps,mergedStyles)})},"header-three":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React.createElement("h3",{className:mergedStyles.headerThree,key:blockProps.keys[i]},child),blockProps,mergedStyles)})},"code-block":function(children,blockProps){return withTextAlignment(React.createElement("pre",{key:blockProps.keys[0],className:mergedStyles.codeBlock},children),blockProps,mergedStyles)},"unordered-list-item":getList(!1,mergedStyles),"ordered-list-item":getList(!0,mergedStyles)}},getEntities=function(typeMap,pluginProps){return _extends({},getPluginsViewer(typeMap,pluginProps))},combineTypeMappers=function(mappers){return mappers&&mappers.length&&!mappers.some(function(resolver){return"function"!=typeof resolver})?mappers.reduce(function(map,mapper){return Object.assign(map,mapper())},{}):(console.error("typeMappers is expected to be a function array"),{})},isEmptyRaw=function(raw){return!raw||!raw.blocks||1===raw.blocks.length&&""===raw.blocks[0].text},options={cleanup:{after:"all",types:"all",split:!0}},Preview=function(_ref6){var raw=_ref6.raw,typeMappers=_ref6.typeMappers,theme=_ref6.theme,isMobile=_ref6.isMobile,decorators=_ref6.decorators,anchorTarget=_ref6.anchorTarget,relValue=_ref6.relValue,mergedStyles=mergeStyles({styles:styles,theme:theme}),isEmpty=isEmptyRaw(raw),typeMap=combineTypeMappers(typeMappers),combinedDecorators=decorators.concat(createInlineStyleDecorators(getStrategyByStyle,mergedStyles));return React.createElement("div",{className:mergedStyles.preview},isEmpty&&React.createElement("div",null,"There is nothing to render..."),!isEmpty&&redraft(raw,{inline:getInline(mergedStyles),blocks:getBlocks(mergedStyles),entities:getEntities(typeMap,{theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue}),decorators:combinedDecorators},options))};Preview.propTypes={raw:PropTypes.shape({blocks:PropTypes.array.isRequired,entityMap:PropTypes.object.isRequired}).isRequired,typeMappers:PropTypes.arrayOf(PropTypes.func),theme:PropTypes.object,isMobile:PropTypes.bool,decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),anchorTarget:PropTypes.string,relValue:PropTypes.string};var RichContentViewer=function(_Component){function RichContentViewer(props){var _this;return(_this=_Component.call(this,props)||this).getInitialState=function(initialState){return initialState?normalizeInitialState(initialState,{anchorTarget:_this.props.anchorTarget,relValue:_this.props.relValue}):{}},_this.state={raw:_this.getInitialState(props.initialState)},_this.styles=mergeStyles({styles:styles,theme:props.theme}),_this}_inheritsLoose(RichContentViewer,_Component);var _proto=RichContentViewer.prototype;return _proto.componentWillReceiveProps=function(nextProps){this.props.initialState!==nextProps.initialState&&this.setState({raw:this.getInitialState(nextProps.initialState)})},_proto.render=function(){var _classNames,styles$$1=this.styles,_this$props=this.props,theme=_this$props.theme,isMobile=_this$props.isMobile,typeMappers=_this$props.typeMappers,decorators=_this$props.decorators,anchorTarget=_this$props.anchorTarget,relValue=_this$props.relValue,wrapperClassName=classNames(styles$$1.wrapper,((_classNames={})[styles$$1.desktop]=!this.props.platform||"desktop"===this.props.platform,_classNames));return React.createElement("div",{className:wrapperClassName},React.createElement("div",{className:styles$$1.editor},React.createElement(Preview,{raw:this.state.raw,decorators:decorators,typeMappers:typeMappers,theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue})),React.createElement(AccessibilityListener,{isMobile:isMobile}))},RichContentViewer}(Component);RichContentViewer.propTypes={initialState:PropTypes.object,isMobile:PropTypes.bool,helpers:PropTypes.object,platform:PropTypes.string,typeMappers:PropTypes.arrayOf(PropTypes.func),decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),theme:PropTypes.object,anchorTarget:PropTypes.string,relValue:PropTypes.string},RichContentViewer.defaultProps={theme:{},decorators:[],typeMappers:[]};export{RichContentViewer}; | ||
import _extends from"@babel/runtime/helpers/extends";import _objectWithoutPropertiesLoose from"@babel/runtime/helpers/objectWithoutPropertiesLoose";import React,{Component}from"react";import PropTypes from"prop-types";import classNames from"classnames";import isFunction from"lodash/isFunction";import{sizeClassName,alignmentClassName,textWrapClassName,mergeStyles,normalizeUrl,createInlineStyleDecorators,AccessibilityListener,normalizeInitialState}from"wix-rich-content-common";import _inheritsLoose from"@babel/runtime/helpers/inheritsLoose";var styles={fontElementMap:"rich-content-viewer_fontElementMap__2536P",pluginContainerReadOnly:"rich-content-viewer_pluginContainerReadOnly__2CvYQ",pluginContainer:"rich-content-viewer_pluginContainer__1sQKR",panelContainer:"rich-content-viewer_panelContainer__1iKfr",wrapper:"rich-content-viewer_wrapper__kcuBq",flex:"rich-content-viewer_flex__32v4L",focused:"rich-content-viewer_focused__2QANw",noOutline:"rich-content-viewer_noOutline__rG7tY",visuallyHidden:"rich-content-viewer_visuallyHidden__1BlbC",hasFocus:"rich-content-viewer_hasFocus__3xWzX",overlay:"rich-content-viewer_overlay__32lvd",hidden:"rich-content-viewer_hidden__2hq23",pluginContainerMobile:"rich-content-viewer_pluginContainerMobile__13mNb",alignLeft:"rich-content-viewer_alignLeft__2k0o0",textWrapNowrap:"rich-content-viewer_textWrapNowrap__3MdB6",alignCenter:"rich-content-viewer_alignCenter__Slk8p",alignRight:"rich-content-viewer_alignRight__1MOUB",sizeFullWidth:"rich-content-viewer_sizeFullWidth__3ciQ2",sizeContent:"rich-content-viewer_sizeContent__1hD8w",sizeSmall:"rich-content-viewer_sizeSmall__3Q43X",sizeSmallCenter:"rich-content-viewer_sizeSmallCenter__1jZaq",isImage:"rich-content-viewer_isImage__3m3_b",anchor:"rich-content-viewer_anchor__i8Flr",desktop:"rich-content-viewer_desktop__uatYj",editor:"rich-content-viewer_editor__kaqlz",android:"rich-content-viewer_android__18id9",atomic:"rich-content-viewer_atomic__q2uC4",toolbar:"rich-content-viewer_toolbar__3HztD",block:"rich-content-viewer_block__Rhs1S",elementSpacing:"rich-content-viewer_elementSpacing__208Ie",blockStyleSpacing:"rich-content-viewer_blockStyleSpacing__1J-OE",text:"rich-content-viewer_text__XzvDs rich-content-viewer_elementSpacing__208Ie",left:"rich-content-viewer_left__2p1aK",center:"rich-content-viewer_center__ujPQ6",right:"rich-content-viewer_right__2KAc8",justify:"rich-content-viewer_justify__1iXso",quote:"rich-content-viewer_quote__3jY04 rich-content-viewer_blockStyleSpacing__1J-OE",headerOne:"rich-content-viewer_headerOne__1EKGD rich-content-viewer_elementSpacing__208Ie",headerTwo:"rich-content-viewer_headerTwo__3f-vr rich-content-viewer_elementSpacing__208Ie",headerThree:"rich-content-viewer_headerThree__3tkn1 rich-content-viewer_elementSpacing__208Ie",indent:"rich-content-viewer_indent__2RESO rich-content-viewer_elementSpacing__208Ie",orderedList:"rich-content-viewer_orderedList__3_0WU rich-content-viewer_elementSpacing__208Ie",unorderedList:"rich-content-viewer_unorderedList__1BJwx rich-content-viewer_elementSpacing__208Ie",code:"rich-content-viewer_code__sEtbn rich-content-viewer_blockStyleSpacing__1J-OE",codeBlock:"rich-content-viewer_codeBlock__3I8mR rich-content-viewer_blockStyleSpacing__1J-OE",normalText:"rich-content-viewer_normalText__1b-JN",preview:"rich-content-viewer_preview__1ppsP"};function unwrapExports(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";return parts.length>1&&(result=parts[0]+"@",string=parts[1]),result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter<length;)(value=string.charCodeAt(counter++))>=55296&&value<=56319&&counter<length?56320==(64512&(extra=string.charCodeAt(counter++)))?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return value>65535&&(output+=stringFromCharCode((value-=65536)>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function basicToDigit(codePoint){return codePoint-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;index>=inputLength&&error("invalid-input"),((digit=basicToDigit(input.charCodeAt(index++)))>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,!(digit<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)w>floor(maxInt/(baseMinusT=base-t))&&error("overflow"),w*=baseMinusT;bias=adapt(i-oldi,out=output.length+1,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(inputLength=(input=ucs2decode(input)).length,n=initialN,delta=0,bias=initialBias,j=0;j<inputLength;++j)(currentValue=input[j])<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)(currentValue=input[j])>=n&¤tValue<m&&(m=currentValue);for(m-n>floor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if((currentValue=input[j])<n&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;!(q<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}var version="1.4.1",ucs2={decode:ucs2decode,encode:ucs2encode},punycode={version:version,ucs2:ucs2,toASCII:toASCII,toUnicode:toUnicode,encode:encode,decode:decode},punycode$1=Object.freeze({decode:decode,encode:encode,toUnicode:toUnicode,toASCII:toASCII,version:version,ucs2:ucs2,default:punycode}),arrayEqual=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(arr1,arr2){if(arr1.length!==arr2.length)return!1;for(var i=0;i++;i<arr1.length)if(arr1[i]!==arr2[i])return!1;return!0}});unwrapExports(arrayEqual);var ContentNode_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var obj,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_arrayEqual2=(obj=arrayEqual)&&obj.__esModule?obj:{default:obj};var ContentNode=function(){function ContentNode(props){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentNode),this.content=props.content||[],this.start=void 0!==props.start?props.start:null,this.end=void 0!==props.end?props.end:null,this.entity=void 0!==props.entity?props.entity:null,this.decorator=void 0!==props.decorator?props.decorator:null,this.decoratorProps=props.decoratorProps||null,this.decoratedText=void 0!==props.decoratedText?props.decoratedText:null,this.contentState=props.contentState,this.style=props.style||null,this.styles=props.styles||null,this.block=props.block||{}}return _createClass(ContentNode,[{key:"getCurrentContent",value:function(){return this.content[this.content.length-1]}},{key:"addToCurrentContent",value:function(string){this.content[this.content.length-1]=this.content[this.content.length-1]+string}},{key:"handleFlatPush",value:function(string,stack){var current=this.getCurrentContent();if(current instanceof ContentNode&&(0,_arrayEqual2.default)(stack,current.styles))current.addToCurrentContent(string);else{var newNode=new ContentNode({styles:[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(stack)),content:[string]});this.content.push(newNode)}}},{key:"pushContent",value:function(string){var stack=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],flat=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!stack||stack.length<1)return"string"==typeof string&&"string"==typeof this.getCurrentContent()?this.addToCurrentContent(string):this.content.push(string),this;if(flat)return this.handleFlatPush(string,stack),this;var arr,_stack=(arr=stack,Array.isArray(arr)?arr:Array.from(arr)),head=_stack[0],rest=_stack.slice(1),current=this.getCurrentContent();if(current instanceof ContentNode&¤t.style===head)current.pushContent(string,rest,flat);else{var newNode=new ContentNode({style:head});newNode.pushContent(string,rest,flat),this.content.push(newNode)}return this}}]),ContentNode}();exports.default=ContentNode});unwrapExports(ContentNode_1);var _punycode=punycode$1&&punycode||punycode$1,RawParser_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_punycode2=_interopRequireDefault(_punycode),_ContentNode2=_interopRequireDefault(ContentNode_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}var getString=function(array,from,to){return _punycode2.default.ucs2.encode(array.slice(from,to))};function addIndexes(indexes,ranges){return ranges.forEach(function(range){indexes.push(range.offset),indexes.push(range.offset+range.length)}),indexes}var RawParser=function(){function RawParser(_ref){var _ref$flat=_ref.flat,flat=void 0!==_ref$flat&&_ref$flat;!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,RawParser),this.flat=flat}return _createClass(RawParser,[{key:"relevantStyles",value:function(offset){return this.ranges.filter(function(range){return offset>=range.offset&&offset<range.offset+range.length}).map(function(style){return style.style})}},{key:"nodeIterator",value:function(node,start,end){var _this=this,indexes=this.relevantIndexes.slice(this.relevantIndexes.indexOf(start),this.relevantIndexes.indexOf(end));return indexes.forEach(function(index,key){var characterStyles=_this.relevantStyles(index),distance=indexes[key+1]?indexes[key+1]-index:1,text=getString(_this.textArray,index,index+distance);node.pushContent(text,characterStyles,_this.flat),!indexes[key+1]&&index<end&&node.pushContent(getString(_this.textArray,index+1,end),_this.relevantStyles(end-1),_this.flat)}),node}},{key:"parse",value:function(block){var _this2=this,text=block.text,ranges=block.inlineStyleRanges,entityRanges=block.entityRanges,_block$decoratorRange=block.decoratorRanges,decoratorRanges=void 0===_block$decoratorRange?[]:_block$decoratorRange;this.textArray=_punycode2.default.ucs2.decode(text),this.ranges=ranges,this.iterator=0,this.relevantIndexes=function(text,inlineRanges){var entityRanges=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],decoratorRanges=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],relevantIndexes=[];return relevantIndexes=addIndexes(relevantIndexes,inlineRanges),relevantIndexes=addIndexes(relevantIndexes,entityRanges),(relevantIndexes=addIndexes(relevantIndexes,decoratorRanges)).push(0),relevantIndexes.push(text.length),relevantIndexes.filter(function(value,index,self){return self.indexOf(value)===index}).sort(function(aa,bb){return aa-bb})}(text,ranges,entityRanges,decoratorRanges);var parsedNodes=function(entityRanges){var decoratorRanges=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],textArray=arguments[2],block=arguments[3],lastIndex=0,mergedRanges=[].concat(_toConsumableArray(entityRanges),_toConsumableArray(decoratorRanges)).sort(function(a,b){return a.offset-b.offset}),nodes=[];return mergedRanges.length<1?(nodes.push(new _ContentNode2.default({block:block,start:0,end:textArray.length})),nodes):(mergedRanges.forEach(function(range){range.offset>lastIndex&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:range.offset})),nodes.push(new _ContentNode2.default({block:block,entity:range.key,decorator:range.component,decoratorProps:range.decoratorProps,decoratedText:range.component?getString(textArray,range.offset,range.offset+range.length):void 0,start:range.offset,end:range.offset+range.length,contentState:range.contentState})),lastIndex=range.offset+range.length}),lastIndex<textArray.length&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:textArray.length})),nodes)}(entityRanges,decoratorRanges,this.textArray,block).map(function(node){return _this2.nodeIterator(node,node.start,node.end)});return new _ContentNode2.default({block:block,content:parsedNodes})}}]),RawParser}();exports.default=RawParser});unwrapExports(RawParser_1);var createStyleRenderer_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(wrapper,stylesMap){return function(children,styleArray,params){var style=function(styleArray,stylesMap){return styleArray.map(function(style){return stylesMap[style]}).reduce(function(prev,next){var mergedStyles={};if(void 0!==next){var key="text-decoration"in next?"text-decoration":"textDecoration";next[key]!==prev[key]&&(mergedStyles[key]=[prev[key],next[key]].join(" ").trim())}return Object.assign(prev,next,mergedStyles)},{})}(styleArray,stylesMap);return wrapper(Object.assign({},{children:children},params,{style:style}))}}});unwrapExports(createStyleRenderer_1);var warn_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(msg){"production"!==process.env.NODE_ENV&&console.warn("Redraft: "+msg)}});unwrapExports(warn_1);var checkCleanup_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(block,prevType,_ref2){var cleanup=_ref2.cleanup;return!(!cleanup||function(block,options){return text=block.text,!(options.trim?!text.trim():!text)||!(!block.data||!Object.keys(block.data).length)||!(!block.entityRanges||!block.entityRanges.length);var text}(block,cleanup)||cleanup.after&&"all"!==cleanup.after&&-1===cleanup.after.indexOf(prevType)||(!cleanup.except||-1!==cleanup.except.indexOf(block.type))&&(!cleanup.types||"all"!==cleanup.types&&-1===cleanup.types.indexOf(block.type)))}});unwrapExports(checkCleanup_1);var getKeyGenerator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(){var key=0;return function(){var current=key;return key+=1,current}}});unwrapExports(getKeyGenerator_1);var checkJoin_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(input,options){return Array.isArray(input)&&options.joinOutput?input.join(""):input}});unwrapExports(checkJoin_1);var pushString_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(string,array,index){var tempArray=array;return array[index]?tempArray[index]+=string:tempArray[index]=string,tempArray}});unwrapExports(pushString_1);var defaultOptions_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default={joinOutput:!1,cleanup:{after:["atomic"],types:["unstyled"],trim:!1,split:!0}}});unwrapExports(defaultOptions_1);var CompositeDecorator=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var CompositeDraftDecorator=function(){function CompositeDraftDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,CompositeDraftDecorator),this.decorators=decorators.slice()}return _createClass(CompositeDraftDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,ii){var counter=0;(0,decorator.strategy)(block,function(start,end){(function(decorations,start,end){for(var ii=start;ii<end;ii++)if(null!=decorations[ii])return!1;return!0})(decorations,start,end)&&(function(targetArr,start,end,componentKey){for(var ii=start;ii<end;ii++)targetArr[ii]=componentKey}(decorations,start,end,ii+"."+counter),counter++)},contentState)}),decorations}},{key:"getComponentForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].component}},{key:"getPropsForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].props}}]),CompositeDraftDecorator}();exports.default=CompositeDraftDecorator});unwrapExports(CompositeDecorator);var MultiDecorator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var MultiDecorator=function(){function MultiDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,MultiDecorator),this.decorators=decorators}return _createClass(MultiDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=new Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,i){decorator.getDecorations(block,contentState).forEach(function(key,offset){key&&(decorations[offset]=i+"-"+key)})}),decorations}},{key:"getComponentForKey",value:function(key){return this.getDecoratorForKey(key).getComponentForKey(MultiDecorator.getInnerKey(key))}},{key:"getPropsForKey",value:function(key){return this.getDecoratorForKey(key).getPropsForKey(MultiDecorator.getInnerKey(key))}},{key:"getDecoratorForKey",value:function(key){var parts=key.split("-"),index=Number(parts[0]);return this.decorators[index]}}],[{key:"getInnerKey",value:function(key){return key.split("-").slice(1).join("-")}}]),MultiDecorator}();exports.default=MultiDecorator});unwrapExports(MultiDecorator_1);var stubContentBlock_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var ContentBlockStub=function(){function ContentBlockStub(block){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentBlockStub),Object.assign(this,block)}return _createClass(ContentBlockStub,[{key:"get",value:function(name){return this[name]}},{key:"getText",value:function(){return this.text}},{key:"getType",value:function(){return this.type}},{key:"getKey",value:function(){return this.key}},{key:"getLength",value:function(){return this.text.length}},{key:"getDepth",value:function(){return this.depth}},{key:"getData",value:function(){return this.data}}]),ContentBlockStub}();exports.default=function(block){return new ContentBlockStub(block)}});unwrapExports(stubContentBlock_1);var withDecorators_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _CompositeDecorator2=_interopRequireDefault(CompositeDecorator),_MultiDecorator2=_interopRequireDefault(MultiDecorator_1),_stubContentBlock2=_interopRequireDefault(stubContentBlock_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var decoratorIsCustom=function(decorator){return"function"==typeof decorator.getDecorations&&"function"==typeof decorator.getComponentForKey&&"function"==typeof decorator.getPropsForKey},resolveDecorators=function(decorators){var compositeDecorator=new _CompositeDecorator2.default(decorators.filter(function(decorator){return!decoratorIsCustom(decorator)})),customDecorators=decorators.filter(function(decorator){return decoratorIsCustom(decorator)}),decor=[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(customDecorators),[compositeDecorator]);return new _MultiDecorator2.default(decor)};exports.default=function(raw,decorators,options){var contentState=options.convertFromRaw&&options.convertFromRaw(raw);return raw.blocks.map(function(block){return function(block,decorators,contentState,_ref){var createContentBlock=_ref.createContentBlock,decoratorRanges=[],decorator=resolveDecorators(decorators),contentBlock=createContentBlock?createContentBlock(block):(0,_stubContentBlock2.default)(block),decorations=decorator.getDecorations(contentBlock,contentState),offset=0;return decorations.forEach(function(key,index){if(key){var nextIndex=index+1,next=decorations[nextIndex];next&&next===key||(decoratorRanges.push({offset:offset,length:nextIndex-offset,component:decorator.getComponentForKey(key),decoratorProps:decorator.getPropsForKey(key)||{},contentState:contentState}),offset=nextIndex)}else offset+=1}),Object.assign({},block,{decoratorRanges:decoratorRanges})}(block,decorators,contentState,options||{})})}});unwrapExports(withDecorators_1);var render_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.render=exports.renderNode=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_warn2=_interopRequireDefault(warn_1),_checkCleanup2=_interopRequireDefault(checkCleanup_1),_getKeyGenerator2=_interopRequireDefault(getKeyGenerator_1),_checkJoin2=_interopRequireDefault(checkJoin_1),_pushString2=_interopRequireDefault(pushString_1),_defaultOptions2=_interopRequireDefault(defaultOptions_1),_withDecorators2=_interopRequireDefault(withDecorators_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var renderNode=exports.renderNode=function renderNode(node,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator){if(node.styles&&styleRenderers)return styleRenderers((0,_checkJoin2.default)(node.content,options),node.styles,{key:keyGenerator()});var children=[],index=0;if(node.content.forEach(function(part){"string"==typeof part?children=(0,_pushString2.default)(part,children,index):(children[index+=1]=renderNode(part,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator),index+=1)}),node.style&&inlineRenderers[node.style])return inlineRenderers[node.style]((0,_checkJoin2.default)(children,options),{key:keyGenerator()});if(null!==node.entity){var entity=entityMap[node.entity];if(entity&&entityRenderers[entity.type])return entityRenderers[entity.type]((0,_checkJoin2.default)(children,options),entity.data,{key:node.entity})}if(null!==node.decorator){var decoratorOffsetKey=[node.block.key,node.start,0].join(".");return node.decorator(Object.assign({children:(0,_checkJoin2.default)(children,options),decoratedText:node.decoratedText,contentState:node.contentState,entityKey:node.entity,offsetKey:decoratorOffsetKey,key:decoratorOffsetKey},node.decoratorProps))}return children},renderGroup=function(group,blockRenderers,rendered,params){var type=params.prevType,depth=params.prevDepth,keys=params.prevKeys,data=params.prevData;0!==group.length&&(blockRenderers[type]?rendered.push(blockRenderers[type](group,{depth:depth,keys:keys,data:data})):rendered.push(group))};exports.render=function(raw){var renderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!raw||!Array.isArray(raw.blocks))return(0,_warn2.default)("invalid raw object"),null;if(!raw.blocks.length)return null;var inlineRenderers=renderers.inline,blockRenderers=renderers.blocks,entityRenderers=renderers.entities,stylesRenderer=renderers.styles,decorators=renderers.decorators;return function renderBlocks(blocks){var inlineRenderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},blockRenderers=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},entityRenderers=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},stylesRenderer=arguments[4],entityMap=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},userOptions=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},options=Object.assign({},_defaultOptions2.default,userOptions),rendered=[],group=[],prevType=null,prevDepth=0,prevKeys=[],prevData=[],splitGroup=!1,Parser=new _RawParser2.default({flat:!!stylesRenderer});return blocks.forEach(function(block){if((0,_checkCleanup2.default)(block,prevType,options))!0===options.cleanup.split&&(splitGroup=!0);else{var node=Parser.parse(block),renderedNode=renderNode(node,inlineRenderers,entityRenderers,stylesRenderer,entityMap,options,(0,_getKeyGenerator2.default)());if((prevType&&prevType!==block.type||splitGroup)&&(renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),prevData=[],prevKeys=[],group=[],splitGroup=!1),block.children){var children=renderBlocks(block.children,inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,entityMap,options);renderedNode.push(children)}group.push(renderedNode),prevType=block.type,prevDepth=block.depth,prevKeys.push(block.key),prevData.push(block.data)}}),renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),(0,_checkJoin2.default)(rendered,options)}(function(blocks){var group=[],depthStack=[],prevDepth=0,unwind=function(targetDepth){var i=prevDepth-targetDepth;for(depthStack.length<i&&(i=depthStack.length);i>0;i-=1){var tmp=group;(group=depthStack.pop())[group.length-1].children=tmp}};return blocks.forEach(function(block){prevDepth<block.depth?(depthStack.push(group),group=[]):prevDepth>block.depth&&unwind(block.depth),prevDepth=block.depth,group.push(block)}),0!==prevDepth&&unwind(0),group}(decorators?(0,_withDecorators2.default)(raw,decorators,options):raw.blocks),inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,raw.entityMap,options)}});unwrapExports(render_1);var render_2=render_1.render,render_3=render_1.renderNode,lib=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompositeDecorator=exports.renderNode=exports.RawParser=exports.createStylesRenderer=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_createStyleRenderer2=_interopRequireDefault(createStyleRenderer_1),_CompositeDecorator2=_interopRequireDefault(CompositeDecorator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.createStylesRenderer=_createStyleRenderer2.default,exports.RawParser=_RawParser2.default,exports.renderNode=render_1.renderNode,exports.CompositeDecorator=_CompositeDecorator2.default,exports.default=render_1.render}),redraft=unwrapExports(lib),lib_1=lib.CompositeDecorator,lib_2=lib.renderNode,lib_3=lib.RawParser,lib_4=lib.createStylesRenderer,renderLink=function(componentData,anchorTarget,relValue){if(componentData.config&&componentData.config.link){var _componentData$config=componentData.config.link,url=_componentData$config.url,target=_componentData$config.target,rel=_componentData$config.rel;return React.createElement("a",{target:target||anchorTarget||"_self",rel:rel||relValue||"noopener",href:normalizeUrl(url),className:styles.anchor})}return null},AtomicBlock=function(_ref){var type=_ref.type,typeMap=_ref.typeMap,componentData=_ref.componentData,children=_ref.children,theme=_ref.theme,isMobile=_ref.isMobile,anchorTarget=_ref.anchorTarget,relValue=_ref.relValue,config=_ref.config,props=_objectWithoutPropertiesLoose(_ref,["type","typeMap","componentData","children","theme","isMobile","anchorTarget","relValue","config"]),mergedStyles=mergeStyles({theme:theme,styles:styles}),_typeMap$type=typeMap[type],Component$$1=_typeMap$type.component,elementType=_typeMap$type.elementType,_ref2=typeMap[type].classNameStrategies||{},size=_ref2.size,alignment=_ref2.alignment,textWrap=_ref2.textWrap,container=_ref2.container,settings=config&&config[type]||{};if(Component$$1){if("inline"!==elementType){var _classNames,containerClassNames=classNames(mergedStyles.pluginContainerReadOnly,((_classNames={})[mergedStyles.pluginContainerMobile]=isMobile,_classNames),isFunction(alignment)?alignment(componentData,theme,styles,isMobile):alignmentClassName(componentData,theme,styles,isMobile),isFunction(size)?size(componentData,theme,styles,isMobile):sizeClassName(componentData,theme,styles,isMobile),isFunction(textWrap)?textWrap(componentData,theme,styles,isMobile):textWrapClassName(componentData,theme,styles,isMobile));return React.createElement("div",{className:containerClassNames},isFunction(container)?React.createElement("div",{className:container(theme)},React.createElement(Component$$1,_extends({componentData:componentData,theme:theme,settings:settings},props),children)):React.createElement(Component$$1,_extends({componentData:componentData,theme:theme,settings:settings},props),children),renderLink(componentData,anchorTarget,relValue))}return React.createElement(Component$$1,_extends({componentData:componentData,theme:theme,settings:settings},props)," ",children," ")}return null};AtomicBlock.propTypes={type:PropTypes.string.isRequired,componentData:PropTypes.object.isRequired,typeMap:PropTypes.object,children:PropTypes.node,theme:PropTypes.object,isMobile:PropTypes.bool,anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object};var getPluginsViewer=function(typeMap,pluginProps){var res={};return Object.keys(typeMap).forEach(function(type){res[type]=function(children,entity,_ref3){var key=_ref3.key;return React.createElement(AtomicBlock,_extends({typeMap:typeMap,type:type,key:key,componentData:entity},pluginProps),children)}}),res},List=function(_ref){var ordered=_ref.ordered,children=_ref.children;return ordered?React.createElement("ol",null,children):React.createElement("ul",null,children)};List.propTypes={ordered:PropTypes.bool,children:PropTypes.node.isRequired};var getStrategyByStyle=function(style){return function(contentBlock,callback){contentBlock&&contentBlock.inlineStyleRanges&&contentBlock.inlineStyleRanges.filter(function(range){return range.style===style}).forEach(function(_ref){var offset=_ref.offset,length=_ref.length;return callback(offset,offset+length)})}},withTextAlignment=function(element,data,mergedStyles){var alignmentClass=data.textAlignment?data.textAlignment:"left",elementProps=_extends({},element.props,{className:element.props.className?classNames(element.props.className,mergedStyles[alignmentClass]):mergedStyles[alignmentClass]});return React.cloneElement(element,elementProps,element.props.children)},getInline=function(mergedStyles){return{BOLD:function(children,_ref){var key=_ref.key;return React.createElement("strong",{key:key},children)},ITALIC:function(children,_ref2){var key=_ref2.key;return React.createElement("em",{key:key},children)},UNDERLINE:function(children,_ref3){var key=_ref3.key;return React.createElement("u",{key:key},children)},CODE:function(children,_ref4){var key=_ref4.key;return React.createElement("span",{key:key,className:mergedStyles.code},children)}}},getList=function(ordered,mergedStyles){return function(children,blockProps){var fixedChildren=children.map(function(child){return child.length?child:[" "]}),className=ordered?"ordered":"unordered";return React.createElement(List,{key:blockProps.keys[0],keys:blockProps.keys,depth:blockProps.depth,ordered:ordered},fixedChildren.map(function(child,i){var dataEntry=blockProps.data.length>i?blockProps.data[i]:{};return withTextAlignment(React.createElement("li",{className:mergedStyles[className+"List"],key:blockProps.keys[i]},React.createElement("div",null,child)),dataEntry,mergedStyles)}))}},getBlocks=function(mergedStyles){return{unstyled:function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React.createElement("div",{key:blockProps.keys[i]},React.createElement("div",null,child)),blockProps.data[i],mergedStyles)})},blockquote:function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React.createElement("blockquote",{className:mergedStyles.quote,key:blockProps.keys[i]},React.createElement("div",null,child)),blockProps.data[i],mergedStyles)})},"header-two":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React.createElement("h2",{className:mergedStyles.headerTwo,key:blockProps.keys[i]},child),blockProps.data[i],mergedStyles)})},"header-three":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React.createElement("h3",{className:mergedStyles.headerThree,key:blockProps.keys[i]},child),blockProps.data[i],mergedStyles)})},"code-block":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React.createElement("pre",{key:blockProps.keys[i],className:mergedStyles.codeBlock},child),blockProps.data[i],mergedStyles)})},"unordered-list-item":getList(!1,mergedStyles),"ordered-list-item":getList(!0,mergedStyles)}},getEntities=function(typeMap,pluginProps){return _extends({},getPluginsViewer(typeMap,pluginProps))},combineTypeMappers=function(mappers){return mappers&&mappers.length&&!mappers.some(function(resolver){return"function"!=typeof resolver})?mappers.reduce(function(map,mapper){return Object.assign(map,mapper())},{}):(console.warn("typeMappers is expected to be a function array"),{})},isEmptyRaw=function(raw){return!raw||!raw.blocks||1===raw.blocks.length&&""===raw.blocks[0].text},options={cleanup:{after:"all",types:"all",split:!0}},Preview=function(_ref5){var raw=_ref5.raw,typeMappers=_ref5.typeMappers,theme=_ref5.theme,isMobile=_ref5.isMobile,decorators=_ref5.decorators,anchorTarget=_ref5.anchorTarget,relValue=_ref5.relValue,config=_ref5.config,mergedStyles=mergeStyles({styles:styles,theme:theme}),isEmpty=isEmptyRaw(raw),typeMap=combineTypeMappers(typeMappers),combinedDecorators=decorators.concat(createInlineStyleDecorators(getStrategyByStyle,mergedStyles));return React.createElement("div",{className:mergedStyles.preview},isEmpty&&React.createElement("div",null,"There is nothing to render..."),!isEmpty&&redraft(raw,{inline:getInline(mergedStyles),blocks:getBlocks(mergedStyles),entities:getEntities(typeMap,{theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue,config:config}),decorators:combinedDecorators},options))};Preview.propTypes={raw:PropTypes.shape({blocks:PropTypes.array.isRequired,entityMap:PropTypes.object.isRequired}).isRequired,typeMappers:PropTypes.arrayOf(PropTypes.func),theme:PropTypes.object,isMobile:PropTypes.bool,decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object};var RichContentViewer=function(_Component){function RichContentViewer(props){var _this;return(_this=_Component.call(this,props)||this).getInitialState=function(initialState){return initialState?normalizeInitialState(initialState,{anchorTarget:_this.props.anchorTarget,relValue:_this.props.relValue}):{}},_this.state={raw:_this.getInitialState(props.initialState)},_this.styles=mergeStyles({styles:styles,theme:props.theme}),_this}_inheritsLoose(RichContentViewer,_Component);var _proto=RichContentViewer.prototype;return _proto.componentWillReceiveProps=function(nextProps){this.props.initialState!==nextProps.initialState&&this.setState({raw:this.getInitialState(nextProps.initialState)})},_proto.render=function(){var _classNames,styles$$1=this.styles,_this$props=this.props,theme=_this$props.theme,isMobile=_this$props.isMobile,typeMappers=_this$props.typeMappers,decorators=_this$props.decorators,anchorTarget=_this$props.anchorTarget,relValue=_this$props.relValue,config=_this$props.config,wrapperClassName=classNames(styles$$1.wrapper,((_classNames={})[styles$$1.desktop]=!this.props.platform||"desktop"===this.props.platform,_classNames));return React.createElement("div",{className:wrapperClassName},React.createElement("div",{className:styles$$1.editor},React.createElement(Preview,{raw:this.state.raw,decorators:decorators,typeMappers:typeMappers,config:config,theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue})),React.createElement(AccessibilityListener,{isMobile:isMobile}))},RichContentViewer}(Component);RichContentViewer.propTypes={initialState:PropTypes.object,isMobile:PropTypes.bool,helpers:PropTypes.object,platform:PropTypes.string,typeMappers:PropTypes.arrayOf(PropTypes.func),decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),theme:PropTypes.object,anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object},RichContentViewer.defaultProps={theme:{},decorators:[],typeMappers:[]};export{RichContentViewer}; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=module.js.map |
@@ -1,3 +0,3 @@ | ||
var WixRichContentViewer=function(exports,_extends,_objectWithoutPropertiesLoose,React,PropTypes,classNames,isFunction,wixRichContentCommon,_inheritsLoose){"use strict";_extends=_extends&&_extends.hasOwnProperty("default")?_extends.default:_extends,_objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose&&_objectWithoutPropertiesLoose.hasOwnProperty("default")?_objectWithoutPropertiesLoose.default:_objectWithoutPropertiesLoose;var React__default="default"in React?React.default:React;PropTypes=PropTypes&&PropTypes.hasOwnProperty("default")?PropTypes.default:PropTypes,classNames=classNames&&classNames.hasOwnProperty("default")?classNames.default:classNames,isFunction=isFunction&&isFunction.hasOwnProperty("default")?isFunction.default:isFunction,_inheritsLoose=_inheritsLoose&&_inheritsLoose.hasOwnProperty("default")?_inheritsLoose.default:_inheritsLoose;var styles={fontElementMap:"rich-content-viewer_fontElementMap__2536P",pluginContainerReadOnly:"rich-content-viewer_pluginContainerReadOnly__2CvYQ",pluginContainer:"rich-content-viewer_pluginContainer__1sQKR",panelContainer:"rich-content-viewer_panelContainer__1iKfr",wrapper:"rich-content-viewer_wrapper__kcuBq",flex:"rich-content-viewer_flex__32v4L",focused:"rich-content-viewer_focused__2QANw",noOutline:"rich-content-viewer_noOutline__rG7tY",visuallyHidden:"rich-content-viewer_visuallyHidden__1BlbC",hasFocus:"rich-content-viewer_hasFocus__3xWzX",overlay:"rich-content-viewer_overlay__32lvd",hidden:"rich-content-viewer_hidden__2hq23",pluginContainerMobile:"rich-content-viewer_pluginContainerMobile__13mNb",alignLeft:"rich-content-viewer_alignLeft__2k0o0",textWrapNowrap:"rich-content-viewer_textWrapNowrap__3MdB6",alignCenter:"rich-content-viewer_alignCenter__Slk8p",alignRight:"rich-content-viewer_alignRight__1MOUB",sizeFullWidth:"rich-content-viewer_sizeFullWidth__3ciQ2",sizeContent:"rich-content-viewer_sizeContent__1hD8w",sizeSmall:"rich-content-viewer_sizeSmall__3Q43X",sizeSmallCenter:"rich-content-viewer_sizeSmallCenter__1jZaq",isImage:"rich-content-viewer_isImage__3m3_b",anchor:"rich-content-viewer_anchor__i8Flr",desktop:"rich-content-viewer_desktop__uatYj",editor:"rich-content-viewer_editor__kaqlz",android:"rich-content-viewer_android__18id9",atomic:"rich-content-viewer_atomic__q2uC4",toolbar:"rich-content-viewer_toolbar__3HztD",block:"rich-content-viewer_block__Rhs1S",elementSpacing:"rich-content-viewer_elementSpacing__208Ie",blockStyleSpacing:"rich-content-viewer_blockStyleSpacing__1J-OE",text:"rich-content-viewer_text__XzvDs rich-content-viewer_elementSpacing__208Ie",left:"rich-content-viewer_left__2p1aK",center:"rich-content-viewer_center__ujPQ6",right:"rich-content-viewer_right__2KAc8",justify:"rich-content-viewer_justify__1iXso",quote:"rich-content-viewer_quote__3jY04 rich-content-viewer_blockStyleSpacing__1J-OE",headerOne:"rich-content-viewer_headerOne__1EKGD rich-content-viewer_elementSpacing__208Ie",headerTwo:"rich-content-viewer_headerTwo__3f-vr rich-content-viewer_elementSpacing__208Ie",headerThree:"rich-content-viewer_headerThree__3tkn1 rich-content-viewer_elementSpacing__208Ie",indent:"rich-content-viewer_indent__2RESO rich-content-viewer_elementSpacing__208Ie",orderedList:"rich-content-viewer_orderedList__3_0WU rich-content-viewer_elementSpacing__208Ie",unorderedList:"rich-content-viewer_unorderedList__1BJwx rich-content-viewer_elementSpacing__208Ie",code:"rich-content-viewer_code__sEtbn rich-content-viewer_blockStyleSpacing__1J-OE",codeBlock:"rich-content-viewer_codeBlock__3I8mR rich-content-viewer_blockStyleSpacing__1J-OE",normalText:"rich-content-viewer_normalText__1b-JN",preview:"rich-content-viewer_preview__1ppsP"};function unwrapExports(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";return parts.length>1&&(result=parts[0]+"@",string=parts[1]),result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter<length;)(value=string.charCodeAt(counter++))>=55296&&value<=56319&&counter<length?56320==(64512&(extra=string.charCodeAt(counter++)))?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return value>65535&&(output+=stringFromCharCode((value-=65536)>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,codePoint,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;index>=inputLength&&error("invalid-input"),((digit=(codePoint=input.charCodeAt(index++))-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base)>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,!(digit<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)w>floor(maxInt/(baseMinusT=base-t))&&error("overflow"),w*=baseMinusT;bias=adapt(i-oldi,out=output.length+1,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(inputLength=(input=ucs2decode(input)).length,n=initialN,delta=0,bias=initialBias,j=0;j<inputLength;++j)(currentValue=input[j])<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)(currentValue=input[j])>=n&¤tValue<m&&(m=currentValue);for(m-n>floor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if((currentValue=input[j])<n&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;!(q<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}var ucs2={decode:ucs2decode,encode:ucs2encode},punycode={version:"1.4.1",ucs2:ucs2,toASCII:toASCII,toUnicode:toUnicode,encode:encode,decode:decode},punycode$1=Object.freeze({decode:decode,encode:encode,toUnicode:toUnicode,toASCII:toASCII,version:"1.4.1",ucs2:ucs2,default:punycode}),arrayEqual=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(arr1,arr2){if(arr1.length!==arr2.length)return!1;for(var i=0;i++;i<arr1.length)if(arr1[i]!==arr2[i])return!1;return!0}});unwrapExports(arrayEqual);var ContentNode_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var obj,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_arrayEqual2=(obj=arrayEqual)&&obj.__esModule?obj:{default:obj};var ContentNode=function(){function ContentNode(props){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentNode),this.content=props.content||[],this.start=void 0!==props.start?props.start:null,this.end=void 0!==props.end?props.end:null,this.entity=void 0!==props.entity?props.entity:null,this.decorator=void 0!==props.decorator?props.decorator:null,this.decoratorProps=props.decoratorProps||null,this.decoratedText=void 0!==props.decoratedText?props.decoratedText:null,this.contentState=props.contentState,this.style=props.style||null,this.styles=props.styles||null,this.block=props.block||{}}return _createClass(ContentNode,[{key:"getCurrentContent",value:function(){return this.content[this.content.length-1]}},{key:"addToCurrentContent",value:function(string){this.content[this.content.length-1]=this.content[this.content.length-1]+string}},{key:"handleFlatPush",value:function(string,stack){var current=this.getCurrentContent();if(current instanceof ContentNode&&(0,_arrayEqual2.default)(stack,current.styles))current.addToCurrentContent(string);else{var newNode=new ContentNode({styles:[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(stack)),content:[string]});this.content.push(newNode)}}},{key:"pushContent",value:function(string){var stack=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],flat=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!stack||stack.length<1)return"string"==typeof string&&"string"==typeof this.getCurrentContent()?this.addToCurrentContent(string):this.content.push(string),this;if(flat)return this.handleFlatPush(string,stack),this;var arr,_stack=(arr=stack,Array.isArray(arr)?arr:Array.from(arr)),head=_stack[0],rest=_stack.slice(1),current=this.getCurrentContent();if(current instanceof ContentNode&¤t.style===head)current.pushContent(string,rest,flat);else{var newNode=new ContentNode({style:head});newNode.pushContent(string,rest,flat),this.content.push(newNode)}return this}}]),ContentNode}();exports.default=ContentNode});unwrapExports(ContentNode_1);var _punycode=punycode$1&&punycode||punycode$1,RawParser_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_punycode2=_interopRequireDefault(_punycode),_ContentNode2=_interopRequireDefault(ContentNode_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}var getString=function(array,from,to){return _punycode2.default.ucs2.encode(array.slice(from,to))};function addIndexes(indexes,ranges){return ranges.forEach(function(range){indexes.push(range.offset),indexes.push(range.offset+range.length)}),indexes}var RawParser=function(){function RawParser(_ref){var _ref$flat=_ref.flat,flat=void 0!==_ref$flat&&_ref$flat;!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,RawParser),this.flat=flat}return _createClass(RawParser,[{key:"relevantStyles",value:function(offset){return this.ranges.filter(function(range){return offset>=range.offset&&offset<range.offset+range.length}).map(function(style){return style.style})}},{key:"nodeIterator",value:function(node,start,end){var _this=this,indexes=this.relevantIndexes.slice(this.relevantIndexes.indexOf(start),this.relevantIndexes.indexOf(end));return indexes.forEach(function(index,key){var characterStyles=_this.relevantStyles(index),distance=indexes[key+1]?indexes[key+1]-index:1,text=getString(_this.textArray,index,index+distance);node.pushContent(text,characterStyles,_this.flat),!indexes[key+1]&&index<end&&node.pushContent(getString(_this.textArray,index+1,end),_this.relevantStyles(end-1),_this.flat)}),node}},{key:"parse",value:function(block){var _this2=this,text=block.text,ranges=block.inlineStyleRanges,entityRanges=block.entityRanges,_block$decoratorRange=block.decoratorRanges,decoratorRanges=void 0===_block$decoratorRange?[]:_block$decoratorRange;this.textArray=_punycode2.default.ucs2.decode(text),this.ranges=ranges,this.iterator=0,this.relevantIndexes=function(text,inlineRanges){var entityRanges=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],decoratorRanges=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],relevantIndexes=[];return relevantIndexes=addIndexes(relevantIndexes,inlineRanges),relevantIndexes=addIndexes(relevantIndexes,entityRanges),(relevantIndexes=addIndexes(relevantIndexes,decoratorRanges)).push(0),relevantIndexes.push(text.length),relevantIndexes.filter(function(value,index,self){return self.indexOf(value)===index}).sort(function(aa,bb){return aa-bb})}(text,ranges,entityRanges,decoratorRanges);var parsedNodes=function(entityRanges){var decoratorRanges=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],textArray=arguments[2],block=arguments[3],lastIndex=0,mergedRanges=[].concat(_toConsumableArray(entityRanges),_toConsumableArray(decoratorRanges)).sort(function(a,b){return a.offset-b.offset}),nodes=[];return mergedRanges.length<1?(nodes.push(new _ContentNode2.default({block:block,start:0,end:textArray.length})),nodes):(mergedRanges.forEach(function(range){range.offset>lastIndex&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:range.offset})),nodes.push(new _ContentNode2.default({block:block,entity:range.key,decorator:range.component,decoratorProps:range.decoratorProps,decoratedText:range.component?getString(textArray,range.offset,range.offset+range.length):void 0,start:range.offset,end:range.offset+range.length,contentState:range.contentState})),lastIndex=range.offset+range.length}),lastIndex<textArray.length&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:textArray.length})),nodes)}(entityRanges,decoratorRanges,this.textArray,block).map(function(node){return _this2.nodeIterator(node,node.start,node.end)});return new _ContentNode2.default({block:block,content:parsedNodes})}}]),RawParser}();exports.default=RawParser});unwrapExports(RawParser_1);var createStyleRenderer_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(wrapper,stylesMap){return function(children,styleArray,params){var style=function(styleArray,stylesMap){return styleArray.map(function(style){return stylesMap[style]}).reduce(function(prev,next){var mergedStyles={};if(void 0!==next){var key="text-decoration"in next?"text-decoration":"textDecoration";next[key]!==prev[key]&&(mergedStyles[key]=[prev[key],next[key]].join(" ").trim())}return Object.assign(prev,next,mergedStyles)},{})}(styleArray,stylesMap);return wrapper(Object.assign({},{children:children},params,{style:style}))}}});unwrapExports(createStyleRenderer_1);var warn_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(msg){"production"!==process.env.NODE_ENV&&console.warn("Redraft: "+msg)}});unwrapExports(warn_1);var checkCleanup_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(block,prevType,_ref2){var cleanup=_ref2.cleanup;return!(!cleanup||function(block,options){return text=block.text,!(options.trim?!text.trim():!text)||!(!block.data||!Object.keys(block.data).length)||!(!block.entityRanges||!block.entityRanges.length);var text}(block,cleanup)||cleanup.after&&"all"!==cleanup.after&&-1===cleanup.after.indexOf(prevType)||(!cleanup.except||-1!==cleanup.except.indexOf(block.type))&&(!cleanup.types||"all"!==cleanup.types&&-1===cleanup.types.indexOf(block.type)))}});unwrapExports(checkCleanup_1);var getKeyGenerator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(){var key=0;return function(){var current=key;return key+=1,current}}});unwrapExports(getKeyGenerator_1);var checkJoin_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(input,options){return Array.isArray(input)&&options.joinOutput?input.join(""):input}});unwrapExports(checkJoin_1);var pushString_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(string,array,index){var tempArray=array;return array[index]?tempArray[index]+=string:tempArray[index]=string,tempArray}});unwrapExports(pushString_1);var defaultOptions_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default={joinOutput:!1,cleanup:{after:["atomic"],types:["unstyled"],trim:!1,split:!0}}});unwrapExports(defaultOptions_1);var CompositeDecorator=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var CompositeDraftDecorator=function(){function CompositeDraftDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,CompositeDraftDecorator),this.decorators=decorators.slice()}return _createClass(CompositeDraftDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,ii){var counter=0;(0,decorator.strategy)(block,function(start,end){(function(decorations,start,end){for(var ii=start;ii<end;ii++)if(null!=decorations[ii])return!1;return!0})(decorations,start,end)&&(function(targetArr,start,end,componentKey){for(var ii=start;ii<end;ii++)targetArr[ii]=componentKey}(decorations,start,end,ii+"."+counter),counter++)},contentState)}),decorations}},{key:"getComponentForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].component}},{key:"getPropsForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].props}}]),CompositeDraftDecorator}();exports.default=CompositeDraftDecorator});unwrapExports(CompositeDecorator);var MultiDecorator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var MultiDecorator=function(){function MultiDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,MultiDecorator),this.decorators=decorators}return _createClass(MultiDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=new Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,i){decorator.getDecorations(block,contentState).forEach(function(key,offset){key&&(decorations[offset]=i+"-"+key)})}),decorations}},{key:"getComponentForKey",value:function(key){return this.getDecoratorForKey(key).getComponentForKey(MultiDecorator.getInnerKey(key))}},{key:"getPropsForKey",value:function(key){return this.getDecoratorForKey(key).getPropsForKey(MultiDecorator.getInnerKey(key))}},{key:"getDecoratorForKey",value:function(key){var parts=key.split("-"),index=Number(parts[0]);return this.decorators[index]}}],[{key:"getInnerKey",value:function(key){return key.split("-").slice(1).join("-")}}]),MultiDecorator}();exports.default=MultiDecorator});unwrapExports(MultiDecorator_1);var stubContentBlock_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var ContentBlockStub=function(){function ContentBlockStub(block){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentBlockStub),Object.assign(this,block)}return _createClass(ContentBlockStub,[{key:"get",value:function(name){return this[name]}},{key:"getText",value:function(){return this.text}},{key:"getType",value:function(){return this.type}},{key:"getKey",value:function(){return this.key}},{key:"getLength",value:function(){return this.text.length}},{key:"getDepth",value:function(){return this.depth}},{key:"getData",value:function(){return this.data}}]),ContentBlockStub}();exports.default=function(block){return new ContentBlockStub(block)}});unwrapExports(stubContentBlock_1);var withDecorators_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _CompositeDecorator2=_interopRequireDefault(CompositeDecorator),_MultiDecorator2=_interopRequireDefault(MultiDecorator_1),_stubContentBlock2=_interopRequireDefault(stubContentBlock_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var decoratorIsCustom=function(decorator){return"function"==typeof decorator.getDecorations&&"function"==typeof decorator.getComponentForKey&&"function"==typeof decorator.getPropsForKey},resolveDecorators=function(decorators){var compositeDecorator=new _CompositeDecorator2.default(decorators.filter(function(decorator){return!decoratorIsCustom(decorator)})),customDecorators=decorators.filter(function(decorator){return decoratorIsCustom(decorator)}),decor=[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(customDecorators),[compositeDecorator]);return new _MultiDecorator2.default(decor)};exports.default=function(raw,decorators,options){var contentState=options.convertFromRaw&&options.convertFromRaw(raw);return raw.blocks.map(function(block){return function(block,decorators,contentState,_ref){var createContentBlock=_ref.createContentBlock,decoratorRanges=[],decorator=resolveDecorators(decorators),contentBlock=createContentBlock?createContentBlock(block):(0,_stubContentBlock2.default)(block),decorations=decorator.getDecorations(contentBlock,contentState),offset=0;return decorations.forEach(function(key,index){if(key){var nextIndex=index+1,next=decorations[nextIndex];next&&next===key||(decoratorRanges.push({offset:offset,length:nextIndex-offset,component:decorator.getComponentForKey(key),decoratorProps:decorator.getPropsForKey(key)||{},contentState:contentState}),offset=nextIndex)}else offset+=1}),Object.assign({},block,{decoratorRanges:decoratorRanges})}(block,decorators,contentState,options||{})})}});unwrapExports(withDecorators_1);var render_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.render=exports.renderNode=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_warn2=_interopRequireDefault(warn_1),_checkCleanup2=_interopRequireDefault(checkCleanup_1),_getKeyGenerator2=_interopRequireDefault(getKeyGenerator_1),_checkJoin2=_interopRequireDefault(checkJoin_1),_pushString2=_interopRequireDefault(pushString_1),_defaultOptions2=_interopRequireDefault(defaultOptions_1),_withDecorators2=_interopRequireDefault(withDecorators_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var renderNode=exports.renderNode=function renderNode(node,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator){if(node.styles&&styleRenderers)return styleRenderers((0,_checkJoin2.default)(node.content,options),node.styles,{key:keyGenerator()});var children=[],index=0;if(node.content.forEach(function(part){"string"==typeof part?children=(0,_pushString2.default)(part,children,index):(children[index+=1]=renderNode(part,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator),index+=1)}),node.style&&inlineRenderers[node.style])return inlineRenderers[node.style]((0,_checkJoin2.default)(children,options),{key:keyGenerator()});if(null!==node.entity){var entity=entityMap[node.entity];if(entity&&entityRenderers[entity.type])return entityRenderers[entity.type]((0,_checkJoin2.default)(children,options),entity.data,{key:node.entity})}if(null!==node.decorator){var decoratorOffsetKey=[node.block.key,node.start,0].join(".");return node.decorator(Object.assign({children:(0,_checkJoin2.default)(children,options),decoratedText:node.decoratedText,contentState:node.contentState,entityKey:node.entity,offsetKey:decoratorOffsetKey,key:decoratorOffsetKey},node.decoratorProps))}return children},renderGroup=function(group,blockRenderers,rendered,params){var type=params.prevType,depth=params.prevDepth,keys=params.prevKeys,data=params.prevData;0!==group.length&&(blockRenderers[type]?rendered.push(blockRenderers[type](group,{depth:depth,keys:keys,data:data})):rendered.push(group))};exports.render=function(raw){var renderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!raw||!Array.isArray(raw.blocks))return(0,_warn2.default)("invalid raw object"),null;if(!raw.blocks.length)return null;var inlineRenderers=renderers.inline,blockRenderers=renderers.blocks,entityRenderers=renderers.entities,stylesRenderer=renderers.styles,decorators=renderers.decorators;return function renderBlocks(blocks){var inlineRenderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},blockRenderers=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},entityRenderers=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},stylesRenderer=arguments[4],entityMap=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},userOptions=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},options=Object.assign({},_defaultOptions2.default,userOptions),rendered=[],group=[],prevType=null,prevDepth=0,prevKeys=[],prevData=[],splitGroup=!1,Parser=new _RawParser2.default({flat:!!stylesRenderer});return blocks.forEach(function(block){if((0,_checkCleanup2.default)(block,prevType,options))!0===options.cleanup.split&&(splitGroup=!0);else{var node=Parser.parse(block),renderedNode=renderNode(node,inlineRenderers,entityRenderers,stylesRenderer,entityMap,options,(0,_getKeyGenerator2.default)());if((prevType&&prevType!==block.type||splitGroup)&&(renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),prevData=[],prevKeys=[],group=[],splitGroup=!1),block.children){var children=renderBlocks(block.children,inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,entityMap,options);renderedNode.push(children)}group.push(renderedNode),prevType=block.type,prevDepth=block.depth,prevKeys.push(block.key),prevData.push(block.data)}}),renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),(0,_checkJoin2.default)(rendered,options)}(function(blocks){var group=[],depthStack=[],prevDepth=0,unwind=function(targetDepth){var i=prevDepth-targetDepth;for(depthStack.length<i&&(i=depthStack.length);i>0;i-=1){var tmp=group;(group=depthStack.pop())[group.length-1].children=tmp}};return blocks.forEach(function(block){prevDepth<block.depth?(depthStack.push(group),group=[]):prevDepth>block.depth&&unwind(block.depth),prevDepth=block.depth,group.push(block)}),0!==prevDepth&&unwind(0),group}(decorators?(0,_withDecorators2.default)(raw,decorators,options):raw.blocks),inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,raw.entityMap,options)}});unwrapExports(render_1);render_1.render,render_1.renderNode;var lib=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompositeDecorator=exports.renderNode=exports.RawParser=exports.createStylesRenderer=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_createStyleRenderer2=_interopRequireDefault(createStyleRenderer_1),_CompositeDecorator2=_interopRequireDefault(CompositeDecorator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.createStylesRenderer=_createStyleRenderer2.default,exports.RawParser=_RawParser2.default,exports.renderNode=render_1.renderNode,exports.CompositeDecorator=_CompositeDecorator2.default,exports.default=render_1.render}),redraft=unwrapExports(lib),AtomicBlock=(lib.CompositeDecorator,lib.renderNode,lib.RawParser,lib.createStylesRenderer,function(_ref){var type=_ref.type,typeMap=_ref.typeMap,componentData=_ref.componentData,children=_ref.children,theme=_ref.theme,isMobile=_ref.isMobile,anchorTarget=_ref.anchorTarget,relValue=_ref.relValue,props=_objectWithoutPropertiesLoose(_ref,["type","typeMap","componentData","children","theme","isMobile","anchorTarget","relValue"]),mergedStyles=wixRichContentCommon.mergeStyles({theme:theme,styles:styles}),_typeMap$type=typeMap[type],Component=_typeMap$type.component,elementType=_typeMap$type.elementType,_ref2=typeMap[type].classNameStrategies||{},size=_ref2.size,alignment=_ref2.alignment,textWrap=_ref2.textWrap,container=_ref2.container;if(Component){if("inline"!==elementType){var _classNames,containerClassNames=classNames(mergedStyles.pluginContainerReadOnly,((_classNames={})[mergedStyles.pluginContainerMobile]=isMobile,_classNames),isFunction(alignment)?alignment(componentData,theme,styles,isMobile):wixRichContentCommon.alignmentClassName(componentData,theme,styles,isMobile),isFunction(size)?size(componentData,theme,styles,isMobile):wixRichContentCommon.sizeClassName(componentData,theme,styles,isMobile),isFunction(textWrap)?textWrap(componentData,theme,styles,isMobile):wixRichContentCommon.textWrapClassName(componentData,theme,styles,isMobile));return React__default.createElement("div",{className:containerClassNames},isFunction(container)?React__default.createElement("div",{className:container(theme)},React__default.createElement(Component,_extends({componentData:componentData,theme:theme},props),children)):React__default.createElement(Component,_extends({componentData:componentData,theme:theme},props),children),function(componentData,anchorTarget,relValue){if(componentData.config&&componentData.config.link){var _componentData$config=componentData.config.link,url=_componentData$config.url,target=_componentData$config.target,rel=_componentData$config.rel;return React__default.createElement("a",{target:target||anchorTarget||"_self",rel:rel||relValue||"noopener",href:wixRichContentCommon.normalizeUrl(url),className:styles.anchor})}return null}(componentData,anchorTarget,relValue))}return React__default.createElement(Component,_extends({componentData:componentData,theme:theme},props)," ",children," ")}return null});AtomicBlock.propTypes={type:PropTypes.string.isRequired,componentData:PropTypes.object.isRequired,typeMap:PropTypes.object,children:PropTypes.node,theme:PropTypes.object,isMobile:PropTypes.bool,anchorTarget:PropTypes.string,relValue:PropTypes.string};var List=function(_ref){var ordered=_ref.ordered,children=_ref.children;return ordered?React__default.createElement("ol",null,children):React__default.createElement("ul",null,children)};List.propTypes={ordered:PropTypes.bool,children:PropTypes.node.isRequired};var getStrategyByStyle=function(style){return function(contentBlock,callback){contentBlock&&contentBlock.inlineStyleRanges&&contentBlock.inlineStyleRanges.filter(function(range){return range.style===style}).forEach(function(_ref){var offset=_ref.offset,length=_ref.length;return callback(offset,offset+length)})}},withTextAlignment=function(element,blockProps,mergedStyles){var data=(blockProps||[]).data,dataEntry=data.length>0?data[0]:{},alignmentClass=dataEntry.textAlignment?dataEntry.textAlignment:"left",elementProps=_extends({},element.props,{className:element.props.className?classNames(element.props.className,mergedStyles[alignmentClass]):mergedStyles[alignmentClass]});return React__default.cloneElement(element,elementProps,element.props.children)},getList=function(ordered,mergedStyles){return function(children,blockProps){var fixedChildren=children.map(function(child){return child.length?child:[" "]}),className=ordered?"ordered":"unordered";return React__default.createElement(List,{key:blockProps.keys[0],keys:blockProps.keys,depth:blockProps.depth,ordered:ordered},fixedChildren.map(function(child,i){var dataEntry=blockProps.data.length>i?[blockProps.data[i]]:[{}];return withTextAlignment(React__default.createElement("li",{className:mergedStyles[className+"List"],key:blockProps.keys[i]},React__default.createElement("div",null,child)),_extends({},blockProps,{data:dataEntry}),mergedStyles)}))}},getEntities=function(typeMap,pluginProps){return _extends({},function(typeMap,pluginProps){var res={};return Object.keys(typeMap).forEach(function(type){res[type]=function(children,entity,_ref3){var key=_ref3.key;return React__default.createElement(AtomicBlock,_extends({typeMap:typeMap,type:type,key:key,componentData:entity},pluginProps),children)}}),res}(typeMap,pluginProps))},options={cleanup:{after:"all",types:"all",split:!0}},Preview=function(_ref6){var mappers,raw=_ref6.raw,typeMappers=_ref6.typeMappers,theme=_ref6.theme,isMobile=_ref6.isMobile,decorators=_ref6.decorators,anchorTarget=_ref6.anchorTarget,relValue=_ref6.relValue,mergedStyles=wixRichContentCommon.mergeStyles({styles:styles,theme:theme}),isEmpty=function(raw){return!raw||!raw.blocks||1===raw.blocks.length&&""===raw.blocks[0].text}(raw),typeMap=(mappers=typeMappers)&&mappers.length&&!mappers.some(function(resolver){return"function"!=typeof resolver})?mappers.reduce(function(map,mapper){return Object.assign(map,mapper())},{}):(console.error("typeMappers is expected to be a function array"),{}),combinedDecorators=decorators.concat(wixRichContentCommon.createInlineStyleDecorators(getStrategyByStyle,mergedStyles));return React__default.createElement("div",{className:mergedStyles.preview},isEmpty&&React__default.createElement("div",null,"There is nothing to render..."),!isEmpty&&redraft(raw,{inline:function(mergedStyles){return{BOLD:function(children,_ref2){var key=_ref2.key;return React__default.createElement("strong",{key:key},children)},ITALIC:function(children,_ref3){var key=_ref3.key;return React__default.createElement("em",{key:key},children)},UNDERLINE:function(children,_ref4){var key=_ref4.key;return React__default.createElement("u",{key:key},children)},CODE:function(children,_ref5){var key=_ref5.key;return React__default.createElement("span",{key:key,className:mergedStyles.code},children)}}}(mergedStyles),blocks:function(mergedStyles){return{unstyled:function(children,blockProps){return withTextAlignment(React__default.createElement("p",{key:blockProps.keys[0]},React__default.createElement("div",null,children)),blockProps,mergedStyles)},blockquote:function(children,blockProps){return withTextAlignment(React__default.createElement("blockquote",{className:mergedStyles.quote,key:blockProps.keys[0]},React__default.createElement("div",null,children)),blockProps,mergedStyles)},"header-two":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h2",{className:mergedStyles.headerTwo,key:blockProps.keys[i]},child),blockProps,mergedStyles)})},"header-three":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h3",{className:mergedStyles.headerThree,key:blockProps.keys[i]},child),blockProps,mergedStyles)})},"code-block":function(children,blockProps){return withTextAlignment(React__default.createElement("pre",{key:blockProps.keys[0],className:mergedStyles.codeBlock},children),blockProps,mergedStyles)},"unordered-list-item":getList(!1,mergedStyles),"ordered-list-item":getList(!0,mergedStyles)}}(mergedStyles),entities:getEntities(typeMap,{theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue}),decorators:combinedDecorators},options))};Preview.propTypes={raw:PropTypes.shape({blocks:PropTypes.array.isRequired,entityMap:PropTypes.object.isRequired}).isRequired,typeMappers:PropTypes.arrayOf(PropTypes.func),theme:PropTypes.object,isMobile:PropTypes.bool,decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),anchorTarget:PropTypes.string,relValue:PropTypes.string};var RichContentViewer=function(_Component){function RichContentViewer(props){var _this;return(_this=_Component.call(this,props)||this).getInitialState=function(initialState){return initialState?wixRichContentCommon.normalizeInitialState(initialState,{anchorTarget:_this.props.anchorTarget,relValue:_this.props.relValue}):{}},_this.state={raw:_this.getInitialState(props.initialState)},_this.styles=wixRichContentCommon.mergeStyles({styles:styles,theme:props.theme}),_this}_inheritsLoose(RichContentViewer,_Component);var _proto=RichContentViewer.prototype;return _proto.componentWillReceiveProps=function(nextProps){this.props.initialState!==nextProps.initialState&&this.setState({raw:this.getInitialState(nextProps.initialState)})},_proto.render=function(){var _classNames,styles$$1=this.styles,_this$props=this.props,theme=_this$props.theme,isMobile=_this$props.isMobile,typeMappers=_this$props.typeMappers,decorators=_this$props.decorators,anchorTarget=_this$props.anchorTarget,relValue=_this$props.relValue,wrapperClassName=classNames(styles$$1.wrapper,((_classNames={})[styles$$1.desktop]=!this.props.platform||"desktop"===this.props.platform,_classNames));return React__default.createElement("div",{className:wrapperClassName},React__default.createElement("div",{className:styles$$1.editor},React__default.createElement(Preview,{raw:this.state.raw,decorators:decorators,typeMappers:typeMappers,theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue})),React__default.createElement(wixRichContentCommon.AccessibilityListener,{isMobile:isMobile}))},RichContentViewer}(React.Component);return RichContentViewer.propTypes={initialState:PropTypes.object,isMobile:PropTypes.bool,helpers:PropTypes.object,platform:PropTypes.string,typeMappers:PropTypes.arrayOf(PropTypes.func),decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),theme:PropTypes.object,anchorTarget:PropTypes.string,relValue:PropTypes.string},RichContentViewer.defaultProps={theme:{},decorators:[],typeMappers:[]},exports.RichContentViewer=RichContentViewer,exports}({},_extends,_objectWithoutPropertiesLoose,React,PropTypes,classNames,isFunction,wixRichContentCommon,_inheritsLoose); | ||
var WixRichContentViewer=function(exports,_extends,_objectWithoutPropertiesLoose,React,PropTypes,classNames,isFunction,wixRichContentCommon,_inheritsLoose){"use strict";_extends=_extends&&_extends.hasOwnProperty("default")?_extends.default:_extends,_objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose&&_objectWithoutPropertiesLoose.hasOwnProperty("default")?_objectWithoutPropertiesLoose.default:_objectWithoutPropertiesLoose;var React__default="default"in React?React.default:React;PropTypes=PropTypes&&PropTypes.hasOwnProperty("default")?PropTypes.default:PropTypes,classNames=classNames&&classNames.hasOwnProperty("default")?classNames.default:classNames,isFunction=isFunction&&isFunction.hasOwnProperty("default")?isFunction.default:isFunction,_inheritsLoose=_inheritsLoose&&_inheritsLoose.hasOwnProperty("default")?_inheritsLoose.default:_inheritsLoose;var styles={fontElementMap:"rich-content-viewer_fontElementMap__2536P",pluginContainerReadOnly:"rich-content-viewer_pluginContainerReadOnly__2CvYQ",pluginContainer:"rich-content-viewer_pluginContainer__1sQKR",panelContainer:"rich-content-viewer_panelContainer__1iKfr",wrapper:"rich-content-viewer_wrapper__kcuBq",flex:"rich-content-viewer_flex__32v4L",focused:"rich-content-viewer_focused__2QANw",noOutline:"rich-content-viewer_noOutline__rG7tY",visuallyHidden:"rich-content-viewer_visuallyHidden__1BlbC",hasFocus:"rich-content-viewer_hasFocus__3xWzX",overlay:"rich-content-viewer_overlay__32lvd",hidden:"rich-content-viewer_hidden__2hq23",pluginContainerMobile:"rich-content-viewer_pluginContainerMobile__13mNb",alignLeft:"rich-content-viewer_alignLeft__2k0o0",textWrapNowrap:"rich-content-viewer_textWrapNowrap__3MdB6",alignCenter:"rich-content-viewer_alignCenter__Slk8p",alignRight:"rich-content-viewer_alignRight__1MOUB",sizeFullWidth:"rich-content-viewer_sizeFullWidth__3ciQ2",sizeContent:"rich-content-viewer_sizeContent__1hD8w",sizeSmall:"rich-content-viewer_sizeSmall__3Q43X",sizeSmallCenter:"rich-content-viewer_sizeSmallCenter__1jZaq",isImage:"rich-content-viewer_isImage__3m3_b",anchor:"rich-content-viewer_anchor__i8Flr",desktop:"rich-content-viewer_desktop__uatYj",editor:"rich-content-viewer_editor__kaqlz",android:"rich-content-viewer_android__18id9",atomic:"rich-content-viewer_atomic__q2uC4",toolbar:"rich-content-viewer_toolbar__3HztD",block:"rich-content-viewer_block__Rhs1S",elementSpacing:"rich-content-viewer_elementSpacing__208Ie",blockStyleSpacing:"rich-content-viewer_blockStyleSpacing__1J-OE",text:"rich-content-viewer_text__XzvDs rich-content-viewer_elementSpacing__208Ie",left:"rich-content-viewer_left__2p1aK",center:"rich-content-viewer_center__ujPQ6",right:"rich-content-viewer_right__2KAc8",justify:"rich-content-viewer_justify__1iXso",quote:"rich-content-viewer_quote__3jY04 rich-content-viewer_blockStyleSpacing__1J-OE",headerOne:"rich-content-viewer_headerOne__1EKGD rich-content-viewer_elementSpacing__208Ie",headerTwo:"rich-content-viewer_headerTwo__3f-vr rich-content-viewer_elementSpacing__208Ie",headerThree:"rich-content-viewer_headerThree__3tkn1 rich-content-viewer_elementSpacing__208Ie",indent:"rich-content-viewer_indent__2RESO rich-content-viewer_elementSpacing__208Ie",orderedList:"rich-content-viewer_orderedList__3_0WU rich-content-viewer_elementSpacing__208Ie",unorderedList:"rich-content-viewer_unorderedList__1BJwx rich-content-viewer_elementSpacing__208Ie",code:"rich-content-viewer_code__sEtbn rich-content-viewer_blockStyleSpacing__1J-OE",codeBlock:"rich-content-viewer_codeBlock__3I8mR rich-content-viewer_blockStyleSpacing__1J-OE",normalText:"rich-content-viewer_normalText__1b-JN",preview:"rich-content-viewer_preview__1ppsP"};function unwrapExports(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";return parts.length>1&&(result=parts[0]+"@",string=parts[1]),result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter<length;)(value=string.charCodeAt(counter++))>=55296&&value<=56319&&counter<length?56320==(64512&(extra=string.charCodeAt(counter++)))?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return value>65535&&(output+=stringFromCharCode((value-=65536)>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,codePoint,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;index>=inputLength&&error("invalid-input"),((digit=(codePoint=input.charCodeAt(index++))-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base)>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,!(digit<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)w>floor(maxInt/(baseMinusT=base-t))&&error("overflow"),w*=baseMinusT;bias=adapt(i-oldi,out=output.length+1,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(inputLength=(input=ucs2decode(input)).length,n=initialN,delta=0,bias=initialBias,j=0;j<inputLength;++j)(currentValue=input[j])<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)(currentValue=input[j])>=n&¤tValue<m&&(m=currentValue);for(m-n>floor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if((currentValue=input[j])<n&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;!(q<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}var ucs2={decode:ucs2decode,encode:ucs2encode},punycode={version:"1.4.1",ucs2:ucs2,toASCII:toASCII,toUnicode:toUnicode,encode:encode,decode:decode},punycode$1=Object.freeze({decode:decode,encode:encode,toUnicode:toUnicode,toASCII:toASCII,version:"1.4.1",ucs2:ucs2,default:punycode}),arrayEqual=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(arr1,arr2){if(arr1.length!==arr2.length)return!1;for(var i=0;i++;i<arr1.length)if(arr1[i]!==arr2[i])return!1;return!0}});unwrapExports(arrayEqual);var ContentNode_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var obj,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_arrayEqual2=(obj=arrayEqual)&&obj.__esModule?obj:{default:obj};var ContentNode=function(){function ContentNode(props){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentNode),this.content=props.content||[],this.start=void 0!==props.start?props.start:null,this.end=void 0!==props.end?props.end:null,this.entity=void 0!==props.entity?props.entity:null,this.decorator=void 0!==props.decorator?props.decorator:null,this.decoratorProps=props.decoratorProps||null,this.decoratedText=void 0!==props.decoratedText?props.decoratedText:null,this.contentState=props.contentState,this.style=props.style||null,this.styles=props.styles||null,this.block=props.block||{}}return _createClass(ContentNode,[{key:"getCurrentContent",value:function(){return this.content[this.content.length-1]}},{key:"addToCurrentContent",value:function(string){this.content[this.content.length-1]=this.content[this.content.length-1]+string}},{key:"handleFlatPush",value:function(string,stack){var current=this.getCurrentContent();if(current instanceof ContentNode&&(0,_arrayEqual2.default)(stack,current.styles))current.addToCurrentContent(string);else{var newNode=new ContentNode({styles:[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(stack)),content:[string]});this.content.push(newNode)}}},{key:"pushContent",value:function(string){var stack=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],flat=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!stack||stack.length<1)return"string"==typeof string&&"string"==typeof this.getCurrentContent()?this.addToCurrentContent(string):this.content.push(string),this;if(flat)return this.handleFlatPush(string,stack),this;var arr,_stack=(arr=stack,Array.isArray(arr)?arr:Array.from(arr)),head=_stack[0],rest=_stack.slice(1),current=this.getCurrentContent();if(current instanceof ContentNode&¤t.style===head)current.pushContent(string,rest,flat);else{var newNode=new ContentNode({style:head});newNode.pushContent(string,rest,flat),this.content.push(newNode)}return this}}]),ContentNode}();exports.default=ContentNode});unwrapExports(ContentNode_1);var _punycode=punycode$1&&punycode||punycode$1,RawParser_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_punycode2=_interopRequireDefault(_punycode),_ContentNode2=_interopRequireDefault(ContentNode_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}var getString=function(array,from,to){return _punycode2.default.ucs2.encode(array.slice(from,to))};function addIndexes(indexes,ranges){return ranges.forEach(function(range){indexes.push(range.offset),indexes.push(range.offset+range.length)}),indexes}var RawParser=function(){function RawParser(_ref){var _ref$flat=_ref.flat,flat=void 0!==_ref$flat&&_ref$flat;!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,RawParser),this.flat=flat}return _createClass(RawParser,[{key:"relevantStyles",value:function(offset){return this.ranges.filter(function(range){return offset>=range.offset&&offset<range.offset+range.length}).map(function(style){return style.style})}},{key:"nodeIterator",value:function(node,start,end){var _this=this,indexes=this.relevantIndexes.slice(this.relevantIndexes.indexOf(start),this.relevantIndexes.indexOf(end));return indexes.forEach(function(index,key){var characterStyles=_this.relevantStyles(index),distance=indexes[key+1]?indexes[key+1]-index:1,text=getString(_this.textArray,index,index+distance);node.pushContent(text,characterStyles,_this.flat),!indexes[key+1]&&index<end&&node.pushContent(getString(_this.textArray,index+1,end),_this.relevantStyles(end-1),_this.flat)}),node}},{key:"parse",value:function(block){var _this2=this,text=block.text,ranges=block.inlineStyleRanges,entityRanges=block.entityRanges,_block$decoratorRange=block.decoratorRanges,decoratorRanges=void 0===_block$decoratorRange?[]:_block$decoratorRange;this.textArray=_punycode2.default.ucs2.decode(text),this.ranges=ranges,this.iterator=0,this.relevantIndexes=function(text,inlineRanges){var entityRanges=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],decoratorRanges=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],relevantIndexes=[];return relevantIndexes=addIndexes(relevantIndexes,inlineRanges),relevantIndexes=addIndexes(relevantIndexes,entityRanges),(relevantIndexes=addIndexes(relevantIndexes,decoratorRanges)).push(0),relevantIndexes.push(text.length),relevantIndexes.filter(function(value,index,self){return self.indexOf(value)===index}).sort(function(aa,bb){return aa-bb})}(text,ranges,entityRanges,decoratorRanges);var parsedNodes=function(entityRanges){var decoratorRanges=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],textArray=arguments[2],block=arguments[3],lastIndex=0,mergedRanges=[].concat(_toConsumableArray(entityRanges),_toConsumableArray(decoratorRanges)).sort(function(a,b){return a.offset-b.offset}),nodes=[];return mergedRanges.length<1?(nodes.push(new _ContentNode2.default({block:block,start:0,end:textArray.length})),nodes):(mergedRanges.forEach(function(range){range.offset>lastIndex&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:range.offset})),nodes.push(new _ContentNode2.default({block:block,entity:range.key,decorator:range.component,decoratorProps:range.decoratorProps,decoratedText:range.component?getString(textArray,range.offset,range.offset+range.length):void 0,start:range.offset,end:range.offset+range.length,contentState:range.contentState})),lastIndex=range.offset+range.length}),lastIndex<textArray.length&&nodes.push(new _ContentNode2.default({block:block,start:lastIndex,end:textArray.length})),nodes)}(entityRanges,decoratorRanges,this.textArray,block).map(function(node){return _this2.nodeIterator(node,node.start,node.end)});return new _ContentNode2.default({block:block,content:parsedNodes})}}]),RawParser}();exports.default=RawParser});unwrapExports(RawParser_1);var createStyleRenderer_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(wrapper,stylesMap){return function(children,styleArray,params){var style=function(styleArray,stylesMap){return styleArray.map(function(style){return stylesMap[style]}).reduce(function(prev,next){var mergedStyles={};if(void 0!==next){var key="text-decoration"in next?"text-decoration":"textDecoration";next[key]!==prev[key]&&(mergedStyles[key]=[prev[key],next[key]].join(" ").trim())}return Object.assign(prev,next,mergedStyles)},{})}(styleArray,stylesMap);return wrapper(Object.assign({},{children:children},params,{style:style}))}}});unwrapExports(createStyleRenderer_1);var warn_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(msg){"production"!==process.env.NODE_ENV&&console.warn("Redraft: "+msg)}});unwrapExports(warn_1);var checkCleanup_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(block,prevType,_ref2){var cleanup=_ref2.cleanup;return!(!cleanup||function(block,options){return text=block.text,!(options.trim?!text.trim():!text)||!(!block.data||!Object.keys(block.data).length)||!(!block.entityRanges||!block.entityRanges.length);var text}(block,cleanup)||cleanup.after&&"all"!==cleanup.after&&-1===cleanup.after.indexOf(prevType)||(!cleanup.except||-1!==cleanup.except.indexOf(block.type))&&(!cleanup.types||"all"!==cleanup.types&&-1===cleanup.types.indexOf(block.type)))}});unwrapExports(checkCleanup_1);var getKeyGenerator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(){var key=0;return function(){var current=key;return key+=1,current}}});unwrapExports(getKeyGenerator_1);var checkJoin_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(input,options){return Array.isArray(input)&&options.joinOutput?input.join(""):input}});unwrapExports(checkJoin_1);var pushString_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(string,array,index){var tempArray=array;return array[index]?tempArray[index]+=string:tempArray[index]=string,tempArray}});unwrapExports(pushString_1);var defaultOptions_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.default={joinOutput:!1,cleanup:{after:["atomic"],types:["unstyled"],trim:!1,split:!0}}});unwrapExports(defaultOptions_1);var CompositeDecorator=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var CompositeDraftDecorator=function(){function CompositeDraftDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,CompositeDraftDecorator),this.decorators=decorators.slice()}return _createClass(CompositeDraftDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,ii){var counter=0;(0,decorator.strategy)(block,function(start,end){(function(decorations,start,end){for(var ii=start;ii<end;ii++)if(null!=decorations[ii])return!1;return!0})(decorations,start,end)&&(function(targetArr,start,end,componentKey){for(var ii=start;ii<end;ii++)targetArr[ii]=componentKey}(decorations,start,end,ii+"."+counter),counter++)},contentState)}),decorations}},{key:"getComponentForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].component}},{key:"getPropsForKey",value:function(key){var componentKey=parseInt(key.split(".")[0],10);return this.decorators[componentKey].props}}]),CompositeDraftDecorator}();exports.default=CompositeDraftDecorator});unwrapExports(CompositeDecorator);var MultiDecorator_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var MultiDecorator=function(){function MultiDecorator(decorators){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,MultiDecorator),this.decorators=decorators}return _createClass(MultiDecorator,[{key:"getDecorations",value:function(block,contentState){var decorations=new Array(block.getText().length).fill(null);return this.decorators.forEach(function(decorator,i){decorator.getDecorations(block,contentState).forEach(function(key,offset){key&&(decorations[offset]=i+"-"+key)})}),decorations}},{key:"getComponentForKey",value:function(key){return this.getDecoratorForKey(key).getComponentForKey(MultiDecorator.getInnerKey(key))}},{key:"getPropsForKey",value:function(key){return this.getDecoratorForKey(key).getPropsForKey(MultiDecorator.getInnerKey(key))}},{key:"getDecoratorForKey",value:function(key){var parts=key.split("-"),index=Number(parts[0]);return this.decorators[index]}}],[{key:"getInnerKey",value:function(key){return key.split("-").slice(1).join("-")}}]),MultiDecorator}();exports.default=MultiDecorator});unwrapExports(MultiDecorator_1);var stubContentBlock_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var ContentBlockStub=function(){function ContentBlockStub(block){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,ContentBlockStub),Object.assign(this,block)}return _createClass(ContentBlockStub,[{key:"get",value:function(name){return this[name]}},{key:"getText",value:function(){return this.text}},{key:"getType",value:function(){return this.type}},{key:"getKey",value:function(){return this.key}},{key:"getLength",value:function(){return this.text.length}},{key:"getDepth",value:function(){return this.depth}},{key:"getData",value:function(){return this.data}}]),ContentBlockStub}();exports.default=function(block){return new ContentBlockStub(block)}});unwrapExports(stubContentBlock_1);var withDecorators_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0});var _CompositeDecorator2=_interopRequireDefault(CompositeDecorator),_MultiDecorator2=_interopRequireDefault(MultiDecorator_1),_stubContentBlock2=_interopRequireDefault(stubContentBlock_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var decoratorIsCustom=function(decorator){return"function"==typeof decorator.getDecorations&&"function"==typeof decorator.getComponentForKey&&"function"==typeof decorator.getPropsForKey},resolveDecorators=function(decorators){var compositeDecorator=new _CompositeDecorator2.default(decorators.filter(function(decorator){return!decoratorIsCustom(decorator)})),customDecorators=decorators.filter(function(decorator){return decoratorIsCustom(decorator)}),decor=[].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(customDecorators),[compositeDecorator]);return new _MultiDecorator2.default(decor)};exports.default=function(raw,decorators,options){var contentState=options.convertFromRaw&&options.convertFromRaw(raw);return raw.blocks.map(function(block){return function(block,decorators,contentState,_ref){var createContentBlock=_ref.createContentBlock,decoratorRanges=[],decorator=resolveDecorators(decorators),contentBlock=createContentBlock?createContentBlock(block):(0,_stubContentBlock2.default)(block),decorations=decorator.getDecorations(contentBlock,contentState),offset=0;return decorations.forEach(function(key,index){if(key){var nextIndex=index+1,next=decorations[nextIndex];next&&next===key||(decoratorRanges.push({offset:offset,length:nextIndex-offset,component:decorator.getComponentForKey(key),decoratorProps:decorator.getPropsForKey(key)||{},contentState:contentState}),offset=nextIndex)}else offset+=1}),Object.assign({},block,{decoratorRanges:decoratorRanges})}(block,decorators,contentState,options||{})})}});unwrapExports(withDecorators_1);var render_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.render=exports.renderNode=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_warn2=_interopRequireDefault(warn_1),_checkCleanup2=_interopRequireDefault(checkCleanup_1),_getKeyGenerator2=_interopRequireDefault(getKeyGenerator_1),_checkJoin2=_interopRequireDefault(checkJoin_1),_pushString2=_interopRequireDefault(pushString_1),_defaultOptions2=_interopRequireDefault(defaultOptions_1),_withDecorators2=_interopRequireDefault(withDecorators_1);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var renderNode=exports.renderNode=function renderNode(node,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator){if(node.styles&&styleRenderers)return styleRenderers((0,_checkJoin2.default)(node.content,options),node.styles,{key:keyGenerator()});var children=[],index=0;if(node.content.forEach(function(part){"string"==typeof part?children=(0,_pushString2.default)(part,children,index):(children[index+=1]=renderNode(part,inlineRenderers,entityRenderers,styleRenderers,entityMap,options,keyGenerator),index+=1)}),node.style&&inlineRenderers[node.style])return inlineRenderers[node.style]((0,_checkJoin2.default)(children,options),{key:keyGenerator()});if(null!==node.entity){var entity=entityMap[node.entity];if(entity&&entityRenderers[entity.type])return entityRenderers[entity.type]((0,_checkJoin2.default)(children,options),entity.data,{key:node.entity})}if(null!==node.decorator){var decoratorOffsetKey=[node.block.key,node.start,0].join(".");return node.decorator(Object.assign({children:(0,_checkJoin2.default)(children,options),decoratedText:node.decoratedText,contentState:node.contentState,entityKey:node.entity,offsetKey:decoratorOffsetKey,key:decoratorOffsetKey},node.decoratorProps))}return children},renderGroup=function(group,blockRenderers,rendered,params){var type=params.prevType,depth=params.prevDepth,keys=params.prevKeys,data=params.prevData;0!==group.length&&(blockRenderers[type]?rendered.push(blockRenderers[type](group,{depth:depth,keys:keys,data:data})):rendered.push(group))};exports.render=function(raw){var renderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!raw||!Array.isArray(raw.blocks))return(0,_warn2.default)("invalid raw object"),null;if(!raw.blocks.length)return null;var inlineRenderers=renderers.inline,blockRenderers=renderers.blocks,entityRenderers=renderers.entities,stylesRenderer=renderers.styles,decorators=renderers.decorators;return function renderBlocks(blocks){var inlineRenderers=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},blockRenderers=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},entityRenderers=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},stylesRenderer=arguments[4],entityMap=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},userOptions=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},options=Object.assign({},_defaultOptions2.default,userOptions),rendered=[],group=[],prevType=null,prevDepth=0,prevKeys=[],prevData=[],splitGroup=!1,Parser=new _RawParser2.default({flat:!!stylesRenderer});return blocks.forEach(function(block){if((0,_checkCleanup2.default)(block,prevType,options))!0===options.cleanup.split&&(splitGroup=!0);else{var node=Parser.parse(block),renderedNode=renderNode(node,inlineRenderers,entityRenderers,stylesRenderer,entityMap,options,(0,_getKeyGenerator2.default)());if((prevType&&prevType!==block.type||splitGroup)&&(renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),prevData=[],prevKeys=[],group=[],splitGroup=!1),block.children){var children=renderBlocks(block.children,inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,entityMap,options);renderedNode.push(children)}group.push(renderedNode),prevType=block.type,prevDepth=block.depth,prevKeys.push(block.key),prevData.push(block.data)}}),renderGroup(group,blockRenderers,rendered,{prevType:prevType,prevDepth:prevDepth,prevKeys:prevKeys,prevData:prevData}),(0,_checkJoin2.default)(rendered,options)}(function(blocks){var group=[],depthStack=[],prevDepth=0,unwind=function(targetDepth){var i=prevDepth-targetDepth;for(depthStack.length<i&&(i=depthStack.length);i>0;i-=1){var tmp=group;(group=depthStack.pop())[group.length-1].children=tmp}};return blocks.forEach(function(block){prevDepth<block.depth?(depthStack.push(group),group=[]):prevDepth>block.depth&&unwind(block.depth),prevDepth=block.depth,group.push(block)}),0!==prevDepth&&unwind(0),group}(decorators?(0,_withDecorators2.default)(raw,decorators,options):raw.blocks),inlineRenderers,blockRenderers,entityRenderers,stylesRenderer,raw.entityMap,options)}});unwrapExports(render_1);render_1.render,render_1.renderNode;var lib=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompositeDecorator=exports.renderNode=exports.RawParser=exports.createStylesRenderer=void 0;var _RawParser2=_interopRequireDefault(RawParser_1),_createStyleRenderer2=_interopRequireDefault(createStyleRenderer_1),_CompositeDecorator2=_interopRequireDefault(CompositeDecorator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.createStylesRenderer=_createStyleRenderer2.default,exports.RawParser=_RawParser2.default,exports.renderNode=render_1.renderNode,exports.CompositeDecorator=_CompositeDecorator2.default,exports.default=render_1.render}),redraft=unwrapExports(lib),AtomicBlock=(lib.CompositeDecorator,lib.renderNode,lib.RawParser,lib.createStylesRenderer,function(_ref){var type=_ref.type,typeMap=_ref.typeMap,componentData=_ref.componentData,children=_ref.children,theme=_ref.theme,isMobile=_ref.isMobile,anchorTarget=_ref.anchorTarget,relValue=_ref.relValue,config=_ref.config,props=_objectWithoutPropertiesLoose(_ref,["type","typeMap","componentData","children","theme","isMobile","anchorTarget","relValue","config"]),mergedStyles=wixRichContentCommon.mergeStyles({theme:theme,styles:styles}),_typeMap$type=typeMap[type],Component=_typeMap$type.component,elementType=_typeMap$type.elementType,_ref2=typeMap[type].classNameStrategies||{},size=_ref2.size,alignment=_ref2.alignment,textWrap=_ref2.textWrap,container=_ref2.container,settings=config&&config[type]||{};if(Component){if("inline"!==elementType){var _classNames,containerClassNames=classNames(mergedStyles.pluginContainerReadOnly,((_classNames={})[mergedStyles.pluginContainerMobile]=isMobile,_classNames),isFunction(alignment)?alignment(componentData,theme,styles,isMobile):wixRichContentCommon.alignmentClassName(componentData,theme,styles,isMobile),isFunction(size)?size(componentData,theme,styles,isMobile):wixRichContentCommon.sizeClassName(componentData,theme,styles,isMobile),isFunction(textWrap)?textWrap(componentData,theme,styles,isMobile):wixRichContentCommon.textWrapClassName(componentData,theme,styles,isMobile));return React__default.createElement("div",{className:containerClassNames},isFunction(container)?React__default.createElement("div",{className:container(theme)},React__default.createElement(Component,_extends({componentData:componentData,theme:theme,settings:settings},props),children)):React__default.createElement(Component,_extends({componentData:componentData,theme:theme,settings:settings},props),children),function(componentData,anchorTarget,relValue){if(componentData.config&&componentData.config.link){var _componentData$config=componentData.config.link,url=_componentData$config.url,target=_componentData$config.target,rel=_componentData$config.rel;return React__default.createElement("a",{target:target||anchorTarget||"_self",rel:rel||relValue||"noopener",href:wixRichContentCommon.normalizeUrl(url),className:styles.anchor})}return null}(componentData,anchorTarget,relValue))}return React__default.createElement(Component,_extends({componentData:componentData,theme:theme,settings:settings},props)," ",children," ")}return null});AtomicBlock.propTypes={type:PropTypes.string.isRequired,componentData:PropTypes.object.isRequired,typeMap:PropTypes.object,children:PropTypes.node,theme:PropTypes.object,isMobile:PropTypes.bool,anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object};var List=function(_ref){var ordered=_ref.ordered,children=_ref.children;return ordered?React__default.createElement("ol",null,children):React__default.createElement("ul",null,children)};List.propTypes={ordered:PropTypes.bool,children:PropTypes.node.isRequired};var getStrategyByStyle=function(style){return function(contentBlock,callback){contentBlock&&contentBlock.inlineStyleRanges&&contentBlock.inlineStyleRanges.filter(function(range){return range.style===style}).forEach(function(_ref){var offset=_ref.offset,length=_ref.length;return callback(offset,offset+length)})}},withTextAlignment=function(element,data,mergedStyles){var alignmentClass=data.textAlignment?data.textAlignment:"left",elementProps=_extends({},element.props,{className:element.props.className?classNames(element.props.className,mergedStyles[alignmentClass]):mergedStyles[alignmentClass]});return React__default.cloneElement(element,elementProps,element.props.children)},getList=function(ordered,mergedStyles){return function(children,blockProps){var fixedChildren=children.map(function(child){return child.length?child:[" "]}),className=ordered?"ordered":"unordered";return React__default.createElement(List,{key:blockProps.keys[0],keys:blockProps.keys,depth:blockProps.depth,ordered:ordered},fixedChildren.map(function(child,i){var dataEntry=blockProps.data.length>i?blockProps.data[i]:{};return withTextAlignment(React__default.createElement("li",{className:mergedStyles[className+"List"],key:blockProps.keys[i]},React__default.createElement("div",null,child)),dataEntry,mergedStyles)}))}},getEntities=function(typeMap,pluginProps){return _extends({},function(typeMap,pluginProps){var res={};return Object.keys(typeMap).forEach(function(type){res[type]=function(children,entity,_ref3){var key=_ref3.key;return React__default.createElement(AtomicBlock,_extends({typeMap:typeMap,type:type,key:key,componentData:entity},pluginProps),children)}}),res}(typeMap,pluginProps))},options={cleanup:{after:"all",types:"all",split:!0}},Preview=function(_ref5){var mappers,raw=_ref5.raw,typeMappers=_ref5.typeMappers,theme=_ref5.theme,isMobile=_ref5.isMobile,decorators=_ref5.decorators,anchorTarget=_ref5.anchorTarget,relValue=_ref5.relValue,config=_ref5.config,mergedStyles=wixRichContentCommon.mergeStyles({styles:styles,theme:theme}),isEmpty=function(raw){return!raw||!raw.blocks||1===raw.blocks.length&&""===raw.blocks[0].text}(raw),typeMap=(mappers=typeMappers)&&mappers.length&&!mappers.some(function(resolver){return"function"!=typeof resolver})?mappers.reduce(function(map,mapper){return Object.assign(map,mapper())},{}):(console.warn("typeMappers is expected to be a function array"),{}),combinedDecorators=decorators.concat(wixRichContentCommon.createInlineStyleDecorators(getStrategyByStyle,mergedStyles));return React__default.createElement("div",{className:mergedStyles.preview},isEmpty&&React__default.createElement("div",null,"There is nothing to render..."),!isEmpty&&redraft(raw,{inline:function(mergedStyles){return{BOLD:function(children,_ref){var key=_ref.key;return React__default.createElement("strong",{key:key},children)},ITALIC:function(children,_ref2){var key=_ref2.key;return React__default.createElement("em",{key:key},children)},UNDERLINE:function(children,_ref3){var key=_ref3.key;return React__default.createElement("u",{key:key},children)},CODE:function(children,_ref4){var key=_ref4.key;return React__default.createElement("span",{key:key,className:mergedStyles.code},children)}}}(mergedStyles),blocks:function(mergedStyles){return{unstyled:function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("div",{key:blockProps.keys[i]},React__default.createElement("div",null,child)),blockProps.data[i],mergedStyles)})},blockquote:function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("blockquote",{className:mergedStyles.quote,key:blockProps.keys[i]},React__default.createElement("div",null,child)),blockProps.data[i],mergedStyles)})},"header-two":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h2",{className:mergedStyles.headerTwo,key:blockProps.keys[i]},child),blockProps.data[i],mergedStyles)})},"header-three":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("h3",{className:mergedStyles.headerThree,key:blockProps.keys[i]},child),blockProps.data[i],mergedStyles)})},"code-block":function(children,blockProps){return children.map(function(child,i){return withTextAlignment(React__default.createElement("pre",{key:blockProps.keys[i],className:mergedStyles.codeBlock},child),blockProps.data[i],mergedStyles)})},"unordered-list-item":getList(!1,mergedStyles),"ordered-list-item":getList(!0,mergedStyles)}}(mergedStyles),entities:getEntities(typeMap,{theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue,config:config}),decorators:combinedDecorators},options))};Preview.propTypes={raw:PropTypes.shape({blocks:PropTypes.array.isRequired,entityMap:PropTypes.object.isRequired}).isRequired,typeMappers:PropTypes.arrayOf(PropTypes.func),theme:PropTypes.object,isMobile:PropTypes.bool,decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object};var RichContentViewer=function(_Component){function RichContentViewer(props){var _this;return(_this=_Component.call(this,props)||this).getInitialState=function(initialState){return initialState?wixRichContentCommon.normalizeInitialState(initialState,{anchorTarget:_this.props.anchorTarget,relValue:_this.props.relValue}):{}},_this.state={raw:_this.getInitialState(props.initialState)},_this.styles=wixRichContentCommon.mergeStyles({styles:styles,theme:props.theme}),_this}_inheritsLoose(RichContentViewer,_Component);var _proto=RichContentViewer.prototype;return _proto.componentWillReceiveProps=function(nextProps){this.props.initialState!==nextProps.initialState&&this.setState({raw:this.getInitialState(nextProps.initialState)})},_proto.render=function(){var _classNames,styles$$1=this.styles,_this$props=this.props,theme=_this$props.theme,isMobile=_this$props.isMobile,typeMappers=_this$props.typeMappers,decorators=_this$props.decorators,anchorTarget=_this$props.anchorTarget,relValue=_this$props.relValue,config=_this$props.config,wrapperClassName=classNames(styles$$1.wrapper,((_classNames={})[styles$$1.desktop]=!this.props.platform||"desktop"===this.props.platform,_classNames));return React__default.createElement("div",{className:wrapperClassName},React__default.createElement("div",{className:styles$$1.editor},React__default.createElement(Preview,{raw:this.state.raw,decorators:decorators,typeMappers:typeMappers,config:config,theme:theme,isMobile:isMobile,anchorTarget:anchorTarget,relValue:relValue})),React__default.createElement(wixRichContentCommon.AccessibilityListener,{isMobile:isMobile}))},RichContentViewer}(React.Component);return RichContentViewer.propTypes={initialState:PropTypes.object,isMobile:PropTypes.bool,helpers:PropTypes.object,platform:PropTypes.string,typeMappers:PropTypes.arrayOf(PropTypes.func),decorators:PropTypes.arrayOf(PropTypes.shape({component:PropTypes.func.isRequired,strategy:PropTypes.func.isRequired})),theme:PropTypes.object,anchorTarget:PropTypes.string,relValue:PropTypes.string,config:PropTypes.object},RichContentViewer.defaultProps={theme:{},decorators:[],typeMappers:[]},exports.RichContentViewer=RichContentViewer,exports}({},_extends,_objectWithoutPropertiesLoose,React,PropTypes,classNames,isFunction,wixRichContentCommon,_inheritsLoose); | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=Viewer.js.map |
{ | ||
"name": "wix-rich-content-viewer", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Jonathan Bachman", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
432219
489
1