Skip to content

feat: ability for RichEditor plugins to provide file attachment provider - #19187

Merged
danharrin merged 8 commits into
filamentphp:4.xfrom
ralphjsmit:rjs/ability-to-resolve-file-attachment-provider-from-plugin
Feb 28, 2026
Merged

feat: ability for RichEditor plugins to provide file attachment provider#19187
danharrin merged 8 commits into
filamentphp:4.xfrom
ralphjsmit:rjs/ability-to-resolve-file-attachment-provider-from-plugin

Conversation

@ralphjsmit

@ralphjsmit ralphjsmit commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

When working on a RichEditor plugin I noticed that it was not possible for a plugin to provide a file attachment provider.

Right now, if a plugin needs a corresponding file attachment provider, the end user has to pass it manually:

$this
    ->registerRichContent('content')
    ->plugins([$plugin])
    ->fileAttachmentProvider($plugin->getFileAttachmentProvider());

This PR adds a HasFileAttachmentProvider interface that plugins can implement alongside RichContentPlugin. When a plugin implements this interface, the RichContentAttribute and RichContentRenderer automatically resolve the file attachment provider from the plugin, so the end user only needs to register the plugin:

$this
    ->registerRichContent('content')
    ->plugins([$plugin]);

The only "tricky" thing is that a rich editor can only have one file attachment provider instead of multiple. In this case it could make sense that the end user would need to manually select which file attachment provider to use. However, I think that if a plugin provides a file attachment provider for including media, then generally the user does not require any other file attachment providers.

Thanks!

@ralphjsmit ralphjsmit changed the title feat: ability for RichEditor plugins to provide file attachment provider feat: ability for RichEditor plugins to provide file attachment provider Feb 3, 2026
@danharrin danharrin added the enhancement New feature or request label Feb 3, 2026
@danharrin danharrin added this to the v4 milestone Feb 3, 2026

@danharrin danharrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't seem like this has changed the rich editor to read from the plugin's file attachment provider, just changed the attribute and renderer. So the editor would only use the provider if a plugin is added to the attribute.

@ralphjsmit

Copy link
Copy Markdown
Contributor Author

It doesn't seem like this has changed the rich editor to read from the plugin's file attachment provider, just changed the attribute and renderer. So the editor would only use the provider if a plugin is added to the attribute.

I see my example was out-of-date, but the reason for not doing this is (and doing it via the attribute/renderer instead) was that the file attachment provider requires an attribute to be set, like attribute(...). So from that perspective it probably would not make sense to allow users to inject a custom fileAttachmentProvider() on the RichEditor itself if they are not using an attribute.

@danharrin

Copy link
Copy Markdown
Member

Please proceed with making it consistent, even if there currently aren't use cases. It will make work to expand the file attachment providers easier in the future

@ralphjsmit

Copy link
Copy Markdown
Contributor Author

@danharrin Updated the RichEditor class to also resolve the fileAttachmentProvider from the plugins in the same way so that it is consistent.

@danharrin danharrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please fix the test failures

@danharrin
danharrin merged commit 3d3833d into filamentphp:4.x Feb 28, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants