diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 3e8fa9b60a..1cd72cd6fa 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -160,7 +160,7 @@ (string/join "/" (reverse parts)))))))) (rum/defc asset-container - [src title child] + [src title full-text child] (rum/with-context [[t] i18n/*tongue-context*] (let [get-block-id #(and % (.getAttribute (.closest % "[blockid]") "blockid")) repo (state/get-current-repo) @@ -185,7 +185,8 @@ :force-local (and sub-selected (get sub-selected 0)) :repo repo :href src - :title title}))})] + :title title + :full-text full-text}))})] (state/set-modal! confirm-fn) (util/stop e)))} svg/trash-sm]] child]]))) @@ -225,7 +226,9 @@ (p/then (editor-handler/make-asset-url href) #(reset! src %))) (when @src - (resizable-image config title @src metadata full_text)))) + (asset-container + href title full_text + (resizable-image config title @src metadata full_text))))) ;; TODO: safe encoding asciis ;; TODO: image link to another link @@ -236,8 +239,7 @@ nil (safe-read-string metadata false)) title (second (first label))] - (if (or (util/starts-with? href "/assets") - (util/starts-with? href "../assets")) + (if (config/local-asset? href) (asset-link config title href label metadata full_text) (let [href (if (util/starts-with? href "http") href diff --git a/src/main/frontend/components/block.css b/src/main/frontend/components/block.css index 2e5734444d..b24c383607 100644 --- a/src/main/frontend/components/block.css +++ b/src/main/frontend/components/block.css @@ -37,6 +37,7 @@ top: 0; right: 0; padding: 5px; + z-index: 1; display: none; > a { diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index e6600f60e3..2bd8fc8edc 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -1589,12 +1589,14 @@ (string/replace (str "[[" href "][" title "]]") replacement))))) (defn delete-asset-of-block! - [{:keys [repo href title block-id force-local] :as opts}] + [{:keys [repo href title full-text block-id force-local] :as opts}] (let [block (db-model/query-block-by-uuid block-id) _ (or block (throw (str block-id " not exists"))) format (:block/format block) text (:block/content block) - content (replace-asset-link-with-href format text href title "")] + content (if full-text + (string/replace text full-text "") + (replace-asset-link-with-href format text href title ""))] (save-block! repo block content) (when force-local ;; FIXME: should be relative to current block page path