fika-editor 3.4.8 → 3.5.1

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.
@@ -63,6 +63,29 @@ export interface ImageNaturalSize {
63
63
  width: number;
64
64
  height: number;
65
65
  }
66
+ /**
67
+ * Place a bitmap into a layout box WITHOUT distorting it.
68
+ *
69
+ * - `contain` (diagrams, screenshots): shrink the box to the image's aspect
70
+ * and center it inside the original box.
71
+ * - `cover` (photos): keep the box and center-crop the overflowing axis via
72
+ * `clip.range` (percentages of the source image).
73
+ *
74
+ * When the natural size is unknown the box is used as-is; `fixedRatio` then
75
+ * stays `false` because the box aspect is not the image's.
76
+ */
77
+ export declare function imageElement(opts: {
78
+ left: number;
79
+ top: number;
80
+ width: number;
81
+ height: number;
82
+ src: string;
83
+ sourceUrl?: string;
84
+ natural?: ImageNaturalSize;
85
+ fit?: 'cover' | 'contain';
86
+ }): Partial<PPTImageElement> & {
87
+ type: 'image';
88
+ };
66
89
  /**
67
90
  * Best-effort natural size of a bitmap. Browser only; resolves `undefined`
68
91
  * on error or after `timeoutMs` so a slow CDN never blocks slide creation.
@@ -1253,6 +1253,23 @@ export type FikaCanvasOperation = {
1253
1253
  height: number;
1254
1254
  shape: 'rect' | 'ellipse';
1255
1255
  fill?: string;
1256
+ }
1257
+ /** Aspect-preserving placement. Defaults to contain so the entire subject remains visible. */
1258
+ | {
1259
+ op: 'image';
1260
+ pageId?: string;
1261
+ id?: string;
1262
+ x: number;
1263
+ y: number;
1264
+ width: number;
1265
+ height: number;
1266
+ src: string;
1267
+ natural: {
1268
+ width: number;
1269
+ height: number;
1270
+ };
1271
+ fit?: 'contain' | 'cover';
1272
+ sourceUrl?: string;
1256
1273
  } | {
1257
1274
  op: 'element';
1258
1275
  pageId?: string;
@@ -189,6 +189,8 @@ The bridge maintains a monotonic `documentVersion` and a separate `snapshotId`.
189
189
  - Passing `{ atomic: false }` keeps successful child changes, rolls back only the failed command, continues later commands, and returns the mixed success/failure result list for the caller to inspect.
190
190
  - Passing `{ commit: false }` to `executeBatch()` suppresses the final batch snapshot.
191
191
  - Passing `{ dryRun: true }` lets commands validate against the staged batch state, then restores the pre-batch runtime state, returns `changed: false`, and creates no snapshot.
192
+ - Calls to `execute()` and `executeBatch()` share one queue, including reads, so concurrent host calls finish in submission order and a failed async command cannot undo a later edit.
193
+ - Dry runs and failed batches restore the composition plan and layout history as well as document state. Validation does not consume planned layout positions or affect later repeat warnings.
192
194
  - `history.commit`, `history.undo`, and `history.redo` are command-layer operations and return bridge state.
193
195
 
194
196
  Events emitted through `subscribe()` include `documentChanged`, `selectionChanged`, `commandApplied`, `commandFailed`, and `destroyed`. Command events include the command envelope and result when available.
@@ -539,13 +541,19 @@ The default read is 40 elements with 160 text characters each; `offset`, `limit`
539
541
  `canvas.apply` accepts `{ operations: [...] }` (1–100 operations) and returns only
540
542
  operation acknowledgements and IDs. One call is one undoable transaction, and a
541
543
  failure rolls back the entire call. Operations are `title`, `viewport`, `page`,
542
- `pageUpdate`, `text`, `textUpdate`, `shape`, `element`, `update`, and `remove`.
544
+ `pageUpdate`, `text`, `textUpdate`, `shape`, `image`, `element`, `update`, and `remove`.
543
545
  Use explicit IDs to reference newly created pages/elements in the same call.
544
546
  Text is authored as Markdown with fixed-size boxes. `textUpdate` preserves the
545
547
  existing first-run typography unless `style` overrides it. The `element` and
546
548
  `update` operations expose native artwork types and nested-frame properties.
547
549
  Existing bridge commands remain available for specialized editing.
548
550
 
551
+ `image` takes `src`, `x`, `y`, `width`, `height`, and the source image's
552
+ `natural: { width, height }`. It defaults to `fit: "contain"`, centering the
553
+ complete image in the requested box without stretching or cutting off the
554
+ subject. Use `fit: "cover"` for a centered crop that fills the box, and
555
+ `sourceUrl` to keep its citation. Both modes use native editable image elements.
556
+
549
557
  For an initial invitation, batch the title, viewport, page, decorative shapes,
550
558
  and text. For a revision, read only the target page and send targeted operations;
551
559
  do not resend the document or automatically attach a screenshot on every turn.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fika-editor",
3
- "version": "3.4.8",
3
+ "version": "3.5.1",
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",