Help & Heavy testing, please!!!

Help & Heavy testing, please!!!

ved Janne Mikkonen -
Antal besvarelser: 21
Special tags has been our problem, because this editor have trashed those tags (nolink, math tags etc.).

Well I did some digging (head first, knee deep) and I think I found some sort of a solution, but It needs really heavy testing fist.

Lets make some changes to htmlarea.php

Fist lets make new function that enumerates all tags we do not wish to be touched in line 2065 right under HTMLArea.needsClosingTag function:

HTMLArea.dontCloseTags = function(el) {
// Put every tag here that we do not want to be touched.
var dontclose = " nolink ";
return (dontclose.indexOf(" " + el.tagName.toLowerCase() + " ") != -1);
};


Then lets make some changes to getHTML function:

find this code:
html += closed ? " />" : ">";

And change it to:
html += closed && !HTMLArea.dontCloseTags ? " />" : ">";

Then find this part:
if (outputRoot && !closed) {
html += "</" + root.tagName.toLowerCase() + ">";
}

and change it to:

if (outputRoot && !closed && HTMLArea.dontCloseTags) {
html += "</" + root.tagName.toLowerCase() + ">";
}


And that should do it! (file is inlcuded revision 1.28).

But it needs really intensive and heavy testing.... Like those math tags eg...

- Janne -


Gennemsnitsbedømmelse:Useful (1)
I svar til Janne Mikkonen

Re: Help & Heavy testing, please!!!

ved Janne Mikkonen -
This need to be slightly changed, but the biggest problem is Internet Explorer!!! If you put special tag at the first line as first or second tag it'll get stripped (like <p><nolink>Hey!</nolink> you there... becomes <p>Hey!</nolink> you there... and its all because of that geriatric mshtml.dll and its capability. Annoying, indeed...)

HTMLArea.dontCloseTags = function(tag) {
    var dontclose = " nolink ";
    tag = tag.replace(/\//,'');
    return (dontclose.indexOf(" " + tag.toLowerCase() + " ") != -1);
};


and:

html += closed && !HTMLArea.dontCloseTags(root.tagName) ? " />" : ">";

and:

if (outputRoot && !closed  || !HTMLArea.is_ie && HTMLArea.dontCloseTags(root.tagName)) {
            html += "</" + root.tagName.toLowerCase() + ">";
        }

I svar til Janne Mikkonen

Re: Help & Heavy testing, please!!!

ved Petr Skoda -
Billede af Core developers Billede af Documentation writers Billede af Peer reviewers Billede af Plugin developers
Hi!

Maybe a bit stupid question, but why to use <nolink> at all? Why not use <span id="nolink"> instead?

skodak
I svar til Petr Skoda

Re: Help & Heavy testing, please!!!

ved Janne Mikkonen -
Well, that could be the solution for nolink, not for other special tags. We'd have to make a parser for those other special tags to convert them to right form every time when data is loaded or unloaded to the editor.

But not bad suggestion at all smiler

- Janne -
I svar til Petr Skoda

Re: Help & Heavy testing, please!!!

ved Martin Dougiamas -
Billede af Core developers Billede af Documentation writers Billede af Moodle HQ Billede af Particularly helpful Moodlers Billede af Plugin developers Billede af Testers
The main reason was to make things easy for users ...
I svar til Martin Dougiamas

Re: Help & Heavy testing, please!!!

ved Petr Skoda -
Billede af Core developers Billede af Documentation writers Billede af Peer reviewers Billede af Plugin developers
... the easiest way for users is visual editing without switching to HTML source mode smiler
  1. select text
  2. click button
  3. text is highlighted (it would be easy with CSS if span is used)

I understand the <nolink> decision, because AFAIK it was made before introduction of HTMLArea and XHTML.



Another crazy idea:
The special tags could be converted by htmlentities() before loading nad then converted back during storage. Maybe it would be easier for the users too...
I svar til Petr Skoda

Re: Help & Heavy testing, please!!!

ved Martin Dougiamas -
Billede af Core developers Billede af Documentation writers Billede af Moodle HQ Billede af Particularly helpful Moodlers Billede af Plugin developers Billede af Testers
Also, remember that quite a lot of people are not using the HTML editor at all ...
I svar til Martin Dougiamas

Re: Help & Heavy testing, please!!!

ved Petr Skoda -
Billede af Core developers Billede af Documentation writers Billede af Peer reviewers Billede af Plugin developers
Could you please tell us, what percentage of moodle.org users uses HTML Editor?
It would be also interesting to know this percentage for users registered before and after introduction of the Editor.

Thanks.
I svar til Petr Skoda

Re: Help & Heavy testing, please!!!

ved Martin Dougiamas -
Billede af Core developers Billede af Documentation writers Billede af Moodle HQ Billede af Particularly helpful Moodlers Billede af Plugin developers Billede af Testers
Ugh, that's a lot of work and I'm not sure if it's useful. Quite a lot of people seem to use Safari, for example, and won't see the editor even when it's enabled.  For what it's worth 216 have it switched off by choice, and 17779 accounts have it on.

The main reason I said it is because at least two large instititutions I know have made the decision to switch it off at site level, because they don't like the messy HTML code the editor generates. They are concerned about accessibility and creating clean code.
I svar til Petr Skoda

Re: Help & Heavy testing, please!!!

ved Janne Mikkonen -
<span id="nolink"> Ok, but html or xhtml can't have same id's more than once in the page.

Convert special tags to htmlentities, Ok good point too, but if I wish to make tutorial to some one and show what is done, then those tags shouldn't be converted. And it's messed up again.  And the solution should be extensible, for all those who need special functionality buttons and attach tags in them.

And the only problem here is IE and its not only this editor (see http://julmajanne.com/editor and its having the same effect as this one). Gecko browsers do not have this stripout problem.

- Janne -
I svar til Janne Mikkonen

Re: Help & Heavy testing, please!!!

ved Petr Skoda -
Billede af Core developers Billede af Documentation writers Billede af Peer reviewers Billede af Plugin developers
You are right, I have completely forgotten the id tag trist Is <span class="nolink">  better? The htmlentities would be really ugly hack.

I have checked some other editors for <p><nolink>Hey!</nolink></p>:

I  like your CBR project!
I svar til Petr Skoda

Re: Help & Heavy testing, please!!!

ved Janne Mikkonen -
Thanks Petr smiler

My editor is still in its early stages and I have had really good learning curve towards better cross browser scripting, although browser differences are very frustrating sometimes (since I'm not a professional programmer but a simple kitchen assistant. That is my real profession, although I'm working as a sysadmin).

I tried fckeditor as well, and I must say they're gone better to worse since they change the editor to cross browser compliant, I hope its getting much better.

What comes to problem at hand I'd really go for the xml namespaces like <mdl:nolink>Do not automatically link this</mdl:nolink>. That'd give us much more extensible approach to whole special tag problem and I think it'll be easier to implement (editor, filters etc).

- Janne -
I svar til Janne Mikkonen

Re: Help & Heavy testing, please!!!

ved Petr Skoda -
Billede af Core developers Billede af Documentation writers Billede af Peer reviewers Billede af Plugin developers
I had to read something about XML namespaces. I am not a programmer too and my knowledge of web is very limited - Moodle motivated me to learn something new blinker.

IMHO the concept of <mdl:something> is interesting.
I svar til Petr Skoda

Re: Help & Heavy testing, please!!!

ved Janne Mikkonen -
Well IE mess up this too sad. I'll be testing this more at this night. In IE we have to do serious juggling...

Namespaces work in IE if the html code isn't translated to xhtml, so if you put line in like: <mld:nolink>do not automatically link this</mdl:nolink> and switch modes back and forth you can see that the line has become <nolink>do not automatically link this</nolink> and switch modes once more and the first <nolink> tag dissapears.

But if I override the xhtml translation prosess, the editor adds string like this a front of namespaces tags <?xml:namespace prefix = mld />.

So I'm going to try this:

When using IE, disable xhtml translation function when editing and fire it up when saving the form. When loading data to editor convert <nolink> tags to xml namespace tags.

- Janne -
I svar til Janne Mikkonen

Re: Help & Heavy testing, please!!!

ved Janne Mikkonen -
I'm almost there! Only thing now is that how do I implement "un"nolink on the same button... I think I sleep for a while first...
I svar til Janne Mikkonen

Re: Help & Heavy testing, please!!!

ved Janne Mikkonen -
Extension to this.

Here is some sort of  implementation of  "nolink" functionality. And it needs very heavy testing...
There are still some "bugs" in IE. When you wish to remove nolink tag, the text selection stays italic.

- Janne -
I svar til Janne Mikkonen

Re: Help & Heavy testing, please!!!

ved Tim Allen -
Was this ever tested and added to the main code or not? thoughtful Otherwise, to solve the <nolink> stripping problem on IE one would have no choice but to use Michael Penny's hack at http://moodle.org/mod/forum/discuss.php?d=8888#42897. A more integrated solution such as Janne's would be better.

Thanks in advance for any feedback. smile