Page 1 of 1
WYSIWYG Editor: Your Document Is Not Well Formed -- Solution
Posted: Sun Aug 24, 2008 12:41 am
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
Will be happy to test
Posted: Sat Aug 30, 2008 10:24 am
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
Posted: Mon Sep 08, 2008 9:58 pm
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.
Posted: Mon Sep 08, 2008 10:09 pm
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.
Posted: Mon Sep 08, 2008 10:43 pm
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
Posted: Tue Sep 09, 2008 3:15 am
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>
Posted: Tue Sep 09, 2008 3:45 am
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; ?>';
Posted: Tue Sep 09, 2008 9:53 am
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
Posted: Tue Sep 09, 2008 8:22 pm
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.
Posted: Wed Sep 10, 2008 2:11 am
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:
So please consider using some other theme as the default in functions_admin_entries.inc.php:
or