medium-editor
Advanced tools
Comparing version 5.3.0 to 5.4.0
@@ -0,1 +1,6 @@ | ||
5.4.0 / 2015-07-16 | ||
================== | ||
* Add support for including 'alt' key in keyboard-commands | ||
5.3.0 / 2015-07-07 | ||
@@ -2,0 +7,0 @@ ================== |
{ | ||
"name": "medium-editor", | ||
"version": "5.3.0", | ||
"version": "5.4.0", | ||
"author": "Davi Ferreira <hi@daviferreira.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -127,3 +127,3 @@ # MediumEditor | ||
Options for the toolbar are passed as an object taht is a member of the outer options object. Example: | ||
Options for the toolbar are passed as an object that is a member of the outer options object. Example: | ||
```javascript | ||
@@ -358,3 +358,4 @@ var editor = new MediumEditor('.editable', { | ||
meta: true, | ||
shift: false | ||
shift: false, | ||
alt: false | ||
}, | ||
@@ -365,3 +366,4 @@ { | ||
meta: true, | ||
shift: false | ||
shift: false, | ||
alt: false | ||
}, | ||
@@ -372,3 +374,4 @@ { | ||
meta: true, | ||
shift: false | ||
shift: false, | ||
alt: false | ||
} | ||
@@ -386,2 +389,3 @@ ], | ||
* _shift_: whether the shift key has to be active or inactive | ||
* _alt_: whether the alt key has to be active or inactive | ||
@@ -388,0 +392,0 @@ To disable the keyboard commands, set the value of the `keyboardCommands` option to `false`: |
@@ -92,3 +92,3 @@ /*global atob, unescape, Uint8Array, Blob*/ | ||
// keyCode, ctrlKey, target, relatedTarget, shiftKey | ||
// keyCode, ctrlKey, target, relatedTarget, shiftKey, altKey | ||
function fireEvent(element, eventName, options) { | ||
@@ -158,2 +158,6 @@ var evt = prepareEvent( | ||
if (options.altKey) { | ||
evt.altKey = true; | ||
} | ||
if (eventName.indexOf('drag') !== -1 || eventName === 'drop') { | ||
@@ -160,0 +164,0 @@ evt.dataTransfer = { |
@@ -57,3 +57,4 @@ /*global MediumEditor, describe, it, expect, beforeEach, | ||
meta: true, | ||
shift: false | ||
shift: false, | ||
alt: false | ||
}, | ||
@@ -64,3 +65,4 @@ { | ||
meta: true, | ||
shift: true | ||
shift: true, | ||
alt: false | ||
} | ||
@@ -87,2 +89,65 @@ ] | ||
it('should support the use of Alt key', function () { | ||
spyOn(MediumEditor.prototype, 'execAction'); | ||
var editor = this.newMediumEditor('.editor', { | ||
keyboardCommands: { | ||
commands: [ | ||
{ | ||
command: 'append-h1', | ||
key: '1', | ||
meta: true, | ||
shift: false, | ||
alt: true | ||
}, | ||
{ | ||
command: 'append-h2', | ||
key: '2', | ||
meta: true, | ||
shift: false, | ||
alt: true | ||
}, | ||
{ | ||
command: 'append-h3', | ||
key: '3', | ||
meta: true, | ||
shift: false, | ||
alt: true | ||
}, | ||
{ | ||
command: 'append-h4', | ||
key: '4', | ||
meta: true, | ||
shift: false, | ||
alt: true | ||
}, | ||
{ | ||
command: 'append-h5', | ||
key: '5', | ||
meta: true, | ||
shift: false, | ||
alt: true | ||
}, | ||
{ | ||
command: 'append-h6', | ||
key: '6', | ||
meta: true, | ||
shift: false, | ||
alt: true | ||
} | ||
] | ||
} | ||
}); | ||
selectElementContentsAndFire(editor.elements[0]); | ||
jasmine.clock().tick(1); | ||
['1', '2', '3', '4', '5', '6'].forEach(function (heading) { | ||
fireEvent(editor.elements[0], 'keydown', { | ||
keyCode: (heading).toString().charCodeAt(0), | ||
ctrlKey: true, | ||
metaKey: true, | ||
altKey: true | ||
}); | ||
expect(editor.execAction).toHaveBeenCalledWith('append-h' + heading); | ||
}); | ||
}); | ||
it('should not execute the button action when shift key is pressed', function () { | ||
@@ -89,0 +154,0 @@ spyOn(MediumEditor.prototype, 'execAction'); |
@@ -19,2 +19,3 @@ var KeyboardCommands; | ||
* shift [boolean] (whether the shift key has to be active or inactive) | ||
* alt [boolean] (whether the alt key has to be active or inactive) | ||
*/ | ||
@@ -26,3 +27,4 @@ commands: [ | ||
meta: true, | ||
shift: false | ||
shift: false, | ||
alt: false | ||
}, | ||
@@ -33,3 +35,4 @@ { | ||
meta: true, | ||
shift: false | ||
shift: false, | ||
alt: false | ||
}, | ||
@@ -40,3 +43,4 @@ { | ||
meta: true, | ||
shift: false | ||
shift: false, | ||
alt: false | ||
} | ||
@@ -66,7 +70,9 @@ ], | ||
var isMeta = Util.isMetaCtrlKey(event), | ||
isShift = !!event.shiftKey; | ||
isShift = !!event.shiftKey, | ||
isAlt = !!event.altKey; | ||
this.keys[keyCode].forEach(function (data) { | ||
if (data.meta === isMeta && | ||
data.shift === isShift) { | ||
data.shift === isShift && | ||
data.alt === isAlt) { | ||
event.preventDefault(); | ||
@@ -73,0 +79,0 @@ event.stopPropagation(); |
@@ -20,3 +20,3 @@ /*global MediumEditor */ | ||
// grunt-bump looks for this: | ||
'version': '5.3.0' | ||
'version': '5.4.0' | ||
}).version); |
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
1396915
118
18086
632