(ns frontend.handler.db-based.export "Handles DB graph exports and imports across graphs" (:require [cljs.pprint :as pprint] [clojure.string :as string] [frontend.config :as config] [frontend.handler.notification :as notification] [frontend.state :as state] [frontend.util :as util] [frontend.util.page :as page-util] [goog.dom :as gdom] [promesa.core :as p])) (defn ^:export export-block-data [] ;; Use editor state to locate most recent block (if-let [block-uuid (:block-id (first (state/get-editor-args)))] (p/let [result (state/ (string/replace repo config/local-db-prefix "") (string/replace #"^/+" "") (str "_" (quot (util/time-ms) 1000)) (str "." (string/lower-case (name extension))))) (defn export-repo-as-db-edn! [repo] (p/let [result (state/> pull-data js/encodeURIComponent (str "data:text/edn;charset=utf-8,")) filename (file-name repo :edn)] (when-let [anchor (gdom/getElement "download-as-db-edn")] (.setAttribute anchor "href" data-str) (.setAttribute anchor "download" filename) (.click anchor))))))