`appendBlockInPage` to support passing in uuid

After looking through the docs and code for Editor.appendBlockInPage (IEditorProxy | @logseq/libs), there doesn’t appear to be a way to create a block by passing in my own uuid. This is useful for syncing across services in case the UUID originates from else where. Any way we could support this? For example:

window.logseq.Editor.appendBlockInPage(pageUuid, content, { uuid });

If we’re in favor, I could take a stab at making a PR for this feature.

I have the same request for createPage

It’s not supported. But I think this could be useful.

One thing to keep in mind with logseq is that the UUIDs aren’t stable. So when the user reindexes, it gets auto generated. So you’ll have to add the property id:: 62fe5f42-9e5b-44e0-b732-10950eb02c8a to it whenever creating a block that requires stable uuids as is apparent in your case.

Is the DB id stable?

Is there a way to specify properties so that they don’t appear/are editable in the UI:

Is there also a way to register an event callback for when logseq reindexes?

the DB id is only stable if id:: 62fe5f42-9e5b-44e0-b732-10950eb02c8a is added to the block or if you create a reference through logseq.

There is a way to specify this, enable this setting in config.edn

:block-hidden-properties #{:uuid}

By DB id I was referring to the numerical value, not the UUID:
Screen Shot 2022-08-18 at 12.22.45 PM

but, are you saying that logseq has special handling that if it sees that property, it won’t reindex the block ref? or are you saying that the only way to guarantee stability is by storing properties and the block ref will always be subject to change?

In any case, I just fired a re-index and the uuids appeared to stay consistent before and after reindexing - in what cases does it change?

enable this setting in config.edn

Is this a user setting or a plugin setting? I’m less inclined to go this route if it’s the former

It’s a user setting. It changes when the id" property doesn’t exist. Id property is created when you create a block reference inside logseq.

Anyways, this PR should add the ability define a custom uuid.

1 Like

Does the trick to add an id property to make uuids stable work for pages? It seems like Logseq sometimes misinterprets the property as being for a property of a block on the page, instead of the page itself