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

draftjs-to-markdown

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draftjs-to-markdown - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

3

lib/draftjs-to-markdown.js

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

module.exports=function(t){function e(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return t[r].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){t.exports=n(2)},function(t,e){"use strict";function n(t,e){if(t)for(var n in t)({}).hasOwnProperty.call(t,n)&&e(n,t[n])}function r(t){return void 0===t||null===t||0===t.length||0===t.trim().length}function a(t){return"unordered-list-item"===t||"ordered-list-item"===t}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=n,e.isEmptyString=r,e.isList=a},function(t,e,n){"use strict";function r(t){return t.type&&v[t.type]}function a(t){return!!(t.entityRanges.length>0&&(0,C.isEmptyString)(t.text))}function o(t,e,n){var r=t[e];return"LINK"===r.type||"MENTION"===r.type?"["+n+"]("+r.data.url+")":"IMAGE"===r.type?"!("+r.data.src+")":"EMBEDDED_LINK"===r.type?'<iframe width="'+r.data.width+'" height="'+r.data.height+'" src="'+r.data.src+'" frameBorder="0" allowFullScreen />':n}function s(t,e){var n=[],r=0;return t.forEach(function(t){t.offset>r&&n.push({start:r,end:t.offset-1}),n.push({start:t.offset,end:t.offset+t.length,entityKey:t.key}),r=t.offset+t.length}),r<e&&n.push({start:r,end:e}),n}function i(t){var e=t.text,n=t.inlineStyleRanges,r={COLOR:new Array(e.length),BGCOLOR:new Array(e.length),FONTSIZE:new Array(e.length),FONTFAMILY:new Array(e.length),SUBSCRIPT:new Array(e.length),SUPERSCRIPT:new Array(e.length),CODE:new Array(e.length),STRIKETHROUGH:new Array(e.length),UNDERLINE:new Array(e.length),ITALIC:new Array(e.length),BOLD: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,a=e;a<n;a+=1)t.style.startsWith("color-")?r.COLOR[a]=t.style.substring(6):t.style.startsWith("bgcolor-")?r.BGCOLOR[a]=t.style.substring(8):t.style.startsWith("fontsize-")?r.FONTSIZE[a]=t.style.substring(9):t.style.startsWith("fontfamily-")?r.FONTFAMILY[a]=t.style.substring(11):r[t.style]&&(r[t.style][a]=!0)}),r}function u(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 l(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.SUBSCRIPT[e]&&(n.SUBSCRIPT=!0),t.SUPERSCRIPT[e]&&(n.SUPERSCRIPT=!0),t.CODE[e]&&(n.CODE=!0),t.STRIKETHROUGH[e]&&(n.STRIKETHROUGH=!0),t.UNDERLINE[e]&&(n.UNDERLINE=!0),t.ITALIC[e]&&(n.ITALIC=!0),t.BOLD[e]&&(n.BOLD=!0),n}function f(t,e,n,r){var a=[],o=t.text;if(o.length>0)for(var s=i(t),f=void 0,c=n;c<r;c+=1)c!==n&&u(s,e,c)?(f.text.push(o[c]),f.end=c+1):(f={styles:l(s,c),text:[o[c]],start:c,end:c+1},a.push(f));return a}function c(t){if(t&&t.length>0){var e=t.map(function(t){switch(t){case"\n":return"\\s\\s\n";case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";default:return t}});return e.join("")}return""}function O(t,e){return"BOLD"===t?"**"+e+"**":"ITALIC"===t?"*"+e+"*":"UNDERLINE"===t?"__"+e+"__":"STRIKETHROUGH"===t?"~~"+e+"~~":"CODE"===t?"`"+e+"`":"SUPERSCRIPT"===t?"<sup>"+e+"</sup>":"SUBSCRIPT"===t?"<sub>"+e+"</sub>":e}function h(t,e){var n=e;return(0,C.forEach)(t,function(t,e){n=O(t,n,e)}),n}function y(t){var e=t.styles,n=t.text,r=c(n);if(e&&(e.COLOR||e.BGCOLOR||e.FONTSIZE||e.FONTFAMILY)){var a='style="';return e.COLOR&&(a+="color: "+e.COLOR+";"),e.BGCOLOR&&(a+="background-color: "+e.BGCOLOR+";"),e.FONTSIZE&&(a+="font-size: "+e.FONTSIZE+"px;"),e.FONTFAMILY&&(a+="font-family: "+e.FONTFAMILY+";"),a+='"',"<span "+a+">"+r+"</span>"}return r}function d(t,e,n){var r=[],a=f(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],n.start,n.end),s="";a.forEach(function(e){var n=f(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],e.start,e.end),r="";n.forEach(function(t){r+=y(t)}),s+=h(e.styles,r)}),r.push(s);var i=r.join("");return void 0!==n.entityKey&&null!==n.entityKey&&(i=o(e,n.entityKey,i)),i}function I(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 g(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 R(t,e){if(a(t))return o(e,t.entityRanges[0].key,"");var n=[],r=s(t.entityRanges,t.text.length);return r.forEach(function(a,o){var s=d(t,e,a);0===o&&(s=I(s)),o===r.length-1&&(s=g(s)),n.push(s)}),n.join("")}function E(t){var e="";return(0,C.forEach)(t,function(t,n){e+=t+":"+n+";"}),e}function p(t,e){var n=E(t);return n?'<span style="'+n+'">'+e+"</span>":e}function L(t,e){var n=[];n.push(r(t));var a=R(t,e);return t.data&&(a=p(t.data,a)),n.push(a),n.push("\n"),n.join("")}function T(t){for(var e="",n=0;n<4*t;n+=1)e+=" ";return e}function S(t){var e=[];return t&&!function(){var n=t.blocks,r=t.entityMap;n&&n.length>0&&n.forEach(function(t){var n=L(t,r);(0,C.isList)(t.type)&&(n=T(t.depth)+n),e.push(n)})}(),e.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.getBlockTagSymbol=r,e.sameStyleAsPrevious=u,e.getStylesAtOffset=l,e.addInlineStyleMarkup=O,e.addStylePropertyMarkdown=y,e.trimLeadingZeros=I,e.trimTrailingZeros=g,e.getBlockContentMarkdown=R,e.getBlockStyle=E,e.default=S;var C=n(1),v={unstyled:"","header-one":"# ","header-two":"## ","header-three":"### ","header-four":"#### ","header-five":"##### ","header-six":"###### ","unordered-list-item":"- ","ordered-list-item":"1. ",blockquote:"> "}}]);
//# sourceMappingURL=draftjs-to-markdown.js.map
module.exports=function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.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=2)}([function(t,e,n){"use strict";function r(t){return t.type&&C[t.type]}function o(t){return!!(t.entityRanges.length>0&&(0,v.isEmptyString)(t.text))}function u(t,e,n){var r=t[e];return"LINK"===r.type||"MENTION"===r.type?"["+n+"]("+r.data.url+")":"IMAGE"===r.type?"!("+r.data.src+")":"EMBEDDED_LINK"===r.type?'<iframe width="'+r.data.width+'" height="'+r.data.height+'" src="'+r.data.src+'" frameBorder="0" allowFullScreen />':n}function a(t,e){var n=[],r=0;return t.forEach(function(t){t.offset>r&&n.push({start:r,end:t.offset-1}),n.push({start:t.offset,end:t.offset+t.length,entityKey:t.key}),r=t.offset+t.length}),r<e&&n.push({start:r,end:e}),n}function i(t){var e=t.text,n=t.inlineStyleRanges,r={COLOR:new Array(e.length),BGCOLOR:new Array(e.length),FONTSIZE:new Array(e.length),FONTFAMILY:new Array(e.length),SUBSCRIPT:new Array(e.length),SUPERSCRIPT:new Array(e.length),CODE:new Array(e.length),STRIKETHROUGH:new Array(e.length),UNDERLINE:new Array(e.length),ITALIC:new Array(e.length),BOLD: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,o=e;o<n;o+=1)t.style.startsWith("color-")?r.COLOR[o]=t.style.substring(6):t.style.startsWith("bgcolor-")?r.BGCOLOR[o]=t.style.substring(8):t.style.startsWith("fontsize-")?r.FONTSIZE[o]=t.style.substring(9):t.style.startsWith("fontfamily-")?r.FONTFAMILY[o]=t.style.substring(11):r[t.style]&&(r[t.style][o]=!0)}),r}function s(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 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.SUBSCRIPT[e]&&(n.SUBSCRIPT=!0),t.SUPERSCRIPT[e]&&(n.SUPERSCRIPT=!0),t.CODE[e]&&(n.CODE=!0),t.STRIKETHROUGH[e]&&(n.STRIKETHROUGH=!0),t.UNDERLINE[e]&&(n.UNDERLINE=!0),t.ITALIC[e]&&(n.ITALIC=!0),t.BOLD[e]&&(n.BOLD=!0),n}function l(t,e,n,r){var o=[],u=t.text;if(u.length>0)for(var a=i(t),l=void 0,c=n;c<r;c+=1)c!==n&&s(a,e,c)?(l.text.push(u[c]),l.end=c+1):(l={styles:f(a,c),text:[u[c]],start:c,end:c+1},o.push(l));return o}function c(t){if(t&&t.length>0){var e=t.map(function(t){switch(t){case"\n":return"\\s\\s\n";case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";default:return t}});return e.join("")}return""}function O(t,e){return"BOLD"===t?"**"+e+"**":"ITALIC"===t?"*"+e+"*":"UNDERLINE"===t?"__"+e+"__":"STRIKETHROUGH"===t?"~~"+e+"~~":"CODE"===t?"`"+e+"`":"SUPERSCRIPT"===t?"<sup>"+e+"</sup>":"SUBSCRIPT"===t?"<sub>"+e+"</sub>":e}function h(t,e){var n=e;return(0,v.forEach)(t,function(t,e){n=O(t,n,e)}),n}function y(t){var e=t.styles,n=t.text,r=c(n);if(e&&(e.COLOR||e.BGCOLOR||e.FONTSIZE||e.FONTFAMILY)){var o='style="';return e.COLOR&&(o+="color: "+e.COLOR+";"),e.BGCOLOR&&(o+="background-color: "+e.BGCOLOR+";"),e.FONTSIZE&&(o+="font-size: "+e.FONTSIZE+"px;"),e.FONTFAMILY&&(o+="font-family: "+e.FONTFAMILY+";"),o+='"',"<span "+o+">"+r+"</span>"}return r}function d(t,e,n){var r=[],o=l(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],n.start,n.end),a="";o.forEach(function(e){var n=l(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],e.start,e.end),r="";n.forEach(function(t){r+=y(t)}),a+=h(e.styles,r)}),r.push(a);var i=r.join("");return void 0!==n.entityKey&&null!==n.entityKey&&(i=u(e,n.entityKey,i)),i}function g(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 I(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 R(t,e){if(o(t))return u(e,t.entityRanges[0].key,"");var n=[],r=a(t.entityRanges,t.text.length);return r.forEach(function(o,u){var a=d(t,e,o);0===u&&(a=g(a)),u===r.length-1&&(a=I(a)),n.push(a)}),n.join("")}function p(t){var e="";return(0,v.forEach)(t,function(t,n){e+=t+":"+n+";"}),e}function E(t,e){var n=p(t);return n?'<span style="'+n+'">'+e+"</span>":e}function L(t,e){var n=[];n.push(r(t));var o=R(t,e);return t.data&&(o=E(t.data,o)),n.push(o),n.push("\n"),n.join("")}function T(t){for(var e="",n=0;n<4*t;n+=1)e+=" ";return e}function S(t){var e=[];return t&&!function(){var n=t.blocks,r=t.entityMap;n&&n.length>0&&n.forEach(function(t){var n=L(t,r);(0,v.isList)(t.type)&&(n=T(t.depth)+n),e.push(n)})}(),e.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.getBlockTagSymbol=r,e.sameStyleAsPrevious=s,e.getStylesAtOffset=f,e.addInlineStyleMarkup=O,e.addStylePropertyMarkdown=y,e.trimLeadingZeros=g,e.trimTrailingZeros=I,e.getBlockContentMarkdown=R,e.getBlockStyle=p,e.default=S;var v=n(1),C={unstyled:"","header-one":"# ","header-two":"## ","header-three":"### ","header-four":"#### ","header-five":"##### ","header-six":"###### ","unordered-list-item":"- ","ordered-list-item":"1. ",blockquote:"> "}},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 o(t){return void 0===t||null===t||0===t.length||0===t.trim().length}function u(t){return"unordered-list-item"===t||"ordered-list-item"===t}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=r,e.isEmptyString=o,e.isList=u},function(t,e,n){t.exports=n(0)}]);
{
"name": "draftjs-to-markdown",
"version": "0.2.0",
"version": "0.3.0",
"description": "A library for draftjs to markdown conversion.",

@@ -20,6 +20,6 @@ "main": "lib/draftjs-to-markdown.js",

"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-mocha": "^4.8.0",
"eslint-plugin-react": "^6.9.0",
"flow-bin": "^0.37.4",
"flow-bin": "^0.38.0",
"immutable": "^3.8.1",

@@ -33,3 +33,3 @@ "jsdom": "^9.9.1",

"sinon": "^1.17.7",
"webpack": "^1.14.0",
"webpack": "^2.2.1",
"webpack-dev-middleware": "^1.9.0"

@@ -36,0 +36,0 @@ },

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