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

Support setting img[alt] on ManagedAttachment #1198

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

Commits on Nov 15, 2024

  1. Support setting img[alt] on ManagedAttachment

    Extend the `PreviewableAttachmentView` to assign
    [HTMLImageElement.alt][] based on the `Attachment` instance's `"alt"`
    attribute.
    
    This enables applications to set the [preview image's alt text][4.8.4.4]
    while editing inside the `<trix-editor>` element. For example, an
    application can modify a `ManagedAttachment` instance through a
    `trix-attachment-add` event listener:
    
    ```js
    addEventListener("trix-attachment-add", ({ attachment }) => {
      attachment.setAttributes({ alt: `Attached file ${attachment.file.name}` })
    })
    ```
    
    [HTMLImageElement.alt]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt
    [4.8.4.4]: https://html.spec.whatwg.org/multipage/images.html#alt
    seanpdoyle committed Nov 15, 2024
    Configuration menu
    Copy the full SHA
    3dd8f6e View commit details
    Browse the repository at this point in the history