Remove unnecessary .trimEnd() and fix facet detection (#3672)

* Fix link facet detection

Exclude the trailing period from the link, similar as done in the atproto package

* Fix JSON to text conversion

The trimEnd() call was only needed because we were always appending \n\n at the end. Fix that by only adding line breaks after non-final paragraphs.

* Detect paste reliably

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
Hailey
2024-04-24 07:10:29 -07:00
committed by GitHub
parent 05beb1bbad
commit b3df0b177f
2 changed files with 25 additions and 14 deletions
@@ -14,11 +14,11 @@
* the facet-set.
*/
import {Mark} from '@tiptap/core'
import {Plugin, PluginKey} from '@tiptap/pm/state'
import {Node as ProsemirrorNode} from '@tiptap/pm/model'
import {Decoration, DecorationSet} from '@tiptap/pm/view'
import {URL_REGEX} from '@atproto/api'
import {Mark} from '@tiptap/core'
import {Node as ProsemirrorNode} from '@tiptap/pm/model'
import {Plugin, PluginKey} from '@tiptap/pm/state'
import {Decoration, DecorationSet} from '@tiptap/pm/view'
import {isValidDomain} from 'lib/strings/url-helpers'
@@ -91,7 +91,7 @@ function iterateUris(str: string, cb: (from: number, to: number) => void) {
uri = `https://${uri}`
}
let from = str.indexOf(match[2], match.index)
let to = from + match[2].length + 1
let to = from + match[2].length
// strip ending puncuation
if (/[.,;!?]$/.test(uri)) {
uri = uri.slice(0, -1)