mirror of https://github.com/logseq/logseq
wip: shape links
parent
76d2282791
commit
ce7133e39d
|
@ -116,7 +116,8 @@
|
||||||
[repo search-q {:keys [type data alias]}]
|
[repo search-q {:keys [type data alias]}]
|
||||||
(search-handler/add-search-to-recent! repo search-q)
|
(search-handler/add-search-to-recent! repo search-q)
|
||||||
(search-handler/clear-search!)
|
(search-handler/clear-search!)
|
||||||
(let [whiteboard? (whiteboard-handler/whiteboard-mode?)]
|
(let [whiteboard? (whiteboard-handler/whiteboard-mode?)
|
||||||
|
search-mode (:search/mode @state/state)]
|
||||||
(case type
|
(case type
|
||||||
:graph-add-filter
|
:graph-add-filter
|
||||||
(state/add-graph-search-filter! search-q)
|
(state/add-graph-search-filter! search-q)
|
||||||
|
@ -127,6 +128,10 @@
|
||||||
(when whiteboard?
|
(when whiteboard?
|
||||||
(whiteboard-handler/create-page! search-q)))
|
(whiteboard-handler/create-page! search-q)))
|
||||||
|
|
||||||
|
:go-to-whiteboard
|
||||||
|
(route/redirect! {:to :whiteboard
|
||||||
|
:path-params {:name search-q}})
|
||||||
|
|
||||||
:page
|
:page
|
||||||
(let [data (or alias data)]
|
(let [data (or alias data)]
|
||||||
(if whiteboard?
|
(if whiteboard?
|
||||||
|
@ -199,6 +204,11 @@
|
||||||
[:div.text.font-bold (str (t :new-page) ": ")
|
[:div.text.font-bold (str (t :new-page) ": ")
|
||||||
[:span.ml-1 (str "\"" search-q "\"")]]
|
[:span.ml-1 (str "\"" search-q "\"")]]
|
||||||
|
|
||||||
|
:go-to-whiteboard
|
||||||
|
[:div.text.font-bold (str (t :go-to-whiteboard) ": ")
|
||||||
|
[:span.ml-1 (str "\"" search-q "\"")]]
|
||||||
|
|
||||||
|
|
||||||
:page
|
:page
|
||||||
[:span {:data-page-ref data}
|
[:span {:data-page-ref data}
|
||||||
(when alias
|
(when alias
|
||||||
|
@ -247,9 +257,16 @@
|
||||||
all?)
|
all?)
|
||||||
[]
|
[]
|
||||||
[{:type :new-page}])
|
[{:type :new-page}])
|
||||||
result (if config/publishing?
|
go-to-whiteboard [{:type :go-to-whiteboard}]
|
||||||
|
result (cond
|
||||||
|
config/publishing?
|
||||||
(concat pages files blocks)
|
(concat pages files blocks)
|
||||||
(concat new-page pages files blocks))
|
|
||||||
|
(= :whiteboard/link search-mode)
|
||||||
|
(concat pages blocks)
|
||||||
|
|
||||||
|
:else
|
||||||
|
(concat new-page go-to-whiteboard pages files blocks))
|
||||||
result (if (= search-mode :graph)
|
result (if (= search-mode :graph)
|
||||||
[{:type :graph-add-filter}]
|
[{:type :graph-add-filter}]
|
||||||
result)
|
result)
|
||||||
|
@ -344,8 +361,17 @@
|
||||||
(search-result-item "Page" original-name))
|
(search-result-item "Page" original-name))
|
||||||
nil))}))])
|
nil))}))])
|
||||||
|
|
||||||
(def default-placeholder
|
(defn default-placeholder
|
||||||
(if config/publishing? (t :search/publishing) (t :search)))
|
[search-mode]
|
||||||
|
(cond
|
||||||
|
config/publishing?
|
||||||
|
(t :search/publishing)
|
||||||
|
|
||||||
|
(= search-mode :whiteboard/link)
|
||||||
|
(t :whiteboard/link-whiteboard-or-block)
|
||||||
|
|
||||||
|
:else
|
||||||
|
(t :search)))
|
||||||
|
|
||||||
(rum/defcs search-modal < rum/reactive
|
(rum/defcs search-modal < rum/reactive
|
||||||
(shortcut/disable-all-shortcuts)
|
(shortcut/disable-all-shortcuts)
|
||||||
|
@ -371,7 +397,7 @@
|
||||||
(t :graph-search)
|
(t :graph-search)
|
||||||
:page
|
:page
|
||||||
(t :page-search)
|
(t :page-search)
|
||||||
default-placeholder)
|
(default-placeholder search-mode))
|
||||||
:auto-complete (if (util/chrome?) "chrome-off" "off") ; off not working here
|
:auto-complete (if (util/chrome?) "chrome-off" "off") ; off not working here
|
||||||
:value search-q
|
:value search-q
|
||||||
:on-change (fn [e]
|
:on-change (fn [e]
|
||||||
|
|
|
@ -37,5 +37,6 @@
|
||||||
tldr-name (str "draws/" name ".tldr")]
|
tldr-name (str "draws/" name ".tldr")]
|
||||||
[:div.absolute.w-full.h-full
|
[:div.absolute.w-full.h-full
|
||||||
;; makes sure the whiteboard will not cover the borders
|
;; makes sure the whiteboard will not cover the borders
|
||||||
{:style {:padding "0.5px"}}
|
{:key name
|
||||||
|
:style {:padding "0.5px"}}
|
||||||
(tldraw-app {:file tldr-name})]))
|
(tldraw-app {:file tldr-name})]))
|
||||||
|
|
|
@ -208,9 +208,11 @@
|
||||||
:unlink "unlink"
|
:unlink "unlink"
|
||||||
:search/publishing "Search"
|
:search/publishing "Search"
|
||||||
:search "Search or create page"
|
:search "Search or create page"
|
||||||
|
:whiteboard/link-whiteboard-or-block "Link whiteboard/page/block"
|
||||||
:page-search "Search in the current page"
|
:page-search "Search in the current page"
|
||||||
:graph-search "Search graph"
|
:graph-search "Search graph"
|
||||||
:new-page "New page"
|
:new-page "New page"
|
||||||
|
:go-to-whiteboard "Go to whiteboard"
|
||||||
:new-file "New file"
|
:new-file "New file"
|
||||||
:new-graph "Add new graph"
|
:new-graph "Add new graph"
|
||||||
:graph "Graph"
|
:graph "Graph"
|
||||||
|
|
|
@ -38,7 +38,10 @@
|
||||||
(draw-handler/save-draw! file s)))
|
(draw-handler/save-draw! file s)))
|
||||||
:model data
|
:model data
|
||||||
:onApp (fn [app]
|
:onApp (fn [app]
|
||||||
(state/set-state! [:ui/whiteboards (::id state)] app))})])))
|
(state/set-state! [:ui/whiteboards (::id state)] app)
|
||||||
|
(gobj/set app "pubEvent"
|
||||||
|
(fn [type & args]
|
||||||
|
(state/pub-event! (cons (keyword type) args)))))})])))
|
||||||
|
|
||||||
(rum/defc tldraw-app
|
(rum/defc tldraw-app
|
||||||
[option]
|
[option]
|
||||||
|
|
|
@ -401,6 +401,10 @@
|
||||||
template
|
template
|
||||||
{:target page}))))))
|
{:target page}))))))
|
||||||
|
|
||||||
|
(defmethod handle :tldraw-link [[_ shapes]]
|
||||||
|
(route-handler/go-to-search! :whiteboard/link)
|
||||||
|
(state/set-state! :whiteboard/linked-shapes shapes))
|
||||||
|
|
||||||
(defn run!
|
(defn run!
|
||||||
[]
|
[]
|
||||||
(let [chan (state/get-events-chan)]
|
(let [chan (state/get-events-chan)]
|
||||||
|
|
|
@ -135,6 +135,7 @@ const _ContextBar: TLContextBarComponent<Shape> = ({
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<a class="shape-link" onClick={() => app.pubEvent("tldraw-link", shapes)}>Link</a>
|
||||||
</div>
|
</div>
|
||||||
</HTMLContainer>
|
</HTMLContainer>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue