MCPcopy Create free account
hub / github.com/breck7/scroll / CodeMirror

Function CodeMirror

external/.scrollLibs.js:10782–10872  ·  view source on GitHub ↗
(place, options)

Source from the content-addressed store, hash-verified

10780 // that user code is usually dealing with.
10781
10782 function CodeMirror(place, options) {
10783 var this$1 = this
10784
10785 if (!(this instanceof CodeMirror)) {
10786 return new CodeMirror(place, options)
10787 }
10788
10789 this.options = options = options ? copyObj(options) : {}
10790 // Determine effective options based on given values and defaults.
10791 copyObj(defaults, options, false)
10792 setGuttersForLineNumbers(options)
10793
10794 var doc = options.value
10795 if (typeof doc == "string") {
10796 doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction)
10797 } else if (options.mode) {
10798 doc.modeOption = options.mode
10799 }
10800 this.doc = doc
10801
10802 var input = new CodeMirror.inputStyles[options.inputStyle](this)
10803 var display = (this.display = new Display(place, doc, input))
10804 display.wrapper.CodeMirror = this
10805 updateGutters(this)
10806 themeChanged(this)
10807 if (options.lineWrapping) {
10808 this.display.wrapper.className += " CodeMirror-wrap"
10809 }
10810 initScrollbars(this)
10811
10812 this.state = {
10813 keyMaps: [], // stores maps added by addKeyMap
10814 overlays: [], // highlighting overlays, as added by addOverlay
10815 modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
10816 overwrite: false,
10817 delayingBlurEvent: false,
10818 focused: false,
10819 suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
10820 pasteIncoming: -1,
10821 cutIncoming: -1, // help recognize paste/cut edits in input.poll
10822 selectingText: false,
10823 draggingText: false,
10824 highlight: new Delayed(), // stores highlight worker timeout
10825 keySeq: null, // Unfinished key sequence
10826 specialChars: null
10827 }
10828
10829 if (options.autofocus && !mobile) {
10830 display.input.focus()
10831 }
10832
10833 // Override magic textarea content restore that IE sometimes does
10834 // on our hidden textarea on reload
10835 if (ie && ie_version < 11) {
10836 setTimeout(function () {
10837 return this$1.display.input.reset(true)
10838 }, 20)
10839 }

Callers 1

fromTextAreaFunction · 0.85

Calls 13

copyObjFunction · 0.85
setGuttersForLineNumbersFunction · 0.85
updateGuttersFunction · 0.85
themeChangedFunction · 0.85
initScrollbarsFunction · 0.85
registerEventHandlersFunction · 0.85
ensureGlobalHandlersFunction · 0.85
startOperationFunction · 0.85
attachDocFunction · 0.85
bindFunction · 0.85
onBlurFunction · 0.85

Tested by

no test coverage detected