Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
color: var(--gray-600);
}

.wiki-document-eyebrow .sep {
margin: 0 0.4em;
color: var(--gray-400);
}

.wiki-document-title {
margin: 0 0 1rem;
}
Expand Down Expand Up @@ -65,18 +70,45 @@
}

.wiki-document-content blockquote {
margin: 1rem 0;
padding-left: 1rem;
border-left: 3px solid var(--gray-300);
/* Reset Bootstrap defaults (full border + 10px 20px padding) that Frappe's print CSS layers in. */
border: 0;
border-left: 4px solid var(--gray-300);
padding: 0 0 0 1em;
margin: 1.6em 0;
font-size: inherit;
font-style: italic;
font-weight: 500;
color: var(--gray-800);
quotes: "\201C" "\201D" "\2018" "\2019";
}

.wiki-document-content blockquote p {
margin: 0.5em 0;
}

.wiki-document-content blockquote p:first-of-type::before {
content: open-quote;
}

.wiki-document-content blockquote p:last-of-type::after {
content: close-quote;
}
</style>

{% set wiki_space = doc.get_wiki_space() %}
{% set breadcrumbs = doc.get_breadcrumbs() %}
{% set space = breadcrumbs.space %}
{# Skip the first ancestor — it's the wiki space's root group, already represented by the space name. #}
{% set ancestors = breadcrumbs.ancestors[1:] if breadcrumbs.ancestors else [] %}
<div class="page-break">
<div class="wiki-document-shell">
<header class="wiki-document-header">
{% if wiki_space %}
<div class="wiki-document-eyebrow">{{ wiki_space.space_name }}</div>
{% if space or ancestors %}
<div class="wiki-document-eyebrow">
{% if space %}{{ space.space_name }}{% endif %}
{% for ancestor in ancestors %}
<span class="sep">›</span>{{ ancestor.title }}
{% endfor %}
</div>
{% endif %}

<h1 class="wiki-document-title">{{ doc.title }}</h1>
Expand Down
8 changes: 5 additions & 3 deletions wiki/templates/wiki/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ <h1 id="wiki-page-title" class="text-3xl font-semibold text-[var(--ink-gray-9)]"
// wikiDocument properties
copied: false,
downloadInProgress: false,
pageRoute: {{ doc.route | tojson }},

get markdown() {
return this.$store.pageContent?.markdown || '';
Expand All @@ -161,7 +160,10 @@ <h1 id="wiki-page-title" class="text-3xl font-semibold text-[var(--ink-gray-9)]"
if (this.downloadInProgress) return;
this.downloadInProgress = true;

const url = `/api/method/wiki.frappe_wiki.doctype.wiki_document.wiki_document.download_pdf?route=${encodeURIComponent(this.pageRoute)}`;
// Read the route fresh each click — SPA navigation updates window.location
// via history.pushState, so this stays in sync with the visible page.
const route = window.location.pathname.replace(/^\/+/, '');
const url = `/api/method/wiki.frappe_wiki.doctype.wiki_document.wiki_document.download_pdf?route=${encodeURIComponent(route)}`;

try {
const response = await fetch(url, { credentials: 'same-origin' });
Expand All @@ -172,7 +174,7 @@ <h1 id="wiki-page-title" class="text-3xl font-semibold text-[var(--ink-gray-9)]"
const objectUrl = URL.createObjectURL(await response.blob());
const link = document.createElement('a');
link.href = objectUrl;
link.download = `${this.pageRoute.split('/').pop() || 'wiki-document'}.pdf`;
link.download = `${route.split('/').pop() || 'wiki-document'}.pdf`;
document.body.appendChild(link);
link.click();
link.remove();
Expand Down
5 changes: 3 additions & 2 deletions wiki/templates/wiki/macros/buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@
class="absolute left-0 sm:left-auto sm:right-0 mt-10 w-72 bg-[var(--surface-white)] border border-[var(--outline-gray-1)] rounded-lg shadow-lg z-50 py-2">
{% endmacro %}

{# Dropdown row that triggers downloadPage() and reflects the downloadInProgress state. #}
{# Dropdown row that triggers downloadPage() and reflects the downloadInProgress state.
Keeps the dropdown open while preparing the PDF so the loading state stays visible. #}
{% macro download_action_item() %}
<button @click="downloadPage(); open = false"
<button @click="downloadPage().finally(() => open = false)"
:disabled="downloadInProgress"
:aria-busy="downloadInProgress"
class="w-full flex items-start gap-3 px-4 py-3 text-left hover:bg-[var(--surface-gray-1)] transition-colors duration-200 cursor-pointer disabled:cursor-wait disabled:opacity-70">
Expand Down
Loading