Skip to content

Commit

Permalink
5.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Apr 12, 2016
1 parent 46660a0 commit 55b7292
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 39 deletions.
11 changes: 10 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
5.15.1 / 2016-04-05
5.16.0 / 2016-04-12
==================
* Add support for multiple targets for attaching/detach event handlers
* Add support for chaining calls to attach/detach events
* Fix issue with click anchor-preview when using showWhenToolbarIsVisible
* Fix IE issue with line-breaking within editor
* Fix Firefox error when using elements other than divs as editor


5.15.1 / 2016-04-05
==================
* Fix link validation in anchor extension
* Improve performance when dealing with a lot of data
* Enable functions to be used as keyboard commands


5.15.0 / 2016-03-23
==================
* Use class instead of inline style for hiding/showing anchor form
Expand Down
17 changes: 9 additions & 8 deletions dist/css/medium-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,15 @@
content: "";
display: table; }

[data-medium-editor-element] img {
max-width: 100%; }

[data-medium-editor-element] sub {
vertical-align: sub; }

[data-medium-editor-element] sup {
vertical-align: super; }
[data-medium-editor-element] {
word-break: break-all;
min-height: 30px; }
[data-medium-editor-element] img {
max-width: 100%; }
[data-medium-editor-element] sub {
vertical-align: sub; }
[data-medium-editor-element] sup {
vertical-align: super; }

.medium-editor-hidden {
display: none; }
2 changes: 1 addition & 1 deletion dist/css/medium-editor.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 49 additions & 24 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2417,18 +2417,26 @@ MediumEditor.extensions = {};

// Helpers for event handling

attachDOMEvent: function (target, event, listener, useCapture) {
target.addEventListener(event, listener, useCapture);
this.events.push([target, event, listener, useCapture]);
attachDOMEvent: function (targets, event, listener, useCapture) {
targets = MediumEditor.util.isElement(targets) || [window, document].indexOf(targets) > -1 ? [targets] : targets;

Array.prototype.forEach.call(targets, function (target) {
target.addEventListener(event, listener, useCapture);
this.events.push([target, event, listener, useCapture]);
}.bind(this));
},

detachDOMEvent: function (target, event, listener, useCapture) {
var index = this.indexOfListener(target, event, listener, useCapture),
e;
if (index !== -1) {
e = this.events.splice(index, 1)[0];
e[0].removeEventListener(e[1], e[2], e[3]);
}
detachDOMEvent: function (targets, event, listener, useCapture) {
var index, e;
targets = MediumEditor.util.isElement(targets) || [window, document].indexOf(targets) > -1 ? [targets] : targets;

Array.prototype.forEach.call(targets, function (target) {
index = this.indexOfListener(target, event, listener, useCapture);
if (index !== -1) {
e = this.events.splice(index, 1)[0];
e[0].removeEventListener(e[1], e[2], e[3]);
}
}.bind(this));
},

indexOfListener: function (target, event, listener, useCapture) {
Expand Down Expand Up @@ -3990,6 +3998,15 @@ MediumEditor.extensions = {};

attachToEditables: function () {
this.subscribe('editableMouseover', this.handleEditableMouseover.bind(this));
this.subscribe('positionedToolbar', this.handlePositionedToolbar.bind(this));
},

handlePositionedToolbar: function () {
// If the toolbar is visible and positioned, we don't need to hide the preview
// when showWhenToolbarIsVisible is true
if (!this.showWhenToolbarIsVisible) {
this.hidePreview();
}
},

handleClick: function (event) {
Expand Down Expand Up @@ -5831,30 +5848,26 @@ MediumEditor.extensions = {};

setToolbarPosition: function () {
var container = this.base.getFocusedElement(),
selection = this.window.getSelection(),
anchorPreview;
selection = this.window.getSelection();

// If there isn't a valid selection, bail
if (!container) {
return this;
}

if (this.static && !this.relativeContainer) {
this.showToolbar();
this.positionStaticToolbar(container);
} else if (!selection.isCollapsed) {
if (this.static || !selection.isCollapsed) {
this.showToolbar();

// we don't need any absolute positioning if relativeContainer is set
if (!this.relativeContainer) {
this.positionToolbar(selection);
if (this.static) {
this.positionStaticToolbar(container);
} else {
this.positionToolbar(selection);
}
}
}

anchorPreview = this.base.getExtensionByName('anchor-preview');

if (anchorPreview && typeof anchorPreview.hidePreview === 'function') {
anchorPreview.hidePreview();
this.trigger('positionedToolbar', {}, this.base.getFocusedElement());
}
},

Expand Down Expand Up @@ -6179,7 +6192,9 @@ MediumEditor.extensions = {};
return;
}

if (MediumEditor.util.isMediumEditorElement(node) && node.children.length === 0) {
// https://github.com/yabwe/medium-editor/issues/994
// Firefox thrown an error when calling `formatBlock` on an empty editable blockContainer that's not a <div>
if (MediumEditor.util.isMediumEditorElement(node) && node.children.length === 0 && !MediumEditor.util.isBlockContainer(node)) {
this.options.ownerDocument.execCommand('formatBlock', false, 'p');
}

Expand Down Expand Up @@ -6695,22 +6710,32 @@ MediumEditor.extensions = {};

on: function (target, event, listener, useCapture) {
this.events.attachDOMEvent(target, event, listener, useCapture);

return this;
},

off: function (target, event, listener, useCapture) {
this.events.detachDOMEvent(target, event, listener, useCapture);

return this;
},

subscribe: function (event, listener) {
this.events.attachCustomEvent(event, listener);

return this;
},

unsubscribe: function (event, listener) {
this.events.detachCustomEvent(event, listener);

return this;
},

trigger: function (name, data, editable) {
this.events.triggerCustomEvent(name, data, editable);

return this;
},

delay: function (fn) {
Expand Down Expand Up @@ -7160,7 +7185,7 @@ MediumEditor.parseVersionString = function (release) {

MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
// grunt-bump looks for this:
'version': '5.15.1'
'version': '5.16.0'
}).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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medium-editor",
"version": "5.15.1",
"version": "5.16.0",
"author": "Davi Ferreira <[email protected]>",
"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.15.1'
'version': '5.16.0'
}).version);

0 comments on commit 55b7292

Please sign in to comment.