Skip to content

Commit 1dc93a9

Browse files
authored
Merge pull request #11034 from quarto-dev/revealjs/scroll-view
2 parents fc232ee + 3ccdfd4 commit 1dc93a9

15 files changed

Lines changed: 471 additions & 23 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"deno.enable": true,
1616
"deno.lint": true,
1717
"deno.unstable": true,
18-
"deno.importMap": "./src/import_map.json"
18+
"deno.importMap": "./src/import_map.json",
19+
"deno.disablePaths": ["tests/integration/playwright/"]
1920
}

news/changelog-1.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ All changes included in 1.6:
3434

3535
- Update to Reveal JS 5.1.0.
3636
- Support for a [Jump To Slide](https://revealjs.com/jump-to-slide/) menu to quickly navigate between slides. Set `jump-to-slide: false` to opt out.
37+
- Support for new [Scroll View](https://revealjs.com/scroll-view/) mode with configuration through new `scroll-view` revealjs's format configuration key. A new menu tool has been added to toggle scroll view mode on and off, associated with `R` key by default.
3738
- Prevent empty SASS built css file to be included in header.
3839
- Remove wrong `sourceMappingUrl` entry in SASS built css.
3940
- ([#7715](https://github.com/quarto-dev/quarto-cli/issues/7715)): Revealjs don't support anymore special Pandoc syntax making BulletList in Blockquotes become incremental list. This was confusing and unexpected behavior. Supported syntax for incremental list is documented at <https://quarto.org/docs/presentations/revealjs/#incremental-lists>.

src/format/reveal/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@ export const kAutoAnimateUnmatched = "autoAnimateUnmatched";
2424
export const kAutoStretch = "auto-stretch";
2525
export const kCodeBlockHeight = "code-block-height";
2626
export const kJumpToSlide = "jumpToSlide";
27+
// scroll view configurations - https://revealjs.com/scroll-view/
28+
export const kScrollView = "scroll-view";
29+
export const kView = "view";
30+
export const kScrollProgress = "scrollProgress";
31+
export const kScrollSnap = "scrollSnap";
32+
export const kScrollActivationWidth = "scrollActivationWidth";
33+
export const kScrollLayout = "scrollLayout";

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ function revealMenuTools(format: Format) {
420420
key: "e",
421421
handler: "togglePdfExport",
422422
},
423+
{
424+
title: "Scroll View Mode",
425+
key: "r",
426+
handler: "toggleScrollView",
427+
},
423428
];
424429
if (format.metadata[kRevealChalkboard]) {
425430
tools.push(

src/format/reveal/format-reveal.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ import {
6262
kPreviewLinksAuto,
6363
kRevealJsConfig,
6464
kScrollable,
65+
kScrollActivationWidth,
66+
kScrollLayout,
67+
kScrollProgress,
68+
kScrollSnap,
69+
kScrollView,
6570
kSlideFooter,
6671
kSlideLogo,
72+
kView,
6773
} from "./constants.ts";
6874
import { revealMetadataFilter } from "./metadata.ts";
6975
import { ProjectContext } from "../../project/types.ts";
@@ -78,6 +84,36 @@ export function revealResolveFormat(format: Format) {
7884
if (format.metadata["navigationMode"] === "vertical") {
7985
format.metadata["navigationMode"] = "default";
8086
}
87+
88+
// normalize scroll-view to map to revealjs configuration
89+
const scrollView = format.metadata[kScrollView];
90+
if (typeof scrollView === "boolean" && scrollView) {
91+
// if scroll-view is true then set view to scroll by default
92+
// using all default option
93+
format.metadata[kView] = "scroll";
94+
} else if (typeof scrollView === "object") {
95+
// if scroll-view is an object then map to revealjs configuration individually
96+
const scrollViewRecord = scrollView as Record<string, unknown>;
97+
// Only activate scroll by default when ask explicitly
98+
if (scrollViewRecord["activate"] === true) {
99+
format.metadata[kView] = "scroll";
100+
}
101+
if (scrollViewRecord["progress"] !== undefined) {
102+
format.metadata[kScrollProgress] = scrollViewRecord["progress"];
103+
}
104+
if (scrollViewRecord["snap"] !== undefined) {
105+
format.metadata[kScrollSnap] = scrollViewRecord["snap"];
106+
}
107+
if (scrollViewRecord["layout"] !== undefined) {
108+
format.metadata[kScrollLayout] = scrollViewRecord["layout"];
109+
}
110+
if (scrollViewRecord["activation-width"] !== undefined) {
111+
format.metadata[kScrollActivationWidth] =
112+
scrollViewRecord["activation-width"];
113+
}
114+
}
115+
// remove scroll-view from metadata
116+
delete format.metadata[kScrollView];
81117
}
82118

83119
export function revealjsFormat() {
@@ -153,6 +189,24 @@ export function revealjsFormat() {
153189
format.metadata[kPdfMaxPagesPerSlide];
154190
}
155191

192+
// pass scroll view settings as they are not yet in revealjs template
193+
if (format.metadata[kView]) {
194+
extraConfig[kView] = format.metadata[kView];
195+
}
196+
if (format.metadata[kScrollProgress] !== undefined) {
197+
extraConfig[kScrollProgress] = format.metadata[kScrollProgress];
198+
}
199+
if (format.metadata[kScrollSnap] !== undefined) {
200+
extraConfig[kScrollSnap] = format.metadata[kScrollSnap];
201+
}
202+
if (format.metadata[kScrollLayout] !== undefined) {
203+
extraConfig[kScrollLayout] = format.metadata[kScrollLayout];
204+
}
205+
if (format.metadata[kScrollActivationWidth] !== undefined) {
206+
extraConfig[kScrollActivationWidth] =
207+
format.metadata[kScrollActivationWidth];
208+
}
209+
156210
// get theme info (including text highlighing mode)
157211
const theme = await revealTheme(
158212
format,

src/format/reveal/metadata.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import {
1313
kJumpToSlide,
1414
kPdfMaxPagesPerSlide,
1515
kPdfSeparateFragments,
16+
kScrollActivationWidth,
17+
kScrollLayout,
18+
kScrollProgress,
19+
kScrollSnap,
20+
kView,
1621
} from "./constants.ts";
1722

1823
export function optionsToKebab(options: string[]) {
@@ -120,6 +125,11 @@ const kRevealOptions = [
120125
kPdfSeparateFragments,
121126
"pdfPageHeightOffset",
122127
kJumpToSlide,
128+
kView,
129+
kScrollProgress,
130+
kScrollSnap,
131+
kScrollLayout,
132+
kScrollActivationWidth,
123133
];
124134

125135
const kRevealKebabOptions = optionsToKebab(kRevealOptions);

src/resources/editor/tools/vs-code.mjs

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18601,6 +18601,66 @@ var require_yaml_intelligence_resources = __commonJS({
1860118601
}
1860218602
]
1860318603
}
18604+
},
18605+
{
18606+
name: "scroll-view",
18607+
description: "Control the scroll view feature of Revealjs",
18608+
tags: {
18609+
formats: [
18610+
"revealjs"
18611+
]
18612+
},
18613+
schema: {
18614+
anyOf: [
18615+
"boolean",
18616+
{
18617+
object: {
18618+
properties: {
18619+
activate: {
18620+
boolean: {
18621+
default: true,
18622+
description: "Activate scroll view by default for the presentation. Otherwise, it is manually avalaible by adding `?view=scroll` to url."
18623+
}
18624+
},
18625+
progress: {
18626+
anyOf: [
18627+
"boolean",
18628+
{
18629+
enum: [
18630+
"auto"
18631+
]
18632+
}
18633+
],
18634+
default: "auto",
18635+
description: "Show the scrollbar while scrolling, hide while idle (default `auto`). Set to 'true' to always show, `false` to always hide."
18636+
},
18637+
snap: {
18638+
enum: [
18639+
"mandatory",
18640+
"proximity",
18641+
false
18642+
],
18643+
default: "mandatory",
18644+
description: "When scrolling, it will automatically snap to the closest slide. Only snap when close to the top of a slide using `proximity`. Disable snapping altogether by setting to `false`.\n"
18645+
},
18646+
layout: {
18647+
enum: [
18648+
"compact",
18649+
"full"
18650+
],
18651+
default: "full",
18652+
description: "By default each slide will be sized to be as tall as the viewport. If you prefer a more dense layout with multiple slides visible in parallel, set to `compact`.\n"
18653+
},
18654+
"activation-width": {
18655+
number: {
18656+
description: "Control scroll view activation width. The scroll view is automatically unable when the viewport reaches mobile widths. Set to `0` to disable automatic scroll view.\n"
18657+
}
18658+
}
18659+
}
18660+
}
18661+
}
18662+
]
18663+
}
1860418664
}
1860518665
],
1860618666
"schema/document-reveal-transitions.yml": [
@@ -23045,6 +23105,12 @@ var require_yaml_intelligence_resources = __commonJS({
2304523105
"Multiplex token server (defaults to Reveal-hosted server)",
2304623106
"Unique presentation id provided by multiplex token server",
2304723107
"Secret provided by multiplex token server",
23108+
"Control the scroll view feature of Revealjs",
23109+
"Activate scroll view by default for the presentation. Otherwise, it\nis manually avalaible by adding <code>?view=scroll</code> to url.",
23110+
"Show the scrollbar while scrolling, hide while idle (default\n<code>auto</code>). Set to \u2018true\u2019 to always show, <code>false</code> to\nalways hide.",
23111+
"When scrolling, it will automatically snap to the closest slide. Only\nsnap when close to the top of a slide using <code>proximity</code>.\nDisable snapping altogether by setting to <code>false</code>.",
23112+
"By default each slide will be sized to be as tall as the viewport. If\nyou prefer a more dense layout with multiple slides visible in parallel,\nset to <code>compact</code>.",
23113+
"Control scroll view activation width. The scroll view is\nautomatically unable when the viewport reaches mobile widths. Set to\n<code>0</code> to disable automatic scroll view.",
2304823114
{
2304923115
short: "Transition style for slides",
2305023116
long: "Transition style for slides backgrounds. (<code>none</code>,\n<code>fade</code>, <code>slide</code>, <code>convex</code>,\n<code>concave</code>, or <code>zoom</code>)"
@@ -23855,8 +23921,7 @@ var require_yaml_intelligence_resources = __commonJS({
2385523921
},
2385623922
"Disambiguating year suffix in author-date styles (e.g.&nbsp;\u201Ca\u201D in \u201CDoe,\n1999a\u201D).",
2385723923
"Manuscript configuration",
23858-
"internal-schema-hack",
23859-
"Alternative text for the logo, used for accessibility."
23924+
"internal-schema-hack"
2386023925
],
2386123926
"schema/external-schemas.yml": [
2386223927
{
@@ -24085,12 +24150,12 @@ var require_yaml_intelligence_resources = __commonJS({
2408524150
mermaid: "%%"
2408624151
},
2408724152
"handlers/mermaid/schema.yml": {
24088-
_internalId: 190453,
24153+
_internalId: 192356,
2408924154
type: "object",
2409024155
description: "be an object",
2409124156
properties: {
2409224157
"mermaid-format": {
24093-
_internalId: 190445,
24158+
_internalId: 192348,
2409424159
type: "enum",
2409524160
enum: [
2409624161
"png",
@@ -24106,7 +24171,7 @@ var require_yaml_intelligence_resources = __commonJS({
2410624171
exhaustiveCompletions: true
2410724172
},
2410824173
theme: {
24109-
_internalId: 190452,
24174+
_internalId: 192355,
2411024175
type: "anyOf",
2411124176
anyOf: [
2411224177
{

src/resources/editor/tools/yaml/web-worker.js

Lines changed: 70 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)