@lofcz/pptist 2.0.13 → 2.0.15

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.
@@ -78,6 +78,22 @@ export declare function normalizeAudioPatch(patch: PptistAudioElementPatch): Par
78
78
  export declare function resolveShapeFormula(element: PPTShapeElement): PPTShapeElement;
79
79
  export declare function normalizeShapeElement(element?: Partial<PPTShapeElement>): PPTShapeElement;
80
80
  export declare function mergeShapeElement(base: PPTShapeElement, patch: Partial<PPTShapeElement>): PPTShapeElement;
81
+ export interface LatexGeometry {
82
+ path: string;
83
+ viewBox: [number, number];
84
+ width: number;
85
+ height: number;
86
+ }
87
+ /**
88
+ * Render a LaTeX formula to its SVG path + intrinsic box via hfmath — the EXACT
89
+ * pipeline the interactive LaTeXEditor uses (`new hfmath(latex).pathd()/box()`).
90
+ *
91
+ * The agent supplies only the `latex` string; it cannot pre-compute the SVG
92
+ * `path`. Without a path the `<svg>` renders nothing, so a "latex" element from
93
+ * the agent shows up blank. Deriving the path here makes agent-authored formulas
94
+ * render identically to ones drawn through the editor UI.
95
+ */
96
+ export declare function deriveLatexGeometry(latex: string): LatexGeometry;
81
97
  export declare function normalizeLatexElement(element: PptistLatexElementInput): PPTLatexElement;
82
98
  export declare function normalizeLineElement(element: Partial<PPTLineElement> & {
83
99
  type?: 'line';
@@ -1,20 +1,3 @@
1
- /**
2
- * Compositional slide layouts for the agentic bridge.
3
- *
4
- * A "layout" is a named, pre-composed slide recipe (title, bullets, two-column,
5
- * image+text, big stat, quote, chart, comparison, …). The agent picks a layout
6
- * by id and fills a few content *slots*; the builder here lays out themed,
7
- * contrast-safe elements using the active style preset's role tokens and a
8
- * fixed margin grid. This is the preferred way to add slides — it removes the
9
- * need to hand-place boxes or hand-pick colors/sizes, and it never emits raw
10
- * authoring HTML the agent has to reason about.
11
- *
12
- * Builders are deterministic and pure (no async, no store access): given a
13
- * viewport, a style preset, and slots, they return a `Partial<Slide>` that the
14
- * bridge normalizes and inserts. Text content is rendered to the small, safe
15
- * HTML subset PPTist stores (`<p>/<ul>/<li>/<span style>` with inline size and
16
- * color), with light inline markdown (`**bold**`, `_italic_`, `` `code` ``).
17
- */
18
1
  import type { PPTChartElement, PPTImageElement, PPTShapeElement, PPTTableElement, PPTTextElement, Slide } from '../../types/slides';
19
2
  import type { PptistStylePreset } from './styles';
20
3
  /**
@@ -62,8 +45,9 @@ export interface PptistLayoutBuildResult {
62
45
  /**
63
46
  * Build a themed slide from a layout id + content slots. Pure and deterministic:
64
47
  * returns a `Partial<Slide>` (background + un-normalized elements) plus any
65
- * non-fatal warnings (e.g. a missing optional image). Throws on missing
66
- * required slots or an unknown layout.
48
+ * non-fatal warnings (e.g. a missing optional image). Text is auto-fit to each
49
+ * box via pretext, so content never overflows. Throws on missing required slots
50
+ * or an unknown layout.
67
51
  */
68
52
  export declare function buildLayoutSlide(layoutId: string, slots: Slots, preset: PptistStylePreset, viewport: {
69
53
  width: number;
@@ -3,9 +3,13 @@ import type { ShapeCategoryKey, ShapePoolItem } from '../../configs/shapes';
3
3
  import type { Broken2LineDirection, ChartData, ChartOptions, ChartType, Gradient, LinePoint, LineStyleType, Note, NoteReply, PPTAnimation, PPTAudioElement, PPTChartElement, PPTElement, PPTElementLink, PPTElementOutline, PPTElementShadow, PPTImageElement, PPTLatexElement, PPTLineElement, PPTShapeElement, PPTTableElement, PPTTextElement, PPTVideoElement, ShapeText, Slide, SlideBackground, SlideTemplate, SlideTheme, TableCell, TableCellStyle, TextAlign, TurningMode } from '../../types/slides';
4
4
  import type { PptistDocument } from '../types';
5
5
  import type { PptistTemplateSlidesCatalogResult, PptistTemplateSummary } from './templates';
6
+ import type { PptistLayout, PptistLayoutBackgroundMode } from './layouts';
7
+ import type { PptistStyleSummary } from './styles';
6
8
  import type { PptistAgenticDocs, PptistCommandDescription, PptistDesignGuide, PptistDomainSummary } from './manifestDocs';
7
9
  export type { PptistAgenticDocs, PptistCommandDescription, PptistCommandDoc, PptistDesignGuide, PptistDesignSystem, PptistDocParam, PptistDomainDoc, PptistDomainSummary, } from './manifestDocs';
8
10
  export type { PptistTemplateSummary, PptistTemplateSlideEntry, PptistTemplateSlidesCatalog, PptistTemplateSlidesCatalogResult, } from './templates';
11
+ export type { PptistLayout, PptistLayoutSlotDef, PptistLayoutBackgroundMode, } from './layouts';
12
+ export type { PptistStyleSummary, PptistStylePreset, PptistStylePalette, PptistStyleScale, PptistStyleFonts, } from './styles';
9
13
  export type PptistKnownCommandType = keyof PptistCommandPayloadMap;
10
14
  export type PptistCommandType = PptistKnownCommandType | (string & {});
11
15
  export interface PptistDeckViewport {
@@ -254,7 +258,7 @@ export interface PptistLatexElementSizing {
254
258
  height?: number;
255
259
  rotate?: number;
256
260
  }
257
- export type PptistLatexElementInput = PptistLatexElementSizing & Pick<PPTLatexElement, 'latex' | 'path'> & Partial<Pick<PPTLatexElement, 'id' | 'color' | 'strokeWidth' | 'viewBox' | 'fixedRatio' | 'link' | 'name' | 'lock' | 'groupId'>>;
261
+ export type PptistLatexElementInput = PptistLatexElementSizing & Pick<PPTLatexElement, 'latex'> & Partial<Pick<PPTLatexElement, 'path' | 'id' | 'color' | 'strokeWidth' | 'viewBox' | 'fixedRatio' | 'link' | 'name' | 'lock' | 'groupId'>>;
258
262
  export type PptistLatexElementPatch = Partial<PptistLatexElementSizing & Pick<PPTLatexElement, 'latex' | 'path' | 'color' | 'strokeWidth' | 'viewBox' | 'fixedRatio' | 'link' | 'name' | 'lock' | 'groupId'>>;
259
263
  export interface PptistCreateLatexElementInput {
260
264
  slideId?: string;
@@ -450,6 +454,35 @@ export interface PptistAgentTemplatesApi {
450
454
  /** List insertable slides for a template, grouped by type (cover, contents, …). */
451
455
  slidesCatalog(templateId: string, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistTemplateSlidesCatalogResult>>;
452
456
  }
457
+ export interface PptistApplyStyleResult {
458
+ /** The preset id actually applied (the requested one, or the default fallback). */
459
+ styleId: string;
460
+ theme: SlideTheme;
461
+ }
462
+ export interface PptistCreateFromLayoutInput {
463
+ /** Layout id from `layouts.catalog` (e.g. `title`, `bullets`, `twoColumn`). */
464
+ layoutId: string;
465
+ /** Content slots for the layout. Keys + shapes are described per layout in the catalog. */
466
+ slots?: Record<string, unknown>;
467
+ index?: number;
468
+ select?: boolean;
469
+ /** Force a feature (dark) or plain background; defaults to the layout's own preference. */
470
+ backgroundMode?: PptistLayoutBackgroundMode;
471
+ }
472
+ export interface PptistCreateFromLayoutResult {
473
+ slideId: string;
474
+ layoutId: string;
475
+ elementIds: string[];
476
+ textElementIds: string[];
477
+ }
478
+ export interface PptistAgentStylesApi {
479
+ /** List the contrast-safe visual identity presets (academic/minimal/bold/playful). */
480
+ catalog(): PptistStyleSummary[];
481
+ }
482
+ export interface PptistAgentLayoutsApi {
483
+ /** List the compositional slide recipes and their content slots. */
484
+ catalog(): PptistLayout[];
485
+ }
453
486
  export interface PptistAgentDeckApi {
454
487
  get(): PptistDeckDocument;
455
488
  set(document: PptistDeckInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistDeckDocument>>;
@@ -460,6 +493,8 @@ export interface PptistAgentDeckApi {
460
493
  getTheme(): SlideTheme;
461
494
  setTheme(theme: PptistSlideThemePatch, meta?: PptistCommandMeta): Promise<PptistCommandResult<SlideTheme>>;
462
495
  applyTemplate(templateId: string, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistApplyTemplateResult>>;
496
+ /** Apply a style preset (from `styles.catalog`) as the deck's visual identity; records `theme.styleId`. */
497
+ applyStyle(styleId: string, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistApplyStyleResult>>;
463
498
  applyTheme(theme: PptistSlideThemePatch, options?: PptistApplyThemeOptions, meta?: PptistCommandMeta): Promise<PptistCommandResult<SlideTheme>>;
464
499
  extractTheme(options?: PptistThemeExtractionOptions): SlideTheme;
465
500
  setViewport(viewport: {
@@ -474,6 +509,8 @@ export interface PptistAgentSlidesApi {
474
509
  current(): Slide | null;
475
510
  read(slideIdOrIndex?: PptistSlideReference, meta?: PptistCommandMeta): Promise<PptistCommandResult<Slide | null>>;
476
511
  create(input?: PptistCreateSlideInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<Slide>>;
512
+ /** Build + insert a themed slide from a layout recipe (from `layouts.catalog`) using the active style preset. */
513
+ createFromLayout(input: PptistCreateFromLayoutInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistCreateFromLayoutResult>>;
477
514
  insertFromTemplate(input: PptistInsertFromTemplateInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistInsertFromTemplateResult>>;
478
515
  insert(input: PptistInsertSlidesInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistInsertSlidesResult>>;
479
516
  update(slideId: string, patch: Partial<Slide>, meta?: PptistCommandMeta): Promise<PptistCommandResult<Slide>>;
@@ -1015,6 +1052,8 @@ export interface PptistAgentApi {
1015
1052
  deck: PptistAgentDeckApi;
1016
1053
  slides: PptistAgentSlidesApi;
1017
1054
  templates: PptistAgentTemplatesApi;
1055
+ styles: PptistAgentStylesApi;
1056
+ layouts: PptistAgentLayoutsApi;
1018
1057
  elements: PptistAgentElementsApi;
1019
1058
  text: PptistAgentTextApi;
1020
1059
  shapes: PptistAgentShapesApi;
@@ -1055,6 +1094,9 @@ export interface PptistCommandPayloadMap {
1055
1094
  'deck.applyTemplate': {
1056
1095
  templateId: string;
1057
1096
  };
1097
+ 'deck.applyStyle': {
1098
+ styleId: string;
1099
+ };
1058
1100
  'deck.extractTheme': {
1059
1101
  options?: PptistThemeExtractionOptions;
1060
1102
  } | undefined;
@@ -1069,6 +1111,8 @@ export interface PptistCommandPayloadMap {
1069
1111
  'templates.slidesCatalog': {
1070
1112
  templateId: string;
1071
1113
  };
1114
+ 'styles.catalog': undefined;
1115
+ 'layouts.catalog': undefined;
1072
1116
  'import.json': PptistDocumentImportPayload;
1073
1117
  'import.pptist': PptistDocumentImportPayload;
1074
1118
  'import.pptxSafe': PptistDocumentImportPayload;
@@ -1083,6 +1127,7 @@ export interface PptistCommandPayloadMap {
1083
1127
  slideIdOrIndex?: PptistSlideReference;
1084
1128
  } | undefined;
1085
1129
  'slides.create': PptistCreateSlideInput | undefined;
1130
+ 'slides.createFromLayout': PptistCreateFromLayoutInput;
1086
1131
  'slides.insertFromTemplate': PptistInsertFromTemplateInput;
1087
1132
  'slides.insert': PptistInsertSlidesInput;
1088
1133
  'slides.update': {
@@ -1685,11 +1730,14 @@ export interface PptistCommandResultDataMap {
1685
1730
  'deck.setTheme': SlideTheme;
1686
1731
  'deck.applyTheme': SlideTheme;
1687
1732
  'deck.applyTemplate': PptistApplyTemplateResult;
1733
+ 'deck.applyStyle': PptistApplyStyleResult;
1688
1734
  'deck.extractTheme': SlideTheme;
1689
1735
  'deck.setViewport': PptistBridgeState;
1690
1736
  'deck.setTemplates': SlideTemplate[];
1691
1737
  'templates.catalog': PptistTemplateSummary[];
1692
1738
  'templates.slidesCatalog': PptistTemplateSlidesCatalogResult;
1739
+ 'styles.catalog': PptistStyleSummary[];
1740
+ 'layouts.catalog': PptistLayout[];
1693
1741
  'import.json': PptistDeckDocument;
1694
1742
  'import.pptist': PptistDeckDocument;
1695
1743
  'import.pptxSafe': PptistDeckDocument;
@@ -1699,6 +1747,7 @@ export interface PptistCommandResultDataMap {
1699
1747
  'slides.current': Slide | null;
1700
1748
  'slides.read': Slide | null;
1701
1749
  'slides.create': Slide;
1750
+ 'slides.createFromLayout': PptistCreateFromLayoutResult;
1702
1751
  'slides.insertFromTemplate': PptistInsertFromTemplateResult;
1703
1752
  'slides.insert': PptistInsertSlidesResult;
1704
1753
  'slides.update': Slide;
@@ -5,7 +5,7 @@ import '../assets/styles/global.scss';
5
5
  import '../assets/styles/font.scss';
6
6
  import type { PptistMountOptions, PptistMountResult } from './types';
7
7
  /**
8
- * Mount PPTist into a DOM node (for sciobot-next / other React hosts).
8
+ * Mount PPTist into a DOM node (for React / other embedding hosts).
9
9
  * Vue + Pinia are bundled in the embed build — the host does not need Vue installed.
10
10
  */
11
11
  export declare function mountPptist(target: HTMLElement | string, options?: PptistMountOptions): Promise<PptistMountResult>;
@@ -24,14 +24,14 @@ export interface PptistStarterPresentationOptions {
24
24
  fontColor?: string;
25
25
  backgroundColor?: string;
26
26
  }
27
- /** Serializable deck passed between sciobot-next and PPTist. */
27
+ /** Serializable deck passed between the embedding host and PPTist. */
28
28
  export interface PptistDocument {
29
29
  title: string;
30
30
  slides: Slide[];
31
31
  theme?: Partial<SlideTheme>;
32
32
  }
33
33
  export interface PptistMountOptions {
34
- /** UI locale — same union as sciobot-next (`cs` | `en` | `sk` | `pl`). */
34
+ /** UI locale (`cs` | `en` | `sk` | `pl`). */
35
35
  locale?: Locales;
36
36
  /** Initial deck; takes precedence over `loadDocument` and the starter slide. */
37
37
  document?: PptistDocument;
@@ -2,7 +2,7 @@ import type { Locales } from './i18n-types';
2
2
  export type { Locales };
3
3
  declare global {
4
4
  interface Window {
5
- /** Set by sciobot-next (React host) before PPTist mount in embed mode */
5
+ /** Set by the embedding host (e.g. a React app) before PPTist mount in embed mode */
6
6
  __PPTIST_LOCALE__?: string;
7
7
  }
8
8
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Vue composable for i18n — mirrors sciobot-next's `useI18nContext()` API.
2
+ * Vue composable for i18n — mirrors the typesafe-i18n `useI18nContext()` API.
3
3
  * Returns reactive `{ LL, locale, setLocale }`.
4
4
  */
5
5
  export declare function useI18nContext(): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/pptist",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
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",