Skip to content

Commit

Permalink
5.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
j0k3r committed Mar 2, 2017
1 parent 8dded04 commit de9371b
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 18 deletions.
49 changes: 49 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
5.23.0 / 2017-03-02
==================
* Only add schemes to URLs with hostnames #1258
* Fix problem with addClassToAnchors #1293
* Adding new 'html' button from #1235 #1291
* Don't encode fragment as part of linkValidation #1257


5.22.2 / 2017-01-19
==================
* Efficiency: Compile RegEx once #1230
* Error in console at link selection #1249
* Check for this.anchorPreview when hiding #1280
* Save some CPU calculations #1271


5.22.1 / 2016-09-29
==================
* Fix encoded urls (in linkValidaton) #1219
* Fix CommonJS environment #1221


5.22.0 / 2016-09-03
==================
* Add new extensions to extensions README #1188
* Fix iframe div #1179
* Fix placeholder text color in flat theme #1192
* Add unwrapTags option to paste extension #1177
* Remove first empty paragraph on backspace #1187
* Update grunt-contrib-jasmine #1185
* Added Embed Button links to README #1183


5.21.1 / 2016-08-11
==================
* Make linkValidation allow hash links #1143
* Fix toolbar in absolute container #1152
* Fix caret issue in blockquote #1162
* Handle new Google Docs font weights #1168
* Add external button example #1175


5.21.0 / 2016-06-21
==================
* Fix issue with electron environment #1125
* Fix for paste and placeholder extensions & add/remove element events #1124
* Placeholder is visible when only empty table is in Editor #1128


5.20.2 / 2016-06-17
==================
(5.20.1 was skipped because of a bad release)
Expand Down
62 changes: 50 additions & 12 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,11 @@ MediumEditor.extensions = {};
}
},

/*
* this function adds one or several classes on an a element.
* if el parameter is not an a, it will look for a children of el.
* if no a children are found, it will look for the a parent.
*/
addClassToAnchors: function (el, buttonClass) {
var classes = buttonClass.split(' '),
i,
Expand All @@ -1028,7 +1033,13 @@ MediumEditor.extensions = {};
el.classList.add(classes[j]);
}
} else {
el = el.getElementsByTagName('a');
var aChildren = el.getElementsByTagName('a');
if (aChildren.length === 0) {
var parentAnchor = Util.getClosestTag(el, 'a');
el = parentAnchor ? [parentAnchor] : [];
} else {
el = aChildren;
}
for (i = 0; i < el.length; i += 1) {
for (j = 0; j < classes.length; j += 1) {
el[i].classList.add(classes[j]);
Expand Down Expand Up @@ -3351,6 +3362,14 @@ MediumEditor.extensions = {};
contentDefault: '<b>image</b>',
contentFA: '<i class="fa fa-picture-o"></i>'
},
'html': {
name: 'html',
action: 'html',
aria: 'evaluate html',
tagNames: ['iframe', 'object'],
contentDefault: '<b>html</b>',
contentFA: '<i class="fa fa-code"></i>'
},
'orderedlist': {
name: 'orderedlist',
action: 'insertorderedlist',
Expand Down Expand Up @@ -3512,6 +3531,7 @@ MediumEditor.extensions = {};
};

})();

(function () {
'use strict';

Expand Down Expand Up @@ -3891,22 +3911,35 @@ MediumEditor.extensions = {};
// Matches common external protocols "mailto:" "tel:" "maps:"
// Matches relative hash link, begins with "#"
var urlSchemeRegex = /^([a-z]+:)?\/\/|^(mailto|tel|maps):|^\#/i,
hasScheme = urlSchemeRegex.test(value),
scheme = '',
// telRegex is a regex for checking if the string is a telephone number
telRegex = /^\+?\s?\(?(?:\d\s?\-?\)?){3,20}$/,
split = value.split('?'),
path = split[0],
query = split[1];
urlParts = value.match(/^(.*?)(?:\?(.*?))?(?:#(.*))?$/),
path = urlParts[1],
query = urlParts[2],
fragment = urlParts[3];

if (telRegex.test(value)) {
return 'tel:' + value;
} else {
// Check for URL scheme and default to http:// if none found
return (urlSchemeRegex.test(value) ? '' : 'http://') +
// Ensure path is encoded
this.ensureEncodedUri(path) +
// Ensure query is encoded
(query === undefined ? '' : '?' + this.ensureEncodedQuery(query));
}

if (!hasScheme) {
var host = path.split('/')[0];
// if the host part of the path looks like a hostname
if (host.match(/.+(\.|:).+/) || host === 'localhost') {
scheme = 'http://';
}
}

return scheme +
// Ensure path is encoded
this.ensureEncodedUri(path) +
// Ensure query is encoded
(query === undefined ? '' : '?' + this.ensureEncodedQuery(query)) +
// Include fragment unencoded as encodeUriComponent is too
// heavy handed for the many characters allowed in a fragment
(fragment === undefined ? '' : '#' + fragment);
},

doFormCancel: function () {
Expand Down Expand Up @@ -7116,6 +7149,11 @@ MediumEditor.extensions = {};
return this.options.ownerDocument.execCommand('insertImage', false, src);
}

if (action === 'html') {
var html = this.options.contentWindow.getSelection().toString().trim();
return MediumEditor.util.insertHTMLCommand(this.options.ownerDocument, html);
}

/* Issue: https://github.com/yabwe/medium-editor/issues/595
* If the action is to justify the text */
if (justifyAction.exec(action)) {
Expand Down Expand Up @@ -7831,7 +7869,7 @@ MediumEditor.parseVersionString = function (release) {

MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
// grunt-bump looks for this:
'version': '5.22.2'
'version': '5.23.0'
}).version);

return MediumEditor;
Expand Down
8 changes: 4 additions & 4 deletions dist/js/medium-editor.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medium-editor",
"version": "5.22.2",
"version": "5.23.0",
"author": "Davi Ferreira <hi@daviferreira.com>",
"contributors": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/js/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ MediumEditor.parseVersionString = function (release) {

MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
// grunt-bump looks for this:
'version': '5.22.2'
'version': '5.23.0'
}).version);

0 comments on commit de9371b

Please sign in to comment.