Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize Attachment Preview URL #1210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanpdoyle
Copy link
Contributor

Related to #1154

First, document the existing Attachment previewing process, including which content types are supported out of the box.

Next, resolve some ManagedAttachment to Attachment proxying issues. The ManagedAttachment class is what gets dispatched as part of trix-attachment-add events. It does not inherit from Attachment, but instead proxies method calls and property access. Prior to this commit, there were some proxy definition gaps.

For example, the ManagedAttachment declares a proxy for the setAttribute method. Unfortunately, an Attachment.setAttribute method did not exist prior to these changes. This commit remedies that.

Next, this commit adds proxy definitions for Attachment.setPreviewURL and Attachment.getPreviewURL so that event handlers can customize the value from the event-level ManagedAttachment instance, without deeply reaching into the Attachment instance (via
event.attachment.attachment).

Related to [basecamp#1154][]

First, document the existing Attachment previewing process, including
_which_ content types are supported out of the box.

Next, resolve some `ManagedAttachment` to `Attachment` proxying issues.
The `ManagedAttachment` class is what gets dispatched as part of
`trix-attachment-add` events. It does not inherit from `Attachment`, but
instead proxies method calls and property access. Prior to this commit,
there were some proxy definition gaps.

For example, the `ManagedAttachment` [declares a proxy for the
`setAttribute` method][setAttribute]. Unfortunately, an
`Attachment.setAttribute` method did not exist prior to these changes.
This commit remedies that.

Next, this commit adds proxy definitions for `Attachment.setPreviewURL`
and `Attachment.getPreviewURL` so that event handlers can customize the
value from the event-level `ManagedAttachment` instance, without deeply
reaching into the `Attachment` instance (via
`event.attachment.attachment`).

[basecamp#1154]: basecamp#1154
[setAttribute]: https://github.com/basecamp/trix/blob/5db0ea49180de97f27b0becf47440690a1eaa39c/src/trix/models/managed_attachment.js#L22
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.

1 participant