Skip to content

Integrate frappe.ui.FileUploader for image uploads in editor#2

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-1
Draft

Integrate frappe.ui.FileUploader for image uploads in editor#2
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-1

Conversation

Copy link
Copy Markdown

Copilot AI commented Aug 5, 2025

This PR integrates the Frappe framework's file library (frappe.ui.FileUploader) with the frappe-editor, replacing the default direct upload mechanism while maintaining backward compatibility.

Changes Made

Core Integration:

  • Added custom upload function that detects and uses frappe.ui.FileUploader when available in Frappe environment
  • Implemented the exact integration pattern specified in the issue:
    new frappe.ui.FileUploader({
      doctype: me.doctype,
      docname: me.docname,
      frm: me,
      files: [file],
      folder: "Home/Attachments",
      on_success(file_doc) { /* handles success */ },
      on_error(error) { /* handles errors */ }
    });

New Props for Document Context:

  • doctype: Associates uploaded files with the current document type
  • docname: Associates uploaded files with the current document
  • frm: Provides form context to the file uploader
  • folder: Specifies destination folder (defaults to "Home/Attachments")

Automatic Context Passing:

  • Updated the Frappe form control to automatically pass document context from the current form
  • Files uploaded through the editor are now properly linked to the document being edited
  • Uses Frappe's file management system instead of bypassing it

Backward Compatibility:

  • Falls back to frappe-ui's default upload behavior when not in a Frappe environment
  • No breaking changes to existing functionality
  • Maintains compatibility for standalone usage

Benefits

  • Proper File Management: Images are now managed through Frappe's file library with proper permissions and organization
  • Document Association: Uploaded files are automatically linked to the current document
  • Consistent UX: Uses the same file upload patterns as the rest of the Frappe framework
  • No Breaking Changes: Existing implementations continue to work without modification

The editor now seamlessly integrates with Frappe's built-in file management while preserving all existing functionality.

Fixes #1.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 5, 2025 15:11
… upload mechanism

Co-authored-by: batonac <4996285+batonac@users.noreply.github.com>
Co-authored-by: batonac <4996285+batonac@users.noreply.github.com>
Copilot AI changed the title [WIP] integrate with the frappe media/file library Integrate frappe.ui.FileUploader for image uploads in editor Aug 5, 2025
Copilot AI requested a review from batonac August 5, 2025 15:20
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.

integrate with the frappe media/file library

2 participants