fika-editor 3.6.10 → 3.6.12

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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Proofing language of the text in PPTX downloads.
3
+ *
4
+ * PowerPoint checks spelling, hyphenates and applies AutoCorrect per text run
5
+ * by its `lang` attribute. Without one every run is US English, so a Czech
6
+ * deck opens with every word underlined as a typo. The host names the deck's
7
+ * language (BCP-47, e.g. `cs` or `sk-SK`); runs that already carry a
8
+ * language keep it.
9
+ */
10
+ /** Region-qualified tag PowerPoint recognises (`cs` → `cs-CZ`), or null for an invalid tag. */
11
+ export declare function pptxLanguageTag(tag?: string | null): string | null;
12
+ export declare function setFikaExportLanguage(tag?: string | null): void;
13
+ export declare function getFikaExportLanguage(): string | null;
@@ -1,10 +1,11 @@
1
1
  import { type TemplatePayload, type TemplatePayloadLoader } from '../../configs/templates';
2
- import type { Slide, SlideTheme, SlideType } from '../../types/slides';
3
- export interface FikaTemplateSummary {
4
- id: string;
5
- name: string;
6
- cover: string;
7
- origin?: string;
2
+ import type { Slide, SlideTheme, SlideTemplate, SlideType } from '../../types/slides';
3
+ export type FikaTemplateSummary = SlideTemplate;
4
+ export interface FikaTemplateCatalogQuery {
5
+ /** Match one declared category. Category and tag comparisons trim whitespace and ignore case. */
6
+ category?: string;
7
+ /** Match every nonblank tag in addition to the category, when supplied. */
8
+ tags?: readonly string[];
8
9
  }
9
10
  export interface FikaTemplateSlideEntry {
10
11
  /** Stable slug within this template, e.g. `cover_1`, `content_2`. */
@@ -21,7 +22,7 @@ export interface FikaTemplateSlidesCatalogResult {
21
22
  byType: FikaTemplateSlidesCatalog;
22
23
  }
23
24
  export declare function registerTemplateLoaders(loaders?: Record<string, TemplatePayloadLoader>): void;
24
- export declare function listTemplateCatalog(): FikaTemplateSummary[];
25
+ export declare function listTemplateCatalog(query?: FikaTemplateCatalogQuery): FikaTemplateSummary[];
25
26
  export declare function loadTemplatePayload(templateId: string): Promise<TemplatePayload>;
26
27
  export declare function buildTemplateSlidesCatalog(templateId: string): Promise<FikaTemplateSlidesCatalogResult>;
27
28
  export declare function resolveTemplateSlide(payload: TemplatePayload, slug: string): {
@@ -2,7 +2,7 @@ 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 { FikaDocument } from '../types';
5
- import type { FikaTemplateSlidesCatalogResult, FikaTemplateSummary } from './templates';
5
+ import type { FikaTemplateCatalogQuery, FikaTemplateSlidesCatalogResult, FikaTemplateSummary } from './templates';
6
6
  import type { FikaLayout, FikaLayoutBackgroundMode } from './layouts';
7
7
  import type { FikaStyleMotif, FikaStyleSummary } from './styles';
8
8
  import type { CompositionAnchor, CompositionPlan, CompositionSlideHint } from './composition';
@@ -10,7 +10,7 @@ import type { FikaAgenticDocs, FikaCommandDescription, FikaDesignGuide, FikaDoma
10
10
  import type { TextRunStyle } from '../../utils/markdown';
11
11
  export type { TextRunStyle } from '../../utils/markdown';
12
12
  export type { FikaAgenticDocs, FikaCommandDescription, FikaCommandDoc, FikaDesignGuide, FikaDesignSystem, FikaDocParam, FikaDomainDoc, FikaDomainSummary } from './manifestDocs';
13
- export type { FikaTemplateSummary, FikaTemplateSlideEntry, FikaTemplateSlidesCatalog, FikaTemplateSlidesCatalogResult } from './templates';
13
+ export type { FikaTemplateCatalogQuery, FikaTemplateSummary, FikaTemplateSlideEntry, FikaTemplateSlidesCatalog, FikaTemplateSlidesCatalogResult } from './templates';
14
14
  export type { FikaLayout, FikaLayoutSlotDef, FikaLayoutBackgroundMode, FikaLayoutVariant } from './layouts';
15
15
  export type { FikaStyleSummary, FikaStylePreset, FikaStylePalette, FikaStyleScale, FikaStyleFonts, FikaStyleMotif } from './styles';
16
16
  export type { CompositionAnchor, CompositionDensity, CompositionPlan, CompositionPlanEntry, CompositionSlideHint } from './composition';
@@ -489,8 +489,8 @@ export interface FikaInsertFromTemplateResult {
489
489
  placeholderElementIds: string[];
490
490
  }
491
491
  export interface FikaAgentTemplatesApi {
492
- /** List host-registered presentation templates shown in the template picker. */
493
- catalog(): FikaTemplateSummary[];
492
+ /** Discover registered templates by category and tags without loading any slides. */
493
+ catalog(query?: FikaTemplateCatalogQuery): FikaTemplateSummary[];
494
494
  /** List insertable slides for a template, grouped by type (cover, contents, …). */
495
495
  slidesCatalog(templateId: string, meta?: FikaCommandMeta): Promise<FikaCommandResult<FikaTemplateSlidesCatalogResult>>;
496
496
  }
@@ -1379,7 +1379,7 @@ export interface FikaCommandPayloadMap {
1379
1379
  'deck.setTemplates': {
1380
1380
  templates: SlideTemplate[];
1381
1381
  };
1382
- 'templates.catalog': undefined;
1382
+ 'templates.catalog': FikaTemplateCatalogQuery | undefined;
1383
1383
  'templates.slidesCatalog': {
1384
1384
  templateId: string;
1385
1385
  };
@@ -7,7 +7,7 @@ export interface FikaExportProgress {
7
7
  /** Normalized 0..1; reaches 1 only when downloadable bytes are ready. */
8
8
  progress: number;
9
9
  }
10
- export interface FikaExportOptions extends Pick<PresentationExportOptions, 'mediaResolver' | 'watermark' | 'metadata'> {
10
+ export interface FikaExportOptions extends Pick<PresentationExportOptions, 'mediaResolver' | 'watermark' | 'metadata' | 'language'> {
11
11
  /** Runtime assets/chunks when exporting before mounting an editor. */
12
12
  assetBaseUrl?: string;
13
13
  /** PDF raster width in pixels. Default 2560, maximum 8192. */
@@ -83,11 +83,11 @@ export interface FikaMountOptions {
83
83
  /** Base URL for runtime image/font assets and fallback mock decks. */
84
84
  assetBaseUrl?: string;
85
85
  /**
86
- * Host-supplied template catalog shown in the design picker.
87
- * Payload JSON is resolved with `templateLoaders` keyed by `templates[].id`.
86
+ * Host-supplied picker entries. Optional discovery fields are available to
87
+ * `controller.templates.catalog()` for entries with a matching loader.
88
88
  */
89
89
  templates?: SlideTemplate[];
90
- /** Optional custom template payload loaders keyed by `templates[].id`. */
90
+ /** Lazy payload loaders keyed by template id. Loader-only ids also appear in the agent catalog. */
91
91
  templateLoaders?: Record<string, FikaTemplateLoader>;
92
92
  /** Fired when title, slides, or theme change (debounced). */
93
93
  onChange?: (document: FikaDocument) => void;
@@ -121,6 +121,13 @@ export interface FikaMountOptions {
121
121
  * resolver fails the export.
122
122
  */
123
123
  exportMetadata?: FikaExportMetadataResolver;
124
+ /**
125
+ * Language of the deck's text (BCP-47, e.g. `cs` or `sk-SK`) written to
126
+ * every PPTX text run, so PowerPoint checks spelling in that language
127
+ * instead of US English. Applies to the editor export dialog and to
128
+ * `exportPresentationPptx` without an explicit `language` option.
129
+ */
130
+ exportLanguage?: string;
124
131
  /**
125
132
  * Local media picker used by the unified Insert → Media action (images,
126
133
  * video, and audio). Pass `upload` to send files to your backend instead of
@@ -19,6 +19,8 @@ export interface PresentationExportOptions {
19
19
  watermark?: FikaExportWatermarkResolver | null;
20
20
  /** Document metadata for the written file; `undefined` falls back to the mounted `exportMetadata`. */
21
21
  metadata?: FikaExportMetadataResolver | null;
22
+ /** Proofing language of the deck's text (BCP-47); `undefined` falls back to the mounted `exportLanguage`. */
23
+ language?: string | null;
22
24
  }
23
25
  export declare function createPresentationExporter({ slides, theme, viewportRatio, title, viewportSize, viewportWidthInches }: PresentationExportState, options?: PresentationExportOptions, job?: import("../utils/jobProgress").JobProgress): {
24
26
  exporting: boolean;
@@ -948,6 +948,11 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
948
948
  id: string;
949
949
  cover: string;
950
950
  origin?: string;
951
+ description?: string;
952
+ categories?: string[];
953
+ tags?: string[];
954
+ useWhen?: string;
955
+ avoidWhen?: string;
951
956
  }[];
952
957
  importedTemplates: {
953
958
  name: string;
@@ -2705,6 +2710,11 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
2705
2710
  id: string;
2706
2711
  cover: string;
2707
2712
  origin?: string;
2713
+ description?: string;
2714
+ categories?: string[];
2715
+ tags?: string[];
2716
+ useWhen?: string;
2717
+ avoidWhen?: string;
2708
2718
  }[];
2709
2719
  importedTemplates: {
2710
2720
  name: string;
@@ -655,6 +655,16 @@ export interface SlideTemplate {
655
655
  id: string;
656
656
  cover: string;
657
657
  origin?: string;
658
+ /** The presentation's purpose and intended audience, in the host's locale. */
659
+ description?: string;
660
+ /** Presentation classes such as report, proposal, portfolio, or lesson. */
661
+ categories?: string[];
662
+ /** Specific tasks, audiences, and visual structures supported by this template. */
663
+ tags?: string[];
664
+ /** Guidance for an author deciding whether to select this template. */
665
+ useWhen?: string;
666
+ /** Conditions under which another presentation structure is a better fit. */
667
+ avoidWhen?: string;
658
668
  }
659
669
  /** Theme pack imported from a local .json / .fika file */
660
670
  export interface ImportedSlideTemplate {
@@ -0,0 +1,6 @@
1
+ import type { PptxExportCommand } from './pptxExportCommands';
2
+ /**
3
+ * Give every recorded text run, table cell and chart the deck's proofing
4
+ * language. Runs with their own language (a quotation, a foreign word) keep it.
5
+ */
6
+ export declare function applyPptxLanguage(commands: PptxExportCommand[], lang: string | null | undefined): void;
@@ -33,6 +33,7 @@ controller.describe(commandType)
33
33
  controller.guides(guideId?)
34
34
 
35
35
  controller.deck.*
36
+ controller.templates.*
36
37
  controller.slides.*
37
38
  controller.elements.*
38
39
  controller.element.*
@@ -52,6 +53,30 @@ controller.export.*
52
53
 
53
54
  Use domain wrappers for common flows. Use `execute()` for command-only operations that are registered but do not yet have a wrapper method.
54
55
 
56
+ ## Template discovery
57
+
58
+ `controller.templates.catalog()` synchronously returns all registered template
59
+ summaries. Pass the same optional query as a command payload to get the list in
60
+ `result.data` on success.
61
+
62
+ ```ts
63
+ const query = { category: 'Report', tags: ['quarterly', 'finance'] }
64
+ const matches = controller.templates.catalog(query)
65
+ const result = await controller.execute({ type: 'templates.catalog', payload: query })
66
+ if (matches.length) {
67
+ const slides = await controller.templates.slidesCatalog(matches[0].id)
68
+ if (slides.ok) console.log(slides.data?.byType.cover)
69
+ }
70
+ ```
71
+
72
+ A template must declare the requested category and every requested tag.
73
+ Comparisons match whole values after trimming and ignoring case. Blank criteria
74
+ are ignored. Each summary includes `id`, `name` and `cover`, plus any supplied
75
+ `origin`, `description`, `categories`, `tags`, `useWhen` and `avoidWhen`.
76
+ Discovery leaves slide payloads unloaded. To inspect a template's slides and
77
+ their insertion slugs, call `templates.slidesCatalog` with its id. An empty
78
+ unfiltered catalog means the host registered no loaders.
79
+
55
80
  ## API Naming
56
81
 
57
82
  Command names use `domain.action` with lower-camel-case actions:
@@ -60,7 +85,7 @@ Command names use `domain.action` with lower-camel-case actions:
60
85
  type FikaCommandType = `${string}.${string}`
61
86
  ```
62
87
 
63
- Canonical domains are `deck`, `import`, `export`, `slides`, `elements`, `animations`, `tables`, `charts`, `notes`, `sections`, `search`, `history`, and `view`.
88
+ Canonical domains include `deck`, `templates`, `import`, `export`, `slides`, `elements`, `animations`, `tables`, `charts`, `notes`, `sections`, `search`, `history`, and `view`.
64
89
 
65
90
  Naming rules:
66
91
 
package/docs/EMBED.md CHANGED
@@ -521,6 +521,35 @@ through storage, static rendering, and editing.
521
521
  Pass `assetBaseUrl` to `mountFika()` to resolve lazy editor CSS under the same
522
522
  asset directory as the embed stylesheet.
523
523
 
524
+ ### Presentation template catalog
525
+
526
+ Register picker entries in `templates` and lazy loaders in `templateLoaders`.
527
+ Use the same id in both. The agent catalog lists entries with loaders in picker
528
+ order, then any remaining loader ids. A loader can resolve to a slide array or
529
+ to a template payload such as `{ slides, theme }`.
530
+
531
+ ```ts
532
+ import { mountFika, type FikaTemplateLoader } from 'fika-editor/embed'
533
+
534
+ async function mountReviewEditor(host: HTMLElement, loadReview: FikaTemplateLoader) {
535
+ return mountFika(host, {
536
+ templates: [{
537
+ id: 'review', name: 'Quarterly review', cover: '/covers/review.png',
538
+ description: 'A results briefing for the board.',
539
+ categories: ['Report'], tags: ['quarterly', 'finance'],
540
+ useWhen: 'Compare results against targets.',
541
+ avoidWhen: 'Introducing a product for the first time.',
542
+ }],
543
+ templateLoaders: { review: loadReview },
544
+ })
545
+ }
546
+ ```
547
+
548
+ The five discovery fields are optional. Entries with just `id`, `name` and
549
+ `cover` still work, as does optional `origin`. A loader registered on its own
550
+ appears with its id as the name and an empty cover. Both catalog APIs read this
551
+ metadata without invoking loaders. See [template discovery](./AGENTIC_BRIDGE.md#template-discovery).
552
+
524
553
  ### Host-configured slide designs
525
554
 
526
555
  Pass `designThemes` to replace the built-in design cards (not editor chrome).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fika-editor",
3
- "version": "3.6.10",
3
+ "version": "3.6.12",
4
4
  "description": "Fika presentation editor embed bundle with a typed agentic bridge.",
5
5
  "type": "module",
6
6
  "main": "dist/embed/fika-embed.js",