dante2-editor 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.babelrc +20 -0
- data/.eslint +13 -0
- data/.gitignore +15 -0
- data/README.md +5 -1
- data/dante2.gemspec +2 -4
- data/{app → demo}/assets/index.html +2 -2
- data/{app → demo}/assets/license.html +1 -1
- data/{app → demo}/assets/options.html +1 -5
- data/{app → demo}/assets/store.json +0 -0
- data/demo/data/poc.js +9 -0
- data/demo/demo.js +9 -0
- data/demo/initialize.js +7 -0
- data/{app → demo}/styles/layout/layout.scss +0 -0
- data/{app → demo}/styles/layout/normalize.css +0 -0
- data/{app → demo}/styles/layout/scaffold.scss +0 -0
- data/{app → demo}/styles/layout/tooltips.scss +0 -0
- data/dist/Dante2.js +2995 -0
- data/dist/Dante2.min.js +3 -0
- data/dist/Dante2.min.js.map +1 -0
- data/dist/DanteStyles.css +2 -0
- data/dist/DanteStyles.css.map +1 -0
- data/dist/DanteStyles.js +102 -0
- data/dist/DanteStyles.min.js +2 -0
- data/dist/DanteStyles.min.js.map +1 -0
- data/dist/dante-vendors.js +48316 -0
- data/dist/dante-vendors.min.js +29 -0
- data/dist/dante-vendors.min.js.map +1 -0
- data/{app/styles/fonts/dante → dist/fonts}/dante.eot +0 -0
- data/{app/styles/fonts/dante → dist/fonts}/dante.svg +0 -0
- data/{app/styles/fonts/dante → dist/fonts}/dante.ttf +0 -0
- data/{app/styles/fonts/dante → dist/fonts}/dante.woff +0 -0
- data/{app/styles/fonts/dante → dist/fonts}/fontello.eot +0 -0
- data/{app/styles/fonts/dante → dist/fonts}/fontello.svg +0 -0
- data/{app/styles/fonts/dante → dist/fonts}/fontello.ttf +0 -0
- data/{app/styles/fonts/dante → dist/fonts}/fontello.woff +0 -0
- data/docs/app.css +430 -1
- data/docs/app.css.map +1 -1
- data/docs/app.js +62 -2
- data/docs/app.js.map +1 -1
- data/docs/dante-vendors.js +49513 -22
- data/docs/dante-vendors.js.map +1 -1
- data/docs/dante.css +1602 -1
- data/docs/dante.css.map +1 -1
- data/docs/dante.js +3310 -3
- data/docs/dante.js.map +1 -1
- data/docs/doc.html +3 -7
- data/docs/index.html +4 -4
- data/docs/license.html +3 -3
- data/docs/options.html +53 -0
- data/package.json +47 -17
- data/rb_lib/dante2-editor/rails.rb +15 -0
- data/{lib → rb_lib}/dante2-editor/version.rb +1 -1
- data/{lib → rb_lib}/dante2-editor.rb +0 -0
- data/src/components/blocks/embed.js +126 -0
- data/src/components/blocks/image.js +377 -0
- data/src/components/blocks/placeholder.js +68 -0
- data/src/components/blocks/video.js +80 -0
- data/src/components/dante.js +291 -0
- data/src/components/dante_editor.js +928 -0
- data/src/components/debug.js +104 -0
- data/src/components/decorators/link.js +64 -0
- data/src/components/popovers/addButton.js +318 -0
- data/src/components/popovers/image.js +188 -0
- data/src/components/popovers/link.js +107 -0
- data/src/components/popovers/toolTip.js +402 -0
- data/{app/utils/logger.coffee → src/components/wrapper.js} +0 -0
- data/{app → src}/images/dante/media-loading-placeholder.png +0 -0
- data/{app → src}/images/site/dante-demo.png +0 -0
- data/{app → src}/images/site/dante-editor-logo.png +0 -0
- data/{app → src}/images/site/github-logo.png +0 -0
- data/src/index.js +9 -0
- data/{app → src}/model/index.js +0 -0
- data/src/style.js +3 -0
- data/{app → src}/styles/dante/_animations.scss +0 -0
- data/{app → src}/styles/dante/_caption.scss +0 -0
- data/{app → src}/styles/dante/_debug.scss +0 -0
- data/{app → src}/styles/dante/_fonts.scss +0 -0
- data/{app → src}/styles/dante/_graf.scss +0 -0
- data/{app → src}/styles/dante/_icons.scss +0 -0
- data/{app → src}/styles/dante/_media.scss +0 -0
- data/{app → src}/styles/dante/_menu.scss +0 -0
- data/{app → src}/styles/dante/_needsorder.scss +0 -0
- data/{app → src}/styles/dante/_popover.scss +0 -0
- data/{app → src}/styles/dante/_post.scss +0 -0
- data/{app → src}/styles/dante/_scaffold.scss +0 -0
- data/{app → src}/styles/dante/_tooltip.scss +0 -0
- data/{app → src}/styles/dante/_utilities.scss +0 -0
- data/{app → src}/styles/dante/_variables.scss +0 -0
- data/{app → src}/styles/dante/blame.scss +0 -0
- data/{app → src}/styles/dante.scss +0 -0
- data/{app → src}/styles/draft.css +0 -0
- data/src/styles/fonts/dante/dante.eot +0 -0
- data/src/styles/fonts/dante/dante.svg +18 -0
- data/src/styles/fonts/dante/dante.ttf +0 -0
- data/src/styles/fonts/dante/dante.woff +0 -0
- data/src/styles/fonts/dante/fontello.eot +0 -0
- data/src/styles/fonts/dante/fontello.svg +36 -0
- data/src/styles/fonts/dante/fontello.ttf +0 -0
- data/src/styles/fonts/dante/fontello.woff +0 -0
- data/src/utils/find_entities.js +17 -0
- data/src/utils/html2content.js +127 -0
- data/src/utils/save_content.js +80 -0
- data/{app → src}/utils/selection.js +0 -0
- data/tools/.eslintrc +9 -0
- data/tools/amd/README.md +7 -0
- data/tools/amd/bower.json +19 -0
- data/tools/amd/build.js +36 -0
- data/tools/build-cli.js +46 -0
- data/tools/build.js +30 -0
- data/tools/buildBabel.js +32 -0
- data/tools/constants.js +10 -0
- data/tools/dist/build.js +13 -0
- data/tools/docs/build.js +12 -0
- data/tools/es/build.js +27 -0
- data/tools/exec.js +50 -0
- data/tools/fs-utils.js +35 -0
- data/tools/lib/build.js +14 -0
- data/tools/promisify.js +14 -0
- data/webpack/base.config.js +89 -0
- data/webpack/docs.config.js +147 -0
- data/webpack/webpack.config.js +78 -0
- data/webpack.config-doc.js +5 -0
- data/webpack.config.js +3 -147
- data/yarn.lock +973 -718
- metadata +108 -64
- data/app/components/App.cjsx +0 -1083
- data/app/components/blocks/embed.cjsx +0 -109
- data/app/components/blocks/image.cjsx +0 -316
- data/app/components/blocks/placeholder.cjsx +0 -60
- data/app/components/blocks/video.cjsx +0 -75
- data/app/components/debug.cjsx +0 -96
- data/app/components/decorators/link.cjsx +0 -61
- data/app/components/popovers/addButton.cjsx +0 -247
- data/app/components/popovers/image.cjsx +0 -160
- data/app/components/popovers/link.cjsx +0 -87
- data/app/components/popovers/toolTip.cjsx +0 -326
- data/app/data/poc.js +0 -15
- data/app/demo.js +0 -7
- data/app/initialize.js +0 -4
- data/app/utils/find_entities.coffee +0 -20
- data/app/utils/html2content.coffee +0 -120
- data/app/utils/save_content.coffee +0 -63
- data/lib/dante2-editor/rails.rb +0 -16
data/docs/dante.js
CHANGED
@@ -1,4 +1,3311 @@
|
|
1
|
-
webpackJsonp([1],{0:function(t,e,o){"use strict";o(280),window.Dante=o(195)},25:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.addNewBlockAt=e.updateTextOfBlock=e.updateDataOfBlock=e.resetBlockWithType=e.addNewBlock=e.getCurrentBlock=e.getNode=e.getDefaultBlockData=void 0;var i=o(36),n=o(9),r=e.getDefaultBlockData=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t){default:return e}},s=(e.getNode=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,e=null;return t.getSelection?e=t.getSelection():t.document.getSelection?e=t.document.getSelection():t.document.selection&&(e=t.document.selection.createRange().text),e},e.getCurrentBlock=function(t){var e=t.getSelection(),o=t.getCurrentContent(),i=o.getBlockForKey(e.getStartKey());return i});e.addNewBlock=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unstyled",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getSelection();if(!i.isCollapsed())return t;var a=t.getCurrentContent(),l=i.getStartKey(),c=a.getBlockMap(),p=s(t);if(!p)return t;if(0===p.getLength()){if(p.getType()===e)return t;var h=p.merge({type:e,data:r(e,o)}),d=a.merge({blockMap:c.set(l,h),selectionAfter:i});return n.EditorState.push(t,d,"change-block-type")}return t},e.resetBlockWithType=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unstyled",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getCurrentContent(),s=t.getSelection(),a=s.getStartKey(),l=i.getBlockMap(),c=l.get(a),p="";console.log("DATA FOR PLACEHOLDER!",o);var h=c.getText();c.getLength()>=2&&(p=h.substr(1));var d=c.merge({text:p,type:e,data:r(e,o)}),u=i.merge({blockMap:l.set(a,d),selectionAfter:s.merge({anchorOffset:0,focusOffset:0})});return n.EditorState.push(t,u,"change-block-type")},e.updateDataOfBlock=function(t,e,o){var i=t.getCurrentContent(),r=e.merge({data:o}),s=i.merge({blockMap:i.getBlockMap().set(e.getKey(),r)});return n.EditorState.push(t,s,"change-block-type")},e.updateTextOfBlock=function(t,e,o){var i=t.getCurrentContent(),r=e.merge({text:o}),s=i.merge({blockMap:i.getBlockMap().set(e.getKey(),r)});return n.EditorState.push(t,s,"change-block-type")},e.addNewBlockAt=function(t,e){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unstyled",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=t.getCurrentContent(),l=a.getBlockMap(),c=l.get(e),p=l.toSeq().takeUntil(function(t){return t===c}),h=l.toSeq().skipUntil(function(t){return t===c}).rest(),d=(0,n.genKey)(),u=new n.ContentBlock({key:d,type:o,text:"",characterList:c.getCharacterList().slice(0,0),depth:0,data:(0,i.Map)(r(o,s))}),f=p.concat([[e,c],[d,u]],h).toOrderedMap(),g=t.getSelection(),m=a.merge({blockMap:f,selectionBefore:g,selectionAfter:g.merge({anchorKey:d,anchorOffset:0,focusKey:d,focusOffset:0,isBackward:!1})});return n.EditorState.push(t,m,"split-block")}},48:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getSelectionRect=function(t){var e=t.getRangeAt(0).getBoundingClientRect(),o=e&&e.top?e:t.getRangeAt(0).getClientRects()[0];if(!o){if(!t.anchorNode||!t.anchorNode.getBoundingClientRect)return null;o=t.anchorNode.getBoundingClientRect(),o.isEmptyline=!0}return o},e.getSelection=function(t){var e=null;return t.getSelection?e=t.getSelection():t.document.getSelection?e=t.document.getSelection():t.document.selection&&(e=t.document.selection.createRange().text),e},e.getSelectedBlockNode=function(t){var e=t.getSelection();if(0===e.rangeCount)return null;var o=e.getRangeAt(0).startContainer;do{if(o.getAttribute&&"true"===o.getAttribute("data-block"))return o;o=o.parentNode}while(null!==o);return null}},144:function(t,e,o){t.exports=o.p+"fonts/dante.eot"},145:function(t,e,o){t.exports=o.p+"fonts/fontello.eot"},192:function(t,e,o){var i,n;i=o(9).Entity,n=function(t,e,o,n){return o.findEntityRanges(function(o){return function(o){var n,r,s;return n=o.getEntity(),s=null!==n&&i.get(n).getType()===t,s?(r={showPopLinkOver:e.showPopLinkOver,hidePopLinkOver:e.hidePopLinkOver},i.mergeData(n,r)):void 0,s}}(this),n)},t.exports=n},193:function(t,e,o){var i,n,r,s,a,l,c,p,h,d,u,f,g,m,y,k,_,v,b,S,E;v=o(9),r=v.ContentState,g=v.genKey,s=v.Entity,i=v.CharacterMetadata,n=v.ContentBlock,h=v.convertFromHTML,y=v.getSafeBodyFromHTML,b=o(36),a=b.List,l=b.OrderedSet,c=b.Repeat,f=b.fromJS,p=function(){var t,e;return t=arguments,e=t.length-1,function(){var o,i;for(o=e,i=t[e].apply(this,arguments);o--;)i=t[o].call(this,i);return i}},m=function(t){return function(t){return{contentType:"image",imgSrc:t.getAttribute("src")}}}(this),E=function(t){return function(t){var e;return null===t?null:(e=document.createElement("blockquote"),e.innerText=JSON.stringify(t),e)}}(this),S=function(t){return function(t,e){var o;if(e instanceof HTMLElement)return o=k(t),o.parentNode.insertBefore(e,o)}}(this),k=function(t){return function(t){var e;for(e=t;t.parentNode;)if("BODY"!==t.parentNode.tagName&&(t=t.parentNode),"BODY"===t.parentNode.tagName)return t}}(this),u=p(E,m),_=function(t){return function(t){return S(t,u(t))}}(this),d=function(t,e){var o,i,n;return n=(new DOMParser).parseFromString(t,"text/html"),o=n.querySelectorAll("img").forEach(function(t){return _(t)}),console.log(n.body.innerHTML),i=h(n.body.innerHTML,y,e),i=i.map(function(t){var e,o;if(console.log("CHECK BLOCK",t.getType()),"blockquote"!==t.getType())return t;e="";try{e=JSON.parse(t.getText())}catch(i){return t}return o=t.merge({type:"image",text:"",data:{url:e.imgSrc,forceUpload:!0}})}),n=null,r.createFromBlockArray(i)},t.exports=d},194:function(t,e,o){var i,n,r;r=o(47),i=o(36),n=function(){function t(t){this.getLocks=t.getLocks,this.config=t.config,this.editorContent=t.editorContent,this.editorState=t.editorState}return t.prototype.handleStore=function(t){return this.store()},t.prototype.store=function(t){if(this.config.data_storage.url&&!(this.getLocks()>0))return clearTimeout(this.timeout),this.timeout=setTimeout(function(e){return function(){return e.checkforStore(t)}}(this),this.config.data_storage.interval)},t.prototype.getTextFromEditor=function(t){return t.blocks.map(function(t){return function(t){return t.text}}(this)).join("\n")},t.prototype.getUrl=function(){var t;return t=this.config.data_storage.url,"function"==typeof t?t():t},t.prototype.getMethod=function(){var t;return t=this.config.data_storage.method,"function"==typeof t?t():t},t.prototype.checkforStore=function(t){var e;if(e=!i.is(i.fromJS(this.editorContent),i.fromJS(t)))return this.config.xhr.before_handler&&this.config.xhr.before_handler(),r({method:this.getMethod(),url:this.getUrl(),data:{editor_content:JSON.stringify(t),text_content:this.getTextFromEditor(t)}}).then(function(t){return function(e){if(t.config.data_storage.success_handler&&t.config.data_storage.success_handler(e),t.config.xhr.success_handler)return t.config.xhr.success_handler(e)}}(this))["catch"](function(t){return function(e){if(t.config.xhr.failure_handler)return t.config.xhr.failure_handler(e)}}(this))},t}(),t.exports=n},195:function(module,exports,__webpack_require__){var BlockMapBuilder,CompositeDecorator,ContentState,Dante,DanteAnchorPopover,DanteEditor,DanteImagePopover,DanteInlineTooltip,DanteTooltip,Debug,DefaultDraftBlockRenderMap,DraftPasteProcessor,Editor,EditorState,EmbedBlock,Entity,ImageBlock,Immutable,KeyBindingUtil,Link,Map,Modifier,PlaceholderBlock,React,ReactDOM,RichUtils,SaveBehavior,SelectionState,VideoBlock,addNewBlock,addNewBlockAt,convertFromHTML,convertFromRaw,convertToHTML,convertToRaw,customHTML2Content,findEntities,fromJS,getCurrentBlock,getDefaultKeyBinding,getSafeBodyFromHTML,getSelection,getSelectionOffsetKeyForNode,getSelectionRect,getVisibleSelectionRect,isSoftNewlineEvent,ref,ref1,ref2,ref3,ref4,resetBlockWithType,updateDataOfBlock,updateTextOfBlock,bind=function(t,e){return function(){return t.apply(e,arguments)}},extend=function(t,e){function o(){this.constructor=t}for(var i in e)hasProp.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},hasProp={}.hasOwnProperty;React=__webpack_require__(6),ReactDOM=__webpack_require__(13),Immutable=__webpack_require__(36),ref=__webpack_require__(36),Map=ref.Map,fromJS=ref.fromJS,ref1=__webpack_require__(9),convertToRaw=ref1.convertToRaw,convertFromRaw=ref1.convertFromRaw,CompositeDecorator=ref1.CompositeDecorator,getVisibleSelectionRect=ref1.getVisibleSelectionRect,getDefaultKeyBinding=ref1.getDefaultKeyBinding,getSelectionOffsetKeyForNode=ref1.getSelectionOffsetKeyForNode,KeyBindingUtil=ref1.KeyBindingUtil,ContentState=ref1.ContentState,Editor=ref1.Editor,EditorState=ref1.EditorState,Entity=ref1.Entity,RichUtils=ref1.RichUtils,DefaultDraftBlockRenderMap=ref1.DefaultDraftBlockRenderMap,SelectionState=ref1.SelectionState,Modifier=ref1.Modifier,BlockMapBuilder=ref1.BlockMapBuilder,getSafeBodyFromHTML=ref1.getSafeBodyFromHTML,DraftPasteProcessor=__webpack_require__(118),ref2=__webpack_require__(213),convertToHTML=ref2.convertToHTML,convertFromHTML=ref2.convertFromHTML,isSoftNewlineEvent=__webpack_require__(263),ref3=__webpack_require__(25),addNewBlock=ref3.addNewBlock,resetBlockWithType=ref3.resetBlockWithType,updateDataOfBlock=ref3.updateDataOfBlock,updateTextOfBlock=ref3.updateTextOfBlock,getCurrentBlock=ref3.getCurrentBlock,addNewBlockAt=ref3.addNewBlockAt,updateDataOfBlock=ref3.updateDataOfBlock,DanteImagePopover=__webpack_require__(203),DanteAnchorPopover=__webpack_require__(204),ref4=__webpack_require__(48),getSelectionRect=ref4.getSelectionRect,getSelection=ref4.getSelection,DanteInlineTooltip=__webpack_require__(202),DanteTooltip=__webpack_require__(205),Link=__webpack_require__(201),Debug=__webpack_require__(200),findEntities=__webpack_require__(192),ImageBlock=__webpack_require__(197),EmbedBlock=__webpack_require__(196),VideoBlock=__webpack_require__(199),PlaceholderBlock=__webpack_require__(198),SaveBehavior=__webpack_require__(194),customHTML2Content=__webpack_require__(193),Dante=function(){function t(t){var e;null==t&&(t={}),console.log("init editor Dante!"),e=Map(fromJS(this.defaultOptions(t))),this.options=e.mergeDeep(t).toJS(),console.log(this.options)}return t.prototype.defaultOptions=function(t){var e;return null==t&&(t={}),e={},e.el="app",e.content="",e.read_only=!1,e.spellcheck=!1,e.title_placeholder="Title",e.body_placeholder="Write your story",e.widgets=[{title:"add an image",icon:"image",type:"image",block:"ImageBlock",editable:!0,renderable:!0,breakOnContinuous:!0,wrapper_class:"graf graf--figure",selected_class:"is-selected is-mediaFocused",selectedFn:function(t){return function(t){var e;switch(e=t.getData().toJS().direction){case"left":return"graf--layoutOutsetLeft";case"center":return"";case"wide":return"sectionLayout--fullWidth";case"fill":return"graf--layoutFillWidth"}}}(this),handleEnterWithoutText:function(t,e){var o;return o=t.state.editorState,t.onChange(addNewBlockAt(o,e.getKey()))},handleEnterWithText:function(t,e){var o;return o=t.state.editorState,t.onChange(addNewBlockAt(o,e.getKey()))},widget_options:{displayOnInlineTooltip:!0,insertion:"upload",insert_block:"image"},options:{upload_url:t.upload_url,upload_callback:t.image_upload_callback,image_delete_callback:t.image_delete_callback,image_caption_placeholder:t.image_caption_placeholder}},{icon:"embed",title:"insert embed",type:"embed",block:"EmbedBlock",editable:!0,renderable:!0,breakOnContinuous:!0,wrapper_class:"graf graf--mixtapeEmbed",selected_class:"is-selected is-mediaFocused",widget_options:{displayOnInlineTooltip:!0,insertion:"placeholder",insert_block:"embed"},options:{endpoint:"//api.embed.ly/1/extract?key="+t.api_key+"&url=",placeholder:"Paste a link to embed content from another site (e.g. Twitter) and press Enter"},handleEnterWithoutText:function(t,e){var o;return o=t.state.editorState,t.onChange(addNewBlockAt(o,e.getKey()))},handleEnterWithText:function(t,e){var o;return o=t.state.editorState,t.onChange(addNewBlockAt(o,e.getKey()))}},{icon:"video",title:"insert video",editable:!0,type:"video",block:"VideoBlock",renderable:!0,breakOnContinuous:!0,wrapper_class:"graf--figure graf--iframe",selected_class:" is-selected is-mediaFocused",widget_options:{displayOnInlineTooltip:!0,insertion:"placeholder",insert_block:"video"},options:{endpoint:"//api.embed.ly/1/oembed?key="+t.api_key+"&url=",placeholder:"Paste a YouTube, Vine, Vimeo, or other video link, and press Enter",caption:"Type caption for embed (optional)"},handleEnterWithoutText:function(t,e){var o;return o=t.state.editorState,t.onChange(addNewBlockAt(o,e.getKey()))},handleEnterWithText:function(t,e){var o;return o=t.state.editorState,t.onChange(addNewBlockAt(o,e.getKey()))}},{renderable:!0,editable:!0,block:"PlaceholderBlock",type:"placeholder",wrapper_class:"is-embedable",selected_class:" is-selected is-mediaFocused",widget_options:{displayOnInlineTooltip:!1},handleEnterWithText:function(t,e){var o,i;return i=t.state.editorState,o={provisory_text:e.getText(),endpoint:e.getData().get("endpoint"),type:e.getData().get("type")},t.onChange(resetBlockWithType(i,o.type,o))}}],e.tooltips=[{ref:"insert_tooltip",component:DanteTooltip,displayOnSelection:!0,selectionElements:["unstyled","blockquote","ordered-list","unordered-list","unordered-list-item","ordered-list-item","code-block","header-one","header-two","header-three","header-four"],widget_options:{block_types:[{label:"h2",style:"header-one",type:"block"},{label:"h3",style:"header-two",type:"block"},{label:"h4",style:"header-three",type:"block"},{label:"blockquote",style:"blockquote",type:"block"},{label:"insertunorderedlist",style:"unordered-list-item",type:"block"},{label:"insertorderedlist",style:"ordered-list-item",type:"block"},{label:"code",style:"code-block",type:"block"},{label:"bold",style:"BOLD",type:"inline"},{label:"italic",style:"ITALIC",type:"inline"}]}},{ref:"add_tooltip",component:DanteInlineTooltip},{ref:"anchor_popover",component:DanteAnchorPopover},{ref:"image_popover",component:DanteImagePopover}],e.xhr={before_handler:null,success_handler:null,error_handler:null},e.data_storage={url:null,method:"POST",success_handler:null,failure_handler:null,interval:1500},e.default_wrappers=[{className:"graf--p",block:"unstyled"},{className:"graf--h2",block:"header-one"},{className:"graf--h3",block:"header-two"},{className:"graf--h4",block:"header-three"},{className:"graf--blockquote",block:"blockquote"},{className:"graf--insertunorderedlist",block:"unordered-list-item"},{className:"graf--insertorderedlist",block:"ordered-list-item"},{className:"graf--code",block:"code-block"},{className:"graf--bold",block:"BOLD"},{className:"graf--italic",block:"ITALIC"}],e.continuousBlocks=["unstyled","blockquote","ordered-list","unordered-list","unordered-list-item","ordered-list-item","code-block"],e.key_commands={"alt-shift":[{key:65,cmd:"add-new-block"}],"alt-cmd":[{key:49,cmd:"toggle_block:header-one"},{key:50,cmd:"toggle_block:header-two"},{key:53,cmd:"toggle_block:blockquote"}],cmd:[{key:66,cmd:"toggle_inline:BOLD"},{key:73,cmd:"toggle_inline:ITALIC"},{key:75,cmd:"insert:link"}]},e.character_convert_mapping={"> ":"blockquote","*.":"unordered-list-item","* ":"unordered-list-item","- ":"unordered-list-item","1.":"ordered-list-item","# ":"header-one","##":"header-two","==":"unstyled","` ":"code-block"},e},t.prototype.getContent=function(){return this.options.content},t.prototype.render=function(){return ReactDOM.render(React.createElement(DanteEditor,{content:this.getContent(),config:this.options}),document.getElementById(this.options.el))},t}(),DanteEditor=function(superClass){function DanteEditor(t){this.render=bind(this.render,this),this.hidePopLinkOver=bind(this.hidePopLinkOver,this),this.showPopLinkOver=bind(this.showPopLinkOver,this),this.handleHidePopLinkOver=bind(this.handleHidePopLinkOver,this),this.handleShowPopLinkOver=bind(this.handleShowPopLinkOver,this),this.tooltipHasSelectionElement=bind(this.tooltipHasSelectionElement,this),this.tooltipsWithProp=bind(this.tooltipsWithProp,this),this.relocateTooltips=bind(this.relocateTooltips,this),this.closePopOvers=bind(this.closePopOvers,this),this.toggleEditable=bind(this.toggleEditable,this),this.setDirection=bind(this.setDirection,this),this.updateBlockData=bind(this.updateBlockData,this),this.KeyBindingFn=bind(this.KeyBindingFn,this),this.findCommandKey=bind(this.findCommandKey,this),this.handleKeyCommand=bind(this.handleKeyCommand,this),this.handleBeforeInput=bind(this.handleBeforeInput,this),this.handleReturn=bind(this.handleReturn,this),this.handleDownArrow=bind(this.handleDownArrow,this),this.handleUpArrow=bind(this.handleUpArrow,this),this.handleDroppedFiles=bind(this.handleDroppedFiles,this),this.handlePasteImage=bind(this.handlePasteImage,this),this.handleHTMLPaste=bind(this.handleHTMLPaste,this),this.handleTXTPaste=bind(this.handleTXTPaste,this),this.handlePasteText=bind(this.handlePasteText,this),this.styleForBlock=bind(this.styleForBlock,this),this.getDataBlock=bind(this.getDataBlock,this),this.blockStyleFn=bind(this.blockStyleFn,this),this.handleBlockRenderer=bind(this.handleBlockRenderer,this),this.blockRenderer=bind(this.blockRenderer,this),this.defaultWrappers=bind(this.defaultWrappers,this),this.renderableBlocks=bind(this.renderableBlocks,this),this.removeLock=bind(this.removeLock,this),this.addLock=bind(this.addLock,this),this.getLocks=bind(this.getLocks,this),this.getTextFromEditor=bind(this.getTextFromEditor,this),this.decodeEditorContent=bind(this.decodeEditorContent,this),this.emitSerializedOutput=bind(this.emitSerializedOutput,this),this.getEditorState=bind(this.getEditorState,this),this.focus=bind(this.focus,this),this.setPreContent=bind(this.setPreContent,this),this.dispatchChangesToSave=bind(this.dispatchChangesToSave,this),this.onChange=bind(this.onChange,this),this.forceRender=bind(this.forceRender,this),this.refreshSelection=bind(this.refreshSelection,this),this.initializeState=bind(this.initializeState,this),DanteEditor.__super__.constructor.call(this,t),this.decorator=new CompositeDecorator([{strategy:findEntities.bind(null,"LINK",this),component:Link}]),this.blockRenderMap=Map({image:{element:"figure"},video:{element:"figure"},embed:{element:"div"},unstyled:{wrapper:null,element:"div"},paragraph:{wrapper:null,element:"div"},placeholder:{wrapper:null,element:"div"}}),this.extendedBlockRenderMap=DefaultDraftBlockRenderMap.merge(this.blockRenderMap),this.state={editorState:this.initializeState(),read_only:this.props.config.read_only,blockRenderMap:this.extendedBlockRenderMap,locks:0,debug:this.props.config.debug},this.widgets=this.props.config.widgets,this.tooltips=this.props.config.tooltips,this.key_commands=this.props.config.key_commands,this.continuousBlocks=this.props.config.continuousBlocks,this.block_types=this.props.config.block_types,this.default_wrappers=this.props.config.default_wrappers,this.character_convert_mapping=this.props.config.character_convert_mapping,this.save=new SaveBehavior({getLocks:this.getLocks,config:{xhr:this.props.config.xhr,data_storage:this.props.config.data_storage},editorState:this.state.editorState,editorContent:this.emitSerializedOutput()})}return extend(DanteEditor,superClass),DanteEditor.prototype.initializeState=function(){return this.props.content?this.decodeEditorContent(this.props.content):EditorState.createEmpty(this.decorator)},DanteEditor.prototype.refreshSelection=function(t){var e,o,i,n,r,s,a;return i=this.state.editorState,s=this.state.editorState.getSelection(),o=i.getCurrentContent(),a=SelectionState.createEmpty(s.getAnchorKey()),n=s.getFocusOffset(),e=s.getAnchorKey(),a=a.merge({anchorOffset:n,focusKey:e,focusOffset:n}),r=EditorState.forceSelection(t,a),this.onChange(r)},DanteEditor.prototype.forceRender=function(t){var e,o,i;return i=this.state.editorState.getSelection(),e=t.getCurrentContent(),o=EditorState.createWithContent(e,this.decorator),this.refreshSelection(o)},DanteEditor.prototype.onChange=function(t){var e,o,i;if(this.setPreContent(),this.setState({editorState:t}),o=getCurrentBlock(this.state.editorState),e=o.getType(),t.getSelection().isCollapsed())this.handleTooltipDisplayOn("displayOnSelection",!1);else{if(i=this.tooltipsWithProp("displayOnSelection")[0],!this.tooltipHasSelectionElement(i,e))return;this.handleTooltipDisplayOn("displayOnSelection")}return setTimeout(function(t){return function(){return t.relocateTooltips()}}(this),0),this.dispatchChangesToSave()},DanteEditor.prototype.dispatchChangesToSave=function(){return clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(function(t){return function(){return t.save.store(t.emitSerializedOutput())}}(this),100)},DanteEditor.prototype.setPreContent=function(){var t;return t=this.emitSerializedOutput(),this.save.editorContent=t},DanteEditor.prototype.focus=function(){},DanteEditor.prototype.getEditorState=function(){return this.state.editorState},DanteEditor.prototype.emitSerializedOutput=function(){var t;return t=convertToRaw(this.state.editorState.getCurrentContent())},DanteEditor.prototype.decodeEditorContent=function(t){var e,o;return o=convertFromRaw(t),e=EditorState.createWithContent(o,this.decorator)},DanteEditor.prototype.getTextFromEditor=function(){var t,e;return t=this.state.editorState.getCurrentContent(),e=t.getBlocksAsArray().map(function(t){return function(t){return t.getText()}}(this)).join("\n"),console.log(e),e},DanteEditor.prototype.emitHTML2=function(){var t;return t=convertToHTML({entityToHTML:function(t){return function(t,e){return"LINK"===t.type?'<a href="'+t.data.url+'">'+e+"</a>":e}}(this)})(this.state.editorState.getCurrentContent())},DanteEditor.prototype.getLocks=function(){return this.state.locks},DanteEditor.prototype.addLock=function(){return this.setState({locks:this.state.locks+=1})},DanteEditor.prototype.removeLock=function(){return this.setState({locks:this.state.locks-=1})},DanteEditor.prototype.renderableBlocks=function(){return this.widgets.filter(function(t){return t.renderable}).map(function(t){return t.type})},DanteEditor.prototype.defaultWrappers=function(t){return this.default_wrappers.filter(function(e){return function(e){return e.block===t}}(this)).map(function(t){return t.className})},DanteEditor.prototype.blockRenderer=function(t){var e,o;switch(t.getType()){case"atomic":e=t.getEntityAt(0),o=Entity.get(e).getType()}return this.renderableBlocks().includes(t.getType())?this.handleBlockRenderer(t):null},DanteEditor.prototype.handleBlockRenderer=function(block){var dataBlock,editable,read_only;return(dataBlock=this.getDataBlock(block))?(read_only=!this.state.read_only&&null,editable=null!==read_only?read_only:dataBlock.editable,{component:eval(dataBlock.block),editable:editable,props:{data:block.getData(),getEditorState:this.getEditorState,setEditorState:this.onChange,addLock:this.addLock,removeLock:this.removeLock,getLocks:this.getLocks,config:dataBlock.options}}):null},DanteEditor.prototype.blockStyleFn=function(t){var e,o,i;return e=getCurrentBlock(this.state.editorState),i=e.getKey()===t.getKey()?"is-selected":"",this.renderableBlocks().includes(t.getType())?this.styleForBlock(t,e,i):(o=this.defaultWrappers(t.getType()),o.length>0?"graf "+o[0]+" "+i:"graf nana "+i)},DanteEditor.prototype.getDataBlock=function(t){return this.widgets.find(function(e){return function(e){return e.type===t.getType()}}(this))},DanteEditor.prototype.styleForBlock=function(t,e,o){var i,n,r;return(i=this.getDataBlock(t))?(n=i.selectedFn?i.selectedFn(t):null,r=o?i.selected_class:"",i.wrapper_class+" "+r+" "+n):null},DanteEditor.prototype.handleTooltipDisplayOn=function(t,e){return null==e&&(e=!0),setTimeout(function(o){return function(){var i;return i=o.tooltipsWithProp(t),i.map(function(t){return o.refs[t.ref].display(e),o.refs[t.ref].relocate()})}}(this),20)},DanteEditor.prototype.handlePasteText=function(t,e){return e?e?this.handleHTMLPaste(t,e):void 0:this.handleTXTPaste(t,e)},DanteEditor.prototype.handleTXTPaste=function(t,e){var o,i,n;switch(o=getCurrentBlock(this.state.editorState),i=this.state.editorState,o.getType()){case"image":case"video":case"placeholder":return n=Modifier.replaceText(i.getCurrentContent(),new SelectionState({anchorKey:o.getKey(),anchorOffset:0,focusKey:o.getKey(),focusOffset:2}),t),i=EditorState.push(i,n,"replace-text"),this.onChange(i),!0;default:return!1}},DanteEditor.prototype.handleHTMLPaste=function(t,e){var o,i,n,r,s,a,l,c,p,h,d;switch(r=getCurrentBlock(this.state.editorState),r.getType()){case"image":case"video":case"placeholder":return this.handleTXTPaste(t,e)}return p=customHTML2Content(e,this.extendedBlockRenderMap),d=this.state.editorState.getSelection(),s=d.getEndKey(),n=this.state.editorState.getCurrentContent(),i=n.blockMap.toSeq().takeUntil(function(t){return function(t){return t.key===s}}(this)),o=n.blockMap.toSeq().skipUntil(function(t){return function(t){return t.key===s}}(this)).rest(),a=p.blockMap.first().getKey(),l=i.concat(p.blockMap,o).toOrderedMap(),c=n.merge({blockMap:l,selectionBefore:d,selectionAfter:d.merge({anchorKey:a,anchorOffset:0,focusKey:a,focusOffset:0,isBackward:!1})}),h=EditorState.push(this.state.editorState,c,"insert-fragment"),this.onChange(h),!0},DanteEditor.prototype.handlePasteImage=function(t){return t.map(function(t){return function(e){var o;return o={url:URL.createObjectURL(e),file:e},t.onChange(addNewBlock(t.state.editorState,"image",o))}}(this))},DanteEditor.prototype.handleDroppedFiles=function(t,e){return e.map(function(t){return function(e){var o;return o={url:URL.createObjectURL(e),file:e},t.onChange(addNewBlock(t.state.editorState,"image",o))}}(this))},DanteEditor.prototype.handleUpArrow=function(t){return setTimeout(function(t){return function(){return t.forceRender(t.state.editorState)}}(this),10)},DanteEditor.prototype.handleDownArrow=function(t){return setTimeout(function(t){return function(){return t.forceRender(t.state.editorState)}}(this),10)},DanteEditor.prototype.handleReturn=function(t){var e,o,i,n,r,s,a;if(this.props.handleReturn&&this.props.handleReturn())return!0;if(n=this.state.editorState,!t.altKey&&!t.metaKey&&!t.ctrlKey){if(i=getCurrentBlock(n),e=i.getType(),a=n.getSelection(),o=this.getDataBlock(i),0===i.getText().length){if(o&&o.handleEnterWithoutText)return o.handleEnterWithText(this,i),this.closePopOvers(),!0;switch(e){case"header-one":return this.onChange(resetBlockWithType(n,"unstyled")),!0;default:return!1}}return i.getText().length>0?"unstyled"===e?(r=Modifier.splitBlock(this.state.editorState.getCurrentContent(),this.state.editorState.getSelection()),s=EditorState.push(this.state.editorState,r,"insert-characters"),this.onChange(s),setTimeout(function(t){return function(){var t,e;return t=document.getElementsByClassName("is-selected"),e=t[0].getBoundingClientRect(),window.scrollTo(0,e.top+window.scrollY-100)}}(this),0),!0):o&&o.handleEnterWithText?(o.handleEnterWithText(this,i),this.closePopOvers(),!0):i.getLength()===a.getStartOffset()&&this.continuousBlocks.indexOf(e)<0&&(this.onChange(addNewBlockAt(n,i.getKey())),!0):i.getLength()===a.getStartOffset()&&this.continuousBlocks.indexOf(e)<0&&(this.onChange(addNewBlockAt(n,i.getKey())),!0)}},DanteEditor.prototype.handleBeforeInput=function(t){var e,o,i,n,r,s,a,l,c,p,h,d,u;return s=getCurrentBlock(this.state.editorState),r=s.getType(),u=this.state.editorState.getSelection(),a=this.state.editorState,0!==s.getText().length&&this.closePopOvers(),p=u.getEndOffset(),c=s.getEntityAt(p-1),l=c&&Entity.get(c).getType(),o=s.getEntityAt(p),e=o&&Entity.get(o).getType()," "===t&&"LINK"===l&&"LINK"!==e?(h=Modifier.insertText(a.getCurrentContent(),u," "),d=EditorState.push(a,h,"insert-characters"),this.onChange(d),!0):0!==r.indexOf("atomic")&&(i=s.getLength(),!(u.getAnchorOffset()>1||i>1||(n=this.character_convert_mapping[s.getText()+t],console.log("BLOCK TO SHOW: "+n),!n||(this.onChange(resetBlockWithType(a,n)),0))))},DanteEditor.prototype.handleKeyCommand=function(t){var e,o,i,n,r;return i=this.state.editorState,!((!this.props.handleKeyCommand||!this.props.handleKeyCommand(t))&&("add-new-block"===t?(this.onChange(addNewBlock(i,"blockquote")),0):(e=getCurrentBlock(i),0===t.indexOf("toggle_inline:")?(n=t.split(":")[1],o=e.getType(),this.onChange(RichUtils.toggleInlineStyle(i,n)),0):0===t.indexOf("toggle_block:")?(n=t.split(":")[1],o=e.getType(),this.onChange(RichUtils.toggleBlockType(i,n)),0):(r=RichUtils.handleKeyCommand(this.state.editorState,t),!r||(this.onChange(r),0)))))},DanteEditor.prototype.findCommandKey=function(t,e){return this.key_commands[t].find(function(t){return t.key===e})},DanteEditor.prototype.KeyBindingFn=function(t){var e;if(t.altKey){if(t.shiftKey)return e=this.findCommandKey("alt-shift",t.which),e?e.cmd:getDefaultKeyBinding(t);if(t.ctrlKey||t.metaKey)return e=this.findCommandKey("alt-cmd",t.which),e?e.cmd:getDefaultKeyBinding(t)}else if(t.ctrlKey||t.metaKey)return e=this.findCommandKey("cmd",t.which),e?e.cmd:getDefaultKeyBinding(t);return getDefaultKeyBinding(t)},DanteEditor.prototype.updateBlockData=function(t,e){var o,i,n;return o=t.getData(),i=o.merge(e),n=updateDataOfBlock(this.state.editorState,t,i),this.forceRender(n)},DanteEditor.prototype.setDirection=function(t){var e,o,i;return o=this.state.editorState.getCurrentContent(),i=this.state.editorState.getSelection(),e=o.getBlockForKey(i.anchorKey),this.updateBlockData(e,{direction:t})},DanteEditor.prototype.toggleEditable=function(){return this.closePopOvers(),this.setState({read_only:!this.state.read_only},this.testEmitAndDecode)},DanteEditor.prototype.closePopOvers=function(){return this.tooltips.map(function(t){return function(e){return t.refs[e.ref].hide()}}(this))},DanteEditor.prototype.relocateTooltips=function(){return this.tooltips.map(function(t){return function(e){return t.refs[e.ref].relocate()}}(this))},DanteEditor.prototype.tooltipsWithProp=function(t){return this.tooltips.filter(function(e){return function(e){return e[t]}}(this))},DanteEditor.prototype.tooltipHasSelectionElement=function(t,e){return t.selectionElements.includes(e)},DanteEditor.prototype.handleShowPopLinkOver=function(t){return this.showPopLinkOver()},DanteEditor.prototype.handleHidePopLinkOver=function(t){return this.hidePopLinkOver()},DanteEditor.prototype.showPopLinkOver=function(t){var e,o;return this.refs.anchor_popover.setState({url:t?t.href:this.refs.anchor_popover.state.url}),o=ReactDOM.findDOMNode(this),t&&(e=this.refs.anchor_popover.relocate(t)),e&&this.refs.anchor_popover.setPosition(e),this.refs.anchor_popover.setState({show:!0}),this.isHover=!0,this.cancelHide()},DanteEditor.prototype.hidePopLinkOver=function(){return this.hideTimeout=setTimeout(function(t){return function(){return t.refs.anchor_popover.hide()}}(this),300)},DanteEditor.prototype.cancelHide=function(){return clearTimeout(this.hideTimeout)},DanteEditor.prototype.render=function(){return React.createElement("div",{id:"content",suppressContentEditableWarning:!0},React.createElement("article",{className:"postArticle"},React.createElement("div",{className:"postContent"},React.createElement("div",{className:"notesSource"},React.createElement("div",{id:"editor",className:"postField postField--body"},React.createElement("section",{className:"section--first section--last"},React.createElement("div",{className:"section-divider layoutSingleColumn"},React.createElement("hr",{className:"section-divider"})),React.createElement("div",{className:"section-content"},React.createElement("div",{ref:"richEditor",className:"section-inner layoutSingleColumn",onClick:this.focus},React.createElement(Editor,{blockRendererFn:this.blockRenderer,editorState:this.state.editorState,onChange:this.onChange,onUpArrow:this.handleUpArrow,onDownArrow:this.handleDownArrow,handleReturn:this.handleReturn,blockRenderMap:this.state.blockRenderMap,blockStyleFn:this.blockStyleFn,handlePastedText:this.handlePasteText,handlePastedFiles:this.handlePasteImage,handleDroppedFiles:this.handleDroppedFiles,handleKeyCommand:this.handleKeyCommand,keyBindingFn:this.KeyBindingFn,handleBeforeInput:this.handleBeforeInput,
|
2
|
-
readOnly:this.state.read_only,placeholder:this.props.config.body_placeholder,ref:"editor"})))))))),this.tooltips.map(function(t){return function(e,o){return React.createElement(e.component,{ref:e.ref,key:o,editor:t,editorState:t.state.editorState,onChange:t.onChange,configTooltip:e,widget_options:e.widget_options,showPopLinkOver:t.showPopLinkOver,hidePopLinkOver:t.hidePopLinkOver,handleOnMouseOver:t.handleShowPopLinkOver,handleOnMouseOut:t.handleHidePopLinkOver})}}(this)),this.state.debug?React.createElement(Debug,{locks:this.state.locks,editor:this}):void 0)},DanteEditor}(React.Component),module.exports=Dante},196:function(t,e,o){var i,n,r,s,a,l,c,p,h,d,u=function(t,e){return function(){return t.apply(e,arguments)}},f=function(t,e){function o(){this.constructor=t}for(var i in e)g.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},g={}.hasOwnProperty;a=o(6),l=o(13),h=o(9),s=h.Entity,c=h.RichUtils,i=h.AtomicBlockUtils,n=h.EditorBlock,p=o(47),d=o(25).updateDataOfBlock,r=function(t){function e(t){this.componentDidMount=u(this.componentDidMount,this),this.dataForUpdate=u(this.dataForUpdate,this),this.updateData=u(this.updateData,this),e.__super__.constructor.call(this,t),this.state={embed_data:this.defaultData(),error:""}}return f(e,t),e.prototype.defaultData=function(){var t;return t=this.props.block.getData().toJS(),t.embed_data||{}},e.prototype.updateData=function(){var t,e,o,i,n,r;return e=this.props.blockProps,t=this.props.block,i=this.props.blockProps.getEditorState,r=this.props.blockProps.setEditorState,o=t.getData(),n=o.merge(this.state),r(d(i(),t,n))},e.prototype.dataForUpdate=function(){return this.props.blockProps.data.toJS()},e.prototype.componentDidMount=function(){if(this.props.blockProps.data&&(this.dataForUpdate().endpoint||this.dataForUpdate().provisory_text))return p({method:"get",url:""+this.dataForUpdate().endpoint+this.dataForUpdate().provisory_text+"&scheme=https"}).then(function(t){return function(e){return t.setState({embed_data:e.data},t.updateData)}}(this))["catch"](function(t){return function(e){return t.setState({error:e.response.data.error_message}),console.log("TODO: error")}}(this))},e.prototype.classForImage=function(){return this.state.embed_data.images?"":"mixtapeImage--empty u-ignoreBlock"},e.prototype.picture=function(){return this.state.embed_data.images&&this.state.embed_data.images.length>0?this.state.embed_data.images[0].url:""},e.prototype.render=function(){return console.log("ERROR",this.state.error),a.createElement("span",null,this.picture()?a.createElement("a",{target:"_blank",className:"js-mixtapeImage mixtapeImage "+this.classForImage(),href:this.state.embed_data.url,style:{backgroundImage:"url('"+this.picture()+"')"}}):void 0,this.state.error?a.createElement("h2",null,this.state.error):void 0,a.createElement("a",{className:"markup--anchor markup--mixtapeEmbed-anchor",target:"_blank",href:this.state.embed_data.url},a.createElement("strong",{className:"markup--strong markup--mixtapeEmbed-strong"},this.state.embed_data.title),a.createElement("em",{className:"markup--em markup--mixtapeEmbed-em"},this.state.embed_data.description)),this.state.embed_data.provider_url)},e}(a.Component),t.exports=r},197:function(t,e,o){var i,r,s,a,l,c,p,h,d,u,f,g,m=function(t,e){return function(){return t.apply(e,arguments)}},y=function(t,e){function o(){this.constructor=t}for(var i in e)k.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},k={}.hasOwnProperty;p=o(6),h=o(13),f=o(9),a=f.Entity,d=f.RichUtils,i=f.AtomicBlockUtils,r=f.EditorBlock,s=f.EditorState,u=o(47),g=o(25).updateDataOfBlock,l=function(t){function e(t){this.render=m(this.render,this),this.handleFocus=m(this.handleFocus,this),this.placeholderText=m(this.placeholderText,this),this.placeHolderEnabled=m(this.placeHolderEnabled,this),this.updateProgressBar=m(this.updateProgressBar,this),this.uploadCompleted=m(this.uploadCompleted,this),this.uploadFile=m(this.uploadFile,this),this.getUploadUrl=m(this.getUploadUrl,this),this.handleGrafFigureSelectImg=m(this.handleGrafFigureSelectImg,this),this.updateDataSelection=m(this.updateDataSelection,this),this.aspectRatio=m(this.aspectRatio,this),this.handleUpload=m(this.handleUpload,this),this.stopLoader=m(this.stopLoader,this),this.startLoader=m(this.startLoader,this),this.replaceImg=m(this.replaceImg,this),this.updateData=m(this.updateData,this),this.defaultAspectRatio=m(this.defaultAspectRatio,this),this.defaultUrl=m(this.defaultUrl,this),this.blockPropsSrc=m(this.blockPropsSrc,this);var o;e.__super__.constructor.call(this,t),o=this.props.block.getData().toJS(),this.config=this.props.blockProps.config,this.file=this.props.blockProps.data.get("file"),this.state={loading:!1,selected:!1,loading_progress:0,enabled:!1,caption:this.defaultPlaceholder(),direction:o.direction||"center",width:0,height:0,file:null,url:this.blockPropsSrc()||this.defaultUrl(o),aspect_ratio:this.defaultAspectRatio(o)}}return y(e,t),e.prototype.blockPropsSrc=function(){return this.props.blockProps.data.src},e.prototype.defaultUrl=function(t){return t.url?t.url:t.url?t.file?URL.createObjectURL(t.file):t.url:this.props.blockProps.data.src},e.prototype.defaultPlaceholder=function(){return this.props.blockProps.config.image_caption_placeholder},e.prototype.defaultAspectRatio=function(t){return t.aspect_ratio?{width:t.aspect_ratio.width,height:t.aspect_ratio.height,ratio:t.aspect_ratio.ratio}:{width:0,height:0,ratio:100}},e.prototype.getAspectRatio=function(t,e){var o,i,n,r,s,a,l;return r=1e3,n=1e3,s=0,l=t,i=e,l>r?(s=r/l,i*=s,l*=s):i>n&&(s=n/i,l*=s,i*=s),o=i/l*100,a={width:l,height:i,ratio:o}},e.prototype.updateData=function(){var t,e,o,i,n,r;return e=this.props.blockProps,t=this.props.block,i=this.props.blockProps.getEditorState,r=this.props.blockProps.setEditorState,o=t.getData(),n=o.merge(this.state).merge({forceUpload:!1}),r(g(i(),t,n))},e.prototype.replaceImg=function(){var t;if(this.img=new Image,this.img.src=this.refs.image_tag.src,this.setState({url:this.img.src}),t=this,this.img.src.includes("blob:")||this.props.block.data.get("forceUpload"))return this.img.onload=function(e){return function(){return e.setState({width:e.img.width,height:e.img.height,aspect_ratio:t.getAspectRatio(e.img.width,e.img.height)}),e.handleUpload()}}(this)},e.prototype.startLoader=function(){return this.setState({loading:!0})},e.prototype.stopLoader=function(){return this.setState({loading:!1})},e.prototype.handleUpload=function(){return this.startLoader(),this.props.blockProps.addLock(),this.updateData(),this.uploadFile()},e.prototype.componentDidMount=function(){return this.replaceImg()},e.prototype.aspectRatio=function(){return{maxWidth:""+this.state.aspect_ratio.width,maxHeight:""+this.state.aspect_ratio.height,ratio:""+this.state.aspect_ratio.height}},e.prototype.updateDataSelection=function(){var t,e,o;return t=this.props.blockProps.getEditorState,o=this.props.blockProps.setEditorState,e=t().getSelection().merge({anchorKey:this.props.block.getKey(),focusKey:this.props.block.getKey()}),o(s.forceSelection(t(),e))},e.prototype.handleGrafFigureSelectImg=function(t){return t.preventDefault(),this.setState({selected:!0},this.updateDataSelection)},e.prototype.coords=function(){return{maxWidth:this.state.aspect_ratio.width+"px",maxHeight:this.state.aspect_ratio.height+"px"}},e.prototype.getBase64Image=function(t){var e,o,i;return e=document.createElement("canvas"),e.width=t.width,e.height=t.height,o=e.getContext("2d"),o.drawImage(t,0,0),i=e.toDataURL("image/png")},e.prototype.formatData=function(){var t;return t=new FormData,this.file?(t.append("file",this.file),t):(t.append("url",this.props.blockProps.data.get("url")),t)},e.prototype.getUploadUrl=function(){var t;return t=this.config.upload_url,"function"==typeof t?t():t},e.prototype.uploadFile=function(){var t;return u({method:"post",url:this.getUploadUrl(),data:this.formatData(),onUploadProgress:function(t){return function(e){return t.updateProgressBar(e)}}(this)}).then(function(t){return function(e){if(t.uploadCompleted(e.data),t.props.blockProps.removeLock(),t.stopLoader(),t.file=null,t.config.upload_callback)return t.config.upload_callback(response,t)}}(this))["catch"](function(t){return function(e){if(t.props.blockProps.removeLock(),t.stopLoader(),console.log("ERROR: got error uploading file "+e),t.config.upload_error_callback)return t.config.upload_error_callback(e,t)}}(this)),t=function(t){return function(e){return t.uploadCompleted(e,n)}}(this)},e.prototype.uploadCompleted=function(t){return this.setState({url:t.url},this.updateData)},e.prototype.updateProgressBar=function(t){var e;if(e=this.state.loading_progress,t.lengthComputable)return e=t.loaded/t.total*100,e=null!=e?e:{complete:0},this.setState({loading_progress:e}),console.log("complete: "+e)},e.prototype.placeHolderEnabled=function(){return this.state.enabled||this.props.block.getText()},e.prototype.placeholderText=function(){return this.placeHolderEnabled()?"":"Write caption for image (optional)"},e.prototype.handleFocus=function(t){return setTimeout(function(t){return function(){return t.setState({enabled:!0})}}(this),0)},e.prototype.render=function(){return p.createElement("div",{ref:"image_tag2",suppressContentEditableWarning:!0},p.createElement("div",{className:"aspectRatioPlaceholder is-locked",style:this.coords(),onClick:this.handleGrafFigureSelectImg},p.createElement("div",{style:{paddingBottom:this.state.aspect_ratio.ratio+"%"},className:"aspect-ratio-fill"}),p.createElement("img",{src:this.state.url,ref:"image_tag",height:this.state.aspect_ratio.height,width:this.state.aspect_ratio.width,className:"graf-image"}),p.createElement(c,{toggle:this.state.loading,progress:this.state.loading_progress})),p.createElement("figcaption",{className:"imageCaption",onMouseDown:this.handleFocus},this.state.enabled?void 0:p.createElement("span",{className:"danteDefaultPlaceholder"},this.placeholderText()),p.createElement(r,Object.assign({},this.props,{editable:!0,className:"imageCaption"}))))},e}(p.Component),c=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return y(e,t),e.prototype.render=function(){return p.createElement("div",null,this.props.toggle?p.createElement("div",{className:"image-upoader-loader"},p.createElement("p",null,100===this.props.progress?"processing image...":p.createElement("span",null,p.createElement("span",null,"loading"),Math.round(this.props.progress)))):void 0)},e}(p.Component),t.exports=l},198:function(t,e,o){var i,n,r,s,a,l,c,p,h=function(t,e){return function(){return t.apply(e,arguments)}},d=function(t,e){function o(){this.constructor=t}for(var i in e)u.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},u={}.hasOwnProperty;a=o(6),l=o(13),p=o(9),r=p.Entity,c=p.RichUtils,i=p.AtomicBlockUtils,n=p.EditorBlock,s=function(t){function e(t){this.classForDefault=h(this.classForDefault,this),this.handleFocus=h(this.handleFocus,this),this.defaultText=h(this.defaultText,this),this.placeholderFromProps=h(this.placeholderFromProps,this),this.placeholderText=h(this.placeholderText,this),e.__super__.constructor.call(this,t),this.state={enabled:!1,data:this.props.blockProps.data.toJS()}}return d(e,t),e.prototype.placeholderText=function(){return this.state.enabled?"":this.props.blockProps.data.toJS().placeholder||this.placeholderFromProps()||this.defaultText()},e.prototype.placeholderFromProps=function(){return this.props.block.toJS().placeholder},e.prototype.defaultText=function(){return"write something "},e.prototype.componentDidMount=function(){},e.prototype.handleFocus=function(t){return setTimeout(function(t){return function(){return t.setState({enabled:!0})}}(this),0)},e.prototype.classForDefault=function(){return this.state.enabled?"":"defaultValue defaultValue--root"},e.prototype.render=function(){return a.createElement("span",{className:this.classForDefault(),onMouseDown:this.handleFocus},this.placeholderText(),a.createElement(n,Object.assign({},this.props,{className:"imageCaption",placeholder:"escrive alalal"})))},e}(a.Component),t.exports=s},199:function(t,e,o){var i,n,r,s,a,l,c,p,h,d,u=function(t,e){return function(){return t.apply(e,arguments)}},f=function(t,e){function o(){this.constructor=t}for(var i in e)g.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},g={}.hasOwnProperty;s=o(6),a=o(13),h=o(9),r=h.Entity,l=h.RichUtils,i=h.AtomicBlockUtils,n=h.EditorBlock,d=o(25).updateDataOfBlock,p=o(47),c=function(t){function e(t){this.dataForUpdate=u(this.dataForUpdate,this),this.updateData=u(this.updateData,this),e.__super__.constructor.call(this,t),this.state={embed_data:this.defaultData()}}return f(e,t),e.prototype.defaultData=function(){var t;return t=this.props.block.getData().toJS(),t.embed_data||{}},e.prototype.updateData=function(){var t,e,o,i,n,r;return e=this.props.blockProps,t=this.props.block,i=this.props.blockProps.getEditorState,r=this.props.blockProps.setEditorState,o=t.getData(),n=o.merge(this.state),r(d(i(),t,n))},e.prototype.dataForUpdate=function(){return this.props.blockProps.data.toJS()},e.prototype.componentDidMount=function(){if(this.props.blockProps.data&&(this.dataForUpdate().endpoint||this.dataForUpdate().provisory_text))return p({method:"get",url:""+this.dataForUpdate().endpoint+this.dataForUpdate().provisory_text+"&scheme=https"}).then(function(t){return function(e){return t.setState({embed_data:e.data},t.updateData)}}(this))["catch"](function(t){return function(t){return console.log("TODO: error")}}(this))},e.prototype.classForImage=function(){return this.state.embed_data.thumbnail_url?"":"mixtapeImage--empty u-ignoreBlock"},e.prototype.render=function(){return s.createElement("figure",{className:"graf--figure graf--iframe graf--first",tabIndex:"0"},s.createElement("div",{className:"iframeContainer",dangerouslySetInnerHTML:{__html:this.state.embed_data.html}}),s.createElement("figcaption",{className:"imageCaption"},s.createElement(n,Object.assign({},this.props,{className:"imageCaption"}))))},e}(s.Component),t.exports=c},200:function(t,e,o){var i,n,r=function(t,e){return function(){return t.apply(e,arguments)}},s=function(t,e){function o(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},a={}.hasOwnProperty;n=o(6),i=function(t){function e(t){null==t&&(t={}),this.render=r(this.render,this),this.open=r(this.open,this),this.toggleDisplay=r(this.toggleDisplay,this),this.logState=r(this.logState,this),this.testEmitTEXT=r(this.testEmitTEXT,this),this.testEmitAndDecode=r(this.testEmitAndDecode,this),this.handleTestEmitTEXT=r(this.handleTestEmitTEXT,this),this.handleTestEmitAndDecode=r(this.handleTestEmitAndDecode,this),this.handleToggleReadOnly=r(this.handleToggleReadOnly,this),this.state={output:"",display:"none"}}return s(e,t),e.prototype.handleToggleReadOnly=function(t){return t.preventDefault(),this.props.editor.toggleEditable(),!1},e.prototype.handleTestEmitAndDecode=function(t){return t.preventDefault(),this.testEmitAndDecode()},e.prototype.handleTestEmitTEXT=function(t){return t.preventDefault(),this.testEmitTEXT()},e.prototype.testEmitAndDecode=function(t){var e;return e=this.props.editor.emitSerializedOutput(),this.props.editor.setState({editorState:this.props.editor.decodeEditorContent(e)},this.logState(JSON.stringify(e))),!1},e.prototype.testEmitTEXT=function(){var t;return t=this.props.editor.getTextFromEditor(),this.logState(t)},e.prototype.logState=function(t){return this.setState({output:t},this.open)},e.prototype.toggleDisplay=function(t){var e;return t.preventDefault(),e="block"===this.state.display?"none":this.state.display,this.setState({display:e})},e.prototype.open=function(){return this.setState({display:"block"})},e.prototype.render=function(){return n.createElement("div",null,n.createElement("div",{className:"debugControls"},n.createElement("ul",null,n.createElement("li",null,"LOCKS: ",this.props.editor.state.locks),n.createElement("li",null,n.createElement("a",{href:"#",onClick:this.handleToggleReadOnly},"EDITABLE: ",this.props.editor.state.read_only?"NO":"YES")),n.createElement("li",null,n.createElement("a",{href:"#",onClick:this.handleTestEmitTEXT},"EDITOR TEXT")),n.createElement("li",null,n.createElement("a",{href:"#",onClick:this.handleTestEmitAndDecode},"EDITOR STATE")))),n.createElement("div",{className:"debugZone",style:{display:this.state.display}},n.createElement("a",{href:"#",className:"dante-debug-close close",onClick:this.toggleDisplay}),n.createElement("div",{className:"debugOutput"},n.createElement("h2",null,"EDITOR OUTPUT"),this.state.output.length>0?n.createElement("pre",null,this.state.output):void 0)))},e}(n.Component),t.exports=i},201:function(t,e,o){var i,n,r,s=function(t,e){return function(){return t.apply(e,arguments)}},a=function(t,e){function o(){this.constructor=t}for(var i in e)l.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},l={}.hasOwnProperty;r=o(6),i=o(9).Entity,n=function(t){function e(t){this._hidePopLinkOver=s(this._hidePopLinkOver,this),this._showPopLinkOver=s(this._showPopLinkOver,this),this._checkProtocol=s(this._checkProtocol,this),this._validateLink=s(this._validateLink,this),e.__super__.constructor.call(this,t),this.isHover=!1}return a(e,t),e.prototype._validateLink=function(){var t;return t=new RegExp("^(https?://)?((([a-zd]([a-zd-]*[a-zd])*).)+[a-z]{2,}|((d{1,3}.){3}d{1,3}))(:d+)?(/[-a-zd%_.~+]*)*(?[;&a-zd%_.~+=-]*)?(#[-a-zd_]*)?$","i"),!!t.test(str)||(alert("Please enter a valid URL."),!1)},e.prototype._checkProtocol=function(){return console.log("xcvd")},e.prototype._showPopLinkOver=function(t){if(this.data.showPopLinkOver)return this.data.showPopLinkOver(this.refs.link)},e.prototype._hidePopLinkOver=function(t){if(this.data.hidePopLinkOver)return this.data.hidePopLinkOver()},e.prototype.render=function(){return this.data=i.get(this.props.entityKey).getData(),r.createElement("a",{ref:"link",href:this.data.url,className:"markup--anchor",onMouseOver:this._showPopLinkOver,onMouseOut:this._hidePopLinkOver},this.props.children)},e}(r.Component),t.exports=n},202:function(t,e,o){var i,n,r,s,a,l,c,p,h,d,u,f,g,m,y,k,_,v,b=function(t,e){return function(){return t.apply(e,arguments)}},S=function(t,e){function o(){this.constructor=t}for(var i in e)E.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},E={}.hasOwnProperty;l=o(6),c=o(13),m=o(9),s=m.Entity,p=m.RichUtils,i=m.AtomicBlockUtils,r=m.EditorState,y=o(25),h=y.addNewBlock,_=y.resetBlockWithType,v=y.updateDataOfBlock,d=y.getCurrentBlock,u=y.getNode,k=o(48),g=k.getSelectionRect,f=k.getSelection,n=function(t){function e(t){this.relocate=b(this.relocate,this),this.clickHandler=b(this.clickHandler,this),this.widgets=b(this.widgets,this),this.handleFileInput=b(this.handleFileInput,this),this.insertImage=b(this.insertImage,this),this.handlePlaceholder=b(this.handlePlaceholder,this),this.clickOnFileUpload=b(this.clickOnFileUpload,this),this.componentWillReceiveProps=b(this.componentWillReceiveProps,this),this.collapse=b(this.collapse,this),this.scale=b(this.scale,this),this._toggleScaled=b(this._toggleScaled,this),this.hide=b(this.hide,this),this.show=b(this.show,this),this.display=b(this.display,this),e.__super__.constructor.call(this,t),this.state={position:{top:0,left:0},show:!1,scaled:!1}}return S(e,t),e.prototype.display=function(t){return t?this.show():this.hide()},e.prototype.show=function(){return this.setState({show:!0})},e.prototype.hide=function(){return this.setState({show:!1})},e.prototype.setPosition=function(t){return this.setState({position:t})},e.prototype._toggleScaled=function(t){return this.state.scaled?this.collapse():this.scale()},e.prototype.scale=function(){return this.setState({scaled:!0})},e.prototype.collapse=function(){return this.setState({scaled:!1})},e.prototype.componentWillReceiveProps=function(t){return this.collapse()},e.prototype.activeClass=function(){return this.isActive()?"is-active":""},e.prototype.isActive=function(){return this.state.show},e.prototype.scaledClass=function(){return this.state.scaled?"is-scaled":""},e.prototype.scaledWidth=function(){return this.state.scaled?"124":"0"},e.prototype.clickOnFileUpload=function(){return this.refs.fileInput.click(),this.collapse(),this.hide()},e.prototype.handlePlaceholder=function(t){var e;return e={type:t.widget_options.insert_block,placeholder:t.options.placeholder,endpoint:t.options.endpoint},this.props.onChange(_(this.props.editorState,"placeholder",e))},e.prototype.insertImage=function(t){var e;return e={url:URL.createObjectURL(t),file:t},this.props.onChange(h(this.props.editorState,"image",e))},e.prototype.handleFileInput=function(t){var e;return e=t.target.files,this.insertImage(e[0])},e.prototype.widgets=function(){return this.props.editor.widgets},e.prototype.clickHandler=function(t,e){var o;switch(o=this.widgets().find(function(t){return t.icon===e}),o.widget_options.insertion){case"upload":return this.clickOnFileUpload(t,o);case"placeholder":return this.handlePlaceholder(o);default:return console.log("WRONG TYPE FOR "+o.widget_options.insertion)}},e.prototype.getItems=function(){return this.widgets().filter(function(t){return function(t){return t.widget_options.displayOnInlineTooltip}}(this))},e.prototype.isDescendant=function(t,e){var o;for(o=e.parentNode;null!==o;){if(o===t)return!0;o=o.parentNode}return!1},e.prototype.relocate=function(){var t,e,o,i,n,r,s,a,l,p,h,m;if(r=this.props.editorState,r.getSelection().isCollapsed()){if(n=d(r),e=n.getType(),o=r.getCurrentContent(),m=r.getSelection(),t=o.getBlockForKey(m.anchorKey),s=f(window),!s.rangeCount)return;return a=u(),h=g(s),i=h,l=c.findDOMNode(this.props.editor),p=l.getBoundingClientRect(),this.isDescendant(l,s.anchorNode)?(this.display(0===t.getText().length&&"unstyled"===e),this.setPosition({top:i.top+window.scrollY,left:i.left+window.scrollX-60})):void this.hide()}return this.hide()},e.prototype.render=function(){return l.createElement("div",{className:"inlineTooltip "+this.activeClass()+" "+this.scaledClass(),style:this.state.position},l.createElement("button",{className:"inlineTooltip-button control",title:"Close Menu","data-action":"inline-menu",onClick:this._toggleScaled},l.createElement("span",{className:"tooltip-icon dante-icon-plus"})),l.createElement("div",{className:"inlineTooltip-menu",style:{width:this.scaledWidth()+"px"}},this.getItems().map(function(t){return function(e,o){return l.createElement(a,{item:e,key:o,clickHandler:t.clickHandler})}}(this)),l.createElement("input",{type:"file",style:{display:"none"},ref:"fileInput",multiple:"multiple",onChange:this.handleFileInput})))},e}(l.Component),a=function(t){function e(){return this.clickHandler=b(this.clickHandler,this),e.__super__.constructor.apply(this,arguments)}return S(e,t),e.prototype.clickHandler=function(t){return t.preventDefault(),this.props.clickHandler(t,this.props.item.icon)},e.prototype.render=function(){return l.createElement("button",{className:"inlineTooltip-button scale",title:this.props.title,onMouseDown:this.clickHandler},l.createElement("span",{className:"tooltip-icon dante-icon-"+this.props.item.icon}))},e}(l.Component),t.exports=n},203:function(t,e,o){var i,n,r,s,a,l,c,p,h,d,u,f,g,m,y,k=function(t,e){return function(){return t.apply(e,arguments)}},_=function(t,e){function o(){this.constructor=t}for(var i in e)v.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},v={}.hasOwnProperty;l=o(6),c=o(13),g=o(9),a=g.Entity,p=g.RichUtils,i=g.AtomicBlockUtils,s=g.EditorState,m=o(48),f=m.getSelectionRect,u=m.getSelection,y=o(25),h=y.getCurrentBlock,d=y.getNode,n=function(t){function e(t){this.handleClick=k(this.handleClick,this),this.componentWillReceiveProps=k(this.componentWillReceiveProps,this),this.relocate=k(this.relocate,this),this.collapse=k(this.collapse,this),this.scale=k(this.scale,this),this._toggleScaled=k(this._toggleScaled,this),this.hide=k(this.hide,this),this.show=k(this.show,this),this.display=k(this.display,this),e.__super__.constructor.call(this,t),this.state={position:{top:0,left:0},show:!1,scaled:!1,buttons:[{type:"left"},{type:"center"},{type:"fill"},{type:"wide"}]}}return _(e,t),e.prototype.display=function(t){return t?this.show():this.hide()},e.prototype.show=function(){return this.setState({show:!0})},e.prototype.hide=function(){return this.setState({show:!1})},e.prototype.setPosition=function(t){return this.setState({position:t})},e.prototype._toggleScaled=function(t){return this.state.scaled?this.collapse():this.scale()},e.prototype.scale=function(){return this.setState({scaled:!0})},e.prototype.collapse=function(){return this.setState({scaled:!1})},e.prototype.relocate=function(){var t,e,o,i,n,r,s,a,l,p,g,m,y,k;return r=this.props.editorState,r.getSelection().isCollapsed()?(n=h(r),e=n.getType(),o=r.getCurrentContent(),k=r.getSelection(),t=o.getBlockForKey(k.anchorKey),a=u(window),a.rangeCount?(l=d(),y=f(a),i=y,g=c.findDOMNode(this.props.editor),m=g.getBoundingClientRect(),this.display("image"===e),"image"===e?(y=l.anchorNode.parentNode.parentNode.parentNode.getBoundingClientRect(),s=this.refs.image_popover,p=s.offsetWidth/2,this.setPosition({top:y.top-m.top+60,left:y.left+y.width/2-p})):void 0):void 0):this.hide()},e.prototype.componentWillReceiveProps=function(t){return this.collapse()},e.prototype.getStyle=function(){if(!this.state.position)return{}},e.prototype.handleClick=function(t){return this.props.editor.setDirection(t.type)},e.prototype.render=function(){return l.createElement("div",{ref:"image_popover",className:"dante-popover popover--Aligntooltip popover--top popover--animated "+(this.state.show?"is-active":void 0),style:{top:this.state.position.top,left:this.state.position.left}},l.createElement("div",{className:"popover-inner"},l.createElement("ul",{className:"dante-menu-buttons"},this.state.buttons.map(function(t){return function(e,o){return l.createElement(r,{item:e,handleClick:t.handleClick,key:o})}}(this)))),l.createElement("div",{className:"popover-arrow"}))},e}(l.Component),r=function(t){function e(){return this.render=k(this.render,this),this.handleClick=k(this.handleClick,this),e.__super__.constructor.apply(this,arguments)}return _(e,t),e.prototype.handleClick=function(t){return t.preventDefault(),this.props.handleClick(this.props.item)},e.prototype.render=function(){return l.createElement("li",{className:"dante-menu-button align-"+this.props.item.type,onMouseDown:this.handleClick},l.createElement("span",{className:"tooltip-icon dante-icon-image-"+this.props.item.type}))},e}(l.Component),t.exports=n},204:function(t,e,o){var i,n,r,s,a=function(t,e){return function(){return t.apply(e,arguments)}},l=function(t,e){function o(){this.constructor=t}for(var i in e)c.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},c={}.hasOwnProperty;n=o(6),r=o(13),s=o(25).getCurrentBlock,i=function(t){function e(t){this.render=a(this.render,this),this.relocate=a(this.relocate,this),this.hide=a(this.hide,this),this.show=a(this.show,this),this.display=a(this.display,this),e.__super__.constructor.call(this,t),this.state={position:{top:0,left:0},show:!1,url:""}}return l(e,t),e.prototype.display=function(t){return t?this.show():this.hide()},e.prototype.show=function(){return this.setState({show:!0})},e.prototype.hide=function(){return this.setState({show:!1})},e.prototype.setPosition=function(t){return this.setState({position:t})},e.prototype.relocate=function(t){var e,o,i,n,a,l,c,p,h,d,u;if(null==t&&(t=null),t)return a=this.props.editorState,n=s(a),e=n.getType(),o=a.getCurrentContent(),u=a.getSelection(),d=t.getBoundingClientRect(),i=d,l=this.refs.dante_popover,c=l.offsetWidth/2,p=r.findDOMNode(this.props.editor),h=p.getBoundingClientRect(),{top:d.top-h.top+160,left:d.left+d.width/2-c}},e.prototype.render=function(){var t,e;return t=this.state.position,e={left:t.left,top:t.top,visibility:""+(this.state.show?"visible":"hidden")},n.createElement("div",{ref:"dante_popover",className:"dante-popover popover--tooltip popover--Linktooltip popover--bottom is-active",style:e,onMouseOver:this.props.handleOnMouseOver,onMouseOut:this.props.handleOnMouseOut},n.createElement("div",{className:"popover-inner"},n.createElement("a",{href:this.props.url,target:"_blank"},this.state.url)),n.createElement("div",{className:"popover-arrow"}))},e}(n.Component),t.exports=i},205:function(t,e,o){var i,n,r,s,a,l,c,p,h,d,u,f,g,m,y,k,_,v,b,S,E,w=function(t,e){return function(){return t.apply(e,arguments)}},C=function(t,e){function o(){this.constructor=t}for(var i in e)D.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},D={}.hasOwnProperty;d=o(6),u=o(13),S=o(9),g=S.convertToRaw,i=S.CompositeDecorator,b=S.getVisibleSelectionRect,y=S.getDefaultKeyBinding,_=S.getSelectionOffsetKeyForNode,h=S.KeyBindingUtil,n=S.ContentState,l=S.Editor,c=S.EditorState,p=S.Entity,f=S.RichUtils,E=o(48),v=E.getSelectionRect,k=E.getSelection,m=o(25).getCurrentBlock,r=function(t){function e(t){this.getDefaultValue=w(this.getDefaultValue,this),this.blockItems=w(this.blockItems,this),this.inlineItems=w(this.inlineItems,this),this.confirmLink=w(this.confirmLink,this),this.handleInputEnter=w(this.handleInputEnter,this),this._disableLinkMode=w(this._disableLinkMode,this),this._enableLinkMode=w(this._enableLinkMode,this),this.displayActiveMenu=w(this.displayActiveMenu,this),this.displayLinkMode=w(this.displayLinkMode,this),this._clickBlockHandler=w(this._clickBlockHandler,this),this.relocate=w(this.relocate,this),this.hide=w(this.hide,this),this.show=w(this.show,this),this.display=w(this.display,this),this._clickInlineHandler=w(this._clickInlineHandler,this),e.__super__.constructor.call(this,t),this.getVisibleSelectionRect=b,this.state={link_mode:!1,show:!1,position:{}}}return C(e,t),e.prototype._clickInlineHandler=function(t,e){return t.preventDefault(),this.props.onChange(f.toggleInlineStyle(this.props.editorState,e)),setTimeout(function(t){return function(){return t.relocate()}}(this),0)},e.prototype.display=function(t){return t?this.show():this.hide()},e.prototype.show=function(){return this.setState({show:!0})},e.prototype.hide=function(){return this.setState({link_mode:!1,show:!1})},e.prototype.setPosition=function(t){return this.setState({position:t})},e.prototype.isDescendant=function(t,e){var o;for(o=e.parentNode;null!==o;){if(o===t)return!0;o=o.parentNode}return!1},e.prototype.relocate=function(){var t,e,o,i,n,r,s,a,l,c;if(e=m(this.props.editorState),t=e.getType(),this.props.configTooltip.selectionElements.indexOf(t)<0)return void this.hide();if(!this.state.link_mode&&this.state.show&&(o=this.refs.dante_menu,r=o.offsetWidth/2,n=k(window),n.rangeCount)){if(l=v(n),s=u.findDOMNode(this.props.editor),a=s.getBoundingClientRect(),!this.isDescendant(s,n.anchorNode))return void this.hide();if(c=l.top-a.top- -90-5,i=l.left+l.width/2-r,c&&i)return this.setState({show:!0,position:{left:i,top:c}})}},e.prototype._clickBlockHandler=function(t,e){return t.preventDefault(),this.props.onChange(f.toggleBlockType(this.props.editorState,e)),setTimeout(function(t){return function(){return t.relocate()}}(this),0)},e.prototype.displayLinkMode=function(){return this.state.link_mode?"dante-menu--linkmode":""},e.prototype.displayActiveMenu=function(){return this.state.show?"dante-menu--active":""},e.prototype._enableLinkMode=function(t){return t.preventDefault(),this.setState({link_mode:!0})},e.prototype._disableLinkMode=function(t){return t.preventDefault(),this.setState({link_mode:!1,url:""})},e.prototype.hideMenu=function(){return this.hide()},e.prototype.handleInputEnter=function(t){if(13===t.which)return this.confirmLink(t)},e.prototype.confirmLink=function(t){var e,o,i,n,r,s;return t.preventDefault(),o=this.props.editorState,s=t.currentTarget.value,
|
3
|
-
|
1
|
+
webpackJsonp([1],{
|
2
|
+
|
3
|
+
/***/ 0:
|
4
|
+
/***/ function(module, exports, __webpack_require__) {
|
5
|
+
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
__webpack_require__(10);
|
9
|
+
|
10
|
+
var _index = __webpack_require__(20);
|
11
|
+
|
12
|
+
/***/ },
|
13
|
+
|
14
|
+
/***/ 10:
|
15
|
+
/***/ function(module, exports) {
|
16
|
+
|
17
|
+
// removed by extract-text-webpack-plugin
|
18
|
+
|
19
|
+
/***/ },
|
20
|
+
|
21
|
+
/***/ 12:
|
22
|
+
/***/ function(module, exports, __webpack_require__) {
|
23
|
+
|
24
|
+
module.exports = __webpack_require__.p + "fonts/fontello.eot";
|
25
|
+
|
26
|
+
/***/ },
|
27
|
+
|
28
|
+
/***/ 13:
|
29
|
+
/***/ function(module, exports, __webpack_require__) {
|
30
|
+
|
31
|
+
module.exports = __webpack_require__.p + "fonts/fontello.woff";
|
32
|
+
|
33
|
+
/***/ },
|
34
|
+
|
35
|
+
/***/ 14:
|
36
|
+
/***/ function(module, exports, __webpack_require__) {
|
37
|
+
|
38
|
+
module.exports = __webpack_require__.p + "fonts/fontello.ttf";
|
39
|
+
|
40
|
+
/***/ },
|
41
|
+
|
42
|
+
/***/ 15:
|
43
|
+
/***/ function(module, exports, __webpack_require__) {
|
44
|
+
|
45
|
+
module.exports = __webpack_require__.p + "fonts/fontello.svg";
|
46
|
+
|
47
|
+
/***/ },
|
48
|
+
|
49
|
+
/***/ 16:
|
50
|
+
/***/ function(module, exports, __webpack_require__) {
|
51
|
+
|
52
|
+
module.exports = __webpack_require__.p + "fonts/dante.eot";
|
53
|
+
|
54
|
+
/***/ },
|
55
|
+
|
56
|
+
/***/ 17:
|
57
|
+
/***/ function(module, exports, __webpack_require__) {
|
58
|
+
|
59
|
+
module.exports = __webpack_require__.p + "fonts/dante.woff";
|
60
|
+
|
61
|
+
/***/ },
|
62
|
+
|
63
|
+
/***/ 18:
|
64
|
+
/***/ function(module, exports, __webpack_require__) {
|
65
|
+
|
66
|
+
module.exports = __webpack_require__.p + "fonts/dante.ttf";
|
67
|
+
|
68
|
+
/***/ },
|
69
|
+
|
70
|
+
/***/ 19:
|
71
|
+
/***/ function(module, exports, __webpack_require__) {
|
72
|
+
|
73
|
+
module.exports = __webpack_require__.p + "fonts/dante.svg";
|
74
|
+
|
75
|
+
/***/ },
|
76
|
+
|
77
|
+
/***/ 20:
|
78
|
+
/***/ function(module, exports, __webpack_require__) {
|
79
|
+
|
80
|
+
'use strict';
|
81
|
+
|
82
|
+
var _dante = __webpack_require__(21);
|
83
|
+
|
84
|
+
var _dante2 = _interopRequireDefault(_dante);
|
85
|
+
|
86
|
+
var _dante_editor = __webpack_require__(206);
|
87
|
+
|
88
|
+
var _dante_editor2 = _interopRequireDefault(_dante_editor);
|
89
|
+
|
90
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
91
|
+
|
92
|
+
module.exports = {
|
93
|
+
Dante: _dante2['default'],
|
94
|
+
DanteEditor: _dante_editor2['default']
|
95
|
+
};
|
96
|
+
|
97
|
+
/***/ },
|
98
|
+
|
99
|
+
/***/ 21:
|
100
|
+
/***/ function(module, exports, __webpack_require__) {
|
101
|
+
|
102
|
+
/* WEBPACK VAR INJECTION */(function(global) {"use strict";
|
103
|
+
|
104
|
+
module.exports = global["Dante"] = __webpack_require__(22);
|
105
|
+
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
106
|
+
|
107
|
+
/***/ },
|
108
|
+
|
109
|
+
/***/ 206:
|
110
|
+
/***/ function(module, exports, __webpack_require__) {
|
111
|
+
|
112
|
+
/* WEBPACK VAR INJECTION */(function(global) {"use strict";
|
113
|
+
|
114
|
+
module.exports = global["DanteEditor"] = __webpack_require__(207);
|
115
|
+
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
116
|
+
|
117
|
+
/***/ },
|
118
|
+
|
119
|
+
/***/ 426:
|
120
|
+
/***/ function(module, exports, __webpack_require__) {
|
121
|
+
|
122
|
+
'use strict';
|
123
|
+
|
124
|
+
Object.defineProperty(exports, "__esModule", {
|
125
|
+
value: true
|
126
|
+
});
|
127
|
+
exports.addNewBlockAt = exports.updateTextOfBlock = exports.updateDataOfBlock = exports.resetBlockWithType = exports.addNewBlock = exports.getCurrentBlock = exports.getNode = exports.getDefaultBlockData = undefined;
|
128
|
+
|
129
|
+
var _immutable = __webpack_require__(205);
|
130
|
+
|
131
|
+
var _draftJs = __webpack_require__(274);
|
132
|
+
|
133
|
+
/*
|
134
|
+
Used from [react-rte](https://github.com/brijeshb42/medium-draft)
|
135
|
+
by [brijeshb42](https://github.com/brijeshb42/medium-draft)
|
136
|
+
*/
|
137
|
+
|
138
|
+
/*
|
139
|
+
Returns default block-level metadata for various block type. Empty object otherwise.
|
140
|
+
*/
|
141
|
+
var getDefaultBlockData = exports.getDefaultBlockData = function getDefaultBlockData(blockType) {
|
142
|
+
var initialData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
143
|
+
|
144
|
+
switch (blockType) {
|
145
|
+
//case Block.TODO: return { checked: false };
|
146
|
+
default:
|
147
|
+
return initialData;
|
148
|
+
}
|
149
|
+
};
|
150
|
+
|
151
|
+
var getNode = exports.getNode = function getNode() {
|
152
|
+
var root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
|
153
|
+
|
154
|
+
var t = null;
|
155
|
+
if (root.getSelection) {
|
156
|
+
t = root.getSelection();
|
157
|
+
} else if (root.document.getSelection) {
|
158
|
+
t = root.document.getSelection();
|
159
|
+
} else if (root.document.selection) {
|
160
|
+
t = root.document.selection.createRange().text;
|
161
|
+
}
|
162
|
+
return t;
|
163
|
+
};
|
164
|
+
|
165
|
+
/*
|
166
|
+
Get currentBlock in the editorState.
|
167
|
+
*/
|
168
|
+
var getCurrentBlock = exports.getCurrentBlock = function getCurrentBlock(editorState) {
|
169
|
+
var selectionState = editorState.getSelection();
|
170
|
+
var contentState = editorState.getCurrentContent();
|
171
|
+
var block = contentState.getBlockForKey(selectionState.getStartKey());
|
172
|
+
return block;
|
173
|
+
};
|
174
|
+
|
175
|
+
/*
|
176
|
+
Adds a new block (currently replaces an empty block) at the current cursor position
|
177
|
+
of the given `newType`.
|
178
|
+
*/
|
179
|
+
var addNewBlock = exports.addNewBlock = function addNewBlock(editorState) {
|
180
|
+
var newType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unstyled";
|
181
|
+
var initialData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
182
|
+
|
183
|
+
var selectionState = editorState.getSelection();
|
184
|
+
if (!selectionState.isCollapsed()) {
|
185
|
+
return editorState;
|
186
|
+
}
|
187
|
+
var contentState = editorState.getCurrentContent();
|
188
|
+
var key = selectionState.getStartKey();
|
189
|
+
var blockMap = contentState.getBlockMap();
|
190
|
+
var currentBlock = getCurrentBlock(editorState);
|
191
|
+
if (!currentBlock) {
|
192
|
+
return editorState;
|
193
|
+
}
|
194
|
+
if (currentBlock.getLength() === 0) {
|
195
|
+
if (currentBlock.getType() === newType) {
|
196
|
+
return editorState;
|
197
|
+
}
|
198
|
+
var newBlock = currentBlock.merge({
|
199
|
+
type: newType,
|
200
|
+
data: getDefaultBlockData(newType, initialData)
|
201
|
+
});
|
202
|
+
var newContentState = contentState.merge({
|
203
|
+
blockMap: blockMap.set(key, newBlock),
|
204
|
+
selectionAfter: selectionState
|
205
|
+
});
|
206
|
+
return _draftJs.EditorState.push(editorState, newContentState, 'change-block-type');
|
207
|
+
}
|
208
|
+
return editorState;
|
209
|
+
};
|
210
|
+
|
211
|
+
/*
|
212
|
+
Changes the block type of the current block.
|
213
|
+
*/
|
214
|
+
var resetBlockWithType = exports.resetBlockWithType = function resetBlockWithType(editorState) {
|
215
|
+
var newType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unstyled";
|
216
|
+
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
217
|
+
|
218
|
+
var contentState = editorState.getCurrentContent();
|
219
|
+
var selectionState = editorState.getSelection();
|
220
|
+
var key = selectionState.getStartKey();
|
221
|
+
var blockMap = contentState.getBlockMap();
|
222
|
+
var block = blockMap.get(key);
|
223
|
+
|
224
|
+
var newText = '';
|
225
|
+
console.log("DATA FOR PLACEHOLDER!", data);
|
226
|
+
var text = block.getText();
|
227
|
+
if (block.getLength() >= 2) {
|
228
|
+
newText = text.substr(1);
|
229
|
+
}
|
230
|
+
|
231
|
+
/*if(data.text){
|
232
|
+
newText = data.text
|
233
|
+
}*/
|
234
|
+
|
235
|
+
//let newText = data.text
|
236
|
+
|
237
|
+
var newBlock = block.merge({
|
238
|
+
text: newText,
|
239
|
+
type: newType,
|
240
|
+
data: getDefaultBlockData(newType, data)
|
241
|
+
});
|
242
|
+
var newContentState = contentState.merge({
|
243
|
+
blockMap: blockMap.set(key, newBlock),
|
244
|
+
selectionAfter: selectionState.merge({
|
245
|
+
anchorOffset: 0,
|
246
|
+
focusOffset: 0
|
247
|
+
})
|
248
|
+
});
|
249
|
+
return _draftJs.EditorState.push(editorState, newContentState, 'change-block-type');
|
250
|
+
};
|
251
|
+
|
252
|
+
/*
|
253
|
+
Update block-level metadata of the given `block` to the `newData`/
|
254
|
+
*/
|
255
|
+
var updateDataOfBlock = exports.updateDataOfBlock = function updateDataOfBlock(editorState, block, newData) {
|
256
|
+
var contentState = editorState.getCurrentContent();
|
257
|
+
var newBlock = block.merge({
|
258
|
+
data: newData
|
259
|
+
});
|
260
|
+
var newContentState = contentState.merge({
|
261
|
+
blockMap: contentState.getBlockMap().set(block.getKey(), newBlock)
|
262
|
+
});
|
263
|
+
return _draftJs.EditorState.push(editorState, newContentState, 'change-block-type');
|
264
|
+
// return editorState;
|
265
|
+
};
|
266
|
+
|
267
|
+
var updateTextOfBlock = exports.updateTextOfBlock = function updateTextOfBlock(editorState, block, text) {
|
268
|
+
var contentState = editorState.getCurrentContent();
|
269
|
+
var newBlock = block.merge({
|
270
|
+
text: text
|
271
|
+
});
|
272
|
+
var newContentState = contentState.merge({
|
273
|
+
blockMap: contentState.getBlockMap().set(block.getKey(), newBlock)
|
274
|
+
});
|
275
|
+
|
276
|
+
return _draftJs.EditorState.push(editorState, newContentState, 'change-block-type');
|
277
|
+
// return editorState;
|
278
|
+
};
|
279
|
+
|
280
|
+
// const BEFORE = -1;
|
281
|
+
// const AFTER = 1;
|
282
|
+
|
283
|
+
/*
|
284
|
+
Used from [react-rte](https://github.com/sstur/react-rte/blob/master/src/lib/insertBlockAfter.js)
|
285
|
+
by [sstur](https://github.com/sstur)
|
286
|
+
*/
|
287
|
+
var addNewBlockAt = exports.addNewBlockAt = function addNewBlockAt(editorState, pivotBlockKey) {
|
288
|
+
var newBlockType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unstyled";
|
289
|
+
var initialData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
290
|
+
|
291
|
+
var content = editorState.getCurrentContent();
|
292
|
+
var blockMap = content.getBlockMap();
|
293
|
+
var block = blockMap.get(pivotBlockKey);
|
294
|
+
var blocksBefore = blockMap.toSeq().takeUntil(function (v) {
|
295
|
+
return v === block;
|
296
|
+
});
|
297
|
+
var blocksAfter = blockMap.toSeq().skipUntil(function (v) {
|
298
|
+
return v === block;
|
299
|
+
}).rest();
|
300
|
+
var newBlockKey = (0, _draftJs.genKey)();
|
301
|
+
|
302
|
+
var newBlock = new _draftJs.ContentBlock({
|
303
|
+
key: newBlockKey,
|
304
|
+
type: newBlockType,
|
305
|
+
text: '',
|
306
|
+
characterList: block.getCharacterList().slice(0, 0),
|
307
|
+
depth: 0,
|
308
|
+
data: (0, _immutable.Map)(getDefaultBlockData(newBlockType, initialData))
|
309
|
+
});
|
310
|
+
|
311
|
+
var newBlockMap = blocksBefore.concat([[pivotBlockKey, block], [newBlockKey, newBlock]], blocksAfter).toOrderedMap();
|
312
|
+
|
313
|
+
var selection = editorState.getSelection();
|
314
|
+
|
315
|
+
var newContent = content.merge({
|
316
|
+
blockMap: newBlockMap,
|
317
|
+
selectionBefore: selection,
|
318
|
+
selectionAfter: selection.merge({
|
319
|
+
anchorKey: newBlockKey,
|
320
|
+
anchorOffset: 0,
|
321
|
+
focusKey: newBlockKey,
|
322
|
+
focusOffset: 0,
|
323
|
+
isBackward: false
|
324
|
+
})
|
325
|
+
});
|
326
|
+
return _draftJs.EditorState.push(editorState, newContent, 'split-block');
|
327
|
+
};
|
328
|
+
|
329
|
+
/***/ },
|
330
|
+
|
331
|
+
/***/ 427:
|
332
|
+
/***/ function(module, exports, __webpack_require__) {
|
333
|
+
|
334
|
+
'use strict';
|
335
|
+
|
336
|
+
Object.defineProperty(exports, "__esModule", {
|
337
|
+
value: true
|
338
|
+
});
|
339
|
+
|
340
|
+
var _getPrototypeOf = __webpack_require__(208);
|
341
|
+
|
342
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
343
|
+
|
344
|
+
var _classCallCheck2 = __webpack_require__(23);
|
345
|
+
|
346
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
347
|
+
|
348
|
+
var _createClass2 = __webpack_require__(24);
|
349
|
+
|
350
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
351
|
+
|
352
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
353
|
+
|
354
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
355
|
+
|
356
|
+
var _inherits2 = __webpack_require__(266);
|
357
|
+
|
358
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
359
|
+
|
360
|
+
var _react = __webpack_require__(43);
|
361
|
+
|
362
|
+
var _react2 = _interopRequireDefault(_react);
|
363
|
+
|
364
|
+
var _draftJs = __webpack_require__(274);
|
365
|
+
|
366
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
367
|
+
|
368
|
+
var Link = function (_React$Component) {
|
369
|
+
(0, _inherits3['default'])(Link, _React$Component);
|
370
|
+
|
371
|
+
function Link(props) {
|
372
|
+
(0, _classCallCheck3['default'])(this, Link);
|
373
|
+
|
374
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (Link.__proto__ || (0, _getPrototypeOf2['default'])(Link)).call(this, props));
|
375
|
+
|
376
|
+
_this._validateLink = _this._validateLink.bind(_this);
|
377
|
+
_this._checkProtocol = _this._checkProtocol.bind(_this);
|
378
|
+
_this._showPopLinkOver = _this._showPopLinkOver.bind(_this);
|
379
|
+
_this._hidePopLinkOver = _this._hidePopLinkOver.bind(_this);
|
380
|
+
_this.isHover = false;
|
381
|
+
return _this;
|
382
|
+
}
|
383
|
+
|
384
|
+
(0, _createClass3['default'])(Link, [{
|
385
|
+
key: '_validateLink',
|
386
|
+
value: function _validateLink() {
|
387
|
+
var pattern = new RegExp('^(https?:\/\/)?' + // protocol
|
388
|
+
'((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|' + // domain name
|
389
|
+
'((\d{1,3}\.){3}\d{1,3}))' + // OR ip (v4) address
|
390
|
+
'(\:\d+)?(\/[-a-z\d%_.~+]*)*' + // port and path
|
391
|
+
'(\?[&a-z\d%_.~+=-]*)?' + // query string
|
392
|
+
'(\#[-a-z\d_]*)?$', 'i'); // fragment locater
|
393
|
+
if (!pattern.test(str)) {
|
394
|
+
alert("Please enter a valid URL.");
|
395
|
+
return false;
|
396
|
+
} else {
|
397
|
+
return true;
|
398
|
+
}
|
399
|
+
}
|
400
|
+
}, {
|
401
|
+
key: '_checkProtocol',
|
402
|
+
value: function _checkProtocol() {
|
403
|
+
return console.log("xcvd");
|
404
|
+
}
|
405
|
+
}, {
|
406
|
+
key: '_showPopLinkOver',
|
407
|
+
value: function _showPopLinkOver(e) {
|
408
|
+
if (!this.data.showPopLinkOver) {
|
409
|
+
return;
|
410
|
+
}
|
411
|
+
return this.data.showPopLinkOver(this.refs.link);
|
412
|
+
}
|
413
|
+
}, {
|
414
|
+
key: '_hidePopLinkOver',
|
415
|
+
value: function _hidePopLinkOver(e) {
|
416
|
+
if (!this.data.hidePopLinkOver) {
|
417
|
+
return;
|
418
|
+
}
|
419
|
+
return this.data.hidePopLinkOver();
|
420
|
+
}
|
421
|
+
}, {
|
422
|
+
key: 'render',
|
423
|
+
value: function render() {
|
424
|
+
this.data = _draftJs.Entity.get(this.props.entityKey).getData();
|
425
|
+
|
426
|
+
return _react2['default'].createElement(
|
427
|
+
'a',
|
428
|
+
{
|
429
|
+
ref: 'link',
|
430
|
+
href: this.data.url,
|
431
|
+
className: 'markup--anchor',
|
432
|
+
onMouseOver: this._showPopLinkOver,
|
433
|
+
onMouseOut: this._hidePopLinkOver
|
434
|
+
},
|
435
|
+
this.props.children
|
436
|
+
);
|
437
|
+
}
|
438
|
+
}]);
|
439
|
+
return Link;
|
440
|
+
}(_react2['default'].Component);
|
441
|
+
|
442
|
+
exports['default'] = Link;
|
443
|
+
|
444
|
+
/***/ },
|
445
|
+
|
446
|
+
/***/ 428:
|
447
|
+
/***/ function(module, exports, __webpack_require__) {
|
448
|
+
|
449
|
+
"use strict";
|
450
|
+
|
451
|
+
Object.defineProperty(exports, "__esModule", {
|
452
|
+
value: true
|
453
|
+
});
|
454
|
+
|
455
|
+
var _stringify = __webpack_require__(429);
|
456
|
+
|
457
|
+
var _stringify2 = _interopRequireDefault(_stringify);
|
458
|
+
|
459
|
+
var _getPrototypeOf = __webpack_require__(208);
|
460
|
+
|
461
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
462
|
+
|
463
|
+
var _classCallCheck2 = __webpack_require__(23);
|
464
|
+
|
465
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
466
|
+
|
467
|
+
var _createClass2 = __webpack_require__(24);
|
468
|
+
|
469
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
470
|
+
|
471
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
472
|
+
|
473
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
474
|
+
|
475
|
+
var _inherits2 = __webpack_require__(266);
|
476
|
+
|
477
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
478
|
+
|
479
|
+
var _react = __webpack_require__(43);
|
480
|
+
|
481
|
+
var _react2 = _interopRequireDefault(_react);
|
482
|
+
|
483
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
484
|
+
|
485
|
+
var Debug = function (_React$Component) {
|
486
|
+
(0, _inherits3["default"])(Debug, _React$Component);
|
487
|
+
|
488
|
+
function Debug() {
|
489
|
+
(0, _classCallCheck3["default"])(this, Debug);
|
490
|
+
|
491
|
+
var _this = (0, _possibleConstructorReturn3["default"])(this, (Debug.__proto__ || (0, _getPrototypeOf2["default"])(Debug)).call(this));
|
492
|
+
|
493
|
+
_this.handleToggleReadOnly = _this.handleToggleReadOnly.bind(_this);
|
494
|
+
_this.handleTestEmitAndDecode = _this.handleTestEmitAndDecode.bind(_this);
|
495
|
+
_this.handleTestEmitTEXT = _this.handleTestEmitTEXT.bind(_this);
|
496
|
+
_this.testEmitAndDecode = _this.testEmitAndDecode.bind(_this);
|
497
|
+
_this.testEmitTEXT = _this.testEmitTEXT.bind(_this);
|
498
|
+
_this.logState = _this.logState.bind(_this);
|
499
|
+
_this.toggleDisplay = _this.toggleDisplay.bind(_this);
|
500
|
+
_this.open = _this.open.bind(_this);
|
501
|
+
_this.render = _this.render.bind(_this);
|
502
|
+
_this.state = {
|
503
|
+
output: "",
|
504
|
+
display: "none"
|
505
|
+
};
|
506
|
+
return _this;
|
507
|
+
}
|
508
|
+
|
509
|
+
(0, _createClass3["default"])(Debug, [{
|
510
|
+
key: "handleToggleReadOnly",
|
511
|
+
value: function handleToggleReadOnly(e) {
|
512
|
+
e.preventDefault();
|
513
|
+
this.props.editor.toggleEditable();
|
514
|
+
return false;
|
515
|
+
}
|
516
|
+
}, {
|
517
|
+
key: "handleTestEmitAndDecode",
|
518
|
+
value: function handleTestEmitAndDecode(e) {
|
519
|
+
e.preventDefault();
|
520
|
+
return this.testEmitAndDecode();
|
521
|
+
}
|
522
|
+
}, {
|
523
|
+
key: "handleTestEmitTEXT",
|
524
|
+
value: function handleTestEmitTEXT(e) {
|
525
|
+
e.preventDefault();
|
526
|
+
return this.testEmitTEXT();
|
527
|
+
}
|
528
|
+
}, {
|
529
|
+
key: "testEmitAndDecode",
|
530
|
+
value: function testEmitAndDecode(e) {
|
531
|
+
var raw_as_json = this.props.editor.emitSerializedOutput();
|
532
|
+
this.props.editor.setState({
|
533
|
+
editorState: this.props.editor.decodeEditorContent(raw_as_json) }, this.logState((0, _stringify2["default"])(raw_as_json)));
|
534
|
+
return false;
|
535
|
+
}
|
536
|
+
}, {
|
537
|
+
key: "testEmitTEXT",
|
538
|
+
value: function testEmitTEXT() {
|
539
|
+
var text = this.props.editor.getTextFromEditor();
|
540
|
+
return this.logState(text);
|
541
|
+
}
|
542
|
+
}, {
|
543
|
+
key: "logState",
|
544
|
+
value: function logState(raw) {
|
545
|
+
return this.setState({ output: raw }, this.open);
|
546
|
+
}
|
547
|
+
}, {
|
548
|
+
key: "toggleDisplay",
|
549
|
+
value: function toggleDisplay(e) {
|
550
|
+
e.preventDefault();
|
551
|
+
var d = this.state.display === "block" ? "none" : this.state.display;
|
552
|
+
return this.setState({
|
553
|
+
display: d });
|
554
|
+
}
|
555
|
+
}, {
|
556
|
+
key: "open",
|
557
|
+
value: function open() {
|
558
|
+
return this.setState({
|
559
|
+
display: "block" });
|
560
|
+
}
|
561
|
+
}, {
|
562
|
+
key: "render",
|
563
|
+
value: function render() {
|
564
|
+
return _react2["default"].createElement(
|
565
|
+
"div",
|
566
|
+
null,
|
567
|
+
_react2["default"].createElement(
|
568
|
+
"div",
|
569
|
+
{ className: "debugControls" },
|
570
|
+
_react2["default"].createElement(
|
571
|
+
"ul",
|
572
|
+
null,
|
573
|
+
_react2["default"].createElement(
|
574
|
+
"li",
|
575
|
+
null,
|
576
|
+
" LOCKS: ",
|
577
|
+
this.props.editor.state.locks,
|
578
|
+
" "
|
579
|
+
),
|
580
|
+
_react2["default"].createElement(
|
581
|
+
"li",
|
582
|
+
null,
|
583
|
+
_react2["default"].createElement(
|
584
|
+
"a",
|
585
|
+
{ href: "#", onClick: this.handleToggleReadOnly },
|
586
|
+
"EDITABLE: ",
|
587
|
+
this.props.editor.state.read_only ? 'NO' : 'YES'
|
588
|
+
)
|
589
|
+
),
|
590
|
+
_react2["default"].createElement(
|
591
|
+
"li",
|
592
|
+
null,
|
593
|
+
_react2["default"].createElement(
|
594
|
+
"a",
|
595
|
+
{ href: "#", onClick: this.handleTestEmitTEXT },
|
596
|
+
"EDITOR TEXT"
|
597
|
+
)
|
598
|
+
),
|
599
|
+
_react2["default"].createElement(
|
600
|
+
"li",
|
601
|
+
null,
|
602
|
+
_react2["default"].createElement(
|
603
|
+
"a",
|
604
|
+
{ href: "#", onClick: this.handleTestEmitAndDecode },
|
605
|
+
"EDITOR STATE"
|
606
|
+
)
|
607
|
+
)
|
608
|
+
)
|
609
|
+
),
|
610
|
+
_react2["default"].createElement(
|
611
|
+
"div",
|
612
|
+
{ className: "debugZone", style: { display: this.state.display } },
|
613
|
+
_react2["default"].createElement("a", { href: "#", className: "dante-debug-close close", onClick: this.toggleDisplay }),
|
614
|
+
_react2["default"].createElement(
|
615
|
+
"div",
|
616
|
+
{ className: "debugOutput" },
|
617
|
+
_react2["default"].createElement(
|
618
|
+
"h2",
|
619
|
+
null,
|
620
|
+
"EDITOR OUTPUT"
|
621
|
+
),
|
622
|
+
this.state.output.length > 0 ? _react2["default"].createElement(
|
623
|
+
"pre",
|
624
|
+
null,
|
625
|
+
this.state.output
|
626
|
+
) : undefined
|
627
|
+
)
|
628
|
+
)
|
629
|
+
);
|
630
|
+
}
|
631
|
+
}]);
|
632
|
+
return Debug;
|
633
|
+
}(_react2["default"].Component);
|
634
|
+
|
635
|
+
exports["default"] = Debug;
|
636
|
+
|
637
|
+
/***/ },
|
638
|
+
|
639
|
+
/***/ 431:
|
640
|
+
/***/ function(module, exports, __webpack_require__) {
|
641
|
+
|
642
|
+
'use strict';
|
643
|
+
|
644
|
+
Object.defineProperty(exports, "__esModule", {
|
645
|
+
value: true
|
646
|
+
});
|
647
|
+
|
648
|
+
var _draftJs = __webpack_require__(274);
|
649
|
+
|
650
|
+
//TODO: what the f*ck is happening here? ;-;
|
651
|
+
var findEntities = function findEntities(entityType, instance, contentBlock, callback) {
|
652
|
+
return contentBlock.findEntityRanges(function (_this) {
|
653
|
+
return function (character) {
|
654
|
+
var entityKey, opts, res;
|
655
|
+
entityKey = character.getEntity();
|
656
|
+
return res = entityKey !== null && _draftJs.Entity.get(entityKey).getType() === entityType, res ? (opts = {
|
657
|
+
showPopLinkOver: instance.showPopLinkOver,
|
658
|
+
hidePopLinkOver: instance.hidePopLinkOver
|
659
|
+
}, _draftJs.Entity.mergeData(entityKey, opts)) : void 0, res;
|
660
|
+
};
|
661
|
+
}(undefined), callback);
|
662
|
+
};
|
663
|
+
|
664
|
+
exports['default'] = findEntities;
|
665
|
+
|
666
|
+
/***/ },
|
667
|
+
|
668
|
+
/***/ 432:
|
669
|
+
/***/ function(module, exports, __webpack_require__) {
|
670
|
+
|
671
|
+
"use strict";
|
672
|
+
|
673
|
+
Object.defineProperty(exports, "__esModule", {
|
674
|
+
value: true
|
675
|
+
});
|
676
|
+
|
677
|
+
var _stringify = __webpack_require__(429);
|
678
|
+
|
679
|
+
var _stringify2 = _interopRequireDefault(_stringify);
|
680
|
+
|
681
|
+
var _classCallCheck2 = __webpack_require__(23);
|
682
|
+
|
683
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
684
|
+
|
685
|
+
var _createClass2 = __webpack_require__(24);
|
686
|
+
|
687
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
688
|
+
|
689
|
+
var _axios = __webpack_require__(433);
|
690
|
+
|
691
|
+
var _axios2 = _interopRequireDefault(_axios);
|
692
|
+
|
693
|
+
var _immutable = __webpack_require__(205);
|
694
|
+
|
695
|
+
var _immutable2 = _interopRequireDefault(_immutable);
|
696
|
+
|
697
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
698
|
+
|
699
|
+
var SaveBehavior = function () {
|
700
|
+
function SaveBehavior(options) {
|
701
|
+
(0, _classCallCheck3["default"])(this, SaveBehavior);
|
702
|
+
|
703
|
+
this.getLocks = options.getLocks;
|
704
|
+
this.config = options.config;
|
705
|
+
this.editorContent = options.editorContent;
|
706
|
+
this.editorState = options.editorState;
|
707
|
+
}
|
708
|
+
|
709
|
+
(0, _createClass3["default"])(SaveBehavior, [{
|
710
|
+
key: "handleStore",
|
711
|
+
value: function handleStore(ev) {
|
712
|
+
return this.store();
|
713
|
+
}
|
714
|
+
}, {
|
715
|
+
key: "store",
|
716
|
+
value: function store(content) {
|
717
|
+
var _this = this;
|
718
|
+
|
719
|
+
if (!this.config.data_storage.url) {
|
720
|
+
return;
|
721
|
+
}
|
722
|
+
if (this.getLocks() > 0) {
|
723
|
+
return;
|
724
|
+
}
|
725
|
+
|
726
|
+
clearTimeout(this.timeout);
|
727
|
+
|
728
|
+
return this.timeout = setTimeout(function () {
|
729
|
+
return _this.checkforStore(content);
|
730
|
+
}, this.config.data_storage.interval);
|
731
|
+
}
|
732
|
+
}, {
|
733
|
+
key: "getTextFromEditor",
|
734
|
+
value: function getTextFromEditor(content) {
|
735
|
+
return content.blocks.map(function (o) {
|
736
|
+
return o.text;
|
737
|
+
}).join("\n");
|
738
|
+
}
|
739
|
+
}, {
|
740
|
+
key: "getUrl",
|
741
|
+
value: function getUrl() {
|
742
|
+
var url = this.config.data_storage.url;
|
743
|
+
|
744
|
+
if (typeof url === "function") {
|
745
|
+
return url();
|
746
|
+
} else {
|
747
|
+
return url;
|
748
|
+
}
|
749
|
+
}
|
750
|
+
}, {
|
751
|
+
key: "getMethod",
|
752
|
+
value: function getMethod() {
|
753
|
+
var method = this.config.data_storage.method;
|
754
|
+
|
755
|
+
if (typeof method === "function") {
|
756
|
+
return method();
|
757
|
+
} else {
|
758
|
+
return method;
|
759
|
+
}
|
760
|
+
}
|
761
|
+
}, {
|
762
|
+
key: "checkforStore",
|
763
|
+
value: function checkforStore(content) {
|
764
|
+
var _this2 = this;
|
765
|
+
|
766
|
+
// ENTER DATA STORE
|
767
|
+
var isChanged = !_immutable2["default"].is(_immutable2["default"].fromJS(this.editorContent), _immutable2["default"].fromJS(content));
|
768
|
+
// console.log("CONTENT CHANGED:", isChanged)
|
769
|
+
|
770
|
+
if (!isChanged) {
|
771
|
+
return;
|
772
|
+
}
|
773
|
+
|
774
|
+
if (this.config.xhr.before_handler) {
|
775
|
+
this.config.xhr.before_handler();
|
776
|
+
}
|
777
|
+
// console.log "SAVING TO: #{@getMethod()} #{@getUrl()}"
|
778
|
+
|
779
|
+
return (0, _axios2["default"])({
|
780
|
+
method: this.getMethod(),
|
781
|
+
url: this.getUrl(),
|
782
|
+
data: {
|
783
|
+
editor_content: (0, _stringify2["default"])(content),
|
784
|
+
text_content: this.getTextFromEditor(content)
|
785
|
+
}
|
786
|
+
}).then(function (result) {
|
787
|
+
// console.log "STORING CONTENT", result
|
788
|
+
if (_this2.config.data_storage.success_handler) {
|
789
|
+
_this2.config.data_storage.success_handler(result);
|
790
|
+
}
|
791
|
+
if (_this2.config.xhr.success_handler) {
|
792
|
+
return _this2.config.xhr.success_handler(result);
|
793
|
+
}
|
794
|
+
})["catch"](function (error) {
|
795
|
+
// console.log("ERROR: got error saving content at #{@config.data_storage.url} - #{error}")
|
796
|
+
if (_this2.config.xhr.failure_handler) {
|
797
|
+
return _this2.config.xhr.failure_handler(error);
|
798
|
+
}
|
799
|
+
});
|
800
|
+
}
|
801
|
+
}]);
|
802
|
+
return SaveBehavior;
|
803
|
+
}();
|
804
|
+
|
805
|
+
exports["default"] = SaveBehavior;
|
806
|
+
|
807
|
+
/***/ },
|
808
|
+
|
809
|
+
/***/ 458:
|
810
|
+
/***/ function(module, exports, __webpack_require__) {
|
811
|
+
|
812
|
+
'use strict';
|
813
|
+
|
814
|
+
Object.defineProperty(exports, "__esModule", {
|
815
|
+
value: true
|
816
|
+
});
|
817
|
+
|
818
|
+
var _stringify = __webpack_require__(429);
|
819
|
+
|
820
|
+
var _stringify2 = _interopRequireDefault(_stringify);
|
821
|
+
|
822
|
+
var _draftJs = __webpack_require__(274);
|
823
|
+
|
824
|
+
var _immutable = __webpack_require__(205);
|
825
|
+
|
826
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
827
|
+
|
828
|
+
// { compose
|
829
|
+
// } = require('underscore')
|
830
|
+
|
831
|
+
// underscore compose function
|
832
|
+
var compose = function compose() {
|
833
|
+
var args = arguments;
|
834
|
+
var start = args.length - 1;
|
835
|
+
return function () {
|
836
|
+
var i = start;
|
837
|
+
var result = args[start].apply(this, arguments);
|
838
|
+
while (i--) {
|
839
|
+
result = args[i].call(this, result);
|
840
|
+
}
|
841
|
+
return result;
|
842
|
+
};
|
843
|
+
};
|
844
|
+
|
845
|
+
// from https://gist.github.com/N1kto/6702e1c2d89a33a15a032c234fc4c34e
|
846
|
+
|
847
|
+
/*
|
848
|
+
* Helpers
|
849
|
+
*/
|
850
|
+
|
851
|
+
// Prepares img meta data object based on img attributes
|
852
|
+
var getBlockSpecForElement = function getBlockSpecForElement(imgElement) {
|
853
|
+
return {
|
854
|
+
contentType: 'image',
|
855
|
+
imgSrc: imgElement.getAttribute('src')
|
856
|
+
};
|
857
|
+
};
|
858
|
+
|
859
|
+
// Wraps meta data in HTML element which is 'understandable' by Draft, I used <blockquote />.
|
860
|
+
var wrapBlockSpec = function wrapBlockSpec(blockSpec) {
|
861
|
+
if (blockSpec === null) {
|
862
|
+
return null;
|
863
|
+
}
|
864
|
+
|
865
|
+
var tempEl = document.createElement('blockquote');
|
866
|
+
// stringify meta data and insert it as text content of temp HTML element. We will later extract
|
867
|
+
// and parse it.
|
868
|
+
tempEl.innerText = (0, _stringify2['default'])(blockSpec);
|
869
|
+
return tempEl;
|
870
|
+
};
|
871
|
+
|
872
|
+
// Replaces <img> element with our temp element
|
873
|
+
var replaceElement = function replaceElement(oldEl, newEl) {
|
874
|
+
if (!(newEl instanceof HTMLElement)) {
|
875
|
+
return;
|
876
|
+
}
|
877
|
+
|
878
|
+
var upEl = getUpEl(oldEl);
|
879
|
+
//parentNode = oldEl.parentNode
|
880
|
+
//return parentNode.replaceChild(newEl, oldEl)
|
881
|
+
return upEl.parentNode.insertBefore(newEl, upEl);
|
882
|
+
};
|
883
|
+
|
884
|
+
var getUpEl = function getUpEl(el) {
|
885
|
+
var original_el = el;
|
886
|
+
while (el.parentNode) {
|
887
|
+
if (el.parentNode.tagName !== 'BODY') {
|
888
|
+
el = el.parentNode;
|
889
|
+
}
|
890
|
+
if (el.parentNode.tagName === 'BODY') {
|
891
|
+
return el;
|
892
|
+
}
|
893
|
+
}
|
894
|
+
};
|
895
|
+
|
896
|
+
var elementToBlockSpecElement = compose(wrapBlockSpec, getBlockSpecForElement);
|
897
|
+
|
898
|
+
var imgReplacer = function imgReplacer(imgElement) {
|
899
|
+
return replaceElement(imgElement, elementToBlockSpecElement(imgElement));
|
900
|
+
};
|
901
|
+
|
902
|
+
/*
|
903
|
+
* Main function
|
904
|
+
*/
|
905
|
+
|
906
|
+
// takes HTML string and returns DraftJS ContentState
|
907
|
+
var customHTML2Content = function customHTML2Content(HTML, blockRn) {
|
908
|
+
var tempDoc = new DOMParser().parseFromString(HTML, 'text/html');
|
909
|
+
// replace all <img /> with <blockquote /> elements
|
910
|
+
|
911
|
+
var a = tempDoc.querySelectorAll('img').forEach(function (item) {
|
912
|
+
return imgReplacer(item);
|
913
|
+
});
|
914
|
+
|
915
|
+
// use DraftJS converter to do initial conversion. I don't provide DOMBuilder and
|
916
|
+
// blockRenderMap arguments here since it should fall back to its default ones, which are fine
|
917
|
+
console.log(tempDoc.body.innerHTML);
|
918
|
+
var contentBlocks = (0, _draftJs.convertFromHTML)(tempDoc.body.innerHTML, _draftJs.getSafeBodyFromHTML, blockRn);
|
919
|
+
|
920
|
+
// now replace <blockquote /> ContentBlocks with 'atomic' ones
|
921
|
+
contentBlocks = contentBlocks.map(function (block) {
|
922
|
+
var newBlock = void 0;
|
923
|
+
console.log("CHECK BLOCK", block.getType());
|
924
|
+
if (block.getType() !== 'blockquote') {
|
925
|
+
return block;
|
926
|
+
}
|
927
|
+
|
928
|
+
var json = "";
|
929
|
+
try {
|
930
|
+
json = JSON.parse(block.getText());
|
931
|
+
} catch (error) {
|
932
|
+
return block;
|
933
|
+
}
|
934
|
+
|
935
|
+
return newBlock = block.merge({
|
936
|
+
type: "image",
|
937
|
+
text: "",
|
938
|
+
data: {
|
939
|
+
url: json.imgSrc,
|
940
|
+
forceUpload: true
|
941
|
+
}
|
942
|
+
});
|
943
|
+
});
|
944
|
+
|
945
|
+
tempDoc = null;
|
946
|
+
return _draftJs.ContentState.createFromBlockArray(contentBlocks);
|
947
|
+
};
|
948
|
+
|
949
|
+
exports['default'] = customHTML2Content;
|
950
|
+
|
951
|
+
/***/ },
|
952
|
+
|
953
|
+
/***/ 459:
|
954
|
+
/***/ function(module, exports, __webpack_require__) {
|
955
|
+
|
956
|
+
'use strict';
|
957
|
+
|
958
|
+
Object.defineProperty(exports, "__esModule", {
|
959
|
+
value: true
|
960
|
+
});
|
961
|
+
|
962
|
+
var _getPrototypeOf = __webpack_require__(208);
|
963
|
+
|
964
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
965
|
+
|
966
|
+
var _classCallCheck2 = __webpack_require__(23);
|
967
|
+
|
968
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
969
|
+
|
970
|
+
var _createClass2 = __webpack_require__(24);
|
971
|
+
|
972
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
973
|
+
|
974
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
975
|
+
|
976
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
977
|
+
|
978
|
+
var _inherits2 = __webpack_require__(266);
|
979
|
+
|
980
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
981
|
+
|
982
|
+
var _react = __webpack_require__(43);
|
983
|
+
|
984
|
+
var _react2 = _interopRequireDefault(_react);
|
985
|
+
|
986
|
+
var _reactDom = __webpack_require__(72);
|
987
|
+
|
988
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
989
|
+
|
990
|
+
var _draftJs = __webpack_require__(274);
|
991
|
+
|
992
|
+
var _selection = __webpack_require__(460);
|
993
|
+
|
994
|
+
var _index = __webpack_require__(426);
|
995
|
+
|
996
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
997
|
+
|
998
|
+
var DanteImagePopover = function (_React$Component) {
|
999
|
+
(0, _inherits3['default'])(DanteImagePopover, _React$Component);
|
1000
|
+
|
1001
|
+
function DanteImagePopover(props) {
|
1002
|
+
(0, _classCallCheck3['default'])(this, DanteImagePopover);
|
1003
|
+
|
1004
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (DanteImagePopover.__proto__ || (0, _getPrototypeOf2['default'])(DanteImagePopover)).call(this, props));
|
1005
|
+
|
1006
|
+
_this.display = _this.display.bind(_this);
|
1007
|
+
_this.show = _this.show.bind(_this);
|
1008
|
+
_this.hide = _this.hide.bind(_this);
|
1009
|
+
_this._toggleScaled = _this._toggleScaled.bind(_this);
|
1010
|
+
_this.scale = _this.scale.bind(_this);
|
1011
|
+
_this.collapse = _this.collapse.bind(_this);
|
1012
|
+
_this.relocate = _this.relocate.bind(_this);
|
1013
|
+
_this.componentWillReceiveProps = _this.componentWillReceiveProps.bind(_this);
|
1014
|
+
_this.handleClick = _this.handleClick.bind(_this);
|
1015
|
+
_this.state = {
|
1016
|
+
position: {
|
1017
|
+
top: 0,
|
1018
|
+
left: 0
|
1019
|
+
},
|
1020
|
+
show: false,
|
1021
|
+
scaled: false,
|
1022
|
+
buttons: [{ type: "left" }, { type: "center" }, { type: "fill" }, { type: "wide" }]
|
1023
|
+
};
|
1024
|
+
return _this;
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
(0, _createClass3['default'])(DanteImagePopover, [{
|
1028
|
+
key: 'display',
|
1029
|
+
value: function display(b) {
|
1030
|
+
if (b) {
|
1031
|
+
return this.show();
|
1032
|
+
} else {
|
1033
|
+
return this.hide();
|
1034
|
+
}
|
1035
|
+
}
|
1036
|
+
}, {
|
1037
|
+
key: 'show',
|
1038
|
+
value: function show() {
|
1039
|
+
return this.setState({
|
1040
|
+
show: true });
|
1041
|
+
}
|
1042
|
+
}, {
|
1043
|
+
key: 'hide',
|
1044
|
+
value: function hide() {
|
1045
|
+
return this.setState({
|
1046
|
+
show: false });
|
1047
|
+
}
|
1048
|
+
}, {
|
1049
|
+
key: 'setPosition',
|
1050
|
+
value: function setPosition(coords) {
|
1051
|
+
return this.setState({
|
1052
|
+
position: coords });
|
1053
|
+
}
|
1054
|
+
}, {
|
1055
|
+
key: '_toggleScaled',
|
1056
|
+
value: function _toggleScaled(ev) {
|
1057
|
+
if (this.state.scaled) {
|
1058
|
+
return this.collapse();
|
1059
|
+
} else {
|
1060
|
+
return this.scale();
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
}, {
|
1064
|
+
key: 'scale',
|
1065
|
+
value: function scale() {
|
1066
|
+
return this.setState({
|
1067
|
+
scaled: true });
|
1068
|
+
}
|
1069
|
+
}, {
|
1070
|
+
key: 'collapse',
|
1071
|
+
value: function collapse() {
|
1072
|
+
return this.setState({
|
1073
|
+
scaled: false });
|
1074
|
+
}
|
1075
|
+
}, {
|
1076
|
+
key: 'relocate',
|
1077
|
+
value: function relocate() {
|
1078
|
+
var editorState = this.props.editorState;
|
1079
|
+
|
1080
|
+
|
1081
|
+
if (editorState.getSelection().isCollapsed()) {
|
1082
|
+
|
1083
|
+
var currentBlock = (0, _index.getCurrentBlock)(editorState);
|
1084
|
+
var blockType = currentBlock.getType();
|
1085
|
+
|
1086
|
+
var contentState = editorState.getCurrentContent();
|
1087
|
+
var selectionState = editorState.getSelection();
|
1088
|
+
|
1089
|
+
var block = contentState.getBlockForKey(selectionState.anchorKey);
|
1090
|
+
|
1091
|
+
var nativeSelection = (0, _selection.getSelection)(window);
|
1092
|
+
if (!nativeSelection.rangeCount) {
|
1093
|
+
return;
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
var node = (0, _index.getNode)();
|
1097
|
+
|
1098
|
+
var selectionBoundary = (0, _selection.getSelectionRect)(nativeSelection);
|
1099
|
+
var coords = selectionBoundary;
|
1100
|
+
|
1101
|
+
var parent = _reactDom2['default'].findDOMNode(this.props.editor);
|
1102
|
+
var parentBoundary = parent.getBoundingClientRect();
|
1103
|
+
|
1104
|
+
this.display(blockType === "image");
|
1105
|
+
|
1106
|
+
if (blockType === "image") {
|
1107
|
+
selectionBoundary = node.anchorNode.parentNode.parentNode.parentNode.getBoundingClientRect();
|
1108
|
+
var el = this.refs.image_popover;
|
1109
|
+
var padd = el.offsetWidth / 2;
|
1110
|
+
return this.setPosition({
|
1111
|
+
top: selectionBoundary.top - parentBoundary.top + 60,
|
1112
|
+
left: selectionBoundary.left + selectionBoundary.width / 2 - padd
|
1113
|
+
});
|
1114
|
+
}
|
1115
|
+
} else {
|
1116
|
+
return this.hide();
|
1117
|
+
}
|
1118
|
+
}
|
1119
|
+
}, {
|
1120
|
+
key: 'componentWillReceiveProps',
|
1121
|
+
value: function componentWillReceiveProps(newProps) {
|
1122
|
+
return this.collapse();
|
1123
|
+
}
|
1124
|
+
}, {
|
1125
|
+
key: 'getStyle',
|
1126
|
+
value: function getStyle() {
|
1127
|
+
if (!this.state.position) {
|
1128
|
+
return {};
|
1129
|
+
}
|
1130
|
+
}
|
1131
|
+
}, {
|
1132
|
+
key: 'handleClick',
|
1133
|
+
value: function handleClick(item) {
|
1134
|
+
return this.props.editor.setDirection(item.type);
|
1135
|
+
}
|
1136
|
+
}, {
|
1137
|
+
key: 'render',
|
1138
|
+
value: function render() {
|
1139
|
+
var _this2 = this;
|
1140
|
+
|
1141
|
+
return _react2['default'].createElement(
|
1142
|
+
'div',
|
1143
|
+
{
|
1144
|
+
ref: 'image_popover',
|
1145
|
+
className: 'dante-popover popover--Aligntooltip popover--top popover--animated ' + (this.state.show ? 'is-active' : undefined),
|
1146
|
+
style: { top: this.state.position.top,
|
1147
|
+
left: this.state.position.left }
|
1148
|
+
},
|
1149
|
+
_react2['default'].createElement(
|
1150
|
+
'div',
|
1151
|
+
{ className: 'popover-inner' },
|
1152
|
+
_react2['default'].createElement(
|
1153
|
+
'ul',
|
1154
|
+
{ className: 'dante-menu-buttons' },
|
1155
|
+
this.state.buttons.map(function (item, i) {
|
1156
|
+
return _react2['default'].createElement(DanteImagePopoverItem, {
|
1157
|
+
item: item,
|
1158
|
+
handleClick: _this2.handleClick,
|
1159
|
+
key: i
|
1160
|
+
});
|
1161
|
+
})
|
1162
|
+
)
|
1163
|
+
),
|
1164
|
+
_react2['default'].createElement('div', { className: 'popover-arrow' })
|
1165
|
+
);
|
1166
|
+
}
|
1167
|
+
}]);
|
1168
|
+
return DanteImagePopover;
|
1169
|
+
}(_react2['default'].Component);
|
1170
|
+
|
1171
|
+
var DanteImagePopoverItem = function (_React$Component2) {
|
1172
|
+
(0, _inherits3['default'])(DanteImagePopoverItem, _React$Component2);
|
1173
|
+
|
1174
|
+
function DanteImagePopoverItem() {
|
1175
|
+
var _ref;
|
1176
|
+
|
1177
|
+
(0, _classCallCheck3['default'])(this, DanteImagePopoverItem);
|
1178
|
+
|
1179
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1180
|
+
args[_key] = arguments[_key];
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
var _this3 = (0, _possibleConstructorReturn3['default'])(this, (_ref = DanteImagePopoverItem.__proto__ || (0, _getPrototypeOf2['default'])(DanteImagePopoverItem)).call.apply(_ref, [this].concat(args)));
|
1184
|
+
|
1185
|
+
_this3.handleClick = _this3.handleClick.bind(_this3);
|
1186
|
+
_this3.render = _this3.render.bind(_this3);
|
1187
|
+
return _this3;
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
(0, _createClass3['default'])(DanteImagePopoverItem, [{
|
1191
|
+
key: 'handleClick',
|
1192
|
+
value: function handleClick(e) {
|
1193
|
+
e.preventDefault();
|
1194
|
+
return this.props.handleClick(this.props.item);
|
1195
|
+
}
|
1196
|
+
}, {
|
1197
|
+
key: 'render',
|
1198
|
+
value: function render() {
|
1199
|
+
return _react2['default'].createElement(
|
1200
|
+
'li',
|
1201
|
+
{
|
1202
|
+
className: 'dante-menu-button align-' + this.props.item.type,
|
1203
|
+
onMouseDown: this.handleClick },
|
1204
|
+
_react2['default'].createElement('span', { className: 'tooltip-icon dante-icon-image-' + this.props.item.type })
|
1205
|
+
);
|
1206
|
+
}
|
1207
|
+
}]);
|
1208
|
+
return DanteImagePopoverItem;
|
1209
|
+
}(_react2['default'].Component);
|
1210
|
+
|
1211
|
+
exports['default'] = DanteImagePopover;
|
1212
|
+
|
1213
|
+
/***/ },
|
1214
|
+
|
1215
|
+
/***/ 460:
|
1216
|
+
/***/ function(module, exports) {
|
1217
|
+
|
1218
|
+
'use strict';
|
1219
|
+
|
1220
|
+
Object.defineProperty(exports, "__esModule", {
|
1221
|
+
value: true
|
1222
|
+
});
|
1223
|
+
/*
|
1224
|
+
Returns the `boundingClientRect` of the passed selection.
|
1225
|
+
*/
|
1226
|
+
var getSelectionRect = exports.getSelectionRect = function getSelectionRect(selected) {
|
1227
|
+
var _rect = selected.getRangeAt(0).getBoundingClientRect();
|
1228
|
+
// selected.getRangeAt(0).getBoundingClientRect()
|
1229
|
+
var rect = _rect && _rect.top ? _rect : selected.getRangeAt(0).getClientRects()[0];
|
1230
|
+
if (!rect) {
|
1231
|
+
if (selected.anchorNode && selected.anchorNode.getBoundingClientRect) {
|
1232
|
+
rect = selected.anchorNode.getBoundingClientRect();
|
1233
|
+
rect.isEmptyline = true;
|
1234
|
+
} else {
|
1235
|
+
return null;
|
1236
|
+
}
|
1237
|
+
}
|
1238
|
+
return rect;
|
1239
|
+
};
|
1240
|
+
|
1241
|
+
/*
|
1242
|
+
Returns the native selection node.
|
1243
|
+
*/
|
1244
|
+
var getSelection = exports.getSelection = function getSelection(root) {
|
1245
|
+
var t = null;
|
1246
|
+
if (root.getSelection) {
|
1247
|
+
t = root.getSelection();
|
1248
|
+
} else if (root.document.getSelection) {
|
1249
|
+
t = root.document.getSelection();
|
1250
|
+
} else if (root.document.selection) {
|
1251
|
+
t = root.document.selection.createRange().text;
|
1252
|
+
}
|
1253
|
+
return t;
|
1254
|
+
};
|
1255
|
+
|
1256
|
+
/*
|
1257
|
+
Recursively finds the DOM Element of the block where the cursor is currently present.
|
1258
|
+
If not found, returns null.
|
1259
|
+
*/
|
1260
|
+
var getSelectedBlockNode = exports.getSelectedBlockNode = function getSelectedBlockNode(root) {
|
1261
|
+
var selection = root.getSelection();
|
1262
|
+
if (selection.rangeCount === 0) {
|
1263
|
+
return null;
|
1264
|
+
}
|
1265
|
+
var node = selection.getRangeAt(0).startContainer;
|
1266
|
+
// console.log(node);
|
1267
|
+
do {
|
1268
|
+
if (node.getAttribute && node.getAttribute('data-block') === 'true') {
|
1269
|
+
return node;
|
1270
|
+
}
|
1271
|
+
node = node.parentNode;
|
1272
|
+
// console.log(node);
|
1273
|
+
} while (node !== null);
|
1274
|
+
return null;
|
1275
|
+
};
|
1276
|
+
|
1277
|
+
/***/ },
|
1278
|
+
|
1279
|
+
/***/ 461:
|
1280
|
+
/***/ function(module, exports, __webpack_require__) {
|
1281
|
+
|
1282
|
+
'use strict';
|
1283
|
+
|
1284
|
+
Object.defineProperty(exports, "__esModule", {
|
1285
|
+
value: true
|
1286
|
+
});
|
1287
|
+
|
1288
|
+
var _getPrototypeOf = __webpack_require__(208);
|
1289
|
+
|
1290
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
1291
|
+
|
1292
|
+
var _classCallCheck2 = __webpack_require__(23);
|
1293
|
+
|
1294
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
1295
|
+
|
1296
|
+
var _createClass2 = __webpack_require__(24);
|
1297
|
+
|
1298
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
1299
|
+
|
1300
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
1301
|
+
|
1302
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
1303
|
+
|
1304
|
+
var _inherits2 = __webpack_require__(266);
|
1305
|
+
|
1306
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
1307
|
+
|
1308
|
+
var _react = __webpack_require__(43);
|
1309
|
+
|
1310
|
+
var _react2 = _interopRequireDefault(_react);
|
1311
|
+
|
1312
|
+
var _reactDom = __webpack_require__(72);
|
1313
|
+
|
1314
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
1315
|
+
|
1316
|
+
var _index = __webpack_require__(426);
|
1317
|
+
|
1318
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
1319
|
+
|
1320
|
+
var DanteAnchorPopover = function (_React$Component) {
|
1321
|
+
(0, _inherits3['default'])(DanteAnchorPopover, _React$Component);
|
1322
|
+
|
1323
|
+
function DanteAnchorPopover(props) {
|
1324
|
+
(0, _classCallCheck3['default'])(this, DanteAnchorPopover);
|
1325
|
+
|
1326
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (DanteAnchorPopover.__proto__ || (0, _getPrototypeOf2['default'])(DanteAnchorPopover)).call(this, props));
|
1327
|
+
|
1328
|
+
_this.display = _this.display.bind(_this);
|
1329
|
+
_this.show = _this.show.bind(_this);
|
1330
|
+
_this.hide = _this.hide.bind(_this);
|
1331
|
+
_this.relocate = _this.relocate.bind(_this);
|
1332
|
+
_this.render = _this.render.bind(_this);
|
1333
|
+
_this.state = {
|
1334
|
+
position: {
|
1335
|
+
top: 0,
|
1336
|
+
left: 0
|
1337
|
+
},
|
1338
|
+
show: false,
|
1339
|
+
url: ""
|
1340
|
+
};
|
1341
|
+
return _this;
|
1342
|
+
}
|
1343
|
+
|
1344
|
+
(0, _createClass3['default'])(DanteAnchorPopover, [{
|
1345
|
+
key: 'display',
|
1346
|
+
value: function display(b) {
|
1347
|
+
if (b) {
|
1348
|
+
return this.show();
|
1349
|
+
} else {
|
1350
|
+
return this.hide();
|
1351
|
+
}
|
1352
|
+
}
|
1353
|
+
}, {
|
1354
|
+
key: 'show',
|
1355
|
+
value: function show() {
|
1356
|
+
return this.setState({
|
1357
|
+
show: true });
|
1358
|
+
}
|
1359
|
+
}, {
|
1360
|
+
key: 'hide',
|
1361
|
+
value: function hide() {
|
1362
|
+
return this.setState({
|
1363
|
+
show: false });
|
1364
|
+
}
|
1365
|
+
}, {
|
1366
|
+
key: 'setPosition',
|
1367
|
+
value: function setPosition(coords) {
|
1368
|
+
return this.setState({
|
1369
|
+
position: coords });
|
1370
|
+
}
|
1371
|
+
}, {
|
1372
|
+
key: 'relocate',
|
1373
|
+
value: function relocate(node) {
|
1374
|
+
if (node == null) {
|
1375
|
+
node = null;
|
1376
|
+
}
|
1377
|
+
if (!node) {
|
1378
|
+
return;
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
var editorState = this.props.editorState;
|
1382
|
+
|
1383
|
+
var currentBlock = (0, _index.getCurrentBlock)(editorState);
|
1384
|
+
var blockType = currentBlock.getType();
|
1385
|
+
|
1386
|
+
var contentState = editorState.getCurrentContent();
|
1387
|
+
var selectionState = editorState.getSelection();
|
1388
|
+
|
1389
|
+
var selectionBoundary = node.getBoundingClientRect();
|
1390
|
+
var coords = selectionBoundary;
|
1391
|
+
|
1392
|
+
var el = this.refs.dante_popover;
|
1393
|
+
var padd = el.offsetWidth / 2;
|
1394
|
+
|
1395
|
+
var parent = _reactDom2['default'].findDOMNode(this.props.editor);
|
1396
|
+
var parentBoundary = parent.getBoundingClientRect();
|
1397
|
+
|
1398
|
+
return {
|
1399
|
+
top: selectionBoundary.top - parentBoundary.top + 160,
|
1400
|
+
left: selectionBoundary.left + selectionBoundary.width / 2 - padd
|
1401
|
+
};
|
1402
|
+
}
|
1403
|
+
}, {
|
1404
|
+
key: 'render',
|
1405
|
+
value: function render() {
|
1406
|
+
var position = this.state.position;
|
1407
|
+
|
1408
|
+
var style = {
|
1409
|
+
left: position.left,
|
1410
|
+
top: position.top,
|
1411
|
+
visibility: '' + (this.state.show ? 'visible' : 'hidden')
|
1412
|
+
};
|
1413
|
+
return _react2['default'].createElement(
|
1414
|
+
'div',
|
1415
|
+
{
|
1416
|
+
ref: 'dante_popover',
|
1417
|
+
className: 'dante-popover popover--tooltip popover--Linktooltip popover--bottom is-active',
|
1418
|
+
style: style,
|
1419
|
+
onMouseOver: this.props.handleOnMouseOver,
|
1420
|
+
onMouseOut: this.props.handleOnMouseOut
|
1421
|
+
},
|
1422
|
+
_react2['default'].createElement(
|
1423
|
+
'div',
|
1424
|
+
{ className: 'popover-inner' },
|
1425
|
+
_react2['default'].createElement(
|
1426
|
+
'a',
|
1427
|
+
{ href: this.props.url, target: '_blank' },
|
1428
|
+
this.state.url
|
1429
|
+
)
|
1430
|
+
),
|
1431
|
+
_react2['default'].createElement('div', { className: 'popover-arrow' })
|
1432
|
+
);
|
1433
|
+
}
|
1434
|
+
}]);
|
1435
|
+
return DanteAnchorPopover;
|
1436
|
+
}(_react2['default'].Component);
|
1437
|
+
|
1438
|
+
exports['default'] = DanteAnchorPopover;
|
1439
|
+
|
1440
|
+
/***/ },
|
1441
|
+
|
1442
|
+
/***/ 462:
|
1443
|
+
/***/ function(module, exports, __webpack_require__) {
|
1444
|
+
|
1445
|
+
'use strict';
|
1446
|
+
|
1447
|
+
Object.defineProperty(exports, "__esModule", {
|
1448
|
+
value: true
|
1449
|
+
});
|
1450
|
+
|
1451
|
+
var _getPrototypeOf = __webpack_require__(208);
|
1452
|
+
|
1453
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
1454
|
+
|
1455
|
+
var _classCallCheck2 = __webpack_require__(23);
|
1456
|
+
|
1457
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
1458
|
+
|
1459
|
+
var _createClass2 = __webpack_require__(24);
|
1460
|
+
|
1461
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
1462
|
+
|
1463
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
1464
|
+
|
1465
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
1466
|
+
|
1467
|
+
var _inherits2 = __webpack_require__(266);
|
1468
|
+
|
1469
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
1470
|
+
|
1471
|
+
var _react = __webpack_require__(43);
|
1472
|
+
|
1473
|
+
var _react2 = _interopRequireDefault(_react);
|
1474
|
+
|
1475
|
+
var _reactDom = __webpack_require__(72);
|
1476
|
+
|
1477
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
1478
|
+
|
1479
|
+
var _draftJs = __webpack_require__(274);
|
1480
|
+
|
1481
|
+
var _index = __webpack_require__(426);
|
1482
|
+
|
1483
|
+
var _selection = __webpack_require__(460);
|
1484
|
+
|
1485
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
1486
|
+
|
1487
|
+
var DanteInlineTooltip = function (_React$Component) {
|
1488
|
+
(0, _inherits3['default'])(DanteInlineTooltip, _React$Component);
|
1489
|
+
|
1490
|
+
function DanteInlineTooltip(props) {
|
1491
|
+
(0, _classCallCheck3['default'])(this, DanteInlineTooltip);
|
1492
|
+
|
1493
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (DanteInlineTooltip.__proto__ || (0, _getPrototypeOf2['default'])(DanteInlineTooltip)).call(this, props));
|
1494
|
+
|
1495
|
+
_this.display = _this.display.bind(_this);
|
1496
|
+
_this.show = _this.show.bind(_this);
|
1497
|
+
_this.hide = _this.hide.bind(_this);
|
1498
|
+
_this._toggleScaled = _this._toggleScaled.bind(_this);
|
1499
|
+
_this.scale = _this.scale.bind(_this);
|
1500
|
+
_this.collapse = _this.collapse.bind(_this);
|
1501
|
+
_this.componentWillReceiveProps = _this.componentWillReceiveProps.bind(_this);
|
1502
|
+
_this.clickOnFileUpload = _this.clickOnFileUpload.bind(_this);
|
1503
|
+
_this.handlePlaceholder = _this.handlePlaceholder.bind(_this);
|
1504
|
+
_this.insertImage = _this.insertImage.bind(_this);
|
1505
|
+
_this.handleFileInput = _this.handleFileInput.bind(_this);
|
1506
|
+
_this.widgets = _this.widgets.bind(_this);
|
1507
|
+
_this.clickHandler = _this.clickHandler.bind(_this);
|
1508
|
+
_this.relocate = _this.relocate.bind(_this);
|
1509
|
+
_this.state = {
|
1510
|
+
position: { top: 0, left: 0 },
|
1511
|
+
show: false,
|
1512
|
+
scaled: false
|
1513
|
+
};
|
1514
|
+
return _this;
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
(0, _createClass3['default'])(DanteInlineTooltip, [{
|
1518
|
+
key: 'display',
|
1519
|
+
value: function display(b) {
|
1520
|
+
if (b) {
|
1521
|
+
return this.show();
|
1522
|
+
} else {
|
1523
|
+
return this.hide();
|
1524
|
+
}
|
1525
|
+
}
|
1526
|
+
}, {
|
1527
|
+
key: 'show',
|
1528
|
+
value: function show() {
|
1529
|
+
return this.setState({
|
1530
|
+
show: true });
|
1531
|
+
}
|
1532
|
+
}, {
|
1533
|
+
key: 'hide',
|
1534
|
+
value: function hide() {
|
1535
|
+
return this.setState({
|
1536
|
+
show: false });
|
1537
|
+
}
|
1538
|
+
}, {
|
1539
|
+
key: 'setPosition',
|
1540
|
+
value: function setPosition(coords) {
|
1541
|
+
return this.setState({
|
1542
|
+
position: coords });
|
1543
|
+
}
|
1544
|
+
}, {
|
1545
|
+
key: '_toggleScaled',
|
1546
|
+
value: function _toggleScaled(ev) {
|
1547
|
+
if (this.state.scaled) {
|
1548
|
+
return this.collapse();
|
1549
|
+
} else {
|
1550
|
+
return this.scale();
|
1551
|
+
}
|
1552
|
+
}
|
1553
|
+
}, {
|
1554
|
+
key: 'scale',
|
1555
|
+
value: function scale() {
|
1556
|
+
return this.setState({
|
1557
|
+
scaled: true });
|
1558
|
+
}
|
1559
|
+
}, {
|
1560
|
+
key: 'collapse',
|
1561
|
+
value: function collapse() {
|
1562
|
+
return this.setState({
|
1563
|
+
scaled: false });
|
1564
|
+
}
|
1565
|
+
}, {
|
1566
|
+
key: 'componentWillReceiveProps',
|
1567
|
+
value: function componentWillReceiveProps(newProps) {
|
1568
|
+
return this.collapse();
|
1569
|
+
}
|
1570
|
+
}, {
|
1571
|
+
key: 'activeClass',
|
1572
|
+
value: function activeClass() {
|
1573
|
+
//if @props.show then "is-active" else ""
|
1574
|
+
if (this.isActive()) {
|
1575
|
+
return "is-active";
|
1576
|
+
} else {
|
1577
|
+
return "";
|
1578
|
+
}
|
1579
|
+
}
|
1580
|
+
}, {
|
1581
|
+
key: 'isActive',
|
1582
|
+
value: function isActive() {
|
1583
|
+
return this.state.show;
|
1584
|
+
}
|
1585
|
+
}, {
|
1586
|
+
key: 'scaledClass',
|
1587
|
+
value: function scaledClass() {
|
1588
|
+
if (this.state.scaled) {
|
1589
|
+
return "is-scaled";
|
1590
|
+
} else {
|
1591
|
+
return "";
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
}, {
|
1595
|
+
key: 'scaledWidth',
|
1596
|
+
value: function scaledWidth() {
|
1597
|
+
if (this.state.scaled) {
|
1598
|
+
return "124";
|
1599
|
+
} else {
|
1600
|
+
return "0";
|
1601
|
+
}
|
1602
|
+
}
|
1603
|
+
}, {
|
1604
|
+
key: 'clickOnFileUpload',
|
1605
|
+
value: function clickOnFileUpload() {
|
1606
|
+
this.refs.fileInput.click();
|
1607
|
+
this.collapse();
|
1608
|
+
return this.hide();
|
1609
|
+
}
|
1610
|
+
}, {
|
1611
|
+
key: 'handlePlaceholder',
|
1612
|
+
value: function handlePlaceholder(input) {
|
1613
|
+
var opts = {
|
1614
|
+
type: input.widget_options.insert_block,
|
1615
|
+
placeholder: input.options.placeholder,
|
1616
|
+
endpoint: input.options.endpoint
|
1617
|
+
};
|
1618
|
+
|
1619
|
+
return this.props.onChange((0, _index.resetBlockWithType)(this.props.editorState, 'placeholder', opts));
|
1620
|
+
}
|
1621
|
+
}, {
|
1622
|
+
key: 'insertImage',
|
1623
|
+
value: function insertImage(file) {
|
1624
|
+
var opts = {
|
1625
|
+
url: URL.createObjectURL(file),
|
1626
|
+
file: file
|
1627
|
+
};
|
1628
|
+
|
1629
|
+
return this.props.onChange((0, _index.addNewBlock)(this.props.editorState, 'image', opts));
|
1630
|
+
}
|
1631
|
+
}, {
|
1632
|
+
key: 'handleFileInput',
|
1633
|
+
value: function handleFileInput(e) {
|
1634
|
+
var fileList = e.target.files;
|
1635
|
+
// TODO: support multiple file uploads
|
1636
|
+
/*
|
1637
|
+
Object.keys(fileList).forEach (o)=>
|
1638
|
+
@.insertImage(fileList[0])
|
1639
|
+
*/
|
1640
|
+
return this.insertImage(fileList[0]);
|
1641
|
+
}
|
1642
|
+
}, {
|
1643
|
+
key: 'widgets',
|
1644
|
+
value: function widgets() {
|
1645
|
+
return this.props.editor.widgets;
|
1646
|
+
}
|
1647
|
+
}, {
|
1648
|
+
key: 'clickHandler',
|
1649
|
+
value: function clickHandler(e, type) {
|
1650
|
+
var request_block = this.widgets().find(function (o) {
|
1651
|
+
return o.icon === type;
|
1652
|
+
});
|
1653
|
+
|
1654
|
+
switch (request_block.widget_options.insertion) {
|
1655
|
+
case "upload":
|
1656
|
+
return this.clickOnFileUpload(e, request_block);
|
1657
|
+
case "placeholder":
|
1658
|
+
return this.handlePlaceholder(request_block);
|
1659
|
+
default:
|
1660
|
+
return console.log('WRONG TYPE FOR ' + request_block.widget_options.insertion);
|
1661
|
+
}
|
1662
|
+
}
|
1663
|
+
}, {
|
1664
|
+
key: 'getItems',
|
1665
|
+
value: function getItems() {
|
1666
|
+
return this.widgets().filter(function (o) {
|
1667
|
+
return o.widget_options.displayOnInlineTooltip;
|
1668
|
+
});
|
1669
|
+
}
|
1670
|
+
}, {
|
1671
|
+
key: 'isDescendant',
|
1672
|
+
value: function isDescendant(parent, child) {
|
1673
|
+
var node = child.parentNode;
|
1674
|
+
while (node !== null) {
|
1675
|
+
if (node === parent) {
|
1676
|
+
return true;
|
1677
|
+
}
|
1678
|
+
node = node.parentNode;
|
1679
|
+
}
|
1680
|
+
return false;
|
1681
|
+
}
|
1682
|
+
}, {
|
1683
|
+
key: 'relocate',
|
1684
|
+
value: function relocate() {
|
1685
|
+
var editorState = this.props.editorState;
|
1686
|
+
|
1687
|
+
|
1688
|
+
if (editorState.getSelection().isCollapsed()) {
|
1689
|
+
|
1690
|
+
var currentBlock = (0, _index.getCurrentBlock)(editorState);
|
1691
|
+
var blockType = currentBlock.getType();
|
1692
|
+
|
1693
|
+
var contentState = editorState.getCurrentContent();
|
1694
|
+
var selectionState = editorState.getSelection();
|
1695
|
+
|
1696
|
+
var block = contentState.getBlockForKey(selectionState.anchorKey);
|
1697
|
+
|
1698
|
+
var nativeSelection = (0, _selection.getSelection)(window);
|
1699
|
+
if (!nativeSelection.rangeCount) {
|
1700
|
+
return;
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
var node = (0, _index.getNode)();
|
1704
|
+
|
1705
|
+
var selectionBoundary = (0, _selection.getSelectionRect)(nativeSelection);
|
1706
|
+
var coords = selectionBoundary; //utils.getSelectionDimensions(node)
|
1707
|
+
|
1708
|
+
var parent = _reactDom2['default'].findDOMNode(this.props.editor);
|
1709
|
+
var parentBoundary = parent.getBoundingClientRect();
|
1710
|
+
|
1711
|
+
// hide if selected node is not in editor
|
1712
|
+
// debugger
|
1713
|
+
//console.log @isDescendant(parent, nativeSelection.anchorNode)
|
1714
|
+
|
1715
|
+
if (!this.isDescendant(parent, nativeSelection.anchorNode)) {
|
1716
|
+
this.hide();
|
1717
|
+
return;
|
1718
|
+
}
|
1719
|
+
|
1720
|
+
// checkeamos si esta vacio
|
1721
|
+
this.display(block.getText().length === 0 && blockType === "unstyled");
|
1722
|
+
return this.setPosition({
|
1723
|
+
top: coords.top + window.scrollY,
|
1724
|
+
left: coords.left + window.scrollX - 60
|
1725
|
+
});
|
1726
|
+
|
1727
|
+
/*
|
1728
|
+
@refs.image_popover.display(blockType is "image")
|
1729
|
+
if blockType is "image"
|
1730
|
+
selectionBoundary = node.anchorNode.parentNode.parentNode.parentNode.getBoundingClientRect()
|
1731
|
+
*el = document.querySelector("#dante_image_popover")
|
1732
|
+
el = @refs.image_popover.refs.image_popover
|
1733
|
+
padd = el.offsetWidth / 2
|
1734
|
+
@refs.image_popover.setPosition
|
1735
|
+
top: selectionBoundary.top - parentBoundary.top + 60
|
1736
|
+
left: selectionBoundary.left + (selectionBoundary.width / 2) - padd
|
1737
|
+
*@setState
|
1738
|
+
* image_popover_position:
|
1739
|
+
* top: selectionBoundary.top - parentBoundary.top + 60
|
1740
|
+
* left: selectionBoundary.left + (selectionBoundary.width / 2) - padd
|
1741
|
+
*
|
1742
|
+
*/
|
1743
|
+
} else {
|
1744
|
+
return this.hide();
|
1745
|
+
}
|
1746
|
+
}
|
1747
|
+
}, {
|
1748
|
+
key: 'render',
|
1749
|
+
value: function render() {
|
1750
|
+
var _this2 = this;
|
1751
|
+
|
1752
|
+
return _react2['default'].createElement(
|
1753
|
+
'div',
|
1754
|
+
{
|
1755
|
+
className: 'inlineTooltip ' + this.activeClass() + ' ' + this.scaledClass(),
|
1756
|
+
style: this.state.position
|
1757
|
+
},
|
1758
|
+
_react2['default'].createElement(
|
1759
|
+
'button',
|
1760
|
+
{
|
1761
|
+
className: 'inlineTooltip-button control',
|
1762
|
+
title: 'Close Menu',
|
1763
|
+
'data-action': 'inline-menu',
|
1764
|
+
onClick: this._toggleScaled
|
1765
|
+
},
|
1766
|
+
_react2['default'].createElement('span', { className: 'tooltip-icon dante-icon-plus' })
|
1767
|
+
),
|
1768
|
+
_react2['default'].createElement(
|
1769
|
+
'div',
|
1770
|
+
{
|
1771
|
+
className: 'inlineTooltip-menu',
|
1772
|
+
style: { width: this.scaledWidth() + 'px' }
|
1773
|
+
},
|
1774
|
+
this.getItems().map(function (item, i) {
|
1775
|
+
return _react2['default'].createElement(InlineTooltipItem, {
|
1776
|
+
item: item,
|
1777
|
+
key: i,
|
1778
|
+
clickHandler: _this2.clickHandler
|
1779
|
+
});
|
1780
|
+
}),
|
1781
|
+
_react2['default'].createElement('input', {
|
1782
|
+
type: 'file',
|
1783
|
+
style: { display: 'none' },
|
1784
|
+
ref: 'fileInput',
|
1785
|
+
multiple: 'multiple',
|
1786
|
+
onChange: this.handleFileInput
|
1787
|
+
})
|
1788
|
+
)
|
1789
|
+
);
|
1790
|
+
}
|
1791
|
+
}]);
|
1792
|
+
return DanteInlineTooltip;
|
1793
|
+
}(_react2['default'].Component);
|
1794
|
+
|
1795
|
+
var InlineTooltipItem = function (_React$Component2) {
|
1796
|
+
(0, _inherits3['default'])(InlineTooltipItem, _React$Component2);
|
1797
|
+
|
1798
|
+
function InlineTooltipItem() {
|
1799
|
+
var _ref;
|
1800
|
+
|
1801
|
+
(0, _classCallCheck3['default'])(this, InlineTooltipItem);
|
1802
|
+
|
1803
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1804
|
+
args[_key] = arguments[_key];
|
1805
|
+
}
|
1806
|
+
|
1807
|
+
var _this3 = (0, _possibleConstructorReturn3['default'])(this, (_ref = InlineTooltipItem.__proto__ || (0, _getPrototypeOf2['default'])(InlineTooltipItem)).call.apply(_ref, [this].concat(args)));
|
1808
|
+
|
1809
|
+
_this3.clickHandler = _this3.clickHandler.bind(_this3);
|
1810
|
+
return _this3;
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
(0, _createClass3['default'])(InlineTooltipItem, [{
|
1814
|
+
key: 'clickHandler',
|
1815
|
+
value: function clickHandler(e) {
|
1816
|
+
e.preventDefault();
|
1817
|
+
return this.props.clickHandler(e, this.props.item.icon);
|
1818
|
+
}
|
1819
|
+
}, {
|
1820
|
+
key: 'render',
|
1821
|
+
value: function render() {
|
1822
|
+
return _react2['default'].createElement(
|
1823
|
+
'button',
|
1824
|
+
{
|
1825
|
+
className: 'inlineTooltip-button scale',
|
1826
|
+
title: this.props.title,
|
1827
|
+
onMouseDown: this.clickHandler
|
1828
|
+
},
|
1829
|
+
_react2['default'].createElement('span', { className: 'tooltip-icon dante-icon-' + this.props.item.icon })
|
1830
|
+
);
|
1831
|
+
}
|
1832
|
+
}]);
|
1833
|
+
return InlineTooltipItem;
|
1834
|
+
}(_react2['default'].Component);
|
1835
|
+
|
1836
|
+
exports['default'] = DanteInlineTooltip;
|
1837
|
+
|
1838
|
+
/***/ },
|
1839
|
+
|
1840
|
+
/***/ 463:
|
1841
|
+
/***/ function(module, exports, __webpack_require__) {
|
1842
|
+
|
1843
|
+
'use strict';
|
1844
|
+
|
1845
|
+
Object.defineProperty(exports, "__esModule", {
|
1846
|
+
value: true
|
1847
|
+
});
|
1848
|
+
|
1849
|
+
var _getPrototypeOf = __webpack_require__(208);
|
1850
|
+
|
1851
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
1852
|
+
|
1853
|
+
var _classCallCheck2 = __webpack_require__(23);
|
1854
|
+
|
1855
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
1856
|
+
|
1857
|
+
var _createClass2 = __webpack_require__(24);
|
1858
|
+
|
1859
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
1860
|
+
|
1861
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
1862
|
+
|
1863
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
1864
|
+
|
1865
|
+
var _inherits2 = __webpack_require__(266);
|
1866
|
+
|
1867
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
1868
|
+
|
1869
|
+
var _react = __webpack_require__(43);
|
1870
|
+
|
1871
|
+
var _react2 = _interopRequireDefault(_react);
|
1872
|
+
|
1873
|
+
var _reactDom = __webpack_require__(72);
|
1874
|
+
|
1875
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
1876
|
+
|
1877
|
+
var _draftJs = __webpack_require__(274);
|
1878
|
+
|
1879
|
+
var _selection = __webpack_require__(460);
|
1880
|
+
|
1881
|
+
var _index = __webpack_require__(426);
|
1882
|
+
|
1883
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
1884
|
+
|
1885
|
+
var DanteTooltip = function (_React$Component) {
|
1886
|
+
(0, _inherits3['default'])(DanteTooltip, _React$Component);
|
1887
|
+
|
1888
|
+
function DanteTooltip(props) {
|
1889
|
+
(0, _classCallCheck3['default'])(this, DanteTooltip);
|
1890
|
+
|
1891
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (DanteTooltip.__proto__ || (0, _getPrototypeOf2['default'])(DanteTooltip)).call(this, props));
|
1892
|
+
|
1893
|
+
_this._clickInlineHandler = _this._clickInlineHandler.bind(_this);
|
1894
|
+
_this.display = _this.display.bind(_this);
|
1895
|
+
_this.show = _this.show.bind(_this);
|
1896
|
+
_this.hide = _this.hide.bind(_this);
|
1897
|
+
_this.relocate = _this.relocate.bind(_this);
|
1898
|
+
_this._clickBlockHandler = _this._clickBlockHandler.bind(_this);
|
1899
|
+
_this.displayLinkMode = _this.displayLinkMode.bind(_this);
|
1900
|
+
_this.displayActiveMenu = _this.displayActiveMenu.bind(_this);
|
1901
|
+
_this._enableLinkMode = _this._enableLinkMode.bind(_this);
|
1902
|
+
_this._disableLinkMode = _this._disableLinkMode.bind(_this);
|
1903
|
+
_this.handleInputEnter = _this.handleInputEnter.bind(_this);
|
1904
|
+
_this.confirmLink = _this.confirmLink.bind(_this);
|
1905
|
+
_this.inlineItems = _this.inlineItems.bind(_this);
|
1906
|
+
_this.blockItems = _this.blockItems.bind(_this);
|
1907
|
+
_this.getDefaultValue = _this.getDefaultValue.bind(_this);
|
1908
|
+
_this.getVisibleSelectionRect = _draftJs.getVisibleSelectionRect;
|
1909
|
+
_this.state = {
|
1910
|
+
link_mode: false,
|
1911
|
+
show: false,
|
1912
|
+
position: {}
|
1913
|
+
};
|
1914
|
+
return _this;
|
1915
|
+
}
|
1916
|
+
|
1917
|
+
(0, _createClass3['default'])(DanteTooltip, [{
|
1918
|
+
key: '_clickInlineHandler',
|
1919
|
+
value: function _clickInlineHandler(ev, style) {
|
1920
|
+
var _this2 = this;
|
1921
|
+
|
1922
|
+
ev.preventDefault();
|
1923
|
+
|
1924
|
+
this.props.onChange(_draftJs.RichUtils.toggleInlineStyle(this.props.editorState, style));
|
1925
|
+
|
1926
|
+
return setTimeout(function () {
|
1927
|
+
return _this2.relocate();
|
1928
|
+
}, 0);
|
1929
|
+
}
|
1930
|
+
}, {
|
1931
|
+
key: 'display',
|
1932
|
+
value: function display(b) {
|
1933
|
+
if (b) {
|
1934
|
+
return this.show();
|
1935
|
+
} else {
|
1936
|
+
return this.hide();
|
1937
|
+
}
|
1938
|
+
}
|
1939
|
+
}, {
|
1940
|
+
key: 'show',
|
1941
|
+
value: function show() {
|
1942
|
+
return this.setState({
|
1943
|
+
show: true });
|
1944
|
+
}
|
1945
|
+
}, {
|
1946
|
+
key: 'hide',
|
1947
|
+
value: function hide() {
|
1948
|
+
return this.setState({
|
1949
|
+
link_mode: false,
|
1950
|
+
show: false
|
1951
|
+
});
|
1952
|
+
}
|
1953
|
+
}, {
|
1954
|
+
key: 'setPosition',
|
1955
|
+
value: function setPosition(coords) {
|
1956
|
+
return this.setState({
|
1957
|
+
position: coords });
|
1958
|
+
}
|
1959
|
+
}, {
|
1960
|
+
key: 'isDescendant',
|
1961
|
+
value: function isDescendant(parent, child) {
|
1962
|
+
var node = child.parentNode;
|
1963
|
+
while (node !== null) {
|
1964
|
+
if (node === parent) {
|
1965
|
+
return true;
|
1966
|
+
}
|
1967
|
+
node = node.parentNode;
|
1968
|
+
}
|
1969
|
+
return false;
|
1970
|
+
}
|
1971
|
+
}, {
|
1972
|
+
key: 'relocate',
|
1973
|
+
value: function relocate() {
|
1974
|
+
|
1975
|
+
var currentBlock = (0, _index.getCurrentBlock)(this.props.editorState);
|
1976
|
+
var blockType = currentBlock.getType();
|
1977
|
+
// display tooltip only for unstyled
|
1978
|
+
|
1979
|
+
if (this.props.configTooltip.selectionElements.indexOf(blockType) < 0) {
|
1980
|
+
this.hide();
|
1981
|
+
return;
|
1982
|
+
}
|
1983
|
+
|
1984
|
+
if (this.state.link_mode) {
|
1985
|
+
return;
|
1986
|
+
}
|
1987
|
+
if (!this.state.show) {
|
1988
|
+
return;
|
1989
|
+
}
|
1990
|
+
|
1991
|
+
var el = this.refs.dante_menu;
|
1992
|
+
var padd = el.offsetWidth / 2;
|
1993
|
+
|
1994
|
+
var nativeSelection = (0, _selection.getSelection)(window);
|
1995
|
+
if (!nativeSelection.rangeCount) {
|
1996
|
+
return;
|
1997
|
+
}
|
1998
|
+
|
1999
|
+
var selectionBoundary = (0, _selection.getSelectionRect)(nativeSelection);
|
2000
|
+
|
2001
|
+
var parent = _reactDom2['default'].findDOMNode(this.props.editor);
|
2002
|
+
var parentBoundary = parent.getBoundingClientRect();
|
2003
|
+
|
2004
|
+
// hide if selected node is not in editor
|
2005
|
+
if (!this.isDescendant(parent, nativeSelection.anchorNode)) {
|
2006
|
+
this.hide();
|
2007
|
+
return;
|
2008
|
+
}
|
2009
|
+
|
2010
|
+
var top = selectionBoundary.top - parentBoundary.top - -90 - 5;
|
2011
|
+
var left = selectionBoundary.left + selectionBoundary.width / 2 - padd;
|
2012
|
+
|
2013
|
+
if (!top || !left) {
|
2014
|
+
return;
|
2015
|
+
}
|
2016
|
+
|
2017
|
+
// console.log "SET SHOW FOR TOOLTIP INSERT MENU"
|
2018
|
+
return this.setState({
|
2019
|
+
show: true,
|
2020
|
+
position: {
|
2021
|
+
left: left,
|
2022
|
+
top: top
|
2023
|
+
}
|
2024
|
+
});
|
2025
|
+
}
|
2026
|
+
}, {
|
2027
|
+
key: '_clickBlockHandler',
|
2028
|
+
value: function _clickBlockHandler(ev, style) {
|
2029
|
+
var _this3 = this;
|
2030
|
+
|
2031
|
+
ev.preventDefault();
|
2032
|
+
|
2033
|
+
this.props.onChange(_draftJs.RichUtils.toggleBlockType(this.props.editorState, style));
|
2034
|
+
|
2035
|
+
return setTimeout(function () {
|
2036
|
+
return _this3.relocate();
|
2037
|
+
}, 0);
|
2038
|
+
}
|
2039
|
+
}, {
|
2040
|
+
key: 'displayLinkMode',
|
2041
|
+
value: function displayLinkMode() {
|
2042
|
+
if (this.state.link_mode) {
|
2043
|
+
return "dante-menu--linkmode";
|
2044
|
+
} else {
|
2045
|
+
return "";
|
2046
|
+
}
|
2047
|
+
}
|
2048
|
+
}, {
|
2049
|
+
key: 'displayActiveMenu',
|
2050
|
+
value: function displayActiveMenu() {
|
2051
|
+
if (this.state.show) {
|
2052
|
+
return "dante-menu--active";
|
2053
|
+
} else {
|
2054
|
+
return "";
|
2055
|
+
}
|
2056
|
+
}
|
2057
|
+
}, {
|
2058
|
+
key: '_enableLinkMode',
|
2059
|
+
value: function _enableLinkMode(ev) {
|
2060
|
+
ev.preventDefault();
|
2061
|
+
return this.setState({
|
2062
|
+
link_mode: true });
|
2063
|
+
}
|
2064
|
+
}, {
|
2065
|
+
key: '_disableLinkMode',
|
2066
|
+
value: function _disableLinkMode(ev) {
|
2067
|
+
ev.preventDefault();
|
2068
|
+
return this.setState({
|
2069
|
+
link_mode: false,
|
2070
|
+
url: ""
|
2071
|
+
});
|
2072
|
+
}
|
2073
|
+
}, {
|
2074
|
+
key: 'hideMenu',
|
2075
|
+
value: function hideMenu() {
|
2076
|
+
return this.hide();
|
2077
|
+
}
|
2078
|
+
}, {
|
2079
|
+
key: 'handleInputEnter',
|
2080
|
+
value: function handleInputEnter(e) {
|
2081
|
+
if (e.which === 13) {
|
2082
|
+
return this.confirmLink(e);
|
2083
|
+
}
|
2084
|
+
}
|
2085
|
+
}, {
|
2086
|
+
key: 'confirmLink',
|
2087
|
+
value: function confirmLink(e) {
|
2088
|
+
e.preventDefault();
|
2089
|
+
var editorState = this.props.editorState;
|
2090
|
+
|
2091
|
+
var urlValue = e.currentTarget.value;
|
2092
|
+
var contentState = editorState.getCurrentContent();
|
2093
|
+
var selection = editorState.getSelection();
|
2094
|
+
|
2095
|
+
var opts = {
|
2096
|
+
url: urlValue,
|
2097
|
+
showPopLinkOver: this.props.showPopLinkOver,
|
2098
|
+
hidePopLinkOver: this.props.hidePopLinkOver
|
2099
|
+
};
|
2100
|
+
|
2101
|
+
var entityKey = _draftJs.Entity.create('LINK', 'MUTABLE', opts);
|
2102
|
+
|
2103
|
+
if (selection.isCollapsed()) {
|
2104
|
+
console.log("COLLAPSED SKIPPING LINK");
|
2105
|
+
return;
|
2106
|
+
}
|
2107
|
+
|
2108
|
+
this.props.onChange(_draftJs.RichUtils.toggleLink(editorState, selection, entityKey));
|
2109
|
+
|
2110
|
+
return this._disableLinkMode(e);
|
2111
|
+
}
|
2112
|
+
}, {
|
2113
|
+
key: 'getPosition',
|
2114
|
+
value: function getPosition() {
|
2115
|
+
var pos = this.state.position;
|
2116
|
+
return pos;
|
2117
|
+
}
|
2118
|
+
}, {
|
2119
|
+
key: 'inlineItems',
|
2120
|
+
value: function inlineItems() {
|
2121
|
+
return this.props.widget_options.block_types.filter(function (o) {
|
2122
|
+
return o.type === "inline";
|
2123
|
+
});
|
2124
|
+
}
|
2125
|
+
}, {
|
2126
|
+
key: 'blockItems',
|
2127
|
+
value: function blockItems() {
|
2128
|
+
return this.props.widget_options.block_types.filter(function (o) {
|
2129
|
+
return o.type === "block";
|
2130
|
+
});
|
2131
|
+
}
|
2132
|
+
}, {
|
2133
|
+
key: 'getDefaultValue',
|
2134
|
+
value: function getDefaultValue() {
|
2135
|
+
var _this4 = this;
|
2136
|
+
|
2137
|
+
if (this.refs.dante_menu_input) {
|
2138
|
+
this.refs.dante_menu_input.value = "";
|
2139
|
+
}
|
2140
|
+
|
2141
|
+
var currentBlock = (0, _index.getCurrentBlock)(this.props.editorState);
|
2142
|
+
var blockType = currentBlock.getType();
|
2143
|
+
var selection = this.props.editor.state.editorState.getSelection();
|
2144
|
+
var selectedEntity = null;
|
2145
|
+
var defaultUrl = null;
|
2146
|
+
return currentBlock.findEntityRanges(function (character) {
|
2147
|
+
var entityKey = character.getEntity();
|
2148
|
+
selectedEntity = entityKey;
|
2149
|
+
return entityKey !== null && _draftJs.Entity.get(entityKey).getType() === 'LINK';
|
2150
|
+
}, function (start, end) {
|
2151
|
+
var selStart = selection.getAnchorOffset();
|
2152
|
+
var selEnd = selection.getFocusOffset();
|
2153
|
+
if (selection.getIsBackward()) {
|
2154
|
+
selStart = selection.getFocusOffset();
|
2155
|
+
selEnd = selection.getAnchorOffset();
|
2156
|
+
}
|
2157
|
+
|
2158
|
+
if (start === selStart && end === selEnd) {
|
2159
|
+
defaultUrl = _draftJs.Entity.get(selectedEntity).getData().url;
|
2160
|
+
return _this4.refs.dante_menu_input.value = defaultUrl;
|
2161
|
+
}
|
2162
|
+
});
|
2163
|
+
}
|
2164
|
+
}, {
|
2165
|
+
key: 'render',
|
2166
|
+
value: function render() {
|
2167
|
+
var _this5 = this;
|
2168
|
+
|
2169
|
+
return _react2['default'].createElement(
|
2170
|
+
'div',
|
2171
|
+
{
|
2172
|
+
id: 'dante-menu',
|
2173
|
+
ref: 'dante_menu',
|
2174
|
+
className: 'dante-menu ' + this.displayActiveMenu() + ' ' + this.displayLinkMode(),
|
2175
|
+
style: this.getPosition()
|
2176
|
+
},
|
2177
|
+
_react2['default'].createElement(
|
2178
|
+
'div',
|
2179
|
+
{ className: 'dante-menu-linkinput' },
|
2180
|
+
_react2['default'].createElement('input', {
|
2181
|
+
className: 'dante-menu-input',
|
2182
|
+
ref: 'dante_menu_input',
|
2183
|
+
placeholder: 'Paste or type a link',
|
2184
|
+
onKeyPress: this.handleInputEnter,
|
2185
|
+
defaultValue: this.getDefaultValue()
|
2186
|
+
}),
|
2187
|
+
_react2['default'].createElement('div', { className: 'dante-menu-button', onMouseDown: this._disableLinkMode })
|
2188
|
+
),
|
2189
|
+
_react2['default'].createElement(
|
2190
|
+
'ul',
|
2191
|
+
{ className: 'dante-menu-buttons' },
|
2192
|
+
this.blockItems().map(function (item, i) {
|
2193
|
+
return _react2['default'].createElement(DanteTooltipItem, {
|
2194
|
+
key: i,
|
2195
|
+
item: item,
|
2196
|
+
handleClick: _this5._clickBlockHandler,
|
2197
|
+
editorState: _this5.props.editorState,
|
2198
|
+
type: 'block',
|
2199
|
+
currentStyle: _this5.props.editorState.getCurrentInlineStyle
|
2200
|
+
});
|
2201
|
+
}),
|
2202
|
+
_react2['default'].createElement(DanteTooltipLink, {
|
2203
|
+
editorState: this.props.editorState,
|
2204
|
+
enableLinkMode: this._enableLinkMode
|
2205
|
+
}),
|
2206
|
+
this.inlineItems().map(function (item, i) {
|
2207
|
+
return _react2['default'].createElement(DanteTooltipItem, {
|
2208
|
+
key: i,
|
2209
|
+
item: item,
|
2210
|
+
type: 'inline',
|
2211
|
+
editorState: _this5.props.editorState,
|
2212
|
+
handleClick: _this5._clickInlineHandler
|
2213
|
+
});
|
2214
|
+
})
|
2215
|
+
)
|
2216
|
+
);
|
2217
|
+
}
|
2218
|
+
}]);
|
2219
|
+
return DanteTooltip;
|
2220
|
+
}(_react2['default'].Component);
|
2221
|
+
|
2222
|
+
var DanteTooltipItem = function (_React$Component2) {
|
2223
|
+
(0, _inherits3['default'])(DanteTooltipItem, _React$Component2);
|
2224
|
+
|
2225
|
+
function DanteTooltipItem() {
|
2226
|
+
var _ref;
|
2227
|
+
|
2228
|
+
(0, _classCallCheck3['default'])(this, DanteTooltipItem);
|
2229
|
+
|
2230
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
2231
|
+
args[_key] = arguments[_key];
|
2232
|
+
}
|
2233
|
+
|
2234
|
+
var _this6 = (0, _possibleConstructorReturn3['default'])(this, (_ref = DanteTooltipItem.__proto__ || (0, _getPrototypeOf2['default'])(DanteTooltipItem)).call.apply(_ref, [this].concat(args)));
|
2235
|
+
|
2236
|
+
_this6.handleClick = _this6.handleClick.bind(_this6);
|
2237
|
+
_this6.activeClass = _this6.activeClass.bind(_this6);
|
2238
|
+
_this6.isActive = _this6.isActive.bind(_this6);
|
2239
|
+
_this6.activeClassInline = _this6.activeClassInline.bind(_this6);
|
2240
|
+
_this6.activeClassBlock = _this6.activeClassBlock.bind(_this6);
|
2241
|
+
_this6.render = _this6.render.bind(_this6);
|
2242
|
+
return _this6;
|
2243
|
+
}
|
2244
|
+
|
2245
|
+
(0, _createClass3['default'])(DanteTooltipItem, [{
|
2246
|
+
key: 'handleClick',
|
2247
|
+
value: function handleClick(ev) {
|
2248
|
+
return this.props.handleClick(ev, this.props.item.style);
|
2249
|
+
}
|
2250
|
+
}, {
|
2251
|
+
key: 'activeClass',
|
2252
|
+
value: function activeClass() {
|
2253
|
+
if (this.isActive()) {
|
2254
|
+
return "active";
|
2255
|
+
} else {
|
2256
|
+
return "";
|
2257
|
+
}
|
2258
|
+
}
|
2259
|
+
}, {
|
2260
|
+
key: 'isActive',
|
2261
|
+
value: function isActive() {
|
2262
|
+
if (this.props.type === "block") {
|
2263
|
+
return this.activeClassBlock();
|
2264
|
+
} else {
|
2265
|
+
return this.activeClassInline();
|
2266
|
+
}
|
2267
|
+
}
|
2268
|
+
}, {
|
2269
|
+
key: 'activeClassInline',
|
2270
|
+
value: function activeClassInline() {
|
2271
|
+
if (!this.props.editorState) {
|
2272
|
+
return;
|
2273
|
+
}
|
2274
|
+
//console.log @props.item
|
2275
|
+
return this.props.editorState.getCurrentInlineStyle().has(this.props.item.style);
|
2276
|
+
}
|
2277
|
+
}, {
|
2278
|
+
key: 'activeClassBlock',
|
2279
|
+
value: function activeClassBlock() {
|
2280
|
+
//console.log "EDITOR STATE", @props.editorState
|
2281
|
+
if (!this.props.editorState) {
|
2282
|
+
return;
|
2283
|
+
}
|
2284
|
+
var selection = this.props.editorState.getSelection();
|
2285
|
+
var blockType = this.props.editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
|
2286
|
+
return this.props.item.style === blockType;
|
2287
|
+
}
|
2288
|
+
}, {
|
2289
|
+
key: 'render',
|
2290
|
+
value: function render() {
|
2291
|
+
return _react2['default'].createElement(
|
2292
|
+
'li',
|
2293
|
+
{ className: 'dante-menu-button ' + this.activeClass(), onMouseDown: this.handleClick },
|
2294
|
+
_react2['default'].createElement('i', { className: 'dante-icon dante-icon-' + this.props.item.label, 'data-action': 'bold' })
|
2295
|
+
);
|
2296
|
+
}
|
2297
|
+
}]);
|
2298
|
+
return DanteTooltipItem;
|
2299
|
+
}(_react2['default'].Component);
|
2300
|
+
|
2301
|
+
var DanteTooltipLink = function (_React$Component3) {
|
2302
|
+
(0, _inherits3['default'])(DanteTooltipLink, _React$Component3);
|
2303
|
+
|
2304
|
+
function DanteTooltipLink() {
|
2305
|
+
var _ref2;
|
2306
|
+
|
2307
|
+
(0, _classCallCheck3['default'])(this, DanteTooltipLink);
|
2308
|
+
|
2309
|
+
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
2310
|
+
args[_key2] = arguments[_key2];
|
2311
|
+
}
|
2312
|
+
|
2313
|
+
var _this7 = (0, _possibleConstructorReturn3['default'])(this, (_ref2 = DanteTooltipLink.__proto__ || (0, _getPrototypeOf2['default'])(DanteTooltipLink)).call.apply(_ref2, [this].concat(args)));
|
2314
|
+
|
2315
|
+
_this7.promptForLink = _this7.promptForLink.bind(_this7);
|
2316
|
+
return _this7;
|
2317
|
+
}
|
2318
|
+
|
2319
|
+
(0, _createClass3['default'])(DanteTooltipLink, [{
|
2320
|
+
key: 'promptForLink',
|
2321
|
+
value: function promptForLink(ev) {
|
2322
|
+
var selection = this.props.editorState.getSelection();
|
2323
|
+
if (!selection.isCollapsed()) {
|
2324
|
+
return this.props.enableLinkMode(ev);
|
2325
|
+
}
|
2326
|
+
}
|
2327
|
+
}, {
|
2328
|
+
key: 'render',
|
2329
|
+
value: function render() {
|
2330
|
+
return _react2['default'].createElement(
|
2331
|
+
'li',
|
2332
|
+
{ className: 'dante-menu-button', onMouseDown: this.promptForLink },
|
2333
|
+
_react2['default'].createElement(
|
2334
|
+
'i',
|
2335
|
+
{ className: 'dante-icon icon-createlink', 'data-action': 'createlink' },
|
2336
|
+
'link'
|
2337
|
+
)
|
2338
|
+
);
|
2339
|
+
}
|
2340
|
+
}]);
|
2341
|
+
return DanteTooltipLink;
|
2342
|
+
}(_react2['default'].Component);
|
2343
|
+
|
2344
|
+
exports['default'] = DanteTooltip;
|
2345
|
+
|
2346
|
+
/***/ },
|
2347
|
+
|
2348
|
+
/***/ 464:
|
2349
|
+
/***/ function(module, exports, __webpack_require__) {
|
2350
|
+
|
2351
|
+
'use strict';
|
2352
|
+
|
2353
|
+
Object.defineProperty(exports, "__esModule", {
|
2354
|
+
value: true
|
2355
|
+
});
|
2356
|
+
|
2357
|
+
var _assign = __webpack_require__(465);
|
2358
|
+
|
2359
|
+
var _assign2 = _interopRequireDefault(_assign);
|
2360
|
+
|
2361
|
+
var _getPrototypeOf = __webpack_require__(208);
|
2362
|
+
|
2363
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
2364
|
+
|
2365
|
+
var _classCallCheck2 = __webpack_require__(23);
|
2366
|
+
|
2367
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
2368
|
+
|
2369
|
+
var _createClass2 = __webpack_require__(24);
|
2370
|
+
|
2371
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
2372
|
+
|
2373
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
2374
|
+
|
2375
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
2376
|
+
|
2377
|
+
var _inherits2 = __webpack_require__(266);
|
2378
|
+
|
2379
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
2380
|
+
|
2381
|
+
var _react = __webpack_require__(43);
|
2382
|
+
|
2383
|
+
var _react2 = _interopRequireDefault(_react);
|
2384
|
+
|
2385
|
+
var _reactDom = __webpack_require__(72);
|
2386
|
+
|
2387
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
2388
|
+
|
2389
|
+
var _draftJs = __webpack_require__(274);
|
2390
|
+
|
2391
|
+
var _axios = __webpack_require__(433);
|
2392
|
+
|
2393
|
+
var _axios2 = _interopRequireDefault(_axios);
|
2394
|
+
|
2395
|
+
var _index = __webpack_require__(426);
|
2396
|
+
|
2397
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
2398
|
+
|
2399
|
+
var ImageBlock = function (_React$Component) {
|
2400
|
+
(0, _inherits3['default'])(ImageBlock, _React$Component);
|
2401
|
+
|
2402
|
+
function ImageBlock(props) {
|
2403
|
+
(0, _classCallCheck3['default'])(this, ImageBlock);
|
2404
|
+
|
2405
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (ImageBlock.__proto__ || (0, _getPrototypeOf2['default'])(ImageBlock)).call(this, props));
|
2406
|
+
|
2407
|
+
_this.blockPropsSrc = _this.blockPropsSrc.bind(_this);
|
2408
|
+
_this.defaultUrl = _this.defaultUrl.bind(_this);
|
2409
|
+
_this.defaultAspectRatio = _this.defaultAspectRatio.bind(_this);
|
2410
|
+
_this.updateData = _this.updateData.bind(_this);
|
2411
|
+
_this.replaceImg = _this.replaceImg.bind(_this);
|
2412
|
+
_this.startLoader = _this.startLoader.bind(_this);
|
2413
|
+
_this.stopLoader = _this.stopLoader.bind(_this);
|
2414
|
+
_this.handleUpload = _this.handleUpload.bind(_this);
|
2415
|
+
_this.aspectRatio = _this.aspectRatio.bind(_this);
|
2416
|
+
_this.updateDataSelection = _this.updateDataSelection.bind(_this);
|
2417
|
+
_this.handleGrafFigureSelectImg = _this.handleGrafFigureSelectImg.bind(_this);
|
2418
|
+
_this.getUploadUrl = _this.getUploadUrl.bind(_this);
|
2419
|
+
_this.uploadFile = _this.uploadFile.bind(_this);
|
2420
|
+
_this.uploadCompleted = _this.uploadCompleted.bind(_this);
|
2421
|
+
_this.updateProgressBar = _this.updateProgressBar.bind(_this);
|
2422
|
+
_this.placeHolderEnabled = _this.placeHolderEnabled.bind(_this);
|
2423
|
+
_this.placeholderText = _this.placeholderText.bind(_this);
|
2424
|
+
_this.handleFocus = _this.handleFocus.bind(_this);
|
2425
|
+
_this.render = _this.render.bind(_this);
|
2426
|
+
var existing_data = _this.props.block.getData().toJS();
|
2427
|
+
|
2428
|
+
_this.config = _this.props.blockProps.config;
|
2429
|
+
_this.file = _this.props.blockProps.data.get('file');
|
2430
|
+
_this.state = {
|
2431
|
+
loading: false,
|
2432
|
+
selected: false,
|
2433
|
+
loading_progress: 0,
|
2434
|
+
enabled: false,
|
2435
|
+
caption: _this.defaultPlaceholder(),
|
2436
|
+
direction: existing_data.direction || "center",
|
2437
|
+
width: 0,
|
2438
|
+
height: 0,
|
2439
|
+
file: null,
|
2440
|
+
url: _this.blockPropsSrc() || _this.defaultUrl(existing_data),
|
2441
|
+
aspect_ratio: _this.defaultAspectRatio(existing_data)
|
2442
|
+
};
|
2443
|
+
return _this;
|
2444
|
+
}
|
2445
|
+
|
2446
|
+
(0, _createClass3['default'])(ImageBlock, [{
|
2447
|
+
key: 'blockPropsSrc',
|
2448
|
+
value: function blockPropsSrc() {
|
2449
|
+
// console.log @.props.blockProps.data.src
|
2450
|
+
return this.props.blockProps.data.src;
|
2451
|
+
}
|
2452
|
+
/*
|
2453
|
+
debugger
|
2454
|
+
block = @.props
|
2455
|
+
entity = block.block.getEntityAt(0)
|
2456
|
+
if entity
|
2457
|
+
data = Entity.get(entity).getData().src
|
2458
|
+
else
|
2459
|
+
null
|
2460
|
+
*/
|
2461
|
+
|
2462
|
+
}, {
|
2463
|
+
key: 'defaultUrl',
|
2464
|
+
value: function defaultUrl(data) {
|
2465
|
+
if (data.url) {
|
2466
|
+
return data.url;
|
2467
|
+
}
|
2468
|
+
|
2469
|
+
if (data.url) {
|
2470
|
+
if (data.file) {
|
2471
|
+
return URL.createObjectURL(data.file);
|
2472
|
+
} else {
|
2473
|
+
return data.url;
|
2474
|
+
}
|
2475
|
+
} else {
|
2476
|
+
return this.props.blockProps.data.src;
|
2477
|
+
}
|
2478
|
+
}
|
2479
|
+
}, {
|
2480
|
+
key: 'defaultPlaceholder',
|
2481
|
+
value: function defaultPlaceholder() {
|
2482
|
+
return this.props.blockProps.config.image_caption_placeholder;
|
2483
|
+
}
|
2484
|
+
}, {
|
2485
|
+
key: 'defaultAspectRatio',
|
2486
|
+
value: function defaultAspectRatio(data) {
|
2487
|
+
if (data.aspect_ratio) {
|
2488
|
+
return {
|
2489
|
+
width: data.aspect_ratio['width'],
|
2490
|
+
height: data.aspect_ratio['height'],
|
2491
|
+
ratio: data.aspect_ratio['ratio']
|
2492
|
+
};
|
2493
|
+
} else {
|
2494
|
+
return {
|
2495
|
+
width: 0,
|
2496
|
+
height: 0,
|
2497
|
+
ratio: 100
|
2498
|
+
};
|
2499
|
+
}
|
2500
|
+
}
|
2501
|
+
}, {
|
2502
|
+
key: 'getAspectRatio',
|
2503
|
+
value: function getAspectRatio(w, h) {
|
2504
|
+
var maxWidth = 1000;
|
2505
|
+
var maxHeight = 1000;
|
2506
|
+
var ratio = 0;
|
2507
|
+
var width = w; // Current image width
|
2508
|
+
var height = h; // Current image height
|
2509
|
+
|
2510
|
+
// Check if the current width is larger than the max
|
2511
|
+
if (width > maxWidth) {
|
2512
|
+
ratio = maxWidth / width; // get ratio for scaling image
|
2513
|
+
height = height * ratio; // Reset height to match scaled image
|
2514
|
+
width = width * ratio; // Reset width to match scaled image
|
2515
|
+
|
2516
|
+
// Check if current height is larger than max
|
2517
|
+
} else if (height > maxHeight) {
|
2518
|
+
ratio = maxHeight / height; // get ratio for scaling image
|
2519
|
+
width = width * ratio; // Reset width to match scaled image
|
2520
|
+
height = height * ratio; // Reset height to match scaled image
|
2521
|
+
}
|
2522
|
+
|
2523
|
+
var fill_ratio = height / width * 100;
|
2524
|
+
var result = { width: width, height: height, ratio: fill_ratio };
|
2525
|
+
// console.log result
|
2526
|
+
return result;
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
// will update block state
|
2530
|
+
|
2531
|
+
}, {
|
2532
|
+
key: 'updateData',
|
2533
|
+
value: function updateData() {
|
2534
|
+
var blockProps = this.props.blockProps;
|
2535
|
+
var block = this.props.block;
|
2536
|
+
var getEditorState = this.props.blockProps.getEditorState;
|
2537
|
+
var setEditorState = this.props.blockProps.setEditorState;
|
2538
|
+
|
2539
|
+
var data = block.getData();
|
2540
|
+
var newData = data.merge(this.state).merge({ forceUpload: false });
|
2541
|
+
return setEditorState((0, _index.updateDataOfBlock)(getEditorState(), block, newData));
|
2542
|
+
}
|
2543
|
+
}, {
|
2544
|
+
key: 'replaceImg',
|
2545
|
+
value: function replaceImg() {
|
2546
|
+
var _this2 = this;
|
2547
|
+
|
2548
|
+
this.img = new Image();
|
2549
|
+
this.img.src = this.refs.image_tag.src;
|
2550
|
+
this.setState({
|
2551
|
+
url: this.img.src });
|
2552
|
+
var self = this;
|
2553
|
+
// exit only when not blob and not forceUload
|
2554
|
+
if (!this.img.src.includes("blob:") && !this.props.block.data.get("forceUpload")) {
|
2555
|
+
return;
|
2556
|
+
}
|
2557
|
+
return this.img.onload = function () {
|
2558
|
+
_this2.setState({
|
2559
|
+
width: _this2.img.width,
|
2560
|
+
height: _this2.img.height,
|
2561
|
+
aspect_ratio: self.getAspectRatio(_this2.img.width, _this2.img.height)
|
2562
|
+
});
|
2563
|
+
|
2564
|
+
return _this2.handleUpload();
|
2565
|
+
};
|
2566
|
+
}
|
2567
|
+
}, {
|
2568
|
+
key: 'startLoader',
|
2569
|
+
value: function startLoader() {
|
2570
|
+
return this.setState({
|
2571
|
+
loading: true });
|
2572
|
+
}
|
2573
|
+
}, {
|
2574
|
+
key: 'stopLoader',
|
2575
|
+
value: function stopLoader() {
|
2576
|
+
return this.setState({
|
2577
|
+
loading: false });
|
2578
|
+
}
|
2579
|
+
}, {
|
2580
|
+
key: 'handleUpload',
|
2581
|
+
value: function handleUpload() {
|
2582
|
+
this.startLoader();
|
2583
|
+
this.props.blockProps.addLock();
|
2584
|
+
this.updateData();
|
2585
|
+
return this.uploadFile();
|
2586
|
+
}
|
2587
|
+
}, {
|
2588
|
+
key: 'componentDidMount',
|
2589
|
+
value: function componentDidMount() {
|
2590
|
+
return this.replaceImg();
|
2591
|
+
}
|
2592
|
+
}, {
|
2593
|
+
key: 'aspectRatio',
|
2594
|
+
value: function aspectRatio() {
|
2595
|
+
return {
|
2596
|
+
maxWidth: '' + this.state.aspect_ratio.width,
|
2597
|
+
maxHeight: '' + this.state.aspect_ratio.height,
|
2598
|
+
ratio: '' + this.state.aspect_ratio.height
|
2599
|
+
};
|
2600
|
+
}
|
2601
|
+
}, {
|
2602
|
+
key: 'updateDataSelection',
|
2603
|
+
value: function updateDataSelection() {
|
2604
|
+
var _props$blockProps = this.props.blockProps,
|
2605
|
+
getEditorState = _props$blockProps.getEditorState,
|
2606
|
+
setEditorState = _props$blockProps.setEditorState;
|
2607
|
+
|
2608
|
+
var newselection = getEditorState().getSelection().merge({
|
2609
|
+
anchorKey: this.props.block.getKey(),
|
2610
|
+
focusKey: this.props.block.getKey()
|
2611
|
+
});
|
2612
|
+
|
2613
|
+
return setEditorState(_draftJs.EditorState.forceSelection(getEditorState(), newselection));
|
2614
|
+
}
|
2615
|
+
}, {
|
2616
|
+
key: 'handleGrafFigureSelectImg',
|
2617
|
+
value: function handleGrafFigureSelectImg(e) {
|
2618
|
+
e.preventDefault();
|
2619
|
+
return this.setState({ selected: true }, this.updateDataSelection);
|
2620
|
+
}
|
2621
|
+
|
2622
|
+
//main_editor.onChange(main_editor.state.editorState)
|
2623
|
+
|
2624
|
+
}, {
|
2625
|
+
key: 'coords',
|
2626
|
+
value: function coords() {
|
2627
|
+
return {
|
2628
|
+
maxWidth: this.state.aspect_ratio.width + 'px',
|
2629
|
+
maxHeight: this.state.aspect_ratio.height + 'px'
|
2630
|
+
};
|
2631
|
+
}
|
2632
|
+
}, {
|
2633
|
+
key: 'getBase64Image',
|
2634
|
+
value: function getBase64Image(img) {
|
2635
|
+
var canvas = document.createElement("canvas");
|
2636
|
+
canvas.width = img.width;
|
2637
|
+
canvas.height = img.height;
|
2638
|
+
var ctx = canvas.getContext("2d");
|
2639
|
+
ctx.drawImage(img, 0, 0);
|
2640
|
+
var dataURL = canvas.toDataURL("image/png");
|
2641
|
+
|
2642
|
+
return dataURL;
|
2643
|
+
}
|
2644
|
+
}, {
|
2645
|
+
key: 'formatData',
|
2646
|
+
value: function formatData() {
|
2647
|
+
var formData = new FormData();
|
2648
|
+
if (this.file) {
|
2649
|
+
var formName = this.config.upload_formName || 'file';
|
2650
|
+
|
2651
|
+
formData.append(formName, this.file);
|
2652
|
+
return formData;
|
2653
|
+
} else {
|
2654
|
+
formData.append('url', this.props.blockProps.data.get("url"));
|
2655
|
+
return formData;
|
2656
|
+
}
|
2657
|
+
}
|
2658
|
+
}, {
|
2659
|
+
key: 'getUploadUrl',
|
2660
|
+
value: function getUploadUrl() {
|
2661
|
+
var url = this.config.upload_url;
|
2662
|
+
if (typeof url === "function") {
|
2663
|
+
return url();
|
2664
|
+
} else {
|
2665
|
+
return url;
|
2666
|
+
}
|
2667
|
+
}
|
2668
|
+
}, {
|
2669
|
+
key: 'getUploadHeaders',
|
2670
|
+
value: function getUploadHeaders() {
|
2671
|
+
return this.config.upload_headers || {};
|
2672
|
+
}
|
2673
|
+
}, {
|
2674
|
+
key: 'uploadFile',
|
2675
|
+
value: function uploadFile() {
|
2676
|
+
var _this3 = this;
|
2677
|
+
|
2678
|
+
var handleUp = void 0;
|
2679
|
+
(0, _axios2['default'])({
|
2680
|
+
method: 'post',
|
2681
|
+
url: this.getUploadUrl(),
|
2682
|
+
headers: this.getUploadHeaders(),
|
2683
|
+
data: this.formatData(),
|
2684
|
+
onUploadProgress: function onUploadProgress(e) {
|
2685
|
+
return _this3.updateProgressBar(e);
|
2686
|
+
}
|
2687
|
+
}).then(function (result) {
|
2688
|
+
_this3.uploadCompleted(result.data);
|
2689
|
+
_this3.props.blockProps.removeLock();
|
2690
|
+
_this3.stopLoader();
|
2691
|
+
_this3.file = null;
|
2692
|
+
|
2693
|
+
if (_this3.config.upload_callback) {
|
2694
|
+
return _this3.config.upload_callback(result, _this3);
|
2695
|
+
}
|
2696
|
+
})['catch'](function (error) {
|
2697
|
+
_this3.props.blockProps.removeLock();
|
2698
|
+
_this3.stopLoader();
|
2699
|
+
|
2700
|
+
console.log('ERROR: got error uploading file ' + error);
|
2701
|
+
if (_this3.config.upload_error_callback) {
|
2702
|
+
return _this3.config.upload_error_callback(error, _this3);
|
2703
|
+
}
|
2704
|
+
});
|
2705
|
+
|
2706
|
+
return handleUp = function handleUp(json_response) {
|
2707
|
+
return _this3.uploadCompleted(json_response, n);
|
2708
|
+
};
|
2709
|
+
}
|
2710
|
+
}, {
|
2711
|
+
key: 'uploadCompleted',
|
2712
|
+
value: function uploadCompleted(json) {
|
2713
|
+
return this.setState({ url: json.url }, this.updateData);
|
2714
|
+
}
|
2715
|
+
}, {
|
2716
|
+
key: 'updateProgressBar',
|
2717
|
+
value: function updateProgressBar(e) {
|
2718
|
+
var complete = this.state.loading_progress;
|
2719
|
+
if (e.lengthComputable) {
|
2720
|
+
complete = e.loaded / e.total * 100;
|
2721
|
+
complete = complete != null ? complete : { complete: 0 };
|
2722
|
+
this.setState({
|
2723
|
+
loading_progress: complete });
|
2724
|
+
return console.log('complete: ' + complete);
|
2725
|
+
}
|
2726
|
+
}
|
2727
|
+
}, {
|
2728
|
+
key: 'placeHolderEnabled',
|
2729
|
+
value: function placeHolderEnabled() {
|
2730
|
+
return this.state.enabled || this.props.block.getText();
|
2731
|
+
}
|
2732
|
+
}, {
|
2733
|
+
key: 'placeholderText',
|
2734
|
+
value: function placeholderText() {
|
2735
|
+
if (this.placeHolderEnabled()) {
|
2736
|
+
return "";
|
2737
|
+
}
|
2738
|
+
return "Write caption for image (optional)";
|
2739
|
+
}
|
2740
|
+
}, {
|
2741
|
+
key: 'handleFocus',
|
2742
|
+
value: function handleFocus(e) {
|
2743
|
+
var _this4 = this;
|
2744
|
+
|
2745
|
+
// console.log "focus on placeholder"
|
2746
|
+
return setTimeout(function () {
|
2747
|
+
return _this4.setState({
|
2748
|
+
enabled: true });
|
2749
|
+
}, 0);
|
2750
|
+
}
|
2751
|
+
}, {
|
2752
|
+
key: 'render',
|
2753
|
+
value: function render() {
|
2754
|
+
|
2755
|
+
return _react2['default'].createElement(
|
2756
|
+
'div',
|
2757
|
+
{ ref: 'image_tag2', suppressContentEditableWarning: true },
|
2758
|
+
_react2['default'].createElement(
|
2759
|
+
'div',
|
2760
|
+
{ className: 'aspectRatioPlaceholder is-locked',
|
2761
|
+
style: this.coords(),
|
2762
|
+
onClick: this.handleGrafFigureSelectImg },
|
2763
|
+
_react2['default'].createElement('div', { style: { paddingBottom: this.state.aspect_ratio.ratio + '%' },
|
2764
|
+
className: 'aspect-ratio-fill' }),
|
2765
|
+
_react2['default'].createElement('img', { src: this.state.url,
|
2766
|
+
ref: 'image_tag',
|
2767
|
+
height: this.state.aspect_ratio.height,
|
2768
|
+
width: this.state.aspect_ratio.width,
|
2769
|
+
className: 'graf-image' }),
|
2770
|
+
_react2['default'].createElement(Loader, { toggle: this.state.loading,
|
2771
|
+
progress: this.state.loading_progress })
|
2772
|
+
),
|
2773
|
+
_react2['default'].createElement(
|
2774
|
+
'figcaption',
|
2775
|
+
{ className: 'imageCaption', onMouseDown: this.handleFocus },
|
2776
|
+
!this.state.enabled ? _react2['default'].createElement(
|
2777
|
+
'span',
|
2778
|
+
{ className: 'danteDefaultPlaceholder' },
|
2779
|
+
this.placeholderText()
|
2780
|
+
) : undefined,
|
2781
|
+
_react2['default'].createElement(_draftJs.EditorBlock, (0, _assign2['default'])({}, this.props, {
|
2782
|
+
"editable": true, "className": "imageCaption" }))
|
2783
|
+
)
|
2784
|
+
);
|
2785
|
+
}
|
2786
|
+
}]);
|
2787
|
+
return ImageBlock;
|
2788
|
+
}(_react2['default'].Component);
|
2789
|
+
|
2790
|
+
exports['default'] = ImageBlock;
|
2791
|
+
|
2792
|
+
var Loader = function (_React$Component2) {
|
2793
|
+
(0, _inherits3['default'])(Loader, _React$Component2);
|
2794
|
+
|
2795
|
+
function Loader() {
|
2796
|
+
(0, _classCallCheck3['default'])(this, Loader);
|
2797
|
+
return (0, _possibleConstructorReturn3['default'])(this, (Loader.__proto__ || (0, _getPrototypeOf2['default'])(Loader)).apply(this, arguments));
|
2798
|
+
}
|
2799
|
+
|
2800
|
+
(0, _createClass3['default'])(Loader, [{
|
2801
|
+
key: 'render',
|
2802
|
+
value: function render() {
|
2803
|
+
return _react2['default'].createElement(
|
2804
|
+
'div',
|
2805
|
+
null,
|
2806
|
+
this.props.toggle ? _react2['default'].createElement(
|
2807
|
+
'div',
|
2808
|
+
{ className: 'image-upoader-loader' },
|
2809
|
+
_react2['default'].createElement(
|
2810
|
+
'p',
|
2811
|
+
null,
|
2812
|
+
this.props.progress === 100 ? "processing image..." : _react2['default'].createElement(
|
2813
|
+
'span',
|
2814
|
+
null,
|
2815
|
+
_react2['default'].createElement(
|
2816
|
+
'span',
|
2817
|
+
null,
|
2818
|
+
'loading'
|
2819
|
+
),
|
2820
|
+
' ',
|
2821
|
+
Math.round(this.props.progress)
|
2822
|
+
)
|
2823
|
+
)
|
2824
|
+
) : undefined
|
2825
|
+
);
|
2826
|
+
}
|
2827
|
+
}]);
|
2828
|
+
return Loader;
|
2829
|
+
}(_react2['default'].Component);
|
2830
|
+
|
2831
|
+
/***/ },
|
2832
|
+
|
2833
|
+
/***/ 469:
|
2834
|
+
/***/ function(module, exports, __webpack_require__) {
|
2835
|
+
|
2836
|
+
'use strict';
|
2837
|
+
|
2838
|
+
Object.defineProperty(exports, "__esModule", {
|
2839
|
+
value: true
|
2840
|
+
});
|
2841
|
+
|
2842
|
+
var _getPrototypeOf = __webpack_require__(208);
|
2843
|
+
|
2844
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
2845
|
+
|
2846
|
+
var _classCallCheck2 = __webpack_require__(23);
|
2847
|
+
|
2848
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
2849
|
+
|
2850
|
+
var _createClass2 = __webpack_require__(24);
|
2851
|
+
|
2852
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
2853
|
+
|
2854
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
2855
|
+
|
2856
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
2857
|
+
|
2858
|
+
var _inherits2 = __webpack_require__(266);
|
2859
|
+
|
2860
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
2861
|
+
|
2862
|
+
var _react = __webpack_require__(43);
|
2863
|
+
|
2864
|
+
var _react2 = _interopRequireDefault(_react);
|
2865
|
+
|
2866
|
+
var _reactDom = __webpack_require__(72);
|
2867
|
+
|
2868
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
2869
|
+
|
2870
|
+
var _draftJs = __webpack_require__(274);
|
2871
|
+
|
2872
|
+
var _axios = __webpack_require__(433);
|
2873
|
+
|
2874
|
+
var _axios2 = _interopRequireDefault(_axios);
|
2875
|
+
|
2876
|
+
var _index = __webpack_require__(426);
|
2877
|
+
|
2878
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
2879
|
+
|
2880
|
+
var EmbedBlock = function (_React$Component) {
|
2881
|
+
(0, _inherits3['default'])(EmbedBlock, _React$Component);
|
2882
|
+
|
2883
|
+
function EmbedBlock(props) {
|
2884
|
+
(0, _classCallCheck3['default'])(this, EmbedBlock);
|
2885
|
+
|
2886
|
+
//api_key = "86c28a410a104c8bb58848733c82f840"
|
2887
|
+
|
2888
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (EmbedBlock.__proto__ || (0, _getPrototypeOf2['default'])(EmbedBlock)).call(this, props));
|
2889
|
+
|
2890
|
+
_this.updateData = _this.updateData.bind(_this);
|
2891
|
+
_this.dataForUpdate = _this.dataForUpdate.bind(_this);
|
2892
|
+
_this.componentDidMount = _this.componentDidMount.bind(_this);
|
2893
|
+
_this.state = {
|
2894
|
+
embed_data: _this.defaultData(),
|
2895
|
+
error: ""
|
2896
|
+
};
|
2897
|
+
return _this;
|
2898
|
+
}
|
2899
|
+
|
2900
|
+
(0, _createClass3['default'])(EmbedBlock, [{
|
2901
|
+
key: 'defaultData',
|
2902
|
+
value: function defaultData() {
|
2903
|
+
var existing_data = this.props.block.getData().toJS();
|
2904
|
+
return existing_data.embed_data || {};
|
2905
|
+
}
|
2906
|
+
|
2907
|
+
// will update block state
|
2908
|
+
|
2909
|
+
}, {
|
2910
|
+
key: 'updateData',
|
2911
|
+
value: function updateData() {
|
2912
|
+
var _props = this.props,
|
2913
|
+
block = _props.block,
|
2914
|
+
blockProps = _props.blockProps;
|
2915
|
+
var _props$blockProps = this.props.blockProps,
|
2916
|
+
getEditorState = _props$blockProps.getEditorState,
|
2917
|
+
setEditorState = _props$blockProps.setEditorState;
|
2918
|
+
|
2919
|
+
var data = block.getData();
|
2920
|
+
var newData = data.merge(this.state);
|
2921
|
+
return setEditorState((0, _index.updateDataOfBlock)(getEditorState(), block, newData));
|
2922
|
+
}
|
2923
|
+
}, {
|
2924
|
+
key: 'dataForUpdate',
|
2925
|
+
value: function dataForUpdate() {
|
2926
|
+
|
2927
|
+
return this.props.blockProps.data.toJS();
|
2928
|
+
}
|
2929
|
+
}, {
|
2930
|
+
key: 'componentDidMount',
|
2931
|
+
value: function componentDidMount() {
|
2932
|
+
var _this2 = this;
|
2933
|
+
|
2934
|
+
if (!this.props.blockProps.data) {
|
2935
|
+
return;
|
2936
|
+
}
|
2937
|
+
|
2938
|
+
// ensure data isnt already loaded
|
2939
|
+
// unless @dataForUpdate().endpoint or @dataForUpdate().provisory_text
|
2940
|
+
|
2941
|
+
if (!this.dataForUpdate().endpoint && !this.dataForUpdate().provisory_text) {
|
2942
|
+
//debugger
|
2943
|
+
return;
|
2944
|
+
}
|
2945
|
+
|
2946
|
+
return (0, _axios2['default'])({
|
2947
|
+
method: 'get',
|
2948
|
+
url: '' + this.dataForUpdate().endpoint + this.dataForUpdate().provisory_text + '&scheme=https'
|
2949
|
+
}).then(function (result) {
|
2950
|
+
|
2951
|
+
return _this2.setState({ embed_data: result.data } //JSON.parse(data.responseText)
|
2952
|
+
, _this2.updateData);
|
2953
|
+
})['catch'](function (error) {
|
2954
|
+
|
2955
|
+
_this2.setState({
|
2956
|
+
error: error.response.data.error_message });
|
2957
|
+
return console.log("TODO: error");
|
2958
|
+
});
|
2959
|
+
}
|
2960
|
+
}, {
|
2961
|
+
key: 'classForImage',
|
2962
|
+
value: function classForImage() {
|
2963
|
+
if (this.state.embed_data.images) {
|
2964
|
+
return "";
|
2965
|
+
} else {
|
2966
|
+
return "mixtapeImage--empty u-ignoreBlock";
|
2967
|
+
}
|
2968
|
+
}
|
2969
|
+
//if @state.embed_data.thumbnail_url then "" else "mixtapeImage--empty u-ignoreBlock"
|
2970
|
+
|
2971
|
+
}, {
|
2972
|
+
key: 'picture',
|
2973
|
+
value: function picture() {
|
2974
|
+
if (this.state.embed_data.images && this.state.embed_data.images.length > 0) {
|
2975
|
+
return this.state.embed_data.images[0].url;
|
2976
|
+
} else {
|
2977
|
+
return "";
|
2978
|
+
}
|
2979
|
+
}
|
2980
|
+
}, {
|
2981
|
+
key: 'render',
|
2982
|
+
value: function render() {
|
2983
|
+
//block = @.props
|
2984
|
+
//foo = @.props.blockProps
|
2985
|
+
//data = Entity.get(block.block.getEntityAt(0)).getData()
|
2986
|
+
console.log("ERROR", this.state.error);
|
2987
|
+
return _react2['default'].createElement(
|
2988
|
+
'span',
|
2989
|
+
null,
|
2990
|
+
this.picture() ? _react2['default'].createElement('a', {
|
2991
|
+
target: '_blank',
|
2992
|
+
className: 'js-mixtapeImage mixtapeImage ' + this.classForImage(),
|
2993
|
+
href: this.state.embed_data.url,
|
2994
|
+
style: { backgroundImage: 'url(\'' + this.picture() + '\')' }
|
2995
|
+
}) : undefined,
|
2996
|
+
this.state.error ? _react2['default'].createElement(
|
2997
|
+
'h2',
|
2998
|
+
null,
|
2999
|
+
this.state.error
|
3000
|
+
) : undefined,
|
3001
|
+
_react2['default'].createElement(
|
3002
|
+
'a',
|
3003
|
+
{
|
3004
|
+
className: 'markup--anchor markup--mixtapeEmbed-anchor',
|
3005
|
+
target: '_blank',
|
3006
|
+
href: this.state.embed_data.url
|
3007
|
+
},
|
3008
|
+
_react2['default'].createElement(
|
3009
|
+
'strong',
|
3010
|
+
{ className: 'markup--strong markup--mixtapeEmbed-strong' },
|
3011
|
+
this.state.embed_data.title
|
3012
|
+
),
|
3013
|
+
_react2['default'].createElement(
|
3014
|
+
'em',
|
3015
|
+
{ className: 'markup--em markup--mixtapeEmbed-em' },
|
3016
|
+
this.state.embed_data.description
|
3017
|
+
)
|
3018
|
+
),
|
3019
|
+
this.state.embed_data.provider_url
|
3020
|
+
);
|
3021
|
+
}
|
3022
|
+
}]);
|
3023
|
+
return EmbedBlock;
|
3024
|
+
}(_react2['default'].Component);
|
3025
|
+
|
3026
|
+
exports['default'] = EmbedBlock;
|
3027
|
+
|
3028
|
+
/***/ },
|
3029
|
+
|
3030
|
+
/***/ 470:
|
3031
|
+
/***/ function(module, exports, __webpack_require__) {
|
3032
|
+
|
3033
|
+
'use strict';
|
3034
|
+
|
3035
|
+
Object.defineProperty(exports, "__esModule", {
|
3036
|
+
value: true
|
3037
|
+
});
|
3038
|
+
|
3039
|
+
var _assign = __webpack_require__(465);
|
3040
|
+
|
3041
|
+
var _assign2 = _interopRequireDefault(_assign);
|
3042
|
+
|
3043
|
+
var _getPrototypeOf = __webpack_require__(208);
|
3044
|
+
|
3045
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
3046
|
+
|
3047
|
+
var _classCallCheck2 = __webpack_require__(23);
|
3048
|
+
|
3049
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
3050
|
+
|
3051
|
+
var _createClass2 = __webpack_require__(24);
|
3052
|
+
|
3053
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
3054
|
+
|
3055
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
3056
|
+
|
3057
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
3058
|
+
|
3059
|
+
var _inherits2 = __webpack_require__(266);
|
3060
|
+
|
3061
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
3062
|
+
|
3063
|
+
var _react = __webpack_require__(43);
|
3064
|
+
|
3065
|
+
var _react2 = _interopRequireDefault(_react);
|
3066
|
+
|
3067
|
+
var _reactDom = __webpack_require__(72);
|
3068
|
+
|
3069
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
3070
|
+
|
3071
|
+
var _draftJs = __webpack_require__(274);
|
3072
|
+
|
3073
|
+
var _index = __webpack_require__(426);
|
3074
|
+
|
3075
|
+
var _axios = __webpack_require__(433);
|
3076
|
+
|
3077
|
+
var _axios2 = _interopRequireDefault(_axios);
|
3078
|
+
|
3079
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3080
|
+
|
3081
|
+
var VideoBlock = function (_React$Component) {
|
3082
|
+
(0, _inherits3['default'])(VideoBlock, _React$Component);
|
3083
|
+
|
3084
|
+
function VideoBlock(props) {
|
3085
|
+
(0, _classCallCheck3['default'])(this, VideoBlock);
|
3086
|
+
|
3087
|
+
//api_key = "86c28a410a104c8bb58848733c82f840"
|
3088
|
+
|
3089
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (VideoBlock.__proto__ || (0, _getPrototypeOf2['default'])(VideoBlock)).call(this, props));
|
3090
|
+
|
3091
|
+
_this.updateData = _this.updateData.bind(_this);
|
3092
|
+
_this.dataForUpdate = _this.dataForUpdate.bind(_this);
|
3093
|
+
_this.state = { embed_data: _this.defaultData() };
|
3094
|
+
return _this;
|
3095
|
+
}
|
3096
|
+
|
3097
|
+
(0, _createClass3['default'])(VideoBlock, [{
|
3098
|
+
key: 'defaultData',
|
3099
|
+
value: function defaultData() {
|
3100
|
+
var existing_data = this.props.block.getData().toJS();
|
3101
|
+
return existing_data.embed_data || {};
|
3102
|
+
}
|
3103
|
+
|
3104
|
+
// will update block state
|
3105
|
+
|
3106
|
+
}, {
|
3107
|
+
key: 'updateData',
|
3108
|
+
value: function updateData() {
|
3109
|
+
var _props = this.props,
|
3110
|
+
block = _props.block,
|
3111
|
+
blockProps = _props.blockProps;
|
3112
|
+
var _props$blockProps = this.props.blockProps,
|
3113
|
+
getEditorState = _props$blockProps.getEditorState,
|
3114
|
+
setEditorState = _props$blockProps.setEditorState;
|
3115
|
+
|
3116
|
+
var data = block.getData();
|
3117
|
+
var newData = data.merge(this.state);
|
3118
|
+
return setEditorState((0, _index.updateDataOfBlock)(getEditorState(), block, newData));
|
3119
|
+
}
|
3120
|
+
}, {
|
3121
|
+
key: 'dataForUpdate',
|
3122
|
+
value: function dataForUpdate() {
|
3123
|
+
return this.props.blockProps.data.toJS();
|
3124
|
+
}
|
3125
|
+
}, {
|
3126
|
+
key: 'componentDidMount',
|
3127
|
+
value: function componentDidMount() {
|
3128
|
+
var _this2 = this;
|
3129
|
+
|
3130
|
+
if (!this.props.blockProps.data) {
|
3131
|
+
return;
|
3132
|
+
}
|
3133
|
+
// ensure data isnt already loaded
|
3134
|
+
if (!this.dataForUpdate().endpoint && !this.dataForUpdate().provisory_text) {
|
3135
|
+
return;
|
3136
|
+
}
|
3137
|
+
|
3138
|
+
return (0, _axios2['default'])({
|
3139
|
+
method: 'get',
|
3140
|
+
url: '' + this.dataForUpdate().endpoint + this.dataForUpdate().provisory_text + '&scheme=https'
|
3141
|
+
}).then(function (result) {
|
3142
|
+
return _this2.setState({ embed_data: result.data } //JSON.parse(data.responseText)
|
3143
|
+
, _this2.updateData);
|
3144
|
+
})['catch'](function (error) {
|
3145
|
+
return console.log("TODO: error");
|
3146
|
+
});
|
3147
|
+
}
|
3148
|
+
}, {
|
3149
|
+
key: 'classForImage',
|
3150
|
+
value: function classForImage() {
|
3151
|
+
if (this.state.embed_data.thumbnail_url) {
|
3152
|
+
return "";
|
3153
|
+
} else {
|
3154
|
+
return "mixtapeImage--empty u-ignoreBlock";
|
3155
|
+
}
|
3156
|
+
}
|
3157
|
+
}, {
|
3158
|
+
key: 'render',
|
3159
|
+
value: function render() {
|
3160
|
+
return _react2['default'].createElement(
|
3161
|
+
'figure',
|
3162
|
+
{ className: 'graf--figure graf--iframe graf--first', tabIndex: '0' },
|
3163
|
+
_react2['default'].createElement('div', { className: 'iframeContainer',
|
3164
|
+
dangerouslySetInnerHTML: { __html: this.state.embed_data.html } }),
|
3165
|
+
_react2['default'].createElement(
|
3166
|
+
'figcaption',
|
3167
|
+
{ className: 'imageCaption' },
|
3168
|
+
_react2['default'].createElement(_draftJs.EditorBlock, (0, _assign2['default'])({}, this.props, { "className": "imageCaption" }))
|
3169
|
+
)
|
3170
|
+
);
|
3171
|
+
}
|
3172
|
+
}]);
|
3173
|
+
return VideoBlock;
|
3174
|
+
}(_react2['default'].Component);
|
3175
|
+
|
3176
|
+
exports['default'] = VideoBlock;
|
3177
|
+
|
3178
|
+
/***/ },
|
3179
|
+
|
3180
|
+
/***/ 471:
|
3181
|
+
/***/ function(module, exports, __webpack_require__) {
|
3182
|
+
|
3183
|
+
'use strict';
|
3184
|
+
|
3185
|
+
Object.defineProperty(exports, "__esModule", {
|
3186
|
+
value: true
|
3187
|
+
});
|
3188
|
+
|
3189
|
+
var _assign = __webpack_require__(465);
|
3190
|
+
|
3191
|
+
var _assign2 = _interopRequireDefault(_assign);
|
3192
|
+
|
3193
|
+
var _getPrototypeOf = __webpack_require__(208);
|
3194
|
+
|
3195
|
+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
3196
|
+
|
3197
|
+
var _classCallCheck2 = __webpack_require__(23);
|
3198
|
+
|
3199
|
+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
3200
|
+
|
3201
|
+
var _createClass2 = __webpack_require__(24);
|
3202
|
+
|
3203
|
+
var _createClass3 = _interopRequireDefault(_createClass2);
|
3204
|
+
|
3205
|
+
var _possibleConstructorReturn2 = __webpack_require__(219);
|
3206
|
+
|
3207
|
+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
3208
|
+
|
3209
|
+
var _inherits2 = __webpack_require__(266);
|
3210
|
+
|
3211
|
+
var _inherits3 = _interopRequireDefault(_inherits2);
|
3212
|
+
|
3213
|
+
var _react = __webpack_require__(43);
|
3214
|
+
|
3215
|
+
var _react2 = _interopRequireDefault(_react);
|
3216
|
+
|
3217
|
+
var _reactDom = __webpack_require__(72);
|
3218
|
+
|
3219
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
3220
|
+
|
3221
|
+
var _draftJs = __webpack_require__(274);
|
3222
|
+
|
3223
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
3224
|
+
|
3225
|
+
var PlaceholderBlock = function (_React$Component) {
|
3226
|
+
(0, _inherits3['default'])(PlaceholderBlock, _React$Component);
|
3227
|
+
|
3228
|
+
function PlaceholderBlock(props) {
|
3229
|
+
(0, _classCallCheck3['default'])(this, PlaceholderBlock);
|
3230
|
+
|
3231
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, (PlaceholderBlock.__proto__ || (0, _getPrototypeOf2['default'])(PlaceholderBlock)).call(this, props));
|
3232
|
+
|
3233
|
+
_this.placeholderText = _this.placeholderText.bind(_this);
|
3234
|
+
_this.placeholderFromProps = _this.placeholderFromProps.bind(_this);
|
3235
|
+
_this.defaultText = _this.defaultText.bind(_this);
|
3236
|
+
_this.handleFocus = _this.handleFocus.bind(_this);
|
3237
|
+
_this.classForDefault = _this.classForDefault.bind(_this);
|
3238
|
+
_this.state = {
|
3239
|
+
enabled: false,
|
3240
|
+
data: _this.props.blockProps.data.toJS()
|
3241
|
+
};
|
3242
|
+
return _this;
|
3243
|
+
}
|
3244
|
+
|
3245
|
+
(0, _createClass3['default'])(PlaceholderBlock, [{
|
3246
|
+
key: 'placeholderText',
|
3247
|
+
value: function placeholderText() {
|
3248
|
+
if (this.state.enabled) {
|
3249
|
+
return "";
|
3250
|
+
}
|
3251
|
+
return this.props.blockProps.data.toJS().placeholder || this.placeholderFromProps() || this.defaultText();
|
3252
|
+
}
|
3253
|
+
//if @.props.blockProps.data then @.props.blockProps.data.placeholder else @defaultText()
|
3254
|
+
|
3255
|
+
|
3256
|
+
}, {
|
3257
|
+
key: 'placeholderFromProps',
|
3258
|
+
value: function placeholderFromProps() {
|
3259
|
+
return this.props.block.toJS().placeholder;
|
3260
|
+
}
|
3261
|
+
}, {
|
3262
|
+
key: 'defaultText',
|
3263
|
+
value: function defaultText() {
|
3264
|
+
return "write something ";
|
3265
|
+
}
|
3266
|
+
}, {
|
3267
|
+
key: 'componentDidMount',
|
3268
|
+
value: function componentDidMount() {}
|
3269
|
+
}, {
|
3270
|
+
key: 'handleFocus',
|
3271
|
+
value: function handleFocus(e) {
|
3272
|
+
var _this2 = this;
|
3273
|
+
|
3274
|
+
// console.log "focus on placeholder"
|
3275
|
+
return setTimeout(function () {
|
3276
|
+
return _this2.setState({
|
3277
|
+
enabled: true });
|
3278
|
+
}, 0);
|
3279
|
+
}
|
3280
|
+
}, {
|
3281
|
+
key: 'classForDefault',
|
3282
|
+
value: function classForDefault() {
|
3283
|
+
if (!this.state.enabled) {
|
3284
|
+
return "defaultValue defaultValue--root";
|
3285
|
+
} else {
|
3286
|
+
return "";
|
3287
|
+
}
|
3288
|
+
}
|
3289
|
+
}, {
|
3290
|
+
key: 'render',
|
3291
|
+
value: function render() {
|
3292
|
+
return _react2['default'].createElement(
|
3293
|
+
'span',
|
3294
|
+
{ className: this.classForDefault(), onMouseDown: this.handleFocus },
|
3295
|
+
this.placeholderText(),
|
3296
|
+
_react2['default'].createElement(_draftJs.EditorBlock, (0, _assign2['default'])({}, this.props, {
|
3297
|
+
"className": "imageCaption",
|
3298
|
+
"placeholder": "escrive alalal"
|
3299
|
+
}))
|
3300
|
+
);
|
3301
|
+
}
|
3302
|
+
}]);
|
3303
|
+
return PlaceholderBlock;
|
3304
|
+
}(_react2['default'].Component);
|
3305
|
+
|
3306
|
+
exports['default'] = PlaceholderBlock;
|
3307
|
+
|
3308
|
+
/***/ }
|
3309
|
+
|
3310
|
+
});
|
4
3311
|
//# sourceMappingURL=dante.js.map
|