Skip to content

MilanLund/kontent-custom-element-ace-code-editor

Repository files navigation

Ace Code Editor Custom Element for Kentico Kontent

The Ace Code Editor custom element is an editable text area enhanced by the Ace Code Editor to provide syntax highlighting for writing code examples. Offers a fine selection of programming languages to be highlighted.

Syntax Highlighter

Setup

If you want to use the Syntax Highlighter in your project in Kentico Kontent, follow these steps:

  1. Deploy the code to a secure publis host
  2. Follow the instructions in the Kentico Kontent documentation to add the element to a content model.

JSON Parameters

You can optionally provide the following JSON parameters for the custom element to configure the initial state of the Syntax Highlighter:

{
    "initTheme": "<THEME CODENAME>",
    "initMode": "<PROGRAMMING LANGUAGE CODENAME>"
}
  • THEME CODENAME is a filename substring prefixed by theme- of a file located in the ace folder (i.e. textmate)
  • PROGRAMMING LANGUAGE CODENAME is a filename substring prefixed by mode- of a file located in the ace folder (i.e. plain_text)

What is saved?

The value contains data about language and code. As Kentico Cloud custom elements can contain only string values or null, the value is stored as a stringified object. That means the value has to be explicitly parsed.

Example

The value contains the following string when obtained from Kentico Cloud:

"{\"language\":\"javascript\",\"code\":\"var text = 'Hello world';\"}"

You need to parse that value to get a proper object (i.e. in JavaScript with the use of the JSON.parse method).

Deploying

Netlify has made this easy. If you click the deploy button below, it will guide you through the process of deploying it to Netlify and leave you with a copy of the repository in your GitHub account as well.

Deploy to Netlify

Licenses

Syntax Highlighter is released under the MIT license. The Ace source code that Syntax Highlighter uses is released under the BSD license.

About

Ace Code Editor custom element for Kentico Kontent

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages