2025-05-11 16:00:39 +02:00

3832 lines
174 KiB
JavaScript

/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// node_modules/obsidian-daily-notes-interface/dist/main.js
var require_main = __commonJS({
"node_modules/obsidian-daily-notes-interface/dist/main.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var obsidian = require("obsidian");
var DEFAULT_DAILY_NOTE_FORMAT = "YYYY-MM-DD";
var DEFAULT_WEEKLY_NOTE_FORMAT = "gggg-[W]ww";
var DEFAULT_MONTHLY_NOTE_FORMAT = "YYYY-MM";
var DEFAULT_QUARTERLY_NOTE_FORMAT = "YYYY-[Q]Q";
var DEFAULT_YEARLY_NOTE_FORMAT = "YYYY";
function shouldUsePeriodicNotesSettings(periodicity) {
var _a, _b;
const periodicNotes = window.app.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a[periodicity]) == null ? void 0 : _b.enabled);
}
function getDailyNoteSettings3() {
var _a, _b, _c, _d;
try {
const { internalPlugins, plugins } = window.app;
if (shouldUsePeriodicNotesSettings("daily")) {
const { format: format2, folder: folder2, template: template2 } = ((_b = (_a = plugins.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.daily) || {};
return {
format: format2 || DEFAULT_DAILY_NOTE_FORMAT,
folder: (folder2 == null ? void 0 : folder2.trim()) || "",
template: (template2 == null ? void 0 : template2.trim()) || ""
};
}
const { folder, format, template } = ((_d = (_c = internalPlugins.getPluginById("daily-notes")) == null ? void 0 : _c.instance) == null ? void 0 : _d.options) || {};
return {
format: format || DEFAULT_DAILY_NOTE_FORMAT,
folder: (folder == null ? void 0 : folder.trim()) || "",
template: (template == null ? void 0 : template.trim()) || ""
};
} catch (err) {
console.info("No custom daily note settings found!", err);
}
}
function getWeeklyNoteSettings() {
var _a, _b, _c, _d, _e, _f, _g;
try {
const pluginManager = window.app.plugins;
const calendarSettings = (_a = pluginManager.getPlugin("calendar")) == null ? void 0 : _a.options;
const periodicNotesSettings = (_c = (_b = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _b.settings) == null ? void 0 : _c.weekly;
if (shouldUsePeriodicNotesSettings("weekly")) {
return {
format: periodicNotesSettings.format || DEFAULT_WEEKLY_NOTE_FORMAT,
folder: ((_d = periodicNotesSettings.folder) == null ? void 0 : _d.trim()) || "",
template: ((_e = periodicNotesSettings.template) == null ? void 0 : _e.trim()) || ""
};
}
const settings = calendarSettings || {};
return {
format: settings.weeklyNoteFormat || DEFAULT_WEEKLY_NOTE_FORMAT,
folder: ((_f = settings.weeklyNoteFolder) == null ? void 0 : _f.trim()) || "",
template: ((_g = settings.weeklyNoteTemplate) == null ? void 0 : _g.trim()) || ""
};
} catch (err) {
console.info("No custom weekly note settings found!", err);
}
}
function getMonthlyNoteSettings() {
var _a, _b, _c, _d;
const pluginManager = window.app.plugins;
try {
const settings = shouldUsePeriodicNotesSettings("monthly") && ((_b = (_a = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.monthly) || {};
return {
format: settings.format || DEFAULT_MONTHLY_NOTE_FORMAT,
folder: ((_c = settings.folder) == null ? void 0 : _c.trim()) || "",
template: ((_d = settings.template) == null ? void 0 : _d.trim()) || ""
};
} catch (err) {
console.info("No custom monthly note settings found!", err);
}
}
function getQuarterlyNoteSettings() {
var _a, _b, _c, _d;
const pluginManager = window.app.plugins;
try {
const settings = shouldUsePeriodicNotesSettings("quarterly") && ((_b = (_a = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.quarterly) || {};
return {
format: settings.format || DEFAULT_QUARTERLY_NOTE_FORMAT,
folder: ((_c = settings.folder) == null ? void 0 : _c.trim()) || "",
template: ((_d = settings.template) == null ? void 0 : _d.trim()) || ""
};
} catch (err) {
console.info("No custom quarterly note settings found!", err);
}
}
function getYearlyNoteSettings() {
var _a, _b, _c, _d;
const pluginManager = window.app.plugins;
try {
const settings = shouldUsePeriodicNotesSettings("yearly") && ((_b = (_a = pluginManager.getPlugin("periodic-notes")) == null ? void 0 : _a.settings) == null ? void 0 : _b.yearly) || {};
return {
format: settings.format || DEFAULT_YEARLY_NOTE_FORMAT,
folder: ((_c = settings.folder) == null ? void 0 : _c.trim()) || "",
template: ((_d = settings.template) == null ? void 0 : _d.trim()) || ""
};
} catch (err) {
console.info("No custom yearly note settings found!", err);
}
}
function join2(...partSegments) {
let parts = [];
for (let i = 0, l = partSegments.length; i < l; i++) {
parts = parts.concat(partSegments[i].split("/"));
}
const newParts = [];
for (let i = 0, l = parts.length; i < l; i++) {
const part = parts[i];
if (!part || part === ".")
continue;
else
newParts.push(part);
}
if (parts[0] === "")
newParts.unshift("");
return newParts.join("/");
}
function basename(fullPath) {
let base = fullPath.substring(fullPath.lastIndexOf("/") + 1);
if (base.lastIndexOf(".") != -1)
base = base.substring(0, base.lastIndexOf("."));
return base;
}
function ensureFolderExists2(path) {
return __async(this, null, function* () {
const dirs = path.replace(/\\/g, "/").split("/");
dirs.pop();
if (dirs.length) {
const dir = join2(...dirs);
if (!window.app.vault.getAbstractFileByPath(dir)) {
yield window.app.vault.createFolder(dir);
}
}
});
}
function getNotePath(directory, filename) {
return __async(this, null, function* () {
if (!filename.endsWith(".md")) {
filename += ".md";
}
const path = obsidian.normalizePath(join2(directory, filename));
yield ensureFolderExists2(path);
return path;
});
}
function getTemplateInfo(template) {
return __async(this, null, function* () {
const { metadataCache, vault } = window.app;
const templatePath = obsidian.normalizePath(template);
if (templatePath === "/") {
return Promise.resolve(["", null]);
}
try {
const templateFile = metadataCache.getFirstLinkpathDest(templatePath, "");
const contents = yield vault.cachedRead(templateFile);
const IFoldInfo = window.app.foldManager.load(templateFile);
return [contents, IFoldInfo];
} catch (err) {
console.error(`Failed to read the daily note template '${templatePath}'`, err);
new obsidian.Notice("Failed to read the daily note template");
return ["", null];
}
});
}
function getDateUID4(date, granularity = "day") {
const ts = date.clone().startOf(granularity).format();
return `${granularity}-${ts}`;
}
function removeEscapedCharacters(format) {
return format.replace(/\[[^\]]*\]/g, "");
}
function isFormatAmbiguous(format, granularity) {
if (granularity === "week") {
const cleanFormat = removeEscapedCharacters(format);
return /w{1,2}/i.test(cleanFormat) && (/M{1,4}/.test(cleanFormat) || /D{1,4}/.test(cleanFormat));
}
return false;
}
function getDateFromFile4(file, granularity) {
return getDateFromFilename(file.basename, granularity);
}
function getDateFromPath2(path, granularity) {
return getDateFromFilename(basename(path), granularity);
}
function getDateFromFilename(filename, granularity) {
const getSettings = {
day: getDailyNoteSettings3,
week: getWeeklyNoteSettings,
month: getMonthlyNoteSettings,
quarter: getQuarterlyNoteSettings,
year: getYearlyNoteSettings
};
const format = getSettings[granularity]().format.split("/").pop();
const noteDate = window.moment(filename, format, true);
if (!noteDate.isValid()) {
return null;
}
if (isFormatAmbiguous(format, granularity)) {
if (granularity === "week") {
const cleanFormat = removeEscapedCharacters(format);
if (/w{1,2}/i.test(cleanFormat)) {
return window.moment(filename, format.replace(/M{1,4}/g, "").replace(/D{1,4}/g, ""), false);
}
}
}
return noteDate;
}
var DailyNotesFolderMissingError = class extends Error {
};
function createDailyNote3(date) {
return __async(this, null, function* () {
const app2 = window.app;
const { vault } = app2;
const moment = window.moment;
const { template, format, folder } = getDailyNoteSettings3();
const [templateContents, IFoldInfo] = yield getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = yield getNotePath(folder, filename);
try {
const createdFile = yield vault.create(normalizedPath, templateContents.replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename).replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = moment();
const currentDate = date.clone().set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*yesterday\s*}}/gi, date.clone().subtract(1, "day").format(format)).replace(/{{\s*tomorrow\s*}}/gi, date.clone().add(1, "d").format(format)));
app2.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
});
}
function getDailyNote2(date, dailyNotes) {
var _a;
return (_a = dailyNotes[getDateUID4(date, "day")]) != null ? _a : null;
}
function getAllDailyNotes2() {
const { vault } = window.app;
const { folder } = getDailyNoteSettings3();
const dailyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!dailyNotesFolder) {
throw new DailyNotesFolderMissingError("Failed to find daily notes folder");
}
const dailyNotes = {};
obsidian.Vault.recurseChildren(dailyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile4(note, "day");
if (date) {
const dateString = getDateUID4(date, "day");
dailyNotes[dateString] = note;
}
}
});
return dailyNotes;
}
var WeeklyNotesFolderMissingError = class extends Error {
};
function getDaysOfWeek2() {
const { moment } = window;
let weekStart = moment.localeData()._week.dow;
const daysOfWeek = [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday"
];
while (weekStart) {
daysOfWeek.push(daysOfWeek.shift());
weekStart--;
}
return daysOfWeek;
}
function getDayOfWeekNumericalValue2(dayOfWeekName) {
return getDaysOfWeek2().indexOf(dayOfWeekName.toLowerCase());
}
function createWeeklyNote(date) {
return __async(this, null, function* () {
const { vault } = window.app;
const { template, format, folder } = getWeeklyNoteSettings();
const [templateContents, IFoldInfo] = yield getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = yield getNotePath(folder, filename);
try {
const createdFile = yield vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const currentDate = date.clone().set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*title\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi, (_, dayOfWeek, momentFormat) => {
const day = getDayOfWeekNumericalValue2(dayOfWeek);
return date.weekday(day).format(momentFormat.trim());
}));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
});
}
function getWeeklyNote(date, weeklyNotes) {
var _a;
return (_a = weeklyNotes[getDateUID4(date, "week")]) != null ? _a : null;
}
function getAllWeeklyNotes2() {
const weeklyNotes = {};
if (!appHasWeeklyNotesPluginLoaded()) {
return weeklyNotes;
}
const { vault } = window.app;
const { folder } = getWeeklyNoteSettings();
const weeklyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!weeklyNotesFolder) {
throw new WeeklyNotesFolderMissingError("Failed to find weekly notes folder");
}
obsidian.Vault.recurseChildren(weeklyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile4(note, "week");
if (date) {
const dateString = getDateUID4(date, "week");
weeklyNotes[dateString] = note;
}
}
});
return weeklyNotes;
}
var MonthlyNotesFolderMissingError = class extends Error {
};
function createMonthlyNote(date) {
return __async(this, null, function* () {
const { vault } = window.app;
const { template, format, folder } = getMonthlyNoteSettings();
const [templateContents, IFoldInfo] = yield getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = yield getNotePath(folder, filename);
try {
const createdFile = yield vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const currentDate = date.clone().set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
});
}
function getMonthlyNote(date, monthlyNotes) {
var _a;
return (_a = monthlyNotes[getDateUID4(date, "month")]) != null ? _a : null;
}
function getAllMonthlyNotes2() {
const monthlyNotes = {};
if (!appHasMonthlyNotesPluginLoaded()) {
return monthlyNotes;
}
const { vault } = window.app;
const { folder } = getMonthlyNoteSettings();
const monthlyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!monthlyNotesFolder) {
throw new MonthlyNotesFolderMissingError("Failed to find monthly notes folder");
}
obsidian.Vault.recurseChildren(monthlyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile4(note, "month");
if (date) {
const dateString = getDateUID4(date, "month");
monthlyNotes[dateString] = note;
}
}
});
return monthlyNotes;
}
var QuarterlyNotesFolderMissingError = class extends Error {
};
function createQuarterlyNote2(date) {
return __async(this, null, function* () {
const { vault } = window.app;
const { template, format, folder } = getQuarterlyNoteSettings();
const [templateContents, IFoldInfo] = yield getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = yield getNotePath(folder, filename);
try {
const createdFile = yield vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const currentDate = date.clone().set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
});
}
function getQuarterlyNote(date, quarterly) {
var _a;
return (_a = quarterly[getDateUID4(date, "quarter")]) != null ? _a : null;
}
function getAllQuarterlyNotes2() {
const quarterly = {};
if (!appHasQuarterlyNotesPluginLoaded()) {
return quarterly;
}
const { vault } = window.app;
const { folder } = getQuarterlyNoteSettings();
const quarterlyFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!quarterlyFolder) {
throw new QuarterlyNotesFolderMissingError("Failed to find quarterly notes folder");
}
obsidian.Vault.recurseChildren(quarterlyFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile4(note, "quarter");
if (date) {
const dateString = getDateUID4(date, "quarter");
quarterly[dateString] = note;
}
}
});
return quarterly;
}
var YearlyNotesFolderMissingError = class extends Error {
};
function createYearlyNote2(date) {
return __async(this, null, function* () {
const { vault } = window.app;
const { template, format, folder } = getYearlyNoteSettings();
const [templateContents, IFoldInfo] = yield getTemplateInfo(template);
const filename = date.format(format);
const normalizedPath = yield getNotePath(folder, filename);
try {
const createdFile = yield vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const currentDate = date.clone().set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
}).replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
});
}
function getYearlyNote(date, yearlyNotes) {
var _a;
return (_a = yearlyNotes[getDateUID4(date, "year")]) != null ? _a : null;
}
function getAllYearlyNotes2() {
const yearlyNotes = {};
if (!appHasYearlyNotesPluginLoaded()) {
return yearlyNotes;
}
const { vault } = window.app;
const { folder } = getYearlyNoteSettings();
const yearlyNotesFolder = vault.getAbstractFileByPath(obsidian.normalizePath(folder));
if (!yearlyNotesFolder) {
throw new YearlyNotesFolderMissingError("Failed to find yearly notes folder");
}
obsidian.Vault.recurseChildren(yearlyNotesFolder, (note) => {
if (note instanceof obsidian.TFile) {
const date = getDateFromFile4(note, "year");
if (date) {
const dateString = getDateUID4(date, "year");
yearlyNotes[dateString] = note;
}
}
});
return yearlyNotes;
}
function appHasDailyNotesPluginLoaded() {
var _a, _b;
const { app: app2 } = window;
const dailyNotesPlugin = app2.internalPlugins.plugins["daily-notes"];
if (dailyNotesPlugin && dailyNotesPlugin.enabled) {
return true;
}
const periodicNotes = app2.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.daily) == null ? void 0 : _b.enabled);
}
function appHasWeeklyNotesPluginLoaded() {
var _a, _b;
const { app: app2 } = window;
if (app2.plugins.getPlugin("calendar")) {
return true;
}
const periodicNotes = app2.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.weekly) == null ? void 0 : _b.enabled);
}
function appHasMonthlyNotesPluginLoaded() {
var _a, _b;
const { app: app2 } = window;
const periodicNotes = app2.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.monthly) == null ? void 0 : _b.enabled);
}
function appHasQuarterlyNotesPluginLoaded() {
var _a, _b;
const { app: app2 } = window;
const periodicNotes = app2.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.quarterly) == null ? void 0 : _b.enabled);
}
function appHasYearlyNotesPluginLoaded() {
var _a, _b;
const { app: app2 } = window;
const periodicNotes = app2.plugins.getPlugin("periodic-notes");
return periodicNotes && ((_b = (_a = periodicNotes.settings) == null ? void 0 : _a.yearly) == null ? void 0 : _b.enabled);
}
function getPeriodicNoteSettings(granularity) {
const getSettings = {
day: getDailyNoteSettings3,
week: getWeeklyNoteSettings,
month: getMonthlyNoteSettings,
quarter: getQuarterlyNoteSettings,
year: getYearlyNoteSettings
}[granularity];
return getSettings();
}
function createPeriodicNote3(granularity, date) {
const createFn = {
day: createDailyNote3,
month: createMonthlyNote,
week: createWeeklyNote
};
return createFn[granularity](date);
}
exports.DEFAULT_DAILY_NOTE_FORMAT = DEFAULT_DAILY_NOTE_FORMAT;
exports.DEFAULT_MONTHLY_NOTE_FORMAT = DEFAULT_MONTHLY_NOTE_FORMAT;
exports.DEFAULT_QUARTERLY_NOTE_FORMAT = DEFAULT_QUARTERLY_NOTE_FORMAT;
exports.DEFAULT_WEEKLY_NOTE_FORMAT = DEFAULT_WEEKLY_NOTE_FORMAT;
exports.DEFAULT_YEARLY_NOTE_FORMAT = DEFAULT_YEARLY_NOTE_FORMAT;
exports.appHasDailyNotesPluginLoaded = appHasDailyNotesPluginLoaded;
exports.appHasMonthlyNotesPluginLoaded = appHasMonthlyNotesPluginLoaded;
exports.appHasQuarterlyNotesPluginLoaded = appHasQuarterlyNotesPluginLoaded;
exports.appHasWeeklyNotesPluginLoaded = appHasWeeklyNotesPluginLoaded;
exports.appHasYearlyNotesPluginLoaded = appHasYearlyNotesPluginLoaded;
exports.createDailyNote = createDailyNote3;
exports.createMonthlyNote = createMonthlyNote;
exports.createPeriodicNote = createPeriodicNote3;
exports.createQuarterlyNote = createQuarterlyNote2;
exports.createWeeklyNote = createWeeklyNote;
exports.createYearlyNote = createYearlyNote2;
exports.getAllDailyNotes = getAllDailyNotes2;
exports.getAllMonthlyNotes = getAllMonthlyNotes2;
exports.getAllQuarterlyNotes = getAllQuarterlyNotes2;
exports.getAllWeeklyNotes = getAllWeeklyNotes2;
exports.getAllYearlyNotes = getAllYearlyNotes2;
exports.getDailyNote = getDailyNote2;
exports.getDailyNoteSettings = getDailyNoteSettings3;
exports.getDateFromFile = getDateFromFile4;
exports.getDateFromPath = getDateFromPath2;
exports.getDateUID = getDateUID4;
exports.getMonthlyNote = getMonthlyNote;
exports.getMonthlyNoteSettings = getMonthlyNoteSettings;
exports.getPeriodicNoteSettings = getPeriodicNoteSettings;
exports.getQuarterlyNote = getQuarterlyNote;
exports.getQuarterlyNoteSettings = getQuarterlyNoteSettings;
exports.getTemplateInfo = getTemplateInfo;
exports.getWeeklyNote = getWeeklyNote;
exports.getWeeklyNoteSettings = getWeeklyNoteSettings;
exports.getYearlyNote = getYearlyNote;
exports.getYearlyNoteSettings = getYearlyNoteSettings;
}
});
// src/main.ts
__export(exports, {
DAYS_PER_UNIT: () => DAYS_PER_UNIT,
DEFAULT_SETTINGS: () => DEFAULT_SETTINGS,
FILEINFO_TO_DISPLAY: () => FILEINFO_TO_DISPLAY,
FILEINFO_TO_DISPLAY_DAY: () => FILEINFO_TO_DISPLAY_DAY,
GRANULARITY_LIST: () => GRANULARITY_LIST,
GRANULARITY_TO_PERIODICITY: () => GRANULARITY_TO_PERIODICITY,
default: () => DailyNoteOutlinePlugin3
});
var import_obsidian11 = __toModule(require("obsidian"));
// src/view.ts
var import_obsidian8 = __toModule(require("obsidian"));
var import_obsidian9 = __toModule(require("obsidian"));
var import_obsidian_daily_notes_interface6 = __toModule(require_main());
// src/drawUI.ts
var import_obsidian5 = __toModule(require("obsidian"));
// src/createAndOpenDailyNote.ts
var import_obsidian_daily_notes_interface = __toModule(require_main());
function createAndOpenDailyNote(granularity, date, allFiles) {
return __async(this, null, function* () {
const { workspace } = window.app;
const createFile = () => __async(this, null, function* () {
let newNote;
switch (granularity) {
case "quarter":
newNote = yield (0, import_obsidian_daily_notes_interface.createQuarterlyNote)(date);
break;
case "year":
newNote = yield (0, import_obsidian_daily_notes_interface.createYearlyNote)(date);
break;
default:
newNote = yield (0, import_obsidian_daily_notes_interface.createPeriodicNote)(granularity, date);
}
yield workspace.getLeaf().openFile(newNote);
});
const dailynote = allFiles[(0, import_obsidian_daily_notes_interface.getDateUID)(date, granularity)];
if (!dailynote) {
yield createFile();
} else {
yield workspace.getLeaf().openFile(dailynote);
}
});
}
// src/modalExtract.ts
var import_obsidian = __toModule(require("obsidian"));
var ModalExtract = class extends import_obsidian.Modal {
constructor(app2, plugin, onSubmit) {
super(app2);
this.plugin = plugin;
this.onSubmit = onSubmit;
}
onOpen() {
this.inputedValue = this.plugin.settings.wordsToExtract;
const { contentEl } = this;
contentEl.createEl("br");
new import_obsidian.Setting(contentEl).setName("Extract by word or phrase:").addText((text) => {
text.setValue(this.plugin.settings.wordsToExtract).inputEl.select();
text.onChange((value) => {
this.inputedValue = value;
});
});
new import_obsidian.Setting(contentEl).addButton((btn) => btn.setButtonText("Extract").setCta().onClick(() => __async(this, null, function* () {
this.executeExtract();
}))).addButton((btn) => btn.setButtonText("Cancel").onClick(() => {
this.close();
}));
this.scope.register([], "Enter", (evt) => {
this.executeExtract();
});
}
onClose() {
let { contentEl } = this;
contentEl.empty();
}
executeExtract() {
return __async(this, null, function* () {
this.close();
this.plugin.settings.wordsToExtract = this.inputedValue;
yield this.plugin.saveSettings();
this.onSubmit(true);
});
}
};
// src/createAndOpenPeriodicNote.ts
var import_obsidian2 = __toModule(require("obsidian"));
var import_obsidian_daily_notes_interface2 = __toModule(require_main());
var DEFAULT_NOTE_FORMAT = {
day: "YYYY-MM-DD",
week: "gggg-[W]ww",
month: "YYYY-MM",
quarter: "YYYY-[Q]Q",
year: "YYYY"
};
function createAndOpenPeriodicNote(granularity, date, calendarSet) {
return __async(this, null, function* () {
const { workspace } = window.app;
let file = window.app.plugins.getPlugin("periodic-notes").cache.getPeriodicNote(calendarSet.id, granularity, date);
if (!file) {
const config = calendarSet[granularity];
const format = calendarSet[granularity].format;
const filename = date.format(format ? format : DEFAULT_NOTE_FORMAT[granularity]);
const templateContents = yield getTemplateContents(window.app, config.templatePath);
const renderedContents = applyTemplateTransformations(filename, granularity, date, format, templateContents);
const destPath = yield getNoteCreationPath(window.app, filename, config);
file = yield window.app.vault.create(destPath, renderedContents);
}
yield workspace.getLeaf().openFile(file);
});
}
function getTemplateContents(app2, templatePath) {
return __async(this, null, function* () {
const { metadataCache, vault } = app2;
const normalizedTemplatePath = (0, import_obsidian2.normalizePath)(templatePath != null ? templatePath : "");
if (templatePath === "/") {
return Promise.resolve("");
}
try {
const templateFile = metadataCache.getFirstLinkpathDest(normalizedTemplatePath, "");
return templateFile ? vault.cachedRead(templateFile) : "";
} catch (err) {
console.error(`Failed to read the daily note template '${normalizedTemplatePath}'`, err);
new import_obsidian2.Notice("Failed to read the daily note template");
return "";
}
});
}
function applyTemplateTransformations(filename, granularity, date, format, rawTemplateContents) {
let templateContents = rawTemplateContents;
templateContents = rawTemplateContents.replace(/{{\s*date\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi, filename);
if (granularity === "day") {
templateContents = templateContents.replace(/{{\s*yesterday\s*}}/gi, date.clone().subtract(1, "day").format(format)).replace(/{{\s*tomorrow\s*}}/gi, date.clone().add(1, "d").format(format)).replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const currentDate = date.clone().set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format);
});
}
if (granularity === "week") {
templateContents = templateContents.replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi, (_, dayOfWeek, momentFormat) => {
const day = getDayOfWeekNumericalValue(dayOfWeek);
return date.weekday(day).format(momentFormat.trim());
});
}
if (granularity === "month") {
templateContents = templateContents.replace(/{{\s*(month)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const monthStart = date.clone().startOf("month").set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
monthStart.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return monthStart.format(momentFormat.substring(1).trim());
}
return monthStart.format(format);
});
}
if (granularity === "quarter") {
templateContents = templateContents.replace(/{{\s*(quarter)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const monthStart = date.clone().startOf("quarter").set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
monthStart.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return monthStart.format(momentFormat.substring(1).trim());
}
return monthStart.format(format);
});
}
if (granularity === "year") {
templateContents = templateContents.replace(/{{\s*(year)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now = window.moment();
const monthStart = date.clone().startOf("year").set({
hour: now.get("hour"),
minute: now.get("minute"),
second: now.get("second")
});
if (calc) {
monthStart.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return monthStart.format(momentFormat.substring(1).trim());
}
return monthStart.format(format);
});
}
return templateContents;
}
function getNoteCreationPath(app2, filename, periodicConfig) {
return __async(this, null, function* () {
var _a;
const directory = (_a = periodicConfig.folder) != null ? _a : "";
const filenameWithExt = !filename.endsWith(".md") ? `${filename}.md` : filename;
const path = (0, import_obsidian2.normalizePath)(join(directory, filenameWithExt));
yield ensureFolderExists(app2, path);
return path;
});
}
function join(...partSegments) {
let parts = [];
for (let i = 0, l = partSegments.length; i < l; i++) {
parts = parts.concat(partSegments[i].split("/"));
}
const newParts = [];
for (let i = 0, l = parts.length; i < l; i++) {
const part = parts[i];
if (!part || part === ".")
continue;
else
newParts.push(part);
}
if (parts[0] === "")
newParts.unshift("");
return newParts.join("/");
}
function ensureFolderExists(app2, path) {
return __async(this, null, function* () {
const dirs = path.replace(/\\/g, "/").split("/");
dirs.pop();
if (dirs.length) {
const dir = join(...dirs);
if (!app2.vault.getAbstractFileByPath(dir)) {
yield app2.vault.createFolder(dir);
}
}
});
}
function getDaysOfWeek() {
const { moment } = window;
let weekStart = moment.localeData()._week.dow;
const daysOfWeek = [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday"
];
while (weekStart) {
const day = daysOfWeek.shift();
if (day)
daysOfWeek.push(day);
weekStart--;
}
return daysOfWeek;
}
function getDayOfWeekNumericalValue(dayOfWeekName) {
return getDaysOfWeek().indexOf(dayOfWeekName.toLowerCase());
}
function createDailyNoteForUnresolvedLink(app2, date) {
return __async(this, null, function* () {
if (date.isSameOrAfter(window.moment(), "day")) {
yield (0, import_obsidian_daily_notes_interface2.createPeriodicNote)("day", date);
} else {
const { format, folder } = (0, import_obsidian_daily_notes_interface2.getDailyNoteSettings)();
const filename = date.format(format);
const filenameWithExt = !filename.endsWith(".md") ? `${filename}.md` : filename;
const path = (0, import_obsidian2.normalizePath)(join(folder != null ? folder : "", filenameWithExt));
yield ensureFolderExists(app2, path);
try {
yield this.app.vault.create(path, "");
} catch (e) {
console.error("Daily Note Outline: Could not create ", path, e.message);
}
}
});
}
function createDailyNoteForUnresolvedLinkPNbeta(app2, date, calendarSet) {
return __async(this, null, function* () {
const isTodayOrFuture = Boolean(date.isSameOrAfter(window.moment(), "day"));
const config = calendarSet.day;
const format = calendarSet.day.format;
const filename = date.format(format ? format : DEFAULT_NOTE_FORMAT.day);
let templateContents = "";
let renderedContents = "";
if (isTodayOrFuture) {
templateContents = yield getTemplateContents(app2, config.templatePath);
renderedContents = applyTemplateTransformations(filename, "day", date, format, templateContents);
}
const destPath = yield getNoteCreationPath(app2, filename, config);
try {
yield this.app.vault.create(destPath, renderedContents);
} catch (e) {
console.error("Daily Note Outline: Could not create", destPath, e.message);
}
});
}
// src/modalJump.ts
var import_obsidian3 = __toModule(require("obsidian"));
var ModalJump = class extends import_obsidian3.Modal {
constructor(app2, plugin, onSubmit) {
super(app2);
this.plugin = plugin;
this.onSubmit = onSubmit;
}
onOpen() {
this.inputedValue = this.plugin.settings.onset;
const { contentEl } = this;
contentEl.createEl("br");
new import_obsidian3.Setting(contentEl).setName("Enter date to jump(YYYY-MM-DD):").addText((text) => {
text.setValue(this.plugin.settings.onset).inputEl.select();
text.onChange((value) => {
this.inputedValue = value;
});
});
new import_obsidian3.Setting(contentEl).addButton((btn) => btn.setButtonText("Jump").setCta().onClick(() => __async(this, null, function* () {
this.executeJump();
}))).addButton((btn) => btn.setButtonText("Cancel").onClick(() => {
this.close();
}));
this.scope.register([], "Enter", (evt) => {
this.executeJump();
});
}
onClose() {
let { contentEl } = this;
contentEl.empty();
}
executeJump() {
return __async(this, null, function* () {
this.close();
this.onSubmit(this.inputedValue);
});
}
};
// src/util.ts
var import_obsidian4 = __toModule(require("obsidian"));
var import_obsidian_daily_notes_interface3 = __toModule(require_main());
function cleanFileFlag(file, settings) {
if (Object.keys(settings.fileFlag[file.path]).length == 0) {
delete settings.fileFlag[file.path];
}
}
function checkFlag(file, flag, settings) {
var _a;
return (_a = settings.fileFlag[file.path]) == null ? void 0 : _a[flag];
}
function addFlag(file, flag, settings) {
if (!settings.fileFlag.hasOwnProperty(file.path)) {
settings.fileFlag[file.path] = {};
}
settings.fileFlag[file.path][flag] = true;
}
function removeFlag(file, flag, settings) {
delete settings.fileFlag[file.path][flag];
cleanFileFlag(file, settings);
}
function getSubpathPosition(app2, file, subpath) {
var _a, _b;
const cache = app2.metadataCache.getFileCache(file);
if (!cache) {
return null;
}
const checkpath = subpath.replace(/[#^]/g, "");
if ((_a = cache.headings) == null ? void 0 : _a.length) {
const index = cache.headings.findIndex((element) => element.heading.replace(/[#^]/g, "") == checkpath);
if (index >= 0) {
return cache.headings[index].position;
}
}
if ((_b = cache.sections) == null ? void 0 : _b.length) {
const index = cache.sections.findIndex((element) => {
var _a2;
return ((_a2 = element.id) == null ? void 0 : _a2.replace(/[#^]/g, "")) == checkpath;
});
if (index >= 0) {
return cache.sections[index].position;
}
}
return null;
}
function checkListCallouts(checkString, callouts) {
if (!callouts)
return null;
for (let i = 0; i < callouts.length; i++) {
if (checkString.startsWith(callouts[i].char + " ")) {
return i;
}
}
return null;
}
function checkTimeList(checkString) {
var _a;
return (_a = checkString.match(/^[0-9]{2}:[0-9]{2}/)) == null ? void 0 : _a[0];
}
function shouldDisplayListItem(data, settings, calloutsIndex) {
if (settings.hideCompletedTasks == true && data.task == "x") {
return false;
}
if (settings.showElements.task == true && data.task !== void 0) {
return true;
}
if (settings.showListCallouts == true && data.listCallout) {
return true;
}
if (settings.showTimeList == true && data.time) {
return true;
}
if (!settings.showElements.listItems || data.level == 2 || data.level == 1 && settings.allRootItems == false) {
return false;
}
return true;
}
function searchFirstNote() {
var _a, _b, _c;
if (this.verPN != 2) {
let targetDate = window.moment().startOf("day");
for (const [key, value] of Object.entries(this.allDailyNotes)) {
const tempDate = (0, import_obsidian_daily_notes_interface3.getDateFromFile)(value, GRANULARITY_LIST[this.activeGranularity]);
if (tempDate.isBefore(targetDate)) {
targetDate = tempDate;
}
}
return targetDate;
} else {
let targetDate = window.moment().startOf("day");
const cache = (_c = (_b = (_a = this.app.plugins.plugins["periodic-notes"]) == null ? void 0 : _a.cache) == null ? void 0 : _b.cachedFiles) == null ? void 0 : _c.get(this.calendarSets[this.activeSet].id);
cache.forEach((value, key) => {
var _a2, _b2, _c2;
if (this.settings.exactMatchOnly && !((_a2 = value.matchData) == null ? void 0 : _a2.exact)) {
return;
}
if (this.settings.markdownOnly && !value.filePath.endsWith(".md")) {
return;
}
if (!value.filePath.startsWith((_b2 = this.calendarSets[this.activeSet][GRANULARITY_LIST[this.activeGranularity]]) == null ? void 0 : _b2.folder.concat("/")) && ((_c2 = this.calendarSets[this.activeSet][GRANULARITY_LIST[this.activeGranularity]]) == null ? void 0 : _c2.folder.folder)) {
return;
}
if (value.granularity == GRANULARITY_LIST[this.activeGranularity] && value.date.isBefore(targetDate)) {
targetDate = value.date;
}
});
return targetDate;
}
}
function checkUnresolvedLinks() {
return __async(this, null, function* () {
if (this.verPN === void 0) {
return;
}
const unresolved = this.app.metadataCache.unresolvedLinks;
const allunresolvedDNLinks = [];
let createdDN = 0;
let notice;
for (const fileName in unresolved) {
for (const unresolvedLink in unresolved[fileName]) {
if (!notice && createdDN >= 5) {
notice = new import_obsidian4.Notice(`Daily Note Outline: created ${createdDN} daily notes for unresolved links`, 0);
}
allunresolvedDNLinks.push(unresolvedLink);
if (this.verPN != 2) {
const linkedDate = (0, import_obsidian_daily_notes_interface3.getDateFromPath)(unresolvedLink, "day");
if (!linkedDate) {
continue;
}
yield createDailyNoteForUnresolvedLink(this.app, linkedDate);
createdDN++;
if (notice) {
notice.setMessage(`Daily Note Outline: created ${createdDN} daily notes for unresolved links`);
}
} else {
for (const calendarSet of this.calendarSets) {
if (!calendarSet.day.enabled) {
continue;
}
const format = calendarSet.day.format;
const linkedDate = window.moment(unresolvedLink, format, true);
if (linkedDate.isValid()) {
yield createDailyNoteForUnresolvedLinkPNbeta(this.app, linkedDate, calendarSet);
createdDN++;
}
}
}
}
}
if (notice) {
new import_obsidian4.Notice("Daily Note Outline: created all daily notes for unresolved links");
notice.hide();
}
});
}
// src/drawUI.ts
function drawUI() {
const navHeader = createDiv("nav-header");
const navButtonContainer = navHeader.createDiv("nav-buttons-container");
const granularity = GRANULARITY_LIST[this.activeGranularity];
uiPreviousPage.call(this, navButtonContainer, granularity);
uiNextPage.call(this, navButtonContainer, granularity);
uiReturnHome.call(this, navButtonContainer);
uiSetting.call(this, navButtonContainer, granularity);
uiCreateDailyNote.call(this, navButtonContainer, granularity);
uiExtract.call(this, navButtonContainer);
uiCollapse.call(this, navButtonContainer);
const navDateRange = navHeader.createDiv("nav-date-range");
let latest = this.searchRange.latest.clone();
let earliest = this.searchRange.earliest.clone();
earliest = latest.clone().subtract(this.settings.duration[granularity] - 1, granularity);
if (latest.isSame(window.moment(), "day")) {
latest = latest.clone().add(Math.ceil(this.settings.offset / DAYS_PER_UNIT[granularity]), granularity);
}
const dateRange = earliest.format("YYYY/MM/DD [-] ") + latest.format(earliest.isSame(latest, "year") ? "MM/DD" : "YYYY/MM/DD");
navDateRange.createDiv("nav-date-range-content").setText(dateRange);
navDateRange.addEventListener("click", (event) => __async(this, null, function* () {
const onSubmit = (enteredDate) => {
const targetDate = window.moment(enteredDate);
if (targetDate.isValid()) {
this.searchRange.latest = targetDate;
this.searchRange.earliest = targetDate.clone().subtract(this.settings.duration.day - 1, "days");
this.refreshView(false, true, true);
} else {
new import_obsidian5.Notice("entered date is invalid.");
}
};
new ModalJump(this.app, this.plugin, onSubmit).open();
}));
navDateRange.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian5.Menu();
menu.addItem((item) => item.setTitle(`Jump to ${this.settings.onset}`).onClick(() => {
const targetDate = window.moment(this.settings.onset, "YYYY-MM-DD");
if (targetDate.isValid()) {
this.searchRange.latest = targetDate;
this.searchRange.earliest = targetDate.clone().subtract(this.settings.duration.day - 1, "days");
} else {
new import_obsidian5.Notice(`${this.settings.onset} is an invalid date.`);
}
this.refreshView(false, true, true);
}));
menu.addSeparator();
menu.addItem((item) => item.setTitle("Jump to 3 months ago").onClick(() => {
this.searchRange.latest.subtract(3, "months");
this.searchRange.earliest.subtract(3, "months");
this.refreshView(false, true, true);
}));
menu.addItem((item) => item.setTitle("Jump to 6 months ago").onClick(() => {
this.searchRange.latest.subtract(6, "months");
this.searchRange.earliest.subtract(6, "months");
this.refreshView(false, true, true);
}));
menu.addItem((item) => item.setTitle("Jump to 1 year ago").onClick(() => {
this.searchRange.latest.subtract(12, "months");
this.searchRange.earliest.subtract(12, "months");
this.refreshView(false, true, true);
}));
menu.addItem((item) => item.setTitle("Jump to 2 years ago").onClick(() => {
this.searchRange.latest.subtract(24, "months");
this.searchRange.earliest.subtract(24, "months");
this.refreshView(false, true, true);
}));
if (window.moment().subtract(3, "months").isSameOrAfter(this.searchRange.latest)) {
menu.addSeparator();
menu.addItem((item) => item.setTitle("Jump to 3 months later").onClick(() => {
this.searchRange.latest.add(3, "months");
this.searchRange.earliest.add(3, "months");
this.refreshView(false, true, true);
}));
}
if (window.moment().subtract(6, "months").isSameOrAfter(this.searchRange.latest)) {
menu.addItem((item) => item.setTitle("Jump to 6 months later").onClick(() => {
this.searchRange.latest.add(6, "months");
this.searchRange.earliest.add(6, "months");
this.refreshView(false, true, true);
}));
}
if (window.moment().subtract(12, "months").isSameOrAfter(this.searchRange.latest)) {
menu.addItem((item) => item.setTitle("Jump to 1 year later").onClick(() => {
this.searchRange.latest.add(12, "months");
this.searchRange.earliest.add(12, "months");
this.refreshView(false, true, true);
}));
}
if (window.moment().subtract(24, "months").isSameOrAfter(this.searchRange.latest)) {
menu.addItem((item) => item.setTitle("Jump to 2 years later").onClick(() => {
this.searchRange.latest.add(24, "months");
this.searchRange.earliest.add(24, "months");
this.refreshView(false, true, true);
}));
}
menu.addSeparator();
menu.addItem((item) => item.setTitle("Jump to the first note").onClick(() => {
const targetDate = searchFirstNote.call(this);
this.searchRange.latest = targetDate;
this.searchRange.earliest = targetDate.clone().subtract(this.settings.duration.day - 1, "days");
this.refreshView(false, true, true);
}));
menu.showAtMouseEvent(event);
});
if (this.settings.periodicNotesEnabled) {
const navGranularity = navHeader.createDiv("nav-date-range");
navGranularity.createDiv("nav-date-range-content").setText(GRANULARITY_LIST[this.activeGranularity]);
navGranularity.addEventListener("click", (evet) => {
var _a, _b, _c;
if (this.settings.showDebugInfo) {
console.log("DNO:clicked to change granularity. verPN, calendarSets:", this.activeGranularity, this.verPN, this.calendarSets);
}
const initialGranularity = this.activeGranularity;
do {
this.activeGranularity = (this.activeGranularity + 1) % GRANULARITY_LIST.length;
} while ((this.verPN == 2 && !((_a = this.calendarSets[this.activeSet][GRANULARITY_LIST[this.activeGranularity]]) == null ? void 0 : _a.enabled) || this.verPN == 1 && !((_c = (_b = this.app.plugins.getPlugin("periodic-notes").settings) == null ? void 0 : _b[GRANULARITY_TO_PERIODICITY[GRANULARITY_LIST[this.activeGranularity]]]) == null ? void 0 : _c.enabled)) && this.activeGranularity != initialGranularity);
this.app.workspace.requestSaveLayout();
this.refreshView(true, true, true);
});
navGranularity.addEventListener("contextmenu", (event) => {
var _a, _b, _c;
const menu = new import_obsidian5.Menu();
for (let i = 0; i < GRANULARITY_LIST.length; i++) {
if (this.verPN == 2 && ((_a = this.calendarSets[this.activeSet][GRANULARITY_LIST[i]]) == null ? void 0 : _a.enabled) || this.verPN == 1 && ((_c = (_b = this.app.plugins.getPlugin("periodic-notes").settings) == null ? void 0 : _b[GRANULARITY_TO_PERIODICITY[GRANULARITY_LIST[i]]]) == null ? void 0 : _c.enabled)) {
const icon = i == this.activeGranularity ? "check" : "";
menu.addItem((item) => item.setTitle(GRANULARITY_LIST[i]).setIcon(icon).onClick(() => {
this.activeGranularity = i;
this.app.workspace.requestSaveLayout();
this.refreshView(true, true, true);
}));
}
}
menu.showAtMouseEvent(event);
});
}
if (this.settings.calendarSetsEnabled) {
const navCalendarSet = navHeader.createDiv("nav-date-range");
navCalendarSet.createDiv("nav-date-range-content").setText(this.calendarSets[this.activeSet].id);
navCalendarSet.addEventListener("click", (evet) => {
this.activeSet = (this.activeSet + 1) % this.calendarSets.length;
this.app.workspace.requestSaveLayout();
this.refreshView(false, true, true);
});
navCalendarSet.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian5.Menu();
for (let i = 0; i < this.calendarSets.length; i++) {
const icon = i == this.activeSet ? "check" : "";
menu.addItem((item) => item.setTitle(this.calendarSets[i].id).setIcon(icon).onClick(() => {
this.activeSet = i;
this.app.workspace.requestSaveLayout();
this.refreshView(false, true, true);
}));
}
menu.showAtMouseEvent(event);
});
}
this.contentEl.empty();
this.contentEl.appendChild(navHeader);
}
function uiPreviousPage(parentEl, granularity) {
let navActionButton = parentEl.createDiv("clickable-icon nav-action-button");
navActionButton.ariaLabel = "previous notes";
(0, import_obsidian5.setIcon)(navActionButton, "arrow-left");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
this.searchRange.latest = this.searchRange.latest.subtract(this.settings.duration[granularity], granularity);
this.searchRange.earliest = this.searchRange.earliest.subtract(this.settings.duration[granularity], granularity);
this.refreshView(false, true, true);
}));
}
function uiNextPage(parentEl, granularity) {
let navActionButton = parentEl.createDiv("clickable-icon nav-action-button");
navActionButton.ariaLabel = "next notes";
(0, import_obsidian5.setIcon)(navActionButton, "arrow-right");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
this.searchRange.latest = this.searchRange.latest.add(this.settings.duration[granularity], granularity);
this.searchRange.earliest = this.searchRange.earliest.add(this.settings.duration[granularity], granularity);
this.refreshView(false, true, true);
}));
}
function uiReturnHome(parentEl) {
let navActionButton = parentEl.createDiv("clickable-icon nav-action-button");
navActionButton.ariaLabel = "home";
(0, import_obsidian5.setIcon)(navActionButton, "home");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
this.resetSearchRange();
this.refreshView(false, true, true);
}));
navActionButton.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian5.Menu();
menu.addItem((item) => item.setTitle("refresh view").setIcon("refresh-cw").onClick(() => __async(this, null, function* () {
this.refreshView(true, true, true);
})));
menu.showAtMouseEvent(event);
});
}
function uiSetting(parentEl, granularity) {
let navActionButton = parentEl.createDiv("clickable-icon nav-action-button");
navActionButton.ariaLabel = "open settings";
(0, import_obsidian5.setIcon)(navActionButton, "settings");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
this.app.setting.open();
this.app.setting.openTabById(this.plugin.manifest.id);
}));
navActionButton.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian5.Menu();
for (const element in this.settings.showElements) {
const icon = this.settings.showElements[element] == true ? "check" : "";
menu.addItem((item) => item.setTitle(`show ${element}`).setIcon(icon).onClick(() => __async(this, null, function* () {
this.settings.showElements[element] = !this.settings.showElements[element];
yield this.plugin.saveSettings();
this.refreshView(false, false, false);
})));
}
const iconBacklink = this.settings.showBacklinks == true ? "check" : "";
menu.addItem((item) => item.setTitle(`show backlink files`).setIcon(iconBacklink).onClick(() => __async(this, null, function* () {
this.settings.showBacklinks = !this.settings.showBacklinks;
yield this.plugin.saveSettings();
this.refreshView(false, false, false);
})));
menu.addSeparator();
if (granularity == "day") {
for (let index in FILEINFO_TO_DISPLAY_DAY) {
const icon = index == this.settings.displayFileInfoDaily ? "check" : "";
menu.addItem((item) => item.setTitle(FILEINFO_TO_DISPLAY_DAY[index]).setIcon(icon).onClick(() => __async(this, null, function* () {
this.settings.displayFileInfoDaily = index;
yield this.plugin.saveSettings();
this.refreshView(false, false, false);
})));
}
} else {
for (let index in FILEINFO_TO_DISPLAY) {
const icon = index == this.settings.displayFileInfoPeriodic ? "check" : "";
menu.addItem((item) => item.setTitle(FILEINFO_TO_DISPLAY[index]).setIcon(icon).onClick(() => __async(this, null, function* () {
this.settings.displayFileInfoPeriodic = index;
yield this.plugin.saveSettings();
this.refreshView(false, false, false);
})));
}
}
menu.addSeparator();
const iconTooltip = this.settings.tooltipPreview ? "check" : "";
menu.addItem((item) => item.setTitle("show tooltip preview").setIcon(iconTooltip).onClick(() => __async(this, null, function* () {
this.settings.tooltipPreview = !this.settings.tooltipPreview;
yield this.plugin.saveSettings();
this.refreshView(false, false, false);
})));
menu.showAtMouseEvent(event);
});
}
function uiCreateDailyNote(parentEl, granularity) {
let navActionButton = parentEl.createDiv("clickable-icon nav-action-button");
let labelForToday = "create/open ";
let labelForNext = "create/open ";
if (granularity == "day") {
labelForToday = labelForToday + "today's ";
labelForNext = labelForNext + "tomorrow's ";
} else {
labelForToday = labelForToday + "present ";
labelForNext = labelForNext + "next ";
}
labelForToday = labelForToday + GRANULARITY_TO_PERIODICITY[granularity] + " note";
labelForNext = labelForNext + GRANULARITY_TO_PERIODICITY[granularity] + " note";
if (this.verPN == 2) {
labelForToday = labelForToday + " for " + this.calendarSets[this.activeSet].id;
labelForNext = labelForNext + " for " + this.calendarSets[this.activeSet].id;
}
navActionButton.ariaLabel = labelForToday;
(0, import_obsidian5.setIcon)(navActionButton, "calendar-plus");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
event.preventDefault;
const date = window.moment();
if (this.verPN == 2) {
createAndOpenPeriodicNote(granularity, date, this.calendarSets[this.activeSet]);
} else {
createAndOpenDailyNote(granularity, date, this.allDailyNotes);
}
}));
navActionButton.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian5.Menu();
menu.addItem((item) => item.setTitle(labelForNext).setIcon("calendar-plus").onClick(() => __async(this, null, function* () {
const date = window.moment().add(1, granularity);
if (this.verPN == 2) {
createAndOpenPeriodicNote(granularity, date, this.calendarSets[this.activeSet]);
} else {
createAndOpenDailyNote(granularity, date, this.allDailyNotes);
}
})));
menu.showAtMouseEvent(event);
});
}
function uiExtract(parentEl) {
let navActionButton = parentEl.createDiv("clickable-icon nav-action-button");
if (!this.extractMode) {
navActionButton.ariaLabel = "extract";
(0, import_obsidian5.setIcon)(navActionButton, "search");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
event.preventDefault;
const onSubmit = (enableExtract) => {
if (enableExtract) {
this.extractMode = true;
this.extractType = "normal";
this.refreshView(false, false, false);
}
};
new ModalExtract(this.app, this.plugin, onSubmit).open();
}));
} else {
navActionButton.ariaLabel = "unextract";
(0, import_obsidian5.setIcon)(navActionButton, "x-circle");
navActionButton.classList.add("is-active");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
this.extractMode = false;
this.extractType = "normal";
this.refreshView(false, false, false);
}));
}
navActionButton.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian5.Menu();
menu.addItem((item) => item.setTitle("extract tasks").setIcon("check-square").onClick(() => __async(this, null, function* () {
this.extractMode = true;
this.extractType = "task";
this.refreshView(false, false, false);
})));
menu.addItem((item) => item.setTitle("extract list callouts").setIcon("lightbulb").onClick(() => __async(this, null, function* () {
this.extractMode = true;
this.extractType = "listCallout";
this.refreshView(false, false, false);
})));
menu.addItem((item) => item.setTitle("extract time lists").setIcon("clock").onClick(() => __async(this, null, function* () {
this.extractMode = true;
this.extractType = "time";
this.refreshView(false, false, false);
})));
menu.showAtMouseEvent(event);
});
}
function uiCollapse(parentEl) {
let navActionButton = parentEl.createDiv("clickable-icon nav-action-button");
if (this.collapseAll) {
navActionButton.classList.add("is-active");
}
if (!this.collapseAll) {
navActionButton.ariaLabel = "collapse all";
(0, import_obsidian5.setIcon)(navActionButton, "chevrons-down-up");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
this.collapseAll = true;
this.refreshView(false, false, false);
}));
} else {
navActionButton.ariaLabel = "expand";
(0, import_obsidian5.setIcon)(navActionButton, "chevrons-down-up");
navActionButton.addEventListener("click", (event) => __async(this, null, function* () {
this.collapseAll = false;
this.refreshView(false, false, false);
}));
}
}
// src/getTargetFiles.ts
var import_obsidian6 = __toModule(require("obsidian"));
var import_obsidian_daily_notes_interface4 = __toModule(require_main());
function getTargetFiles(allFiles, granularity) {
let files = [];
let checkDate = this.searchRange.latest.clone();
let checkDateEarliest = this.searchRange.earliest.clone();
if (checkDate.isSame(window.moment(), "day")) {
checkDate.add(Math.ceil(this.settings.offset / DAYS_PER_UNIT[granularity]), granularity);
}
checkDateEarliest = this.searchRange.latest.clone().subtract(this.settings.duration[granularity] - 1, granularity);
while (checkDate.isSameOrAfter(checkDateEarliest, granularity)) {
if (allFiles[(0, import_obsidian_daily_notes_interface4.getDateUID)(checkDate, granularity)]) {
files.push(allFiles[(0, import_obsidian_daily_notes_interface4.getDateUID)(checkDate, granularity)]);
}
checkDate.subtract(1, granularity);
}
return files;
}
function getTargetPeriodicNotes(calendarSet, granularity) {
var _a;
let files = [];
let checkDate = this.searchRange.latest.clone();
let checkDateEarliest = this.searchRange.earliest.clone();
if (checkDate.isSame(window.moment(), "day")) {
checkDate.add(Math.ceil(this.settings.offset / DAYS_PER_UNIT[granularity]), granularity);
}
checkDateEarliest = this.searchRange.latest.clone().subtract(this.settings.duration[granularity] - 1, granularity);
if (this.settings.showDebugInfo) {
console.log("DNO:searching caches of Periodic Notes... calendar set:", calendarSet);
}
while (checkDate.isSameOrAfter(checkDateEarliest, granularity)) {
const caches = this.app.plugins.getPlugin("periodic-notes").cache.getPeriodicNotes(calendarSet.id, granularity, checkDate);
for (const file of caches) {
if (this.settings.exactMatchOnly && !((_a = file == null ? void 0 : file.matchData) == null ? void 0 : _a.exact)) {
continue;
}
if (this.settings.markdownOnly && !(file == null ? void 0 : file.filePath.endsWith(".md"))) {
continue;
}
if (!file.filePath.startsWith(calendarSet[granularity].folder.concat("/")) && calendarSet[granularity].folder) {
continue;
}
const fileobj = this.app.vault.getAbstractFileByPath(file.filePath);
if (fileobj instanceof import_obsidian6.TFile) {
files.push(fileobj);
}
}
checkDate.subtract(1, granularity);
}
return files;
}
function getBacklinkFiles(app2, file) {
let files = [];
let backlinks = app2.metadataCache.getBacklinksForFile(file).data;
for (const key in backlinks) {
const fileobj = app2.vault.getAbstractFileByPath(key);
if (fileobj instanceof import_obsidian6.TFile) {
files.push(fileobj);
}
}
return files;
}
function getBacklinkFilesDataview(app2, file) {
var _a, _b, _c, _d, _e;
let files = [];
if (!app2.plugins.plugins["dataview"]) {
return getBacklinkFiles(app2, file);
}
let backlinks = (_e = (_d = (_c = (_b = (_a = app2.plugins.plugins) == null ? void 0 : _a.dataview) == null ? void 0 : _b.api) == null ? void 0 : _c.pages(`"${file.path}"`)) == null ? void 0 : _d.values[0]) == null ? void 0 : _e.file.inlinks.values;
if (!backlinks) {
return getBacklinkFiles(app2, file);
}
for (let i = 0; i < backlinks.length; i++) {
const fileobj = app2.vault.getAbstractFileByPath(backlinks[i].path);
if (fileobj instanceof import_obsidian6.TFile) {
files.push(fileobj);
}
}
return files;
}
// src/getOutline.ts
var import_obsidian_daily_notes_interface5 = __toModule(require_main());
function getFileInfo(files) {
return __async(this, null, function* () {
let fileInfo = [];
for (let i = 0; i < files.length; i++) {
const content = yield this.app.vault.cachedRead(files[i]);
const lines = content.split("\n");
const backlinkFiles = this.settings.showBacklinks ? getBacklinkFilesDataview(this.app, files[i]) : void 0;
let info = {
date: (0, import_obsidian_daily_notes_interface5.getDateFromFile)(files[i], GRANULARITY_LIST[this.activeGranularity]),
lines,
numOfLines: lines.length,
isFolded: false,
backlinks: backlinkFiles,
frontmatterLinks: void 0
};
if (this.verPN == 2) {
info.date = this.app.plugins.getPlugin("periodic-notes").cache.cachedFiles.get(this.calendarSets[this.activeSet].id).get(files[i].path).date;
}
fileInfo.push(info);
}
return fileInfo;
});
}
function getOutline(files, info) {
return __async(this, null, function* () {
var _a, _b;
let data = [];
for (let i = 0; i < files.length; i++) {
const cache = this.app.metadataCache.getFileCache(files[i]);
info[i].frontmatterLinks = cache == null ? void 0 : cache.frontmatterLinks;
data[i] = [];
if (!cache) {
continue;
}
if (cache.hasOwnProperty("headings")) {
for (let j = 0; j < cache.headings.length; j++) {
const element = {
typeOfElement: "heading",
position: cache.headings[j].position,
displayText: cache.headings[j].heading,
level: cache.headings[j].level
};
data[i].push(element);
}
}
if (cache.hasOwnProperty("links")) {
for (let j = 0; j < cache.links.length; j++) {
const element = {
typeOfElement: "link",
position: cache.links[j].position,
displayText: cache.links[j].displayText == "" ? cache.links[j].original.substring(1, cache.links[j].original.indexOf("]")) : cache.links[j].displayText,
link: cache.links[j].link
};
data[i].push(element);
}
}
if (cache.hasOwnProperty("embeds")) {
for (let j = 0; j < cache.embeds.length; j++) {
const element = {
typeOfElement: "link",
position: cache.embeds[j].position,
displayText: cache.embeds[j].displayText == "" ? cache.embeds[j].original.substring(1, cache.embeds[j].original.indexOf("]")) : cache.embeds[j].displayText,
link: cache.embeds[j].link
};
data[i].push(element);
}
}
if (cache.hasOwnProperty("listItems")) {
for (let j = 0; j < cache.listItems.length; j++) {
let displayText = this.fileInfo[i].lines[cache.listItems[j].position.start.line].replace(/^(\s|\t)*-\s(\[.\]\s)*/, "");
let listLevel = 0;
if (cache.listItems[j].parent > 0) {
listLevel = 2;
} else if (j > 0) {
if (!(Math.abs(cache.listItems[j].parent) == cache.listItems[j].position.start.line) && cache.listItems[j].position.start.line - cache.listItems[j - 1].position.start.line == 1) {
listLevel = 1;
}
}
const listCallout = checkListCallouts(displayText, (_b = (_a = this.app.plugins.plugins) == null ? void 0 : _a["obsidian-list-callouts"]) == null ? void 0 : _b.settings);
const time = checkTimeList(displayText);
const element = {
typeOfElement: "listItems",
position: cache.listItems[j].position,
displayText: this.fileInfo[i].lines[cache.listItems[j].position.start.line].replace(/^(\s|\t)*-\s(\[.\]\s)*/, ""),
level: listLevel,
task: cache.listItems[j].task,
listCallout,
time
};
data[i].push(element);
}
}
if (cache.hasOwnProperty("tags")) {
for (let j = 0; j < cache.tags.length; j++) {
const element = {
typeOfElement: "tag",
position: cache.tags[j].position,
displayText: cache.tags[j].tag.substring(1)
};
data[i].push(element);
}
}
data[i].sort((a, b) => {
return a.position.start.offset - b.position.start.offset;
});
}
return data;
});
}
// src/constructDOM.ts
var import_obsidian7 = __toModule(require("obsidian"));
function drawOutline(files, info, data) {
var _a, _b, _c, _d, _e, _f, _g, _h;
const containerEl = createDiv("nav-files-container node-insert-event");
const rootEl = containerEl.createDiv("tree-item nav-folder mod-root");
const rootChildrenEl = rootEl.createDiv("tree-item-children nav-folder-children");
if (files.length == 0) {
rootChildrenEl.createEl("h4", {
text: "Daily/periodic note loading error(try clicking on the Home icon)"
});
}
let includeMode = this.settings.includeOnly != "none" && (Boolean(this.settings.wordsToInclude.length) || this.settings.includeBeginning);
let maxLevel = this.settings.headingLevel.indexOf(true);
for (let i = 0; i < files.length; i++) {
let latestHeadingLevel = 0;
const dailyNoteEl = rootChildrenEl.createDiv("tree-item nav-folder");
const dailyNoteTitleEl = dailyNoteEl.createDiv("tree-item-self is-clickable mod-collapsible nav-folder-title");
const dailyNoteChildrenEl = dailyNoteEl.createDiv("tree-item-children nav-folder-children");
const changeColor = this.settings.noteTitleBackgroundColor;
if (changeColor != "none") {
const customColor = this.settings.customNoteTitleBackgroundColor;
const customColorHover = this.settings.customNoteTitleBackgroundColorHover;
const theme = Boolean(document.getElementsByTagName("body")[0].classList.contains("theme-light")) ? "light" : "dark";
dailyNoteTitleEl.style.backgroundColor = customColor[changeColor][theme];
dailyNoteTitleEl.addEventListener("mouseover", function() {
this.style.backgroundColor = customColorHover[changeColor][theme];
});
dailyNoteTitleEl.addEventListener("mouseout", function() {
this.style.backgroundColor = customColor[changeColor][theme];
});
}
const noteCollapseIcon = dailyNoteTitleEl.createDiv("tree-item-icon collapse-icon nav-folder-collapse-indicator");
(0, import_obsidian7.setIcon)(noteCollapseIcon, "right-triangle");
noteCollapseIcon.addEventListener("click", (event) => __async(this, null, function* () {
event.stopPropagation();
if (info[i].isFolded) {
if (!this.collapseAll) {
if (checkFlag(files[i], "fold", this.settings)) {
removeFlag(files[i], "fold", this.settings);
yield this.plugin.saveSettings();
}
}
dailyNoteEl.classList.remove("is-collapsed");
noteCollapseIcon.classList.remove("is-collapsed");
info[i].isFolded = false;
dailyNoteChildrenEl.style.display = "block";
} else {
if (!this.collapseAll) {
addFlag(files[i], "fold", this.settings);
}
yield this.plugin.saveSettings();
dailyNoteEl.classList.add("is-collapsed");
noteCollapseIcon.classList.add("is-collapsed");
info[i].isFolded = true;
dailyNoteChildrenEl.style.display = "none";
}
}));
let name = files[i].basename;
if (this.settings.attachWeeklyNotesName && GRANULARITY_LIST[this.activeGranularity] == "week") {
name = name + " (" + this.fileInfo[i].date.clone().startOf("week").format("MM/DD [-] ") + this.fileInfo[i].date.clone().endOf("week").format("MM/DD") + ")";
}
dailyNoteTitleEl.createDiv("tree-item-inner nav-folder-title-content").setText(name);
const infoToDisplay = this.activeGranularity == 0 ? this.settings.displayFileInfoDaily : this.settings.displayFileInfoPeriodic;
switch (infoToDisplay) {
case "lines":
dailyNoteTitleEl.dataset.subinfo = info[i].numOfLines.toString();
break;
case "days":
let basedate = this.settings.setBaseDateAsHome == false ? window.moment() : window.moment(this.settings.onset);
dailyNoteTitleEl.dataset.subinfo = Math.abs(info[i].date.diff(basedate.startOf(GRANULARITY_LIST[this.activeGranularity]), GRANULARITY_LIST[this.activeGranularity])).toString();
break;
case "dow":
dailyNoteTitleEl.dataset.subinfo = info[i].date.format("dddd");
break;
case "dowshort":
dailyNoteTitleEl.dataset.subinfo = info[i].date.format("ddd");
break;
case "weeknumber":
dailyNoteTitleEl.dataset.subinfo = info[i].date.format("[w]ww");
break;
case "tag":
let firsttagIndex = data[i].findIndex((element, index) => data[i][index].typeOfElement == "tag");
if (firsttagIndex >= 0) {
dailyNoteTitleEl.dataset.subinfo = data[i][firsttagIndex].displayText;
}
break;
case "none":
break;
default:
break;
}
dailyNoteTitleEl.addEventListener("click", (event) => __async(this, null, function* () {
yield this.app.workspace.getLeaf().openFile(files[i]);
}), false);
dailyNoteTitleEl.addEventListener("mouseover", (event) => {
this.app.workspace.trigger("hover-link", {
event,
source: DailyNoteOutlineViewType,
hoverParent: rootEl,
targetEl: dailyNoteTitleEl,
linktext: files[i].path
});
});
dailyNoteTitleEl.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian7.Menu();
menu.addItem((item) => item.setTitle("Open in new tab").setIcon("file-plus").onClick(() => {
event.preventDefault();
this.app.workspace.getLeaf("tab").openFile(files[i]);
}));
menu.addItem((item) => item.setTitle("Open to the right").setIcon("separator-vertical").onClick(() => {
event.preventDefault();
this.app.workspace.getLeaf("split").openFile(files[i]);
}));
menu.addItem((item) => item.setTitle("Open in new window").setIcon("scan").onClick(() => __async(this, null, function* () {
yield this.app.workspace.openPopoutLeaf({ size: { width: this.settings.popoutSize.width, height: this.settings.popoutSize.height } }).openFile(files[i]);
if (this.settings.popoutAlwaysOnTop) {
setPopoutAlwaysOnTop();
}
})));
menu.showAtMouseEvent(event);
});
let isIncluded = this.settings.includeBeginning;
let includeModeHeadingLevel;
let isExcluded = false;
let excludeType;
let excludeModeHeadingLevel;
let primeType = this.settings.includeOnly == "none" ? this.settings.primeElement : this.settings.includeOnly;
let isExtracted = false;
if (this.settings.showPropertyLinks && info[i].frontmatterLinks) {
for (let j = 0; j < info[i].frontmatterLinks.length; j++) {
const linkTarget = this.app.metadataCache.getFirstLinkpathDest((0, import_obsidian7.parseLinktext)(info[i].frontmatterLinks[j].link).path, files[i].path);
if (!(linkTarget instanceof import_obsidian7.TFile)) {
continue;
}
const linkSubpath = (0, import_obsidian7.parseLinktext)(info[i].frontmatterLinks[j].link).subpath;
if (this.extractMode == true) {
if (this.extractType == "noraml" && info[i].frontmatterLinks[j].displayText.toLowerCase().includes(this.settings.wordsToExtract.toLowerCase())) {
isExtracted = true;
} else {
continue;
}
}
const outlineEl = dailyNoteChildrenEl.createDiv("tree-item nav-file");
const outlineTitle = outlineEl.createDiv("tree-item-self is-clickable nav-file-title");
(0, import_obsidian7.setIcon)(outlineTitle, "link");
outlineTitle.style.paddingLeft = "0.5em";
outlineTitle.createDiv("tree-item-inner nav-file-title-content").setText(info[i].frontmatterLinks[j].displayText);
outlineTitle.addEventListener("click", (event) => __async(this, null, function* () {
yield this.app.workspace.getLeaf().openFile(files[i]);
}), false);
outlineTitle.addEventListener("mouseover", (event) => {
var _a2;
if (linkTarget) {
let posInfo = {};
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
if ((_a2 = subpathPosition == null ? void 0 : subpathPosition.start) == null ? void 0 : _a2.line) {
posInfo = { scroll: subpathPosition.start.line };
}
}
this.app.workspace.trigger("hover-link", {
event,
source: DailyNoteOutlineViewType,
hoverParent: rootEl,
targetEl: outlineTitle,
linktext: linkTarget.path,
state: posInfo
});
}
});
outlineTitle.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian7.Menu();
menu.addItem((item) => item.setTitle("Extract").setIcon("search").onClick(() => __async(this, null, function* () {
this.plugin.settings.wordsToExtract = info[i].frontmatterLinks[j].displayText;
yield this.plugin.saveSettings();
this.extractMode = true;
this.extractType = "normal";
this.refreshView(false, false);
})));
menu.addSeparator();
menu.addItem((item) => item.setTitle("Open linked file").setIcon("links-going-out").onClick(() => __async(this, null, function* () {
var _a2;
yield this.app.workspace.getLeaf().openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
})));
menu.addSeparator();
menu.addItem((item) => item.setTitle("Open linked file in new tab").setIcon("file-plus").onClick(() => __async(this, null, function* () {
var _a2;
yield this.app.workspace.getLeaf("tab").openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
})));
menu.addItem((item) => item.setTitle("Open linked file to the right").setIcon("separator-vertical").onClick(() => __async(this, null, function* () {
var _a2;
yield this.app.workspace.getLeaf("split").openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
})));
menu.addItem((item) => item.setTitle("Open linked file in new window").setIcon("scan").onClick(() => __async(this, null, function* () {
var _a2;
yield this.app.workspace.openPopoutLeaf({ size: { width: this.settings.popoutSize.width, height: this.settings.popoutSize.height } }).openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
if (this.settings.popoutAlwaysOnTop) {
setPopoutAlwaysOnTop();
}
})));
menu.addSeparator();
menu.addItem((item) => item.setTitle("Open in new tab").setIcon("file-plus").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("tab").openFile(files[i]);
})));
menu.addItem((item) => item.setTitle("Open to the right").setIcon("separator-vertical").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("split").openFile(files[i]);
})));
menu.addItem((item) => item.setTitle("Open in new window").setIcon("scan").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("window").openFile(files[i]);
})));
menu.showAtMouseEvent(event);
});
}
}
if (data[i].length > 0) {
elementloop:
for (let j = 0; j < data[i].length; j++) {
const element = data[i][j].typeOfElement;
let displayText = data[i][j].displayText;
const linkTarget = element !== "link" ? null : this.app.metadataCache.getFirstLinkpathDest((0, import_obsidian7.parseLinktext)((_a = data[i][j]) == null ? void 0 : _a.link).path, files[i].path);
const linkSubpath = !linkTarget ? void 0 : (0, import_obsidian7.parseLinktext)((_b = data[i][j]) == null ? void 0 : _b.link).subpath;
if (includeMode && this.settings.includeOnly == element) {
if (isIncluded == true && element == "heading" && data[i][j].level > includeModeHeadingLevel) {
} else {
isIncluded = false;
for (const value of this.settings.wordsToInclude) {
if (value && displayText.includes(value)) {
isIncluded = true;
if (element == "heading") {
includeModeHeadingLevel = data[i][j].level;
}
}
}
}
}
if (!isIncluded) {
continue;
}
if (!isExcluded || isExcluded && (excludeType == element || primeType == element)) {
if (element == "heading" && data[i][j].level > excludeModeHeadingLevel) {
} else {
isExcluded = false;
for (const value of this.settings.wordsToExclude[element]) {
if (value && displayText.includes(value)) {
isExcluded = true;
excludeType = element;
if (element == "heading") {
excludeModeHeadingLevel = data[i][j].level;
}
}
}
}
}
if (isExcluded) {
continue;
}
if (!data[i][j].task && this.settings.showElements[element] == false) {
continue;
} else if (data[i][j].task && !this.settings.showElements.task) {
continue;
}
for (const value of this.settings.wordsToIgnore[element]) {
if (value && displayText.includes(value)) {
continue elementloop;
}
}
if (this.extractMode == true) {
if (this.extractType == "normal" && displayText.toLowerCase().includes(this.settings.wordsToExtract.toLowerCase())) {
isExtracted = true;
} else if (this.extractType == "task" && data[i][j].task !== void 0) {
isExtracted = true;
} else if (this.extractType == "listCallout" && typeof data[i][j].listCallout == "number") {
isExtracted = true;
} else if (this.extractType == "time" && data[i][j].time) {
isExtracted = true;
} else {
continue;
}
}
if (element == "heading") {
latestHeadingLevel = data[i][j].level;
if (!this.settings.headingLevel[data[i][j].level - 1]) {
continue;
}
}
if (element == "link") {
}
if (element == "tag") {
}
let calloutsIndex = void 0;
if (element == "listItems") {
if (shouldDisplayListItem(data[i][j], this.settings, calloutsIndex) == false) {
continue;
}
}
const outlineEl = dailyNoteChildrenEl.createDiv("tree-item nav-file");
const outlineTitle = outlineEl.createDiv("tree-item-self is-clickable nav-file-title");
switch (this.settings.icon[element]) {
case "none":
break;
case "headingwithnumber":
(0, import_obsidian7.setIcon)(outlineTitle, `heading-${data[i][j].level}`);
break;
case "custom":
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.customIcon[element]);
break;
default:
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.icon[element]);
break;
}
if (element == "listItems") {
if (data[i][j].task !== void 0) {
if (data[i][j].task == "x") {
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.icon.taskDone == "custom" ? this.settings.customIcon.taskDone : this.settings.icon.taskDone);
} else {
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.icon.task == "custom" ? this.settings.customIcon.task : this.settings.icon.task);
}
const customStatus = Object.keys(this.settings.taskIcon).find((customStatus2) => this.settings.taskIcon[customStatus2].symbol === data[i][j].task);
if (customStatus) {
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.taskIcon[customStatus].icon);
}
}
let calloutsIndex2 = (_c = data[i][j]) == null ? void 0 : _c.listCallout;
if (typeof calloutsIndex2 == "number") {
outlineTitle.style.backgroundColor = `RGBA(${this.app.plugins.plugins["obsidian-list-callouts"].settings[calloutsIndex2].color},0.15)`;
if (this.app.plugins.plugins["obsidian-list-callouts"].settings[calloutsIndex2].hasOwnProperty("icon") && data[i][j].task === void 0) {
(0, import_obsidian7.setIcon)(outlineTitle, this.app.plugins.plugins["obsidian-list-callouts"].settings[calloutsIndex2].icon);
displayText = displayText.replace(/^\S+\s/, "");
}
}
if ((_d = data[i][j]) == null ? void 0 : _d.time) {
if (data[i][j].task === void 0) {
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.icon.time == "custom" ? this.settings.customIcon.time : this.settings.icon.time);
}
}
}
let prefix = this.settings.prefix[element];
if (element == "heading") {
switch (this.settings.repeatHeadingPrefix) {
case "level":
prefix = prefix.repeat(data[i][j].level);
break;
case "levelminus1":
prefix = prefix.repeat(data[i][j].level - 1);
break;
}
}
if (element == "listItems" && data[i][j].time) {
prefix = this.settings.prefix.time;
}
let indent = 0.5;
if (element == "heading" && this.settings.indent.heading == true) {
indent = indent + (data[i][j].level - (maxLevel + 1)) * 1.5;
}
if (element != "heading" && this.settings.indentFollowHeading) {
const additionalIndent = (latestHeadingLevel - (maxLevel + 1) + (this.settings.indentFollowHeading == 2 ? 1 : 0)) * 1.5;
indent = indent + (additionalIndent > 0 ? additionalIndent : 0);
}
if (element == "link" && data[i][j].position.start.line == ((_e = data[i][j - 1]) == null ? void 0 : _e.position.start.line)) {
indent = indent + 1.5;
}
outlineTitle.style.paddingLeft = `${indent}em`;
if (element == "listItems" && data[i][j].task !== void 0) {
prefix = data[i][j].task == "x" ? this.settings.prefix.taskDone : this.settings.prefix.task;
if (this.settings.addCheckboxText) {
prefix = prefix + "[" + data[i][j].task + "] ";
}
}
displayText = this.stripMarkdownSymbol(displayText);
const outlineTitleContent = outlineTitle.createDiv("tree-item-inner nav-file-title-content");
outlineTitleContent.setText(prefix + displayText);
if (this.settings.wrapLine) {
outlineTitleContent.classList.add("wrap-line");
}
if (this.settings.inlinePreview) {
let previewText = "";
if ((element == "link" || element == "tag") && data[i][j].position.end.col < info[i].lines[data[i][j].position.start.line].length) {
previewText = info[i].lines[data[i][j].position.start.line].slice(data[i][j].position.end.col);
} else {
previewText = data[i][j].position.start.line < info[i].numOfLines - 1 ? info[i].lines[data[i][j].position.start.line + 1] : "";
}
outlineTitle.createDiv("nav-file-title-preview").setText(previewText);
}
if (this.settings.tooltipPreview) {
let previewText2 = "";
let endLine = info[i].numOfLines - 1;
let k = j + 1;
endpreviewloop:
while (k < data[i].length) {
if (this.settings.showElements[data[i][k].typeOfElement]) {
if (data[i][k].typeOfElement == "listItems" && (data[i][k].level >= 2 || this.settings.allRootItems == false && data[i][k].level == 1 && (this.settings.allTasks == false || data[i][k].task === void 0) || this.settings.taskOnly && data[i][k].task === void 0 || this.settings.hideCompletedTasks && data[i][k].task == "x")) {
k++;
continue;
} else if (data[i][k].typeOfElement == "heading" && this.settings.headingLevel[data[i][k].level - 1] == false) {
k++;
continue;
} else {
for (const value of this.settings.wordsToIgnore[data[i][k].typeOfElement]) {
if (value && data[i][k].displayText.includes(value)) {
k++;
continue endpreviewloop;
}
}
endLine = data[i][k].position.start.line - 1;
break;
}
}
k++;
}
for (let l = data[i][j].position.start.line; l <= endLine; l++) {
previewText2 = previewText2 + info[i].lines[l] + "\n";
}
previewText2 = previewText2.replace(/\n$|\n(?=\n)/g, "");
(0, import_obsidian7.setTooltip)(outlineTitle, previewText2, { classes: ["DNO-preview"] });
outlineTitle.dataset.tooltipPosition = this.settings.tooltipPreviewDirection;
outlineTitle.setAttribute("data-tooltip-delay", "10");
}
outlineTitle.addEventListener("click", (event) => __async(this, null, function* () {
yield this.app.workspace.getLeaf().openFile(files[i]);
scrollToElement(data[i][j].position.start.line, data[i][j].position.start.col, this.app);
}), false);
outlineTitle.addEventListener("mouseover", (event) => {
this.app.workspace.trigger("hover-link", {
event,
source: DailyNoteOutlineViewType,
hoverParent: rootEl,
targetEl: outlineTitle,
linktext: files[i].path,
state: { scroll: data[i][j].position.start.line }
});
});
outlineTitle.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian7.Menu();
menu.addItem((item) => item.setTitle("Extract").setIcon("search").onClick(() => __async(this, null, function* () {
this.plugin.settings.wordsToExtract = data[i][j].displayText;
yield this.plugin.saveSettings();
this.extractMode = true;
this.extractType = "normal";
this.refreshView(false, false, false);
})));
menu.addSeparator();
if (element == "link") {
menu.addItem((item) => item.setTitle("Open linked file").setIcon("links-going-out").onClick(() => __async(this, null, function* () {
var _a2;
yield this.app.workspace.getLeaf().openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
})));
menu.addSeparator();
menu.addItem((item) => item.setTitle("Open linked file in new tab").setIcon("file-plus").onClick(() => __async(this, null, function* () {
var _a2;
yield this.app.workspace.getLeaf("tab").openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
})));
menu.addItem((item) => item.setTitle("Open linked file to the right").setIcon("separator-vertical").onClick(() => __async(this, null, function* () {
var _a2;
if (linkTarget != this.activeFile) {
this.holdUpdateOnce = true;
}
yield this.app.workspace.getLeaf("split").openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
})));
menu.addItem((item) => item.setTitle("Open linked file in new window").setIcon("scan").onClick(() => __async(this, null, function* () {
var _a2;
if (linkTarget != this.activeFile) {
this.holdUpdateOnce = true;
}
yield this.app.workspace.openPopoutLeaf({ size: { width: this.settings.popoutSize.width, height: this.settings.popoutSize.height } }).openFile(linkTarget);
if (linkSubpath) {
const subpathPosition = getSubpathPosition(this.app, linkTarget, linkSubpath);
scrollToElement((_a2 = subpathPosition.start) == null ? void 0 : _a2.line, 0, this.app);
}
if (this.settings.popoutAlwaysOnTop) {
setPopoutAlwaysOnTop();
}
})));
menu.addSeparator();
}
menu.addItem((item) => item.setTitle("Open in new tab").setIcon("file-plus").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("tab").openFile(files[i]);
this.scrollToElement(data[i][j].position.start.line, data[i][j].position.start.col);
})));
menu.addItem((item) => item.setTitle("Open to the right").setIcon("separator-vertical").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("split").openFile(files[i]);
this.scrollToElement(data[i][j].position.start.line, data[i][j].position.start.col);
})));
menu.addItem((item) => item.setTitle("Open in new window").setIcon("scan").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("window").openFile(files[i]);
this.scrollToElement(data[i][j].position.start.line, data[i][j].position.start.col);
})));
menu.showAtMouseEvent(event);
});
}
} else {
if (this.extractMode == false) {
for (let j = 0; j < info[i].lines.length; j++) {
if (info[i].lines[j] == "") {
continue;
} else {
const outlineEl = dailyNoteChildrenEl.createDiv("tree-item nav-file");
const outlineTitle = outlineEl.createDiv("tree-item-self is-clickable nav-file-title");
outlineTitle.createDiv("tree-item-inner nav-file-title-content").setText(info[i].lines[j]);
outlineTitle.addEventListener("click", (event) => __async(this, null, function* () {
event.preventDefault();
yield this.app.workspace.getLeaf().openFile(files[i]);
}), false);
let previewText2 = info[i].lines.join("\n");
(0, import_obsidian7.setTooltip)(outlineTitle, previewText2, { classes: ["DNO-preview"] });
outlineTitle.dataset.tooltipPosition = this.settings.tooltipPreviewDirection;
outlineTitle.setAttribute("data-tooltip-delay", "10");
break;
}
}
}
}
if (!this.settings.getBacklinks || !this.settings.showBacklinks) {
continue;
}
for (let j = 0; j < ((_f = info[i].backlinks) == null ? void 0 : _f.length); j++) {
if (this.extractMode == true) {
if (this.extractType == "normal" && info[i].backlinks[j].basename.toLowerCase().includes(this.settings.wordsToExtract.toLowerCase())) {
isExtracted = true;
} else {
continue;
}
}
const outlineEl = dailyNoteChildrenEl.createDiv("tree-item nav-file");
const outlineTitle = outlineEl.createDiv("tree-item-self is-clickable nav-file-title");
switch (this.settings.icon.backlink) {
case "none":
break;
case "custom":
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.customIcon.backlink);
break;
default:
(0, import_obsidian7.setIcon)(outlineTitle, this.settings.icon.backlink);
break;
}
outlineTitle.style.paddingLeft = "0.5em";
outlineTitle.createDiv("tree-item-inner nav-file-title-content").setText(info[i].backlinks[j].basename);
outlineTitle.addEventListener("click", (event) => __async(this, null, function* () {
yield this.app.workspace.getLeaf().openFile(info[i].backlinks[j]);
const view = this.app.workspace.getActiveViewOfType(import_obsidian7.MarkdownView);
}), false);
outlineTitle.addEventListener("mouseover", (event) => {
this.app.workspace.trigger("hover-link", {
event,
source: DailyNoteOutlineViewType,
hoverParent: rootEl,
targetEl: outlineTitle,
linktext: info[i].backlinks[j].path
});
});
outlineTitle.addEventListener("contextmenu", (event) => {
const menu = new import_obsidian7.Menu();
menu.addItem((item) => item.setTitle("Open backlink file in new tab").setIcon("file-plus").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("tab").openFile(info[i].backlinks[j]);
})));
menu.addItem((item) => item.setTitle("Open linked file to the right").setIcon("separator-vertical").onClick(() => __async(this, null, function* () {
yield this.app.workspace.getLeaf("split").openFile(info[i].backlinks[j]);
})));
menu.addItem((item) => item.setTitle("Open linked file in new window").setIcon("scan").onClick(() => __async(this, null, function* () {
yield this.app.workspace.openPopoutLeaf({ size: { width: this.settings.popoutSize.width, height: this.settings.popoutSize.height } }).openFile(info[i].backlinks[j]);
if (this.settings.popoutAlwaysOnTop) {
setPopoutAlwaysOnTop();
}
})));
menu.showAtMouseEvent(event);
});
}
if (this.collapseAll || ((_h = (_g = this.settings.fileFlag) == null ? void 0 : _g[files[i].path]) == null ? void 0 : _h.fold)) {
dailyNoteEl.classList.add("is-collpased");
noteCollapseIcon.classList.add("is-collapsed");
info[i].isFolded = true;
dailyNoteChildrenEl.style.display = "none";
} else {
info[i].isFolded = false;
}
if (this.extractMode == true && isExtracted == false) {
dailyNoteEl.remove();
}
}
this.contentEl.appendChild(containerEl);
}
function scrollToElement(line, col, app2) {
const view = app2.workspace.getActiveViewOfType(import_obsidian7.MarkdownView);
if (view) {
view.setEphemeralState({ line });
}
}
function setPopoutAlwaysOnTop() {
const { remote } = require("electron");
const activeWindow = remote.BrowserWindow.getFocusedWindow();
activeWindow.setAlwaysOnTop(true);
}
// src/view.ts
var DailyNoteOutlineViewType = "daily-note-outline";
var DailyNoteOutlineView = class extends import_obsidian9.ItemView {
constructor(leaf, plugin, settings) {
super(leaf);
this.searchRange = {
latest: window.moment(),
earliest: window.moment()
};
this.extractMode = false;
this.extractType = "noraml";
this.collapseAll = false;
this.activeSet = 0;
this.activeGranularity = 0;
this.plugin = plugin;
this.settings = settings;
}
getViewType() {
return DailyNoteOutlineViewType;
}
getDisplayText() {
return "Daily Note Outline";
}
getIcon() {
return "calendar-clock";
}
onOpen() {
return __async(this, null, function* () {
this.initView();
const debouncedAutoRefresh = (0, import_obsidian8.debounce)(this.autoRefresh, 2e3, true);
this.flagRedraw = false;
this.flagRegetAll = false;
this.registerEvent(this.app.metadataCache.on("changed", (file, data, cache) => {
var _a;
if ((_a = this.targetFiles) == null ? void 0 : _a.includes(file)) {
this.flagRedraw = true;
debouncedAutoRefresh.call(this);
}
}));
this.registerEvent(this.app.vault.on("create", (file) => {
this.flagRegetAll = true;
debouncedAutoRefresh.call(this);
}));
this.registerEvent(this.app.vault.on("delete", (file) => {
this.flagRegetAll = true;
debouncedAutoRefresh.call(this);
}));
});
}
onClose() {
return __async(this, null, function* () {
});
}
setState(state, result) {
var __superGet = (key) => super[key];
return __async(this, null, function* () {
if (state.activeSet) {
this.activeSet = state.activeSet;
}
if (state.activeGranularity) {
this.activeGranularity = state.activeGranularity;
}
return __superGet("setState").call(this, state, result);
});
}
getState() {
return {
activeSet: this.activeSet,
activeGranularity: this.activeGranularity
};
}
initView() {
return __async(this, null, function* () {
yield this.bootDelay();
this.collapseAll = this.settings.collapseAllAtStartup;
this.verPN = yield this.checkPeriodicNotes();
if (this.settings.checkUnresolvedLinksAtStartup) {
yield checkUnresolvedLinks.call(this);
}
this.resetSearchRange();
this.refreshView(true, true, true);
});
}
bootDelay() {
return __async(this, null, function* () {
return new Promise((resolve) => {
setTimeout(resolve, this.settings.bootDelayTime);
});
});
}
autoRefresh() {
return __async(this, null, function* () {
if (!(this.flagRedraw || this.flagRegetAll)) {
return;
}
this.refreshView(this.flagRegetAll, this.flagRegetAll, true);
this.flagRegetAll = false;
this.flagRedraw = false;
});
}
refreshView(flagRegetAll, flagGetTarget, flagGetOutline) {
return __async(this, null, function* () {
var _a;
const startTime = performance.now();
if (this.settings.showDebugInfo) {
console.log("DNO:start refreshing view. CalendarSets:", this.calendarSets);
}
this.verPN = yield this.checkPeriodicNotes();
if (this.verPN != 2) {
if (flagRegetAll) {
this.allDailyNotes = this.getAllNotes();
}
if (flagGetTarget) {
this.targetFiles = getTargetFiles.call(this, this.allDailyNotes, GRANULARITY_LIST[this.activeGranularity]);
}
if (flagGetOutline) {
this.fileInfo = yield getFileInfo.call(this, this.targetFiles);
this.outlineData = yield getOutline.call(this, this.targetFiles, this.fileInfo);
}
drawUI.call(this);
drawOutline.call(this, this.targetFiles, this.fileInfo, this.outlineData);
} else {
if (!this.calendarSets[this.activeSet]) {
this.activeSet = 0;
}
if (!((_a = this.calendarSets[this.activeSet][GRANULARITY_LIST[this.activeGranularity]]) == null ? void 0 : _a.enabled)) {
if (this.settings.showDebugInfo) {
console.log("DNO: Calender set is not enabled. this.activeGranularity is set to 0. Calendarsets, this.activeSet, this.activeGranularity:", this.calendarSets, this.activeSet, this.activeGranularity);
}
this.activeGranularity = 0;
}
if (flagGetTarget) {
this.targetFiles = getTargetPeriodicNotes.call(this, this.calendarSets[this.activeSet], GRANULARITY_LIST[this.activeGranularity]);
}
if (flagGetOutline) {
this.fileInfo = yield getFileInfo.call(this, this.targetFiles);
this.outlineData = yield getOutline.call(this, this.targetFiles, this.fileInfo);
}
drawUI.call(this);
drawOutline.call(this, this.targetFiles, this.fileInfo, this.outlineData);
}
const endTime = performance.now();
if (this.settings.showDebugInfo) {
console.log("DNO: time required to refresh view: ", endTime - startTime);
}
});
}
stripMarkdownSymbol(text) {
return text.replace(/(\[\[)|(\]\])/g, "");
}
resetSearchRange() {
if (this.settings.setBaseDateAsHome == true) {
const onsetDate = window.moment(this.settings.onset, "YYYY-MM-DD");
if (onsetDate.isValid()) {
this.searchRange.latest = onsetDate;
this.searchRange.earliest = onsetDate.clone().subtract(this.settings.duration.day - 1, "days");
} else {
new import_obsidian8.Notice("onset date is invalid");
this.searchRange.latest = window.moment().startOf("day");
this.searchRange.earliest = window.moment().startOf("day").subtract(this.settings.duration.day - 1, "days");
}
} else {
this.searchRange.latest = window.moment().startOf("day");
this.searchRange.earliest = window.moment().startOf("day").subtract(this.settings.duration.day - 1, "days");
}
}
checkPeriodicNotes() {
return __async(this, null, function* () {
var _a, _b, _c, _d, _e, _f;
if (this.settings.showDebugInfo) {
console.log("DNO:checking the version of Periodic Notes plugin");
}
if (app.plugins.plugins["periodic-notes"]) {
if (Number(app.plugins.plugins["periodic-notes"].manifest.version.split(".")[0]) >= 1) {
this.calendarSets = (_a = this.app.plugins.getPlugin("periodic-notes")) == null ? void 0 : _a.calendarSetManager.getCalendarSets();
if (this.settings.showDebugInfo) {
console.log("DNO: return of this.app.PN.calendarSetManager.getCalendarSets(): ", (_b = this.app.plugins.getPlugin("periodic-notes")) == null ? void 0 : _b.calendarSetManager.getCalendarSets());
console.log("DNO: return of window.app.PN.calendarSetManager.getCalendarSets(): ", (_c = window.app.plugins.getPlugin("periodic-notes")) == null ? void 0 : _c.calendarSetManager.getCalendarSets());
}
if (!this.calendarSets.length) {
new import_obsidian8.Notice("failed to import calendar sets to Daily Note Outline");
}
const initialGranularity = this.activeGranularity;
while (!((_d = this.calendarSets[this.activeSet][GRANULARITY_LIST[this.activeGranularity]]) == null ? void 0 : _d.enabled)) {
this.activeGranularity = (this.activeGranularity + 1) % GRANULARITY_LIST.length;
if (this.activeGranularity == initialGranularity) {
break;
}
}
this.app.workspace.requestSaveLayout();
if (this.settings.showDebugInfo) {
console.log("DNO: obtained verPN: ", this.verPN, " calendarSets: ", this.calendarSets);
}
return 2;
} else {
this.settings.calendarSetsEnabled = false;
this.activeSet = 0;
yield this.plugin.saveSettings();
const initialGranularity = this.activeGranularity;
while (!((_f = (_e = this.app.plugins.getPlugin("periodic-notes").settings) == null ? void 0 : _e[GRANULARITY_TO_PERIODICITY[GRANULARITY_LIST[this.activeGranularity]]]) == null ? void 0 : _f.enabled)) {
this.activeGranularity = (this.activeGranularity + 1) % GRANULARITY_LIST.length;
if (this.activeGranularity == initialGranularity) {
break;
}
}
this.app.workspace.requestSaveLayout();
return 1;
}
} else {
this.settings.periodicNotesEnabled = false;
this.settings.calendarSetsEnabled = false;
this.activeGranularity = 0;
this.activeSet = 0;
yield this.plugin.saveSettings();
return 0;
}
});
}
getAllNotes() {
switch (this.activeGranularity) {
case 0:
return (0, import_obsidian_daily_notes_interface6.getAllDailyNotes)();
case 1:
return (0, import_obsidian_daily_notes_interface6.getAllWeeklyNotes)();
case 2:
return (0, import_obsidian_daily_notes_interface6.getAllMonthlyNotes)();
case 3:
return (0, import_obsidian_daily_notes_interface6.getAllQuarterlyNotes)();
case 4:
return (0, import_obsidian_daily_notes_interface6.getAllYearlyNotes)();
}
}
};
// src/setting.ts
var import_obsidian10 = __toModule(require("obsidian"));
var DailyNoteOutlineSettingTab = class extends import_obsidian10.PluginSettingTab {
constructor(app2, plugin) {
super(app2, plugin);
this.plugin = plugin;
}
display() {
var _a, _b;
let { containerEl } = this;
containerEl.empty();
if (!((_a = app.internalPlugins.plugins["daily-notes"]) == null ? void 0 : _a.enabled) && !app.plugins.plugins["periodic-notes"]) {
this.containerEl.createDiv("settings-banner", (banner) => {
banner.createEl("h3", {
text: "Neither Daily Note plugin nor Periodic Notes community plugin is enabled"
});
});
}
new import_obsidian10.Setting(containerEl).setName("Search duration").setDesc("number of days to search per page (default = 28)").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.duration.day)).setValue(String(this.plugin.settings.duration.day));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 0 || parsed >= 366) {
parsed = DEFAULT_SETTINGS.duration.day;
}
this.plugin.settings.duration.day = parsed;
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(false, true, true);
});
});
new import_obsidian10.Setting(containerEl).setName("Include future daily notes").setClass("setting-indent").setDesc("in backward search, include n days of future daily notes (default = 5)").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.offset)).setValue(String(this.plugin.settings.offset));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let inputedValue = Number(e.target.value);
if (inputedValue < 0) {
inputedValue = 0;
} else if (inputedValue >= 366) {
inputedValue = 366;
}
this.plugin.settings.offset = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(false, true, true);
});
});
new import_obsidian10.Setting(containerEl).setName("Base date").setDesc("You can set one base date to use for jumping back(YYYY-MM-DD)").addText((text) => {
text.setPlaceholder(DEFAULT_SETTINGS.onset).setValue(this.plugin.settings.onset).onChange((value) => __async(this, null, function* () {
this.plugin.settings.onset = value;
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(false, true, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Set Base date as Home").setClass("setting-indent").setDesc("If enabled, daily notes created on base date are displayed in the view at startup or when Home icon is clicked.").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.setBaseDateAsHome).onChange((value) => __async(this, null, function* () {
this.plugin.settings.setBaseDateAsHome = value;
this.display();
yield this.plugin.saveSettings();
}));
});
new import_obsidian10.Setting(containerEl).setName("Show headings").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showElements.heading).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showElements.heading = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Show links").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showElements.link).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showElements.link = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Show tags").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showElements.tag).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showElements.tag = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Show list items").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showElements.listItems).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showElements.listItems = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.showElements.listItems) {
new import_obsidian10.Setting(containerEl).setName("Show all root list items").setDesc("if disabled, only top item of the list is displayed").setClass("setting-indent").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.allRootItems).onChange((value) => __async(this, null, function* () {
this.plugin.settings.allRootItems = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Show all list callouts").setDesc("shows all list items marked with List Callouts plugin").setClass("setting-indent").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showListCallouts).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showListCallouts = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Show all time lists").setDesc("shows all list items start with time(- HH:mm )").setClass("setting-indent").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showTimeList).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showTimeList = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
new import_obsidian10.Setting(containerEl).setName("Show tasks").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showElements.task).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showElements.task = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.showElements.task) {
new import_obsidian10.Setting(containerEl).setName("Hide completed tasks").setClass("setting-indent").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.hideCompletedTasks).onChange((value) => __async(this, null, function* () {
this.plugin.settings.hideCompletedTasks = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
new import_obsidian10.Setting(containerEl).setName("Show links in properties").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showPropertyLinks).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showPropertyLinks = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, true, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Show backlink files").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showBacklinks).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showBacklinks = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, true, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Collapse all at startup").setDesc("enable collapse all function at startup").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.collapseAllAtStartup).onChange((value) => __async(this, null, function* () {
this.plugin.settings.collapseAllAtStartup = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, false);
}));
});
new import_obsidian10.Setting(containerEl).setName("Display file information for daily notes").setDesc("choose type of file information to display with the file name for daily notes").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("lines", "lines of the note").addOption("days", "days from base date").addOption("dow", "day of the week").addOption("dowshort", "day of the week(short)").addOption("weeknumber", "week number").addOption("tag", "first tag").setValue(this.plugin.settings.displayFileInfoDaily).onChange((value) => __async(this, null, function* () {
this.plugin.settings.displayFileInfoDaily = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.periodicNotesEnabled) {
new import_obsidian10.Setting(containerEl).setName("Display file information for periodic notes").setDesc("choose type of file information to display for periodic notes other than daily notes").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("lines", "lines of the note").addOption("days", "distance from base date").addOption("tag", "first tag").setValue(this.plugin.settings.displayFileInfoPeriodic).onChange((value) => __async(this, null, function* () {
this.plugin.settings.displayFileInfoPeriodic = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
new import_obsidian10.Setting(containerEl).setName("Position of the plugin view").setDesc("Specify default position where this plugin's view appears").addDropdown((dropdown) => {
dropdown.addOption("right", "right side pane").addOption("left", "left side pane").addOption("tab", "new tab in main pane").addOption("split", "splitted pane").addOption("popout", "popout window").setValue(this.plugin.settings.viewPosition).onChange((value) => __async(this, null, function* () {
this.plugin.settings.viewPosition = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
this.containerEl.createEl("h4", {
text: "Periodic Notes",
cls: "setting-category"
});
if (!app.plugins.plugins["periodic-notes"]) {
this.containerEl.createEl("p", {
text: "Periodic Notes community plugin is not enabled",
cls: "setting-item-description"
});
} else {
const verCheck = Number((_b = app.plugins.plugins["periodic-notes"]) == null ? void 0 : _b.manifest.version.split(".")[0]);
if (verCheck >= 1) {
new import_obsidian10.Setting(containerEl).setName("calendar sets").setDesc("enable calendar sets feature. You have to activate and configure the beta version of the Periodic Notes Plugin first.").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.calendarSetsEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.calendarSetsEnabled = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(true, true, true);
}));
});
}
new import_obsidian10.Setting(containerEl).setName("periodic notes").setDesc("enable weekly/monthly/quarterly/yearly notes. You have to activate and configure the Periodic Notes Plugin first.").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.periodicNotesEnabled).onChange((value) => __async(this, null, function* () {
this.plugin.settings.periodicNotesEnabled = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(true, true, true);
}));
});
if (this.plugin.settings.periodicNotesEnabled) {
this.containerEl.createEl("p", {
text: "Search duration for periodic notes",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("weekly notes").setClass("setting-indent").setDesc("number of weeks to search per page (default = 12)").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.duration.week)).setValue(String(this.plugin.settings.duration.week));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 0 || parsed >= 366) {
parsed = DEFAULT_SETTINGS.duration.week;
}
this.plugin.settings.duration.week = parsed;
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(false, true, true);
});
});
new import_obsidian10.Setting(containerEl).setName("monthly notes").setClass("setting-indent").setDesc("number of months to search per page (default = 12)").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.duration.month)).setValue(String(this.plugin.settings.duration.month));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 0 || parsed >= 366) {
parsed = DEFAULT_SETTINGS.duration.month;
}
this.plugin.settings.duration.month = parsed;
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(false, true, true);
});
});
new import_obsidian10.Setting(containerEl).setName("quarterly notes").setClass("setting-indent").setDesc("number of quarters to search per page (default = 8)").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.duration.quarter)).setValue(String(this.plugin.settings.duration.quarter));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 0 || parsed >= 366) {
parsed = DEFAULT_SETTINGS.duration.quarter;
}
this.plugin.settings.duration.quarter = parsed;
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(false, true, true);
});
});
new import_obsidian10.Setting(containerEl).setName("yearly notes").setClass("setting-indent").setDesc("number of years to search per page (default = 12)").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.duration.year)).setValue(String(this.plugin.settings.duration.year));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 0 || parsed >= 366) {
parsed = DEFAULT_SETTINGS.duration.year;
}
this.plugin.settings.duration.year = parsed;
yield this.plugin.saveSettings();
this.plugin.view.resetSearchRange();
this.plugin.view.refreshView(false, true, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("attach date range to weekly notes").setDesc("display date range next to weekly notes' name").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.attachWeeklyNotesName).onChange((value) => __async(this, null, function* () {
this.plugin.settings.attachWeeklyNotesName = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
this.containerEl.createEl("h4", {
text: "Headings",
cls: "setting-category"
});
if (this.plugin.settings.showElements.heading) {
this.containerEl.createEl("p", {
text: "Heading level to display",
cls: "setting-item-description"
});
this.plugin.settings.headingLevel.forEach((value, index, arry) => {
new import_obsidian10.Setting(containerEl).setName(`Level${index + 1}`).setClass("setting-indent").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.headingLevel[index]).onChange((value2) => __async(this, null, function* () {
this.plugin.settings.headingLevel[index] = value2;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
});
} else {
this.containerEl.createEl("p", {
text: "To display this section, activate 'Show headings' in Basics section.",
cls: "setting-item-description"
});
}
this.containerEl.createEl("h4", {
text: "Preview"
});
new import_obsidian10.Setting(containerEl).setName("Inline preview").setDesc("Show a few subsequent words next to the outline element name").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.inlinePreview).onChange((value) => __async(this, null, function* () {
this.plugin.settings.inlinePreview = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Tooltip preview").setDesc("Show subsequent sentences as a tooltip when hover").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.tooltipPreview).onChange((value) => __async(this, null, function* () {
this.plugin.settings.tooltipPreview = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.tooltipPreview) {
new import_obsidian10.Setting(containerEl).setName("Tooltip preview direction").setClass("setting-indent").setDesc("specify the direction to display tooltip preview").addDropdown((dropdown) => {
dropdown.addOption("left", "left").addOption("right", "right").addOption("bottom", "bottom").addOption("top", "top").setValue(this.plugin.settings.tooltipPreviewDirection).onChange((value) => __async(this, null, function* () {
this.plugin.settings.tooltipPreviewDirection = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
this.containerEl.createEl("h4", {
text: "Popout window",
cls: "setting-category"
});
this.containerEl.createEl("p", {
text: "Popout window size",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Width").setDesc("default & min = 600").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.popoutSize.width)).setValue(String(this.plugin.settings.popoutSize.width));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 600) {
parsed = DEFAULT_SETTINGS.popoutSize.width;
}
this.plugin.settings.popoutSize.width = parsed;
yield this.plugin.saveSettings();
});
});
new import_obsidian10.Setting(containerEl).setName("Height").setDesc("default = 800 min = 600").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.popoutSize.height)).setValue(String(this.plugin.settings.popoutSize.height));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 600) {
parsed = DEFAULT_SETTINGS.popoutSize.height;
}
this.plugin.settings.popoutSize.height = parsed;
yield this.plugin.saveSettings();
});
});
new import_obsidian10.Setting(containerEl).setName("Set popout window always on top").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.popoutAlwaysOnTop).onChange((value) => __async(this, null, function* () {
this.plugin.settings.popoutAlwaysOnTop = value;
this.display();
yield this.plugin.saveSettings();
}));
});
this.containerEl.createEl("h4", {
text: "Simple filter",
cls: "setting-category"
});
if (this.plugin.settings.showElements.heading) {
new import_obsidian10.Setting(containerEl).setName("Headings to ignore").setDesc("Headings which include listed words will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToIgnore.heading.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToIgnore.heading = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.link) {
new import_obsidian10.Setting(containerEl).setName("Links to ignore").setDesc("Links which include listed words will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToIgnore.link.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToIgnore.link = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.tag) {
new import_obsidian10.Setting(containerEl).setName("Tags to ignore").setDesc("tags which include listed words will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToIgnore.tag.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToIgnore.tag = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.listItems) {
new import_obsidian10.Setting(containerEl).setName("List items to ignore").setDesc("List items which include listed words will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToIgnore.listItems.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToIgnore.listItems = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
this.containerEl.createEl("h4", {
text: "Include",
cls: "setting-category"
});
this.containerEl.createEl("p", {
text: "If you specify one outline element type and words to include, only elements which belong to the included elements are displayed.",
cls: "setting-item-description"
});
this.containerEl.createEl("p", {
text: "**NOTE**: If Include filter is set incorrectly, a number of outlines may not be displayed. In such a case, try setting 'Element type for include' to 'no Include filter'.",
cls: "setting-item-description"
});
new import_obsidian10.Setting(containerEl).setName("Element type for include").addDropdown((dropdown) => {
dropdown.addOption("none", "no Include filter").addOption("heading", "heading").addOption("link", "link").addOption("tag", "tag").addOption("listItems", "listItems").setValue(this.plugin.settings.includeOnly).onChange((value) => __async(this, null, function* () {
this.plugin.settings.includeOnly = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.includeOnly != "none") {
new import_obsidian10.Setting(containerEl).setName("Words to include").setClass("setting-indent").setDesc("Only elements specified in 'Element type for include' which include listed words will be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToInclude.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToInclude = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
new import_obsidian10.Setting(containerEl).setName("Include the beginning part").setClass("setting-indent").setDesc("Specify whether to include the beginning parts of each daily note with no element to include ").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.includeBeginning).onChange((value) => __async(this, null, function* () {
this.plugin.settings.includeBeginning = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
this.containerEl.createEl("h4", {
text: "Exclude",
cls: "setting-category"
});
this.containerEl.createEl("p", {
text: "Specified outline elements and elements belonging to that element will not be displayed.",
cls: "setting-item-description"
});
new import_obsidian10.Setting(containerEl).setName("Exclusion ends at").setDesc("Excluding elements specified below ends at the selected type of elements. If you specified 'Element type for include' above, this value is ignored and excludeing elements ends at that type of elements.").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("heading", "heading").addOption("link", "link").addOption("tag", "tag").addOption("listItems", "listItems").setValue(this.plugin.settings.primeElement).onChange((value) => __async(this, null, function* () {
this.plugin.settings.primeElement = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.showElements.heading) {
new import_obsidian10.Setting(containerEl).setName("Headings to exclude").setDesc("Headings which include listed words and elements which belong to them will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToExclude.heading.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToExclude.heading = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.link) {
new import_obsidian10.Setting(containerEl).setName("Links to exclude").setDesc("Links which include listed words and elements which belong to them will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToExclude.link.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToExclude.link = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.tag) {
new import_obsidian10.Setting(containerEl).setName("Tags to exclude").setDesc("tags which include listed words and elements which belong to them will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToExclude.tag.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToExclude.tag = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.listItems) {
new import_obsidian10.Setting(containerEl).setName("List items to exclude").setDesc("List items which include listed words and elements which belong to them will not be displayed. Separate with a new line.").addTextArea((textArea) => {
textArea.setValue(this.plugin.settings.wordsToExclude.listItems.join("\n"));
textArea.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.wordsToExclude.listItems = inputedValue.split("\n");
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
this.containerEl.createEl("h4", {
text: "Appearance",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Wrap outline element text").setDesc("If enabled, long element names are displayed wrapped on multiple lines").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.wrapLine).onChange((value) => __async(this, null, function* () {
this.plugin.settings.wrapLine = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Indentation of outline elements (other than headings)").setDesc("Whether other elements should be indented to preceding headings").addDropdown((dropdown) => {
dropdown.addOption("0", "none").addOption("1", "follow preceding heading").addOption("2", "preceding heading + 1").setValue(String(this.plugin.settings.indentFollowHeading)).onChange((value) => __async(this, null, function* () {
this.plugin.settings.indentFollowHeading = Number(value);
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Note title background color").setDesc("No change: use the current CSS theme setting values. Accent: highlight file names. Custom: Specify any color code. Please update the view when you toggled Obsidian's base theme(light/dark). (default = no change)").addDropdown((dropdown) => {
dropdown.addOption("none", "no change").addOption("accent", "accent").addOption("custom", "custom").setValue(this.plugin.settings.noteTitleBackgroundColor).onChange((value) => __async(this, null, function* () {
this.plugin.settings.noteTitleBackgroundColor = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.noteTitleBackgroundColor == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom note title background color (light)").setClass("setting-indent").setDesc("Specify background color (ex. #FFFFFF or rgb(255,255,255))").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setValue(this.plugin.settings.customNoteTitleBackgroundColor.custom.light);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customNoteTitleBackgroundColor.custom.light = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
new import_obsidian10.Setting(containerEl).setName("Custom note title background color (light, on hover)").setClass("setting-indent").setDesc("Specify background color on hover (ex. #FFFFFF or rgb(255,255,255))").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setValue(this.plugin.settings.customNoteTitleBackgroundColorHover.custom.light);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customNoteTitleBackgroundColorHover.custom.light = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
new import_obsidian10.Setting(containerEl).setName("Custom note title background color (dark)").setClass("setting-indent").setDesc("Specify background color (ex. #FFFFFF or rgb(255,255,255))").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setValue(this.plugin.settings.customNoteTitleBackgroundColor.custom.dark);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customNoteTitleBackgroundColor.custom.dark = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
new import_obsidian10.Setting(containerEl).setName("Custom note title background color (dark, on hover)").setClass("setting-indent").setDesc("Specify background color on hover (ex. #FFFFFF or rgb(255,255,255))").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setValue(this.plugin.settings.customNoteTitleBackgroundColorHover.custom.dark);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customNoteTitleBackgroundColorHover.custom.dark = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.heading) {
this.containerEl.createEl("p", {
text: "Headings",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("hash", "hash").addOption("chevron-right", "chevron-right").addOption("custom", "custom").setValue(this.plugin.settings.icon.heading).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.heading = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.heading == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.heading).setValue(this.plugin.settings.customIcon.heading);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.heading = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.heading).setValue(this.plugin.settings.prefix.heading);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.heading = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
if (this.plugin.settings.prefix.heading != "") {
new import_obsidian10.Setting(containerEl).setName("Repeat heading prefix").setClass("setting-indent-2").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("level", "as many times as its level").addOption("levelminus1", "level - 1").setValue(this.plugin.settings.repeatHeadingPrefix).onChange((value) => __async(this, null, function* () {
this.plugin.settings.repeatHeadingPrefix = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
new import_obsidian10.Setting(containerEl).setName("Add indent").setClass("setting-indent").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.indent.heading).onChange((value) => __async(this, null, function* () {
this.plugin.settings.indent.heading = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
}
if (this.plugin.settings.showElements.link) {
this.containerEl.createEl("p", {
text: "Links",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("link", "link").addOption("link-2", "link-2").addOption("custom", "custom").setValue(this.plugin.settings.icon.link).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.link = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.link == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.link).setValue(this.plugin.settings.customIcon.link);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.link = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.link).setValue(this.plugin.settings.prefix.link);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.link = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.tag) {
this.containerEl.createEl("p", {
text: "Tags",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("tag", "tag").addOption("hash", "hash").addOption("custom", "custom").setValue(this.plugin.settings.icon.tag).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.tag = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.tag == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.tag).setValue(this.plugin.settings.customIcon.tag);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.tag = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.tag).setValue(this.plugin.settings.prefix.tag);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.tag = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showElements.link) {
this.containerEl.createEl("p", {
text: "List items",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("list", "list").addOption("chevron-right", "chevron-right").addOption("minus", "minus").addOption("circle-dot", "circle-dot").addOption("asterisk", "asterisk").addOption("custom", "custom").setValue(this.plugin.settings.icon.listItems).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.listItems = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.listItems == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.listItems).setValue(this.plugin.settings.customIcon.listItems);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.listItems = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.listItems).setValue(this.plugin.settings.prefix.listItems);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.listItems = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
this.containerEl.createEl("p", {
text: "Time lists",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("clock", "clock").addOption("message-square", "message-square").addOption("message-circle", "message-circle").addOption("twitter", "twitter").addOption("custom", "custom").setValue(this.plugin.settings.icon.time).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.time = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.time == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.time).setValue(this.plugin.settings.customIcon.time);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.time = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.time).setValue(this.plugin.settings.prefix.time);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.time = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
this.containerEl.createEl("p", {
text: "Tasks",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("square", "square").addOption("circle", "circle").addOption("list-checks", "list-checks").addOption("custom", "custom").setValue(this.plugin.settings.icon.task).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.task = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.task == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.task).setValue(this.plugin.settings.customIcon.task);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.task = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.task).setValue(this.plugin.settings.prefix.task);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.task = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
new import_obsidian10.Setting(containerEl).setName("Add checkbox text to prefix").setDesc("add [ ] or [x]").setClass("setting-indent").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.addCheckboxText).onChange((value) => __async(this, null, function* () {
this.plugin.settings.addCheckboxText = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
this.containerEl.createEl("p", {
text: "Completed tasks",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("check-square", "check-square").addOption("check-circle", "check-circle").addOption("check", "check").addOption("custom", "custom").setValue(this.plugin.settings.icon.taskDone).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.taskDone = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.taskDone == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.taskDone).setValue(this.plugin.settings.customIcon.taskDone);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.taskDone = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.taskDone).setValue(this.plugin.settings.prefix.taskDone);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.taskDone = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
if (this.plugin.settings.showBacklinks) {
this.containerEl.createEl("p", {
text: "Backlinks",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Icon").setClass("setting-indent").addDropdown((dropdown) => {
dropdown.addOption("none", "none").addOption("links-coming-in", "links-coming-in").addOption("file", "file").addOption("corner-up-left", "corner-up-left").addOption("clock", "clock").addOption("custom", "custom").setValue(this.plugin.settings.icon.backlink).onChange((value) => __async(this, null, function* () {
this.plugin.settings.icon.backlink = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.icon.backlink == "custom") {
new import_obsidian10.Setting(containerEl).setName("Custom icon").setClass("setting-indent-2").setDesc("enter Lucide Icon name").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.customIcon.backlink).setValue(this.plugin.settings.customIcon.backlink);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.customIcon.backlink = inputedValue;
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
new import_obsidian10.Setting(containerEl).setName("Prefix").setClass("setting-indent").addText((text) => {
text.inputEl.setAttr("type", "string");
text.setPlaceholder(DEFAULT_SETTINGS.prefix.backlink).setValue(this.plugin.settings.prefix.backlink);
text.inputEl.onblur = (e) => __async(this, null, function* () {
const inputedValue = e.target.value;
this.plugin.settings.prefix.backlink = inputedValue;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
});
});
}
this.containerEl.createEl("h4", {
text: "Others",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("Show only .md files").setDesc("Turn on if non-md files are displayed in the view").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.markdownOnly).onChange((value) => __async(this, null, function* () {
this.plugin.settings.markdownOnly = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
new import_obsidian10.Setting(containerEl).setName("Show only exactly matched files").setDesc("Turn on if you do not want to see files that do not exactly match the format").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.exactMatchOnly).onChange((value) => __async(this, null, function* () {
this.plugin.settings.exactMatchOnly = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(false, false, true);
}));
});
if (this.plugin.settings.showBacklinks) {
new import_obsidian10.Setting(containerEl).setName("Create daily notes corresponding to unresolved links at startup").setDesc("To detect backlinks to daily notes, at startup, the plugin searches for links to dates and creates the corresponding daily note if one has not been created.").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.checkUnresolvedLinksAtStartup).onChange((value) => __async(this, null, function* () {
this.plugin.settings.checkUnresolvedLinksAtStartup = value;
this.display();
yield this.plugin.saveSettings();
this.plugin.view.refreshView(true, true, true);
}));
});
}
new import_obsidian10.Setting(containerEl).setName("Startup delay time(ms)").setDesc("Wait for the specified time at startup. If daily notes fail to load at startup, increasing this may resolve the issue. (default = 300)").addText((text) => {
text.inputEl.setAttr("type", "number");
text.setPlaceholder(String(DEFAULT_SETTINGS.bootDelayTime)).setValue(String(this.plugin.settings.bootDelayTime));
text.inputEl.onblur = (e) => __async(this, null, function* () {
let parsed = parseInt(e.target.value, 10);
if (parsed <= 0 || parsed >= 2e5) {
parsed = DEFAULT_SETTINGS.bootDelayTime;
}
this.plugin.settings.bootDelayTime = parsed;
yield this.plugin.saveSettings();
});
});
this.containerEl.createEl("h4", {
text: "Debug",
cls: "setting-category"
});
new import_obsidian10.Setting(containerEl).setName("show debug information").setDesc("display debug information in the console").addToggle((toggle) => {
toggle.setValue(this.plugin.settings.showDebugInfo).onChange((value) => __async(this, null, function* () {
this.plugin.settings.showDebugInfo = value;
this.display();
yield this.plugin.saveSettings();
}));
});
}
};
// src/main.ts
var DEFAULT_SETTINGS = {
offset: 7,
onset: "2020-03-30",
duration: {
day: 28,
week: 12,
month: 12,
quarter: 8,
year: 3
},
showElements: {
heading: true,
link: true,
tag: true,
listItems: true,
task: true
},
headingLevel: [true, true, true, false, false, false],
allRootItems: false,
allTasks: true,
taskOnly: false,
hideCompletedTasks: false,
displayFileInfo: "lines",
displayFileInfoDaily: "lines",
displayFileInfoPeriodic: "lines",
viewPosition: "right",
markdownOnly: true,
exactMatchOnly: false,
wordsToIgnore: {
heading: [],
link: [],
tag: [],
listItems: []
},
inlinePreview: true,
tooltipPreview: true,
tooltipPreviewDirection: "left",
includeOnly: "none",
wordsToInclude: [],
includeBeginning: true,
primeElement: "none",
wordsToExclude: {
heading: [],
link: [],
tag: [],
listItems: []
},
wordsToExtract: "",
icon: {
heading: "none",
link: "link",
tag: "tag",
listItems: "list",
note: "file",
task: "square",
taskDone: "check-square",
backlink: "links-coming-in",
time: "clock"
},
customIcon: {
heading: "hash",
link: "link",
tag: "tag",
listItems: "list",
note: "file",
task: "square",
taskDone: "check-square",
backlink: "links-coming-in",
time: "clock"
},
indent: {
heading: true,
link: true,
listItems: true
},
indentFollowHeading: 0,
prefix: {
heading: "",
link: "",
tag: "",
listItems: "",
task: "",
taskDone: "",
backlink: "",
time: ""
},
repeatHeadingPrefix: "none",
addCheckboxText: false,
periodicNotesEnabled: true,
calendarSetsEnabled: true,
attachWeeklyNotesName: true,
showDebugInfo: false,
noteTitleBackgroundColor: "none",
customNoteTitleBackgroundColor: {
accent: {
light: "#E3E3E3",
dark: "#363636"
},
custom: {
light: "#BEBEBE",
dark: "#4E4E4E"
}
},
customNoteTitleBackgroundColorHover: {
accent: {
light: "#D3D3D3",
dark: "#464646"
},
custom: {
light: "#AEAEAE",
dark: "#5E5E5E"
}
},
fileFlag: {},
taskIcon: {
incomplete: { symbol: "/", icon: "columns" },
canceled: { symbol: "-", icon: "minus-square" },
fowarded: { symbol: ">", icon: "send" },
scheduling: { symbol: "<", icon: "calendar" },
question: { symbol: "?", icon: "help-circle" },
important: { symbol: "!", icon: "alert-triangle" },
star: { symbol: "*", icon: "star" },
quote: { symbol: '"', icon: "quote" },
location: { symbol: "l", icon: "map-pin" },
bookmark: { symbol: "b", icon: "bookmark" },
information: { symbol: "i", icon: "info" },
savings: { symbol: "S", icon: "dollar-sign" },
idea: { symbol: "I", icon: "siren" },
pros: { symbol: "p", icon: "thumbs-up" },
cons: { symbol: "c", icon: "thumbs-down" },
fire: { symbol: "f", icon: "flame" },
key: { symbol: "k", icon: "key" },
win: { symbol: "w", icon: "cake" },
up: { symbol: "u", icon: "trending-up" },
down: { symbol: "d", icon: "trending-down" }
},
collapseAllAtStartup: false,
showBacklinks: false,
showPropertyLinks: true,
popoutSize: {
width: 600,
height: 800
},
popoutAlwaysOnTop: false,
showListCallouts: true,
showTimeList: true,
setBaseDateAsHome: false,
checkUnresolvedLinksAtStartup: false,
wrapLine: true,
bootDelayTime: 300
};
var DAYS_PER_UNIT = {
day: 1,
week: 7,
month: 30,
quarter: 90,
year: 365
};
var GRANULARITY_LIST = ["day", "week", "month", "quarter", "year"];
var GRANULARITY_TO_PERIODICITY = {
day: "daily",
week: "weekly",
month: "monthly",
quarter: "quarterly",
year: "yearly"
};
var FILEINFO_TO_DISPLAY = {
none: "none",
lines: "num of lines",
days: "distance",
tag: "first tag"
};
var FILEINFO_TO_DISPLAY_DAY = {
none: "none",
lines: "num of lines",
days: "distance",
tag: "first tag",
dow: "day of week",
dowshort: "day of week(short)",
weeknumber: "week number"
};
var DailyNoteOutlinePlugin3 = class extends import_obsidian11.Plugin {
constructor() {
super(...arguments);
this.checkView = (activateView) => __async(this, null, function* () {
let [leaf] = this.app.workspace.getLeavesOfType(DailyNoteOutlineViewType);
if (!leaf) {
switch (this.settings.viewPosition) {
case "right":
leaf = this.app.workspace.getRightLeaf(false);
break;
case "left":
leaf = this.app.workspace.getLeftLeaf(false);
break;
case "tab":
leaf = this.app.workspace.getLeaf("tab");
break;
case "split":
leaf = this.app.workspace.getLeaf("split");
break;
case "popout":
leaf = this.app.workspace.getLeaf("window");
break;
}
yield leaf.setViewState({ type: DailyNoteOutlineViewType });
}
if (activateView) {
this.app.workspace.revealLeaf(leaf);
}
});
}
onload() {
return __async(this, null, function* () {
yield this.loadSettings();
this.registerView(DailyNoteOutlineViewType, (leaf) => this.view = new DailyNoteOutlineView(leaf, this, this.settings));
this.addCommand({
id: "daily-note-outline-open",
name: "Open Outline",
callback: () => __async(this, null, function* () {
this.checkView(true);
})
});
this.addCommand({
id: "create-dailynote-for-unresolved-links",
name: "Create daily notes for unresolved links",
callback: () => __async(this, null, function* () {
checkUnresolvedLinks.call(this.view);
})
});
this.app.workspace.onLayoutReady(() => __async(this, null, function* () {
this.checkView(false);
}));
this.addSettingTab(new DailyNoteOutlineSettingTab(this.app, this));
});
}
onunload() {
this.app.workspace.detachLeavesOfType(DailyNoteOutlineViewType);
}
loadSettings() {
return __async(this, null, function* () {
this.settings = Object.assign({}, DEFAULT_SETTINGS, yield this.loadData());
if (typeof this.settings.duration === "number") {
this.settings.duration = DEFAULT_SETTINGS.duration;
}
if (!this.settings.icon.hasOwnProperty("backlink")) {
this.settings.icon.backlink = DEFAULT_SETTINGS.icon.backlink;
this.settings.customIcon.backlink = DEFAULT_SETTINGS.customIcon.backlink;
this.settings.prefix.backlink = DEFAULT_SETTINGS.prefix.backlink;
}
if (!this.settings.icon.hasOwnProperty("time")) {
this.settings.icon.time = DEFAULT_SETTINGS.icon.time;
this.settings.customIcon.time = DEFAULT_SETTINGS.customIcon.time;
this.settings.prefix.time = DEFAULT_SETTINGS.prefix.time;
}
if (!this.settings.showElements.hasOwnProperty("task")) {
this.settings.showElements.task = DEFAULT_SETTINGS.showElements.task;
}
});
}
saveSettings() {
return __async(this, null, function* () {
yield this.saveData(this.settings);
});
}
};
/* nosourcemap */