Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
igHtmlEditor disable images
posted

Hi Infragistics,

Is there a way to disable inserting images into the rich text editor?
Even when the toolbar button is hidden users can still copy-paste or drag-and-drop images.

Parents
No Data
Reply
  • 1300
    Verified Answer
    Offline posted

    Hello Ben,

    After investigating this further, I have determined that when an image is being pasted on the htmlEditor the event could not be canceled, since the image is already in the editor.

    However, what I could suggest is binding a method to the paste event of the editor and checking if an image is being pasted. If yes, the image could be removed as follows:

    paste: function (evt, ui) {

                        setTimeout(() => {

                            let img = ui.owner.workspace.contentDocument.images[0];

                            let length = ui.owner.workspace.contentDocument.images.length;

                            if (img) {

                                for(let i = 0; i < length; i++) {

                                    ui.owner.workspace.contentDocument.images[0].remove();

                                }

                            }

                        }, 0);

                    },

    Regarding the drag and drop in the igHtmlEditor, a method could be bound to the drop event of the contentDocument and could be canceled as below:

    $("#htmlEditor").igHtmlEditor({

                . . .

                rendered: function (evt, ui) {

                     $(ui.owner.workspace.contentDocument).on({

                          'drop': handleFileDrop,

                     });

                },

    . . .

    function handleFileDrop(evt) {

         evt.preventDefault();

     }

    Please let me know if you need any further information regarding this matter.

    Regards,
    Monika Kirkova,
    Infragistics

Children
No Data