draftjs-to-markdown
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -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.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=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function r(t){return!!(t.entityRanges.length>0&&(0,C.isEmptyString)(t.text))}function o(t,e,n,r){var o=t[e];if("function"==typeof r){var a=r(o,n);if(a)return a}return"MENTION"===o.type?"["+n+"]("+o.data.url+")":"LINK"===o.type?"["+n+"]("+o.data.url+")":"IMAGE"===o.type?"!["+(o.data.alt||"")+"]("+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 a(t,e){var n=[];if(e)for(var r=0,o=0,a=t,i=e.trigger||"#",u=e.separator||" ";a.length>0&&o>=0;)if(a[0]===i?(o=0,r=0,a=a.substr(i.length)):(o=a.indexOf(u+i))>=0&&(a=a.substr(o+(u+i).length),r+=o+u.length),o>=0){var s=a.indexOf(u)>=0?a.indexOf(u):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,o=t.entityRanges.map(function(t){return{offset:t.offset,length:t.length,key:t.key,type:"ENTITY"}});return o=o.concat(a(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 u(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 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=[],a=t.text;if(a.length>0)for(var i=u(t),l=void 0,c=n;c<r;c+=1)c!==n&&s(i,e,c)?(l.text.push(a[c]),l.end=c+1):(l={styles:f(i,c),text:[a[c]],start:c,end:c+1},o.push(l));return o}function c(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 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 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 g(t,e,n,r){var a=[],i=l(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],n.start,n.end),u="";i.forEach(function(e){var n=l(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],e.start,e.end),r="";n.forEach(function(t){r+=y(t)}),u+=h(e.styles,r)}),a.push(u);var s=a.join("");return"ENTITY"===n.type?void 0!==n.entityKey&&null!==n.entityKey&&(s=o(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 d(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 I(t,e,n,a){if(r(t))return o(e,t.entityRanges[0].key,void 0,a);var u=[],s=i(t,n);return s.forEach(function(n,r){var o=g(t,e,n,a);0===r&&(o=p(o)),r===s.length-1&&(o=d(o)),u.push(o)}),u.join("")}function E(t){var e="";return(0,C.forEach)(t,function(t,n){e+=t+":"+n+";"}),e}function T(t,e){var n=E(t);return n?'<span style="'+n+'">'+e+"</span>":e}function R(t,e,n,r,o,a){var i=[];i.push(e[t.type]);var u=I(t,n,r,o);return t.data&&(u=T(t.data,u)),i.push(u),i.push(a&&a.emptyLineBeforeBlock?"\n\n":"\n"),i.join("")}function L(t){for(var e="",n=0;n<4*t;n+=1)e+=" ";return e}function v(t,e,n,r){var o=[];if(t){var a=S({},N,r&&r.blockTypesMapping&&r.blockTypesMapping),i=t.blocks,u=t.entityMap;i&&i.length>0&&i.forEach(function(t){var i=R(t,a,u,e,n,r);(0,C.isList)(t.type)&&(i=L(t.depth)+i),o.push(i)})}return o.join("")}Object.defineProperty(e,"__esModule",{value:!0});var S=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e.sameStyleAsPrevious=s,e.getStylesAtOffset=f,e.addInlineStyleMarkdown=O,e.addStylePropertyMarkdown=y,e.trimLeadingZeros=p,e.trimTrailingZeros=d,e.getBlockContentMarkdown=I,e.getBlockStyle=E,e.default=v;var C=n(2),N={unstyled:"","header-one":"# ","header-two":"## ","header-three":"### ","header-four":"#### ","header-five":"##### ","header-six":"###### ","unordered-list-item":"- ","ordered-list-item":"1. ",blockquote:"> ",code:" "}},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 a(t){return"unordered-list-item"===t||"ordered-list-item"===t}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=r,e.isEmptyString=o,e.isList=a}]); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.draftjsToMarkdown=e():t.draftjsToMarkdown=e()}("undefined"!=typeof self?self:this,function(){return 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.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=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function r(t){return!!(t.entityRanges.length>0&&(0,C.isEmptyString)(t.text))}function o(t,e,n,r){var o=t[e];if("function"==typeof r){var i=r(o,n);if(i)return i}return"MENTION"===o.type?"["+n+"]("+o.data.url+")":"LINK"===o.type?"["+n+"]("+o.data.url+")":"IMAGE"===o.type?"!["+(o.data.alt||"")+"]("+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,i=t,a=e.trigger||"#",u=e.separator||" ";i.length>0&&o>=0;)if(i[0]===a?(o=0,r=0,i=i.substr(a.length)):(o=i.indexOf(u+a))>=0&&(i=i.substr(o+(u+a).length),r+=o+u.length),o>=0){var f=i.indexOf(u)>=0?i.indexOf(u):i.length,s=i.substr(0,f);s&&s.length>0&&n.push({offset:r,length:s.length+a.length,type:"HASHTAG"}),r+=a.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 u(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 s(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=[],i=t.text;if(i.length>0)for(var a=u(t),l=void 0,c=n;c<r;c+=1)c!==n&&f(a,e,c)?(l.text.push(i[c]),l.end=c+1):(l={styles:s(a,c),text:[i[c]],start:c,end:c+1},o.push(l));return o}function c(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 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 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 i=[],a=l(t,["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"],n.start,n.end),u="";a.forEach(function(e){var n=l(t,["COLOR","BGCOLOR","FONTSIZE","FONTFAMILY"],e.start,e.end),r="";n.forEach(function(t){r+=y(t)}),u+=h(e.styles,r)}),i.push(u);var f=i.join("");return"ENTITY"===n.type?void 0!==n.entityKey&&null!==n.entityKey&&(f=o(e,n.entityKey,f,r)):"HASHTAG"===n.type&&(f="["+f+"]("+f+")"),f}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 g(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 I(t,e,n,i){if(r(t))return o(e,t.entityRanges[0].key,void 0,i);var u=[],f=a(t,n);return f.forEach(function(n,r){var o=d(t,e,n,i);0===r&&(o=p(o)),r===f.length-1&&(o=g(o)),u.push(o)}),u.join("")}function T(t){var e="";return(0,C.forEach)(t,function(t,n){e+=t+":"+n+";"}),e}function E(t,e){var n=T(t);return n?'<span style="'+n+'">'+e+"</span>":e}function R(t,e,n,r,o,i){var a=[];a.push(e[t.type]);var u=I(t,n,r,o);return t.data&&(u=E(t.data,u)),a.push(u),a.push(i&&i.emptyLineBeforeBlock?"\n\n":"\n"),a.join("")}function L(t){for(var e="",n=0;n<4*t;n+=1)e+=" ";return e}function v(t,e,n,r){var o=[];if(t){var i=S({},N,r&&r.blockTypesMapping&&r.blockTypesMapping),a=t.blocks,u=t.entityMap;a&&a.length>0&&a.forEach(function(t){var a=R(t,i,u,e,n,r);(0,C.isList)(t.type)&&(a=L(t.depth)+a),o.push(a)})}return o.join("")}Object.defineProperty(e,"__esModule",{value:!0});var S=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e.sameStyleAsPrevious=f,e.getStylesAtOffset=s,e.addInlineStyleMarkdown=O,e.addStylePropertyMarkdown=y,e.trimLeadingZeros=p,e.trimTrailingZeros=g,e.getBlockContentMarkdown=I,e.getBlockStyle=T,e.default=v;var C=n(2),N={unstyled:"","header-one":"# ","header-two":"## ","header-three":"### ","header-four":"#### ","header-five":"##### ","header-six":"###### ","unordered-list-item":"- ","ordered-list-item":"1. ",blockquote:"> ",code:" "}},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 i(t){return"unordered-list-item"===t||"ordered-list-item"===t}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=r,e.isEmptyString=o,e.isList=i}])}); |
{ | ||
"name": "draftjs-to-markdown", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "A library for draftjs to markdown conversion.", | ||
@@ -50,3 +50,3 @@ "main": "lib/draftjs-to-markdown.js", | ||
"license": "MIT", | ||
"dependencies": "" | ||
"dependencies": {} | ||
} |
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
168909