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

      # positives while the chapter is being created, causing it to be deleted.
      (!mutations.some ({addedNodes, removedNodes}) ->
        addedNodes.length > 0 || removedNodes.length > 0) &&
      !document.getElementById(headingEditorElemId).textContent.match(/\S/) &&
      !document.getElementById(bodyEditorElemId).textContent.match(/\S/)

  editorHeadingPromise = setUpEditor headingEditorElemId, chapter.heading, false, (mutations, node) ->
    sync.getCurrentDoc().done (doc) ->
      heading = node.textContent



setUpChapter = (chapter) ->
  chapterId = chapter.id

  # 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.)
