API to access the "Rename heading" functionality?

If you open the context menu while the cursor is on a heading, there’s an option to “Rename heading”, which has the benefit of updating links to that heading. Is there a way to access that functionality via API?

(I am the author of the number-headings-obsidian plugin GitHub - onlyafly/number-headings-obsidian: Automatically number headings in a document in Obsidian and would like to add some functionality to update links to headings when the numbering is updated.)

2 Likes

Bump. I also need this functionality.

I think it’s not officially available, but you can find out what’s happening there by searching app.js by renameHeading. It might be possible to access the underlying mechanism from your plugin by monkey-patching.

But as for heading numbering, I would take another approach that doesn’t hard-code them directly into notes: heading numbers can be computed/derived from the note content and can be displayed without actually modifying it.

1 Like