You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Offline

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

Please create a new Ticket and we will get back to you as soon as we can.

#113183 Javacript access to content

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by yannickgaultier on Tuesday, 07 March 2023 15:27 GMT

yannickgaultier
Hi Ryan, Yannick from Weeblr here, hope you're doing well.

For several of my extensions (4SEO, 4Podcast and some more to come), I am in need for accessing the content editor with javascript.
Nothing fancy, things like:
- getting and setting the current editor content (as HTML)
- possibly getting user selection position, or getting the selected HTML

Both Joomla 3 and Joomla 4, but J4 is a priority.

Do you have some doc on how to "officially" do that? or what'd be your advice on the most compatible way to do this with JCE?

I mean by that: if I can have the same code for both Joomla TinyMCE and JCE, it's best.

Thanks for any pointer,

Yannick Gaultier
https://weeblr.com




Ryan
JCE does implement the Joomla Editor API functions (where id is the id value of the textarea) :

Joomla.editors.instances[id].getValue();
Joomla.editors.instances[id].setValue(value);
Joomla.editors.instances[id].getSelection();
Joomla.editors.instances[id].replaceSelection(value);

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

yannickgaultier
Thanks, I had thought so but best to confirm!

Cheers