mirror of
https://github.com/lizard-heart/obsidian-to-omnifocus.git
synced 2026-07-22 07:30:26 +00:00
Merge pull request #13 from hissohathair/collected-fixes
Collected fixes for some open issues
This commit is contained in:
commit
5c54131ab5
5 changed files with 88 additions and 26 deletions
34
.github/workflows/release.yml
vendored
Normal file
34
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
name: Release Obsidian plugin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Use Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: "18.x"
|
||||||
|
|
||||||
|
- name: Build plugin
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
tag="${GITHUB_REF#refs/tags/}"
|
||||||
|
|
||||||
|
gh release create "$tag" \
|
||||||
|
--title="$tag" \
|
||||||
|
--draft \
|
||||||
|
main.js manifest.json
|
||||||
17
CHANGES.md
Normal file
17
CHANGES.md
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
## 1.1.0 (July 2024)
|
||||||
|
|
||||||
|
- Fixes issue with vault names containing spaces (#4). Thanks to shabegom.
|
||||||
|
- Accepts "* [ ]" in addition to "- [ ]" as task indicators (#6)
|
||||||
|
- Set a due date by adding "// YYYY-MM-DD" to end of task (#11)
|
||||||
|
|
||||||
|
## 1.0.7 (June 2023)
|
||||||
|
|
||||||
|
- Fixed issue with duplicate tasks.
|
||||||
|
|
||||||
|
## 1.0.6 (March 2023)
|
||||||
|
|
||||||
|
- Adds a command to export selection to Omnifocus. Thanks to mattsmallman.
|
||||||
|
|
||||||
|
## 1.0.4 - 1.0.5 (Feb-Mar 2023)
|
||||||
|
|
||||||
|
- Initial releases.
|
||||||
|
|
@ -17,6 +17,15 @@ This plugin will extract tasks from the current note open in Obsidian and create
|
||||||
4. Asign any projects and tasks in the Omnifocus modal that appears
|
4. Asign any projects and tasks in the Omnifocus modal that appears
|
||||||
5. The tasks should be marked as complete in Obsidian if that setting is enabled
|
5. The tasks should be marked as complete in Obsidian if that setting is enabled
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
- [ ] This task will be sent to OmniFocus
|
||||||
|
- [x] This task will not (already checked)
|
||||||
|
* [ ] This task will be sent to OmniFocus
|
||||||
|
- [ ] This task is due 1 Feb // 2025-02-01
|
||||||
|
```
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
In case you want to support development:
|
In case you want to support development:
|
||||||
<br>
|
<br>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "tasks-to-omnifocus",
|
"id": "tasks-to-omnifocus",
|
||||||
"name": "Send Tasks to OmniFocus",
|
"name": "Send Tasks to OmniFocus",
|
||||||
"version": "1.0.7",
|
"version": "1.1.0",
|
||||||
"minAppVersion": "0.12.0",
|
"minAppVersion": "0.12.0",
|
||||||
"description": "An Obsidian plugin will extract tasks from the current note and create them in OmniFocus.",
|
"description": "An Obsidian plugin will extract tasks from the current note and create them in OmniFocus.",
|
||||||
"author": "Henry Gustafson",
|
"author": "Henry Gustafson",
|
||||||
|
|
|
||||||
36
src/main.ts
36
src/main.ts
|
|
@ -1,11 +1,6 @@
|
||||||
import { serialize } from "monkey-around";
|
|
||||||
import {
|
import {
|
||||||
MarkdownView,
|
MarkdownView,
|
||||||
CachedMetadata,
|
|
||||||
Notice,
|
|
||||||
Plugin,
|
Plugin,
|
||||||
TFile,
|
|
||||||
Vault,
|
|
||||||
Editor,
|
Editor,
|
||||||
} from "obsidian";
|
} from "obsidian";
|
||||||
|
|
||||||
|
|
@ -41,30 +36,37 @@ export default class TasksToOmnifocus extends Plugin {
|
||||||
this.addSettingTab(new TasksToOmnifocusSettingTab(this.app, this));
|
this.addSettingTab(new TasksToOmnifocusSettingTab(this.app, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
async addToOmnifocus(isSelection: bool, editor: Editor, view: MarkdownView) {
|
async addToOmnifocus(isSelection: boolean, editor: Editor, view: MarkdownView) {
|
||||||
var editorText;
|
let editorText;
|
||||||
if (isSelection) {
|
if (isSelection) {
|
||||||
editorText = editor.getSelection();
|
editorText = editor.getSelection();
|
||||||
} else {
|
} else {
|
||||||
editorText = editor.getValue();
|
editorText = editor.getValue();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let tasks = editorText.match(/- \[ \] .*/g);
|
const tasks = editorText.match(/[-*] \[ \] .*/g);
|
||||||
|
|
||||||
for (let task of tasks) {
|
for (const task of tasks) {
|
||||||
let taskName = task.replace("- [ ] ", "");
|
let taskName = task.replace(/[-*] \[ \] /, "");
|
||||||
let taskNameEncoded = encodeURIComponent(taskName);
|
// check if taskName has "//" followed by a date, and if so extract the date for later use and remove it from taskName
|
||||||
let noteURL = view.file.path.replace(/ /g, "%20").replace(/\//g, "%2F");
|
const dateMatch = taskName.match(/(\/\/\s*)(\d{4}-\d{2}-\d{2})/);
|
||||||
let vaultName = app.vault.getName();
|
let taskDate = "";
|
||||||
let taskNoteEncoded = encodeURIComponent("obsidian://open?=" + vaultName + "&file=" + noteURL);
|
if (dateMatch) {
|
||||||
|
taskDate = dateMatch[2];
|
||||||
|
taskName = taskName.replace(dateMatch[0], "");
|
||||||
|
}
|
||||||
|
const taskNameEncoded = encodeURIComponent(taskName);
|
||||||
|
const noteURL = view.file.path.replace(/ /g, "%20").replace(/\//g, "%2F");
|
||||||
|
const vaultName = this.app.vault.getName().replace(/\s/g, "%20");
|
||||||
|
const taskNoteEncoded = encodeURIComponent("obsidian://open?=" + vaultName + "&file=" + noteURL);
|
||||||
|
|
||||||
window.open(
|
window.open(
|
||||||
`omnifocus:///add?name=${taskNameEncoded}¬e=${taskNoteEncoded}`
|
`omnifocus:///add?name=${taskNameEncoded}¬e=${taskNoteEncoded}&due=${taskDate}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.settings.markComplete) {
|
if (this.settings.markComplete) {
|
||||||
let completedText = editorText.replace(/- \[ \]/g, "- [x]");
|
const completedText = editorText.replace(/([-*]) \[ \]/g, "$1 [x]");
|
||||||
if (isSelection) {
|
if (isSelection) {
|
||||||
editor.replaceSelection(completedText);
|
editor.replaceSelection(completedText);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -73,7 +75,7 @@ export default class TasksToOmnifocus extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error('Error extracting tasks', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue