GitPedia

CodeFlask

A micro code-editor for awesome web pages.

From kazzkiq·Updated June 11, 2026·View on GitHub·

**CodeFlask** is A micro code-editor for awesome web pages. The project is written primarily in JavaScript, distributed under the MIT License license, first published in 2015. It has gained significant community traction with 1,115 stars and 124 forks on GitHub. Key topics include: code-editor, css, highlight, html, javascript.

Latest release: v1.4.1
May 13, 2019View Changelog →

npm version
Build Status

<p align="center"> <img src="logo.png" width="190"><br> CodeFlask: A micro code-editor for awesome web pages. </p> <p align="center"> <img src="code.png" width="739"> </p>

Installation

You can install CodeFlask via npm:

npm install codeflask

Or use it directly in browser via cdn service:

https://unpkg.com/codeflask/build/codeflask.min.js

Usage

js
import CodeFlask from 'codeflask'; const flask = new CodeFlask('#my-selector', { language: 'js' });

You can also pass a DOM element instead of a selector:

js
import CodeFlask from 'codeflask'; const editorElem = document.getElementById('editor'); const flask = new CodeFlask(editorElem, { language: 'js' });

Usage with Shadow DOM:

js
import CodeFlask from 'codeflask'; ... const shadowElem = this.shadowRoot.querySelector('#editor'); const flask = new CodeFlask(shadowElem, { language: 'js', styleParent: this.shadowRoot });

Listening for changes in editor

js
flask.onUpdate((code) => { // do something with code here. // this will trigger whenever the code // in the editor changes. });

Updating the editor programatically

js
// This will also trigger .onUpdate() flask.updateCode('const my_new_code_here = "Blabla"');

Getting the current code from editor

js
const code = flask.getCode();

Enabling line numbers

js
import CodeFlask from 'codeflask'; const flask = new CodeFlask('#my-selector', { language: 'js', lineNumbers: true });

Enabling rtl (right to left writing)

js
import CodeFlask from 'codeflask'; const flask = new CodeFlask('#my-selector', { language: 'js', rtl: true });

Enabling read only mode

js
import CodeFlask from 'codeflask'; const flask = new CodeFlask('#my-selector', { language: 'js', readonly: true });

Adding other languages support:

js
flask.addLanguage('ruby', options)

For Example to add 'Ruby'

js
import Prism from 'prismjs'; import CodeFlask from 'codeflask'; const flask = new CodeFlask('#my-selector', { language: 'ruby', readonly: true }); flask.addLanguage('ruby', Prism.languages['ruby']);

This API is simply a proxy to add a new language to Prism itself (the code highlighter). The options parameter must be the same accepted in Prism. You can read more about it here.

By default, CodeFlask supports the following languages (which are also the default supported in Prism):

  • Markup (HTML/XML);
  • CSS;
  • C-like;
  • JavaScript;

Adding your own theme to CodeFlask

By default, CodeFlask comes with a simple theme made from scratch called CodeNoon.

You can easily override this theme with your own by writting your own CSS and adding it to your project. If that's the case, you should also disable CodeNoon with the defaultTheme option:

js
import CodeFlask from 'codeflask'; const flask = new CodeFlask('#my-selector', { language: 'js', defaultTheme: false });

Credits & Thanks

CodeFlask.js was made possible by awesome open-source projects such as Prism.js and Rollup.

Contributors

Showing top 12 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from kazzkiq/CodeFlask via the GitHub API.Last fetched: 6/14/2026