diff --git a/src/muya/lib/config/index.js b/src/muya/lib/config/index.js index 815f5bcf..3a583693 100644 --- a/src/muya/lib/config/index.js +++ b/src/muya/lib/config/index.js @@ -55,7 +55,8 @@ export const EVENT_KEYS = Object.freeze(generateKeyHash([ 'ArrowLeft', 'ArrowRight', 'Tab', - 'Escape' + 'Escape', + 'Shift' ])) export const LOWERCASE_TAGS = Object.freeze(generateKeyHash([ diff --git a/src/muya/lib/eventHandler/keyboard.js b/src/muya/lib/eventHandler/keyboard.js index c4462cf8..68922db2 100644 --- a/src/muya/lib/eventHandler/keyboard.js +++ b/src/muya/lib/eventHandler/keyboard.js @@ -8,6 +8,7 @@ class Keyboard { constructor (muya) { this.muya = muya this.isComposed = false + this.isShiftDown = false this.shownFloat = new Set() this.recordIsComposed() this.dispatchEditorState() @@ -187,6 +188,10 @@ class Keyboard { case EVENT_KEYS.Tab: contentState.tabHandler(event) break + case EVENT_KEYS.Shift: + eventCenter.dispatch('muya-format-picker', { reference: null }) + this.isShiftDown = true + break default: break } @@ -252,6 +257,10 @@ class Keyboard { }) } + if (event.key === EVENT_KEYS.Shift) { + this.isShiftDown = false + } + const { anchor, focus, start, end } = selection.getCursorRange() if (!anchor || !focus) { return @@ -276,6 +285,7 @@ class Keyboard { const block = contentState.getBlock(anchor.key) if ( + this.isShiftDown === false && anchor.key === focus.key && anchor.offset !== focus.offset && block.functionType !== 'codeContent' &&