Skip to content

Commit 28bc28e

Browse files
committed
enhance(apis): support custom uuid to create page
1 parent a138a0e commit 28bc28e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

libs/src/LSPlugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ export interface IEditorProxy extends Record<string, any> {
762762
opts?: Partial<{
763763
redirect: boolean
764764
createFirstBlock: boolean
765+
customUUID: string
765766
format: BlockEntity['format']
766767
journal: boolean
767768
}>

src/main/logseq/api/editor.cljs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
this
124124
(let [properties (bean/->clj properties)
125125
db-based? (config/db-based-graph?)
126-
{:keys [redirect format journal schema class]} (bean/->clj opts)]
126+
{:keys [redirect format journal schema class customUUID]} (bean/->clj opts)]
127127
(p/let [page (<get-block name {:children? false})
128128
new-page (when-not page
129129
(page-handler/<create!
@@ -133,8 +133,10 @@
133133
:journal? journal
134134
:class? class
135135
:format format}
136-
(not db-based?)
137-
(assoc :properties properties))))
136+
(string? customUUID)
137+
(assoc :uuid (uuid customUUID))
138+
(not db-based?)
139+
(assoc :properties properties))))
138140
_ (when (and db-based? (seq properties))
139141
(api-block/db-based-save-block-properties! new-page properties {:plugin this
140142
:schema schema}))]

0 commit comments

Comments
 (0)