Get Started
Plugins
Macros
More information

Highlight code

Description

Connects the highlight.js library for highlighting code syntax with the necessary language, style, and background color.

Plugin type: visual, non-system.

Supported editors: documents, spreadsheets, presentations.

HighlightCode
Installation

Available by default in the cloud, on-premises and desktop versions of ONLYOFFICE editors

You can remove it following the desktop, on-premises, or cloud installation instructions.

The plugin guid: {BE5CBF95-C0AD-4842-B157-AC40FEDD9841}.

Usage
  1. Find the plugin in the Plugins tab.
  2. Paste the code into the plugin window
  3. The language is detected automatically, but you can change it. You can also customize the code display style, tabs and background color.
  4. Click the Ok button to paste the code into the document.
Plugin structure

Repository on GitHub: https://github.com/ONLYOFFICE/plugin-highlightcode.

  1. config.json, index.html and code.js
  2. Icons
  3. The translations folder contains translations into Russian, German, Spanish and French.
  4. The styles folder contains all the code styles that the plugin supports.
  5. plugin_style.css and scrollable_div.js are used to adjust the plugin style.
  6. Third-party service:
    • Highlight.js library - a syntax highlighter written in JavaScript (https://highlightjs.org/). License: BSD License.
    • Spectrum - a JavaScriptcolorpickerplugin that uses the jQuery framework. License: MIT License.
    • jQuery - a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development (https://jquery.com). License: MIT License.
    • Select2 gives you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly used options (https://select2.org/). License: MIT.
Config
{
    "name": "Highlight code",
    "nameLocale": {
        "ru": "Подсветка кода",
        "fr": "Code en surbrillance",
        "es": "Resaltar el código",
        "de": "Code hervorheben"
    },
    "guid": "asc.{BE5CBF95-C0AD-4842-B157-AC40FEDD9841}",

    "variations": [
        {
            "description": "Highlight code",
            "descriptionLocale": {
                "ru": "Подсветка кода",
                "fr": "Code en surbrillance",
                "es": "Resaltar el código",
                "de": "Code hervorheben"
            },
            "url": "index.html",

            "icons": [ "icon.png", "icon@2x.png", "icon.png", "icon@2x.png" ],
            "isViewer": false,
            "EditorsSupport": [ "word", "cell", "slide" ],

            "isVisual": true,
            "isModal": true,
            "isInsideMode": false,

            "initDataType": "html",
            "initData": "",

            "isUpdateOleOnResize": false,

            "buttons": [
                {
                    "text": "Ok",
                    "primary": true
                },
                {
                    "text": "Cancel",
                    "primary": false,
                    "textLocale": {
                        "ru": "Отмена",
                        "fr": "Annuler",
                        "es": "Cancelar",
                        "de": "Abbrechen"
                    }
                }
            ],

            "initOnSelectionChanged": true
        }
    ]
}
Methods and events

The main plugin code is located here.

Support

If you want to request a feature or report a bug regarding this plugin, use the issues section on GitHub.