Skip to content

Commit

Permalink
Added timestamp hover for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Erallie committed Nov 28, 2024
1 parent 20917e4 commit 619b0a0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, moment } from 'obsidian';
import { Plugin, moment, Notice, Platform } from 'obsidian';

// Remember to rename these classes and interfaces!

Expand Down Expand Up @@ -79,7 +79,13 @@ export default class DiscordTimestamps extends Plugin {
newEl.appendText(textSlices[i]);
}
if (i < timestampSlices.length && i < timestampHover.length) {
newEl.createEl('span', { text: timestampSlices[i], cls: 'discord-timestamps' }).ariaLabel = timestampHover[i]
let timestampEl = newEl.createEl('span', { text: timestampSlices[i], cls: 'discord-timestamps' });
timestampEl.ariaLabel = timestampHover[i];
timestampEl.onClickEvent((ev) => {
if (Platform.isMobile) {
new Notice(timestampHover[i]);
}
})
}
else if (timestampSlices.length !== timestampHover.length) {
console.error("The lengths of timestampSlices and timestampHover are NOT EQUAL!");
Expand Down

0 comments on commit 619b0a0

Please sign in to comment.