View Demo »
Report Bug
-
Request Feature
you can directly use cdn
<script src="https://cdn.jsdelivr.net/npm/iblize/dist/iblize.min.js"></script>
or install from npm
$ npm install iblize --save
iblize needs a div container to hold all elements.
<div id="editor"></div>
then set the container width and height. you can also use inline style.
#editor { width: 100%; height: 400px }
the first argument can be a string selector or an dom element
// use selector
const iblize = new Iblize("#editor");
// use dom element
const iblize = new Iblize(document.querySelector("#editor"));
the second argument is options. see all options
const iblize = new Iblize("#editor", {
language: "html",
// etc
});
you can set editor value programmatically with javascript
iblize.setValue("console.log('Hello World')");
or directly from html (value must be wrapped with comment tag)
<div id="editor">
<!--
<h1>Hello World</h1>
-->
</div>
listen when the editor value changes
iblize.onUpdate((value) => {
// do anything with value
});
done 👌. if you find bug or if you have a cool idea please tell me
-
Type:
String
-
Default:
"js"
the name of language to highlight list of supported languages
Iblize has some built-in language modules. markup ( html, xml ), css, javascript / js, and clike. By default if you use a language other than the built-in one, Iblize will automatically load the language modules from cdn. But dont worry, if you want to work offline or load the modules locally, you can set languagesPath option bellow.
-
Type:
String
-
Default:
""
path to languages folder. You can find the folder in the dist folder.
-
Type:
Boolean
-
Default:
true
controls the display of line numbers
-
Type:
Boolean
-
Default:
false
controls the readonly mode
-
Type:
Number
-
Default:
2
the number of spaces
-
Type:
String
-
Default:
"iblize-dark"
the name of theme themes list
Same with language, by default Iblize will load the themes from cdn.
-
Type:
String
-
Default:
""
path to themes folder. You can find the folder in the dist folder.
documentation move here
PrismJs - main iblize syntax highlighter
tested on latest version of major browser
Distributed under the MIT License. See LICENSE for more information.