Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Update Medium Editor files
Browse files Browse the repository at this point in the history
  • Loading branch information
marjinal1st committed Feb 27, 2015
1 parent b838798 commit 8efdb52
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
52 changes: 27 additions & 25 deletions vendor/assets/javascripts/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions vendor/assets/stylesheets/medium-editor/themes/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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; }
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions vendor/assets/stylesheets/medium-editor/themes/mani.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions vendor/assets/stylesheets/medium-editor/themes/roman.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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;
Expand Down

0 comments on commit 8efdb52

Please sign in to comment.