@openpresentation/opf-render 0.35.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -449,7 +449,7 @@ The base and Office pack standalone SVGs both contain two Roboto rules (430,764
449
449
 
450
450
  ### The slideshow
451
451
 
452
- `present(source, options)` takes an OPF document, its URL or an `<opf-deck>` element and covers the page with a full-screen player (call it from a click or key handler; full screen and the speaker view need a user gesture). It resolves with a `PlayerSession` (`slide`, `total`, `page`, `pages`, `next()`, `previous()`, `first()`, `last()`, `goto(n)`, `blank('black' | 'white' | 'none')`, `openPresenterView()`, `close()`; events `slidechange`, `blank`, `presenterview`, `close`). One show per document: a second call returns the running one.
452
+ `present(source, options)` takes an OPF document, its URL or an `<opf-deck>` element and covers the page with a full-screen player (call it from a click or key handler; full screen and the speaker view need a user gesture). It resolves with a `PlayerSession` (`slide`, `total`, `page`, `pages`, `next()`, `previous()`, `first()`, `last()`, `goto(n)`, `blank('black' | 'white' | 'none')`, `openPresenterView()`, `close()`; events `slidechange`, `blank`, `presenterview`, `close`). One show per document: a second call returns the running one. `embeds: (src) => boolean` (FR-08) names the embedded pages shown live, by address: each is a sandboxed frame (`sandbox="allow-scripts allow-same-origin allow-popups allow-forms"`, `referrerpolicy="no-referrer"`, `loading="lazy"`, no `allow`) over the embed's picture or card, which stays under it until the page loads; none is live by default, a page of the presenting page's own origin never is, and a click on a live frame never moves the show. `@openpresentation/opf-render/live-embeds` exports the helper (`mountLiveEmbeds`, `embedsOf`, `isSameOriginPage`) for a host with its own presenter; see [Embed](../../docs/content-payloads.md#embed).
453
453
 
454
454
  Keys: Right, Down, Page Down, Space, Enter and `N` are next; Left, Up, Page Up, Backspace, Shift+Space and `P` are previous; Home and End; a slide number then Enter (Escape clears it); `B` and `W` toggle a black or white screen (any navigation key brings the slide back first); `S` opens the speaker view; `F` toggles full screen; Escape leaves (leaving full screen any other way ends the show too). Click or tap advances (the left third goes back) and a horizontal swipe navigates. The player is a modal dialog: the rest of the page is inert, focus stays inside it and returns to where it was when the show ends, and an element that started it follows the show and fires `slidechange`.
455
455
 
@@ -615,13 +615,13 @@ Browser support boundary: `toSvg` and `resolvePresentation` are browser-importab
615
615
 
616
616
  Chartex chart previews (FF-22b) draw the constructs opf-pptx exports as Office 2016 chartex parts: `treemap` (squarified tiles of the first series, one color per tile, category labels), `histogram` (a lone value column binned like PowerPoint with Scott's rule count and right-closed bins, or one column per category), `pareto` (columns sorted descending with the cumulative-percentage line on a 0-100% axis), `box-and-whisker` (rows grouped by category, one box per series, exclusive quartiles, whiskers within 1.5 IQR, mean markers, outlier points), `waterfall` (floating bars from the running total, increases and decreases in the first two palette colors, connector lines) and `funnel` (centered bars with value labels). `world` is an honest non-geographic preview: one tile per region shaded by value with its name and value. No geography data is shipped; PowerPoint draws the real map from Bing geodata it fetches itself, so the preview and the native map agree on labels, values and the series color, not on shapes. Each chartex kind also accepts a lone value column (row numbers as categories; histogram and pareto bin the values). Every mark and label keeps a `data-opf-path` (bins and boxes trace to their value column).
617
617
 
618
- Combo charts (FA-15): `type: "combo"` draws clustered columns with line series (lines with markers) in one plot. Core's `resolveChartData` resolves the plan, so the preview and the PPTX export agree: the series that `chart.line` names (by default the last series) are lines, `chart.secondaryAxis` puts lines on a secondary value axis at the right (at the left right to left) with its own scale and its tick labels in the first secondary series' column format, and the series are drawn and listed in the legend columns first, then the primary-axis lines, then the secondary-axis lines. Gridlines follow the primary axis; `axisTitles.secondary` titles the secondary axis (rotated, inside a right legend); data labels sit outside the end of the columns and above the line points unless `dataLabels.position` says otherwise.
618
+ Combo charts (FA-15): `type: "combo"` draws clustered columns with line series (lines with markers) in one plot. Core's `resolveChartData` resolves the plan, so the preview and the PPTX export agree: the series that `chart.lineSeries` names (by default the last series) are lines, `chart.secondaryAxis` puts lines on a secondary value axis at the right (at the left right to left) with its own scale and its tick labels in the first secondary series' column format, and the series are drawn and listed in the legend columns first, then the primary-axis lines, then the secondary-axis lines. Gridlines follow the primary axis; `axisTitles.secondary` titles the secondary axis (rotated, inside a right legend); data labels sit outside the end of the columns and above the line points unless `dataLabels.position` says otherwise.
619
619
 
620
620
  Explicit chart reference lines (LH-110): `chart.referenceLines` holds ordered numeric values in their own value-axis units, optional verbatim endpoint labels and independent ColorRef/width/solid-dash-dot strokes. A line chart keeps its existing solid data line while a target can be dashed. Column, bar, line, line-with-markers, area and combo are supported; absence or an empty list draws none. Titles/subtitles never create thresholds or period bands. Shared composition supplies bounds, plot and label placement, including RTL and collisions; combo primary/secondary scales are shared with PPTX. Vertical references span first-to-last category centers when there are at least two categories; bar and singleton fallbacks span the full plot. See [the contract and PPTX edit/import limits](../../docs/chart-options.md#explicit-reference-lines).
621
621
 
622
622
  Chart options (RR-35): a chart's optional `axisTitles`, `legend` and `dataLabels` (core `docs/chart-options.md`) are drawn. A named legend position is carved from the chart box before the plot is laid out, axis titles sit beside the axes (the value title rotated 270 degrees), and data labels follow the content (category, value, percent), position and separator the chart type supports. An option a type cannot show is dropped with a `chart-option-adapted` diagnostic; a chart without the fields draws as before.
623
623
 
624
- Chart colors, text and value axis (RR-89, RR-90, RR-92; need core 0.22.0: `chartSeriesPalette`, `chartTextSize` and the composed `chart.valueAxis`): series are drawn in core's `chartSeriesPalette` of the deck's resolved color scheme (`accent1` to `accent6`, then the same accents tinted toward white), adjusted per chart panel by `chartPaletteForFill`, so `design.colorScheme` recolors charts; chart axis, legend, category and data-label text is core's `chartTextSize` (20 px, shrunk only for a small chart box, never below `minFontSize`); and a column, bar, line or area chart draws the value axis (`min`, `max`, `majorUnit`) core composes for its box, the axis the PPTX export writes. Combo charts likewise consume composed primary and secondary axes; chart constructs without composed bounds retain their own scale.
624
+ Chart colors, text and value axis (RR-89, RR-90, RR-92; need core 0.22.0: `chartSeriesPalette`, `chartTextSize` and the composed `chart.valueAxis`): series are drawn in core's `chartSeriesPalette` of the deck's resolved color scheme (`accent1` to `accent6`, then the same accents tinted toward white), adjusted per chart panel by `chartPaletteForFill`, so `design.colorScheme` recolors charts; chart axis, legend, category and data-label text is core's `chartTextSize` (20 px, shrunk only for a small chart box, never below `minFontSizePx`); and a column, bar, line or area chart draws the value axis (`min`, `max`, `majorUnit`) core composes for its box, the axis the PPTX export writes. Combo charts likewise consume composed primary and secondary axes; chart constructs without composed bounds retain their own scale.
625
625
 
626
626
  Chart emphasis (FA-14): `chart.highlight` names the series (data columns) and categories (row labels) that carry the message. Highlighted marks are filled with the deck primary and every other mark with a muted neutral derived from the chart panel and text colors (core `chartHighlightColors`; core `chartHighlightMarks` decides which marks are named: a mark is highlighted when its series or its category is). It colors columns, bars, line series and (for a category highlight) line points, areas, scatter and radar series, and pie and doughnut slices, with legend keys and data label contrast following; the chartex constructs draw as before and the `chart-option-adapted` diagnostic names the dropped part. Series keep their order and a chart without `highlight` draws the same SVG as before.
627
627
 
@@ -12,7 +12,8 @@ const INACTIVE = Object.freeze({ active: false, axisTitles: {}, diagnostics: []
12
12
  */
13
13
  export function resolveOptions(chart, spec) {
14
14
  if (!chart || typeof chart !== "object") return INACTIVE;
15
- return resolveChartOptions(chart, { kind: spec.kind, stacked: spec.grouping === "stacked" || spec.grouping === "percentStacked" });
15
+ // FR-07: a bullet chart takes a horizontal bar chart's options (core chartOptionTarget('bullet') is a bar).
16
+ return resolveChartOptions(chart, { kind: spec.kind === "bullet" ? "bar" : spec.kind, stacked: spec.grouping === "stacked" || spec.grouping === "percentStacked" });
16
17
  }
17
18
 
18
19
  export function reportOptionDiagnostics(c, resolved) {
@@ -26,7 +27,7 @@ export function reportOptionDiagnostics(c, resolved) {
26
27
  * secondary value axis at the right, next to that axis; right to left, its two value axes trade sides (FA-15).
27
28
  */
28
29
  function titleSides(spec, rtl = false) {
29
- const verticalCategory = (spec.kind === "bar" && spec.dir === "bar") || spec.kind === "funnel";
30
+ const verticalCategory = (spec.kind === "bar" && spec.dir === "bar") || spec.kind === "funnel" || spec.kind === "bullet";
30
31
  if (spec.kind === "combo") return rtl ? { category: "bottom", value: "right", secondary: "left" } : { category: "bottom", value: "left", secondary: "right" };
31
32
  return verticalCategory ? { category: "left", value: "bottom" } : { category: "bottom", value: "left" };
32
33
  }
package/dist/charts.js CHANGED
@@ -4,7 +4,8 @@
4
4
  // The table below is carried here so the preview stays synchronous and self-contained; test/chart-catalog.mjs checks it
5
5
  // against core's CHART_TYPES. Each type renders the construct PowerPoint shows for the exported chart; any other value
6
6
  // returns null so the caller keeps its legacy single-series preview.
7
- import { chartAxisFraction as axisFraction, chartAxisScale as composedScale, chartBarGeometry, chartBarSeriesOffset, chartDrawPlan, chartSlicePlan, CHART_SLICE_SEPARATOR_PX, histogramBins, paretoPlan, scottBinCount, chartWaterfallColors, waterfallLabelText, markLabelColor, chartEmphasisColors, chartSeriesLabelColor, chartContextColors, chartFocusContextColors, chartSeriesStrokes, chartHighlightColors, chartHighlightMarks, chartLayerDataLabels, chartNumber, chartValueAxisHidden, chartPaletteForFill, chartSchemeSeries, chartSeriesPalette as coreChartSeriesPalette, chartTextSize, CHART_MAX_INTERVALS, chartIntervalsFor, formatDataNumber, groupNumber, groupsAxisTicks, groupsDataRange, groupsThousands, maxIntervalsFor, niceScale, stackCategoryValues, waterfallSteps, numberFormatError, resolveChartData, resolveTextStyle, textColorForFill, textWidthMeasurer, formatNumber, formatPercentNumber, chartNumberLanguage } from "@openpresentation/opf/composition";
7
+ import { chartAxisFraction as axisFraction, chartAxisScale as composedScale, chartBarGeometry, chartBarSeriesOffset, chartDrawPlan, chartSlicePlan, CHART_SLICE_SEPARATOR_PX, histogramBins, paretoPlan, scottBinCount, chartWaterfallColors, waterfallLabelText, markLabelColor, chartEmphasisColors, chartSeriesLabelColor, chartContextColors, chartFocusContextColors, chartSeriesStrokes, chartHighlightColors, chartHighlightMarks, chartLayerDataLabels, chartNumber, chartValueAxisHidden, chartPaletteForFill, chartSchemeSeries, chartSeriesPalette as coreChartSeriesPalette, chartTextSize, CHART_MAX_INTERVALS, chartIntervalsFor, formatDataNumber, groupNumber, groupsAxisTicks, groupsDataRange, groupsThousands, maxIntervalsFor, niceScale, stackCategoryValues, waterfallSteps, numberFormatError, resolveChartData, resolveTextStyle, textColorForFill, textWidthMeasurer, formatNumber, formatPercentNumber, chartNumberLanguage, chartBands, chartBandRanges, chartBandFill, chartBandMutedColor, bandLabelColor, BULLET_BAR_SHARE, BULLET_TARGET_SHARE, BULLET_TARGET_WIDTH_PX } from "@openpresentation/opf/composition";
8
+ import { PRESET_DASHES } from "./shapes.js";
8
9
  import { drawAxisTitles, drawBarLabel, drawCenteredLabel, drawPointLabel, drawSliceLabel, labelFill, labelString, outsideLabelReserve, reportOptionDiagnostics, reserveAxisTitles, resolveOptions } from "./chart-options.js";
9
10
 
10
11
  // The series colors for a chart panel: core's `chartSeriesPalette` (the deck color scheme's accents, RR-89, with the chart's own
@@ -28,6 +29,16 @@ function highlightFor(c, resolved, spec, data) {
28
29
  return { ...marks, ...chartHighlightColors(c.surface, c.bound.design.colors.primary, c.labelColor) };
29
30
  }
30
31
 
32
+ // FR-07 (supervisor, 2026-11-26): in a chart with bands, the muted marks of a highlight take the neutral at 1.5:1 from the chart's strongest
33
+ // band, on the side away from the surface (core chartBandMutedColor, which the PPTX export calls with the same colors); without bands the
34
+ // muted color is the one above.
35
+ function bandHighlight(c, highlight) {
36
+ if (!highlight) return undefined;
37
+ const fills = bandsOver(c, c.valueAxis ?? bandAxis(c)).map((band) => band.fill);
38
+ const muted = chartBandMutedColor(fills, c.surface, c.bound.design.colors.text);
39
+ return muted ? { ...highlight, muted } : highlight;
40
+ }
41
+
31
42
  // LH-03, LH-95: a one-series small column or bar chart draws its emphasized point (core: the last one with a value) in a stronger shade of
32
43
  // the series color and every other point in the series color (core chartEmphasisColors); it is drawn as a category highlight of that point.
33
44
  function emphasisFor(c, layer) {
@@ -77,7 +88,14 @@ function drawHeader(c, spec, header) {
77
88
  if (header.legend) {
78
89
  c.legendManaged = true;
79
90
  const plan = spec.kind === "combo" ? comboPlan(c, c.series()) : undefined;
91
+ // FR-07: a band's entry (the bands come first) in the band's color.
92
+ const bandFills = header.legend.entries.some((entry) => entry.band !== undefined) ? new Map(bandLegendEntries(c).map((entry) => [entry.path, entry.color])) : undefined;
80
93
  for (const entry of header.legend.entries) {
94
+ if (entry.band !== undefined) {
95
+ const path = `${c.path}.bands.${entry.band}`, metrics = { swatch: c.fontPx * 0.6, gap: c.fontPx * 0.4, keyWidth: c.fontPx * 0.6 };
96
+ if (bandFills?.has(path)) drawLegendEntry(c, { name: entry.name, color: bandFills.get(path), path }, entry.box.x, entry.box.y, entry.box.height, metrics, entry.box.width);
97
+ continue;
98
+ }
81
99
  const s = c.series()[entry.series];
82
100
  const key = entry.key === "line" ? "line" : undefined;
83
101
  const marker = key === "line" && (spec.kind === "combo" ? plan?.[entry.series]?.role === "line" : Boolean(spec.markers));
@@ -137,7 +155,9 @@ export const CHART_TYPES = Object.freeze({
137
155
  funnel: { kind: "funnel" },
138
156
  world: { kind: "map" },
139
157
  // FA-15: clustered columns with line series (markers), the lines optionally on a secondary value axis (core resolves the plan).
140
- combo: { kind: "combo", dir: "col", grouping: "clustered", markers: true }
158
+ combo: { kind: "combo", dir: "col", grouping: "clustered", markers: true },
159
+ // FR-07: one thin horizontal bar per category against its target tick, over the chart's bands.
160
+ bullet: { kind: "bullet", dir: "bar", grouping: "clustered" }
141
161
  });
142
162
 
143
163
  /** Resolve a chart type (core's CHART_TYPES vocabulary, OPF 0.15) to its preview spec id, or null for any other value. */
@@ -162,7 +182,8 @@ const RENDERERS = {
162
182
  waterfall: renderWaterfallChart,
163
183
  funnel: renderFunnelChart,
164
184
  map: renderRegionMapChart,
165
- combo: renderComboChart
185
+ combo: renderComboChart,
186
+ bullet: renderBulletChart
166
187
  };
167
188
 
168
189
  // Chartex constructs also accept a lone value column (the exporter plots it
@@ -196,7 +217,7 @@ export function renderCatalogChart(item, box, bound, options, svg) {
196
217
  const fitReport = doughnutFit && { code: "chart-option-adapted", option: "dataLabels.content", reason: "unsupported-content", message: `The labels of a doughnut sit inside their slices, and '${doughnutFit.from.join(', ')}' does not fit the ring, so ${doughnutFit.content ? `they show '${doughnutFit.content.join(', ')}' instead (the legend names the slices)` : 'no labels are drawn (the legend names the slices)'}.` };
197
218
  if (fitReport && authoredSpec) resolved.diagnostics = [...resolved.diagnostics, fitReport];
198
219
  // FA-14: a highlight changes colors only (no space is reserved), so it is resolved whether or not an option is active.
199
- c.highlight = highlightFor(c, resolved, spec, data) ?? focusFor(c, layer, spec) ?? emphasisFor(c, layer);
220
+ c.highlight = bandHighlight(c, highlightFor(c, resolved, spec, data)) ?? focusFor(c, layer, spec) ?? emphasisFor(c, layer);
200
221
  // LH-03, LH-142: no value axis (a small chart's labels or a horizontal stacked bar chart's segment values carry the values): core decides it.
201
222
  c.valueAxisHidden = chartValueAxisHidden(layer);
202
223
  c.ringNames = layer?.rings;
@@ -211,6 +232,8 @@ export function renderCatalogChart(item, box, bound, options, svg) {
211
232
  c.doughnut = layer?.doughnut;
212
233
  c.stack = layer?.stack;
213
234
  c.references = layer?.references;
235
+ // FR-07: the band labels inside their bands (core placeBandLabels), or the fallback that lists them in the legend.
236
+ c.bandLabels = layer?.bandLabels;
214
237
  if (layer?.valueList || layer?.stack?.names) c.legendManaged = true;
215
238
  // LH-93: sibling charts sharing one value axis share one plot height; core gives each its inner plot as an inset from the chart box.
216
239
  const inset = layer?.plot;
@@ -250,6 +273,17 @@ export function renderCatalogChart(item, box, bound, options, svg) {
250
273
  // Explicit reference lines are drawn over the data.
251
274
  render(c, spec);
252
275
  drawReferenceLines(c, layer?.references?.lines);
276
+ // FR-07: band labels on top of the data (PowerPoint draws data labels above every series), in the secondary text color.
277
+ // One color for every band label of the chart (core bandLabelColor): the secondary text color when it reads at 4.5:1 on every labeled band,
278
+ // else the primary text color, as the PowerPoint export writes it. A band on which even that stays below 4.5:1 is reported; its label is drawn.
279
+ const placedLabels = layer?.bandLabels?.legend ? [] : layer?.bandLabels?.labels ?? [];
280
+ if (placedLabels.length) {
281
+ const bandFills = new Map(bandsOver(c, c.valueAxis ?? { min: 0, max: 1 }).map((band) => [band.index, band.fill]));
282
+ // FR-07d: labels beside the plot stand on the surface, in the secondary text color.
283
+ const { color, failing } = layer.bandLabels.beside ? { color: c.chartTextColor, failing: [] } : bandLabelColor(placedLabels.map((label) => bandFills.get(label.index) ?? c.surface), c.chartTextColor, c.labelColor);
284
+ for (const at of failing) c.svg.reportDiagnostic?.({ code: "text-contrast", path: `${c.path}.bands.${placedLabels[at].index}.label`, message: `The band label "${placedLabels[at].text}" stays below 4.5:1 on its band in the text color; choose a lighter band color.` }, c.options);
285
+ for (const label of placedLabels) c.text(label.text, label.box, `${c.path}.bands.${label.index}.label`, label.align, color);
286
+ }
253
287
  drawStackNames(c, layer?.stack?.names);
254
288
  drawStackEnds(c, layer?.stack?.ends);
255
289
  if (resolved.active) drawAxisTitles(c);
@@ -268,7 +302,7 @@ export function chartData(item, bound) {
268
302
  const language = bound?.scriptFonts?.profile?.bcp47;
269
303
  const plan = chartDrawPlan(chart, resolved, { language: typeof language === "string" ? language : undefined });
270
304
  const formats = plan.formats.map((format) => typeof format === "string" && format !== "" && !numberFormatError(format) ? format : undefined);
271
- return { type: plan.type, fallback: plan.fallback, columns: plan.columns, hasX: plan.hasX, rows: plan.rows, formats, trace: tracePaths(item, bound, { ...resolved, columns: plan.columns, regrouped: plan.columns.length !== resolved.columns.length }), ...(resolved.combo ? { combo: resolved.combo } : {}) };
305
+ return { type: plan.type, fallback: plan.fallback, columns: plan.columns, hasX: plan.hasX, rows: plan.rows, formats, trace: tracePaths(item, bound, { ...resolved, columns: plan.columns, regrouped: plan.columns.length !== resolved.columns.length }), ...(resolved.combo ? { combo: resolved.combo } : {}), ...(resolved.target ? { target: resolved.target } : {}) };
272
306
  }
273
307
 
274
308
  // The authored object at a composed path ("slides.0.blocks.1.chart"), or undefined.
@@ -307,11 +341,11 @@ function tracePaths(item, bound, resolved) {
307
341
  return columnMap.every((column, index) => column === index) ? null : { columnMap };
308
342
  }
309
343
 
310
- function chartContext(item, box, bound, options, svg, { rows, columns, formats, trace, combo, hasX = false }, layer) {
344
+ function chartContext(item, box, bound, options, svg, { rows, columns, formats, trace, combo, hasX = false, target }, layer) {
311
345
  const u = Math.min(bound.design.dimensions.width, bound.design.dimensions.height) / 720;
312
346
  const composition = bound.composition ?? bound.geometry.composition ?? {};
313
- // RR-90: core's chart text size (20 px, shrunk only for a small box, never below minFontSize), the size core's value-axis density assumes.
314
- const requested = chartTextSize({ width: box.width, height: box.height, scale: u, minFontSize: composition.minFontSize }), fontPx = requested * u;
347
+ // RR-90: core's chart text size (20 px, shrunk only for a small box, never below minFontSizePx), the size core's value-axis density assumes.
348
+ const requested = chartTextSize({ width: box.width, height: box.height, scale: u, minFontSizePx: composition.minFontSizePx }), fontPx = requested * u;
315
349
  // LH-03, LH-105: a chart has no panel, so its colors are judged against what it stands on: the card, or the slide background.
316
350
  const surface = item.frameBox ? bound.design.roles.neutrals.card.hex : bound.design.backgroundColor ?? bound.design.colors.background;
317
351
  // RR-96: every neutral comes from the slide's variant (core `roles.neutrals`: tx1 mixed into bg1, the colors the PPTX export writes as
@@ -333,7 +367,7 @@ const neutrals = bound.design.roles.neutrals;
333
367
  return path.replace(/^(.*\.data\.(?:columns\.|rows\.\d+\.))(\d+)$/, (whole, head, column) => `${head}${trace.columnMap[Number(column)] ?? column}`);
334
368
  };
335
369
  const c = {
336
- item, box, bound, options, svg, rows, columns, formats, combo, hasX, children, u, fontPx, surface, labelColor, chartTextColor,
370
+ item, box, bound, options, svg, rows, columns, formats, combo, hasX, target, children, u, fontPx, surface, labelColor, chartTextColor,
337
371
  path: item.path,
338
372
  tracePath,
339
373
  pt: u * 4 / 3,
@@ -499,12 +533,14 @@ function legendSource(c, spec) {
499
533
  case "pie":
500
534
  case "doughnut": return c.rows.map((row, i) => ({ name: c.label(row[0]), color: sliceColor(c, i), path: `${c.path}.data.rows.${i}.0` }));
501
535
  case "scatter": return fromSeries(scatterSeries(c.rows, c.columns, c.formats, c.hasX).series, "marker");
502
- case "line": return fromSeries(c.series(), "line", spec.markers);
536
+ case "line": return [...bandLegendEntries(c), ...fromSeries(c.series(), "line", spec.markers)];
503
537
  case "radar": return fromSeries(c.series(), spec.style === "filled" ? undefined : "line", spec.markers);
504
538
  case "box": return fromSeries(c.columns.length === 1 ? [{ name: c.label(c.columns[0]), column: 0, index: 0 }] : c.series());
505
539
  case "bar":
506
- case "area": return fromSeries(c.series());
540
+ case "area": return [...bandLegendEntries(c), ...fromSeries(c.series())];
507
541
  case "combo": return comboLegendEntries(c, c.series());
542
+ // FR-07: a bullet chart's legend names its measure and its labeled bands.
543
+ case "bullet": return [...bandLegendEntries(c), ...fromSeries(c.series().slice(0, 1))];
508
544
  default: return [];
509
545
  }
510
546
  }
@@ -554,10 +590,47 @@ function placeLegend(c, spec, position) {
554
590
 
555
591
  function seriesLegend(c, series, key, marker = false) {
556
592
  return series.length > 1
557
- ? legendEntries(c, series.map((s) => ({ name: s.name, color: seriesColor(c, s.index), path: `${c.path}.data.columns.${s.column}`, key, marker })))
593
+ ? legendEntries(c, [...bandLegendEntries(c), ...series.map((s) => ({ name: s.name, color: seriesColor(c, s.index), path: `${c.path}.data.columns.${s.column}`, key, marker }))])
558
594
  : 0;
559
595
  }
560
596
 
597
+ // FR-07: the chart's bands (core chartBands, sorted; empty for a type that draws none) over an axis, with their fills (core chartBandFill:
598
+ // the scheme's text mixed into the surface, darkest lowest, or a band's own scheme color as a light tint, mixed in OKLab).
599
+ function bandColors(c) {
600
+ return { surface: c.surface, text: c.bound.design.colors.text, resolve: (name) => String(c.resolveColorRef(name, c.bound.design.colors.text) ?? c.bound.design.colors.text).slice(0, 7).toUpperCase() };
601
+ }
602
+ // An axis over every band, for a chart without a composed value axis.
603
+ function bandAxis(c) {
604
+ const bands = chartBands(c.item.value);
605
+ return { min: Math.min(0, ...bands.map((band) => band.to)) - 1, max: Math.max(0, ...bands.map((band) => band.to)) };
606
+ }
607
+ function bandsOver(c, scale) {
608
+ const bands = chartBands(c.item.value);
609
+ if (!bands.length) return [];
610
+ const colors = bandColors(c);
611
+ return chartBandRanges(bands, scale).map((band) => ({ ...band, fill: chartBandFill(band, colors) }));
612
+ }
613
+ // A labeled band's legend entry, before the series (a band without a label has none), when its label does not stand inside its band.
614
+ // PowerPoint lists the band group, which it draws first, before the data whatever the file says (native check 2026-11-25).
615
+ function bandLegendEntries(c) {
616
+ // FR-07 (owner, "1B"): the labels stand inside their bands; the legend lists them only in composition's fallback (or with no composition).
617
+ if (c.bandLabels && !c.bandLabels.legend) return [];
618
+ const bands = chartBands(c.item.value);
619
+ if (!bands.length) return [];
620
+ const axis = c.valueAxis ?? bandAxis(c);
621
+ const colors = bandColors(c);
622
+ return chartBandRanges(bands, axis).filter((band) => band.label !== undefined).map((band) => ({ name: band.label, color: chartBandFill(band, colors), path: `${c.path}.bands.${band.index}` }));
623
+ }
624
+ // FR-07: bands as rectangles across the plot, over the gridlines and behind the data (as PowerPoint draws them). `along` is the extent on the category axis: the whole plot
625
+ // for bars and columns, the first to the last category center for lines and areas (what PowerPoint's area series covers).
626
+ function drawBands(c, bands, { plot, at, horizontal, along }) {
627
+ for (const band of bands) {
628
+ const a = at(band.from), b = at(band.to);
629
+ const rect = horizontal ? { x: Math.min(a, b), y: along.start, width: Math.abs(b - a), height: along.end - along.start } : { x: along.start, y: Math.min(a, b), width: along.end - along.start, height: Math.abs(b - a) };
630
+ if (rect.width > 0 && rect.height > 0) c.mark("rect", { ...rect, fill: band.fill }, `${c.path}.bands.${band.index}`);
631
+ }
632
+ }
633
+
561
634
  function gridline(c, x1, y1, x2, y2) {
562
635
  c.mark("line", { x1, y1, x2, y2, stroke: c.gridColor, "stroke-width": c.pt });
563
636
  }
@@ -757,11 +830,11 @@ function planRowLabels(c, entries, band, gutter) {
757
830
 
758
831
  // `rowTop(i)` is the top of category i's row; rows are `band` tall. A two-line label is given its two lines' height around its row's
759
832
  // middle, so it is drawn at the chart text size even where it reaches past its row (LH-120).
760
- function drawRowLabels(c, plan, entries, band, gutter, x, rowTop) {
833
+ function drawRowLabels(c, plan, entries, band, gutter, x, rowTop, align = "right") {
761
834
  const span = plan.n * band;
762
835
  for (const label of plan.labels) {
763
836
  const middle = rowTop(label.i) + band / 2, height = Math.max(span, label.text.split(/\n/).length * c.textHeight);
764
- c.text(label.text, { x, y: middle - height / 2, width: gutter, height }, entries[label.i].path, "right");
837
+ c.text(label.text, { x, y: middle - height / 2, width: gutter, height }, entries[label.i].path, align);
765
838
  }
766
839
  reportTruncatedLabels(c, plan.labels.filter((label) => label.truncated).map((label) => entries[label.i].path));
767
840
  }
@@ -877,6 +950,16 @@ function renderCategoryChart(c, spec) {
877
950
  else c.text(label, { x: box.x + pad, y: position - c.lineHeight / 2, width: plot.x - box.x - pad - fontPx * 0.35, height: c.lineHeight }, c.path, "right");
878
951
  }
879
952
  }
953
+ // FR-07: bands over the gridlines and behind the data, as PowerPoint draws them (its gridlines are behind every series, and the bands
954
+ // are series): a gridline shows only where no band is. A line or area chart's bands run from the first to the last category center (an
955
+ // edge-to-edge area's points are the plot's edges), as PowerPoint's area series covers; a bar or column chart's the whole plot.
956
+ const bands = bandsOver(c, scale);
957
+ if (bands.length) {
958
+ const length = horizontal ? plot.height : plot.width, start = horizontal ? plot.y : plot.x;
959
+ const edge = labelPlot !== undefined && labelPlot !== plot;
960
+ const inset = spec.kind !== "bar" && count >= 2 && !edge ? length / count / 2 : 0;
961
+ drawBands(c, bands, { plot, at, horizontal, along: { start: start + inset, end: start + length - inset } });
962
+ }
880
963
  const band = (horizontal ? plot.height : plot.width) / count;
881
964
  if (spec.kind === "bar") drawBars(c, spec, series, stacks, { plot, band, at, horizontal, scale, categorySlot, rowTop });
882
965
  else if (spec.kind === "line") drawLines(c, spec, series, stacks, { plot, band, at, categorySlot });
@@ -997,7 +1080,7 @@ function drawAreas(c, series, stacks, { plot, band, at, crossing, categorySlot =
997
1080
  function drawReferenceLines(c, lines) {
998
1081
  for (const line of lines ?? []) {
999
1082
  const color=line.stroke.color===undefined?c.chartTextColor:c.resolveColorRef(line.stroke.color,c.chartTextColor);
1000
- const width=line.strokeWidth,dash=line.stroke.dash==='dash'?[4*width,3*width]:line.stroke.dash==='dot'?[width,3*width]:undefined;
1083
+ const width=line.strokeWidth,pattern=PRESET_DASHES[line.stroke.dash],dash=pattern?pattern.map(part=>part*width):undefined;
1001
1084
  if(width>0)c.mark('line',{x1:line.x1,y1:line.y1,x2:line.x2,y2:line.y2,stroke:color,'stroke-width':width,...(dash?{'stroke-dasharray':dash.map(c.num).join(' ')}:{})},c.path+'.referenceLines.'+line.index);
1002
1085
  // RR-105: a label core could not keep off the marks stands on a plate of the chart's surface (the PPTX export fills its label so).
1003
1086
  if(line.label!==undefined&&line.labelBox&&line.labelPlate)c.mark('rect',{...line.labelBox,fill:c.surface},c.path+'.referenceLines.'+line.index+'.label');
@@ -1067,6 +1150,71 @@ function drawValueList(c, list) {
1067
1150
  // the primary axis, whose ticks take the first column series' format. The PPTX export writes the same plan natively.
1068
1151
 
1069
1152
  /** The combo plan of a chart: core's, or (a core without it) every series a column except the last, a line, all on the primary axis. */
1153
+ // ---------------------------------------------------------------------------
1154
+ // FR-07: the bullet chart. One row per category, top to bottom in data order; within a row, from back to front: the bands across the
1155
+ // full row height (one rectangle per band over every row), the measure bar (a third of the row, centered, in the series color) and the
1156
+ // target tick (two thirds of the row, 2 reference pixels wide, in the text color). The value axis is core's (chartValueAxis: from 0,
1157
+ // unless a value or band is negative, to the largest value, target or band end). Right to left, the category names stand at the right
1158
+ // and the value axis runs from the right.
1159
+
1160
+ function renderBulletChart(c) {
1161
+ const { box, pad, fontPx } = c;
1162
+ const right2left = rtl(c);
1163
+ const [measure] = c.series();
1164
+ if (!measure) return;
1165
+ const format = measure.format;
1166
+ const categories = c.rows.map((row) => c.label(row[0]));
1167
+ const count = categories.length;
1168
+ const targets = c.target?.values ?? [];
1169
+ const extents = [...measure.values, ...targets].filter((value) => value !== null);
1170
+ const dataMin = Math.min(0, ...extents), dataMax = Math.max(0, ...extents, ...chartBands(c.item.value).map((band) => band.to));
1171
+ const tickGroup = format === undefined && c.valueAxis && groupsAxisTicks(c.valueAxis) ? { language: typeof c.language === "string" ? c.language : undefined } : undefined;
1172
+ const longestWord = Math.max(0, ...categories.flatMap((name) => flatLabel(name).split(BREAKABLE).map((word) => c.width(word)))) + fontPx * 0.5;
1173
+ const categoryWidth = Math.min(Math.max(box.width * 0.3, Math.min(box.width * 0.4, longestWord)), Math.max(0, ...categories.map((name) => c.width(flatLabel(name)))) + fontPx * 0.5);
1174
+ const top = box.y + pad + c.lineHeight / 2, bottom = box.y + box.height - pad - c.lineHeight;
1175
+ const gutterX = right2left ? box.x + box.width - pad - categoryWidth : box.x + pad;
1176
+ const x = right2left ? box.x + pad + fontPx : box.x + pad + categoryWidth + c.pad / 2;
1177
+ const width = Math.max(1, right2left ? gutterX - c.pad / 2 - x : box.x + box.width - pad - fontPx - x);
1178
+ const tickWidth = Math.max(c.width(formatTick(dataMax, false, format, tickGroup, c.language)), c.width(formatTick(dataMin, false, format, tickGroup, c.language))) + fontPx;
1179
+ const scale = categoryScale(c, dataMin, dataMax, width, tickWidth, false);
1180
+ // Core's plot (bulletPlot), which the PowerPoint export writes as the inner plot layout; the same arithmetic without it.
1181
+ const plot = c.plotBox ? { ...c.plotBox } : { x, y: top, width, height: Math.max(1, bottom - top) };
1182
+ c.plotArea = plot;
1183
+ const at = (value) => right2left ? plot.x + plot.width - axisFraction(value, scale) * plot.width : plot.x + axisFraction(value, scale) * plot.width;
1184
+ const rowBand = plot.height / count, rowTop = (i) => plot.y + i * rowBand;
1185
+ const entries = categories.map((name, i) => ({ name, path: `${c.path}.data.rows.${i}.0` }));
1186
+ drawRowLabels(c, planRowLabels(c, entries, rowBand, categoryWidth), entries, rowBand, categoryWidth, gutterX, rowTop, right2left ? "left" : "right");
1187
+ for (const tick of scale.ticks) {
1188
+ const position = at(tick), label = formatTick(tick, false, format, tickGroup, c.language);
1189
+ gridline(c, position, plot.y, position, plot.y + plot.height);
1190
+ const labelWidth = c.width(label) + fontPx;
1191
+ c.text(label, { x: position - labelWidth / 2, y: plot.y + plot.height, width: labelWidth, height: c.lineHeight }, c.path);
1192
+ }
1193
+ // The bands across every row, over the gridlines (as PowerPoint draws them) and behind the bars.
1194
+ drawBands(c, bandsOver(c, scale), { plot, at, horizontal: true, along: { start: plot.y, end: plot.y + plot.height } });
1195
+ const crossing = at(Math.min(scale.max, Math.max(scale.min, 0)));
1196
+ const barHeight = rowBand * BULLET_BAR_SHARE, tickHeight = rowBand * BULLET_TARGET_SHARE;
1197
+ const labels = [];
1198
+ measure.values.forEach((value, i) => {
1199
+ if (value === null) return;
1200
+ const end = at(Math.min(scale.max, Math.max(scale.min, value)));
1201
+ const rect = { x: Math.min(crossing, end), y: rowTop(i) + (rowBand - barHeight) / 2, width: Math.abs(end - crossing), height: barHeight };
1202
+ const path = `${c.path}.data.rows.${i}.${measure.column}`, color = markColor(c, 0, i);
1203
+ c.mark("rect", { ...rect, fill: color }, path);
1204
+ const grows = (value >= 0) !== right2left ? "right" : "left";
1205
+ if (c.dataLabels) labels.push({ rect, direction: grows, path, color, text: labelString(c, { category: categories[i], value, format, group: measure.group }) });
1206
+ });
1207
+ // The target ticks over the bars; a row without a target has none.
1208
+ targets.forEach((target, i) => {
1209
+ if (target === null || target < scale.min || target > scale.max) return;
1210
+ const position = at(target), middle = rowTop(i) + rowBand / 2;
1211
+ c.mark("line", { x1: position, y1: middle - tickHeight / 2, x2: position, y2: middle + tickHeight / 2, stroke: c.labelColor, "stroke-width": BULLET_TARGET_WIDTH_PX * c.u }, `${c.path}.mapping.target`);
1212
+ });
1213
+ for (const label of labels) drawBarLabel(c, label.text, label.rect, label.direction, label.path, label.color);
1214
+ axisLine(c, crossing, plot.y, crossing, plot.y + plot.height);
1215
+ axisLine(c, plot.x, plot.y + plot.height, plot.x + plot.width, plot.y + plot.height);
1216
+ }
1217
+
1070
1218
  function comboPlan(c, series) {
1071
1219
  if (Array.isArray(c.combo) && c.combo.length === series.length) return c.combo;
1072
1220
  return series.map((_, index) => ({ role: series.length > 1 && index === series.length - 1 ? "line" : "bar", axis: "primary" }));
@@ -80,6 +80,23 @@ export function counterText(position, total, page = 1, pages = 1) {
80
80
  return `${position} / ${total}${pages > 1 ? ` · ${page}/${pages}` : ""}`;
81
81
  }
82
82
 
83
+ /**
84
+ * FR-03: the link an event target sits in. `slide` is the id of a `slide:<id>` link (the renderer marks its anchor with `data-opf-slide-link`),
85
+ * `link` is the anchor, and a target in no link gives undefined. A player or presenter jumps to a slide link itself and leaves every other link to the browser.
86
+ */
87
+ export function linkAt(target) {
88
+ const anchor = target && typeof target.closest === "function" ? target.closest("a[href]") : null;
89
+ if (!anchor) return undefined;
90
+ const slide = anchor.getAttribute("data-opf-slide-link");
91
+ return { link: anchor, ...(slide ? { slide } : {}) };
92
+ }
93
+
94
+ /** FR-03: the document index of the slide with this id, or -1 (the id of a slide link names a slide of the deck). */
95
+ export function slideIndexById(document, id) {
96
+ const slides = Array.isArray(document?.slides) ? document.slides : [];
97
+ return slides.findIndex((slide) => isObject(slide) && slide.id === id);
98
+ }
99
+
83
100
  /** Whole numbers only: "3", " 3 " and 3 are slide 3; "", "3.5", "x" and 0 are not slide numbers. */
84
101
  export function parseSlideNumber(value) {
85
102
  if (typeof value === "number") return Number.isInteger(value) ? value : undefined;
package/dist/element.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // the slide a page shows is the slide the preview, the editor and the PDF show. Importing this module touches no DOM, so it
3
3
  // is safe on a server (Next.js); `defineOpfDeck()` registers the tag in a browser.
4
4
  import {
5
- DeckError, counterText, createCursor, createDeckStore, isRtlLanguage, localIsoDate, parseDeckDocument, parseSlideNumber, presentableIndexes,
6
- prepareSlideSvg, sanitizeSvgTree, slideInfo, slideLabel, svgDimensions, plainText,
5
+ DeckError, counterText, createCursor, createDeckStore, isRtlLanguage, linkAt, localIsoDate, parseDeckDocument, parseSlideNumber, presentableIndexes,
6
+ prepareSlideSvg, sanitizeSvgTree, slideIndexById, slideInfo, slideLabel, svgDimensions, plainText,
7
7
  } from "./deck-runtime.js";
8
8
  import { loadPreviewFonts } from "./preview-fonts.js";
9
9
  import { toSvg } from "./svg.js";
@@ -347,6 +347,14 @@ function createElementClass() {
347
347
  parts.next.addEventListener("click", () => this.next());
348
348
  parts.present.addEventListener("click", () => { this.present().catch((error) => this.#report(error instanceof DeckError ? error : new DeckError("present-failed", error?.message ?? "Could not start the slideshow.", { cause: error }), false)); });
349
349
  parts.viewport.addEventListener("keydown", (event) => this.#onKey(event));
350
+ // FR-03: a slide link in the slide shows that slide (a hidden slide is not in the sequence, so a link to it goes nowhere here); other links are the browser's.
351
+ parts.viewport.addEventListener("click", (event) => {
352
+ const slide = linkAt(event.composedPath?.()[0] ?? event.target)?.slide;
353
+ if (slide === undefined) return;
354
+ event.preventDefault();
355
+ const index = slideIndexById(this.#deck, slide);
356
+ if (index >= 0 && this.#cursor?.sequence.includes(index)) { this.#announce = true; this.#go(() => this.#cursor?.gotoIndex(index)); }
357
+ });
350
358
  parts.viewport.addEventListener("pointerdown", (event) => { if (event.pointerType !== "mouse") this.#pointer = { x: event.clientX, y: event.clientY, id: event.pointerId }; });
351
359
  parts.viewport.addEventListener("pointerup", (event) => this.#onPointerUp(event));
352
360
  parts.viewport.addEventListener("pointercancel", () => { this.#pointer = undefined; });
@@ -115,3 +115,27 @@ export function separateLigatures(svg) {
115
115
  // Candidates that were measured and did not qualify. Never bundled or selected automatically.
116
116
  // Akasia (Aptos) was dropped: its repository is gone and Intos, pinned and measured identical to Aptos 2.01, replaces it.
117
117
  export const EXPERIMENTAL_FONT_CANDIDATES = Object.freeze([Object.freeze({requestedFamily:"Segoe UI",substitute:"Selawik",source:"https://github.com/microsoft/Selawik/releases/tag/1.01",note:"Microsoft's OFL Segoe UI fallback, measured 2026-09-29 against Segoe UI 5.71: mean width difference 0.16% and up to 2.5% in regular, 2.65% in italic (no italic faces), 1.75% in Semibold, 349 code points, lowercase 5% shorter, hhea ascent 8% smaller. Fails the metric bar; not bundled. See docs/evidence/font-replacements-20260923/metric-candidates-20260929.json in core."})]);
118
+
119
+ // opf#1472: glyphs a bundled face draws wrongly. The vendored files stay byte for byte as upstream ships them, so a known bad glyph is
120
+ // recorded here instead, and the script-font planner (script-fonts.js) draws that one character from `replacement` (the first loaded
121
+ // family that has it) at the advance the bad face gave it. A row names the exact file (`sha256`, the one in the face's PROVENANCE.json):
122
+ // a fixed upstream release changes the hash, and test/glyph-defects.mjs fails until the row is removed.
123
+ const INTOS_BAD_DCROAT = Object.freeze({
124
+ repository: "https://github.com/muglug/intos", commit: "fef9315c14da9e4b23b4c3cac8e718998d4e4736", release: "1.000",
125
+ defect: "U+0111 (glyph dcroat) is a mirrored d with a bar to its right in the regular faces, and a d whose bar is drawn as broken blocks in the bold faces; the italic and serif faces draw it correctly",
126
+ codePoints: Object.freeze([0x111]), replacement: Object.freeze(["Arimo", "Noto Sans", "Roboto"]), issue: "OpenPresentation/opf#1472"
127
+ });
128
+ const intosFace = (family, weight, file, sha256) => Object.freeze({family, weight, italic: false, file, sha256, ...INTOS_BAD_DCROAT});
129
+ export const GLYPH_DEFECTS = Object.freeze([
130
+ intosFace("Intos", 400, "Intos-Regular.ttf", "4de204b6414d30f9f49b9375dc9b71ccea1683e55ac37de6c8d541abbc760eea"),
131
+ intosFace("Intos", 700, "Intos-Bold.ttf", "8afd148fff67d6426d0d6906d4c6232886aedc81a7832544806e6c93c44340ab"),
132
+ intosFace("Intos Display", 400, "IntosDisplay-Regular.ttf", "b652fdab5e8939540f084529a507ddd158629985b8eee1b553ef05c46d131877"),
133
+ intosFace("Intos Display", 700, "IntosDisplay-Bold.ttf", "5055714a7215331b7786b10538138baa4dc969a8afe018bbf459f8b5395026d8"),
134
+ intosFace("Intos Narrow", 400, "IntosNarrow-Regular.ttf", "ea91acdb933f2f1919df688f154140b851191adf4ecb77f7d931724198ea23c1"),
135
+ intosFace("Intos Narrow", 700, "IntosNarrow-Bold.ttf", "59fd6e53b61ae483809ce1d8fc396357ec33d7beedef2e81f87da11551a99e51")
136
+ ]);
137
+ /** The known bad glyphs of the face `family` at `weight` and `italic`: `{codePoints, replacement}`, or undefined. */
138
+ export function glyphDefectsFor(family, weight, italic) {
139
+ const name = String(family).toLowerCase();
140
+ return GLYPH_DEFECTS.find(row => row.family.toLowerCase() === name && row.weight === weight && row.italic === !!italic);
141
+ }
package/dist/fonts.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TextMeasurement, TextStyle, ScriptRole } from "@openpresentation/opf/composition";
1
+ import type { ResolvedScriptFonts, TextMeasurement, TextStyle, ScriptRole } from "@openpresentation/opf/composition";
2
2
  import type { FontPolicyEntry } from "@openpresentation/opf/font-policy";
3
3
  import type { LazyFont } from "./fonts-node.js";
4
4
  import type {ToSvgOptions} from "./svg.js";
@@ -124,7 +124,7 @@ export interface ScriptFontProfile {
124
124
  heading?: ScriptFontSlots; body?: ScriptFontSlots;
125
125
  supplement?: { script: string; heading: string; body: string };
126
126
  script?: string; bcp47?: string; lang?: string; direction?: "ltr" | "rtl"; rtl?: boolean;
127
- languageSource?: "document" | "option" | "default"; scriptRole?: ScriptRole; serif?: boolean;
127
+ languageSource?: ResolvedScriptFonts["languageSource"]; scriptRole?: ScriptRole; serif?: boolean;
128
128
  }
129
129
  export interface ScriptRun { text: string; script: string; role: ScriptRole }
130
130
  export interface PlannedRun { text: string; family: string; own: boolean; stack?: string[] }
@@ -181,3 +181,6 @@ export declare function hasEmojiPresentation(text: string): boolean;
181
181
  export declare function hasMathNotation(text: string): boolean;
182
182
  /** Color faces of the manifest: resvg draws their monochrome stand-in (`rasterFamily`); browsers draw them in color. */
183
183
  export declare const COLOR_FONT_FACES: readonly { family: string; file: string; package: string; format: string; rasterFamily: string }[];
184
+ /** opf#1472: glyphs a bundled face draws wrongly; the preview draws each from the first loaded family of `replacement` at the bad glyph's advance. */
185
+ export declare const GLYPH_DEFECTS: readonly Readonly<{family:string;weight:number;italic:boolean;file:string;sha256:string;repository:string;commit:string;release:string;defect:string;codePoints:readonly number[];replacement:readonly string[];issue:string}>[];
186
+ export declare function glyphDefectsFor(family:string,weight:number,italic:boolean):typeof GLYPH_DEFECTS[number]|undefined;
package/dist/fonts.js CHANGED
@@ -5,6 +5,6 @@
5
5
  export { OPFFontError } from "./font-registry.js";
6
6
  export { FONT_POLICY, fontPolicyFor } from "@openpresentation/opf/font-policy";
7
7
  export { SYMBOL_SCRIPT, SYMBOL_PLACEHOLDER, SYMBOL_PREVIEW_FACES, SYMBOL_FACE_FAMILIES, isSymbolEncodedFamily, symbolPreviewFaces, symbolCodeOf, mapSymbolText } from "./symbol-fonts.js";
8
- export { FONT_COMPATIBILITY, EXPERIMENTAL_FONT_CANDIDATES, disabledFeaturesFor } from "./font-compatibility.js";
8
+ export { FONT_COMPATIBILITY, GLYPH_DEFECTS, glyphDefectsFor, EXPERIMENTAL_FONT_CANDIDATES, disabledFeaturesFor } from "./font-compatibility.js";
9
9
  export { EMOJI_FONT_FAMILIES, SCRIPT_FONT_FAMILIES, SCRIPT_FONT_REPLACEMENTS, createScriptFonts, createScriptTextMeasurement, designatedFamilies, glyphFallbackFamilies, detectScripts, hasEmojiPresentation, hasMathNotation, itemizeScripts, openTypeLanguage, scriptFontAliases, scriptFontRole, sizeAdjustFor, adjustedFontSize, lineAscentFor, baselineShift, scriptOfCharacter, textRole } from "./script-fonts.js";
10
10
  export { COLOR_FONT_FACES } from "./color-fonts.js";
package/dist/index.d.ts CHANGED
@@ -345,6 +345,8 @@ export interface MeasurePicturesOptions {
345
345
  /** Called with `picture-not-measured` for a picture that could not be read or decoded; its scrim keeps the worst case. */
346
346
  onDiagnostic?: (diagnostic: RenderDiagnostic) => void;
347
347
  }
348
+ /** FR-03: true for an http, https, mailto or tel link, the links a viewer opens outside the deck (never `slide:<id>`, `javascript:` or `data:`). */
349
+ export declare function isOpenableLink(href: unknown): href is string;
348
350
  /**
349
351
  * LH-145: the luminance sampler of a deck's picture backgrounds, each decoded once. Pass the result as `pictureLuminance` to `toSvg` and to the
350
352
  * PPTX export, so the automatic scrim is sized for the picture under the text in both. Never rejects for a picture it cannot read.
@@ -0,0 +1,38 @@
1
+ /** What a live frame may do: scripts, its own origin, pop-ups and forms; no camera, microphone or location. */
2
+ export declare const LIVE_EMBED_SANDBOX: string;
3
+
4
+ /**
5
+ * Whether an address is on the origin of the page that presents it. Such a page is never shown live, whatever the host's `embeds`
6
+ * option says: a sandbox that allows scripts and its own origin does not contain a page of the host's own origin.
7
+ */
8
+ export declare function isSameOriginPage(src: string, origin: string | undefined): boolean;
9
+
10
+ /** An embed a slide's SVG draws (the renderer marks it with `data-opf-embed*`): its path, address, title and the element whose box is the frame. */
11
+ export interface DrawnEmbed { path: string; src: string; title: string; area: Element }
12
+
13
+ /** The embeds an SVG slide draws. */
14
+ export declare function embedsOf(svg: Element | null | undefined): DrawnEmbed[];
15
+
16
+ export interface MountLiveEmbedsOptions {
17
+ /** The element that holds the slide's SVG; the frames go in a layer appended to it. */
18
+ host: HTMLElement;
19
+ svg: Element;
20
+ /** The host's answer for an address: true shows that page live. Absent: no page is shown live. */
21
+ embeds?: (src: string) => boolean;
22
+ /** The presenting page's origin. Default: the document's. */
23
+ origin?: string;
24
+ document?: Document;
25
+ }
26
+
27
+ export interface LiveEmbeds {
28
+ frames: HTMLIFrameElement[];
29
+ /** Remove the layer and its frames. */
30
+ destroy(): void;
31
+ }
32
+
33
+ /**
34
+ * Put a sandboxed frame (`sandbox`, `referrerpolicy="no-referrer"`, `loading="lazy"`, no `allow`) over each embed of `svg` that the host
35
+ * allows. The static form stays under it until the frame loads. A click on a live frame never changes the slide; Tab enters a frame
36
+ * only after a click on it.
37
+ */
38
+ export declare function mountLiveEmbeds(options: MountLiveEmbedsOptions): LiveEmbeds;