• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.6.6
    • 2.6.5
    • Inline Editor
    • None
    • FF3

      Pasting a word document into Firefox 3 doesn't work

      Update HtmlArea.js with :

      HTMLArea.prototype._wordClean = function() {
      var editor = this;

      function clearClass(node) {
      var newc = node.className.replace(/(^|\s)mso.*?(\s|$)/ig, ' ');
      if (newc != node.className) {
      node.className = newc;
      if (!/\S/.test(node.className))

      { node.removeAttribute("className"); }

      }
      };
      function clearPrefixAttributes(node) {
      var toremove = new Array();
      for (var i = 0; i < node.attributes.length; i++)
      {
      var index = node.attributes[i].nodeName.indexOf(":");
      if (index != -1)

      { toremove.push(node.attributes[i]); }

      }
      for (var i=0; i < toremove.length; i++)

      { node.attributes.removeNamedItem(toremove[i].name) }

      }
      function clearStyle(node)

      { node.style.cssText = ""; }

      ;

      function stripTag(el)
      {
      while (el.childNodes.length > 0)
      {
      var tmp = el.childNodes[0];
      if (!HTMLArea.is_ie)

      { // FF sucks :) el.parentNode.appendChild(tmp); }

      el.parentNode.insertBefore(tmp, el);
      if (tmp.nodeType == 1 && parseTree(tmp) != null)
      checkEmpty(tmp);
      }
      el.parentNode.removeChild(el);
      };

      // vire certains tags vides
      function checkEmpty(el) {
      if (/^(a|b|strong|i)$/i.test(el.tagName) && !el.firstChild)

      { el.parentNode.removeChild(el); }

      };

      // vire les tags interdits (font et span)
      function clearTag(el) {
      if (/^span|font|pre$/i.test(el.tagName))
      {
      var ftmp = null;
      while (el.firstChild)
      {
      var tmp = el.firstChild;
      if (ftmp == null)
      ftmp = tmp;
      el.removeChild(tmp);
      if (!HTMLArea.is_ie)

      { // FF sucks :) el.parentNode.appendChild(tmp); }

      el.parentNode.insertBefore(tmp, el);
      if (tmp.nodeType == 1)
      {
      var pTmp = parseTree(tmp);
      if (pTmp != null)

      { ftmp = pTmp; checkEmpty(tmp); }

      }
      }
      el.parentNode.removeChild(el);
      return ftmp;
      }

      return el;
      };

      // recursivite globale
      function parseTree(root) {
      var tag = root.tagName.toLowerCase();
      if ((HTMLArea.is_ie && root.scopeName != 'HTML') || (!HTMLArea.is_ie && /:/.test(tag)))

      { stripTag(root); return null; }

      else {
      var go = true;
      while (go)

      { go = false; clearClass(root); clearStyle(root); clearPrefixAttributes(root); var newroot = clearTag(root); if (newroot == null) return null; go = (newroot != root && newroot.tagName != undefined); root = newroot; }

      if (root.childNodes.length != 0)
      {
      var next;
      for (var i = root.firstChild; i; i = next)

      { next = i.nextSibling; if (/^script|!$/i.test(i.tagName)) i.parentNode.removeChild(i); else if (i.nodeType == 1 && parseTree(i) != null) checkEmpty(i); }

      }
      }
      return root;
      };

      function trim(t)

      { while (t.length > 0 && /[\t\n\r ]/.test(t.charAt(0))) t = t.substring(1); while (t.length > 0 && /[\t\n\r ]/.test(t.charAt(t.length - 1))) t = t.substring(0, t.length - 2); return t }

      parseTree(this._pasteDoc.body);
      this._pasteDoc.body.innerHTML = trim(this._pasteDoc.body.innerHTML);

      // showStats();
      // this.debugTree();
      // this.setHTML(this.getHTML());
      // this.setHTML(this.getInnerHTML());
      // this.forceRedraw();
      this.updateToolbar();

      };

            Unassigned Unassigned
            delphine Delphine Gavalda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: