WYSIWYG Editor: Your Document Is Not Well Formed -- Solution

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

WYSIWYG Editor: Your Document Is Not Well Formed -- Solution

Post by garvinhicking »

Hi!

I read from a few users that the default s9y editor often tells them "Your Document is not well formed".

I've read on a bug page for Xinha (the follow-up to htmlarea) that people fixed the bug by removing some part of code inside the htmlarea/htmlarea.js file. More precisely this:

Code: Select all

HTMLArea.getHTML = function(root, outputRoot, editor){
    try{
        return HTMLArea.getHTMLWrapper(root,outputRoot,editor);
    }
    catch(e){
        alert('Your Document is not well formed. Check JavaScript console for details.');
        return editor._iframe.contentWindow.document.body.innerHTML;
    }
}
and replace all that to:

Code: Select all

HTMLArea.getHTML = function(root, outputRoot, editor){
    return HTMLArea.getHTMLWrapper(root,outputRoot,editor);
}
First reports showed that users were then able to properly operate the WYSIWYG panel. Since I personally don't use it -- are there people volunteering to test this and see if they can work properly with it?

Then it could be incluided in the official s9y distro.

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/
shovals
Regular
Posts: 26
Joined: Sun Jul 20, 2008 10:54 am
Contact:

Will be happy to test

Post by shovals »

Hi Garvin,
I've seen this error several times.
I will be happy to get rid of it...
I've made the modifications and will test your code from now on.
Hope for the best :)

----------------------------
http://www.fazaza.com
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

Ok I made the changes and followed the same steps to recreate the bug. It doesn't work. No error message but when you click on save the entry body is not saved. Also you can't view the html code of the entry body either. The editor just gets stuck. So basically if you create a new entry the entire contents of the entry body are lost. If you edit an existing entry then changes you make are lost.
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

BTW I tried the xinha demo and I can't recreate this bug there. Maybe s9y should use xinha as its wysiwyg :) ? Its released under the BSD license afterall.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Abdussamad!

Hm, strange. In the other thread, I got at least 3 people saying it works for them...don't know what to make of it. In the xinha log, it said this fix resolved the issues.

If one can help with the integration of the WYSIWYG so that everything that currently works with htmlarea would work with xinha as a full replacement, I'd surely appreciate that...

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/
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

Ah what do you know? It turns out xinha is a drop in replacement for htmlarea :) . After downloading and unzipping the xinha files into [s9ydir]/xinha I just opened up [s9ydir]/include/functions_entries_admin.inc.php and replaced these lines:

Code: Select all

 <script type="text/javascript">
        _editor_url = "<?php echo $serendipity['serendipityHTTPPath'] . 'htmlarea/'; ?>";
        _editor_lang = "<?php echo WYSIWYG_LANG; ?>";
        var editorref = '';
    </script>
    <script type="text/javascript" src="htmlarea/htmlarea.js"></script>
    <script type="text/javascript" src="htmlarea/lang/<?php echo WYSIWYG_LANG; ?>.js"></script>
    <script type="text/javascript" src="htmlarea/dialog.js"></script>
    <style  type="text/css">@import url(htmlarea/htmlarea.css);</style>

With these:

Code: Select all

 <script type="text/javascript">
        _editor_url = "<?php echo $serendipity['serendipityHTTPPath'] . 'xinha/'; ?>";
        _editor_lang = "<?php echo WYSIWYG_LANG; ?>";
         _editor_skin = "silva"; 
        var editorref = '';
    </script>
      <script type="text/javascript" src="xinha/XinhaCore.js"></script>
    

I also had to change the rewrite rule in .htaccess (if using url rewriting):

Code: Select all


RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
Replaced with:

Code: Select all

RewriteRule ^xinha/(.*) xinha/$1 [L,QSA]
There is just one problem. Unlike htmlarea where the languages include the charset in xinha all the language files are utf and the charset is not specified. So for example if I change to german then WYSIWYG_LANG=de-utf8 it won't display german text. It should be just "de" for xinha. You can see for yourself if you compare the files in xinha/lang with the files in htmlarea/lang.

So somebody will have to go through all the files in [s9y_dir]/lang and change the defines for WYSIWYG_LANG to *not* include the charset.

OR

You could do a substring (atleast until the language file maintainers get into gear):

Code: Select all

<script type="text/javascript">
        _editor_url = "<?php echo $serendipity['serendipityHTTPPath'] . 'xinha/'; ?>";
        _editor_lang = "<?php echo substr(WYSIWYG_LANG,0,2); ?>";
         _editor_skin = "silva"; 
        var editorref = '';
    </script>
      <script type="text/javascript" src="xinha/XinhaCore.js"></script>
    


abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

Ok a few other minor changes in functions_entries_admin :):

Copy htmlarea/images/ed_s9yimage.gif to xinha/images and then this code:

Code: Select all

config<?php echo $jsname; ?>.registerButton('image_selector', '<?PHP echo MANAGE_IMAGES; ?>', '<?php echo $serendipity['serendipityHTTPPath']; ?>htmlarea/images/ed_s9yimage.gif', false,


Replaced with:

Code: Select all

config<?php echo $jsname; ?>.registerButton('image_selector', '<?PHP echo MANAGE_IMAGES; ?>', '<?php echo $serendipity['serendipityHTTPPath']; ?>xinha/images/ed_s9yimage.gif', false,

To make the media manager inserted images appear properly in the editor:

Code: Select all


config<?php echo $jsname; ?>.cssFile = '<?php echo $csscode; ?>';

Replaced with

Code: Select all

config<?php echo $jsname; ?>.pageStyle = '<?php echo $csscode; ?>';

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

Post by garvinhicking »

Hi!

Awesome! If I only knew that before. Seems to work well for me, also.

I just committed a patch to SVN trunk and hope that many people can test this, especially on shared installations.

I chose to put it into the existing htmlarea directory so that no new directory for shared installs is required, and no changes of rewrite rules.

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/
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Wow, fantastic! Thanks, abdussamad!

Garvin, I see you've got the language files changed, too. I was going to offer, but you've got teh mad skillz.
Judebert
---
Website | Wishlist | PayPal
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Post by abdussamad »

I'd like to point out one other modification. I made the mistake of using the silva theme in the code I previously posted. It uses a large font size for the display of the html hierarchy in the editor's status bar and if you click on a media manager inserted image in the editor the list of tags is so long that it looks ugly.

See what I mean: Image

So please consider using some other theme as the default in functions_admin_entries.inc.php:

Code: Select all

   _editor_skin = "blue-mettalic"; 
or

Code: Select all

   _editor_skin = "blue-look"; 
Post Reply