From 9daa1b14a727d4a4708c411317f0b9b8f35bf5fe Mon Sep 17 00:00:00 2001 From: gabrielmedina Date: Thu, 24 Mar 2016 08:20:16 -0400 Subject: [PATCH] Update version to 5.15.0 --- README.md | 2 +- lib/medium-editor-rails/version.rb | 4 +- medium-editor-rails.gemspec | 6 +- vendor/assets/javascripts/medium-editor.js | 64 +++++++++++++++++-- .../medium-editor/medium-editor.css | 3 + 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e951c64..df07162 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This gem integrates [Medium Editor](https://github.com/yabwe/medium-editor) with ## Version -The latest version of Medium Editor bundled by this gem is [5.14.4](https://github.com/yabwe/medium-editor/releases) +The latest version of Medium Editor bundled by this gem is [5.15.0](https://github.com/yabwe/medium-editor/releases) ## Installation diff --git a/lib/medium-editor-rails/version.rb b/lib/medium-editor-rails/version.rb index 29ac293..1749704 100644 --- a/lib/medium-editor-rails/version.rb +++ b/lib/medium-editor-rails/version.rb @@ -1,6 +1,6 @@ module MediumEditorRails module Rails - VERSION = '2.1.0' - MEDIUM_EDITOR_VERSION = '5.14.4' + VERSION = '2.2.0' + MEDIUM_EDITOR_VERSION = '5.15.0' end end diff --git a/medium-editor-rails.gemspec b/medium-editor-rails.gemspec index c55b4a1..17aaacc 100644 --- a/medium-editor-rails.gemspec +++ b/medium-editor-rails.gemspec @@ -6,9 +6,9 @@ require 'medium-editor-rails/version' Gem::Specification.new do |gem| gem.name = 'medium-editor-rails' gem.version = MediumEditorRails::Rails::VERSION - gem.authors = ['Ahmet Sezgin Duran'] - gem.email = ['marjinalist1@gmail.com'] - gem.summary = %q{Medium Editor integrated in Rails asset pipeline} + gem.authors = ['Ahmet Sezgin Duran', 'Gabriel Medina'] + gem.email = ['marjinalist1@gmail.com', 'gmedina.santos@gmail.com'] + gem.summary = %q{Metdium Editor integrated in Rails asset pipeline} gem.description = gem.summary gem.homepage = 'https://github.com/marjinal1st/medium-editor-rails' gem.license = 'MIT' diff --git a/vendor/assets/javascripts/medium-editor.js b/vendor/assets/javascripts/medium-editor.js index 1c40717..abd5543 100644 --- a/vendor/assets/javascripts/medium-editor.js +++ b/vendor/assets/javascripts/medium-editor.js @@ -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. * @@ -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 @@ -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 @@ -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 = ''; }, @@ -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; @@ -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); } }, @@ -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; diff --git a/vendor/assets/stylesheets/medium-editor/medium-editor.css b/vendor/assets/stylesheets/medium-editor/medium-editor.css index dfc9410..2fbff8a 100644 --- a/vendor/assets/stylesheets/medium-editor/medium-editor.css +++ b/vendor/assets/stylesheets/medium-editor/medium-editor.css @@ -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: "";