/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ "use strict";var y=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var T=(d,i)=>{for(var a in i)y(d,a,{get:i[a],enumerable:!0})},L=(d,i,a,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of E(i))!k.call(d,t)&&t!==a&&y(d,t,{get:()=>i[t],enumerable:!(n=F(i,t))||n.enumerable});return d};var N=d=>L(y({},"__esModule",{value:!0}),d);var M={};T(M,{default:()=>w});module.exports=N(M);var h=require("obsidian");var S=require("obsidian");var u={frames:[],padding:5},C={obsidian:{url:"https://forum.obsidian.md/",displayName:"Obsidian Forum",icon:"edit",hideOnMobile:!0,addRibbonIcon:!0,openInCenter:!0,zoomLevel:1,forceIframe:!1,customCss:"",customJs:""},detexify:{url:"https://detexify.kirelabs.org/classify.html",displayName:"Detexify",icon:"type",hideOnMobile:!0,addRibbonIcon:!0,openInCenter:!1,zoomLevel:.95,forceIframe:!1,customCss:`/* hide info clutter and ad banner */ #classify--info-area, .adsbygoogle { display: none !important }`,customJs:""},calendar:{url:"https://calendar.google.com/calendar",displayName:"Google Calendar",icon:"calendar",hideOnMobile:!0,addRibbonIcon:!0,openInCenter:!0,zoomLevel:1,forceIframe:!1,customCss:`/* hide the menu bar "Calendar" text and remove minimum width */ div[style*="min-width: 238px"] { min-width: 0 !important; padding-right: 0 !important; } div[style*="min-width: 238px"] span[role*="heading"] { display: none !important; }`,customJs:""},keep:{url:"https://keep.google.com",displayName:"Google Keep",icon:"files",hideOnMobile:!0,addRibbonIcon:!1,openInCenter:!1,zoomLevel:1,forceIframe:!1,customCss:`/* hide the menu bar, the "Keep" text and the Google Apps button */ html > body > div:nth-child(2) > div:nth-child(2) > div:first-child, html > body > div:first-child > header:first-child > div > div:first-child > div > div:first-child > a:first-child > span, html > body > div:first-child > header:first-child > div:nth-child(2) > div:first-child > div:first-child, html > body > div:first-child > header:first-child > div:nth-child(2) > div:nth-child(3) > div:first-child > div:first-child > div:first-child { display: none !important; } html > body > div:first-child > header:first-child > div > div:first-child > div > div:first-child > a:first-child { cursor: default; }`,customJs:""},todoist:{url:"https://todoist.com",displayName:"Todoist",icon:"list-checks",hideOnMobile:!0,addRibbonIcon:!1,openInCenter:!1,zoomLevel:1,forceIframe:!1,customCss:`/* hide the help, home, search, and productivity overview buttons, create extra space, and prevent toast pop-up from acting weird */ [aria-label="Go to Home view"], #quick_find, [aria-label="Productivity"], [aria-label="Help & Feedback"] { display: none !important; } .view_content { padding-left: 15px; } .view_header { padding-left: 15px; padding-top: 10px; } .undo_toast { width: 95%; }`,customJs:""},notion:{url:"https://www.notion.so/",displayName:"Notion",icon:"box",hideOnMobile:!0,addRibbonIcon:!0,openInCenter:!0,zoomLevel:1,forceIframe:!1,customCss:"",customJs:""},twitter:{url:"https://twitter.com",displayName:"Twitter",icon:"twitter",hideOnMobile:!0,addRibbonIcon:!1,openInCenter:!1,zoomLevel:1,forceIframe:!1,customCss:"",customJs:""},tasks:{url:"https://tasks.google.com/embed/?origin=https://calendar.google.com&fullWidth=1",displayName:"Google Tasks",icon:"list-checks",hideOnMobile:!0,addRibbonIcon:!1,openInCenter:!1,zoomLevel:1,forceIframe:!1,customCss:"",customJs:""},"readwise-daily-review":{url:"https://readwise.io/dailyreview",displayName:"Readwise Daily Review",icon:"highlighter",hideOnMobile:!0,addRibbonIcon:!1,openInCenter:!1,zoomLevel:1,forceIframe:!1,customCss:`.fixed-nav { display: none !important; }`,customJs:""}};function g(d){return d.icon?`lucide-${d.icon}`:"documents"}function v(d){return d.displayName.toLowerCase().replace(/\s/g,"-")}var m=class{constructor(i,a){this.settings=i,this.data=a}create(i,a,n,t){let s=`padding: ${this.settings.padding}px;`;if(n&&(s+=n),S.Platform.isDesktopApp&&!this.data.forceIframe){let e=a.doc;this.frame=a.createEl("webview"),this.frame.partition="persist:vault-"+i.appId,a.appendChild(this.frame),this.frame.setAttribute("allowpopups",""),this.frame.addEventListener("dom-ready",()=>{this.frame.setZoomFactor(this.data.zoomLevel),this.frame.insertCSS(this.data.customCss),this.frame.executeJavaScript(this.data.customJs)}),this.frame.addEventListener("destroyed",()=>{e!=a.doc&&(this.frame.detach(),this.create(i,a,n,t))})}else this.frame=a.createEl("iframe"),a.appendChild(this.frame),this.frame.setAttribute("sandbox","allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation allow-downloads"),this.frame.setAttribute("allow","encrypted-media; fullscreen; oversized-images; picture-in-picture; sync-xhr; geolocation;"),s+=`transform: scale(${this.data.zoomLevel}); transform-origin: 0 0;`;this.frame.addClass("custom-frames-frame"),this.frame.addClass(`custom-frames-${v(this.data)}`),this.frame.setAttribute("style",s);let o=new URL(this.data.url);if(t){let e=new URL(t,o.origin);e.searchParams.forEach((r,l)=>{o.searchParams.set(l,r)}),e.pathname!=="/"&&(o.pathname+=e.pathname),o.hash=e.hash||o.hash}this.frame.setAttribute("src",o.toString())}refresh(){this.frame instanceof HTMLIFrameElement?this.frame.contentWindow.location.reload():this.frame.reload()}return(){this.frame instanceof HTMLIFrameElement?this.frame.contentWindow.open(this.data.url):this.frame.loadURL(this.data.url)}goBack(){this.frame instanceof HTMLIFrameElement?this.frame.contentWindow.history.back():this.frame.goBack()}goForward(){this.frame instanceof HTMLIFrameElement?this.frame.contentWindow.history.forward():this.frame.goForward()}toggleDevTools(){this.frame instanceof HTMLIFrameElement||(this.frame.isDevToolsOpened()?this.frame.closeDevTools():this.frame.openDevTools())}getCurrentUrl(){return this.frame instanceof HTMLIFrameElement?this.frame.contentWindow.location.href:this.frame.getURL()}focus(){this.frame instanceof HTMLIFrameElement?this.frame.contentWindow.focus():this.frame.focus()}};var c=require("obsidian");var b=class extends c.PluginSettingTab{constructor(i,a){super(i,a),this.plugin=a}display(){this.containerEl.empty();let i=new c.SettingGroup(this.containerEl);i.addSetting(t=>void t.setName(createFragment(s=>s.createSpan({text:"Please note that Obsidian has to be restarted or reloaded for most Custom Frames settings to take effect.",cls:"mod-warning"})))),i.addSetting(t=>void t.setName("Frame padding").setDesc("The padding that should be left around the inside of custom frame panes, in pixels.").addText(s=>{s.inputEl.type="number",s.setValue(String(this.plugin.settings.padding)),s.onChange(async o=>{this.plugin.settings.padding=o.length?Number(o):u.padding,await this.plugin.saveSettings()})}));for(let t of this.plugin.settings.frames){let s=new c.SettingGroup(this.containerEl).setHeading(t.displayName||"Unnamed frame");s.addSetting(o=>void o.setName("Display name").setDesc("The display name that this frame should have.").addText(e=>{e.setValue(t.displayName),e.onChange(async r=>{t.displayName=r,s.setHeading(t.displayName||"Unnamed frame"),await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Icon").setDesc(createFragment(e=>{e.createSpan({text:"The icon that this frame's pane should have. The names of any "}),e.createEl("a",{text:"Lucide icons",href:"https://lucide.dev/"}),e.createSpan({text:" can be used."})})).addText(e=>{e.setValue(t.icon),e.onChange(async r=>{t.icon=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("URL").setDesc("The URL that should be opened in this frame.").addText(e=>{e.setValue(t.url),e.onChange(async r=>{t.url=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Disable on mobile").setDesc("Custom Frames is a lot more restricted on mobile devices and doesn't allow for the same types of content to be displayed. If a frame doesn't work as expected on mobile, it can be disabled.").addToggle(e=>{e.setValue(t.hideOnMobile),e.onChange(async r=>{t.hideOnMobile=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Add ribbon icon").setDesc("Whether a button to open this frame should be added to the ribbon.").addToggle(e=>{e.setValue(t.addRibbonIcon),e.onChange(async r=>{t.addRibbonIcon=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Open in center").setDesc("Whether this frame should be opened in the unpinned center editor rather than one of the panes on the side. This is useful for sites that don't work well in a narrow view, or sites that don't require a note to be open when viewed.").addToggle(e=>{e.setValue(t.openInCenter),e.onChange(async r=>{t.openInCenter=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Force iframe").setDesc(createFragment(e=>{e.createSpan({text:"Whether this frame should use iframes on desktop as opposed to Electron webviews."}),e.createEl("br"),e.createEl("em",{text:"Only enable this setting if the frame is causing issues or frequent crashes. This setting causes all desktop-only settings to be ignored."})})).addToggle(e=>{e.setValue(t.forceIframe),e.onChange(async r=>{t.forceIframe=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Page zoom").setDesc("The zoom that this frame's page should be displayed with, as a percentage.").addText(e=>{e.inputEl.type="number",e.setValue(String(t.zoomLevel*100)),e.onChange(async r=>{t.zoomLevel=r.length?Number(r)/100:1,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Additional CSS").setDesc(createFragment(e=>{e.createSpan({text:"A snippet of additional CSS that should be applied to this frame."}),e.createEl("br"),e.createEl("em",{text:"Note that this is only applied on desktop."})})).addTextArea(e=>{e.inputEl.rows=5,e.inputEl.cols=50,e.setValue(t.customCss),e.onChange(async r=>{t.customCss=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.setName("Additional JavaScript").setDesc(createFragment(e=>{e.createSpan({text:"A snippet of additional JavaScript that should be applied to this frame."}),e.createEl("br"),e.createEl("em",{text:"Note that this is only applied on desktop."})})).addTextArea(e=>{e.inputEl.rows=5,e.inputEl.cols=50,e.setValue(t.customJs),e.onChange(async r=>{t.customJs=r,await this.plugin.saveSettings()})})),s.addSetting(o=>void o.addButton(e=>void e.setButtonText("Remove frame").onClick(async()=>{this.plugin.settings.frames.remove(t),await this.plugin.saveSettings(),this.display()})))}let a=new c.SettingGroup(this.containerEl);a.addSetting(t=>void t.setName(createFragment(s=>{s.createSpan({text:"Please be advised that, when adding a site as a custom frame, you potentially expose personal information you enter to other plugins you have installed. For more information, see the discussion on ",cls:"mod-warning"}),s.createEl("a",{text:"GitHub",href:"https://github.com/Ellpeck/ObsidianCustomFrames/issues/54#issuecomment-1210879685",cls:"mod-warning"}),s.createSpan({text:".",cls:"mod-warning"})})));let n;a.addSetting(t=>void t.setName(`Create a new frame, either from a preset shipped with the plugin, or a custom one that you can edit yourself. Each frame's pane can be opened using the "Custom Frames: Open" command.`).addDropdown(s=>{s.addOption("new","Custom");for(let[o,e]of Object.entries(C).sort((r,l)=>r[1].displayName.localeCompare(l[1].displayName)))s.addOption(o,e.displayName);n=s}).addButton(s=>void s.setButtonText("Add frame").setClass("custom-frames-add").onClick(async()=>{let o=n.getValue();o=="new"?this.plugin.settings.frames.push({url:"",displayName:"New Frame",icon:"",hideOnMobile:!0,addRibbonIcon:!1,openInCenter:!1,zoomLevel:1,forceIframe:!1,customCss:"",customJs:""}):this.plugin.settings.frames.push(C[o]),await this.plugin.saveSettings(),this.display()}))),this.containerEl.createEl("hr"),this.containerEl.createEl("p",{text:"Need help using the plugin? Feel free to join the Discord server!"}),this.containerEl.createEl("a",{href:"https://link.ellpeck.de/discordweb"}).createEl("img",{attr:{src:"https://ellpeck.de/res/discord-wide.png"},cls:"custom-frames-support"}),this.containerEl.createEl("p",{text:"If you like this plugin and want to support its development, you can do so through my website by clicking this fancy image!"}),this.containerEl.createEl("a",{href:"https://ellpeck.de/support"}).createEl("img",{attr:{src:"https://ellpeck.de/res/generalsupport-wide.png"},cls:"custom-frames-support"})}};var x=require("obsidian");var p=class p extends x.ItemView{constructor(i,a,n,t){super(i),this.data=n,this.name=t,this.frame=new m(a,n),this.navigation=n.openInCenter;for(let s of p.actions)this.addAction(s.icon,s.name,()=>s.action(this))}onload(){this.contentEl.empty(),this.contentEl.addClass("custom-frames-view"),this.frame.create(this.app,this.contentEl)}onPaneMenu(i,a){super.onPaneMenu(i,a);for(let n of p.actions)i.addItem(t=>{t.setTitle(n.name),t.setIcon(n.icon),t.onClick(()=>n.action(this))})}getViewType(){return this.name}getDisplayText(){return this.data.displayName}getIcon(){return g(this.data)}focus(){this.frame.focus()}};p.actions=[{name:"Return to original page",icon:"home",action:i=>i.frame.return()},{name:"Open dev tools",icon:"binary",action:i=>i.frame.toggleDevTools()},{name:"Copy link",icon:"link",action:i=>void navigator.clipboard.writeText(i.frame.getCurrentUrl())},{name:"Open in browser",icon:"globe",action:i=>open(i.frame.getCurrentUrl())},{name:"Refresh",icon:"refresh-cw",action:i=>i.frame.refresh()},{name:"Go forward",icon:"arrow-right",action:i=>i.frame.goForward()},{name:"Go back",icon:"arrow-left",action:i=>i.frame.goBack()}];var f=p;var w=class extends h.Plugin{async onload(){await this.loadSettings();for(let i of this.settings.frames){if(!i.url||!i.displayName)continue;let a=`custom-frames-${v(i)}`;if(!(h.Platform.isMobileApp&&i.hideOnMobile))try{this.registerView(a,n=>new f(n,this.settings,i,a)),this.addCommand({id:`open-${a}`,name:`Open ${i.displayName}`,callback:()=>this.openLeaf(a,i.openInCenter,!1)}),i.addRibbonIcon&&this.addRibbonIcon(g(i),`Open ${i.displayName}`,n=>this.openLeaf(a,i.openInCenter,h.Platform.isMacOS?n.metaKey:n.ctrlKey))}catch{console.error(`Couldn't register frame ${a}, is there already one with the same name?`)}}this.addSettingTab(new b(this.app,this)),this.registerMarkdownCodeBlockProcessor("custom-frames",(i,a)=>{a.empty(),a.addClass("custom-frames-view-file");let n=/frame:([^\n]+)/gi.exec(i),t=n&&n[1].trim();if(!t){a.createSpan({text:"Couldn't parse frame name"});return}let s=this.settings.frames.find(I=>I.displayName==t);if(!s){a.createSpan({text:`Couldn't find a frame with name ${t}`});return}if(h.Platform.isMobileApp&&s.hideOnMobile){a.createSpan({text:`${t} is hidden on mobile`});return}let o=/style:([^\n]+)/gi.exec(i),e=o&&o[1].trim();e||="height: 600px;";let r=/urlsuffix:([^\n]+)/gi.exec(i),l=r&&r[1].trim();l||="",new m(this.settings,s).create(this.app,a,e,l)})}async loadSettings(){this.settings=Object.assign({},u,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}async openLeaf(i,a,n){let t;a?(t=this.app.workspace.getLeaf(n),await t.setViewState({type:i,active:!0})):(this.app.workspace.getLeavesOfType(i).length||await this.app.workspace.getRightLeaf(!1).setViewState({type:i,active:!0}),t=this.app.workspace.getLeavesOfType(i)[0],t&&this.app.workspace.revealLeaf(t)),t?.view instanceof f&&t.view.focus()}}; /* nosourcemap */