Ticket #629 (closed defect: no action needed)

Opened 7 years ago

Last modified 5 years ago

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

Changed 5 years ago by ray

  • milestone set to 0.96

Changed 5 years ago by douglas

  • status changed from new to closed
  • resolution set to no action needed

Word cleaning is now in Xinha, no action needed

Note: See TracTickets for help on using tickets.