mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
Upload images before publishing GitHub drafts (#38928)
* Upload GitHub images when pasted or dropped Keep image bytes out of issue and review bodies by uploading from the owning composer and inserting hosted attachment URLs. Co-authored-by: lydiassssz <60514233+lydiassssz@users.noreply.github.com> * Preserve GitHub image intake across editor and thread states * Keep image placeholder boundaries and ordinary HTML paste intact * Match the native replace overload in the image projection fixture * Use typed element queries in the image intake fixture * Narrow textarea elements at the fixture boundary * Show failed GitHub draft images as filename links * Keep GitHub draft attachment links current across updates * Supply the repository address in the attachment preview fixture --------- Co-authored-by: lydiassssz <60514233+lydiassssz@users.noreply.github.com>
This commit is contained in:
co-authored by
lydiassssz
parent
a943631bd2
commit
548ba48c32
@@ -0,0 +1,24 @@
|
||||
export const GITHUB_IMAGE_ATTACHMENT_CAPABILITY = 'github.image-attachments.v1' as const
|
||||
export const GITHUB_IMAGE_MAX_BYTES = 10 * 1024 * 1024
|
||||
export const GITHUB_IMAGE_TYPES = [
|
||||
'image/png',
|
||||
'image/jpeg',
|
||||
'image/gif',
|
||||
'image/webp',
|
||||
'image/svg+xml'
|
||||
] as const
|
||||
|
||||
export class GitHubImageValidationError extends Error {}
|
||||
|
||||
export function assertGitHubImage(contentType: string, size: number): void {
|
||||
if (!GITHUB_IMAGE_TYPES.some((type) => type === contentType)) {
|
||||
throw new GitHubImageValidationError(
|
||||
'GitHub images must be PNG, JPEG, GIF, WebP, or SVG. Use an image URL for another format.'
|
||||
)
|
||||
}
|
||||
if (!Number.isSafeInteger(size) || size <= 0 || size > GITHUB_IMAGE_MAX_BYTES) {
|
||||
throw new GitHubImageValidationError(
|
||||
'GitHub images must be nonempty and no larger than 10 MB. Choose a smaller image.'
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user