Skip to content

Commit

Permalink
5.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Feb 10, 2016
1 parent 2017070 commit 512f13f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
@@ -1,3 +1,12 @@
5.14.2 / 2016-02-10
==================
* Support Microsoft Edge
* Fallback to custom insertHTML command instead of built-in command for Edge
* Use shim code for detecting input on contenteditable for Edge
* Fix issue with converting blockquotes to paragraphs in Edge
* Update documentation, fix tests, and include Edge in browser testing


5.14.1 / 2016-02-05
==================
* Fix issue with saving selection after newline and whitespace text nodes
Expand Down
21 changes: 15 additions & 6 deletions dist/js/medium-editor.js
Expand Up @@ -445,6 +445,8 @@ MediumEditor.extensions = {};
// by rg89
isIE: ((navigator.appName === 'Microsoft Internet Explorer') || ((navigator.appName === 'Netscape') && (new RegExp('Trident/.*rv:([0-9]{1,}[.0-9]{0,})').exec(navigator.userAgent) !== null))),

isEdge: (/Edge\/\d+/).exec(navigator.userAgent) !== null,

// if firefox
isFF: (navigator.userAgent.toLowerCase().indexOf('firefox') > -1),

Expand Down Expand Up @@ -842,7 +844,14 @@ MediumEditor.extensions = {};
insertHTMLCommand: function (doc, html) {
var selection, range, el, fragment, node, lastNode, toReplace;

if (doc.queryCommandSupported('insertHTML')) {
/* Edge's implementation of insertHTML is just buggy right now:
* - Doesn't allow leading white space at the beginning of an element
* - Found a case when a <font size="2"> tag was inserted when calling alignCenter inside a blockquote
*
* There are likely many other bugs, these are just the ones we found so far.
* For now, let's just use the same fallback we did for IE
*/
if (!MediumEditor.util.isEdge && doc.queryCommandSupported('insertHTML')) {
try {
return doc.execCommand('insertHTML', false, html);
} catch (ignore) {}
Expand Down Expand Up @@ -931,16 +940,16 @@ MediumEditor.extensions = {};
tagName = '<' + tagName + '>';
}

// When FF or IE, we have to handle blockquote node seperately as 'formatblock' does not work.
// When FF, IE and Edge, we have to handle blockquote node seperately as 'formatblock' does not work.
// https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#Commands
if (blockContainer && blockContainer.nodeName.toLowerCase() === 'blockquote') {
// For IE, just use outdent
if (Util.isIE && tagName === '<p>') {
return doc.execCommand('outdent', false, tagName);
}

// For Firefox, make sure there's a nested block element before calling outdent
if (Util.isFF && tagName === 'p') {
// For Firefox and Edge, make sure there's a nested block element before calling outdent
if ((Util.isFF || Util.isEdge) && tagName === 'p') {
childNodes = Array.prototype.slice.call(blockContainer.childNodes);
// If there are some non-block elements we need to wrap everything in a <p> before we outdent
if (childNodes.some(function (childNode) {
Expand Down Expand Up @@ -2361,7 +2370,7 @@ MediumEditor.extensions = {};
};

Events.prototype = {
InputEventOnContenteditableSupported: !MediumEditor.util.isIE,
InputEventOnContenteditableSupported: !MediumEditor.util.isIE && !MediumEditor.util.isEdge,

// Helpers for event handling

Expand Down Expand Up @@ -7047,7 +7056,7 @@ MediumEditor.parseVersionString = function (release) {

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

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

Large diffs are not rendered by default.

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

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

0 comments on commit 512f13f

Please sign in to comment.