improve: remove image with extension link(image) syntax

pull/1108/head
charlie 2021-01-15 18:14:10 +08:00
parent eeabf42fb6
commit f564cc3616
3 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -37,6 +37,7 @@
top: 0;
right: 0;
padding: 5px;
z-index: 1;
display: none;
> a {

View File

@ -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