fix: Improve emoji trigger for french language

closes #5611
This commit is contained in:
Tom Moor
2023-07-29 20:58:33 -04:00
parent ddc883bfcd
commit b88670b58d

View File

@@ -13,15 +13,28 @@ import { MarkdownSerializerState } from "../lib/markdown/serializer";
import { SuggestionsMenuType } from "../plugins/Suggestions";
import emojiRule from "../rules/emoji";
/**
* Languages using the colon character with a space infront in standard
* punctuation. In this case the trigger is only matched once there is additional
* text after the colon.
*/
const languagesUsingColon = ["fr"];
export default class Emoji extends Suggestion {
get type() {
return "node";
}
get defaultOptions() {
const languageIsUsingColon = languagesUsingColon.includes(
navigator?.language.slice(0, 2)
);
return {
type: SuggestionsMenuType.Emoji,
openRegex: /(?:^|\s):([0-9a-zA-Z_+-]+)?$/,
openRegex: new RegExp(
`(?:^|\\s):([0-9a-zA-Z_+-]+)${languageIsUsingColon ? "+" : "?"}$`
),
closeRegex:
/(?:^|\s):(([0-9a-zA-Z_+-]*\s+)|(\s+[0-9a-zA-Z_+-]+)|[^0-9a-zA-Z_+-]+)$/,
enabledInTable: true,