@lofcz/pptist 2.0.21 → 2.0.22

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.
@@ -6,7 +6,7 @@ export declare const BULLET_INDENT = 28;
6
6
  export interface TextFitBlock {
7
7
  /** Plain text of the block (markers stripped). */
8
8
  text: string;
9
- /** Font size in px the block renders at (its largest run, to stay safe). */
9
+ /** Authored font size in px (its largest run, to stay safe). */
10
10
  size: number;
11
11
  bold?: boolean;
12
12
  italic?: boolean;
@@ -19,45 +19,41 @@ export interface MeasureBlocksOptions {
19
19
  innerWidth: number;
20
20
  /** Line height multiplier (e.g. 1.5). */
21
21
  lineHeight: number;
22
- /** Vertical gap added between consecutive blocks, in px. */
22
+ /** Vertical gap added between consecutive blocks, in px (NOT scaled by sizeScale). */
23
23
  blockSpace?: number;
24
24
  /** Indent subtracted from the text column for list items, in px. */
25
25
  bulletIndent?: number;
26
26
  letterSpacing?: number;
27
- /** Multiply every size + gap by this factor before measuring (default 1). */
28
- scale?: number;
27
+ /** Multiply every block's font size by this factor before measuring (default 1). */
28
+ sizeScale?: number;
29
29
  }
30
30
  /**
31
- * Total wrapped height (px) of `blocks` laid out in a column of `innerWidth`.
32
- * Each block is measured independently with its own font, then summed with the
31
+ * Total wrapped height (px) of `blocks` laid out in a column of `innerWidth`,
32
+ * with each block's font size multiplied by `sizeScale`. Each block is measured
33
+ * independently with pretext, then summed with the (unscaled, px-fixed)
33
34
  * inter-block gap. Returns 0 for an empty input.
34
35
  */
35
36
  export declare function measureTextBlocksHeight(blocks: TextFitBlock[], options: MeasureBlocksOptions): number;
36
- export interface FitScaleOptions {
37
+ export interface FitFontScaleOptions {
37
38
  innerWidth: number;
38
39
  innerHeight: number;
39
40
  lineHeight: number;
40
41
  blockSpace?: number;
41
42
  bulletIndent?: number;
42
43
  letterSpacing?: number;
43
- /** Smallest scale to fall back to before clipping takes over (default 0.2). */
44
+ /** Smallest font factor to fall back to before clipping takes over (default 0.1). */
44
45
  minScale?: number;
45
46
  }
46
47
  /**
47
- * Largest uniform scale in `[minScale, 1]` at which `blocks` fit `innerHeight`.
48
- *
49
- * The renderer applies the result as `transform: scale(s)`, which scales the
50
- * already-wrapped block geometrically so the on-screen height is exactly
51
- * `naturalHeight * s`. That makes the fit a single measurement (no search):
52
- * `s = innerHeight / naturalHeight`, clamped. Returns 1 when content already
53
- * fits (or when measurement isn't possible).
48
+ * Largest uniform font factor in `[minScale, 1]` at which `blocks` fit
49
+ * `innerHeight`, found by binary search over pretext measurements. The factor
50
+ * multiplies the authored font sizes; because wrapping changes as the type
51
+ * shrinks, this re-measures at each candidate (not a single geometric divide).
52
+ * Returns 1 when content already fits (or measurement isn't possible).
54
53
  */
55
- export declare function fitScaleForBlocks(blocks: TextFitBlock[], options: FitScaleOptions): number;
56
- export type TextFitAlign = 'left' | 'center' | 'right';
54
+ export declare function fitFontScaleForBlocks(blocks: TextFitBlock[], options: FitFontScaleOptions): number;
57
55
  export interface ExtractedContent {
58
56
  blocks: TextFitBlock[];
59
- /** Dominant horizontal alignment (first non-empty block), for the scale origin. */
60
- align: TextFitAlign;
61
57
  }
62
58
  export interface ExtractOptions {
63
59
  defaultFontFamily: string;
@@ -71,3 +67,10 @@ export interface ExtractOptions {
71
67
  * so the marker indent is accounted for.
72
68
  */
73
69
  export declare function extractFitBlocksFromHtml(html: string, options: ExtractOptions): ExtractedContent;
70
+ /**
71
+ * Return a copy of `html` with every inline `font-size:Npx` multiplied by
72
+ * `scale` (rounded to 0.1px). Text without an explicit size is untouched here —
73
+ * the renderer scales that through the `--text-fit-base-size` CSS variable. A
74
+ * scale >= 1 (or a non-DOM context) returns the HTML unchanged.
75
+ */
76
+ export declare function scaleHtmlFontSizes(html: string, scale: number): string;
@@ -1,18 +1,22 @@
1
1
  import { type CSSProperties, type Ref } from 'vue';
2
2
  import type { PPTTextElement } from '../../../../types/slides';
3
3
  /**
4
- * Auto-fit a fixed-size text box so its content never overflows.
4
+ * Auto-fit a fixed-size text box so its content never overflows — by computing a
5
+ * real font size with pretext, not a CSS transform.
5
6
  *
6
- * Only fixed-height (`fixedHeight`) text boxes are constrained they have a
7
- * locked region instead of growing to fit. We measure the rendered content with
8
- * pretext (the same engine the agentic layout builder uses) and return a uniform
9
- * scale (<= 1) plus a transform-origin that respects the box's horizontal
10
- * alignment and `vAlign`. The renderer applies these to the text node as a CSS
11
- * transform, shrinking the type down from its authored size only as far as
12
- * needed. Vertical (top-to-bottom) text is left unscaled.
7
+ * Only fixed-height (`fixedHeight`) boxes are constrained; normal boxes grow to
8
+ * fit. We measure the wrapped content with pretext (the same engine the agentic
9
+ * layout builder uses) and binary-search the largest uniform font factor at which
10
+ * it still fits. The renderer then applies that factor as actual font sizes:
11
+ * - text with an explicit inline size renders from `fittedContent` (sizes
12
+ * rewritten to `size * factor`);
13
+ * - text using the default size shrinks via the `--text-fit-base-size` CSS
14
+ * variable (the computed px value), since `.ProseMirror` hardcodes 16px.
15
+ * Vertical (top-to-bottom) text is left untouched.
13
16
  */
14
17
  declare const _default: (elementInfo: Ref<PPTTextElement>) => {
15
18
  fitScale: Ref<number, number>;
16
- fitStyle: import("vue").ComputedRef<CSSProperties>;
19
+ fittedContent: import("vue").ComputedRef<string>;
20
+ fitVars: import("vue").ComputedRef<CSSProperties>;
17
21
  };
18
22
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/pptist",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "description": "PPTist presentation editor embed bundle with a typed agentic bridge.",
5
5
  "type": "module",
6
6
  "main": "dist/embed/pptist-embed.js",