diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8b5d92..12e6eed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
#### [Current]
+ * [3e8148f](../../commit/3e8148f) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
+
+#### 0.11.0
+ * [90cef00](../../commit/90cef00) - __(Ahmet Sezgin Duran)__ Bump versions 0.11.0 and 1.9.4
* [c949af6](../../commit/c949af6) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
* [6e867bb](../../commit/6e867bb) - __(Ahmet Sezgin Duran)__ Add Gemnasium badge
* [618bf25](../../commit/618bf25) - __(Ahmet Sezgin Duran)__ Merge tag '0.10.0' into develop
diff --git a/README.md b/README.md
index 2029d25..e18d058 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ This gem integrates [Medium Editor](https://github.com/daviferreira/medium-edito
## Version
-The latest version of Medium Editor bundled by this gem is [1.9.4](https://github.com/daviferreira/medium-editor/releases)
+The latest version of Medium Editor bundled by this gem is [1.9.8](https://github.com/daviferreira/medium-editor/releases)
## Installation
diff --git a/lib/medium-editor-rails/version.rb b/lib/medium-editor-rails/version.rb
index e6307e4..5700924 100644
--- a/lib/medium-editor-rails/version.rb
+++ b/lib/medium-editor-rails/version.rb
@@ -1,6 +1,6 @@
module MediumEditorRails
module Rails
- VERSION = '0.11.0'
- MEDIUM_EDITOR_VERSION = '1.9.4'
+ VERSION = '0.12.0'
+ MEDIUM_EDITOR_VERSION = '1.9.8'
end
end
diff --git a/vendor/assets/javascripts/medium-editor.js b/vendor/assets/javascripts/medium-editor.js
index 30f9f70..47a54dc 100644
--- a/vendor/assets/javascripts/medium-editor.js
+++ b/vendor/assets/javascripts/medium-editor.js
@@ -276,14 +276,18 @@ if (typeof module === 'object') {
this.elements[index].addEventListener('keyup', function (e) {
var node = getSelectionStart(),
- tagName;
+ tagName,
+ editorElement;
+
if (node && node.getAttribute('data-medium-element') && node.children.length === 0 && !(self.options.disableReturn || node.getAttribute('data-disable-return'))) {
document.execCommand('formatBlock', false, 'p');
}
if (e.which === 13) {
node = getSelectionStart();
tagName = node.tagName.toLowerCase();
- if (!(self.options.disableReturn || this.getAttribute('data-disable-return')) &&
+ editorElement = self.getSelectionElement();
+
+ if (!(self.options.disableReturn || editorElement.getAttribute('data-disable-return')) &&
tagName !== 'li' && !self.isListItemChild(node)) {
if (!e.shiftKey) {
document.execCommand('formatBlock', false, 'p');
@@ -375,7 +379,11 @@ if (typeof module === 'object') {
'unorderedlist': '',
'pre': '',
'indent': '',
- 'outdent': ''
+ 'outdent': '',
+ 'justifyCenter': '',
+ 'justifyFull': '',
+ 'justifyLeft': '',
+ 'justifyRight': ''
};
return buttonTemplates[btnType] || false;
},
@@ -399,7 +407,11 @@ if (typeof module === 'object') {
'unorderedlist': '•',
'pre': '0101',
'indent': '→',
- 'outdent': '←'
+ 'outdent': '←',
+ 'justifyCenter': 'C',
+ 'justifyFull': 'J',
+ 'justifyLeft': 'L',
+ 'justifyRight': 'R'
};
if (buttonLabelType === 'fontawesome') {
customButtonLabels = {
@@ -415,7 +427,11 @@ if (typeof module === 'object') {
'unorderedlist': '',
'pre': '',
'indent': '',
- 'outdent': ''
+ 'outdent': '',
+ 'justifyCenter': '',
+ 'justifyFull': '',
+ 'justifyLeft': '',
+ 'justifyRight': ''
};
} else if (typeof buttonLabelType === 'object') {
customButtonLabels = buttonLabelType;
@@ -625,36 +641,31 @@ if (typeof module === 'object') {
},
findMatchingSelectionParent: function(testElementFunction) {
- var selection = window.getSelection(),
- range, current, parent,
- result,
- getElement = function (e) {
- var localParent = e;
- try {
- while (!testElementFunction(localParent)) {
- localParent = localParent.parentNode;
- }
- } catch (errb) {
- return false;
- }
- return localParent;
- };
- // First try on current node
- try {
- range = selection.getRangeAt(0);
- current = range.commonAncestorContainer;
- parent = current.parentNode;
-
- if (testElementFunction(current)) {
- result = current;
- } else {
- result = getElement(parent);
- }
- // If not search in the parent nodes.
- } catch (err) {
- result = getElement(parent);
+ var selection = window.getSelection(), range, current;
+
+ if (selection.rangeCount === 0) {
+ return false;
}
- return result;
+
+ range = selection.getRangeAt(0);
+ current = range.commonAncestorContainer;
+
+ do {
+ if (current.nodeType === 1){
+ if ( testElementFunction(current) )
+ {
+ return current;
+ }
+ // do not traverse upwards past the nearest containing editor
+ if (current.getAttribute('data-medium-element')) {
+ return false;
+ }
+ }
+
+ current = current.parentNode;
+ } while (current);
+
+ return false;
},
getSelectionElement: function () {
@@ -1325,7 +1336,8 @@ if (typeof module === 'object') {
}
document.execCommand('insertHTML', false, html);
} else {
- document.execCommand('insertHTML', false, e.clipboardData.getData('text/plain'));
+ html = self.htmlEntities(e.clipboardData.getData('text/plain'));
+ document.execCommand('insertHTML', false, html);
}
}
};