From 358fa83d6de96be82355b3a2711df2c44d34dcbf Mon Sep 17 00:00:00 2001 From: Lori <59900828+Lorilandly@users.noreply.github.com> Date: Sun, 27 Feb 2022 23:15:42 +0900 Subject: [PATCH] Update auto pair quote logic (#2960) * Update autoPairQuote logic * Fix spelling * Update Regex thing I thought matching anything except for space might be a better choice than selectively match some characters --- CONTRIBUTING.md | 2 +- src/muya/lib/contentState/inputCtrl.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56ef7e89..70d99c66 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ We are really excited that you are interested in contributing to MarkText :tada: ## Philosophy 🔑 Our philosophy is to keep things clean, simple and minimal. -MarkText is constantly changing and we want these improvements to align with our philosphy. For example, look at the side bar and tabs; these two panels provide awesome functionality *and* aren't distracting to the user. We'll continue adding more features (like plugins) that can be activated via 'settings' to improve MarkText. This will allow everyone to customize MarkText for their needs and provide a minimal default interface. +MarkText is constantly changing and we want these improvements to align with our philosophy. For example, look at the side bar and tabs; these two panels provide awesome functionality *and* aren't distracting to the user. We'll continue adding more features (like plugins) that can be activated via 'settings' to improve MarkText. This will allow everyone to customize MarkText for their needs and provide a minimal default interface. ## Issue Reporting Guidelines diff --git a/src/muya/lib/contentState/inputCtrl.js b/src/muya/lib/contentState/inputCtrl.js index 2b38320b..55c6d38e 100644 --- a/src/muya/lib/contentState/inputCtrl.js +++ b/src/muya/lib/contentState/inputCtrl.js @@ -225,9 +225,9 @@ const inputCtrl = ContentState => { // Issue 2566: Do not complete markdown syntax if the previous character is // alphanumeric. !/\\/.test(preInputChar) && - ((autoPairQuote && /[']{1}/.test(inputChar) && !(/[a-zA-Z\d]{1}/.test(preInputChar))) || - (autoPairQuote && /["]{1}/.test(inputChar)) || - (autoPairBracket && /[\{\[\(]{1}/.test(inputChar)) || + ((autoPairQuote && /[']{1}/.test(inputChar) && !(/[\S]{1}/.test(postInputChar)) && !(/[a-zA-Z\d]{1}/.test(preInputChar))) || + (autoPairQuote && /["]{1}/.test(inputChar) && !(/[\S]{1}/.test(postInputChar))) || + (autoPairBracket && /[\{\[\(]{1}/.test(inputChar) && !(/[\S]{1}/.test(postInputChar))) || (block.functionType !== 'codeContent' && !isInInlineMath && !isInInlineCode && autoPairMarkdownSyntax && !/[a-z0-9]{1}/i.test(preInputChar) && /[*$`~_]{1}/.test(inputChar))) ) { needRender = true