Support Article
Avoid pasting images in rich text editor (RTE)
SA-23988
Summary
Images to be pasted in RTE must be suppressed.
Error Messages
Not Applicable
Steps to Reproduce
1. Open a work object where RTE exists.
2. Paste HTML with images from Outlook or Word document.
3. Notice the images are pasted.
Root Cause
It is an expected behavior. In Pega 7.x implementation CKEditor is used, hence RTE is allowed to paste images. In PRPC 6.x, YUI editor is used, hence the image was suppressed while pasting into RTE.
Resolution
Perform the following local-change:
Include the code below in USERWORKFORM (or create an non-auto generated section and use this section where images must not be pasted in RTE.)
<script>
$(document).ready(function(){
setTimeout(function(){
if(window.CKEDITOR) {
for ( var ck_instance in window.CKEDITOR.instances ){
var cke=window.CKEDITOR.instances[ck_instance];
cke.on('paste', function(evt) {
if(evt.data.dataValue.indexOf("<img")>-1) {
var pData=evt.data.dataValue;
var count = (pData.match(/<img/g) || []).length;
while(count>0)
{
var rImgText=pData.split("<img")[1].split(">")[0];
rImgText="<img"+rImgText+">";
pData=pData.replace(rImgText,"");
count--;
}
evt.data.dataValue=pData;
}
});
}}
},50);
});
</script>
Published June 2, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.