enforce 64 characters
This commit is contained in:
@@ -85,34 +85,26 @@ export const Tags = Node.create<TagOptions>({
|
|||||||
const startIndex = cursorPosition - text.length
|
const startIndex = cursorPosition - text.length
|
||||||
let [matchedString, tag] = match
|
let [matchedString, tag] = match
|
||||||
|
|
||||||
const tagWithoutPunctuation = tag.replace(puncRegex, '')
|
const sanitized = tag.replace(puncRegex, '').replace(/^#/, '')
|
||||||
// allow for multiple ending punctuation marks
|
|
||||||
const punctuationIndexOffset =
|
|
||||||
tag.length - tagWithoutPunctuation.length
|
|
||||||
|
|
||||||
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)
|
const from = startIndex + match.index + matchedString.indexOf(tag)
|
||||||
// `to` should not include ending punctuation
|
|
||||||
const to = from + tag.length
|
const to = from + tag.length
|
||||||
|
|
||||||
console.log({
|
if (from < cursorPosition && to >= cursorPosition) {
|
||||||
from,
|
|
||||||
to,
|
|
||||||
})
|
|
||||||
if (
|
|
||||||
from < cursorPosition &&
|
|
||||||
to >= cursorPosition - punctuationIndexOffset
|
|
||||||
) {
|
|
||||||
return {
|
return {
|
||||||
range: {
|
range: {
|
||||||
from,
|
from,
|
||||||
to,
|
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(/^#/, ''),
|
query: tag.replace(/^#/, ''),
|
||||||
// raw text string
|
// raw text string
|
||||||
|
|||||||
Reference in New Issue
Block a user