/* 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: () => Prozen }); module.exports = __toCommonJS(main_exports); var import_obsidian = require("obsidian"); var DEFAULT_SETTINGS = { animationDuration: 2, showHeader: false, showScroll: false, showGraphControls: false, forceReadable: true, vignetteOpacity: 0.75, vignetteScaleLinear: 20, vignetteScaleRadial: 75 }; var Prozen = class extends import_obsidian.Plugin { async onload() { await this.loadSettings(); this.addCommand({ id: "zenmode", name: "Zen mode", callback: this.fullscreenMode.bind(this) }); this.addSettingTab(new ProzenSettingTab(this.app, this)); } onunload() { } async loadSettings() { this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); } async saveSettings() { await this.saveData(this.settings); } fullscreenMode() { const leaf = this.app.workspace.getActiveViewOfType(import_obsidian.ItemView).leaf; if (!leaf) return; if (leaf.view.getViewType() === "empty") return; const root = document.documentElement; root.style.setProperty("--fadeIn-duration", this.settings.animationDuration + "s"); root.style.setProperty("--vignette-opacity", this.settings.vignetteOpacity); root.style.setProperty("--vignette-scale-linear", this.settings.vignetteScaleLinear + "%"); root.style.setProperty("--vignette-scale-radial", this.settings.vignetteScaleRadial + "%"); const containerEl = leaf.containerEl; if (!document.fullscreenElement) { containerEl.requestFullscreen(); this.addStyles(leaf); } else { document.exitFullscreen(); this.removeStyles(leaf); } containerEl.onfullscreenchange = () => { if (!document.fullscreenElement) { this.removeStyles(leaf); } }; } addStyles(leaf) { const viewEl = leaf.view.contentEl; const header = leaf.view.headerEl; const isGraph = leaf.view.getViewType() === "graph"; let graphControls; if (isGraph) { graphControls = leaf.view.dataEngine.controlsEl; } if (!this.settings.showScroll) { viewEl.classList.add("noscroll"); } if (isGraph && !this.settings.showGraphControls) { graphControls.classList.add("hide"); } isGraph ? viewEl.classList.add("vignette-radial") : viewEl.classList.add("vignette-linear"); if (!isGraph && this.settings.forceReadable) { leaf.view.editMode.editorEl.classList.add("is-readable-line-width"); } viewEl.classList.add("animate"); this.settings.showHeader ? header.classList.add("animate") : header.classList.add("hide"); } removeStyles(leaf) { const viewEl = leaf.view.contentEl; const header = leaf.view.headerEl; const isGraph = leaf.view.getViewType() === "graph"; let graphControls; if (isGraph) { graphControls = leaf.view.dataEngine.controlsEl; graphControls.classList.remove("animate", "hide"); } else if (!this.app.vault.getConfig("readableLineLength")) { leaf.view.editMode.editorEl.classList.remove("is-readable-line-width"); } viewEl.classList.remove("vignette-linear", "vignette-radial", "animate", "noscroll"); header.classList.remove("animate", "hide"); } }; var ProzenSettingTab = class extends import_obsidian.PluginSettingTab { constructor(app, plugin) { super(app, plugin); this.plugin = plugin; } display() { const { containerEl } = this; containerEl.empty(); this.containerEl.createEl("h3", { text: "Vignette" }); let vignetteOpacityNumber; new import_obsidian.Setting(containerEl).setName("Opacity").setDesc("Intensity of vignette's dimming effect. Set to 0 to turn vignetting off.").addSlider((slider) => slider.setLimits(0, 1, 0.01).setValue(this.plugin.settings.vignetteOpacity).onChange(async (value) => { vignetteOpacityNumber.innerText = " " + value.toString(); this.plugin.settings.vignetteOpacity = value; await this.plugin.saveSettings(); })).settingEl.createDiv("", (el) => { vignetteOpacityNumber = el; el.style.minWidth = "2.0em"; el.style.textAlign = "right"; el.innerText = " " + this.plugin.settings.vignetteOpacity.toString(); }); let vignetteScaleLinearNumber; new import_obsidian.Setting(containerEl).setName("Scale in text views").setDesc("Determines how close to the screen's center vignetting spreads from both sides of the screen, as linear gradients.").addSlider((slider) => slider.setLimits(5, 50, 5).setValue(this.plugin.settings.vignetteScaleLinear).onChange(async (value) => { vignetteScaleLinearNumber.innerText = " " + value.toString(); this.plugin.settings.vignetteScaleLinear = value; await this.plugin.saveSettings(); })).settingEl.createDiv("", (el) => { vignetteScaleLinearNumber = el; el.style.minWidth = "2.0em"; el.style.textAlign = "right"; el.innerText = " " + this.plugin.settings.vignetteScaleLinear.toString(); }); let vignetteScaleRadialNumber; new import_obsidian.Setting(containerEl).setName("Scale in graph view").setDesc("Determines how close to the screen's center vignetting spreads from borders of the screen, as a radial gradient.").addSlider((slider) => slider.setLimits(5, 100, 5).setValue(this.plugin.settings.vignetteScaleRadial).onChange(async (value) => { vignetteScaleRadialNumber.innerText = " " + value.toString(); this.plugin.settings.vignetteScaleRadial = value; await this.plugin.saveSettings(); })).settingEl.createDiv("", (el) => { vignetteScaleRadialNumber = el; el.style.minWidth = "2.0em"; el.style.textAlign = "right"; el.innerText = " " + this.plugin.settings.vignetteScaleRadial.toString(); }); this.containerEl.createEl("h3", { text: "Animation" }); new import_obsidian.Setting(containerEl).setName("Fade-in duration").setDesc("The duration (in seconds) of fade-in animation on entering Zen mode").addText((text) => text.setPlaceholder("1.2").setValue(String(this.plugin.settings.animationDuration)).onChange(async (value) => { this.plugin.settings.animationDuration = Number(value); await this.plugin.saveSettings(); })); this.containerEl.createEl("h3", { text: "Element Toggles" }); new import_obsidian.Setting(containerEl).setName("Show header").setDesc("Show the tab's header in Zen mode").addToggle((toggle) => toggle.setValue(this.plugin.settings.showHeader).onChange(async (value) => { this.plugin.settings.showHeader = value; await this.plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Show scrollbar").setDesc("Show the scrollbar in Zen mode. If it is hidden, scrolling is still available with mousewheel, arrows, touchpad, etc.").addToggle((toggle) => toggle.setValue(this.plugin.settings.showScroll).onChange(async (value) => { this.plugin.settings.showScroll = value; await this.plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Show graph controls").setDesc("Show the graph view's controls in Zen mode").addToggle((toggle) => toggle.setValue(this.plugin.settings.showGraphControls).onChange(async (value) => { this.plugin.settings.showGraphControls = value; await this.plugin.saveSettings(); })); this.containerEl.createEl("h3", { text: "Misc" }); new import_obsidian.Setting(containerEl).setName("Force content centering").setDesc("Center text content in Zen mode, even if in regular view it takes all of the screen's width (ignore 'Editor -> Readable line length' being off in Zen mode)").addToggle((toggle) => toggle.setValue(this.plugin.settings.forceReadable).onChange(async (value) => { this.plugin.settings.forceReadable = value; await this.plugin.saveSettings(); })); } }; /* nosourcemap */