Adding new symbols to "Insert Special Character"

Adding new symbols to "Insert Special Character"

Enrique Castro發表於
Number of replies: 29
Core developers的相片
Hi all,
Writing Greek letters and other special symbols in the HTML editor is somewhat tricky. Reading these forums and those of "Moodle en Español" I have seen several questions about this. If you are a mathematician or physic probably you are used to TeX and Moodle is nice for that. But for casual use greek letters and special symbols are a mess. And I have the impression that there is a need to write some alphas or betas from time to time in almost every field, by teachers and by students.

The standard practice seems to be to go to HTML source, write down the HTML entity code, like α or ε, and go back to HTML editor. This is not practical:
  • puts into users (teachers and students ) the  need to remember that codes
  • actually exposes them to the HTML source, something the HTML editor was designed to avoid

The HTML editor do have a toolbutton called "Insert Special Characters" to insert special symbols. However, the available symbols are not particularly useful. New symbols can be added by editing  the file moodle/lib/editor/popups/dlg_ins_char.php and listing the desired entities. However, those changes will be lost upon next upgrade.

Thus I would like to propose a change in the management of the symbols available in the "Insert Special Character" box. I can suggest two pathways, one more conservative, other more flexible, but I think both easy to perform.
Alternative 1
Just adding more symbols to the standard list in dlg_ins_char.php.
The new symbols would be 
full greek letter in lower and Upper case, math symbols, some arrows etc.

Since this file is part of standard Moodle we all will have access to the same symbols. The only problem I see may be screen space if too many symbols are added.

Alternative 2
making the list of symbols available on that box customizable in the same way as the language packs.
We could include in each language pack a file with the symbol list (either a new "symbols.php" file or added to the editor.php file. In this way symbols would remain user-customizable AND upgrade-friendly.

I do not want to impose work on anyone, I can manage to do it myself, but I would like to know if a general solution is desirable or just I hack my own site.

What do you think? Janne, do you see this as useful?

- Enrique -
評比平均分數: -
In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Janne Mikkonen發表於
Core developers的相片
Hi Enrique,

I like the symbols.php idea. Symbols could also have several differents sets and from those sets we could generate dropdown menu to choose desired charset table. Although there should be at least one default charset table.

- Janne -
In reply to Janne Mikkonen

Re: Adding new symbols to "Insert Special Character"

Enrique Castro發表於
Core developers的相片
Hi Janne,
I have been thinking about the multiple charsets and dropdown list.
Personally I only see three possible symbolsets, those defines by W3C's HTML reference:
  • Character entity references for ISO 8859-1 characters
  • Character entity references for symbols, mathematical symbols, and Greek letters
  • Character entity references for markup-significant and internationalization characters
If the number of sets is fixed, it is very easy to manage them with a simple lang-style file symbol.php, with localized strings.
$string['greeksetname']= "letras griegas"
$string['greekset']= '"Α","Β", ... ,"Ω"

But if the number of allowed symbolsets (and their names) is undefined and customizable, then I think that cannot be managed only from a lang-style file. Pulling and undetermined number of names and sets cannot be done with simple get_string(stringname, module) without more information.

But it would be as easy to manage symbolsets like fonts, adding a new configuration setting for a symbolset list. However, if all HTML character entities are listed in the three standard sets, I do see the necessity for custom sets. Is there a need for restricted, truncated, sets?

I am working in the fixed three sets options. I will send to you a prototype example in (I hope) a few hours

- Enrique -
In reply to Janne Mikkonen

Re: Adding new symbols to "Insert Special Character"

Lars Jensen發表於
Hi Enrique and Janne,

A drop-down menu would be great, but it would still be very useful to have  a way to enter the symbols directly from the keyboard. Those of us that use special characters quickly learn the character codes, and then it is much faster to type from the keyboard than to use a window with drop-down menus. -A drop-down menu is more intuitive than switching to HTML source and back, but I don't think it is any faster.
Lars.
In reply to Janne Mikkonen

Re: Adding new symbols to "Insert Special Character"

Enrique Castro發表於
Core developers的相片
OK, here is the prototype

There are three panes accessible through the droplist button.
There is plenty of space for other symbols, if needed. In fact, after seeing it I would prefer to have these three panes grouped as "greek & math", "iso-8559-1" (collecting actual second and third panes) and a third for "user defined symbols"

Making the system fully customizable, with unlimited panes is easy, but requires to add configuration settings into admin/editor.php. My personal opinion is that there is no need to go further. Unicode is the solution in the not so long term. I see this as a present convenience.

- Enrique -
In reply to Janne Mikkonen

Re: Adding new symbols to "Insert Special Character"

Enrique Castro發表於
Core developers的相片
This is a composite snapshot of those panes


附件 insertchars.gif
In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Julian Whitehead發表於
Okay, this looks fantastic. While TeX is pretty good (and very powerful) this is an excellent short term measure.

I love what you have done, how do I get it into my moodle? Is it just a case of uploading the files in the zip to a suitable location?

At the very least you have shown me how to edit the file the gives instruction for the pop-up!

Thanks!

Jools
In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Martin Dougiamas發表於
Core developers的相片 Documentation writers的相片 Moodle HQ的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片
I'm all for this ... Janne, what do you think?
In reply to Martin Dougiamas

Re: Adding new symbols to "Insert Special Character"

Janne Mikkonen發表於
Core developers的相片
I like it a lot what Enrique has done 大笑 I'll check it through shortly (at the moment I have quite high fever. As it comes down I'll continue).
In reply to Janne Mikkonen

Re: Adding new symbols to "Insert Special Character"

Enrique Castro發表於
Core developers的相片
I'm sorry you are ill, Janne.
The chage is minimal, I'm only an "aficionado".
You can rest and get better.
When healthy and ready, tell me if you need other "preformatted" symbol lists. Probably you have better tasks to invest your time. I can do the low-profile work.

- Enrique -
In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Thomas Caswell發表於
This modification no longer seems to work with Moodle 1.6. How can one easily manipulate the "insert special characters" function to work in Moodle 1.6? Is there a new way to do this with UTF-8?

Regards,
Thom
In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Jaime Alamo發表於
hi all,

(sorry for Janne. Give your body the attentions it requires.)

I like that very much. I always wondered why the ins char didn´t take account of the font selected in the pop-up menu (like Windings, Symbol, ...)

In order to just insert alphas and betas , I write a's and b's, select them and set Symbol font for them.
Obviously, to have this operative, the admin must set it first , in Configuration ->Editor settings -> add Symbol font. I don't know if there is a limit on how many fonts can be added. The admin adds one at a time, and always appears a new blank entry box.
this way, it is not inserted &alpha; but <span style="font-family: symbol;">a First is shorter. But for me It would be enough that:
1st the "Insert Special Character" Table would show characters using the appropriate / selected font;
2nd insert clicked character with that font type and
3rd put the cursor after it !.

This is in my to do list. But now I´m working in an inserttext function that it is starting to work. see some later post.

For alphas and betas inside formulas, I use the mimeteX filter.

In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Enrique Castro發表於
Core developers的相片
Hi,
I have rewritten this hack for HTMLarea editor to work like "insert symbol" feature in MS-Word or OpenOffice Writer.

Taking advantage of utf-8 support present from version 1.6, now this dialog will display the full range of unicode utf-8 characters supported by the web broser/font combination. A combobox allows to choose the unicode block to show within UCS: Basic Latin, Greek, Math operators an so on. Even Arabic, gujarati, katakana and all others blocks, if desired.

To avoid making that selector too clumsy I have added a visibility setting that controls which of the 154 unicode blocks of characters are available. This could be added as as site setting in the admin tree (no done yet).

The attachment is tested in 1.9 HEAD, but should work as well in 1.7 and 1.8

Hope that this might be useful for somebody



In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Patrick Sedivy發表於

Hi Enrique,

I think that your solution can help me with my issue. How do I install the file you attached with your post?

In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

Dean Stringer發表於
Hi Enrique,

Thanx for your work. This is working well for us in Firefox but IE 6 and 7 don't like the lack of semicolon on the end of each of the entity codes as they are currently rendered out of utf8_block_get_symbols() in utf8_blocks.php.

I've tweaked line 191 to add a semicolon in the following way which has fixed it for us in IE...

$char = '&#x'.dechex($i).';';

By the way, has this been committed to the Moodle codebase yet? We had a look for tracker items but couldn't find anything related to it.

cheers,
Dean Stringer (Waikato University, New Zealand)
In reply to Dean Stringer

Re: Adding new symbols to "Insert Special Character"

Enrique Castro發表於
Core developers的相片
Hi Dean
Thanks for the fixing. I am attaching an updated file witha README and instruction for installation.
This in tracker as issue MDL-10243, assigned to Janne Mikkonen.
If you could drop Janne a tip about this, or vote for the issue or whatever, I can work on making an interface for admin to set which UTF-8 blocks are visible. We at ULPGC are satisfied with those currently displayed.
In reply to Enrique Castro

Re: Adding new symbols to "Insert Special Character"

vic estilo發表於

Hi Enrique,

     Thank you for this mod! This is just the perfect alternative that we've been looking for since we cannot implement TeX due to security issues. I noticed that some characters(Mathematical Operators) are not displayed properly in IE but in Firefox everything is ok. 
     Read this article and it suggested to change IE font to Arial Unicode MS and all mathematical operator symbols are now displaying correctly.
http://www.lib.uchicago.edu/e/su/mideast/encyclopedia/browsers.html

     Hope this helps.

Cheers,
Vic

In reply to vic estilo

Re: Adding new symbols to "Insert Special Character"

Nigel Osborne發表於

Same for me, just what we needed. Except...

As you can see in the attached image, the display isn't working in IE7. Its fine in FF. I did make the change suggested by Dean above (which was NOT included in the revision attached to Enrique's post of 10 April 2008, 05:25 AM

Can anyone suggest what I need to do to get this working in IE?

(I've tried changing IEs display fornt to Arail Unicode MS, as Vic suggests, but that had no effect, I've also cleared all cache's in case that was the problem)

附件 Image2.jpg
In reply to Nigel Osborne

Re: Adding new symbols to "Insert Special Character"

Nigel Osborne發表於
Sorry - forget that query - my own fault - I didn't apply Dean's IE7 fix properly.
In reply to Nigel Osborne

Re: Adding new symbols to "Insert Special Character"

Nigel Osborne發表於

I do have one other query though. Where can I change the size of the popup window? Its not wide enough for many of the character sets, and with no scroll bars its not obvious how users can reach the 'hidden' characters.

I thought it would be this line 5 in \lib\editor\htmlarea\popupwin.js:

var dlg = window.open("", "__ha_dialog",
                  "toolbar=no,menubar=no,personalbar=no,width=600,height=600," +
                  "scrollbars=no,resizable=no");

but it has no efffect.

In reply to Nigel Osborne

Re: Adding new symbols to "Insert Special Character"

Nigel Osborne發表於

I do have one other query though. Where can I change the size of the popup window? Its not wide enough for many of the character sets, and with no scroll bars its not obvious how users can reach the 'hidden' characters.

I thought it would be this line 5 in \lib\editor\htmlarea\popupwin.js:

var dlg = window.open("", "__ha_dialog",
                  "toolbar=no,menubar=no,personalbar=no,width=600,height=600," +
                  "scrollbars=no,resizable=no");

but it has no efffect.

In reply to Nigel Osborne

Re: Adding new symbols to "Insert Special Character"

Nigel Osborne發表於

...and another question on this topic (I hope someone reads these soon sad

The new Special Characters appear to work great now - or at least they do in the HTML edit window. But once the message is saved they disappear, with most being replaced by "?"

This is in IE7 and FF3 browsers, inserting Mathematical operators

I've tried all the suggested changes to browser language, unicode etc. Anything else I can do?

In reply to Nigel Osborne

Re: Adding new symbols to "Insert Special Character"

Mathieu Petit-Clair發表於
Core developers的相片 Moodle HQ的相片 MoodleCloud team的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片
Hi Nigel,

The size of the popup is fixed in /lib/editor/htmlarea/dialog.js, line 35 (Moodle 1.9.2). You might need to force-reload the page, or empty the browser's cache to make this change work.

Are you sure you have the fonts to display the characters you've added? Can't think of anything else right away...

EDIT: can you tell us what characters you are adding? (the character code or the entity would help to test this out).

Mat
In reply to Mathieu Petit-Clair

Re: Adding new symbols to "Insert Special Character"

Nigel Osborne發表於

Thanks for the help Mat. At least now the pop-up window is a better size.

I am trying to add characters from the 'Mathematcal operators' set . None appear. I am wondering if our server doesn't have a unicode font. Could this be the problem? If so I will have to talk to the server host.

In reply to Nigel Osborne

Re: Adding new symbols to "Insert Special Character"

Mauno Korpelainen發表於

Nigel,

can your browser show these Mathematical operators (utf8 characters)

∀∁∂∃∄
∅∆∇∈∉
∑∫∡⊈⋀

If it can't the problem is in browser settings or missing utf8 fonts (your computer). If it can the problem might be in server settings (for example utf8 characters are not saved as utf8 characters to database...) - is your Sitewide locale empty (by default) in Administration -> Language -> Language settings?

In reply to Mauno Korpelainen

Re: Adding new symbols to "Insert Special Character"

Marc Grober發表於
Mauno,

We should probably write a client How To for the docs and include all the URLs that have been posted, including for windows users an explanation of the Windows Character Map (for discussion see, http://tlt.psu.edu/suggestions/international/accents/charmap.html) as compared to the "Choose Character" dialog which is equivalent to clicking on the symbol icon on htmlarea. Server side info on expanding the symbol dialog for tinyMCE should probably be included and I suppose using firefox to spell check etc could also be addressed.

Let me know when you need me to review it ;=}

GoG
In reply to Marc Grober

Re: Adding new symbols to "Insert Special Character"

Mauno Korpelainen發表於

I agree - and we could create different versions of this nice plugin extension that Enrique has made (for moodle 2.0 ...because adding new plugins to tinymce is much easier than adding new plugins to htmlarea). I tested about year ago a modified plugin for tinymce 2 with same approach as Uniview and character pickers by Richard Ishida http://rishida.net/utilities and it allowed both adding any unicode characters or corresponding gif images, single or several characters at the same time but it was a really raw version - and I never published it...

The ideal character picker and equation editor might have some common features...

For example Gunther Krauss has made a nice character picker http://www.guntherkrauss.de/computer/xml/daten/edicode.html and other editors have several plugin of their own to help adding unicode characters - not only maths but almost any unicode characters that are available.

This "unicode topic" is just extremely large...

附件 unicodes.gif
In reply to Mauno Korpelainen

Re: Adding new symbols to "Insert Special Character"

Marc Grober發表於
And growing larger ;=}
Part of the problem is that there are impacts everywhere.... Just in this discussion we see discussion of use of OS utilities, browser settings, Moodle client interface and dialogs and server resources..... Makes one's head hurt... and for folks on this side of the lake it is in some respects more difficult as we tend to assume that anything starting with "uni" means one world government, enslavement, the end of the world......

I think I would start at the top with what unicode means, and then break things out by functional element along the lines above.....

From a development perspective, it might be neat for the users of <rankle>Windows</rankle> if the user could actually invoke the OS character map from the editor (as in Ctrl-Alt-C) don't you think? One thing I did like about dragmath by the way is that Chris and Alex did all their tables in XML so it is easily extensible, and while java can be painful at times, theirs is a nifty little way to manipulate any symbols..... also, I think that EqEd offers something here as well....

But as discussed before, such considerations are for the moment outside the current target for Moodle 2.0.... but we have again hijacked a thread.... and we should start something fresh
In reply to Mauno Korpelainen

Re: Adding new symbols to "Insert Special Character"

Nigel Osborne發表於

Thanks Mauno

I can see those symbols OK here; and the Sitewide locale is empty. I'll see what our web host can do about possible server issues.

In reply to Nigel Osborne

Re: Adding new symbols to "Insert Special Character"

Anjani kumar upadhyay發表於
The question and ans which I can see from my system is not in the write format ?

how can format can be set correctly?

this is really embarrassing.