mirror of
https://github.com/mryanb/obsidian-asana.git
synced 2026-07-22 05:38:24 +00:00
chore: Add settings for markdown links
This commit is contained in:
parent
bf2cc39a54
commit
46b60c3334
1 changed files with 17 additions and 4 deletions
21
main.ts
21
main.ts
|
|
@ -18,6 +18,7 @@ interface AsanaPluginSettings {
|
|||
asanaToken: string;
|
||||
markTaskAsCompleted: boolean;
|
||||
pinnedProjects: string[]; // Array of project IDs or names
|
||||
enableMarkdownLink: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -27,6 +28,7 @@ const DEFAULT_SETTINGS: AsanaPluginSettings = {
|
|||
asanaToken: '',
|
||||
markTaskAsCompleted: false,
|
||||
pinnedProjects: [],
|
||||
enableMarkdownLink: true,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -99,15 +101,11 @@ export default class AsanaPlugin extends Plugin {
|
|||
selectedText = editor.getLine(cursor.line);
|
||||
}
|
||||
|
||||
console.log(selectedText);
|
||||
|
||||
// Remove leading whitespace, then any list markers and checkboxes
|
||||
selectedText = selectedText
|
||||
.replace(/^\s*(?:[-*]\s*)?(?:\[[ xX]\]\s*)?/, '')
|
||||
.trim();
|
||||
|
||||
console.log(selectedText);
|
||||
|
||||
// Prompt the user to select workspace, project, and section
|
||||
const taskDetails = await this.promptForTaskDetails();
|
||||
if (!taskDetails) {
|
||||
|
|
@ -332,6 +330,11 @@ export default class AsanaPlugin extends Plugin {
|
|||
projectName: string,
|
||||
sectionName: string
|
||||
) {
|
||||
if (!this.settings.enableMarkdownLink) {
|
||||
// If the setting is disabled, do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
const linkText = `[asana#${projectName}/${sectionName}](${taskUrl})`;
|
||||
const selectedText = editor.getSelection();
|
||||
if (selectedText) {
|
||||
|
|
@ -521,6 +524,16 @@ class AsanaSettingTab extends PluginSettingTab {
|
|||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Enable Markdown Link')
|
||||
.setDesc('Insert a markdown link to the task record in the note after task creation.')
|
||||
.addToggle((toggle) =>
|
||||
toggle.setValue(this.plugin.settings.enableMarkdownLink).onChange(async (value) => {
|
||||
this.plugin.settings.enableMarkdownLink = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// Add pinned projects
|
||||
new Setting(containerEl)
|
||||
.setName('Pinned Projects')
|
||||
|
|
|
|||
Loading…
Reference in a new issue