Skip to content

Commit

Permalink
Merge pull request #12 from dhurley94/fix-leaf-error
Browse files Browse the repository at this point in the history
Fix handle leaf error from invalid command
  • Loading branch information
dhurley94 authored Aug 12, 2024
2 parents 4772b20 + 4cd6d15 commit 4a7c4c3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "giphy-insert",
"name": "Giphy Insert",
"version": "1.1.3",
"version": "1.1.4",
"minAppVersion": "0.15.0",
"description": "This is a Giphy plugin for Obsidian. This plugin helps users insert Gifs from the Giphy API.",
"author": "drhurley94",
"authorUrl": "https://github.com/dhurley94",
"isDesktopOnly": false
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-giphy-plugin",
"version": "1.1.3",
"version": "1.1.4",
"description": "This is a plugin for Obsidian that help you insert Giphy images (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
12 changes: 0 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export default class GiphyPlugin extends ObsidianPlugin {
this.giphyClient = new GiphyApiClient(this.settings.apiKey);
this.giphyService = new GiphyService(this.giphyClient);

this.registerEvent(this.app.workspace.on('active-leaf-change', this.handleActiveLeafChange.bind(this)));

this.addCommand({
id: 'search-giphy',
name: 'Search Giphy for GIFs',
Expand Down Expand Up @@ -88,16 +86,6 @@ export default class GiphyPlugin extends ObsidianPlugin {
});
}

private handleActiveLeafChange(): void {
const activeLeaf = this.app.workspace.getLeaf();
if (activeLeaf?.view instanceof MarkdownView) {
const editor = activeLeaf.view.editor;
if (editor) {
editor.exec(this.handleEditorChange.bind(this));
}
}
}

private handleEditorChange(cm: any, change: any): void {
const insertedText: string = change?.text?.join('') || '';
if (DEFAULT_SETTINGS.slashCommands.filter((command) => insertedText.includes(`/${command}`))) {
Expand Down
5 changes: 3 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"1.1.0": "0.15.0",
"1.1.1": "0.15.0",
"1.1.2": "0.15.0",
"1.1.3": "0.15.0"
}
"1.1.3": "0.15.0",
"1.1.4": "0.15.0"
}

0 comments on commit 4a7c4c3

Please sign in to comment.