Drag and drop text on editor with restricting edit zone

Hello,

I set up a drag and drop in the document editor.

It works well but I manage to drop some text in an area protected by a password and therefore in principle not editable...

Here's a code snippet:

   onDrop (event) {
   
     console.log (`Drop content`, event)

     var text = event.dataTransfer.getData ('Text'). replace (/ \ n / g, '') .replace (/ \ r / g, '') .replace (/ \ r \ n / g, '' )

     this.documenteditorcontainer.documentEditor.selection.select ({x: event.offsetX, y: event.offsetY, extend: false})

     this.documenteditorcontainer.documentEditor.editor.insertText (text)

   }

Thank you in advance for your response.

Regards,

Christophe

6 Replies 1 reply marked as answer

SM Suriya Murugan Syncfusion Team August 17, 2020 01:02 PM UTC

Hi Christophe, 
 
 
When you drag and drop a content, the dragged content will be inserted in the current cursor position, if the cursor position is inside the non-editable region, the dragged content will not be inserted since the cursor is in non-editable region. But this behavior works fine when you insert inside a editable region. 
 
But using select and insertText API, you can insert the text in non-editable region. 
 
 
Regards, 

Suriya M. 



CD Christophe Deladrier August 21, 2020 01:59 PM UTC

Hello Suriya,

Thanks for your feedback.

Is it possible to check with an existing function the position of the cursor in order to validate that the cursor is not in a non-editable zone before doing an insertText ?

Regards,

Christophe


SM Suriya Murugan Syncfusion Team August 24, 2020 11:47 AM UTC

Hi Christophe, 
 
Internally, we have API to check selection is in editable region. We have planned to expose it as public for your requirement. We will include it in our EJ2 patch release which scheduled on September 2,2020. 
 
You can track the status through below link: 
 
 
Regards, 
 
Suriya M. 
 
 
 



CD Christophe Deladrier August 24, 2020 12:41 PM UTC

Hi Suriya,

Perfect !

Thanks a lot.

Regards,

Christophe


HC Harini Chellappa Syncfusion Team August 25, 2020 05:16 AM UTC

Hi Christophe, 
 
Most welcome. Will update once included. 
 
Regards, 
 
Harini C 



SR Stephen Raj Chandra Sekar Syncfusion Team December 18, 2020 06:47 AM UTC

Hi Christophe, 
 
We are glad to announce that our 2020 Volume 4 release v18.4.0.30  is rolled out successfully and exposed isSelectionIsAtEditRegion API to public in this release. 
 
Kindly upgrade your NPM packages to latest version to resolve the reported issue. 
 
 
Usage of API 
containerInstance.documentEditor.selection.isSelectionInEditRegion(); 
 
Regards, 
Stephen Raj

Marked as answer
Loader.
Up arrow icon