Skip to content

Commit 227de9d

Browse files
authored
Merge pull request #33 from NomarCub/obsidian-1.5-update
Obsidian 1.5 update
2 parents 71452fe + 9aadb1f commit 227de9d

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ This plugin context the following context menus
1111

1212
in reading view in [Obsidian](https://obsidian.md/).
1313

14-
This makes copying URLs in reading view like it is in editing view by deafult. For copying images in edit mode check out [Ozan's Image in Editor Plugin](https://github.com/ozntel/oz-image-in-editor-obsidian)
14+
This makes copying URLs in reading view like it is in editing view by deafult.
15+
16+
See these other plugins for related functionality:
17+
- [Ozan's Image in Editor Plugin](https://github.com/ozntel/oz-image-in-editor-obsidian)
18+
- [Image Toolkit](https://github.com/sissilab/obsidian-image-toolkit)
1519

1620
Copying images:
1721

@@ -25,7 +29,7 @@ Opening PDFs externally:
2529

2630
![Opening PDFs externally on desktop](https://user-images.githubusercontent.com/5298006/171170626-5a94f5dc-61fc-4661-a9f2-38a0fb0181f5.gif)
2731

28-
All features work on mobile, but were only tested on Android:
32+
All features work on mobile, but were only tested on Android. Mobile uses the native image sharing functionality instead of the clipboard, and it downloads online images temporarily so they can be shared.
2933

3034
![Copying URLs on Android](https://user-images.githubusercontent.com/5298006/125515758-bdf77074-a58c-4a6d-affa-88d031991ab2.gif)
3135

manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"id": "copy-url-in-preview",
33
"name": "Copy Image and URL context menu",
4-
"version": "1.5.1",
5-
"minAppVersion": "0.16.3",
4+
"version": "1.5.2",
5+
"minAppVersion": "1.4.11",
66
"description": "Copy Image, Copy URL and Open PDF externally context menu in reading view (formerly preview mode)",
77
"author": "NomarCub",
88
"authorUrl": "https://github.com/NomarCub",

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "copy-url-in-preview",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "Copy Image, Copy URL and Open PDF externally context menu in reading view (formerly preview mode) for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {
@@ -18,7 +18,7 @@
1818
"builtin-modules": "3.3.0",
1919
"esbuild": "0.17.3",
2020
"eslint": "8.46.0",
21-
"obsidian": "^0.16.3",
21+
"obsidian": "^1.4.11",
2222
"tslib": "2.4.0",
2323
"typescript": "4.7.4"
2424
}

src/main.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class CopyUrlInPreview extends Plugin {
3030
await this.loadSettings();
3131
this.addSettingTab(new CopyUrlInPreviewSettingTab(this.app, this));
3232
this.registerDocument(document);
33-
app.workspace.on("window-open",
33+
this.app.workspace.on("window-open",
3434
(workspaceWindow, window) => {
3535
this.registerDocument(window.document);
3636
});
@@ -122,7 +122,7 @@ export default class CopyUrlInPreview extends Plugin {
122122
}
123123

124124
storeLastHoveredLinkInEditor(event: MouseEvent) {
125-
const editor = app.workspace.getActiveViewOfType(MarkdownView)?.editor as EditorInternalApi;
125+
const editor = this.app.workspace.getActiveViewOfType(MarkdownView)?.editor as EditorInternalApi;
126126
if (!editor) {
127127
return;
128128
}
@@ -304,10 +304,9 @@ export default class CopyUrlInPreview extends Plugin {
304304
})
305305
);
306306
if (protocol === "app:" && Platform.isDesktop) {
307-
// href probably also works
308307
// getResourcePath("") also works for root path
309-
const baseFilePath = (app.vault.adapter as FileSystemAdapterWithInternalApi).getFilePath("");
310-
const baseFilePathName: string = (baseFilePath as any).pathname;
308+
const baseFilePath = (this.app.vault.adapter as FileSystemAdapterWithInternalApi).getFilePath("");
309+
const baseFilePathName: string = baseFilePath.replace("file://", "");
311310
const urlPathName: string = (url as any).pathname;
312311
if (urlPathName.startsWith(baseFilePathName)) {
313312
let relativePath = urlPathName.replace(baseFilePathName, "");
@@ -316,21 +315,21 @@ export default class CopyUrlInPreview extends Plugin {
316315
menu.addItem((item: MenuItem) => item
317316
.setIcon("arrow-up-right")
318317
.setTitle("Open in default app")
319-
.onClick(() => (app as AppWithDesktopInternalApi).openWithDefaultApp(relativePath))
318+
.onClick(() => (this.app as AppWithDesktopInternalApi).openWithDefaultApp(relativePath))
320319
);
321320
menu.addItem((item: MenuItem) => item
322321
.setIcon("arrow-up-right")
323322
.setTitle(Platform.isMacOS ? "Reveal in finder" : "Show in system explorer")
324323
.onClick(() => {
325-
(app as AppWithDesktopInternalApi).showInFolder(relativePath);
324+
(this.app as AppWithDesktopInternalApi).showInFolder(relativePath);
326325
})
327326
);
328327
menu.addItem((item: MenuItem) => item
329328
.setIcon("folder")
330329
.setTitle("Reveal file in navigation")
331330
.onClick(() => {
332-
const abstractFilePath = app.vault.getAbstractFileByPath(relativePath.substring(1));
333-
(app as any).internalPlugins.getEnabledPluginById("file-explorer").revealInFolder(abstractFilePath);
331+
const abstractFilePath = this.app.vault.getAbstractFileByPath(relativePath.substring(1));
332+
(this.app as any).internalPlugins.getEnabledPluginById("file-explorer").revealInFolder(abstractFilePath);
334333
})
335334
);
336335
}

versions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"1.0.0": "0.11.13",
33
"1.3.2": "0.14.8",
44
"1.3.5": "0.15.4",
5-
"1.4.0": "0.16.3"
5+
"1.4.0": "0.16.3",
6+
"1.5.2": "1.4.11"
67
}

0 commit comments

Comments
 (0)