Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Typing `@today` <kbd>Enter</kbd> will automatically be expanded to the current d
| Setting | Description | Default |
| --------------- | ------------------------------------------------------- | ------- |
| Enable/Disable | A global toggle to enable or disable the autosuggest | Enabled |
| Prefix phrase | Characters(s) added to the beginning of a date suggestion | `time:` or `#` |
| Trigger phrase | Character(s) required to open the autosuggest | `@` |
| Insert as link? | Dates will be inserted as wikilinks (i.e. `[[<date>]]`) | Yes |

Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "nldates-obsidian",
"name": "Natural Language Dates",
"name": "Natural Language Dates [PZ]",
"description": "Create date-links based on natural language",
"version": "0.6.2",
"version": "0.6.3.beta",
"author": "Argentina Ortega Sainz",
"authorUrl": "https://argentinaos.com/",
"isDesktopOnly": false,
Expand Down
17 changes: 17 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type DayOfWeek =
export interface NLDSettings {
autosuggestToggleLink: boolean;
autocompleteTriggerPhrase: string;
autocompletePrefixPhrase: string;
isAutosuggestEnabled: boolean;

format: string;
Expand All @@ -30,6 +31,7 @@ export interface NLDSettings {
export const DEFAULT_SETTINGS: NLDSettings = {
autosuggestToggleLink: true,
autocompleteTriggerPhrase: "@",
autocompletePrefixPhrase: "",
isAutosuggestEnabled: true,

format: "YYYY-MM-DD",
Expand Down Expand Up @@ -165,6 +167,21 @@ export class NLDSettingsTab extends PluginSettingTab {
})
);

new Setting(containerEl)
.setName("Prefix")
.setDesc(
"Characters(s) that will be added before the date, which can be used for formatting"
)
.addMomentFormat((text) =>
text
.setPlaceholder(DEFAULT_SETTINGS.autocompletePrefixPhrase)
.setValue(this.plugin.settings.autocompletePrefixPhrase || "")
.onChange(async (value) => {
this.plugin.settings.autocompletePrefixPhrase = value.trim();
await this.plugin.saveSettings();
})
);

new Setting(containerEl)
.setName("Trigger phrase")
.setDesc("Character(s) that will cause the date autosuggest to open")
Expand Down
5 changes: 5 additions & 0 deletions src/suggest/date-suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class DateSuggest extends EditorSuggest<IDateCompletion> {
const includeAlias = event.shiftKey;
let dateStr = "";
let makeIntoLink = this.plugin.settings.autosuggestToggleLink;
let datePrefix = this.plugin.settings.autocompletePrefixPhrase;

if (suggestion.label.startsWith("time:")) {
const timePart = suggestion.label.substring(5);
Expand All @@ -109,6 +110,10 @@ export default class DateSuggest extends EditorSuggest<IDateCompletion> {
dateStr = this.plugin.parseDate(suggestion.label).formattedString;
}

if (datePrefix) {
dateStr = datePrefix + " " + dateStr;
}

if (makeIntoLink) {
dateStr = generateMarkdownLink(
this.app,
Expand Down