Forum Academy Marketplace Showcase Pricing Features

Is it possible to extend a plugin and access its elements?

Hey, newbie question here.

I would like to add some custom functionality to Bubble’s Rich Text Editor plugin.
By creating a new plugin.

I would need to access the contents of the text input, but have no idea how.

Is this possible at all?

— What i’m trying: setting/appending text to the editor contents —

// Get the element - this works
var rich_text_input = document.getElementById(instance.data.element_id);

// doesn't work - can't access the QuillJS function as such
rich_text_input.setContents(properties.text_to_append); 

// doesn't work - this replaces the entire html of the editor including toolbar
rich_text_input.innerHTML = properties.text_to_append;

That’s because you are just getting the bare root element of the editor. You need to reference the QuillJS API that wraps the whole element. I’d have to dig into their documentation to get the specifics. Assuming you have a reference to a myapi JS CDN in a script element, the general pattern in the initialize function is usually:

// Find your element
instance.data.mydomelement = document.getElementById(instance.data.element_id);

// Wrap it in the API
instance.data.myapihandle = myapi.wrap(mydomelement);

// Now do the stuff
instance.data.myapihandle.setsomestate("statefull content");
2 Likes

Thanks! Yep I figured it out. I simply referenced the the Quill object and manipulated it the way I needed.

2 Likes