Highlighted
Micro Focus Expert
Micro Focus Expert
131 views

(SM) Support Tip: Deny Pasting Images directly in the SM HTML editor control

Normally, the HTML editor does not allow to Paste images from the clipboard, but Mozilla Firefox does. When doing that, saving a KM article will take too much time, so in order to avoid this performance problem the following steps will disable that option. Take into account that when upgrading the webclient, these changes should be done again.

 

  1. Create a folder with name “stopimagepaste” under “C:\<Tomcat Installation folder>\webapps\<SM webtier version>\ckeditor\<SM webtier version>\plugins\
  2. In the folder created in the step 1, create a file with name “plugin.js”. This file will contain the following code:

// Handles image pasting in Firefox

CKEDITOR.plugins.add( 'stopimagepaste',

{

init : function( editor )

{

 

// Paste from clipboard:

editor.on( 'paste', function(e) {

 

var html = e.data.html;

if (!html)

return;

 

// Replace data&colon; images in Firefox and upload them

e.data.html = html.replace( /<img( [^>]*)?>/gi, function( img )

{

alert("Pasting images directly into the editor is not allowed. ");

return "";

});

});

 

} //Init

} );

3.  Open the config.js file located in the folder “C:\<Tomcat Installation folder>\webapps\<SM webtier version>\ckeditor\<SM webtier version>” and add the following line:

config.extraPlugins = 'stopimagepaste';

Note: Make sure this line is added after the “config.language…” line:

4.  Restart Tomcat.

5.  When trying to paste images in the html editor the following message will be displayed:

 

Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.