Opened 13 years ago

Closed 11 years ago

#629 closed defect (no action needed)

clearFonts function that removes font tags and spans

Reported by: mharrisonline Owned by: gogo
Priority: low Milestone: 0.96
Component: Xinha Core Version:
Severity: normal Keywords:
Cc:

Description

I wanted my clear fonts button to also offer to remove all font tags, as well as all spans, which are often added when Word documents are pasted in. This is what I did:

HTMLArea.prototype._clearFonts = function() {
  var D = this.getInnerHTML();

  if(confirm(HTMLArea._lc("Would you like to remove all font tags?")))
  {
	D = D.replace(/<\/?\s*FONT[^>]*>/gi, "" );
  }
  
  if(confirm(HTMLArea._lc("Would you like to clear font typefaces in spans and other tags? These are often created when text is pasted from Microsoft Word.")))
  {
    D = D.replace(/face="[^"]*"/gi, '');
    D = D.replace(/font-family:[^;}"']+;?/gi, '');
  }

  if(confirm(HTMLArea._lc("Would you like to clear all font sizes in spans and other tags? These are often created when text is pasted from Microsoft Word.")))
  {
    D = D.replace(/size="[^"]*"/gi, '');
    D = D.replace(/font-size:[^;}"']+;?/gi, '');
  }

  if(confirm(HTMLArea._lc("Would you like to clear all font colors in spans and other tags? These are often created when text is pasted from Microsoft Word.")))
  {
    D = D.replace(/color="[^"]*"/gi, '');
    D = D.replace(/([^-])color:[^;}"']+;?/gi, '$1');
  }
  if(confirm(HTMLArea._lc("Would you like to remove all span tags? These are often created when text is pasted from Microsoft Word.")))
  {
	D = D.replace(/<\/?\s*SPAN[^>]*>/gi, "" );
  }
  D = D.replace(/(style|class)="\s*"/gi, '');
  D = D.replace(/<(font|span)\s*>/gi, '');
  this.setHTML(D);
  this.updateToolbar();
};

Change History (2)

comment:1 Changed 11 years ago by ray

  • Milestone set to 0.96

comment:2 Changed 11 years ago by douglas

  • Resolution set to no action needed
  • Status changed from new to closed

Word cleaning is now in Xinha, no action needed

Note: See TracTickets for help on using tickets.