Disabling drag and drop functionality within TinyMCE

Vote:
 

Hello,

I need to disable the ability to drag and drop media files (or indeed any files) into the tinyMCE editor, I have added the following code which is based on the following documentation but it doesn't look to do anything at all, and I am still able to drag and drop.

                .AddPlugin("paste", (settings, content, propertyName) =>
                {
                    settings["paste_block_drop"] = true;
                })

The above was taken based on the following TinyMCE documentation

paste_block_drop

Due to browser limitations, it is not possible to filter content that is dragged and dropped into the editor. When paste_block_drop is set to true the plugin will disable drag and dropping content into the editor. This prevents the unfiltered content from being introduced. Copy and paste is still enabled.

Default value: false

Possible values: true, false

Does anyone have any idea why this is not working, or has someone else implemented the required functionality in the same/different manner.

#286664
Sep 05, 2022 14:56
Vote:
 

Optimizely CMS unfortunately used TinyMCE v4 which does not have this function.  The v4 docs are here: https://www.tiny.cloud/docs-4x/plugins/paste/#options

You may be able to get some of the desired effects with the paste_as_text and paste_data_images but you will need to experiment with these and see if this causes more issues for the CMS editors.

#286703
Sep 06, 2022 7:54
Vote:
 

Thanks for that Mark, I completely missed I was looking at the wrong version. I have tried instead to use paste_as_text and paste_data_images but it seems to have no effect and does not disable the drag and drop of media items

                .AddPlugin("paste", (settings, content, propertyName) =>
                {
                    settings["paste_data_images"] = false;
                    settings["paste_as_text"] = true;
                })

Does anyone have any further ideas as to how I can go about disabling drag and drop in the tinyMCE editor??

#286704
Sep 06, 2022 8:04
Vote:
 

You can use an editor descriptor to set the allowed types (AllowedTypes attribute does not work for XhtmlString). The example below makes so that only pages can be dragged and dropped into the text.

[EditorDescriptorRegistration(TargetType = typeof(XhtmlString), EditorDescriptorBehavior = EditorDescriptorBehavior.Default)]
public class XhtmlStringsEditorDescriptor : EditorDescriptor
{
    public XhtmlStringsEditorDescriptor()
    {
        AllowedTypes = new[] { typeof(PageData) };
    }
}
#286752
Edited, Sep 07, 2022 7:14
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.