Expand my Community achievements bar.

RTE CTRL+V copying inline styles

Avatar

Level 4

Hi Everyone,

When i copy the content from browser and then to notepad, notepad++ to rich 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...

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

These are the two styles which is getting added to <p> tag when pasting from notepad.

AEM version:5.6.1

Any help would be greatly appreciated.

 

Thanks 

Mini

6 Replies

Avatar

Administrator

Try this:

Copy: Ctrl + C

Paste : Ctrl + Shift + V

~kautuk



Kautuk Sahni

Avatar

Level 3

 ctrl+v needs to be handled explicitly. Or you can use following alternative.

1. Enable "Paste as text" plugin in RTE

2. While copying single paragraph use Paste as text plugin (it will not copy any styles)

3. While copying multiple paragraphs use ctrl + v and paste in the RTE directly. Do not use "Paste as text" plugin while copying multiple paragraphs as it will add <br> tags

Avatar

Level 7

Try adding a property "removeSingleParagraphContainer = {String}true (Not boolean property)

at the node where xtype=rte.

regards,

Ankur

Avatar

Administrator

Adding more references to Ankur's reply:

Please have a look at:-

Link:- https://mkbansal.wordpress.com/2016/01/02/aem-rte-remove-p-tag/

Link:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

// Remove <p> in richtext in touch UI

 The default behavior of AEM generates those <p> tags and can only be removed if you author only one paragraph by adding property removeSingleParagraphContainer suggested above

 

~kautuk



Kautuk Sahni

Avatar

Level 4

Hi Kautuk,

    This will work only for single paragraph. I need to remove it for multiple paragraphs.

Thanks 

Mini

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