@openpresentation/opf 0.12.2 → 0.13.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/dist/audit.d.ts +9 -130
- package/dist/audit.js +5 -5
- package/dist/{catalogs-BnI7JKcn.d.ts → catalogs-ywCamd8C.d.ts} +1 -1
- package/dist/catalogs.d.ts +2 -2
- package/dist/chart-data-Cdr6rRVV.d.ts +177 -0
- package/dist/{chunk-6LZK2IZB.js → chunk-7N4VMAT4.js} +11 -7
- package/dist/{chunk-4LAM3N6S.js → chunk-7QBCWNWL.js} +424 -18
- package/dist/{chunk-SOSOBKQ2.js → chunk-ATGDDJPX.js} +4 -5
- package/dist/{chunk-V2537ENL.js → chunk-II5EYKZU.js} +9 -7
- package/dist/{chunk-MWPMJE6P.js → chunk-INU7ZNSB.js} +50 -2
- package/dist/{chunk-RUC7L5DJ.js → chunk-IS2CPNVJ.js} +1 -1
- package/dist/{chunk-JKVKYVWL.js → chunk-IYCJUKWD.js} +90 -471
- package/dist/{chunk-HOBSL7AJ.js → chunk-MPM7NRG7.js} +2396 -1408
- package/dist/{chunk-AUM5MXBR.js → chunk-RAYB46AB.js} +8 -6
- package/dist/{composition-DWbCiMwF.d.ts → composition-D7we69Tr.d.ts} +7 -0
- package/dist/composition.d.ts +2 -1
- package/dist/composition.js +1 -1
- package/dist/convert.d.ts +4 -1
- package/dist/convert.js +33 -16
- package/dist/data.d.ts +2 -1
- package/dist/data.js +3 -1
- package/dist/diff.d.ts +1 -1
- package/dist/diff.js +8 -7
- package/dist/docs.js +26 -20
- package/dist/examples.d.ts +1 -1
- package/dist/examples.js +102 -57
- package/dist/format.js +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.js +8 -8
- package/dist/lint-B7azdiuE.d.ts +197 -0
- package/dist/lint.d.ts +7 -70
- package/dist/lint.js +4 -4
- package/dist/markdown.d.ts +7 -5
- package/dist/markdown.js +5 -5
- package/dist/pagination.d.ts +2 -1
- package/dist/pagination.js +4 -4
- package/dist/patch.js +4 -4
- package/dist/{presentation-DcF-MZcz.d.ts → presentation-mG-IYErQ.d.ts} +187 -14
- package/dist/{schemas-BSjlG8-R.d.ts → schemas-BbPonsTz.d.ts} +18 -0
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +1 -1
- package/dist/spec/catalogs/manifest.json +3 -3
- package/dist/spec/schemas/opf.schema.json +238 -20
- package/dist/types.d.ts +4 -4
- package/dist/{validator-DfG9yxba.d.ts → validator-CIylxoIm.d.ts} +3 -3
- package/dist/validator.d.ts +4 -4
- package/dist/validator.js +3 -3
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assertValidPresentation } from './chunk-
|
|
2
|
-
import { DEFAULT_FONT_SCHEME, resolveFontSchemeReference, resolveFontFamilies, resolveCanvasDimensions, composeSlide, tableRowBoundaries, visitContentPayloads, sliceNumberedItems } from './chunk-
|
|
1
|
+
import { assertValidPresentation } from './chunk-IYCJUKWD.js';
|
|
2
|
+
import { DEFAULT_FONT_SCHEME, resolveFontSchemeReference, resolveFontFamilies, resolveCanvasDimensions, composeSlide, tableRowBoundaries, visitContentPayloads, sliceNumberedItems } from './chunk-MPM7NRG7.js';
|
|
3
3
|
import { catalogs } from './chunk-E34DJ5LL.js';
|
|
4
4
|
|
|
5
5
|
// src/pagination.ts
|
|
@@ -35,6 +35,10 @@ function sliceRichText(value, start, end) {
|
|
|
35
35
|
return [typeof run === "string" ? text.slice(left, right) : { ...run, text: text.slice(left, right) }];
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
+
var deckContext = (presentation) => {
|
|
39
|
+
const deck = isRecord(presentation) ? presentation : {};
|
|
40
|
+
return { ...Array.isArray(deck.references) ? { references: deck.references } : {}, ...isRecord(deck.datasets) ? { datasets: deck.datasets } : {} };
|
|
41
|
+
};
|
|
38
42
|
function leafFor(path, field, value) {
|
|
39
43
|
const leaf = { path, field, value };
|
|
40
44
|
let text;
|
|
@@ -66,8 +70,7 @@ function leafFor(path, field, value) {
|
|
|
66
70
|
return leaf;
|
|
67
71
|
}
|
|
68
72
|
function paginateSlide(input, options = {}) {
|
|
69
|
-
|
|
70
|
-
assertValidPresentation({ ...Array.isArray(deckReferences) ? { references: deckReferences } : {}, slides: [input] });
|
|
73
|
+
assertValidPresentation({ ...deckContext(options.presentation), slides: [input] });
|
|
71
74
|
let source = clone(input);
|
|
72
75
|
const maxSlides = options.maxSlides ?? 100;
|
|
73
76
|
if (!Number.isInteger(maxSlides) || maxSlides < 1 || maxSlides > 1e4) throw new RangeError("maxSlides must be an integer between 1 and 10000.");
|
|
@@ -180,8 +183,7 @@ function paginateSlide(input, options = {}) {
|
|
|
180
183
|
const issues = fit(geometry(slide, slides.length).diagnostics);
|
|
181
184
|
if (issues.length) throw new OPFPaginationError("A continuation page does not fit at its final page number. No partial result was returned.", issues);
|
|
182
185
|
assignPageIds(slide, slides.length);
|
|
183
|
-
|
|
184
|
-
assertValidPresentation({ ...Array.isArray(references) ? { references } : {}, slides: [slide] });
|
|
186
|
+
assertValidPresentation({ ...deckContext(options.presentation), slides: [slide] });
|
|
185
187
|
slides.push(slide);
|
|
186
188
|
pages.push({ slideIndex: sourceIndex + slides.length - 1, mappings, ...initial.furniture ? { repeatedMappings: repeatedMappings(slides.length - 1) } : {} });
|
|
187
189
|
selected = /* @__PURE__ */ new Map();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import './chart-data-Cdr6rRVV.js';
|
|
2
|
+
|
|
1
3
|
/** Canonical table grid. No renderer, fonts, DOM or network dependencies. */
|
|
2
4
|
interface TableBorder {
|
|
3
5
|
color: string;
|
|
@@ -911,6 +913,7 @@ interface ComposeSlideOptions {
|
|
|
911
913
|
slides?: unknown;
|
|
912
914
|
catalogs?: unknown;
|
|
913
915
|
references?: unknown;
|
|
916
|
+
datasets?: unknown;
|
|
914
917
|
};
|
|
915
918
|
/**
|
|
916
919
|
* Whether the slide background is dark, by the host's own luminance test. Selects the light logo
|
|
@@ -1471,6 +1474,10 @@ interface TableLayoutOptions {
|
|
|
1471
1474
|
fontFamily?: string;
|
|
1472
1475
|
textMeasurement?: TextMeasurement;
|
|
1473
1476
|
path?: string;
|
|
1477
|
+
/** RR-54: the document, for a dataset-backed table (`{ dataset }`): its headers, rows and column formats come from `datasets`. */
|
|
1478
|
+
presentation?: {
|
|
1479
|
+
datasets?: unknown;
|
|
1480
|
+
};
|
|
1474
1481
|
/**
|
|
1475
1482
|
* Deck direction. A right-to-left deck lays the columns out right to left: the first column is the rightmost
|
|
1476
1483
|
* and each cell's text reports its paragraph direction (RR-05).
|
package/dist/composition.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { A as AnnotatedRun, a as AnnotationFitter, b as AnnotationLayoutOptions, c as CAPTIONABLE_FIELDS, d as CAPTION_FONT_RATIO, e as CAPTION_MAX_RATIO, f as CHART_SERIES_MIN_DIFFERENCE, g as CHART_SERIES_MIN_LIGHTNESS_STEP, h as CITATION_MARKER_RAISE, i as CITATION_MARKER_SCALE, j as Caption, k as CaptionAlignment, l as CaptionObject, m as CaptionPosition, n as CaptionSettings, o as ChartLabelContent, p as ChartLabelPosition, q as ChartLegendPosition, r as ChartOptionDiagnostic, s as ChartOptionKind, t as ChartOptionSupport, u as ChartOptionTarget, v as CitationMarker, w as CitationNote, x as CodeContent, y as CodeLayout, z as CodeLayoutDiagnostic, B as CodeLayoutOptions, D as CodeLineSegment, E as CodeLineSource, G as CodeTextFit, H as CodeTextPart, C as ComposeSlideOptions, I as ComposedCaption, J as ComposedFlow, K as ComposedFootnoteEntry, N as ComposedFootnotes, O as ComposedGroup, P as ComposedItem, Q as ComposedLogo, R as ComposedSlideImage, S as Composition, U as CompositionCandidate, V as CompositionDecision, W as CompositionExplanation, X as CompositionPenalties, Y as CompositionTrack, Z as DEFAULT_CHART_LABEL_SEPARATOR, _ as DEFAULT_FONT_SCHEME, $ as DEFAULT_FURNITURE_DATE_FORMAT, a0 as DEFAULT_SLIDE_NUMBER_FORMAT, a1 as DeckCitations, a2 as FONT_SIZE_GRID_PER_PX, a3 as FOOTNOTE_MAX_RATIO, c7 as FontFaceSelection, a4 as FontFamilies, F as FontSchemeDiagnostic, a5 as FootnoteLayoutOptions, a6 as FurnitureField, a7 as FurnitureImagePart, a8 as FurnitureLayout, a9 as FurniturePart, aa as FurniturePartBase, ab as FurnitureSocialLink, ac as FurnitureTextExtras, ad as FurnitureTextPart, ae as LayoutBox, L as LayoutDiagnostic, af as ListBulletImage, ag as ListEntryLayout, ah as ListFit, ai as ListFitOptions, aj as ListNumber, ak as ListText, al as ListValue, am as LogoSlot, an as MAX_COMPOSITION_DEPTH, ao as MAX_NUMBERING_LEVELS, ap as MAX_NUMBERING_VALUE, aq as MAX_ROMAN_VALUE, ar as MeasureTextWidth, as as MetricContent, M as MetricLayout, at as MetricLayoutDiagnostic, au as MetricLayoutOptions, av as MetricTextPart, aw as MetricTextSource, ax as NUMBERING_STYLES, ay as NUMBERING_SUFFIXES, az as Numbering, aA as NumberingInput, aB as NumberingStyleName, aC as NumberingSuffix, aD as OPFCompositionError, aE as PICTURE_BULLET_SCALE, aF as PhysicalAlignment, aG as QuoteContent, aH as QuoteLayout, aI as QuoteLayoutDiagnostic, aJ as QuoteLayoutOptions, aK as QuoteTextPart, aL as QuoteTextSource, c8 as ReadingBox, aM as Reference, aN as ReferencesSlideOptions, aQ as ResolveLogoOptions, aR as ResolvedChartDataLabels, aS as ResolvedChartOptions, aT as ResolvedFontScheme, aU as ResolvedLogo, aV as ResolvedNumbering, aW as RichText, aX as RichTextFit, aY as RichTextFragment, aZ as RichTextLine, a_ as RichTextOptions, a$ as RichTextRun, b0 as SlideCitations, b1 as SlideComposition, b2 as SlideImageShape, b3 as SocialPlatformRecord, b4 as SocialProfile, c9 as SourceTextFit, ca as TableBorder, cb as TableCellLayout, cc as TableCellStyle, cd as TableGrid, ce as TableGridCell, cf as TableGridIssue, cg as TableLayout, ch as TableLayoutOptions, ci as TableRowLayout, b5 as TextDirection, b6 as TextFit, b7 as TextLineInk, cj as TextLineSegment, ck as TextLineSource, T as TextMeasurement, b8 as TextPlacement, b9 as TextPlacementLine, ba as TextStyle, bb as TimelineContent, bc as TimelineEvent, bd as TimelineLayout, be as TimelineLayoutDiagnostic, bf as TimelineLayoutOptions, bg as TimelineTextPart, bh as annotationText, bi as captionSettings, bj as chartColorForFill, bk as chartLabelText, bl as chartOptionSupport, bm as chartOptionTarget, bn as chartPaletteForFill, bo as citationMarkerText, bp as collectCitations, bq as colorContrast, br as composeSlide, bs as fitList, bt as fitRichText, bu as fitText, bv as formatChartLabelNumber, bw as formatChartLabelPercent, bx as formatFurnitureDate, by as formatListNumber, bz as formatSlideNumber, bA as layoutCaption, bB as layoutCode, bC as layoutFootnotes, bD as layoutFurniture, bE as layoutMetric, bF as layoutQuote, cl as layoutTable, bG as layoutTimeline, bH as listNumbers, bI as measureText, bJ as measureTextOutline, bL as numberingAtLevel, bM as numberingStyleDraws, bN as paragraphDirection, bO as paragraphDirectionAt, bP as physicalAlignment, bQ as placeTextLines, bR as referencesSlide, bS as resolveCanvasDimensions, bT as resolveChartOptions, bV as resolveFontFamilies, bW as resolveFontSchemeReference, bX as resolveLogo, bY as resolveNumbering, bZ as resolveSocialProfile, b_ as resolveTextStyle, b$ as sliceNumberedItems, c0 as slideCitations, cm as slideImageShape, c1 as snapFontSizeDown, c2 as snapFontSizeUp, cn as tableGrid, co as tableRowBoundaries, c3 as textColorForFill, c4 as textWidthMeasurer, cp as visualReadingOrder, c5 as walkCitationRuns, c6 as wrapText } from './composition-
|
|
1
|
+
export { A as AnnotatedRun, a as AnnotationFitter, b as AnnotationLayoutOptions, c as CAPTIONABLE_FIELDS, d as CAPTION_FONT_RATIO, e as CAPTION_MAX_RATIO, f as CHART_SERIES_MIN_DIFFERENCE, g as CHART_SERIES_MIN_LIGHTNESS_STEP, h as CITATION_MARKER_RAISE, i as CITATION_MARKER_SCALE, j as Caption, k as CaptionAlignment, l as CaptionObject, m as CaptionPosition, n as CaptionSettings, o as ChartLabelContent, p as ChartLabelPosition, q as ChartLegendPosition, r as ChartOptionDiagnostic, s as ChartOptionKind, t as ChartOptionSupport, u as ChartOptionTarget, v as CitationMarker, w as CitationNote, x as CodeContent, y as CodeLayout, z as CodeLayoutDiagnostic, B as CodeLayoutOptions, D as CodeLineSegment, E as CodeLineSource, G as CodeTextFit, H as CodeTextPart, C as ComposeSlideOptions, I as ComposedCaption, J as ComposedFlow, K as ComposedFootnoteEntry, N as ComposedFootnotes, O as ComposedGroup, P as ComposedItem, Q as ComposedLogo, R as ComposedSlideImage, S as Composition, U as CompositionCandidate, V as CompositionDecision, W as CompositionExplanation, X as CompositionPenalties, Y as CompositionTrack, Z as DEFAULT_CHART_LABEL_SEPARATOR, _ as DEFAULT_FONT_SCHEME, $ as DEFAULT_FURNITURE_DATE_FORMAT, a0 as DEFAULT_SLIDE_NUMBER_FORMAT, a1 as DeckCitations, a2 as FONT_SIZE_GRID_PER_PX, a3 as FOOTNOTE_MAX_RATIO, c7 as FontFaceSelection, a4 as FontFamilies, F as FontSchemeDiagnostic, a5 as FootnoteLayoutOptions, a6 as FurnitureField, a7 as FurnitureImagePart, a8 as FurnitureLayout, a9 as FurniturePart, aa as FurniturePartBase, ab as FurnitureSocialLink, ac as FurnitureTextExtras, ad as FurnitureTextPart, ae as LayoutBox, L as LayoutDiagnostic, af as ListBulletImage, ag as ListEntryLayout, ah as ListFit, ai as ListFitOptions, aj as ListNumber, ak as ListText, al as ListValue, am as LogoSlot, an as MAX_COMPOSITION_DEPTH, ao as MAX_NUMBERING_LEVELS, ap as MAX_NUMBERING_VALUE, aq as MAX_ROMAN_VALUE, ar as MeasureTextWidth, as as MetricContent, M as MetricLayout, at as MetricLayoutDiagnostic, au as MetricLayoutOptions, av as MetricTextPart, aw as MetricTextSource, ax as NUMBERING_STYLES, ay as NUMBERING_SUFFIXES, az as Numbering, aA as NumberingInput, aB as NumberingStyleName, aC as NumberingSuffix, aD as OPFCompositionError, aE as PICTURE_BULLET_SCALE, aF as PhysicalAlignment, aG as QuoteContent, aH as QuoteLayout, aI as QuoteLayoutDiagnostic, aJ as QuoteLayoutOptions, aK as QuoteTextPart, aL as QuoteTextSource, c8 as ReadingBox, aM as Reference, aN as ReferencesSlideOptions, aQ as ResolveLogoOptions, aR as ResolvedChartDataLabels, aS as ResolvedChartOptions, aT as ResolvedFontScheme, aU as ResolvedLogo, aV as ResolvedNumbering, aW as RichText, aX as RichTextFit, aY as RichTextFragment, aZ as RichTextLine, a_ as RichTextOptions, a$ as RichTextRun, b0 as SlideCitations, b1 as SlideComposition, b2 as SlideImageShape, b3 as SocialPlatformRecord, b4 as SocialProfile, c9 as SourceTextFit, ca as TableBorder, cb as TableCellLayout, cc as TableCellStyle, cd as TableGrid, ce as TableGridCell, cf as TableGridIssue, cg as TableLayout, ch as TableLayoutOptions, ci as TableRowLayout, b5 as TextDirection, b6 as TextFit, b7 as TextLineInk, cj as TextLineSegment, ck as TextLineSource, T as TextMeasurement, b8 as TextPlacement, b9 as TextPlacementLine, ba as TextStyle, bb as TimelineContent, bc as TimelineEvent, bd as TimelineLayout, be as TimelineLayoutDiagnostic, bf as TimelineLayoutOptions, bg as TimelineTextPart, bh as annotationText, bi as captionSettings, bj as chartColorForFill, bk as chartLabelText, bl as chartOptionSupport, bm as chartOptionTarget, bn as chartPaletteForFill, bo as citationMarkerText, bp as collectCitations, bq as colorContrast, br as composeSlide, bs as fitList, bt as fitRichText, bu as fitText, bv as formatChartLabelNumber, bw as formatChartLabelPercent, bx as formatFurnitureDate, by as formatListNumber, bz as formatSlideNumber, bA as layoutCaption, bB as layoutCode, bC as layoutFootnotes, bD as layoutFurniture, bE as layoutMetric, bF as layoutQuote, cl as layoutTable, bG as layoutTimeline, bH as listNumbers, bI as measureText, bJ as measureTextOutline, bL as numberingAtLevel, bM as numberingStyleDraws, bN as paragraphDirection, bO as paragraphDirectionAt, bP as physicalAlignment, bQ as placeTextLines, bR as referencesSlide, bS as resolveCanvasDimensions, bT as resolveChartOptions, bV as resolveFontFamilies, bW as resolveFontSchemeReference, bX as resolveLogo, bY as resolveNumbering, bZ as resolveSocialProfile, b_ as resolveTextStyle, b$ as sliceNumberedItems, c0 as slideCitations, cm as slideImageShape, c1 as snapFontSizeDown, c2 as snapFontSizeUp, cn as tableGrid, co as tableRowBoundaries, c3 as textColorForFill, c4 as textWidthMeasurer, cp as visualReadingOrder, c5 as walkCitationRuns, c6 as wrapText } from './composition-D7we69Tr.js';
|
|
2
|
+
export { C as ChartMapping, D as DataCellValue, d as DataColumn, e as DataDiagnostic, h as DataSourceRef, j as DataTableCell, k as DataTableHeader, n as Dataset, o as DatasetRef, R as ResolvedChartData, p as ResolvedTableData, q as chartNumber, s as excelNumberFormat, t as formatDataNumber, u as inlineChartData, v as inlineDatasets, w as inlineTableData, x as isDatasetRef, y as isXYChartType, z as numberFormatError, A as numberFormatFromExcel, B as resolveChartData, E as resolveTableData, G as tableCellDisplayValue } from './chart-data-Cdr6rRVV.js';
|
package/dist/composition.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CAPTIONABLE_FIELDS, CAPTION_FONT_RATIO, CAPTION_MAX_RATIO, CHART_SERIES_MIN_DIFFERENCE, CHART_SERIES_MIN_LIGHTNESS_STEP, CITATION_MARKER_RAISE, CITATION_MARKER_SCALE, DEFAULT_CHART_LABEL_SEPARATOR, DEFAULT_FONT_SCHEME, DEFAULT_FURNITURE_DATE_FORMAT, DEFAULT_SLIDE_NUMBER_FORMAT, FONT_SIZE_GRID_PER_PX, FOOTNOTE_MAX_RATIO, MAX_COMPOSITION_DEPTH, MAX_NUMBERING_LEVELS, MAX_NUMBERING_VALUE, MAX_ROMAN_VALUE, NUMBERING_STYLES, NUMBERING_SUFFIXES, OPFCompositionError, PICTURE_BULLET_SCALE, annotationText, captionSettings, chartColorForFill, chartLabelText, chartOptionSupport, chartOptionTarget, chartPaletteForFill, citationMarkerText, collectCitations, colorContrast, composeSlide, fitList, fitRichText, fitText, formatChartLabelNumber, formatChartLabelPercent, formatFurnitureDate, formatListNumber, formatSlideNumber, layoutCaption, layoutCode, layoutFootnotes, layoutFurniture, layoutMetric, layoutQuote, layoutTable, layoutTimeline, listNumbers, measureText, measureTextOutline, numberingAtLevel, numberingStyleDraws, paragraphDirection, paragraphDirectionAt, physicalAlignment, placeTextLines, referencesSlide, resolveCanvasDimensions, resolveChartOptions, resolveFontFamilies, resolveFontSchemeReference, resolveLogo, resolveNumbering, resolveSocialProfile, resolveTextStyle, sliceNumberedItems, slideCitations, slideImageShape, snapFontSizeDown, snapFontSizeUp, tableGrid, tableRowBoundaries, textColorForFill, textWidthMeasurer, visualReadingOrder, walkCitationRuns, wrapText } from './chunk-
|
|
1
|
+
export { CAPTIONABLE_FIELDS, CAPTION_FONT_RATIO, CAPTION_MAX_RATIO, CHART_SERIES_MIN_DIFFERENCE, CHART_SERIES_MIN_LIGHTNESS_STEP, CITATION_MARKER_RAISE, CITATION_MARKER_SCALE, DEFAULT_CHART_LABEL_SEPARATOR, DEFAULT_FONT_SCHEME, DEFAULT_FURNITURE_DATE_FORMAT, DEFAULT_SLIDE_NUMBER_FORMAT, FONT_SIZE_GRID_PER_PX, FOOTNOTE_MAX_RATIO, MAX_COMPOSITION_DEPTH, MAX_NUMBERING_LEVELS, MAX_NUMBERING_VALUE, MAX_ROMAN_VALUE, NUMBERING_STYLES, NUMBERING_SUFFIXES, OPFCompositionError, PICTURE_BULLET_SCALE, annotationText, captionSettings, chartColorForFill, chartLabelText, chartNumber, chartOptionSupport, chartOptionTarget, chartPaletteForFill, citationMarkerText, collectCitations, colorContrast, composeSlide, excelNumberFormat, fitList, fitRichText, fitText, formatChartLabelNumber, formatChartLabelPercent, formatDataNumber, formatFurnitureDate, formatListNumber, formatSlideNumber, inlineChartData, inlineDatasets, inlineTableData, isDatasetRef, isXYChartType, layoutCaption, layoutCode, layoutFootnotes, layoutFurniture, layoutMetric, layoutQuote, layoutTable, layoutTimeline, listNumbers, measureText, measureTextOutline, numberFormatError, numberFormatFromExcel, numberingAtLevel, numberingStyleDraws, paragraphDirection, paragraphDirectionAt, physicalAlignment, placeTextLines, referencesSlide, resolveCanvasDimensions, resolveChartData, resolveChartOptions, resolveFontFamilies, resolveFontSchemeReference, resolveLogo, resolveNumbering, resolveSocialProfile, resolveTableData, resolveTextStyle, sliceNumberedItems, slideCitations, slideImageShape, snapFontSizeDown, snapFontSizeUp, tableCellDisplayValue, tableGrid, tableRowBoundaries, textColorForFill, textWidthMeasurer, visualReadingOrder, walkCitationRuns, wrapText } from './chunk-MPM7NRG7.js';
|
|
2
2
|
import './chunk-E34DJ5LL.js';
|
package/dist/convert.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PaginatedPage, PresentationPaginationOptions } from './pagination.js';
|
|
2
|
-
import './composition-
|
|
2
|
+
import './composition-D7we69Tr.js';
|
|
3
|
+
import './chart-data-Cdr6rRVV.js';
|
|
3
4
|
|
|
4
5
|
type Json = any;
|
|
5
6
|
type Obj = Record<string, any>;
|
|
@@ -46,6 +47,8 @@ declare const CONTENT_KIND_LABELS: Readonly<Record<ContentKind, string>>;
|
|
|
46
47
|
*/
|
|
47
48
|
declare const CONTENT_CONVERSIONS: Readonly<Record<string, readonly ContentKind[]>>;
|
|
48
49
|
interface ConvertOptions extends TableOptions {
|
|
50
|
+
/** RR-54: the document the payload belongs to. A dataset-backed chart or table needs it (its `datasets`) to convert to another kind or to validate. */
|
|
51
|
+
document?: unknown;
|
|
49
52
|
/** Text to timeline: also read `label: text` with any short label as the date (default: only date-like labels). */
|
|
50
53
|
looseWhen?: boolean;
|
|
51
54
|
/** Code to text: `auto` (default) writes a fenced block when the code has a language or file name so nothing is lost; `never` writes the bare source and reports the loss. */
|
package/dist/convert.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { paginatePresentation, OPFPaginationError } from './chunk-
|
|
2
|
-
import { CONTENT_KEYS, isRecord, contentKeysOf, refuse, clone, Loss, isSlideLike, assertValidOwner, report, OPFConversionError, plainOf, assertValidOutput, same, splitRuns, runsOf, lineIsPlain, linePlain, concatText, parseQuoteLines, parseCodeFence, splitWhen, parseListLine, levelsFromIndents, lineValue, joinLines, hasFormatting, fenceCode } from './chunk-
|
|
3
|
-
export { OPFConversionError } from './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
import { promotedRegionKeys, visitContentPayloads } from './chunk-
|
|
1
|
+
import { paginatePresentation, OPFPaginationError } from './chunk-RAYB46AB.js';
|
|
2
|
+
import { CONTENT_KEYS, isRecord, contentKeysOf, refuse, clone, Loss, isSlideLike, assertValidOwner, report, OPFConversionError, plainOf, assertValidOutput, same, splitRuns, runsOf, lineIsPlain, linePlain, concatText, parseQuoteLines, parseCodeFence, splitWhen, parseListLine, levelsFromIndents, lineValue, joinLines, hasFormatting, fenceCode } from './chunk-II5EYKZU.js';
|
|
3
|
+
export { OPFConversionError } from './chunk-II5EYKZU.js';
|
|
4
|
+
import './chunk-IYCJUKWD.js';
|
|
5
|
+
import { promotedRegionKeys, isDatasetRef, inlineTableData, visitContentPayloads, chartNumber } from './chunk-MPM7NRG7.js';
|
|
6
6
|
import './chunk-S5W34SIJ.js';
|
|
7
7
|
import './chunk-E34DJ5LL.js';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-7QBCWNWL.js';
|
|
9
9
|
|
|
10
10
|
// src/convert/tables.ts
|
|
11
11
|
function cellOf(raw) {
|
|
12
12
|
if (isRecord(raw) && Object.hasOwn(raw, "value")) {
|
|
13
|
-
return { value: raw.value, styled: isRecord(raw.style) && Object.keys(raw.style).length > 0, merged: (raw.colSpan ?? 1) > 1 || (raw.rowSpan ?? 1) > 1 };
|
|
13
|
+
return { value: raw.value, styled: isRecord(raw.style) && Object.keys(raw.style).length > 0, merged: (raw.colSpan ?? 1) > 1 || (raw.rowSpan ?? 1) > 1, formatted: typeof raw.format === "string" };
|
|
14
14
|
}
|
|
15
|
+
if (isRecord(raw) && typeof raw.name === "string") return { value: raw.name, styled: false, merged: false, formatted: typeof raw.format === "string" };
|
|
15
16
|
return { value: raw, styled: false, merged: false };
|
|
16
17
|
}
|
|
17
18
|
function valueText(value) {
|
|
@@ -33,6 +34,7 @@ function readCells(table, loss, purpose, allowMerged = false) {
|
|
|
33
34
|
loss.note("merged cells");
|
|
34
35
|
}
|
|
35
36
|
if (cell.styled) loss.note("cell styles");
|
|
37
|
+
if (cell.formatted) loss.note("number formats");
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
return { columns: Array.isArray(table.columns) ? table.columns.map((cell) => cellOf(cell).value) : void 0, rows: rows.map((row) => row.map((cell) => cellOf(cell).value)) };
|
|
@@ -454,13 +456,21 @@ function timelineToList(timeline, loss) {
|
|
|
454
456
|
}
|
|
455
457
|
function chartToTable(chart, loss) {
|
|
456
458
|
const data = chart?.data;
|
|
459
|
+
if (chart?.mapping !== void 0) loss.note("series mapping");
|
|
460
|
+
if (isDatasetRef(data)) {
|
|
461
|
+
if (chart.type) loss.note("chart type");
|
|
462
|
+
return { key: "table", value: { dataset: data.dataset, ...Array.isArray(data.fields) ? { fields: clone(data.fields) } : {} } };
|
|
463
|
+
}
|
|
457
464
|
if (!data || !Array.isArray(data.columns) || !Array.isArray(data.rows)) throw refuse("This chart reads external data. Only a chart with inline columns and rows converts to a table.");
|
|
458
465
|
if (chart.type) loss.note("chart type");
|
|
466
|
+
if (data.source !== void 0) loss.note("data source");
|
|
459
467
|
return { key: "table", value: { columns: clone(data.columns), rows: clone(data.rows) } };
|
|
460
468
|
}
|
|
461
469
|
function tableToChart(table) {
|
|
470
|
+
if (isDatasetRef(table)) return { key: "chart", value: { type: "column", data: { dataset: table.dataset, ...Array.isArray(table.fields) ? { fields: clone(table.fields) } : {} } } };
|
|
462
471
|
const { columns, rows } = table ?? {};
|
|
463
|
-
|
|
472
|
+
const label = (column) => isRecord(column) && !Object.hasOwn(column, "value") && typeof column.name === "string" ? column.name : column;
|
|
473
|
+
if (!Array.isArray(columns) || !columns.length || columns.some((column) => typeof label(column) !== "string" || label(column) === "")) throw refuse("A chart needs a plain text label for every column. Add column labels to the table first.");
|
|
464
474
|
const body = rows.map((row, rowIndex) => {
|
|
465
475
|
if (row.length !== columns.length) throw refuse(`Row ${rowIndex + 1} does not have ${columns.length} cells.`, { row: rowIndex });
|
|
466
476
|
return row.map((cell, columnIndex) => {
|
|
@@ -468,12 +478,13 @@ function tableToChart(table) {
|
|
|
468
478
|
if (columnIndex === 0) return cell;
|
|
469
479
|
if (cell === null || cell === "") return null;
|
|
470
480
|
if (typeof cell === "number") return cell;
|
|
471
|
-
|
|
481
|
+
const number = chartNumber(cell);
|
|
482
|
+
if (number !== null) return number;
|
|
472
483
|
throw refuse(`Row ${rowIndex + 1}, column ${columnIndex + 1} ("${String(cell)}") is not a number, so it cannot be a chart value.`, { row: rowIndex, column: columnIndex });
|
|
473
484
|
});
|
|
474
485
|
});
|
|
475
486
|
if (!body.length) throw refuse("A chart needs at least one row.");
|
|
476
|
-
return { key: "chart", value: { type: "column", data: { columns:
|
|
487
|
+
return { key: "chart", value: { type: "column", data: { columns: clone(columns), rows: body } } };
|
|
477
488
|
}
|
|
478
489
|
function convertField(from, to, content, options, loss) {
|
|
479
490
|
if (from === "chart") return chartToTable(content, loss);
|
|
@@ -517,7 +528,13 @@ function convertContent(payload, to, options = {}) {
|
|
|
517
528
|
throw refuse(`${label} content cannot be converted to ${CONTENT_KIND_LABELS[to]?.toLowerCase() ?? to}. ${targets.length ? `It converts to: ${targets.map((target) => CONTENT_KIND_LABELS[target].toLowerCase()).join(", ")}.` : "It has no text to convert."}`, { from: info.kind, to });
|
|
518
529
|
}
|
|
519
530
|
const loss = new Loss();
|
|
520
|
-
|
|
531
|
+
let content = info.content;
|
|
532
|
+
if (info.kind === "table" && to !== "chart" && isDatasetRef(content)) {
|
|
533
|
+
content = inlineTableData(content, options.document);
|
|
534
|
+
if (isDatasetRef(content)) throw refuse(`This table shows dataset '${content.dataset}'. Pass the document (options.document) so its rows can be converted.`);
|
|
535
|
+
loss.note("dataset reference (the rows are copied)");
|
|
536
|
+
}
|
|
537
|
+
const { key, value } = convertField(info.kind, to, content, options, loss);
|
|
521
538
|
const out = {};
|
|
522
539
|
for (const [name, entry] of Object.entries(owner)) {
|
|
523
540
|
if (CONTENT_KEYS.includes(name) || name === "type" || name === "blocks") continue;
|
|
@@ -529,7 +546,7 @@ function convertContent(payload, to, options = {}) {
|
|
|
529
546
|
}
|
|
530
547
|
if (owner.type !== void 0) out.type = TYPE_OF_KIND[to] ?? to;
|
|
531
548
|
out[key] = value;
|
|
532
|
-
assertValidOwner(out);
|
|
549
|
+
assertValidOwner(out, isRecord(options.document) ? options.document : {});
|
|
533
550
|
return { payload: out, from: info.kind, to, key, changed: true, ...report(loss.list) };
|
|
534
551
|
}
|
|
535
552
|
function contentConversionTargets(payload, options = {}) {
|
|
@@ -921,7 +938,7 @@ function splitSlide(presentation, slideIndex, options = {}) {
|
|
|
921
938
|
slide.blocks = clone(blocks.slice(from, bounds[part + 1]));
|
|
922
939
|
return slide;
|
|
923
940
|
});
|
|
924
|
-
assertValidOutput(slides, "slides");
|
|
941
|
+
assertValidOutput(slides, "slides", presentation);
|
|
925
942
|
return { presentation: replaceSlides(presentation, slideIndex, 1, slides), slides, range: { start: slideIndex, deleteCount: 1 }, changed: true, ...report(loss.list) };
|
|
926
943
|
}
|
|
927
944
|
var remapPath = (path, from, to) => path.replace(new RegExp(`^slides\\.${from}(?=\\.|$)`), `slides.${to}`);
|
|
@@ -959,7 +976,7 @@ function splitSlideOnOverflow(presentation, slideIndex, options = {}) {
|
|
|
959
976
|
mappings: page.mappings.map((mapping) => ({ ...mapping, sourcePath: remapPath(mapping.sourcePath, 0, slideIndex), outputPath: remapPath(mapping.outputPath, 0, slideIndex + page.slideIndex) })),
|
|
960
977
|
...page.repeatedMappings ? { repeatedMappings: page.repeatedMappings.map((mapping) => ({ ...mapping, sourcePath: remapPath(mapping.sourcePath, 0, slideIndex), outputPath: remapPath(mapping.outputPath, 0, slideIndex + page.slideIndex) })) } : {}
|
|
961
978
|
}));
|
|
962
|
-
assertValidOutput(paginated, "slides");
|
|
979
|
+
assertValidOutput(paginated, "slides", presentation);
|
|
963
980
|
return { presentation: replaceSlides(whole, slideIndex, 1, paginated), slides: paginated, range: { start: slideIndex, deleteCount: 1 }, changed: true, pages, ...report([]) };
|
|
964
981
|
}
|
|
965
982
|
function mergeSlides(presentation, start, count = 2) {
|
|
@@ -986,7 +1003,7 @@ function mergeSlides(presentation, start, count = 2) {
|
|
|
986
1003
|
if (blocks.length) merged.blocks = blocks;
|
|
987
1004
|
const notes = slides.map((slide) => slide.notes).filter((note) => typeof note === "string" && note !== "");
|
|
988
1005
|
if (notes.length) merged.notes = notes.join("\n\n");
|
|
989
|
-
assertValidOutput(merged, "slide");
|
|
1006
|
+
assertValidOutput(merged, "slide", presentation);
|
|
990
1007
|
return { presentation: replaceSlides(presentation, start, count, [merged]), slides: [merged], range: { start, deleteCount: count }, changed: true, ...report(loss.list) };
|
|
991
1008
|
}
|
|
992
1009
|
var segments = (path) => path.split(".");
|
|
@@ -1035,7 +1052,7 @@ function unpaginate(presentation, pages, options = {}) {
|
|
|
1035
1052
|
end = Math.max(end, indexes[0] + indexes.length);
|
|
1036
1053
|
removed += indexes.length - 1;
|
|
1037
1054
|
}
|
|
1038
|
-
assertValidOutput(current.slides, "slides");
|
|
1055
|
+
assertValidOutput(current.slides, "slides", presentation);
|
|
1039
1056
|
const deleteCount = end - first;
|
|
1040
1057
|
return { presentation: current, slides: current.slides.slice(first, first + deleteCount - removed), range: { start: first, deleteCount }, changed: true, ...report([]) };
|
|
1041
1058
|
}
|
package/dist/data.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export { C as ChartMapping, a as ChartNumberFix, b as ChartNumberFixOperation, c as ChartNumberFixOptions, D as DataCellValue, d as DataColumn, e as DataDiagnostic, f as DataDiagnosticCode, g as DataResolveOptions, h as DataSourceRef, i as DataStyledCell, j as DataTableCell, k as DataTableHeader, l as DataTableValue, m as DataTextRun, n as Dataset, o as DatasetRef, R as ResolvedChartData, p as ResolvedTableData, q as chartNumber, r as datasetDiagnostics, s as excelNumberFormat, t as formatDataNumber, u as inlineChartData, v as inlineDatasets, w as inlineTableData, x as isDatasetRef, y as isXYChartType, z as numberFormatError, A as numberFormatFromExcel, B as resolveChartData, E as resolveTableData, F as suggestChartNumberFix, G as tableCellDisplayValue, H as unusedDatasets } from './chart-data-Cdr6rRVV.js';
|
|
2
|
+
|
|
2
3
|
type DataCell = string | number | boolean | null;
|
|
3
4
|
interface TabularData {
|
|
4
5
|
columns: string[];
|
package/dist/data.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { OPFDataImportError, createDataContent, parseTabularData } from './chunk-
|
|
1
|
+
export { OPFDataImportError, createDataContent, parseTabularData } from './chunk-ATGDDJPX.js';
|
|
2
|
+
export { chartNumber, datasetDiagnostics, excelNumberFormat, formatDataNumber, inlineChartData, inlineDatasets, inlineTableData, isDatasetRef, isXYChartType, numberFormatError, numberFormatFromExcel, resolveChartData, resolveTableData, suggestChartNumberFix, tableCellDisplayValue, unusedDatasets } from './chunk-MPM7NRG7.js';
|
|
3
|
+
import './chunk-E34DJ5LL.js';
|
package/dist/diff.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ declare function mergePresentations(base: unknown, ours: unknown, theirs: unknow
|
|
|
78
78
|
|
|
79
79
|
type DiffChangeType = "added" | "removed" | "changed" | "moved";
|
|
80
80
|
/** What kind of thing changed. */
|
|
81
|
-
type DiffCategory = "slide" | "block" | "field" | "design" | "metadata" | "assets" | "catalogs" | "variables" | "narrative" | "extensions";
|
|
81
|
+
type DiffCategory = "slide" | "block" | "field" | "design" | "metadata" | "assets" | "datasets" | "catalogs" | "variables" | "narrative" | "extensions";
|
|
82
82
|
interface DiffSlideRef {
|
|
83
83
|
id?: string;
|
|
84
84
|
title?: string;
|
package/dist/diff.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsonEqual, formatPointer } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
import { jsonEqual, formatPointer } from './chunk-IS2CPNVJ.js';
|
|
2
|
+
import './chunk-IYCJUKWD.js';
|
|
3
|
+
import './chunk-MPM7NRG7.js';
|
|
4
4
|
import './chunk-S5W34SIJ.js';
|
|
5
5
|
import './chunk-E34DJ5LL.js';
|
|
6
|
-
import './chunk-
|
|
6
|
+
import './chunk-7QBCWNWL.js';
|
|
7
7
|
|
|
8
8
|
// src/diff-match.ts
|
|
9
9
|
var DEFAULT_MATCH_THRESHOLD = 0.5;
|
|
@@ -373,7 +373,7 @@ function mergePresentations(base, ours, theirs, options = {}) {
|
|
|
373
373
|
// src/diff.ts
|
|
374
374
|
var isObject3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
375
375
|
var REGION_KEY = /^(top|middle|bottom|left|center|right)([:+].*)?$/u;
|
|
376
|
-
var ROOT_CATEGORIES = { design: "design", assets: "assets", catalogs: "catalogs", variables: "variables", narrative: "narrative", extensions: "extensions" };
|
|
376
|
+
var ROOT_CATEGORIES = { design: "design", assets: "assets", datasets: "datasets", catalogs: "catalogs", variables: "variables", narrative: "narrative", extensions: "extensions" };
|
|
377
377
|
function categoryOf(tokens) {
|
|
378
378
|
const [root] = tokens;
|
|
379
379
|
if (root === void 0) return "metadata";
|
|
@@ -550,6 +550,7 @@ var SECTION_TITLES = {
|
|
|
550
550
|
variables: "Variables",
|
|
551
551
|
narrative: "Narrative",
|
|
552
552
|
assets: "Assets",
|
|
553
|
+
datasets: "Datasets",
|
|
553
554
|
catalogs: "Catalogs",
|
|
554
555
|
extensions: "Extensions",
|
|
555
556
|
slide: "Slides",
|
|
@@ -563,12 +564,12 @@ function formatDiffReport(diff) {
|
|
|
563
564
|
const headline = [];
|
|
564
565
|
const slideParts = [[s.added, "added"], [s.removed, "removed"], [s.moved, "moved"], [s.modified, "modified"]].filter(([n]) => n > 0).map(([n, label]) => `${n} ${label}`);
|
|
565
566
|
if (slideParts.length) headline.push(`slides: ${slideParts.join(", ")}`);
|
|
566
|
-
for (const category of ["metadata", "design", "variables", "narrative", "assets", "catalogs", "extensions"]) {
|
|
567
|
+
for (const category of ["metadata", "design", "variables", "narrative", "assets", "datasets", "catalogs", "extensions"]) {
|
|
567
568
|
const count = diff.summary.byCategory[category];
|
|
568
569
|
if (count) headline.push(`${category}: ${count}`);
|
|
569
570
|
}
|
|
570
571
|
lines.push(`${diff.summary.total} change${diff.summary.total === 1 ? "" : "s"} (${headline.join("; ")})`, "");
|
|
571
|
-
for (const category of ["metadata", "design", "variables", "narrative", "assets", "catalogs", "extensions"]) {
|
|
572
|
+
for (const category of ["metadata", "design", "variables", "narrative", "assets", "datasets", "catalogs", "extensions"]) {
|
|
572
573
|
const section = diff.changes.filter((change) => change.category === category);
|
|
573
574
|
if (!section.length) continue;
|
|
574
575
|
lines.push(SECTION_TITLES[category]);
|