mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 04:20:36 +08:00
fix: no need to auto pair when * is to open a list item
This commit is contained in:
parent
193b62023e
commit
2597c316ed
@ -340,7 +340,7 @@ const updateCtrl = ContentState => {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// auto pair
|
||||
if (block && block.text !== text) {
|
||||
const BRACKET_HASH = {
|
||||
'{': '}',
|
||||
@ -351,21 +351,26 @@ const updateCtrl = ContentState => {
|
||||
'"': '"',
|
||||
"'": "'"
|
||||
}
|
||||
if (start.key === end.key && start.offset === end.offset && event.type === 'input' && BRACKET_HASH[event.data]) {
|
||||
if (start.key === end.key && start.offset === end.offset && event.type === 'input') {
|
||||
const { offset } = start
|
||||
const {
|
||||
autoPairBracket, autoPairMarkdownSyntax, autoPairQuote
|
||||
} = this
|
||||
const { autoPairBracket, autoPairMarkdownSyntax, autoPairQuote } = this
|
||||
const inputChar = text.charAt(+offset - 1)
|
||||
const preInputChar = text.charAt(+offset - 2)
|
||||
const postInputChar = text.charAt(+offset)
|
||||
/* eslint-disable no-useless-escape */
|
||||
if (
|
||||
(autoPairQuote && /["']{1}/.test(inputChar)) ||
|
||||
(autoPairBracket && /[\{\[\(]{1}/.test(inputChar)) ||
|
||||
(autoPairMarkdownSyntax && /[*_]{1}/.test(inputChar))
|
||||
) {
|
||||
text = text.substring(0, offset) + BRACKET_HASH[inputChar] + text.substring(offset)
|
||||
text = BRACKET_HASH[event.data]
|
||||
? text.substring(0, offset) + BRACKET_HASH[inputChar] + text.substring(offset)
|
||||
: text
|
||||
}
|
||||
/* eslint-ensable no-useless-escape */
|
||||
if (/\s/.test(event.data) && preInputChar === '*' && postInputChar === '*') {
|
||||
text = text.substring(0, offset) + text.substring(offset + 1)
|
||||
}
|
||||
}
|
||||
block.text = text
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
import fileIcons from '../fileIcons'
|
||||
import {
|
||||
CLASS_OR_ID
|
||||
} from '../config'
|
||||
import { CLASS_OR_ID } from '../config'
|
||||
|
||||
import './index.css'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user