Skip to content

Commit

Permalink
Merge pull request #204 from bhsd-harry/newsection
Browse files Browse the repository at this point in the history
fix(quickEdit): parse new section anchor

那先合了
  • Loading branch information
dragon-fish authored Oct 18, 2023
2 parents 2e9ab09 + 01104ca commit 1c21a00
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/module/quickEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,19 @@ export function quickEdit(options) {
})
return
}
function confirm(result) {
async function confirm(result) {
if (result) {
let summaryVal = $optionsLabel.find('.editSummary').val()
const sectiontitle =
options.section === 'new'
? $newSectionTitleInput.val()
: undefined
let summaryVal = $optionsLabel.find('.editSummary').val(),
sectiontitle
if (options.section === 'new') {
sectiontitle = $newSectionTitleInput.val()
const anchor = (await mwApi.post({
action: 'parse', text: `==${sectiontitle}==`,
contentmodel: 'wikitext', prop: 'sections', formatversion: 2,
})).parse.sections[0].anchor
summaryVal = summaryVal.replace(
/\$section/gi,
`/* ${sectiontitle} */`
`/* ${anchor} */`
)
}
const text = $editArea.val(),
Expand Down

0 comments on commit 1c21a00

Please sign in to comment.