From 4f1716d0692fd0e2fe08f594a5699968a6a24b6b Mon Sep 17 00:00:00 2001 From: alexanderroese Date: Wed, 14 Aug 2024 00:34:40 +0200 Subject: [PATCH] add info message for space between emoji and text --- snippets/shx-3d-render-input.liquid | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/snippets/shx-3d-render-input.liquid b/snippets/shx-3d-render-input.liquid index d6cfbfe..9a064bd 100644 --- a/snippets/shx-3d-render-input.liquid +++ b/snippets/shx-3d-render-input.liquid @@ -554,19 +554,11 @@ // this function is to show the user a help message if there could be spacing added between emojis and text function isEmojiSpacingOk(text) { - // regex to find emojis followed by a letter or another emoji without a space in between - let regex = /([\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}])([^\\s]|$)|([^\\s])([\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}])/gu; - + // regex to find emojis not followed or preceded by a space + let regex = /([\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}])(?=[^\s])|(?<=[^\s])([\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}])/gu; + // check if the regex finds a matching pattern - let match; - while ((match = regex.exec(text)) !== null) { - // either match[2] or match[4] is the problematic character - if ((match[2] !== ' ' && match[2] !== '') || (match[3] && match[3] !== ' ')) { - return false; - } - } - - return true; + return !regex.test(text); } function SHX_IFC_genTextInput(inputID, labelText, inputName, inputVal, section_id, maxLength = 24, emojisSupported = false) {