How to override heading styles

How can we override the output style of these headings:
And if overriding is not possible, how can we create new headings with custom styles?


Sample output:

I was able to create a new style for paragraph & character but they were not treated as a heading:

    document.editor.createStyle(JSON.stringify(customHeadigStyle));
    document.editorModule.applyStyle(selectedStyle.name);


And when I try to add table of contents, it was not recognized as a heading:




18 Replies

SM Suriya Murugan Syncfusion Team May 16, 2022 01:19 PM UTC

Hi Deejay,


You can manually override the style by following below steps:


  1. Click manage style options in dropdown.

Graphical user interface, text, application

Description automatically generated

  1. Dialog will open. Select the style which you want to modify and then click Modify options.

Graphical user interface, text, application

Description automatically generated

  1. Here, you can change the format based on your requirement and then click ok button.

  2. Now, apply style and respective heading style will apply.

Please let us know whether this satisfied your requirement.


Regards,

Suriya M.



DE Deejay replied to Suriya Murugan May 16, 2022 11:09 PM UTC

Our Concern:


Apologies for the confusion. 

So basically we have implemented our own heading dropdown.

And the way we apply heading is using:

document.editorModule.applyStyle('Heading 1'); ​// If user has selected Heading 1 from the dropdown


Our problem is that, when we do this, text font style for the selected text would automatically be converted to Calibri Light​ regardless of the font style it has. 


We also want that when user selects Heading 1, we can apply our own custom style for heading 1
without the user going through another process of converting that heading's style to something else.

As of now, this is what we are doing:

Unfortunately, the converted text is not recognized as a heading, but just a text with a custom font styles.



After testing it again, here's my new findings:

Steps to replicate:

  1. Go to this demo
  2. Make sure to clear everything from the document
  3. Type something like "Hello World". Notice that the font style is Calibri by default
  4. Select and highlight "Hello World"  
  5. Select Headng 1 from dropdown
  6. Notice that the font style is now Calibri Light

But if you change the font style before converting text to Heading 1 the font style will remain.
Steps to reproduce:
  1. Go to this demo
  2. Make sure to clear everything from the document
  3. Type something like "Hello World". Notice that the font style is Calibri by default
  4. Change Font Style to Arial
  5. Select and highlight "Hello World"  
  6. Select Headng 1 from dropdown
  7. Notice that the font style is still Arial


Our Setup:

  • @syncfusion/ej2-react-documenteditor v20.1.51

  • Default character & paragraph format:



SM Suriya Murugan Syncfusion Team May 18, 2022 03:53 AM UTC

Hi Deejay,


We will check and update details shortly.


Regards,

Suriya M.



AE Ajithamarlin Edward Syncfusion Team May 18, 2022 02:23 PM UTC

HI Deejay,


We can able to reproduce the reported issue. Currently, we are validating the issue and get back to you with more details by May 20,2022.


Regards,

Ajithamarlin E



SM Suriya Murugan Syncfusion Team May 24, 2022 05:28 AM UTC

Hi Deejay,


We need additional timeline to check this issue and will update details by May 24, 2022.


Regards,

Suriya M.



AE Ajithamarlin Edward Syncfusion Team May 24, 2022 04:47 PM UTC

HI Deejay,


We have confirmed the reported issue as a defect and logged a defect report. We will fix this issue in our EJ2 patch release which is scheduled for June 14,2022.  


You can track the status of the bug through the below feedback link:

https://www.syncfusion.com/feedback/35146/resolve-the-character-formatting-issue-on-changing-from-normal-to-heading-1-for



Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”


Regards,

Ajithamarlin E



SM Suriya Murugan Syncfusion Team June 14, 2022 11:54 AM UTC

Hi Deejay,



Sorry for the inconvenience.


We are not possible to include the fix for reported issue in our latest patch release. We will include this fix in our 2022 volume 2 main release which is scheduled for end of June 2022.


You can track the status of the bug through the below feedback link:

https://www.syncfusion.com/feedback/35146/resolve-the-character-formatting-issue-on-changing-from-normal-to-heading-1-for


Regards,

Suriya M.



AE Ajithamarlin Edward Syncfusion Team July 1, 2022 02:46 PM UTC

Hi Deejay,


Sorry for the inconvenience.


We are not possible to include the fix for reported issue in our ​2022 volume 2 main release. We will include this fix in our next EJ2 weekly patch release which is scheduled for July 20, 2022.


Regards,

Ajithamarlin E



DE Deejay July 25, 2022 01:09 AM UTC

Hi  Ajithamarlin Edward,

Btw any updates on this? 

Thanks,


Regards,
Deejay



SM Suriya Murugan Syncfusion Team July 25, 2022 11:04 AM UTC

Hi Deejay,


We are glad to announce that our patch release (v20.2.39) is rolled out successfully. In this release, we have added the fix for the reported issue.


Please upgrade to the latest version packages to resolve this issue. 

https://www.npmjs.com/package/@syncfusion/ej2-documenteditor

https://www.npmjs.com/package/@syncfusion/ej2-react-documenteditor


Please let us know if you need any further assistance.


Regards,

Suriya M.



DE Deejay July 25, 2022 11:55 PM UTC

Hi  Suriya Murugan, 

I just tested this today, the bug was fixed. Thanks

But can you share to us how to override heading styles? or create a custom heading?

I tried this, thinking I can override the styles for heading, but it does not work.

   
const selectedStyle = {
  type: 'Paragraph',
  basedOn: 'Normal',
// If I renamed the name to something else, I'm able to insert new custom style,
// but it is not recognized as a heading.
// The way I know is when Insert table of contents, // It would complain that no heading is found in
  name: 'Heading 1',
  characterFormat: {
    fontSize: 16,
    fontFamily: defaultFontFamily,
    fontColor: documentEditorDefaults.fontColor, // just some color
    bold: true,
    italic: false,
    underline: 'None',
  }
}
documentEditor.editor.createStyle(JSON.stringify(selectedStyle));
    documentEditor.editorModule.applyStyle(selectedStyle.name);


SM Suriya Murugan Syncfusion Team July 27, 2022 04:19 AM UTC

Hi Deejay,


We are checking your requirement and will update details by July 27, 2022.


Regards,

Suriya M.



SM Suriya Murugan Syncfusion Team August 2, 2022 03:23 AM UTC

Hi Deejay,


Please find the Create Style behavior in Document editor.

  1. If you give a new style with same name(name that already exist in the document). We create a unique name for the currently given custom style and return that custom style.

  2. If your need is to have the default styles modified(Heading 1 to Heading 6). Then you can edit the needed style in document editor using the manage style or the MS Word and create a template document use that template document to open by default in the application level.


Please let us know if you need any further assistance.


Regards,

Suriya M.



DE Deejay August 25, 2022 01:18 AM UTC

Hi Suriya Murugan,

Yes I would like to modify (Heading 1 to Heading 6). But I would l like to do it through code
Basically our company is implementing our own tool & dropdown for Heading Selection

What I need is to override the default style for Heading 1
so I need to change it through code,
So when the user selects Heading 1,
it would automatically apply the new modified heading style for good user experience
Is there a way you can share a code on how to do this? I cannot find it in your docs.





SM Suriya Murugan Syncfusion Team August 26, 2022 03:53 AM UTC

Hi Deejay,


We will check and update details by August 26, 2022.


Regards,

Suriya M.



DE Deejay January 9, 2023 12:16 AM UTC

Hi Surya Murugan, any updates on this? 



KM Kavitha Muralitharan Syncfusion Team January 10, 2023 12:30 PM UTC

Deejay, We are considering this as a feature request. We will implement this and include it in 2023 volume 1 release which is expected on end of March .


Please track the status of this feature from below feedback link: https://www.syncfusion.com/feedback/40286/api-to-modify-the-predefined-styles-in-document-editor



KM Kavitha Muralitharan Syncfusion Team March 30, 2023 09:21 AM UTC

Hi deejay,


we are glad to announce that our patch release (v21.1.37)  is rolled out successfully.


In this release, we have included the Feature “API to modify the predefined styles”.



Please upgrade to the latest version packages to use this feature.


 NPM Link: (Client-side)

 https://www.npmjs.com/package/@syncfusion/ej2-documenteditor

 https://www.npmjs.com/package/@syncfusion/ej2-react-documenteditor



NuGet link: (Server-side)

 https://www.nuget.org/packages/Syncfusion.Ej2.Wordeditor.ASPNet.Core/

 https://www.nuget.org/packages/Syncfusion.Ej2.Wordeditor.ASPNet.MVC5/


Feedback Link:  https://www.syncfusion.com/feedback/40286/api-to-modify-the-predefined-styles-in-document-editor


let styleJson: any = {

"type": "Paragraph",

"name": "Heading 1",

"characterFormat": { "fontSize": 32, "fontFamily": "Calibri" }

};

documentEditor.editor.createStyle(styleName, true);



API Reference :  https://ej2.syncfusion.com/documentation/api/document-editor/editor/#createstyle


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,

Kavitha M



Loader.
Up arrow icon