File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1441,6 +1441,10 @@ var CodeMirror = (function() {
14411441 to : function ( ) { if ( this . atOccurrence ) return copyPos ( this . pos . to ) ; }
14421442 } ;
14431443
1444+ for ( var ext in extensions )
1445+ if ( extensions . propertyIsEnumerable ( ext ) &&
1446+ ! instance . propertyIsEnumerable ( ext ) )
1447+ instance [ ext ] = extensions [ ext ] ;
14441448 return instance ;
14451449 } // (end of function CodeMirror)
14461450
@@ -1507,6 +1511,11 @@ var CodeMirror = (function() {
15071511 return list ;
15081512 } ;
15091513
1514+ var extensions = { } ;
1515+ CodeMirror . defineExtension = function ( name , func ) {
1516+ extensions [ name ] = func ;
1517+ } ;
1518+
15101519 CodeMirror . fromTextArea = function ( textarea , options ) {
15111520 if ( ! options ) options = { } ;
15121521 options . value = textarea . value ;
Original file line number Diff line number Diff line change @@ -581,6 +581,12 @@ <h2 id="api">Programming API</h2>
581581 the editor's current content).</ dd >
582582 </ dl >
583583
584+ < p id ="defineExtension "> If you want define extra methods in terms
585+ of the CodeMirror API, is it possible to
586+ use < code > CodeMirror.defineExtension(name, value)</ code > . This
587+ will cause the given value (usually a method) to be added to all
588+ CodeMirror instances created from then on.</ p >
589+
584590 < h2 id ="modeapi "> Writing CodeMirror Modes</ h2 >
585591
586592 < p > Modes typically consist of a JavaScript file and a CSS file.
You can’t perform that action at this time.
0 commit comments