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?
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.
☒ 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
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?
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
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?
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.
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 %>
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?
https://github.com/lazaronixon/trix-extensions
Is Rails UJS / Rails.ajax still the way to go with Rails 7? (although seems to work fine)
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.
It is setting that on the whole document, not just elements within the controller, right?
https://stackoverflow.com/questions/70837739/dynamicly-add-a-button-that-is-linked-to-an-action/70849603#70849603
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.
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.