CODE Pasting (w/color & formatting)

Do you want to: Suggest a feature / Ask a how-to question
Document Server version: OLYOFFICE Desktop Editors version 7.1.1.57
OS: Win10 & Linux MINT
Browser version: BRAVE v.1.42.96

Greetings,
I am searching for a feature that will allow me to paste a block of copied program code into my Document.
I would like it to retain the original formatting, indentions, line spacing, and text colors, upon pasting into the Document.

Currently, MS Word does not handle this feature very well, but I use a round-about method: InsertObjectCreate NewOpenDocument Text. This MS Word feature allows a user to ‘implant’ a different text-based styled sheet into the existing Word Document. While it is not ideal, it does allow a user to simply double-click on the section and opens up the styled sheet for editing/copying.

As a programmer, I would really like an office suite that can handle code blocks that handle text color and formatting accordingly. Lines numbers are optional, as I generally do not care about line numbers from my code.

Is there currently a feature in OO that can handle this? I was not able to see anything in the menus.
As it stands now, when I attempt to paste a block of code, copied from Visual Studio 2022 or Visual Code 2022, it does not retain the color, nor proper line spacing (everything is black text with double line-spacing)

Thank you for your continued excellent hard work on this application.

Regards.

Hi,
Please try this plugin:
https://api.onlyoffice.com/plugin/example/highlightcode
It is available in ONLYOFFICE Desktop Editors by default (Plugin tab).

@Carl,

That is excellent! I completely missed that when I was looking for it. :worried:
Thank you very much. This will help so much with my project documentation.

Outstanding application! I am liking OO more & more each day.

Thanks & Regards.

Hi all,

Just a quick update on this:
It appears that some of the copied/pasted code does not retain the color scheme, even when selecting the appropriate data type/format (a.k.a. CS or CPP, etc.)
Is there a setting that needs to be tweaked, or is it simply due to certain colors are not being translated accordingly due to the differences in Visual Studio and OO?
MS Word seems to have this issue too, but I would think that something like colors, which seem to be hex based, would be able to be translated.

This is the copied code block from VS:
Snip-01

This is the pasted result in OO:
Snip-02

Also, one other thing:
Is it possible to set the default background color for the code block insertion feature? Currently I have to set it each time I add a new insertion. I’m still looking through the settings, but cannot seem to locate it.

Thanks & Regards.

Hello @FriQenstein,
Sorry for the late reply.
I don’t think such customizations are possible because the highlighting is done by means of this library: https://highlightjs.org/