Browse Source

Merge pull request #2140 from ian-r-rose/expose_modelDB

Surface the `IModelDB` of a document model.
Steven Silvester 8 years ago
parent
commit
f05fa83a1e

+ 12 - 1
packages/codeeditor/src/editor.ts

@@ -167,6 +167,12 @@ namespace CodeEditor {
      * The currently selected code.
      */
     readonly selections: IObservableMap<ITextSelection[]>;
+
+    /**
+     * The underlying `IModelDB` instance in which model
+     * data is stored.
+     */
+    readonly modelDB: IModelDB;
   }
 
   /**
@@ -196,6 +202,12 @@ namespace CodeEditor {
       this.modelDB.createMap('selections');
     }
 
+    /**
+     * The underlying `IModelDB` instance in which model
+     * data is stored.
+     */
+    readonly modelDB: IModelDB;
+
     /**
      * A signal emitted when a mimetype changes.
      */
@@ -257,7 +269,6 @@ namespace CodeEditor {
       });
     }
 
-    protected modelDB: IModelDB = null;
     private _isDisposed = false;
     private _mimeTypeChanged = new Signal<this, IChangedArgs<string>>(this);
   }

+ 10 - 0
packages/docregistry/src/registry.ts

@@ -580,6 +580,16 @@ namespace DocumentRegistry {
      */
     readonly defaultKernelLanguage: string;
 
+    /**
+     * The underlying `IModelDB` instance in which model
+     * data is stored.
+     *
+     * ### Notes
+     * Making direct edits to the values stored in the`IModelDB`
+     * is not recommended, and may produce unpredictable results.
+     */
+    readonly modelDB: IModelDB;
+
     /**
      * Serialize the model to a string.
      */

+ 8 - 0
test/src/codeeditor/editor.spec.ts

@@ -117,6 +117,14 @@ describe('CodeEditor.Model', () => {
 
   });
 
+  describe('#modelDB', () => {
+
+    it('should get the modelDB object associated with the model', () => {
+      expect(model.modelDB.has('value')).to.be(true);
+    });
+
+  });
+
   describe('#isDisposed', () => {
 
     it('should test whether the model is disposed', () => {