mirror of https://github.com/logseq/logseq
fix: reorg routes
parent
eae267364a
commit
a05ab09f89
|
@ -23,9 +23,9 @@
|
||||||
:excalidraw
|
:excalidraw
|
||||||
{:entries [frontend.extensions.excalidraw]
|
{:entries [frontend.extensions.excalidraw]
|
||||||
:depends-on #{:main}}
|
:depends-on #{:main}}
|
||||||
;; :tldraw
|
:tldraw
|
||||||
;; {:entries [frontend.extensions.tldraw]
|
{:entries [frontend.extensions.tldraw]
|
||||||
;; :depends-on #{:main}}
|
:depends-on #{:main}}
|
||||||
}
|
}
|
||||||
:output-dir "./static/js"
|
:output-dir "./static/js"
|
||||||
:asset-path "/static/js"
|
:asset-path "/static/js"
|
||||||
|
@ -84,9 +84,9 @@
|
||||||
:excalidraw
|
:excalidraw
|
||||||
{:entries [frontend.extensions.excalidraw]
|
{:entries [frontend.extensions.excalidraw]
|
||||||
:depends-on #{:main}}
|
:depends-on #{:main}}
|
||||||
;; :tldraw
|
:tldraw
|
||||||
;; {:entries [frontend.extensions.tldraw]
|
{:entries [frontend.extensions.tldraw]
|
||||||
;; :depends-on #{:main}}
|
:depends-on #{:main}}
|
||||||
}
|
}
|
||||||
:output-dir "./static/js/publishing"
|
:output-dir "./static/js/publishing"
|
||||||
:asset-path "static/js"
|
:asset-path "static/js"
|
||||||
|
|
|
@ -274,7 +274,6 @@
|
||||||
["Calculator" [[:editor/input "```calc\n\n```" {:backward-pos 4}]
|
["Calculator" [[:editor/input "```calc\n\n```" {:backward-pos 4}]
|
||||||
[:codemirror/focus]] "Insert a calculator"]
|
[:codemirror/focus]] "Insert a calculator"]
|
||||||
["draw" (draw-handler/initialize-excalidarw-file) "Draw a graph with Excalidraw"]
|
["draw" (draw-handler/initialize-excalidarw-file) "Draw a graph with Excalidraw"]
|
||||||
["tldraw" (draw-handler/initialize-tldraw-file) "Draw a graph with tldraw"]
|
|
||||||
|
|
||||||
(when (util/zh-CN-supported?)
|
(when (util/zh-CN-supported?)
|
||||||
["Embed Bilibili video" [[:editor/input "{{bilibili }}" {:last-pattern (state/get-editor-command-trigger)
|
["Embed Bilibili video" [[:editor/input "{{bilibili }}" {:last-pattern (state/get-editor-command-trigger)
|
||||||
|
|
|
@ -596,19 +596,6 @@
|
||||||
(when draw-component
|
(when draw-component
|
||||||
(draw-component {:file file :block-uuid block-uuid}))))
|
(draw-component {:file file :block-uuid block-uuid}))))
|
||||||
|
|
||||||
(defonce tldraw-loaded? (atom false))
|
|
||||||
(rum/defc tldraw < rum/reactive
|
|
||||||
{:init (fn [state]
|
|
||||||
(p/let [_ (loader/load :tldraw)]
|
|
||||||
(reset! tldraw-loaded? true))
|
|
||||||
state)}
|
|
||||||
[file block-uuid]
|
|
||||||
(let [loaded? (rum/react tldraw-loaded?)
|
|
||||||
draw-component (when loaded?
|
|
||||||
(resolve 'frontend.extensions.tldraw/draw))]
|
|
||||||
(when draw-component
|
|
||||||
(draw-component {:file file :block-uuid block-uuid}))))
|
|
||||||
|
|
||||||
(rum/defc page-reference < rum/reactive
|
(rum/defc page-reference < rum/reactive
|
||||||
[html-export? s config label]
|
[html-export? s config label]
|
||||||
(let [show-brackets? (state/show-brackets?)
|
(let [show-brackets? (state/show-brackets?)
|
||||||
|
@ -621,11 +608,6 @@
|
||||||
(.stopPropagation e))}
|
(.stopPropagation e))}
|
||||||
(excalidraw s block-uuid)]
|
(excalidraw s block-uuid)]
|
||||||
|
|
||||||
(string/ends-with? s ".tldr")
|
|
||||||
[:div.draw.cursor-default {:on-click (fn [e]
|
|
||||||
(.stopPropagation e))}
|
|
||||||
(tldraw s block-uuid)]
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:span.page-reference
|
[:span.page-reference
|
||||||
{:data-ref s}
|
{:data-ref s}
|
||||||
|
|
|
@ -318,7 +318,7 @@
|
||||||
(rum/local false ::control-show?)
|
(rum/local false ::control-show?)
|
||||||
[state {:keys [repo page-name] :as option}]
|
[state {:keys [repo page-name] :as option}]
|
||||||
(when-let [path-page-name (or page-name
|
(when-let [path-page-name (or page-name
|
||||||
(gobj/get option "pageId")
|
(gobj/get option "pageId") ;; FIXME: tldraw-logseq hack
|
||||||
(get-page-name state)
|
(get-page-name state)
|
||||||
(state/get-current-page))]
|
(state/get-current-page))]
|
||||||
(let [current-repo (state/sub :git/current-repo)
|
(let [current-repo (state/sub :git/current-repo)
|
||||||
|
|
|
@ -245,8 +245,8 @@
|
||||||
|
|
||||||
(sidebar-item
|
(sidebar-item
|
||||||
{:class "whiteboard"
|
{:class "whiteboard"
|
||||||
:title "Whiteboard"
|
:title "Whiteboards"
|
||||||
:href (rfe/href :whiteboard)
|
:href (rfe/href :whiteboards)
|
||||||
:icon "files"})]]
|
:icon "files"})]]
|
||||||
|
|
||||||
(favorites t)
|
(favorites t)
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
(ns frontend.components.whiteboard
|
||||||
|
(:require [frontend.handler.route :as route-handler]
|
||||||
|
[shadow.loader :as loader]
|
||||||
|
[frontend.util :as util]
|
||||||
|
[promesa.core :as p]
|
||||||
|
[rum.core :as rum]))
|
||||||
|
|
||||||
|
(defonce tldraw-loaded? (atom false))
|
||||||
|
(rum/defc tldraw-app < rum/reactive
|
||||||
|
{:init (fn [state]
|
||||||
|
(p/let [_ (loader/load :tldraw)]
|
||||||
|
(reset! tldraw-loaded? true))
|
||||||
|
state)}
|
||||||
|
[option]
|
||||||
|
(let [loaded? (rum/react tldraw-loaded?)
|
||||||
|
draw-component (when loaded?
|
||||||
|
(resolve 'frontend.extensions.tldraw/tldraw-app))]
|
||||||
|
(when draw-component
|
||||||
|
(draw-component option))))
|
||||||
|
|
||||||
|
(defn- get-whiteboard-name
|
||||||
|
[state]
|
||||||
|
(let [route-match (first (:rum/args state))]
|
||||||
|
(get-in route-match [:parameters :path :name])))
|
||||||
|
|
||||||
|
(rum/defc whiteboard-dashboard
|
||||||
|
[]
|
||||||
|
;; Placeholder
|
||||||
|
[:a {:on-mouse-down
|
||||||
|
(fn [e]
|
||||||
|
(util/stop e)
|
||||||
|
(route-handler/redirect-to-whiteboard! "test"))} "test"])
|
||||||
|
|
||||||
|
(rum/defcs whiteboard < rum/reactive
|
||||||
|
[state]
|
||||||
|
(let [name (get-whiteboard-name state)
|
||||||
|
tldr-name (str "draws/" name ".tldr")]
|
||||||
|
(tldraw-app {:file tldr-name})))
|
|
@ -15,6 +15,7 @@
|
||||||
(rum/defcs draw-inner < rum/reactive
|
(rum/defcs draw-inner < rum/reactive
|
||||||
(rum/local false ::view-mode?)
|
(rum/local false ::view-mode?)
|
||||||
[state data option]
|
[state data option]
|
||||||
|
(println state data option)
|
||||||
(let [{:keys [file]} option]
|
(let [{:keys [file]} option]
|
||||||
(when file
|
(when file
|
||||||
[:div.overflow-hidden.draw.tldraw
|
[:div.overflow-hidden.draw.tldraw
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
[:div.draw-wrap.relative
|
[:div.draw-wrap.relative
|
||||||
{:on-blur #(state/set-block-component-editing-mode! false)
|
{:on-blur #(state/set-block-component-editing-mode! false)
|
||||||
:on-wheel util/stop-propagation ;; wheel -> overscroll may cause browser navigation
|
:on-wheel util/stop-propagation ;; wheel -> overscroll may cause browser navigation
|
||||||
:style {:height "calc(100vh - 80px)" }}
|
:style {:height "calc(100vh - 80px)"}}
|
||||||
|
|
||||||
(tldraw {:PageComponent page
|
(tldraw {:PageComponent page
|
||||||
:searchHandler (comp clj->js vec search/page-search)
|
:searchHandler (comp clj->js vec search/page-search)
|
||||||
|
@ -32,6 +33,6 @@
|
||||||
(draw-handler/save-draw! file s)))
|
(draw-handler/save-draw! file s)))
|
||||||
:model data})]])))
|
:model data})]])))
|
||||||
|
|
||||||
(rum/defc draw
|
(rum/defc tldraw-app
|
||||||
[option]
|
[option]
|
||||||
(draw-common/draw-wrapper option draw-inner))
|
(draw-common/draw-wrapper option draw-inner))
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
(readdir [_this dir]
|
(readdir [_this dir]
|
||||||
(let [prefix (str "handle/" dir)
|
(let [prefix (str "handle/" dir)
|
||||||
cached-files (keys @nfs-file-handles-cache)]
|
cached-files (keys @nfs-file-handles-cache)]
|
||||||
|
(println "cached-files" cached-files)
|
||||||
(p/resolved
|
(p/resolved
|
||||||
(->> (filter #(string/starts-with? % (str prefix "/")) cached-files)
|
(->> (filter #(string/starts-with? % (str prefix "/")) cached-files)
|
||||||
(map (fn [path]
|
(map (fn [path]
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
[frontend.state :as state]
|
[frontend.state :as state]
|
||||||
[frontend.util :as util]
|
[frontend.util :as util]
|
||||||
[logseq.graph-parser.config :as gp-config]
|
[logseq.graph-parser.config :as gp-config]
|
||||||
|
[frontend.fs.protocol :as protocol]
|
||||||
[promesa.core :as p]))
|
[promesa.core :as p]))
|
||||||
|
|
||||||
(defn create-draws-directory!
|
(defn create-draws-directory!
|
||||||
|
@ -19,6 +20,15 @@
|
||||||
(fn [_result] nil)
|
(fn [_result] nil)
|
||||||
(fn [_error] nil)))))
|
(fn [_error] nil)))))
|
||||||
|
|
||||||
|
(defn ls-draws-directory!
|
||||||
|
[repo]
|
||||||
|
(when repo
|
||||||
|
(p/let [repo-dir (config/get-repo-dir repo)
|
||||||
|
fs (fs/get-fs repo-dir)
|
||||||
|
dir (str repo (str "/" gp-config/default-draw-directory))
|
||||||
|
files (protocol/readdir fs dir)]
|
||||||
|
files)))
|
||||||
|
|
||||||
(defn save-draw!
|
(defn save-draw!
|
||||||
[file data]
|
[file data]
|
||||||
(let [path file
|
(let [path file
|
||||||
|
|
|
@ -55,6 +55,11 @@
|
||||||
:query-params {:anchor anchor}
|
:query-params {:anchor anchor}
|
||||||
:push push})))
|
:push push})))
|
||||||
|
|
||||||
|
(defn redirect-to-whiteboard!
|
||||||
|
[name]
|
||||||
|
(redirect! {:to :whiteboard
|
||||||
|
:path-params {:name (str name)}}))
|
||||||
|
|
||||||
(defn get-title
|
(defn get-title
|
||||||
[name path-params]
|
[name path-params]
|
||||||
(case name
|
(case name
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
(ns frontend.routes
|
(ns frontend.routes
|
||||||
(:require [frontend.components.home :as home]
|
(:require [frontend.components.file :as file]
|
||||||
[frontend.components.repo :as repo]
|
[frontend.components.home :as home]
|
||||||
[frontend.components.file :as file]
|
[frontend.components.journal :as journal]
|
||||||
|
[frontend.components.onboarding.setups :as setups]
|
||||||
[frontend.components.page :as page]
|
[frontend.components.page :as page]
|
||||||
[frontend.components.plugins :as plugins]
|
[frontend.components.plugins :as plugins]
|
||||||
[frontend.components.journal :as journal]
|
[frontend.components.repo :as repo]
|
||||||
[frontend.components.search :as search]
|
[frontend.components.search :as search]
|
||||||
[frontend.components.settings :as settings]
|
[frontend.components.settings :as settings]
|
||||||
[frontend.components.shortcut :as shortcut]
|
[frontend.components.shortcut :as shortcut]
|
||||||
[frontend.components.onboarding.setups :as setups]
|
[frontend.components.whiteboard :as whiteboard]
|
||||||
[frontend.extensions.tldraw :as tldraw]
|
|
||||||
[frontend.extensions.zotero :as zotero]))
|
[frontend.extensions.zotero :as zotero]))
|
||||||
|
|
||||||
;; http://localhost:3000/#?anchor=fn.1
|
;; http://localhost:3000/#?anchor=fn.1
|
||||||
|
@ -22,9 +22,13 @@
|
||||||
{:name :repos
|
{:name :repos
|
||||||
:view repo/repos}]
|
:view repo/repos}]
|
||||||
|
|
||||||
["/whiteboard"
|
["/whiteboard/:name"
|
||||||
{:name :whiteboard
|
{:name :whiteboard
|
||||||
:view #(tldraw/draw {:file "draws/2022-05-15-01-47-49.tldr"})}]
|
:view whiteboard/whiteboard}]
|
||||||
|
|
||||||
|
["/whiteboards"
|
||||||
|
{:name :whiteboards
|
||||||
|
:view whiteboard/whiteboard-dashboard}]
|
||||||
|
|
||||||
["/repo/add"
|
["/repo/add"
|
||||||
{:name :repo-add
|
{:name :repo-add
|
||||||
|
|
Loading…
Reference in New Issue