(place, options)
| 7839 | // that user code is usually dealing with. |
| 7840 | |
| 7841 | function CodeMirror(place, options) { |
| 7842 | var this$1 = this; |
| 7843 | |
| 7844 | if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) } |
| 7845 | |
| 7846 | this.options = options = options ? copyObj(options) : {}; |
| 7847 | // Determine effective options based on given values and defaults. |
| 7848 | copyObj(defaults, options, false); |
| 7849 | |
| 7850 | var doc = options.value; |
| 7851 | if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); } |
| 7852 | else if (options.mode) { doc.modeOption = options.mode; } |
| 7853 | this.doc = doc; |
| 7854 | |
| 7855 | var input = new CodeMirror.inputStyles[options.inputStyle](this); |
| 7856 | var display = this.display = new Display(place, doc, input, options); |
| 7857 | display.wrapper.CodeMirror = this; |
| 7858 | themeChanged(this); |
| 7859 | if (options.lineWrapping) |
| 7860 | { this.display.wrapper.className += " CodeMirror-wrap"; } |
| 7861 | initScrollbars(this); |
| 7862 | |
| 7863 | this.state = { |
| 7864 | keyMaps: [], // stores maps added by addKeyMap |
| 7865 | overlays: [], // highlighting overlays, as added by addOverlay |
| 7866 | modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info |
| 7867 | overwrite: false, |
| 7868 | delayingBlurEvent: false, |
| 7869 | focused: false, |
| 7870 | suppressEdits: false, // used to disable editing during key handlers when in readOnly mode |
| 7871 | pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll |
| 7872 | selectingText: false, |
| 7873 | draggingText: false, |
| 7874 | highlight: new Delayed(), // stores highlight worker timeout |
| 7875 | keySeq: null, // Unfinished key sequence |
| 7876 | specialChars: null |
| 7877 | }; |
| 7878 | |
| 7879 | if (options.autofocus && !mobile) { display.input.focus(); } |
| 7880 | |
| 7881 | // Override magic textarea content restore that IE sometimes does |
| 7882 | // on our hidden textarea on reload |
| 7883 | if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); } |
| 7884 | |
| 7885 | registerEventHandlers(this); |
| 7886 | ensureGlobalHandlers(); |
| 7887 | |
| 7888 | startOperation(this); |
| 7889 | this.curOp.forceUpdate = true; |
| 7890 | attachDoc(this, doc); |
| 7891 | |
| 7892 | if ((options.autofocus && !mobile) || this.hasFocus()) |
| 7893 | { setTimeout(function () { |
| 7894 | if (this$1.hasFocus() && !this$1.state.focused) { onFocus(this$1); } |
| 7895 | }, 20); } |
| 7896 | else |
| 7897 | { onBlur(this); } |
| 7898 |
no test coverage detected