-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a643ff
commit 9f53803
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { SettingItemType } from "api/types"; | ||
import { createSimpleSetting } from "./base"; | ||
|
||
export const ApplyTagsWhileInsertingSetting = createSimpleSetting<boolean>("applyTagsWhileInserting", { | ||
public: true, | ||
type: SettingItemType.Bool, | ||
value: true, | ||
label: "Apply tags while inserting template", | ||
description: "Apply tags using 'template_tags' variable while inserting template to notes/to-dos.", | ||
section: "templatesPlugin" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import joplin from "api"; | ||
import { SettingItem } from "api/types"; | ||
|
||
export interface PluginSetting<T> { | ||
id: string; | ||
manifest: SettingItem; | ||
|
||
get(): Promise<T>; | ||
set(newValue: T): Promise<void>; | ||
} | ||
|
||
export const createSimpleSetting = <T>(id: string, manifest: SettingItem): PluginSetting<T> => { | ||
return class { | ||
static id = id; | ||
static manifest = manifest; | ||
|
||
static async get(): Promise<T> { | ||
return await joplin.settings.value(id); | ||
} | ||
|
||
static async set(newValue: T): Promise<void> { | ||
await joplin.settings.setValue(id, newValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { SettingItemType } from "api/types"; | ||
import { createSimpleSetting } from "./base"; | ||
|
||
export const DefaultNoteTemplateIdSetting = createSimpleSetting<string | null>("defaultNoteTemplateId", { | ||
public: false, | ||
type: SettingItemType.String, | ||
value: null, | ||
label: "Default note template ID" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import joplin from "api"; | ||
import { SettingItemType } from "api/types"; | ||
import { PluginSetting } from "./base"; | ||
|
||
export interface DefaultTemplatesConfig { | ||
[notebookId: string]: { | ||
defaultNoteTemplateId: string | null; | ||
defaultTodoTemplateId: string | null; | ||
} | ||
} | ||
|
||
export const DefaultTemplatesConfigSetting: PluginSetting<DefaultTemplatesConfig> = class { | ||
static id = "defaultTemplatesConfig"; | ||
|
||
static manifest = { | ||
public: false, | ||
type: SettingItemType.Object, | ||
value: null, | ||
label: "Default templates config" | ||
}; | ||
|
||
static async get(): Promise<DefaultTemplatesConfig> { | ||
const defaultTemplatesConfig: DefaultTemplatesConfig | null = await joplin.settings.value(DefaultTemplatesConfigSetting.id); | ||
return defaultTemplatesConfig ? defaultTemplatesConfig : {}; | ||
} | ||
|
||
static async set(newValue: DefaultTemplatesConfig): Promise<void> { | ||
await joplin.settings.setValue(DefaultTemplatesConfigSetting.id, newValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { SettingItemType } from "api/types"; | ||
import { createSimpleSetting } from "./base"; | ||
|
||
export const DefaultTodoTemplateIdSetting = createSimpleSetting<string | null>("defaultTodoTemplateId", { | ||
public: false, | ||
type: SettingItemType.String, | ||
value: null, | ||
label: "Default to-do template ID" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { SettingItemType } from "api/types"; | ||
import { createSimpleSetting } from "./base"; | ||
|
||
export const TemplatesSourceSetting = createSimpleSetting<string>("templatesSource", { | ||
public: true, | ||
type: SettingItemType.String, | ||
isEnum: true, | ||
value: "tag", | ||
options: { | ||
"tag": "Tag", | ||
"notebook": "Notebook" | ||
}, | ||
label: "Are templates set with tags or stored in a notebook?", | ||
description: "If set to 'Tag', any note/to-do with a 'template' tag is considered a template. If set to 'Notebook', any note/todo stored in a notebook titled 'Templates' is considered a template.", | ||
section: "templatesPlugin" | ||
}); |