Prevent a user removing Bookmarks and Section Breaks

I'd really like to be able to have a word document in the Blazor Document Editor which is split up into Sections, each section marked by a bookmark. I'd want to be able to manage the Sections (and bookmarks) programatically (adding and removing Sections based on business logic within the application) and only allow the user to edit the content within the sections - but at the moment, although I can add bookmarks and section breaks using the EditorModule I can't find a way to prevent the user just pressing backspace and removing them - or making a selection over a section break and cutting or pasting over them which destroys them.

I looked at the Restrict Editing options to see if I could make special sections that a user could edit but this seems to be limited to fields or totally read-only.
Is there a reliable and safe way to protect section breaks and both prevent a user removing them and also prevent them adding more by pasting Word content that has them embedded?

As an alternative - I could make each 'section' it's own document (which would get around the issue of the user accidentally joining two sections by deleting the section break) but then I don't know how I'd be able to present them as if they were a single document from a UI perspective - perhaps some clever switch document logic at the edges?)

Any thoughts or ideas would be appreciated

Cheers,

Tim


6 Replies 1 reply marked as answer

KB Kurthis Banu Abdul Majeeth Syncfusion Team February 18, 2021 05:34 PM UTC

Hi Kaine, 

Regarding: Restrict Editing options to only allow the user to edit the content within the sections 

Document Editor having support for your requirement. 

Please, refer the below link for protect document from different users: 

Regarding: How to add the user and protected from different users: 


Regarding: Customized Demo sample working functionalities  



Explanation about Customized Demo sample working functionalities : 
Document editor opens a protected document that includes permitted ranges for two users identified by email: each user is authorized to edit a separate text area. 
You can switch between the current user to edit different parts by selecting dropdown list in User permissions pane. 
User can add the user in dropdown who have editing permission in document by using addItem method. 
The range that is enabled for the current user is highlighted. 
You can disable the highlighting or customize its color using the corresponding demo’s elements. 


For your reference: 
you can navigate the edit region using the option FIND NEXT REGION I CAN EDIT  
You can saw the possible edit region also using the option SHOW ALL REGION I CAN EDIT 
Note: Validate username format: (e.g) [email protected] 



You can get the customization sample code from source tap in the demo link .please refer below screenshot also. 

 

Regards, 
Kurthis Banu A. 



Marked as answer

KA Kaine February 18, 2021 06:07 PM UTC

Hi,

Thank you for the quick response - this looks like it could be useful.

How can I set the protected areas programatically?

If I add a new section using the InsertSectionBreak() method on the EditorModule class I would also need to make the content within that section editable by the user without needing a manager user to log in and edit the protected areas through the GUI.

Many thanks,

Tim



KB Kurthis Banu Abdul Majeeth Syncfusion Team February 21, 2021 04:12 PM UTC

Hi Kaine,  

Code snippet for restrict editing:  

// To select current bookmark 
 container.GetDocumentEditor().GetSelection().SelectBookmark("BookmarkName"); 
  // To select current paragraph        
container.GetDocumentEditor().GetSelection().SelectParagraph(); 

//When the document is protected allows to edit the selected content. “Everyone” is allowed to edit.  
            
container.GetDocumentEditor().GetEditor().InsertEditingRegion(); 

// You can use the currentUser property to authorize the current document user by name, email, or user group name. 
container.GetDocumentEditor().CurrentUser = "[email protected]"; 


// Enforce document protection have to specify password, whether to limit formatting or not, whether isReadOnly or not  

container. GetDocumentEditor().GetEditor().EnforceProtection("123", ProtectionType.NoProtection); 

//stop the document protection  
container.GetDocumentEditor().GetEditor().StopProtection("123"); 


To navigate within edit region, make use of below API  
container. GetDocumentEditor().GetSelection().ShowAllEditingRegion(); 

container. GetDocumentEditor().GetSelection().NavigateToNextEditingRegion(); 


 
       
  
For your reference java script documentation link: 



Regards, 
Kurthis Banu A. 



KA Kaine February 26, 2021 08:54 PM UTC

Great! That's very helpful thank you.

I notice while exploring the API documentation that there are some methods that are in the JavaScript API that are not currently exposed to the Blazor components. (I'm currently using (18.4.0.44)

For example, the Editor has a JavaScript method for DeleteBookmark (which would be very useful for my use case) that does not appear on the EditorModule in c#. The InsertBookmark is there and the SelectBookmark appears on the SelectionModule class, but the DeleteBookmark is not exposed to the Blazor component.

Has DeleteBookmark been moved to some other C# class or is this just not implemented in the Blazor library? If it is not implemented is there a plan to implement it? Alternately, is there a guide for using JavaScript Interop from Blazor to access API functions that are not implemented in the Blazor components?

Cheers,

Tim



SM Suriya Murugan Syncfusion Team March 1, 2021 12:45 PM UTC

Hi Tim, 

Syncfusion Greetings! 

We have planned to include the requested API in Blazor environment. We will include it in our 2021 Volume 1 release which is tentatively scheduled on mid of March 2021. 

Regards, 
Suriya M. 



SM Suriya Murugan Syncfusion Team April 8, 2021 04:03 AM UTC

Hi Tim Kaine, 

We are glad to announce that our Essential studio 2021 Volume 1 main release v19.1.0.54 and we have included API for deleting bookmark in it. Please find the API details below. 

container.DocumentEditor.Editor.DeleteBookmark("<<BookmarkName>>"); 

Regards, 
Suriya M. 


Loader.
Up arrow icon