MCPcopy Create free account
hub / github.com/TruthHun/BookStack / CodeMirror

Function CodeMirror

static/mergely/lib/codemirror.js:61–128  ·  view source on GitHub ↗
(place, options)

Source from the content-addressed store, hash-verified

59 // that user code is usually dealing with.
60
61 function CodeMirror(place, options) {
62 if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
63
64 this.options = options = options ? copyObj(options) : {};
65 // Determine effective options based on given values and defaults.
66 copyObj(defaults, options, false);
67 setGuttersForLineNumbers(options);
68
69 var doc = options.value;
70 if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
71 this.doc = doc;
72
73 var input = new CodeMirror.inputStyles[options.inputStyle](this);
74 var display = this.display = new Display(place, doc, input);
75 display.wrapper.CodeMirror = this;
76 updateGutters(this);
77 themeChanged(this);
78 if (options.lineWrapping)
79 this.display.wrapper.className += " CodeMirror-wrap";
80 if (options.autofocus && !mobile) display.input.focus();
81 initScrollbars(this);
82
83 this.state = {
84 keyMaps: [], // stores maps added by addKeyMap
85 overlays: [], // highlighting overlays, as added by addOverlay
86 modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
87 overwrite: false,
88 delayingBlurEvent: false,
89 focused: false,
90 suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
91 pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
92 selectingText: false,
93 draggingText: false,
94 highlight: new Delayed(), // stores highlight worker timeout
95 keySeq: null, // Unfinished key sequence
96 specialChars: null
97 };
98
99 var cm = this;
100
101 // Override magic textarea content restore that IE sometimes does
102 // on our hidden textarea on reload
103 if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
104
105 registerEventHandlers(this);
106 ensureGlobalHandlers();
107
108 startOperation(this);
109 this.curOp.forceUpdate = true;
110 attachDoc(this, doc);
111
112 if ((options.autofocus && !mobile) || cm.hasFocus())
113 setTimeout(bind(onFocus, this), 20);
114 else
115 onBlur(this);
116
117 for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
118 optionHandlers[opt](this, options[opt], Init);

Callers 1

codemirror.jsFile · 0.70

Calls 13

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

Tested by

no test coverage detected