mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:01:19 +08:00
Bugfix: #67
This commit is contained in:
parent
f08d01a6c5
commit
9719fa37be
@ -74,10 +74,34 @@ const backspaceCtrl = ContentState => {
|
||||
|
||||
ContentState.prototype.backspaceHandler = function (event) {
|
||||
const { start, end } = selection.getCursorRange()
|
||||
if (start.key !== end.key) {
|
||||
event.preventDefault()
|
||||
const startBlock = this.getBlock(start.key)
|
||||
const endBlock = this.getBlock(end.key)
|
||||
// bugfix: #67 problem 1
|
||||
if (startBlock.icon) return event.preventDefault()
|
||||
// fixbug: unexpect remove all editor html.
|
||||
if (start.key === end.key && startBlock.type === 'figure' && !startBlock.preSibling) {
|
||||
event.preventDefault()
|
||||
let newBlock
|
||||
if (this.blocks.length === 1) {
|
||||
startBlock.type = 'p'
|
||||
startBlock.text = ''
|
||||
startBlock.children = []
|
||||
newBlock = startBlock
|
||||
} else {
|
||||
this.removeBlock(startBlock)
|
||||
newBlock = this.getNextSibling(startBlock)
|
||||
}
|
||||
const key = newBlock.key
|
||||
const offset = 0
|
||||
this.cursor = {
|
||||
start: { key, offset },
|
||||
end: { key, offset }
|
||||
}
|
||||
return this.render()
|
||||
}
|
||||
|
||||
if (start.key !== end.key) {
|
||||
event.preventDefault()
|
||||
const key = start.key
|
||||
const offset = start.offset
|
||||
|
||||
|
@ -240,6 +240,11 @@ const updateCtrl = ContentState => {
|
||||
ContentState.prototype.updateState = function (event) {
|
||||
const { floatBox } = this
|
||||
const { start, end } = selection.getCursorRange()
|
||||
const key = start.key
|
||||
const block = this.getBlock(key)
|
||||
// bugfix: #67 problem 1
|
||||
if (block.icon) return event.preventDefault()
|
||||
|
||||
const { start: oldStart, end: oldEnd } = this.cursor
|
||||
|
||||
if (event.type === 'keyup' && (event.key === 'ArrowUp' || event.key === 'ArrowDown') && floatBox.show) {
|
||||
@ -291,12 +296,10 @@ const updateCtrl = ContentState => {
|
||||
}
|
||||
return
|
||||
}
|
||||
const key = start.key
|
||||
|
||||
const oldKey = lastCursor ? lastCursor.start.key : null
|
||||
const paragraph = document.querySelector(`#${key}`)
|
||||
let text = getTextContent(paragraph, [ CLASS_OR_ID['AG_MATH_RENDER'] ])
|
||||
const block = this.getBlock(key)
|
||||
|
||||
let needRender = false
|
||||
if (event.type === 'click' && block.type === 'figure' && block.functionType === 'table') {
|
||||
// first cell in thead
|
||||
|
Loading…
Reference in New Issue
Block a user