text-snippets-obsidian
text-snippets-obsidian copied to clipboard
Will Snippets work in the new version of the editor?
I found that snippets work fine in older versions of the editor, when will newer versions be supported?
Same for me. Snippets doesn't work in the new Live Preview mode.
I used the dev tools to find out what's going on; there's this stacktrace that shows up when invoking the command in Live Preview:
TypeError: editor.findWordAt is not a function
at TextSnippets.getWordBoundaries (eval at <anonymous> (app.js:1), <anonymous>:100:27)
at TextSnippets.insertSnippet (eval at <anonymous> (app.js:1), <anonymous>:173:14)
at TextSnippets.SnippetOnTrigger (eval at <anonymous> (app.js:1), <anonymous>:237:18)
at Object.callback (eval at <anonymous> (app.js:1), <anonymous>:44:38)
at uR (app.js:1)
at t.executeCommandById (app.js:1)
at t.onTrigger (app.js:1)
at t.handleKey (app.js:1)
at t.onKeyEvent (app.js:1)
CodeMirror indeed exposes a findWordAt() method (search for it at https://codemirror.net/doc/manual.html#api_selection) but, in Live Preview mode, the CodeMirror.Editor instance in editor indeed does not expose that method; according to Release v0.13.0, we could be calling the wordAt() method (which seems to call the internal findWordAt() method!), instead, which I confirmed was available by setting a breakpoint and adding the following watches in the debugger:
editor.findWordAt === undefined // yields true
editor.wordAt === undefined // yields false
It seems to me detecting which one of those is available before invoking it would fix this obstacle that's preventing the use of this plugin.
Huh, someone else figured it out in #25, so this could be closed as a duplicate.
Huh, someone else figured it out in #25, so this could be closed as a duplicate.
Thanks! Following your tips, I have solved the problem.
Live Preview support added in 0.0.7. Be sure to check the toggle in settings and restart the plugin.