···
type ComAtprotoRepoStrongRef,
17
-
import {TID} from '@atproto/common-web'
17
+
import { TID } from '@atproto/common-web'
import * as dcbor from '@ipld/dag-cbor'
19
-
import {t} from '@lingui/macro'
20
-
import {type QueryClient} from '@tanstack/react-query'
21
-
import {sha256} from 'js-sha256'
22
-
import {CID} from 'multiformats/cid'
19
+
import { t } from '@lingui/macro'
20
+
import { type QueryClient } from '@tanstack/react-query'
21
+
import { sha256 } from 'js-sha256'
22
+
import { CID } from 'multiformats/cid'
import * as Hasher from 'multiformats/hashes/hasher'
25
-
import {isNetworkError} from '#/lib/strings/errors'
26
-
import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip'
27
-
import {logger} from '#/logger'
28
-
import {compressImage} from '#/state/gallery'
25
+
import { isNetworkError } from '#/lib/strings/errors'
26
+
import { shortenLinks, stripInvalidMentions, parseMarkdownLinks } from '#/lib/strings/rich-text-manip'
27
+
import { logger } from '#/logger'
28
+
import { compressImage } from '#/state/gallery'
···
} from '#/view/com/composer/state/composer'
42
-
import {createGIFDescription} from '../gif-alt-text'
43
-
import {uploadBlob} from './upload-blob'
42
+
import { createGIFDescription } from '../gif-alt-text'
43
+
import { uploadBlob } from './upload-blob'
45
+
export { uploadBlob }
···
if (draft.labels.length) {
$type: 'com.atproto.label.defs#selfLabels',
99
-
values: draft.labels.map(val => ({val})),
99
+
values: draft.labels.map(val => ({ val })),
···
async function resolveRT(agent: BskyAgent, richtext: RichText) {
···
.replace(/^(\s*\n)+/, '')
// Trim any trailing whitespace.
202
-
let rt = new RichText({text: trimmedText}, {cleanNewlines: true})
203
+
const { text: parsedText, facets: markdownFacets } =
204
+
parseMarkdownLinks(trimmedText)
206
+
let rt = new RichText({ text: parsedText }, { cleanNewlines: true })
await rt.detectFacets(agent)
209
+
if (markdownFacets.length > 0) {
210
+
const nonOverlapping = (rt.facets || []).filter(f => {
211
+
return !markdownFacets.some(mf => {
213
+
(f.index.byteStart >= mf.index.byteStart &&
214
+
f.index.byteStart < mf.index.byteEnd) ||
215
+
(f.index.byteEnd > mf.index.byteStart &&
216
+
f.index.byteEnd <= mf.index.byteEnd) ||
217
+
(mf.index.byteStart >= f.index.byteStart &&
218
+
mf.index.byteStart < f.index.byteEnd)
222
+
rt.facets = [...nonOverlapping, ...markdownFacets].sort(
223
+
(a, b) => a.index.byteStart - b.index.byteStart,
rt = stripInvalidMentions(rt)
···
const images: AppBskyEmbedImages.Image[] = await Promise.all(
imagesDraft.map(async (image, i) => {
logger.debug(`Compressing image #${i}`)
306
-
const {path, width, height, mime} = await compressImage(image)
328
+
const { path, width, height, mime } = await compressImage(image)
logger.debug(`Uploading image #${i}`)
const res = await uploadBlob(agent, path, mime)
312
-
aspectRatio: {width, height},
334
+
aspectRatio: { width, height },
···
.filter(caption => caption.lang !== '')
330
-
const {data} = await agent.uploadBlob(caption.file, {
352
+
const { data } = await agent.uploadBlob(caption.file, {
333
-
return {lang: caption.lang, file: data.blob}
355
+
return { lang: caption.lang, file: data.blob }
···
// aspect ratio values must be >0 - better to leave as unset otherwise
// posting will fail if aspect ratio is set to 0
343
-
const aspectRatio = width > 0 && height > 0 ? {width, height} : undefined
365
+
const aspectRatio = width > 0 && height > 0 ? { width, height } : undefined
···
let blob: BlobRef | undefined
onStateChange?.(t`Uploading link thumbnail...`)
369
-
const {path, mime} = resolvedGif.thumb.source
391
+
const { path, mime } = resolvedGif.thumb.source
const response = await uploadBlob(agent, path, mime)
blob = response.data.blob
···
let blob: BlobRef | undefined
if (resolvedLink.thumb) {
onStateChange?.(t`Uploading link thumbnail...`)
393
-
const {path, mime} = resolvedLink.thumb.source
415
+
const { path, mime } = resolvedLink.thumb.source
const response = await uploadBlob(agent, path, mime)
blob = response.data.blob