You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The patch method supports inserting content relative to a header if you send a request like:
PATCH /path/to/some/file.md HTTP/1.1Content-Type: text/markdownHeading: Some heading in your documentContent-Insertion-Position: end|beginning
Obsidian also supports block references, and those references are available via the CachedMetadata API. These would require slightly different headers, though:
Block-Reference-Id: The ID of the block reference to insert content relative to.
Content-Insertion-Position: Valid values before, on, after. The values after and on differ from one another in that that on will insert text immediately before the block reference marker on the same line as it, whereas after will insert on the next line.
Use of Heading and Block-Reference-Id in the same request or using a Content-Insertion-Position invalid for the provided reference (either Heading or Block-Reference-Id) will result in a 400 error.
The text was updated successfully, but these errors were encountered:
coddingtonbear
changed the title
Support for inserting content relative to block references
PATCH support for inserting content relative to block references
Oct 12, 2022
coddingtonbear
changed the title
PATCH support for inserting content relative to block references
PATCH /vault/* support for inserting content relative to block references
Oct 24, 2022
- Right now, it will insert either on the line before or after the block
reference. Idealy we'd:
- Make 'before' insert at the beginning of the line of the block
reference instead of on the preceding line. If folks want to insert
on the preceding line, they can just add a new line at the end of
their content.
- Add a new 'on' position that inserts at the end of the line of the
block reference, but before the block reference ID itself. This
should become the default.
- Leave 'after' as-is.
- There's a weird behavior right now where it doesn't appear that the
CachedMetadata object is being updated when I make file changes. This
means that repeated REST requests will possibly insert on the wrong
line. I don't know what's causing this and _assume_ it's an Obsidian
bug, but it might be something else. I do believe that the
CachedMetadata object is updated when I PATCH relative to a heading, at
least.
The patch method supports inserting content relative to a header if you send a request like:
Obsidian also supports block references, and those references are available via the
CachedMetadata
API. These would require slightly different headers, though:Block-Reference-Id
: The ID of the block reference to insert content relative to.Content-Insertion-Position
: Valid valuesbefore
,on
,after
. The valuesafter
andon
differ from one another in that thaton
will insert text immediately before the block reference marker on the same line as it, whereasafter
will insert on the next line.Use of
Heading
andBlock-Reference-Id
in the same request or using aContent-Insertion-Position
invalid for the provided reference (eitherHeading
orBlock-Reference-Id
) will result in a 400 error.The text was updated successfully, but these errors were encountered: