blob: 934206c823a1e680674e70272c22415cd205d0cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// EDITOR CONSTRUCTOR
import { CodeMirror } from "./CodeMirror.js"
export { CodeMirror } from "./CodeMirror.js"
import { eventMixin } from "../util/event.js"
import { indexOf } from "../util/misc.js"
import { defineOptions } from "./options.js"
defineOptions(CodeMirror)
import addEditorMethods from "./methods.js"
addEditorMethods(CodeMirror)
import Doc from "../model/Doc.js"
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
let dontDelegate = "iter insert remove copy getEditor constructor".split(" ")
for (let prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
CodeMirror.prototype[prop] = (function(method) {
return function() {return method.apply(this.doc, arguments)}
})(Doc.prototype[prop])
eventMixin(Doc)
// INPUT HANDLING
import ContentEditableInput from "../input/ContentEditableInput.js"
import TextareaInput from "../input/TextareaInput.js"
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}
// MODE DEFINITION AND QUERYING
import { defineMIME, defineMode } from "../modes.js"
// Extra arguments are stored as the mode's dependencies, which is
// used by (legacy) mechanisms like loadmode.js to automatically
// load a mode. (Preferred mechanism is the require/define calls.)
CodeMirror.defineMode = function(name/*, mode, …*/) {
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name
defineMode.apply(this, arguments)
}
CodeMirror.defineMIME = defineMIME
// Minimal default mode.
CodeMirror.defineMode("null", () => ({token: stream => stream.skipToEnd()}))
CodeMirror.defineMIME("text/plain", "null")
// EXTENSIONS
CodeMirror.defineExtension = (name, func) => {
CodeMirror.prototype[name] = func
}
CodeMirror.defineDocExtension = (name, func) => {
Doc.prototype[name] = func
}
import { fromTextArea } from "./fromTextArea.js"
CodeMirror.fromTextArea = fromTextArea
import { addLegacyProps } from "./legacy.js"
addLegacyProps(CodeMirror)
CodeMirror.version = "5.51.0"
|