Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 3.9 KB

writes.md

File metadata and controls

23 lines (17 loc) · 3.9 KB

Write Operations

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 uses getUidsFromId to extract the block UID and then calls submitActions to update the block content to an empty string.
  • clearBlockByUid: Clears the content of a block by its UID. It directly calls submitActions 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 using gatherActions and submits them using submitActions.
  • 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 using submitActions.
  • deleteBlock: Deletes a block by its UID. It submits a delete action using submitActions.
  • 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 using getActiveUids and submits an update action using submitActions.
  • updateBlock: Updates the properties of a block, including text, heading, text alignment, view type, and open state. It submits these updates using submitActions.

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