mirror of
https://github.com/marktext/marktext.git
synced 2025-05-19 02:10:34 +08:00
fix: #522 paste bug when paste into empty line
This commit is contained in:
parent
3c52ecf87a
commit
f0c691ea98
@ -133,7 +133,7 @@ const enterCtrl = ContentState => {
|
||||
}
|
||||
}
|
||||
|
||||
const { key } = newBlock
|
||||
const { key } = newBlock.children[0]
|
||||
const offset = 0
|
||||
this.cursor = {
|
||||
start: { key, offset },
|
||||
|
@ -70,7 +70,6 @@ const pasteCtrl = ContentState => {
|
||||
event.preventDefault()
|
||||
const text = event.clipboardData.getData('text/plain')
|
||||
let html = event.clipboardData.getData('text/html')
|
||||
|
||||
html = this.standardizeHTML(html)
|
||||
const copyType = this.checkCopyType(html, text)
|
||||
const { start, end } = this.cursor
|
||||
@ -97,7 +96,6 @@ const pasteCtrl = ContentState => {
|
||||
const blockText = startBlock.text
|
||||
const prePartText = blockText.substring(0, start.offset)
|
||||
const postPartText = blockText.substring(end.offset)
|
||||
console.log(prePartText, '|', postPartText)
|
||||
const textList = text.split(LINE_BREAKS_REG)
|
||||
if (textList.length > 1) {
|
||||
textList.forEach((line, i) => {
|
||||
@ -190,7 +188,9 @@ const pasteCtrl = ContentState => {
|
||||
return getLastBlock(lastBlock.children)
|
||||
}
|
||||
}
|
||||
|
||||
const lastBlock = getLastBlock(stateFragments)
|
||||
|
||||
let key = lastBlock.key
|
||||
let offset = lastBlock.text.length
|
||||
lastBlock.text += cacheText
|
||||
|
Loading…
Reference in New Issue
Block a user