logseq / plugins

Documentation site of Logseq plugins
https://plugins-doc.logseq.com/
19 stars 4 forks source link

🧩 logseq.Editor.upsertBlockProperty #19

Open utterances-bot opened 2 months ago

utterances-bot commented 2 months ago

https://plugins-doc.logseq.com/logseq/Editor/upsertBlockProperty

zhaochunqi commented 1 month ago

thanks! @YU000jp very useful information!

b-yp commented 1 month ago

There is a bug when updating as page properties. Use updateBlock() and enter property:: value/n directly at the beginning of its content. The \n means a new line.) This will load the value into the database as a page property.

That means I need to create a new block, then update the block, and write the block's content in the form of properties. This way, I can set the page properties, right? I'll try it tonight.

zhaochunqi commented 1 month ago

@b-yp The problem is when you update properties using upsertBlockProperty it will work as expected, but it will not write to the db, you will need to reindex your graph to make it work.

b-yp commented 1 month ago

@b-yp The problem is when you update properties using upsertBlockProperty it will work as expected, but it will not write to the db, you will need to reindex your graph to make it work.

Yes, I am currently stuck at this point. I have many methods to set properties for a page, but these methods do not write to the database; they only look good on the page. When I use the menu (Make it public publishing) to set the public property, it still creates a new block to save the properties, rather than adding them to the original one. Logseq does not have a dedicated API for setting page properties.