obsidian-shiki-plugin
obsidian-shiki-plugin copied to clipboard
Support line editing in live preview
This is more of an idea. It's related to #19, but still not direct editing.
A row edit button is added to each line of the code block. When clicked, it selects the corresponding line. This allows us to start editing from the middle of the block rather than from the beginning.
The feature is shown in the video below (click the edit button on line 15 to edit the line).
https://github.com/user-attachments/assets/0896bc2d-8658-414b-a13e-7c550b3bfd69
To avoid the edit buttons being obscured by native buttons, I also added some settings to hide copy buttons and edit block buttons, which default to false.
Known limitations:
- If a new file is opened in reading mode, the row edit buttons for the first code block are not added when switching from reading mode to live preview. I didn't look into why this happens.
- Changes to settings will take effect in newly rendered code blocks, not old ones. Well.. not interested.
- The solution relies on native buttons to work, such as the edit block button to break the uneditable state of a code block. Didn't find a better way to do this.
Appreciate any improvements :)