text-snippets-obsidian icon indicating copy to clipboard operation
text-snippets-obsidian copied to clipboard

Fix tab and space not working in WYSIWYG

Open SekoiaTree opened this issue 3 years ago • 2 comments
trafficstars

Disclaimer: I translated this code back and forth from typescript.

I have tested this on Legacy mode and it works, but these edits fix it for latest version. The code for legacy is essentially copied from current.

Fixes #19, fixes #25 (maybe?), fixes #37 (maybe?), fixes #47 and fixes #52

The way this works is by using this.registerDomEvent instead of CodeMirror edits. The key down event now also checks whether the current window is a markdown view, so you can't have accidental replaces in any other areas. If that's actually wanted, feel free to remove it (or make it a setting, although I haven't seen a place where the distinction would actually be relevant)

SekoiaTree avatar Sep 20 '22 07:09 SekoiaTree

Tested and works for me, although I wonder if registerDomEvent is the cleanest way of capturing keypresses.

I've seen advanced tables use registerEditorExtension for CM6 which might keep the behaviour localized to the editor.

Arax20 avatar Oct 04 '22 12:10 Arax20

Oh yeah that'd definitely work too. I might try and do that but I'm quite busy atm so yeah

SekoiaTree avatar Oct 05 '22 10:10 SekoiaTree