diff --git a/vendor/assets/javascripts/medium-editor.js b/vendor/assets/javascripts/medium-editor.js index 5255781..55685f9 100644 --- a/vendor/assets/javascripts/medium-editor.js +++ b/vendor/assets/javascripts/medium-editor.js @@ -176,7 +176,9 @@ if (!("classList" in document.createElement("_"))) { if (typeof module === 'object') { module.exports = factory; } else if (typeof define === 'function' && define.amd) { - define(factory); + define(function () { + return factory; + }); } else { root.MediumEditor = factory; } @@ -848,11 +850,7 @@ var DefaultButton, queryCommandState: function () { var queryState = null; if (this.options.useQueryState) { - try { - queryState = this.base.options.ownerDocument.queryCommandState(this.getAction()); - } catch (exc) { - queryState = null; - } + queryState = this.base.queryCommandState(this.getAction()); } return queryState; }, @@ -2377,6 +2375,28 @@ function MediumEditor(elements, options) { return this; }, + // Wrapper around document.queryCommandState for checking whether an action has already + // been applied to the current selection + queryCommandState: function (action) { + var fullAction = /^full-(.+)$/gi, + match, + queryState = null; + + // Actions starting with 'full-' need to be modified since this is a medium-editor concept + match = fullAction.exec(action); + if (match) { + action = match[1]; + } + + try { + queryState = this.options.ownerDocument.queryCommandState(action); + } catch (exc) { + queryState = null; + } + + return queryState; + }, + execAction: function (action, opts) { /*jslint regexp: true*/ var fullAction = /^full-(.+)$/gi, @@ -2427,26 +2447,8 @@ function MediumEditor(elements, options) { return this.options.ownerDocument.execCommand(action, false, null); }, - // TODO: move these two methods to selection.js - // http://stackoverflow.com/questions/15867542/range-object-get-selection-parent-node-chrome-vs-firefox - rangeSelectsSingleNode: function (range) { - var startNode = range.startContainer; - return startNode === range.endContainer && - startNode.hasChildNodes() && - range.endOffset === range.startOffset + 1; - }, - getSelectedParentElement: function () { - var selectedParentElement = null, - range = this.selectionRange; - if (this.rangeSelectsSingleNode(range) && range.startContainer.childNodes[range.startOffset].nodeType !== 3) { - selectedParentElement = range.startContainer.childNodes[range.startOffset]; - } else if (range.startContainer.nodeType === 3) { - selectedParentElement = range.startContainer.parentNode; - } else { - selectedParentElement = range.startContainer; - } - return selectedParentElement; + return Selection.getSelectedParentElement(); }, execFormatBlock: function (el) { diff --git a/vendor/assets/stylesheets/medium-editor/themes/default.css b/vendor/assets/stylesheets/medium-editor/themes/default.css index 4a3feb2..264f7bf 100755 --- a/vendor/assets/stylesheets/medium-editor/themes/default.css +++ b/vendor/assets/stylesheets/medium-editor/themes/default.css @@ -10,7 +10,7 @@ border: 1px solid #000; background-color: #242424; background: -webkit-linear-gradient(bottom, #242424, rgba(36, 36, 36, 0.75)); - background: linear-gradient(bottom, #242424, rgba(36, 36, 36, 0.75)); + background: linear-gradient(to bottom, #242424, rgba(36, 36, 36, 0.75)); border-radius: 5px; box-shadow: 0 0 3px #000; } .medium-editor-toolbar li button { @@ -23,7 +23,7 @@ background-color: #242424; color: #fff; background: -webkit-linear-gradient(bottom, #242424, rgba(36, 36, 36, 0.89)); - background: linear-gradient(bottom, #242424, rgba(36, 36, 36, 0.89)); + background: linear-gradient(to bottom, #242424, rgba(36, 36, 36, 0.89)); box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); -webkit-transition: background-color .2s ease-in; transition: background-color .2s ease-in; } @@ -40,7 +40,7 @@ background-color: #000; color: #fff; background: -webkit-linear-gradient(bottom, #242424, rgba(0, 0, 0, 0.89)); - background: linear-gradient(bottom, #242424, rgba(0, 0, 0, 0.89)); } + background: linear-gradient(to bottom, #242424, rgba(0, 0, 0, 0.89)); } .medium-editor-toolbar-form { background: #242424; diff --git a/vendor/assets/stylesheets/medium-editor/themes/mani.css b/vendor/assets/stylesheets/medium-editor/themes/mani.css index acd3f2c..4c2e7ca 100644 --- a/vendor/assets/stylesheets/medium-editor/themes/mani.css +++ b/vendor/assets/stylesheets/medium-editor/themes/mani.css @@ -6,7 +6,7 @@ background-color: #dee7f0; background-color: rgba(222, 231, 240, 0.95); background: -webkit-linear-gradient(bottom, #dee7f0, #ffffff); - background: linear-gradient(bottom, #dee7f0, #ffffff); + background: linear-gradient(to bottom, #dee7f0, #ffffff); border-radius: 2px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); } .medium-editor-toolbar li button { @@ -33,7 +33,7 @@ background-color: rgba(92, 144, 199, 0.45); color: #000; background: -webkit-linear-gradient(bottom, #dee7f0, rgba(0, 0, 0, 0.1)); - background: linear-gradient(bottom, #dee7f0, rgba(0, 0, 0, 0.1)); } + background: linear-gradient(to bottom, #dee7f0, rgba(0, 0, 0, 0.1)); } .medium-editor-toolbar-form { background: #dee7f0; diff --git a/vendor/assets/stylesheets/medium-editor/themes/roman.css b/vendor/assets/stylesheets/medium-editor/themes/roman.css index 94a706c..68f07de 100644 --- a/vendor/assets/stylesheets/medium-editor/themes/roman.css +++ b/vendor/assets/stylesheets/medium-editor/themes/roman.css @@ -15,7 +15,7 @@ color: #889aac; box-shadow: inset 0 0 3px #f8f8e6; background: -webkit-linear-gradient(top, #fff, rgba(0, 0, 0, 0.1)); - background: linear-gradient(top, #fff, rgba(0, 0, 0, 0.1)); + background: linear-gradient(to top, #fff, rgba(0, 0, 0, 0.1)); text-shadow: 1px 4px 6px #def, 0 0 0 #000, 1px 4px 6px #def; -webkit-transition: background-color .2s ease-in; transition: background-color .2s ease-in; } @@ -34,7 +34,7 @@ color: #000; color: rgba(0, 0, 0, 0.8); background: -webkit-linear-gradient(bottom, #fff, rgba(0, 0, 0, 0.2)); - background: linear-gradient(bottom, #fff, rgba(0, 0, 0, 0.2)); } + background: linear-gradient(to bottom, #fff, rgba(0, 0, 0, 0.2)); } .medium-editor-toolbar-form { background: #fff;