        (goog.editor/Field. element)
        (goog.editor/SeamlessField. element))))
 
+(declare list-documents)
+
 (defn launch [element doc-session]
   (let [field     (spawn-editor element)
         content   (doc-session :get :content)

                    CLICK
                    (fn [e] (dispatch/fire :document-requested (.-id item)))))))

(defn excerpt [s chars]
  (.substring s 0 chars))

(defn list-documents [documents]
  (let [element ($ "#sidebar-documents > ol")]
    (destroy-children! element)
    (doseq [[id doc] documents]
      (append! element (single-node (str "<li id=\"" (name id) "\">"
                                         (excerpt (:content doc) 20)
                                         "</li>"))))
    (add-documents-list-listeners)))


(ns one.sample.view.editor
  (:use [query            :only [$]]
        [domina           :only [append! destroy-children! detach! nodes
                                 single-node]]
        [one.sample.model :only [docs]])
  (:require [goog.events               :as event]
            [goog.editor.Field         :as editor-iframe]
            [goog.editor.SeamlessField :as editor-div]
