draft-extend
Advanced tools
Comparing version 1.6.3 to 1.6.4
@@ -1,6 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("Immutable"),require("Draft"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","Immutable","Draft","ReactDOM"],t):"object"==typeof exports?exports.DraftExtend=t(require("React"),require("Immutable"),require("Draft"),require("ReactDOM")):e.DraftExtend=t(e.React,e.Immutable,e.Draft,e.ReactDOM)}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.compose=t.pluginUtils=t.createPlugin=t.KeyCommandController=t.Toolbar=t.Editor=void 0;var o=n(10),a=r(o),i=n(12),s=r(i),u=n(5),l=r(u),d=n(13),c=r(d),f=n(14),p=r(f),y=n(7),h=r(y);t.Editor=a.default,t.Toolbar=s.default,t.KeyCommandController=l.default,t.createPlugin=c.default,t.pluginUtils=p.default,t.compose=h.default},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=n(1),o=n(18);if("undefined"==typeof r)throw Error("create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.");var a=(new r.Component).updater;e.exports=o(r.Component,r.isValidElement,a)},function(e,n){e.exports=t},function(e,t,n){e.exports=n(22)()},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i=n(1),s=r(i),u=n(4),l=r(u),d=n(2),c=r(d),f=n(9),p=r(f),y=n(3),h=n(6),m={addKeyCommandListener:l.default.func,removeKeyCommandListener:l.default.func,handleKeyCommand:l.default.func},v=function(e){return(0,c.default)({displayName:"KeyCommandController("+e.displayName+")",propTypes:a({editorState:l.default.object,onChange:l.default.func,keyCommandListeners:l.default.arrayOf(l.default.func)},m),getDefaultProps:function(){return{keyCommandListeners:[]}},componentWillMount:function(){this.keyCommandOverrides=(0,y.List)(this.props.keyCommandListeners),this.keyCommandListeners=(0,y.List)()},componentDidMount:function(){var e=this,t=Object.keys(m),n=t.filter(function(t){return void 0!==e.props[t]}),r=0===n.length,o=n.length===t.length;(0,p.default)(r||o,"KeyCommandController: A KeyCommandController is receiving only some props ("+n.join(", ")+") necessary to defer to a parent key command controller."),o&&this.props.keyCommandListeners.forEach(function(t){e.props.addKeyCommandListener(t)})},componentWillUnmount:function(){var e=this;this.props.removeKeyCommandListener&&this.props.keyCommandListeners.forEach(function(t){e.props.removeKeyCommandListener(t)})},addKeyCommandListener:function e(t){var e=this.props.addKeyCommandListener;return e?void e(t):void(this.keyCommandListeners=this.keyCommandListeners.unshift(t))},removeKeyCommandListener:function e(t){var e=this.props.removeKeyCommandListener;return e?void e(t):void(this.keyCommandListeners=this.keyCommandListeners.filterNot(function(e){return e===t}))},handleKeyCommand:function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.props,o=r.editorState,a=r.onChange,e=r.handleKeyCommand;if(e)return e(t,n);var i=this.keyCommandListeners.concat(this.keyCommandOverrides).reduce(function(e,r){var o=e.state,i=e.hasChanged;if(i===!0)return{state:o,hasChanged:i};var s=r(o,t,n),u=s instanceof h.EditorState;return s===!0||u&&s!==o?u?(a(s),{state:s,hasChanged:!0}):{state:o,hasChanged:!0}:{state:o,hasChanged:i}},{state:o,hasChanged:!1});return i.hasChanged},focus:function(){this.refs.editor.focus()},blur:function(){this.refs.editor.blur()},render:function(){var t=this.props,n=t.editorState,r=t.onChange,i=(t.keyCommandListeners,o(t,["editorState","onChange","keyCommandListeners"]));return s.default.createElement(e,a({},i,{ref:"editor",editorState:n,onChange:r,addKeyCommandListener:this.addKeyCommandListener,removeKeyCommandListener:this.removeKeyCommandListener,handleKeyCommand:this.handleKeyCommand}))}})};t.default=v},function(e,t){e.exports=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){if(0===t.length)return arguments.length<=0?void 0:arguments[0];var e=t[t.length-1],n=t.slice(0,-1);return n.reduceRight(function(e,t){return t(e)},e.apply(void 0,arguments))}}},function(e,t,n){"use strict";function r(e,t,n,r,a,i,s,u){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var d=[n,r,a,i,s,u],c=0;l=new Error(t.replace(/%s/g,function(){return d[c++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t,n){"use strict";var r=function(e,t,n,r,o,a,i,s){if(!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,r,o,a,i,s],d=0;u=new Error(t.replace(/%s/g,function(){return l[d++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}};e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i=n(1),s=r(i),u=n(4),l=r(u),d=n(2),c=r(d),f=n(6),p=n(5),y=r(p),h=n(11),m=r(h),v={className:l.default.string,editorState:l.default.object,onChange:l.default.func,decorators:l.default.array,baseDecorator:l.default.func,styleMap:l.default.object,styleFn:l.default.func,buttons:l.default.array,overlays:l.default.array,blockRendererFn:l.default.func,blockStyleFn:l.default.func,keyBindingFn:l.default.func,addKeyCommandListener:l.default.func.isRequired,removeKeyCommandListener:l.default.func.isRequired,handleReturn:l.default.func,onEscape:l.default.func,onTab:l.default.func,onUpArrow:l.default.func,onDownArrow:l.default.func,readOnly:l.default.bool,showButtons:l.default.bool,renderTray:l.default.func},g=(0,c.default)({displayName:"EditorWrapper",propTypes:v,childContextTypes:{getEditorState:l.default.func,getReadOnly:l.default.func,setReadOnly:l.default.func,onChange:l.default.func,focus:l.default.func,blur:l.default.func,editorRef:l.default.object},getDefaultProps:function(){return{className:"",editorState:f.EditorState.createEmpty(),onChange:function(){},decorators:[],baseDecorator:f.CompositeDecorator,styleMap:{},styleFn:function(){},buttons:[],overlays:[],blockRendererFn:function(){},blockStyleFn:function(){},keyBindingFn:function(){},readOnly:!1,showButtons:!0}},getInitialState:function(){var e=this.props.baseDecorator,t=new e(this.props.decorators);return{decorator:t,readOnly:!1}},getChildContext:function(){return{getEditorState:this.getDecoratedState,getReadOnly:this.getReadOnly,setReadOnly:this.setReadOnly,onChange:this.props.onChange,focus:this.focus,blur:this.blur,editorRef:this.refs.editor}},componentWillReceiveProps:function(e){if(e.decorators.length===this.state.decorator._decorators.length){var t=this.state.decorator._decorators.every(function(t,n){return t===e.decorators[n]});if(t)return}this.setState({decorator:new e.baseDecorator(e.decorators)})},keyBindingFn:function(e){var t=this.props.keyBindingFn(e);return t?t:(0,f.getDefaultKeyBinding)(e)},handleReturn:function(e,t){return this.props.handleReturn&&this.props.handleReturn(e,t)||this.props.handleKeyCommand("return",e)},onEscape:function(e){return this.props.onEscape&&this.props.onEscape(e)||this.props.handleKeyCommand("escape",e)},onTab:function(e){return this.props.onTab&&this.props.onTab(e)||this.props.handleKeyCommand("tab",e)},onUpArrow:function(e){return this.props.onUpArrow&&this.props.onUpArrow(e)||this.props.handleKeyCommand("up-arrow",e)},onDownArrow:function(e){return this.props.onDownArrow&&this.props.onDownArrow(e)||this.props.handleKeyCommand("down-arrow",e)},focus:function(){this.refs.editor.focus()},blur:function(){this.refs.editor.blur()},getOtherProps:function(){var e=this,t=Object.keys(this.props),n=Object.keys(v),r=t.filter(function(e){return n.indexOf(e)===-1});return r.reduce(function(t,n){return t[n]=e.props[n],t},{})},getReadOnly:function(){return this.state.readOnly||this.props.readOnly},setReadOnly:function(e){this.setState({readOnly:e})},getDecoratedState:function(){var e=this.props.editorState,t=this.state.decorator,n=e.getDecorator();return n&&n._decorators===t._decorators?e:f.EditorState.set(e,{decorator:t})},renderTray:function e(){var e=this.props.renderTray;return"function"!=typeof e?null:e()},renderPluginButtons:function(){var e=this,t=this.props,n=t.onChange,r=t.addKeyCommandListener,o=t.removeKeyCommandListener,i=t.showButtons;if(i===!1)return null;var u=this.getDecoratedState();return this.props.buttons.map(function(t,i){return s.default.createElement(t,a({},e.getOtherProps(),{key:"button-"+i,attachedToEditor:!0,editorState:u,onChange:n,addKeyCommandListener:r,removeKeyCommandListener:o}))})},renderOverlays:function(){var e=this,t=this.props,n=t.onChange,r=t.addKeyCommandListener,o=t.removeKeyCommandListener,i=this.getDecoratedState();return this.props.overlays.map(function(t,u){return s.default.createElement(m.default,{key:u},s.default.createElement(t,a({},e.getOtherProps(),{editorState:i,onChange:n,addKeyCommandListener:r,removeKeyCommandListener:o})))})},render:function(){var e=this.props,t=e.styleMap,n=e.styleFn,r=e.blockRendererFn,i=e.blockStyleFn,u=e.onChange,l=e.handleKeyCommand,d=o(e,["styleMap","styleFn","blockRendererFn","blockStyleFn","onChange","handleKeyCommand"]),c=this.getDecoratedState(),p="draft-extend "+this.props.className,y=this.getReadOnly();return s.default.createElement("div",{className:p},s.default.createElement("div",{className:"draft-extend-editor"},s.default.createElement(f.Editor,a({},d,{ref:"editor",editorState:c,readOnly:y,onChange:u,blockStyleFn:i,blockRendererFn:r,customStyleMap:t,customStyleFn:n,handleKeyCommand:l,keyBindingFn:this.keyBindingFn,handleReturn:this.handleReturn,onEscape:this.onEscape,onTab:this.onTab,onUpArrow:this.onUpArrow,onDownArrow:this.onDownArrow})),s.default.createElement("div",{className:"draft-extend-tray"},this.renderTray()),s.default.createElement("div",{className:"draft-extend-controls"},this.renderPluginButtons()),s.default.createElement("div",{className:"draft-extend-overlays"},this.renderOverlays())))}});t.default=(0,y.default)(g)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),a=r(o),i=n(24),s=r(i),u=n(2),l=r(u);t.default=(0,l.default)({displayName:"OverlayWrapper",getInitialState:function(){var e=document.createElement("div");return document.body.appendChild(e),{node:e}},componentDidMount:function(){this.renderOverlay()},componentDidUpdate:function(){this.renderOverlay()},componentWillUnmount:function(){s.default.unmountComponentAtNode(this.state.node)},renderOverlay:function(){var e=a.default.Children.only(this.props.children);s.default.render(e,this.state.node)},render:function(){return null}})},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i=n(1),s=r(i),u=n(4),l=r(u),d=n(2),c=r(d),f=n(5),p=r(f),y=(0,c.default)({displayName:"Toolbar",propTypes:{editorState:l.default.object,onChange:l.default.func,buttons:l.default.array,addKeyCommandListener:l.default.func.isRequired,removeKeyCommandListener:l.default.func.isRequired},childContextTypes:{getEditorState:l.default.func,onChange:l.default.func},getChildContext:function(){return{getEditorState:this.getEditorState,onChange:this.props.onChange}},getEditorState:function(){return this.props.editorState},renderButtons:function(){var e=this.props,t=e.editorState,n=e.onChange,r=e.buttons,i=e.addKeyCommandListener,u=e.removeKeyCommandListener,l=o(e,["editorState","onChange","buttons","addKeyCommandListener","removeKeyCommandListener"]);return r.map(function(e,r){return s.default.createElement(e,a({},l,{key:"button-"+r,editorState:t,onChange:n,addKeyCommandListener:i,removeKeyCommandListener:u}))})},render:function(){return s.default.createElement("ul",{className:"draft-extend-controls"},this.renderButtons())}});t.default=(0,p.default)(y)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=n(1),i=r(a),s=n(4),u=r(s),l=n(2),d=r(l),c=n(3),f=n(16),p=r(f),y=n(7),h=r(y),m=n(15),v=r(m),g=n(17),b=r(g),C=function(){},E=[],O={},_=function(e){return function(){return e.apply(void 0,arguments)}};_.__isMiddleware=!0;var M=(0,p.default)(h.default),S=(0,p.default)(v.default),T=(0,p.default)(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return Object.assign.apply(Object,[{}].concat(t))}),k=(0,p.default)(function(e,t){return e.concat(t)}),w=(0,p.default)(function(e){return Array.isArray(e)?e:[e]}),D=(0,p.default)(function(e){return function(t,n){return e(t,n,(0,c.OrderedSet)())}}),R=(0,p.default)(b.default),x=function e(t){var n=t.displayName,r=void 0===n?"Plugin":n,a=t.decorators,s=void 0===a?E:a,l=t.buttons,c=void 0===l?E:l,f=t.overlays,p=void 0===f?E:f,y=t.styleMap,h=void 0===y?O:y,m=t.styleFn,v=void 0===m?C:m,g=t.blockRendererFn,b=void 0===g?C:g,x=t.blockStyleFn,j=void 0===x?C:x,L=t.keyBindingFn,N=void 0===L?C:L,F=t.keyCommandListener,P=void 0===F?C:F,A=t.htmlToStyle,K=void 0===A?_:A,I=t.htmlToBlock,B=void 0===I?_:I,Y=t.htmlToEntity,U=void 0===Y?_:Y,q=t.textToEntity,W=void 0===q?_:q,H=t.styleToHTML,G=void 0===H?_:H,V=t.blockToHTML,z=void 0===V?_:V,Z=t.entityToHTML,J=void 0===Z?_:Z;return function(t){return s=w(s),c=w(c),p=w(p),t.prototype&&t.prototype.isReactComponent?(0,d.default)({displayName:r,propTypes:{styleMap:u.default.object,styleFn:u.default.func,decorators:u.default.array,buttons:u.default.array,overlays:u.default.array,blockRendererFn:u.default.func,blockStyleFn:u.default.func,keyBindingFn:u.default.func,keyCommandListeners:u.default.arrayOf(u.default.func)},getDefaultProps:function(){return{styleMap:O,styleFn:C,decorators:E,buttons:E,overlays:E,blockRendererFn:C,blockStyleFn:C,keyBindingFn:C,keyCommandListeners:E}},focus:function(){this.refs.child.focus&&this.refs.child.focus()},blur:function(){this.refs.child.blur&&this.refs.child.blur()},render:function(){var e=T(this.props.styleMap,h),n=S(this.props.styleFn,v),r=k(this.props.decorators,s),a=k(this.props.buttons,c),u=k(this.props.overlays,p),l=S(b,this.props.blockRendererFn),d=S(j,this.props.blockStyleFn),f=S(N,this.props.keyBindingFn),y=k(this.props.keyCommandListeners,w(P));return i.default.createElement(t,o({},this.props,{ref:"child",styleMap:e,styleFn:n,decorators:r,buttons:a,overlays:u,blockRendererFn:l,blockStyleFn:d,keyBindingFn:f,keyCommandListeners:y}))}}):function(){for(var n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];if(1===r.length&&("string"==typeof r[0]||r[0].hasOwnProperty("_map")&&null!=r[0].getBlockMap))return t({htmlToStyle:K,htmlToBlock:B,htmlToEntity:U,textToEntity:W,styleToHTML:G,blockToHTML:z,entityToHTML:J}).apply(void 0,r);var a=r[0],i=M(R(D(K)),R(a.htmlToStyle));i.__isMiddleware=!0;var s=M(R(B),R(a.htmlToBlock));s.__isMiddleware=!0;var u=M(R(U),R(a.htmlToEntity));u.__isMiddleware=!0;var l=M(R(W),R(a.textToEntity));l.__isMiddleware=!0;var d=M(R(G),R(a.styleToHTML));d.__isMiddleware=!0;var c=M(R(z),R(a.blockToHTML));c.__isMiddleware=!0;var f=M(R(J),R(a.entityToHTML));return f.__isMiddleware=!0,e({htmlToStyle:i,htmlToBlock:s,htmlToEntity:u,textToEntity:l,styleToHTML:d,blockToHTML:c,entityToHTML:f})(t)}}};t.default=x},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(6),a=n(3),i=n(9),s=r(i),u=function(e){return e.replace(/[a-z][A-Z]/g,function(e){return e[0]+"-"+e[1].toLowerCase()})},l=function(e){var t=e.getCurrentContent().getBlockForKey(e.getSelection().getStartKey());if(t)return t.getEntityAt(e.getSelection().getStartOffset())};t.default={camelCaseToHyphen:u,styleObjectToString:function(e){return Object.keys(e).map(function(t){return u(t)+": "+e[t]+";"}).join(" ").replace(/"/g,'\\"')},entityStrategy:function(e){return function(t,n,r){t.findEntityRanges(function(t){var n=t.getEntity();if(null===n)return!1;var a=r&&r.getEntity?r.getEntity(n):o.Entity.get(n);return a&&a.getType()===e},n)}},getEntitySelection:function(e,t){var n=[];return e.getCurrentContent().getBlocksAsArray().forEach(function(e){e.findEntityRanges(function(e){return e.getEntity()===t},function(t,r){n.push(o.SelectionState.createEmpty(e.getKey()).merge({anchorOffset:t,focusOffset:r,isBackward:!1,hasFocus:!0}))})}),(0,s.default)(1===n.length,"getEntitySelection: More than one range with the same entityKey. Please use unique entity instances"),n[0]},insertBlockAtCursor:function(e,t){var n=e.getCurrentContent(),r=e.getSelection(),i=o.Modifier.removeRange(n,r,"backward"),s=i.getSelectionAfter(),u=o.Modifier.splitBlock(i,s),l=u.getSelectionAfter(),d=o.Modifier.setBlockType(u,l,t.getType()),c=[t,new o.ContentBlock({key:(0,o.genKey)(),type:"unstyled",text:"",characterList:(0,a.List)()})],f=o.BlockMapBuilder.createFromArray(c),p=o.Modifier.replaceWithFragment(d,l,f),y=p.merge({selectionBefore:r,selectionAfter:p.getSelectionAfter().set("hasFocus",!0)});return o.EditorState.push(e,y,"insert-fragment")},getSelectedInlineStyles:function(e){var t=e.getSelection(),n=e.getCurrentContent(),r=n.getBlockMap().skipUntil(function(e,n){return n===t.getStartKey()}).takeUntil(function(e,r){return n.getKeyBefore(r)===t.getEndKey()});return r.reduce(function(e,n){var r=n.getKey(),o=0,a=n.getLength()-1;r===t.getStartKey()&&(o=t.getStartOffset()),r===t.getEndKey()&&(a=t.getEndOffset());for(var i=o;i<=a;i++)e=e.union(n.getInlineStyleAt(i));return e},(0,a.Set)())},matchAll:function(e,t){for(var n=[],r=t.exec(e);null!==r;)n.push(r.concat([r.index])),r=t.exec(e);return n},getActiveEntity:l,isEntityActive:function(e,t){var n=l(e),r=e.getCurrentContent();if(n){var a=r.getEntity?r.getEntity(n):o.Entity.get(n);return a&&a.type===t}return!1}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(){var n=e.apply(void 0,arguments);return null===n||void 0===n?t.apply(void 0,arguments):n}}},function(e,t,n){"use strict";function r(e){var t=(0,o.Map)();return function(){var n=o.List.of.apply(o.List,arguments);return t.has(n)||(t=t.set(n,e.apply(void 0,arguments))),t.get(n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(3)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=n(3),a=function(e){return e&&e.__isMiddleware?e:function(t){return function(){if("object"===("undefined"==typeof e?"undefined":r(e))){var n=arguments.length<=0?void 0:arguments[0],a=void 0;if("string"==typeof n){var i=n;a=e[i]}else a=e[n.type];return null!==a&&void 0!==a?a:t.apply(void 0,arguments)}var s=void 0;try{var u=e.apply(void 0,arguments);if(null===u||void 0===u)s=t.apply(void 0,arguments);else if(2===arguments.length&&"string"==typeof(arguments.length<=1?void 0:arguments[1])&&(arguments.length<=1?void 0:arguments[1])===u)s=t.apply(void 0,arguments);else if(Array.isArray(u))s=u.concat(t.apply(void 0,arguments));else if(o.OrderedSet.isOrderedSet(u)){var l,d=(l=arguments.length-1,arguments.length<=l?void 0:arguments[l]);s=d.union(u).union(t.apply(void 0,arguments))}else s="function"==typeof u?e(t).apply(void 0,arguments):u}catch(n){s=e(t).apply(void 0,arguments)}finally{return s}}}};t.default=a},function(e,t,n){"use strict";function r(e){return e}function o(e,t,n){function o(e,t){var n=g.hasOwnProperty(t)?g[t]:null;O.hasOwnProperty(t)&&u("OVERRIDE_BASE"===n,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",t),e&&u("DEFINE_MANY"===n||"DEFINE_MANY_MERGED"===n,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",t)}function a(e,n){if(n){u("function"!=typeof n,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),u(!t(n),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var r=e.prototype,a=r.__reactAutoBindPairs;n.hasOwnProperty(l)&&b.mixins(e,n.mixins);for(var i in n)if(n.hasOwnProperty(i)&&i!==l){var s=n[i],d=r.hasOwnProperty(i);if(o(d,i),b.hasOwnProperty(i))b[i](e,s);else{var c=g.hasOwnProperty(i),y="function"==typeof s,h=y&&!c&&!d&&n.autobind!==!1;if(h)a.push(i,s),r[i]=s;else if(d){var m=g[i];u(c&&("DEFINE_MANY_MERGED"===m||"DEFINE_MANY"===m),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",m,i),"DEFINE_MANY_MERGED"===m?r[i]=f(r[i],s):"DEFINE_MANY"===m&&(r[i]=p(r[i],s))}else r[i]=s}}}else;}function d(e,t){if(t)for(var n in t){var r=t[n];if(t.hasOwnProperty(n)){var o=n in b;u(!o,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',n);var a=n in e;u(!a,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",n),e[n]=r}}}function c(e,t){u(e&&t&&"object"==typeof e&&"object"==typeof t,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var n in t)t.hasOwnProperty(n)&&(u(void 0===e[n],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",n),e[n]=t[n]);return e}function f(e,t){return function(){var n=e.apply(this,arguments),r=t.apply(this,arguments);if(null==n)return r;if(null==r)return n;var o={};return c(o,n),c(o,r),o}}function p(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function y(e,t){var n=t.bind(e);return n}function h(e){for(var t=e.__reactAutoBindPairs,n=0;n<t.length;n+=2){var r=t[n],o=t[n+1];e[r]=y(e,o)}}function m(e){var t=r(function(e,r,o){this.__reactAutoBindPairs.length&&h(this),this.props=e,this.context=r,this.refs=s,this.updater=o||n,this.state=null;var a=this.getInitialState?this.getInitialState():null;u("object"==typeof a&&!Array.isArray(a),"%s.getInitialState(): must return an object or null",t.displayName||"ReactCompositeComponent"),this.state=a});t.prototype=new _,t.prototype.constructor=t,t.prototype.__reactAutoBindPairs=[],v.forEach(a.bind(null,t)),a(t,C),a(t,e),a(t,E),t.getDefaultProps&&(t.defaultProps=t.getDefaultProps()),u(t.prototype.render,"createClass(...): Class specification must implement a `render` method.");for(var o in g)t.prototype[o]||(t.prototype[o]=null);return t}var v=[],g={mixins:"DEFINE_MANY",statics:"DEFINE_MANY",propTypes:"DEFINE_MANY",contextTypes:"DEFINE_MANY",childContextTypes:"DEFINE_MANY",getDefaultProps:"DEFINE_MANY_MERGED",getInitialState:"DEFINE_MANY_MERGED",getChildContext:"DEFINE_MANY_MERGED",render:"DEFINE_ONCE",componentWillMount:"DEFINE_MANY",componentDidMount:"DEFINE_MANY",componentWillReceiveProps:"DEFINE_MANY",shouldComponentUpdate:"DEFINE_ONCE",componentWillUpdate:"DEFINE_MANY",componentDidUpdate:"DEFINE_MANY",componentWillUnmount:"DEFINE_MANY",updateComponent:"OVERRIDE_BASE"},b={displayName:function(e,t){e.displayName=t},mixins:function(e,t){if(t)for(var n=0;n<t.length;n++)a(e,t[n])},childContextTypes:function(e,t){e.childContextTypes=i({},e.childContextTypes,t)},contextTypes:function(e,t){e.contextTypes=i({},e.contextTypes,t)},getDefaultProps:function(e,t){e.getDefaultProps?e.getDefaultProps=f(e.getDefaultProps,t):e.getDefaultProps=t},propTypes:function(e,t){e.propTypes=i({},e.propTypes,t)},statics:function(e,t){d(e,t)},autobind:function(){}},C={componentDidMount:function(){this.__isMounted=!0}},E={componentWillUnmount:function(){this.__isMounted=!1}},O={replaceState:function(e,t){this.updater.enqueueReplaceState(this,e,t)},isMounted:function(){return!!this.__isMounted}},_=function(){};return i(_.prototype,e.prototype,O),m}var a,i=n(21),s=n(20),u=n(8),l="mixins";a={},e.exports=o},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";var r={};e.exports=r},function(e,t){/* | ||
object-assign | ||
(c) Sindre Sorhus | ||
@license MIT | ||
*/ | ||
"use strict";function n(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}var o=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=r()?Object.assign:function(e,t){for(var r,s,u=n(e),l=1;l<arguments.length;l++){r=Object(arguments[l]);for(var d in r)a.call(r,d)&&(u[d]=r[d]);if(o){s=o(r);for(var c=0;c<s.length;c++)i.call(r,s[c])&&(u[s[c]]=r[s[c]])}}return u}},function(e,t,n){"use strict";var r=n(19),o=n(8),a=n(23);e.exports=function(){function e(e,t,n,r,i,s){s!==a&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t){e.exports=r}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Immutable"),require("React"),require("Draft"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["Immutable","React","Draft","ReactDOM"],t):"object"==typeof exports?exports.DraftExtend=t(require("Immutable"),require("React"),require("Draft"),require("ReactDOM")):e.DraftExtend=t(e.Immutable,e.React,e.Draft,e.ReactDOM)}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.compose=t.pluginUtils=t.createPlugin=t.KeyCommandController=t.Toolbar=t.Editor=void 0;var o=n(8),a=r(o),i=n(10),u=r(i),s=n(4),l=r(s),d=n(11),c=r(d),f=n(12),y=r(f),p=n(6),h=r(p);t.Editor=a.default,t.Toolbar=u.default,t.KeyCommandController=l.default,t.createPlugin=c.default,t.pluginUtils=y.default,t.compose=h.default},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){e.exports=n(16)()},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),d=n(2),c=r(d),f=n(3),y=r(f),p=n(7),h=r(p),m=n(1),v=n(5),b={addKeyCommandListener:y.default.func,removeKeyCommandListener:y.default.func,handleKeyCommand:y.default.func},g=function(e){var t=function(t){function n(e){a(this,n);var t=i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.addKeyCommandListener=t.addKeyCommandListener.bind(t),t.removeKeyCommandListener=t.removeKeyCommandListener.bind(t),t.handleKeyCommand=t.handleKeyCommand.bind(t),t.focus=t.focus.bind(t),t.blur=t.blur.bind(t),t}return u(n,t),l(n,[{key:"componentWillMount",value:function(){this.keyCommandOverrides=(0,m.List)(this.props.keyCommandListeners),this.keyCommandListeners=(0,m.List)()}},{key:"componentDidMount",value:function(){var e=this,t=Object.keys(b),n=t.filter(function(t){return void 0!==e.props[t]}),r=0===n.length,o=n.length===t.length;(0,h.default)(r||o,"KeyCommandController: A KeyCommandController is receiving only some props ("+n.join(", ")+") necessary to defer to a parent key command controller."),o&&this.props.keyCommandListeners.forEach(function(t){e.props.addKeyCommandListener(t)})}},{key:"componentWillUnmount",value:function(){var e=this;this.props.removeKeyCommandListener&&this.props.keyCommandListeners.forEach(function(t){e.props.removeKeyCommandListener(t)})}},{key:"addKeyCommandListener",value:function e(t){var e=this.props.addKeyCommandListener;return e?void e(t):void(this.keyCommandListeners=this.keyCommandListeners.unshift(t))}},{key:"removeKeyCommandListener",value:function e(t){var e=this.props.removeKeyCommandListener;return e?void e(t):void(this.keyCommandListeners=this.keyCommandListeners.filterNot(function(e){return e===t}))}},{key:"handleKeyCommand",value:function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.props,o=r.editorState,a=r.onChange,e=r.handleKeyCommand;if(e)return e(t,n);var i=this.keyCommandListeners.concat(this.keyCommandOverrides).reduce(function(e,r){var o=e.state,i=e.hasChanged;if(i===!0)return{state:o,hasChanged:i};var u=r(o,t,n),s=u instanceof v.EditorState;return u===!0||s&&u!==o?s?(a(u),{state:u,hasChanged:!0}):{state:o,hasChanged:!0}:{state:o,hasChanged:i}},{state:o,hasChanged:!1});return i.hasChanged}},{key:"focus",value:function(){this.refs.editor.focus()}},{key:"blur",value:function(){this.refs.editor.blur()}},{key:"render",value:function(){var t=this.props,n=t.editorState,r=t.onChange,a=(t.keyCommandListeners,o(t,["editorState","onChange","keyCommandListeners"]));return c.default.createElement(e,s({},a,{ref:"editor",editorState:n,onChange:r,addKeyCommandListener:this.addKeyCommandListener,removeKeyCommandListener:this.removeKeyCommandListener,handleKeyCommand:this.handleKeyCommand}))}}]),n}(c.default.Component);return t.displayName="KeyCommandController("+e.displayName+")",t.propTypes=s({editorState:y.default.object,onChange:y.default.func,keyCommandListeners:y.default.arrayOf(y.default.func)},b),t.defaultProps={keyCommandListeners:[]},t};t.default=g},function(e,t){e.exports=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){if(0===t.length)return arguments.length<=0?void 0:arguments[0];var e=t[t.length-1],n=t.slice(0,-1);return n.reduceRight(function(e,t){return t(e)},e.apply(void 0,arguments))}}},function(e,t,n){"use strict";var r=function(e,t,n,r,o,a,i,u){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,r,o,a,i,u],d=0;s=new Error(t.replace(/%s/g,function(){return l[d++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}};e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),d=n(2),c=r(d),f=n(3),y=r(f),p=n(5),h=n(4),m=r(h),v=n(9),b=r(v),g={className:y.default.string,editorState:y.default.object,onChange:y.default.func,decorators:y.default.array,baseDecorator:y.default.func,styleMap:y.default.object,styleFn:y.default.func,buttons:y.default.array,overlays:y.default.array,blockRendererFn:y.default.func,blockStyleFn:y.default.func,keyBindingFn:y.default.func,addKeyCommandListener:y.default.func.isRequired,removeKeyCommandListener:y.default.func.isRequired,handleReturn:y.default.func,onEscape:y.default.func,onTab:y.default.func,onUpArrow:y.default.func,onDownArrow:y.default.func,readOnly:y.default.bool,showButtons:y.default.bool,renderTray:y.default.func},C=function(e){function t(e){a(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e)),r=e.baseDecorator,o=new r(e.decorators);return n.state={decorator:o,readOnly:!1},n.keyBindingFn=n.keyBindingFn.bind(n),n.handleReturn=n.handleReturn.bind(n),n.onEscape=n.onEscape.bind(n),n.onTab=n.onTab.bind(n),n.onUpArrow=n.onUpArrow.bind(n),n.onDownArrow=n.onDownArrow.bind(n),n.focus=n.focus.bind(n),n.blur=n.blur.bind(n),n.getOtherProps=n.getOtherProps.bind(n),n.getReadOnly=n.getReadOnly.bind(n),n.setReadOnly=n.setReadOnly.bind(n),n.getDecoratedState=n.getDecoratedState.bind(n),n}return u(t,e),l(t,[{key:"getChildContext",value:function(){return{getEditorState:this.getDecoratedState,getReadOnly:this.getReadOnly,setReadOnly:this.setReadOnly,onChange:this.props.onChange,focus:this.focus,blur:this.blur,editorRef:this.refs.editor}}},{key:"componentWillReceiveProps",value:function(e){if(e.decorators.length===this.state.decorator._decorators.length){var t=this.state.decorator._decorators.every(function(t,n){return t===e.decorators[n]});if(t)return}this.setState({decorator:new e.baseDecorator(e.decorators)})}},{key:"keyBindingFn",value:function(e){var t=this.props.keyBindingFn(e);return t?t:(0,p.getDefaultKeyBinding)(e)}},{key:"handleReturn",value:function(e,t){return this.props.handleReturn&&this.props.handleReturn(e,t)||this.props.handleKeyCommand("return",e)}},{key:"onEscape",value:function(e){return this.props.onEscape&&this.props.onEscape(e)||this.props.handleKeyCommand("escape",e)}},{key:"onTab",value:function(e){return this.props.onTab&&this.props.onTab(e)||this.props.handleKeyCommand("tab",e)}},{key:"onUpArrow",value:function(e){return this.props.onUpArrow&&this.props.onUpArrow(e)||this.props.handleKeyCommand("up-arrow",e)}},{key:"onDownArrow",value:function(e){return this.props.onDownArrow&&this.props.onDownArrow(e)||this.props.handleKeyCommand("down-arrow",e)}},{key:"focus",value:function(){this.refs.editor.focus()}},{key:"blur",value:function(){this.refs.editor.blur()}},{key:"getOtherProps",value:function(){var e=this,t=Object.keys(this.props),n=Object.keys(g),r=t.filter(function(e){return n.indexOf(e)===-1});return r.reduce(function(t,n){return t[n]=e.props[n],t},{})}},{key:"getReadOnly",value:function(){return this.state.readOnly||this.props.readOnly}},{key:"setReadOnly",value:function(e){this.setState({readOnly:e})}},{key:"getDecoratedState",value:function(){var e=this.props.editorState,t=this.state.decorator,n=e.getDecorator();return n&&n._decorators===t._decorators?e:p.EditorState.set(e,{decorator:t})}},{key:"renderTray",value:function e(){var e=this.props.renderTray;return"function"!=typeof e?null:e()}},{key:"renderPluginButtons",value:function(){var e=this,t=this.props,n=t.onChange,r=t.addKeyCommandListener,o=t.removeKeyCommandListener,a=t.showButtons;if(a===!1)return null;var i=this.getDecoratedState();return this.props.buttons.map(function(t,a){return c.default.createElement(t,s({},e.getOtherProps(),{key:"button-"+a,attachedToEditor:!0,editorState:i,onChange:n,addKeyCommandListener:r,removeKeyCommandListener:o}))})}},{key:"renderOverlays",value:function(){var e=this,t=this.props,n=t.onChange,r=t.addKeyCommandListener,o=t.removeKeyCommandListener,a=this.getDecoratedState();return this.props.overlays.map(function(t,i){return c.default.createElement(b.default,{key:i},c.default.createElement(t,s({},e.getOtherProps(),{editorState:a,onChange:n,addKeyCommandListener:r,removeKeyCommandListener:o})))})}},{key:"render",value:function(){var e=this.props,t=e.styleMap,n=e.styleFn,r=e.blockRendererFn,a=e.blockStyleFn,i=e.onChange,u=e.handleKeyCommand,l=o(e,["styleMap","styleFn","blockRendererFn","blockStyleFn","onChange","handleKeyCommand"]),d=this.getDecoratedState(),f="draft-extend "+this.props.className,y=this.getReadOnly();return c.default.createElement("div",{className:f},c.default.createElement("div",{className:"draft-extend-editor"},c.default.createElement(p.Editor,s({},l,{ref:"editor",editorState:d,readOnly:y,onChange:i,blockStyleFn:a,blockRendererFn:r,customStyleMap:t,customStyleFn:n,handleKeyCommand:u,keyBindingFn:this.keyBindingFn,handleReturn:this.handleReturn,onEscape:this.onEscape,onTab:this.onTab,onUpArrow:this.onUpArrow,onDownArrow:this.onDownArrow})),c.default.createElement("div",{className:"draft-extend-tray"},this.renderTray()),c.default.createElement("div",{className:"draft-extend-controls"},this.renderPluginButtons()),c.default.createElement("div",{className:"draft-extend-overlays"},this.renderOverlays())))}}]),t}(c.default.Component);C.propTypes=g,C.defaultProps={className:"",editorState:p.EditorState.createEmpty(),onChange:function(){},decorators:[],baseDecorator:p.CompositeDecorator,styleMap:{},styleFn:function(){},buttons:[],overlays:[],blockRendererFn:function(){},blockStyleFn:function(){},keyBindingFn:function(){},readOnly:!1,showButtons:!0},C.childContextTypes={getEditorState:y.default.func,getReadOnly:y.default.func,setReadOnly:y.default.func,onChange:y.default.func,focus:y.default.func,blur:y.default.func,editorRef:y.default.object},t.default=(0,m.default)(C)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(2),l=r(s),d=n(18),c=r(d),f=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e)),r=document.createElement("div");return document.body.appendChild(r),n.state={node:r},n}return i(t,e),u(t,[{key:"componentDidMount",value:function(){this.renderOverlay()}},{key:"componentDidUpdate",value:function(){this.renderOverlay()}},{key:"componentWillUnmount",value:function(){c.default.unmountComponentAtNode(this.state.node)}},{key:"renderOverlay",value:function(){var e=l.default.Children.only(this.props.children);c.default.render(e,this.state.node)}},{key:"render",value:function(){return null}}]),t}(l.default.Component);t.default=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),d=n(2),c=r(d),f=n(3),y=r(f),p=n(4),h=r(p),m=function(e){function t(e){a(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.getEditorState=n.getEditorState.bind(n),n}return u(t,e),l(t,[{key:"getChildContext",value:function(){return{getEditorState:this.getEditorState,onChange:this.props.onChange}}},{key:"getEditorState",value:function(){return this.props.editorState}},{key:"renderButtons",value:function(){var e=this.props,t=e.editorState,n=e.onChange,r=e.buttons,a=e.addKeyCommandListener,i=e.removeKeyCommandListener,u=o(e,["editorState","onChange","buttons","addKeyCommandListener","removeKeyCommandListener"]);return r.map(function(e,r){return c.default.createElement(e,s({},u,{key:"button-"+r,editorState:t,onChange:n,addKeyCommandListener:a,removeKeyCommandListener:i}))})}},{key:"render",value:function(){return c.default.createElement("ul",{className:"draft-extend-controls"},this.renderButtons())}}]),t}(c.default.Component);m.propTypes={editorState:y.default.object,onChange:y.default.func,buttons:y.default.array,addKeyCommandListener:y.default.func.isRequired,removeKeyCommandListener:y.default.func.isRequired},m.childContextTypes={getEditorState:y.default.func,onChange:y.default.func},t.default=(0,h.default)(m)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),d=r(l),c=n(3),f=r(c),y=n(1),p=n(14),h=r(p),m=n(6),v=r(m),b=n(13),g=r(b),C=n(15),O=r(C),k=function(){},_=[],w={},E=function(e){return function(){return e.apply(void 0,arguments)}};E.__isMiddleware=!0;var S=(0,h.default)(v.default),T=(0,h.default)(g.default),L=(0,h.default)(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return Object.assign.apply(Object,[{}].concat(t))}),j=(0,h.default)(function(e,t){return e.concat(t)}),K=(0,h.default)(function(e){return Array.isArray(e)?e:[e]}),M=(0,h.default)(function(e){return function(t,n){return e(t,n,(0,y.OrderedSet)())}}),P=(0,h.default)(O.default),R=function e(t){var n=t.displayName,r=void 0===n?"Plugin":n,l=t.decorators,c=void 0===l?_:l,y=t.buttons,p=void 0===y?_:y,h=t.overlays,m=void 0===h?_:h,v=t.styleMap,b=void 0===v?w:v,g=t.styleFn,C=void 0===g?k:g,O=t.blockRendererFn,R=void 0===O?k:O,F=t.blockStyleFn,x=void 0===F?k:F,A=t.keyBindingFn,B=void 0===A?k:A,D=t.keyCommandListener,U=void 0===D?k:D,N=t.htmlToStyle,q=void 0===N?E:N,H=t.htmlToBlock,I=void 0===H?E:H,W=t.htmlToEntity,V=void 0===W?E:W,z=t.textToEntity,Y=void 0===z?E:z,Z=t.styleToHTML,G=void 0===Z?E:Z,J=t.blockToHTML,Q=void 0===J?E:J,X=t.entityToHTML,$=void 0===X?E:X;return function(t){if(c=K(c),p=K(p),m=K(m),t.prototype&&t.prototype.isReactComponent){var n=function(e){function n(e){o(this,n);var t=a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.focus=t.focus.bind(t),t.blur=t.blur.bind(t),t}return i(n,e),s(n,[{key:"focus",value:function(){this.refs.child.focus&&this.refs.child.focus()}},{key:"blur",value:function(){this.refs.child.blur&&this.refs.child.blur()}},{key:"render",value:function(){var e=L(this.props.styleMap,b),n=T(this.props.styleFn,C),r=j(this.props.decorators,c),o=j(this.props.buttons,p),a=j(this.props.overlays,m),i=T(R,this.props.blockRendererFn),s=T(x,this.props.blockStyleFn),l=T(B,this.props.keyBindingFn),f=j(this.props.keyCommandListeners,K(U));return d.default.createElement(t,u({},this.props,{ref:"child",styleMap:e,styleFn:n,decorators:r,buttons:o,overlays:a,blockRendererFn:i,blockStyleFn:s,keyBindingFn:l,keyCommandListeners:f}))}}]),n}(d.default.Component);return n.displayName=r,n.propTypes={styleMap:f.default.object,styleFn:f.default.func,decorators:f.default.array,buttons:f.default.array,overlays:f.default.array,blockRendererFn:f.default.func,blockStyleFn:f.default.func,keyBindingFn:f.default.func,keyCommandListeners:f.default.arrayOf(f.default.func)},n.defaultProps={styleMap:w,styleFn:k,decorators:_,buttons:_,overlays:_,blockRendererFn:k,blockStyleFn:k,keyBindingFn:k,keyCommandListeners:_},n}return function(){for(var n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];if(1===r.length&&("string"==typeof r[0]||r[0].hasOwnProperty("_map")&&null!=r[0].getBlockMap))return t({htmlToStyle:q,htmlToBlock:I,htmlToEntity:V,textToEntity:Y,styleToHTML:G,blockToHTML:Q,entityToHTML:$}).apply(void 0,r);var a=r[0],i=S(P(M(q)),P(a.htmlToStyle));i.__isMiddleware=!0;var u=S(P(I),P(a.htmlToBlock));u.__isMiddleware=!0;var s=S(P(V),P(a.htmlToEntity));s.__isMiddleware=!0;var l=S(P(Y),P(a.textToEntity));l.__isMiddleware=!0;var d=S(P(G),P(a.styleToHTML));d.__isMiddleware=!0;var c=S(P(Q),P(a.blockToHTML));c.__isMiddleware=!0;var f=S(P($),P(a.entityToHTML));return f.__isMiddleware=!0,e({htmlToStyle:i,htmlToBlock:u,htmlToEntity:s,textToEntity:l,styleToHTML:d,blockToHTML:c,entityToHTML:f})(t)}}};t.default=R},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),a=n(1),i=n(7),u=r(i),s=function(e){return e.replace(/[a-z][A-Z]/g,function(e){return e[0]+"-"+e[1].toLowerCase()})},l=function(e){var t=e.getCurrentContent().getBlockForKey(e.getSelection().getStartKey());if(t)return t.getEntityAt(e.getSelection().getStartOffset())};t.default={camelCaseToHyphen:s,styleObjectToString:function(e){return Object.keys(e).map(function(t){return s(t)+": "+e[t]+";"}).join(" ").replace(/"/g,'\\"')},entityStrategy:function(e){return function(t,n,r){t.findEntityRanges(function(t){var n=t.getEntity();if(null===n)return!1;var a=r&&r.getEntity?r.getEntity(n):o.Entity.get(n);return a&&a.getType()===e},n)}},getEntitySelection:function(e,t){var n=[];return e.getCurrentContent().getBlocksAsArray().forEach(function(e){e.findEntityRanges(function(e){return e.getEntity()===t},function(t,r){n.push(o.SelectionState.createEmpty(e.getKey()).merge({anchorOffset:t,focusOffset:r,isBackward:!1,hasFocus:!0}))})}),(0,u.default)(1===n.length,"getEntitySelection: More than one range with the same entityKey. Please use unique entity instances"),n[0]},insertBlockAtCursor:function(e,t){var n=e.getCurrentContent(),r=e.getSelection(),i=o.Modifier.removeRange(n,r,"backward"),u=i.getSelectionAfter(),s=o.Modifier.splitBlock(i,u),l=s.getSelectionAfter(),d=o.Modifier.setBlockType(s,l,t.getType()),c=[t,new o.ContentBlock({key:(0,o.genKey)(),type:"unstyled",text:"",characterList:(0,a.List)()})],f=o.BlockMapBuilder.createFromArray(c),y=o.Modifier.replaceWithFragment(d,l,f),p=y.merge({selectionBefore:r,selectionAfter:y.getSelectionAfter().set("hasFocus",!0)});return o.EditorState.push(e,p,"insert-fragment")},getSelectedInlineStyles:function(e){var t=e.getSelection(),n=e.getCurrentContent(),r=n.getBlockMap().skipUntil(function(e,n){return n===t.getStartKey()}).takeUntil(function(e,r){return n.getKeyBefore(r)===t.getEndKey()});return r.reduce(function(e,n){var r=n.getKey(),o=0,a=n.getLength()-1;r===t.getStartKey()&&(o=t.getStartOffset()),r===t.getEndKey()&&(a=t.getEndOffset());for(var i=o;i<=a;i++)e=e.union(n.getInlineStyleAt(i));return e},(0,a.Set)())},matchAll:function(e,t){for(var n=[],r=t.exec(e);null!==r;)n.push(r.concat([r.index])),r=t.exec(e);return n},getActiveEntity:l,isEntityActive:function(e,t){var n=l(e),r=e.getCurrentContent();if(n){var a=r.getEntity?r.getEntity(n):o.Entity.get(n);return a&&a.type===t}return!1}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(){var n=e.apply(void 0,arguments);return null===n||void 0===n?t.apply(void 0,arguments):n}}},function(e,t,n){"use strict";function r(e){var t=(0,o.Map)();return function(){var n=o.List.of.apply(o.List,arguments);return t.has(n)||(t=t.set(n,e.apply(void 0,arguments))),t.get(n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=n(1),a=function(e){return e&&e.__isMiddleware?e:function(t){return function(){if("object"===("undefined"==typeof e?"undefined":r(e))){var n=arguments.length<=0?void 0:arguments[0],a=void 0;if("string"==typeof n){var i=n;a=e[i]}else a=e[n.type];return null!==a&&void 0!==a?a:t.apply(void 0,arguments)}var u=void 0;try{var s=e.apply(void 0,arguments);if(null===s||void 0===s)u=t.apply(void 0,arguments);else if(2===arguments.length&&"string"==typeof(arguments.length<=1?void 0:arguments[1])&&(arguments.length<=1?void 0:arguments[1])===s)u=t.apply(void 0,arguments);else if(Array.isArray(s))u=s.concat(t.apply(void 0,arguments));else if(o.OrderedSet.isOrderedSet(s)){var l,d=(l=arguments.length-1,arguments.length<=l?void 0:arguments[l]);u=d.union(s).union(t.apply(void 0,arguments))}else u="function"==typeof s?e(t).apply(void 0,arguments):s}catch(n){u=e(t).apply(void 0,arguments)}finally{return u}}}};t.default=a},function(e,t,n){"use strict";function r(){}function o(){}var a=n(17);o.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,o,i){if(i!==a){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:r};return n.PropTypes=n,n}},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t){e.exports=r}])}); |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
@@ -18,6 +20,2 @@ | ||
var _createReactClass = require('create-react-class'); | ||
var _createReactClass2 = _interopRequireDefault(_createReactClass); | ||
var _draftJs = require('draft-js'); | ||
@@ -37,2 +35,8 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var propTypes = { | ||
@@ -63,250 +67,309 @@ className: _propTypes2.default.string, | ||
var EditorWrapper = (0, _createReactClass2.default)({ | ||
displayName: 'EditorWrapper', | ||
var EditorWrapper = function (_React$Component) { | ||
_inherits(EditorWrapper, _React$Component); | ||
propTypes: propTypes, | ||
function EditorWrapper(props) { | ||
_classCallCheck(this, EditorWrapper); | ||
childContextTypes: { | ||
getEditorState: _propTypes2.default.func, | ||
getReadOnly: _propTypes2.default.func, | ||
setReadOnly: _propTypes2.default.func, | ||
onChange: _propTypes2.default.func, | ||
focus: _propTypes2.default.func, | ||
blur: _propTypes2.default.func, | ||
editorRef: _propTypes2.default.object | ||
}, | ||
var _this = _possibleConstructorReturn(this, (EditorWrapper.__proto__ || Object.getPrototypeOf(EditorWrapper)).call(this, props)); | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
className: '', | ||
editorState: _draftJs.EditorState.createEmpty(), | ||
onChange: function onChange() {}, | ||
decorators: [], | ||
baseDecorator: _draftJs.CompositeDecorator, | ||
styleMap: {}, | ||
styleFn: function styleFn() {}, | ||
buttons: [], | ||
overlays: [], | ||
blockRendererFn: function blockRendererFn() {}, | ||
blockStyleFn: function blockStyleFn() {}, | ||
keyBindingFn: function keyBindingFn() {}, | ||
readOnly: false, | ||
showButtons: true | ||
}; | ||
}, | ||
getInitialState: function getInitialState() { | ||
var baseDecorator = this.props.baseDecorator; | ||
var baseDecorator = props.baseDecorator; | ||
var decorator = new baseDecorator(this.props.decorators); | ||
return { | ||
var decorator = new baseDecorator(props.decorators); | ||
_this.state = { | ||
decorator: decorator, | ||
readOnly: false | ||
}; | ||
}, | ||
getChildContext: function getChildContext() { | ||
return { | ||
getEditorState: this.getDecoratedState, | ||
getReadOnly: this.getReadOnly, | ||
setReadOnly: this.setReadOnly, | ||
onChange: this.props.onChange, | ||
focus: this.focus, | ||
blur: this.blur, | ||
editorRef: this.refs.editor | ||
}; | ||
}, | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
if (nextProps.decorators.length === this.state.decorator._decorators.length) { | ||
var allDecoratorsMatch = this.state.decorator._decorators.every(function (decorator, i) { | ||
return decorator === nextProps.decorators[i]; | ||
_this.keyBindingFn = _this.keyBindingFn.bind(_this); | ||
_this.handleReturn = _this.handleReturn.bind(_this); | ||
_this.onEscape = _this.onEscape.bind(_this); | ||
_this.onTab = _this.onTab.bind(_this); | ||
_this.onUpArrow = _this.onUpArrow.bind(_this); | ||
_this.onDownArrow = _this.onDownArrow.bind(_this); | ||
_this.focus = _this.focus.bind(_this); | ||
_this.blur = _this.blur.bind(_this); | ||
_this.getOtherProps = _this.getOtherProps.bind(_this); | ||
_this.getReadOnly = _this.getReadOnly.bind(_this); | ||
_this.setReadOnly = _this.setReadOnly.bind(_this); | ||
_this.getDecoratedState = _this.getDecoratedState.bind(_this); | ||
return _this; | ||
} | ||
_createClass(EditorWrapper, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
getEditorState: this.getDecoratedState, | ||
getReadOnly: this.getReadOnly, | ||
setReadOnly: this.setReadOnly, | ||
onChange: this.props.onChange, | ||
focus: this.focus, | ||
blur: this.blur, | ||
editorRef: this.refs.editor | ||
}; | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (nextProps.decorators.length === this.state.decorator._decorators.length) { | ||
var allDecoratorsMatch = this.state.decorator._decorators.every(function (decorator, i) { | ||
return decorator === nextProps.decorators[i]; | ||
}); | ||
if (allDecoratorsMatch) { | ||
return; | ||
} | ||
} | ||
this.setState({ | ||
decorator: new nextProps.baseDecorator(nextProps.decorators) | ||
}); | ||
if (allDecoratorsMatch) { | ||
return; | ||
} | ||
}, { | ||
key: 'keyBindingFn', | ||
value: function keyBindingFn(e) { | ||
var pluginsCommand = this.props.keyBindingFn(e); | ||
if (pluginsCommand) { | ||
return pluginsCommand; | ||
} | ||
} | ||
this.setState({ decorator: new nextProps.baseDecorator(nextProps.decorators) }); | ||
}, | ||
keyBindingFn: function keyBindingFn(e) { | ||
var pluginsCommand = this.props.keyBindingFn(e); | ||
if (pluginsCommand) { | ||
return pluginsCommand; | ||
return (0, _draftJs.getDefaultKeyBinding)(e); | ||
} | ||
}, { | ||
key: 'handleReturn', | ||
value: function handleReturn(e, editorState) { | ||
return this.props.handleReturn && this.props.handleReturn(e, editorState) || this.props.handleKeyCommand('return', e); | ||
} | ||
}, { | ||
key: 'onEscape', | ||
value: function onEscape(e) { | ||
return this.props.onEscape && this.props.onEscape(e) || this.props.handleKeyCommand('escape', e); | ||
} | ||
}, { | ||
key: 'onTab', | ||
value: function onTab(e) { | ||
return this.props.onTab && this.props.onTab(e) || this.props.handleKeyCommand('tab', e); | ||
} | ||
}, { | ||
key: 'onUpArrow', | ||
value: function onUpArrow(e) { | ||
return this.props.onUpArrow && this.props.onUpArrow(e) || this.props.handleKeyCommand('up-arrow', e); | ||
} | ||
}, { | ||
key: 'onDownArrow', | ||
value: function onDownArrow(e) { | ||
return this.props.onDownArrow && this.props.onDownArrow(e) || this.props.handleKeyCommand('down-arrow', e); | ||
} | ||
}, { | ||
key: 'focus', | ||
value: function focus() { | ||
this.refs.editor.focus(); | ||
} | ||
}, { | ||
key: 'blur', | ||
value: function blur() { | ||
this.refs.editor.blur(); | ||
} | ||
}, { | ||
key: 'getOtherProps', | ||
value: function getOtherProps() { | ||
var _this2 = this; | ||
return (0, _draftJs.getDefaultKeyBinding)(e); | ||
}, | ||
handleReturn: function handleReturn(e, editorState) { | ||
return this.props.handleReturn && this.props.handleReturn(e, editorState) || this.props.handleKeyCommand('return', e); | ||
}, | ||
onEscape: function onEscape(e) { | ||
return this.props.onEscape && this.props.onEscape(e) || this.props.handleKeyCommand('escape', e); | ||
}, | ||
onTab: function onTab(e) { | ||
return this.props.onTab && this.props.onTab(e) || this.props.handleKeyCommand('tab', e); | ||
}, | ||
onUpArrow: function onUpArrow(e) { | ||
return this.props.onUpArrow && this.props.onUpArrow(e) || this.props.handleKeyCommand('up-arrow', e); | ||
}, | ||
onDownArrow: function onDownArrow(e) { | ||
return this.props.onDownArrow && this.props.onDownArrow(e) || this.props.handleKeyCommand('down-arrow', e); | ||
}, | ||
focus: function focus() { | ||
this.refs.editor.focus(); | ||
}, | ||
blur: function blur() { | ||
this.refs.editor.blur(); | ||
}, | ||
getOtherProps: function getOtherProps() { | ||
var _this = this; | ||
var propKeys = Object.keys(this.props); | ||
var propTypeKeys = Object.keys(propTypes); | ||
var propKeys = Object.keys(this.props); | ||
var propTypeKeys = Object.keys(propTypes); | ||
var propsToPass = propKeys.filter(function (prop) { | ||
return propTypeKeys.indexOf(prop) === -1; | ||
}); | ||
var propsToPass = propKeys.filter(function (prop) { | ||
return propTypeKeys.indexOf(prop) === -1; | ||
}); | ||
return propsToPass.reduce(function (acc, prop) { | ||
acc[prop] = _this2.props[prop]; | ||
return acc; | ||
}, {}); | ||
} | ||
}, { | ||
key: 'getReadOnly', | ||
value: function getReadOnly() { | ||
return this.state.readOnly || this.props.readOnly; | ||
} | ||
}, { | ||
key: 'setReadOnly', | ||
value: function setReadOnly(readOnly) { | ||
this.setState({ readOnly: readOnly }); | ||
} | ||
}, { | ||
key: 'getDecoratedState', | ||
value: function getDecoratedState() { | ||
var editorState = this.props.editorState; | ||
var decorator = this.state.decorator; | ||
return propsToPass.reduce(function (acc, prop) { | ||
acc[prop] = _this.props[prop]; | ||
return acc; | ||
}, {}); | ||
}, | ||
getReadOnly: function getReadOnly() { | ||
return this.state.readOnly || this.props.readOnly; | ||
}, | ||
setReadOnly: function setReadOnly(readOnly) { | ||
this.setState({ readOnly: readOnly }); | ||
}, | ||
getDecoratedState: function getDecoratedState() { | ||
var editorState = this.props.editorState; | ||
var decorator = this.state.decorator; | ||
var currentDecorator = editorState.getDecorator(); | ||
var currentDecorator = editorState.getDecorator(); | ||
if (currentDecorator && currentDecorator._decorators === decorator._decorators) { | ||
return editorState; | ||
} | ||
if (currentDecorator && currentDecorator._decorators === decorator._decorators) { | ||
return editorState; | ||
return _draftJs.EditorState.set(editorState, { decorator: decorator }); | ||
} | ||
}, { | ||
key: 'renderTray', | ||
value: function renderTray() { | ||
var renderTray = this.props.renderTray; | ||
return _draftJs.EditorState.set(editorState, { decorator: decorator }); | ||
}, | ||
renderTray: function renderTray() { | ||
var renderTray = this.props.renderTray; | ||
if (typeof renderTray !== 'function') { | ||
return null; | ||
} | ||
if (typeof renderTray !== 'function') { | ||
return null; | ||
return renderTray(); | ||
} | ||
}, { | ||
key: 'renderPluginButtons', | ||
value: function renderPluginButtons() { | ||
var _this3 = this; | ||
return renderTray(); | ||
}, | ||
renderPluginButtons: function renderPluginButtons() { | ||
var _this2 = this; | ||
var _props = this.props, | ||
onChange = _props.onChange, | ||
addKeyCommandListener = _props.addKeyCommandListener, | ||
removeKeyCommandListener = _props.removeKeyCommandListener, | ||
showButtons = _props.showButtons; | ||
var _props = this.props, | ||
onChange = _props.onChange, | ||
addKeyCommandListener = _props.addKeyCommandListener, | ||
removeKeyCommandListener = _props.removeKeyCommandListener, | ||
showButtons = _props.showButtons; | ||
if (showButtons === false) { | ||
return null; | ||
} | ||
if (showButtons === false) { | ||
return null; | ||
var decoratedState = this.getDecoratedState(); | ||
return this.props.buttons.map(function (Button, index) { | ||
return _react2.default.createElement(Button, _extends({}, _this3.getOtherProps(), { | ||
key: 'button-' + index, | ||
attachedToEditor: true, | ||
editorState: decoratedState, | ||
onChange: onChange, | ||
addKeyCommandListener: addKeyCommandListener, | ||
removeKeyCommandListener: removeKeyCommandListener | ||
})); | ||
}); | ||
} | ||
}, { | ||
key: 'renderOverlays', | ||
value: function renderOverlays() { | ||
var _this4 = this; | ||
var decoratedState = this.getDecoratedState(); | ||
var _props2 = this.props, | ||
onChange = _props2.onChange, | ||
addKeyCommandListener = _props2.addKeyCommandListener, | ||
removeKeyCommandListener = _props2.removeKeyCommandListener; | ||
return this.props.buttons.map(function (Button, index) { | ||
return _react2.default.createElement(Button, _extends({}, _this2.getOtherProps(), { | ||
key: 'button-' + index, | ||
attachedToEditor: true, | ||
editorState: decoratedState, | ||
onChange: onChange, | ||
addKeyCommandListener: addKeyCommandListener, | ||
removeKeyCommandListener: removeKeyCommandListener | ||
})); | ||
}); | ||
}, | ||
renderOverlays: function renderOverlays() { | ||
var _this3 = this; | ||
var _props2 = this.props, | ||
onChange = _props2.onChange, | ||
addKeyCommandListener = _props2.addKeyCommandListener, | ||
removeKeyCommandListener = _props2.removeKeyCommandListener; | ||
var decoratedState = this.getDecoratedState(); | ||
return this.props.overlays.map(function (Overlay, index) { | ||
return _react2.default.createElement( | ||
_OverlayWrapper2.default, | ||
{ key: index }, | ||
_react2.default.createElement(Overlay, _extends({}, _this4.getOtherProps(), { | ||
editorState: decoratedState, | ||
onChange: onChange, | ||
addKeyCommandListener: addKeyCommandListener, | ||
removeKeyCommandListener: removeKeyCommandListener | ||
})) | ||
); | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _props3 = this.props, | ||
styleMap = _props3.styleMap, | ||
styleFn = _props3.styleFn, | ||
blockRendererFn = _props3.blockRendererFn, | ||
blockStyleFn = _props3.blockStyleFn, | ||
onChange = _props3.onChange, | ||
handleKeyCommand = _props3.handleKeyCommand, | ||
otherProps = _objectWithoutProperties(_props3, ['styleMap', 'styleFn', 'blockRendererFn', 'blockStyleFn', 'onChange', 'handleKeyCommand']); | ||
var decoratedState = this.getDecoratedState(); | ||
var decoratedState = this.getDecoratedState(); | ||
var className = 'draft-extend ' + this.props.className; | ||
return this.props.overlays.map(function (Overlay, index) { | ||
var readOnly = this.getReadOnly(); | ||
return _react2.default.createElement( | ||
_OverlayWrapper2.default, | ||
{ key: index }, | ||
_react2.default.createElement(Overlay, _extends({}, _this3.getOtherProps(), { | ||
editorState: decoratedState, | ||
onChange: onChange, | ||
addKeyCommandListener: addKeyCommandListener, | ||
removeKeyCommandListener: removeKeyCommandListener | ||
})) | ||
); | ||
}); | ||
}, | ||
render: function render() { | ||
var _props3 = this.props, | ||
styleMap = _props3.styleMap, | ||
styleFn = _props3.styleFn, | ||
blockRendererFn = _props3.blockRendererFn, | ||
blockStyleFn = _props3.blockStyleFn, | ||
onChange = _props3.onChange, | ||
handleKeyCommand = _props3.handleKeyCommand, | ||
otherProps = _objectWithoutProperties(_props3, ['styleMap', 'styleFn', 'blockRendererFn', 'blockStyleFn', 'onChange', 'handleKeyCommand']); | ||
var decoratedState = this.getDecoratedState(); | ||
var className = 'draft-extend ' + this.props.className; | ||
var readOnly = this.getReadOnly(); | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: className }, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'draft-extend-editor' }, | ||
_react2.default.createElement(_draftJs.Editor, _extends({}, otherProps, { | ||
ref: 'editor', | ||
editorState: decoratedState, | ||
readOnly: readOnly, | ||
onChange: onChange, | ||
blockStyleFn: blockStyleFn, | ||
blockRendererFn: blockRendererFn, | ||
customStyleMap: styleMap, | ||
customStyleFn: styleFn, | ||
handleKeyCommand: handleKeyCommand, | ||
keyBindingFn: this.keyBindingFn, | ||
handleReturn: this.handleReturn, | ||
onEscape: this.onEscape, | ||
onTab: this.onTab, | ||
onUpArrow: this.onUpArrow, | ||
onDownArrow: this.onDownArrow | ||
})), | ||
{ className: className }, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'draft-extend-tray' }, | ||
this.renderTray() | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'draft-extend-controls' }, | ||
this.renderPluginButtons() | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'draft-extend-overlays' }, | ||
this.renderOverlays() | ||
{ className: 'draft-extend-editor' }, | ||
_react2.default.createElement(_draftJs.Editor, _extends({}, otherProps, { | ||
ref: 'editor', | ||
editorState: decoratedState, | ||
readOnly: readOnly, | ||
onChange: onChange, | ||
blockStyleFn: blockStyleFn, | ||
blockRendererFn: blockRendererFn, | ||
customStyleMap: styleMap, | ||
customStyleFn: styleFn, | ||
handleKeyCommand: handleKeyCommand, | ||
keyBindingFn: this.keyBindingFn, | ||
handleReturn: this.handleReturn, | ||
onEscape: this.onEscape, | ||
onTab: this.onTab, | ||
onUpArrow: this.onUpArrow, | ||
onDownArrow: this.onDownArrow | ||
})), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'draft-extend-tray' }, | ||
this.renderTray() | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'draft-extend-controls' }, | ||
this.renderPluginButtons() | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'draft-extend-overlays' }, | ||
this.renderOverlays() | ||
) | ||
) | ||
) | ||
); | ||
} | ||
}); | ||
); | ||
} | ||
}]); | ||
return EditorWrapper; | ||
}(_react2.default.Component); | ||
EditorWrapper.propTypes = propTypes; | ||
EditorWrapper.defaultProps = { | ||
className: '', | ||
editorState: _draftJs.EditorState.createEmpty(), | ||
onChange: function onChange() {}, | ||
decorators: [], | ||
baseDecorator: _draftJs.CompositeDecorator, | ||
styleMap: {}, | ||
styleFn: function styleFn() {}, | ||
buttons: [], | ||
overlays: [], | ||
blockRendererFn: function blockRendererFn() {}, | ||
blockStyleFn: function blockStyleFn() {}, | ||
keyBindingFn: function keyBindingFn() {}, | ||
readOnly: false, | ||
showButtons: true | ||
}; | ||
EditorWrapper.childContextTypes = { | ||
getEditorState: _propTypes2.default.func, | ||
getReadOnly: _propTypes2.default.func, | ||
setReadOnly: _propTypes2.default.func, | ||
onChange: _propTypes2.default.func, | ||
focus: _propTypes2.default.func, | ||
blur: _propTypes2.default.func, | ||
editorRef: _propTypes2.default.object | ||
}; | ||
exports.default = (0, _KeyCommandController2.default)(EditorWrapper); |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
@@ -18,6 +20,2 @@ | ||
var _createReactClass = require('create-react-class'); | ||
var _createReactClass2 = _interopRequireDefault(_createReactClass); | ||
var _invariant = require('invariant'); | ||
@@ -35,2 +33,8 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var providedProps = { | ||
@@ -43,145 +47,182 @@ addKeyCommandListener: _propTypes2.default.func, | ||
var KeyCommandController = function KeyCommandController(Component) { | ||
return (0, _createReactClass2.default)({ | ||
displayName: 'KeyCommandController(' + Component.displayName + ')', | ||
var KeyCommand = function (_React$Component) { | ||
_inherits(KeyCommand, _React$Component); | ||
propTypes: _extends({ | ||
editorState: _propTypes2.default.object, | ||
onChange: _propTypes2.default.func, | ||
keyCommandListeners: _propTypes2.default.arrayOf(_propTypes2.default.func) | ||
}, providedProps), | ||
function KeyCommand(props) { | ||
_classCallCheck(this, KeyCommand); | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
keyCommandListeners: [] | ||
}; | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
this.keyCommandOverrides = (0, _immutable.List)(this.props.keyCommandListeners); | ||
this.keyCommandListeners = (0, _immutable.List)(); | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
var _this = this; | ||
var _this = _possibleConstructorReturn(this, (KeyCommand.__proto__ || Object.getPrototypeOf(KeyCommand)).call(this, props)); | ||
// ensure valid props for deferral | ||
var propNames = Object.keys(providedProps); | ||
var presentProps = propNames.filter(function (propName) { | ||
return _this.props[propName] !== undefined; | ||
}); | ||
var nonePresent = presentProps.length === 0; | ||
var allPresent = presentProps.length === propNames.length; | ||
_this.addKeyCommandListener = _this.addKeyCommandListener.bind(_this); | ||
_this.removeKeyCommandListener = _this.removeKeyCommandListener.bind(_this); | ||
_this.handleKeyCommand = _this.handleKeyCommand.bind(_this); | ||
_this.focus = _this.focus.bind(_this); | ||
_this.blur = _this.blur.bind(_this); | ||
return _this; | ||
} | ||
(0, _invariant2.default)(nonePresent || allPresent, 'KeyCommandController: A KeyCommandController is receiving only some props (' + presentProps.join(', ') + ') necessary to defer to a parent key command controller.'); | ||
if (allPresent) { | ||
this.props.keyCommandListeners.forEach(function (listener) { | ||
_this.props.addKeyCommandListener(listener); | ||
}); | ||
_createClass(KeyCommand, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
this.keyCommandOverrides = (0, _immutable.List)(this.props.keyCommandListeners); | ||
this.keyCommandListeners = (0, _immutable.List)(); | ||
} | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
var _this2 = this; | ||
}, { | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
if (this.props.removeKeyCommandListener) { | ||
this.props.keyCommandListeners.forEach(function (listener) { | ||
_this2.props.removeKeyCommandListener(listener); | ||
// ensure valid props for deferral | ||
var propNames = Object.keys(providedProps); | ||
var presentProps = propNames.filter(function (propName) { | ||
return _this2.props[propName] !== undefined; | ||
}); | ||
} | ||
}, | ||
addKeyCommandListener: function addKeyCommandListener(listener) { | ||
var addKeyCommandListener = this.props.addKeyCommandListener; | ||
var nonePresent = presentProps.length === 0; | ||
var allPresent = presentProps.length === propNames.length; | ||
(0, _invariant2.default)(nonePresent || allPresent, 'KeyCommandController: A KeyCommandController is receiving only some props (' + presentProps.join(', ') + ') necessary to defer to a parent key command controller.'); | ||
if (addKeyCommandListener) { | ||
addKeyCommandListener(listener); | ||
return; | ||
if (allPresent) { | ||
this.props.keyCommandListeners.forEach(function (listener) { | ||
_this2.props.addKeyCommandListener(listener); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var _this3 = this; | ||
this.keyCommandListeners = this.keyCommandListeners.unshift(listener); | ||
}, | ||
removeKeyCommandListener: function removeKeyCommandListener(listener) { | ||
var removeKeyCommandListener = this.props.removeKeyCommandListener; | ||
if (this.props.removeKeyCommandListener) { | ||
this.props.keyCommandListeners.forEach(function (listener) { | ||
_this3.props.removeKeyCommandListener(listener); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: 'addKeyCommandListener', | ||
value: function addKeyCommandListener(listener) { | ||
var addKeyCommandListener = this.props.addKeyCommandListener; | ||
if (removeKeyCommandListener) { | ||
removeKeyCommandListener(listener); | ||
return; | ||
if (addKeyCommandListener) { | ||
addKeyCommandListener(listener); | ||
return; | ||
} | ||
this.keyCommandListeners = this.keyCommandListeners.unshift(listener); | ||
} | ||
}, { | ||
key: 'removeKeyCommandListener', | ||
value: function removeKeyCommandListener(listener) { | ||
var removeKeyCommandListener = this.props.removeKeyCommandListener; | ||
this.keyCommandListeners = this.keyCommandListeners.filterNot(function (l) { | ||
return l === listener; | ||
}); | ||
}, | ||
handleKeyCommand: function handleKeyCommand(command) { | ||
var keyboardEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var _props = this.props, | ||
editorState = _props.editorState, | ||
onChange = _props.onChange, | ||
handleKeyCommand = _props.handleKeyCommand; | ||
if (removeKeyCommandListener) { | ||
removeKeyCommandListener(listener); | ||
return; | ||
} | ||
if (handleKeyCommand) { | ||
return handleKeyCommand(command, keyboardEvent); | ||
this.keyCommandListeners = this.keyCommandListeners.filterNot(function (l) { | ||
return l === listener; | ||
}); | ||
} | ||
}, { | ||
key: 'handleKeyCommand', | ||
value: function handleKeyCommand(command) { | ||
var keyboardEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var _props = this.props, | ||
editorState = _props.editorState, | ||
onChange = _props.onChange, | ||
handleKeyCommand = _props.handleKeyCommand; | ||
var result = this.keyCommandListeners.concat(this.keyCommandOverrides).reduce(function (_ref, listener) { | ||
var state = _ref.state, | ||
hasChanged = _ref.hasChanged; | ||
if (hasChanged === true) { | ||
return { | ||
state: state, | ||
hasChanged: hasChanged | ||
}; | ||
if (handleKeyCommand) { | ||
return handleKeyCommand(command, keyboardEvent); | ||
} | ||
var listenerResult = listener(state, command, keyboardEvent); | ||
var isEditorState = listenerResult instanceof _draftJs.EditorState; | ||
var result = this.keyCommandListeners.concat(this.keyCommandOverrides).reduce(function (_ref, listener) { | ||
var state = _ref.state, | ||
hasChanged = _ref.hasChanged; | ||
if (listenerResult === true || isEditorState && listenerResult !== state) { | ||
if (isEditorState) { | ||
onChange(listenerResult); | ||
if (hasChanged === true) { | ||
return { | ||
state: listenerResult, | ||
state: state, | ||
hasChanged: hasChanged | ||
}; | ||
} | ||
var listenerResult = listener(state, command, keyboardEvent); | ||
var isEditorState = listenerResult instanceof _draftJs.EditorState; | ||
if (listenerResult === true || isEditorState && listenerResult !== state) { | ||
if (isEditorState) { | ||
onChange(listenerResult); | ||
return { | ||
state: listenerResult, | ||
hasChanged: true | ||
}; | ||
} | ||
return { | ||
state: state, | ||
hasChanged: true | ||
}; | ||
} | ||
return { | ||
state: state, | ||
hasChanged: true | ||
hasChanged: hasChanged | ||
}; | ||
} | ||
}, { state: editorState, hasChanged: false }); | ||
return { | ||
state: state, | ||
hasChanged: hasChanged | ||
}; | ||
}, { state: editorState, hasChanged: false }); | ||
return result.hasChanged; | ||
} | ||
}, { | ||
key: 'focus', | ||
value: function focus() { | ||
this.refs.editor.focus(); | ||
} | ||
}, { | ||
key: 'blur', | ||
value: function blur() { | ||
this.refs.editor.blur(); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _props2 = this.props, | ||
editorState = _props2.editorState, | ||
onChange = _props2.onChange, | ||
keyCommandListeners = _props2.keyCommandListeners, | ||
others = _objectWithoutProperties(_props2, ['editorState', 'onChange', 'keyCommandListeners']); | ||
return result.hasChanged; | ||
}, | ||
focus: function focus() { | ||
this.refs.editor.focus(); | ||
}, | ||
blur: function blur() { | ||
this.refs.editor.blur(); | ||
}, | ||
render: function render() { | ||
var _props2 = this.props, | ||
editorState = _props2.editorState, | ||
onChange = _props2.onChange, | ||
keyCommandListeners = _props2.keyCommandListeners, | ||
others = _objectWithoutProperties(_props2, ['editorState', 'onChange', 'keyCommandListeners']); | ||
return _react2.default.createElement(Component, _extends({}, others, { | ||
ref: 'editor', | ||
editorState: editorState, | ||
onChange: onChange, | ||
addKeyCommandListener: this.addKeyCommandListener, | ||
removeKeyCommandListener: this.removeKeyCommandListener, | ||
handleKeyCommand: this.handleKeyCommand | ||
})); | ||
} | ||
}]); | ||
return _react2.default.createElement(Component, _extends({}, others, { | ||
ref: 'editor', | ||
editorState: editorState, | ||
onChange: onChange, | ||
addKeyCommandListener: this.addKeyCommandListener, | ||
removeKeyCommandListener: this.removeKeyCommandListener, | ||
handleKeyCommand: this.handleKeyCommand | ||
})); | ||
} | ||
}); | ||
return KeyCommand; | ||
}(_react2.default.Component); | ||
KeyCommand.displayName = 'KeyCommandController(' + Component.displayName + ')'; | ||
KeyCommand.propTypes = _extends({ | ||
editorState: _propTypes2.default.object, | ||
onChange: _propTypes2.default.func, | ||
keyCommandListeners: _propTypes2.default.arrayOf(_propTypes2.default.func) | ||
}, providedProps); | ||
KeyCommand.defaultProps = { | ||
keyCommandListeners: [] | ||
}; | ||
return KeyCommand; | ||
}; | ||
exports.default = KeyCommandController; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
@@ -16,32 +18,56 @@ | ||
var _createReactClass = require('create-react-class'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _createReactClass2 = _interopRequireDefault(_createReactClass); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
exports.default = (0, _createReactClass2.default)({ | ||
displayName: 'OverlayWrapper', | ||
getInitialState: function getInitialState() { | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var OverlayWrapper = function (_React$Component) { | ||
_inherits(OverlayWrapper, _React$Component); | ||
function OverlayWrapper(props) { | ||
_classCallCheck(this, OverlayWrapper); | ||
var _this = _possibleConstructorReturn(this, (OverlayWrapper.__proto__ || Object.getPrototypeOf(OverlayWrapper)).call(this, props)); | ||
var node = document.createElement('div'); | ||
document.body.appendChild(node); | ||
return { node: node }; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
this.renderOverlay(); | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
this.renderOverlay(); | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
_reactDom2.default.unmountComponentAtNode(this.state.node); | ||
}, | ||
renderOverlay: function renderOverlay() { | ||
var child = _react2.default.Children.only(this.props.children); | ||
_reactDom2.default.render(child, this.state.node); | ||
}, | ||
render: function render() { | ||
return null; | ||
_this.state = { node: node }; | ||
return _this; | ||
} | ||
}); | ||
_createClass(OverlayWrapper, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.renderOverlay(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this.renderOverlay(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
_reactDom2.default.unmountComponentAtNode(this.state.node); | ||
} | ||
}, { | ||
key: 'renderOverlay', | ||
value: function renderOverlay() { | ||
var child = _react2.default.Children.only(this.props.children); | ||
_reactDom2.default.render(child, this.state.node); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return null; | ||
} | ||
}]); | ||
return OverlayWrapper; | ||
}(_react2.default.Component); | ||
exports.default = OverlayWrapper; |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
@@ -18,6 +20,2 @@ | ||
var _createReactClass = require('create-react-class'); | ||
var _createReactClass2 = _interopRequireDefault(_createReactClass); | ||
var _KeyCommandController = require('./KeyCommandController'); | ||
@@ -31,55 +29,81 @@ | ||
var Toolbar = (0, _createReactClass2.default)({ | ||
displayName: 'Toolbar', | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
propTypes: { | ||
editorState: _propTypes2.default.object, | ||
onChange: _propTypes2.default.func, | ||
buttons: _propTypes2.default.array, | ||
addKeyCommandListener: _propTypes2.default.func.isRequired, | ||
removeKeyCommandListener: _propTypes2.default.func.isRequired | ||
}, | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
childContextTypes: { | ||
getEditorState: _propTypes2.default.func, | ||
onChange: _propTypes2.default.func | ||
}, | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
getChildContext: function getChildContext() { | ||
return { | ||
getEditorState: this.getEditorState, | ||
onChange: this.props.onChange | ||
}; | ||
}, | ||
getEditorState: function getEditorState() { | ||
return this.props.editorState; | ||
}, | ||
renderButtons: function renderButtons() { | ||
var _props = this.props, | ||
editorState = _props.editorState, | ||
onChange = _props.onChange, | ||
buttons = _props.buttons, | ||
addKeyCommandListener = _props.addKeyCommandListener, | ||
removeKeyCommandListener = _props.removeKeyCommandListener, | ||
otherProps = _objectWithoutProperties(_props, ['editorState', 'onChange', 'buttons', 'addKeyCommandListener', 'removeKeyCommandListener']); | ||
var Toolbar = function (_React$Component) { | ||
_inherits(Toolbar, _React$Component); | ||
return buttons.map(function (Button, index) { | ||
return _react2.default.createElement(Button, _extends({}, otherProps, { | ||
key: 'button-' + index, | ||
editorState: editorState, | ||
onChange: onChange, | ||
addKeyCommandListener: addKeyCommandListener, | ||
removeKeyCommandListener: removeKeyCommandListener | ||
})); | ||
}); | ||
}, | ||
render: function render() { | ||
return _react2.default.createElement( | ||
'ul', | ||
{ className: 'draft-extend-controls' }, | ||
this.renderButtons() | ||
); | ||
function Toolbar(props) { | ||
_classCallCheck(this, Toolbar); | ||
var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, props)); | ||
_this.getEditorState = _this.getEditorState.bind(_this); | ||
return _this; | ||
} | ||
}); | ||
_createClass(Toolbar, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
getEditorState: this.getEditorState, | ||
onChange: this.props.onChange | ||
}; | ||
} | ||
}, { | ||
key: 'getEditorState', | ||
value: function getEditorState() { | ||
return this.props.editorState; | ||
} | ||
}, { | ||
key: 'renderButtons', | ||
value: function renderButtons() { | ||
var _props = this.props, | ||
editorState = _props.editorState, | ||
onChange = _props.onChange, | ||
buttons = _props.buttons, | ||
addKeyCommandListener = _props.addKeyCommandListener, | ||
removeKeyCommandListener = _props.removeKeyCommandListener, | ||
otherProps = _objectWithoutProperties(_props, ['editorState', 'onChange', 'buttons', 'addKeyCommandListener', 'removeKeyCommandListener']); | ||
return buttons.map(function (Button, index) { | ||
return _react2.default.createElement(Button, _extends({}, otherProps, { | ||
key: 'button-' + index, | ||
editorState: editorState, | ||
onChange: onChange, | ||
addKeyCommandListener: addKeyCommandListener, | ||
removeKeyCommandListener: removeKeyCommandListener | ||
})); | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement( | ||
'ul', | ||
{ className: 'draft-extend-controls' }, | ||
this.renderButtons() | ||
); | ||
} | ||
}]); | ||
return Toolbar; | ||
}(_react2.default.Component); | ||
Toolbar.propTypes = { | ||
editorState: _propTypes2.default.object, | ||
onChange: _propTypes2.default.func, | ||
buttons: _propTypes2.default.array, | ||
addKeyCommandListener: _propTypes2.default.func.isRequired, | ||
removeKeyCommandListener: _propTypes2.default.func.isRequired | ||
}; | ||
Toolbar.childContextTypes = { | ||
getEditorState: _propTypes2.default.func, | ||
onChange: _propTypes2.default.func | ||
}; | ||
exports.default = (0, _KeyCommandController2.default)(Toolbar); |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
@@ -18,6 +20,2 @@ | ||
var _createReactClass = require('create-react-class'); | ||
var _createReactClass2 = _interopRequireDefault(_createReactClass); | ||
var _immutable = require('immutable'); | ||
@@ -43,2 +41,8 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var emptyFunction = function emptyFunction() {}; | ||
@@ -119,65 +123,87 @@ var emptyArray = []; | ||
// wrapping an Editor component | ||
return (0, _createReactClass2.default)({ | ||
displayName: displayName, | ||
var Plugin = function (_React$Component) { | ||
_inherits(Plugin, _React$Component); | ||
propTypes: { | ||
styleMap: _propTypes2.default.object, | ||
styleFn: _propTypes2.default.func, | ||
decorators: _propTypes2.default.array, | ||
buttons: _propTypes2.default.array, | ||
overlays: _propTypes2.default.array, | ||
blockRendererFn: _propTypes2.default.func, | ||
blockStyleFn: _propTypes2.default.func, | ||
keyBindingFn: _propTypes2.default.func, | ||
keyCommandListeners: _propTypes2.default.arrayOf(_propTypes2.default.func) | ||
}, | ||
function Plugin(props) { | ||
_classCallCheck(this, Plugin); | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
styleMap: emptyObject, | ||
styleFn: emptyFunction, | ||
decorators: emptyArray, | ||
buttons: emptyArray, | ||
overlays: emptyArray, | ||
blockRendererFn: emptyFunction, | ||
blockStyleFn: emptyFunction, | ||
keyBindingFn: emptyFunction, | ||
keyCommandListeners: emptyArray | ||
}; | ||
}, | ||
focus: function focus() { | ||
if (this.refs.child.focus) { | ||
this.refs.child.focus(); | ||
var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || Object.getPrototypeOf(Plugin)).call(this, props)); | ||
_this.focus = _this.focus.bind(_this); | ||
_this.blur = _this.blur.bind(_this); | ||
return _this; | ||
} | ||
_createClass(Plugin, [{ | ||
key: 'focus', | ||
value: function focus() { | ||
if (this.refs.child.focus) { | ||
this.refs.child.focus(); | ||
} | ||
} | ||
}, | ||
blur: function blur() { | ||
if (this.refs.child.blur) { | ||
this.refs.child.blur(); | ||
}, { | ||
key: 'blur', | ||
value: function blur() { | ||
if (this.refs.child.blur) { | ||
this.refs.child.blur(); | ||
} | ||
} | ||
}, | ||
render: function render() { | ||
var newStyleMap = memoizedAssign(this.props.styleMap, styleMap); | ||
var newStyleFn = memoizedAccumulateFunction(this.props.styleFn, styleFn); | ||
var newDecorators = memoizedConcat(this.props.decorators, decorators); | ||
var newButtons = memoizedConcat(this.props.buttons, buttons); | ||
var newOverlays = memoizedConcat(this.props.overlays, overlays); | ||
var newBlockRendererFn = memoizedAccumulateFunction(blockRendererFn, this.props.blockRendererFn); | ||
var newBlockStyleFn = memoizedAccumulateFunction(blockStyleFn, this.props.blockStyleFn); | ||
var newKeyBindingFn = memoizedAccumulateFunction(keyBindingFn, this.props.keyBindingFn); | ||
var newKeyCommandListeners = memoizedConcat(this.props.keyCommandListeners, memoizedCoerceArray(keyCommandListener)); | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var newStyleMap = memoizedAssign(this.props.styleMap, styleMap); | ||
var newStyleFn = memoizedAccumulateFunction(this.props.styleFn, styleFn); | ||
var newDecorators = memoizedConcat(this.props.decorators, decorators); | ||
var newButtons = memoizedConcat(this.props.buttons, buttons); | ||
var newOverlays = memoizedConcat(this.props.overlays, overlays); | ||
var newBlockRendererFn = memoizedAccumulateFunction(blockRendererFn, this.props.blockRendererFn); | ||
var newBlockStyleFn = memoizedAccumulateFunction(blockStyleFn, this.props.blockStyleFn); | ||
var newKeyBindingFn = memoizedAccumulateFunction(keyBindingFn, this.props.keyBindingFn); | ||
var newKeyCommandListeners = memoizedConcat(this.props.keyCommandListeners, memoizedCoerceArray(keyCommandListener)); | ||
return _react2.default.createElement(ToWrap, _extends({}, this.props, { | ||
ref: 'child', | ||
styleMap: newStyleMap, | ||
styleFn: newStyleFn, | ||
decorators: newDecorators, | ||
buttons: newButtons, | ||
overlays: newOverlays, | ||
blockRendererFn: newBlockRendererFn, | ||
blockStyleFn: newBlockStyleFn, | ||
keyBindingFn: newKeyBindingFn, | ||
keyCommandListeners: newKeyCommandListeners | ||
})); | ||
} | ||
}); | ||
return _react2.default.createElement(ToWrap, _extends({}, this.props, { | ||
ref: 'child', | ||
styleMap: newStyleMap, | ||
styleFn: newStyleFn, | ||
decorators: newDecorators, | ||
buttons: newButtons, | ||
overlays: newOverlays, | ||
blockRendererFn: newBlockRendererFn, | ||
blockStyleFn: newBlockStyleFn, | ||
keyBindingFn: newKeyBindingFn, | ||
keyCommandListeners: newKeyCommandListeners | ||
})); | ||
} | ||
}]); | ||
return Plugin; | ||
}(_react2.default.Component); | ||
Plugin.displayName = displayName; | ||
Plugin.propTypes = { | ||
styleMap: _propTypes2.default.object, | ||
styleFn: _propTypes2.default.func, | ||
decorators: _propTypes2.default.array, | ||
buttons: _propTypes2.default.array, | ||
overlays: _propTypes2.default.array, | ||
blockRendererFn: _propTypes2.default.func, | ||
blockStyleFn: _propTypes2.default.func, | ||
keyBindingFn: _propTypes2.default.func, | ||
keyCommandListeners: _propTypes2.default.arrayOf(_propTypes2.default.func) | ||
}; | ||
Plugin.defaultProps = { | ||
styleMap: emptyObject, | ||
styleFn: emptyFunction, | ||
decorators: emptyArray, | ||
buttons: emptyArray, | ||
overlays: emptyArray, | ||
blockRendererFn: emptyFunction, | ||
blockStyleFn: emptyFunction, | ||
keyBindingFn: emptyFunction, | ||
keyCommandListeners: emptyArray | ||
}; | ||
return Plugin; | ||
} else { | ||
@@ -184,0 +210,0 @@ // wrapping a converter function |
{ | ||
"name": "draft-extend", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "Build extensible Draft.js editors with configurable plugins and integrated serialization.", | ||
@@ -34,6 +34,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"create-react-class": "^15.6.2", | ||
"immutable": "^3.8.1", | ||
"invariant": "^2.2.1", | ||
"prop-types": "^15.6.0" | ||
"prop-types": "^15.7.2" | ||
}, | ||
@@ -48,4 +47,4 @@ "devDependencies": { | ||
"babel-standalone": "^6.7.7", | ||
"draft-convert": "^1.3.1", | ||
"draft-js": "^0.8.1", | ||
"draft-convert": "^2.1.4", | ||
"draft-js": "^0.10.5", | ||
"es6-shim": "^0.35.0", | ||
@@ -52,0 +51,0 @@ "react": "^16.2.0", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
200130
3401
- Removedcreate-react-class@^15.6.2
- Removedcreate-react-class@15.7.0(transitive)
Updatedprop-types@^15.7.2