Merge pull request #91 from deafmute1/issue90-desktop-uri

Add App URIs for links
This commit is contained in:
HeroBlackInk 2024-10-03 02:24:30 +08:00 committed by GitHub
commit 4976caab80
4 changed files with 23 additions and 4 deletions

4
.gitignore vendored
View file

@ -21,3 +21,7 @@ userData
# Exclude macOS Finder (System Explorer) View States
.DS_Store
# Add js build artifacts
*.js

6
package-lock.json generated
View file

@ -1,13 +1,13 @@
{
"name": "obsidian-sample-plugin",
"name": "ultimate-todoist-sync",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "obsidian-sample-plugin",
"name": "ultimate-todoist-sync",
"version": "1.0.0",
"license": "MIT",
"license": "GNU GPLv3",
"dependencies": {
"@doist/todoist-api-typescript": "^2.1.2"
},

View file

@ -21,6 +21,7 @@ export interface UltimateTodoistSyncSettings {
enableFullVaultSync: boolean;
statistics: any;
debugMode:boolean;
useAppURI:boolean;
}
@ -34,6 +35,7 @@ export const DEFAULT_SETTINGS: UltimateTodoistSyncSettings = {
enableFullVaultSync:false,
statistics:{},
debugMode:false,
useAppURI:true,
//mySetting: 'default',
//todoistTasksFilePath: 'todoistTasks.json'
@ -396,6 +398,19 @@ export class UltimateTodoistSyncSettingTab extends PluginSettingTab {
this.plugin.todoistSync.backupTodoistAllResources()
})
);
new Setting(containerEl)
.setName('Use Desktop URIs')
.setDesc('If enabled produces application URI links (todoist://...) instead of web urls (https://...), which open in the app instead of the browser')
.addToggle(component =>
component
.setValue(this.plugin.settings.useAppURI)
.onChange((value)=>{
this.plugin.settings.useAppURI = value
this.plugin.saveSettings()
})
)
}
}

View file

@ -154,7 +154,7 @@ export class TodoistSync {
//todoist id 保存到 任务后面
const text_with_out_link = `${linetxt} %%[todoist_id:: ${todoist_id}]%%`;
const link = `[link](${newTask.url})`
const link = this.plugin.settings.useAppURI ? `[link](todoist://task?id=${newTask.id})` : `[link](${newTask.url})`
const text = this.plugin.taskParser.addTodoistLink(text_with_out_link,link)
const from = { line: cursor.line, ch: 0 };
const to = { line: cursor.line, ch: linetxt.length };