From 297fc414c2b44bf2e5b402a673ff838de95c31ef Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 7 Mar 2023 16:01:11 +0100 Subject: [PATCH 1/5] prevent auto formatting of external revealjs plugin we import --- .prettierignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..1f650b11b35 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +src/resources/formats/revealjs/plugins/line-highlight/line-highlight.js +src/resources/formats/revealjs/plugins/menu/menu.js +src/resources/formats/revealjs/plugins/menu/quarto-menu.js +src/resources/formats/revealjs/plugins/multiplex/multiplex.js +src/resources/formats/revealjs/plugins/multiplex/socket.io.js +src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js +src/resources/formats/revealjs/plugins/support/support.js +src/resources/formats/revealjs/plugins/tone/tone.js \ No newline at end of file From 2536c8e9e7c40dd2c8f77a5c54b5b6482f09b053 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 7 Mar 2023 16:12:53 +0100 Subject: [PATCH 2/5] Patch PdfExport RevealJS plugin to export toggle function This will enable toggling PDF export mode using API --- src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js b/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js index c399fa9dea5..bf9104c8ec0 100644 --- a/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js +++ b/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js @@ -101,6 +101,9 @@ var PdfExport = ( function( _Reveal ){ Reveal = _Reveal; install(); }; + Plugin.togglePdfExport = function () { + togglePdfExport(); + }; } return Plugin; From 8d3c25c5aebe1c9f121e7f6b2c1280bab9450e52 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 7 Mar 2023 16:17:53 +0100 Subject: [PATCH 3/5] Use exported togglePdfExport function for activating PDF mode from menu and keyboard shortcut --- src/format/reveal/format-reveal-plugin.ts | 2 +- src/resources/formats/revealjs/plugins/menu/quarto-menu.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/format/reveal/format-reveal-plugin.ts b/src/format/reveal/format-reveal-plugin.ts index df635d7b561..c848420e543 100644 --- a/src/format/reveal/format-reveal-plugin.ts +++ b/src/format/reveal/format-reveal-plugin.ts @@ -437,7 +437,7 @@ function revealMenuTools(format: Format) { { title: "PDF Export Mode", key: "e", - handler: "overview", + handler: "togglePdfExport", }, ]; if (format.metadata[kRevealChalkboard]) { diff --git a/src/resources/formats/revealjs/plugins/menu/quarto-menu.js b/src/resources/formats/revealjs/plugins/menu/quarto-menu.js index 1245b0d634f..96740536977 100644 --- a/src/resources/formats/revealjs/plugins/menu/quarto-menu.js +++ b/src/resources/formats/revealjs/plugins/menu/quarto-menu.js @@ -37,4 +37,7 @@ window.RevealMenuToolHandlers = { downloadDrawings: revealMenuToolHandler(function () { RevealChalkboard.download(); }), + togglePdfExport: revealMenuToolHandler(function () { + PdfExport.togglePdfExport(); + }), }; From 91854fcc680e8d13059f6dd6f182c81c32322493 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 7 Mar 2023 17:55:45 +0100 Subject: [PATCH 4/5] Add support for Git patches in update-html-dependencies --- package/src/bld.ts | 4 +-- ...RevealJS-plugin-to-export-toggle-fun.patch | 27 +++++++++++++++++++ .../src/common/update-html-dependencies.ts | 25 ++++++++++++++--- package/src/util/git.ts | 24 +++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 package/src/common/patches/0001-Patch-PdfExport-RevealJS-plugin-to-export-toggle-fun.patch diff --git a/package/src/bld.ts b/package/src/bld.ts index b2f0dfc1425..415003991e9 100644 --- a/package/src/bld.ts +++ b/package/src/bld.ts @@ -10,7 +10,7 @@ import { configure } from "./common/configure.ts"; import { mainRunner } from "../../src/core/main.ts"; import { prepareDist } from "./common/prepare-dist.ts"; -import { updateHtmlDepedencies } from "./common/update-html-dependencies.ts"; +import { updateHtmlDependencies } from "./common/update-html-dependencies.ts"; import { makeInstallerDeb } from "./linux/installer.ts"; import { makeInstallerMac } from "./macos/installer.ts"; import { @@ -64,7 +64,7 @@ function getCommands() { ), ); commands.push( - packageCommand(updateHtmlDepedencies) + packageCommand(updateHtmlDependencies) .name("update-html-dependencies") .description( "Updates Bootstrap, themes, and JS/CSS dependencies based upon the version in configuration", diff --git a/package/src/common/patches/0001-Patch-PdfExport-RevealJS-plugin-to-export-toggle-fun.patch b/package/src/common/patches/0001-Patch-PdfExport-RevealJS-plugin-to-export-toggle-fun.patch new file mode 100644 index 00000000000..d00dd243cf4 --- /dev/null +++ b/package/src/common/patches/0001-Patch-PdfExport-RevealJS-plugin-to-export-toggle-fun.patch @@ -0,0 +1,27 @@ +From cdf668f9b164dca04eece54c88eaed4541211335 Mon Sep 17 00:00:00 2001 +From: Christophe Dervieux +Date: Tue, 7 Mar 2023 16:12:53 +0100 +Subject: [PATCH] Patch PdfExport RevealJS plugin to export toggle function + +This will enable toggling PDF export mode using API +--- + src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js b/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js +index c399fa9de..bf9104c8e 100644 +--- a/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js ++++ b/src/resources/formats/revealjs/plugins/pdfexport/pdfexport.js +@@ -101,6 +101,9 @@ var PdfExport = ( function( _Reveal ){ + Reveal = _Reveal; + install(); + }; ++ Plugin.togglePdfExport = function () { ++ togglePdfExport(); ++ }; + } + + return Plugin; +-- +2.39.2.windows.1 + diff --git a/package/src/common/update-html-dependencies.ts b/package/src/common/update-html-dependencies.ts index c044edfa543..58c9b5ec7dc 100644 --- a/package/src/common/update-html-dependencies.ts +++ b/package/src/common/update-html-dependencies.ts @@ -10,14 +10,14 @@ import { info } from "log/mod.ts"; import { dirname, extname, join } from "path/mod.ts"; import { lines } from "../../../src/core/text.ts"; import { runCmd } from "../util/cmd.ts"; -import { Repo, withRepo } from "../util/git.ts"; +import { applyGitPatches, Repo, withRepo } from "../util/git.ts"; import { download, unzip } from "../util/utils.ts"; import { Configuration } from "./config.ts"; import { visitLines } from "../../../src/core/file.ts"; import { copyMinimal } from "../../../src/core/copy.ts"; -export async function updateHtmlDepedencies(config: Configuration) { +export async function updateHtmlDependencies(config: Configuration) { info("Updating Bootstrap with version info:"); // Read the version information from the environment @@ -57,6 +57,18 @@ export async function updateHtmlDepedencies(config: Configuration) { "dist", ); + // For applying git patch to what we retreive + const patchesDir = join( + config.directoryInfo.pkg, + "src", "common", "patches" + ) + + function resolvePatches (patches: string[]) { + return patches.map(patch => { + return join(patchesDir, patch) + }) + } + // Anchor const anchorJs = join(formatDir, "anchor", "anchor.min.js"); await updateUnpkgDependency( @@ -360,6 +372,7 @@ export async function updateHtmlDepedencies(config: Configuration) { "plugins", "pdfexport", ); + await updateGithubSourceCodeDependency( "reveal-pdfexport", "McShelby/reveal-pdfexport", @@ -374,7 +387,10 @@ export async function updateHtmlDepedencies(config: Configuration) { return Promise.resolve(); }, false, // not a commit - false, // no v prefix + false, // no v prefix, + resolvePatches([ + "0001-Patch-PdfExport-RevealJS-plugin-to-export-toggle-fun.patch" + ]) ); // Github CSS (used for GFM HTML preview) @@ -492,6 +508,7 @@ export async function updateHtmlDepedencies(config: Configuration) { info( "\n** Done- please commit any files that have been updated. **\n", ); + } async function updatePdfJs( @@ -786,6 +803,7 @@ async function updateGithubSourceCodeDependency( onDownload: (dir: string, version: string) => Promise, commit = false, // set to true when commit is used instead of a tag vPrefix = true, // set to false if github tags don't use a v prefix + patches?: string[] ) { info(`Updating ${name}...`); const version = Deno.env.get(versionEnvVar); @@ -805,6 +823,7 @@ async function updateGithubSourceCodeDependency( await unzip(zipFile, working); await onDownload(working, version); + if (patches) await applyGitPatches(patches) } else { throw new Error(`${versionEnvVar} is not defined`); } diff --git a/package/src/util/git.ts b/package/src/util/git.ts index e397f24c5c9..0997edfb23c 100644 --- a/package/src/util/git.ts +++ b/package/src/util/git.ts @@ -1,5 +1,6 @@ import { join } from "path/mod.ts"; import { info } from "log/mod.ts"; +import * as colors from "fmt/colors.ts"; export interface Repo { dir: string; @@ -87,3 +88,26 @@ async function clone(workingDir: string, url: string) { throw Error("No output from git clone"); } } + + +export async function applyGitPatches(patches: string[]) { + if (!patches) return undefined + info(`Applying Git patches...`); + Promise.all( + patches.map( async (patch) => { + info(` - patch ${colors.blue(patch)}`) + const gitCmd: string[] = []; + gitCmd.push("git"); + gitCmd.push("apply"); + gitCmd.push(patch); + const p = Deno.run({ + cmd: gitCmd, + stderr: "piped", + }); + const status = await p.status(); + if (status.code !== 0) { + throw Error("Failed to apply patch"); + } + }) + ) +} \ No newline at end of file From 3e3ddeac2d812d1b17d64a9971963df8e6c84959 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 7 Mar 2023 18:01:15 +0100 Subject: [PATCH 5/5] Remove space in configuration and insure it is trimmed --- configuration | 2 +- package/src/common/update-html-dependencies.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration b/configuration index af17e0cbf27..dcb8520ee1a 100644 --- a/configuration +++ b/configuration @@ -27,7 +27,7 @@ export CLIPBOARD_JS=2.0.11 export TIPPY_JS=6.3.7 export PDF_JS=2.8.335 # Using commit to fix https://github.com/quarto-dev/quarto-cli/issues/2430 - revert to using a release tag when included -export REVEAL_JS=e281b3234e7991283ce4dcca705dd9a6a9ebe5d2 +export REVEAL_JS=e281b3234e7991283ce4dcca705dd9a6a9ebe5d2 export REVEAL_JS_MENU=2.1.0 export REVEAL_JS_CHALKBOARD=a88c134e2cf3c7780448db003e7329c3cbd8cfb4 export REVEAL_JS_PDFEXPORT=2.0.1 diff --git a/package/src/common/update-html-dependencies.ts b/package/src/common/update-html-dependencies.ts index 58c9b5ec7dc..c2108158ee8 100644 --- a/package/src/common/update-html-dependencies.ts +++ b/package/src/common/update-html-dependencies.ts @@ -806,7 +806,7 @@ async function updateGithubSourceCodeDependency( patches?: string[] ) { info(`Updating ${name}...`); - const version = Deno.env.get(versionEnvVar); + const version = Deno.env.get(versionEnvVar)?.trim(); if (version) { const fileName = `${name}.zip`; const distUrl = join(