Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245/*THIS IS A GENERATED/BUNDLED FILE BY ESBUILDif you want to view the source, please visit the github repository of this plugin*/
var __defProp = Object.defineProperty;var __getOwnPropDesc = Object.getOwnPropertyDescriptor;var __getOwnPropNames = Object.getOwnPropertyNames;var __hasOwnProp = Object.prototype.hasOwnProperty;var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true });};var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to;};var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/main.jsvar main_exports = {};__export(main_exports, { AblazeModal: () => AblazeModal, default: () => Ablaze});module.exports = __toCommonJS(main_exports);var import_obsidian = require("obsidian");
// templates.jsonvar templates_default = [ { name: "Entity", color: "#000", icon: "\u26AB\uFE0F", tag: "entity", id: "5445-a8c0" }, { name: "Reference", color: "#4c9fcf", icon: "\u{1F4D8}", tag: "reference", id: "5262-2367" }, { name: "Notion", color: "#ff6c08", icon: "\u{1F4D2}", tag: "notions", id: "43c5-942b" }, { name: "Idea", color: "#3cc722", icon: "\u{1F4D7}", tag: "ideas", id: "1446-7f74" }, { name: "Project", color: "#000", icon: "\u2728", tag: "projects", id: "55df-b26a" }, { name: "Blog", color: "#5b84b1", icon: "\u24C7", tag: "blog", id: "9f52-2843" }, { name: "Document", color: "#6e05c1", icon: "\u{1F47E}", tag: "document", id: "e01c-2aa4" }, { name: "Admin", color: "#900", icon: "\u{1F479}", tag: "admin", id: "e612-399b" }, { name: "Personal", color: "#d372ff", icon: "\u{1FAA9}", tag: "personal", id: "8ff9-5ce6" }];
// src/main.jsvar VIEW_NAME = "ablaze-view";var Ablaze = class extends import_obsidian.Plugin { async onload() { this.registerView(VIEW_NAME, (leaf) => new AblazeView(leaf, this)); this.addRibbonIcon("book-template", "Open Ablaze", () => this.activateView()); this.addCommand({ id: "open-view", name: "Open panel", callback: () => this.activateView() }); } // Runs once, when the user first enables the plugin; after that the // workspace remembers the leaf across restarts. async onUserEnable() { await this.activateView(); } async activateView() { const { workspace } = this.app; let leaf = workspace.getLeavesOfType(VIEW_NAME)[0]; if (!leaf) { leaf = workspace.getRightLeaf(false); if (!leaf) return; await leaf.setViewState({ type: VIEW_NAME, active: true }); } await workspace.revealLeaf(leaf); }};var AblazeView = class extends import_obsidian.ItemView { constructor(leaf, plugin) { super(leaf); this.plugin = plugin; } async onOpen() { this.contentEl.empty(); this.contentEl.addClass("ablaze-root"); const container = this.contentEl.createEl("div", { cls: "ablaze-tmpl-container" }); templates_default.forEach((data) => { const { name, color, icon } = data; const but = container.createEl("button", { text: `${icon} ${name}` }); but.style.color = color; but.onclick = () => new AblazeModal(this.app, data).open(); }); this.contentEl.createEl("div", { cls: "ablaze-version", text: `v${this.plugin.manifest.version}` }); } getViewType() { return VIEW_NAME; } getDisplayText() { return "Ablaze"; } getIcon() { return "book-template"; }};var AblazeModal = class extends import_obsidian.Modal { constructor(app, data) { super(app); this.data = data; } onOpen() { let exists = false, filename = ""; const { contentEl } = this; const h1 = contentEl.createEl("h1", { text: `${this.data.icon} ` }); h1.style.color = this.data.color; const input = h1.createEl("input", { cls: "ablaze-new-name" }); input.placeholder = this.data.name; if (this.data.tag === "personal") input.value = today(); input.focus(); const actions = contentEl.createEl("div", { cls: "ablaze-actions" }); const ok = actions.createEl("button", { text: "Ok" }); contentEl.createEl("span", { text: "file: " }); const status = contentEl.createEl("code"); let markdowns = this.app.vault.getMarkdownFiles(); const refresh = () => { filename = `${sanitize(input.value)}.md`; exists = !!markdowns.find((f) => f.name === filename); status.textContent = filename; status.style.color = exists ? "var(--text-error)" : "var(--text-normal)"; }; const handleDone = async () => { if (exists || !input.value) { markdowns = this.app.vault.getMarkdownFiles(); refresh(); return; } const md = makeNewMD(input.value, this.data); const newMD = await this.app.vault.create(filename, md); this.app.workspace.getLeaf("tab").openFile(newMD); this.close(); }; ok.onclick = handleDone; input.onkeyup = async (ev) => { refresh(); if (ev.key === "Enter") await handleDone(); }; refresh(); } onClose() { const { contentEl } = this; contentEl.empty(); }};function sanitize(str) { return (str || "").replace(/[:/"]/g, "_");}function today() { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;}function makeNewMD(title, data) { let front = ""; let extraTag = ""; if (data.tag === "reference") { extraTag = "article"; front = `author: []url: ""`; } else if (data.tag === "blog") { front = `lang: enimage: ""imageDescription: tkstatus: draftpublication: 2077-03-15description: "tk"slug: tk-tkbodyType: obsidiansubtitle: tk`; } else if (data.tag === "personal") { front = `date: ${today()}`; } const tags = [data.tag]; if (extraTag) tags.push(extraTag); return `---${front}tags: [${tags.join(", ")}]---# ${title}`;}