medium-editor-markdown
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -9,4 +9,4 @@ # :eight_spoked_asterisk: :stars: :sparkles: :dizzy: :star2: :star2: :sparkles: :dizzy: :star2: :star2: Contributing :star: :star2: :dizzy: :sparkles: :star: :star2: :dizzy: :sparkles: :stars: :eight_spoked_asterisk: | ||
## Discuss the changes before doing them | ||
- First of all, open an issue in the repository, using the [bug tracker][1] | ||
describing the contribution you'd like to make, the bug you found or any | ||
- First of all, open an issue in the repository, using the [bug tracker][1], | ||
describing the contribution you would like to make, the bug you found or any | ||
other ideas you have. This will help us to get you started on the right | ||
@@ -16,7 +16,8 @@ foot. | ||
- If it makes sense, add the platform and software information (e.g. operating | ||
system, Node.JS version etc), screenshots (so we can see what you're seeing). | ||
system, Node.JS version etc.), screenshots (so we can see what you are | ||
seeing). | ||
- It's recommended to wait for feedback before continuing to next steps. However, | ||
if the issue is clear (e.g. a typo) and the fix is simple, you can continue | ||
and fix it. | ||
- It is recommended to wait for feedback before continuing to next steps. | ||
However, if the issue is clear (e.g. a typo) and the fix is simple, you can | ||
continue and fix it. | ||
@@ -31,4 +32,5 @@ ## Fixing issues | ||
- If the project contains a `package.json` file add yourself in the | ||
`contributors` array (if it doesn't exist, create it): | ||
- If the project contains a `package.json` or a `bower.json` file add yourself | ||
in the `contributors` array (or `authors` in the case of `bower.json`; | ||
if the array does not exist, create it): | ||
@@ -38,3 +40,3 @@ ```json | ||
"contributors": [ | ||
"Your Name <and@email.address> (http://your.website) | ||
"Your Name <and@email.address> (http://your.website)" | ||
] | ||
@@ -47,7 +49,7 @@ } | ||
- Open a pull request, and reference the initial issue in the pull request | ||
message (e.g. *fixes #<your-issue-number*). Write a good description and | ||
message (e.g. *fixes #<your-issue-number>*). Write a good description and | ||
title, so everybody will know what is fixed/improved. | ||
- If it makes sense, add screenshots, gifs etc, so it's easier to see what's | ||
going on. | ||
- If it makes sense, add screenshots, gifs etc., so it is easier to see what | ||
is going on. | ||
@@ -61,2 +63,3 @@ ## Wait for feedback | ||
Finally, your contributions will be merged, and everyone will be happy! :smile: | ||
Contributions are more than welcome! | ||
@@ -63,0 +66,0 @@ Thanks! :sweat_smile: |
@@ -19,11 +19,9 @@ (function (root) { | ||
// Called by medium-editor during init | ||
this.init = function (meInstance) { | ||
this.init = function () { | ||
this.me = meInstance; | ||
// If this instance of medium-editor doesn't have any elements, there's nothing for us to do | ||
if (!this.me.elements || !this.me.elements.length) { return; } | ||
if (!this.base.elements || !this.base.elements.length) { return; } | ||
// Element(s) that this instance of medium-editor is attached to is/are stored in .elements | ||
this.element = this.me.elements[0]; | ||
this.element = this.base.elements[0]; | ||
@@ -30,0 +28,0 @@ var handler = function () { |
@@ -1,1 +0,1 @@ | ||
!function(t){if("function"!=typeof MediumEditor)throw new Error("Medium Editor is not loaded on the page.");var n=function(t,n){"function"==typeof t&&(n=t,t={}),t=Object(t),t.events=t.events||["input","change"],n=n||t.callback||function(){},this.init=function(e){if(this.me=e,this.me.elements&&this.me.elements.length){this.element=this.me.elements[0];var i=function(){n(toMarkdown(this.element.innerHTML).split("\n").map(function(t){return t.trim()}).join("\n").trim())}.bind(this);t.events.forEach(function(t){this.element.addEventListener(t,i)}.bind(this)),i()}}};t.MeMarkdown=n}(this); | ||
!function(n){if("function"!=typeof MediumEditor)throw new Error("Medium Editor is not loaded on the page.");var t=function(n,t){"function"==typeof n&&(t=n,n={}),n=Object(n),n.events=n.events||["input","change"],t=t||n.callback||function(){},this.init=function(){if(this.base.elements&&this.base.elements.length){this.element=this.base.elements[0];var e=function(){t(toMarkdown(this.element.innerHTML).split("\n").map(function(n){return n.trim()}).join("\n").trim())}.bind(this);n.events.forEach(function(n){this.element.addEventListener(n,e)}.bind(this)),e()}}};n.MeMarkdown=t}(this); |
@@ -218,2 +218,8 @@ (function (root) { | ||
// Remove blank nodes | ||
if (!isVoid(node) && !/A/.test(node.nodeName) && /^\s*$/i.test(content)) { | ||
node._replacement = ''; | ||
return; | ||
} | ||
for (var i = 0; i < converters.length; i++) { | ||
@@ -241,7 +247,2 @@ var converter = converters[i]; | ||
// Remove blank nodes | ||
if (!isVoid(node) && !/A/.test(node.nodeName) && /^\s*$/i.test(content)) { | ||
replacement = ''; | ||
} | ||
node._replacement = replacement; | ||
@@ -291,3 +292,3 @@ } | ||
},{"./lib/gfm-converters":2,"./lib/md-converters":3,"collapse-whitespace":5,"jsdom":6}],2:[function(require,module,exports){ | ||
},{"./lib/gfm-converters":2,"./lib/md-converters":3,"collapse-whitespace":4,"jsdom":7}],2:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -557,3 +558,141 @@ | ||
},{}],4:[function(require,module,exports){ | ||
'use strict'; | ||
var voidElements = require('void-elements'); | ||
Object.keys(voidElements).forEach(function (name) { | ||
voidElements[name.toUpperCase()] = 1; | ||
}); | ||
var blockElements = {}; | ||
require('block-elements').forEach(function (name) { | ||
blockElements[name.toUpperCase()] = 1; | ||
}); | ||
/** | ||
* isBlockElem(node) determines if the given node is a block element. | ||
* | ||
* @param {Node} node | ||
* @return {Boolean} | ||
*/ | ||
function isBlockElem(node) { | ||
return !!(node && blockElements[node.nodeName]); | ||
} | ||
/** | ||
* isVoid(node) determines if the given node is a void element. | ||
* | ||
* @param {Node} node | ||
* @return {Boolean} | ||
*/ | ||
function isVoid(node) { | ||
return !!(node && voidElements[node.nodeName]); | ||
} | ||
/** | ||
* whitespace(elem [, isBlock]) removes extraneous whitespace from an | ||
* the given element. The function isBlock may optionally be passed in | ||
* to determine whether or not an element is a block element; if none | ||
* is provided, defaults to using the list of block elements provided | ||
* by the `block-elements` module. | ||
* | ||
* @param {Node} elem | ||
* @param {Function} blockTest | ||
*/ | ||
function collapseWhitespace(elem, isBlock) { | ||
if (!elem.firstChild || elem.nodeName === 'PRE') return; | ||
if (typeof isBlock !== 'function') { | ||
isBlock = isBlockElem; | ||
} | ||
var prevText = null; | ||
var prevVoid = false; | ||
var prev = null; | ||
var node = next(prev, elem); | ||
while (node !== elem) { | ||
if (node.nodeType === 3) { | ||
// Node.TEXT_NODE | ||
var text = node.data.replace(/[ \r\n\t]+/g, ' '); | ||
if ((!prevText || / $/.test(prevText.data)) && !prevVoid && text[0] === ' ') { | ||
text = text.substr(1); | ||
} | ||
// `text` might be empty at this point. | ||
if (!text) { | ||
node = remove(node); | ||
continue; | ||
} | ||
node.data = text; | ||
prevText = node; | ||
} else if (node.nodeType === 1) { | ||
// Node.ELEMENT_NODE | ||
if (isBlock(node) || node.nodeName === 'BR') { | ||
if (prevText) { | ||
prevText.data = prevText.data.replace(/ $/, ''); | ||
} | ||
prevText = null; | ||
prevVoid = false; | ||
} else if (isVoid(node)) { | ||
// Avoid trimming space around non-block, non-BR void elements. | ||
prevText = null; | ||
prevVoid = true; | ||
} | ||
} else { | ||
node = remove(node); | ||
continue; | ||
} | ||
var nextNode = next(prev, node); | ||
prev = node; | ||
node = nextNode; | ||
} | ||
if (prevText) { | ||
prevText.data = prevText.data.replace(/ $/, ''); | ||
if (!prevText.data) { | ||
remove(prevText); | ||
} | ||
} | ||
} | ||
/** | ||
* remove(node) removes the given node from the DOM and returns the | ||
* next node in the sequence. | ||
* | ||
* @param {Node} node | ||
* @return {Node} node | ||
*/ | ||
function remove(node) { | ||
var next = node.nextSibling || node.parentNode; | ||
node.parentNode.removeChild(node); | ||
return next; | ||
} | ||
/** | ||
* next(prev, current) returns the next node in the sequence, given the | ||
* current and previous nodes. | ||
* | ||
* @param {Node} prev | ||
* @param {Node} current | ||
* @return {Node} | ||
*/ | ||
function next(prev, current) { | ||
if (prev && prev.parentNode === current || current.nodeName === 'PRE') { | ||
return current.nextSibling || current.parentNode; | ||
} | ||
return current.firstChild || current.nextSibling || current.parentNode; | ||
} | ||
module.exports = collapseWhitespace; | ||
},{"block-elements":5,"void-elements":6}],5:[function(require,module,exports){ | ||
/** | ||
* This file automatically generated from `build.js`. | ||
@@ -587,2 +726,4 @@ * Do not manually edit. | ||
"hr", | ||
"main", | ||
"nav", | ||
"noscript", | ||
@@ -600,124 +741,29 @@ "ol", | ||
},{}],5:[function(require,module,exports){ | ||
'use strict'; | ||
var blocks = require('block-elements').map(function (name) { | ||
return name.toUpperCase() | ||
}) | ||
function defaultBlockTest (node) { | ||
return isElem(node) && blocks.indexOf(node.nodeName) >= 0 | ||
} | ||
function isText (node) { | ||
return node && node.nodeType === 3 | ||
} | ||
function isElem (node) { | ||
return node && node.nodeType === 1 | ||
} | ||
},{}],6:[function(require,module,exports){ | ||
/** | ||
* whitespace(elem [, isBlock]) removes extraneous whitespace from an | ||
* the given element. The function isBlock may optionally be passed in | ||
* to determine whether or not an element is a block element; if none | ||
* is provided, defaults to using the list of block elements provided | ||
* by the `block-elements` module. | ||
* | ||
* @param {Element} root | ||
* @param {Function} isBlock | ||
* This file automatically generated from `pre-publish.js`. | ||
* Do not manually edit. | ||
*/ | ||
function whitespace (root, isBlock) { | ||
var startSpace = /^ /, | ||
endSpace = / $/, | ||
nextNode, | ||
prevNode, | ||
prevText, | ||
node, | ||
text | ||
if (typeof isBlock !== 'function') | ||
isBlock = defaultBlockTest | ||
module.exports = { | ||
"area": true, | ||
"base": true, | ||
"br": true, | ||
"col": true, | ||
"embed": true, | ||
"hr": true, | ||
"img": true, | ||
"input": true, | ||
"keygen": true, | ||
"link": true, | ||
"menuitem": true, | ||
"meta": true, | ||
"param": true, | ||
"source": true, | ||
"track": true, | ||
"wbr": true | ||
}; | ||
function next (node) { | ||
while (node && node !== root) { | ||
if (node.nextSibling) | ||
return node.nextSibling | ||
},{}],7:[function(require,module,exports){ | ||
node = node.parentNode | ||
if (prevText && isBlock(node)) { | ||
prevText.data = prevText.data.replace(/[ \r\n\t]$/, '') | ||
prevText = null | ||
} | ||
} | ||
return null | ||
} | ||
function first (node) { | ||
return node.firstChild ? node.firstChild : next(node) | ||
} | ||
function remove (node) { | ||
var nextNode = next(node) | ||
node.parentNode.removeChild(node) | ||
return nextNode | ||
} | ||
if (root.nodeName === 'PRE') return | ||
// Join adjacent text nodes and whatnot. | ||
root.normalize() | ||
node = first(root) | ||
while (node) { | ||
prevNode = node.previousSibling | ||
nextNode = node.nextSibling | ||
if (isText(node)) { | ||
text = node.data.replace(/[ \r\n\t]+/g, ' ') | ||
if (!prevText || prevNode && isBlock(prevNode)) | ||
text = text.replace(startSpace, '') | ||
if (nextNode && isBlock(nextNode)) | ||
text = text.replace(endSpace, '') | ||
if (prevText && endSpace.test(prevText.data) && | ||
startSpace.test(text)) | ||
text = text.substr(1) | ||
if (text) { | ||
node.data = text | ||
prevText = node | ||
node = next(node) | ||
} else { | ||
node = remove(node) | ||
} | ||
} else if (isElem(node)) { | ||
if (node.nodeName === 'PRE') { | ||
node = next(node) | ||
continue | ||
} | ||
if (prevText && isBlock(node)) { | ||
prevText.data = prevText.data.replace(endSpace, '') | ||
prevText = null | ||
} | ||
node = first(node) | ||
} else { | ||
node = remove(node) | ||
} | ||
} | ||
// Trim trailing space from last text node | ||
if (prevText) | ||
prevText.data = prevText.data.replace(endSpace, '') | ||
} | ||
module.exports = whitespace | ||
},{"block-elements":4}],6:[function(require,module,exports){ | ||
},{}]},{},[1])(1) | ||
@@ -739,11 +785,9 @@ }); | ||
// Called by medium-editor during init | ||
this.init = function (meInstance) { | ||
this.init = function () { | ||
this.me = meInstance; | ||
// If this instance of medium-editor doesn't have any elements, there's nothing for us to do | ||
if (!this.me.elements || !this.me.elements.length) { return; } | ||
if (!this.base.elements || !this.base.elements.length) { return; } | ||
// Element(s) that this instance of medium-editor is attached to is/are stored in .elements | ||
this.element = this.me.elements[0]; | ||
this.element = this.base.elements[0]; | ||
@@ -750,0 +794,0 @@ var handler = function () { |
@@ -1,1 +0,1 @@ | ||
!function(e){if("function"!=typeof MediumEditor)throw new Error("Medium Editor is not loaded on the page.");!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.toMarkdown=e()}}(function(){return function e(n,t,r){function i(a,c){if(!t[a]){if(!n[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var f=t[a]={exports:{}};n[a][0].call(f.exports,function(e){var t=n[a][1][e];return i(t?t:e)},f,f.exports,e,n,t,r)}return t[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,n){"use strict";function t(e){return e.replace(/^[ \r\n\t]+|[ \r\n\t]+$/g,"")}function r(e){return-1!==w.indexOf(e.nodeName.toLowerCase())}function i(e){return-1!==C.indexOf(e.nodeName.toLowerCase())}function o(){var e=x.DOMParser,n=!1;try{(new e).parseFromString("","text/html")&&(n=!0)}catch(t){}return n}function a(){var e=function(){};return e.prototype.parseFromString=function(e){var n=v.implementation.createHTMLDocument("");return e.toLowerCase().indexOf("<!doctype")>-1?n.documentElement.innerHTML=e:n.body.innerHTML=e,n},e}function c(e){var n=(new E).parseFromString(e,"text/html");return y(n,r),n}function l(e){for(var n,t,r,i=[e],o=[];i.length>0;)for(n=i.shift(),o.push(n),t=n.childNodes,r=0;r<t.length;r++)1===t[r].nodeType&&i.push(t[r]);return o.shift(),o}function u(e){for(var n="",t=0;t<e.childNodes.length;t++)if(1===e.childNodes[t].nodeType)n+=e.childNodes[t]._replacement;else{if(3!==e.childNodes[t].nodeType)continue;n+=e.childNodes[t].data}return n}function f(e,n){return e.cloneNode(!1).outerHTML.replace("><",">"+n+"<")}function d(e,n){if("string"==typeof n)return n===e.nodeName.toLowerCase();if(Array.isArray(n))return-1!==n.indexOf(e.nodeName.toLowerCase());if("function"==typeof n)return n.call(h,e);throw new TypeError("`filter` needs to be a string, array, or function")}function s(e,n){var t,i,o;return"left"===e?(t=n.previousSibling,i=/ $/):(t=n.nextSibling,i=/^ /),t&&(3===t.nodeType?o=i.test(t.nodeValue):1!==t.nodeType||r(t)||(o=i.test(t.textContent))),o}function p(e){var n="",t="";if(!r(e)){var i=/^[ \r\n\t]/.test(e.innerHTML),o=/[ \r\n\t]$/.test(e.innerHTML);i&&!s("left",e)&&(n=" "),o&&!s("right",e)&&(t=" ")}return{leading:n,trailing:t}}function m(e){for(var n,r=u(e),o=0;o<g.length;o++){var a=g[o];if(d(e,a.filter)){if("function"!=typeof a.replacement)throw new TypeError("`replacement` needs to be a function that returns a string");var c=p(e);(c.leading||c.trailing)&&(r=t(r)),n=c.leading+a.replacement.call(h,r,e)+c.trailing;break}}i(e)||/A/.test(e.nodeName)||!/^\s*$/i.test(r)||(n=""),e._replacement=n}var h,g,v,N=e("./lib/md-converters"),b=e("./lib/gfm-converters"),y=e("collapse-whitespace"),x="undefined"!=typeof window?window:this;v="undefined"==typeof document?e("jsdom").jsdom():document;var w=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"],C=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],E=o()?x.DOMParser:a();h=function(e,n){if(n=n||{},"string"!=typeof e)throw new TypeError(e+" is not a string");e=e.replace(/(\d+)\. /g,"$1\\. ");var t,r=c(e).body,i=l(r);g=N.slice(0),n.gfm&&(g=b.concat(g)),n.converters&&(g=n.converters.concat(g));for(var o=i.length-1;o>=0;o--)m(i[o]);return t=u(r),t.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,"").replace(/\n\s+\n/g,"\n\n").replace(/\n{3,}/g,"\n\n")},h.isBlock=r,h.isVoid=i,h.trim=t,h.outer=f,n.exports=h},{"./lib/gfm-converters":2,"./lib/md-converters":3,"collapse-whitespace":5,jsdom:6}],2:[function(e,n){"use strict";function t(e,n){var t=Array.prototype.indexOf.call(n.parentNode.childNodes,n),r=" ";return 0===t&&(r="| "),r+e+" |"}var r=/highlight highlight-(\S+)/;n.exports=[{filter:"br",replacement:function(){return"\n"}},{filter:["del","s","strike"],replacement:function(e){return"~~"+e+"~~"}},{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,n){return(n.checked?"[x]":"[ ]")+" "}},{filter:["th","td"],replacement:function(e,n){return t(e,n)}},{filter:"tr",replacement:function(e,n){var r="",i={left:":--",right:"--:",center:":-:"};if("THEAD"===n.parentNode.nodeName)for(var o=0;o<n.childNodes.length;o++){var a=n.childNodes[o].attributes.align,c="---";a&&(c=i[a.value]||c),r+=t(c,n.childNodes[o])}return"\n"+e+(r?"\n"+r:"")}},{filter:"table",replacement:function(e){return"\n\n"+e+"\n\n"}},{filter:["thead","tbody","tfoot"],replacement:function(e){return e}},{filter:function(e){return"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,n){return"\n\n```\n"+n.firstChild.textContent+"\n```\n\n"}},{filter:function(e){return"PRE"===e.nodeName&&"DIV"===e.parentNode.nodeName&&r.test(e.parentNode.className)},replacement:function(e,n){var t=n.parentNode.className.match(r)[1];return"\n\n```"+t+"\n"+n.textContent+"\n```\n\n"}},{filter:function(e){return"DIV"===e.nodeName&&r.test(e.className)},replacement:function(e){return"\n\n"+e+"\n\n"}}]},{}],3:[function(e,n){"use strict";n.exports=[{filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},{filter:"br",replacement:function(){return" \n"}},{filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,n){for(var t=n.nodeName.charAt(1),r="",i=0;t>i;i++)r+="#";return"\n\n"+r+" "+e+"\n\n"}},{filter:"hr",replacement:function(){return"\n\n* * *\n\n"}},{filter:["em","i"],replacement:function(e){return"_"+e+"_"}},{filter:["strong","b"],replacement:function(e){return"**"+e+"**"}},{filter:function(e){var n=e.previousSibling||e.nextSibling,t="PRE"===e.parentNode.nodeName&&!n;return"CODE"===e.nodeName&&!t},replacement:function(e){return"`"+e+"`"}},{filter:function(e){return"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,n){var t=n.title?' "'+n.title+'"':"";return"["+e+"]("+n.getAttribute("href")+t+")"}},{filter:"img",replacement:function(e,n){var t=n.alt||"",r=n.getAttribute("src")||"",i=n.title||"",o=i?' "'+i+'"':"";return r?"!["+t+"]("+r+o+")":""}},{filter:function(e){return"PRE"===e.nodeName&&"CODE"===e.firstChild.nodeName},replacement:function(e,n){return"\n\n "+n.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},{filter:"blockquote",replacement:function(e){return e=this.trim(e),e=e.replace(/\n{3,}/g,"\n\n"),e=e.replace(/^/gm,"> "),"\n\n"+e+"\n\n"}},{filter:"li",replacement:function(e,n){e=e.replace(/^\s+/,"").replace(/\n/gm,"\n ");var t="* ",r=n.parentNode,i=Array.prototype.indexOf.call(r.children,n)+1;return t=/ol/i.test(r.nodeName)?i+". ":"* ",t+e}},{filter:["ul","ol"],replacement:function(e,n){for(var t=[],r=0;r<n.childNodes.length;r++)t.push(n.childNodes[r]._replacement);return/li/i.test(n.parentNode.nodeName)?"\n"+t.join("\n"):"\n\n"+t.join("\n")+"\n\n"}},{filter:function(e){return this.isBlock(e)},replacement:function(e,n){return"\n\n"+this.outer(n,e)+"\n\n"}},{filter:function(){return!0},replacement:function(e,n){return this.outer(n,e)}}]},{}],4:[function(e,n){n.exports=["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","noscript","ol","output","p","pre","section","table","tfoot","ul","video"]},{}],5:[function(e,n){"use strict";function t(e){return i(e)&&a.indexOf(e.nodeName)>=0}function r(e){return e&&3===e.nodeType}function i(e){return e&&1===e.nodeType}function o(e,n){function o(t){for(;t&&t!==e;){if(t.nextSibling)return t.nextSibling;t=t.parentNode,f&&n(t)&&(f.data=f.data.replace(/[ \r\n\t]$/,""),f=null)}return null}function a(e){return e.firstChild?e.firstChild:o(e)}function c(e){var n=o(e);return e.parentNode.removeChild(e),n}var l,u,f,d,s,p=/^ /,m=/ $/;if("function"!=typeof n&&(n=t),"PRE"!==e.nodeName){for(e.normalize(),d=a(e);d;)if(u=d.previousSibling,l=d.nextSibling,r(d))s=d.data.replace(/[ \r\n\t]+/g," "),(!f||u&&n(u))&&(s=s.replace(p,"")),l&&n(l)&&(s=s.replace(m,"")),f&&m.test(f.data)&&p.test(s)&&(s=s.substr(1)),s?(d.data=s,f=d,d=o(d)):d=c(d);else if(i(d)){if("PRE"===d.nodeName){d=o(d);continue}f&&n(d)&&(f.data=f.data.replace(m,""),f=null),d=a(d)}else d=c(d);f&&(f.data=f.data.replace(m,""))}}var a=e("block-elements").map(function(e){return e.toUpperCase()});n.exports=o},{"block-elements":4}],6:[function(){},{}]},{},[1])(1)});var n=function(e,n){"function"==typeof e&&(n=e,e={}),e=Object(e),e.events=e.events||["input","change"],n=n||e.callback||function(){},this.init=function(t){if(this.me=t,this.me.elements&&this.me.elements.length){this.element=this.me.elements[0];var r=function(){n(toMarkdown(this.element.innerHTML).split("\n").map(function(e){return e.trim()}).join("\n").trim())}.bind(this);e.events.forEach(function(e){this.element.addEventListener(e,r)}.bind(this)),r()}}};e.MeMarkdown=n}(this); | ||
!function(e){if("function"!=typeof MediumEditor)throw new Error("Medium Editor is not loaded on the page.");!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.toMarkdown=e()}}(function(){return function e(n,t,r){function i(a,c){if(!t[a]){if(!n[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var f=t[a]={exports:{}};n[a][0].call(f.exports,function(e){var t=n[a][1][e];return i(t?t:e)},f,f.exports,e,n,t,r)}return t[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,n,t){"use strict";function r(e){return e.replace(/^[ \r\n\t]+|[ \r\n\t]+$/g,"")}function i(e){return-1!==C.indexOf(e.nodeName.toLowerCase())}function o(e){return-1!==E.indexOf(e.nodeName.toLowerCase())}function a(){var e=x.DOMParser,n=!1;try{(new e).parseFromString("","text/html")&&(n=!0)}catch(t){}return n}function c(){var e=function(){};return e.prototype.parseFromString=function(e){var n=N.implementation.createHTMLDocument("");return e.toLowerCase().indexOf("<!doctype")>-1?n.documentElement.innerHTML=e:n.body.innerHTML=e,n},e}function l(e){var n=(new k).parseFromString(e,"text/html");return w(n,i),n}function u(e){for(var n,t,r,i=[e],o=[];i.length>0;)for(n=i.shift(),o.push(n),t=n.childNodes,r=0;r<t.length;r++)1===t[r].nodeType&&i.push(t[r]);return o.shift(),o}function f(e){for(var n="",t=0;t<e.childNodes.length;t++)if(1===e.childNodes[t].nodeType)n+=e.childNodes[t]._replacement;else{if(3!==e.childNodes[t].nodeType)continue;n+=e.childNodes[t].data}return n}function d(e,n){return e.cloneNode(!1).outerHTML.replace("><",">"+n+"<")}function s(e,n){if("string"==typeof n)return n===e.nodeName.toLowerCase();if(Array.isArray(n))return-1!==n.indexOf(e.nodeName.toLowerCase());if("function"==typeof n)return n.call(g,e);throw new TypeError("`filter` needs to be a string, array, or function")}function p(e,n){var t,r,o;return"left"===e?(t=n.previousSibling,r=/ $/):(t=n.nextSibling,r=/^ /),t&&(3===t.nodeType?o=r.test(t.nodeValue):1!==t.nodeType||i(t)||(o=r.test(t.textContent))),o}function m(e){var n="",t="";if(!i(e)){var r=/^[ \r\n\t]/.test(e.innerHTML),o=/[ \r\n\t]$/.test(e.innerHTML);r&&!p("left",e)&&(n=" "),o&&!p("right",e)&&(t=" ")}return{leading:n,trailing:t}}function h(e){var n,t=f(e);if(!o(e)&&!/A/.test(e.nodeName)&&/^\s*$/i.test(t))return void(e._replacement="");for(var i=0;i<v.length;i++){var a=v[i];if(s(e,a.filter)){if("function"!=typeof a.replacement)throw new TypeError("`replacement` needs to be a function that returns a string");var c=m(e);(c.leading||c.trailing)&&(t=r(t)),n=c.leading+a.replacement.call(g,t,e)+c.trailing;break}}e._replacement=n}var g,v,N,b=e("./lib/md-converters"),y=e("./lib/gfm-converters"),w=e("collapse-whitespace"),x="undefined"!=typeof window?window:this;N="undefined"==typeof document?e("jsdom").jsdom():document;var C=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"],E=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],k=a()?x.DOMParser:c();g=function(e,n){if(n=n||{},"string"!=typeof e)throw new TypeError(e+" is not a string");e=e.replace(/(\d+)\. /g,"$1\\. ");var t,r=l(e).body,i=u(r);v=b.slice(0),n.gfm&&(v=y.concat(v)),n.converters&&(v=n.converters.concat(v));for(var o=i.length-1;o>=0;o--)h(i[o]);return t=f(r),t.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,"").replace(/\n\s+\n/g,"\n\n").replace(/\n{3,}/g,"\n\n")},g.isBlock=i,g.isVoid=o,g.trim=r,g.outer=d,n.exports=g},{"./lib/gfm-converters":2,"./lib/md-converters":3,"collapse-whitespace":4,jsdom:7}],2:[function(e,n,t){"use strict";function r(e,n){var t=Array.prototype.indexOf.call(n.parentNode.childNodes,n),r=" ";return 0===t&&(r="| "),r+e+" |"}var i=/highlight highlight-(\S+)/;n.exports=[{filter:"br",replacement:function(){return"\n"}},{filter:["del","s","strike"],replacement:function(e){return"~~"+e+"~~"}},{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,n){return(n.checked?"[x]":"[ ]")+" "}},{filter:["th","td"],replacement:function(e,n){return r(e,n)}},{filter:"tr",replacement:function(e,n){var t="",i={left:":--",right:"--:",center:":-:"};if("THEAD"===n.parentNode.nodeName)for(var o=0;o<n.childNodes.length;o++){var a=n.childNodes[o].attributes.align,c="---";a&&(c=i[a.value]||c),t+=r(c,n.childNodes[o])}return"\n"+e+(t?"\n"+t:"")}},{filter:"table",replacement:function(e){return"\n\n"+e+"\n\n"}},{filter:["thead","tbody","tfoot"],replacement:function(e){return e}},{filter:function(e){return"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,n){return"\n\n```\n"+n.firstChild.textContent+"\n```\n\n"}},{filter:function(e){return"PRE"===e.nodeName&&"DIV"===e.parentNode.nodeName&&i.test(e.parentNode.className)},replacement:function(e,n){var t=n.parentNode.className.match(i)[1];return"\n\n```"+t+"\n"+n.textContent+"\n```\n\n"}},{filter:function(e){return"DIV"===e.nodeName&&i.test(e.className)},replacement:function(e){return"\n\n"+e+"\n\n"}}]},{}],3:[function(e,n,t){"use strict";n.exports=[{filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},{filter:"br",replacement:function(){return" \n"}},{filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,n){for(var t=n.nodeName.charAt(1),r="",i=0;t>i;i++)r+="#";return"\n\n"+r+" "+e+"\n\n"}},{filter:"hr",replacement:function(){return"\n\n* * *\n\n"}},{filter:["em","i"],replacement:function(e){return"_"+e+"_"}},{filter:["strong","b"],replacement:function(e){return"**"+e+"**"}},{filter:function(e){var n=e.previousSibling||e.nextSibling,t="PRE"===e.parentNode.nodeName&&!n;return"CODE"===e.nodeName&&!t},replacement:function(e){return"`"+e+"`"}},{filter:function(e){return"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,n){var t=n.title?' "'+n.title+'"':"";return"["+e+"]("+n.getAttribute("href")+t+")"}},{filter:"img",replacement:function(e,n){var t=n.alt||"",r=n.getAttribute("src")||"",i=n.title||"",o=i?' "'+i+'"':"";return r?"!["+t+"]("+r+o+")":""}},{filter:function(e){return"PRE"===e.nodeName&&"CODE"===e.firstChild.nodeName},replacement:function(e,n){return"\n\n "+n.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},{filter:"blockquote",replacement:function(e){return e=this.trim(e),e=e.replace(/\n{3,}/g,"\n\n"),e=e.replace(/^/gm,"> "),"\n\n"+e+"\n\n"}},{filter:"li",replacement:function(e,n){e=e.replace(/^\s+/,"").replace(/\n/gm,"\n ");var t="* ",r=n.parentNode,i=Array.prototype.indexOf.call(r.children,n)+1;return t=/ol/i.test(r.nodeName)?i+". ":"* ",t+e}},{filter:["ul","ol"],replacement:function(e,n){for(var t=[],r=0;r<n.childNodes.length;r++)t.push(n.childNodes[r]._replacement);return/li/i.test(n.parentNode.nodeName)?"\n"+t.join("\n"):"\n\n"+t.join("\n")+"\n\n"}},{filter:function(e){return this.isBlock(e)},replacement:function(e,n){return"\n\n"+this.outer(n,e)+"\n\n"}},{filter:function(){return!0},replacement:function(e,n){return this.outer(n,e)}}]},{}],4:[function(e,n,t){"use strict";function r(e){return!(!e||!u[e.nodeName])}function i(e){return!(!e||!l[e.nodeName])}function o(e,n){if(e.firstChild&&"PRE"!==e.nodeName){"function"!=typeof n&&(n=r);for(var t=null,o=!1,l=null,u=c(l,e);u!==e;){if(3===u.nodeType){var f=u.data.replace(/[ \r\n\t]+/g," ");if(t&&!/ $/.test(t.data)||o||" "!==f[0]||(f=f.substr(1)),!f){u=a(u);continue}u.data=f,t=u}else{if(1!==u.nodeType){u=a(u);continue}n(u)||"BR"===u.nodeName?(t&&(t.data=t.data.replace(/ $/,"")),t=null,o=!1):i(u)&&(t=null,o=!0)}var d=c(l,u);l=u,u=d}t&&(t.data=t.data.replace(/ $/,""),t.data||a(t))}}function a(e){var n=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),n}function c(e,n){return e&&e.parentNode===n||"PRE"===n.nodeName?n.nextSibling||n.parentNode:n.firstChild||n.nextSibling||n.parentNode}var l=e("void-elements");Object.keys(l).forEach(function(e){l[e.toUpperCase()]=1});var u={};e("block-elements").forEach(function(e){u[e.toUpperCase()]=1}),n.exports=o},{"block-elements":5,"void-elements":6}],5:[function(e,n,t){n.exports=["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"]},{}],6:[function(e,n,t){n.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}},{}],7:[function(e,n,t){},{}]},{},[1])(1)});var n=function(e,n){"function"==typeof e&&(n=e,e={}),e=Object(e),e.events=e.events||["input","change"],n=n||e.callback||function(){},this.init=function(){if(this.base.elements&&this.base.elements.length){this.element=this.base.elements[0];var t=function(){n(toMarkdown(this.element.innerHTML).split("\n").map(function(e){return e.trim()}).join("\n").trim())}.bind(this);e.events.forEach(function(e){this.element.addEventListener(e,t)}.bind(this)),t()}}};e.MeMarkdown=n}(this); |
{ | ||
"name": "medium-editor-markdown", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A Medium Editor extension to add markdown support.", | ||
@@ -12,5 +12,6 @@ "main": "src/medium-editor-md.js", | ||
}, | ||
"author": "Ionică Bizău <bizauionica@gmail.com>", | ||
"author": "Ionică Bizău <bizauionica@gmail.com> (http://ionicabizau.net)", | ||
"contributors": [ | ||
"Nate Mielnik <nathan@outlook.com>" | ||
"Nate Mielnik <nathan@outlook.com>", | ||
"@prevuelta (http://www.pablorevuelta.com/)" | ||
], | ||
@@ -20,4 +21,4 @@ "license": "KINDLY", | ||
"barbe": "^2.0.0", | ||
"to-markdown": "1.2.0", | ||
"uglify-js": "2.4.16" | ||
"to-markdown": "^2.0.1", | ||
"uglify-js": "^2.5.0" | ||
}, | ||
@@ -41,2 +42,2 @@ "devDependencies": {}, | ||
} | ||
} | ||
} |
@@ -87,4 +87,3 @@ <!----------------------------------------------------------------------------> | ||
## License | ||
[KINDLY][license] © [Ionică Bizău][website]–The [LICENSE](/LICENSE) file contains | ||
a copy of the license. | ||
[KINDLY][license] © [Ionică Bizău][website] | ||
@@ -96,2 +95,2 @@ [license]: http://ionicabizau.github.io/kindly-license/?author=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica@gmail.com%3E&year=2015 | ||
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MG98D7NPFZ3MG | ||
[donate-now]: http://i.imgur.com/jioicaN.png | ||
[donate-now]: http://i.imgur.com/6cMbHOC.png |
@@ -28,11 +28,9 @@ /** | ||
// Called by medium-editor during init | ||
this.init = function (meInstance) { | ||
this.init = function () { | ||
this.me = meInstance; | ||
// If this instance of medium-editor doesn't have any elements, there's nothing for us to do | ||
if (!this.me.elements || !this.me.elements.length) { return; } | ||
if (!this.base.elements || !this.base.elements.length) { return; } | ||
// Element(s) that this instance of medium-editor is attached to is/are stored in .elements | ||
this.element = this.me.elements[0]; | ||
this.element = this.base.elements[0]; | ||
@@ -39,0 +37,0 @@ var handler = function () { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
152321
1310
94
+ Addedabab@1.0.4(transitive)
+ Addedalign-text@0.1.4(transitive)
+ Addedarray-equal@1.0.2(transitive)
+ Addedblock-elements@1.2.0(transitive)
+ Addedcamelcase@1.2.1(transitive)
+ Addedcenter-align@0.1.3(transitive)
+ Addedcliui@2.1.0(transitive)
+ Addedcollapse-whitespace@1.1.2(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedjsdom@8.5.0(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addedlazy-cache@1.0.4(transitive)
+ Addedlongest@1.0.1(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedright-align@0.1.3(transitive)
+ Addedsax@1.3.0(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsymbol-tree@3.2.4(transitive)
+ Addedto-markdown@2.1.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addeduglify-js@2.8.29(transitive)
+ Addedvoid-elements@2.0.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@2.0.1(transitive)
+ Addedwindow-size@0.1.0(transitive)
+ Addedwordwrap@0.0.2(transitive)
+ Addedxml-name-validator@2.0.1(transitive)
+ Addedyargs@3.10.0(transitive)
- Removedacorn@0.11.0(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedasync@0.2.10(transitive)
- Removedbindings@1.5.0(transitive)
- Removedbrowser-request@0.3.3(transitive)
- Removedcontextify@0.1.15(transitive)
- Removeddom-serializer@0.2.2(transitive)
- Removeddomelementtype@1.3.12.3.0(transitive)
- Removeddomhandler@2.4.2(transitive)
- Removeddomutils@1.7.0(transitive)
- Removedentities@1.1.22.2.0(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removedhtmlparser2@3.10.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjsdom@3.1.2(transitive)
- Removednan@2.19.0(transitive)
- Removedoptimist@0.3.7(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsource-map@0.1.34(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedto-markdown@1.2.0(transitive)
- Removeduglify-js@2.4.16(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwordwrap@0.0.3(transitive)
- Removedxml-name-validator@1.0.0(transitive)
- Removedxmlhttprequest@1.8.0(transitive)
Updatedto-markdown@^2.0.1
Updateduglify-js@^2.5.0