 ;;**********************************************************
 ;; transient docs
 ;;**********************************************************
-
-(def active-dialog nil)
 
 (defui open-input [this]
   [:input {:type "file"}]

                                    info (:info @this)
                                    fname (:name info)
                                    ext (when-let [e (:exts info)]
                                          (str "." (name (first e))))
                                    s (save-input this (files/join path (str fname ext)))]
                                (set! active-dialog s)
                                (dom/trigger s :click))))

(behavior ::save-as-rename!
                  :triggers #{:save-as-rename!}
                  :reaction (fn [this]
                              (dom/trigger (save-input this (-> @this :info :path)) :click)))

(behavior ::save-as
                  :triggers #{:save-as!}
                  :reaction (fn [this path]
                              (let [type (files/path->type path)
                                    prev-tags (-> @this :info :tags)
                                    mode (files/path->mode path)
                                    neue-doc (doc/create {:doc (editor/get-doc this)
                                                          :line-ending files/line-ending
                                                          :mtime (files/stats path)
                                                          :mime mode})]
                                (when (:doc @this)
                                  (object/raise (:doc @this) :close.force))
                                (doc/register-doc neue-doc path)
                                (object/update! this [:info] merge (path->info path))
                                (object/merge! this {:dirty true
                                                     :doc neue-doc})
                                (editor/set-mode this mode)
                                (object/remove-tags this (conj prev-tags :editor.transient))
                                (object/add-tags this (conj (:tags type) :editor.file-backed))
                                (object/raise this :save-as)
                                (object/raise this :save))))

(behavior ::check-read-only
                  :desc "Opener: check if file is read only"

                     (when-not (empty? (dom/val me))
                       (object/raise this :open! (dom/val me))))))

(defn save-input [this path]
  (ipc/call this :save-as!
            :dialog.showSaveDialog ipc/win {:defaultPath path}))

(defn path->info [path]
  (when path
