mProjectsCode / obsidian-shiki-plugin

MIT License
53 stars 6 forks source link

Enable direct editing of codeblocks #19

Open niwazukihon opened 2 months ago

niwazukihon commented 2 months ago

Is your feature request related to a problem? Please describe. After enabling the plugin, codeblocks can no longer be directly edited. This is mentioned in #1. I also don't see any "edit button" mentioned in that issue.

Currently if I need to edit a codeblock, which I do very often, I need to place the cursor above the codeblock and hit down arrow to enter it and then edit. It's inconvenient. I also rarely copy the entire codeblock and mostly copy individual commands.

Describe the solution you'd like I want an option to revert to the default behavior, maybe remove the copy button as well. Thank you.

Additional context

mProjectsCode commented 2 months ago

Live preview has this button in the upper right corner of the code block that can be used to edit it. image

niwazukihon commented 2 months ago

I don't see the edit button (any language), but clicking the top right corner does select all content in the codeblock.

It's better than before. Would be great to be able to edit directly tho.

mProjectsCode commented 2 months ago

It's better than before. Would be great to be able to edit directly tho.

That's not planned. Clicking into the code of a code block should not switch to editing the code block. Instead, it should let you select the code.

HildaJ commented 2 months ago

It's better than before. Would be great to be able to edit directly tho.

That's not planned. Clicking into the code of a code block should not switch to editing the code block. Instead, it should let you select the code.

Hi @mProjectsCode Thanks for your contribution on this plugin!

Actually, I agree with @niwazukihon . It is more convenient to directly editing the code block than selecting the edit button. It could be better to have an option for those who prefer direct editing.

mProjectsCode commented 2 months ago

A setting for this sounds good, but the bigger problem is that I don't know how to switch the code block to editing, as Obsidian induces the current behavior.

HildaJ commented 2 months ago

For reference, I am now trying to switch from the plugin cm editor syntax highlight to Shiki. For the former, code in the code blocks was editable, although it doesn't support as many syntaxes as Shiki does and is not maintained anymore.

I understand that it could be tricky to add this feature. Thanks for your prompt reply!

Real-Gecko commented 1 week ago

By default codeblock becomes editable on click, would be nice to have such feature with this plugin