Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2011-04-06 13:10:33

jovani
New member
Registered: 2011-04-04
Posts: 2

Remove formatting NOT working on a saved document in IE

Hi,

I have a document with some styles applied (with xinha). When i reopen the document, and press "remove formatting", nothing happens. I only tried this with IE8 on win 7. This is working fine on FF.

I was able to fix the issue but need your comment coz i am not 100% sure if what i am doing is correct.

An excerpt from InternetExplorer.js under "onExecCommand":

*****
case 'removeformat':
      var editor = this.editor;
      var sel = editor.getSelection();
      var selSave = editor.saveSelection(sel);

      var i, el, els;

      function clean (el)
      {
        if (el.nodeType != 1) return;
        el.removeAttribute('style');
        for (var j=0; j<el.childNodes.length;j++)
        {
          clean(el.childNodes[j]);
        }
        if ( (el.tagName.toLowerCase() == 'span' && !el.attributes.length ) || el.tagName.toLowerCase() == 'font')
        {
          el.outerHTML = el.innerHTML;
        }
      }
      if ( editor.selectionEmpty(sel) )
      {
        els = editor._doc.body.childNodes;
        for (i = 0; i < els.length; i++)
        {
          el = els[i];
          if (el.nodeType != 1) continue;
          if (el.tagName.toLowerCase() == 'span')
          {
            newNode = editor.convertNode(el, 'div');
            el.parentNode.replaceChild(newNode, el);
            el = newNode;
          }
          clean(el);
        }
      }
      editor._doc.execCommand(cmdID, UI, param);
****

The fix i did was to negate the condition on selectionEmpty(sel) so changing it to: if ( !editor.selectionEmpty(sel) ).

That fix will allow inline styles inside <span> to be removed and cleaned.


So my question is, did i do the correct fix?

Thanks!!!

Offline

#2 2011-04-08 00:11:52

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Remove formatting NOT working on a saved document in IE

The purpose of that code seems to be to only do the full cleaning if there is no selection.  If you were seeing the problem without having selected anything, then it's a problem with the selection handling (which indicates you might be using an older version of Xinha, try with the latest trunk).

If your change works for you, go with it.


James Sleeman

Offline

#3 2011-04-13 08:52:01

jovani
New member
Registered: 2011-04-04
Posts: 2

Re: Remove formatting NOT working on a saved document in IE

Thanks James.

Offline

Board footer

Powered by FluxBB