@lofcz/pptist 2.0.8 → 2.0.9

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.
@@ -1,5 +1,7 @@
1
- export declare const EASTERN_EXTRAS_FONT_VALUES: string[];
2
- export declare const FONTS: {
3
- label: import("typesafe-i18n").LocalizedString;
1
+ export interface FontOption {
2
+ label: string;
4
3
  value: string;
5
- }[];
4
+ }
5
+ export declare const EASTERN_EXTRAS_FONT_VALUES: string[];
6
+ export declare function getFonts(): FontOption[];
7
+ export declare function useFonts(): import("vue").ComputedRef<FontOption[]>;
@@ -0,0 +1,72 @@
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
+ import type { PPTChartElement, PPTImageElement, PPTShapeElement, PPTTableElement, PPTTextElement, Slide } from '../../types/slides';
19
+ import type { PptistStylePreset } from './styles';
20
+ /**
21
+ * Un-normalized element inputs the builder emits. Typed as a discriminated
22
+ * union of per-type partials so the engine's required fields are still checked,
23
+ * while letting the bridge's `normalizeElement` fill ids/defaults on insert.
24
+ */
25
+ export type PptistLayoutElementInput = (Partial<PPTTextElement> & {
26
+ type: 'text';
27
+ }) | (Partial<PPTShapeElement> & {
28
+ type: 'shape';
29
+ }) | (Partial<PPTImageElement> & {
30
+ type: 'image';
31
+ }) | (Partial<PPTChartElement> & {
32
+ type: 'chart';
33
+ }) | (Partial<PPTTableElement> & {
34
+ type: 'table';
35
+ });
36
+ export type PptistLayoutBackgroundMode = 'auto' | 'feature' | 'plain';
37
+ export interface PptistLayoutSlotDef {
38
+ name: string;
39
+ /** Coarse shape of the value the agent should pass for this slot. */
40
+ type: 'text' | 'bullets' | 'image' | 'chart' | 'stats' | 'rows';
41
+ required: boolean;
42
+ description: string;
43
+ }
44
+ export interface PptistLayout {
45
+ id: string;
46
+ label: string;
47
+ /** One-line catalog description of the composition (what it looks like). */
48
+ summary: string;
49
+ /** When to reach for it. */
50
+ bestFor: string;
51
+ /** Whether it defaults to a feature (dark) background. */
52
+ feature: boolean;
53
+ slots: PptistLayoutSlotDef[];
54
+ }
55
+ type Slots = Record<string, unknown>;
56
+ export declare const PPTX_LAYOUTS: PptistLayout[];
57
+ export declare function listLayouts(): PptistLayout[];
58
+ export interface PptistLayoutBuildResult {
59
+ slide: Partial<Slide>;
60
+ warnings: string[];
61
+ }
62
+ /**
63
+ * Build a themed slide from a layout id + content slots. Pure and deterministic:
64
+ * 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.
67
+ */
68
+ export declare function buildLayoutSlide(layoutId: string, slots: Slots, preset: PptistStylePreset, viewport: {
69
+ width: number;
70
+ height: number;
71
+ }, backgroundMode?: PptistLayoutBackgroundMode): PptistLayoutBuildResult;
72
+ export {};
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Style presets for the agentic bridge.
3
+ *
4
+ * A "style" is a small, curated bundle of design tokens — a color palette with
5
+ * named *roles* (background / title / body / accent / …), a heading+body font
6
+ * pairing, and a typographic size scale. Presets are hand-tuned so every
7
+ * role-pair clears WCAG AA contrast, which lets the agent build good-looking,
8
+ * legible slides without hand-picking colors or font sizes.
9
+ *
10
+ * The agent flow is:
11
+ * 1. `styles.catalog` → see the available presets.
12
+ * 2. `deck.applyStyle` → pick ONE; it sets the deck theme + records `styleId`.
13
+ * 3. `slides.createFromLayout` → layouts read the active preset's role tokens
14
+ * to place themed, contrast-safe elements.
15
+ *
16
+ * Only the preset *id* is persisted on the deck theme (`theme.styleId`); the
17
+ * rich token data lives here in code, so it always renders deterministically
18
+ * and survives document serialization without bloating the saved deck.
19
+ */
20
+ import type { SlideTheme } from '../../types/slides';
21
+ /** Named color roles. Every role pairs with a readable foreground/background. */
22
+ export interface PptistStylePalette {
23
+ /** Default slide background (content slides). */
24
+ background: string;
25
+ /** Subtle panel/card fill that sits on `background`. */
26
+ surface: string;
27
+ /** Heading/title text on `background`/`surface`. */
28
+ title: string;
29
+ /** Body/paragraph text on `background`/`surface`. */
30
+ body: string;
31
+ /** De-emphasized text (captions, labels) on `background`/`surface`. */
32
+ muted: string;
33
+ /** Hairline rules, dividers, and thin borders. */
34
+ rule: string;
35
+ /** Primary accent (bars, highlights, key numbers). */
36
+ accent: string;
37
+ /** Secondary accent for variety (second series, alt highlight). */
38
+ accent2: string;
39
+ /** Tinted accent wash for soft panels/bands. */
40
+ accentSoft: string;
41
+ /** Readable foreground when placed on `accent`. */
42
+ onAccent: string;
43
+ /** Feature background for title/section/closing slides (usually dark). */
44
+ featureBackground: string;
45
+ /** Title text on `featureBackground`. */
46
+ featureTitle: string;
47
+ /** Body/subtitle text on `featureBackground`. */
48
+ featureBody: string;
49
+ /** Accent that pops on `featureBackground`. */
50
+ featureAccent: string;
51
+ }
52
+ /** Typographic size scale in px (canvas units), largest → smallest. */
53
+ export interface PptistStyleScale {
54
+ /** Hero/cover title. */
55
+ display: number;
56
+ /** Standard slide title. */
57
+ title: number;
58
+ /** Section header / column heading. */
59
+ sectionHeader: number;
60
+ /** Body copy and bullets. */
61
+ body: number;
62
+ /** Eyebrow labels, kickers, tags. */
63
+ label: number;
64
+ /** Captions, footnotes, source lines. */
65
+ caption: number;
66
+ }
67
+ export interface PptistStyleFonts {
68
+ /** Heading/display font family. */
69
+ heading: string;
70
+ /** Body/paragraph font family. */
71
+ body: string;
72
+ }
73
+ export interface PptistStylePreset {
74
+ id: string;
75
+ /** Human label shown in the catalog. */
76
+ label: string;
77
+ /** One-line description of the look & best use. */
78
+ description: string;
79
+ fonts: PptistStyleFonts;
80
+ palette: PptistStylePalette;
81
+ scale: PptistStyleScale;
82
+ /** Ordered chart series colors derived from the palette. */
83
+ chartColors: string[];
84
+ }
85
+ /** Compact catalog entry (what `styles.catalog` returns to the agent). */
86
+ export interface PptistStyleSummary {
87
+ id: string;
88
+ label: string;
89
+ description: string;
90
+ fonts: PptistStyleFonts;
91
+ /** A few representative colors so the agent can picture the look. */
92
+ preview: {
93
+ background: string;
94
+ title: string;
95
+ body: string;
96
+ accent: string;
97
+ featureBackground: string;
98
+ };
99
+ }
100
+ export declare const DEFAULT_STYLE_ID = "academic";
101
+ export declare const PPTX_STYLE_PRESETS: PptistStylePreset[];
102
+ export declare function getStylePreset(id?: string | null): PptistStylePreset | undefined;
103
+ /** Resolve a usable preset, falling back to the default when id is missing/unknown. */
104
+ export declare function resolveStylePreset(id?: string | null): PptistStylePreset;
105
+ export declare function listStylePresets(): PptistStyleSummary[];
106
+ /**
107
+ * Build the deck-theme patch for a preset. Sets the inheritable defaults that
108
+ * manually-created elements pick up (`fontColor`, `fontName`, `backgroundColor`,
109
+ * `themeColors`) and records `styleId` so layouts can resolve the full preset.
110
+ */
111
+ export declare function styleThemePatch(preset: PptistStylePreset): Partial<SlideTheme>;
@@ -2,8 +2,12 @@ import type { Locales } from '../../i18n/locale';
2
2
  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
+ import type { PptistStyleSummary } from './styles';
6
+ import type { PptistLayout, PptistLayoutBackgroundMode } from './layouts';
5
7
  import type { PptistAgenticDocs, PptistCommandDescription, PptistDesignGuide, PptistDomainSummary } from './manifestDocs';
6
8
  export type { PptistAgenticDocs, PptistCommandDescription, PptistCommandDoc, PptistDesignGuide, PptistDesignSystem, PptistDocParam, PptistDomainDoc, PptistDomainSummary, } from './manifestDocs';
9
+ export type { PptistStylePreset, PptistStylePalette, PptistStyleScale, PptistStyleFonts, PptistStyleSummary, } from './styles';
10
+ export type { PptistLayout, PptistLayoutSlotDef, PptistLayoutBackgroundMode, } from './layouts';
7
11
  export type PptistKnownCommandType = keyof PptistCommandPayloadMap;
8
12
  export type PptistCommandType = PptistKnownCommandType | (string & {});
9
13
  export interface PptistDeckViewport {
@@ -420,6 +424,46 @@ export interface PptistElementFlipInput {
420
424
  flipH?: boolean;
421
425
  flipV?: boolean;
422
426
  }
427
+ export interface PptistApplyStyleOptions {
428
+ /** Restyle existing slide content (fonts/colors) to match the preset too. */
429
+ applyToSlides?: boolean;
430
+ }
431
+ export interface PptistApplyStyleResult {
432
+ styleId: string;
433
+ theme: SlideTheme;
434
+ }
435
+ export interface PptistCreateFromLayoutInput {
436
+ /** Layout id from `layouts.catalog` (e.g. `bullets`, `twoColumn`, `chart`). */
437
+ layout: string;
438
+ /** Content slots for the layout. Shapes vary per layout (see its `slots`). */
439
+ slots?: Record<string, unknown>;
440
+ /** Style preset id to use; defaults to the deck's active style. */
441
+ style?: string;
442
+ /** Insertion index (defaults to the end). */
443
+ index?: number;
444
+ /** Select the new slide after creating it (default true). */
445
+ select?: boolean;
446
+ /** Background override: `auto` (layout default), `feature` (dark), `plain`. */
447
+ background?: PptistLayoutBackgroundMode;
448
+ }
449
+ export interface PptistCreateFromLayoutResult {
450
+ slideId: string;
451
+ elementIds: string[];
452
+ layout: string;
453
+ styleId: string;
454
+ }
455
+ export interface PptistAgentStylesApi {
456
+ /** List the style presets (id, label, fonts, preview colors). */
457
+ catalog(): PptistStyleSummary[];
458
+ /** Apply a preset to the deck theme (and optionally restyle existing slides). */
459
+ apply(style: string, options?: PptistApplyStyleOptions, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistApplyStyleResult>>;
460
+ }
461
+ export interface PptistAgentLayoutsApi {
462
+ /** List the compositional layouts with their content slots. */
463
+ catalog(): PptistLayout[];
464
+ /** Create a new themed slide from a layout id + slots. */
465
+ createSlide(input: PptistCreateFromLayoutInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistCreateFromLayoutResult>>;
466
+ }
423
467
  export interface PptistAgentDeckApi {
424
468
  get(): PptistDeckDocument;
425
469
  set(document: PptistDeckInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistDeckDocument>>;
@@ -429,6 +473,7 @@ export interface PptistAgentDeckApi {
429
473
  }>>;
430
474
  getTheme(): SlideTheme;
431
475
  setTheme(theme: PptistSlideThemePatch, meta?: PptistCommandMeta): Promise<PptistCommandResult<SlideTheme>>;
476
+ applyStyle(style: string, options?: PptistApplyStyleOptions, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistApplyStyleResult>>;
432
477
  applyTheme(theme: PptistSlideThemePatch, options?: PptistApplyThemeOptions, meta?: PptistCommandMeta): Promise<PptistCommandResult<SlideTheme>>;
433
478
  extractTheme(options?: PptistThemeExtractionOptions): SlideTheme;
434
479
  setViewport(viewport: {
@@ -443,6 +488,7 @@ export interface PptistAgentSlidesApi {
443
488
  current(): Slide | null;
444
489
  read(slideIdOrIndex?: PptistSlideReference, meta?: PptistCommandMeta): Promise<PptistCommandResult<Slide | null>>;
445
490
  create(input?: PptistCreateSlideInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<Slide>>;
491
+ createFromLayout(input: PptistCreateFromLayoutInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistCreateFromLayoutResult>>;
446
492
  insert(input: PptistInsertSlidesInput, meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistInsertSlidesResult>>;
447
493
  update(slideId: string, patch: Partial<Slide>, meta?: PptistCommandMeta): Promise<PptistCommandResult<Slide>>;
448
494
  delete(slideId: string | string[], meta?: PptistCommandMeta): Promise<PptistCommandResult<PptistDeleteSlidesResult>>;
@@ -982,6 +1028,8 @@ export interface PptistAgentApi {
982
1028
  guides(guideId?: string): PptistDesignGuide[] | PptistDesignGuide | null;
983
1029
  deck: PptistAgentDeckApi;
984
1030
  slides: PptistAgentSlidesApi;
1031
+ styles: PptistAgentStylesApi;
1032
+ layouts: PptistAgentLayoutsApi;
985
1033
  elements: PptistAgentElementsApi;
986
1034
  text: PptistAgentTextApi;
987
1035
  shapes: PptistAgentShapesApi;
@@ -1019,6 +1067,10 @@ export interface PptistCommandPayloadMap {
1019
1067
  theme: PptistSlideThemePatch | Partial<SlideTheme>;
1020
1068
  options?: PptistApplyThemeOptions;
1021
1069
  };
1070
+ 'deck.applyStyle': {
1071
+ style: string;
1072
+ applyToSlides?: boolean;
1073
+ };
1022
1074
  'deck.extractTheme': {
1023
1075
  options?: PptistThemeExtractionOptions;
1024
1076
  } | undefined;
@@ -1029,6 +1081,8 @@ export interface PptistCommandPayloadMap {
1029
1081
  'deck.setTemplates': {
1030
1082
  templates: SlideTemplate[];
1031
1083
  };
1084
+ 'styles.catalog': undefined;
1085
+ 'layouts.catalog': undefined;
1032
1086
  'import.json': PptistDocumentImportPayload;
1033
1087
  'import.pptist': PptistDocumentImportPayload;
1034
1088
  'import.pptxSafe': PptistDocumentImportPayload;
@@ -1043,6 +1097,7 @@ export interface PptistCommandPayloadMap {
1043
1097
  slideIdOrIndex?: PptistSlideReference;
1044
1098
  } | undefined;
1045
1099
  'slides.create': PptistCreateSlideInput | undefined;
1100
+ 'slides.createFromLayout': PptistCreateFromLayoutInput;
1046
1101
  'slides.insert': PptistInsertSlidesInput;
1047
1102
  'slides.update': {
1048
1103
  slideId: string;
@@ -1643,9 +1698,12 @@ export interface PptistCommandResultDataMap {
1643
1698
  'deck.getTheme': SlideTheme;
1644
1699
  'deck.setTheme': SlideTheme;
1645
1700
  'deck.applyTheme': SlideTheme;
1701
+ 'deck.applyStyle': PptistApplyStyleResult;
1646
1702
  'deck.extractTheme': SlideTheme;
1647
1703
  'deck.setViewport': PptistBridgeState;
1648
1704
  'deck.setTemplates': SlideTemplate[];
1705
+ 'styles.catalog': PptistStyleSummary[];
1706
+ 'layouts.catalog': PptistLayout[];
1649
1707
  'import.json': PptistDeckDocument;
1650
1708
  'import.pptist': PptistDeckDocument;
1651
1709
  'import.pptxSafe': PptistDeckDocument;
@@ -1655,6 +1713,7 @@ export interface PptistCommandResultDataMap {
1655
1713
  'slides.current': Slide | null;
1656
1714
  'slides.read': Slide | null;
1657
1715
  'slides.create': Slide;
1716
+ 'slides.createFromLayout': PptistCreateFromLayoutResult;
1658
1717
  'slides.insert': PptistInsertSlidesResult;
1659
1718
  'slides.update': Slide;
1660
1719
  'slides.delete': PptistDeleteSlidesResult;
@@ -2976,7 +2976,7 @@ export type NamespaceEditorTranslation = {
2976
2976
  */
2977
2977
  exportFiles: string;
2978
2978
  /**
2979
- * R​e​s​e​t​ sl​i​de​s
2979
+ * N​e​w​ ​p​r​e​s​e​n​t​at​i​on
2980
2980
  */
2981
2981
  resetSlides: string;
2982
2982
  /**
@@ -7518,7 +7518,7 @@ export type TranslationFunctions = {
7518
7518
  */
7519
7519
  exportFiles: () => LocalizedString;
7520
7520
  /**
7521
- * Reset slides
7521
+ * New presentation
7522
7522
  */
7523
7523
  resetSlides: () => LocalizedString;
7524
7524
  /**
@@ -41,6 +41,7 @@ export declare const useSlidesStore: import("pinia").StoreDefinition<"slides", S
41
41
  blur: number;
42
42
  color: string;
43
43
  };
44
+ styleId?: string | undefined;
44
45
  };
45
46
  slides: {
46
47
  id: string;
@@ -797,6 +798,7 @@ export declare const useSlidesStore: import("pinia").StoreDefinition<"slides", S
797
798
  blur: number;
798
799
  color: string;
799
800
  };
801
+ styleId?: string | undefined;
800
802
  };
801
803
  slides: {
802
804
  id: string;
@@ -1197,6 +1199,7 @@ export declare const useSlidesStore: import("pinia").StoreDefinition<"slides", S
1197
1199
  blur: number;
1198
1200
  color: string;
1199
1201
  };
1202
+ styleId?: string | undefined;
1200
1203
  };
1201
1204
  slides: {
1202
1205
  id: string;
@@ -738,6 +738,13 @@ export interface SlideTheme {
738
738
  fontName: string;
739
739
  outline: PPTElementOutline;
740
740
  shadow: PPTElementShadow;
741
+ /**
742
+ * Id of the agentic style preset last applied via `deck.applyStyle`. Additive
743
+ * and optional: it lets `slides.createFromLayout` inherit the active preset's
744
+ * role tokens (colors, fonts, type scale) without re-specifying them. It is a
745
+ * plain string so it survives theme merges and document (de)serialization.
746
+ */
747
+ styleId?: string;
741
748
  }
742
749
  export interface SlideTemplate {
743
750
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/pptist",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
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",