|  | @@ -8,8 +8,8 @@ if (Meteor.isClient) {
 | 
	
		
			
				|  |  |    Template.editor.helpers({
 | 
	
		
			
				|  |  |      // Return the id of the first document you can find.
 | 
	
		
			
				|  |  |      docid: function () {
 | 
	
		
			
				|  |  | -      const doc = Documents.findOne();
 | 
	
		
			
				|  |  | -      return doc ? doc._id : undefined;
 | 
	
		
			
				|  |  | +      setupCurrentDocument();
 | 
	
		
			
				|  |  | +      return Session.get("docid");
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      // Configure the CodeMirror editor.
 | 
	
		
			
				|  |  |      config: function () {
 | 
	
	
		
			
				|  | @@ -121,6 +121,17 @@ Meteor.methods({
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +function setupCurrentDocument() {
 | 
	
		
			
				|  |  | +  let doc;
 | 
	
		
			
				|  |  | +  // No docid set yet.
 | 
	
		
			
				|  |  | +  if (!Session.get("docid")) {
 | 
	
		
			
				|  |  | +    doc = Documents.findOne();
 | 
	
		
			
				|  |  | +    if (doc) {
 | 
	
		
			
				|  |  | +      Session.set("docid", doc._id);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  // This renames object keys by removing hyphens to make them compatible
 | 
	
		
			
				|  |  |  // with spacebars.
 | 
	
		
			
				|  |  |  function fixObjectsKeys(obj) {
 |