Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/julianpoemp/ngx-codejar

Angular wrapper for CodeJar code-editor. With this you can easily add code editors to your Angular app.
https://github.com/julianpoemp/ngx-codejar

angular angular-lib code-editor codejar highlighter highlightjs prismjs

Last synced: about 2 months ago
JSON representation

Angular wrapper for CodeJar code-editor. With this you can easily add code editors to your Angular app.

Awesome Lists containing this project

README

        

# ngx-codejar npm

This is an Angular wrapper for the code-editor [CodeJar](https://github.com/antonmedv/codejar) by Anton Medvedev. It
allows to easily use CodeJar in Angular projects.


thumbnail

## Demo

Visit the demo page: https://julianpoemp.github.io/ngx-codejar/

## About CodeJar

CodeJar is an embeddable javascript code-editor that supports different highlighter like Highlight.js or PrimsJs.
According to the [main project](https://github.com/antonmedv/codejar) it has the following features:

- Preserves indentation on a new line
- Adds closing brackets, quotes
- Indents line with the Tab key
- Supports undo/redo

## Compatibility

NgxCodeJar
CodeJar
Angular
Readme

7.x
4.x
>= 16

README

6.x
4.x
15.x

README

## Overview

- [Install ngx-codejar with highlight.js](https://github.com/julianpoemp/ngx-codejar#how-to-use-codejar-with-angular-and-highlightjs)
- [Install ngx-codejar with prism.js](https://github.com/julianpoemp/ngx-codejar#how-to-use-codejar-with-angular-and-prismjs)
- [Options](https://github.com/julianpoemp/ngx-codejar#properties--events)
- [Development](https://github.com/julianpoemp/ngx-codejar#development)
- [Contribution](https://github.com/julianpoemp/ngx-codejar#development)
- [Troubleshooting](https://github.com/julianpoemp/ngx-codejar#development)

## Installation

### How to use CodeJar with Angular and highlight.js

If you want to use CodeJar with [highlight.js](https://highlightjs.org/) you should do the following steps:

1. 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
````

2. Import NgxCodeJarComponent `NgxCodeJarComponent` to your app's ngModule import property (standalone!):

````typescript
@NgModule({
declarations: [
// ...
],
imports: [
// ...,
NgxCodeJarComponent
],
// ...
})
````

3. Select themes from `node_modules/highlight.js/styles` and add them to the styles section of your `angular.json`.
4. Add `node_modules/codejar-linenumbers/es/codejar-linenumbers.css` to the styles section of your `angular.json`
5. Now see https://julianpoemp.github.io/ngx-codejar/ on how to use it.

### How to use CodeJar with Angular and Prism.js

If you want to use codejar with [prism.js](https://prismjs.com/) you should do the following steps:

1. Install prism.js, codejar, codejar-linenumbers and ngx-codejar:

````
npm install --save codejar codejar-linenumbers prismjs ngx-codejar && npm install --save-dev @types/prismjs
````

2. Import module `NgxCodeJarComponent` to your app's ngModule imports property (!standalone):

````typescript
@NgModule({
declarations: [
// ...
],
imports: [
// ...,
NgxCodeJarComponent
],
// ...
})
````

3. Select themes from `node_modules/prismjs/themes` and add them to the styles section of your `angular.json`.
4. Add `node_modules/codejar-linenumbers/es/codejar-linenumbers.css` to the styles section of your `angular.json`
5. Now see https://julianpoemp.github.io/ngx-codejar/ on how to use it.

### Properties & Events

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.
-

## Development

Call `npm start` to start the demo locally. Build the library using `ng build ngx-codejar`.

## Contribution

Feel free to create pull requests or issues with suggestions! :)

## Troubleshooting

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.