@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 +3 -3
- package/dist/chart-options.js +3 -2
- package/dist/charts.js +163 -15
- package/dist/deck-runtime.js +17 -0
- package/dist/element.js +10 -2
- package/dist/font-compatibility.js +24 -0
- package/dist/fonts.d.ts +5 -2
- package/dist/fonts.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/live-embeds.d.ts +38 -0
- package/dist/live-embeds.js +93 -0
- package/dist/pdf-vector.js +37 -4
- package/dist/player.d.ts +6 -0
- package/dist/player.js +23 -5
- package/dist/preview-fonts-node.js +1 -1
- package/dist/raster-images.js +20 -6
- package/dist/script-fonts.js +67 -2
- package/dist/shapes.js +21 -3
- package/dist/svg.d.ts +2 -0
- package/dist/svg.js +155 -27
- package/package.json +8 -4
package/dist/svg.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
layoutTable, fitList, fitRichText, composeSlide, emphasisSurface, resolveTextStyle, textWidthMeasurer, fitText, styledText, LIST_RULE_WIDTH, LIST_ACCENT_RULE_WIDTH, textColorForFill, chartColorForFill,
|
|
5
5
|
resolveColorRef as resolveCoreColorRef, colorTransform, applyColorTransform, stackedText, resolveScriptFonts, paragraphDirection, physicalAlignment, itemAlignment, patternRuns, isolateNumbers,
|
|
6
|
-
metricTrendMark as coreMetricTrendMark, metricPillFill, metricValueColor, tokenizeCode, codeLineRuns, codeSyntaxPaletteForRoles, readableSchemeColor, resolveChartData,
|
|
6
|
+
metricTrendMark as coreMetricTrendMark, metricPillFill, metricValueColor, metricGaugeDrawing, tokenizeCode, codeLineRuns, codeSyntaxPaletteForRoles, readableSchemeColor, resolveChartData,
|
|
7
7
|
timelineMarkerShapes, timelineTextColor, layoutWatermark, tableHighlightColor,
|
|
8
8
|
arrangementPaint, colorContrast,
|
|
9
9
|
codeHighlightLines, codeLineNumbers, codeHighlightBands, codeHighlightColors, fitImage, pictureOverlay, intrinsicImageAspect, intrinsicImageSize, diagramPalette, paintDiagramGroup, iconPathData,
|
|
@@ -12,6 +12,11 @@ import {
|
|
|
12
12
|
// The renderer is a library: it never imports a catalog. Hosts register theirs (`options.catalogs`, core `Catalog[]`, for
|
|
13
13
|
// example `defaultCatalog` from `@openpresentation/gallery`) and core resolves every reference against them.
|
|
14
14
|
import {
|
|
15
|
+
collectSlideLinks,
|
|
16
|
+
embedCardLayout,
|
|
17
|
+
embedSite,
|
|
18
|
+
embedTitle,
|
|
19
|
+
embedValue,
|
|
15
20
|
hasContentVariables,
|
|
16
21
|
isTemplate,
|
|
17
22
|
resolveDrawnFontFamilies,
|
|
@@ -25,7 +30,7 @@ import { fontPolicyFor } from "@openpresentation/opf/font-policy";
|
|
|
25
30
|
import { disabledFeaturesStyle } from "./font-compatibility.js";
|
|
26
31
|
import { isDatasetChart, isDatasetTable, renderCatalogChart } from "./charts.js";
|
|
27
32
|
import { renderCaption, renderFootnotes } from "./annotations.js";
|
|
28
|
-
import { renderConnector, renderShapeBlock, strokeElements } from "./shapes.js";
|
|
33
|
+
import { linkAnchorAttrs, renderConnector, renderShapeBlock, strokeElements } from "./shapes.js";
|
|
29
34
|
import { drawnFaces } from "./drawn-faces.js";
|
|
30
35
|
import { dataUrlFsType, embeddingAllowed } from "./font-fstype.js";
|
|
31
36
|
import { rejectRenamedOptions, selectSlides } from "./slide-sources.js";
|
|
@@ -80,6 +85,7 @@ const ROOT_PAYLOAD_FIELDS = [
|
|
|
80
85
|
"bullets",
|
|
81
86
|
"image",
|
|
82
87
|
"video",
|
|
88
|
+
"embed",
|
|
83
89
|
"chart",
|
|
84
90
|
"table",
|
|
85
91
|
"code",
|
|
@@ -94,6 +100,7 @@ const FIELD_TYPE = Object.freeze({
|
|
|
94
100
|
bullets: "list",
|
|
95
101
|
image: "image",
|
|
96
102
|
video: "video",
|
|
103
|
+
embed: "embed",
|
|
97
104
|
chart: "chart",
|
|
98
105
|
table: "table",
|
|
99
106
|
code: "code",
|
|
@@ -309,7 +316,15 @@ function untrackLast(content) {
|
|
|
309
316
|
}
|
|
310
317
|
const sameBox = (a, b) => !!a && !!b && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
311
318
|
|
|
312
|
-
const LINK_URL = /^(https?:|mailto:|tel:)/i;
|
|
319
|
+
const LINK_URL = /^(https?:|mailto:|tel:|slide:)/i;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* FR-03: whether a link opens outside the deck: the schemes the renderer draws as a link except `slide:<id>` (a viewer shows that slide itself).
|
|
323
|
+
* A host that opens links for a read-only slide view asks this and ignores every other address (a `javascript:` or `data:` link is never opened).
|
|
324
|
+
*/
|
|
325
|
+
export function isOpenableLink(href) {
|
|
326
|
+
return typeof href === "string" && LINK_URL.test(href) && !/^slide:/i.test(href);
|
|
327
|
+
}
|
|
313
328
|
|
|
314
329
|
// What the renderer paints with, from the records core's `resolveSlideContext` resolved (slide design, then deck design, then
|
|
315
330
|
// theme, then the engine default, per field: the one order every engine uses). The theme and the color scheme keep their
|
|
@@ -667,6 +682,11 @@ export function toSvg(input, slides, options) {
|
|
|
667
682
|
return numbers.map(number => renderResolvedSlide(resolved, number - 1, drawn));
|
|
668
683
|
}
|
|
669
684
|
|
|
685
|
+
// FR-03: the ids the slide links of the deck name, collected once per resolved deck.
|
|
686
|
+
function linkedSlideIds(resolved) {
|
|
687
|
+
return (resolved.slideLinkIds ??= new Set(collectSlideLinks(resolved.presentation.slides).map(entry => entry.id)));
|
|
688
|
+
}
|
|
689
|
+
|
|
670
690
|
function renderResolvedSlide(resolved, slideIndex, options) {
|
|
671
691
|
const bound = resolved.slides[slideIndex];
|
|
672
692
|
// Paint with the same script-aware measurement composition used.
|
|
@@ -717,6 +737,8 @@ function renderResolvedSlide(resolved, slideIndex, options) {
|
|
|
717
737
|
role: "group",
|
|
718
738
|
"aria-roledescription": "slide",
|
|
719
739
|
"aria-label": title,
|
|
740
|
+
// FR-03: the id of a slide another slide links to (`slide:<id>`), so a PDF page knows which slide it is. Other slides stay as they were.
|
|
741
|
+
"data-opf-slide": linkedSlideIds(resolved).has(bound.slide.id) ? bound.slide.id : undefined,
|
|
720
742
|
viewBox: `0 0 ${width} ${height}`,
|
|
721
743
|
width,
|
|
722
744
|
height,
|
|
@@ -1108,6 +1130,8 @@ function renderPayload(item, box, bound, options) {
|
|
|
1108
1130
|
return renderShapeBlock(item, shapeHelpers(item, bound, options));
|
|
1109
1131
|
case "video":
|
|
1110
1132
|
return renderMedia(item, box, bound, options);
|
|
1133
|
+
case "embed":
|
|
1134
|
+
return renderEmbed(item, box, bound, options);
|
|
1111
1135
|
case "code":
|
|
1112
1136
|
return renderCode(item, box, bound, options);
|
|
1113
1137
|
case "metric":
|
|
@@ -1127,7 +1151,8 @@ function renderPayload(item, box, bound, options) {
|
|
|
1127
1151
|
|
|
1128
1152
|
function renderTextPayload(item, box, bound, options) {
|
|
1129
1153
|
// LH-63: a text whose first line is a run-in heading draws core's runs (item.runs: the same characters, the heading bold).
|
|
1130
|
-
|
|
1154
|
+
// The runs draw only with a fit core laid out from them (richLines); a plain fit draws the authored value.
|
|
1155
|
+
const value = item.runs && (!item.text || "richLines" in item.text) ? item.runs : item.value;
|
|
1131
1156
|
return (Array.isArray(value) ? renderRichTextBox : renderTextBox)(Array.isArray(value) ? value : flattenText(value), box, bound, {
|
|
1132
1157
|
path: item.path,
|
|
1133
1158
|
// Core resolves one alignment per composed item for every engine, from the slide's design, the deck's design
|
|
@@ -1164,7 +1189,7 @@ function renderList(item, box, bound, options) {
|
|
|
1164
1189
|
return tag('g',{...traceAttrs(options,item.path),...(item.listColumns.some(column=>column.text.overflow)?{'data-opf-overflow':'true'}:{})},columns.join('\n'));
|
|
1165
1190
|
}
|
|
1166
1191
|
const scale=Math.min(bound.design.dimensions.width,bound.design.dimensions.height)/720;
|
|
1167
|
-
const fit=item.text?.listEntries?item.text:fitList(item.value,box,25*scale,((bound.composition??bound.geometry.composition).
|
|
1192
|
+
const fit=item.text?.listEntries?item.text:fitList(item.value,box,25*scale,((bound.composition??bound.geometry.composition).minFontSizePx??16)*scale,{style:{fontFamily:bound.design.fonts.body,fontWeight:400,path:item.path},...(bound.design.fonts.code?{codeFontFamily:bound.design.fonts.code}:{}),textMeasurement:options.textMeasurement,...(item.payload?.numbering!==undefined?{numbering:item.payload.numbering}:{})});
|
|
1168
1193
|
return tag('g',{...traceAttrs(options,item.path),...(fit.overflow?{'data-opf-overflow':'true'}:{})},listEntriesSvg(item,fit,bound,options).join('\n'));
|
|
1169
1194
|
}
|
|
1170
1195
|
|
|
@@ -1445,7 +1470,7 @@ function renderImage(item, box, bound, options) {
|
|
|
1445
1470
|
const description=asset.alt??asset.title??'Image';
|
|
1446
1471
|
const label=`Image unavailable\n${description}`;
|
|
1447
1472
|
const style=resolveTextStyle({fontFamily:bound.design.fonts.body,fontWeight:600,path:item.path},options.textMeasurement);
|
|
1448
|
-
const fit=fitText(label,inner,20*scale,((bound.composition??bound.geometry.composition).
|
|
1473
|
+
const fit=fitText(label,inner,20*scale,((bound.composition??bound.geometry.composition).minFontSizePx??16)*scale,textWidthMeasurer(style,options.textMeasurement));
|
|
1449
1474
|
const textColor=textColorForFill(fill,bound.design.colors.text);
|
|
1450
1475
|
reportDiagnostic({code:'unresolved-asset',path:item.path,message,reason,source:asset.src,assetId:missingReference,description,placeholder:fit.overflow?'icon':'label'},options);
|
|
1451
1476
|
const children = [
|
|
@@ -1540,6 +1565,53 @@ function renderMedia(item, box, bound, options) {
|
|
|
1540
1565
|
return tag("g", traceAttrs(options, item.path), children.join("\n"));
|
|
1541
1566
|
}
|
|
1542
1567
|
|
|
1568
|
+
// FR-08: an embed is drawn as its static form, wherever the page is not shown live: the `preview` picture whole (contain) on the scheme's
|
|
1569
|
+
// surface color, or, without a preview (or one that does not resolve), the card (core embedCardLayout: a link badge, the title and the
|
|
1570
|
+
// site name). The frame is a link to `src` that opens a new tab; a web presenter whose host allows the page reads the frame's
|
|
1571
|
+
// data-opf-embed attributes and puts a sandboxed iframe over it (the engines never load `src`). The transparent rect in the link is
|
|
1572
|
+
// the area a PDF link annotation covers.
|
|
1573
|
+
function renderEmbed(item, box, bound, options) {
|
|
1574
|
+
const embed = embedValue(item.value);
|
|
1575
|
+
if (!embed) return "";
|
|
1576
|
+
const title = embedTitle(item.value), site = embedSite(embed.src), scale = Math.min(bound.design.dimensions.width, bound.design.dimensions.height) / 720;
|
|
1577
|
+
const frame = { x: box.x, y: box.y, width: box.width, height: box.height };
|
|
1578
|
+
const children = [];
|
|
1579
|
+
let picture;
|
|
1580
|
+
if (embed.preview !== undefined) {
|
|
1581
|
+
const resolved = resolveImageSource({ value: embed.preview, path: item.path }, bound, options);
|
|
1582
|
+
if (resolved.drawable) picture = resolved.source;
|
|
1583
|
+
else {
|
|
1584
|
+
const reason = resolved.missingReference ? "missing-reference" : "unsupported-source";
|
|
1585
|
+
const message = unresolvedImageMessage("Embed preview", embed.preview, resolved.missingReference, "the preview draws the embed's card instead");
|
|
1586
|
+
if (options.strictAssets) throw new OPFRenderError("unresolved-asset", message, { path: `${item.path}.preview`, reason });
|
|
1587
|
+
reportDiagnostic({ code: "unresolved-asset", path: `${item.path}.preview`, message, reason, source: embed.preview, assetId: resolved.missingReference, description: title, placeholder: "card" }, options);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
if (picture !== undefined) {
|
|
1591
|
+
children.push(tag("rect", { ...HIDDEN, x: frame.x, y: frame.y, width: frame.width, height: frame.height, fill: bound.design.colors.surface, ...traceAttrs(options, item.path) }));
|
|
1592
|
+
children.push(tag("image", { ...HIDDEN, href: picture, x: frame.x, y: frame.y, width: frame.width, height: frame.height, preserveAspectRatio: "xMidYMid meet" }));
|
|
1593
|
+
} else {
|
|
1594
|
+
const card = embedCardLayout({ frame, title, site, headingFamily: bound.design.fonts.heading, bodyFamily: bound.design.fonts.body, scale,
|
|
1595
|
+
minFontSizePx: (bound.composition ?? bound.geometry.composition).minFontSizePx ?? 16, measurement: options.textMeasurement });
|
|
1596
|
+
children.push(tag("rect", { ...HIDDEN, x: frame.x, y: frame.y, width: frame.width, height: frame.height, rx: stableNumber(card.radius), fill: bound.design.colors.surface, stroke: bound.design.colors.border, "stroke-width": 1, ...traceAttrs(options, item.path) }));
|
|
1597
|
+
children.push(tag("circle", { ...HIDDEN, cx: stableNumber(card.icon.badge.x + card.icon.badge.width / 2), cy: stableNumber(card.icon.badge.y + card.icon.badge.height / 2), r: stableNumber(card.icon.badge.width / 2), fill: bound.design.colors.primary }));
|
|
1598
|
+
children.push(tag("path", { ...HIDDEN, d: `M ${card.icon.points.map(([x, y]) => `${stableNumber(x)} ${stableNumber(y)}`).join(" L ")} Z`, fill: readableSchemeColor(bound.design.colors.primary, bound.design.roles).hex }));
|
|
1599
|
+
for (const [text, fill] of [[card.title, bound.design.colors.text], [card.site, bound.design.colors.mutedText]]) {
|
|
1600
|
+
if (!text) continue;
|
|
1601
|
+
const family = fontStack(text.style.fontFamily, bound.design.fontScheme.type);
|
|
1602
|
+
children.push(tag("g", { "data-opf-embed-text": text === card.title ? "title" : "site" }, text.lines.map((line, index) => tag("text", {
|
|
1603
|
+
x: stableNumber(text.box.x + text.box.width / 2), y: stableNumber(text.box.y + text.fontSize + index * text.lineHeight), "text-anchor": "middle", "font-family": family, "font-size": stableNumber(text.fontSize),
|
|
1604
|
+
"font-weight": text.style.fontWeight === 400 ? undefined : text.style.fontWeight, fill
|
|
1605
|
+
}, escapeText(line))).join("\n")));
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
// The area a link annotation covers, and what a presenter measures to put a live frame over this one.
|
|
1609
|
+
children.push(tag("rect", { ...HIDDEN, "data-opf-link-area": "true", x: frame.x, y: frame.y, width: frame.width, height: frame.height, fill: "none", "pointer-events": "all" }));
|
|
1610
|
+
const link = tag("a", { ...linkAnchorAttrs(embed.src, { newTab: true }), "aria-label": title }, children.join("\n"));
|
|
1611
|
+
return tag("g", { ...traceAttrs(options, item.path), "data-opf-embed": item.path, "data-opf-embed-src": embed.src, "data-opf-embed-title": title,
|
|
1612
|
+
"data-opf-embed-x": stableNumber(frame.x), "data-opf-embed-y": stableNumber(frame.y), "data-opf-embed-width": stableNumber(frame.width), "data-opf-embed-height": stableNumber(frame.height) }, link);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1543
1615
|
function renderCode(item, box, bound, options) {
|
|
1544
1616
|
const layout = item.codeLayout;
|
|
1545
1617
|
if (!layout) throw new OPFRenderError('missing-code-layout', 'Code rendering requires a coordinated core build with shared code geometry.', {path:item.path});
|
|
@@ -1615,6 +1687,8 @@ function renderMetric(item, box, bound, options) {
|
|
|
1615
1687
|
const pillFill=layout.deltaPill?metricPillFill(backdrop,bound.design.colors.text):undefined;
|
|
1616
1688
|
if (layout.deltaPill) { const pill=layout.deltaPill.box; children.push(tag('rect',{...HIDDEN,x:stableNumber(pill.x),y:stableNumber(pill.y),width:stableNumber(pill.width),height:stableNumber(pill.height),rx:stableNumber(layout.deltaPill.radius),fill:pillFill,...(options.trace?{'data-opf-metric-role':'pill'}:{})})); }
|
|
1617
1689
|
const trendMark=metricTrendMark(layout,bound,pillFill??backdrop);
|
|
1690
|
+
// FR-07, part 3: a gauge (layout.gauge) draws core's plan under the text: the arcs as the blockArc preset's outline, the target tick and the ends' labels.
|
|
1691
|
+
if (layout.gauge) children.push(renderGauge(item,layout.gauge,bound,backdrop,options));
|
|
1618
1692
|
// LH-53: a unit on its value's line is part of the figure and takes the value's color.
|
|
1619
1693
|
// LH-135: a label drawn as the metric's eyebrow takes the eyebrow's color on its backdrop (eyebrowFill), in capitals with core's tracking.
|
|
1620
1694
|
const partFill=part=>trendMark&&(part.role==='trend'||part.role==='delta')?trendMark.color:part.role==='value'||part.role==='unit'&&layout.arrangement==='inline-unit'?metricValueColor(bound.design.colors.primary,backdrop,bound.design.colors.text):layout.eyebrow&&part.role==='label'?eyebrowFill(bound.design,item):bound.design.colors.text;
|
|
@@ -1662,6 +1736,22 @@ function renderMetric(item, box, bound, options) {
|
|
|
1662
1736
|
return tag('g',{...traceAttrs(options,item.path),...(options.trace?{'data-opf-metric-container':'true'}:{})},children.join('\n'));
|
|
1663
1737
|
}
|
|
1664
1738
|
|
|
1739
|
+
// FR-07, part 3: the colors a gauge is drawn in (core metricGaugeDrawing), against the metric's backdrop. The PowerPoint export passes the same.
|
|
1740
|
+
function gaugeColors(bound,backdrop) {
|
|
1741
|
+
const text=bound.design.colors.text;
|
|
1742
|
+
return {surface:backdrop,text,primary:bound.design.colors.primary,muted:bound.design.colors.mutedText,resolve:name=>String(resolveColorRef(name,bound,text)??text).slice(0,7).toUpperCase()};
|
|
1743
|
+
}
|
|
1744
|
+
// FR-07, part 3: a metric's gauge. Each arc is PowerPoint's blockArc preset at its frame and adjustments (core presetGeometry draws its
|
|
1745
|
+
// outline), so the preview draws what the native shapes draw; the target is a line, the ends' labels text centered under the arc's ends.
|
|
1746
|
+
function renderGauge(item,gauge,bound,backdrop,options) {
|
|
1747
|
+
const drawing=metricGaugeDrawing(gauge,gaugeColors(bound,backdrop)),out=[];
|
|
1748
|
+
for (const arc of drawing.arcs) out.push(tag('path',{...HIDDEN,d:arc.d,transform:`translate(${stableNumber(arc.frame.x)} ${stableNumber(arc.frame.y)})`,fill:arc.fill,...(options.trace?{'data-opf-metric-role':'mark','data-opf-gauge-part':arc.part}:{})}));
|
|
1749
|
+
if (drawing.target) { const t=drawing.target; out.push(tag('line',{...HIDDEN,x1:stableNumber(t.x1),y1:stableNumber(t.y1),x2:stableNumber(t.x2),y2:stableNumber(t.y2),stroke:t.color,'stroke-width':stableNumber(t.width),...(options.trace?{'data-opf-metric-role':'mark','data-opf-gauge-part':t.part}:{})})); }
|
|
1750
|
+
for (const {part,color,end} of drawing.ends) out.push(tag('text',{x:stableNumber(end.x),y:stableNumber(end.baseline),'text-anchor':'middle','font-family':fontStack(gauge.endStyle.fontFamily,bound.design.fontScheme.type),'font-size':stableNumber(end.fontSize),
|
|
1751
|
+
'font-weight':gauge.endStyle.fontWeight,'xml:space':'preserve',style:'white-space:pre','text-rendering':'geometricPrecision',fill:color,direction:'ltr',...(options.trace?{'data-opf-metric-role':'mark','data-opf-gauge-part':part}:{})},escapeText(end.text)));
|
|
1752
|
+
return tag('g',{...traceAttrs(options,`${item.path}.gauge`)},out.join('\n'));
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1665
1755
|
// The trend arrow and color for a laid-out metric (core metricTrendMark); undefined without a trend.
|
|
1666
1756
|
function metricTrendMark(layout,bound,background) {
|
|
1667
1757
|
return coreMetricTrendMark(layout,{background,neutral:bound.design.roles.neutrals.trendNeutral.hex});
|
|
@@ -1710,11 +1800,11 @@ function renderTimeline(item, box, bound, options) {
|
|
|
1710
1800
|
if(!layout)throw new OPFRenderError('missing-timeline-layout','Timeline rendering requires a coordinated core build with shared timeline geometry.',{path:item.path});
|
|
1711
1801
|
const scale=Math.min(bound.design.dimensions.width,bound.design.dimensions.height)/720;
|
|
1712
1802
|
const background=bound.design.backgroundColor??bound.design.colors.background;
|
|
1713
|
-
const children=[tag('line',{...HIDDEN,...layout.connector,stroke:bound.design.colors.border,'stroke-width':3*scale,...traceAttrs(options,item.path)})];
|
|
1803
|
+
const children=[tag('line',{...HIDDEN,...layout.connector,stroke:bound.design.colors.border,'stroke-width':layout.lineWidth??3*scale,...traceAttrs(options,item.path)})];
|
|
1714
1804
|
for(const range of layout.ranges??[])children.push(tag('rect',{...HIDDEN,x:stableNumber(range.box.x),y:stableNumber(range.box.y),width:stableNumber(range.box.width),height:stableNumber(range.box.height),fill:bound.design.colors.primary,'fill-opacity':.32,stroke:background,'stroke-width':stableNumber(2*scale),...traceAttrs(options,range.path),...(options.trace?{'data-opf-timeline-range':range.eventIndex}:{})}));
|
|
1715
1805
|
for(const link of layout.rangeLinks??[])children.push(tag('line',{...HIDDEN,x1:stableNumber(link.x1),y1:stableNumber(link.y1),x2:stableNumber(link.x2),y2:stableNumber(link.y2),stroke:bound.design.colors.border,'stroke-width':stableNumber(scale),...traceAttrs(options,link.path),...(options.trace?{'data-opf-timeline-range-link':link.eventIndex}:{})}));
|
|
1716
1806
|
// LH-121: the connector up to the current event in the primary color, over the border-colored rest.
|
|
1717
|
-
if(layout.progress)children.push(tag('line',{...HIDDEN,...layout.progress,stroke:bound.design.colors.primary,'stroke-width':3*scale,...traceAttrs(options,item.path),...(options.trace?{'data-opf-timeline-progress':'true'}:{})}));
|
|
1807
|
+
if(layout.progress)children.push(tag('line',{...HIDDEN,...layout.progress,stroke:bound.design.colors.primary,'stroke-width':layout.lineWidth??3*scale,...traceAttrs(options,item.path),...(options.trace?{'data-opf-timeline-progress':'true'}:{})}));
|
|
1718
1808
|
// FA-11: status colors come from the deck (core's timelineMarkerShapes / timelineTextColor); a marker with no status draws the plain primary circle.
|
|
1719
1809
|
const statusColors={background,primary:bound.design.colors.primary,text:bound.design.colors.text,mutedText:bound.design.colors.mutedText};
|
|
1720
1810
|
for(const marker of layout.markers){
|
|
@@ -1742,9 +1832,14 @@ function renderTimeline(item, box, bound, options) {
|
|
|
1742
1832
|
return tag('g',{...traceAttrs(options,item.path),...(options.trace?{'data-opf-timeline-arrangement':layout.arrangement}:{})},children.join('\n'));
|
|
1743
1833
|
}
|
|
1744
1834
|
|
|
1835
|
+
// FR-07: how a color scale's scheme names resolve on this slide (the same ColorRef resolution fills use), and the slide's text color.
|
|
1836
|
+
function tableScaleColors(bound) {
|
|
1837
|
+
return {resolve:(name) => String(resolveColorRef(name, bound, "#000000")).slice(0, 7).toUpperCase(), text:bound.design.colors.text, background:bound.design.colors.background};
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1745
1840
|
function renderTable(item, box, bound, options) {
|
|
1746
1841
|
const scale = Math.min(bound.design.dimensions.width, bound.design.dimensions.height) / 720;
|
|
1747
|
-
const layout = layoutTable(item.value, box, {scale,
|
|
1842
|
+
const layout = layoutTable(item.value, box, {scale, minFontSizePx:(bound.composition ?? bound.geometry.composition).minFontSizePx, fontFamily:bound.design.fonts.body, ...(bound.design.fonts.code ? {codeFontFamily:bound.design.fonts.code} : {}), textMeasurement:options.textMeasurement, path:item.path, presentation:bound.presentation, ...(typeof bound.scriptFonts?.profile?.bcp47 === "string" ? {language:bound.scriptFonts.profile.bcp47} : {}), alignment:itemAlignment(bound.geometry.design.contentAlignment), ...(bound.geometry?.direction === "rtl" ? {direction:"rtl"} : {}), ...(item.tableGrowth ? {growth:item.tableGrowth} : {}), ...(item.tableHighlight ? {highlight:item.tableHighlight} : {}), ...(item.value?.colorScale ? {colorScale:tableScaleColors(bound)} : {})});
|
|
1748
1843
|
const children = [];
|
|
1749
1844
|
// LH-113: a highlighted row (table.highlight, or the rows the slide's texts name) draws on an accent tint of the surface.
|
|
1750
1845
|
const highlightFill = layout.rows.some((row) => row.cells.some((cell) => cell.highlighted)) ? tableHighlightColor(bound.design.colors.surface, bound.design.colors.primary, bound.design.colors.text) : undefined;
|
|
@@ -1755,11 +1850,12 @@ function renderTable(item, box, bound, options) {
|
|
|
1755
1850
|
const defaultEdges = [], explicitEdges = [];
|
|
1756
1851
|
for (const row of layout.rows) for (const cell of row.cells) {
|
|
1757
1852
|
const style = cell.style ?? {};
|
|
1758
|
-
|
|
1853
|
+
// FR-07: a number cell of a color scale takes the scale's fill (a fill of its own wins; the scale wins over the highlight tint).
|
|
1854
|
+
const defaultFill = cell.header ? bound.design.colors.primary : cell.scaled ? cell.scaled.fill : cell.highlighted ? highlightFill : bound.design.colors.surface;
|
|
1759
1855
|
const fill = style.fill == null
|
|
1760
1856
|
? defaultFill
|
|
1761
1857
|
: resolveColorRef(style.fill, bound, defaultFill);
|
|
1762
|
-
const defaultText = cell.header ? readableSchemeColor(fill, bound.design.roles).hex : textColorForFill(fill, bound.design.colors.text);
|
|
1858
|
+
const defaultText = cell.header ? readableSchemeColor(fill, bound.design.roles).hex : cell.scaled && style.fill == null ? cell.scaled.text : textColorForFill(fill, bound.design.colors.text);
|
|
1763
1859
|
const textFill = style.color == null
|
|
1764
1860
|
? defaultText
|
|
1765
1861
|
: resolveColorRef(style.color, bound, defaultText);
|
|
@@ -2116,19 +2212,24 @@ function scriptLine(text, style, bound, type, { rtl = false, numbers = rtl, plac
|
|
|
2116
2212
|
// `numbers` asks for it in a fragment of a flowing right-to-left line, which is one isolate across its fragments.
|
|
2117
2213
|
const escaped = text => escapeText(numbers && text ? isolateNumbers(text) : text);
|
|
2118
2214
|
const runs = value && scripts ? scripts.plan(value, style) : [{ text: value, own: true }];
|
|
2215
|
+
// opf#1472: a tracked line (letter-spacing; a single run draws without textLength) of the line's own face and glyphs replaced at their
|
|
2216
|
+
// exact advance flows like the single run it replaces: a rasterizer applies the letter-spacing again inside a positioned tspan's textLength.
|
|
2217
|
+
// An untracked line takes the positioned path below, as every multi-face line does.
|
|
2218
|
+
const replaced = style?.tracking && runs.some(run => run.advance !== undefined) && runs.every(run => run.own || run.advance !== undefined);
|
|
2219
|
+
if (replaced) placement = runPlacement = undefined;
|
|
2119
2220
|
if (!placement && runPlacement && runs.length > 1) placement = runPlacement;
|
|
2120
2221
|
// RR-38: PowerPoint's baseline of a line in Arabic Typesetting sits above core's (one em below the line top): the caller moves it up by `baselineShift` em.
|
|
2121
2222
|
const shiftOf = list => { const shift = baselineShift(list); return shift ? { baselineShift: shift } : {}; };
|
|
2122
2223
|
// FF-45: symbol runs (Wingdings, Symbol, Webdings codes drawn as their Unicode equivalents) are always positioned when the
|
|
2123
2224
|
// line is placed, one tspan per glyph at the verified symbol font's advance, so a single mapped glyph is never stretched to it.
|
|
2124
2225
|
const symbols = runs.some(run => run.symbol);
|
|
2125
|
-
if (runs.length === 1 && !(symbols && placement && placement.width > 0)) {
|
|
2226
|
+
if (runs.length === 1 && !replaced && !(symbols && placement && placement.width > 0)) {
|
|
2126
2227
|
const [run] = runs;
|
|
2127
2228
|
// RR-38: a replacement the policy scales (Arabic Typesetting -> Noto Naskh Arabic, 0.64) is drawn at the scaled size; the caller applies it.
|
|
2128
2229
|
return { content: isolate(escaped(run.own ? value : run.text)), family: run.own ? undefined : fontStack(run.stack ?? run.family, type), ...(run.sizeAdjust ? { sizeAdjust: run.sizeAdjust } : {}), ...shiftOf(runs) };
|
|
2129
2230
|
}
|
|
2130
2231
|
const baseSize = placement?.fontSize ?? fontSize;
|
|
2131
|
-
const adjusted = run => run.sizeAdjust && baseSize > 0 ? stableNumber(adjustedFontSize(baseSize, run.sizeAdjust)) : undefined;
|
|
2232
|
+
const adjusted = run => run.fontScale && baseSize > 0 ? stableNumber(baseSize * run.fontScale) : run.sizeAdjust && baseSize > 0 ? stableNumber(adjustedFontSize(baseSize, run.sizeAdjust)) : undefined;
|
|
2132
2233
|
const widths = placement && placement.width > 0 ? scripts.runWidths(runs, placement.fontSize, style) : undefined;
|
|
2133
2234
|
if (!widths) {
|
|
2134
2235
|
return { content: isolate(runs.map(run => run.own ? escaped(run.text)
|
|
@@ -2287,7 +2388,7 @@ function renderEmbeddedFonts(fonts = []) {
|
|
|
2287
2388
|
|
|
2288
2389
|
function renderRichTextBox(value, box, bound, config) {
|
|
2289
2390
|
const scale=Math.min(bound.design.dimensions.width,bound.design.dimensions.height)/720;
|
|
2290
|
-
const fit=config.fit??fitRichText(value,box,config.fontSize*scale,((bound.composition??bound.geometry.composition).
|
|
2391
|
+
const fit=config.fit??fitRichText(value,box,config.fontSize*scale,((bound.composition??bound.geometry.composition).minFontSizePx??16)*scale,{style:{fontFamily:config.fontFamily,fontWeight:config.fontWeight??400,path:config.path},...(bound.design.fonts.code?{codeFontFamily:bound.design.fonts.code}:{}),textMeasurement:config.options.textMeasurement});
|
|
2291
2392
|
if(fit.overflow&&!config.diagnosticsHandled){const diagnostic={code:'text-overflow',path:config.path,message:'Mixed-style text exceeds its cell at the minimum font size.'};reportDiagnostic(diagnostic,config.options);if((bound.composition??bound.geometry.composition).overflow==='error')throw new OPFRenderError('layout-overflow',diagnostic.message,{diagnostics:[diagnostic]});}
|
|
2292
2393
|
return renderRichLines(value,fit,box,bound,config);
|
|
2293
2394
|
}
|
|
@@ -2309,7 +2410,8 @@ function trimRichLineEdges(line,textMeasurement) {
|
|
|
2309
2410
|
if(!changed)return null;
|
|
2310
2411
|
let x=0;
|
|
2311
2412
|
for(const fragment of fragments){fragment.x=x;x+=fragment.width;}
|
|
2312
|
-
|
|
2413
|
+
// The trimmed line is its glyphs: no whitespace hangs from it any more.
|
|
2414
|
+
return {...line,fragments,width:x,hang:undefined,advance:undefined};
|
|
2313
2415
|
}
|
|
2314
2416
|
|
|
2315
2417
|
function richLineContext(value,fit,bound,config) {
|
|
@@ -2346,8 +2448,12 @@ function renderRichLines(value,fit,box,bound,config) {
|
|
|
2346
2448
|
const {edgeTrim,line,placed,baseline}=richLineGeometry(sourceLine,lineIndex,fit,box,bound,alignment,rtl,config.options.textMeasurement);
|
|
2347
2449
|
const lineHasTab=line.fragments.some(fragment=>fragment.kind==='tab');
|
|
2348
2450
|
const flow=naturalFlow&&!lineHasTab;
|
|
2349
|
-
|
|
2350
|
-
|
|
2451
|
+
// Whitespace that hangs at a soft wrap (core's RichTextLine.hang) takes no room: the line is aligned by its glyphs and its text,
|
|
2452
|
+
// whitespace included, reaches past them on its end side (the left of a right-to-left line). Core placed a measured line so already.
|
|
2453
|
+
// `span` is the advance of the text the line draws, from originX.
|
|
2454
|
+
const hang=line.hang>0?line.hang:0,span=hang?line.advance:line.width,glyphs=span-hang,hangLead=rtl?hang:0;
|
|
2455
|
+
const offset=(alignment==='right'?box.width-glyphs:alignment==='center'?(box.width-glyphs)/2:0)-hangLead;
|
|
2456
|
+
const originX=placed?placed.x+(edgeTrim?(sourceLine.hang>0?sourceLine.advance:sourceLine.width)-line.width:0):box.x+offset;
|
|
2351
2457
|
const firstFragment=line.fragments[0];
|
|
2352
2458
|
const renderFragment=(fragment,asFlow,edges={})=>{
|
|
2353
2459
|
const run=fragment.run;
|
|
@@ -2356,7 +2462,7 @@ function renderRichLines(value,fit,box,bound,config) {
|
|
|
2356
2462
|
// quantization drift. Height and baseline retain the selected font size.
|
|
2357
2463
|
// A right-to-left line places its fragments from the right edge (FF-19).
|
|
2358
2464
|
// Estimated (natural-flow) lines keep logical order; the browser reorders them.
|
|
2359
|
-
const fragmentX=rtl&&!naturalFlow?
|
|
2465
|
+
const fragmentX=rtl&&!naturalFlow?span-fragment.x-fragment.width:fragment.x;
|
|
2360
2466
|
const position=asFlow?{'baseline-shift':fragment.baselineShift?stableNumber(-fragment.baselineShift):undefined}:{x:stableNumber(originX+fragmentX),y:stableNumber(baseline+fragment.baselineShift)};
|
|
2361
2467
|
// A link run is drawn as PowerPoint draws one: underlined, in the scheme hyperlink color unless the run sets its own color.
|
|
2362
2468
|
const linked = fragment.kind !== 'marker' && typeof run.link === 'string' && LINK_URL.test(run.link);
|
|
@@ -2405,7 +2511,7 @@ function renderRichLines(value,fit,box,bound,config) {
|
|
|
2405
2511
|
// and outside the link, so every source offset still has a traced node whose text is its source text (an editor selects by offset;
|
|
2406
2512
|
// a selection ending after that space found no node). Without a trace the output is unchanged.
|
|
2407
2513
|
const cutSpace=config.options.trace&&endTrail&&!marker?tag(asFlow?'tspan':'text',{'data-opf-text-start':runOffsets[fragment.runIndex]+fragment.end-endTrail.length,'data-opf-text-end':runOffsets[fragment.runIndex]+fragment.end,'data-opf-segment':fragment.kind,...(asFlow?{}:{x:stableNumber(originX+fragmentX+gap+drawnWidth),y:position.y}),'xml:space':'preserve','font-family':scripted.family??fontStack(fragment.style.fontFamily,run.code===true?'monospace':bound.design.fontScheme.type),'font-size':stableNumber(adjustedFontSize(fragment.fontSize,scripted.sizeAdjust)),'font-weight':fragment.style.fontWeight,'font-style':fragment.style.italic?'italic':asFlow?'normal':undefined,fill:runFill},escapeText(endTrail)):'';
|
|
2408
|
-
if(linked)return tag('a',
|
|
2514
|
+
if(linked)return tag('a',linkAnchorAttrs(run.link,{newTab:true}),rendered)+cutSpace;
|
|
2409
2515
|
return rendered+cutSpace;
|
|
2410
2516
|
};
|
|
2411
2517
|
if(naturalFlow&&lineHasTab) {
|
|
@@ -2420,7 +2526,8 @@ function renderRichLines(value,fit,box,bound,config) {
|
|
|
2420
2526
|
// A flowing right-to-left line is one isolate across its fragments.
|
|
2421
2527
|
const fragments=line.fragments.map((fragment,index)=>renderFragment(fragment,flow,flow?{first:rtl&&!index,last:rtl&&index===line.fragments.length-1}:{}));
|
|
2422
2528
|
if(!flow)return fragments.join('\n');
|
|
2423
|
-
const
|
|
2529
|
+
const factor=alignment==='right'?1:alignment==='center'?.5:0;
|
|
2530
|
+
const x=(alignment==='right'?box.x+box.width:alignment==='center'?box.x+box.width/2:box.x)+hang*(rtl?factor-1:factor);
|
|
2424
2531
|
const first=line.fragments[0];
|
|
2425
2532
|
return tag('text',{x:stableNumber(x),y:stableNumber(baseline),'text-anchor':alignment==='right'?'end':alignment==='center'?'middle':'start','xml:space':'preserve','font-family':fontStack(first?.style.fontFamily??config.fontFamily,bound.design.fontScheme.type),'font-size':stableNumber(first?.fontSize??fit.fontSize),'font-weight':first?.style.fontWeight??config.fontWeight??400,'font-style':first?.style.italic?'italic':undefined,[NO_POLICY_FEATURES]:true},fragments.join(''));
|
|
2426
2533
|
});
|
|
@@ -2430,7 +2537,9 @@ function renderRichLines(value,fit,box,bound,config) {
|
|
|
2430
2537
|
if(index){const newline=/^(\r\n|\r|\n)/.exec(whole.slice(cursor));if(newline)cursor+=newline[0].length;}
|
|
2431
2538
|
const start=cursor;cursor+=(fit.lines[index]??'').length;
|
|
2432
2539
|
const alignment=lineAlignment(index);
|
|
2433
|
-
|
|
2540
|
+
// The line's start: its glyphs aligned, any whitespace hanging at its wrap after them (as drawn above).
|
|
2541
|
+
const glyphs=line.hang>0?line.advance-line.hang:line.width,hangLead=line.hang>0&&fit.directions?.[index]==='rtl'?line.hang:0;
|
|
2542
|
+
const offset=(alignment==='right'?box.width-glyphs:alignment==='center'?(box.width-glyphs)/2:0)-hangLead;
|
|
2434
2543
|
const placed=fit.placement?.lines[index];
|
|
2435
2544
|
return {start,end:cursor,x:placed?.x??box.x+offset,y:placed?.y??box.y+line.y,height:placed?.height??line.height,
|
|
2436
2545
|
...(naturalFlow&&line.fragments.some(fragment=>fragment.kind==='tab')?{spacing:'natural-chunks-estimated-tabs'}:{})};
|
|
@@ -2449,7 +2558,7 @@ function renderTextBox(text, box, bound, config) {
|
|
|
2449
2558
|
const scale = Math.min(bound.design.dimensions.width, bound.design.dimensions.height) / 720;
|
|
2450
2559
|
const style = config.textStyle ?? resolveTextStyle({fontFamily:config.fontFamily,fontWeight:config.fontWeight ?? 400,italic:config.italic ?? false,path:config.path},config.options.textMeasurement);
|
|
2451
2560
|
const fit = config.fit ?? fitText(String(text ?? ""), box, config.fontSize * scale,
|
|
2452
|
-
((bound.composition ?? bound.geometry.composition).
|
|
2561
|
+
((bound.composition ?? bound.geometry.composition).minFontSizePx ?? 16) * scale, textWidthMeasurer(style,config.options.textMeasurement));
|
|
2453
2562
|
if (fit.overflow && !config.diagnosticsHandled) {
|
|
2454
2563
|
const diagnostic = { code: "text-overflow", path: config.path,
|
|
2455
2564
|
message: "Text exceeds its cell at the minimum font size; shorten it, increase its space, or split the slide." };
|
|
@@ -2475,7 +2584,15 @@ function renderTextBox(text, box, bound, config) {
|
|
|
2475
2584
|
// The line's paragraph decides its direction: source offsets when layout has them, else the next match.
|
|
2476
2585
|
const found=sourceLine?sourceLine.start:source.indexOf(line,cursor),lineStart=found>=0?found:cursor;cursor=lineStart+line.length;
|
|
2477
2586
|
const rtl=fit.directions?fit.directions[index]==='rtl':boxRtl(lineStart);
|
|
2478
|
-
|
|
2587
|
+
// Whitespace that hangs at a soft wrap (core's TextLineSource.hang) takes no room: the glyphs are aligned and the text, its
|
|
2588
|
+
// whitespace included, reaches past them on the line's end side (the right of a left-to-right line, the left of a right-to-left
|
|
2589
|
+
// one). Core placed a measured line so already (placed.x, placed.width); `shift` is how far the text's anchor is from the glyphs'.
|
|
2590
|
+
const hang=placed?placed.hang??0:sourceLine?.hang>0?sourceLine.hang:0,lineRtl=placed?fit.directions?.[index]==='rtl':rtl;
|
|
2591
|
+
// A right-to-left line is drawn without its hanging whitespace, by its glyphs (below), as its native paragraph is anchored.
|
|
2592
|
+
const hangShift=lineRtl?0:hang*factor,hangLead=lineRtl?hang:0;
|
|
2593
|
+
const origin=placed?.x??x-((sourceLine?.advance??sourceLine?.width??0)-hang)*factor-hangLead;
|
|
2594
|
+
// The anchor point of the glyphs (the box edge or center), which an editor lays its input on.
|
|
2595
|
+
const glyphAnchor=placed?placed.x+hangLead+(placed.width-hang)*factor:x;
|
|
2479
2596
|
const tabs=sourceLine?.segments.some(segment=>segment.kind==='tab');
|
|
2480
2597
|
let content,family,positioned=false,trimWidth=0,sizeAdjust,shift=0;
|
|
2481
2598
|
if(tabs) content=sourceLine.segments.map(segment=>{
|
|
@@ -2494,8 +2611,12 @@ function renderTextBox(text, box, bound, config) {
|
|
|
2494
2611
|
else {
|
|
2495
2612
|
// PowerPoint ignores whitespace at either edge of a right-aligned right-to-left line (the glyph edge stays on the box edge, native check
|
|
2496
2613
|
// 2026-10-02), so a soft-wrapped line that keeps its trailing space, or a leading space, draws without it (RR-05).
|
|
2497
|
-
|
|
2498
|
-
|
|
2614
|
+
// A right-to-left line of any other alignment draws without the whitespace that hangs at its wrap too: the SVG sets it in an isolate
|
|
2615
|
+
// in a left-to-right text, where trailing whitespace would go to the right (Unicode bidi L1), while core and PowerPoint hang it on
|
|
2616
|
+
// the line's left; the glyphs are drawn where core aligned them (glyphAnchor).
|
|
2617
|
+
const edge=rtl&&alignment==='right'?/^(\s*)([\s\S]*?)(\s*)$/.exec(line):rtl&&hang>0?/^()([\s\S]*?)(\s*)$/.exec(line):null,trimmed=edge&&edge[2]&&(edge[1]||edge[3])?edge:null;
|
|
2618
|
+
// The whitespace that hangs at the wrap is core's measured hang (the advance its placement leaves for it).
|
|
2619
|
+
if(trimmed){const measureEdge=textWidthMeasurer(style,config.options.textMeasurement);trimWidth=measureEdge(trimmed[1],size)+(placed&&hang&&trimmed[3]?hang:measureEdge(trimmed[3],size));}
|
|
2499
2620
|
({content,family,positioned=false,sizeAdjust,baselineShift:shift=0}=scriptLine(styledText(trimmed?trimmed[2]:line,style),style,bound,type,{rtl,placement:placed?.width>0?{x:placed.x+trimWidth,width:placed.width-trimWidth,fontSize:size}:undefined,fontSize:size}));
|
|
2500
2621
|
}
|
|
2501
2622
|
// Positioned script runs carry their own x and textLength (FF-19).
|
|
@@ -2511,8 +2632,9 @@ function renderTextBox(text, box, bound, config) {
|
|
|
2511
2632
|
// rasterizer, so the line starts there instead of hanging from its middle or end. Estimated widths keep the anchor: the shaper's
|
|
2512
2633
|
// width differs from core's there, and the anchor keeps the edge.
|
|
2513
2634
|
const exactStart=!start&&factor>0&&style.tracking<0&&!rtl&&!trimWidth&&!!config.options.textMeasurement?.measure&&(placed?.width>0||sourceLine?.width>0);
|
|
2635
|
+
const hung=!start&&hangShift!==0;
|
|
2514
2636
|
return tag("text", {
|
|
2515
|
-
x: stableNumber(tabs||exactStart?origin:positioned?placed.x:placed?placed.x+placed.width*factor:x), y: stableNumber((placed?.baseline??startY + index * fit.lineHeight) - shift * size),
|
|
2637
|
+
x: stableNumber(tabs||exactStart?origin:positioned?placed.x:trimWidth?glyphAnchor:placed?placed.x+placed.width*factor:x+hangShift), y: stableNumber((placed?.baseline??startY + index * fit.lineHeight) - shift * size),
|
|
2516
2638
|
"text-anchor": start||exactStart?'start':anchor, "font-family": family ?? fontStack(style.fontFamily, type),
|
|
2517
2639
|
"font-size": stableNumber(adjustedFontSize(size,sizeAdjust)), "font-weight": style.fontWeight, "font-style": style.italic ? "italic" : undefined, fill: config.fill,
|
|
2518
2640
|
// LH-32: an eyebrow (the tag, a label core sets as one) draws its capitals with core's letter spacing, as core measured it, at its
|
|
@@ -2524,7 +2646,13 @@ function renderTextBox(text, box, bound, config) {
|
|
|
2524
2646
|
...(config.options.trace&&sourceLine?{'data-opf-source-start':sourceOffset+sourceLine.start,'data-opf-source-end':sourceOffset+sourceLine.end,'data-opf-source-next-start':sourceOffset+sourceLine.nextStart,'data-opf-line-boundary':sourceLine.boundary}:{}),
|
|
2525
2647
|
// opf#1322: a line that starts at core's x still says how it is aligned and where its anchor point is (text-anchor no longer does):
|
|
2526
2648
|
// an editor lays its input over the line from them, and a reader of the SVG compares them with the native export.
|
|
2527
|
-
|
|
2649
|
+
// A line whose whitespace hangs at its wrap is anchored past its glyphs' anchor point, which these name the same way (the anchor of its
|
|
2650
|
+
// glyphs, where an editor's input, which hangs the whitespace too, has its own), and data-opf-hang says how far from it the anchor of
|
|
2651
|
+
// the text, whitespace included, is (where the native export anchors its paragraph): `hang` times the alignment factor. A
|
|
2652
|
+
// right-to-left line is drawn and exported by its glyphs and names nothing.
|
|
2653
|
+
// A traced drawing names them for every such line; an untraced one only where it names the anchor anyway (a line that starts at x).
|
|
2654
|
+
...(exactStart||hung&&config.options.trace?{'data-opf-anchor':anchor,'data-opf-anchor-x':stableNumber(glyphAnchor)}:{}),
|
|
2655
|
+
...(hung&&(exactStart||config.options.trace)?{'data-opf-hang':stableNumber(hangShift)}:{}),
|
|
2528
2656
|
}, content);
|
|
2529
2657
|
});
|
|
2530
2658
|
return tag("g", { ...traceAttrs(config.options, config.path),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpresentation/opf-render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Deterministic local OPF renderer for SVG, PNG, and PDF output.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -68,6 +68,10 @@
|
|
|
68
68
|
"types": "./dist/player.d.ts",
|
|
69
69
|
"default": "./dist/player.js"
|
|
70
70
|
},
|
|
71
|
+
"./live-embeds": {
|
|
72
|
+
"types": "./dist/live-embeds.d.ts",
|
|
73
|
+
"default": "./dist/live-embeds.js"
|
|
74
|
+
},
|
|
71
75
|
"./element": {
|
|
72
76
|
"types": "./dist/element.d.ts",
|
|
73
77
|
"default": "./dist/element.js"
|
|
@@ -94,7 +98,7 @@
|
|
|
94
98
|
"fontkit": "^3.0.0",
|
|
95
99
|
"harfbuzzjs": "1.6.4",
|
|
96
100
|
"pako": "3.0.3",
|
|
97
|
-
"@openpresentation/opf": "^0.
|
|
101
|
+
"@openpresentation/opf": "^0.37.0"
|
|
98
102
|
},
|
|
99
103
|
"peerDependencies": {
|
|
100
104
|
"@expo-google-fonts/arimo": "0.4.3",
|
|
@@ -343,7 +347,7 @@
|
|
|
343
347
|
"pdfjs-dist": "6.5.438",
|
|
344
348
|
"playwright": "1.65.0",
|
|
345
349
|
"sharp": "0.35.5",
|
|
346
|
-
"@openpresentation/gallery": "0.
|
|
350
|
+
"@openpresentation/gallery": "0.37.0"
|
|
347
351
|
},
|
|
348
352
|
"bin": {
|
|
349
353
|
"opf-preview-fonts": "./dist/preview-fonts-cli.js"
|
|
@@ -400,5 +404,5 @@
|
|
|
400
404
|
"test:preview-a11y-browser": "node test/preview-a11y-browser.mjs",
|
|
401
405
|
"test:forced-colors-browser": "node test/forced-colors-browser.mjs artifacts/forced-colors"
|
|
402
406
|
},
|
|
403
|
-
"gitHead": "
|
|
407
|
+
"gitHead": "e6aa9c9ce3109709b8b8f14171ce71af339c3004"
|
|
404
408
|
}
|