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.