scrivito_editors 1.5.5 → 1.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/scrivito_editors.js +5 -1
  3. data/app/assets/javascripts/scrivito_editors/binary_editor.js +1 -6
  4. data/app/assets/javascripts/scrivito_editors/date_editor.js +1 -1
  5. data/app/assets/javascripts/scrivito_editors/default_editor.js +3 -12
  6. data/app/assets/javascripts/scrivito_editors/helpers/setup_button_container.js +19 -0
  7. data/app/assets/javascripts/scrivito_editors/image_editor.js +1 -1
  8. data/app/assets/javascripts/scrivito_editors/link_editor.js +6 -4
  9. data/app/assets/javascripts/scrivito_editors/linklist_editor.js +6 -4
  10. data/app/assets/javascripts/scrivito_editors/number_editor.js +88 -0
  11. data/app/assets/javascripts/scrivito_editors/redactor_editor.js +12 -3
  12. data/app/assets/javascripts/scrivito_editors/reference_editor.js +22 -7
  13. data/app/assets/javascripts/scrivito_editors/referencelist_editor.js +4 -4
  14. data/app/assets/javascripts/scrivito_editors/slider_editor.js +3 -3
  15. data/app/assets/stylesheets/scrivito_editors/ui_container.css +11 -11
  16. data/vendor/assets/javascripts/URI.js +56 -0
  17. data/vendor/assets/javascripts/medium-editor.js +184 -55
  18. data/vendor/assets/stylesheets/medium-editor-themes/flat.css +1 -1
  19. metadata +9 -18
  20. data/app/assets/javascripts/scrivito_editors/dependencies/jquery_ui.js.erb +0 -11
  21. data/app/assets/javascripts/scrivito_editors/deprecated_data_attrs.js +0 -44
  22. data/app/assets/javascripts/scrivito_editors/helpers/file_dropzone.js +0 -38
  23. data/app/assets/javascripts/scrivito_editors/helpers/setup_binary_button_container.js +0 -12
  24. data/app/assets/javascripts/scrivito_editors/image_drop_editor.js +0 -52
  25. data/app/assets/stylesheets/scrivito_editors/image_drop_editor.css +0 -7
@@ -0,0 +1,56 @@
1
+ /*! URI.js v1.18.1 http://medialize.github.io/URI.js/ */
2
+ /* build contains: URI.js */
3
+ (function(n,v){"object"===typeof exports?module.exports=v(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],v):n.URI=v(n.punycode,n.IPv6,n.SecondLevelDomains,n)})(this,function(n,v,t,h){function d(a,b){var c=1<=arguments.length,g=2<=arguments.length;if(!(this instanceof d))return c?g?new d(a,b):new d(a):new d;if(void 0===a){if(c)throw new TypeError("undefined is not a valid argument for URI");
4
+ a="undefined"!==typeof location?location.href+"":""}this.href(a);return void 0!==b?this.absoluteTo(b):this}function q(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function u(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function k(a){return"Array"===u(a)}function C(a,b){var c={},d,f;if("RegExp"===u(b))c=null;else if(k(b))for(d=0,f=b.length;d<f;d++)c[b[d]]=!0;else c[b]=!0;d=0;for(f=a.length;d<f;d++)if(c&&void 0!==c[a[d]]||!c&&b.test(a[d]))a.splice(d,
5
+ 1),f--,d--;return a}function y(a,b){var c,d;if(k(b)){c=0;for(d=b.length;c<d;c++)if(!y(a,b[c]))return!1;return!0}var f=u(b);c=0;for(d=a.length;c<d;c++)if("RegExp"===f){if("string"===typeof a[c]&&a[c].match(b))return!0}else if(a[c]===b)return!0;return!1}function D(a,b){if(!k(a)||!k(b)||a.length!==b.length)return!1;a.sort();b.sort();for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function z(a){return a.replace(/^\/+|\/+$/g,"")}function F(a){return escape(a)}function A(a){return encodeURIComponent(a).replace(/[!'()*]/g,
6
+ F).replace(/\*/g,"%2A")}function w(a){return function(b,c){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!c);return this}}function E(a,b){return function(c,d){if(void 0===c)return this._parts[a]||"";null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1)));this._parts[a]=c;this.build(!d);return this}}var G=h&&h.URI;d.version="1.18.1";var e=d.prototype,p=Object.prototype.hasOwnProperty;d._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,
7
+ port:null,path:null,query:null,fragment:null,duplicateQueryParameters:d.duplicateQueryParameters,escapeQuerySpace:d.escapeQuerySpace}};d.duplicateQueryParameters=!1;d.escapeQuerySpace=!0;d.protocol_expression=/^[a-z][a-z0-9.+-]*$/i;d.idn_expression=/[^a-z0-9\.-]/i;d.punycode_expression=/(xn--)/i;d.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;d.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
8
+ d.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters=
9
+ /[^a-zA-Z0-9\.-]/;d.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:d.domAttributes[b]}};d.encode=A;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=A;d.decode=
10
+ decodeURIComponent};d.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",",
11
+ "%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}};d.encodeQuery=function(a,b){var c=d.encode(a+"");void 0===b&&(b=d.escapeQuerySpace);return b?c.replace(/%20/g,"+"):c};d.decodeQuery=function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,
12
+ "%20"):a)}catch(c){return a}};var r={encode:"encode",decode:"decode"},x,B=function(a,b){return function(c){try{return d[b](c+"").replace(d.characters[a][b].expression,function(c){return d.characters[a][b].map[c]})}catch(g){return c}}};for(x in r)d[x+"PathSegment"]=B("pathname",r[x]),d[x+"UrnPathSegment"]=B("urnpath",r[x]);r=function(a,b,c){return function(g){var f;f=c?function(a){return d[b](d[c](a))}:d[b];g=(g+"").split(a);for(var e=0,l=g.length;e<l;e++)g[e]=f(g[e]);return g.join(a)}};d.decodePath=
13
+ r("/","decodePathSegment");d.decodeUrnPath=r(":","decodeUrnPathSegment");d.recodePath=r("/","encodePathSegment","decode");d.recodeUrnPath=r(":","encodeUrnPathSegment","decode");d.encodeReserved=B("reserved","encode");d.parse=function(a,b){var c;b||(b={});c=a.indexOf("#");-1<c&&(b.fragment=a.substring(c+1)||null,a=a.substring(0,c));c=a.indexOf("?");-1<c&&(b.query=a.substring(c+1)||null,a=a.substring(0,c));"//"===a.substring(0,2)?(b.protocol=null,a=a.substring(2),a=d.parseAuthority(a,b)):(c=a.indexOf(":"),
14
+ -1<c&&(b.protocol=a.substring(0,c)||null,b.protocol&&!b.protocol.match(d.protocol_expression)?b.protocol=void 0:"//"===a.substring(c+1,c+3)?(a=a.substring(c+3),a=d.parseAuthority(a,b)):(a=a.substring(c+1),b.urn=!0)));b.path=a;return b};d.parseHost=function(a,b){a=a.replace(/\\/g,"/");var c=a.indexOf("/"),d;-1===c&&(c=a.length);if("["===a.charAt(0))d=a.indexOf("]"),b.hostname=a.substring(1,d)||null,b.port=a.substring(d+2,c)||null,"/"===b.port&&(b.port=null);else{var f=a.indexOf(":");d=a.indexOf("/");
15
+ f=a.indexOf(":",f+1);-1!==f&&(-1===d||f<d)?(b.hostname=a.substring(0,c)||null,b.port=null):(d=a.substring(0,c).split(":"),b.hostname=d[0]||null,b.port=d[1]||null)}b.hostname&&"/"!==a.substring(c).charAt(0)&&(c++,a="/"+a);return a.substring(c)||"/"};d.parseAuthority=function(a,b){a=d.parseUserinfo(a,b);return d.parseHost(a,b)};d.parseUserinfo=function(a,b){var c=a.indexOf("/"),g=a.lastIndexOf("@",-1<c?c:a.length-1);-1<g&&(-1===c||g<c)?(c=a.substring(0,g).split(":"),b.username=c[0]?d.decode(c[0]):null,
16
+ c.shift(),b.password=c[0]?d.decode(c.join(":")):null,a=a.substring(g+1)):(b.username=null,b.password=null);return a};d.parseQuery=function(a,b){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var c={},g=a.split("&"),f=g.length,e,l,m=0;m<f;m++)if(e=g[m].split("="),l=d.decodeQuery(e.shift(),b),e=e.length?d.decodeQuery(e.join("="),b):null,p.call(c,l)){if("string"===typeof c[l]||null===c[l])c[l]=[c[l]];c[l].push(e)}else c[l]=e;return c};d.build=function(a){var b="";
17
+ a.protocol&&(b+=a.protocol+":");a.urn||!b&&!a.hostname||(b+="//");b+=d.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&"string"===typeof a.hostname&&(b+="/"),b+=a.path);"string"===typeof a.query&&a.query&&(b+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(b+="#"+a.fragment);return b};d.buildHost=function(a){var b="";if(a.hostname)b=d.ip6_expression.test(a.hostname)?b+("["+a.hostname+"]"):b+a.hostname;else return"";a.port&&(b+=":"+a.port);return b};d.buildAuthority=
18
+ function(a){return d.buildUserinfo(a)+d.buildHost(a)};d.buildUserinfo=function(a){var b="";a.username&&(b+=d.encode(a.username));a.password&&(b+=":"+d.encode(a.password));b&&(b+="@");return b};d.buildQuery=function(a,b,c){var g="",f,e,l,m;for(e in a)if(p.call(a,e)&&e)if(k(a[e]))for(f={},l=0,m=a[e].length;l<m;l++)void 0!==a[e][l]&&void 0===f[a[e][l]+""]&&(g+="&"+d.buildQueryParameter(e,a[e][l],c),!0!==b&&(f[a[e][l]+""]=!0));else void 0!==a[e]&&(g+="&"+d.buildQueryParameter(e,a[e],c));return g.substring(1)};
19
+ d.buildQueryParameter=function(a,b,c){return d.encodeQuery(a,c)+(null!==b?"="+d.encodeQuery(b,c):"")};d.addQuery=function(a,b,c){if("object"===typeof b)for(var g in b)p.call(b,g)&&d.addQuery(a,g,b[g]);else if("string"===typeof b)void 0===a[b]?a[b]=c:("string"===typeof a[b]&&(a[b]=[a[b]]),k(c)||(c=[c]),a[b]=(a[b]||[]).concat(c));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};d.removeQuery=function(a,b,c){var g;if(k(b))for(c=0,g=b.length;c<g;c++)a[b[c]]=
20
+ void 0;else if("RegExp"===u(b))for(g in a)b.test(g)&&(a[g]=void 0);else if("object"===typeof b)for(g in b)p.call(b,g)&&d.removeQuery(a,g,b[g]);else if("string"===typeof b)void 0!==c?"RegExp"===u(c)?!k(a[b])&&c.test(a[b])?a[b]=void 0:a[b]=C(a[b],c):a[b]!==String(c)||k(c)&&1!==c.length?k(a[b])&&(a[b]=C(a[b],c)):a[b]=void 0:a[b]=void 0;else throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");};d.hasQuery=function(a,b,c,g){switch(u(b)){case "String":break;
21
+ case "RegExp":for(var f in a)if(p.call(a,f)&&b.test(f)&&(void 0===c||d.hasQuery(a,f,c)))return!0;return!1;case "Object":for(var e in b)if(p.call(b,e)&&!d.hasQuery(a,e,b[e]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");}switch(u(c)){case "Undefined":return b in a;case "Boolean":return a=!(k(a[b])?!a[b].length:!a[b]),c===a;case "Function":return!!c(a[b],b,a);case "Array":return k(a[b])?(g?y:D)(a[b],c):!1;case "RegExp":return k(a[b])?
22
+ g?y(a[b],c):!1:!(!a[b]||!a[b].match(c));case "Number":c=String(c);case "String":return k(a[b])?g?y(a[b],c):!1:a[b]===c;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");}};d.joinPaths=function(){for(var a=[],b=[],c=0,g=0;g<arguments.length;g++){var f=new d(arguments[g]);a.push(f);for(var f=f.segment(),e=0;e<f.length;e++)"string"===typeof f[e]&&b.push(f[e]),f[e]&&c++}if(!b.length||!c)return new d("");b=(new d("")).segment(b);
23
+ ""!==a[0].path()&&"/"!==a[0].path().slice(0,1)||b.path("/"+b.path());return b.normalize()};d.commonPath=function(a,b){var c=Math.min(a.length,b.length),d;for(d=0;d<c;d++)if(a.charAt(d)!==b.charAt(d)){d--;break}if(1>d)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(d)||"/"!==b.charAt(d))d=a.substring(0,d).lastIndexOf("/");return a.substring(0,d+1)};d.withinString=function(a,b,c){c||(c={});var g=c.start||d.findUri.start,e=c.end||d.findUri.end,H=c.trim||d.findUri.trim,l=
24
+ /[a-z0-9-]=["']?$/i;for(g.lastIndex=0;;){var m=g.exec(a);if(!m)break;m=m.index;if(c.ignoreHtml){var k=a.slice(Math.max(m-3,0),m);if(k&&l.test(k))continue}var k=m+a.slice(m).search(e),h=a.slice(m,k).replace(H,"");c.ignore&&c.ignore.test(h)||(k=m+h.length,h=b(h,m,k,a),a=a.slice(0,m)+h+a.slice(k),g.lastIndex=m+h.length)}g.lastIndex=0;return a};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!n)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');
25
+ if(n.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},h.URITemplate&&"function"===typeof h.URITemplate.noConflict&&(a.URITemplate=h.URITemplate.noConflict()),h.IPv6&&"function"===typeof h.IPv6.noConflict&&(a.IPv6=h.IPv6.noConflict()),h.SecondLevelDomains&&"function"===typeof h.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=h.SecondLevelDomains.noConflict()),
26
+ a;h.URI===this&&(h.URI=G);return this};e.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new d(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};e.protocol=w("protocol");e.username=w("username");e.password=w("password");e.hostname=w("hostname");e.port=w("port");e.query=E("query","?");e.fragment=E("fragment","#");e.search=function(a,b){var c=
27
+ this.query(a,b);return"string"===typeof c&&c.length?"?"+c:c};e.hash=function(a,b){var c=this.fragment(a,b);return"string"===typeof c&&c.length?"#"+c:c};e.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?(this._parts.urn?d.decodeUrnPath:d.decodePath)(c):c}this._parts.path=this._parts.urn?a?d.recodeUrnPath(a):"":a?d.recodePath(a):"/";this.build(!b);return this};e.path=e.pathname;e.href=function(a,b){var c;if(void 0===a)return this.toString();
28
+ this._string="";this._parts=d._parts();var g=a instanceof d,e="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(e=d.getDomAttribute(a),a=a[e]||"",e=!1);!g&&e&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a||a instanceof String)this._parts=d.parse(String(a),this._parts);else if(g||e)for(c in g=g?a._parts:a,g)p.call(this._parts,c)&&(this._parts[c]=g[c]);else throw new TypeError("invalid input");this.build(!b);return this};e.is=function(a){var b=!1,c=!1,g=!1,e=!1,k=!1,
29
+ l=!1,m=!1,h=!this._parts.urn;this._parts.hostname&&(h=!1,c=d.ip4_expression.test(this._parts.hostname),g=d.ip6_expression.test(this._parts.hostname),b=c||g,k=(e=!b)&&t&&t.has(this._parts.hostname),l=e&&d.idn_expression.test(this._parts.hostname),m=e&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return h;case "absolute":return!h;case "domain":case "name":return e;case "sld":return k;case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;case "ip6":case "ipv6":case "inet6":return g;
30
+ case "idn":return l;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return m}return null};var I=e.protocol,J=e.port,K=e.hostname;e.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(d.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return I.call(this,a,b)};e.scheme=e.protocol;e.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==
31
+ a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');return J.call(this,a,b)};e.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};if("/"!==d.parseHost(a,c))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');a=c.hostname}return K.call(this,a,b)};e.origin=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===
32
+ a){var c=this.protocol();return this.authority()?(c?c+"://":"")+this.authority():""}c=d(a);this.protocol(c.protocol()).authority(c.authority()).build(!b);return this};e.host=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";if("/"!==d.parseHost(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');this.build(!b);return this};e.authority=function(a,b){if(this._parts.urn)return void 0===
33
+ a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";if("/"!==d.parseAuthority(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');this.build(!b);return this};e.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){var c=d.buildUserinfo(this._parts);return c?c.substring(0,c.length-1):c}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};e.resource=function(a,
34
+ b){var c;if(void 0===a)return this.path()+this.search()+this.hash();c=d.parse(a);this._parts.path=c.path;this._parts.query=c.query;this._parts.fragment=c.fragment;this.build(!b);return this};e.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,c)||""}c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,
35
+ c);c=new RegExp("^"+q(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(c,a);this.build(!b);return this};e.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g);if(c&&2>c.length)return this._parts.hostname;c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",
36
+ c-1)+1;return this._parts.hostname.substring(c)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=new RegExp(q(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);return this};e.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.lastIndexOf("."),
37
+ c=this._parts.hostname.substring(c+1);return!0!==b&&t&&t.list[c.toLowerCase()]?t.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(t&&t.is(a))c=new RegExp(q(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");c=new RegExp(q(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,
38
+ a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};e.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1,c=this._parts.path.substring(0,c)||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}c=this._parts.path.length-this.filename().length;c=this._parts.path.substring(0,c);c=new RegExp("^"+
39
+ q(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);return this};e.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this._parts.path.lastIndexOf("/"),c=this._parts.path.substring(c+1);return a?d.decodePathSegment(c):c}c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&
40
+ (c=!0);var g=new RegExp(q(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(g,a);c?this.normalizePath(b):this.build(!b);return this};e.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),g=c.lastIndexOf(".");if(-1===g)return"";c=c.substring(g+1);c=/^[a-z0-9%]+$/i.test(c)?c:"";return a?d.decodePathSegment(c):c}"."===a.charAt(0)&&(a=a.substring(1));if(c=this.suffix())g=
41
+ a?new RegExp(q(c)+"$"):new RegExp(q("."+c)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}g&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(g,a));this.build(!b);return this};e.segment=function(a,b,c){var d=this._parts.urn?":":"/",e=this.path(),h="/"===e.substring(0,1),e=e.split(d);void 0!==a&&"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');h&&e.shift();0>a&&(a=Math.max(e.length+
42
+ a,0));if(void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(k(b)){e=[];a=0;for(var l=b.length;a<l;a++)if(b[a].length||e.length&&e[e.length-1].length)e.length&&!e[e.length-1].length&&e.pop(),e.push(z(b[a]))}else{if(b||"string"===typeof b)b=z(b),""===e[e.length-1]?e[e.length-1]=b:e.push(b)}else b?e[a]=z(b):e.splice(a,1);h&&e.unshift("");return this.path(e.join(d),c)};e.segmentCoded=function(a,b,c){var e,f;"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0===b){a=this.segment(a,b,c);if(k(a))for(e=
43
+ 0,f=a.length;e<f;e++)a[e]=d.decode(a[e]);else a=void 0!==a?d.decode(a):void 0;return a}if(k(b))for(e=0,f=b.length;e<f;e++)b[e]=d.encode(b[e]);else b="string"===typeof b||b instanceof String?d.encode(b):b;return this.segment(a,b,c)};var L=e.query;e.query=function(a,b){if(!0===a)return d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"===typeof a){var c=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,c);this._parts.query=d.buildQuery(e||c,this._parts.duplicateQueryParameters,
44
+ this._parts.escapeQuerySpace);this.build(!b);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=d.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this):L.call(this,a,b)};e.setQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"===typeof a||a instanceof String)e[a]=void 0!==b?b:null;else if("object"===typeof a)for(var f in a)p.call(a,f)&&(e[f]=a[f]);else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
45
+ this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};e.addQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);d.addQuery(e,a,void 0===b?null:b);this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};e.removeQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,
46
+ this._parts.escapeQuerySpace);d.removeQuery(e,a,b);this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};e.hasQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return d.hasQuery(e,a,b,c)};e.setSearch=e.setQuery;e.addSearch=e.addQuery;e.removeSearch=e.removeQuery;e.hasSearch=e.hasQuery;e.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():
47
+ this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};e.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};e.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&n?this._parts.hostname=n.toASCII(this._parts.hostname):this.is("IPv6")&&v&&(this._parts.hostname=v.best(this._parts.hostname)),this._parts.hostname=
48
+ this._parts.hostname.toLowerCase(),this.build(!a));return this};e.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===d.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};e.normalizePath=function(a){var b=this._parts.path;if(!b)return this;if(this._parts.urn)return this._parts.path=d.recodeUrnPath(this._parts.path),this.build(!a),this;if("/"===this._parts.path)return this;var b=d.recodePath(b),c,e="",f,k;"/"!==b.charAt(0)&&(c=!0,
49
+ b="/"+b);if("/.."===b.slice(-3)||"/."===b.slice(-2))b+="/";b=b.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");c&&(e=b.substring(1).match(/^(\.\.\/)+/)||"")&&(e=e[0]);for(;;){f=b.search(/\/\.\.(\/|$)/);if(-1===f)break;else if(0===f){b=b.substring(3);continue}k=b.substring(0,f).lastIndexOf("/");-1===k&&(k=f);b=b.substring(0,k)+b.substring(f+3)}c&&this.is("relative")&&(b=e+b.substring(1));this._parts.path=b;this.build(!a);return this};e.normalizePathname=e.normalizePath;e.normalizeQuery=
50
+ function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(d.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a));return this};e.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};e.normalizeSearch=e.normalizeQuery;e.normalizeHash=e.normalizeFragment;e.iso8859=function(){var a=d.encode,b=d.decode;d.encode=escape;d.decode=decodeURIComponent;try{this.normalize()}finally{d.encode=
51
+ a,d.decode=b}return this};e.unicode=function(){var a=d.encode,b=d.decode;d.encode=A;d.decode=unescape;try{this.normalize()}finally{d.encode=a,d.decode=b}return this};e.readable=function(){var a=this.clone();a.username("").password("").normalize();var b="";a._parts.protocol&&(b+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&n?(b+=n.toUnicode(a._parts.hostname),a._parts.port&&(b+=":"+a._parts.port)):b+=a.host());a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(b+="/");
52
+ b+=a.path(!0);if(a._parts.query){for(var c="",e=0,f=a._parts.query.split("&"),k=f.length;e<k;e++){var l=(f[e]||"").split("="),c=c+("&"+d.decodeQuery(l[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==l[1]&&(c+="="+d.decodeQuery(l[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}b+="?"+c.substring(1)}return b+=d.decodeQuery(a.hash(),!0)};e.absoluteTo=function(a){var b=this.clone(),c=["protocol","username","password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");
53
+ a instanceof d||(a=new d(a));b._parts.protocol||(b._parts.protocol=a._parts.protocol);if(this._parts.hostname)return b;for(e=0;f=c[e];e++)b._parts[f]=a._parts[f];b._parts.path?".."===b._parts.path.substring(-2)&&(b._parts.path+="/"):(b._parts.path=a._parts.path,b._parts.query||(b._parts.query=a._parts.query));"/"!==b.path().charAt(0)&&(c=(c=a.directory())?c:0===a.path().indexOf("/")?"/":"",b._parts.path=(c?c+"/":"")+b._parts.path,b.normalizePath());b.build();return b};e.relativeTo=function(a){var b=
54
+ this.clone().normalize(),c,e,f;if(b._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new d(a)).normalize();c=b._parts;e=a._parts;f=b.path();a=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==a.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");c.protocol===e.protocol&&(c.protocol=null);if(c.username===e.username&&c.password===e.password&&null===c.protocol&&null===c.username&&null===c.password&&c.hostname===
55
+ e.hostname&&c.port===e.port)c.hostname=null,c.port=null;else return b.build();if(f===a)return c.path="",b.build();f=d.commonPath(f,a);if(!f)return b.build();e=e.path.substring(f.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");c.path=e+c.path.substring(f.length)||"./";return b.build()};e.equals=function(a){var b=this.clone(),c=new d(a),e;a={};var f,h;b.normalize();c.normalize();if(b.toString()===c.toString())return!0;f=b.query();e=c.query();b.query("");c.query("");if(b.toString()!==c.toString()||
56
+ f.length!==e.length)return!1;b=d.parseQuery(f,this._parts.escapeQuerySpace);e=d.parseQuery(e,this._parts.escapeQuerySpace);for(h in b)if(p.call(b,h)){if(!k(b[h])){if(b[h]!==e[h])return!1}else if(!D(b[h],e[h]))return!1;a[h]=!0}for(h in e)if(p.call(e,h)&&!a[h])return!1;return!0};e.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};e.escapeQuerySpace=function(a){this._parts.escapeQuerySpace=!!a;return this};return d});
@@ -385,7 +385,7 @@ if (!("classList" in document.createElement("_"))) {
385
385
 
386
386
  (function (root, factory) {
387
387
  'use strict';
388
- var isElectron = typeof module === 'object' && process && process.versions && process.versions.electron;
388
+ var isElectron = typeof module === 'object' && typeof process !== 'undefined' && process && process.versions && process.versions.electron;
389
389
  if (!isElectron && typeof module === 'object') {
390
390
  module.exports = factory;
391
391
  } else if (typeof define === 'function' && define.amd) {
@@ -1430,11 +1430,15 @@ MediumEditor.extensions = {};
1430
1430
  },
1431
1431
 
1432
1432
  cleanupTags: function (el, tags) {
1433
- tags.forEach(function (tag) {
1434
- if (el.nodeName.toLowerCase() === tag) {
1435
- el.parentNode.removeChild(el);
1436
- }
1437
- });
1433
+ if (tags.indexOf(el.nodeName.toLowerCase()) !== -1) {
1434
+ el.parentNode.removeChild(el);
1435
+ }
1436
+ },
1437
+
1438
+ unwrapTags: function (el, tags) {
1439
+ if (tags.indexOf(el.nodeName.toLowerCase()) !== -1) {
1440
+ MediumEditor.util.unwrap(el, document);
1441
+ }
1438
1442
  },
1439
1443
 
1440
1444
  // get the closest parent
@@ -2465,7 +2469,10 @@ MediumEditor.extensions = {};
2465
2469
  // Helpers for event handling
2466
2470
 
2467
2471
  attachDOMEvent: function (targets, event, listener, useCapture) {
2468
- targets = MediumEditor.util.isElement(targets) || [window, document].indexOf(targets) > -1 ? [targets] : targets;
2472
+ var win = this.base.options.contentWindow,
2473
+ doc = this.base.options.ownerDocument;
2474
+
2475
+ targets = MediumEditor.util.isElement(targets) || [win, doc].indexOf(targets) > -1 ? [targets] : targets;
2469
2476
 
2470
2477
  Array.prototype.forEach.call(targets, function (target) {
2471
2478
  target.addEventListener(event, listener, useCapture);
@@ -2474,8 +2481,11 @@ MediumEditor.extensions = {};
2474
2481
  },
2475
2482
 
2476
2483
  detachDOMEvent: function (targets, event, listener, useCapture) {
2477
- var index, e;
2478
- targets = MediumEditor.util.isElement(targets) || [window, document].indexOf(targets) > -1 ? [targets] : targets;
2484
+ var index, e,
2485
+ win = this.base.options.contentWindow,
2486
+ doc = this.base.options.ownerDocument;
2487
+
2488
+ targets = MediumEditor.util.isElement(targets) || [win, doc].indexOf(targets) > -1 ? [targets] : targets;
2479
2489
 
2480
2490
  Array.prototype.forEach.call(targets, function (target) {
2481
2491
  index = this.indexOfListener(target, event, listener, useCapture);
@@ -2643,23 +2653,23 @@ MediumEditor.extensions = {};
2643
2653
 
2644
2654
  // Helper method to call all listeners to execCommand
2645
2655
  var callListeners = function (args, result) {
2646
- if (doc.execCommand.listeners) {
2647
- doc.execCommand.listeners.forEach(function (listener) {
2648
- listener({
2649
- command: args[0],
2650
- value: args[2],
2651
- args: args,
2652
- result: result
2653
- });
2656
+ if (doc.execCommand.listeners) {
2657
+ doc.execCommand.listeners.forEach(function (listener) {
2658
+ listener({
2659
+ command: args[0],
2660
+ value: args[2],
2661
+ args: args,
2662
+ result: result
2654
2663
  });
2655
- }
2656
- },
2664
+ });
2665
+ }
2666
+ },
2657
2667
 
2658
- // Create a wrapper method for execCommand which will:
2659
- // 1) Call document.execCommand with the correct arguments
2660
- // 2) Loop through any listeners and notify them that execCommand was called
2661
- // passing extra info on the call
2662
- // 3) Return the result
2668
+ // Create a wrapper method for execCommand which will:
2669
+ // 1) Call document.execCommand with the correct arguments
2670
+ // 2) Loop through any listeners and notify them that execCommand was called
2671
+ // passing extra info on the call
2672
+ // 3) Return the result
2663
2673
  wrapper = function () {
2664
2674
  var result = doc.execCommand.orig.apply(this, arguments);
2665
2675
 
@@ -2834,10 +2844,10 @@ MediumEditor.extensions = {};
2834
2844
  // For clicks, we need to know if the mousedown that caused the click happened inside the existing focused element
2835
2845
  // or one of the extension elements. If so, we don't want to focus another element
2836
2846
  if (hadFocus &&
2837
- eventObj.type === 'click' &&
2838
- this.lastMousedownTarget &&
2839
- (MediumEditor.util.isDescendant(hadFocus, this.lastMousedownTarget, true) ||
2840
- isElementDescendantOfExtension(this.base.extensions, this.lastMousedownTarget))) {
2847
+ eventObj.type === 'click' &&
2848
+ this.lastMousedownTarget &&
2849
+ (MediumEditor.util.isDescendant(hadFocus, this.lastMousedownTarget, true) ||
2850
+ isElementDescendantOfExtension(this.base.extensions, this.lastMousedownTarget))) {
2841
2851
  toFocus = hadFocus;
2842
2852
  }
2843
2853
 
@@ -2855,7 +2865,7 @@ MediumEditor.extensions = {};
2855
2865
 
2856
2866
  // Check if the target is external (not part of the editor, toolbar, or any other extension)
2857
2867
  var externalEvent = !MediumEditor.util.isDescendant(hadFocus, target, true) &&
2858
- !isElementDescendantOfExtension(this.base.extensions, target);
2868
+ !isElementDescendantOfExtension(this.base.extensions, target);
2859
2869
 
2860
2870
  if (toFocus !== hadFocus) {
2861
2871
  // If element has focus, and focus is going outside of editor
@@ -3854,18 +3864,47 @@ MediumEditor.extensions = {};
3854
3864
  this.base.checkSelection();
3855
3865
  },
3856
3866
 
3867
+ ensureEncodedUri: function (str) {
3868
+ return str === decodeURI(str) ? encodeURI(str) : str;
3869
+ },
3870
+
3871
+ ensureEncodedUriComponent: function (str) {
3872
+ return str === decodeURIComponent(str) ? encodeURIComponent(str) : str;
3873
+ },
3874
+
3875
+ ensureEncodedParam: function (param) {
3876
+ var split = param.split('='),
3877
+ key = split[0],
3878
+ val = split[1];
3879
+
3880
+ return key + (val === undefined ? '' : '=' + this.ensureEncodedUriComponent(val));
3881
+ },
3882
+
3883
+ ensureEncodedQuery: function (queryString) {
3884
+ return queryString.split('&').map(this.ensureEncodedParam.bind(this)).join('&');
3885
+ },
3886
+
3857
3887
  checkLinkFormat: function (value) {
3858
3888
  // Matches any alphabetical characters followed by ://
3859
3889
  // Matches protocol relative "//"
3860
3890
  // Matches common external protocols "mailto:" "tel:" "maps:"
3861
- var urlSchemeRegex = /^([a-z]+:)?\/\/|^(mailto|tel|maps):/i,
3862
- // var te is a regex for checking if the string is a telephone number
3863
- telRegex = /^\+?\s?\(?(?:\d\s?\-?\)?){3,20}$/;
3891
+ // Matches relative hash link, begins with "#"
3892
+ var urlSchemeRegex = /^([a-z]+:)?\/\/|^(mailto|tel|maps):|^\#/i,
3893
+ // telRegex is a regex for checking if the string is a telephone number
3894
+ telRegex = /^\+?\s?\(?(?:\d\s?\-?\)?){3,20}$/,
3895
+ split = value.split('?'),
3896
+ path = split[0],
3897
+ query = split[1];
3898
+
3864
3899
  if (telRegex.test(value)) {
3865
3900
  return 'tel:' + value;
3866
3901
  } else {
3867
3902
  // Check for URL scheme and default to http:// if none found
3868
- return (urlSchemeRegex.test(value) ? '' : 'http://') + encodeURI(value);
3903
+ return (urlSchemeRegex.test(value) ? '' : 'http://') +
3904
+ // Ensure path is encoded
3905
+ this.ensureEncodedUri(path) +
3906
+ // Ensure query is encoded
3907
+ (query === undefined ? '' : '?' + this.ensureEncodedQuery(query));
3869
3908
  }
3870
3909
  },
3871
3910
 
@@ -4060,13 +4099,15 @@ MediumEditor.extensions = {};
4060
4099
 
4061
4100
  positionPreview: function (activeAnchor) {
4062
4101
  activeAnchor = activeAnchor || this.activeAnchor;
4063
- var buttonHeight = this.anchorPreview.offsetHeight,
4102
+ var containerWidth = this.window.innerWidth,
4103
+ buttonHeight = this.anchorPreview.offsetHeight,
4064
4104
  boundary = activeAnchor.getBoundingClientRect(),
4065
- middleBoundary = (boundary.left + boundary.right) / 2,
4066
4105
  diffLeft = this.diffLeft,
4067
4106
  diffTop = this.diffTop,
4068
- halfOffsetWidth,
4069
- defaultLeft;
4107
+ elementsContainer = this.getEditorOption('elementsContainer'),
4108
+ elementsContainerAbsolute = ['absolute', 'fixed'].indexOf(window.getComputedStyle(elementsContainer).getPropertyValue('position')) > -1,
4109
+ relativeBoundary = {},
4110
+ halfOffsetWidth, defaultLeft, middleBoundary, elementsContainerBoundary, top;
4070
4111
 
4071
4112
  halfOffsetWidth = this.anchorPreview.offsetWidth / 2;
4072
4113
  var toolbarExtension = this.base.getExtensionByName('toolbar');
@@ -4076,12 +4117,35 @@ MediumEditor.extensions = {};
4076
4117
  }
4077
4118
  defaultLeft = diffLeft - halfOffsetWidth;
4078
4119
 
4079
- this.anchorPreview.style.top = Math.round(buttonHeight + boundary.bottom - diffTop + this.window.pageYOffset - this.anchorPreview.offsetHeight) + 'px';
4120
+ // If container element is absolute / fixed, recalculate boundaries to be relative to the container
4121
+ if (elementsContainerAbsolute) {
4122
+ elementsContainerBoundary = elementsContainer.getBoundingClientRect();
4123
+ ['top', 'left'].forEach(function (key) {
4124
+ relativeBoundary[key] = boundary[key] - elementsContainerBoundary[key];
4125
+ });
4126
+
4127
+ relativeBoundary.width = boundary.width;
4128
+ relativeBoundary.height = boundary.height;
4129
+ boundary = relativeBoundary;
4130
+
4131
+ containerWidth = elementsContainerBoundary.width;
4132
+
4133
+ // Adjust top position according to container scroll position
4134
+ top = elementsContainer.scrollTop;
4135
+ } else {
4136
+ // Adjust top position according to window scroll position
4137
+ top = this.window.pageYOffset;
4138
+ }
4139
+
4140
+ middleBoundary = boundary.left + boundary.width / 2;
4141
+ top += buttonHeight + boundary.top + boundary.height - diffTop - this.anchorPreview.offsetHeight;
4142
+
4143
+ this.anchorPreview.style.top = Math.round(top) + 'px';
4080
4144
  this.anchorPreview.style.right = 'initial';
4081
4145
  if (middleBoundary < halfOffsetWidth) {
4082
4146
  this.anchorPreview.style.left = defaultLeft + halfOffsetWidth + 'px';
4083
4147
  this.anchorPreview.style.right = 'initial';
4084
- } else if ((this.window.innerWidth - middleBoundary) < halfOffsetWidth) {
4148
+ } else if ((containerWidth - middleBoundary) < halfOffsetWidth) {
4085
4149
  this.anchorPreview.style.left = 'auto';
4086
4150
  this.anchorPreview.style.right = 0;
4087
4151
  } else {
@@ -5068,13 +5132,13 @@ MediumEditor.extensions = {};
5068
5132
  [new RegExp(/<br class="Apple-interchange-newline">/g), '<br>'],
5069
5133
 
5070
5134
  // replace google docs italics+bold with a span to be replaced once the html is inserted
5071
- [new RegExp(/<span[^>]*(font-style:italic;font-weight:bold|font-weight:bold;font-style:italic)[^>]*>/gi), '<span class="replace-with italic bold">'],
5135
+ [new RegExp(/<span[^>]*(font-style:italic;font-weight:(bold|700)|font-weight:(bold|700);font-style:italic)[^>]*>/gi), '<span class="replace-with italic bold">'],
5072
5136
 
5073
5137
  // replace google docs italics with a span to be replaced once the html is inserted
5074
5138
  [new RegExp(/<span[^>]*font-style:italic[^>]*>/gi), '<span class="replace-with italic">'],
5075
5139
 
5076
5140
  //[replace google docs bolds with a span to be replaced once the html is inserted
5077
- [new RegExp(/<span[^>]*font-weight:bold[^>]*>/gi), '<span class="replace-with bold">'],
5141
+ [new RegExp(/<span[^>]*font-weight:(bold|700)[^>]*>/gi), '<span class="replace-with bold">'],
5078
5142
 
5079
5143
  // replace manually entered b/i/a tags with real ones
5080
5144
  [new RegExp(/&lt;(\/?)(i|b|a)&gt;/gi), '<$1$2>'],
@@ -5170,6 +5234,13 @@ MediumEditor.extensions = {};
5170
5234
  */
5171
5235
  cleanTags: ['meta'],
5172
5236
 
5237
+ /* unwrapTags: [Array]
5238
+ * list of element tag names to unwrap (remove the element tag but retain its child elements)
5239
+ * during paste when __cleanPastedHTML__ is `true` or when
5240
+ * calling `cleanPaste(text)` or `pasteHTML(html, options)` helper methods.
5241
+ */
5242
+ unwrapTags: [],
5243
+
5173
5244
  init: function () {
5174
5245
  MediumEditor.Extension.prototype.init.apply(this, arguments);
5175
5246
 
@@ -5453,7 +5524,8 @@ MediumEditor.extensions = {};
5453
5524
  pasteHTML: function (html, options) {
5454
5525
  options = MediumEditor.util.defaults({}, options, {
5455
5526
  cleanAttrs: this.cleanAttrs,
5456
- cleanTags: this.cleanTags
5527
+ cleanTags: this.cleanTags,
5528
+ unwrapTags: this.unwrapTags
5457
5529
  });
5458
5530
 
5459
5531
  var elList, workEl, i, fragmentBody, pasteBlock = this.document.createDocumentFragment();
@@ -5475,6 +5547,7 @@ MediumEditor.extensions = {};
5475
5547
 
5476
5548
  MediumEditor.util.cleanupAttrs(workEl, options.cleanAttrs);
5477
5549
  MediumEditor.util.cleanupTags(workEl, options.cleanTags);
5550
+ MediumEditor.util.unwrapTags(workEl, options.unwrapTags);
5478
5551
  }
5479
5552
 
5480
5553
  MediumEditor.util.insertHTMLCommand(this.document, fragmentBody.innerHTML.replace(/&nbsp;/g, ' '));
@@ -6306,35 +6379,66 @@ MediumEditor.extensions = {};
6306
6379
  }
6307
6380
  }
6308
6381
 
6309
- var windowWidth = this.window.innerWidth,
6310
- middleBoundary = (boundary.left + boundary.right) / 2,
6382
+ var containerWidth = this.window.innerWidth,
6311
6383
  toolbarElement = this.getToolbarElement(),
6312
6384
  toolbarHeight = toolbarElement.offsetHeight,
6313
6385
  toolbarWidth = toolbarElement.offsetWidth,
6314
6386
  halfOffsetWidth = toolbarWidth / 2,
6315
6387
  buttonHeight = 50,
6316
- defaultLeft = this.diffLeft - halfOffsetWidth;
6388
+ defaultLeft = this.diffLeft - halfOffsetWidth,
6389
+ elementsContainer = this.getEditorOption('elementsContainer'),
6390
+ elementsContainerAbsolute = ['absolute', 'fixed'].indexOf(window.getComputedStyle(elementsContainer).getPropertyValue('position')) > -1,
6391
+ positions = {},
6392
+ relativeBoundary = {},
6393
+ middleBoundary, elementsContainerBoundary;
6394
+
6395
+ // If container element is absolute / fixed, recalculate boundaries to be relative to the container
6396
+ if (elementsContainerAbsolute) {
6397
+ elementsContainerBoundary = elementsContainer.getBoundingClientRect();
6398
+ ['top', 'left'].forEach(function (key) {
6399
+ relativeBoundary[key] = boundary[key] - elementsContainerBoundary[key];
6400
+ });
6401
+
6402
+ relativeBoundary.width = boundary.width;
6403
+ relativeBoundary.height = boundary.height;
6404
+ boundary = relativeBoundary;
6405
+
6406
+ containerWidth = elementsContainerBoundary.width;
6407
+
6408
+ // Adjust top position according to container scroll position
6409
+ positions.top = elementsContainer.scrollTop;
6410
+ } else {
6411
+ // Adjust top position according to window scroll position
6412
+ positions.top = this.window.pageYOffset;
6413
+ }
6414
+
6415
+ middleBoundary = boundary.left + boundary.width / 2;
6416
+ positions.top += boundary.top - toolbarHeight;
6317
6417
 
6318
6418
  if (boundary.top < buttonHeight) {
6319
6419
  toolbarElement.classList.add('medium-toolbar-arrow-over');
6320
6420
  toolbarElement.classList.remove('medium-toolbar-arrow-under');
6321
- toolbarElement.style.top = buttonHeight + boundary.bottom - this.diffTop + this.window.pageYOffset - toolbarHeight + 'px';
6421
+ positions.top += buttonHeight + boundary.height - this.diffTop;
6322
6422
  } else {
6323
6423
  toolbarElement.classList.add('medium-toolbar-arrow-under');
6324
6424
  toolbarElement.classList.remove('medium-toolbar-arrow-over');
6325
- toolbarElement.style.top = boundary.top + this.diffTop + this.window.pageYOffset - toolbarHeight + 'px';
6425
+ positions.top += this.diffTop;
6326
6426
  }
6327
6427
 
6328
6428
  if (middleBoundary < halfOffsetWidth) {
6329
- toolbarElement.style.left = defaultLeft + halfOffsetWidth + 'px';
6330
- toolbarElement.style.right = 'initial';
6331
- } else if ((windowWidth - middleBoundary) < halfOffsetWidth) {
6332
- toolbarElement.style.left = 'auto';
6333
- toolbarElement.style.right = 0;
6429
+ positions.left = defaultLeft + halfOffsetWidth;
6430
+ positions.right = 'initial';
6431
+ } else if ((containerWidth - middleBoundary) < halfOffsetWidth) {
6432
+ positions.left = 'auto';
6433
+ positions.right = 0;
6334
6434
  } else {
6335
- toolbarElement.style.left = defaultLeft + middleBoundary + 'px';
6336
- toolbarElement.style.right = 'initial';
6435
+ positions.left = defaultLeft + middleBoundary;
6436
+ positions.right = 'initial';
6337
6437
  }
6438
+
6439
+ ['top', 'left', 'right'].forEach(function (key) {
6440
+ toolbarElement.style[key] = positions[key] + (isNaN(positions[key]) ? '' : 'px');
6441
+ });
6338
6442
  }
6339
6443
  });
6340
6444
 
@@ -6541,6 +6645,31 @@ MediumEditor.extensions = {};
6541
6645
  // then pressing backspace key should change the <blockquote> to a <p> tag
6542
6646
  event.preventDefault();
6543
6647
  MediumEditor.util.execFormatBlock(this.options.ownerDocument, 'p');
6648
+ } else if (MediumEditor.util.isKey(event, MediumEditor.util.keyCode.ENTER) &&
6649
+ (MediumEditor.util.getClosestTag(node, 'blockquote') !== false) &&
6650
+ MediumEditor.selection.getCaretOffsets(node).right === 0) {
6651
+
6652
+ // when cursor is at the end of <blockquote>,
6653
+ // then pressing enter key should create <p> tag, not <blockquote>
6654
+ p = this.options.ownerDocument.createElement('p');
6655
+ p.innerHTML = '<br>';
6656
+ node.parentElement.insertBefore(p, node.nextSibling);
6657
+
6658
+ // move the cursor into the new paragraph
6659
+ MediumEditor.selection.moveCursor(this.options.ownerDocument, p);
6660
+
6661
+ event.preventDefault();
6662
+ } else if (MediumEditor.util.isKey(event, MediumEditor.util.keyCode.BACKSPACE) &&
6663
+ MediumEditor.util.isMediumEditorElement(node.parentElement) &&
6664
+ !node.previousElementSibling &&
6665
+ node.nextElementSibling &&
6666
+ isEmpty.test(node.innerHTML)) {
6667
+
6668
+ // when cursor is in the first element, it's empty and user presses backspace,
6669
+ // do delete action instead to get rid of the first element and move caret to 2nd
6670
+ event.preventDefault();
6671
+ MediumEditor.selection.moveCursor(this.options.ownerDocument, node.nextSibling);
6672
+ node.parentElement.removeChild(node);
6544
6673
  }
6545
6674
  }
6546
6675
 
@@ -7697,7 +7826,7 @@ MediumEditor.parseVersionString = function (release) {
7697
7826
 
7698
7827
  MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
7699
7828
  // grunt-bump looks for this:
7700
- 'version': '5.21.0'
7829
+ 'version': '5.22.1'
7701
7830
  }).version);
7702
7831
 
7703
7832
  return MediumEditor;
@@ -55,4 +55,4 @@
55
55
  color: #fff; }
56
56
 
57
57
  .medium-editor-placeholder:after {
58
- color: #fff; }
58
+ color: #9ccea6; }