'use strict'; var obsidian = require('obsidian'); var path = require('path'); var os = require('os'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var obsidian__default = /*#__PURE__*/_interopDefaultLegacy(obsidian); var path__default = /*#__PURE__*/_interopDefaultLegacy(path); const langToMomentLocale = { en: "en-gb", zh: "zh-cn", "zh-TW": "zh-tw", ru: "ru", ko: "ko", it: "it", id: "id", ro: "ro", "pt-BR": "pt-br", cz: "cs", de: "de", es: "es", fr: "fr", no: "nn", pl: "pl", pt: "pt", tr: "tr", hi: "hi", nl: "nl", ar: "ar", ja: "ja", }; async function configureMomentLocale() { var _a; const obsidianLang = localStorage.getItem("language"); const systemLang = (_a = navigator.language) === null || _a === void 0 ? void 0 : _a.toLowerCase(); let momentLocale = langToMomentLocale[obsidianLang]; if (systemLang.startsWith(obsidianLang)) { momentLocale = systemLang; } const currentLocale = window.moment.locale(momentLocale); console.info(`Calendar initialization: Trying to switch Moment.js global locale to ${momentLocale}, got ${currentLocale}`); } const DEFAULT_WEEK_FORMAT = "YYYY-[W]ww"; const DEFAULT_WORDS_PER_DOT = 250; const VIEW_TYPE_CALENDAR = "calendar"; function noop() { } function assign(tar, src) { // @ts-ignore for (const k in src) tar[k] = src[k]; return tar; } function is_promise(value) { return value && typeof value === 'object' && typeof value.then === 'function'; } function run(fn) { return fn(); } function blank_object() { return Object.create(null); } function run_all(fns) { fns.forEach(run); } function is_function(thing) { return typeof thing === 'function'; } function safe_not_equal(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } function is_empty(obj) { return Object.keys(obj).length === 0; } function append(target, node) { target.appendChild(node); } function insert(target, node, anchor) { target.insertBefore(node, anchor || null); } function detach(node) { node.parentNode.removeChild(node); } function destroy_each(iterations, detaching) { for (let i = 0; i < iterations.length; i += 1) { if (iterations[i]) iterations[i].d(detaching); } } function element(name) { return document.createElement(name); } function svg_element(name) { return document.createElementNS('http://www.w3.org/2000/svg', name); } function text(data) { return document.createTextNode(data); } function space() { return text(' '); } function empty() { return text(''); } function listen(node, event, handler, options) { node.addEventListener(event, handler, options); return () => node.removeEventListener(event, handler, options); } function attr(node, attribute, value) { if (value == null) node.removeAttribute(attribute); else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value); } function children(element) { return Array.from(element.childNodes); } function set_data(text, data) { data = '' + data; if (text.wholeText !== data) text.data = data; } function toggle_class(element, name, toggle) { element.classList[toggle ? 'add' : 'remove'](name); } let current_component; function set_current_component(component) { current_component = component; } function get_current_component() { if (!current_component) throw new Error('Function called outside component initialization'); return current_component; } function onDestroy(fn) { get_current_component().$$.on_destroy.push(fn); } const dirty_components = []; const binding_callbacks = []; const render_callbacks = []; const flush_callbacks = []; const resolved_promise = Promise.resolve(); let update_scheduled = false; function schedule_update() { if (!update_scheduled) { update_scheduled = true; resolved_promise.then(flush); } } function add_render_callback(fn) { render_callbacks.push(fn); } let flushing = false; const seen_callbacks = new Set(); function flush() { if (flushing) return; flushing = true; do { // first, call beforeUpdate functions // and update components for (let i = 0; i < dirty_components.length; i += 1) { const component = dirty_components[i]; set_current_component(component); update(component.$$); } set_current_component(null); dirty_components.length = 0; while (binding_callbacks.length) binding_callbacks.pop()(); // then, once components are updated, call // afterUpdate functions. This may cause // subsequent updates... for (let i = 0; i < render_callbacks.length; i += 1) { const callback = render_callbacks[i]; if (!seen_callbacks.has(callback)) { // ...so guard against infinite loops seen_callbacks.add(callback); callback(); } } render_callbacks.length = 0; } while (dirty_components.length); while (flush_callbacks.length) { flush_callbacks.pop()(); } update_scheduled = false; flushing = false; seen_callbacks.clear(); } function update($$) { if ($$.fragment !== null) { $$.update(); run_all($$.before_update); const dirty = $$.dirty; $$.dirty = [-1]; $$.fragment && $$.fragment.p($$.ctx, dirty); $$.after_update.forEach(add_render_callback); } } const outroing = new Set(); let outros; function group_outros() { outros = { r: 0, c: [], p: outros // parent group }; } function check_outros() { if (!outros.r) { run_all(outros.c); } outros = outros.p; } function transition_in(block, local) { if (block && block.i) { outroing.delete(block); block.i(local); } } function transition_out(block, local, detach, callback) { if (block && block.o) { if (outroing.has(block)) return; outroing.add(block); outros.c.push(() => { outroing.delete(block); if (callback) { if (detach) block.d(1); callback(); } }); block.o(local); } } function handle_promise(promise, info) { const token = info.token = {}; function update(type, index, key, value) { if (info.token !== token) return; info.resolved = value; let child_ctx = info.ctx; if (key !== undefined) { child_ctx = child_ctx.slice(); child_ctx[key] = value; } const block = type && (info.current = type)(child_ctx); let needs_flush = false; if (info.block) { if (info.blocks) { info.blocks.forEach((block, i) => { if (i !== index && block) { group_outros(); transition_out(block, 1, 1, () => { info.blocks[i] = null; }); check_outros(); } }); } else { info.block.d(1); } block.c(); transition_in(block, 1); block.m(info.mount(), info.anchor); needs_flush = true; } info.block = block; if (info.blocks) info.blocks[index] = block; if (needs_flush) { flush(); } } if (is_promise(promise)) { const current_component = get_current_component(); promise.then(value => { set_current_component(current_component); update(info.then, 1, info.value, value); set_current_component(null); }, error => { set_current_component(current_component); update(info.catch, 2, info.error, error); set_current_component(null); if (!info.hasCatch) { throw error; } }); // if we previously had a then/catch block, destroy it if (info.current !== info.pending) { update(info.pending, 0); return true; } } else { if (info.current !== info.then) { update(info.then, 1, info.value, promise); return true; } info.resolved = promise; } } function get_spread_update(levels, updates) { const update = {}; const to_null_out = {}; const accounted_for = { $$scope: 1 }; let i = levels.length; while (i--) { const o = levels[i]; const n = updates[i]; if (n) { for (const key in o) { if (!(key in n)) to_null_out[key] = 1; } for (const key in n) { if (!accounted_for[key]) { update[key] = n[key]; accounted_for[key] = 1; } } levels[i] = n; } else { for (const key in o) { accounted_for[key] = 1; } } } for (const key in to_null_out) { if (!(key in update)) update[key] = undefined; } return update; } function get_spread_object(spread_props) { return typeof spread_props === 'object' && spread_props !== null ? spread_props : {}; } function create_component(block) { block && block.c(); } function mount_component(component, target, anchor) { const { fragment, on_mount, on_destroy, after_update } = component.$$; fragment && fragment.m(target, anchor); // onMount happens before the initial afterUpdate add_render_callback(() => { const new_on_destroy = on_mount.map(run).filter(is_function); if (on_destroy) { on_destroy.push(...new_on_destroy); } else { // Edge case - component was destroyed immediately, // most likely as a result of a binding initialising run_all(new_on_destroy); } component.$$.on_mount = []; }); after_update.forEach(add_render_callback); } function destroy_component(component, detaching) { const $$ = component.$$; if ($$.fragment !== null) { run_all($$.on_destroy); $$.fragment && $$.fragment.d(detaching); // TODO null out other refs, including component.$$ (but need to // preserve final state?) $$.on_destroy = $$.fragment = null; $$.ctx = []; } } function make_dirty(component, i) { if (component.$$.dirty[0] === -1) { dirty_components.push(component); schedule_update(); component.$$.dirty.fill(0); } component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { const parent_component = current_component; set_current_component(component); const prop_values = options.props || {}; const $$ = component.$$ = { fragment: null, ctx: null, // state props, update: noop, not_equal, bound: blank_object(), // lifecycle on_mount: [], on_destroy: [], before_update: [], after_update: [], context: new Map(parent_component ? parent_component.$$.context : []), // everything else callbacks: blank_object(), dirty, skip_bound: false }; let ready = false; $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value); if (ready) make_dirty(component, i); } return ret; }) : []; $$.update(); ready = true; run_all($$.before_update); // `false` as a special case of no DOM component $$.fragment = create_fragment ? create_fragment($$.ctx) : false; if (options.target) { if (options.hydrate) { const nodes = children(options.target); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.l(nodes); nodes.forEach(detach); } else { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.c(); } if (options.intro) transition_in(component.$$.fragment); mount_component(component, options.target, options.anchor); flush(); } set_current_component(parent_component); } /** * Base class for Svelte components. Used when dev=false. */ class SvelteComponent { $destroy() { destroy_component(this, 1); this.$destroy = noop; } $on(type, callback) { const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); callbacks.push(callback); return () => { const index = callbacks.indexOf(callback); if (index !== -1) callbacks.splice(index, 1); }; } $set($$props) { if (this.$$set && !is_empty($$props)) { this.$$.skip_bound = true; this.$$set($$props); this.$$.skip_bound = false; } } } const subscriber_queue = []; /** * Create a `Writable` store that allows both updating and reading by subscription. * @param {*=}value initial value * @param {StartStopNotifier=}start start and stop notifications for subscriptions */ function writable(value, start = noop) { let stop; const subscribers = []; function set(new_value) { if (safe_not_equal(value, new_value)) { value = new_value; if (stop) { // store is ready const run_queue = !subscriber_queue.length; for (let i = 0; i < subscribers.length; i += 1) { const s = subscribers[i]; s[1](); subscriber_queue.push(s, value); } if (run_queue) { for (let i = 0; i < subscriber_queue.length; i += 2) { subscriber_queue[i][0](subscriber_queue[i + 1]); } subscriber_queue.length = 0; } } } } function update(fn) { set(fn(value)); } function subscribe(run, invalidate = noop) { const subscriber = [run, invalidate]; subscribers.push(subscriber); if (subscribers.length === 1) { stop = start(set) || noop; } run(value); return () => { const index = subscribers.indexOf(subscriber); if (index !== -1) { subscribers.splice(index, 1); } if (subscribers.length === 0) { stop(); stop = null; } }; } return { set, update, subscribe }; } /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var DEFAULT_DATE_FORMAT = "YYYY-MM-DD"; var DailyNotesFolderMissingError = /** @class */ (function (_super) { __extends(DailyNotesFolderMissingError, _super); function DailyNotesFolderMissingError() { return _super !== null && _super.apply(this, arguments) || this; } return DailyNotesFolderMissingError; }(Error)); function getNotePath(directory, filename) { if (!filename.endsWith(".md")) { filename += ".md"; } return obsidian__default['default'].normalizePath(path__default['default'].join(directory, filename)); } /** * Read the user settings for the `daily-notes` plugin * to keep behavior of creating a new note in-sync. */ function getDailyNoteSettings() { var _a, _b; try { // XXX: Access private API for internal plugins // eslint-disable-next-line @typescript-eslint/no-explicit-any var settings = window.app.internalPlugins.plugins["daily-notes"] .instance.options; return { format: settings.format || DEFAULT_DATE_FORMAT, folder: ((_a = settings.folder) === null || _a === void 0 ? void 0 : _a.trim()) || "", template: ((_b = settings.template) === null || _b === void 0 ? void 0 : _b.trim()) || "", }; } catch (err) { console.info("No custom daily note settings found!", err); } } function appHasDailyNotesPluginLoaded() { var app = window.app; // eslint-disable-next-line @typescript-eslint/no-explicit-any var dailyNotesPlugin = app.internalPlugins.plugins["daily-notes"]; return dailyNotesPlugin && dailyNotesPlugin.enabled; } function getTemplateContents(template) { return __awaiter(this, void 0, void 0, function () { var app, metadataCache, vault, templatePath, templateFile, contents, err_1; return __generator(this, function (_a) { switch (_a.label) { case 0: app = window.app; metadataCache = app.metadataCache, vault = app.vault; templatePath = obsidian__default['default'].normalizePath(template); if (templatePath === "/") { return [2 /*return*/, Promise.resolve("")]; } _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); templateFile = metadataCache.getFirstLinkpathDest(templatePath, ""); return [4 /*yield*/, vault.cachedRead(templateFile)]; case 2: contents = _a.sent(); return [2 /*return*/, contents]; case 3: err_1 = _a.sent(); console.error("Failed to read the daily note template '" + templatePath + "'", err_1); new obsidian__default['default'].Notice("Failed to read the daily note template"); return [2 /*return*/, ""]; case 4: return [2 /*return*/]; } }); }); } /** * This function mimics the behavior of the daily-notes plugin * so it will replace {{date}}, {{title}}, and {{time}} with the * formatted timestamp. * * Note: it has an added bonus that it's not 'today' specific. */ function createDailyNote(date) { return __awaiter(this, void 0, void 0, function () { var app, vault, moment, _a, template, format, folder, templateContents, filename, normalizedPath, createdFile, err_2; return __generator(this, function (_b) { switch (_b.label) { case 0: app = window.app; vault = app.vault; moment = window.moment; _a = getDailyNoteSettings(), template = _a.template, format = _a.format, folder = _a.folder; return [4 /*yield*/, getTemplateContents(template)]; case 1: templateContents = _b.sent(); filename = date.format(format); normalizedPath = getNotePath(folder, filename); _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); return [4 /*yield*/, vault.create(normalizedPath, templateContents .replace(/{{\s*(date|time)\s*:(.*?)}}/gi, function (_, _timeOrDate, momentFormat) { return date.format(momentFormat.trim()); }) .replace(/{{\s*date\s*}}/gi, filename) .replace(/{{\s*time\s*}}/gi, moment().format("HH:mm")) .replace(/{{\s*title\s*}}/gi, filename))]; case 3: createdFile = _b.sent(); return [2 /*return*/, createdFile]; case 4: err_2 = _b.sent(); console.error("Failed to create file: '" + normalizedPath + "'", err_2); new obsidian__default['default'].Notice("Unable to create new file."); return [3 /*break*/, 5]; case 5: return [2 /*return*/]; } }); }); } function getDailyNote(date, dailyNotes) { /** * Look for an exact match filename first, if one doesn't * exist, walk through all the daily notes and find any files * on the same day. */ var vault = window.app.vault; var _a = getDailyNoteSettings(), format = _a.format, folder = _a.folder; var formattedDate = date.format(format); var dailyNotePath = getNotePath(folder, formattedDate); var exactMatch = vault.getAbstractFileByPath(dailyNotePath); if (exactMatch) { return exactMatch; } for (var _i = 0, dailyNotes_1 = dailyNotes; _i < dailyNotes_1.length; _i++) { var dailyNote = dailyNotes_1[_i]; if (dailyNote.date.isSame(date, "day")) { return dailyNote.file; } } return null; } function getAllDailyNotes() { /** * Find all daily notes in the daily note folder */ var moment = window.moment; var vault = window.app.vault; var _a = getDailyNoteSettings(), format = _a.format, folder = _a.folder; var dailyNotesFolder = vault.getAbstractFileByPath(obsidian__default['default'].normalizePath(folder)); if (!dailyNotesFolder) { throw new DailyNotesFolderMissingError("Failed to find daily notes folder"); } var dailyNotes = []; obsidian__default['default'].Vault.recurseChildren(dailyNotesFolder, function (note) { if (note instanceof obsidian__default['default'].TFile) { var noteDate = moment(note.basename, format, true); if (noteDate.isValid()) { dailyNotes.push({ date: noteDate, file: note, }); } } }); return dailyNotes; } var appHasDailyNotesPluginLoaded_1 = appHasDailyNotesPluginLoaded; var createDailyNote_1 = createDailyNote; var getAllDailyNotes_1 = getAllDailyNotes; var getDailyNote_1 = getDailyNote; var getDailyNoteSettings_1 = getDailyNoteSettings; var getTemplateContents_1 = getTemplateContents; function getWeeklyNoteSettings(settings) { return { format: settings.weeklyNoteFormat || DEFAULT_WEEK_FORMAT, folder: settings.weeklyNoteFolder ? settings.weeklyNoteFolder.trim() : "", template: settings.weeklyNoteTemplate ? settings.weeklyNoteTemplate.trim() : "", }; } const SettingsInstance = writable({ shouldConfirmBeforeCreate: true, weekStart: "locale", wordsPerDot: DEFAULT_WORDS_PER_DOT, showWeeklyNote: false, weeklyNoteFormat: "", weeklyNoteTemplate: "", weeklyNoteFolder: "", }); function syncMomentLocaleWithSettings(settings) { const { moment } = window; const currentLocale = moment.locale(); // Save the initial locale weekspec so that we can restore // it when toggling between the different options in settings. if (!window._bundledLocaleWeekSpec) { // eslint-disable-next-line @typescript-eslint/no-explicit-any window._bundledLocaleWeekSpec = moment.localeData()._week; } if (settings.weekStart === "locale") { moment.updateLocale(currentLocale, { week: window._bundledLocaleWeekSpec, }); } else { moment.updateLocale(currentLocale, { week: { dow: settings.weekStart === "monday" ? 1 : 0, }, }); } } class CalendarSettingsTab extends obsidian.PluginSettingTab { constructor(app, plugin) { super(app, plugin); this.plugin = plugin; } display() { this.containerEl.empty(); this.containerEl.createEl("h3", { text: "General Settings", }); this.addDotThresholdSetting(); this.addStartWeekOnMondaySetting(); this.addConfirmCreateSetting(); this.addShowWeeklyNoteSetting(); if (this.plugin.options.showWeeklyNote) { this.containerEl.createEl("h3", { text: "Weekly Note Settings", }); this.addWeeklyNoteFormatSetting(); this.addWeeklyNoteTemplateSetting(); this.addWeeklyNoteFolderSetting(); } if (!appHasDailyNotesPluginLoaded_1()) { this.containerEl.createEl("h3", { text: "⚠️ Daily Notes plugin not enabled", }); this.containerEl.createEl("p", { text: "The calendar is best used in conjunction with the Daily Notes plugin. Enable it in your plugin settings for a more optimal experience.", }); } } addDotThresholdSetting() { new obsidian.Setting(this.containerEl) .setName("Words per dot") .setDesc("How many words should be represented by a single dot?") .addText((textfield) => { textfield.setPlaceholder(String(DEFAULT_WORDS_PER_DOT)); textfield.inputEl.type = "number"; textfield.setValue(String(this.plugin.options.wordsPerDot)); textfield.onChange(async (value) => { this.plugin.writeOptions((old) => (old.wordsPerDot = Number(value))); }); }); } addStartWeekOnMondaySetting() { const { moment } = window; const [sunday, monday] = moment.weekdays(); // eslint-disable-next-line @typescript-eslint/no-explicit-any const localeWeekStartNum = moment.localeData()._week.dow; const localeWeekStart = moment.weekdays()[localeWeekStartNum]; new obsidian.Setting(this.containerEl) .setName("Start week on:") .setDesc("Choose what day of the week to start. Select 'Locale default' to use the default specified by moment.js") .addDropdown((dropdown) => { dropdown.addOption("locale", `Locale default (${localeWeekStart})`); dropdown.addOption("sunday", sunday); dropdown.addOption("monday", monday); dropdown.setValue(this.plugin.options.weekStart); dropdown.onChange(async (value) => { this.plugin.writeOptions((old) => (old.weekStart = value)); }); }); } addConfirmCreateSetting() { new obsidian.Setting(this.containerEl) .setName("Confirm before creating new note") .setDesc("Show a confirmation modal before creating a new note") .addToggle((toggle) => { toggle.setValue(this.plugin.options.shouldConfirmBeforeCreate); toggle.onChange(async (value) => { this.plugin.writeOptions((old) => (old.shouldConfirmBeforeCreate = value)); }); }); } addShowWeeklyNoteSetting() { new obsidian.Setting(this.containerEl) .setName("Show week number") .setDesc("Enable this to add a column with the week number") .addToggle((toggle) => { toggle.setValue(this.plugin.options.showWeeklyNote); toggle.onChange(async (value) => { this.plugin.writeOptions((old) => (old.showWeeklyNote = value)); this.display(); // show/hide weekly settings }); }); } addWeeklyNoteFormatSetting() { new obsidian.Setting(this.containerEl) .setName("Weekly note format") .setDesc("For more syntax help, refer to format reference") .addText((textfield) => { textfield.setValue(this.plugin.options.weeklyNoteFormat); textfield.setPlaceholder(DEFAULT_WEEK_FORMAT); textfield.onChange(async (value) => { this.plugin.writeOptions((old) => (old.weeklyNoteFormat = value)); }); }); } addWeeklyNoteTemplateSetting() { new obsidian.Setting(this.containerEl) .setName("Weekly note template") .setDesc("Choose the file you want to use as the template for your weekly notes") .addText((textfield) => { textfield.setValue(this.plugin.options.weeklyNoteTemplate); textfield.onChange(async (value) => { this.plugin.writeOptions((old) => (old.weeklyNoteTemplate = value)); }); }); } addWeeklyNoteFolderSetting() { new obsidian.Setting(this.containerEl) .setName("Weekly note folder") .setDesc("New weekly notes will be placed here") .addText((textfield) => { textfield.setValue(this.plugin.options.weeklyNoteFolder); textfield.onChange(async (value) => { this.plugin.writeOptions((old) => (old.weeklyNoteFolder = value)); }); }); } } class ConfirmationModal extends obsidian.Modal { constructor(app, config) { super(app); const { cta, onAccept, text, title } = config; this.contentEl.createEl("h2", { text: title }); this.contentEl.createEl("p", { text }); this.contentEl .createEl("button", { text: "Never mind" }) .addEventListener("click", () => this.close()); this.contentEl .createEl("button", { cls: "mod-cta", text: cta, }) .addEventListener("click", async (e) => { await onAccept(e); this.close(); }); } } function createConfirmationDialog({ cta, onAccept, text, title, }) { new ConfirmationModal(window.app, { cta, onAccept, text, title }).open(); } /** * Create a Daily Note for a given date. */ async function tryToCreateDailyNote(date, inNewSplit, settings, cb) { const { workspace } = window.app; const { format } = getDailyNoteSettings_1(); const filename = date.format(format); const createFile = async () => { const dailyNote = await createDailyNote_1(date); const leaf = inNewSplit ? workspace.splitActiveLeaf() : workspace.getUnpinnedLeaf(); await leaf.openFile(dailyNote); cb === null || cb === void 0 ? void 0 : cb(dailyNote); }; if (settings.shouldConfirmBeforeCreate) { createConfirmationDialog({ cta: "Create", onAccept: createFile, text: `File ${filename} does not exist. Would you like to create it?`, title: "New Daily Note", }); } else { await createFile(); } } function getNotePath$1(directory, filename) { if (!filename.endsWith(".md")) { filename += ".md"; } return obsidian.normalizePath(path.join(directory, filename)); } function getDayOfWeekNumericalValue(dayOfWeekName) { const { moment } = window; // eslint-disable-next-line @typescript-eslint/no-explicit-any const weekStart = moment.localeData()._week.dow; const daysOfWeek = [ "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday", ]; return (daysOfWeek.indexOf(dayOfWeekName.toLowerCase()) + weekStart) % 7; } async function createWeeklyNote(date, settings) { const { vault } = window.app; const { template, format, folder } = getWeeklyNoteSettings(settings); const templateContents = await getTemplateContents_1(template); const filename = date.format(format); const normalizedPath = getNotePath$1(folder, filename); try { const createdFile = await vault.create(normalizedPath, templateContents .replace(/{{\s*(date|time)\s*:(.*?)}}/gi, (_, _timeOrDate, momentFormat) => { return date.format(momentFormat.trim()); }) .replace(/{{\s*title\s*}}/gi, filename) .replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi, (_, dayOfWeek, momentFormat) => { const day = getDayOfWeekNumericalValue(dayOfWeek); return date.weekday(day).format(momentFormat.trim()); })); return createdFile; } catch (err) { console.error(`Failed to create file: '${normalizedPath}'`, err); new obsidian.Notice("Unable to create new file."); } } function getWeeklyNote(date, settings) { const { vault } = window.app; const startOfWeek = date.clone().weekday(0); const { format, folder } = getWeeklyNoteSettings(settings); const baseFilename = startOfWeek.format(format); const fullPath = getNotePath$1(folder, baseFilename); return vault.getAbstractFileByPath(fullPath); } /** * Create a Weekly Note for a given date. */ async function tryToCreateWeeklyNote(date, inNewSplit, settings, cb) { const { workspace } = window.app; const { format } = getWeeklyNoteSettings(settings); const filename = date.format(format); const createFile = async () => { const dailyNote = await createWeeklyNote(date, settings); const leaf = inNewSplit ? workspace.splitActiveLeaf() : workspace.getUnpinnedLeaf(); await leaf.openFile(dailyNote); cb === null || cb === void 0 ? void 0 : cb(); }; if (settings.shouldConfirmBeforeCreate) { createConfirmationDialog({ cta: "Create", onAccept: createFile, text: `File ${filename} does not exist. Would you like to create it?`, title: "New Daily Note", }); } else { await createFile(); } } const NUM_MAX_DOTS = 5; function clamp(num, lowerBound, upperBound) { return Math.min(Math.max(lowerBound, num), upperBound); } function getWordCount(text) { const wordChars = /(?:[',.0-9;A-Z_a-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0589\u05D0-\u05EA\u05EF-\u05F2\u060C\u060D\u0620-\u064A\u0660-\u0669\u066C\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07F8\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A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u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2018\u2019\u2024\u203F\u2040\u2044\u2054\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BA\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DB5\u4E00-\u9FEF\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7B9\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\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uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFF1]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|[\u00AD\u2010\u2011]|\u002D(?!\u002D))+/g; return (text.match(wordChars) || []).length; } async function getNumberOfDots(note, settings) { if (!note || settings.wordsPerDot <= 0) { return 0; } const fileContents = await window.app.vault.cachedRead(note); const numDots = getWordCount(fileContents) / settings.wordsPerDot; return clamp(Math.floor(numDots), 1, NUM_MAX_DOTS); } function getNoteTags(note) { var _a; if (!note) { return []; } const { metadataCache } = window.app; const frontmatter = (_a = metadataCache.getFileCache(note)) === null || _a === void 0 ? void 0 : _a.frontmatter; const tags = []; if (frontmatter) { const frontmatterTags = obsidian.parseFrontMatterTags(frontmatter) || []; tags.push(...frontmatterTags); } return tags.map((tag) => tag.substring(1)); } async function getNumberOfRemainingTasks(note) { if (!note) { return 0; } const { vault } = window.app; const fileContents = await vault.cachedRead(note); return (fileContents.match(/(-|\*) \[ \]/g) || []).length; } function isMacOS() { return os.platform() === "darwin"; } function isMetaPressed(e) { return isMacOS() ? e.metaKey : e.ctrlKey; } function getDaysOfWeek(_settings) { return window.moment.weekdaysShort(true); } function isWeekend(date) { return date.isoWeekday() === 6 || date.isoWeekday() === 7; } function getStartOfWeek(days, _weekNum) { return days[0].date.weekday(0); } /** * Generate a 2D array of daily information to power * the calendar view. */ function getMonthData(activeFile, displayedMonth, settings) { const month = []; let week; let dailyNotes = []; try { dailyNotes = getAllDailyNotes_1(); console.log("dailynotes", dailyNotes); } catch (err) { new obsidian.Notice(err); } const startOfMonth = displayedMonth.clone().date(1); const startOffset = startOfMonth.weekday(); let date = startOfMonth.clone().subtract(startOffset, "days"); for (let _day = 0; _day < 42; _day++) { if (_day % 7 === 0) { week = { days: [], weekNum: date.week(), weeklyNote: getWeeklyNote(date, settings), }; month.push(week); } const note = getDailyNote_1(date, dailyNotes); week.days.push({ date, note, isActive: activeFile && activeFile === (note === null || note === void 0 ? void 0 : note.basename), numDots: getNumberOfDots(note, settings), numTasksRemaining: getNumberOfRemainingTasks(note), tags: getNoteTags(note), }); date = date.clone().add(1, "days"); } return month; } /* src/ui/Day.svelte generated by Svelte v3.31.0 */ function add_css() { var style = element("style"); style.id = "svelte-xik4h1-style"; style.textContent = ".day.svelte-xik4h1.svelte-xik4h1{background-color:var(--color-background-day);border-radius:4px;color:var(--color-text-day);cursor:pointer;font-size:0.8em;height:100%;padding:4px;position:relative;text-align:center;transition:background-color 0.1s ease-in, color 0.1s ease-in;vertical-align:baseline}.day.svelte-xik4h1.svelte-xik4h1:hover{background-color:var(--interactive-hover)}.day.active.svelte-xik4h1.svelte-xik4h1:hover{background-color:var(--interactive-accent-hover)}.adjacent-month.svelte-xik4h1.svelte-xik4h1{opacity:0.25}.today.svelte-xik4h1.svelte-xik4h1{color:var(--color-text-today)}.active.svelte-xik4h1.svelte-xik4h1,.active.today.svelte-xik4h1.svelte-xik4h1{color:var(--text-on-accent);background-color:var(--interactive-accent)}.dot-container.svelte-xik4h1.svelte-xik4h1{display:flex;flex-wrap:wrap;justify-content:center;line-height:6px;min-height:6px}.dot.svelte-xik4h1.svelte-xik4h1,.task.svelte-xik4h1.svelte-xik4h1{display:inline-block;fill:var(--color-dot);height:6px;width:6px;margin:0 1px}.active.svelte-xik4h1 .dot.svelte-xik4h1{fill:var(--text-on-accent)}.task.svelte-xik4h1.svelte-xik4h1{fill:none;stroke:var(--color-dot)}.active.svelte-xik4h1 .task.svelte-xik4h1{stroke:var(--text-on-accent)}"; append(document.head, style); } function get_each_context(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[15] = list[i]; return child_ctx; } // (1:0)