mirror of
https://github.com/heroblackink/ultimate-todoist-sync-for-obsidian.git
synced 2026-07-22 07:40:27 +00:00
feat(ui): add Todoist deep link in Task Manager detail view
This commit is contained in:
parent
c3e24c1c82
commit
c8122f73c4
2 changed files with 46 additions and 11 deletions
|
|
@ -563,6 +563,14 @@ export class TaskManagerModal extends Modal {
|
|||
const idRow = infoCard.createDiv({ cls: 'tm-detail-info-row' });
|
||||
idRow.createSpan({ cls: 'tm-detail-info-label', text: 'Task ID' });
|
||||
idRow.createSpan({ cls: 'tm-detail-info-value tm-task-id', text: taskId });
|
||||
const todoistRow = infoCard.createDiv({ cls: 'tm-detail-info-row' });
|
||||
todoistRow.createSpan({ cls: 'tm-detail-info-label', text: 'Todoist' });
|
||||
const todoistLink = todoistRow.createEl('a', { cls: 'tm-detail-info-value tm-todoist-link', text: 'Open in Todoist' });
|
||||
todoistLink.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.openTodoistTask(taskId);
|
||||
});
|
||||
const fileRow = infoCard.createDiv({ cls: 'tm-detail-info-row' });
|
||||
fileRow.createSpan({ cls: 'tm-detail-info-label', text: 'File' });
|
||||
const fileLink = fileRow.createEl('a', { cls: 'tm-detail-info-value tm-file-link', text: filePath || '—' });
|
||||
|
|
@ -909,16 +917,33 @@ export class TaskManagerModal extends Modal {
|
|||
document.body.appendChild(overlay);
|
||||
});
|
||||
}
|
||||
private openFile(filePath: string) {
|
||||
const file = this.app.vault.getAbstractFileByPath(filePath);
|
||||
if (file instanceof TFile) {
|
||||
this.app.workspace.getLeaf(false).openFile(file);
|
||||
}
|
||||
}
|
||||
private navigateToList() {
|
||||
this.currentView = 'list';
|
||||
this.selectedTaskId = null;
|
||||
this.renderCurrentView();
|
||||
private openFile(filePath: string) {
|
||||
const file = this.app.vault.getAbstractFileByPath(filePath);
|
||||
if (file instanceof TFile) {
|
||||
this.app.workspace.getLeaf(false).openFile(file);
|
||||
}
|
||||
}
|
||||
private buildTodoistTaskUrl(taskId: string): string {
|
||||
const encodedTaskId = encodeURIComponent(taskId);
|
||||
if (this.plugin.settings.useAppURI) {
|
||||
return `todoist://task?id=${encodedTaskId}`;
|
||||
}
|
||||
|
||||
return `https://app.todoist.com/app/task/${encodedTaskId}`;
|
||||
}
|
||||
private openTodoistTask(taskId: string): void {
|
||||
if (!taskId) {
|
||||
new Notice('Task ID not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
const url = this.buildTodoistTaskUrl(taskId);
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
private navigateToList() {
|
||||
this.currentView = 'list';
|
||||
this.selectedTaskId = null;
|
||||
this.renderCurrentView();
|
||||
}
|
||||
private async getTaskLine(taskId: string, filePath: string): Promise<string | null> {
|
||||
try {
|
||||
|
|
|
|||
12
styles.css
12
styles.css
|
|
@ -137,6 +137,16 @@
|
|||
.tm-file-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.tm-todoist-link {
|
||||
font-size: 12px;
|
||||
color: var(--text-accent);
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tm-todoist-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
/* Diff table */
|
||||
.tm-diff {
|
||||
width: 100%;
|
||||
|
|
@ -434,4 +444,4 @@
|
|||
margin-top: 16px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--background-modifier-border);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue