mirror of
https://github.com/marktext/marktext.git
synced 2025-05-12 06:50:32 +08:00
fix: update paragraph menu item task list
error (#1330)
* fix: update paragraph menu item `task list` error * Update exportStyleHTML api * Update escapeText, because Safari do not support ?>! in reg
This commit is contained in:
parent
c52431cb92
commit
a4f5269beb
@ -157,7 +157,11 @@ const paragraphCtrl = ContentState => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.updateTaskListItem(listItemParagraph, listType)
|
this.updateTaskListItem(listItemParagraph, listType)
|
||||||
this.partialRender()
|
this.partialRender()
|
||||||
|
this.muya.dispatchSelectionChange()
|
||||||
|
this.muya.dispatchSelectionFormats()
|
||||||
|
this.muya.dispatchChange()
|
||||||
})
|
})
|
||||||
|
return false
|
||||||
} else {
|
} else {
|
||||||
this.updateList(paragraph, listType, undefined, block)
|
this.updateList(paragraph, listType, undefined, block)
|
||||||
}
|
}
|
||||||
@ -189,6 +193,8 @@ const paragraphCtrl = ContentState => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentState.prototype.handleLooseListItem = function () {
|
ContentState.prototype.handleLooseListItem = function () {
|
||||||
@ -447,6 +453,7 @@ const paragraphCtrl = ContentState => {
|
|||||||
const { start, end } = this.cursor
|
const { start, end } = this.cursor
|
||||||
const block = this.getBlock(start.key)
|
const block = this.getBlock(start.key)
|
||||||
const { text } = block
|
const { text } = block
|
||||||
|
let needDispatchChange = true
|
||||||
|
|
||||||
switch (paraType) {
|
switch (paraType) {
|
||||||
case 'front-matter': {
|
case 'front-matter': {
|
||||||
@ -456,7 +463,7 @@ const paragraphCtrl = ContentState => {
|
|||||||
case 'ul-bullet':
|
case 'ul-bullet':
|
||||||
case 'ul-task':
|
case 'ul-task':
|
||||||
case 'ol-order': {
|
case 'ol-order': {
|
||||||
this.handleListMenu(paraType, insertMode)
|
needDispatchChange = this.handleListMenu(paraType, insertMode)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'loose-list-item': {
|
case 'loose-list-item': {
|
||||||
@ -601,10 +608,12 @@ const paragraphCtrl = ContentState => {
|
|||||||
this.partialRender()
|
this.partialRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needDispatchChange) {
|
||||||
this.muya.dispatchSelectionChange()
|
this.muya.dispatchSelectionChange()
|
||||||
this.muya.dispatchSelectionFormats()
|
this.muya.dispatchSelectionFormats()
|
||||||
this.muya.dispatchChange()
|
this.muya.dispatchChange()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ContentState.prototype.insertParagraph = function (location, text = '', outMost = false) {
|
ContentState.prototype.insertParagraph = function (location, text = '', outMost = false) {
|
||||||
const { start, end } = this.cursor
|
const { start, end } = this.cursor
|
||||||
|
@ -139,9 +139,9 @@ class Muya {
|
|||||||
return this.contentState.history.clearHistory()
|
return this.contentState.history.clearHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
exportStyledHTML (title = '', printOptimization = false) {
|
exportStyledHTML (title = '', printOptimization = false, extraCss = '') {
|
||||||
const { markdown } = this
|
const { markdown } = this
|
||||||
return new ExportHtml(markdown, this).generate(title, printOptimization)
|
return new ExportHtml(markdown, this).generate(title, printOptimization, extraCss)
|
||||||
}
|
}
|
||||||
|
|
||||||
exportHtml () {
|
exportHtml () {
|
||||||
|
@ -258,7 +258,7 @@ class ExportMarkdown {
|
|||||||
const tHeader = table.children[0]
|
const tHeader = table.children[0]
|
||||||
const tBody = table.children[1]
|
const tBody = table.children[1]
|
||||||
const escapeText = str => {
|
const escapeText = str => {
|
||||||
return str.replace(/(?<!\\)\|/g, '\\|')
|
return str.replace(/([^\\])\|/g, '$1\\|')
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.push(tHeader.children[0].children.map(th => escapeText(th.text).trim()))
|
tableData.push(tHeader.children[0].children.map(th => escapeText(th.text).trim()))
|
||||||
|
Loading…
Reference in New Issue
Block a user