Obsidian plugin to mirror blocks (e.g. synced tasks)

I’ve create a proof of concept plugin to mirror blocks.

Create a block in one file (e.g. - [ ] Task ^abc) and copy the block (just simple copy-paste) including the same block id to another file. The plugin will mirror any changes to that line, e.g. when you’re changing te task to - [x] Task ^abc it will be reflected in both files (also e.g. when using the Tasks plugin to change the task). For now it will update any changes from the current files to all other files that contain the same block id.

Caveats / bugs

  • I think the block identifier can be anywhere in the line (have not checked), but it ignores block identifiers e.g. in internal links. It uses the cachedMetadata.blocks to find blocks based on what Obsidian thinks is a block
  • Obsidian only considers specific things as ‘blocks’ (e.g. tasks, list items, heading, but not multiple lines in the same paragraph)
  • When using with tasks and crossing off many items at the same time (and with multiple files open that contain mirrored blocks) it can create a race condition
  • Currently it only considers single-line blocks

Installation

This plugin is currently a proof-of-concept! :warning: Use at your own risk :warning:. This plugin writes to your vault and could be doing things wrong and overwrite every file in your vault. Best tried on a demo vault!

  • Make sure your NodeJS is at least v16 (node --version).
  • npm i or yarn to install dependencies.
  • npm run dev to start compilation in watch mode.

Idea

See this discussion: Synced Lines (or blocks) for Obsidian?

Noteplan has a great feature Synced Lines: A Synced Line is a single line of text, such as a task, quote, bullet point, etc. that is mirrored across notes. If you paste that Synced Line into another note and change the content of that line of text in any of the notes, NotePlan will sync this change to all connected copies. Check out this page for more background: Synced Lines - NotePlan Knowledge Base

This borders on discussion of ‘editable transclusions’ although this is a bit more straightforward. But I think this is still a great idea worth pursueing: use a block reference as a unique identifier and keep a line (or possibly block) synced across a vault. Most important might be the performance needed.

History (before creating this plugin)

I’ve done some digging and think it would be possible to recreate Synced Lines in Obsidian, e.g. @TfTHacker has created a great (API) infrastructure with the Strange New Worlds plugin that possibly could be reused. In Discord user ‘boninall’ has also created something that looks a lot like Synced Lines. There’s a (currently) empty Github repository for that idea here: GitHub - Quorafind/Obsidian-Block-Reference

8 Likes