mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 22:41:53 +08:00
* Improvement: #414 Add functional bracket auto-completion * bugFix: #414 wrong action with delete auto-complation function * bugfix: Fixed bullet order list chinese input error
This commit is contained in:
parent
41736a88e5
commit
486eb933b0
@ -408,20 +408,34 @@ const updateCtrl = ContentState => {
|
|||||||
const preInputChar = text.charAt(+offset - 2)
|
const preInputChar = text.charAt(+offset - 2)
|
||||||
const postInputChar = text.charAt(+offset)
|
const postInputChar = text.charAt(+offset)
|
||||||
/* eslint-disable no-useless-escape */
|
/* eslint-disable no-useless-escape */
|
||||||
// Not Unicode aware, since things like \p{Alphabetic} or \p{L} are not supported yet
|
|
||||||
if (
|
if (
|
||||||
(autoPairQuote && /[']{1}/.test(inputChar) && !(/[a-zA-Z\d]{1}/.test(preInputChar))) ||
|
(event.inputType.indexOf('delete') === -1) &&
|
||||||
(autoPairQuote && /["]{1}/.test(inputChar)) ||
|
(inputChar === postInputChar) &&
|
||||||
(autoPairBracket && /[\{\[\(]{1}/.test(inputChar)) ||
|
(
|
||||||
(autoPairMarkdownSyntax && /[*_]{1}/.test(inputChar))
|
(autoPairQuote && /[']{1}/.test(inputChar)) ||
|
||||||
|
(autoPairQuote && /["]{1}/.test(inputChar)) ||
|
||||||
|
(autoPairBracket && /[\}\]\)]{1}/.test(inputChar)) ||
|
||||||
|
(autoPairMarkdownSyntax && /[*_]{1}/.test(inputChar))
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
text = BRACKET_HASH[event.data]
|
|
||||||
? text.substring(0, offset) + BRACKET_HASH[inputChar] + text.substring(offset)
|
|
||||||
: text
|
|
||||||
}
|
|
||||||
/* eslint-enable no-useless-escape */
|
|
||||||
if (/\s/.test(event.data) && preInputChar === '*' && postInputChar === '*') {
|
|
||||||
text = text.substring(0, offset) + text.substring(offset + 1)
|
text = text.substring(0, offset) + text.substring(offset + 1)
|
||||||
|
} else {
|
||||||
|
/* eslint-disable no-useless-escape */
|
||||||
|
// Not Unicode aware, since things like \p{Alphabetic} or \p{L} are not supported yet
|
||||||
|
if (
|
||||||
|
(autoPairQuote && /[']{1}/.test(inputChar) && !(/[a-zA-Z\d]{1}/.test(preInputChar))) ||
|
||||||
|
(autoPairQuote && /["]{1}/.test(inputChar)) ||
|
||||||
|
(autoPairBracket && /[\{\[\(]{1}/.test(inputChar)) ||
|
||||||
|
(autoPairMarkdownSyntax && /[*_]{1}/.test(inputChar))
|
||||||
|
) {
|
||||||
|
text = BRACKET_HASH[event.data]
|
||||||
|
? text.substring(0, offset) + BRACKET_HASH[inputChar] + text.substring(offset)
|
||||||
|
: text
|
||||||
|
}
|
||||||
|
/* eslint-enable no-useless-escape */
|
||||||
|
if (/\s/.test(event.data) && preInputChar === '*' && postInputChar === '*') {
|
||||||
|
text = text.substring(0, offset) + text.substring(offset + 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
block.text = text
|
block.text = text
|
||||||
|
Loading…
Reference in New Issue
Block a user