draft-extend
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -158,3 +158,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
childContextTypes: { | ||
editorState: _react.PropTypes.instanceOf(_draftJs.EditorState), | ||
getEditorState: _react.PropTypes.func, | ||
onChange: _react.PropTypes.func | ||
@@ -186,3 +186,3 @@ }, | ||
return { | ||
editorState: this.getDecoratedState(), | ||
getEditorState: this.getDecoratedState, | ||
onChange: this.props.onChange | ||
@@ -189,0 +189,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!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.Editor=void 0;var o=n(4),i=r(o),a=n(6),s=r(a),u=n(7),c=r(u),l=n(8),d=r(l);t.Editor=i.default,t.createPlugin=s.default,t.pluginUtils=c.default,t.compose=d.default},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},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 i=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(2),s=r(a),u=n(1),c=n(3),l=n(5),d=r(l),f={className:a.PropTypes.string,editorState:a.PropTypes.object,onChange:a.PropTypes.func,decorators:a.PropTypes.array,styleMap:a.PropTypes.object,buttons:a.PropTypes.array,overlays:a.PropTypes.array,blockRendererFn:a.PropTypes.func,blockStyleFn:a.PropTypes.func,keyBindingFn:a.PropTypes.func,keyCommandListeners:a.PropTypes.arrayOf(a.PropTypes.func),handleReturn:a.PropTypes.func,onEscape:a.PropTypes.func,onTab:a.PropTypes.func,onUpArrow:a.PropTypes.func,onDownArrow:a.PropTypes.func};t.default=s.default.createClass({displayName:"Editor",propTypes:f,childContextTypes:{editorState:a.PropTypes.instanceOf(c.EditorState),onChange:a.PropTypes.func},getDefaultProps:function(){return{className:"",editorState:c.EditorState.createEmpty(),onChange:function(){},decorators:[],styleMap:{},buttons:[],overlays:[],blockRendererFn:function(){},blockStyleFn:function(){},keyBindingFn:function(){},keyCommandListeners:[]}},getInitialState:function(){var e=new c.CompositeDecorator(this.props.decorators);return{decorator:e}},getChildContext:function(){return{editorState:this.getDecoratedState(),onChange:this.props.onChange}},componentWillMount:function(){this.keyCommandListeners=(0,u.List)(this.props.keyCommandListeners)},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 c.CompositeDecorator(e.decorators)})},addKeyCommandListener:function(e){this.keyCommandListeners=this.keyCommandListeners.unshift(e)},removeKeyCommandListener:function(e){this.keyCommandListeners=this.keyCommandListeners.filterNot(function(t){return t===e})},keyBindingFn:function(e){var t=this.props.keyBindingFn(e);return t?t:(0,c.getDefaultKeyBinding)(e)},handleKeyCommand:function(e){var t=this,n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],r=this.getDecoratedState(),o=this.keyCommandListeners.reduce(function(r,o){var i=r.state,a=r.hasChanged;if(a===!0)return{state:i,hasChanged:a};var s=o(i,e,n),u=s instanceof c.EditorState;return s===!0||u&&s!==i?u?(t.props.onChange(s),{state:s,hasChanged:!0}):{state:i,hasChanged:!0}:{state:i,hasChanged:a}},{state:r,hasChanged:!1});return o.hasChanged},handleReturn:function(e){return this.props.handleReturn&&this.props.handleReturn(e)||this.handleKeyCommand("return",e)},onEscape:function(e){return this.props.onEscape&&this.props.onEscape(e)||this.handleKeyCommand("escape",e)},onTab:function(e){return this.props.onTab&&this.props.onTab(e)||this.handleKeyCommand("tab",e)},onUpArrow:function(e){return this.props.onUpArrow&&this.props.onUpArrow(e)||this.handleKeyCommand("up-arrow",e)},onDownArrow:function(e){return this.props.onDownArrow&&this.props.onDownArrow(e)||this.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(f),r=t.filter(function(e){return n.indexOf(e)===-1});return r.reduce(function(t,n){return t[n]=e.props[n],t},{})},getDecoratedState:function(){var e=this.props.editorState,t=this.state.decorator,n=e.getDecorator();return n&&n._decorators===t._decorators?e:c.EditorState.set(e,{decorator:t})},renderPluginButtons:function(){var e=this,t=this.getDecoratedState();return this.props.buttons.map(function(n,r){return s.default.createElement("li",{key:"button-"+r},s.default.createElement(n,i({},e.getOtherProps(),{editorState:t,onChange:e.props.onChange,addKeyCommandListener:e.addKeyCommandListener,removeKeyCommandListener:e.removeKeyCommandListener})))})},renderOverlays:function(){var e=this,t=this.getDecoratedState();return this.props.overlays.map(function(n){return s.default.createElement(d.default,null,s.default.createElement(n,i({},e.getOtherProps(),{editorState:t,onChange:e.props.onChange,addKeyCommandListener:e.addKeyCommandListener,removeKeyCommandListener:e.removeKeyCommandListener})))})},render:function(){var e=this.props,t=e.styleMap,n=e.blockRendererFn,r=e.blockStyleFn,a=e.onChange,u=o(e,["styleMap","blockRendererFn","blockStyleFn","onChange"]),l=this.getDecoratedState(),d="draft-extend "+this.props.className;return s.default.createElement("div",{className:d},s.default.createElement("ul",{className:"draft-extend-controls"},this.renderPluginButtons()),s.default.createElement("div",{className:"draft-extend-editor"},s.default.createElement(c.Editor,i({},u,{ref:"editor",editorState:l,onChange:a,blockStyleFn:r,blockRendererFn:n,customStyleMap:t,keyBindingFn:this.keyBindingFn,handleKeyCommand:this.handleKeyCommand,handleReturn:this.handleReturn,onEscape:this.onEscape,onTab:this.onTab,onUpArrow:this.onUpArrow,onDownArrow:this.onDownArrow})),s.default.createElement("div",{className:"draft-extend-overlays"},this.renderOverlays())))}})},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(2),i=r(o),a=n(11),s=r(a);t.default=i.default.createClass({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=i.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}}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i=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(2),s=r(a),u=n(9),c=r(u),l=function(){},d=[],f={},p=function(e,t,n){return n},y=function(e,t,n){},h=function(e,t){},m=function(e){return[]},g=function(e,t){return t},v=function(e,t){return function(){var n=t.apply(void 0,arguments);return null===n||void 0===n?e.apply(void 0,arguments):n}},b=(0,c.default)(v),T=(0,c.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))}),C=(0,c.default)(function(e,t){return e.concat(t)}),k=(0,c.default)(function(e){return Array.isArray(e)?e:[e]}),S=function E(e){var t=e.displayName,n=void 0===t?"Plugin":t,r=e.decorators,u=void 0===r?d:r,c=e.buttons,v=void 0===c?d:c,S=e.overlays,P=void 0===S?d:S,M=e.styleMap,O=void 0===M?f:M,L=e.blockRendererFn,w=void 0===L?l:L,F=e.blockStyleFn,x=void 0===F?l:F,A=e.keyBindingFn,B=void 0===A?l:A,D=e.keyCommandListener,K=void 0===D?l:D,R=e.htmlToStyle,_=void 0===R?p:R,j=e.htmlToBlock,H=void 0===j?y:j,N=e.htmlToEntity,U=void 0===N?h:N,q=e.textToEntity,I=void 0===q?m:q,W=e.styleToHTML,z=void 0===W?f:W,V=e.blockToHTML,Z=void 0===V?f:V,G=e.entityToHTML,J=void 0===G?g:G;return function(e){return u=k(u),v=k(v),P=k(P),e.prototype&&e.prototype.isReactComponent?s.default.createClass({displayName:n,propTypes:{styleMap:a.PropTypes.object,decorators:a.PropTypes.array,buttons:a.PropTypes.array,overlays:a.PropTypes.array,blockRendererFn:a.PropTypes.func,blockStyleFn:a.PropTypes.func,keyBindingFn:a.PropTypes.func,keyCommandListeners:a.PropTypes.arrayOf(a.PropTypes.func)},getDefaultProps:function(){return{styleMap:f,decorators:d,buttons:d,overlays:d,blockRendererFn:l,blockStyleFn:l,keyBindingFn:l,keyCommandListeners:d}},focus:function(){this.refs.child.focus&&this.refs.child.focus()},blur:function(){this.refs.child.blur&&this.refs.child.blur()},render:function(){var t=T(this.props.styleMap,O),n=C(this.props.decorators,u),r=C(this.props.buttons,v),o=C(this.props.overlays,P),a=b(this.props.blockRendererFn,w),c=b(this.props.blockStyleFn,x),l=b(this.props.keyBindingFn,B),d=C(this.props.keyCommandListeners,k(K));return s.default.createElement(e,i({},this.props,{ref:"child",styleMap:t,decorators:n,buttons:r,overlays:o,blockRendererFn:a,blockStyleFn:c,keyBindingFn:l,keyCommandListeners:d}))}}):function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1===n.length&&("string"==typeof n[0]||n[0].hasOwnProperty("_map")&&null!=n[0].getBlockMap))return e({htmlToStyle:_,htmlToBlock:H,htmlToEntity:U,textToEntity:I,styleToHTML:z,blockToHTML:Z,entityToHTML:J}).apply(void 0,n);var i=function(){var t=n[0],r=function(e,n,r){var o=t.htmlToStyle(e,n,r);return _(e,n,o)},o=function(e,n,r){return t.htmlToBlock(e,n,r)||H(e,n,r)},i=function(e,n){return t.htmlToEntity(e,n)||U(e,n)},a=function(e){return t.textToEntity(e).concat(I(e))},s=Object.assign({},t.styleToHTML,z),u=Object.assign({},t.blockToHTML,Z),c=function(e,n){var r=t.entityToHTML(e,n);return J(e,r)};return{v:E({htmlToStyle:r,htmlToBlock:o,htmlToEntity:i,textToEntity:a,styleToHTML:s,blockToHTML:u,entityToHTML:c})(e)}}();return"object"===("undefined"==typeof i?"undefined":o(i))?i.v:void 0}}};t.default=S},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(3),i=n(1),a=n(10),s=r(a),u=function(e){return e.replace(/[a-z][A-Z]/g,function(e){return e[0]+"-"+e[1].toLowerCase()})},c=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(/"/,'\\"')},entityStrategy:function(e){return function(t,n){t.findEntityRanges(function(t){var n=t.getEntity();return null!==n&&o.Entity.get(n).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(),a=o.Modifier.removeRange(n,r,"backward"),s=a.getSelectionAfter(),u=o.Modifier.splitBlock(a,s),c=u.getSelectionAfter(),l=o.Modifier.setBlockType(u,c,t.getType()),d=[t,new o.ContentBlock({key:(0,o.genKey)(),type:"unstyled",text:"",characterList:(0,i.List)()})],f=o.BlockMapBuilder.createFromArray(d),p=o.Modifier.replaceWithFragment(l,c,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,i=n.getLength()-1;r===t.getStartKey()&&(o=t.getStartOffset()),r===t.getEndKey()&&(i=t.getEndOffset());for(var a=o;a<=i;a++)e=e.union(n.getInlineStyleAt(a));return e},(0,i.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:c,isEntityActive:function(e,t){var n=c(e);if(n){var r=o.Entity.get(n);return r&&r.type===t}return!1}}},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){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";var r=function(e,t,n,r,o,i,a,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 c=[n,r,o,i,a,s],l=0;u=new Error(t.replace(/%s/g,function(){return c[l++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}};e.exports=r},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.Editor=void 0;var o=n(4),i=r(o),a=n(6),s=r(a),u=n(7),c=r(u),l=n(8),d=r(l);t.Editor=i.default,t.createPlugin=s.default,t.pluginUtils=c.default,t.compose=d.default},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},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 i=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(2),s=r(a),u=n(1),c=n(3),l=n(5),d=r(l),f={className:a.PropTypes.string,editorState:a.PropTypes.object,onChange:a.PropTypes.func,decorators:a.PropTypes.array,styleMap:a.PropTypes.object,buttons:a.PropTypes.array,overlays:a.PropTypes.array,blockRendererFn:a.PropTypes.func,blockStyleFn:a.PropTypes.func,keyBindingFn:a.PropTypes.func,keyCommandListeners:a.PropTypes.arrayOf(a.PropTypes.func),handleReturn:a.PropTypes.func,onEscape:a.PropTypes.func,onTab:a.PropTypes.func,onUpArrow:a.PropTypes.func,onDownArrow:a.PropTypes.func};t.default=s.default.createClass({displayName:"Editor",propTypes:f,childContextTypes:{getEditorState:a.PropTypes.func,onChange:a.PropTypes.func},getDefaultProps:function(){return{className:"",editorState:c.EditorState.createEmpty(),onChange:function(){},decorators:[],styleMap:{},buttons:[],overlays:[],blockRendererFn:function(){},blockStyleFn:function(){},keyBindingFn:function(){},keyCommandListeners:[]}},getInitialState:function(){var e=new c.CompositeDecorator(this.props.decorators);return{decorator:e}},getChildContext:function(){return{getEditorState:this.getDecoratedState,onChange:this.props.onChange}},componentWillMount:function(){this.keyCommandListeners=(0,u.List)(this.props.keyCommandListeners)},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 c.CompositeDecorator(e.decorators)})},addKeyCommandListener:function(e){this.keyCommandListeners=this.keyCommandListeners.unshift(e)},removeKeyCommandListener:function(e){this.keyCommandListeners=this.keyCommandListeners.filterNot(function(t){return t===e})},keyBindingFn:function(e){var t=this.props.keyBindingFn(e);return t?t:(0,c.getDefaultKeyBinding)(e)},handleKeyCommand:function(e){var t=this,n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],r=this.getDecoratedState(),o=this.keyCommandListeners.reduce(function(r,o){var i=r.state,a=r.hasChanged;if(a===!0)return{state:i,hasChanged:a};var s=o(i,e,n),u=s instanceof c.EditorState;return s===!0||u&&s!==i?u?(t.props.onChange(s),{state:s,hasChanged:!0}):{state:i,hasChanged:!0}:{state:i,hasChanged:a}},{state:r,hasChanged:!1});return o.hasChanged},handleReturn:function(e){return this.props.handleReturn&&this.props.handleReturn(e)||this.handleKeyCommand("return",e)},onEscape:function(e){return this.props.onEscape&&this.props.onEscape(e)||this.handleKeyCommand("escape",e)},onTab:function(e){return this.props.onTab&&this.props.onTab(e)||this.handleKeyCommand("tab",e)},onUpArrow:function(e){return this.props.onUpArrow&&this.props.onUpArrow(e)||this.handleKeyCommand("up-arrow",e)},onDownArrow:function(e){return this.props.onDownArrow&&this.props.onDownArrow(e)||this.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(f),r=t.filter(function(e){return n.indexOf(e)===-1});return r.reduce(function(t,n){return t[n]=e.props[n],t},{})},getDecoratedState:function(){var e=this.props.editorState,t=this.state.decorator,n=e.getDecorator();return n&&n._decorators===t._decorators?e:c.EditorState.set(e,{decorator:t})},renderPluginButtons:function(){var e=this,t=this.getDecoratedState();return this.props.buttons.map(function(n,r){return s.default.createElement("li",{key:"button-"+r},s.default.createElement(n,i({},e.getOtherProps(),{editorState:t,onChange:e.props.onChange,addKeyCommandListener:e.addKeyCommandListener,removeKeyCommandListener:e.removeKeyCommandListener})))})},renderOverlays:function(){var e=this,t=this.getDecoratedState();return this.props.overlays.map(function(n){return s.default.createElement(d.default,null,s.default.createElement(n,i({},e.getOtherProps(),{editorState:t,onChange:e.props.onChange,addKeyCommandListener:e.addKeyCommandListener,removeKeyCommandListener:e.removeKeyCommandListener})))})},render:function(){var e=this.props,t=e.styleMap,n=e.blockRendererFn,r=e.blockStyleFn,a=e.onChange,u=o(e,["styleMap","blockRendererFn","blockStyleFn","onChange"]),l=this.getDecoratedState(),d="draft-extend "+this.props.className;return s.default.createElement("div",{className:d},s.default.createElement("ul",{className:"draft-extend-controls"},this.renderPluginButtons()),s.default.createElement("div",{className:"draft-extend-editor"},s.default.createElement(c.Editor,i({},u,{ref:"editor",editorState:l,onChange:a,blockStyleFn:r,blockRendererFn:n,customStyleMap:t,keyBindingFn:this.keyBindingFn,handleKeyCommand:this.handleKeyCommand,handleReturn:this.handleReturn,onEscape:this.onEscape,onTab:this.onTab,onUpArrow:this.onUpArrow,onDownArrow:this.onDownArrow})),s.default.createElement("div",{className:"draft-extend-overlays"},this.renderOverlays())))}})},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(2),i=r(o),a=n(11),s=r(a);t.default=i.default.createClass({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=i.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}}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i=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(2),s=r(a),u=n(9),c=r(u),l=function(){},d=[],f={},p=function(e,t,n){return n},y=function(e,t,n){},h=function(e,t){},m=function(e){return[]},g=function(e,t){return t},v=function(e,t){return function(){var n=t.apply(void 0,arguments);return null===n||void 0===n?e.apply(void 0,arguments):n}},b=(0,c.default)(v),T=(0,c.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))}),C=(0,c.default)(function(e,t){return e.concat(t)}),k=(0,c.default)(function(e){return Array.isArray(e)?e:[e]}),S=function E(e){var t=e.displayName,n=void 0===t?"Plugin":t,r=e.decorators,u=void 0===r?d:r,c=e.buttons,v=void 0===c?d:c,S=e.overlays,P=void 0===S?d:S,M=e.styleMap,O=void 0===M?f:M,L=e.blockRendererFn,w=void 0===L?l:L,F=e.blockStyleFn,x=void 0===F?l:F,A=e.keyBindingFn,B=void 0===A?l:A,D=e.keyCommandListener,K=void 0===D?l:D,R=e.htmlToStyle,_=void 0===R?p:R,j=e.htmlToBlock,H=void 0===j?y:j,N=e.htmlToEntity,U=void 0===N?h:N,q=e.textToEntity,I=void 0===q?m:q,W=e.styleToHTML,z=void 0===W?f:W,V=e.blockToHTML,Z=void 0===V?f:V,G=e.entityToHTML,J=void 0===G?g:G;return function(e){return u=k(u),v=k(v),P=k(P),e.prototype&&e.prototype.isReactComponent?s.default.createClass({displayName:n,propTypes:{styleMap:a.PropTypes.object,decorators:a.PropTypes.array,buttons:a.PropTypes.array,overlays:a.PropTypes.array,blockRendererFn:a.PropTypes.func,blockStyleFn:a.PropTypes.func,keyBindingFn:a.PropTypes.func,keyCommandListeners:a.PropTypes.arrayOf(a.PropTypes.func)},getDefaultProps:function(){return{styleMap:f,decorators:d,buttons:d,overlays:d,blockRendererFn:l,blockStyleFn:l,keyBindingFn:l,keyCommandListeners:d}},focus:function(){this.refs.child.focus&&this.refs.child.focus()},blur:function(){this.refs.child.blur&&this.refs.child.blur()},render:function(){var t=T(this.props.styleMap,O),n=C(this.props.decorators,u),r=C(this.props.buttons,v),o=C(this.props.overlays,P),a=b(this.props.blockRendererFn,w),c=b(this.props.blockStyleFn,x),l=b(this.props.keyBindingFn,B),d=C(this.props.keyCommandListeners,k(K));return s.default.createElement(e,i({},this.props,{ref:"child",styleMap:t,decorators:n,buttons:r,overlays:o,blockRendererFn:a,blockStyleFn:c,keyBindingFn:l,keyCommandListeners:d}))}}):function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1===n.length&&("string"==typeof n[0]||n[0].hasOwnProperty("_map")&&null!=n[0].getBlockMap))return e({htmlToStyle:_,htmlToBlock:H,htmlToEntity:U,textToEntity:I,styleToHTML:z,blockToHTML:Z,entityToHTML:J}).apply(void 0,n);var i=function(){var t=n[0],r=function(e,n,r){var o=t.htmlToStyle(e,n,r);return _(e,n,o)},o=function(e,n,r){return t.htmlToBlock(e,n,r)||H(e,n,r)},i=function(e,n){return t.htmlToEntity(e,n)||U(e,n)},a=function(e){return t.textToEntity(e).concat(I(e))},s=Object.assign({},t.styleToHTML,z),u=Object.assign({},t.blockToHTML,Z),c=function(e,n){var r=t.entityToHTML(e,n);return J(e,r)};return{v:E({htmlToStyle:r,htmlToBlock:o,htmlToEntity:i,textToEntity:a,styleToHTML:s,blockToHTML:u,entityToHTML:c})(e)}}();return"object"===("undefined"==typeof i?"undefined":o(i))?i.v:void 0}}};t.default=S},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(3),i=n(1),a=n(10),s=r(a),u=function(e){return e.replace(/[a-z][A-Z]/g,function(e){return e[0]+"-"+e[1].toLowerCase()})},c=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(/"/,'\\"')},entityStrategy:function(e){return function(t,n){t.findEntityRanges(function(t){var n=t.getEntity();return null!==n&&o.Entity.get(n).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(),a=o.Modifier.removeRange(n,r,"backward"),s=a.getSelectionAfter(),u=o.Modifier.splitBlock(a,s),c=u.getSelectionAfter(),l=o.Modifier.setBlockType(u,c,t.getType()),d=[t,new o.ContentBlock({key:(0,o.genKey)(),type:"unstyled",text:"",characterList:(0,i.List)()})],f=o.BlockMapBuilder.createFromArray(d),p=o.Modifier.replaceWithFragment(l,c,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,i=n.getLength()-1;r===t.getStartKey()&&(o=t.getStartOffset()),r===t.getEndKey()&&(i=t.getEndOffset());for(var a=o;a<=i;a++)e=e.union(n.getInlineStyleAt(a));return e},(0,i.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:c,isEntityActive:function(e,t){var n=c(e);if(n){var r=o.Entity.get(n);return r&&r.type===t}return!1}}},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){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";var r=function(e,t,n,r,o,i,a,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 c=[n,r,o,i,a,s],l=0;u=new Error(t.replace(/%s/g,function(){return c[l++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}};e.exports=r},function(e,t){e.exports=r}])}); |
@@ -50,3 +50,3 @@ 'use strict'; | ||
childContextTypes: { | ||
editorState: _react.PropTypes.instanceOf(_draftJs.EditorState), | ||
getEditorState: _react.PropTypes.func, | ||
onChange: _react.PropTypes.func | ||
@@ -78,3 +78,3 @@ }, | ||
return { | ||
editorState: this.getDecoratedState(), | ||
getEditorState: this.getDecoratedState, | ||
onChange: this.props.onChange | ||
@@ -81,0 +81,0 @@ }; |
{ | ||
"name": "draft-extend", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Build extensible Draft.js editors with configurable plugins and integrated serialization.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
80989