trix icon indicating copy to clipboard operation
trix copied to clipboard

Content Attachment Does not Show in Trix Editor when Coming back to Edit Mode

Open SudharakaP opened this issue 4 years ago • 2 comments

I am trying to add a content attachment as per, https://github.com/basecamp/trix#inserting-a-content-attachment. And that works fine. When the content attachment is added the trix-editor content looks like this.

image

Now when I go back to the edit mode I would like to populate all this content including the content attachment on the editor. For this I pass in all the content to the input element (https://github.com/basecamp/trix#populating-with-stored-content) which looks like,

<div>My awesome video<br /><figure><iframe src="https://player.vimeo.com/video/521163890/?showinfo=0" allowfullscreen frameborder="0"></iframe><figcaption></figcaption></figure><br /><br /></div>

But somehow when I pass this the editor seems to strip the iframe;

image

Is there anything I am missing here? Any help will be greatly appreciated. Please let me know if you need more information. 🤔

The associated PR that I am working on to integrate the content attachments is; https://github.com/opencollective/opencollective-frontend/pull/6042

SudharakaP avatar Mar 14 '21 08:03 SudharakaP

Think I figured it out. It seems I've missed the line in the documentation where it says;

Trix won’t load any HTML content inside a <trix-editor>…</trix-editor> tag.

Which means that I had to write a special function to re-add the content attachments when the edit mode is triggered.

Hopefully Trix will provide a way to make this a bit easier in the future as this seems a bit hacky. Or is there a way already that I am missing? 😄

SudharakaP avatar Mar 15 '21 01:03 SudharakaP

This issue has been automatically marked as stale after 90 days of inactivity. It will be closed if no further activity occurs.

stale[bot] avatar Jul 21 '21 04:07 stale[bot]