Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate SingleFile with "Share API" (Safari and Chromium on Windows) #1381

Closed
gildas-lormeau opened this issue Feb 4, 2024 · 14 comments
Closed

Comments

@gildas-lormeau
Copy link
Owner

The goal would be to include a “Save page to Notes” and “Save selection to Notes” in the list of suggestions.

@appledispatch
Copy link

I just posted an article for my publication, Apple Dispatch, about integrating SingleFile, Apple Notes and Safari that is relevant to this suggested feature request and also how to harness the power of SingleFile in general.

The way that I'm sharing items now is by Right-clicking the downloaded HTML file, selecting Share…, and then choosing Notes. It would be great to have the tighter integration built directly into the Safari Share Sheet.

Thanks for your continued efforts on such an amazing tool!

@gildas-lormeau
Copy link
Owner Author

Thank you very much for the article. I did a quick test in Safari and it looks promising. The good news is that it supports the navigator.share() API.

FYI, here is the test I did:

  1. Open https://www.example.com in Safari
  2. Open the JavaScript console (via the menu Develop > Show JavaScript Console)
  3. Paste the code below in the console and press Enter
document.onclick = () => navigator.share({ files: [new File([ document.documentElement.outerHTML ], "example.html")]})
  1. Click anywhere on the page
  2. A popup should allow you to add the page in Notes

I will do a more advanced integration test in SingleFile, I'll keep you informed ;)

@appledispatch
Copy link

That is absolutely fantastic! I just ran the code you posted and it works perfectly! Thanks for sharing it.

I noticed if I click away from the share sheet, without sharing to Notes, I get these errors in the console: (Unhandled Promise Rejection: InvalidStateError: share() is already in progress) and this one: (Unhandled Promise Rejection: AbortError: Abort due to cancellation of share.) Maybe this is the intended behavior?

I put the word out about my article highlighting SingleFile over at the excellent /MacApps subreddit and they are really digging it there. It’s turning on a lot of people (≈ 3.9k currently) to your wonderful extension in the Apple community.

Yes indeed, please keep me in the loop as things progress. I will be posting about this @Apple Dispatch for my Apple Notes series once this feature becomes a reality.

Truly exciting developments!

@gildas-lormeau
Copy link
Owner Author

gildas-lormeau commented Feb 18, 2024

It's implemented. I added a new option share page in the Destination section. When checked, a banner with a Share page... button will appear at the top of the page when you save it. By clicking on this button, you will be able to share the saved page on Notes, see the screenshot below. Unfortunately, this button requires an extra click, but I have no choice from a technical point of view.

The new option will be available in the next version.

image

@appledispatch
Copy link

Thanks so much for your excellent work on this new feature! I love to see SingleFile getting even tighter integration with Safari and Notes.

Can't wait to see this drop on the App Store.

@gildas-lormeau
Copy link
Owner Author

The new version (1.2.0) is available for download on the App store.

@appledispatch
Copy link

This is absolutely killer! Is there a way for this new implementation to also work for Save selection to Notes?

@gildas-lormeau
Copy link
Owner Author

Actually, it should also work for selection if you use the context menu and select 'Save selection' instead of clicking on SingleFile button.

@appledispatch
Copy link

That's great! Is there a way for the 'Share page…' button to change to 'Share selection…' when choosing that option from the context menu?

@gildas-lormeau
Copy link
Owner Author

Thank you for the suggestion, it is fixed. The fix will be available in the next version.

@appledispatch
Copy link

Any time. Well done!

@gildas-lormeau gildas-lormeau changed the title Integrate SingleFile with the Safari Share Extension framework Integrate SingleFile with "Share API" (Safari and Chromium on Windows) Feb 22, 2024
@appledispatch
Copy link

Is there a way to get macOS Spotlight to index the HTML files saved by SingleFile? It seems that files saved to Apple Notes can only be searched by title and not by the text contained within each HTML document.

@gildas-lormeau
Copy link
Owner Author

gildas-lormeau commented Mar 2, 2024

I don't think it's possible. It looks like it's a "bug" in Notes, see https://discussions.apple.com/thread/251960240?answerId=253757819022.

However, you can search for attached pages with the Finder in ~/Library/Group Containers/group.com.apple.notes/Accounts.

@appledispatch
Copy link

You're definitely on to something with that Apple Discussion thread. I was able to find out that Spotlight will index and search text content within Safari webarchives, but Notes cannot do the same. It looks like Apple did not implement that part of the Spotlight Index API in Notes.

So, it seems pretty clear why Notes cannot search SingleFile archives, but I'm still not sure why Spotlight can't search them. Maybe, Apple only allows the API to work on its own HTML archive format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants