Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
codejar
Advanced tools
Readme
Install CodeJar 🍯 via npm:
npm i codejar
Create an element and init the CodeJar 🍯:
<div class="editor"></div>
<script>
let jar = CodeJar(document.querySelector('.editor'), highlight)
</script>
Second argument to CodeJar
is a highlighting function (like Prism.js, highlight.js):
const highlight = (editor: HTMLElement) => {
const code = editor.textContent
code = code.replace('foo', '<span style="color: red">foo</span>')
editor.innerHTML = code
}
const jar = CodeJar(editor, highlight)
Third argument to CodeJar
is options:
tab: string
replaces "tabs" with given string. Default: \t
.
tab-size
to customize size.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
.catchTab: boolean
catches Tab keypress events and replaces it with tab
string. Default: true
.preserveIdent: boolean
keeps indent levels on new line. Default true
.addClosing: boolean
automatically adds closing brackets, quotes. Default true
.history
records history. Default true
.window
window object. Default: window
.const options = {
tab: ' '.repeat(4), // default is '\t'
indentOn: /[(\[]$/, // default is /{$/
}
const jar = CodeJar(editor, highlight, options)
updateCode(string)
Updates the code.
jar.updateCode(`let foo = bar`)
updateOptions(Partial<Options>)
Updates the options.
jar.updateOptions({tab: '\t'})
onUpdate((code: string) => void)
Calls callback on code updates.
jar.onUpdate(code => {
console.log(code)
})
toString(): string
Return current code.
let code = jar.toString()
save(): string
Saves current cursor position.
let pos = jar.save()
restore(pos: Position)
Restore cursor position.
jar.restore(pos)
recordHistory()
Saves current editor state to history.
destroy()
Removes event listeners from editor.
FAQs
An embeddable code editor for the browser
The npm package codejar receives a total of 8,550 weekly downloads. As such, codejar popularity was classified as popular.
We found that codejar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.