@office-kit/pptx-preview 0.13.0 → 0.14.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 +1 -1
- package/dist/{index-DwLYANVE.d.ts → index-DUFPGYOf.d.ts} +26 -39
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/dist/{src-DYfIZIh8.js → src-Bwmf324Z.js} +313 -1052
- package/dist/src-Bwmf324Z.js.map +1 -0
- package/package.json +3 -3
- package/dist/src-DYfIZIh8.js.map +0 -1
package/README.md
CHANGED
|
@@ -195,4 +195,4 @@ the editable paragraph text.
|
|
|
195
195
|
|
|
196
196
|
### Text regions for editing overlays
|
|
197
197
|
|
|
198
|
-
`
|
|
198
|
+
`shapeTextRect(shape)` returns where a shape lays out its text, as fractions of its own extent: the `<a:rect>` its custom geometry states, or the one ECMA-376 defines for its preset (an ellipse's inscribed rectangle, a triangle's lower middle), following its adjust values. It is `null` when text takes the whole box. `resolveTextBodyRect(bounds, margins, region)` places that region in `bounds` less the body insets, giving the same inner text rectangle the preview uses before wrapping and autofit. Pass `{x, y, w, h}` and `{left, top, right, bottom}` in the same unit, normally EMU, with inherited/default margins already resolved. Margins that would collapse a region are dropped; a full box with nonpositive width or height stays degenerate so callers can handle it explicitly.
|
|
@@ -121,41 +121,33 @@ declare const paragraphNumberLabels: (paraData: ReadonlyArray<{
|
|
|
121
121
|
}>) => Array<string | null>;
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/text-body-rect.d.ts
|
|
124
|
+
/** A text rectangle as fractions of the shape's extent. */
|
|
125
|
+
interface TextRectFractions {
|
|
126
|
+
readonly l: number;
|
|
127
|
+
readonly t: number;
|
|
128
|
+
readonly r: number;
|
|
129
|
+
readonly b: number;
|
|
130
|
+
}
|
|
124
131
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
132
|
+
* Where a shape lays out its text, as fractions of its own extent: the
|
|
133
|
+
* `<a:rect>` its geometry states, written in its `<a:custGeom>` or in
|
|
134
|
+
* ECMA-376's definition of its preset (an ellipse's inscribed rectangle, a
|
|
135
|
+
* triangle's lower middle, an arrow's shaft). `null` lays text into the whole
|
|
136
|
+
* box: a shape that inherits its geometry, or whose rectangle has no room.
|
|
137
|
+
*
|
|
138
|
+
* The rectangle is in the shape's own `<a:ext>` space, so dividing by that —
|
|
139
|
+
* not by on-screen bounds, which carry a group's or autofit's scale — is what
|
|
140
|
+
* lets the result travel with the shape.
|
|
130
141
|
*/
|
|
131
|
-
declare function
|
|
132
|
-
textRect: {
|
|
133
|
-
l: number;
|
|
134
|
-
t: number;
|
|
135
|
-
r: number;
|
|
136
|
-
b: number;
|
|
137
|
-
} | null;
|
|
138
|
-
} | null, extent: {
|
|
139
|
-
w: number;
|
|
140
|
-
h: number;
|
|
141
|
-
} | null): {
|
|
142
|
-
l: number;
|
|
143
|
-
t: number;
|
|
144
|
-
r: number;
|
|
145
|
-
b: number;
|
|
146
|
-
} | null;
|
|
142
|
+
declare function shapeTextRect(shape: SlideShapeData): TextRectFractions | null;
|
|
147
143
|
/**
|
|
148
|
-
* Text layout rectangle used by the preview
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* margins collapse a
|
|
152
|
-
*
|
|
153
|
-
* A custom-geometry shape states its own rectangle in `<a:custGeom><a:rect>`.
|
|
154
|
-
* Pass it as `custom`, as fractions of the shape's extent so that it scales
|
|
155
|
-
* with `bounds` the way a preset region does, and it wins: unlike the table
|
|
156
|
-
* above it is not an approximation of anything — it is what the file says.
|
|
144
|
+
* Text layout rectangle used by the preview: `region` (from
|
|
145
|
+
* {@link shapeTextRect}, or `null` for the whole box) placed in `bounds`, less
|
|
146
|
+
* the body insets. All coordinates and margins must use the same unit
|
|
147
|
+
* (normally EMU). When margins collapse a region, the region is kept without
|
|
148
|
+
* them, as PowerPoint does.
|
|
157
149
|
*/
|
|
158
|
-
declare function resolveTextBodyRect(
|
|
150
|
+
declare function resolveTextBodyRect(bounds: {
|
|
159
151
|
x: number;
|
|
160
152
|
y: number;
|
|
161
153
|
w: number;
|
|
@@ -165,12 +157,7 @@ declare function resolveTextBodyRect(preset: string | null, bounds: {
|
|
|
165
157
|
top: number;
|
|
166
158
|
right: number;
|
|
167
159
|
bottom: number;
|
|
168
|
-
},
|
|
169
|
-
l: number;
|
|
170
|
-
t: number;
|
|
171
|
-
r: number;
|
|
172
|
-
b: number;
|
|
173
|
-
} | null): {
|
|
160
|
+
}, region: TextRectFractions | null): {
|
|
174
161
|
x: number;
|
|
175
162
|
y: number;
|
|
176
163
|
w: number;
|
|
@@ -245,5 +232,5 @@ declare function shapeTextAnchorOffset(pres: PresentationData, shape: SlideShape
|
|
|
245
232
|
*/
|
|
246
233
|
declare function textUnderlineStyle(underline: TextFormat['underline'], color: string, includeDecorationColor?: boolean): string;
|
|
247
234
|
//#endregion
|
|
248
|
-
export {
|
|
249
|
-
//# sourceMappingURL=index-
|
|
235
|
+
export { SERIF as C, defaultMeasurer as D, TextMeasurer as E, substituteFamily as O, SANS as S, TextLayoutMode as T, ARIAL as _, VerticalTextStyle as a, MeasureResult as b, TextRectFractions as c, paragraphNumberLabels as d, AuditTextLayoutOptions as f, renderTextEffectsSvg as g, renderSlideSvg as h, shapeTextAnchorOffset as i, resolveTextBodyRect as l, auditTextLayout as m, ShapeAutoFitScaleOptions as n, textColumnsStyle as o, TextAuditIssue as p, shapeAutoFitScale as r, verticalTextStyle as s, textUnderlineStyle as t, shapeTextRect as u, FontSpec as v, TIMES as w, RenderSlideOptions as x, MONO as y };
|
|
236
|
+
//# sourceMappingURL=index-DUFPGYOf.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { ARIAL, type AuditTextLayoutOptions, type FontSpec, MONO, type MeasureResult, type RenderSlideOptions, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type VerticalTextStyle, auditTextLayout, defaultMeasurer, paragraphNumberLabels, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale,
|
|
1
|
+
import { C as SERIF, D as defaultMeasurer, E as TextMeasurer, O as substituteFamily, S as SANS, T as TextLayoutMode, _ as ARIAL, a as VerticalTextStyle, b as MeasureResult, c as TextRectFractions, d as paragraphNumberLabels, f as AuditTextLayoutOptions, g as renderTextEffectsSvg, h as renderSlideSvg, i as shapeTextAnchorOffset, l as resolveTextBodyRect, m as auditTextLayout, n as ShapeAutoFitScaleOptions, o as textColumnsStyle, p as TextAuditIssue, r as shapeAutoFitScale, s as verticalTextStyle, t as textUnderlineStyle, u as shapeTextRect, v as FontSpec, w as TIMES, x as RenderSlideOptions, y as MONO } from "./index-DUFPGYOf.js";
|
|
2
|
+
export { ARIAL, type AuditTextLayoutOptions, type FontSpec, MONO, type MeasureResult, type RenderSlideOptions, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type TextRectFractions, type VerticalTextStyle, auditTextLayout, defaultMeasurer, paragraphNumberLabels, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as textColumnsStyle, a as renderTextEffectsSvg, b as
|
|
2
|
-
export { ARIAL, MONO, SANS, SERIF, TIMES, auditTextLayout, defaultMeasurer, paragraphNumberLabels, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale,
|
|
1
|
+
import { _ as textColumnsStyle, a as renderTextEffectsSvg, b as shapeTextRect, c as MONO, d as TIMES, f as defaultMeasurer, g as textUnderlineStyle, h as paragraphNumberLabels, i as renderSlideSvg, l as SANS, m as substituteFamily, n as shapeTextAnchorOffset, o as ARIAL, r as auditTextLayout, t as shapeAutoFitScale, u as SERIF, v as verticalTextStyle, y as resolveTextBodyRect } from "./src-Bwmf324Z.js";
|
|
2
|
+
export { ARIAL, MONO, SANS, SERIF, TIMES, auditTextLayout, defaultMeasurer, paragraphNumberLabels, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as SERIF, D as defaultMeasurer, E as TextMeasurer, O as substituteFamily, S as SANS, T as TextLayoutMode, _ as ARIAL, a as VerticalTextStyle, b as MeasureResult, c as TextRectFractions, d as paragraphNumberLabels, f as AuditTextLayoutOptions, g as renderTextEffectsSvg, h as renderSlideSvg, i as shapeTextAnchorOffset, l as resolveTextBodyRect, m as auditTextLayout, n as ShapeAutoFitScaleOptions, o as textColumnsStyle, p as TextAuditIssue, r as shapeAutoFitScale, s as verticalTextStyle, t as textUnderlineStyle, u as shapeTextRect, v as FontSpec, w as TIMES, x as RenderSlideOptions, y as MONO } from "./index-DUFPGYOf.js";
|
|
2
2
|
import { PresentationData, SlideData } from "@office-kit/pptx";
|
|
3
3
|
|
|
4
4
|
//#region src/measure.d.ts
|
|
@@ -73,5 +73,5 @@ declare const renderSlideToRgba: (pres: PresentationData, slide: SlideData, opts
|
|
|
73
73
|
readonly png: Uint8Array;
|
|
74
74
|
};
|
|
75
75
|
//#endregion
|
|
76
|
-
export { ARIAL, type AuditTextLayoutOptions, FONT_DIR, FONT_FILES, type FontSpec, type FontkitMeasurerOptions, MONO, type MeasureResult, type RegisteredFont, RenderImageOptions, type RenderSlideOptions, RgbaImage, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type VerticalTextStyle, auditTextLayout, buildFontkitMeasurer, defaultMeasurer, paragraphNumberLabels, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale,
|
|
76
|
+
export { ARIAL, type AuditTextLayoutOptions, FONT_DIR, FONT_FILES, type FontSpec, type FontkitMeasurerOptions, MONO, type MeasureResult, type RegisteredFont, RenderImageOptions, type RenderSlideOptions, RgbaImage, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type TextRectFractions, type VerticalTextStyle, auditTextLayout, buildFontkitMeasurer, defaultMeasurer, paragraphNumberLabels, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
|
|
77
77
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as textColumnsStyle, a as renderTextEffectsSvg, b as
|
|
1
|
+
import { _ as textColumnsStyle, a as renderTextEffectsSvg, b as shapeTextRect, c as MONO, d as TIMES, f as defaultMeasurer, g as textUnderlineStyle, h as paragraphNumberLabels, i as renderSlideSvg, l as SANS, m as substituteFamily, n as shapeTextAnchorOffset, o as ARIAL, p as isCjk, r as auditTextLayout, s as AVG_GLYPH_W_RATIO, t as shapeAutoFitScale, u as SERIF, v as verticalTextStyle, y as resolveTextBodyRect } from "./src-Bwmf324Z.js";
|
|
2
2
|
import { getSlideSize } from "@office-kit/pptx";
|
|
3
3
|
import { Resvg } from "@resvg/resvg-js";
|
|
4
4
|
import * as fontkit from "fontkit";
|
|
@@ -195,6 +195,6 @@ const renderSlideToRgba = (pres, slide, opts = {}) => {
|
|
|
195
195
|
};
|
|
196
196
|
};
|
|
197
197
|
//#endregion
|
|
198
|
-
export { ARIAL, FONT_DIR, FONT_FILES, MONO, SANS, SERIF, TIMES, auditTextLayout, buildFontkitMeasurer, defaultMeasurer, paragraphNumberLabels, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale,
|
|
198
|
+
export { ARIAL, FONT_DIR, FONT_FILES, MONO, SANS, SERIF, TIMES, auditTextLayout, buildFontkitMeasurer, defaultMeasurer, paragraphNumberLabels, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
|
|
199
199
|
|
|
200
200
|
//# sourceMappingURL=node.js.map
|