XINHA has started to support Opera and Safari

XINHA has started to support Opera and Safari

by Mauno Korpelainen -
Number of replies: 4

Latest nightly build of XINHA has started to work with the latest Opera and Safari too - Thank you Petr Dlouhý for noticing this!

http://xinha.gogo.co.nz/xinha-nightly/examples/ExtendedDemo.html

So we have now 5 possible editors: TinyMCE, FCKEditor, YUIRTE, Xinha and current HtmlArea. Integration of Xinha can be done with similar structure as integration of htmlarea so this is worth testing although TinyMCE and FCKEditor may be more flexible choices.

Average of ratings: -
In reply to Mauno Korpelainen

Re: XINHA has started to support Opera and Safari

by Mauno Korpelainen -

I tested integration immediately and Xinha rendered editor a little slower than htmlarea but in first test version I replaced textareas "for-textarea" with a different way than before (without disabeling htmlarea) in moodle 2.0.

Note - just for testing:

First I uploaded the latest nightly build version of Xinha from http://xinha.webfactional.com/wiki/DownloadsPage

Then I changed in weblib.php:

function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') {
    global $CFG, $COURSE, $HTTPSPAGEREQUIRED;
 static $scriptcount = 0;
    $str = '';
    if ($id === '') {
        $id = 'edit-'.$name;
    }

if (empty($courseid)) {
            $courseid = $COURSE->id;
        }
if ($usehtmleditor) {
            if (!empty($courseid) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $courseid))) {
                $httpsrequired = empty($HTTPSPAGEREQUIRED) ? '' : '&ampt;httpsrequired=1';
                // needed for course file area browsing in image insert plugin
                $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
                        $CFG->httpswwwroot .'/lib/editor/xinha/XinhaCore.js?id='.$courseid.$httpsrequired.'"></script>'."\n" : '';
            } else {
                $httpsrequired = empty($HTTPSPAGEREQUIRED) ? '' : '?httpsrequired=1';
                $str .= ($scriptcount < 1) ? '<script type="text/javascript" src="'.
                         $CFG->httpswwwroot .'/lib/editor/xinha/XinhaCore.js'.$httpsrequired.'"></script>'."\n" : '';

            }
$scriptcount++;
    $str .= '<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
    $str .= htmlspecialchars($value);
    $str .= '</textarea>'."\n";
    $str .= '<script type="text/javascript">
//<![CDATA[
document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');
//]]>
</script>';
    if ($return) {
        return $str;
    }
    echo $str;
       }
else
{
    $str .= '<textarea class="alltext" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'; 
    $str .= s($value);
    $str .= '</textarea>'."\n";
    if ($return) {
        return $str;
    }
    echo $str;
}
}

For testing (other configuration files can be edited if needed) I added to standard theme meta.php the init code of Xinha:

<script type="text/javascript">
    _editor_url  = "<?php echo $CFG->wwwroot .'/lib/editor/xinha/' ?>";
    _editor_lang = "en";
  </script>
<script type="text/javascript">
xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;

    // This contains the names of textareas we will make into Xinha editors
    xinha_init = xinha_init ? xinha_init : function()
    {

      xinha_plugins = xinha_plugins ? xinha_plugins :
      [
       'CharacterMap',
       'ContextMenu',
       'ListType',
       'SpellChecker',
       'Stylist',
       'SuperClean',
       'TableOperations'
      ];
             if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;

      xinha_editors = xinha_editors ? xinha_editors :
      [
        'form-textarea'
      ];

      xinha_config = xinha_config ? xinha_config() : new Xinha.Config();
      xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
      Xinha.startEditors(xinha_editors);
    }
</script>

Finally I edited in moodlelib.php function can_use_html_editor to let Safari and Opera to use editor. Worked beutifully!

Xinha uses mostly the same code as old htmlArea - Xinha even knows that it is was originally "htmlarea" and renames itself to Xinha.

In reply to Mauno Korpelainen

Re: XINHA has started to support Opera and Safari

by Yew Hong Ng -
I noticed that Xinha has an equation editor which renders MATHML. that's quite nice. However, in the online demo after creating my equation in the editor and clicking on submit, the preview becomes something like this:
  • `dy/dx=2xx^2+int_1^2f(x)dx -a/(b+1)`
instead of the proper mathml rendering. Why do I not see the equation properly?
In reply to Yew Hong Ng

Re: XINHA has started to support Opera and Safari

by Marc Grober -
Please review the info at jipsen's site provided in prior post. The backticks for asciimathml are equivalent to what doubledollar signs are for latex and now that you have created the equations, you have to have it interpreted by asciimathml