Download & Extend

Table creates borders that won't go away

Project:OpenWYSIWYG Editor
Version:6.x-1.0-beta3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I'll created a table, specify no border. When I save and edit and save again, the border is now set to 1 px dashed. If I delete the offending HTML code, it puts the border back in ignoring my deletes. I've tried setting it to 0px and it sets it back to 1px. Ditto for any other edit to try to hide the border like a color change. It just keeps resetting it back to some default coming from who knows where. How do I get this to stop?

Comments

#1

Category:support request» bug report

I confirm this is a bug and I will try to fix this in next release.

The workaround right now is:
- avoid to use Full HTML, mean you can select "Filtered HTML" then add these tags:
<table> <th> <tr> <td>

#2

This won't be a solution as we need tables. I need to display content in two columns.

#3

I've started using FCKeditor and IMCE instead. If this module is ever fixed, I'm willing to try it again.

#4

I'd like to say that I've patched this issue in my version of OpenWYSIWYG. This too annoyed the crap out of me because the system is great and I'm made tons of mods and made my own add-ons to make my CMS the best out there. I have just always had this issue. To resolve this problem, open wysiwyg.js, scroll to about line 1650. You should see the function updateTextArea: function(n){. Look through the commands inside that function and add this before and after the line that reads var content = this.getEditorWindow(n).document.body.innerHTML;
WYSIWYG_Table.disableHighlighting(n); <- This goes before
WYSIWYG_Table.refreshHighlighting(n); <- This goes after

When done, the section should look like it does below.

updateTextArea: function(n) {
// on update switch editor back to html mode
if(this.viewTextMode[n]) { this.viewText(n); }
// Disable WYSIWYG table styles
WYSIWYG_Table.disableHighlighting(n);
// get inner HTML
var content = this.getEditorWindow(n).document.body.innerHTML;
// Renenable WYSIWYG table styles
WYSIWYG_Table.refreshHighlighting(n);
// strip off defined URLs on IE
content = this.stripURLPath(n, content);
// replace all decimal color strings with hex color strings
content = WYSIWYG_Core.replaceRGBWithHexColor(content);
// remove line breaks before content will be updated
//if(this.config[n].ReplaceLineBreaks) { content = content.replace(/(\r\n)|(\n)/ig, ""); }
// set content back in textarea
$(n).value = content;
},

Any other questions or comments, E-Mail me back at dmoree[AT]shadowbranch(DOT)com

#5

I think I found the script you are referring to in modules/openwysiwyg/library/scripts/openwysiwyg.modified.js

Here is my cut/paste after editing (in case I did a typo), but it didn't work.

updateTextArea: function(n) {
// on update switch editor back to html mode
if(this.viewTextMode[n]) { this.viewText(n); }
// Disable WYSIWYG table styles
WYSIWYG_Table.disableHighlighting(n);
// get inner HTML
var content = this.getEditorWindow(n).document.body.innerHTML;
// Renenable WYSIWYG table styles
WYSIWYG_Table.refreshHighlighting(n);
// strip off defined URLs on IE
content = this.stripURLPath(n, content);
// replace all decimal color strings with hex color strings
content = WYSIWYG_Core.replaceRGBWithHexColor(content);
// remove line breaks before content will be updated
if(this.config[n].ReplaceLineBreaks) { content = content.replace(/(\r\n)|(\n)/ig, ""); }
// set content back in textarea
$_openwysiwyg(n).value = content;
},

#6

I tried using filtered HTML with the table tags included, but the bug seems to persist :(

#7

@#4 are you talking about OpenWYSIWYG Editor or Wysiwyg?

@#5 I did the same and also did NOT work
BUT we are modifying openwysiwyg.modified.js while #4 says

open wysiwyg.js, scroll to about line 1650

(which I didn't find)

#8

in file wysuwyg.js

Line : 2688 - 2695

_enableHighlighting: function(node) {
        var style = WYSIWYG_Core.getAttribute(node, "style");
        if(style == null) style = " ";
        //alert("ENABLE: ELM = " + node.tagName + "; STYLE = " + style);
        WYSIWYG_Core.removeAttribute(node, "prevstyle");
        WYSIWYG_Core.setAttribute(node, "prevstyle", style);
        //WYSIWYG_Core.setAttribute(node, "style", "border:1px dashed #AAAAAA;"); <------- Add Comment to disable table border
},

#9

Is this still an ongoing problem? I have managed to fix part of this problem but are having troubles when saving to the database.
When in design HTML mode you can see the table borders as expected, In TEXT mode the style tags that shows the dashed #aaa border no longer appears. Took me ages to track that down.

My problem is that when i save its saving the code from the HTML view and not the TEXT view which which contains the correct html code. Can anyone help.

Sorry if that sounds jibberish.

Im integrating this with .net by the way but hoping that someone with better javascript skills can help me here.

As most of these posts on here seem dated i havent posted the code i used to remove the table borders but am happy to share with anyone interested.

the_git_2000AThotmail.com

#10

Got the same problem, tried the solutions above without any luck. I still want to see the table in the editor so "thebusted" solution isn't really a option.
It feels like I will have to make an ugly workaround... When getting the text from the database I will try replacing the style code before displaying it it the browser.

#11

Assigned to:Anonymous» jessejohhavoc
Status:active» fixed

I solved it!

On line 2694 there is the following code (if its not this line do a search for "dashed"):
    WYSIWYG_Core.setAttribute(node, "style", "border:1px dashed #AAAAAA;");

Comment it out (put // before it) and oila!

#12

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#13

@#11 was your solution committed?

#14

Assigned to:jessejohhavoc» Anonymous
Status:closed (fixed)» active

#15

To retain the ability to "see" the table borders in the editor, while allowing for 0px borders in the output, what I did was do a search and replace of the output HTML on the server side, before saving to the database. Kind of a hack, but it works!!!

More specifically, I did a search for:

#aaaaaa 1px dashed

and replaced all instances with:

0px

So, what is saved into the database has 0px borders. The editor, however, always shows the "#aaaaaa 1px dashed" borders for you, even when it reloads the HTML from your database! It's then stripped out again by the search/replace function when you re-save the HTML into your database.

The only caveat to this workaround is if you really DID want borders with #aaaaaa 1px dashed attributes :) I suppose you could put a checkbox elsewhere on the page, to indicate whether or not your server-side code should strip out the "#aaaaaa 1px dashed" style attributes...

Enjoy!

#16

I was unable to find the wysuwyg.js script mentioned above, (I have the most recent build, 6.x-1.0-rc1 2009-Jun-25), but I did locate the same code mentioned above by posters #8 and #11 in this js: openwysiwyg.modified.js, (located here: openwysiwyg/library/scripts). I commented out the appropriate bit, but the annoying #%^#@! border just kept returning; I even deleted the line from the code, but the borders STILL kept coming back.

As a last-ditch effort to maintain a grasp on being easygoing, I performed a search for the word "table" on the entire js document, and on lines 1338-1339 found the following:

// Enable table highlighting
WYSIWYG_Table.refreshHighlighting(n);

I commented out the 2nd line:

// Enable table highlighting
// WYSIWYG_Table.refreshHighlighting(n);

And much to my surprise, I don't have borders around my tables any longer. Of course now I can't put a border around a table if I want to...but for the most part, I'm back to being easygoing anyway.