draftjs-utils
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("draft-js"),require("immutable")):"function"==typeof define&&define.amd?define(["draft-js","immutable"],t):"object"==typeof exports?exports.draftjsUtils=t(require("draft-js"),require("immutable")):e.draftjsUtils=t(e["draft-js"],e.immutable)}(window,function(n,r){return c={},o.m=i=[function(e,t,n){"use strict";n.d(t,"h",function(){return r}),n.d(t,"g",function(){return l}),n.d(t,"f",function(){return o}),n.d(t,"e",function(){return u}),n.d(t,"d",function(){return f}),n.d(t,"j",function(){return a}),n.d(t,"m",function(){return s}),n.d(t,"k",function(){return g}),n.d(t,"a",function(){return d}),n.d(t,"l",function(){return S}),n.d(t,"c",function(){return p}),n.d(t,"n",function(){return y}),n.d(t,"i",function(){return b}),n.d(t,"b",function(){return C});var c=n(1),i=n(4);function r(e){var t=e.getSelection(),n=e.getCurrentContent(),r=t.getStartKey(),o=t.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(e,t){return t===r}).takeUntil(function(e,t){return t===o}).concat([[o,i.get(o)]])}function l(e){return r(e).toList()}function o(e){if(e)return l(e).get(0)}function u(e){if(e){var n=o(e),t=e.getCurrentContent().getBlockMap().toSeq().toList(),r=0;if(t.forEach(function(e,t){e.get("key")===n.get("key")&&(r=t-1)}),-1<r)return t.get(r)}}function f(e){return e?e.getCurrentContent().getBlockMap().toList():new i.List}function a(e){var t=l(e);if(!t.some(function(e){return e.type!==t.get(0).type}))return t.get(0).type}function s(e){var t=c.RichUtils.tryToRemoveBlockStyle(e);return t?c.EditorState.push(e,t,"change-block-type"):e}function g(e){var t="",n=e.getSelection(),r=n.getAnchorOffset(),o=n.getFocusOffset(),i=l(e);if(0<i.size){if(n.getIsBackward()){var c=r;r=o,o=c}for(var u=0;u<i.size;u+=1){var f=0===u?r:0,a=u===i.size-1?o:i.get(u).getText().length;t+=i.get(u).getText().slice(f,a)}}return t}function d(e){var t=e.getCurrentContent(),n=e.getSelection(),r=c.Modifier.removeRange(t,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=c.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),c.EditorState.push(e,r,"insert-fragment")}function S(e){var t=c.Modifier.splitBlock(e.getCurrentContent(),e.getSelection());return s(c.EditorState.push(e,t,"split-block"))}function p(e){var t=e.getCurrentContent().getBlockMap().toList(),n=e.getSelection().merge({anchorKey:t.first().get("key"),anchorOffset:0,focusKey:t.last().get("key"),focusOffset:t.last().getLength()}),r=c.Modifier.removeRange(e.getCurrentContent(),n,"forward");return c.EditorState.push(e,r,"remove-range")}function y(e,t){var n=c.Modifier.setBlockData(e.getCurrentContent(),e.getSelection(),t);return c.EditorState.push(e,n,"change-block-data")}function b(e){var r=new i.Map({}),t=l(e);if(t&&0<t.size)for(var n=function(e){var n=t.get(e).getData();if(!n||0===n.size)return r=r.clear(),"break";if(0===e)r=n;else if(r.forEach(function(e,t){n.get(t)&&n.get(t)===e||(r=r.delete(t))}),0===r.size)return r=r.clear(),"break"},o=0;o<t.size;o+=1){if("break"===n(o))break}return r}var v=Object(i.Map)({code:{element:"pre"}}),C=c.DefaultDraftBlockRenderMap.merge(v)},function(e,t){e.exports=n},function(e,t,n){"use strict";n.d(t,"f",function(){return c}),n.d(t,"e",function(){return u}),n.d(t,"c",function(){return a}),n.d(t,"b",function(){return d}),n.d(t,"h",function(){return S}),n.d(t,"a",function(){return p}),n.d(t,"d",function(){return b}),n.d(t,"g",function(){return v});var f=n(1),l=n(0);function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return(i="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})(e)}function c(e){var t=e.getSelection();if(t.isCollapsed()){var n={},r=e.getCurrentInlineStyle().toList().toJS();if(r)return["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(e){n[e]=0<=r.indexOf(e)}),n}var c=t.getStartOffset(),u=t.getEndOffset(),f=Object(l.g)(e);if(0<f.size){var o=function(){for(var n={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},r=0;r<f.size;r+=1){var e=0===r?c:0,t=r===f.size-1?u:f.get(r).getText().length;e===t&&0===e?(e=1,t=2):e===t&&--e;for(var o=function(e){var t=f.get(r).getInlineStyleAt(e);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(e){n[e]=n[e]&&t.get(e)===e})},i=e;i<t;i+=1)o(i)}return{v:n}}();if("object"===i(o))return o.v}return{}}function u(e){var t,n=e.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&--r;for(var i=Object(l.f)(e),c=r;c<o;c+=1){var u=i.getEntityAt(c);if(!u){t=void 0;break}if(c===r)t=u;else if(t!==u){t=void 0;break}}return t}function a(e,t){var n,r=Object(l.f)(e);return r.findEntityRanges(function(e){return e.get("entity")===t},function(e,t){n={start:e,end:t,text:r.get("text").slice(e,t)}}),n}var s={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}},g=function(e,t,n){s[e]["".concat(e.toLowerCase(),"-").concat(n)]=o({},"".concat(t),n)},d=function(){return function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach(function(e){o(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}({},s.color,{},s.bgcolor,{},s.fontSize,{},s.fontFamily,{CODE:s.CODE,SUPERSCRIPT:s.SUPERSCRIPT,SUBSCRIPT:s.SUBSCRIPT})};function S(e,t,n){var r=e.getSelection(),o=Object.keys(s[t]).reduce(function(e,t){return f.Modifier.removeInlineStyle(e,r,t)},e.getCurrentContent()),i=f.EditorState.push(e,o,"changeinline-style"),c=e.getCurrentInlineStyle();if(r.isCollapsed()&&(i=c.reduce(function(e,t){return f.RichUtils.toggleInlineStyle(e,t)},i)),"SUPERSCRIPT"===t||"SUBSCRIPT"==t)c.has(n)||(i=f.RichUtils.toggleInlineStyle(i,n));else{var u="bgcolor"===t?"backgroundColor":t;c.has("".concat(u,"-").concat(n))||(i=f.RichUtils.toggleInlineStyle(i,"".concat(t.toLowerCase(),"-").concat(n)),g(t,u,n))}return i}function p(e){e&&e.getCurrentContent().getBlockMap().map(function(e){return e.get("characterList")}).toList().flatten().forEach(function(e){e&&0===e.indexOf("color-")?g("color","color",e.substr(6)):e&&0===e.indexOf("bgcolor-")?g("bgcolor","backgroundColor",e.substr(8)):e&&0===e.indexOf("fontsize-")?g("fontSize","fontSize",+e.substr(9)):e&&0===e.indexOf("fontfamily-")&&g("fontFamily","fontFamily",e.substr(11))})}function y(e,t,n){var r=e.getInlineStyleAt(n).toList().filter(function(e){return e.startsWith(t.toLowerCase())});if(r&&0<r.size)return r.get(0)}function b(r,a){if(r&&a&&0<a.length){var e=function(){var e=r.getSelection(),i={};if(e.isCollapsed())return a.forEach(function(e){i[e]=function(e,t){var n=e.getCurrentInlineStyle().toList().filter(function(e){return e.startsWith(t.toLowerCase())});if(n&&0<n.size)return n.get(0)}(r,e)}),{v:i};var c=e.getStartOffset(),u=e.getEndOffset(),f=Object(l.g)(r);if(0<f.size){for(var t=function(n){var e=0===n?c:0,t=n===f.size-1?u:f.get(n).getText().length;e===t&&0===e?(e=1,t=2):e===t&&--e;for(var r=function(t){t===e?a.forEach(function(e){i[e]=y(f.get(n),e,t)}):a.forEach(function(e){i[e]&&i[e]!==y(f.get(n),e,t)&&(i[e]=void 0)})},o=e;o<t;o+=1)r(o)},n=0;n<f.size;n+=1)t(n);return{v:i}}}();if("object"===i(e))return e.v}return{}}function v(t){var e=t.getCurrentInlineStyle(),n=t.getCurrentContent();return e.forEach(function(e){n=f.Modifier.removeInlineStyle(n,t.getSelection(),e)}),f.EditorState.push(t,n,"change-inline-style")}},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"a",function(){return o});var C=n(1),O=n(0);function r(e){if(e){var t=e.getType();return"unordered-list-item"===t||"ordered-list-item"===t}return!1}function o(e,t,n){var r,o=e.getSelection();r=o.getIsBackward()?o.getFocusKey():o.getAnchorKey();var i=e.getCurrentContent(),c=i.getBlockForKey(r),u=c.getType();if("unordered-list-item"!==u&&"ordered-list-item"!==u)return e;var f=i.getBlockBefore(r);if(!f)return e;if(f.getType()!==u)return e;var a=c.getDepth();if(1===t&&a===n)return e;var l,s,g,d,S,p,y,b=Math.min(f.getDepth()+1,n),v=(s=t,g=b,d=(l=e).getSelection(),S=l.getCurrentContent(),p=S.getBlockMap(),y=Object(O.h)(l).map(function(e){var t=e.getDepth()+s;return t=Math.max(0,Math.min(t,g)),e.set("depth",t)}),p=p.merge(y),S.merge({blockMap:p,selectionBefore:d,selectionAfter:d}));return C.EditorState.push(e,v,"adjust-depth")}},function(e,t){e.exports=r},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r=n(1),c=n(0),u=n(3);function o(e,t){var n;return 13===(n=t).which&&(n.getModifierState("Shift")||n.getModifierState("Alt")||n.getModifierState("Control"))?e.getSelection().isCollapsed()?r.RichUtils.insertSoftNewline(e):Object(c.a)(e):function(e){var t=e.getSelection();if(t.isCollapsed()){var n=e.getCurrentContent(),r=t.getStartKey(),o=n.getBlockForKey(r);if(!Object(u.b)(o)&&"unstyled"!==o.getType()&&o.getLength()===t.getStartOffset())return Object(c.l)(e);if(Object(u.b)(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return Object(c.m)(e);if(0<i)return Object(u.a)(e,-1,i)}}}(e)}},function(e,t,n){e.exports=n(7)},function(e,t,i){"use strict";i.r(t),function(e){var t=i(2),n=i(0),r=i(5),o=i(3);e.exports={getSelectedBlocksMap:n.h,getSelectedBlocksList:n.g,getSelectedBlock:n.f,getBlockBeforeSelectedBlock:n.e,getAllBlocks:n.d,getSelectedBlocksType:n.j,removeSelectedBlocksStyle:n.m,getSelectionText:n.k,addLineBreakRemovingSelection:n.a,insertNewUnstyledBlock:n.l,clearEditorContent:n.c,setBlockData:n.n,getSelectedBlocksMetadata:n.i,blockRenderMap:n.b,getEntityRange:t.c,getCustomStyleMap:t.b,toggleCustomInlineStyle:t.h,getSelectionEntity:t.e,extractInlineStyle:t.a,removeAllInlineStyles:t.g,getSelectionInlineStyle:t.f,getSelectionCustomInlineStyle:t.d,handleNewLine:r.a,isListBlock:o.b,changeDepth:o.a}}.call(this,i(8)(e))},function(e,t){e.exports=function(e){if(!e.webpackPolyfill){var t=Object.create(e);t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1}return t}}],o.c=c,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=6);function o(e){if(c[e])return c[e].exports;var t=c[e]={i:e,l:!1,exports:{}};return i[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}var i,c}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("draft-js"),require("immutable")):"function"==typeof define&&define.amd?define(["draft-js","immutable"],t):"object"==typeof exports?exports.draftjsUtils=t(require("draft-js"),require("immutable")):e.draftjsUtils=t(e["draft-js"],e.immutable)}(window,function(n,r){return c={},o.m=i=[function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,n){e.exports=n(3)},function(e,t,n){"use strict";n.r(t);var C=n(0),i=n(1);function m(e){var t=e.getSelection(),n=e.getCurrentContent(),r=t.getStartKey(),o=t.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(e,t){return t===r}).takeUntil(function(e,t){return t===o}).concat([[o,i.get(o)]])}function u(e){return m(e).toList()}function l(e){if(e)return u(e).get(0)}function c(e){var t=C.RichUtils.tryToRemoveBlockStyle(e);return t?C.EditorState.push(e,t,"change-block-type"):e}function r(e){var t=e.getCurrentContent(),n=e.getSelection(),r=C.Modifier.removeRange(t,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=C.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),C.EditorState.push(e,r,"insert-fragment")}function f(e){var t=C.Modifier.splitBlock(e.getCurrentContent(),e.getSelection());return c(C.EditorState.push(e,t,"split-block"))}var o=Object(i.Map)({code:{element:"pre"}}),a=C.DefaultDraftBlockRenderMap.merge(o);function s(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e){return(S="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})(e)}function d(e,t,n){p[e]["".concat(e.toLowerCase(),"-").concat(n)]=g({},"".concat(t),n)}var p={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}};function y(e,t,n){var r=e.getInlineStyleAt(n).toList().filter(function(e){return e.startsWith(t.toLowerCase())});if(r&&0<r.size)return r.get(0)}function v(e){if(e){var t=e.getType();return"unordered-list-item"===t||"ordered-list-item"===t}return!1}function b(e,t,n){var r,o=e.getSelection();r=o.getIsBackward()?o.getFocusKey():o.getAnchorKey();var i=e.getCurrentContent(),c=i.getBlockForKey(r),f=c.getType();if("unordered-list-item"!==f&&"ordered-list-item"!==f)return e;var l=i.getBlockBefore(r);if(!l)return e;if(l.getType()!==f)return e;var a=c.getDepth();if(1===t&&a===n)return e;var u,s,g,S,d,p,y,v=Math.min(l.getDepth()+1,n),b=(s=t,g=v,S=(u=e).getSelection(),d=u.getCurrentContent(),p=d.getBlockMap(),y=m(u).map(function(e){var t=e.getDepth()+s;return t=Math.max(0,Math.min(t,g)),e.set("depth",t)}),p=p.merge(y),d.merge({blockMap:p,selectionBefore:S,selectionAfter:S}));return C.EditorState.push(e,b,"adjust-depth")}t.default={getSelectedBlocksMap:m,getSelectedBlocksList:u,getSelectedBlock:l,getBlockBeforeSelectedBlock:function(e){if(e){var n=l(e),t=e.getCurrentContent().getBlockMap().toSeq().toList(),r=0;if(t.forEach(function(e,t){e.get("key")===n.get("key")&&(r=t-1)}),-1<r)return t.get(r)}},getAllBlocks:function(e){return e?e.getCurrentContent().getBlockMap().toList():new i.List},getSelectedBlocksType:function(e){var t=u(e);if(!t.some(function(e){return e.type!==t.get(0).type}))return t.get(0).type},removeSelectedBlocksStyle:c,getSelectionText:function(e){var t="",n=e.getSelection(),r=n.getAnchorOffset(),o=n.getFocusOffset(),i=u(e);if(0<i.size){if(n.getIsBackward()){var c=r;r=o,o=c}for(var f=0;f<i.size;f+=1){var l=0===f?r:0,a=f===i.size-1?o:i.get(f).getText().length;t+=i.get(f).getText().slice(l,a)}}return t},addLineBreakRemovingSelection:r,insertNewUnstyledBlock:f,clearEditorContent:function(e){var t=e.getCurrentContent().getBlockMap().toList(),n=e.getSelection().merge({anchorKey:t.first().get("key"),anchorOffset:0,focusKey:t.last().get("key"),focusOffset:t.last().getLength()}),r=C.Modifier.removeRange(e.getCurrentContent(),n,"forward");return C.EditorState.push(e,r,"remove-range")},setBlockData:function(e,t){var n=C.Modifier.setBlockData(e.getCurrentContent(),e.getSelection(),t);return C.EditorState.push(e,n,"change-block-data")},getSelectedBlocksMetadata:function(e){var r=new i.Map({}),t=u(e);if(t&&0<t.size)for(var n=function(e){var n=t.get(e).getData();if(!n||0===n.size)return r=r.clear(),"break";if(0===e)r=n;else if(r.forEach(function(e,t){n.get(t)&&n.get(t)===e||(r=r.delete(t))}),0===r.size)return r=r.clear(),"break"},o=0;o<t.size;o+=1){if("break"===n(o))break}return r},blockRenderMap:a,getEntityRange:function(e,t){var n,r=l(e);return r.findEntityRanges(function(e){return e.get("entity")===t},function(e,t){n={start:e,end:t,text:r.get("text").slice(e,t)}}),n},getCustomStyleMap:function(){return function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach(function(e){g(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}({},p.color,{},p.bgcolor,{},p.fontSize,{},p.fontFamily,{CODE:p.CODE,SUPERSCRIPT:p.SUPERSCRIPT,SUBSCRIPT:p.SUBSCRIPT})},toggleCustomInlineStyle:function(e,t,n){var r=e.getSelection(),o=Object.keys(p[t]).reduce(function(e,t){return C.Modifier.removeInlineStyle(e,r,t)},e.getCurrentContent()),i=C.EditorState.push(e,o,"changeinline-style"),c=e.getCurrentInlineStyle();if(r.isCollapsed()&&(i=c.reduce(function(e,t){return C.RichUtils.toggleInlineStyle(e,t)},i)),"SUPERSCRIPT"===t||"SUBSCRIPT"==t)c.has(n)||(i=C.RichUtils.toggleInlineStyle(i,n));else{var f="bgcolor"===t?"backgroundColor":t;c.has("".concat(f,"-").concat(n))||(i=C.RichUtils.toggleInlineStyle(i,"".concat(t.toLowerCase(),"-").concat(n)),d(t,f,n))}return i},getSelectionEntity:function(e){var t,n=e.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&--r;for(var i=l(e),c=r;c<o;c+=1){var f=i.getEntityAt(c);if(!f){t=void 0;break}if(c===r)t=f;else if(t!==f){t=void 0;break}}return t},extractInlineStyle:function(e){e&&e.getCurrentContent().getBlockMap().map(function(e){return e.get("characterList")}).toList().flatten().forEach(function(e){e&&0===e.indexOf("color-")?d("color","color",e.substr(6)):e&&0===e.indexOf("bgcolor-")?d("bgcolor","backgroundColor",e.substr(8)):e&&0===e.indexOf("fontsize-")?d("fontSize","fontSize",+e.substr(9)):e&&0===e.indexOf("fontfamily-")&&d("fontFamily","fontFamily",e.substr(11))})},removeAllInlineStyles:function(t){var e=t.getCurrentInlineStyle(),n=t.getCurrentContent();return e.forEach(function(e){n=C.Modifier.removeInlineStyle(n,t.getSelection(),e)}),C.EditorState.push(t,n,"change-inline-style")},getSelectionInlineStyle:function(e){var t=e.getSelection();if(t.isCollapsed()){var n={},r=e.getCurrentInlineStyle().toList().toJS();if(r)return["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(e){n[e]=0<=r.indexOf(e)}),n}var c=t.getStartOffset(),f=t.getEndOffset(),l=u(e);if(0<l.size){var o=function(){for(var n={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},r=0;r<l.size;r+=1){var e=0===r?c:0,t=r===l.size-1?f:l.get(r).getText().length;e===t&&0===e?(e=1,t=2):e===t&&--e;for(var o=function(e){var t=l.get(r).getInlineStyleAt(e);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(e){n[e]=n[e]&&t.get(e)===e})},i=e;i<t;i+=1)o(i)}return{v:n}}();if("object"===S(o))return o.v}return{}},getSelectionCustomInlineStyle:function(r,a){if(r&&a&&0<a.length){var e=function(){var e=r.getSelection(),i={};if(e.isCollapsed())return a.forEach(function(e){i[e]=function(e,t){var n=e.getCurrentInlineStyle().toList().filter(function(e){return e.startsWith(t.toLowerCase())});if(n&&0<n.size)return n.get(0)}(r,e)}),{v:i};var c=e.getStartOffset(),f=e.getEndOffset(),l=u(r);if(0<l.size){for(var t=function(n){var e=0===n?c:0,t=n===l.size-1?f:l.get(n).getText().length;e===t&&0===e?(e=1,t=2):e===t&&--e;for(var r=function(t){t===e?a.forEach(function(e){i[e]=y(l.get(n),e,t)}):a.forEach(function(e){i[e]&&i[e]!==y(l.get(n),e,t)&&(i[e]=void 0)})},o=e;o<t;o+=1)r(o)},n=0;n<l.size;n+=1)t(n);return{v:i}}}();if("object"===S(e))return e.v}return{}},handleNewLine:function(e,t){var n;return 13===(n=t).which&&(n.getModifierState("Shift")||n.getModifierState("Alt")||n.getModifierState("Control"))?e.getSelection().isCollapsed()?C.RichUtils.insertSoftNewline(e):r(e):function(e){var t=e.getSelection();if(t.isCollapsed()){var n=e.getCurrentContent(),r=t.getStartKey(),o=n.getBlockForKey(r);if(!v(o)&&"unstyled"!==o.getType()&&o.getLength()===t.getStartOffset())return f(e);if(v(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return c(e);if(0<i)return b(e,-1,i)}}}(e)},isListBlock:v,changeDepth:b}}],o.c=c,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=2);function o(e){if(c[e])return c[e].exports;var t=c[e]={i:e,l:!1,exports:{}};return i[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}var i,c}); |
{ | ||
"name": "draftjs-utils", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "Collection of utility function for use with Draftjs.", | ||
@@ -5,0 +5,0 @@ "main": "lib/draftjs-utils.js", |
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
235652