1234567891011121314151617181920212223242526272829 |
- // Note: not Documents, but this.Documents, because of the editing package (?)
- this.Documents = new Mongo.Collection("documents");
- if (Meteor.isClient) {
- Template.editor.helpers({
- docid: function () {
- let doc = Documents.findOne();
- return doc ? doc._id : undefined;
- },
- config: function () {
- return function (editor) {
- editor.on("change", function (cm_editor, info) {
- let $preview = $("#viewer_iframe");
- $preview.contents().find("html").html(cm_editor.getValue());
- });
- };
- }
- });
- }
- if (Meteor.isServer) {
- Meteor.startup(function () {
- // startup code that creates a document in case there isn't one yet.
- if (!Documents.findOne()) {
- Documents.insert({ title: "my new document" });
- }
- });
- }
|