mirror of
https://github.com/Hopiu/django-markdownx.git
synced 2026-05-17 17:21:05 +00:00
cmd+[ and cmd+] key support
This commit is contained in:
parent
e0ab9cb7aa
commit
740b7b20c4
1 changed files with 24 additions and 3 deletions
|
|
@ -32,7 +32,9 @@ const UPLOAD_URL_ATTRIBUTE: string = "data-markdownx-upload-urls-path",
|
|||
UPLOAD_START_OPACITY: string = "0.3",
|
||||
NORMAL_OPACITY: string = "1",
|
||||
INDENTATION_KEY: string = "Tab",
|
||||
DUPLICATION_KEY: string = "d";
|
||||
DUPLICATION_KEY: string = "d",
|
||||
BRACKET_LEFT_KEY: string = "[",
|
||||
BRACKET_RIGHT_KEY: string = "]";
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -162,8 +164,13 @@ const keyboardEvents = {
|
|||
*/
|
||||
hub: function (event: KeyboardEvent): Function | Boolean {
|
||||
|
||||
// `Tab` for indentation, `d` for duplication.
|
||||
if (event.key !== INDENTATION_KEY && event.key !== DUPLICATION_KEY) return null;
|
||||
// `Tab` or `CMD+Bracket` for indentation, `d` for duplication.
|
||||
if (
|
||||
event.key !== INDENTATION_KEY &&
|
||||
event.key !== DUPLICATION_KEY &&
|
||||
event.key !== BRACKET_LEFT_KEY &&
|
||||
event.key !== BRACKET_RIGHT_KEY
|
||||
) return null;
|
||||
|
||||
event = EventHandlers.inhibitDefault(event);
|
||||
|
||||
|
|
@ -177,6 +184,20 @@ const keyboardEvents = {
|
|||
// Is CTRL or CMD (on Mac) pressed?
|
||||
return this._applyDuplication;
|
||||
|
||||
} else return false
|
||||
|
||||
case BRACKET_LEFT_KEY: // For unindentation.
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
// Is CTRL or CMD (on Mac) pressed?
|
||||
return this._removeIndentation;
|
||||
|
||||
} else return false;
|
||||
|
||||
case BRACKET_RIGHT_KEY: // For unindentation.
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
// Is CTRL or CMD (on Mac) pressed?
|
||||
return this._applyIndentation;
|
||||
|
||||
} else return false;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in a new issue