basecamp / basecamp/trix

Custom Attachments Issues with ActionText/Rails - Youtube Video Embeds

Open
#1,062 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
20k
Forks
1.1k
Avg merge
3d 12h
Merged PRs (30d)
13

Description

Im using trix in rails 7+ for context.

This has been talked about before, but i'm still struggling. I'm trying to attach a YT video into my Trix Editor/ActionText rich content.

```
let embed = ''
let attachment = new trixInst.Attachment({ content: embed, contentType: 'text/html' })
trixEdtior.editor.insertAttachment(attachment);
```

This doesn't work for some reason. It attaches the video into the editor. But after saving it doesn't seem to convert/save to an ActionTextAttachment?

I thought based on this commit (https://github.com/rails/rails/commit/4499a3cdd0c), we can just set the html as the content as long as we set the `contentType` something custom with HTML?

Do we need to create a partial that matches the contentType? Im not sure. I was able to get something working with SGID's, but I'd really prefer to not have to persist every youtube video into a table record if possible.

I have also whitelisted the Iframe Tag.

Do we still need to do this with SGIDS? and `ActionText::Attachable`?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Trix Attachment API entry points shown in the example and compare their ActionText/Rails serialization path with commit 4499a3cdd0c. Check whether a custom contentType is persisted and rendered without an SGID or matching partial; done means the supported path for YouTube iframe embeds is documented or the limitation is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rails
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.