Compare commits

...

21 commits
1.0.5 ... main

Author SHA1 Message Date
Henry Gustafson
5c54131ab5
Merge pull request #13 from hissohathair/collected-fixes
Collected fixes for some open issues
2024-08-14 21:23:41 -07:00
Daniel Austin
66b83fb68f fix: Remove console log
Also avoid `app` directly, prefer `this.app`.
Guidelines: https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines
2024-07-21 15:45:08 +10:00
Daniel Austin
7d8784f6c4 docs: Updating doc files 2024-07-13 18:48:50 +10:00
Daniel Austin
d549bdc32e 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)
2024-07-13 17:04:50 +10:00
Daniel Austin
3842d40077 build: Add release workflow and CHANGES 2024-07-13 16:44:11 +10:00
Daniel Austin
d7759d8552 fix: Allow dash and asterisk marked tasks (#6)
Fix for issue #6 -- allows both "- [ ]" and "* [ ]" as task indicators.
2024-07-13 16:33:58 +10:00
Daniel Austin
69bd5fb946 chore: Address TS warnings 2024-07-13 16:22:23 +10:00
Sam Morrison
fe0ec58056 fix typing of boolean arg 2024-04-02 11:25:38 -04:00
Sam Morrison
177af7f8be replace spaces in titles with %20F 2024-04-02 11:23:36 -04:00
Henry Gustafson
f50f7650c1
Create FUNDING.yml 2023-09-01 21:31:38 -07:00
lizard-heart
f56917b75e increment version number 2023-05-31 18:50:48 -07:00
Henry Gustafson
f3d6b2d73a
Merge pull request #5 from nweisenfeld/neil/fix-doubles
update markComplete to work with selection or whole document
2023-05-31 15:52:49 -07:00
Henry Gustafson
f64589bfc5
Update main.ts 2023-05-31 15:51:36 -07:00
Neil Weisenfeld
a941b2acb5 update markComplete to work with selection or whole document 2023-05-24 10:22:57 -04:00
lizard-heart
3f96123b56 add donation link 2023-04-02 22:13:23 -07:00
lizard-heart
05e7ef1219 refactor 2023-03-26 11:20:53 -07:00
Henry Gustafson
b7aecc8ad6
Merge pull request #2 from mattsmallman/main
Added - Extract Tasks from selection into Omnifocus Command
2023-03-26 11:13:24 -07:00
Matt Smallman
4351cd8d5f
Update main.ts 2023-03-26 15:37:41 +01:00
Matt Smallman
f7b8f3932f
Update main.ts 2023-03-26 15:17:08 +01:00
Henry Gustafson
2903418300
Update README.md 2023-03-24 09:22:07 -07:00
Henry Gustafson
011b9d7467
rename 2023-03-24 09:15:16 -07:00
8 changed files with 140 additions and 85 deletions

34
.github/workflows/release.yml vendored Normal file
View 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

2
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,2 @@
{
}

17
CHANGES.md Normal file
View 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.

1
FUNDING.yml Normal file
View file

@ -0,0 +1 @@
github: lizard-heart

View file

@ -16,3 +16,19 @@ This plugin will extract tasks from the current note open in Obsidian and create
3. Run the `Extract Tasks Into OmniFocus` command
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
## 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
In case you want to support development:
<br>
<a href="https://www.buymeacoffee.com/lizardheart">
<img alt="Buy me a Coffee" height="39px" src="https://raw.githubusercontent.com/lizard-heart/lizard-heart/main/buy-me-a-cofee.png" />
</a>

View file

@ -1,10 +1,11 @@
{
"id": "tasks-to-omnifocus",
"name": "Send Tasks to OmniFocus",
"version": "1.0.5",
"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",
"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
}

View file

@ -1,105 +1,89 @@
import { serialize } from "monkey-around";
import {
MarkdownView,
CachedMetadata,
Notice,
Plugin,
TFile,
Vault,
Editor,
} from "obsidian";
import {
ListModifiedSettingsRenamed,
TasksToOmnifocusSettings,
DEFAULT_SETTINGS,
ListModifiedSettingTabRenamed,
TasksToOmnifocusSettingTab,
} from "./settings";
export default class ListModifiedRenamed extends Plugin {
settings: ListModifiedSettingsRenamed;
export default class TasksToOmnifocus extends Plugin {
settings: TasksToOmnifocusSettings;
async onload() {
await this.loadSettings();
// this.addCommand({
// id: "extract-tasks",
// name: "Extract Tasks Into OmniFocus",
// callback: () => this.sendToOF(),
// });
this.addCommand({
id: 'extract-tasks',
name: 'Extract Tasks Into OmniFocus',
editorCallback: (editor: Editor, view: MarkdownView) => {
const editorText = editor.getValue()
try {
let tasks = editorText.match(/- \[ \] .*/g);
for (let task of tasks) {
let taskName = task.replace("- [ ] ", "");
let taskNameEncoded = encodeURIComponent(taskName);
let noteURL = view.file.path.replace(/ /g, "%20").replace(/\//g, "%2F");
let vaultName = app.vault.getName();
let taskNoteEncoded = encodeURIComponent("obsidian://open?=" + vaultName + "&file=" + noteURL);
window.open(
`omnifocus:///add?name=${taskNameEncoded}&note=${taskNoteEncoded}`
);
}
if (this.settings.markComplete) {
let completedText = editorText.replace(/- \[ \]/g, "- [x]");
editor.setValue(completedText);
}
} catch (err) {
}
this.addToOmnifocus(false, editor, view);
},
});
this.addSettingTab(new ListModifiedSettingTabRenamed(this.app, this));
this.addCommand({
id: 'extract-tasks-selection',
name: 'Extract Tasks from selection Into OmniFocus',
editorCallback: (editor: Editor, view: MarkdownView) => {
this.addToOmnifocus(true, editor, view);
},
});
this.addSettingTab(new TasksToOmnifocusSettingTab(this.app, this));
}
async addToOmnifocus(isSelection: boolean, editor: Editor, view: MarkdownView) {
let editorText;
if (isSelection) {
editorText = editor.getSelection();
} else {
editorText = editor.getValue();
}
try {
const tasks = editorText.match(/[-*] \[ \] .*/g);
for (const task of tasks) {
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], "");
}
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(
`omnifocus:///add?name=${taskNameEncoded}&note=${taskNoteEncoded}&due=${taskDate}`
);
}
if (this.settings.markComplete) {
const completedText = editorText.replace(/([-*]) \[ \]/g, "$1 [x]");
if (isSelection) {
editor.replaceSelection(completedText);
} else {
editor.setValue(completedText)
}
}
} catch (err) {
console.error('Error extracting tasks', err);
}
}
async saveSettings() {
await this.saveData(this.settings);
}
onunload() {}
// // the first function that runs
// async sendToOF() {
// // const app = window.app as App;
// const view = this.app.workspace.getActiveViewOfType(MarkdownView);
// if (view!=null) {
// const editor = view.editor;
// const editorText = editor.getValue();
// try {
// let tasks = editorText.match(/- \[ \] .*/g);
// for (let task of tasks) {
// let taskName = task.replace("- [ ] ", "");
// let taskNameEncoded = encodeURIComponent(taskName);
// let noteURL = view.file.path.replace(/ /g, "%20").replace(/\//g, "%2F");
// let vaultName = app.vault.getName();
// let taskNoteEncoded = encodeURIComponent("obsidian://open?=" + vaultName + "&file="+noteURL);
// window.open(
// `omnifocus:///add?name=${taskNameEncoded}&note=${taskNoteEncoded}`
// );
// }
// if (this.settings.markComplete) {
// let completedText = editorText.replace(/- \[ \]/g, "- [x]");
// editor.setValue(completedText);
// }
// } catch (err) {
// }
// }
// }
onunload() { }
private async loadSettings() {

View file

@ -1,16 +1,16 @@
import { App, PluginSettingTab, Setting } from "obsidian";
import ListModified from "./main";
export interface ListModifiedSettingsRenamed {
export interface TasksToOmnifocusSettings {
markComplete: boolean;
}
export const DEFAULT_SETTINGS: ListModifiedSettingsRenamed = {
export const DEFAULT_SETTINGS: TasksToOmnifocusSettings = {
markComplete: true,
};
export class ListModifiedSettingTabRenamed extends PluginSettingTab {
export class TasksToOmnifocusSettingTab extends PluginSettingTab {
plugin: ListModified;
tagString: string;