mirror of
https://github.com/lizard-heart/obsidian-to-omnifocus.git
synced 2026-07-22 04:34:30 +00:00
feat: Allow due date to be set (#11)
Fix for issue #11, you can set a due date in YYYY-MM-DD format using "//" (similar to Confluence Markdown)
This commit is contained in:
parent
3842d40077
commit
d549bdc32e
3 changed files with 20 additions and 11 deletions
|
|
@ -2,3 +2,4 @@
|
|||
|
||||
- Fixes issue with vault names containing spaces (#4) (shabegom)
|
||||
- Accepts "* [ ]" in addition to "- [ ]" as task indicates (#6)
|
||||
- Set a due date by adding "// YYYY-MM-DD" to end of task (#11)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"id": "tasks-to-omnifocus",
|
||||
"name": "Send Tasks to OmniFocus",
|
||||
"version": "1.0.7",
|
||||
"minAppVersion": "0.12.0",
|
||||
"description": "An Obsidian plugin will extract tasks from the current note and create them in OmniFocus.",
|
||||
"author": "Henry Gustafson",
|
||||
"authorUrl": "https://lizard-heart.github.io",
|
||||
"fundingUrl": "https://buymeacoffee.com/lizardheart",
|
||||
"isDesktopOnly": false
|
||||
"id": "tasks-to-omnifocus",
|
||||
"name": "Send Tasks to OmniFocus",
|
||||
"version": "1.1.0",
|
||||
"minAppVersion": "0.12.0",
|
||||
"description": "An Obsidian plugin will extract tasks from the current note and create them in OmniFocus.",
|
||||
"author": "Henry Gustafson",
|
||||
"authorUrl": "https://lizard-heart.github.io",
|
||||
"fundingUrl": "https://buymeacoffee.com/lizardheart",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
|
|
|
|||
12
src/main.ts
12
src/main.ts
|
|
@ -47,14 +47,22 @@ export default class TasksToOmnifocus extends Plugin {
|
|||
const tasks = editorText.match(/[-*] \[ \] .*/g);
|
||||
|
||||
for (const task of tasks) {
|
||||
const taskName = task.replace(/[-*] \[ \] /, "");
|
||||
let taskName = task.replace(/[-*] \[ \] /, "");
|
||||
// check if taskName has "//" followed by a date, and if so extract the date for later use and remove it from taskName
|
||||
const dateMatch = taskName.match(/(\/\/\s*)(\d{4}-\d{2}-\d{2})/);
|
||||
let taskDate = "";
|
||||
if (dateMatch) {
|
||||
taskDate = dateMatch[2];
|
||||
taskName = taskName.replace(dateMatch[0], "");
|
||||
console.log(`Setting taskDate to ${taskDate}`);
|
||||
}
|
||||
const taskNameEncoded = encodeURIComponent(taskName);
|
||||
const noteURL = view.file.path.replace(/ /g, "%20").replace(/\//g, "%2F");
|
||||
const vaultName = app.vault.getName().replace(/\s/g, "%20");
|
||||
const taskNoteEncoded = encodeURIComponent("obsidian://open?=" + vaultName + "&file=" + noteURL);
|
||||
|
||||
window.open(
|
||||
`omnifocus:///add?name=${taskNameEncoded}¬e=${taskNoteEncoded}`
|
||||
`omnifocus:///add?name=${taskNameEncoded}¬e=${taskNoteEncoded}&due=${taskDate}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue