 
 setUpChapter = (chapter) ->
   chapterId = chapter.id
-  headingEditorElemId = "edit-chapter-heading-#{chapterId}"
-  bodyEditorElemId    = "edit-chapter-body-#{chapterId}"
 
   # If you delete the chapter's body and heading, assume you want it gone.
   # (If you didn't, you can just re-add it; there couldn't have been data loss.)


  editorBodyPromise = new Promise (resolve, reject) ->
    sync.getSnapshot(chapter.snapshotId).done (snapshot) ->
      setUpEditor bodyEditorElemId, snapshot.html, true, (mutations, node) ->
        snapshotId    = chapter.snapshotId
        html          = node.innerHTML
        text          = node.textContent

loadAsCurrentDoc = (doc) ->
  app.ports.loadAsCurrentDoc.send doc

  setUpEditor getTitleElem, doc.title, false, (mutations, node) ->
    sync.getDoc(doc.id).done (doc) ->
      doc.title = node.textContent
      sync.saveDoc(doc).done -> app.ports.setTitle.send doc.title

  setUpEditor getDescriptionElem, doc.description, false, (mutations, node) ->
    sync.getDoc(doc.id).done (doc) ->
      doc.description = node.textContent
      sync.saveDoc(doc).done -> app.ports.setDescription.send doc.description
