Embed a code editor with Ace.js


This article shows how to embed the Ace.js editor into a Kintone record, so that the user's typed text can be displayed as code. This article will configure the editor to specifically use JavaScript syntax.

What is Ace.js?

Ace is an embeddable code editor for web pages. It matches features of other popular code editors (such as Sublime Text), and can be easily customized based on preference.


Details of the customization

On the Record create/edit page, the Ace editor is displayed where the user can type directly into.
When the record is saved, a "read-only" version of the Ace editor is displayed on the Record details page.
The user can re-edit the code by accessing the Record edit page.


Codes that do not follow the specified syntax will be noted as errors inside the Ace.js code editor.



Applying the customization

Prepare a Kintone App

Prepare a Kintone App that contains the following two fields:

Field Type Field Code / Element ID Field Name
Text Area code Code
Blank Space editor  


The Text area field will be hidden when the Record create/edit/details pages are displayed, but is necessary to store the code that is written in the Ace editor.



Prepare 2 JavaScript files

The Ace Library

Use the Ace library CDN link hosted on the Kintone CDN.

The Main code

The main code utilizes the Ace methods to embed the Ace editor with different configurations depending on what Kintone events were triggered.

When the record create or record edit event is triggered, the Text Area field is hidden, and the Ace editor is displayed on the Blank Space field.
When the record is saved, the contents inside the Ace editor are saved into the Text Area field. This data in the Text Area field is later used to populate the contents of the Ace editor when the record edit event is triggered.
When the record details event is triggered, the Text Area field is hidden again, and a "read-only" version of the Ace editor is displayed on the Blank space field.

Prepare a CSS file

The CSS file is used to brush up the look of the Ace editor in Kintone.

Set the files in the App

Access the App's settings page, and set these files in the JavaScript and CSS Customization page.

Screenshot of the JavaScript and CSS Customization settings

Update the App's settings once the files have been set.


The code in this tutorial is largely based off the Embedding Guide from the Ace website, but modified to be compatible with Kintone. The website contains more detailed guides on customizing the editor. For example, to change the syntax language, "session.setMode("ace/mode/javascript")" can be rewritten to include the desired code syntax.

Was this article helpful?
0 out of 0 found this helpful
Do you have any questions or issues related to this article?
Please share your views with us in the Community forums!