|
|
@@ -656,7 +656,7 @@
|
|
|
|
|
|
All page-names are sanitized except page-name-in-block"
|
|
|
[state
|
|
|
- {:keys [contents-page? whiteboard-page? html-export? other-position? show-unique-title? stop-click-event?
|
|
|
+ {:keys [contents-page? whiteboard-page? other-position? show-unique-title? stop-click-event?
|
|
|
on-context-menu]
|
|
|
:or {stop-click-event? true}
|
|
|
:as config}
|
|
|
@@ -701,12 +701,13 @@
|
|
|
(reset! *mouse-down? true))))
|
|
|
:on-pointer-up (fn [e]
|
|
|
(when @*mouse-down?
|
|
|
+ (util/stop e)
|
|
|
(state/clear-edit!)
|
|
|
- (when-not (or (:disable-click? config)
|
|
|
- (:disable-redirect? config))
|
|
|
+ (when-not (:disable-click? config)
|
|
|
(open-page-ref config page-entity e page-name contents-page?))
|
|
|
(reset! *mouse-down? false)))
|
|
|
:on-key-up (fn [e] (when (and e (= (.-key e) "Enter") (not other-position?))
|
|
|
+ (util/stop e)
|
|
|
(state/clear-edit!)
|
|
|
(open-page-ref config page-entity e page-name contents-page?)))}
|
|
|
on-context-menu
|
|
|
@@ -726,7 +727,7 @@
|
|
|
(last child)
|
|
|
(let [{:keys [content children]} (last child)
|
|
|
page-name (subs content 2 (- (count content) 2))]
|
|
|
- (rum/with-key (page-reference html-export? page-name (assoc config :children children) nil) page-name))))
|
|
|
+ (rum/with-key (page-reference (assoc config :children children) page-name nil) page-name))))
|
|
|
(let [page-component (cond
|
|
|
(and label
|
|
|
(string? label)
|
|
|
@@ -943,26 +944,22 @@
|
|
|
config (assoc config :block entity)]
|
|
|
(cond
|
|
|
entity
|
|
|
- (if (or (ldb/page? entity) (not (:block/page entity)))
|
|
|
- (let [page-name (some-> (:block/title entity) util/page-name-sanity-lc)
|
|
|
- whiteboard-page? (model/whiteboard-page? entity)
|
|
|
- inner (page-inner (assoc config :whiteboard-page? whiteboard-page?) entity children label)
|
|
|
- modal? (shui-dialog/has-modal?)]
|
|
|
- (if (and (not (util/mobile?))
|
|
|
- (not= page-name (:id config))
|
|
|
- (not (false? preview?))
|
|
|
- (not disable-preview?)
|
|
|
- (not modal?))
|
|
|
- (page-preview-trigger (assoc config :children inner) entity)
|
|
|
- inner))
|
|
|
- (block-reference config (:block/uuid entity)
|
|
|
- (if (string? label)
|
|
|
- (gp-mldoc/inline->edn label (mldoc/get-default-config :markdown))
|
|
|
- label)))
|
|
|
+ (let [page-name (some-> (:block/title entity) util/page-name-sanity-lc)
|
|
|
+ whiteboard-page? (model/whiteboard-page? entity)
|
|
|
+ inner (page-inner (assoc config :whiteboard-page? whiteboard-page?) entity children label)
|
|
|
+ modal? (shui-dialog/has-modal?)]
|
|
|
+ (if (and (not (util/mobile?))
|
|
|
+ (not= page-name (:id config))
|
|
|
+ (not (false? preview?))
|
|
|
+ (not disable-preview?)
|
|
|
+ (not modal?))
|
|
|
+ (page-preview-trigger (assoc config :children inner) entity)
|
|
|
+ inner))
|
|
|
|
|
|
(and (:block/name page) show-non-exists-page?)
|
|
|
(page-inner config (merge
|
|
|
- {:block/title (:block/name page)
|
|
|
+ {:block/title (or (:block/title page)
|
|
|
+ (:block/name page))
|
|
|
:block/name (:block/name page)}
|
|
|
page) children label)
|
|
|
|
|
|
@@ -977,8 +974,9 @@
|
|
|
|
|
|
(rum/defc page-cp
|
|
|
[config page]
|
|
|
- (rum/with-key (page-cp-inner config page)
|
|
|
- (or (str (:db/id page)) (str (:block/uuid page)) (:block/name page))))
|
|
|
+ (let [id (or (:db/id page) (:block/uuid page) (:block/name page))]
|
|
|
+ (rum/with-key (page-cp-inner config page)
|
|
|
+ (str id))))
|
|
|
|
|
|
(rum/defc asset-reference
|
|
|
[config title path]
|
|
|
@@ -1068,58 +1066,62 @@
|
|
|
(declare block-positioned-properties)
|
|
|
(rum/defc page-reference < rum/reactive db-mixins/query
|
|
|
"Component for page reference"
|
|
|
- [html-export? uuid-or-title* {:keys [nested-link? show-brackets? id] :as config} label]
|
|
|
+ [{:keys [html-export? nested-link? show-brackets? id] :as config*} uuid-or-title* label]
|
|
|
(when uuid-or-title*
|
|
|
(let [uuid-or-title (if (string? uuid-or-title*)
|
|
|
- (string/trim uuid-or-title*)
|
|
|
+ (let [str-id (string/trim uuid-or-title*)]
|
|
|
+ (if (util/uuid-string? str-id)
|
|
|
+ (parse-uuid str-id)
|
|
|
+ str-id))
|
|
|
uuid-or-title*)
|
|
|
- show-brackets? (if (some? show-brackets?) show-brackets? (state/show-brackets?))
|
|
|
- contents-page? (= "contents" (string/lower-case (str id)))
|
|
|
- block* (db/get-page uuid-or-title)
|
|
|
- block (or (some-> (:db/id block*) db/sub-block) block*)
|
|
|
- config' (assoc config
|
|
|
- :label (mldoc/plain->text label)
|
|
|
- :contents-page? contents-page?
|
|
|
- :show-icon? true?)
|
|
|
- asset? (some? (:logseq.property.asset/type block))
|
|
|
- page? (ldb/page? block)
|
|
|
- brackets? (and (or show-brackets? nested-link?)
|
|
|
- (not html-export?)
|
|
|
- (not contents-page?)
|
|
|
- page?)]
|
|
|
- (when-not (= (:db/id block) (:db/id (:block config)))
|
|
|
- (cond
|
|
|
- (and asset? (img-audio-video? block))
|
|
|
- (asset-cp config block)
|
|
|
-
|
|
|
- (or page? (:block/tags block))
|
|
|
- [:span.page-reference
|
|
|
- {:data-ref (str uuid-or-title)}
|
|
|
- (when brackets?
|
|
|
- [:span.text-gray-500.bracket page-ref/left-brackets])
|
|
|
- (when (and (config/db-based-graph?) (ldb/class-instance? (db/entity :logseq.class/Task) block))
|
|
|
- [:div.inline-block
|
|
|
- {:style {:margin-right 1
|
|
|
- :margin-top -2
|
|
|
- :vertical-align "middle"}
|
|
|
- :on-pointer-down (fn [e]
|
|
|
- (util/stop e))}
|
|
|
- (block-positioned-properties config block :block-left)])
|
|
|
- (page-cp config' (if (uuid? uuid-or-title)
|
|
|
- {:block/uuid uuid-or-title}
|
|
|
- {:block/name uuid-or-title}))
|
|
|
- (when brackets?
|
|
|
- [:span.text-gray-500.bracket page-ref/right-brackets])]
|
|
|
-
|
|
|
- (and (string? uuid-or-title) (string/ends-with? uuid-or-title ".excalidraw"))
|
|
|
- [:div.draw {:on-click (fn [e]
|
|
|
- (.stopPropagation e))}
|
|
|
- (excalidraw uuid-or-title (:block/uuid config))]
|
|
|
-
|
|
|
- :else
|
|
|
- (page-cp config' (if (uuid? uuid-or-title)
|
|
|
- {:block/uuid uuid-or-title}
|
|
|
- {:block/name uuid-or-title})))))))
|
|
|
+ self-reference? (when (set? (:ref-set config*))
|
|
|
+ (contains? (:ref-set config*) uuid-or-title))]
|
|
|
+ (when-not self-reference?
|
|
|
+ (let [config (update config* :ref-set (fn [s]
|
|
|
+ (let [bid (:block/uuid (:block config*))]
|
|
|
+ (if (nil? s)
|
|
|
+ #{bid}
|
|
|
+ (conj s bid uuid-or-title)))))
|
|
|
+ show-brackets? (if (some? show-brackets?) show-brackets? (state/show-brackets?))
|
|
|
+ contents-page? (= "contents" (string/lower-case (str id)))
|
|
|
+ block* (db/get-page uuid-or-title)
|
|
|
+ block (or (some-> (:db/id block*) db/sub-block) block*)
|
|
|
+ config' (assoc config
|
|
|
+ :label (mldoc/plain->text label)
|
|
|
+ :contents-page? contents-page?
|
|
|
+ :show-icon? true?)
|
|
|
+ asset? (some? (:logseq.property.asset/type block))
|
|
|
+ brackets? (and (or show-brackets? nested-link?)
|
|
|
+ (not html-export?)
|
|
|
+ (not contents-page?))]
|
|
|
+ (when-not (= (:db/id block) (:db/id (:block config)))
|
|
|
+ (cond
|
|
|
+ (and asset? (img-audio-video? block))
|
|
|
+ (asset-cp config block)
|
|
|
+
|
|
|
+ (and (string? uuid-or-title) (string/ends-with? uuid-or-title ".excalidraw"))
|
|
|
+ [:div.draw {:on-click (fn [e]
|
|
|
+ (.stopPropagation e))}
|
|
|
+ (excalidraw uuid-or-title (:block/uuid config))]
|
|
|
+
|
|
|
+ :else
|
|
|
+ [:span.page-reference
|
|
|
+ {:data-ref (str uuid-or-title)}
|
|
|
+ (when brackets?
|
|
|
+ [:span.text-gray-500.bracket page-ref/left-brackets])
|
|
|
+ (when (and (config/db-based-graph?) (ldb/class-instance? (db/entity :logseq.class/Task) block))
|
|
|
+ [:div.inline-block
|
|
|
+ {:style {:margin-right 1
|
|
|
+ :margin-top -2
|
|
|
+ :vertical-align "middle"}
|
|
|
+ :on-pointer-down (fn [e]
|
|
|
+ (util/stop e))}
|
|
|
+ (block-positioned-properties config block :block-left)])
|
|
|
+ (page-cp config' (if (uuid? uuid-or-title)
|
|
|
+ {:block/uuid uuid-or-title}
|
|
|
+ {:block/name uuid-or-title}))
|
|
|
+ (when brackets?
|
|
|
+ [:span.text-gray-500.bracket page-ref/right-brackets])])))))))
|
|
|
|
|
|
(defn- latex-environment-content
|
|
|
[name option content]
|
|
|
@@ -1340,13 +1342,18 @@
|
|
|
(set-block! block)))
|
|
|
[])
|
|
|
(when-not self-reference?
|
|
|
- (if block
|
|
|
+ (cond
|
|
|
+ (config/db-based-graph?)
|
|
|
+ (page-reference config block-id label)
|
|
|
+
|
|
|
+ block
|
|
|
(let [config' (update config :ref-set (fn [s]
|
|
|
(let [bid (:block/uuid (:block config))]
|
|
|
(if (nil? s)
|
|
|
#{bid}
|
|
|
(conj s bid block-id)))))]
|
|
|
(block-reference-aux config' block label))
|
|
|
+ :else
|
|
|
(invalid-node-ref block-id)))))
|
|
|
|
|
|
(defn- render-macro
|
|
|
@@ -1475,7 +1482,7 @@
|
|
|
(block-reference config id label))
|
|
|
|
|
|
(not (string/includes? s "."))
|
|
|
- (page-reference (:html-export? config) s config label)
|
|
|
+ (page-reference config s label)
|
|
|
|
|
|
(path/protocol-url? s)
|
|
|
(->elem :a {:href s
|
|
|
@@ -1507,9 +1514,9 @@
|
|
|
(map-inline config label)))
|
|
|
|
|
|
:else
|
|
|
- (page-reference (:html-export? config) s config label)))
|
|
|
+ (page-reference config s label)))
|
|
|
|
|
|
-(defn- link-cp [config html-export? link]
|
|
|
+(defn- link-cp [config link]
|
|
|
(let [{:keys [url label title metadata full_text]} link]
|
|
|
(match url
|
|
|
["Block_ref" id]
|
|
|
@@ -1533,7 +1540,7 @@
|
|
|
(let [label* (if (seq (mldoc/plain->text label)) label nil)]
|
|
|
(if (and (string? page) (string/blank? page))
|
|
|
[:span (ref/->page-ref page)]
|
|
|
- (page-reference (:html-export? config) page config label*)))))
|
|
|
+ (page-reference config page label*)))))
|
|
|
|
|
|
["Embed_data" src]
|
|
|
(image-link config url src nil metadata full_text)
|
|
|
@@ -1555,7 +1562,7 @@
|
|
|
block (db/entity [:block/uuid id])]
|
|
|
(if (:block/pre-block? block)
|
|
|
(let [page (:block/page block)]
|
|
|
- (page-reference html-export? (:block/name page) config label))
|
|
|
+ (page-reference config (:block/name page) label))
|
|
|
(block-reference config (:link path) label)))
|
|
|
|
|
|
(= protocol "file")
|
|
|
@@ -1977,7 +1984,7 @@
|
|
|
(nested-link config html-export? link)
|
|
|
|
|
|
["Link" link]
|
|
|
- (link-cp config html-export? link)
|
|
|
+ (link-cp config link)
|
|
|
|
|
|
[(:or "Verbatim" "Code") s]
|
|
|
[:code s]
|
|
|
@@ -2052,7 +2059,6 @@
|
|
|
selected? (contains? selected block-id)]
|
|
|
(when-not selected?
|
|
|
(util/clear-selection!)
|
|
|
- (state/conj-selection-block! (gdom/getElement block-id) :down)
|
|
|
(editor-handler/highlight-block! uuid)))
|
|
|
|
|
|
(editor-handler/block->data-transfer! uuid event false)
|
|
|
@@ -2171,7 +2177,7 @@
|
|
|
(reset! *bullet-dragging? true)
|
|
|
(util/stop-propagation event)
|
|
|
(bullet-drag-start event block uuid block-id))
|
|
|
- :on-drag-end (fn [_]
|
|
|
+ :on-drag-end (fn [_e]
|
|
|
(reset! *bullet-dragging? false))
|
|
|
:blockid (str uuid)
|
|
|
:class (str (when collapsed? "bullet-closed")
|
|
|
@@ -3039,7 +3045,6 @@
|
|
|
(block-content config block edit-input-id block-id *show-query?))))
|
|
|
|
|
|
(rum/defcs ^:large-vars/cleanup-todo block-content-or-editor < rum/reactive
|
|
|
- (rum/local false ::hover?)
|
|
|
[state config {:block/keys [uuid] :as block} {:keys [edit-input-id block-id edit? hide-block-refs-count? refs-count *hide-block-refs? *show-query?]}]
|
|
|
(let [format (if (config/db-based-graph? (state/get-current-repo))
|
|
|
:markdown
|
|
|
@@ -3076,7 +3081,10 @@
|
|
|
:format format}
|
|
|
edit-input-id
|
|
|
config))]
|
|
|
- [:div.flex.flex-1.w-full.block-content-wrapper {:style {:display "flex"}}
|
|
|
+ [:div.flex.flex-1.w-full.block-content-wrapper
|
|
|
+ {:style {:display "flex"}}
|
|
|
+ (when-let [actions-cp (:page-title-actions-cp config)]
|
|
|
+ (actions-cp block))
|
|
|
(block-content-with-error config block edit-input-id block-id *show-query? editor-box)
|
|
|
|
|
|
(when (and (not hide-block-refs-count?)
|
|
|
@@ -3182,7 +3190,6 @@
|
|
|
rest)
|
|
|
config (assoc config
|
|
|
:breadcrumb? true
|
|
|
- :disable-redirect? true
|
|
|
:disable-preview? true
|
|
|
:stop-click-event? false)]
|
|
|
(when (seq parents)
|
|
|
@@ -3615,8 +3622,6 @@
|
|
|
|
|
|
[:div.flex.flex-col.w-full
|
|
|
[:div.block-main-content.flex.flex-row.gap-2
|
|
|
- (when-let [actions-cp (:page-title-actions-cp config)]
|
|
|
- (actions-cp block))
|
|
|
(when page-icon
|
|
|
page-icon)
|
|
|
|