draftjs-to-markdown
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -1,1 +0,1 @@ | ||
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&&N[t.type]}function o(t){return!!(t.entityRanges.length>0&&(0,C.isEmptyString)(t.text))}function u(t,e,n,r){var o=t[e];if("function"==typeof r){var u=r(o,n);if(u)return u}return"MENTION"===o.type?"["+n+"]("+o.data.url+")":"LINK"===o.type?"["+o.data.title+"]("+o.data.url+")":"IMAGE"===o.type?"!("+o.data.src+")":"EMBEDDED_LINK"===o.type?'<iframe width="'+o.data.width+'" height="'+o.data.height+'" src="'+o.data.src+'" frameBorder="0" allowFullScreen />':n}function i(t,e){var n=[];if(e)for(var r=0,o=0,u=t,i=e.trigger||"#",a=e.separator||" ";u.length>0&&o>=0;)if(u[0]===i?(o=0,r=0,u=u.substr(i.length)):(o=u.indexOf(a+i),o>=0&&(u=u.substr(o+(a+i).length),r+=o+a.length)),o>=0){var s=u.indexOf(a)>=0?u.indexOf(a):u.length,f=u.substr(0,s);f&&f.length>0&&n.push({offset:r,length:f.length+i.length,type:"HASHTAG"}),r+=i.length}return n}function a(t,e){var n=[],r=0,o=t.entityRanges.map(function(t){var e=t.offset,n=t.length,r=t.key;return{offset:e,length:n,key:r,type:"ENTITY"}});return o=o.concat(i(t.text,e)),o=o.sort(function(t,e){return t.offset-e.offset}),o.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,type:t.type}),r=t.offset+t.length}),r<t.text.length&&n.push({start:r,end:t.text.length}),n}function s(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)0===t.style.indexOf("color-")?r.COLOR[o]=t.style.substring(6):0===t.style.indexOf("bgcolor-")?r.BGCOLOR[o]=t.style.substring(8):0===t.style.indexOf("fontsize-")?r.FONTSIZE[o]=t.style.substring(9):0===t.style.indexOf("fontfamily-")?r.FONTFAMILY[o]=t.style.substring(11):r[t.style]&&(r[t.style][o]=!0)}),r}function f(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 c(t,e,n,r){var o=[],u=t.text;if(u.length>0)for(var i=s(t),a=void 0,c=n;c<r;c+=1)c!==n&&f(i,e,c)?(a.text.push(u[c]),a.end=c+1):(a={styles:l(i,c),text:[u[c]],start:c,end:c+1},o.push(a));return o}function O(t){if(t&&t.length>0){var e=t.map(function(t){switch(t){case"\n":return"\\s\\s\n";case"&":return"&";case"<":return"<";case">":return">";default:return t}});return e.join("")}return""}function h(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 y(t,e){var n=e;return(0,C.forEach)(t,function(t,e){n=h(t,n,e)}),n}function g(t){var e=t.styles,n=t.text,r=O(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,r){var o=[],i=c(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],n.start,n.end),a="";i.forEach(function(e){var n=c(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],e.start,e.end),r="";n.forEach(function(t){r+=g(t)}),a+=y(e.styles,r)}),o.push(a);var s=o.join("");return"ENTITY"===n.type?void 0!==n.entityKey&&null!==n.entityKey&&(s=u(e,n.entityKey,s,r)):"HASHTAG"===n.type&&(s="["+s+"]("+s+")"),s}function p(t){if(t){for(var e=t,n=0;n<e.length&&" "===t[n];n+=1)e=e.replace(" "," ");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)+" "+e.substring(n+1);return e}return t}function E(t,e,n,r){if(o(t))return u(e,t.entityRanges[0].key,void 0,r);var i=[],s=a(t,n);return s.forEach(function(n,r){var o=d(t,e,n);0===r&&(o=p(o)),r===s.length-1&&(o=I(o)),i.push(o)}),i.join("")}function R(t){var e="";return(0,C.forEach)(t,function(t,n){e+=t+":"+n+";"}),e}function T(t,e){var n=R(t);return n?'<span style="'+n+'">'+e+"</span>":e}function L(t,e,n,o){var u=[];u.push(r(t));var i=E(t,e,n,o);return t.data&&(i=T(t.data,i)),u.push(i),u.push("\n"),u.join("")}function S(t){for(var e="",n=0;n<4*t;n+=1)e+=" ";return e}function v(t,e,n){var r=[];return t&&!function(){var o=t.blocks,u=t.entityMap;o&&o.length>0&&o.forEach(function(t){var o=L(t,u,e,n);(0,C.isList)(t.type)&&(o=S(t.depth)+o),r.push(o)})}(),r.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.getBlockTagSymbol=r,e.sameStyleAsPrevious=f,e.getStylesAtOffset=l,e.addInlineStyleMarkdown=h,e.addStylePropertyMarkdown=g,e.trimLeadingZeros=p,e.trimTrailingZeros=I,e.getBlockContentMarkdown=E,e.getBlockStyle=R,e.default=v;var C=n(1),N={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)}]); | ||
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&&N[t.type]}function o(t){return!!(t.entityRanges.length>0&&(0,C.isEmptyString)(t.text))}function u(t,e,n,r){var o=t[e];if("function"==typeof r){var u=r(o,n);if(u)return u}return"MENTION"===o.type?"["+n+"]("+o.data.url+")":"LINK"===o.type?"["+o.data.title+"]("+o.data.url+")":"IMAGE"===o.type?"!("+o.data.src+")":"EMBEDDED_LINK"===o.type?'<iframe width="'+o.data.width+'" height="'+o.data.height+'" src="'+o.data.src+'" frameBorder="0" allowFullScreen />':n}function i(t,e){var n=[];if(e)for(var r=0,o=0,u=t,i=e.trigger||"#",a=e.separator||" ";u.length>0&&o>=0;)if(u[0]===i?(o=0,r=0,u=u.substr(i.length)):(o=u.indexOf(a+i))>=0&&(u=u.substr(o+(a+i).length),r+=o+a.length),o>=0){var s=u.indexOf(a)>=0?u.indexOf(a):u.length,f=u.substr(0,s);f&&f.length>0&&n.push({offset:r,length:f.length+i.length,type:"HASHTAG"}),r+=i.length}return n}function a(t,e){var n=[],r=0,o=t.entityRanges.map(function(t){return{offset:t.offset,length:t.length,key:t.key,type:"ENTITY"}});return o=o.concat(i(t.text,e)),o=o.sort(function(t,e){return t.offset-e.offset}),o.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,type:t.type}),r=t.offset+t.length}),r<t.text.length&&n.push({start:r,end:t.text.length}),n}function s(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)0===t.style.indexOf("color-")?r.COLOR[o]=t.style.substring(6):0===t.style.indexOf("bgcolor-")?r.BGCOLOR[o]=t.style.substring(8):0===t.style.indexOf("fontsize-")?r.FONTSIZE[o]=t.style.substring(9):0===t.style.indexOf("fontfamily-")?r.FONTFAMILY[o]=t.style.substring(11):r[t.style]&&(r[t.style][o]=!0)}),r}function f(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 c(t,e,n,r){var o=[],u=t.text;if(u.length>0)for(var i=s(t),a=void 0,c=n;c<r;c+=1)c!==n&&f(i,e,c)?(a.text.push(u[c]),a.end=c+1):(a={styles:l(i,c),text:[u[c]],start:c,end:c+1},o.push(a));return o}function O(t){if(t&&t.length>0){return t.map(function(t){switch(t){case"\n":return"\\s\\s\n";case"&":return"&";case"<":return"<";case">":return">";default:return t}}).join("")}return""}function h(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 y(t,e){var n=e;return(0,C.forEach)(t,function(t,e){n=h(t,n,e)}),n}function g(t){var e=t.styles,n=t.text,r=O(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+";"),"<span "+(o+='"')+">"+r+"</span>"}return r}function d(t,e,n,r){var o=[],i=c(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],n.start,n.end),a="";i.forEach(function(e){var n=c(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],e.start,e.end),r="";n.forEach(function(t){r+=g(t)}),a+=y(e.styles,r)}),o.push(a);var s=o.join("");return"ENTITY"===n.type?void 0!==n.entityKey&&null!==n.entityKey&&(s=u(e,n.entityKey,s,r)):"HASHTAG"===n.type&&(s="["+s+"]("+s+")"),s}function p(t){if(t){for(var e=t,n=0;n<e.length&&" "===t[n];n+=1)e=e.replace(" "," ");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)+" "+e.substring(n+1);return e}return t}function E(t,e,n,r){if(o(t))return u(e,t.entityRanges[0].key,void 0,r);var i=[],s=a(t,n);return s.forEach(function(n,r){var o=d(t,e,n);0===r&&(o=p(o)),r===s.length-1&&(o=I(o)),i.push(o)}),i.join("")}function R(t){var e="";return(0,C.forEach)(t,function(t,n){e+=t+":"+n+";"}),e}function T(t,e){var n=R(t);return n?'<span style="'+n+'">'+e+"</span>":e}function L(t,e,n,o){var u=[];u.push(r(t));var i=E(t,e,n,o);return t.data&&(i=T(t.data,i)),u.push(i),u.push("\n"),u.join("")}function S(t){for(var e="",n=0;n<4*t;n+=1)e+=" ";return e}function v(t,e,n){var r=[];if(t){var o=t.blocks,u=t.entityMap;o&&o.length>0&&o.forEach(function(t){var o=L(t,u,e,n);(0,C.isList)(t.type)&&(o=S(t.depth)+o),r.push(o)})}return r.join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.getBlockTagSymbol=r,e.sameStyleAsPrevious=f,e.getStylesAtOffset=l,e.addInlineStyleMarkdown=h,e.addStylePropertyMarkdown=g,e.trimLeadingZeros=p,e.trimTrailingZeros=I,e.getBlockContentMarkdown=E,e.getBlockStyle=R,e.default=v;var C=n(1),N={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.3.2", | ||
"version": "0.4.0", | ||
"description": "A library for draftjs to markdown conversion.", | ||
"main": "lib/draftjs-to-markdown.js", | ||
"devDependencies": { | ||
"babel-core": "^6.21.0", | ||
"babel-core": "^6.23.1", | ||
"babel-eslint": "^7.1.1", | ||
"babel-loader": "^6.2.10", | ||
"babel-plugin-transform-flow-strip-types": "^6.21.0", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babel-preset-react": "^6.16.0", | ||
"babel-preset-stage-0": "^6.16.0", | ||
"babel-register": "^6.18.0", | ||
"babel-loader": "^6.4.0", | ||
"babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babel-preset-react": "^6.23.0", | ||
"babel-preset-stage-0": "^6.22.0", | ||
"babel-register": "^6.23.0", | ||
"chai": "^3.5.0", | ||
"enzyme": "^2.7.0", | ||
"eslint": "^3.13.1", | ||
"eslint-config-airbnb": "^14.0.0", | ||
"enzyme": "^2.7.1", | ||
"eslint": "^3.17.1", | ||
"eslint-config-airbnb": "^14.1.0", | ||
"eslint-plugin-import": "2.2.0", | ||
"eslint-plugin-jsx-a11y": "^4.0.0", | ||
"eslint-plugin-mocha": "^4.8.0", | ||
"eslint-plugin-react": "^6.9.0", | ||
"flow-bin": "^0.38.0", | ||
"immutable": "^3.8.1", | ||
"jsdom": "^9.9.1", | ||
"eslint-plugin-react": "^6.10.0", | ||
"flow-bin": "^0.41.0", | ||
"immutable": "^4.0.0-rc.1", | ||
"jsdom": "^9.11.0", | ||
"mocha": "^3.2.0", | ||
@@ -30,6 +30,6 @@ "react": "^15.4.2", | ||
"react-dom": "^15.4.2", | ||
"rimraf": "^2.5.4", | ||
"rimraf": "^2.6.1", | ||
"sinon": "^1.17.7", | ||
"webpack": "^2.2.1", | ||
"webpack-dev-middleware": "^1.9.0" | ||
"webpack-dev-middleware": "^1.10.1" | ||
}, | ||
@@ -36,0 +36,0 @@ "repository": { |
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
143063