/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if 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); // main.ts var main_exports = {}; __export(main_exports, { default: () => MenuPlugin }); module.exports = __toCommonJS(main_exports); var import_obsidian = require("obsidian"); var { shell } = require("electron"); var MenuPlugin = class extends import_obsidian.Plugin { async onload() { this.registerMarkdownCodeBlockProcessor("menu", (source, el, ctx) => { const lines = source.trim().split("\n"); let layout = ""; let colors = {}; const links = []; for (const line of lines) { const trimmed = line.trim(); if (trimmed.startsWith("layout:") || trimmed.startsWith("class:")) { const colonIndex = trimmed.indexOf(":"); layout = trimmed.substring(colonIndex + 1).trim(); } else if (trimmed.includes(":") && !trimmed.startsWith("[") && !trimmed.startsWith("[[")) { const [key, ...valueParts] = trimmed.split(":"); const value = valueParts.join(":").trim(); if (key && value && !key.includes("//") && !key.includes("http")) { colors[key.trim()] = value; } } else if (trimmed && !trimmed.includes(":")) { links.push(trimmed); } else if (trimmed.startsWith("[")) { links.push(trimmed); } } const finalLayout = layout || "default"; const container = el.createEl("div", { cls: `menu-container ${finalLayout}` }); if (Object.keys(colors).length > 0) { for (const [key, value] of Object.entries(colors)) { container.style.setProperty(`--${key}`, value); } } for (const link of links) { if (link.startsWith("[[") && link.endsWith("]]")) { const linkContent = link.slice(2, -2); let href = linkContent; let text = linkContent; if (linkContent.includes("|")) { [href, text] = linkContent.split("|"); } const a = container.createEl("a", { text, attr: { "data-href": href } }); a.addClass("menu-internal-link"); } else if (link.match(/^\[.*\]\(.*\)$/)) { const match = link.match(/^\[(.*)\]\((.*)\)$/); if (match) { const text = match[1]; const url = match[2]; const a = container.createEl("a", { text, attr: url.startsWith("file://") ? {} : { href: url, target: "_blank", rel: "noopener noreferrer" } }); a.style.cursor = "pointer"; if (url.startsWith("file://")) { a.addClass("menu-file-link"); } else { a.addClass("menu-external-link"); } a.addEventListener("click", (e) => { e.preventDefault(); if (url.startsWith("file://")) { try { let filePath = decodeURIComponent(url.substring(7)); if (filePath.startsWith("/") && filePath.charAt(2) === ":") { filePath = filePath.substring(1); } console.log("Opening file path:", filePath); shell.openPath(filePath); } catch (error) { console.error("Failed to open file:", error); } } else { window.open(url, "_blank", "noopener,noreferrer"); } }); } } } }); } onunload() { } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = {});