Syntax Highlighting Common Library

Last modified by Admin on 2021/05/19 01:35

cogProvides a Syntax Highlighting library
TypeXAR
Category
Developed by

Vincent Massol, Eduard Moraru

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

This is a technical library. If you're looking for the Syntax Highlighting Application, check it out here.

  • Provides a RequireJS module to initialize CodeMirror editors in XWiki
  • Basic addons are added autoatically to the editor. Other CodeMirror addons can be added by the user
  • Choose the theme of the editor

How to use

var syntaxHighlightingPath = "$xwiki.getURL('SyntaxHighlighting.SyntaxHighlighting','jsx')";
require([syntaxHighlightingPath], function(SH) {
 
 // Change the theme of the future CodeMirror editors initialized
 SH.setTheme('ambiance');
 // Transform a textarea into a CodeMirror editor
 SH.initCodeMirror('#textareaId', 'css');
 
 // Transform a textarea into a CodeMirror editor
 SH.initCodeMirror('#textareaId2', 'javascript', [
    ['SyntaxHighlighting_cm/addon/display/placeholder'],
    {lineWrapping : true}
  ]);

});

Available methods

  • setTheme(String themeName)
    • themeName : See the list of available themes and their rendering here
  • initCodeMirror(String cssSelector, String mode [, Array<String, Object> addons])
    • cssSelector : A cssSelector representing all the textareas that have to be transformed into CodeMirror editors
    • mode : The language used in the editor. See the full list of available languages. You can also use "xwiki/2.0" or "xwiki/2.1" which add support the the velocity, groovy, python or html macros in addition to the wiki syntax tags.
    • addons : An array componed of <Array<String> requireURL, Object parameters> elements.
      • requireURL : A array of URL to load the addons enabling the parameters in the webjar, starting with "SyntaxHighlighting_cm/". e.g. : ['SyntaxHighlighting_cm/addon/display/placeholder']
      • parameter : An object {parameter1 : 'value', parameter2 : 'value'}

Release Notes

All release notes

4.6

4.5.2

4.5.1

4.5

4.4

4.3.1

4.3

4.2

4.1

4.0

3.4

3.3

3.2

3.1.1

3.1

3.0

This version improved the overall stability of the application but unfortunatey also introduced a serious performance issue that can lead to the syntax highlighting being activated 10+ seconds after the page is loaded. An improvement of this problem will come with the new version that will be released once XWiki 7.1M1 is released and an even better solution will hopefully come after that. To stay up to date with the problem, please watch the assigned WIKIEDITOR-21 Jira issue

2.2

2.1

2.0

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Dependencies

Dependencies for this extension (org.xwiki.contrib.editortool:editor-tool-highlighting-ui-code 4.6):

Tags:
    

Get Connected