You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

codejar

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codejar - npm Package Compare versions

Comparing version

to
3.6.0

1

codejar.d.ts
declare type Options = {
tab: string;
indentOn: RegExp;
moveToNewLine: RegExp;
spellcheck: boolean;

@@ -5,0 +6,0 @@ catchTab: boolean;

11

codejar.js
const globalWindow = window;
export function CodeJar(editor, highlight, opt = {}) {
const options = Object.assign({ tab: '\t', indentOn: /{$/, spellcheck: false, catchTab: true, preserveIdent: true, addClosing: true, history: true, window: globalWindow }, opt);
const options = Object.assign({ tab: '\t', indentOn: /[({\[]$/, moveToNewLine: /^[)}\]]/, spellcheck: false, catchTab: true, preserveIdent: true, addClosing: true, history: true, window: globalWindow }, opt);
const window = options.window;

@@ -216,3 +216,2 @@ const document = window.document;

// If last symbol is "{" ident new line
// Allow user defines indent rule
if (options.indentOn.test(before)) {

@@ -231,3 +230,3 @@ newLinePadding += options.tab;

// Place adjacent "}" on next line
if (newLinePadding !== padding && after[0] === '}') {
if (newLinePadding !== padding && options.moveToNewLine.test(after)) {
const pos = save();

@@ -360,3 +359,7 @@ insert('\n' + padding);

highlight(editor);
restore({ start: pos.start + text.length, end: pos.start + text.length });
restore({
start: Math.min(pos.start, pos.end) + text.length,
end: Math.min(pos.start, pos.end) + text.length,
dir: '<-',
});
}

@@ -363,0 +366,0 @@ function visit(editor, visitor) {

@@ -6,2 +6,3 @@ const globalWindow = window

indentOn: RegExp
moveToNewLine: RegExp
spellcheck: boolean

@@ -31,3 +32,4 @@ catchTab: boolean

tab: '\t',
indentOn: /{$/,
indentOn: /[({\[]$/,
moveToNewLine: /^[)}\]]/,
spellcheck: false,

@@ -266,3 +268,2 @@ catchTab: true,

// If last symbol is "{" ident new line
// Allow user defines indent rule
if (options.indentOn.test(before)) {

@@ -282,3 +283,3 @@ newLinePadding += options.tab

// Place adjacent "}" on next line
if (newLinePadding !== padding && after[0] === '}') {
if (newLinePadding !== padding && options.moveToNewLine.test(after)) {
const pos = save()

@@ -416,3 +417,7 @@ insert('\n' + padding)

highlight(editor)
restore({start: pos.start + text.length, end: pos.start + text.length})
restore({
start: Math.min(pos.start, pos.end) + text.length,
end: Math.min(pos.start, pos.end) + text.length,
dir: '<-',
})
}

@@ -419,0 +424,0 @@

{
"name": "codejar",
"version": "3.5.0",
"version": "3.6.0",
"description": "An embeddable code editor for the browser",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -56,4 +56,4 @@ <p align="center"><a href="https://medv.io/codejar/"><img src="https://medv.io/assets/codejar.svg" width="72"></a></p>

- Note: use css rule `tab-size` to customize size.
- `indentOn: RegExp` allows auto indent rule to be customized. Default `{$`.
- Auto-tab if the text before cursor match the given regex while pressing Enter.
- `indentOn: RegExp` allows auto indent rule to be customized. Default `/[({\[]$/`.
- `moveToNewLine: RegExp` checks in extra newline character need to be added. Default `/^[)}\]]/`.
- `spellcheck: boolean` enables spellchecking on the editor. Default `false`.

@@ -156,3 +156,4 @@ - `catchTab: boolean` catches Tab keypress events and replaces it with `tab` string. Default: `true`.

* [react-codejar](https://github.com/guilhermelimak/react-codejar)
* [react-codejar](https://github.com/guilhermelimak/react-codejar) - a react wrapper for CodeJar.
* [ngx-codejar](https://github.com/julianpoemp/ngx-codejar) - an angular wrapper for CodeJar.

@@ -159,0 +160,0 @@ ## License

Sorry, the diff of this file is not supported yet