This PR adds support for inserting images into the rich text editor via both **copy & paste** and **drag & drop**, whether from local files or image DOM nodes. It leverages the bulk uploads UI to provide a smooth workflow for: - Selecting the target collection - Filling in any required fields defined on the uploads collection - Uploading multiple images at once This significantly improves the UX for adding images to rich text, and also works seamlessly when pasting images from external editors like Google Docs or Microsoft Word. Test pre-release: `3.57.0-internal.801ab5a` ## Showcase - drag & drop images from computer https://github.com/user-attachments/assets/c558c034-d2e4-40d8-9035-c0681389fb7b ## Showcase - copy & paste images from computer https://github.com/user-attachments/assets/f36faf94-5274-4151-b141-00aff2b0efa4 ## Showcase - copy & paste image DOM nodes https://github.com/user-attachments/assets/2839ed0f-3f28-4e8d-8b47-01d0cb947edc --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211217132290841
48 lines
894 B
TypeScript
48 lines
894 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import { uploads2Slug, uploadsSlug } from '../../slugs.js'
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export const Uploads: CollectionConfig = {
|
|
slug: uploadsSlug,
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'media',
|
|
type: 'upload',
|
|
filterOptions: {
|
|
mimeType: {
|
|
equals: 'image/png',
|
|
},
|
|
},
|
|
relationTo: uploadsSlug,
|
|
},
|
|
// {
|
|
// name: 'richText',
|
|
// type: 'richText',
|
|
// },
|
|
],
|
|
upload: {
|
|
staticDir: path.resolve(dirname, './uploads'),
|
|
},
|
|
}
|
|
|
|
export const Uploads2: CollectionConfig = {
|
|
...Uploads,
|
|
slug: uploads2Slug,
|
|
fields: [
|
|
...Uploads.fields,
|
|
{
|
|
name: 'altText',
|
|
type: 'text',
|
|
},
|
|
],
|
|
}
|