Skip to content

Commit 891e82b

Browse files
authored
Merge pull request #4676 from quarto-dev/revealjs/pdf-export-button
Fix Pdf Export mode menu button and keyboard shortcut
2 parents ccabe04 + 3e3ddea commit 891e82b

File tree

9 files changed

+92
-8
lines changed

9 files changed

+92
-8
lines changed

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
src/resources/formats/revealjs/plugins/line-highlight/line-highlight.js
2+
src/resources/formats/revealjs/plugins/menu/menu.js
3+
src/resources/formats/revealjs/plugins/menu/quarto-menu.js
4+
src/resources/formats/revealjs/plugins/multiplex/multiplex.js
5+
src/resources/formats/revealjs/plugins/multiplex/socket.io.js
6+
src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js
7+
src/resources/formats/revealjs/plugins/support/support.js
8+
src/resources/formats/revealjs/plugins/tone/tone.js

configuration

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export CLIPBOARD_JS=2.0.11
2727
export TIPPY_JS=6.3.7
2828
export PDF_JS=2.8.335
2929
# Using commit to fix https://github.com/quarto-dev/quarto-cli/issues/2430 - revert to using a release tag when included
30-
export REVEAL_JS=e281b3234e7991283ce4dcca705dd9a6a9ebe5d2
30+
export REVEAL_JS=e281b3234e7991283ce4dcca705dd9a6a9ebe5d2
3131
export REVEAL_JS_MENU=2.1.0
3232
export REVEAL_JS_CHALKBOARD=a88c134e2cf3c7780448db003e7329c3cbd8cfb4
3333
export REVEAL_JS_PDFEXPORT=2.0.1

package/src/bld.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { configure } from "./common/configure.ts";
1010
import { mainRunner } from "../../src/core/main.ts";
1111

1212
import { prepareDist } from "./common/prepare-dist.ts";
13-
import { updateHtmlDepedencies } from "./common/update-html-dependencies.ts";
13+
import { updateHtmlDependencies } from "./common/update-html-dependencies.ts";
1414
import { makeInstallerDeb } from "./linux/installer.ts";
1515
import { makeInstallerMac } from "./macos/installer.ts";
1616
import {
@@ -64,7 +64,7 @@ function getCommands() {
6464
),
6565
);
6666
commands.push(
67-
packageCommand(updateHtmlDepedencies)
67+
packageCommand(updateHtmlDependencies)
6868
.name("update-html-dependencies")
6969
.description(
7070
"Updates Bootstrap, themes, and JS/CSS dependencies based upon the version in configuration",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From cdf668f9b164dca04eece54c88eaed4541211335 Mon Sep 17 00:00:00 2001
2+
From: Christophe Dervieux <[email protected]>
3+
Date: Tue, 7 Mar 2023 16:12:53 +0100
4+
Subject: [PATCH] Patch PdfExport RevealJS plugin to export toggle function
5+
6+
This will enable toggling PDF export mode using API
7+
---
8+
src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js | 3 +++
9+
1 file changed, 3 insertions(+)
10+
11+
diff --git a/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js b/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js
12+
index c399fa9de..bf9104c8e 100644
13+
--- a/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js
14+
+++ b/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js
15+
@@ -101,6 +101,9 @@ var PdfExport = ( function( _Reveal ){
16+
Reveal = _Reveal;
17+
install();
18+
};
19+
+ Plugin.togglePdfExport = function () {
20+
+ togglePdfExport();
21+
+ };
22+
}
23+
24+
return Plugin;
25+
--
26+
2.39.2.windows.1
27+

package/src/common/update-html-dependencies.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import { info } from "log/mod.ts";
1010
import { dirname, extname, join } from "path/mod.ts";
1111
import { lines } from "../../../src/core/text.ts";
1212
import { runCmd } from "../util/cmd.ts";
13-
import { Repo, withRepo } from "../util/git.ts";
13+
import { applyGitPatches, Repo, withRepo } from "../util/git.ts";
1414

1515
import { download, unzip } from "../util/utils.ts";
1616
import { Configuration } from "./config.ts";
1717
import { visitLines } from "../../../src/core/file.ts";
1818
import { copyMinimal } from "../../../src/core/copy.ts";
1919

20-
export async function updateHtmlDepedencies(config: Configuration) {
20+
export async function updateHtmlDependencies(config: Configuration) {
2121
info("Updating Bootstrap with version info:");
2222

2323
// Read the version information from the environment
@@ -57,6 +57,18 @@ export async function updateHtmlDepedencies(config: Configuration) {
5757
"dist",
5858
);
5959

60+
// For applying git patch to what we retreive
61+
const patchesDir = join(
62+
config.directoryInfo.pkg,
63+
"src", "common", "patches"
64+
)
65+
66+
function resolvePatches (patches: string[]) {
67+
return patches.map(patch => {
68+
return join(patchesDir, patch)
69+
})
70+
}
71+
6072
// Anchor
6173
const anchorJs = join(formatDir, "anchor", "anchor.min.js");
6274
await updateUnpkgDependency(
@@ -360,6 +372,7 @@ export async function updateHtmlDepedencies(config: Configuration) {
360372
"plugins",
361373
"pdfexport",
362374
);
375+
363376
await updateGithubSourceCodeDependency(
364377
"reveal-pdfexport",
365378
"McShelby/reveal-pdfexport",
@@ -374,7 +387,10 @@ export async function updateHtmlDepedencies(config: Configuration) {
374387
return Promise.resolve();
375388
},
376389
false, // not a commit
377-
false, // no v prefix
390+
false, // no v prefix,
391+
resolvePatches([
392+
"0001-Patch-PdfExport-RevealJS-plugin-to-export-toggle-fun.patch"
393+
])
378394
);
379395

380396
// Github CSS (used for GFM HTML preview)
@@ -492,6 +508,7 @@ export async function updateHtmlDepedencies(config: Configuration) {
492508
info(
493509
"\n** Done- please commit any files that have been updated. **\n",
494510
);
511+
495512
}
496513

497514
async function updatePdfJs(
@@ -786,9 +803,10 @@ async function updateGithubSourceCodeDependency(
786803
onDownload: (dir: string, version: string) => Promise<void>,
787804
commit = false, // set to true when commit is used instead of a tag
788805
vPrefix = true, // set to false if github tags don't use a v prefix
806+
patches?: string[]
789807
) {
790808
info(`Updating ${name}...`);
791-
const version = Deno.env.get(versionEnvVar);
809+
const version = Deno.env.get(versionEnvVar)?.trim();
792810
if (version) {
793811
const fileName = `${name}.zip`;
794812
const distUrl = join(
@@ -805,6 +823,7 @@ async function updateGithubSourceCodeDependency(
805823
await unzip(zipFile, working);
806824

807825
await onDownload(working, version);
826+
if (patches) await applyGitPatches(patches)
808827
} else {
809828
throw new Error(`${versionEnvVar} is not defined`);
810829
}

package/src/util/git.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { join } from "path/mod.ts";
22
import { info } from "log/mod.ts";
3+
import * as colors from "fmt/colors.ts";
34

45
export interface Repo {
56
dir: string;
@@ -87,3 +88,26 @@ async function clone(workingDir: string, url: string) {
8788
throw Error("No output from git clone");
8889
}
8990
}
91+
92+
93+
export async function applyGitPatches(patches: string[]) {
94+
if (!patches) return undefined
95+
info(`Applying Git patches...`);
96+
Promise.all(
97+
patches.map( async (patch) => {
98+
info(` - patch ${colors.blue(patch)}`)
99+
const gitCmd: string[] = [];
100+
gitCmd.push("git");
101+
gitCmd.push("apply");
102+
gitCmd.push(patch);
103+
const p = Deno.run({
104+
cmd: gitCmd,
105+
stderr: "piped",
106+
});
107+
const status = await p.status();
108+
if (status.code !== 0) {
109+
throw Error("Failed to apply patch");
110+
}
111+
})
112+
)
113+
}

src/format/reveal/format-reveal-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ function revealMenuTools(format: Format) {
437437
{
438438
title: "PDF Export Mode",
439439
key: "e",
440-
handler: "overview",
440+
handler: "togglePdfExport",
441441
},
442442
];
443443
if (format.metadata[kRevealChalkboard]) {

src/resources/formats/revealjs/plugins/menu/quarto-menu.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ window.RevealMenuToolHandlers = {
3737
downloadDrawings: revealMenuToolHandler(function () {
3838
RevealChalkboard.download();
3939
}),
40+
togglePdfExport: revealMenuToolHandler(function () {
41+
PdfExport.togglePdfExport();
42+
}),
4043
};

src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ var PdfExport = ( function( _Reveal ){
101101
Reveal = _Reveal;
102102
install();
103103
};
104+
Plugin.togglePdfExport = function () {
105+
togglePdfExport();
106+
};
104107
}
105108

106109
return Plugin;

0 commit comments

Comments
 (0)