Skip to content

Commit

Permalink
feat(Threading): ✨ Custom date format in threading template
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jan 2, 2022
1 parent 0d72077 commit df0b7eb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
21 changes: 17 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21069,6 +21069,7 @@ const DEFAULT_SETTINGS = {
alphaSortAsc: true,
altLinkFields: [],
CSVPaths: "",
dateFormat: "YYYY-MM-DD",
debugMode: "WARN",
defaultView: true,
dendronNoteDelimiter: ".",
Expand Down Expand Up @@ -25709,16 +25710,27 @@ class BCSettingTab extends require$$0.PluginSettingTab {
<li><code>{{field}}</code>: the field being thread into</li>
<li><code>{{dir}}</code>: the direction being thread into</li>
<li><code>{{current}}</code>: the current note name</li>
<li><code>{{date}}</code>: the current date</li>
</ul>
`))
<li><code>{{date}}</code>: the current date (Set the format in the setting below)</li>
</ul>`))
.addText((text) => {
text.setValue(settings.threadingTemplate);
text.inputEl.onblur = async () => {
settings.threadingTemplate = text.getValue();
await plugin.saveSettings();
};
});
new require$$0.Setting(threadingDetails)
.setName("Date Format")
.setDesc("The date format used in the Threading Template (setting above)")
.addMomentFormat((format) => {
format
.setDefaultFormat(DEFAULT_SETTINGS.dateFormat)
.setValue(settings.dateFormat)
.onChange(async (value) => {
settings.dateFormat = value;
await plugin.saveSettings();
});
});
const debugDetails = details("Debugging");
new require$$0.Setting(debugDetails)
.setName("Debug Mode")
Expand Down Expand Up @@ -51958,7 +51970,8 @@ class BCPlugin extends require$$0.Plugin {
.replace("{{current}}", currFile.basename)
.replace("{{field}}", field)
.replace("{{dir}}", dir)
.replace("{{date}}", new Date().toLocaleDateString().replaceAll(/[/\\]/g, ""));
//@ts-ignore
.replace("{{date}}", require$$0.moment().format(settings.dateFormat));
let i = 1;
while (app.metadataCache.getFirstLinkpathDest(newBasename, "")) {
if (i === 1)
Expand Down
19 changes: 16 additions & 3 deletions src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import log from "loglevel";
import {
App,
DropdownComponent,
MomentFormatComponent,
Notice,
PluginSettingTab,
Setting,
Expand Down Expand Up @@ -956,9 +957,8 @@ export class BCSettingTab extends PluginSettingTab {
<li><code>{{field}}</code>: the field being thread into</li>
<li><code>{{dir}}</code>: the direction being thread into</li>
<li><code>{{current}}</code>: the current note name</li>
<li><code>{{date}}</code>: the current date</li>
</ul>
`
<li><code>{{date}}</code>: the current date (Set the format in the setting below)</li>
</ul>`
)
)
.addText((text) => {
Expand All @@ -969,6 +969,19 @@ export class BCSettingTab extends PluginSettingTab {
};
});

new Setting(threadingDetails)
.setName("Date Format")
.setDesc("The date format used in the Threading Template (setting above)")
.addMomentFormat((format) => {
format
.setDefaultFormat(DEFAULT_SETTINGS.dateFormat)
.setValue(settings.dateFormat)
.onChange(async (value) => {
settings.dateFormat = value;
await plugin.saveSettings();
});
});

const debugDetails = details("Debugging");

new Setting(debugDetails)
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const DEFAULT_SETTINGS: BCSettings = {
alphaSortAsc: true,
altLinkFields: [],
CSVPaths: "",
dateFormat: "YYYY-MM-DD",
debugMode: "WARN",
defaultView: true,
dendronNoteDelimiter: ".",
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface BCSettings {
defaultView: boolean;
dendronNoteDelimiter: string;
dendronNoteField: string;
dateFormat: string;
downViewWrap: boolean;
dotsColour: string;
enableAlphaSort: boolean;
Expand Down
8 changes: 3 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
addIcon,
EventRef,
MarkdownView,
moment_2,
moment,
normalizePath,
Notice,
Plugin,
Expand Down Expand Up @@ -444,10 +444,8 @@ export default class BCPlugin extends Plugin {
.replace("{{current}}", currFile.basename)
.replace("{{field}}", field)
.replace("{{dir}}", dir)
.replace(
"{{date}}",
new Date().toLocaleDateString().replaceAll(/[/\\]/g, "")
);
//@ts-ignore
.replace("{{date}}", moment().format(settings.dateFormat));

let i = 1;
while (app.metadataCache.getFirstLinkpathDest(newBasename, "")) {
Expand Down

0 comments on commit df0b7eb

Please sign in to comment.