Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

RTE edit plugin issue

Avatar

Level 3

Hello,

When i copy the content from notepad, notepad++ to rixh text, by default tool is adding font family to p tag. How to avoid adding style attribute to P tag when content is copied from browser, notepad etc...

I added edit plugin (features are blank array, defaultPasteMode="plaintext"), but no luck.

AEM version: 6.0 with SP2

Appreciated for quick response.

5 Replies

Avatar

Level 10

IN the docs - it states: 

STYLES (TEXT)

Styles affect the appearance of a portion of text, from a single character upwards. They are based on CSS classes (already existing in your CSS stylesheet); as they enclose a portion of text within span tags using the class attribute to reference the CSS class. For example:

    <span class=monospaced>Monospaced Text Here</span>

To enable styles for selection in the dialog you:

  • enable the Style drop-down selector by enabling the plugin
  • specify the location(s) of the stylesheet(s) you want to reference
  • specify the individual styles that can be selected from the Style drop down list

So using Styles plug-in you can reference a CSS that specifies the font type you want to use. 

https://docs.adobe.com/docs/en/aem/6-0/administer/operations/page-authoring/rich-text-editor.html

Avatar

Level 3

I dont want to add any style attribute. Just wanted to avoid the style tag which is added by default when content is copied from notepad ++. 

How can i avoid OOTB style addition?

Avatar

Level 10

Is it adding the style even if you copy from the notepad ?? 

Most of the times, copying from textpad, notepad or word would come along with these styles with it. I would say, you can write a quick listener before saving to remove/clean these styles

Avatar

Level 3

Yes. style attribute added to p tag as below

<p style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">

Avatar

Former Community Member

Try Applying the Following Listener under "Dialog" of that component and use the property "beforesubmit" it will surely Work 100% 

 

 

function(dialog)
{


var i;

for (i = 0; dialog.findByType("richtext", true)[i]="undefined"; i++) { 

var rte = dialog.findByType("richtext", true)[i];


var para=rte.getName();


var text=dialog.getField(para).getValue();


var final=text.split("font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;").join("");


dialog.getField(para).setValue(final);

}

}

 

 

 

Thanks,

Nikhil Kumar