Trumbowyg Paste embed plugin

in #utopian-io6 years ago (edited)

Trumbowyg is a wysiwyg text editor for web. A nice javascript library that's easy to implement and expand. AFAIK it's the best free editor around. It was only missing a function I needed for a website: When user pastes a link, it needs to be formatted automatically. So if it's a youtube video, it should iframe the video. If it's a spotify song, it should iframe the song. There already was a solution for this, called the noembed plugin. But the downside of that is that the user has to click on "noembed", paste the link and press OK. It needs to be simpler for the user.
Users don't know noembed, embedding should happen automatically when a link is pasted. That's what this plugin is for and that's why I made it. It looks for paste event, checks if it's a url and uses noembed API to retrieve an iframe from that url. If it can't retrieve an iframe, it will put an anchor tag around the url. It doesn't do anything on text or HTML paste.

New Feature: Paste Embed plugin

I made it into a plugin so you only have to load trumbowyg.pasteembed.min.js for it to work.
I also added documentation and a demo.
image.png

trumbowyg.pasteembed.js

I looked at how others had made plugins for trumbowyg. Combined some code I saw on a noembed plugin, and some plugin with a paste handler. For me it was a big puzzle since there was no documentation on how trumbowyg works and handles things.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thanks for the contribution. It has been approved.


Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Hey @maxse I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Utopian Witness!

Participate on Discord. Lets GROW TOGETHER!

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 57849.42
ETH 3122.29
USDT 1.00
SBD 2.43