Disable features from text editor

Disable features from text editor

by The Dreamer -
Number of replies: 3

Hello,

I have to provide rich text editing inside my activity module, but I don't want the user to be able to add images, videos, or links. Is there a way to disable specific feature of the editor from `formslib.php`?

If not possible, is there an easy way within the Moodle library to sanitise the submitted HTML and remove any link, video, and photo? Or do I need to do it using classic PHP methods?

Thanks for your help!

Average of ratings: -
In reply to The Dreamer

Re: Disable features from text editor

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi The Dreamer,

For the editor, it would depend on the editor you are using. TinyMCE and Atto have some settings to configure the editor's toolbar which you may be able to customize in your custom activity plugin or globally throughout the site. I think you may also be able to force the plain text editor or simply use a plain text (textarea) type field in your form. These are all guesses as I have not looked into it further. For sample code, look at other Moodle activities that have a similar type field to what you are looking for.

With regards to sanitizing, take a look at the Moodle API Output functions:
https://docs.moodle.org/dev/Output_functions

Best regards,

Michael Milette
In reply to The Dreamer

Re: Disable features from text editor

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
In reply to Marcus Green

Re: Disable features from text editor

by The Dreamer -
Thank you both for your help!

@Marcus Green this is exactly what I was looking for. But I still have one issue… the Editor API required the ID of the textarea (obviously) but I'm using repeat_elements to have multiple textarea, depending of the user's needs. Any idea how to combine both APIs and get this working?
Average of ratings: Useful (1)