@unlayer/types 1.516.0 → 1.520.0
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.
- package/dist/editor/editor.d.ts +133 -0
- package/dist/editor/export.d.ts +6 -0
- package/dist/editor/features.d.ts +1 -1
- package/package.json +1 -1
package/dist/editor/editor.d.ts
CHANGED
|
@@ -326,8 +326,116 @@ interface Config {
|
|
|
326
326
|
defaultErrors: Audit[];
|
|
327
327
|
}) => Audit[] | Promise<Audit[]>;
|
|
328
328
|
tabs?: Tabs;
|
|
329
|
+
/**
|
|
330
|
+
* Lets AI agents operating the page (browser agents, automation scripts)
|
|
331
|
+
* find this editor through `unlayer.agent` and edit its design JSON instead
|
|
332
|
+
* of driving the drag-and-drop UI. Once the editor confirms it supports
|
|
333
|
+
* this (older pinned or stable versions don't), appends a short pointer to
|
|
334
|
+
* the editor iframe's accessible name; nothing changes on screen. Set to
|
|
335
|
+
* `false` to leave this editor out of `unlayer.agent`. Defaults to `true`.
|
|
336
|
+
*/
|
|
337
|
+
agentApi?: boolean;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface AgentTarget {
|
|
341
|
+
/** Index into `describe().editors`. Defaults to the first editor. */
|
|
342
|
+
editor?: number;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface AgentDesignIssue {
|
|
346
|
+
path: string;
|
|
347
|
+
message: string;
|
|
348
|
+
code: string;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface AgentLoadDesignResult {
|
|
352
|
+
/** True when the design passed validation and was loaded. */
|
|
353
|
+
ok: boolean;
|
|
354
|
+
loaded: boolean;
|
|
355
|
+
errors: AgentDesignIssue[];
|
|
356
|
+
errorCount: number;
|
|
357
|
+
/**
|
|
358
|
+
* Ids of elements the template protects (locked, or not editable,
|
|
359
|
+
* deletable, or movable) that the design tried to change. They keep their
|
|
360
|
+
* current content; everything else was applied.
|
|
361
|
+
*/
|
|
362
|
+
protectedElements?: string[];
|
|
363
|
+
/** The editor's quality checks on the loaded design; null if they couldn't run. */
|
|
364
|
+
audit?: {
|
|
365
|
+
status: 'PASS' | 'FAIL';
|
|
366
|
+
issues: Array<{
|
|
367
|
+
severity: 'ERROR' | 'WARNING';
|
|
368
|
+
title: string;
|
|
369
|
+
description: string;
|
|
370
|
+
elementId?: string;
|
|
371
|
+
}>;
|
|
372
|
+
issueCount: number;
|
|
373
|
+
} | null;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface AgentEditorSummary {
|
|
377
|
+
index: number;
|
|
378
|
+
containerId: string | null;
|
|
379
|
+
version: string | undefined;
|
|
329
380
|
}
|
|
330
381
|
|
|
382
|
+
export interface AgentDescription {
|
|
383
|
+
/** Markdown instructions for the agent. Read this first. */
|
|
384
|
+
guide: string;
|
|
385
|
+
editors: AgentEditorSummary[];
|
|
386
|
+
editor: number;
|
|
387
|
+
displayMode: string;
|
|
388
|
+
designMode: string | null;
|
|
389
|
+
schemaVersion: number;
|
|
390
|
+
contentTypes: string[];
|
|
391
|
+
customTools: Array<Record<string, unknown> & {
|
|
392
|
+
slug: string;
|
|
393
|
+
}>;
|
|
394
|
+
/** Merge tags to personalize text with, written exactly as `value`. */
|
|
395
|
+
mergeTags: Array<{
|
|
396
|
+
name: string;
|
|
397
|
+
value: string;
|
|
398
|
+
}>;
|
|
399
|
+
fonts: Array<{
|
|
400
|
+
label: string;
|
|
401
|
+
value: string;
|
|
402
|
+
}>;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* `unlayer.agent`: a promise-based surface for AI agents operating the page.
|
|
406
|
+
*
|
|
407
|
+
* Agents fail at the drag-and-drop UI but write good design JSON once they
|
|
408
|
+
* know `loadDesign` exists. This gives them one discoverable entry point,
|
|
409
|
+
* `describe()`, that returns instructions plus this editor's real
|
|
410
|
+
* capabilities (content types, custom tools, fonts), and a `loadDesign` that
|
|
411
|
+
* reports schema errors instead of silently loading a broken design.
|
|
412
|
+
*/
|
|
413
|
+
|
|
414
|
+
export interface AgentApi {
|
|
415
|
+
/** Instructions and this editor's capabilities. Call this first. */
|
|
416
|
+
describe(target?: AgentTarget): Promise<AgentDescription>;
|
|
417
|
+
/** Full JSON Schema of the design this editor accepts, custom tools included. */
|
|
418
|
+
schema(target?: AgentTarget): Promise<Record<string, unknown>>;
|
|
419
|
+
getDesign(target?: AgentTarget): Promise<JSONTemplate>;
|
|
420
|
+
/**
|
|
421
|
+
* Validates, then loads. On `{ ok: false, loaded: false }` nothing changed;
|
|
422
|
+
* fix `errors` and retry.
|
|
423
|
+
*/
|
|
424
|
+
loadDesign(design: JSONTemplate, options?: AgentTarget): Promise<AgentLoadDesignResult>;
|
|
425
|
+
exportHtml(options?: AgentTarget & ExportHtmlOptions): Promise<ExportHtmlResult>;
|
|
426
|
+
/**
|
|
427
|
+
* Opens the editor's preview at a device size, so the agent can check its
|
|
428
|
+
* work in a screenshot; `null` closes it and puts the canvas back on the
|
|
429
|
+
* device it was on. Resolves once the change has rendered.
|
|
430
|
+
*/
|
|
431
|
+
preview(device: AgentPreviewDevice | null, target?: AgentTarget): Promise<void>;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export type AgentPreviewDevice =
|
|
435
|
+
| 'desktop'
|
|
436
|
+
| 'tablet'
|
|
437
|
+
| 'mobile';
|
|
438
|
+
|
|
331
439
|
type Message = Record<string, any>;
|
|
332
440
|
|
|
333
441
|
interface MessageData {
|
|
@@ -357,6 +465,12 @@ export interface FrameOptions {
|
|
|
357
465
|
*/
|
|
358
466
|
iframeTextColor?: string;
|
|
359
467
|
}
|
|
468
|
+
/** What this frame's editor build says it supports. */
|
|
469
|
+
|
|
470
|
+
export interface FrameCapabilities {
|
|
471
|
+
/** Answers `agent:*` messages (`unlayer.agent`). */
|
|
472
|
+
agentApi: boolean;
|
|
473
|
+
}
|
|
360
474
|
|
|
361
475
|
declare class Frame {
|
|
362
476
|
id: number;
|
|
@@ -367,9 +481,19 @@ declare class Frame {
|
|
|
367
481
|
callbacks: {
|
|
368
482
|
[key: number]: ((...args: any[]) => any) | undefined;
|
|
369
483
|
};
|
|
484
|
+
/** Null until the editor announces itself (or the iframe finishes loading). */
|
|
485
|
+
capabilities: FrameCapabilities | null;
|
|
486
|
+
private capabilityListeners;
|
|
370
487
|
constructor(src: string, options?: FrameOptions);
|
|
371
488
|
createIframe(src: string, { iframeBackgroundColor, iframeTextColor }?: FrameOptions): HTMLIFrameElement;
|
|
372
489
|
destroy: () => void;
|
|
490
|
+
/**
|
|
491
|
+
* Calls `listener` with the editor's capabilities once they are known, and
|
|
492
|
+
* again if they improve: an `unlayer:ready` that arrives after the load
|
|
493
|
+
* fallback still turns a capability on. Capabilities never turn off.
|
|
494
|
+
*/
|
|
495
|
+
onCapabilities(listener: (capabilities: FrameCapabilities) => void): void;
|
|
496
|
+
private setCapabilities;
|
|
373
497
|
appendTo(el: Element): void;
|
|
374
498
|
onWindowMessage: (event: MessageEvent<any>) => void;
|
|
375
499
|
postMessage(action: string, message: Message): void;
|
|
@@ -386,6 +510,9 @@ declare class EditorClass<TClassDisplayMode extends DisplayMode | undefined = un
|
|
|
386
510
|
frame: Frame | null;
|
|
387
511
|
constructor(config?: Config);
|
|
388
512
|
init(config?: Config): void;
|
|
513
|
+
/** Container element id, so agents can tell several editors apart. */
|
|
514
|
+
get agentContainerId(): string | null;
|
|
515
|
+
private initAgentApi;
|
|
389
516
|
private captureTargetElement;
|
|
390
517
|
destroy(): void;
|
|
391
518
|
versions: {
|
|
@@ -513,6 +640,12 @@ declare class EditorClass<TClassDisplayMode extends DisplayMode | undefined = un
|
|
|
513
640
|
}
|
|
514
641
|
|
|
515
642
|
declare class Embed extends EditorClass {
|
|
643
|
+
/**
|
|
644
|
+
* Entry point for AI agents operating the page: start with
|
|
645
|
+
* `await unlayer.agent.describe()`. Covers every editor on the page,
|
|
646
|
+
* including `createEditor()` instances.
|
|
647
|
+
*/
|
|
648
|
+
agent: AgentApi;
|
|
516
649
|
createEditor<TDisplayMode extends DisplayMode | undefined = undefined>(config: Config): EditorClass<TDisplayMode>;
|
|
517
650
|
}
|
|
518
651
|
|
package/dist/editor/export.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface ExportHtmlOptions {
|
|
|
19
19
|
live?: boolean;
|
|
20
20
|
mergeTags?: MergeTagsValues;
|
|
21
21
|
minify?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Include classic Outlook for Windows and legacy IE conditional markup in
|
|
24
|
+
* email HTML. Defaults to true. False also removes custom HTML conditionals;
|
|
25
|
+
* AMP HTML and other display modes are unchanged.
|
|
26
|
+
*/
|
|
27
|
+
outlookSupport?: boolean;
|
|
22
28
|
popupId?: string;
|
|
23
29
|
title?: string;
|
|
24
30
|
validateAmp?: boolean;
|
|
@@ -224,7 +224,7 @@ export interface Features {
|
|
|
224
224
|
* Preferred AI model for the assistant. Accepts:
|
|
225
225
|
*
|
|
226
226
|
* - a `"<provider>/<modelId>"` pair (e.g. `"openai/gpt-5.6-luna"`,
|
|
227
|
-
* `"anthropic/claude-opus-5"`) — pins both provider and model,
|
|
227
|
+
* `"anthropic/claude-opus-5-5"`) — pins both provider and model,
|
|
228
228
|
* unambiguous;
|
|
229
229
|
* - a bare model id (e.g. `"gpt-5.6-luna"`);
|
|
230
230
|
* - a provider name (e.g. `"openai"`, `"anthropic"`) — selects the
|