Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

draft-extend

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draft-extend - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0-beta

lib/util/middlewareAdapter.js

311

dist/draft-extend.js

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["DraftExtend"] = factory(root["Immutable"], root["React"], root["Draft"], root["ReactDOM"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_13__) {
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_13__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -65,15 +65,15 @@ /******/ // The module cache

var _Editor = __webpack_require__(4);
var _Editor = __webpack_require__(5);
var _Editor2 = _interopRequireDefault(_Editor);
var _createPlugin = __webpack_require__(6);
var _createPlugin = __webpack_require__(7);
var _createPlugin2 = _interopRequireDefault(_createPlugin);
var _utils = __webpack_require__(7);
var _utils = __webpack_require__(8);
var _utils2 = _interopRequireDefault(_utils);
var _compose = __webpack_require__(10);
var _compose = __webpack_require__(3);

@@ -105,6 +105,35 @@ var _compose2 = _interopRequireDefault(_compose);

module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function () {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
return function () {
if (funcs.length === 0) {
return arguments.length <= 0 ? undefined : arguments[0];
}
var last = funcs[funcs.length - 1];
var rest = funcs.slice(0, -1);
return rest.reduceRight(function (composed, f) {
return f(composed);
}, last.apply(undefined, arguments));
};
};
/***/ },
/* 4 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {

@@ -126,5 +155,5 @@

var _draftJs = __webpack_require__(3);
var _draftJs = __webpack_require__(4);
var _OverlayWrapper = __webpack_require__(5);
var _OverlayWrapper = __webpack_require__(6);

@@ -418,3 +447,3 @@ var _OverlayWrapper2 = _interopRequireDefault(_OverlayWrapper);

/***/ },
/* 5 */
/* 6 */
/***/ function(module, exports, __webpack_require__) {

@@ -465,3 +494,3 @@

/***/ },
/* 6 */
/* 7 */
/***/ function(module, exports, __webpack_require__) {

@@ -475,4 +504,2 @@

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -484,14 +511,20 @@

var _memoize = __webpack_require__(11);
var _immutable = __webpack_require__(1);
var _memoize = __webpack_require__(10);
var _memoize2 = _interopRequireDefault(_memoize);
var _blockTypeObjectFunction = __webpack_require__(9);
var _compose = __webpack_require__(3);
var _blockTypeObjectFunction2 = _interopRequireDefault(_blockTypeObjectFunction);
var _compose2 = _interopRequireDefault(_compose);
var _accumulateFunction = __webpack_require__(8);
var _accumulateFunction = __webpack_require__(9);
var _accumulateFunction2 = _interopRequireDefault(_accumulateFunction);
var _middlewareAdapter = __webpack_require__(11);
var _middlewareAdapter2 = _interopRequireDefault(_middlewareAdapter);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -503,22 +536,10 @@

var defaultHTMLToStyle = function defaultHTMLToStyle(nodeName, node, currentStyle) {
return currentStyle;
var defaultMiddlewareFunction = function defaultMiddlewareFunction(next) {
return function () {
return next.apply(undefined, arguments);
};
};
var defaultHTMLToBlock = function defaultHTMLToBlock(nodeName, node, lastList) {
return undefined;
};
var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
return undefined;
};
var defaultTextToEntity = function defaultTextToEntity(text) {
return [];
};
var defaultBlockToHTML = function defaultBlockToHTML(block) {
return undefined;
};
var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
return originalText;
};
defaultMiddlewareFunction.__isMiddleware = true;
var memoizedBlockTypeObjectFunction = (0, _memoize2.default)(_blockTypeObjectFunction2.default);
var memoizedCompose = (0, _memoize2.default)(_compose2.default);
var memoizedAccumulateFunction = (0, _memoize2.default)(_accumulateFunction2.default);

@@ -538,2 +559,8 @@ var memoizedAssign = (0, _memoize2.default)(function () {

});
var memoizedPassEmptyStyles = (0, _memoize2.default)(function (func) {
return function (nodeName, node) {
return func(nodeName, node, (0, _immutable.OrderedSet)());
};
});
var memoizedMiddlewareAdapter = (0, _memoize2.default)(_middlewareAdapter2.default);

@@ -560,15 +587,15 @@ var createPlugin = function createPlugin(_ref) {

var _ref$htmlToStyle = _ref.htmlToStyle;
var htmlToStyle = _ref$htmlToStyle === undefined ? defaultHTMLToStyle : _ref$htmlToStyle;
var htmlToStyle = _ref$htmlToStyle === undefined ? defaultMiddlewareFunction : _ref$htmlToStyle;
var _ref$htmlToBlock = _ref.htmlToBlock;
var htmlToBlock = _ref$htmlToBlock === undefined ? defaultHTMLToBlock : _ref$htmlToBlock;
var htmlToBlock = _ref$htmlToBlock === undefined ? defaultMiddlewareFunction : _ref$htmlToBlock;
var _ref$htmlToEntity = _ref.htmlToEntity;
var htmlToEntity = _ref$htmlToEntity === undefined ? defaultHTMLToEntity : _ref$htmlToEntity;
var htmlToEntity = _ref$htmlToEntity === undefined ? defaultMiddlewareFunction : _ref$htmlToEntity;
var _ref$textToEntity = _ref.textToEntity;
var textToEntity = _ref$textToEntity === undefined ? defaultTextToEntity : _ref$textToEntity;
var textToEntity = _ref$textToEntity === undefined ? defaultMiddlewareFunction : _ref$textToEntity;
var _ref$styleToHTML = _ref.styleToHTML;
var styleToHTML = _ref$styleToHTML === undefined ? emptyObject : _ref$styleToHTML;
var styleToHTML = _ref$styleToHTML === undefined ? defaultMiddlewareFunction : _ref$styleToHTML;
var _ref$blockToHTML = _ref.blockToHTML;
var blockToHTML = _ref$blockToHTML === undefined ? defaultBlockToHTML : _ref$blockToHTML;
var blockToHTML = _ref$blockToHTML === undefined ? defaultMiddlewareFunction : _ref$blockToHTML;
var _ref$entityToHTML = _ref.entityToHTML;
var entityToHTML = _ref$entityToHTML === undefined ? defaultEntityToHTML : _ref$entityToHTML;
var entityToHTML = _ref$entityToHTML === undefined ? defaultMiddlewareFunction : _ref$entityToHTML;
return function (ToWrap) {

@@ -642,3 +669,2 @@ decorators = memoizedCoerceArray(decorators);

// wrapping a converter function
return function () {

@@ -651,3 +677,2 @@ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

// actively converting an HTML string/ContentState, so pass additional options to the next converter function.
return ToWrap({

@@ -663,45 +688,38 @@ htmlToStyle: htmlToStyle,

} else {
var _ret = function () {
// receiving a plugin to accumulate upon for a converter - accumulate
// options and return a new plugin wrapped around the passed one ready
// to take either another plugin or a string/ContentState
// receiving a plugin to accumulate upon for a converter - accumulate
// options and return a new plugin wrapped around the passed one ready
// to take either another plugin or a string/ContentState
var oldOptions = args[0];
var oldOptions = args[0];
var newHTMLToStyle = function newHTMLToStyle(nodeName, node, currentStyle) {
var acc = oldOptions.htmlToStyle(nodeName, node, currentStyle);
return htmlToStyle(nodeName, node, acc);
};
var newHTMLToStyle = memoizedCompose(memoizedMiddlewareAdapter(memoizedPassEmptyStyles(htmlToStyle)), memoizedMiddlewareAdapter(oldOptions.htmlToStyle));
newHTMLToStyle.__isMiddleware = true;
var newHTMLToBlock = memoizedAccumulateFunction(htmlToBlock, oldOptions.htmlToBlock);
var newHTMLToBlock = memoizedCompose(memoizedMiddlewareAdapter(htmlToBlock), memoizedMiddlewareAdapter(oldOptions.htmlToBlock));
newHTMLToBlock.__isMiddleware = true;
var newHTMLToEntity = memoizedAccumulateFunction(htmlToEntity, oldOptions.htmlToEntity);
var newHTMLToEntity = memoizedCompose(memoizedMiddlewareAdapter(htmlToEntity), memoizedMiddlewareAdapter(oldOptions.htmlToEntity));
newHTMLToEntity.__isMiddleware = true;
var newTextToEntity = function newTextToEntity(text) {
return oldOptions.textToEntity(text).concat(textToEntity(text));
};
var newTextToEntity = memoizedCompose(memoizedMiddlewareAdapter(textToEntity), memoizedMiddlewareAdapter(oldOptions.textToEntity));
newTextToEntity.__isMiddleware = true;
var newStyleToHTML = Object.assign({}, oldOptions.styleToHTML, styleToHTML);
var newStyleToHTML = memoizedCompose(memoizedMiddlewareAdapter(styleToHTML), memoizedMiddlewareAdapter(oldOptions.styleToHTML));
newStyleToHTML.__isMiddleware = true;
var newBlockToHTML = memoizedAccumulateFunction(memoizedBlockTypeObjectFunction(blockToHTML), memoizedBlockTypeObjectFunction(oldOptions.blockToHTML));
var newBlockToHTML = memoizedCompose(memoizedMiddlewareAdapter(blockToHTML), memoizedMiddlewareAdapter(oldOptions.blockToHTML));
newBlockToHTML.__isMiddleware = true;
var newEntityToHTML = function newEntityToHTML(entity, originalText) {
var acc = oldOptions.entityToHTML(entity, originalText);
return entityToHTML(entity, acc);
};
var newEntityToHTML = memoizedCompose(memoizedMiddlewareAdapter(entityToHTML), memoizedMiddlewareAdapter(oldOptions.entityToHTML));
newEntityToHTML.__isMiddleware = true;
return {
v: createPlugin({
htmlToStyle: newHTMLToStyle,
htmlToBlock: newHTMLToBlock,
htmlToEntity: newHTMLToEntity,
textToEntity: newTextToEntity,
styleToHTML: newStyleToHTML,
blockToHTML: newBlockToHTML,
entityToHTML: newEntityToHTML
})(ToWrap)
};
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
return createPlugin({
htmlToStyle: newHTMLToStyle,
htmlToBlock: newHTMLToBlock,
htmlToEntity: newHTMLToEntity,
textToEntity: newTextToEntity,
styleToHTML: newStyleToHTML,
blockToHTML: newBlockToHTML,
entityToHTML: newEntityToHTML
})(ToWrap);
}

@@ -716,3 +734,3 @@ };

/***/ },
/* 7 */
/* 8 */
/***/ function(module, exports, __webpack_require__) {

@@ -726,3 +744,3 @@

var _draftJs = __webpack_require__(3);
var _draftJs = __webpack_require__(4);

@@ -868,3 +886,3 @@ var _immutable = __webpack_require__(1);

/***/ },
/* 8 */
/* 9 */
/***/ function(module, exports) {

@@ -891,4 +909,4 @@

/***/ },
/* 9 */
/***/ function(module, exports) {
/* 10 */
/***/ function(module, exports, __webpack_require__) {

@@ -900,39 +918,18 @@ 'use strict';

});
exports.default = blockTypeObjectFunction;
function blockTypeObjectFunction(typeObject) {
if (typeof typeObject === 'function') {
return typeObject;
}
exports.default = memoize;
return function (block) {
return typeObject[block.type];
};
}
var _immutable = __webpack_require__(1);
/***/ },
/* 10 */
/***/ function(module, exports) {
// memoization higher-order function using Immutable.js.
// used to memoize accumulated options when rendering plugin wrapper components.
"use strict";
function memoize(func) {
var _cache = (0, _immutable.Map)();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function () {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
return function () {
if (funcs.length === 0) {
return arguments.length <= 0 ? undefined : arguments[0];
var argList = _immutable.List.of.apply(_immutable.List, arguments);
if (!_cache.has(argList)) {
_cache = _cache.set(argList, func.apply(undefined, arguments));
}
var last = funcs[funcs.length - 1];
var rest = funcs.slice(0, -1);
return rest.reduceRight(function (composed, f) {
return f(composed);
}, last.apply(undefined, arguments));
return _cache.get(argList);
};

@@ -950,21 +947,87 @@ };

});
exports.default = memoize;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _immutable = __webpack_require__(1);
// memoization higher-order function using Immutable.js.
// used to memoize accumulated options when rendering plugin wrapper components.
// function to handle previous techniques to convert to HTML, including
// plain objects with `{start, end}` values and non-HOF functions that return
// either a String or ReactElement
function memoize(func) {
var _cache = (0, _immutable.Map)();
var middlewareAdapter = function middlewareAdapter(middleware) {
if (middleware && middleware.__isMiddleware) {
return middleware;
}
return function (next) {
return function () {
if ((typeof middleware === 'undefined' ? 'undefined' : _typeof(middleware)) === 'object') {
// handle old blockToHTML objects
var block = arguments.length <= 0 ? undefined : arguments[0];
return function () {
var argList = _immutable.List.of.apply(_immutable.List, arguments);
if (!_cache.has(argList)) {
_cache = _cache.set(argList, func.apply(undefined, arguments));
}
return _cache.get(argList);
var objectResult = void 0;
if (typeof block === 'string') {
// handle case of inline style value
var style = block;
if (true) {
console.warn('styleToHTML: Use of plain objects to define HTML output is being deprecated. Please switch to using functions that return a {start, end} object or ReactElement.');
}
objectResult = middleware[style];
} else {
if (true) {
console.warn('blockToHTML: Use of plain objects to define HTML output is being deprecated. Please switch to using functions that return a {start, end} object or ReactElement.');
}
objectResult = middleware[block.type];
}
// check for inline style value instead of a raw block
if (objectResult !== null && objectResult !== undefined) {
return objectResult;
}
return next.apply(undefined, arguments);
}
var returnValue = void 0;
try {
// try immediately giving the function the content data in case it's a simple
// function that doesn't expect a `next` function
var nonMiddlewareResult = middleware.apply(undefined, arguments);
if (nonMiddlewareResult === null || nonMiddlewareResult === undefined) {
// the behavior for non-middleware functions is to delegate by returning
// `null` or `undefined`, so do delegation for them
returnValue = next.apply(undefined, arguments);
} else if (arguments.length === 2 && typeof (arguments.length <= 1 ? undefined : arguments[1]) === 'string' && (arguments.length <= 1 ? undefined : arguments[1]) === nonMiddlewareResult) {
// entityToHTML option returned `originalText`, i.e. no change was made
returnValue = next.apply(undefined, arguments);
} else if (Array.isArray(nonMiddlewareResult)) {
// returned an array from a textToEntity function, concat with next
returnValue = nonMiddlewareResult.concat(next.apply(undefined, arguments));
} else if (_immutable.OrderedSet.isOrderedSet(nonMiddlewareResult)) {
// returned an OrderedSet from htmlToStyle, pass to next as third argument
var previousStyles = arguments.length <= arguments.length - 1 + 0 ? undefined : arguments[arguments.length - 1 + 0];
returnValue = previousStyles.union(nonMiddlewareResult).union(next.apply(undefined, arguments));
} else if (typeof nonMiddlewareResult === 'function') {
// most middleware HOFs will return another function when invoked, so we
// can assume that it is one here
returnValue = middleware(next).apply(undefined, arguments);
} else {
// the function was a simple non-middleware function and
// returned a reasonable value, so return its result
returnValue = nonMiddlewareResult;
}
} catch (e) {
// it's possible that trying to use a middleware function like a simple non-
// middleware function will throw, so try it as a middleware HOF
returnValue = middleware(next).apply(undefined, arguments);
} finally {
return returnValue;
}
};
};
};
exports.default = middlewareAdapter;
/***/ },

@@ -971,0 +1034,0 @@ /* 12 */

@@ -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(10),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,readOnly:a.PropTypes.bool};t.default=s.default.createClass({displayName:"Editor",propTypes:f,childContextTypes:{getEditorState:a.PropTypes.func,getReadOnly:a.PropTypes.func,setReadOnly:a.PropTypes.func,onChange:a.PropTypes.func,focus:a.PropTypes.func,blur:a.PropTypes.func},getDefaultProps:function(){return{className:"",editorState:c.EditorState.createEmpty(),onChange:function(){},decorators:[],styleMap:{},buttons:[],overlays:[],blockRendererFn:function(){},blockStyleFn:function(){},keyBindingFn:function(){},keyCommandListeners:[],readOnly:!1}},getInitialState:function(){var e=new c.CompositeDecorator(this.props.decorators);return{decorator:e,readOnly:!1}},getChildContext:function(){return{getEditorState:this.getDecoratedState,getReadOnly:this.getReadOnly,setReadOnly:this.setReadOnly,onChange:this.props.onChange,focus:this.focus,blur:this.blur}},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},{})},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: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(n,i({},e.getOtherProps(),{addKeyCommandListener:e.addKeyCommandListener,editorState:t,key:"button"+r,onChange:e.props.onChange,removeKeyCommandListener:e.removeKeyCommandListener}))})},renderOverlays:function(){var e=this,t=this.getDecoratedState();return this.props.overlays.map(function(n,r){return s.default.createElement(d.default,{key:r},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,f=this.getReadOnly();return s.default.createElement("div",{className:d},s.default.createElement("div",{className:"draft-extend-editor"},s.default.createElement(c.Editor,i({},u,{ref:"editor",editorState:l,readOnly:f,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-controls"},this.renderPluginButtons()),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(13),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(11),c=r(u),l=n(9),d=r(l),f=n(8),p=r(f),y=function(){},h=[],m={},g=function(e,t,n){return n},v=function(e,t,n){},b=function(e,t){},T=function(e){return[]},C=function(e){},k=function(e,t){return t},O=(0,c.default)(d.default),S=(0,c.default)(p.default),P=(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))}),E=(0,c.default)(function(e,t){return e.concat(t)}),M=(0,c.default)(function(e){return Array.isArray(e)?e:[e]}),L=function R(e){var t=e.displayName,n=void 0===t?"Plugin":t,r=e.decorators,u=void 0===r?h:r,c=e.buttons,l=void 0===c?h:c,d=e.overlays,f=void 0===d?h:d,p=e.styleMap,L=void 0===p?m:p,w=e.blockRendererFn,F=void 0===w?y:w,x=e.blockStyleFn,_=void 0===x?y:x,A=e.keyBindingFn,B=void 0===A?y:A,D=e.keyCommandListener,K=void 0===D?y:D,j=e.htmlToStyle,H=void 0===j?g:j,N=e.htmlToBlock,U=void 0===N?v:N,q=e.htmlToEntity,I=void 0===q?b:q,W=e.textToEntity,z=void 0===W?T:W,V=e.styleToHTML,Z=void 0===V?m:V,G=e.blockToHTML,J=void 0===G?C:G,Q=e.entityToHTML,X=void 0===Q?k:Q;return function(e){return u=M(u),l=M(l),f=M(f),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:m,decorators:h,buttons:h,overlays:h,blockRendererFn:y,blockStyleFn:y,keyBindingFn:y,keyCommandListeners:h}},focus:function(){this.refs.child.focus&&this.refs.child.focus()},blur:function(){this.refs.child.blur&&this.refs.child.blur()},render:function(){var t=P(this.props.styleMap,L),n=E(this.props.decorators,u),r=E(this.props.buttons,l),o=E(this.props.overlays,f),a=S(F,this.props.blockRendererFn),c=S(_,this.props.blockStyleFn),d=S(B,this.props.keyBindingFn),p=E(this.props.keyCommandListeners,M(K));return s.default.createElement(e,i({},this.props,{ref:"child",styleMap:t,decorators:n,buttons:r,overlays:o,blockRendererFn:a,blockStyleFn:c,keyBindingFn:d,keyCommandListeners:p}))}}):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:H,htmlToBlock:U,htmlToEntity:I,textToEntity:z,styleToHTML:Z,blockToHTML:J,entityToHTML:X}).apply(void 0,n);var i=function(){var t=n[0],r=function(e,n,r){var o=t.htmlToStyle(e,n,r);return H(e,n,o)},o=S(U,t.htmlToBlock),i=S(I,t.htmlToEntity),a=function(e){return t.textToEntity(e).concat(z(e))},s=Object.assign({},t.styleToHTML,Z),u=S(O(J),O(t.blockToHTML)),c=function(e,n){var r=t.entityToHTML(e,n);return X(e,r)};return{v:R({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=L},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(12),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(/"/g,'\\"')},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(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){"use strict";function n(e){return"function"==typeof e?e:function(t){return e[t.type]}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=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){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(5),i=r(o),a=n(7),s=r(a),u=n(8),l=r(u),d=n(3),c=r(d);t.Editor=i.default,t.createPlugin=s.default,t.pluginUtils=l.default,t.compose=c.default},function(t,n){t.exports=e},function(e,n){e.exports=t},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){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),l=n(4),d=n(6),c=r(d),p={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,readOnly:a.PropTypes.bool};t.default=s.default.createClass({displayName:"Editor",propTypes:p,childContextTypes:{getEditorState:a.PropTypes.func,getReadOnly:a.PropTypes.func,setReadOnly:a.PropTypes.func,onChange:a.PropTypes.func,focus:a.PropTypes.func,blur:a.PropTypes.func},getDefaultProps:function(){return{className:"",editorState:l.EditorState.createEmpty(),onChange:function(){},decorators:[],styleMap:{},buttons:[],overlays:[],blockRendererFn:function(){},blockStyleFn:function(){},keyBindingFn:function(){},keyCommandListeners:[],readOnly:!1}},getInitialState:function(){var e=new l.CompositeDecorator(this.props.decorators);return{decorator:e,readOnly:!1}},getChildContext:function(){return{getEditorState:this.getDecoratedState,getReadOnly:this.getReadOnly,setReadOnly:this.setReadOnly,onChange:this.props.onChange,focus:this.focus,blur:this.blur}},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 l.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,l.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 l.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(p),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:l.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(n,i({},e.getOtherProps(),{addKeyCommandListener:e.addKeyCommandListener,editorState:t,key:"button"+r,onChange:e.props.onChange,removeKeyCommandListener:e.removeKeyCommandListener}))})},renderOverlays:function(){var e=this,t=this.getDecoratedState();return this.props.overlays.map(function(n,r){return s.default.createElement(c.default,{key:r},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"]),d=this.getDecoratedState(),c="draft-extend "+this.props.className,p=this.getReadOnly();return s.default.createElement("div",{className:c},s.default.createElement("div",{className:"draft-extend-editor"},s.default.createElement(l.Editor,i({},u,{ref:"editor",editorState:d,readOnly:p,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-controls"},this.renderPluginButtons()),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(13),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=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(2),a=r(i),s=n(1),u=n(10),l=r(u),d=n(3),c=r(d),p=n(9),f=r(p),y=n(11),h=r(y),m=function(){},v=[],g={},b=function(e){return function(){return e.apply(void 0,arguments)}};b.__isMiddleware=!0;var T=(0,l.default)(c.default),C=(0,l.default)(f.default),k=(0,l.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))}),S=(0,l.default)(function(e,t){return e.concat(t)}),O=(0,l.default)(function(e){return Array.isArray(e)?e:[e]}),M=(0,l.default)(function(e){return function(t,n){return e(t,n,(0,s.OrderedSet)())}}),P=(0,l.default)(h.default),E=function _(e){var t=e.displayName,n=void 0===t?"Plugin":t,r=e.decorators,s=void 0===r?v:r,u=e.buttons,l=void 0===u?v:u,d=e.overlays,c=void 0===d?v:d,p=e.styleMap,f=void 0===p?g:p,y=e.blockRendererFn,h=void 0===y?m:y,E=e.blockStyleFn,w=void 0===E?m:E,L=e.keyBindingFn,R=void 0===L?m:L,F=e.keyCommandListener,A=void 0===F?m:F,x=e.htmlToStyle,B=void 0===x?b:x,D=e.htmlToBlock,K=void 0===D?b:D,j=e.htmlToEntity,H=void 0===j?b:j,N=e.textToEntity,U=void 0===N?b:N,q=e.styleToHTML,I=void 0===q?b:q,W=e.blockToHTML,z=void 0===W?b:W,V=e.entityToHTML,Z=void 0===V?b:V;return function(e){return s=O(s),l=O(l),c=O(c),e.prototype&&e.prototype.isReactComponent?a.default.createClass({displayName:n,propTypes:{styleMap:i.PropTypes.object,decorators:i.PropTypes.array,buttons:i.PropTypes.array,overlays:i.PropTypes.array,blockRendererFn:i.PropTypes.func,blockStyleFn:i.PropTypes.func,keyBindingFn:i.PropTypes.func,keyCommandListeners:i.PropTypes.arrayOf(i.PropTypes.func)},getDefaultProps:function(){return{styleMap:g,decorators:v,buttons:v,overlays:v,blockRendererFn:m,blockStyleFn:m,keyBindingFn:m,keyCommandListeners:v}},focus:function(){this.refs.child.focus&&this.refs.child.focus()},blur:function(){this.refs.child.blur&&this.refs.child.blur()},render:function(){var t=k(this.props.styleMap,f),n=S(this.props.decorators,s),r=S(this.props.buttons,l),i=S(this.props.overlays,c),u=C(h,this.props.blockRendererFn),d=C(w,this.props.blockStyleFn),p=C(R,this.props.keyBindingFn),y=S(this.props.keyCommandListeners,O(A));return a.default.createElement(e,o({},this.props,{ref:"child",styleMap:t,decorators:n,buttons:r,overlays:i,blockRendererFn:u,blockStyleFn:d,keyBindingFn:p,keyCommandListeners:y}))}}):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:B,htmlToBlock:K,htmlToEntity:H,textToEntity:U,styleToHTML:I,blockToHTML:z,entityToHTML:Z}).apply(void 0,n);var o=n[0],i=T(P(M(B)),P(o.htmlToStyle));i.__isMiddleware=!0;var a=T(P(K),P(o.htmlToBlock));a.__isMiddleware=!0;var s=T(P(H),P(o.htmlToEntity));s.__isMiddleware=!0;var u=T(P(U),P(o.textToEntity));u.__isMiddleware=!0;var l=T(P(I),P(o.styleToHTML));l.__isMiddleware=!0;var d=T(P(z),P(o.blockToHTML));d.__isMiddleware=!0;var c=T(P(Z),P(o.entityToHTML));return c.__isMiddleware=!0,_({htmlToStyle:i,htmlToBlock:a,htmlToEntity:s,textToEntity:u,styleToHTML:l,blockToHTML:d,entityToHTML:c})(e)}}};t.default=E},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(4),i=n(1),a=n(12),s=r(a),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){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),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,i.List)()})],p=o.BlockMapBuilder.createFromArray(c),f=o.Modifier.replaceWithFragment(d,l,p),y=f.merge({selectionBefore:r,selectionAfter:f.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:l,isEntityActive:function(e,t){var n=l(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(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?"symbol":typeof e},o=n(1),i=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],i=void 0;if("string"==typeof n){var a=n;i=e[a]}else i=e[n.type];return null!==i&&void 0!==i?i: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=arguments.length<=arguments.length-1+0?void 0:arguments[arguments.length-1+0];s=l.union(u).union(t.apply(void 0,arguments))}else s="function"==typeof u?e(t).apply(void 0,arguments):u}catch(d){s=e(t).apply(void 0,arguments)}finally{return s}}}};t.default=i},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 l=[n,r,o,i,a,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){e.exports=r}])});

@@ -7,4 +7,2 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -16,2 +14,4 @@

var _immutable = require('immutable');
var _memoize = require('../util/memoize');

@@ -21,5 +21,5 @@

var _blockTypeObjectFunction = require('../util/blockTypeObjectFunction');
var _compose = require('../util/compose');
var _blockTypeObjectFunction2 = _interopRequireDefault(_blockTypeObjectFunction);
var _compose2 = _interopRequireDefault(_compose);

@@ -30,2 +30,6 @@ var _accumulateFunction = require('../util/accumulateFunction');

var _middlewareAdapter = require('../util/middlewareAdapter');
var _middlewareAdapter2 = _interopRequireDefault(_middlewareAdapter);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -37,22 +41,10 @@

var defaultHTMLToStyle = function defaultHTMLToStyle(nodeName, node, currentStyle) {
return currentStyle;
var defaultMiddlewareFunction = function defaultMiddlewareFunction(next) {
return function () {
return next.apply(undefined, arguments);
};
};
var defaultHTMLToBlock = function defaultHTMLToBlock(nodeName, node, lastList) {
return undefined;
};
var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
return undefined;
};
var defaultTextToEntity = function defaultTextToEntity(text) {
return [];
};
var defaultBlockToHTML = function defaultBlockToHTML(block) {
return undefined;
};
var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
return originalText;
};
defaultMiddlewareFunction.__isMiddleware = true;
var memoizedBlockTypeObjectFunction = (0, _memoize2.default)(_blockTypeObjectFunction2.default);
var memoizedCompose = (0, _memoize2.default)(_compose2.default);
var memoizedAccumulateFunction = (0, _memoize2.default)(_accumulateFunction2.default);

@@ -72,2 +64,8 @@ var memoizedAssign = (0, _memoize2.default)(function () {

});
var memoizedPassEmptyStyles = (0, _memoize2.default)(function (func) {
return function (nodeName, node) {
return func(nodeName, node, (0, _immutable.OrderedSet)());
};
});
var memoizedMiddlewareAdapter = (0, _memoize2.default)(_middlewareAdapter2.default);

@@ -94,15 +92,15 @@ var createPlugin = function createPlugin(_ref) {

var _ref$htmlToStyle = _ref.htmlToStyle;
var htmlToStyle = _ref$htmlToStyle === undefined ? defaultHTMLToStyle : _ref$htmlToStyle;
var htmlToStyle = _ref$htmlToStyle === undefined ? defaultMiddlewareFunction : _ref$htmlToStyle;
var _ref$htmlToBlock = _ref.htmlToBlock;
var htmlToBlock = _ref$htmlToBlock === undefined ? defaultHTMLToBlock : _ref$htmlToBlock;
var htmlToBlock = _ref$htmlToBlock === undefined ? defaultMiddlewareFunction : _ref$htmlToBlock;
var _ref$htmlToEntity = _ref.htmlToEntity;
var htmlToEntity = _ref$htmlToEntity === undefined ? defaultHTMLToEntity : _ref$htmlToEntity;
var htmlToEntity = _ref$htmlToEntity === undefined ? defaultMiddlewareFunction : _ref$htmlToEntity;
var _ref$textToEntity = _ref.textToEntity;
var textToEntity = _ref$textToEntity === undefined ? defaultTextToEntity : _ref$textToEntity;
var textToEntity = _ref$textToEntity === undefined ? defaultMiddlewareFunction : _ref$textToEntity;
var _ref$styleToHTML = _ref.styleToHTML;
var styleToHTML = _ref$styleToHTML === undefined ? emptyObject : _ref$styleToHTML;
var styleToHTML = _ref$styleToHTML === undefined ? defaultMiddlewareFunction : _ref$styleToHTML;
var _ref$blockToHTML = _ref.blockToHTML;
var blockToHTML = _ref$blockToHTML === undefined ? defaultBlockToHTML : _ref$blockToHTML;
var blockToHTML = _ref$blockToHTML === undefined ? defaultMiddlewareFunction : _ref$blockToHTML;
var _ref$entityToHTML = _ref.entityToHTML;
var entityToHTML = _ref$entityToHTML === undefined ? defaultEntityToHTML : _ref$entityToHTML;
var entityToHTML = _ref$entityToHTML === undefined ? defaultMiddlewareFunction : _ref$entityToHTML;
return function (ToWrap) {

@@ -176,3 +174,2 @@ decorators = memoizedCoerceArray(decorators);

// wrapping a converter function
return function () {

@@ -185,3 +182,2 @@ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

// actively converting an HTML string/ContentState, so pass additional options to the next converter function.
return ToWrap({

@@ -197,45 +193,38 @@ htmlToStyle: htmlToStyle,

} else {
var _ret = function () {
// receiving a plugin to accumulate upon for a converter - accumulate
// options and return a new plugin wrapped around the passed one ready
// to take either another plugin or a string/ContentState
// receiving a plugin to accumulate upon for a converter - accumulate
// options and return a new plugin wrapped around the passed one ready
// to take either another plugin or a string/ContentState
var oldOptions = args[0];
var oldOptions = args[0];
var newHTMLToStyle = function newHTMLToStyle(nodeName, node, currentStyle) {
var acc = oldOptions.htmlToStyle(nodeName, node, currentStyle);
return htmlToStyle(nodeName, node, acc);
};
var newHTMLToStyle = memoizedCompose(memoizedMiddlewareAdapter(memoizedPassEmptyStyles(htmlToStyle)), memoizedMiddlewareAdapter(oldOptions.htmlToStyle));
newHTMLToStyle.__isMiddleware = true;
var newHTMLToBlock = memoizedAccumulateFunction(htmlToBlock, oldOptions.htmlToBlock);
var newHTMLToBlock = memoizedCompose(memoizedMiddlewareAdapter(htmlToBlock), memoizedMiddlewareAdapter(oldOptions.htmlToBlock));
newHTMLToBlock.__isMiddleware = true;
var newHTMLToEntity = memoizedAccumulateFunction(htmlToEntity, oldOptions.htmlToEntity);
var newHTMLToEntity = memoizedCompose(memoizedMiddlewareAdapter(htmlToEntity), memoizedMiddlewareAdapter(oldOptions.htmlToEntity));
newHTMLToEntity.__isMiddleware = true;
var newTextToEntity = function newTextToEntity(text) {
return oldOptions.textToEntity(text).concat(textToEntity(text));
};
var newTextToEntity = memoizedCompose(memoizedMiddlewareAdapter(textToEntity), memoizedMiddlewareAdapter(oldOptions.textToEntity));
newTextToEntity.__isMiddleware = true;
var newStyleToHTML = Object.assign({}, oldOptions.styleToHTML, styleToHTML);
var newStyleToHTML = memoizedCompose(memoizedMiddlewareAdapter(styleToHTML), memoizedMiddlewareAdapter(oldOptions.styleToHTML));
newStyleToHTML.__isMiddleware = true;
var newBlockToHTML = memoizedAccumulateFunction(memoizedBlockTypeObjectFunction(blockToHTML), memoizedBlockTypeObjectFunction(oldOptions.blockToHTML));
var newBlockToHTML = memoizedCompose(memoizedMiddlewareAdapter(blockToHTML), memoizedMiddlewareAdapter(oldOptions.blockToHTML));
newBlockToHTML.__isMiddleware = true;
var newEntityToHTML = function newEntityToHTML(entity, originalText) {
var acc = oldOptions.entityToHTML(entity, originalText);
return entityToHTML(entity, acc);
};
var newEntityToHTML = memoizedCompose(memoizedMiddlewareAdapter(entityToHTML), memoizedMiddlewareAdapter(oldOptions.entityToHTML));
newEntityToHTML.__isMiddleware = true;
return {
v: createPlugin({
htmlToStyle: newHTMLToStyle,
htmlToBlock: newHTMLToBlock,
htmlToEntity: newHTMLToEntity,
textToEntity: newTextToEntity,
styleToHTML: newStyleToHTML,
blockToHTML: newBlockToHTML,
entityToHTML: newEntityToHTML
})(ToWrap)
};
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
return createPlugin({
htmlToStyle: newHTMLToStyle,
htmlToBlock: newHTMLToBlock,
htmlToEntity: newHTMLToEntity,
textToEntity: newTextToEntity,
styleToHTML: newStyleToHTML,
blockToHTML: newBlockToHTML,
entityToHTML: newEntityToHTML
})(ToWrap);
}

@@ -242,0 +231,0 @@ };

{
"name": "draft-extend",
"version": "1.4.1",
"version": "1.5.0-beta",
"description": "Build extensible Draft.js editors with configurable plugins and integrated serialization.",

@@ -44,3 +44,3 @@ "main": "lib/index.js",

"babel-standalone": "^6.7.7",
"draft-convert": "^1.2.0",
"draft-convert": "^1.3.1",
"draft-js": "^0.8.1",

@@ -47,0 +47,0 @@ "es6-shim": "^0.35.0",

@@ -16,3 +16,3 @@ # draft-extend

## Overview
Draft Extend is a platform to build a full-featured Draft.js editor using modular plugins that can integrate with [draft-convert](#) to serialize with HTML. The higher-order function API makes it extremely easy to use any number of plugins for rendering and conversion.
Draft Extend is a platform to build a full-featured Draft.js editor using modular plugins that can integrate with [draft-convert](http://github.com/HubSpot/draft-convert) to serialize with HTML. The higher-order function API makes it extremely easy to use any number of plugins for rendering and conversion.

@@ -19,0 +19,0 @@ #### Usage:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc