Skip to content

Commit

Permalink
Default settings for time format
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikmayer committed May 12, 2024
1 parent c886c09 commit 0ecb71e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "yesterday",
"name": "Yesterday",
"version": "1.0.10",
"version": "1.0.11",
"minAppVersion": "0.12.0",
"description": "Transform your notes into a visually stunning diary, integrating dialogs, chat logs, and media content blocks for a seamless journaling experience.",
"author": "Dominik Mayer",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-yesterday",
"version": "1.0.10",
"version": "1.0.11",
"description": "Plugin that provides Yesterday journaling support to Obsidian",
"main": "main.js",
"scripts": {
Expand Down
52 changes: 35 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export default class Yesterday extends Plugin {
const fileName = path + "/" + now.format('YYYY-MM-DD - HH-mm-ss') + ".md";
new Notice("Creating " + fileName);

const frontmatter = await createFrontmatter(now.format(this.settings.datePropFormat), this);
const frontmatter = await createFrontmatter(now.format(this.settings.datePropFormat || DEFAULT_SETTINGS.datePropFormat), this);
new Notice(frontmatter);

try {
Expand Down Expand Up @@ -458,27 +458,45 @@ class YesterdaySettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
}));

containerEl.createEl('br');
const timeFormatSection = containerEl.createEl('div', { cls: 'setting-item setting-item-heading' });
const timeFormatSectionInfo = timeFormatSection.createEl('div', { cls: 'setting-item-info' });
timeFormatSectionInfo.createEl('div', { text: 'Time format', cls: 'setting-item-name' });
const subHeading = containerEl.createDiv()
subHeading.createEl('a', { text: 'Format documentation', href: 'https://day.js.org/docs/en/display/format' });
containerEl.createEl('br');
const timeFormatSection = containerEl.createEl('div', { cls: 'setting-item setting-item-heading' });
const timeFormatSectionInfo = timeFormatSection.createEl('div', { cls: 'setting-item-info' });
timeFormatSectionInfo.createEl('div', { text: 'Time format', cls: 'setting-item-name' });

const timeFormatDescription = timeFormatSectionInfo.createEl('div', { cls: 'setting-item-description' });

const timeFormatText = createEl('span', {
text: 'If you change the time format your journal will not work with the '
});
timeFormatDescription.appendChild(timeFormatText);

const appLink = createEl('a', {
text: 'Yesterday app',
href: 'https://www.yesterday.md'
});
timeFormatText.appendChild(appLink);
timeFormatText.appendChild(document.createTextNode('.'));

const additionalText = createEl('span', {
text: ' See the '
});
timeFormatDescription.appendChild(additionalText);

const docLink = createEl('a', {
text: 'format documentation',
href: 'https://day.js.org/docs/en/display/format'
});
additionalText.appendChild(docLink);
additionalText.appendChild(document.createTextNode(' for details.'));

new Setting(containerEl)
.setName('Format of \'date\' property')
.setDesc('Format of value which will be written to \'date\' property of newly created entry')
.addMomentFormat(toggle => toggle
.setValue(this.plugin.settings.datePropFormat)
.setName('Frontmatter \'date\'')
.setDesc('The format of the \'date\' property in the frontmatter of newly created entries')
.addMomentFormat(text => text.setPlaceholder(DEFAULT_SETTINGS.datePropFormat)
.setValue((this.plugin.settings.datePropFormat || '') + '')
.setDefaultFormat(DEFAULT_SETTINGS.datePropFormat)
.onChange(async (v) => {
let value = v.trim()
if (value != '') {
this.plugin.settings.datePropFormat = value;
} else {
this.plugin.settings.datePropFormat = DEFAULT_SETTINGS.datePropFormat;
}
this.plugin.settings.datePropFormat = value;
await this.plugin.saveSettings();
}));
}
Expand Down

0 comments on commit 0ecb71e

Please sign in to comment.