We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changing heading level programatically

I am trying to change the selected text heading level programatically.. like applying "normal" or "heading 1" or heading 2. etc

 Any help much appreciated.

Thank you

1 Reply

SM Suriya Murugan Syncfusion Team February 22, 2019 10:14 AM UTC

Hi Sampurnima, 
  
Thanks for contacting Syncfusion support. 

In our DocumentEditor control, we have some predefined set of styles such as 'Normal', 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6'. You can apply these styles to selected text by using ‘applyStyle()’ method of Editor module. Please find the sample code to apply predefined styles to selected text.  

Sample Code: 
//Apply Normal style 
documenteditor.editor.applyStyle("Normal"); 
//Apply Heading 1 style 
documenteditor.editor.applyStyle("Heading 1"); 
//Apply Heading 2 style 
documenteditor.editor.applyStyle("Heading 2"); 
//Apply Heading 3 style 
documenteditor.editor.applyStyle("Heading 3"); 
//Apply Heading 4 style 
documenteditor.editor.applyStyle("Heading 4"); 
//Apply Heading 5 style 
documenteditor.editor.applyStyle("Heading 5"); 
//Apply Heading 6 style 
documenteditor.editor.applyStyle("Heading 6"); 

And we also have support for adding custom styles in DocumentEditor. Please find the step to define a new style and apply it in document editor from below documentation link. 



Regards, 

Suriya M. 


Loader.
Live Chat Icon For mobile
Up arrow icon