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