diff --git a/markdownx/.static/markdownx/js/markdownx.ts b/markdownx/.static/markdownx/js/markdownx.ts index 0cf035a..c3cbade 100644 --- a/markdownx/.static/markdownx/js/markdownx.ts +++ b/markdownx/.static/markdownx/js/markdownx.ts @@ -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: