Pasting Images into XPages CKEditor

Programs like ‘Snipping Tool’ on Windows, are super useful for users to make a quick snapshot, do some quick markup on the image, paste into chat/email and send.

Unfortunately when using the default configuration of CKEditor in XPages (the inputRichText control), support for pasting images is not available for all browsers, and even for the ones that do support it, the images are only pasted as a PNG data URI. I have explained data URI images in a previous post, so check that out if you are unfamiliar with it.

This also means the pasted images will not display properly in Some versions of IBM Notes client, and also if you are using the content of the inputRichText for sending email content, the pasted images will also not display in the majority of webmail / email clients. This will result in a lot of replies from recipients along the lines of “I can’t see any images’.

My major project recently has been a webmail interface for XPages, and accordingly I needed to solve this problem to make the users happy!

From first solution to Current solution

The solution to this problem, was to intercept the image paste event and instead of creating the data URI image, it uploads the image via the same mechanism that is used for the standard ‘image button’ on the CKEditor toolbar. This involves posting the image data to a URL and interpreting the ‘success’ response, and then inserting the corresponding ‘<img>’ tag into the editor content.

The first solution I came up was a modification of the free imagepaste CKEditor plugin by Alfonso Martinez de Lizarrondo. Unfortunately this solution only worked for Firefox. So it was a good start but not completely useful because some users preferred to use Chrome.

Alfonso had also released a paid plugin called SimpleUploads, which included support for other browsers such as Chrome and Internet Explorer. So I purchased this plugin and ripped the parts out of it that were needed to support chrome and internet explorer, and modified my existing solution.

This was great for me! Now my users could paste from Firefox, Chrome and Internet Explorer. However I could not share this solution on my blog because it included source code from the plugin that I purchased. The plugin is not licensed as Open Source, so this would not be within my rights to do so.

So when a stackoverflow user had the same problem,  I decided to amend the solution so that I could share it whilst respecting the licensing conditions of the original plugin author.

Alfonso had actually already included some callback functions which allowed customisation of the simpleuploads plugin. It turns out I could actually reconfigure my solution to be an ‘extension’ of the simpleuploads plugin.

I modified the solution to use the callbacks and it was almost perfect, but I just needed Alfonso to make 1 minor change to the SimpleUploads plugin. He agreed to make the change and his latest version of SimpleUploads includes the modification to allow my solution to work.

The Solution

Obtain SimpleUploads

So as mentioned above, you will need to purchase the SimpleUploads plugin and make sure you have the latest version or at least verson 4.4.4

It starts at 10 Euros for a single site licence.

  • If you are a new customer you will automatically receive the latest version.
  • If you had previously bought SimpleUploads you may need to request the latest version from Alfonso. Alfonso has not pushed the new version out to his customer mailing list yet as the change is not significant for other users.

Install SimpleUploads

Once you have obtained the simple uploads plugin, put it in your WEB-INF directory of the NSF

Create a new Javascript library in your nsf

This library will configure CKEditor to know the whereabouts of simpleuploads plugin, and also include the necessary extensions to simpleuploads to allow it to work with XPages.

I have called it ‘xspSimpleUploads’

Here are the contents of the library:

Configure your XPage and Ckeditor

You must include the Script Library on your xpage, and you must tell your CKeditor to use simpleuploads via the extraPlugins dojoAttribute

Here is an example page that I am using with the key points highlighted.


Your users should be able to paste images with no worries!

As usual, I am sure I haven’t thought of everything so if you have any problems with the above, then please let me know!


As requested by Timothy Briley, here is a demonstration video which demonstrates the problem and shows the steps to implement the solution.

You may also like...

25 Responses

  1. Timothy Briley says:


    Any chance you could put up a demo on Youtube?

  2. Hi Cameron, I got an invalidStateError in Internet Explorer 11 which prevented pasting of the image. I fixed it by removing the line where the xhr responseType is set ( = ‘document’;) – see for a similar error.

    Do you get the same error with IE?

    • camerongregor says:

      Sorry for the delayed response. Yeah that seems to make sense.
      Basically, the xpages code sends the response in a xml format which is responseType = ‘document’. So I had asked Alfonso to make SimpleUploads use a pre-created xhr object so that I could set the response type to document. This seems to cause the problem you say, because it looks like the error is caused if you set responseType before the ‘open’ method call.

      There is some code in my solution (lines 64-72) above that falls back to the default ‘json’ response type, in which it will treat the response a a single string, extract the contents of a particular part using regex. I think this woks just fine and sounds like it is more reliable solution (thanks to IE!) I just did the document response way because it was more ‘correct’

      Thanks for pointing this out, I hope that anyone else with this problem will see this. Does you commented out solution work ok with chrome / firefox? if so I will update the code above to comment it out as well

  3. Oliver Busse says:

    Hi Cameron!
    I just installed the plugin but getting a problem:
    I first also had to comment out the line Per already mentioned. Now I have a problem in line 71 of your code which tries to read – the responseText is just not in the xhr object (not shown in Chrome debugger). It seems that the response is empty though the response URL points to a valid resource – the server computed it as expected. So far the solution is not usable. Running 9.0.1FP7 if this is important.
    Any ideas?

    • camerongregor says:

      Hi Oliver, sorry it’s not working yet
      What properties are in the xhr object? e.g. add a logging statement just before trying to use responseText

      Also what if you look at the ‘network’ tab of Chrome Debugger, is there anything in the response for that related XHR network call?

      • Oliver Busse says:

        It’s working on a plain Xpage, so it’s the same problem we have on our app in general with adding images also via the toolbar button.
        BTW: it also won’t work w/o a datasource attached to the richtext control, as the response from the XHR request will be a “500 command not handled exception”. I guess it’s the $$-stuff that is submitted to the server and the server not knowing what to do with it.

  4. Sridhar says:

    I brought a plugin from simpleuploads
    I’m using Notes 9.0.1
    I have obtained the simple uploads plugin, and put it in my WEB-INF directory of the NSF
    Created a Javascript script library ‘xspSimpleUploads’
    Created a xpage with richtext field and added Dojo attribute “extraPlugins” “simpleuploads added JS library to xpages resources
    When I tried to see the result, nothing is happening,
    did I miss anything here ???

  5. Sridhar says:


    I followed every step you mentioned in this blog, but it is not working in IE11 but working fine in Google Chrome, Any suggestions on how to make it work on IE11, because all my users use IE11


    • camerongregor says:

      Hi Sridhar, sorry for the slow response! Did you read Per’s comment regarding IE 11 ? have you tried his suggestion?

      • Sridhar says:

        Hi Cameron,

        I tried that suggestion, still not working, is there any browser security settings i need to change ?


  6. May says:

    Hi Cameron, as I can see your CKeditor is different then mine. I can’t paste an image in my body. Can you tell me which version of CKeditor you have and how you update it on the server please.

  7. May says:

    Hi Cameron, the CKeditor I have doesn’t do anything when I copy paste an image did you change your version of CKeditor on Notes Server ? If yes, which version you used and how you update on server.

    Thank you

    • camerongregor says:

      Hi May,
      I am using the CKEditor that is there by default for Domino Server (I have not upgraded the version). Currently using Domino 9.0.1 FP7
      What version of Domino are you using? which Browser are you using to paste the images?

      • May says:

        Hi Cameron,

        I’m using Domino 9.0.1 FP9 and the version of CKEditor is I have an XPages with an inputRichText and when I try to copy paste an image from Snipping Tool is not doing anything with Firefox version 52.9.0. Do I do something wrong .

        My other question is when I open an existing document with a mime on the browser, all image doesn’t show on the inputRichText. Do you have an idea.

        Thank you

      • May says:

        Hi Cameron

        I found what was the problem, I had in my “xsp.client.script.dojo.html5attr=true” and that cause problem so I removed it. I bought the simpleuploads plugins and that work great.

        • camerongregor says:

          That is Fantastic May I am glad you have found a solution. Sorry I was not of much help.
          Thank you for posting this so that others may also benefit if they have the same problem
          I am glad the plugin is working for you!

  8. May says:

    Hi Cameron,

    for my second question here is the details of what I see with your Mime Inspector maybe that will help you to help me.

    Has Embbeded Images to Save Yes
    Has Attachments to Save No
    Is Mime Yes
    Is Discarded Yes

    multipart/relatedEncoding:no encoding header
    multipart/alternativeEncoding:no encoding header
    image/jpegDisposition:inline; filename=”craft_beer_1800.jpg”; size=179021;creation-date=”Thu, 21 Jun 2018 11:47:32 GMT”;modification-date=”Thu, 21 Jun 2018 11:47:32 GMT”Encoding:binary



  9. Tali Berzins says:


    Is Swiper going to be compatible with version 10 Notes/Domino? Thank you, Tali

    • camerongregor says:

      Hi Tali, I haven’t tried it with version 10 yet but I will ask around and see if it is working for those who have been beta testing it

  10. May says:

    Hi Cameron

    I bought the plugins SimpleUpload and work well with your code, but I can’t configure to get work the copy paste image and add file in the same CKeditor. What I need to add in your code to make the add file work ? Thanks you May

Leave a Reply

Your email address will not be published. Required fields are marked *