@office-kit/pptx 0.18.0 → 0.18.1
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/CHANGELOG.md +10 -0
- package/dist/{api-0CdoUwvg.js → api-DlzYhUxG.js} +30 -10
- package/dist/api-DlzYhUxG.js.map +1 -0
- package/dist/{index-bswJVsv2.d.ts → index-CAPRpjn2.d.ts} +25 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/package.json +1 -1
- package/dist/api-0CdoUwvg.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @office-kit/pptx
|
|
2
2
|
|
|
3
|
+
## 0.18.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c8bf75d: fix: `getParagraphAlignment` and `getTableCellAlignment` returned an invalid `algn` value from a file as if it were a valid alignment
|
|
8
|
+
|
|
9
|
+
Both getters cast the attribute straight to `ParagraphAlignment`, so a hand-edited or third-party deck with `algn="bogus"` handed `'bogus'` to typed code. They now parse the value, and anything outside `ST_TextAlignType` reads as `null` (unset), like the other alignment readers already did.
|
|
10
|
+
|
|
11
|
+
Their return type is now the new `ParagraphAlignmentToken` (`'l' | 'ctr' | 'r' | 'just' | 'dist' | 'justLow' | 'thaiDist'`) instead of the wider `ParagraphAlignment`. Runtime values are unchanged — these two getters have always returned the spec token, so `setParagraphAlignment(shape, 0, 'center')` reads back as `'ctr'` — but the old type also listed `'center'`, which let `getParagraphAlignment(…) === 'center'` compile although it can never be true. That comparison is now a type error; compare with `'ctr'`, or read the plain-English name from `getParagraphPropertiesEffective` / `getTableCellParagraphs`.
|
|
12
|
+
|
|
3
13
|
## 0.18.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -2380,6 +2380,20 @@ const buildBulletElement = (n) => {
|
|
|
2380
2380
|
};
|
|
2381
2381
|
const NAME_PPR_FOR_BULLET = qname("a", "pPr", NS.dml);
|
|
2382
2382
|
const NAME_P_FOR_BULLET = qname("a", "p", NS.dml);
|
|
2383
|
+
const ALIGNMENT_TOKENS = [
|
|
2384
|
+
"l",
|
|
2385
|
+
"ctr",
|
|
2386
|
+
"r",
|
|
2387
|
+
"just",
|
|
2388
|
+
"dist",
|
|
2389
|
+
"justLow",
|
|
2390
|
+
"thaiDist"
|
|
2391
|
+
];
|
|
2392
|
+
/**
|
|
2393
|
+
* Parses an `algn` attribute value from a file. A value outside
|
|
2394
|
+
* `ST_TextAlignType` is malformed input and reads as unset.
|
|
2395
|
+
*/
|
|
2396
|
+
const parseAlignmentToken = (value) => ALIGNMENT_TOKENS.find((token) => token === value) ?? null;
|
|
2383
2397
|
const alignToken = (a, caller) => {
|
|
2384
2398
|
oneOf(a, [
|
|
2385
2399
|
"left",
|
|
@@ -11949,10 +11963,12 @@ const getTableCellPosition = (cell) => ({
|
|
|
11949
11963
|
col: cell[CELL_COL]
|
|
11950
11964
|
});
|
|
11951
11965
|
/**
|
|
11952
|
-
* Reads the horizontal alignment from the cell's first paragraph
|
|
11953
|
-
* (`l`, `ctr`, `r`, `just`, `dist`, `justLow`, `thaiDist`)
|
|
11954
|
-
* `
|
|
11955
|
-
* has no
|
|
11966
|
+
* Reads the horizontal alignment from the cell's first paragraph as its
|
|
11967
|
+
* spec token (`l`, `ctr`, `r`, `just`, `dist`, `justLow`, `thaiDist`) — so
|
|
11968
|
+
* `setTableCellAlignment(cell, 'center')` reads back as `'ctr'`. Returns
|
|
11969
|
+
* `null` when the cell has no `<a:txBody>`, or its first paragraph has no
|
|
11970
|
+
* valid `algn` attribute (PowerPoint then defaults to `l`). For a
|
|
11971
|
+
* plain-English name per paragraph, use `getTableCellParagraphs`.
|
|
11956
11972
|
*/
|
|
11957
11973
|
const getTableCellAlignment = (cell) => {
|
|
11958
11974
|
const txBody = firstChildElement(cell[CELL_ELEMENT], NAME_A_TX_BODY_TBL);
|
|
@@ -11961,7 +11977,7 @@ const getTableCellAlignment = (cell) => {
|
|
|
11961
11977
|
if (p.kind !== "element" || p.name.namespaceURI !== NS.dml || p.name.localName !== "p") continue;
|
|
11962
11978
|
const pPr = firstChildElement(p, qname("a", "pPr", NS.dml));
|
|
11963
11979
|
if (!pPr) return null;
|
|
11964
|
-
return getAttrValue(pPr, qname("", "algn", ""))
|
|
11980
|
+
return parseAlignmentToken(getAttrValue(pPr, qname("", "algn", "")));
|
|
11965
11981
|
}
|
|
11966
11982
|
return null;
|
|
11967
11983
|
};
|
|
@@ -14417,13 +14433,17 @@ const setParagraphLevel = (shape, paragraphIndex, level) => {
|
|
|
14417
14433
|
commitAndRefresh(shape);
|
|
14418
14434
|
};
|
|
14419
14435
|
/**
|
|
14420
|
-
* Reads the paragraph's
|
|
14421
|
-
* `
|
|
14436
|
+
* Reads the paragraph's own `algn` as its spec token (`l`, `ctr`, `r`,
|
|
14437
|
+
* `just`, `dist`, `justLow`, `thaiDist`) — so `setParagraphAlignment(…,
|
|
14438
|
+
* 'center')` reads back as `'ctr'`. Returns `null` when the attribute is
|
|
14439
|
+
* absent (the paragraph inherits from its layout / master) or is not a
|
|
14440
|
+
* valid token. For the inherited value under a plain-English name, use
|
|
14441
|
+
* `getParagraphPropertiesEffective`.
|
|
14422
14442
|
*/
|
|
14423
14443
|
const getParagraphAlignment = (shape, paragraphIndex) => {
|
|
14424
14444
|
const pPr = firstChildElement(requireParagraph(shape, paragraphIndex), NAME_A_PPR);
|
|
14425
14445
|
if (pPr === null) return null;
|
|
14426
|
-
return getAttrValue(pPr, ATTR_ALGN_FN)
|
|
14446
|
+
return parseAlignmentToken(getAttrValue(pPr, ATTR_ALGN_FN));
|
|
14427
14447
|
};
|
|
14428
14448
|
/**
|
|
14429
14449
|
* Reads the paragraph's nesting level (`lvl` attribute), or `0` when
|
|
@@ -19472,8 +19492,8 @@ const getShapeMedia = (shape) => {
|
|
|
19472
19492
|
const findShapesWithMedia = (slide) => slide[SLIDE_SHAPES].filter((shape) => getShapeMedia(shape) !== null);
|
|
19473
19493
|
//#endregion
|
|
19474
19494
|
//#region src/api/index.ts
|
|
19475
|
-
const VERSION = "0.18.
|
|
19495
|
+
const VERSION = "0.18.1";
|
|
19476
19496
|
//#endregion
|
|
19477
19497
|
export { replaceTokensInPresentation as $, getTableCellAnchor as $a, appendSlideNotes as $i, getShapePreset as $n, getSlideLayoutType as $o, getShapeParagraphCount as $r, findCommentsByAuthor as $s, getShapeStroke as $t, getOutlineText as A, removeSlideNotes as Aa, getShapeImageBiLevelThreshold as Ai, setSlideLayout as An, setTableCellTextFormat as Ao, setShapePatternFill as Ar, getSlideColorMapOverride as As, setShapeText as At, getSlideLayoutCount as B, getPackageSize as Ba, getShapeImagePartName as Bi, getShapeAltTitle as Bn, getPresentationCreated as Bo, getShapeRunFormat as Br, getSlideMasterBackgroundPatternFill as Bs, findShapesByEffect as Bt, setSlideSections as C, getSlidesWithHyperlinks as Ca, emu as Cc, findFlippedShapes as Ci, getShapeSlide as Cn, setTableCellAnchor as Co, setShapeAdjustValues as Cr, getEffectiveColorMap as Cs, getShapeTextColumns as Ct, findSlidesByNotes as D, getSlidesWithTables as Da, findSlidesByLayoutPartName as Di, getSlideShapes as Dn, setTableCellParagraphs as Do, setShapeImageFill as Dr, getSlideBackgroundGradientFill as Ds, setShapeAlignment as Dt, findSlideByTitle as E, getSlidesWithOverlap as Ea, pt as Ec, findSlidesByLayoutName as Ei, getSlideLayout as En, setTableCellMargins as Eo, setShapeGradientFill as Er, getSlideBackground as Es, getShapeTextWrap as Et, getShapeAt as F, setSlideTransition as Fa, getShapeImageDuotone as Fi, getGroupChildren as Fn, getThumbnail as Fo, setShapeStrokeArrow as Fr, getSlideLayoutBackgroundShapes as Fs, setShapeTextDirection as Ft, getSlideXmlString as G, setMediaPartBytes as Ga, setShapeImageContrast as Gi, getShapeDescription as Gn, touchModified as Go, getParagraphBulletImageBytes as Gr, setShapeClickAction as Gs, setShapeShadow as Gt, getSlidePartName as H, getSlideMediaPartNames as Ha, hasShapeText as Hi, getShapeBoundsResolved as Hn, incrementRevision as Ho, resolveDrawingColorOpacity as Hr, setSlideBackground as Hs, getShapeEffects as Ht, getSlideAt as I, _internalPackageOf as Ia, getShapeImageFillBytes as Ii, getGroupTransform as In, removeThumbnail as Io, setShapeStrokeCap as Ir, getSlideLayoutShapes as Is, setShapeTextFormat as It, isSlideHidden as J, clearTableCellFill as Ja, SLIDE_SIZE_16_10 as Ji, getShapeKind as Jn, findSlideLayoutByPartName as Jo, getParagraphIndent as Jr, clearAllSlideComments as Js, getShapeFill as Jt, getSlides as K, slidesUsingMediaPart as Ka, setShapeImageCrop as Ki, getShapeFlip as Kn, findLayoutsWithPlaceholderType as Ko, getParagraphBulletStyle as Kr, setShapeImage as Ks, getShapeGradientFill as Kt, getSlideCount as L, compactPackage as La, getShapeImageFormat as Li, getMaxShapeId as Ln, setThumbnail as Lo, setShapeStrokeCompound as Lr, getSlideMasterBackground as Ls, setShapeTextMargins as Lt, getPresentationText as M, setSlideNotes as Ma, getShapeImageBytes as Mi, centerShapeOnSlide as Mn, setTableRowHeight as Mo, setShapeRotation as Mr, getSlideLayoutBackgroundGradientFill as Ms, setShapeTextAutoFit as Mt, getPresentationTextLength as N, clearSlideTransition as Na, getShapeImageContrast as Ni, findShapesAtPoint as Nn, setTableStyleFlags as No, setShapeSize as Nr, getSlideLayoutBackgroundImageBytes as Ns, setShapeTextBodyRotationDeg as Nt, findSlidesByText as O, getVisibleSlides as Oa, findSlidesByLayoutType as Oi, getSlidesWithEmptyPlaceholders as On, setTableCellText as Oo, setShapeNoFill as Or, getSlideBackgroundImageBytes as Os, setShapeBullets as Ot, getPresentationTextLengthsBySlide as P, getSlideTransition as Pa, getShapeImageCrop as Pi, findShapesInRect as Pn, setTableStyleId as Po, setShapeStroke as Pr, getSlideLayoutBackgroundPatternFill as Ps, setShapeTextColumns as Pt, replaceTextInSlideNotes as Q, getTableCellAlignment as Qa, setSlideSize as Qi, getShapePosition as Qn, getSlideLayoutPlaceholders as Qo, getShapeHyperlinkTooltip as Qr, findCommentsBefore as Qs, getShapeFillOpacity as Qt, getSlideIndex as R, getMediaParts as Ra, getShapeImageLinkUrl as Ri, getMaxShapeIdInPresentation as Rn, getCoreProperties as Ro, setShapeStrokeDash as Rr, getSlideMasterBackgroundGradientFill as Rs, setShapeTextWrap as Rt, getSlideSections as S, getSlidesWithComments as Sa, cm as Sc, setShapeAnimation as Si, getShapeIndex as Sn, setTableCellAlignment as So, getShapeStrokeDash as Sr, setChartSpec as Ss, getShapeTextBodyRotationDeg as St, findSlideByText as T, getSlidesWithNotes as Ta, mm as Tc, findShapesOutsideCanvas as Ti, getShapesBounds as Tn, setTableCellFill as To, setShapeFlip as Tr, clearSlideBackground as Ts, getShapeTextMargins as Tt, getSlideText as U, listPackageParts as Ua, isShapeImageGrayscale as Ui, getShapeCenter as Un, setCoreProperties as Uo, getParagraphAlignment as Ur, setSlideBackgroundImage as Us, getShapeEffectsEffective as Ut, getSlideOutline as V, getPresentationSummary as Va, hasShapeImage as Vi, getShapeBounds as Vn, getPresentationModified as Vo, resolveDrawingColor as Vr, getSlideMasterShapes as Vs, getShapeEffect as Vt, getSlideTextLength as W, readPackagePart as Wa, setShapeImageBrightness as Wi, getShapeCustomGeometry as Wn, setExtendedProperties as Wo, getParagraphBullet as Wr, getShapeClickAction as Ws, setShapeGlow as Wt, replaceTextInPresentation as X, getSlideTables as Xa, SLIDE_SIZE_4_3 as Xi, getShapePlaceholderIdx as Xn, getSlideLayoutName as Xo, getParagraphLineSpacing as Xr, findCommentAuthorByName as Xs, getShapeFillColorResolved as Xt, replaceTextInNotes as Y, getPresentationTableCountsBySlide as Ya, SLIDE_SIZE_16_9 as Yi, getShapeName as Yn, findSlideLayoutByType as Yo, getParagraphLevel as Yr, clearSlideComments as Ys, getShapeFillColor as Yt, replaceTextInSlide as Z, getTableCell as Za, getSlideSize as Zi, getShapePlaceholderType as Zn, getSlideLayoutPartName as Zo, getParagraphSpacing as Zr, findCommentsAfter as Zs, getShapeFillEffective as Zt, moveSlide as _, getPresentationNotesLengthsBySlide as _a, setPresentationFonts as _c, setSlidePlaceholders as _i, findShapesByText as _n, isChartShape as _o, shapesOverlap as _r, getShapeChartKind as _s, appendShapeText as _t, groupShapes as a, findSlidesWithChartTrendlines as aa, getCommentPosition as ac, getShapeRunText as ai, getShapeStrokeJoin as an, getTableCellSpan as ao, getSlideMasterPartNames as ar, getShapeHyperlink as as, addSlideShape as at, sortSlides as b, getSlideNotesLength as ba, loadPresentation as bc, findShapesWithAnimation as bi, findSlidePlaceholderByIdx as bn, removeTableColumn as bo, getShapePatternFill as br, getShapeChartSpec as bs, getShapeTextAutoFit as bt, addContentSlide as c, getAllHyperlinks as ca, getCommentsSortedByDate as cc, setParagraphBullet as ci, findEmptyPlaceholders as cn, getTableCells as co, isShapeHidden as cr, setShapeRunFormat as cs, bringShapeForward as ct, addSlideAt as d, getAllTables as da, getPresentationCommenters as dc, setParagraphSpacing as di, findShapeByText as dn, getTableRowHeights as do, pointInShape as dr, findChartsBySeriesName as ds, copyShape as dt, clearAllHyperlinks as ea, findCommentsByText as ec, getShapeParagraphElements as ei, getShapeStrokeCap as en, getTableCellBorders as eo, getShapeRotation as er, getSlideLayoutUsageCounts as es, searchSlides as et, addTitleSlide as f, getDistinctHyperlinkUrls as fa, getSlideCommentAuthors as fc, setShapeRunHyperlink as fi, findShapeInPresentation as fn, getTableSize as fo, renameShape as fr, findChartsWithDataLabels as fs, getShapeZIndex as ft, mergePresentations as g, getPresentationNotesLength as ga, getPresentationTheme as gc, setSlideBody as gi, findShapesByPreset as gn, insertTableRow as go, setShapeHidden as gr, getShapeChartCategories as gs, setShapeZIndex as gt, importSlide as h, getPresentationHyperlinkCountsBySlide as ha, getPresentationFonts as hc, getSlideTitle as hi, findShapesByName as hn, insertTableColumn as ho, setShapeDescription as hr, getPresentationChartKindCounts as hs, sendShapeToBack as ht, getShapeMedia as i, findSlidesWithChartKind as ia, getCommentDate as ic, getShapeRunHyperlinkTooltip as ii, getShapeStrokeEffective as in, getTableCellPosition as io, getSlideMasterPartName as ir, getParagraphPropertiesEffective as is, addSlideLine as it, getPresentationShapeCountsBySlide as j, replaceHyperlink as ja, getShapeImageBrightness as ji, translateShapes as jn, setTableColumnWidth as jo, setShapePosition as jr, getSlideLayoutBackground as js, setShapeTextAnchor as jt, getAllShapes as k, hasSlideNotes as ka, getPresentationImageCountsBySlide as ki, replaceTokensInSlide as kn, setTableCellTextDirection as ko, setShapeNoStroke as kr, getSlideBackgroundPatternFill as ks, setShapeParagraphs as kt, addSectionHeaderSlide as l, getAllImages as la, getPresentationCommentCountsByAuthor as lc, setParagraphLevel as li, findShapeById as ln, getTableColumnWidths as lo, isShapePlaceholder as lr, addSlideChart as ls, bringShapeToFront as lt, duplicateSlideAt as m, getHiddenSlides as ma, removeSlideComment as mc, getSlideBody as mi, findShapesByKind as mn, getTableStyleId as mo, setShapeBounds as mr, getPresentationChartCountsBySlide as ms, sendShapeBackward as mt, addSlideMedia as n, clearSlideHyperlinks as na, getCommentAuthor as nc, getShapeRunCount as ni, getShapeStrokeColorResolved as nn, getTableCellMargins as no, getShapeText as nr, getSlideLayouts as ns, slideHasAnimations as nt, ungroupShapes as o, getAllCharts as oa, getCommentSlide as oc, isParagraphBulletPicture as oi, getShapeStrokeOpacity as on, getTableCellText as oo, getSlideMasterUsageCounts as or, getShapeRunFormatEffective as os, addSlideTable as ot, duplicateSlide as p, getEmptySlides as pa, getSlideComments as pc, setShapeRunText as pi, findShapesByHyperlink as pn, getTableStyleFlags as po, setShapeAltTitle as pr, findChartsWithTrendlines as ps, removeShape as pt, getSlidesByLayout as q, validatePresentation as qa, setShapeImageOpacity as qi, getShapeId as qn, findSlideLayout as qo, getParagraphEndFormat as qr, addSlideComment as qs, getShapeGradientFillEffective as qt, findShapesWithMedia as r, findSlidesByHyperlink as ra, getCommentAuthors as rc, getShapeRunHyperlink as ri, getShapeStrokeCompound as rn, getTableCellParagraphs as ro, getSlideMasterCount as rr, getUnusedSlideLayouts as rs, addSlideImage as rt, addBlankSlide as s, getAllComments as sa, getCommentText as sc, setParagraphAlignment as si, getShapeStrokeWidth as sn, getTableCellTextDirection as so, getUnusedSlideMasters as sr, setShapeHyperlink as ss, addSlideTextBox as st, VERSION as t, clearAllSlideNotes as ta, findSlidesWithCommentsByAuthor as tc, getShapeRunClickAction as ti, getShapeStrokeColor as tn, getTableCellFill as to, getShapeSize as tr, getSlideLayoutUsageCountsByType as ts, setSlideHidden as tt, addSlide as u, getAllNotes as ua, getPresentationCommentCountsBySlide as uc, setParagraphLineSpacing as ui, findShapeByName as un, getTableDimensions as uo, isShapeTextBox as ur, findChartByKind as us, clearSlideShapes as ut, removeSlide as v, getPresentationNotesText as va, setPresentationTheme as vc, setSlideTitle as vi, findShapesWithHyperlinks as vn, isTableShape as vo, clearShapeFill as vr, getShapeChartSeriesNames as vs, getShapeBodyPrEffective as vt, findSlideByPartName as w, getSlidesWithImages as wa, inches as wc, findOverlappingShapePairs as wi, getShapeXmlString as wn, setTableCellBorders as wo, setShapeFill as wr, resolveDeckBodyTextColor as ws, getShapeTextDirection as wt, swapSlides as x, getSlidesWithCharts as xa, savePresentation as xc, getShapeAnimation as xi, findSlidePlaceholders as xn, removeTableRow as xo, getShapeStrokeArrow as xr, getSlideCharts as xs, getShapeTextAutoFitParams as xt, reverseSlides as y, getSlideNotes as ya, createPresentation as yc, clearSlideAnimations as yi, findSlidePlaceholder as yn, mergeTableCells as yo, clearShapeStroke as yr, getShapeChartSeriesValues as ys, getShapeTextAnchor as yt, getSlideInfo as z, getOrphanMediaPartNames as za, getShapeImageOpacity as zi, getShapeAdjustValues as zn, getExtendedProperties as zo, setShapeStrokeJoin as zr, getSlideMasterBackgroundImageBytes as zs, clearShapeEffects as zt };
|
|
19478
19498
|
|
|
19479
|
-
//# sourceMappingURL=api-
|
|
19499
|
+
//# sourceMappingURL=api-DlzYhUxG.js.map
|