Skip to content

Support pasted files in CloudUploader - #211

Draft
brandonkelly wants to merge 1 commit into
3.xfrom
asset-field-paste-uploads
Draft

brandonkelly wants to merge 1 commit into
3.xfrom
asset-field-paste-uploads

Conversation

@brandonkelly

Copy link
Copy Markdown
Member

Summary

craftcms/cms#20212 lets people paste files into Assets fields. Craft.BaseUploader handles the paste and passes the files to a new addFiles() method, which each uploader class implements. This adds it to CloudUploader:

 Craft.CloudUploader
+  addFiles(files) -> uploadFiles(files)
   destroy()
+    this.base()   // removes BaseUploader's paste listener

On Craft versions before 5.12, addFiles() is never called and the base destroy() is a no-op, so the change is safe there too.

Evidence

Tested in Chromium on a Craft install running craftcms/cms#20212. CloudUploader was created with a pasteZone, uploadFile() was stubbed to record what it received, and a real PNG was pasted with Ctrl+V:

uploadFile() received: ["pasted-image-20261030-115350.png:image/png"]
document paste listeners after destroy(): 3 -> 2

Draft until craftcms/cms#20212 is merged.

Related issues

Implement Craft.BaseUploader::addFiles(), which Craft 5.12 calls with
files pasted into an Assets field, and call the base destroy() so its
paste listener gets removed.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-337a4ca6-6db4-4b70-9d96-a975fa2a035b

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the clipboard-file support change.

No open issues 🎉

What changed in this PR

Adds clipboard-file support to Craft.CloudUploader, integrating with the BaseUploader paste handling introduced in craftcms/cms#20212.

Changes:

  • Adds addFiles() to route pasted files through the existing upload pipeline.
  • Calls the base destroy() method to remove its paste listener.
  • Updates the compiled uploader and source map.
File Description
src/​web/​assets/​uploader/​src/​Uploader.js Adds pasted-file handling and base cleanup.
src/​web/​assets/​uploader/​dist/​Uploader.js.map Updates source mappings for the uploader changes.
src/​web/​assets/​uploader/​dist/​Uploader.js Includes the changes in the compiled browser asset.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants