mirror of
https://github.com/logseq/logseq.git
synced 2026-05-01 09:26:28 +00:00
wip: remove :block/name uniqueness for db based graphs
This PR also remove supports for: 1. merge pages when renaming a page to existing page 2. namespaces such as a/b/c 3. nested page such as [[a [[nested page]]]] Pages merge might be added back depends on RTC, but it should be decoupled from renaming, otherwise it's too complex. Namespaces and nested pages have been contributed some critical bugs that lead data-loss, they're so complex together with page alias, it's just impossible to have a good test coverage and ensure the app is stable, especially when page rename and RTC.
This commit is contained in:
@@ -82,42 +82,42 @@
|
||||
source-page (db-model/get-alias-source-page (state/get-current-repo) name)
|
||||
ctx-icon #(shui/tabler-icon %1 {:class "scale-90 pr-1 opacity-80"})
|
||||
open-in-sidebar #(when-let [page-entity (and (not whiteboard-page?)
|
||||
(if (empty? source-page)
|
||||
(db/entity [:block/name name]) source-page))]
|
||||
(if (empty? source-page)
|
||||
(db/entity [:block/name name]) source-page))]
|
||||
(state/sidebar-add-block!
|
||||
(state/get-current-repo)
|
||||
(:db/id page-entity)
|
||||
:page))
|
||||
(state/get-current-repo)
|
||||
(:db/id page-entity)
|
||||
:page))
|
||||
x-menu-content (fn []
|
||||
(let [x-menu-item shui/dropdown-menu-item
|
||||
x-menu-shortcut shui/dropdown-menu-shortcut]
|
||||
[:<>
|
||||
(when-not recent?
|
||||
(x-menu-item
|
||||
{:on-click #(page-handler/<unfavorite-page! original-name)}
|
||||
(ctx-icon "star-off")
|
||||
(t :page/unfavorite)
|
||||
(x-menu-shortcut (when-let [binding (shortcut-dh/shortcut-binding :command/toggle-favorite)]
|
||||
(some-> binding
|
||||
(first)
|
||||
(shortcut-utils/decorate-binding))))))
|
||||
{:on-click #(page-handler/<unfavorite-page! original-name)}
|
||||
(ctx-icon "star-off")
|
||||
(t :page/unfavorite)
|
||||
(x-menu-shortcut (when-let [binding (shortcut-dh/shortcut-binding :command/toggle-favorite)]
|
||||
(some-> binding
|
||||
(first)
|
||||
(shortcut-utils/decorate-binding))))))
|
||||
(when-let [page-fpath (and (util/electron?) file-rpath
|
||||
(config/get-repo-fpath (state/get-current-repo) file-rpath))]
|
||||
(config/get-repo-fpath (state/get-current-repo) file-rpath))]
|
||||
[:<>
|
||||
(x-menu-item
|
||||
{:on-click #(ipc/ipc :openFileInFolder page-fpath)}
|
||||
(ctx-icon "folder")
|
||||
(t :page/open-in-finder))
|
||||
{:on-click #(ipc/ipc :openFileInFolder page-fpath)}
|
||||
(ctx-icon "folder")
|
||||
(t :page/open-in-finder))
|
||||
|
||||
(x-menu-item
|
||||
{:on-click #(js/window.apis.openPath page-fpath)}
|
||||
(ctx-icon "file")
|
||||
(t :page/open-with-default-app))])
|
||||
{:on-click #(js/window.apis.openPath page-fpath)}
|
||||
(ctx-icon "file")
|
||||
(t :page/open-with-default-app))])
|
||||
(x-menu-item
|
||||
{:on-click open-in-sidebar}
|
||||
(ctx-icon "layout-sidebar-right")
|
||||
(t :content/open-in-sidebar)
|
||||
(x-menu-shortcut (shortcut-utils/decorate-binding "shift+click")))]))]
|
||||
{:on-click open-in-sidebar}
|
||||
(ctx-icon "layout-sidebar-right")
|
||||
(t :content/open-in-sidebar)
|
||||
(x-menu-shortcut (shortcut-utils/decorate-binding "shift+click")))]))]
|
||||
|
||||
;; TODO: move to standalone component
|
||||
[:a.flex.items-center.justify-between.relative.group
|
||||
@@ -126,32 +126,30 @@
|
||||
(let [name (if (empty? source-page) name (:block/name source-page))]
|
||||
(if (gobj/get e "shiftKey")
|
||||
(open-in-sidebar)
|
||||
(if whiteboard-page?
|
||||
(route-handler/redirect-to-whiteboard! name {:click-from-recent? recent?})
|
||||
(route-handler/redirect-to-page! name {:click-from-recent? recent?})))))
|
||||
(route-handler/redirect-to-page! name {:click-from-recent? recent?}))))
|
||||
:on-context-menu (fn [^js e]
|
||||
(shui/popup-show! e (x-menu-content)
|
||||
{:as-dropdown? true
|
||||
:content-props {:on-click (fn [] (shui/popup-hide!))
|
||||
:class "w-60"}})
|
||||
{:as-dropdown? true
|
||||
:content-props {:on-click (fn [] (shui/popup-hide!))
|
||||
:class "w-60"}})
|
||||
(util/stop e))}
|
||||
[:span.page-icon.ml-3.justify-center (if whiteboard-page? (ui/icon "whiteboard" {:extension? true}) icon)]
|
||||
[:span.page-title {:class (when untitled? "opacity-50")}
|
||||
(if untitled? (t :untitled)
|
||||
(pdf-utils/fix-local-asset-pagename original-name))]
|
||||
(pdf-utils/fix-local-asset-pagename original-name))]
|
||||
|
||||
;; dots trigger
|
||||
(shui/button
|
||||
{:size :sm
|
||||
:variant :ghost
|
||||
:class "absolute right-2 top-0 px-1.5 scale-75 opacity-30 hidden group-hover:block hover:opacity-80 active:opacity-100"
|
||||
:on-click #(do
|
||||
(shui/popup-show! (.-target %) (x-menu-content)
|
||||
{:as-dropdown? true
|
||||
:content-props {:on-click (fn [] (shui/popup-hide!))
|
||||
:class "w-60"}})
|
||||
(util/stop %))}
|
||||
[:i.relative {:style {:top "1px"}} (shui/tabler-icon "dots")])]))
|
||||
{:size :sm
|
||||
:variant :ghost
|
||||
:class "absolute right-2 top-0 px-1.5 scale-75 opacity-30 hidden group-hover:block hover:opacity-80 active:opacity-100"
|
||||
:on-click #(do
|
||||
(shui/popup-show! (.-target %) (x-menu-content)
|
||||
{:as-dropdown? true
|
||||
:content-props {:on-click (fn [] (shui/popup-hide!))
|
||||
:class "w-60"}})
|
||||
(util/stop %))}
|
||||
[:i.relative {:style {:top "1px"}} (shui/tabler-icon "dots")])]))
|
||||
|
||||
;; Fall back to default if icon is undefined or empty
|
||||
|
||||
@@ -203,7 +201,7 @@
|
||||
{:key name
|
||||
:title name
|
||||
:draggable true
|
||||
:on-drag-start (fn [event] (editor-handler/block->data-transfer! name event))
|
||||
:on-drag-start (fn [event] (editor-handler/block->data-transfer! name event true))
|
||||
:data-ref name}
|
||||
(page-name name (icon/get-page-icon entity {}) true)]))])))
|
||||
|
||||
@@ -838,7 +836,7 @@
|
||||
block-el (.closest target ".bullet-container[blockid]")
|
||||
block-id (some-> block-el (.getAttribute "blockid"))
|
||||
{:keys [block block-ref]} (state/sub :block-ref/context)
|
||||
{:keys [page]} (state/sub :page-title/context)]
|
||||
{:keys [page page-entity]} (state/sub :page-title/context)]
|
||||
|
||||
(let [show!
|
||||
(fn [content]
|
||||
@@ -851,7 +849,7 @@
|
||||
(cond
|
||||
page
|
||||
(do
|
||||
(show! (cp-content/page-title-custom-context-menu-content page))
|
||||
(show! (cp-content/page-title-custom-context-menu-content page-entity))
|
||||
(state/set-state! :page-title/context nil))
|
||||
|
||||
block-ref
|
||||
|
||||
Reference in New Issue
Block a user