New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

draftjs-to-html

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draftjs-to-html - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

2

lib/draftjs-to-html.js

@@ -1,1 +0,1 @@

module.exports=function(t){function e(r){if(n[r])return n[r].exports;var u=n[r]={i:r,l:!1,exports:{}};return t[r].call(u.exports,u,u.exports,e),u.l=!0,u.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,n){"use strict";function r(t){return t&&S[t]}function u(t){var e="";return(0,L.forEach)(t,function(t,n){n&&(e+=t+":"+n+";")}),e}function a(t,e){var n=[];if(e)for(var r=0,u=0,a=t,i=e.trigger||"#",o=e.separator||" ";a.length>0&&u>=0;)if(a[0]===i?(u=0,r=0,a=a.substr(i.length)):(u=a.indexOf(o+i))>=0&&(a=a.substr(u+(o+i).length),r+=u+o.length),u>=0){var s=a.indexOf(o)>=0?a.indexOf(o):a.length,f=a.substr(0,s);f&&f.length>0&&n.push({offset:r,length:f.length+i.length,type:"HASHTAG"}),r+=i.length}return n}function i(t,e){var n=[],r=0,u=t.entityRanges.map(function(t){return{offset:t.offset,length:t.length,key:t.key,type:"ENTITY"}});return u=u.concat(a(t.text,e)),u=u.sort(function(t,e){return t.offset-e.offset}),u.forEach(function(t){t.offset>r&&n.push({start:r,end:t.offset}),n.push({start:t.offset,end:t.offset+t.length,entityKey:t.key,type:t.type}),r=t.offset+t.length}),r<t.text.length&&n.push({start:r,end:t.text.length}),n}function o(t){return!!(t.entityRanges.length>0&&(0,L.isEmptyString)(t.text)||"atomic"===t.type)}function s(t){var e=t.text,n=t.inlineStyleRanges,r={BOLD:new Array(e.length),ITALIC:new Array(e.length),UNDERLINE:new Array(e.length),STRIKETHROUGH:new Array(e.length),CODE:new Array(e.length),SUPERSCRIPT:new Array(e.length),SUBSCRIPT:new Array(e.length),COLOR:new Array(e.length),BGCOLOR:new Array(e.length),FONTSIZE:new Array(e.length),FONTFAMILY:new Array(e.length),length:e.length};return n&&n.length>0&&n.forEach(function(t){for(var e=t.offset,n=e+t.length,u=e;u<n;u+=1)0===t.style.indexOf("color-")?r.COLOR[u]=t.style.substring(6):0===t.style.indexOf("bgcolor-")?r.BGCOLOR[u]=t.style.substring(8):0===t.style.indexOf("fontsize-")?r.FONTSIZE[u]=t.style.substring(9):0===t.style.indexOf("fontfamily-")?r.FONTFAMILY[u]=t.style.substring(11):r[t.style]&&(r[t.style][u]=!0)}),r}function f(t,e){var n={};return t.COLOR[e]&&(n.COLOR=t.COLOR[e]),t.BGCOLOR[e]&&(n.BGCOLOR=t.BGCOLOR[e]),t.FONTSIZE[e]&&(n.FONTSIZE=t.FONTSIZE[e]),t.FONTFAMILY[e]&&(n.FONTFAMILY=t.FONTFAMILY[e]),t.UNDERLINE[e]&&(n.UNDERLINE=!0),t.ITALIC[e]&&(n.ITALIC=!0),t.BOLD[e]&&(n.BOLD=!0),t.STRIKETHROUGH[e]&&(n.STRIKETHROUGH=!0),t.CODE[e]&&(n.CODE=!0),t.SUBSCRIPT[e]&&(n.SUBSCRIPT=!0),t.SUPERSCRIPT[e]&&(n.SUPERSCRIPT=!0),n}function l(t,e,n){var r=!0;return n>0&&n<t.length?e.forEach(function(e){r=r&&t[e][n]===t[e][n-1]}):r=!1,r}function h(t,e){return"BOLD"===t?"<strong>"+e+"</strong>":"ITALIC"===t?"<em>"+e+"</em>":"UNDERLINE"===t?"<ins>"+e+"</ins>":"STRIKETHROUGH"===t?"<del>"+e+"</del>":"CODE"===t?"<code>"+e+"</code>":"SUPERSCRIPT"===t?"<sup>"+e+"</sup>":"SUBSCRIPT"===t?"<sub>"+e+"</sub>":e}function c(t){if(t&&t.length>0){return t.map(function(t){switch(t){case"\n":return"<br>\n";case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";default:return t}}).join("")}return""}function g(t,e){if(t&&(t.COLOR||t.BGCOLOR||t.FONTSIZE||t.FONTFAMILY)){var n='style="';return t.COLOR&&(n+="color: "+t.COLOR+";"),t.BGCOLOR&&(n+="background-color: "+t.BGCOLOR+";"),t.FONTSIZE&&(n+="font-size: "+t.FONTSIZE+"px;"),t.FONTFAMILY&&(n+="font-family: "+t.FONTFAMILY+";"),"<span "+(n+='"')+">"+e+"</span>"}return e}function p(t,e,n,r){var u=t[e];if("function"==typeof r){var a=r(u,n);if(a)return a}if("MENTION"===u.type)return'<a href="'+u.data.url+'" class="wysiwyg-mention" data-mention data-value="'+u.data.value+'">'+n+"</a>";if("LINK"===u.type){var i=u.data.target||"_self";return'<a href="'+u.data.url+'" target="'+i+'" >'+n+"</a>"}return"IMAGE"===u.type?'<img src="'+u.data.src+'" style="float:'+(u.data.alignment||"none")+";height: "+u.data.height+";width: "+u.data.width+'"/>':"EMBEDDED_LINK"===u.type?'<iframe width="'+u.data.width+'" height="'+u.data.height+'" src="'+u.data.src+'" frameBorder="0"></iframe>':n}function y(t,e,n,r){var u=[],a=t.text;if(a.length>0)for(var i=s(t),o=void 0,h=n;h<r;h+=1)h!==n&&l(i,e,h)?(o.text.push(a[h]),o.end=h+1):(o={styles:f(i,h),text:[a[h]],start:h,end:h+1},u.push(o));return u}function O(t){if(t){for(var e=t,n=0;n<e.length&&" "===t[n];n+=1)e=e.replace(" ","&nbsp;");return e}return t}function d(t){if(t){for(var e=t,n=e.length-1;n>=0&&" "===e[n];n-=1)e=e.substring(0,n)+"&nbsp;"+e.substring(n+1);return e}return t}function I(t){var e=t.styles,n=t.text,r=c(n);return(0,L.forEach)(e,function(t,e){r=h(t,r,e)}),r}function T(t,e){var n=y(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],e.start,e.end),r="";return n.forEach(function(t){r+=I(t)}),r=g(e.styles,r)}function v(t,e,n,r){var u=[];y(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],n.start,n.end).forEach(function(e){u.push(T(t,e))});var a=u.join("");return"ENTITY"===n.type?void 0!==n.entityKey&&null!==n.entityKey&&(a=p(e,n.entityKey,a,r)):"HASHTAG"===n.type&&(a='<a href="'+a+'" class="wysiwyg-hashtag">'+a+"</a>"),a}function E(t,e,n,r){var u=[],a=i(t,n);return a.forEach(function(n,i){var o=v(t,e,n,r);0===i&&(o=O(o)),i===a.length-1&&(o=d(o)),u.push(o)}),u.join("")}function R(t,e,n,a,i){var s=[];if(o(t))s.push(p(e,t.entityRanges[0].key,void 0,i));else{var f=r(t.type);if(f){s.push("<"+f);var l=u(t.data);l&&s.push(' style="'+l+'"'),a&&s.push(' dir = "auto"'),s.push(">"),s.push(E(t,e,n,i)),s.push("</"+f+">")}}return s.push("\n"),s.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.getBlockTag=r,e.getBlockStyle=u,e.getStylesAtOffset=f,e.sameStyleAsPrevious=l,e.addInlineStyleMarkup=h,e.addStylePropertyMarkup=g,e.trimLeadingZeros=O,e.trimTrailingZeros=d,e.getBlockInnerMarkup=E,e.getBlockMarkup=R;var L=n(2),S={unstyled:"p","header-one":"h1","header-two":"h2","header-three":"h3","header-four":"h4","header-five":"h5","header-six":"h6","unordered-list-item":"ul","ordered-list-item":"ol",blockquote:"blockquote"}},function(t,e,n){"use strict";function r(t,e,n,r){var i=[];if(t){var o=t.blocks,s=t.entityMap;if(o&&o.length>0){var f=[];if(o.forEach(function(t){if((0,a.isList)(t.type))f.push(t);else{if(f.length>0){var o=(0,a.getListMarkup)(f,s,e,r);i.push(o),f=[]}var l=(0,u.getBlockMarkup)(t,s,e,n,r);i.push(l)}}),f.length>0){var l=(0,a.getListMarkup)(f,s,e,n,r);i.push(l),f=[]}}}return i.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var u=n(0),a=n(3)},function(t,e,n){"use strict";function r(t,e){if(t)for(var n in t)({}).hasOwnProperty.call(t,n)&&e(n,t[n])}function u(t){return void 0===t||null===t||0===t.length||0===t.trim().length}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=r,e.isEmptyString=u},function(t,e,n){"use strict";function r(t){return"unordered-list-item"===t||"ordered-list-item"===t}function u(t,e,n,r,i){var o=[],s=[],f=void 0;return t.forEach(function(t){var l=!1;if(f?f.type!==t.type?(o.push("</"+(0,a.getBlockTag)(f.type)+">\n"),o.push("<"+(0,a.getBlockTag)(t.type)+">\n")):f.depth===t.depth?s&&s.length>0&&(o.push(u(s,e,n,r,i)),s=[]):(l=!0,s.push(t)):o.push("<"+(0,a.getBlockTag)(t.type)+">\n"),!l){o.push("<li");var h=(0,a.getBlockStyle)(t.data);h&&o.push(' style="'+h+'"'),r&&o.push(' dir = "auto"'),o.push(">"),o.push((0,a.getBlockInnerMarkup)(t,e,n,i)),o.push("</li>\n"),f=t}}),s&&s.length>0&&o.push(u(s,e,n,r,i)),o.push("</"+(0,a.getBlockTag)(f.type)+">\n"),o.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.isList=r,e.getListMarkup=u;var a=n(0)},function(t,e,n){t.exports=n(1)}]);
module.exports=function(t){function e(r){if(n[r])return n[r].exports;var u=n[r]={i:r,l:!1,exports:{}};return t[r].call(u.exports,u,u.exports,e),u.l=!0,u.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,n){"use strict";function r(t){return t&&S[t]}function u(t){var e="";return(0,L.forEach)(t,function(t,n){n&&(e+=t+":"+n+";")}),e}function a(t,e){var n=[];if(e)for(var r=0,u=0,a=t,i=e.trigger||"#",o=e.separator||" ";a.length>0&&u>=0;)if(a[0]===i?(u=0,r=0,a=a.substr(i.length)):(u=a.indexOf(o+i))>=0&&(a=a.substr(u+(o+i).length),r+=u+o.length),u>=0){var s=a.indexOf(o)>=0?a.indexOf(o):a.length,f=a.substr(0,s);f&&f.length>0&&n.push({offset:r,length:f.length+i.length,type:"HASHTAG"}),r+=i.length}return n}function i(t,e){var n=[],r=0,u=t.entityRanges.map(function(t){return{offset:t.offset,length:t.length,key:t.key,type:"ENTITY"}});return u=u.concat(a(t.text,e)),u=u.sort(function(t,e){return t.offset-e.offset}),u.forEach(function(t){t.offset>r&&n.push({start:r,end:t.offset}),n.push({start:t.offset,end:t.offset+t.length,entityKey:t.key,type:t.type}),r=t.offset+t.length}),r<t.text.length&&n.push({start:r,end:t.text.length}),n}function o(t){return!!(t.entityRanges.length>0&&(0,L.isEmptyString)(t.text)||"atomic"===t.type)}function s(t){var e=t.text,n=t.inlineStyleRanges,r={BOLD:new Array(e.length),ITALIC:new Array(e.length),UNDERLINE:new Array(e.length),STRIKETHROUGH:new Array(e.length),CODE:new Array(e.length),SUPERSCRIPT:new Array(e.length),SUBSCRIPT:new Array(e.length),COLOR:new Array(e.length),BGCOLOR:new Array(e.length),FONTSIZE:new Array(e.length),FONTFAMILY:new Array(e.length),length:e.length};return n&&n.length>0&&n.forEach(function(t){for(var e=t.offset,n=e+t.length,u=e;u<n;u+=1)0===t.style.indexOf("color-")?r.COLOR[u]=t.style.substring(6):0===t.style.indexOf("bgcolor-")?r.BGCOLOR[u]=t.style.substring(8):0===t.style.indexOf("fontsize-")?r.FONTSIZE[u]=t.style.substring(9):0===t.style.indexOf("fontfamily-")?r.FONTFAMILY[u]=t.style.substring(11):r[t.style]&&(r[t.style][u]=!0)}),r}function f(t,e){var n={};return t.COLOR[e]&&(n.COLOR=t.COLOR[e]),t.BGCOLOR[e]&&(n.BGCOLOR=t.BGCOLOR[e]),t.FONTSIZE[e]&&(n.FONTSIZE=t.FONTSIZE[e]),t.FONTFAMILY[e]&&(n.FONTFAMILY=t.FONTFAMILY[e]),t.UNDERLINE[e]&&(n.UNDERLINE=!0),t.ITALIC[e]&&(n.ITALIC=!0),t.BOLD[e]&&(n.BOLD=!0),t.STRIKETHROUGH[e]&&(n.STRIKETHROUGH=!0),t.CODE[e]&&(n.CODE=!0),t.SUBSCRIPT[e]&&(n.SUBSCRIPT=!0),t.SUPERSCRIPT[e]&&(n.SUPERSCRIPT=!0),n}function l(t,e,n){var r=!0;return n>0&&n<t.length?e.forEach(function(e){r=r&&t[e][n]===t[e][n-1]}):r=!1,r}function h(t,e){return"BOLD"===t?"<strong>"+e+"</strong>":"ITALIC"===t?"<em>"+e+"</em>":"UNDERLINE"===t?"<ins>"+e+"</ins>":"STRIKETHROUGH"===t?"<del>"+e+"</del>":"CODE"===t?"<code>"+e+"</code>":"SUPERSCRIPT"===t?"<sup>"+e+"</sup>":"SUBSCRIPT"===t?"<sub>"+e+"</sub>":e}function c(t){if(t&&t.length>0){return t.map(function(t){switch(t){case"\n":return"<br>\n";case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";default:return t}}).join("")}return""}function g(t,e){if(t&&(t.COLOR||t.BGCOLOR||t.FONTSIZE||t.FONTFAMILY)){var n='style="';return t.COLOR&&(n+="color: "+t.COLOR+";"),t.BGCOLOR&&(n+="background-color: "+t.BGCOLOR+";"),t.FONTSIZE&&(n+="font-size: "+t.FONTSIZE+"px;"),t.FONTFAMILY&&(n+="font-family: "+t.FONTFAMILY+";"),"<span "+(n+='"')+">"+e+"</span>"}return e}function p(t,e,n,r){var u=t[e];if("function"==typeof r){var a=r(u,n);if(a)return a}if("MENTION"===u.type)return'<a href="'+u.data.url+'" class="wysiwyg-mention" data-mention data-value="'+u.data.value+'">'+n+"</a>";if("LINK"===u.type){var i=u.data.target||"_self";return'<a href="'+u.data.url+'" target="'+i+'" >'+n+"</a>"}return"IMAGE"===u.type?'<img src="'+u.data.src+'" alt="'+u.data.alt+'" style="float:'+(u.data.alignment||"none")+";height: "+u.data.height+";width: "+u.data.width+'"/>':"EMBEDDED_LINK"===u.type?'<iframe width="'+u.data.width+'" height="'+u.data.height+'" src="'+u.data.src+'" frameBorder="0"></iframe>':n}function y(t,e,n,r){var u=[],a=t.text;if(a.length>0)for(var i=s(t),o=void 0,h=n;h<r;h+=1)h!==n&&l(i,e,h)?(o.text.push(a[h]),o.end=h+1):(o={styles:f(i,h),text:[a[h]],start:h,end:h+1},u.push(o));return u}function O(t){if(t){for(var e=t,n=0;n<e.length&&" "===t[n];n+=1)e=e.replace(" ","&nbsp;");return e}return t}function d(t){if(t){for(var e=t,n=e.length-1;n>=0&&" "===e[n];n-=1)e=e.substring(0,n)+"&nbsp;"+e.substring(n+1);return e}return t}function I(t){var e=t.styles,n=t.text,r=c(n);return(0,L.forEach)(e,function(t,e){r=h(t,r,e)}),r}function T(t,e){var n=y(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],e.start,e.end),r="";return n.forEach(function(t){r+=I(t)}),r=g(e.styles,r)}function v(t,e,n,r){var u=[];y(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],n.start,n.end).forEach(function(e){u.push(T(t,e))});var a=u.join("");return"ENTITY"===n.type?void 0!==n.entityKey&&null!==n.entityKey&&(a=p(e,n.entityKey,a,r)):"HASHTAG"===n.type&&(a='<a href="'+a+'" class="wysiwyg-hashtag">'+a+"</a>"),a}function E(t,e,n,r){var u=[],a=i(t,n);return a.forEach(function(n,i){var o=v(t,e,n,r);0===i&&(o=O(o)),i===a.length-1&&(o=d(o)),u.push(o)}),u.join("")}function R(t,e,n,a,i){var s=[];if(o(t))s.push(p(e,t.entityRanges[0].key,void 0,i));else{var f=r(t.type);if(f){s.push("<"+f);var l=u(t.data);l&&s.push(' style="'+l+'"'),a&&s.push(' dir = "auto"'),s.push(">"),s.push(E(t,e,n,i)),s.push("</"+f+">")}}return s.push("\n"),s.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.getBlockTag=r,e.getBlockStyle=u,e.getStylesAtOffset=f,e.sameStyleAsPrevious=l,e.addInlineStyleMarkup=h,e.addStylePropertyMarkup=g,e.trimLeadingZeros=O,e.trimTrailingZeros=d,e.getBlockInnerMarkup=E,e.getBlockMarkup=R;var L=n(2),S={unstyled:"p","header-one":"h1","header-two":"h2","header-three":"h3","header-four":"h4","header-five":"h5","header-six":"h6","unordered-list-item":"ul","ordered-list-item":"ol",blockquote:"blockquote"}},function(t,e,n){"use strict";function r(t,e,n,r){var i=[];if(t){var o=t.blocks,s=t.entityMap;if(o&&o.length>0){var f=[];if(o.forEach(function(t){if((0,a.isList)(t.type))f.push(t);else{if(f.length>0){var o=(0,a.getListMarkup)(f,s,e,r);i.push(o),f=[]}var l=(0,u.getBlockMarkup)(t,s,e,n,r);i.push(l)}}),f.length>0){var l=(0,a.getListMarkup)(f,s,e,n,r);i.push(l),f=[]}}}return i.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var u=n(0),a=n(3)},function(t,e,n){"use strict";function r(t,e){if(t)for(var n in t)({}).hasOwnProperty.call(t,n)&&e(n,t[n])}function u(t){return void 0===t||null===t||0===t.length||0===t.trim().length}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=r,e.isEmptyString=u},function(t,e,n){"use strict";function r(t){return"unordered-list-item"===t||"ordered-list-item"===t}function u(t,e,n,r,i){var o=[],s=[],f=void 0;return t.forEach(function(t){var l=!1;if(f?f.type!==t.type?(o.push("</"+(0,a.getBlockTag)(f.type)+">\n"),o.push("<"+(0,a.getBlockTag)(t.type)+">\n")):f.depth===t.depth?s&&s.length>0&&(o.push(u(s,e,n,r,i)),s=[]):(l=!0,s.push(t)):o.push("<"+(0,a.getBlockTag)(t.type)+">\n"),!l){o.push("<li");var h=(0,a.getBlockStyle)(t.data);h&&o.push(' style="'+h+'"'),r&&o.push(' dir = "auto"'),o.push(">"),o.push((0,a.getBlockInnerMarkup)(t,e,n,i)),o.push("</li>\n"),f=t}}),s&&s.length>0&&o.push(u(s,e,n,r,i)),o.push("</"+(0,a.getBlockTag)(f.type)+">\n"),o.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.isList=r,e.getListMarkup=u;var a=n(0)},function(t,e,n){t.exports=n(1)}]);
{
"name": "draftjs-to-html",
"version": "0.7.2",
"version": "0.7.3",
"description": "A library for draftjs to html conversion.",

@@ -5,0 +5,0 @@ "main": "lib/draftjs-to-html.js",

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