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

draftjs-utils

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draftjs-utils - npm Package Compare versions

Comparing version 0.9.4 to 0.10.0

yarn-error.log

2

lib/draftjs-utils.js

@@ -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)}("undefined"!=typeof self?self:this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(t,n){t.exports=e},function(e,t,n){"use strict";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 o(e){return r(e).toList()}function i(e){if(e)return o(e).get(0)}function l(e){if(e){var t=i(e),n=e.getCurrentContent(),r=n.getBlockMap().toSeq().toList(),o=0;if(r.forEach(function(e,n){e.get("key")===t.get("key")&&(o=n-1)}),o>-1)return r.get(o)}}function c(e){return e?e.getCurrentContent().getBlockMap().toList():new v.List}function a(e){var t=o(e);if(!t.some(function(e){return e.type!==t.get(0).type}))return t.get(0).type}function f(e){var t=p.RichUtils.tryToRemoveBlockStyle(e);return t?p.EditorState.push(e,t,"change-block-type"):e}function u(e){var t="",n=e.getSelection(),r=n.getAnchorOffset(),i=n.getFocusOffset(),l=o(e);if(l.size>0){if(n.getIsBackward()){var c=r;r=i,i=c}for(var a=0;a<l.size;a+=1){var f=0===a?r:0,u=a===l.size-1?i:l.get(a).getText().length;t+=l.get(a).getText().slice(f,u)}}return t}function s(e){var t=e.getCurrentContent(),n=e.getSelection(),r=p.Modifier.removeRange(t,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=p.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),p.EditorState.push(e,r,"insert-fragment")}function g(e){var t=p.Modifier.splitBlock(e.getCurrentContent(),e.getSelection());return f(p.EditorState.push(e,t,"split-block"))}function d(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=p.Modifier.removeRange(e.getCurrentContent(),n,"forward");return p.EditorState.push(e,r,"remove-range")}function S(e,t){var n=p.Modifier.setBlockData(e.getCurrentContent(),e.getSelection(),t);return p.EditorState.push(e,n,"change-block-data")}function y(e){var t=new v.Map({}),n=o(e);if(n&&n.size>0)for(var r=0;r<n.size;r+=1){var i=function(e){var r=n.get(e).getData();if(!r||0===r.size)return t=t.clear(),"break";if(0===e)t=r;else if(t.forEach(function(e,n){r.get(n)&&r.get(n)===e||(t=t.delete(n))}),0===t.size)return t=t.clear(),"break"}(r);if("break"===i)break}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.blockRenderMap=void 0,t.getSelectedBlocksMap=r,t.getSelectedBlocksList=o,t.getSelectedBlock=i,t.getBlockBeforeSelectedBlock=l,t.getAllBlocks=c,t.getSelectedBlocksType=a,t.removeSelectedBlocksStyle=f,t.getSelectionText=u,t.addLineBreakRemovingSelection=s,t.insertNewUnstyledBlock=g,t.clearEditorContent=d,t.setBlockData=S,t.getSelectedBlocksMetadata=y;var p=n(0),v=n(6),k=(0,v.Map)({code:{element:"pre"}});t.blockRenderMap=p.DefaultDraftBlockRenderMap.merge(k)},function(e,t,n){"use strict";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=e.getSelection(),o=e.getCurrentContent(),i=o.getBlockMap(),l=(0,c.getSelectedBlocksMap)(e).map(function(e){var r=e.getDepth()+t;return r=Math.max(0,Math.min(r,n)),e.set("depth",r)});return i=i.merge(l),o.merge({blockMap:i,selectionBefore:r,selectionAfter:r})}function i(e,t,n){var r=e.getSelection(),i=void 0;i=r.getIsBackward()?r.getFocusKey():r.getAnchorKey();var c=e.getCurrentContent(),a=c.getBlockForKey(i),f=a.getType();if("unordered-list-item"!==f&&"ordered-list-item"!==f)return e;var u=c.getBlockBefore(i);if(!u)return e;if(u.getType()!==f)return e;var s=a.getDepth();if(1===t&&s===n)return e;var g=Math.min(u.getDepth()+1,n),d=o(e,t,g);return l.EditorState.push(e,d,"adjust-depth")}Object.defineProperty(t,"__esModule",{value:!0}),t.isListBlock=r,t.changeDepth=i;var l=n(0),c=n(1)},function(e,t,n){e.exports=n(4)},function(e,t,n){"use strict";var r=n(5),o=n(1),i=n(7),l=function(e){return e&&e.__esModule?e:{default:e}}(i),c=n(2);e.exports={getSelectedBlocksMap:o.getSelectedBlocksMap,getSelectedBlocksList:o.getSelectedBlocksList,getSelectedBlock:o.getSelectedBlock,getBlockBeforeSelectedBlock:o.getBlockBeforeSelectedBlock,getAllBlocks:o.getAllBlocks,getSelectedBlocksType:o.getSelectedBlocksType,removeSelectedBlocksStyle:o.removeSelectedBlocksStyle,getSelectionText:o.getSelectionText,addLineBreakRemovingSelection:o.addLineBreakRemovingSelection,insertNewUnstyledBlock:o.insertNewUnstyledBlock,clearEditorContent:o.clearEditorContent,setBlockData:o.setBlockData,getSelectedBlocksMetadata:o.getSelectedBlocksMetadata,blockRenderMap:o.blockRenderMap,getEntityRange:r.getEntityRange,getCustomStyleMap:r.getCustomStyleMap,toggleCustomInlineStyle:r.toggleCustomInlineStyle,getSelectionEntity:r.getSelectionEntity,extractInlineStyle:r.extractInlineStyle,removeAllInlineStyles:r.removeAllInlineStyles,getSelectionInlineStyle:r.getSelectionInlineStyle,getSelectionCustomInlineStyle:r.getSelectionCustomInlineStyle,handleNewLine:l.default,isListBlock:c.isListBlock,changeDepth:c.changeDepth}},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(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]=r.indexOf(e)>=0}),n}var o=t.getStartOffset(),i=t.getEndOffset(),l=(0,p.getSelectedBlocksList)(e);if(l.size>0){var c=function(){for(var e={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},t=0;t<l.size;t+=1){var n=0===t?o:0,r=t===l.size-1?i:l.get(t).getText().length;n===r&&0===n?(n=1,r=2):n===r&&(n-=1);for(var c=n;c<r;c+=1)!function(n){var r=l.get(t).getInlineStyleAt(n);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){e[t]=e[t]&&r.get(t)===t})}(c)}return{v:e}}();if("object"===(void 0===c?"undefined":S(c)))return c.v}return{}}function i(e){var t=void 0,n=e.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&(r-=1);for(var i=(0,p.getSelectedBlock)(e),l=r;l<o;l+=1){var c=i.getEntityAt(l);if(!c){t=void 0;break}if(l===r)t=c;else if(t!==c){t=void 0;break}}return t}function l(e,t){var n=(0,p.getSelectedBlock)(e),r=void 0;return n.findEntityRanges(function(e){return e.get("entity")===t},function(e,t){r={start:e,end:t,text:n.get("text").slice(e,t)}}),r}function c(e,t,n){var r=e.getSelection(),o=Object.keys(v[t]).reduce(function(e,t){return y.Modifier.removeInlineStyle(e,r,t)},e.getCurrentContent()),i=y.EditorState.push(e,o,"changeinline-style"),l=e.getCurrentInlineStyle();if(r.isCollapsed()&&(i=l.reduce(function(e,t){return y.RichUtils.toggleInlineStyle(e,t)},i)),"SUPERSCRIPT"===t||"SUBSCRIPT"==t)l.has(n)||(i=y.RichUtils.toggleInlineStyle(i,n));else{var c="bgcolor"===t?"backgroundColor":t;l.has(c+"-"+n)||(i=y.RichUtils.toggleInlineStyle(i,t.toLowerCase()+"-"+n),k(t,c,n))}return i}function a(e){if(e){e.getCurrentContent().getBlockMap().map(function(e){return e.get("characterList")}).toList().flatten().forEach(function(e){e&&0===e.indexOf("color-")?k("color","color",e.substr(6)):e&&0===e.indexOf("bgcolor-")?k("bgcolor","backgroundColor",e.substr(8)):e&&0===e.indexOf("fontsize-")?k("fontSize","fontSize",+e.substr(9)):e&&0===e.indexOf("fontfamily-")&&k("fontFamily","fontFamily",e.substr(11))})}}function f(e,t,n){var r=e.getInlineStyleAt(n).toList(),o=r.filter(function(e){return e.startsWith(t.toLowerCase())});if(o&&o.size>0)return o.get(0)}function u(e,t){var n=e.getCurrentInlineStyle().toList(),r=n.filter(function(e){return e.startsWith(t.toLowerCase())});if(r&&r.size>0)return r.get(0)}function s(e,t){if(e&&t&&t.length>0){var n=function(){var n=e.getSelection(),r={};if(n.isCollapsed())return t.forEach(function(t){r[t]=u(e,t)}),{v:r};var o=n.getStartOffset(),i=n.getEndOffset(),l=(0,p.getSelectedBlocksList)(e);if(l.size>0){for(var c=0;c<l.size;c+=1)!function(e){var n=0===e?o:0,c=e===l.size-1?i:l.get(e).getText().length;n===c&&0===n?(n=1,c=2):n===c&&(n-=1);for(var a=n;a<c;a+=1)!function(o){o===n?t.forEach(function(t){r[t]=f(l.get(e),t,o)}):t.forEach(function(t){r[t]&&r[t]!==f(l.get(e),t,o)&&(r[t]=void 0)})}(a)}(c);return{v:r}}}();if("object"===(void 0===n?"undefined":S(n)))return n.v}return{}}function g(e){var t=e.getCurrentInlineStyle(),n=e.getCurrentContent();return t.forEach(function(t){n=y.Modifier.removeInlineStyle(n,e.getSelection(),t)}),y.EditorState.push(e,n,"change-inline-style")}Object.defineProperty(t,"__esModule",{value:!0}),t.getCustomStyleMap=void 0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S="function"==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};t.getSelectionInlineStyle=o,t.getSelectionEntity=i,t.getEntityRange=l,t.toggleCustomInlineStyle=c,t.extractInlineStyle=a,t.getSelectionCustomInlineStyle=s,t.removeAllInlineStyles=g;var y=n(0),p=n(1),v={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"}},k=function(e,t,n){v[e][e.toLowerCase()+"-"+n]=r({},""+t,n)};t.getCustomStyleMap=function(){return d({},v.color,v.bgcolor,v.fontSize,v.fontFamily,{CODE:v.CODE,SUPERSCRIPT:v.SUPERSCRIPT,SUBSCRIPT:v.SUBSCRIPT})}},function(e,n){e.exports=t},function(e,t,n){"use strict";function r(e){var t=e.getSelection();if(t.isCollapsed()){var n=e.getCurrentContent(),r=t.getStartKey(),o=n.getBlockForKey(r);if(!(0,a.isListBlock)(o)&&"unstyled"!==o.getType()&&o.getLength()===t.getStartOffset())return(0,c.insertNewUnstyledBlock)(e);if((0,a.isListBlock)(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return(0,c.removeSelectedBlocksStyle)(e);if(i>0)return(0,a.changeDepth)(e,-1,i)}}}function o(e){return 13===e.which&&(e.getModifierState("Shift")||e.getModifierState("Alt")||e.getModifierState("Control"))}function i(e,t){if(o(t)){return e.getSelection().isCollapsed()?l.RichUtils.insertSoftNewline(e):(0,c.addLineBreakRemovingSelection)(e)}return r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var l=n(0),c=n(1),a=n(2)}])});
!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});
{
"name": "draftjs-utils",
"version": "0.9.4",
"version": "0.10.0",
"description": "Collection of utility function for use with Draftjs.",
"main": "lib/draftjs-utils.js",
"peerDependencies": {
"draft-js": "^0.10.x",
"draft-js": "^0.11.x",
"immutable": "3.x.x || 4.x.x"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.3",
"babel-loader": "^7.1.2",
"@babel/core": "^7.7.5",
"@babel/preset-env": "^7.7.6",
"@babel/preset-react": "^7.7.4",
"@babel/register": "^7.7.4",
"autoprefixer": "^9.7.3",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"chai": "^4.1.2",
"draft-js": "^0.10.4",
"chai": "^4.2.0",
"draft-js": "^0.11.3",
"enzyme": "^3.10.0",
"eslint": "^6.7.2",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-react": "^7.17.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"flow-bin": "^0.113.0",
"immutable": "^3.8.2",
"enzyme": "^3.2.0",
"eslint": "^4.12.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-react": "^7.5.1",
"flow-bin": "^0.60.1",
"jsdom": "^11.5.1",
"mocha": "^4.0.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"rimraf": "^2.6.2",
"sinon": "^4.1.2",
"webpack": "^3.9.1"
"jsdom": "^15.2.1",
"mocha": "^6.2.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"rimraf": "^3.0.0",
"sinon": "^7.5.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
},

@@ -43,7 +46,5 @@ "repository": {

"clean": "rimraf lib",
"build:webpack":
"NODE_ENV=production webpack --config config/webpack.prod.config.js",
"build:webpack": "NODE_ENV=production webpack --mode production --config config/webpack.prod.config.js",
"build": "npm run clean && npm run build:webpack",
"test":
"mocha --compilers js:config/test-compiler.js config/test-setup.js js/**/*Test.js",
"test": "mocha --require config/test-compiler.js config/test-setup.js js/**/*Test.js",
"lint": "eslint js",

@@ -50,0 +51,0 @@ "flow": "flow; test $? -eq 0 -o $? -eq 2",

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