General developer forum

Stripped down Atto editor

 
I Teach With Moodle
Re: Stripped down Atto editor
Particularly helpful MoodlersPlugin developersTesters

Thanks a lot for the link, Paul. I am struggling to get things going, as there is no documentation. 

Here is what I have so far, which does not work (i.e. all of the Atto icons are displayed).

$editoroptions = array(
'maxfiles' => 0,
'maxbytes' => 0,
'trusttext' => false,
'noclean' => false,
'context' => $context,
'subdirs' => 0,
'atto:toolbar' => 'style1 = bold, italic'
);

Has anyone implemented this successfully? Am I placing the atto options in the wrong place?

Cheers, 

Fred

 
Average of ratings: -
Picture of Peter Spicer
Re: Stripped down Atto editor
 

Hi,

Might be a late reply, but if you're trying to use this inside a regular moodleform instance somewhere, it won't work because of a bug in Moodle - https://tracker.moodle.org/projects/MDL/issues/MDL-59904

As I said in the ticket, I created a new class in my plugin called MoodleQuickForm_simpleeditor, saved as mod/myplugin/simpleeditor.php (not the real path, but one for example uses):

class MoodleQuickForm_simpleeditor extends MoodleQuickForm_editor {
    public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
        $this->_options['atto:toolbar'] = '';
        parent::__construct($elementName, $elementLabel, $attributes, $options);
    }
}

Then in my form definition I have:

    public function definition() {
        global $CFG;

        // Load the files we're going to need.
        require_once("$CFG->libdir/form/editor.php");
        require_once("$CFG->dirroot/mod/myplugin/simpleeditor.php");

        $mform = $this->_form;
        require_once("$CFG->libdir/form/editor.php");
        \MoodleQuickForm::registerElementType('simpleeditor', "$CFG->libdir/form/editor.php", 'MoodleQuickForm_simpleeditor');

        $editoroptions = array(
            'subdirs' => 0,
            'maxbytes' => 0,
            'maxfiles' => 0,
            'changeformat' => 0,
            'context' => null,
            'noclean' => 0,
            'trusttext' => 0,
            'enable_filemanagement' => false,
            'atto:toolbar' => 'style1 = bold, italic',
        );
        $mform->addElement('simpleeditor', 'mytextfield', null, null, $editoroptions);
        $mform->setType('mytextfield', PARAM_RAW);
    }

(My editor doesn't have a text label on it, but that's because I wanted it to be that way. You'd put the text label in place of the first null there.)

Hope this helps,

Peter

 
Average of ratings: -
Picture of Peter Spicer
Re: Stripped down Atto editor
 

Apologies, I copied the wrong link, it should be https://tracker.moodle.org/browse/MDL-59981 instead (and I am unable to edit the previous post)

 
Average of ratings: -