update
This commit is contained in:
parent
b231c8422b
commit
63078612b1
3 changed files with 44 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "the-fold-within",
|
"name": "the-fold-within",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pdf-parse": "^1.1.1"
|
"pdf-parse": "^1.1.1"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -256,23 +256,40 @@ async function renderMarkdown(rel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderIframe(rel) {
|
function renderIframe(rel) {
|
||||||
|
const viewer = els.viewer;
|
||||||
|
const container = document.createElement("div");
|
||||||
|
container.className = "preview-wrapper";
|
||||||
|
|
||||||
|
const header = document.createElement("div");
|
||||||
|
header.className = "preview-header";
|
||||||
|
header.innerHTML = `<button class="popout-btn" data-src="${rel}">Open Full View ↗</button>`;
|
||||||
|
|
||||||
const iframe = document.createElement("iframe");
|
const iframe = document.createElement("iframe");
|
||||||
iframe.src = "/" + rel;
|
iframe.src = "/" + rel;
|
||||||
iframe.loading = "eager";
|
iframe.loading = "eager";
|
||||||
iframe.setAttribute("sandbox", "allow-same-origin allow-scripts allow-forms");
|
iframe.setAttribute("sandbox", "allow-same-origin allow-scripts allow-forms");
|
||||||
els.viewer.appendChild(iframe);
|
|
||||||
|
container.appendChild(header);
|
||||||
|
container.appendChild(iframe);
|
||||||
|
viewer.appendChild(container);
|
||||||
|
|
||||||
|
header.querySelector(".popout-btn").addEventListener("click", e => {
|
||||||
|
const url = e.target.dataset.src.startsWith("/") ? e.target.dataset.src : "/" + e.target.dataset.src;
|
||||||
|
window.open(url, "_blank", "noopener,noreferrer");
|
||||||
|
});
|
||||||
|
|
||||||
iframe.onload = () => {
|
iframe.onload = () => {
|
||||||
try {
|
try {
|
||||||
const doc = iframe.contentDocument;
|
const doc = iframe.contentDocument;
|
||||||
const style = doc.createElement("style");
|
const style = doc.createElement("style");
|
||||||
style.textContent = `
|
style.textContent = `
|
||||||
html,body{background:#0b0b0b;color:#e6e3d7;font-family:Inter,sans-serif;margin:0;padding:2rem;}
|
html,body{background:#0b0b0b;color:#e6e3d7;font-family:Inter,sans-serif;
|
||||||
|
margin:0;padding:2rem;}
|
||||||
*{max-width:720px;margin:auto;}
|
*{max-width:720px;margin:auto;}
|
||||||
img, video, iframe {max-width:100%;height:auto;}
|
img,video,iframe{max-width:100%;height:auto;}
|
||||||
`;
|
`;
|
||||||
doc.head.appendChild(style);
|
doc.head.appendChild(style);
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -195,3 +195,25 @@ body.sidebar-open #sidebar { transform: translateX(0); }
|
||||||
border: 0; border-radius: var(--radius); background: transparent;
|
border: 0; border-radius: var(--radius); background: transparent;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* === POP-OUT PREVIEW === */
|
||||||
|
.preview-header {
|
||||||
|
text-align: right;
|
||||||
|
background: rgba(224,184,75,0.08);
|
||||||
|
border-bottom: 1px solid #333;
|
||||||
|
padding: .4rem 1rem;
|
||||||
|
}
|
||||||
|
.popout-btn {
|
||||||
|
background: none;
|
||||||
|
border: 1px solid var(--accent);
|
||||||
|
color: var(--accent);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: .25rem .6rem;
|
||||||
|
font-size: .85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all .25s ease;
|
||||||
|
}
|
||||||
|
.popout-btn:hover {
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue