mirror of
https://github.com/marktext/marktext.git
synced 2025-05-19 10:20:54 +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
|
const offset = 0
|
||||||
this.cursor = {
|
this.cursor = {
|
||||||
start: { key, offset },
|
start: { key, offset },
|
||||||
|
@ -70,7 +70,6 @@ const pasteCtrl = ContentState => {
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const text = event.clipboardData.getData('text/plain')
|
const text = event.clipboardData.getData('text/plain')
|
||||||
let html = event.clipboardData.getData('text/html')
|
let html = event.clipboardData.getData('text/html')
|
||||||
|
|
||||||
html = this.standardizeHTML(html)
|
html = this.standardizeHTML(html)
|
||||||
const copyType = this.checkCopyType(html, text)
|
const copyType = this.checkCopyType(html, text)
|
||||||
const { start, end } = this.cursor
|
const { start, end } = this.cursor
|
||||||
@ -97,7 +96,6 @@ const pasteCtrl = ContentState => {
|
|||||||
const blockText = startBlock.text
|
const blockText = startBlock.text
|
||||||
const prePartText = blockText.substring(0, start.offset)
|
const prePartText = blockText.substring(0, start.offset)
|
||||||
const postPartText = blockText.substring(end.offset)
|
const postPartText = blockText.substring(end.offset)
|
||||||
console.log(prePartText, '|', postPartText)
|
|
||||||
const textList = text.split(LINE_BREAKS_REG)
|
const textList = text.split(LINE_BREAKS_REG)
|
||||||
if (textList.length > 1) {
|
if (textList.length > 1) {
|
||||||
textList.forEach((line, i) => {
|
textList.forEach((line, i) => {
|
||||||
@ -190,7 +188,9 @@ const pasteCtrl = ContentState => {
|
|||||||
return getLastBlock(lastBlock.children)
|
return getLastBlock(lastBlock.children)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastBlock = getLastBlock(stateFragments)
|
const lastBlock = getLastBlock(stateFragments)
|
||||||
|
|
||||||
let key = lastBlock.key
|
let key = lastBlock.key
|
||||||
let offset = lastBlock.text.length
|
let offset = lastBlock.text.length
|
||||||
lastBlock.text += cacheText
|
lastBlock.text += cacheText
|
||||||
|
Loading…
Reference in New Issue
Block a user