diff --git a/deps/graph-parser/src/logseq/graph_parser/config.cljs b/deps/graph-parser/src/logseq/graph_parser/config.cljs index f37dbc10a..488d9f811 100644 --- a/deps/graph-parser/src/logseq/graph_parser/config.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/config.cljs @@ -31,7 +31,7 @@ (defn text-formats [] #{:json :org :md :yml :dat :asciidoc :rst :txt :markdown :adoc :html :js :ts :edn :clj :ml :rb :ex :erl :java :php :c :css - :excalidraw}) + :excalidraw :sh}) (defn img-formats [] diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 82376bc78..5c1c4a051 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -33,6 +33,7 @@ [frontend.extensions.zotero :as zotero] [frontend.format.block :as block] [frontend.format.mldoc :as mldoc] + [frontend.fs :as fs] [frontend.handler.block :as block-handler] [frontend.handler.common :as common-handler] [frontend.handler.dnd :as dnd] @@ -48,20 +49,20 @@ [frontend.security :as security] [frontend.state :as state] [frontend.template :as template] - [logseq.graph-parser.text :as text] [frontend.ui :as ui] [frontend.util :as util] [frontend.util.clock :as clock] [frontend.util.drawer :as drawer] - [frontend.util.text :as text-util] [frontend.util.property :as property] - [logseq.graph-parser.config :as gp-config] - [logseq.graph-parser.util :as gp-util] - [logseq.graph-parser.mldoc :as gp-mldoc] - [logseq.graph-parser.block :as gp-block] + [frontend.util.text :as text-util] [goog.dom :as gdom] [goog.object :as gobj] [lambdaisland.glogi :as log] + [logseq.graph-parser.block :as gp-block] + [logseq.graph-parser.config :as gp-config] + [logseq.graph-parser.mldoc :as gp-mldoc] + [logseq.graph-parser.text :as text] + [logseq.graph-parser.util :as gp-util] [medley.core :as medley] [promesa.core :as p] [reitit.frontend.easy :as rfe] @@ -271,12 +272,15 @@ (when @src (let [ext (keyword (util/get-file-ext @src)) + repo (state/get-current-repo) + repo-dir (config/get-repo-dir (state/get-current-repo)) + path (str (config/get-repo-dir repo) href) share-fn (fn [event] (util/stop event) (when (mobile-util/native-platform?) - (p/let [url (str (config/get-repo-dir (state/get-current-repo)) href)] - (.share Share #js {:url url - :title "Open file with your favorite app"}))))] + (.share Share #js {:url path + :title "Open file with your favorite app"})))] + (cond (contains? config/audio-formats ext) (audio-cp @src) @@ -284,13 +288,20 @@ (contains? (gp-config/img-formats) ext) (resizable-image config title @src metadata full_text true) + (contains? (gp-config/text-formats) ext) + [:a.asset-ref.is-plaintext {:href (rfe/href :file {:path path}) + :on-click (fn [_event] + (p/let [result (fs/read-file repo-dir path)] + (db/set-file-content! repo path result )))} + title] + (= ext :pdf) [:a.asset-ref.is-pdf {:href @src :on-click share-fn} title] :else - [:a.asset-ref.is-doc {:ref @src + [:a.asset-ref.is-doc {:href @src :on-click share-fn} title])))))