Editor Tools - Highlighting - UI - Code

Version 4.1 by Admin on 2016/07/20 10:29

cogProvides a Syntax Highlighting library
TypeXAR
Category
Developed by

Vincent Massol, Eduard Moraru

Active Installs62
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'}

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 3.4):

Tags:
    

Get Connected