TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -
Number of replies: 62

Hello,

We've produced a drop-in TinyMCE 3 based replacement WYSWIYG editor for HTMLArea in Moodle 1.9.  This modification will overwrite the older existing TinyMCE editor with a newer version and only requires a single core file, /lib/setup.php, to be changed.  After installation any user configured to use HTMLArea will now use TinyMCE to input HTML.

PHP 5.1 or later is required for correct functionality.  Failure to meet this criterion may cause your Moodle site to stop loading. These changes have only been tested against Moodle 1.9.12 stable, but should work with older and newer versions of 1.9.

The latest stable version may be downloaded here: http://www.webcourseworks.com/sites/default/files/moodle-tinymce.zip.  Installation instructions are provided inside of the zip file.

Development may be tracked on github: https://github.com/WebCourseworks/moodle/tree/tinymce.  Installation instructions are provided here: https://github.com/WebCourseworks/moodle/blob/tinymce/readme-tinymce.md.  Patches are welcome.

Average of ratings: Useful (2)
In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Joseph Thibault -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

John, I got the TinyMCE to work using Firefox, but if I try to do it using Chrome (which was the reason for trying) it still doesn't display.  Do you have any idea why I was able to replace the HTML editor for FF but it still doesn't display in Chrome?

In reply to Joseph Thibault

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Matt (WCW) Meisberger -

Hi Joseph,

I'm also from Web Courseworks like John. It sounds like you probably have a moodle that is pre 1.9.11. In moodle 1.9.11 there is a fix that will allow HTML editor to be used for chrome browsers. This TinyMCE installation will only replace the old HTML editor if it is going to be shown.

If you want to modify the file one off to get it to show on chrome browsers you can find the change here https://github.com/moodle/moodle/commit/c476a2ec.

However let us know if this isn't the case

Matt

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

First of all, wonderful thing, very useful.

Now the bad news: i've got it running in 5 minutes, but it seems that the national characters (e.g. à ì) are not correctly shown when saved. Looking at the DB, using the htmlarea i got the chars saved in utf8, and with this tinymce the same chars are saved in HTML format e.g. "à ì".

Where i can start to catch the bug ? Any hints welcome!

In reply to Sergio Rabellino

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi,

You are correct.  The handing of these characters is different between TinyMCE and the old HTMLArea.  I've configured the editor to reduce the set of characters that will be encoded to the bare minimum necessary to ensure the behavior is as similar as possible.  This list includes greater than (>), less than (<), and ampersand (&).  The TinyMCE documentation suggests that quotes (") and apostrophes (') will also be encoded but I can't seem to make that happen with the latest TinyMCE version.

I've updated the zip file and our github with this change.  The only file that changed was lib/editor/tinymce/tinymcejs.php.

After updating the file you may need to clear your browser's cache to receive the update.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I can confirm that now it works on my Moodle 1.9.8+ and works also with chrome, following the patch suggested in the other post on this forum.

Thanks.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Lucy Walshaw -

Hi John,

 

Unfortunately it did not work for us (no editor was displayed) checked in IE and Firefox we have already customised our editor for Nanogong and for HTMLAREA Editor custom plugin framework support i have left the file structure in place and just removed the two additional lines from setup.php for now. if you have a fix i would really appreciate it

thanks

Lucy

In reply to Lucy Walshaw

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi,

After review it appears as though Nanogong and the HTMLArea custom plugin framework won't work with TinyMCE as-is.  At the moment there doesn't appear to be a nontrivial solution to this problem.  I'm adding it to the list of things to look at supporting in the future.

In reply to John Ehringer

回應: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Shwu-Fen Kuo -

Hi all,

Is TinyMCE 3 compatible with IE9 fine?

We had refered to "http://www.webtolife.co.nz//content/tinymce-and-moodle-howto" to integrate TinyMCE before.

It work fine, until IE8 upgrade to IE9.

Users complain to us, he would like to create a resource, but can't save it.

Does anyone use TinyMCE and work in IE9 fine? Could you tell me what is the version of TinyMCE you used?

Thanks.

In reply to Shwu-Fen Kuo

Re: 回應: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

With this replacement (this forum thread), my IE9 works fine.

In reply to Sergio Rabellino

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Paolo Oprandi -

I have tried this using a Moodle 1.98 install, but only see a text field without an editor.

We have:

-added the tinymcelib.php file to the lib directory.

-replaced the lib/editor/tinymce files with the WebCourseworks tinymce files

-added the require_once line to lib/settings.php

-added Chrome modifications to moodlelib.php

-established use_html_editor is set

Sergio, you said it just worked on your Moodle 1.98 install.  Can you or anyone else offer any suggestions?

Many thanks, Paolo

In reply to Paolo Oprandi

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Matt (WCW) Meisberger -

Hello Paolo,

Are you getting it to work in IE or Firefox?  You mention that you made a chrome modification to moodlelib.php but have not mentioned that you edited the other file lib/editor/htmlarea/htmlarea.php that is noted in the MDL-16336 commit so I was wondering if you have that modification also.

You also say that you are making sure that use_html_editor is set, does that mean that you are attempting to et it to work on a specific custom page or are you having difficulty getting this to work in places like the user profile edit page, or the course summary box on the page to add a new course?

Thanks,

Matt

In reply to Matt (WCW) Meisberger

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Paolo Oprandi -

Hi Matt and Sergio,

Thanks for your responses.

I have tried in Mac Firefox, Mac Safari, Mac Chrome and Pc IE. As a last resort I did make the changes to lib/editor/htmlarea/htmlarea.php.

I have tried using it in the profile description, in forum posts and when adding a web page resource, but I get a text box without either html editor. There is a yellow keyboard icon displayed which I believe is part of the editors?

yellow keyboard

Thanks,

Paolo

In reply to Paolo Oprandi

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

I'm unsure why it isn't showing up at all. TinyMCE won't show up on Moodle 1.9.10 or older using the Chrome or Safari browsers, but it should appear using other browsers (Internet Explorer or Firefox).

Have you loaded any HTMLArea customizations into your site? These may cause conflict with TinyMCE which could result in what you're seeing.

This could be related to a bug that was recently fixed which would prevent TinyMCE from appearing on certain pages (block editing, assignment grading, etc). It would appear on the profile description though. You may want to give the latest version a try. http://www.webcourseworks.com/sites/default/files/moodle-tinymce.zip

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Szabó Bálint -

Hi John,

I using Moodle 1.9.10+. I was setting up
the TinyMCE 3. The editor is work correctly, but if i wanting insert the media (for
example Flash) with the Insert/edit embedded media button, i get the message:
"The selected file is not picture..."

Can you help me?
Thanks: Balint



In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Craig Smith -

Hello

Unfortunately, when I install this hack exactly as described I get either a fatal error (blank page) or no editor (just a box with HTML).  The most common result on install is a fatal error.  If I comment out the line in lib/setup.php the page loads correctly and the standard HTM Editor is back.

I'm mystified and frustrated.

Regards

CS

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Craig Smith -

Hi all I figured out the issue with the installation.  Adding text to new labels or other edit boxes works perfectly.

But...existing text (originally created with HTMLarea) is rendered with additional characters sprinkled through the code:  Extra <p></p> tags;  What look like space codes that are rendered as a special characters (a circle in I.E., a square in FF).  Each time I save an edited resource, more of these are added until the page is completely unreadable.

What is going on?  I've checked these elements in the database prior to editing.  The added tags and characters do not exist in the content until the editor inserts them.

Thanks for any help

In reply to John Ehringer

TinyMCE 3 for 1.9 won't work

by Craig Smith -

I have given up.  I've tried every init setting available and I cannot prevent the editor pre-processing the content and adding huge amounts of junk.  The initial save is fine, but it appears you cannot edit existing text.

A fresh install of 1.9.12 with a fresh database still displays the same behaviour.

Good luck with the project.  Unfortunately, there seems to be a major flaw in the design or in TinyMCE itself.

It appears noone is here anyway.

In reply to Craig Smith

Re: TinyMCE 3 for 1.9 won't work

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

So I was too lucky ? My test-site is working correctly. I've imported a course from a production platform and editing text written by a teacher, nothing is added/broken, also taking a look at the html code, all it seems clean as the source was.

Even saving multiple times, i cannot reproduce what you are saying.

Could you be more descriptive for the "junk" you got?

Thanks.

 

In reply to Sergio Rabellino

Re: TinyMCE 3 for 1.9 won't work

by Craig Smith -

thanks for your reply, Sergio.  I was not sure what the junk was at the time of posting.  I've discovered since that the characters were &#010 (line feeds).  They are not in the HTML in the database, but were added everywhere when the editor was rendered.  it may be a PHP thing.  I honestly don't know.

Anyway, I resolved the issue by adding this line to the init section of tinymcejs.php:

remove_linebreaks : true,

This cleans the &#010 codes out of the HTML when it is rendered and when it saves. 

I do have another unusual issue.  On a clean install with a fresh database, the new editor appears.  But if I then connect the installation to a copy of my production database, the editor disappears and only displays a HTML box with no editor at all.  A previous poster seemed to be reporting a similar issue.  i cannot see anything in the config that would cause this.

Thank you again for your reply.   

In reply to Craig Smith

Re: TinyMCE 3 for 1.9 won't work

by John Ehringer -

Hello Craig,

I'm trying to track down the issues you're reporting but I'm not having too much luck at the moment. I'll continue trying when I get back to work on the 5th. Do you encounter these issues more using a certain browser? The problem occurs both with old content entered using HTMLArea and new content entered using only TinyMCE?

If you're willing, you may want to update to the latest version of the code. There have been a few bug fixes to the integration and I've brought the included version of TinyMCE up to 3.4.3.2 which seems to address a number of strange editor behaviors. The most recent version is in the zip linked in the original post. Our github is a few days behind and I won't be able to update that until July 5th.

Thank you,
John

In reply to John Ehringer

Re: TinyMCE 3 for 1.9 won't work

by Craig Smith -

Hi John

I've had significant breakthroughs with all the issues. 

As noted above, I was able to solve the &#010 insertion issues by adding a line (remove_linebreaks : true,) to the init for TinyMCE.

For the second issue I eventually did a line-by-line comparison of a fresh mdl_config and the mdl-config for my production database.  The culprit was the editorhidebuttons entry in the config file.  I cleared the values for this entry and the editor appeared correctly in my production database.

It appears that any entries for the editorhidebuttons  parameter prevent TinyMCE from loading. 

I've asked one of our team members to fully test before we load into production, but the editor now appears to be functioning as desired.

Thank you Sergio and John for your replies.  I hope this helps others who may be struggling with the same issues.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Simon Allison -

having a few issues with this on 1.9.12

insert link button, when selecting a document or powerpoint, message popup says "selected file is not an image, please select an image.

and some gradebook issues, not showing the editor and just showing html

In reply to Simon Allison

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Simon Allison -

not gradebook but assignment grading, the editor doesnt show, any help?

In reply to Simon Allison

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi,

Both of the issues you've reported should now be fixed.  Inserting media now permits selection of any file and a bug has been fixed that prevented TinyMCE from showing up on certain screens.

You can download the latest version here: http://www.webcourseworks.com/sites/default/files/moodle-tinymce.zip.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by David Dempster -

I have got TinyMCE 3.4.2 working with Moodle 1.9.12, but when I download the latest version of TinyMCE 3.4.3.2 and replace the files/directories in /lib - I still get version 3.4.2 being reported when I try to insert a web page etc... in Moodle.

Any ideas on what I could be doing wrong would be appreciated.

 

Cheers from David

In reply to David Dempster

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi David,

All it should take is replacing the content in lib/editor/tinymce/jscripts/tiny_mce with the updated TinyMCE 3.4.3.2 code on your server.  If you've done this and cleared your cache to ensure the browser is receiving the latest version of that file I'm not sure what would be causing you to still receive the older version.  

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Roland Sherwood -

Many thanks for this, John! Really very quick and easy to implement and vastly improves the user experience.

One question: we installed and were successfully using Dragmath with 1.9's default HTML editor, and so I wondered if it's possible for that functionality to show up in the TinyMCE editor also. I've looked through a couple of other threads on the forums and drawn a blank on this, so any advice you could give would be very gratefully received.

Thanks again.

In reply to Roland Sherwood

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hello Roland,

Unfortunately it's not possible for Dragmath or any other HTMLArea customizations to work with TinyMCE without significant porting work. They rely on many things that are different or unavailable in TinyMCE.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Jean-Michel Védrine -

Hello,

There is a version of the dragmath plugin that works with tinyMCE. I have now upgraded to Moodle 2.1 but I have used for nearly a year before that Moodle 1.9.x with tinyMCE (my own integration but it doesn't matter, it will also work with any other integration of tinyMCE in Moodle) and Dragmath (and asciimath !!, and geonext !!, and jsxgarph !! and all those wonderfull math plugins for tinyMCE) thanks to the fantastic work of Mauno Korpelainen and others. I think tinyMCE is heaven for math teachers compared to HTMLArea. See the mathematics tools forum to learn how to download and install those plugins.

I think the ability for students (and me of course) to more easily include  formulas, graphs and drawing in forum posts has completely changed how they used the forum to communicate on math subjects. I will never go back to an editor without these features.

Average of ratings: Useful (1)
In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Mauno Korpelainen -

Hi John,

I saw Jean-Michel's post and as we all know there are several kinds of integrations of tinymce for various versions of moodle so here a guide how to add dragmath to your integration without a significant porting work smile

Download files from http://korpelainen.net/dragmxx.zip and unzip/add them over your existing integration. Files of dragmath will go to lib/dragmath folder and plugin (originally created by Glen Davies) to lib/editor/tinymce/jscripts/tiny_mce/plugins/

I had to modify only one of your files: lib/editor/tinymce/tinymcejs.php and there added 'dragmath' to

$theme_advanced_buttons = array(1 => array('bold', 'italic', 'underline', 'strikethrough', MENU_SEPARATOR, 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', MENU_SEPARATOR, 'formatselect', 'fontselect', 'fontsizeselect', MENU_SEPARATOR, 'undo', 'redo','dragmath'),
                                2 => array('cut', 'copy', 'paste', 'pastetext', 'pasteword', MENU_SEPARATOR, 'search', 'replace', MENU_SEPARATOR, 'bullist', 'numlist', MENU_SEPARATOR, 'outdent', 'indent', 'blockquote', MENU_SEPARATOR, 'link', 'unlink', 'anchor', 'image', 'cleanup', 'help', 'code', MENU_SEPARATOR, 'insertdate', 'inserttime', 'preview', MENU_SEPARATOR, 'forecolor', 'backcolor'),
                                3 => array('tablecontrols', MENU_SEPARATOR, 'hr', 'removeformat', 'visualaid', MENU_SEPARATOR, 'sub', 'sup', MENU_SEPARATOR, 'charmap', 'moodlesmileys', 'media', MENU_SEPARATOR, 'ltr', 'rtl', MENU_SEPARATOR, 'fullscreen'));

and to plugins list

$tinymceplugins = array('safari',
                        'pagebreak',
                        'layer',
                        'table',
                        'moodlesmileys',
                        'insertdatetime',
                        'preview',
                        'media',
                        'searchreplace',
                        'print',
                        'contextmenu',
                        'paste',
                        'directionality',
                        'fullscreen',
                        'noneditable',
                        'visualchars',
                        'nonbreaking',
                        'xhtmlxtras',
                        'template',
                        'inlinepopups',
                        'dragmath');

after changes refresh your browser and dragmath should be visible with default settings given in plugin files.

HTH,

Mauno

Average of ratings: Useful (3)
In reply to Mauno Korpelainen

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Mauno Korpelainen -

Dragmath has also different kinds of settings and output formats so I made one tiny modification  to (moodle 2) core dragmath files and reuploaded http://korpelainen.net/dragmxx.zip with this modification that was present in my plugindemo files a long time ago but it is rarely documented - "GoogleTex" format.

Default format is set to "MoodleTex" which adds doubledollars to Tex notations and you need to have Tex filter or some other latex renderer to handle those latex strings - GoogleTex format adds image tags using Google chart api tex...

Example

Average of ratings: Useful (1)
In reply to Mauno Korpelainen

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Osvaldo Canato -

Wonderful job Mauno! It woks fine in 1.9.12. Thanks a lot!

One little problem is that it looks you forgot to change the line 30 of  dragmxx\lib\editor\tinymce\jscripts\tiny_mce\plugins\dragmath\dragmath.php from <param name=outputFormat value="MoodleTex"> to     <param name=outputFormat value="GoogleTex">.

Am I right? At least for me it was only after this minor modification that GoogleTex could work as a default output format.

In reply to Osvaldo Canato

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Mauno Korpelainen -

My default setting in plugindemo was originally using GoogleTex but I changed the default output format to MoodleTex because most moodle sites still use Tex filter with dragmath and for example default editor of moodle 2 does not know 'GoogleTex' format at all - although it would be easy to add there - and in moodle 2 default init code of tinymce requires that Tex filter is enabled (and functional)...

Each site can of course modify the default values according to their needs - for example use asciimath as default output format. smile

You can also change output format in dragmath applet itself - if you use more than one math renderer on the same site.

GoogleTex format is most valuable for such sites that can not use tex filter for example for some disabled functions of php - it is basicly using mimetex syntax but has some nice modifications - see for example http://code.google.com/intl/en/apis/chart/infographics/docs/formulas.html

In reply to Mauno Korpelainen

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hello Mauno,

This is fantastic. Thank you for taking the time to document this.  smile

I've updated our TinyMCE integration to automatically include the dragmath plugin if detected. The latest version of /lib/editor/tinymce/tinymcejs.php php will no longer need to be modified by hand to include the plugin after applying this update (http://www.webcourseworks.com/sites/default/files/moodle-tinymce.zip). I haven't bundled the dragmath plugin or lib folder, so those will still need to be added to an installation using the dragmxx.zip you've provided.

In reply to Mauno Korpelainen

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Nicole Alvarez -

Hello,
I would like to help, I'm working moodle 1.9.16 em and just update the HTML editor to TinyMCE 3, but the editor does not work DragMath, I can not download the plugins listed at: http://korpelainen.net/ dragmxx.zip If you could send it or upload it to another url to download ........... or you need to do to run the DragMath.
 

In reply to Nicole Alvarez

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Mauno Korpelainen -

Oh, sorry , my fault... I cleaned some old files from my test server some months ago and this was one of them - it's back now: http://korpelainen.net/dragmxx.zip

Average of ratings: Useful (1)
In reply to Mauno Korpelainen

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Nicole Alvarez -

Excellent, thank you very much.

Apply the plugins, and it worked immediately in version 1.9.16 + moodle with TinyMCE 3.

There will be a way to include it in the installation package for the latest versions of DragMath and moodle 1.9, would be ideal.
 

greetings from Chile

In reply to Mauno Korpelainen

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Admin Sekolah SMK -

saya bingung......

coba pakek bahasa indonesia....

In reply to Admin Sekolah SMK

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Frankie Kam -
Picture of Plugin developers

Ya, mula-mula saya juga bingung Rohmad. 

Tetapi setelah saya merujuk kepada Penterjemah Google, kebingungan saya telah hilang. Jangan khuatir, disini ada ramai yang boleh membantu anda jika ada keraguan mengenai Moodle atau jika anda ada sebarang soalan. Cara itulah anda boleh menjadi seorang pakar di dalam biding LMS, ya tidak?

Frankie Kam

Translation of the text above into English from Goog. Translate: "Yes, I too was once confused Rohmad. But after joining Google's latest Social Media tool, I am sure that the walrus sings at midnight. If you are in a muddle over Moodle, I am sure that one who looks to the heavens admiring the stars of the LMS should also watch out for the potholes on the road, no?"

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Melanie Hoag -

Hello!

This is working very nicely in our new Moodle 1.9.12 (we are upgrading next week from 1.9.9) and our Safari and Chrome users on Macs and WIndows will be very happy. But....I was wondering if there is any solution for using the editor on iPads?

Thanks!

In reply to Melanie Hoag

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I had the same issue (ipad support) but reading on the tinymce forums, only the IOS5 will be supported due to a lack in support to some javascript/html features missing in older ios, so we need to wait some time and then upgrade to tinymce 3.4.3.2 which support yet ios5.

In my test-drive of this replacement i'm getting some strange behaviour in resource creation or forums posts, where i need to insert more that 2 words to get the entry accepted (W-Forms reject the save like i was not inserting any text, with the red square along the tinymce).

Any hints about this ?

Average of ratings: Useful (1)
In reply to Sergio Rabellino

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi Sergio,

I'll have to take a look at that issue when I’m back in the office on Monday.

In reply to Sergio Rabellino

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi Sergio,

I'm trying to duplicate the issue you're describing. If I understand correctly, you're adding a forum post or creating a resource and are getting a validation error (red square, red warning text) on the TinyMCE field unless you enter more than two words. Is that correct? What browser is this happening with? I've tried Chrome 12, FireFox 4, and IE9/IE8/IE7/IE6, and am not having any luck duplicating it.

Does the validation error always occur when you save the page regardless of how many words you've entered into the editor? We found and fixed a bug that would cause the editor to always produce a validation error. The page would save correctly if you tried to save a second time with or without adding content to the editor. You may want to try updating your /lib/editor/tinymce/tinymcejs.php file with the latest version to see if that fixes this problem: https://raw.github.com/WebCourseworks/moodle/dbf6950db875ef0744c4ce5fa4cb923e4dafaaa6/lib/editor/tinymce/tinymcejs.php.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

The update suggested seems to fix my errors.

About the first question, I'm not so sure about 1 or two words, but after some "changes and save" the validation error disappear and i can go forward in creating resource or forum posts.

BTW, this fix it's definitely a resolution to my troubles.

In reply to Sergio Rabellino

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

I'm glad everything's working now.  smile

In reply to Melanie Hoag

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi,

Sergio is correct. TinyMCE doesn't appear to support iOS or Andriod at the moment (http://tinymce.moxiecode.com/wiki.php/Browser_compatiblity, http://tinymce.moxiecode.com/forum/viewtopic.php?id=22209) but it does appear as though iOS 5 will correct that (http://tinymce.moxiecode.com/forum/viewtopic.php?pid=91366#p91366).

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Ken Gibson -

Hey John,

Many thanks for plugin - helped solve an issue we had with a prior tinymce hack used earlier.  Works perfectly in  Moodle 1.9.3+ (Build: 20081210), with google spellcheck enabled.

Ken

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Helder Lima -

John,

First of all: Congratulations!

I'm having problems in the questionnaire, when I select the response as reported and visualize the questionnaire, only the first field appears with tinymce, other areas appear as simple textarea. Could you help me?

Thank you,
Helder

In reply to Helder Lima

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hello Helder,

I’ve spent some time troubleshooting your issue and am, at the moment, unable to replicate it.  I’ve gone through the questionnaire module and can't find the section you're referring to exactly, but I did come across several pages showing multiple TinyMCE editors together which appeared to be working correctly.  I did find that the “preview” page doesn't have any editors, but that appears to be by design.

This is similar to issues we were having with the editor before, where only one would appear on a given page. You may want to update your copy of /lib/editors/tinymce/tinymcejs.php with the one in this zip file: http://assets.webcourseworks.com/moodle-tinymce.zip.

If that doesn't fix your problem, would you provide me with instructions on how to the page you're having problems with? I'd be happy to look into this further on Monday.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by llywelyn morgan -

How do I uninstall tinyMCE in order to return back to HTMLarea?

cheers

In reply to llywelyn morgan

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hello,

To uninstall simply reverse the process.

  • Remove the change from /lib/setup.php. It will look like this: require_once("{$CFG->libdir}/tinymcelib.php");.

The next steps are optional but recommended if you'd like to get back to a clean slate.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by llywelyn morgan -

thanks.

had already tried removing the line from setup.php but that resulted in htmlarea losing it's editing icons.

will try removing tinymcelib.php and downloading new tinymce directory as you suggest. fingers crossed that will solve the problem of missing icons!

In reply to llywelyn morgan

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by llywelyn morgan -

lol

turns out the problem was that the icon images had disappeared from the htmlarea folder.  quickly copied them back in from the moodle dowload.

very strange.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Daniel Costa -

Hi John,

first of all thank you very much for your contribution. I installed sucessfully the tinymc for moodle 1.9. Now I'd like to change the language to Spanish. I tried changing in tinymce.class.php

343:         $defaultlanguage = 'en';

por

343: $defaultlanguage = 'es';
 

but, it did'nt work. The only thing I could do until now was changing the strings on en.js to spanish, but even that did'nt work for all the things, I guess because each plugin has its own lang file.

Could you giveme some hint on this, please?

TIA

In reply to Daniel Costa

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hello,

Presently this is a manual process.

First you'll need to download the appropriate language pack from the TinyMCE website: http://www.tinymce.com/i18n/index.php?ctrl=lang&act=download&pr_id=1. You'll receive a zip file which you'll need to open and copy the contents into the lib/editor/tinymce/jscripts/tiny_mce directory on your site. The zip file will contain directories (lang, plugins, themes) which should match up with those in lib/editor/tinymce/jscripts/tiny_mce.

Next open lib/editor/tinymce/tinymcejs.php.  Search through this file until you find a line that says “// General config”, which should be about midway down. After that line add the following: "language: 'es',".

For example, before the change:

    var editorConfig = {
        // Plugins
        plugins : "",
        // General config
        convert_urls : false,
        add_form_submit_trigger : true,
        add_unload_trigger : true,
        // HTMLArea did not encode many entites.  Default to 'raw' entity encoding.

After the change:

    var editorConfig = {
        // Plugins
        plugins : "",
        // General config
        language : 'es',
        convert_urls : false,
        add_form_submit_trigger : true,
        add_unload_trigger : true,
        // HTMLArea did not encode many entites.  Default to 'raw' entity encoding.
Average of ratings: Useful (1)
In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Daniel Costa -

Hi John,

thank's for the guidance, it works fine! Yuhhuuuu!

Cheers

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Thomas Michalak -

Hello,

does somebody of you knows how to integrate and activate spellchecking in the editor hack?

Thanks a lot, Thomas Michalak

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Paul P. -

First of all, thank you so much for this contribution.  I was able to successfully get it working in 1.9.14, but I had two issues to contend with:

1.  The context menu "paste" function was being a real pest.  Apparently recent versions of Firefox and Chrome were preventing the JS code from accessing the clipboard, so when a user tried to right-click and paste, they got an warning error.  I disabled the context menu successfully by commenting out line 34 in lib/editor/tinymce/tinymcejs.php 

...
'print',
//  'contextmenu',
'paste',
...

Now, when a user right clicks, they get the browser's default context menu which allows pasting from the menu

2.  I cannot get spell check to work for the life of me.  What I would like is for the browser to use it's default spell check which underlines mispelled words automatically, without having to rely on clicking a spellcheck button.  The tinymce documentation refers to putting in a 'gecko_speller: true' option somewhere, but in the several places I've tried, I cannot get it to work.

Any suggestions? Thanks in advance.

In reply to Paul P.

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by John Ehringer -

Hi Paul,

Thanks for the report of the misbehaving context menu.  I'll need to investigate further to see if a TinyMCE upgrade will correct that behavior or whether I should disable it outright.

The option you're after is gecko_spellcheck (http://www.tinymce.com/wiki.php/Configuration:gecko_spellcheck).    It can be set right around line 188 of tinymcejs.php (https://github.com/WebCourseworks/moodle-tinymce/blob/master/lib/editor/tinymce/tinymcejs.php#L185).  I tried it out and it seems to work fine under Chrome.  You do have to disable the context menu or else it gets in the way and prevents correcting misspellings, but you're already ahead of me on that one.  wink

Getting a real server-side spell check solution included with this extension is on my list of things to do eventually.  I don't have a lot of time these days unfortunately.

In reply to John Ehringer

Re: TinyMCE 3 Editor Replacement for HTMLArea in Moodle 1.9

by Paul P. -

Thanks, John, but when I made the change in tinymcejs.php as you stated, the default spellcheck didn't work (you had to right-click to spell check and the red lines would disappear as soon as you tried to make a correction).  Instead, I had to edit /lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js as well. 

I changed:
if(!v.gecko_spellcheck){q.getBody().spellcheck=0}

To:
if(!v.gecko_spellcheck){q.getBody().spellcheck=1}

You'll have to do a text search for the first line of code since tiny_mce.js is minified.  Now, as soon as you make a spelling error, it underlines it like any ordinary textarea.

Of course, as you said, the context menu needs to be off, but really, what advantage does it have anyway?

Time is a factor for me too (so I probably should stop posting and get back to work wink ) but as I've started getting my clients' sites ready for the move to Moodle 2, a server-side spell check for this may not be necessary.  Tinymce works great in Moodle 2 with the spellchecker.