-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add embed menu option to open media in obsidian
- Loading branch information
Showing
7 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import type { Menu } from "obsidian"; | ||
import { decodeWebpageUrl, isWebpageUrl } from "@/lib/remote-player/encode"; | ||
import { isMediaFileViewType } from "../view-type"; | ||
import type { PlayerContext } from "."; | ||
|
||
export function urlMenu(menu: Menu, { source }: PlayerContext) { | ||
if (isMediaFileViewType(source.viewType) || !source.src.startsWith("http")) | ||
const isUrl = source.src.startsWith("http"), | ||
isWebpageEncoded = isWebpageUrl(source.src); | ||
if (isMediaFileViewType(source.viewType) || (!isUrl && !isWebpageEncoded)) | ||
return; | ||
const url = isWebpageEncoded ? decodeWebpageUrl(source.src) : source.src; | ||
menu.addItem((item) => | ||
item | ||
.setTitle("Open in browser") | ||
.setIcon("globe") | ||
.setSection("view") | ||
.onClick(() => { | ||
window.open(source.src); | ||
window.open(url); | ||
}), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters