Title: Office Editor - Font Size Changes Automatically When Typing in DOCX Tables (Need to Force Default Font)

I’m using WebViewer with Office Editor enabled to edit DOCX files in an Angular application. I’m experiencing an issue where the font size automatically changes when typing in different parts of the document, particularly in tables.

Problem:

  • When I click in different cells of a table and start typing, the font size changes to whatever is defined in the document’s existing styles (e.g., 5pt, 7pt, 9pt)

  • I want to force ALL new text input to always use Arial 12pt, regardless of the cursor position or existing document styles

  • The document contains tables with embedded run-level font styles that override my cursor settings

What I’ve Tried:

  1. Using setMainCursorStyle in cursorsReady event:

typescript

doc.addEventListener('cursorsReady', () => {
    const officeEditor = doc.getOfficeEditor();
    officeEditor.setMainCursorStyle({
        fontFace: 'Arial',
        pointSize: 12,
    });
});This only works for the initial cursor position but doesn't prevent font inheritance when clicking on existing text with different styles.Adding event listeners for cursor and selection changes:

typescriptdoc.addEventListener('cursorPropertiesUpdated', () => {
    officeEditor.setMainCursorStyle({
        fontFace: 'Arial',
        pointSize: 12,
    });
});

doc.addEventListener('selectionPropertiesUpdated', () => {
    officeEditor.updateSelectionStyle({
        'font-family': 'Arial',
        'font-size': '12pt'
    });
});
Still doesn't prevent the font from changing when typing in table cells with existing small font sizes.

Question:
What is the correct way to force Office Editor to always use a specific default font (Arial 12pt) for all new text input, regardless of the existing document styles or cursor position? Is there a way to override the document's embedded run-level styles or prevent font inheritance from existing text?
The desired behavior is that when a user types anywhere in the document (including in table cells with different font styles), the new text should always be Arial 12pt.

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


You’re experiencing issues with maintaining a consistent font size and style when typing in DOCX tables using WebViewer’s Office Editor in an Angular application. The problem arises due to the document’s existing styles, particularly in tables, which override your desired font settings.

Some things you can try:

  • Use the setDefaultFont method to set a default font for any new text input. This should help enforce Arial 12pt as the default.

  • Override document styles by programmatically applying a consistent style after any user input. Use event listeners to detect typing or changes and apply your desired style.

  • Consider modifying the document template to remove or standardize embedded styles, ensuring that your desired style is applied consistently from the start.

  • Explore applying a global style override at the document level, ensuring that specific styles are applied across all elements, including tables.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

Hi there,

Tables in DOCX editors have limited space, and the font will auto size to fit inside of the table cell.

If you would like to use the same font size for all the cells in the table, you can change the font size of that table to your specific font size.

For example, if you create a table in our office-editor demo, it will have a cell font-size of 10:

You can select your table and set the font size to another, i.e. 12:

Then the font size for the cell will be 12:

Best regards,

Kevin