Skip to content

Commit

Permalink
5.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Mar 24, 2016
1 parent 00d868a commit 5d52829
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 13 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
5.15.0 / 2016-03-23
==================
* Use class instead of inline style for hiding/showing anchor form
* Add helpers for hiding/showing form into form extension base class
* Fix issue where auto-link extension re-enabled IE's built-in auto-link when other instances still existed
* Fix anchor form to display form before attempting to position correctly
* Add new selection.clearSelection() helper method for moving cursor to beginning/end of selection


5.14.4 / 2016-02-25
==================
* editableInput event fixes
Expand Down
3 changes: 3 additions & 0 deletions dist/css/medium-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
margin: 0 10px;
text-decoration: none; }

.medium-editor-toolbar-form-active {
display: block; }

.medium-editor-toolbar-actions:after {
clear: both;
content: "";
Expand Down
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.

64 changes: 57 additions & 7 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2354,6 +2354,20 @@ MediumEditor.extensions = {};
return range;
},

/**
* Clear the current highlighted selection and set the caret to the start or the end of that prior selection, defaults to end.
*
* @param {DomDocument} doc Current document
* @param {boolean} moveCursorToStart A boolean representing whether or not to set the caret to the beginning of the prior selection.
*/
clearSelection: function (doc, moveCursorToStart) {
if (moveCursorToStart) {
doc.getSelection().collapseToStart();
} else {
doc.getSelection().collapseToEnd();
}
},

/**
* Move cursor to the given node with the given offset.
*
Expand Down Expand Up @@ -3409,6 +3423,11 @@ MediumEditor.extensions = {};
formSaveLabel: '✓',
formCloseLabel: '×',

/* activeClass: [string]
* set class which added to shown form
*/
activeClass: 'medium-editor-toolbar-form-active',

/* hasForm: [boolean]
*
* Setting this to true will cause getForm() to be called
Expand All @@ -3431,14 +3450,34 @@ MediumEditor.extensions = {};
* This function should return true/false reflecting
* whether the form is currently displayed
*/
isDisplayed: function () {},
isDisplayed: function () {
if (this.hasForm) {
return this.getForm().classList.contains(this.activeClass);
}
return false;
},

/* hideForm: [function ()]
*
* This function should show the form element inside
* the toolbar container
*/
showForm: function () {
if (this.hasForm) {
this.getForm().classList.add(this.activeClass);
}
},

/* hideForm: [function ()]
*
* This function should hide the form element inside
* the toolbar container
*/
hideForm: function () {},
hideForm: function () {
if (this.hasForm) {
this.getForm().classList.remove(this.activeClass);
}
},

/************************ Helpers ************************
* The following are helpers that are either set by MediumEditor
Expand Down Expand Up @@ -3627,11 +3666,11 @@ MediumEditor.extensions = {};

// Used by medium-editor when the default toolbar is to be displayed
isDisplayed: function () {
return this.getForm().style.display === 'block';
return MediumEditor.extensions.form.prototype.isDisplayed.apply(this);
},

hideForm: function () {
this.getForm().style.display = 'none';
MediumEditor.extensions.form.prototype.hideForm.apply(this);
this.getInput().value = '';
},

Expand All @@ -3651,7 +3690,7 @@ MediumEditor.extensions = {};

this.base.saveSelection();
this.hideToolbarDefaultActions();
this.getForm().style.display = 'block';
MediumEditor.extensions.form.prototype.showForm.apply(this);
this.setToolbarPosition();

input.value = opts.url;
Expand Down Expand Up @@ -4125,9 +4164,20 @@ MediumEditor.extensions = {};
this.document.execCommand('AutoUrlDetect', false, false);
},

isLastInstance: function () {
var activeInstances = 0;
for (var i = 0; i < this.window._mediumEditors.length; i++) {
var editor = this.window._mediumEditors[i];
if (editor !== null && editor.getExtensionByName('autoLink') !== undefined) {
activeInstances++;
}
}
return activeInstances === 1;
},

destroy: function () {
// Turn AutoUrlDetect back on
if (this.document.queryCommandSupported('AutoUrlDetect')) {
if (this.document.queryCommandSupported('AutoUrlDetect') && this.isLastInstance()) {
this.document.execCommand('AutoUrlDetect', false, true);
}
},
Expand Down Expand Up @@ -7104,7 +7154,7 @@ MediumEditor.parseVersionString = function (release) {

MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
// grunt-bump looks for this:
'version': '5.14.4'
'version': '5.15.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.14.4",
"version": "5.15.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.14.4'
'version': '5.15.0'
}).version);

0 comments on commit 5d52829

Please sign in to comment.