Styles in OnlyOffice other than paragraphs

I would like to add my request for character styles as well. They’re extremely useful. For example, I may have quotations in the middle of paragraphs and I’d like to be able to give them “Quotation” character styles so I can easily change the look of all quotations.

Hello @DavidHJameson

Thanks for your interest in this feature. I’ve added your query to the suggestion.

Another perfect example of the coolness of character styles, David, thanks for adding your voice.

In HTML, David’s example is like <q>This is a quote</q> and my (earlier) example is like <code>c = 42;</code>. Neither require a line break, separate paragraph or other “set off”.

Indeed - having used MS Word since it was originally released for DOS, I learned the Styles concept very early and have used them ever since.

Note that these days, MS Word supports more than just paragraph and character styles. List styles are particularly useful.

Hi, I know I am late, however this discussion seems still active.

Today I’ve encountered the same problem, however, it’s not that hard to workaround and I will tell you how I managed to reach the result wanted by @Bonzini , DavidHJameson ( sorry new users can’t mention more than 2 people ) and probably even more users.

It is true that if you select only a piece of text in a paragraph, then style it and then create a new style from the selection, it will color the entire paragraph ( unless you are working with a native OnlyOffice format as @crazydocs suggested ), which is unfortunate :joy: .

How to solve this ?
You can set your pointer on a random location of a paragraph, then break it with a new line to separate from the upper part of the paragraph, then write some sample words and another new line character to separate from the bottom part of the paragraph.
Subsequently select the sample text you’ve written, style it and create a new style from selection, this will only change the sample text style and leave the rest unaltered, because the sample text is by itself an entire paragraph.
Finally you can delete the sample text, and now as you would normally do you can select any text that you want to be styled with your newly created style and simply apply it.

With a similar approach you can also update your style, in this case when you write your sample text and after having applied a style to it, select it, then go to your styles right click the one you want to update and select “Update style from selection”.

Hope this has helped.

With a similar approach you can also update your style, in this case when you write your sample text and after having applied a style to it

To clarify, here with “after having applied a style”, I mean after you’ve styled it, I don’t mean that you must necessarily select a style from the ones available.

I tried your idea and I don’t think it works. For example, if I create a new “Code” style with monospaced font and gray background and create some sample text like this:

and I then edit the second version to bring it all into the text line, like this:

you can see that it’s kept the font but lost the background and style information.

You are right ! However the problem arises only when using style that define a background, because the other style attributes like font and spacing are applied correctly. This to me looks more like a bug rather than a missing functionality, it shouldn’t be hard to fix.

not just a problem with the background - the styling itself is lost. So if you change the styling afterward, the edited text that has lost its styling (because the line feed at the end is lost, I guess) won’t change.

I see my screen shot did not show that I had positioned my cursor in the edited text, but imagining it there, you can see the style has reverted to Normal (the style of the paragraph), though as you say the specific edited text is still in monospace.

Hello @mjkstra, @Bonzini

Styles are differentiated by type - paragraph style and text style. When changing existing styles you need to pay attention which one is changed to avoid situation such as when applying style to a text passage whole paragraph becomes of the same style.

I’d recommend trying to create new styles with option Same as created new style as per To create a completely new style section of this documentation:
https://helpcenter.onlyoffice.com/onlyoffice-editors/onlyoffice-document-editor/usageinstructions/formattingpresets.aspx

Also, background is not an element of the style, unfortunately, so this is expected behavior that it is not applied when specific style is selected.

If I misunderstood, please let me know.

@Constantine @mjkstra

Leaving aside the background colour for a moment, if I enter the following:

image

Into a document using Normal style, then change the code fragment to font DejaVu Sans so that it looks like this

image

and then highlight the code fragment and define a new style called I/L Code (meaning “inline code”) using the Create new style, it creates a paragraph style:

image

But a paragraph style is not what I want here, I just want to create a style that I can use on a string of text within a paragraph.

This is the whole point of this how-to question / suggestion.

If you have some idea as to how to create a “text style” in OnlyOffice, I’d love to know about that.

Returning to the issue of background, I suppose in the case of a “text style”, what is wanted is not “background” but “highlight”. A further limitation with “highlight” is that there appears to be a fixed palette of not-very-attractive colours.

I’ve mentioned the guide on how to create new styles. Until full-featured menu for styles creation is implemented, you just need to keep in mind that when specific paragraph style applied to selected text passage, it will create new paragraph style.

To create custom text style you need to select paragraph, change its font so that this text is no longer actually inherits paragraph style, apply formatting you’d like to save as custom text style and create it. After that you can reset paragraph to its style and apply custom text style to selected passage. This is currently the only workaround.

@Constantine, thanks for your patience with me. I followed your instructions diligently and this seems to have worked.

Specifically,

  1. I created some paragraph text, set the font to Ubuntu Sans Mono, right-clicked on the text and did Formatting as Style > Create new style and called the new style Code

  2. Then I typed a paragraph in Normal which contained a fragment I wanted to show as code, so I highlighted it and clicked on the Code style in the Styles pane above, and sure enough just the wanted text was converted to Ubuntu Sans Mono, without messing with the rest of the line. Which is good.

However, if I then place my cursor in the line that is Normal style with the fragment contained in Code style, in the Normal part, the Normal style is highlighted (darker border) in the Styles panel; but if I place my cursor in the fragment in Code style, neither Normal nor Code is highlighted in the Styles panel.

Also, which seems odd to me, if I change the font of the paragraph in Code style to a different font (in my case DejaVu Sans Mono), then right-click on the paragraph and click Formatting as style > Update Code style, the other examples of Code style in my text don’t update their font to DejaVu Sans Mono (neither the second copy of the original Code paragraphs nor the fragment to which I applied the Code style as per your instructions).

Here is a screen shot to show what I mean by the above

You can see the first code paragraphs at the beginning of the document that I switched to DejaVu Sans Mono and then updated the Code style, and then the ones following the paragraph “Here we are…” that stayed in Ubuntu Sans Mono, as well as the segment in the last line.

Unfortunately my cursor does not appear in the screen shot but I confirm it was placed in the second set of code paragraphs (following “Here we are…”).

I see. The problem comes from the fact that separate style manager is not yet implemented, this is exactly the point of this topic. What I’ve suggested is just workarounds for current situation with styles.

We are working on the suggestion discussed here. Sorry for inconvenience.

@Constantine thanks for your response. Your workaround is a good interim step, so very much appreciated. But the ability to manage the “text styles” in documents already created would be wonderful.