microdotblog / microblog-react

MIT License
29 stars 3 forks source link

Sharing text and web page URL #40

Closed manton closed 1 year ago

manton commented 1 year ago

In version 2.x, if you select text in Safari and use the share toolbar button (not the context menu), it will grab both the selected text and the web page URL to include in the draft Markdown post. I'm remembering now that this requires setting a JavaScript file that runs inside Safari and can extract the info via the DOM or whatever.

@vincentritter I've checked this into the fix/share-selected-text branch. However, I'm hitting my head against crashes and other debugging problems, so haven't figured out what is missing yet to finish reimplementing this feature. It may require tweaks to the ReactNativeShareMenu code.

vincentritter commented 1 year ago

Thanks @manton – I'll have a look into this.

vincentritter commented 1 year ago

I can replicate the crash, but it's not showing the root cause of why it's happening. Still investigating.

vincentritter commented 1 year ago

OK, can see the issue when debugging the actual share extension.

manton commented 1 year ago

@vincentritter I think I'm going to tweak the text a little so it matches the web app when making a new post from a highlight. Also will look at restoring the bookmark feature, which I think broke with this.

vincentritter commented 1 year ago

That's a good catch!

Have a look at the following in "/src/stores/Share.js", line 230:

can_save_as_bookmark() {
  return self.share_type === "text" && self.share_text.length > 0 && (self.share_text.startsWith("http://") || self.share_text.startsWith("https://")) && string_checker._validate_url(self.share_text)
}

You'll have to change the "share_type" to json as that's new now, plus the actual text check too, to take into account the markdown.

vincentritter commented 1 year ago

@manton – I made tweaks in this branch: https://github.com/microdotblog/microblog-react/tree/feature/share-sheet-tweaks

It'll offer to save the bookmark correctly now.

Feel free to use that branch to make your other tweaks.