https://github.com/RoamJS/roamjs-components/blob/main/src/writes
https://github.com/RoamJS/roamjs-components/blob/main/src/writes
contains functions that handle various write operations in a Roam. These functions include clearing, creating, updating, and deleting blocks, as well as creating pages and managing sidebar operations.
clearBlockById
: Clears the content of a block by its ID. It usesgetUidsFromId
to extract the block UID and then callssubmitActions
to update the block content to an empty string.clearBlockByUid
: Clears the content of a block by its UID. It directly callssubmitActions
with an update action to set the block content to an empty string.createBlock
: Creates a new block with the provided content and options. It gathers the necessary actions usinggatherActions
and submits them usingsubmitActions
.createPage
: Creates a new page with the provided title. It checks if the title matches a daily note pattern and generates a UID if necessary. It then submits actions to create the page and any child blocks usingsubmitActions
.deleteBlock
: Deletes a block by its UID. It submits a delete action usingsubmitActions
.openBlockInSidebar
: Opens a block in the sidebar. It checks if the block is already open in the sidebar and either opens the sidebar or adds a new window with the block UID.updateActiveBlock
: Updates the content of the currently active block. It retrieves the active block UID usinggetActiveUids
and submits an update action usingsubmitActions
.updateBlock
: Updates the properties of a block, including text, heading, text alignment, view type, and open state. It submits these updates usingsubmitActions
.
The submitActions
function is central to these operations, handling the submission of various actions to the Roam Research API. It manages an action queue and retries actions in case of API errors.
For more details on see