brian PRO said almost 3 years ago on Embedding Youtube Videos into Action Text with Stimulus :
This is great thank you. Hopefully, more features like this will be added because of the launch of hey.com.

I am looking to add a colour wheel to the Trix editor so that users can change the colour of their text, and add more heading options. Can you give me any advice on how I would accomplish this task?

pete said almost 3 years ago on Embedding Youtube Videos into Action Text with Stimulus :
Brian - check out, not a colorwheel but might be sufficient
https://github.com/lazaronixon/trix-extensions


atstockland said about 2 years ago on Embedding Youtube Videos into Action Text with Stimulus :
Hi Dave!  Is this how you embed these videos?  I'm have a customer who creates custom training video in aviation, and they don't want the videos being downloaded, or YouTube links being passed around.  This seems like the solution.  I see you're html video link points to a blob...so, I'm assuming the technique in this video is what you're actually using.  If so, I'm gonna utilize this in my project.

David Kimura PRO said about 2 years ago on Embedding Youtube Videos into Action Text with Stimulus :
  I'm using a variation of this method for the Drifting Ruby videos. However, it's pretty much on par with how I'm doing it. One thing that I do prior to uploading the video is first using Handbrake to transcode the video. https://www.driftingruby.com/episodes/adaptive-bitrate-streaming-with-active-storage 


atstockland said about 2 years ago on Embedding Youtube Videos into Action Text with Stimulus :
I implemented this feature in my project...following along with this video was flawless.  However, my embeded youtube video in ActionText has a src of the actual youtube url, which I need to avoid.  I don't want a savy user to be able to access the video link in the page source.   I see your source is a blob, so I'm assuming maybe you are hosting these videos and are not using youtube.  Is that correct?   I wonder how I could accomplish that without hosting my own videos?

David Kimura PRO said about 2 years ago on Embedding Youtube Videos into Action Text with Stimulus :
Ah gotcha. Yes, if a user is not logged into the site, they will get an embedded youtube video. It looks like this site may suggestions to control this at the Youtube config level. https://moz.com/community/q/allow-embedding-on-a-youtube-but-only-for-specific-sites


asecondwill said over 1 year ago on Embedding Youtube Videos into Action Text with Stimulus :
Thanks for this video.  I'm finding Trix really hard to get my head around and this is a big help. 

Is Rails UJS / Rails.ajax still the way to go with Rails 7?  (although seems to work fine)

asecondwill said over 1 year ago on Embedding Youtube Videos into Action Text with Stimulus :
I've noticed that if i have two actiontext fields on the same page, the embed dialog stops working.  Is that because of use of document rather than this when finding elements? 

David Kimura PRO said over 1 year ago on Embedding Youtube Videos into Action Text with Stimulus :
It will probably work with UJS, but I would probably move things over to a fetch so that it will work longer term if you move fully to hotwire.

I haven't tried it out with two actiontexts, there may be somethings that need to change with the controller to handle it properly with two action texts on the same view.

asecondwill said over 1 year ago on Embedding Youtube Videos into Action Text with Stimulus :
I think it's because when you do things like 

document.querySelector('[data-trix-action="embed"]').addEventListener("click", event => {

It is setting that on the whole document, not just elements within the controller, right? 

So need to replace 
document.
With something more specific.  Any hints what?   this.element does take querySelector

asecondwill said over 1 year ago on Embedding Youtube Videos into Action Text with Stimulus :
In case anybody else wanting more than one editor on the page, this is how I got it working:

https://stackoverflow.com/questions/70837739/dynamicly-add-a-button-that-is-linked-to-an-action/70849603#70849603

asecondwill said over 1 year ago on Embedding Youtube Videos into Action Text with Stimulus :
For some attachments, It would be great to add attributes that don't change.  The text in a link for example or a class on an image attachment. 

Is that possible to do ?

Something like this:

  const attachment = new Trix.Attachment({content, sgid})
  attachment.setAttributes(link_text: link_text, link_class: 'a-class')

And then have access to the attributes in the rendering partial for that Model.

daijinara PRO said 8 months ago on Embedding Youtube Videos into Action Text with Stimulus :
If anyone is interested in using request.js instead of ujs, then
async attachContent(content) {
        let _this = this
        let formData = new FormData()
        formData.append("content", content)
        const response = await patch('/embed', { body: formData, responseKind: "json" })
        if (response.ok) {
            const data = response.json
            data.then((result) => {
                const attachment = new Trix.Attachment(result)
                _this.element.editor.insertAttachment(attachment)
                _this.element.editor.insertLineBreak()
            })
        }
    }

However, Rails 7 & turbo-rails ver. >=1.1.0 does not display ActionText attachments. It's really ugly but below is what I did while I am waiting for its upgrade. 
<% post.content.body.attachables.each do |node| %>
    <%= render partial: 'embeds/embed', locals: { embed: Embed.new(id: node.id) } %>
<% end %>

Login to Comment