diff --git a/dist/manifest.json b/dist/manifest.json index af58632..81acf57 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,7 +1,7 @@ { "id": "todotxt", "name": "TodoTxt", - "version": "1.4.4", + "version": "1.5.0", "minAppVersion": "0.15.0", "description": "Manage Todo.txt files.", "author": "Mark Grimes", diff --git a/dist/versions.json b/dist/versions.json index ef2b4df..4f44db5 100644 --- a/dist/versions.json +++ b/dist/versions.json @@ -16,5 +16,6 @@ "1.3.3": "0.15.0", "1.4.0": "0.15.0", "1.4.3": "0.15.0", - "1.4.4": "0.15.0" -} + "1.4.4": "0.15.0", + "1.5.0": "0.15.0" +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index af58632..81acf57 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "todotxt", "name": "TodoTxt", - "version": "1.4.4", + "version": "1.5.0", "minAppVersion": "0.15.0", "description": "Manage Todo.txt files.", "author": "Mark Grimes", diff --git a/package.json b/package.json index f2455c3..2a396fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-sample-plugin", - "version": "1.4.4", + "version": "1.5.0", "description": "This is a sample plugin for Obsidian (https://obsidian.md)", "main": "dist/main.js", "scripts": { diff --git a/src/ui/todoslist.tsx b/src/ui/todoslist.tsx index dae6555..732b9e7 100644 --- a/src/ui/todoslist.tsx +++ b/src/ui/todoslist.tsx @@ -8,6 +8,7 @@ type TodosListProps = { onCompleteToggle: (t: Todo) => void; onDeleteClicked: (t: Todo) => void; onEditClicked: (t: Todo) => void; + onNavigate: (url: string, newTab: boolean) => void; }; export const TodosList = (props: TodosListProps) => { @@ -34,6 +35,7 @@ export const TodosList = (props: TodosListProps) => { onDeleteClicked={props.onDeleteClicked} onEditClicked={props.onEditClicked} onKeyPressed={handleKeyPress} + onNavigate={props.onNavigate} key={todo.id} /> ))} diff --git a/src/ui/todosview.tsx b/src/ui/todosview.tsx index 9be0aa3..8f6e7d7 100644 --- a/src/ui/todosview.tsx +++ b/src/ui/todosview.tsx @@ -13,6 +13,7 @@ type TodosViewProps = { defaultOrganizeBy: 'project' | 'context'; preservePriority: boolean; recurringTasks: boolean; + onNavigate: (url: string, newTab: boolean) => void; }; type OrganizeBy = 'project' | 'context'; @@ -176,6 +177,7 @@ export const TodosView = (props: TodosViewProps) => { onCompleteToggle={handleCompleteToggle} onDeleteClicked={handleShowDelete} onEditClicked={handleShowEdit} + onNavigate={props.onNavigate} /> ))} diff --git a/src/ui/todoview.tsx b/src/ui/todoview.tsx index f51d845..0b4b3ab 100644 --- a/src/ui/todoview.tsx +++ b/src/ui/todoview.tsx @@ -11,6 +11,7 @@ type TodoViewProps = { onDeleteClicked: (t: Todo) => void; onEditClicked: (t: Todo) => void; onKeyPressed: (e: React.KeyboardEvent, t: Todo) => void; + onNavigate: (url: string, newTab: boolean) => void; }; export const TodoView = (props: TodoViewProps) => { const { todo } = props; @@ -43,7 +44,10 @@ export const TodoView = (props: TodoViewProps) => { todo.preThreshold() ? 'todo-prethreshold' : '', )} > - {todo.description} + {todo.tags.map((tag, i) => ( @@ -106,3 +110,36 @@ const TodoTagView = ({ tag }: { tag: TodoTag }) => { ); }; + +const DESC_RE = /(\[\[[^\]]+\]\])/g; + +const TodoDescription = ({ + description, + onNavigate, +}: { + description: string; + onNavigate: (url: string, newTab: boolean) => void; +}) => { + const parts = description.split(DESC_RE); + console.log(description, parts); + + return ( + + {parts.map((part) => { + const url = part.match(/^\[\[(.*)\]\]$/); + if (url) + return ( + { + e.preventDefault(); + onNavigate(url[1], true); + }} + > + {url[1]} + + ); + return <>{part}; + })} + + ); +}; diff --git a/src/view.tsx b/src/view.tsx index 79748be..d03f72b 100644 --- a/src/view.tsx +++ b/src/view.tsx @@ -59,6 +59,11 @@ export class TodotxtView extends TextFileView { this.requestSave(); } + handleNavigate(url: string, newTab: boolean) { + const callingFilePath = ''; // TODO: this must be available in `this` + this.plugin.app.workspace.openLinkText(url, callingFilePath, newTab); + } + refresh() { const settings = this.plugin?.settings; @@ -70,6 +75,7 @@ export class TodotxtView extends TextFileView { defaultOrganizeBy={settings?.defaultOrganizeBy || 'project'} preservePriority={settings?.preservePriority ?? true} recurringTasks={settings?.recurringTasks ?? false} + onNavigate={this.handleNavigate.bind(this)} />, ); } diff --git a/versions.json b/versions.json index ef2b4df..4f44db5 100644 --- a/versions.json +++ b/versions.json @@ -16,5 +16,6 @@ "1.3.3": "0.15.0", "1.4.0": "0.15.0", "1.4.3": "0.15.0", - "1.4.4": "0.15.0" -} + "1.4.4": "0.15.0", + "1.5.0": "0.15.0" +} \ No newline at end of file