medium-editor
Advanced tools
Comparing version 4.7.1 to 4.7.2
{ | ||
"name": "medium-editor", | ||
"version": "4.7.1", | ||
"version": "4.7.2", | ||
"homepage": "http://daviferreira.github.io/medium-editor/", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -0,1 +1,7 @@ | ||
4.7.2 / 2015-05-06 | ||
================== | ||
* Add shortcut to insert a link (ctrl/cmd + k) | ||
* Fix `this.getAttribute is not a function` error | ||
4.7.1 / 2015-04-30 | ||
@@ -2,0 +8,0 @@ ================== |
{ | ||
"name": "medium-editor", | ||
"version": "4.7.1", | ||
"version": "4.7.2", | ||
"author": "Davi Ferreira <hi@daviferreira.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -38,2 +38,19 @@ /*global MediumEditor, describe, it, expect, spyOn, | ||
}); | ||
it('should show the form on shortcut', function () { | ||
var editor = new MediumEditor('.editor'), | ||
anchorExtension = editor.getExtensionByName('anchor'), | ||
code = 'k'.charCodeAt(0); | ||
selectElementContentsAndFire(editor.elements[0]); | ||
jasmine.clock().tick(1); | ||
fireEvent(editor.elements[0], 'keydown', { | ||
keyCode: code, | ||
ctrlKey: true, | ||
metaKey: true | ||
}); | ||
expect(editor.toolbar.isDisplayed()).toBe(true); | ||
expect(anchorExtension.isDisplayed()).toBe(true); | ||
}); | ||
}); | ||
@@ -40,0 +57,0 @@ |
@@ -74,3 +74,4 @@ /*global MediumEditor, describe, it, expect, spyOn, | ||
keyCode: code, | ||
ctrlKey: true | ||
ctrlKey: true, | ||
metaKey: true | ||
}); | ||
@@ -77,0 +78,0 @@ expect(editor.execAction).toHaveBeenCalled(); |
@@ -70,2 +70,6 @@ /*global atob, unescape, Uint8Array, Blob*/ | ||
if (options.metaKey) { | ||
evt.metaKey = true; | ||
} | ||
if (options.target) { | ||
@@ -72,0 +76,0 @@ evt.target = options.target; |
@@ -0,1 +1,3 @@ | ||
/*global Util */ | ||
var DefaultButton; | ||
@@ -56,14 +58,12 @@ | ||
handleKeydown: function (evt) { | ||
var key, action; | ||
var key = String.fromCharCode(evt.which || evt.keyCode).toLowerCase(), | ||
action; | ||
if (evt.ctrlKey || evt.metaKey) { | ||
key = String.fromCharCode(evt.which || evt.keyCode).toLowerCase(); | ||
if (this.options.key === key) { | ||
evt.preventDefault(); | ||
evt.stopPropagation(); | ||
if (this.options.key === key && Util.isMetaCtrlKey(evt)) { | ||
evt.preventDefault(); | ||
evt.stopPropagation(); | ||
action = this.getAction(); | ||
if (action) { | ||
this.base.execAction(action); | ||
} | ||
action = this.getAction(); | ||
if (action) { | ||
this.base.execAction(action); | ||
} | ||
@@ -70,0 +70,0 @@ } |
@@ -18,3 +18,3 @@ /*global FileReader, Util, ButtonsData, DefaultButton, | ||
event.preventDefault(); | ||
} else if (this.options.disableDoubleReturn || this.getAttribute('data-disable-double-return')) { | ||
} else if (this.options.disableDoubleReturn || element.getAttribute('data-disable-double-return')) { | ||
var node = Util.getSelectionStart(this.options.ownerDocument); | ||
@@ -21,0 +21,0 @@ if (node && node.textContent.trim() === '') { |
@@ -16,3 +16,4 @@ /*global Util, Selection, DefaultButton */ | ||
contentDefault: '<b>#</b>', | ||
contentFA: '<i class="fa fa-link"></i>' | ||
contentFA: '<i class="fa fa-link"></i>', | ||
key: 'k' | ||
}; | ||
@@ -50,2 +51,15 @@ this.name = 'anchor'; | ||
// Called when user hits the defined shortcut (CTRL / COMMAND + K) | ||
// Overrides DefaultButton.handleKeydown | ||
handleKeydown: function (evt) { | ||
var key = String.fromCharCode(evt.which || evt.keyCode).toLowerCase(); | ||
if (this.options.key === key && Util.isMetaCtrlKey(evt)) { | ||
evt.preventDefault(); | ||
evt.stopPropagation(); | ||
this.handleClick(evt); | ||
} | ||
}, | ||
// Called by medium-editor to append form to the toolbar | ||
@@ -52,0 +66,0 @@ getForm: function () { |
@@ -58,2 +58,5 @@ /*global NodeFilter, console*/ | ||
// http://stackoverflow.com/a/11752084/569101 | ||
isMac: (window.navigator.platform.toUpperCase().indexOf('MAC') >= 0), | ||
// https://github.com/jashkenas/underscore | ||
@@ -69,2 +72,14 @@ keyCode: { | ||
/** | ||
* Returns true if it's metaKey on Mac, or ctrlKey on non-Mac. | ||
* See #591 | ||
*/ | ||
isMetaCtrlKey: function (event) { | ||
if ((this.isMac && event.metaKey) || (!this.isMac && event.ctrlKey)) { | ||
return true; | ||
} | ||
return false; | ||
}, | ||
parentElements: ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'pre'], | ||
@@ -71,0 +86,0 @@ |
@@ -14,3 +14,3 @@ /*global MediumEditor */ | ||
// grunt-bump looks for this: | ||
'version': '4.7.1' | ||
'version': '4.7.2' | ||
}).version.split('.')); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1085031
13173
97