mirror of https://github.com/logseq/logseq
rename whiteboard pages
parent
2bb7ef5919
commit
f4715f59fd
|
@ -124,7 +124,7 @@
|
|||
(defn page-name-sanity-lc
|
||||
"Sanitize the query string for a page name (mandate for :block/name)"
|
||||
[s]
|
||||
(page-name-sanity (string/lower-case s)))
|
||||
(when s (page-name-sanity (string/lower-case s))))
|
||||
|
||||
(defn capitalize-all
|
||||
[s]
|
||||
|
|
|
@ -554,7 +554,7 @@
|
|||
wide-mode? (state/sub :ui/wide-mode?)
|
||||
right-sidebar-blocks (state/sub-right-sidebar-blocks)
|
||||
route-name (get-in route-match [:data :name])
|
||||
margin-less-pages? (boolean (#{:graph :whiteboard} route-name))
|
||||
margin-less-pages? (boolean (#{:graph :whiteboard :whiteboards} route-name))
|
||||
db-restoring? (state/sub :db/restoring?)
|
||||
indexeddb-support? (state/sub :indexeddb/support?)
|
||||
page? (= :page route-name)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns frontend.components.whiteboard
|
||||
(:require [frontend.handler.route :as route-handler]
|
||||
[frontend.modules.shortcut.core :as shortcut]
|
||||
(:require [frontend.components.page :as page]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.util :as util]
|
||||
[promesa.core :as p]
|
||||
[rum.core :as rum]
|
||||
|
@ -24,6 +24,16 @@
|
|||
(let [route-match (first (:rum/args state))]
|
||||
(get-in route-match [:parameters :path :name])))
|
||||
|
||||
(rum/defc dashboard-card
|
||||
[page-name]
|
||||
[:a {:on-mouse-down
|
||||
(fn [e]
|
||||
(util/stop e)
|
||||
(route-handler/redirect-to-whiteboard! page-name))} page-name])
|
||||
|
||||
;; (rum/defc dashboard-grid
|
||||
;; )
|
||||
|
||||
(rum/defc whiteboard-dashboard
|
||||
[]
|
||||
;; Placeholder
|
||||
|
@ -36,7 +46,14 @@
|
|||
[state]
|
||||
(let [name (get-whiteboard-name state)]
|
||||
[:div.absolute.w-full.h-full
|
||||
|
||||
;; makes sure the whiteboard will not cover the borders
|
||||
{:key name
|
||||
:style {:padding "0.5px" :z-index 0}}
|
||||
|
||||
[:span.inline-flex.absolute
|
||||
{:key name
|
||||
:style {:z-index 2000}}
|
||||
(page/page-title name nil name nil false)]
|
||||
|
||||
(tldraw-app name)]))
|
||||
|
|
|
@ -1648,6 +1648,7 @@
|
|||
(let [properties shape]
|
||||
{:block/uuid (uuid (:id properties))
|
||||
:block/page {:block/name page-name}
|
||||
:block/content "" ;; give it empty string since some block utility requires it
|
||||
:block/properties properties}))
|
||||
|
||||
(defn- tldr-page->blocks-tx [page-name tldr-data]
|
||||
|
@ -1695,3 +1696,20 @@
|
|||
(when-let [file (:block/file page)]
|
||||
(when-let [path (:file/path (db-utils/entity (:db/id file)))]
|
||||
(gp-config/whiteboard? path))))))
|
||||
|
||||
;; fixme: caching?
|
||||
(defn get-all-whiteboard-tldrs
|
||||
"Returns a vector of all whiteboard tldrs."
|
||||
[repo]
|
||||
(let [result (d/q
|
||||
'[:find [(pull ?page [* {:block/_page [:block/properties]}]) ...]
|
||||
:where
|
||||
[?page :block/name]
|
||||
[?page :block/whiteboard? true]]
|
||||
(conn/get-db repo))
|
||||
tldrs (mapv (fn [row] (let [blocks (:block/_page row)
|
||||
page (dissoc row :block/_page)]
|
||||
(whiteboard-clj->tldr page blocks))) result)]
|
||||
tldrs))
|
||||
|
||||
(get-all-whiteboard-tldrs (state/get-current-repo))
|
||||
|
|
|
@ -242,6 +242,7 @@
|
|||
:convert-markdown "Convert Markdown headings to unordered lists (# -> -)"
|
||||
:all-graphs "All graphs"
|
||||
:all-pages "All pages"
|
||||
:all-whiteboards "All whiteboards"
|
||||
:all-files "All files"
|
||||
:remove-orphaned-pages "Remove orphaned pages"
|
||||
:all-journals "All journals"
|
||||
|
|
|
@ -405,14 +405,16 @@
|
|||
file (:block/file page)
|
||||
journal? (:block/journal? page)
|
||||
properties-block (:data (outliner-tree/-get-down (outliner-core/block page)))
|
||||
properties-content (:block/content properties-block)
|
||||
properties-block-tx (when (and properties-block
|
||||
(string/includes? (util/page-name-sanity-lc (:block/content properties-block))
|
||||
properties-content
|
||||
(string/includes? (util/page-name-sanity-lc properties-content)
|
||||
old-page-name))
|
||||
(let [front-matter? (and (property/front-matter? (:block/content properties-block))
|
||||
(let [front-matter? (and (property/front-matter? properties-content)
|
||||
(= :markdown (:block/format properties-block)))]
|
||||
{:db/id (:db/id properties-block)
|
||||
:block/content (property/insert-property (:block/format properties-block)
|
||||
(:block/content properties-block)
|
||||
properties-content
|
||||
:title
|
||||
new-name
|
||||
front-matter?)}))
|
||||
|
@ -438,7 +440,7 @@
|
|||
|
||||
;; Redirect to the newly renamed page
|
||||
(when redirect?
|
||||
(route-handler/redirect! {:to :page
|
||||
(route-handler/redirect! {:to (if (:block/whiteboard? page) :whiteboard :page)
|
||||
:push false
|
||||
:path-params {:name new-page-name}}))
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(ns frontend.handler.whiteboard
|
||||
(:require [frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
[clojure.string :as string]))
|
||||
|
||||
;; FIXME: embed /draw should be supported too
|
||||
|
|
Loading…
Reference in New Issue