Page 1 of 1

problem with WYSIWYG editor

Posted: Tue Dec 28, 2004 6:27 pm
by Justin2
I have problem with WYSIWYG editor. In IE on page serendipity_entries.php?serendipity[adminModule]=entries&serendipity[adminAction]=new are 2 errors.

first:
line: 2
sing: 1
error: syntax error
code: 0

second:
line: 250
sing: 3
error: HTMLArea.I18N.tooltips value null or not object
code: 0

WYSIWYG editor don't display. Where is problem< I use Serendipity 0.7.1

Re: problem with WYSIWYG editor

Posted: Wed Dec 29, 2004 4:01 pm
by garvinhicking
Which Serendipity language are you using?

Regards,
Garvin

Posted: Thu Jan 27, 2005 1:21 am
by bluelayer
hie

i have the same problem, i have the portuguese version... the english version works perfect, how to fix that ??

thanks :)

Posted: Thu Jan 27, 2005 8:45 pm
by :tragic hero:
The same problem, I have a spanish version, as soon as I change it to english language wysiwyg works right.

Regards.

Posted: Fri Jan 28, 2005 12:44 pm
by garvinhicking
HTMLArea has been updated in the 0.8 Version we're providing currently a snapshot for. Can you please try that version? It should work there.

Since we're quite near to releasing 0.8 it would be unneccessary work to upgrade 0.7.1's htmlarea.

Regards
Garvin

HTMLArea nightmares solved.

Posted: Sun Jan 30, 2005 5:27 pm
by ykoehler
Hi,

I spent 1 hour yesterday on debugging the HTMLArea issue with I18N. There is a lot of post around the web and on the HTMLArea forum itself about this issue. The problem I think is both, due to an HTMLArea bug and to most web site inserting HTMLArea in their system.

It has to do with the way HTMLArea support loading additionnal scripts dynamically without having to specifying them all before instantiating an editor. Basically the way HTMLArea works is that it will create a array of script name that has to be loaded at the time the htmlarea.js is processsed.

Then, once HTMLArea.init() function is called, those script inside the array are appended to the <head> tag of the document using a script tag such as this:

<script language="text/javacsript" src="my additionnal script to load"/>

But, the script isn't load, and the process to add those file is actually not immediate, there is a setTimeout which is used to call that function as many time as there is script inserted in the array.

By the time the additionnal scripts are really loaded, the code found in the HTML already attempted to instantiate the HTMLArea.Config object which will fail because the needed content inside the additionnal script has yet to be loaded.

That is why you will see many solutions such as manually adding the require additionnal file just after the htmlarea.js insertion point or mechanism to wait for the file to be loaded before the instantiation using something such as if (HTMLArea == null) settimeout() else instantiate.

My solution isn't yet perfect but I can garantee it to work. Until HTMLArea itself fix this by creating a documented way to have additionnal script loaded without race issues then I see no official or clean way to do it.

The solution is mostly based on serendipity but it could also be used by others. Serendipity put the Spawn<?=$jsname;?>() function inside the onload event of the body tag. That function, instead of instantiating the HTMLArea should actually call HTMLArea.init() so to let the chance to HTMLArea to load additionnal script.

Then the function must wait for HTMLArea to be loaded. My technic is to use a function like WaitForHTMLArea<?=$jsname;?>() and check for element that are known to be important for the instantation to work:

HTMLArea
HTMLArea.I18N
SpellChecker
SpellChecker.I18N

Once the elements are present, the function call another one, that is actually the original serendipity function renamed to StartHTMLArea<?=$jsname;?>.

Here is the complete code, it has to be added to serendipity_functions.inc.php inside v0.7.1:

function WaitForHTMLAreaToLoad<?php echo $jsname; ?>() {
if (HTMLArea == null || HTMLArea.I18N == null || HTMLArea.I18N.tooltips$
setTimeout("WaitForHTMLAreaToLoad<?php echo $jsname; ?>()",50);
} else {
InitHTMLArea<?php echo $jsname; ?>();
}
}
function InitHTMLArea<?php echo $jsname; ?>()
{
//
// Original content of previous Spawn function
//
}
function Spawn<?php echo $jsname; ?>() {
HTMLArea.init();
WaitForHTMLAreaToLoad<?php echo $jsname; ?>();
}


Note also that I have found 3 others issues specific to the serendipity use of HTMLArea. I think they are related to changes made inside HTMLArea version that weren't followed by the team of serendipity.

Those are:

Change "insertorderedlist" to "orderedlist"
Change "insertunorderedlist" to "unorderedlist"
Change "config<?php echo $jsname; ?>.cssCode"
to "config<?php echo $jsname; ?>.pageStyle"

Now, my HTMLArea are always working and the Spell checker works also nicely.

Re: HTMLArea nightmares solved.

Posted: Sun Jan 30, 2005 7:36 pm
by garvinhicking
Yanick, could you test Serendipity 0.8 with that issue? I made some tweaks to the instantiation of HTMLArea there, which should make your workaround unneccessary...?

Regards,
Garvin

Re: HTMLArea nightmares solved.

Posted: Mon Jan 31, 2005 1:28 pm
by ykoehler
Hi Garvin,
garvinhicking wrote:Yanick, could you test Serendipity 0.8 with that issue?
I'd love to, yet I cannot promise anything about it. I do not have 0.8 installed and doing so does require a little setup time. Once I do get the chance to do that I will post my results to this post.

I may be able to have a look at the code tonight which would probably require less time than installing the v0.8.

Re: HTMLArea nightmares solved.

Posted: Mon Jan 31, 2005 2:39 pm
by garvinhicking
Hi Yannick,

okay - that's great as well. But the code of htmlarea itself has also changed a bit, so it may be better to try to install the actuall version, if you ever have free time to play with it :)

Just report here please if you find it solved or not :)

Regards,
Garvin