프로젝트
GitHub에서 보기
antonmedv/codejar
소개
브라우저에 임베드할 수 있는 코드 편집기 🍯
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- +4
- in 15 days
- +4
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalCodeJar – an embeddable code editor for the browser
A tiny (~3 kB) editor with no dependencies. Instead of a hidden <textarea>
over highlighted code, CodeJar makes the highlighted element itself
contenteditable, so you type directly into it. Bring your own highlighter.
npm i codejar
import { CodeJar } from 'codejar'
import Prism from 'prismjs'
const jar = CodeJar(document.querySelector('.editor'), (editor) => {
editor.innerHTML = Prism.highlight(
editor.textContent,
Prism.languages.js,
'js',
)
})
Options
Passed as the third argument:
tab— string inserted on Tab. Default'\t'.indentOn— indent the new line if the text before the caret matches. Default/[({[]$/.moveToNewLine— move the text after the caret to its own line if it matches. Default/^[)}\]]/.spellcheck— defaultfalse.catchTab— handle Tab and Shift+Tab. Defaulttrue.preserveIdent— keep indentation on a new line. Defaulttrue.addClosing— auto-close brackets and quotes. Defaulttrue.autoclose—{ open, close }pairs to auto-close. Default{ open: `([{'"`, close: `)]}'"` }.history— undo/redo. Defaulttrue.window— window to use, e.g. for iframes.
API
updateCode(code, callOnUpdate = true)— set the code.updateOptions(options)— change options.onUpdate(callback)— called with the code on every change.toString()— get the code.save()/restore(pos)— save and restore the caret or selection.recordHistory()— push the current state onto the undo stack.destroy()— remove event listeners.
License
관련 프로젝트 살펴보기
불러오는 중…