Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit 38073cd

Browse files
committed
Wrap all modules in AMD and CommonJS-supporting shims
1 parent 451c9a8 commit 38073cd

134 files changed

Lines changed: 1640 additions & 363 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

addon/comment/comment.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
"use strict";
310

411
var noOptions = {};
@@ -159,4 +166,4 @@
159166
});
160167
return true;
161168
});
162-
})();
169+
});

addon/comment/continuecomment.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
var modes = ["clike", "css", "javascript"];
310
for (var i = 0; i < modes.length; ++i)
411
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
@@ -59,4 +66,4 @@
5966
cm.addKeyMap(map);
6067
}
6168
});
62-
})();
69+
});

addon/dialog/dialog.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
// Open simple dialogs on top of an editor. Relies on dialog.css.
22

3-
(function() {
3+
(function(mod) {
4+
if (typeof exports == "object" && typeof module == "object") // CommonJS
5+
mod(require("../../lib/codemirror"));
6+
else if (typeof define == "function" && define.amd) // AMD
7+
define(["../../lib/codemirror"], mod);
8+
else // Plain browser env
9+
mod(CodeMirror);
10+
})(function(CodeMirror) {
411
function dialogDiv(cm, template, bottom) {
512
var wrap = cm.getWrapperElement();
613
var dialog;
@@ -119,4 +126,4 @@
119126
if (duration)
120127
doneTimer = setTimeout(close, options.duration);
121128
});
122-
})();
129+
});

addon/display/fullscreen.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
"use strict";
310

411
CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
@@ -28,4 +35,4 @@
2835
window.scrollTo(info.scrollLeft, info.scrollTop);
2936
cm.refresh();
3037
}
31-
})();
38+
});

addon/display/placeholder.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
310
var prev = old && old != CodeMirror.Init;
411
if (val && !prev) {
@@ -45,4 +52,4 @@
4552
function isEmpty(cm) {
4653
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
4754
}
48-
})();
55+
});

addon/edit/closebrackets.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
var DEFAULT_BRACKETS = "()[]{}''\"\"";
310
var DEFAULT_EXPLODE_ON_ENTER = "[]{}";
411
var SPACE_CHAR_REGEX = /\s/;
@@ -112,4 +119,4 @@
112119
});
113120
};
114121
}
115-
})();
122+
});

addon/edit/closetag.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222
* See demos/closetag.html for a usage example.
2323
*/
2424

25-
(function() {
25+
(function(mod) {
26+
if (typeof exports == "object" && typeof module == "object") // CommonJS
27+
mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
28+
else if (typeof define == "function" && define.amd) // AMD
29+
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
30+
else // Plain browser env
31+
mod(CodeMirror);
32+
})(function(CodeMirror) {
2633
CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
2734
if (old != CodeMirror.Init && old)
2835
cm.removeKeyMap("autoCloseTags");
@@ -106,4 +113,4 @@
106113
if (collection[i] == elt) return i;
107114
return -1;
108115
}
109-
})();
116+
});

addon/edit/continuelist.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
"use strict";
310

411
var listRE = /^(\s*)([*+-]|(\d+)\.)(\s*)/,
@@ -25,4 +32,4 @@
2532

2633
cm.replaceSelections(replacements, null, "+insert");
2734
};
28-
}());
35+
});

addon/edit/matchbrackets.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
310
(document.documentMode == null || document.documentMode < 8);
411

@@ -93,4 +100,4 @@
93100
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict){
94101
return findMatchingBracket(this, pos, strict);
95102
});
96-
})();
103+
});

addon/edit/matchtags.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
(function() {
1+
(function(mod) {
2+
if (typeof exports == "object" && typeof module == "object") // CommonJS
3+
mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
4+
else if (typeof define == "function" && define.amd) // AMD
5+
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
6+
else // Plain browser env
7+
mod(CodeMirror);
8+
})(function(CodeMirror) {
29
"use strict";
310

411
CodeMirror.defineOption("matchTags", false, function(cm, val, old) {
@@ -53,4 +60,4 @@
5360
if (other) cm.setSelection(other.to, other.from);
5461
}
5562
};
56-
})();
63+
});

0 commit comments

Comments
 (0)