mirror of
https://github.com/marktext/marktext.git
synced 2025-05-19 02:10:34 +08:00
parent
ffafb11aee
commit
b7468117e9
@ -245,22 +245,22 @@ const paragraphCtrl = ContentState => {
|
|||||||
}
|
}
|
||||||
// change fenced code block to p paragraph
|
// change fenced code block to p paragraph
|
||||||
if (affiliation.length && affiliation[0].type === 'pre' && /code/.test(affiliation[0].functionType)) {
|
if (affiliation.length && affiliation[0].type === 'pre' && /code/.test(affiliation[0].functionType)) {
|
||||||
const preBlock = affiliation[0]
|
const codeBlock = affiliation[0]
|
||||||
const codeContent = preBlock.children[1].children[0]
|
const codeContent = codeBlock.children[1].children[0].text
|
||||||
preBlock.type = 'p'
|
const states = this.markdownToState(codeContent)
|
||||||
preBlock.children = []
|
|
||||||
|
|
||||||
const newParagraphBlock = this.createBlockP(codeContent.text)
|
for (const state of states) {
|
||||||
this.insertBefore(newParagraphBlock, preBlock)
|
this.insertBefore(state, codeBlock)
|
||||||
|
}
|
||||||
|
|
||||||
this.removeBlock(preBlock)
|
this.removeBlock(codeBlock)
|
||||||
const { start, end } = this.cursor
|
|
||||||
|
|
||||||
const key = newParagraphBlock.children[0].key
|
|
||||||
|
|
||||||
|
const cursorBlock = this.firstInDescendant(states[0])
|
||||||
|
const { key, text } = cursorBlock
|
||||||
|
const offset = text.length
|
||||||
this.cursor = {
|
this.cursor = {
|
||||||
start: { key, offset: start.offset },
|
start: { key, offset },
|
||||||
end: { key, offset: end.offset }
|
end: { key, offset }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (start.key === end.key) {
|
if (start.key === end.key) {
|
||||||
@ -625,7 +625,7 @@ const paragraphCtrl = ContentState => {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (paraType === 'front-matter') {
|
if (paraType === 'front-matter' || paraType === 'pre') {
|
||||||
this.render()
|
this.render()
|
||||||
} else {
|
} else {
|
||||||
this.partialRender()
|
this.partialRender()
|
||||||
|
Loading…
Reference in New Issue
Block a user