jmilldotdev / obsidian-wikipedia

Grabs information from Wikipedia for a topic and brings it into Obsidian notes
MIT License
96 stars 16 forks source link

Search results displayed in the middle of frontmatter #16

Open marconoris opened 9 months ago

marconoris commented 9 months ago

Hi,

there is an issue when plugin publish search results in note: it put results in the middle of frontmatter and not in cursor location...

rcherny commented 4 months ago

This #16 seems to be a duplicate of #17.

rcherny commented 4 months ago

Looking at the code, it seems like possibly it is inserted to actually replace the selection:

https://github.com/jmilldotdev/obsidian-wikipedia/blob/master/main.ts#L165

editor.replaceSelection(this.formatExtractInsert(extract, searchTerm));

From testing, this does seem to resolve the problem.

If you put in your heading, and then the place where you want the content to be injected, it replaces. Example:

# Obsidian 

content (select this text)

Result:

# Obsidian

> Obsidian is a personal knowledge base and note-taking software application that operates on Markdown files. It allows users to make internal links for notes and then to visualize the connections as a graph. It is designed to help users organize and structure their thoughts and knowledge in a flexible, non-linear way. The software is free for personal use, with commercial licenses available for pay.
>
> [Wikipedia](https://en.wikipedia.org/wiki/Obsidian%20(software))