Browse Source

Merge pull request #5912 from weseek/feat/gw7814-prevent-emoji-picker-showing-when-colons-inside-word

feat: Update emoji regex pattern
Yuki Takei 3 years ago
parent
commit
14ca392956
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/app/src/components/PageEditor/EmojiPickerHelper.ts

+ 4 - 1
packages/app/src/components/PageEditor/EmojiPickerHelper.ts

@@ -2,6 +2,9 @@ import { CSSProperties } from 'react';
 
 
 import i18n from 'i18next';
 import i18n from 'i18next';
 
 
+// https://regex101.com/r/Gqhor8/1
+const EMOJI_PATTERN = new RegExp(/\B:[^:\s]+/);
+
 export default class EmojiPickerHelper {
 export default class EmojiPickerHelper {
 
 
 editor;
 editor;
@@ -10,7 +13,7 @@ pattern: RegExp;
 
 
 constructor(editor) {
 constructor(editor) {
   this.editor = editor;
   this.editor = editor;
-  this.pattern = /:[^:\s]+/;
+  this.pattern = EMOJI_PATTERN;
 }
 }
 
 
 setStyle = ():CSSProperties => {
 setStyle = ():CSSProperties => {