mirror of
https://github.com/marktext/marktext.git
synced 2025-05-08 07:19:48 +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(() => {
|
||||
this.updateTaskListItem(listItemParagraph, listType)
|
||||
this.partialRender()
|
||||
this.muya.dispatchSelectionChange()
|
||||
this.muya.dispatchSelectionFormats()
|
||||
this.muya.dispatchChange()
|
||||
})
|
||||
return false
|
||||
} else {
|
||||
this.updateList(paragraph, listType, undefined, block)
|
||||
}
|
||||
@ -189,6 +193,8 @@ const paragraphCtrl = ContentState => {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
ContentState.prototype.handleLooseListItem = function () {
|
||||
@ -447,6 +453,7 @@ const paragraphCtrl = ContentState => {
|
||||
const { start, end } = this.cursor
|
||||
const block = this.getBlock(start.key)
|
||||
const { text } = block
|
||||
let needDispatchChange = true
|
||||
|
||||
switch (paraType) {
|
||||
case 'front-matter': {
|
||||
@ -456,7 +463,7 @@ const paragraphCtrl = ContentState => {
|
||||
case 'ul-bullet':
|
||||
case 'ul-task':
|
||||
case 'ol-order': {
|
||||
this.handleListMenu(paraType, insertMode)
|
||||
needDispatchChange = this.handleListMenu(paraType, insertMode)
|
||||
break
|
||||
}
|
||||
case 'loose-list-item': {
|
||||
@ -601,9 +608,11 @@ const paragraphCtrl = ContentState => {
|
||||
this.partialRender()
|
||||
}
|
||||
|
||||
this.muya.dispatchSelectionChange()
|
||||
this.muya.dispatchSelectionFormats()
|
||||
this.muya.dispatchChange()
|
||||
if (needDispatchChange) {
|
||||
this.muya.dispatchSelectionChange()
|
||||
this.muya.dispatchSelectionFormats()
|
||||
this.muya.dispatchChange()
|
||||
}
|
||||
}
|
||||
|
||||
ContentState.prototype.insertParagraph = function (location, text = '', outMost = false) {
|
||||
|
@ -139,9 +139,9 @@ class Muya {
|
||||
return this.contentState.history.clearHistory()
|
||||
}
|
||||
|
||||
exportStyledHTML (title = '', printOptimization = false) {
|
||||
exportStyledHTML (title = '', printOptimization = false, extraCss = '') {
|
||||
const { markdown } = this
|
||||
return new ExportHtml(markdown, this).generate(title, printOptimization)
|
||||
return new ExportHtml(markdown, this).generate(title, printOptimization, extraCss)
|
||||
}
|
||||
|
||||
exportHtml () {
|
||||
|
@ -258,7 +258,7 @@ class ExportMarkdown {
|
||||
const tHeader = table.children[0]
|
||||
const tBody = table.children[1]
|
||||
const escapeText = str => {
|
||||
return str.replace(/(?<!\\)\|/g, '\\|')
|
||||
return str.replace(/([^\\])\|/g, '$1\\|')
|
||||
}
|
||||
|
||||
tableData.push(tHeader.children[0].children.map(th => escapeText(th.text).trim()))
|
||||
|
Loading…
Reference in New Issue
Block a user