mirror of
https://github.com/zadam/trilium.git
synced 2026-01-01 12:14:24 +01:00
feat(pdfjs): optionally hide left sidebar
This commit is contained in:
parent
c473fba628
commit
eee8d9ab7c
@ -6,7 +6,7 @@ import FBlob from "../../../entities/fblob";
|
||||
import FNote from "../../../entities/fnote";
|
||||
import server from "../../../services/server";
|
||||
import { useViewModeConfig } from "../../collections/NoteList";
|
||||
import { useTriliumOption } from "../../react/hooks";
|
||||
import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";
|
||||
|
||||
const VARIABLE_WHITELIST = new Set([
|
||||
"root-background",
|
||||
@ -25,6 +25,7 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
|
||||
const { onLoad } = useStyleInjection(iframeRef);
|
||||
const historyConfig = useViewModeConfig(note, "pdfHistory");
|
||||
const [ locale ] = useTriliumOption("locale");
|
||||
const [ newLayout ] = useTriliumOptionBool("newLayout");
|
||||
|
||||
useEffect(() => {
|
||||
function handleMessage(event: MessageEvent) {
|
||||
@ -154,7 +155,7 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
|
||||
<iframe
|
||||
ref={iframeRef}
|
||||
class="pdf-preview"
|
||||
src={`pdfjs/web/viewer.html?file=../../api/notes/${note.noteId}/open&lang=${locale}`}
|
||||
src={`pdfjs/web/viewer.html?file=../../api/notes/${note.noteId}/open&lang=${locale}&sidebar=${newLayout ? "0" : "1"}`}
|
||||
onLoad={() => {
|
||||
const win = iframeRef.current?.contentWindow;
|
||||
if (win) {
|
||||
|
||||
@ -12,3 +12,7 @@
|
||||
box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
#toolbarViewerLeft > .toolbarButtonSpacer:first-child {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@ -7,8 +7,12 @@ import { setupPdfLayers } from "./layers";
|
||||
const LOG_EVENT_BUS = false;
|
||||
|
||||
async function main() {
|
||||
console.log("Hi");
|
||||
interceptPersistence(getCustomAppOptions());
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.get("sidebar") === "0") {
|
||||
hideSidebar();
|
||||
}
|
||||
|
||||
interceptPersistence(getCustomAppOptions(urlParams));
|
||||
|
||||
// Wait for the PDF viewer application to be available.
|
||||
while (!window.PDFViewerApplication) {
|
||||
@ -31,14 +35,27 @@ async function main() {
|
||||
await app.initializedPromise;
|
||||
};
|
||||
|
||||
function getCustomAppOptions() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
function hideSidebar() {
|
||||
window.TRILIUM_HIDE_SIDEBAR = true;
|
||||
const toggleButtonEl = document.getElementById("viewsManagerToggleButton");
|
||||
if (toggleButtonEl) {
|
||||
const spacer = toggleButtonEl.nextElementSibling.nextElementSibling;
|
||||
if (spacer.classList.contains("toolbarButtonSpacer")) {
|
||||
spacer.remove();
|
||||
}
|
||||
toggleButtonEl.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function getCustomAppOptions(urlParams: URLSearchParams) {
|
||||
return {
|
||||
localeProperties: {
|
||||
// Read from URL query
|
||||
lang: urlParams.get("lang") || "en"
|
||||
}
|
||||
},
|
||||
// Control sidebar visibility via query parameter
|
||||
// sidebarViewOnLoad: -1 disables sidebar, 0 = NONE (default)
|
||||
viewsManager: null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -18609,7 +18609,7 @@ function getViewerConfiguration() {
|
||||
imageAltTextSettingsSeparator: document.getElementById("imageAltTextSettingsSeparator"),
|
||||
documentPropertiesButton: document.getElementById("documentProperties")
|
||||
},
|
||||
viewsManager: {
|
||||
viewsManager: window.TRILIUM_HIDE_SIDEBAR ? null : {
|
||||
outerContainer: document.getElementById("outerContainer"),
|
||||
toggleButton: document.getElementById("viewsManagerToggleButton"),
|
||||
sidebarContainer: document.getElementById("viewsManager"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user