mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:01:19 +08:00
Modify the pop-up conditions of muya-format-picker
This commit is contained in:
parent
b75895cdd1
commit
c8803a7cb0
@ -55,7 +55,8 @@ export const EVENT_KEYS = Object.freeze(generateKeyHash([
|
|||||||
'ArrowLeft',
|
'ArrowLeft',
|
||||||
'ArrowRight',
|
'ArrowRight',
|
||||||
'Tab',
|
'Tab',
|
||||||
'Escape'
|
'Escape',
|
||||||
|
'Shift'
|
||||||
]))
|
]))
|
||||||
|
|
||||||
export const LOWERCASE_TAGS = Object.freeze(generateKeyHash([
|
export const LOWERCASE_TAGS = Object.freeze(generateKeyHash([
|
||||||
|
@ -8,6 +8,7 @@ class Keyboard {
|
|||||||
constructor (muya) {
|
constructor (muya) {
|
||||||
this.muya = muya
|
this.muya = muya
|
||||||
this.isComposed = false
|
this.isComposed = false
|
||||||
|
this.isShiftDown = false
|
||||||
this.shownFloat = new Set()
|
this.shownFloat = new Set()
|
||||||
this.recordIsComposed()
|
this.recordIsComposed()
|
||||||
this.dispatchEditorState()
|
this.dispatchEditorState()
|
||||||
@ -187,6 +188,10 @@ class Keyboard {
|
|||||||
case EVENT_KEYS.Tab:
|
case EVENT_KEYS.Tab:
|
||||||
contentState.tabHandler(event)
|
contentState.tabHandler(event)
|
||||||
break
|
break
|
||||||
|
case EVENT_KEYS.Shift:
|
||||||
|
eventCenter.dispatch('muya-format-picker', { reference: null })
|
||||||
|
this.isShiftDown = true
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -252,6 +257,10 @@ class Keyboard {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.key === EVENT_KEYS.Shift) {
|
||||||
|
this.isShiftDown = false
|
||||||
|
}
|
||||||
|
|
||||||
const { anchor, focus, start, end } = selection.getCursorRange()
|
const { anchor, focus, start, end } = selection.getCursorRange()
|
||||||
if (!anchor || !focus) {
|
if (!anchor || !focus) {
|
||||||
return
|
return
|
||||||
@ -276,6 +285,7 @@ class Keyboard {
|
|||||||
|
|
||||||
const block = contentState.getBlock(anchor.key)
|
const block = contentState.getBlock(anchor.key)
|
||||||
if (
|
if (
|
||||||
|
this.isShiftDown === false &&
|
||||||
anchor.key === focus.key &&
|
anchor.key === focus.key &&
|
||||||
anchor.offset !== focus.offset &&
|
anchor.offset !== focus.offset &&
|
||||||
block.functionType !== 'codeContent' &&
|
block.functionType !== 'codeContent' &&
|
||||||
|
Loading…
Reference in New Issue
Block a user