Skip to content

Commit

Permalink
0.5.23
Browse files Browse the repository at this point in the history
Add icons for mobile ease of access
  • Loading branch information
alangrainger committed Oct 18, 2023
2 parents dd1777b + fc52cda commit bc8050f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "share-note",
"name": "Share Note",
"version": "0.5.22",
"version": "0.5.23",
"minAppVersion": "0.15.0",
"description": "Instantly share a note, with the full theme and content exactly like you see in Reading View. Data is shared encrypted by default, and only you and the person you send it to have the key.",
"author": "Alan Grainger",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "share-note",
"version": "0.5.22",
"version": "0.5.23",
"description": "Instantly share a note, with the full theme and content exactly like you see in Reading View. Data is shared encrypted by default, and only you and the person you send it to have the key.",
"main": "main.js",
"scripts": {
Expand Down
36 changes: 35 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, TFile } from 'obsidian'
import { Plugin, setIcon, TFile } from 'obsidian'
import { DEFAULT_SETTINGS, ShareSettings, ShareSettingsTab, YamlField } from './settings'
import Note from './note'
import API from './api'
Expand Down Expand Up @@ -56,6 +56,40 @@ export default class SharePlugin extends Plugin {
}
})

// Add share icons to properties panel
this.registerEvent(this.app.workspace.on('active-leaf-change', () => {
console.log('icons')
// I tried using onLayoutReady() here rather than a timeout, but it did not work.
// It seems that the layout is still updating even after it is "ready".
setTimeout(() => {
document.querySelectorAll(`div.metadata-property[data-property-key="${this.field(YamlField.link)}"]`)
.forEach(propertyEl => {
const valueEl = propertyEl.querySelector('div.metadata-property-value')
if (valueEl && !valueEl.querySelector('div.share-note-icons')) {
const iconsEl = document.createElement('div')
iconsEl.classList.add('share-note-icons')
// Re-share note icon
const shareIcon = iconsEl.createEl('span')
shareIcon.title = 'Re-share note'
setIcon(shareIcon, 'upload-cloud')
shareIcon.onclick = () => this.uploadNote()
// Copy to clipboard icon
const copyIcon = iconsEl.createEl('span')
copyIcon.title = 'Copy link to clipboard'
setIcon(copyIcon, 'copy')
copyIcon.onclick = async () => {
const link = propertyEl.querySelector('div.metadata-link-inner.external-link') as HTMLElement
if (link) {
await navigator.clipboard.writeText(link.innerText)
new StatusMessage('📋 Shared link copied to clipboard')
}
}
valueEl.prepend(iconsEl)
}
})
}, 200)
}))

// Add command - Share note
this.addCommand({
id: 'share-note',
Expand Down
10 changes: 10 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@
background: #629762;
color: white
}

.share-note-icons {
display: flex;
}

.share-note-icons > span {
display: flex;
margin-left: 5px;
cursor: pointer;
}
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"0.5.19": "0.15.0",
"0.5.20": "0.15.0",
"0.5.21": "0.15.0",
"0.5.22": "0.15.0"
"0.5.22": "0.15.0",
"0.5.23": "0.15.0"
}

0 comments on commit bc8050f

Please sign in to comment.