problem with WYSIWYG editor

Found a bug? Tell us!!
Post Reply
Justin2

problem with WYSIWYG editor

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: problem with WYSIWYG editor

Post by garvinhicking »

Which Serendipity language are you using?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bluelayer
Posts: 4
Joined: Thu Jan 27, 2005 1:20 am

Post by bluelayer »

hie

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

thanks :)
:tragic hero:

Post by :tragic hero: »

The same problem, I have a spanish version, as soon as I change it to english language wysiwyg works right.

Regards.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ykoehler
Regular
Posts: 11
Joined: Sun Jan 30, 2005 12:57 am
Location: Montreal
Contact:

HTMLArea nightmares solved.

Post 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.
Yannick Koehler
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: HTMLArea nightmares solved.

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ykoehler
Regular
Posts: 11
Joined: Sun Jan 30, 2005 12:57 am
Location: Montreal
Contact:

Re: HTMLArea nightmares solved.

Post 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.
Yannick Koehler
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: HTMLArea nightmares solved.

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply