This is an Angular wrapper for the code-editor CodeJar by Anton Medvedev. It allows to easily use CodeJar in Angular projects.
Visit the demo page: https://julianpoemp.github.io/ngx-codejar/
CodeJar is an embeddable javascript code-editor that supports different highlighter like Highlight.js or PrimsJs. According to the main project it has the following features:
NgxCodeJar | CodeJar | Angular | Readme |
---|---|---|---|
7.x | 4.x | >= 16 | README |
6.x | 4.x | 15.x | README |
If you want to use CodeJar with highlight.js you should do the following steps:
Install highlight.js, CodeJar, codejar-linenumbers and ngx-codejar:
npm install --save codejar codejar-linenumbers highlight.js ngx-codejar && npm install --save-dev @types/highlight.js
Import NgxCodeJarComponent NgxCodeJarComponent
to your app's ngModule import property (standalone!):
@NgModule({
declarations: [
// ...
],
imports: [
// ...,
NgxCodeJarComponent
],
// ...
})
node_modules/highlight.js/styles
and add them to the styles section of your angular.json
.node_modules/codejar-linenumbers/es/codejar-linenumbers.css
to the styles section of your angular.json
If you want to use codejar with prism.js you should do the following steps:
Install prism.js, codejar, codejar-linenumbers and ngx-codejar:
npm install --save codejar codejar-linenumbers prismjs ngx-codejar && npm install --save-dev @types/prismjs
Import module NgxCodeJarComponent
to your app's ngModule imports property (!standalone):
@NgModule({
declarations: [
// ...
],
imports: [
// ...,
NgxCodeJarComponent
],
// ...
})
node_modules/prismjs/themes
and add them to the styles section of your angular.json
.node_modules/codejar-linenumbers/es/codejar-linenumbers.css
to the styles section of your angular.json
Type | Name | Description | Default |
---|---|---|---|
Property | code | property for two-way data-binding. | - |
Property | highlighter | selects which highlighter should be used ('prism' or 'hljs') | 'hljs' |
Property | options | Options provided by CodeJar + additional Options (tabSize) | Defaults provided by Codejar Defaults by CodeJar |
Property | showLineNumbers | adds line numbers | false |
Property | highlightMethod | set a method for code highlight | (editor: CodeJarContainer) => {} |
Property | readonly | defines if user is allowed to make code changes | false |
Event | update | this event is triggered after the code was updated. | - |
Call npm start
to start the demo locally. Build the library using ng build ngx-codejar
.
Feel free to create pull requests or issues with suggestions! :)
This package is just a wrapper for CodeJar. If you have any problems using it please make sure, that the problem is related to this wrapper.