From 41c4b4af7b55a4df413f4f3cb6de595fcba9debc Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 10 Oct 2023 15:19:39 -0500 Subject: [PATCH] enforce 64 characters --- .../composer/text-input/web/Tags/plugin.tsx | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/view/com/composer/text-input/web/Tags/plugin.tsx b/src/view/com/composer/text-input/web/Tags/plugin.tsx index ba2bebea5b..52ed5a95b8 100644 --- a/src/view/com/composer/text-input/web/Tags/plugin.tsx +++ b/src/view/com/composer/text-input/web/Tags/plugin.tsx @@ -85,34 +85,26 @@ export const Tags = Node.create({ const startIndex = cursorPosition - text.length let [matchedString, tag] = match - const tagWithoutPunctuation = tag.replace(puncRegex, '') - // allow for multiple ending punctuation marks - const punctuationIndexOffset = - tag.length - tagWithoutPunctuation.length + const sanitized = tag.replace(puncRegex, '').replace(/^#/, '') - if (tagWithoutPunctuation.length > 66) return null + // one of our hashtag spec rules + if (sanitized.length > 64) return null const from = startIndex + match.index + matchedString.indexOf(tag) - // `to` should not include ending punctuation const to = from + tag.length - console.log({ - from, - to, - }) - if ( - from < cursorPosition && - to >= cursorPosition - punctuationIndexOffset - ) { + if (from < cursorPosition && to >= cursorPosition) { return { range: { from, to, }, /** - * This is passed to the `items({ query })` method configured in `createTagsAutocomplete`. + * This is passed to the `items({ query })` method configured in + * `createTagsAutocomplete`. * - * TODO This value should follow the rules of our hashtags spec. + * We parse out the punctuation later, but we don't want to pass + * the # to the search query. */ query: tag.replace(/^#/, ''), // raw text string