@unlayer/types 1.397.0 → 1.399.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.
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterName, Variant } from '../editor/types';
4
4
 
5
5
  type BodyValuesBase = {
6
6
  _styleGuide: string;
@@ -147,8 +147,6 @@ export type BodyValues<
147
147
  ? BodyValuesForDocument
148
148
  : never;
149
149
 
150
- import type { Variant } from '../editor/types';
151
-
152
150
  type BodyExporter = (
153
151
  innerHTML: string,
154
152
  bodyValues: Record<string, any>, // @deprecated use last param instead
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterName, Variant } from '../editor/types';
4
4
 
5
5
  type ColumnValuesBase = {
6
6
  border: {
@@ -60,7 +60,6 @@ export type ColumnValues<
60
60
 
61
61
  import type { BodyValues } from '../containers/body';
62
62
  import type { RowValues } from '../containers/row';
63
- import type { Variant } from '../editor/types';
64
63
 
65
64
  type ColumnExporter = (
66
65
  innerHTML: string,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { Device, DisplayMode, ExporterConfig, ExporterName, Variant } from '../editor/types';
4
4
 
5
5
  export type ContentValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -33,7 +33,6 @@ import type { BodyValues } from '../containers/body';
33
33
  import type { ColumnValues } from '../containers/column';
34
34
  import type { RowValues } from '../containers/row';
35
35
  import type { MergeTagsValues } from '../editor/merge-tags';
36
- import type { ExporterConfig, Variant } from '../editor/types';
37
36
 
38
37
  type ContentExporter = (
39
38
  innerHTML: string,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { Collection, Device, DisplayMode, ExporterConfig, ExporterName, Variant } from '../editor/types';
4
4
 
5
5
  type RowValuesBase = {
6
6
  [x: string]: unknown;
@@ -79,7 +79,6 @@ export type RowValues<
79
79
  : never;
80
80
 
81
81
  import type { BodyValues } from '../containers/body';
82
- import type { Collection, ExporterConfig, Variant } from '../editor/types';
83
82
 
84
83
  type RowExporter = (
85
84
  innerHTML: string,
package/dist/design.d.ts CHANGED
@@ -53,9 +53,18 @@ type DesignContentItemOf<
53
53
  values: TValues & ContentValues<TDisplayMode>;
54
54
  };
55
55
 
56
+ type DesignCustomContentItem<
57
+ TDisplayMode extends DisplayMode | undefined = undefined,
58
+ > = {
59
+ id?: string;
60
+ type: 'custom';
61
+ slug: string;
62
+ values: ContentValues<TDisplayMode> & Record<string, unknown>;
63
+ };
64
+
56
65
  export type DesignContentType = keyof ContentToolValuesMap | (string & {});
57
66
 
58
- export type DesignContentItem<
67
+ type DesignBuiltInContentItem<
59
68
  TDisplayMode extends DisplayMode | undefined = undefined,
60
69
  > = {
61
70
  [K in keyof ContentToolValuesMap<TDisplayMode>]: DesignContentItemOf<
@@ -65,6 +74,12 @@ export type DesignContentItem<
65
74
  >;
66
75
  }[keyof ContentToolValuesMap<TDisplayMode>];
67
76
 
77
+ export type DesignContentItem<
78
+ TDisplayMode extends DisplayMode | undefined = undefined,
79
+ > =
80
+ | DesignBuiltInContentItem<TDisplayMode>
81
+ | DesignCustomContentItem<TDisplayMode>;
82
+
68
83
  export type DesignColumn<
69
84
  TDisplayMode extends DisplayMode | undefined = undefined,
70
85
  > = {
@@ -39,3 +39,57 @@ export type User = {
39
39
  email?: string;
40
40
  signature?: string;
41
41
  };
42
+
43
+ type JSONSchema = Record<string, unknown>;
44
+
45
+ type InferSchemaType<S> = S extends { readonly type: 'string' }
46
+ ? string
47
+ : S extends { readonly type: 'number' | 'integer' }
48
+ ? number
49
+ : S extends { readonly type: 'boolean' }
50
+ ? boolean
51
+ : S extends { readonly type: 'array'; readonly items: infer I }
52
+ ? InferSchemaType<I>[]
53
+ : S extends { readonly type: 'array' }
54
+ ? unknown[]
55
+ : S extends {
56
+ readonly type: 'object';
57
+ readonly properties: infer P extends Record<string, unknown>;
58
+ }
59
+ ? { -readonly [K in keyof P]: InferSchemaType<P[K]> }
60
+ : unknown;
61
+ export type { InferSchemaType };
62
+
63
+ export type UpdateValueFn<Value = unknown> = (newValue: Value | undefined, data?: object) => void;
64
+
65
+ export type WidgetMountFn<Value = unknown> = (node: HTMLDivElement | null, value: Value | undefined, updateValue: UpdateValueFn<Value>, data: unknown) => void;
66
+
67
+ export type WidgetRenderFn<Value = unknown> = (value: Value | undefined, updateValue: UpdateValueFn<Value>, data: unknown) => string;
68
+
69
+ export interface WidgetConfig<Value = unknown> {
70
+ mount: WidgetMountFn<Value>;
71
+ render: WidgetRenderFn<Value>;
72
+ /**
73
+ * JSON Schema describing the value shape produced by this widget.
74
+ * Used by the AI Copilot to understand what fields this custom property editor supports.
75
+ *
76
+ * @example
77
+ * ```js
78
+ * unlayer.registerPropertyEditor({
79
+ * name: 'qr_generator',
80
+ * Widget: unlayer.createWidget({
81
+ * schema: {
82
+ * type: 'object',
83
+ * properties: {
84
+ * qrCode: { type: 'string', description: 'Base64-encoded QR image' },
85
+ * srcUrl: { type: 'string', description: 'URL encoded in the QR code' },
86
+ * },
87
+ * },
88
+ * render(value) { ... },
89
+ * mount(node, value, updateValue) { ... },
90
+ * }),
91
+ * });
92
+ * ```
93
+ */
94
+ schema?: JSONSchema | null;
95
+ }
@@ -1,7 +1,7 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
3
  import type { Audit, Validator } from './audit';
4
- import type { EditorSettings, SafeHtmlOptions, Tabs, User } from './config';
4
+ import type { EditorSettings, InferSchemaType, SafeHtmlOptions, Tabs, User, WidgetConfig, WidgetMountFn, WidgetRenderFn } from './config';
5
5
  import type { DesignMode, DesignTags, DesignTagsConfig, JSONTemplate } from './design';
6
6
  import type { DisplayConditions } from './display-conditions';
7
7
  import type { ExportFromApiResult, ExportHtmlOptions, ExportHtmlResult, ExportImageFromApiOptions, ExportLiveHtmlOptions, ExportLiveHtmlResult, ExportPdfFromApiOptions, ExportPlainTextOptions, ExportPlainTextResult, ExportZipFromApiOptions, SaveDesignOptions } from './export';
@@ -16,13 +16,7 @@ import type { CallbackTypeMap, Collection, Device, DisplayMode, ExporterConfig,
16
16
  import type { DeepPartial, LanguagesValue } from './utils';
17
17
  import type { BodyValues } from '../containers/body';
18
18
  import type { ColumnValues } from '../containers/column';
19
-
20
- type RowValues = any;
21
-
22
- /**
23
- * Server-safe configuration for exporters.
24
- * Passed via meta to allow dependency injection instead of importing config directly.
25
- */
19
+ import type { RowValues } from '../containers/row';
26
20
 
27
21
  export type Container = 'body' | 'row' | 'column' | 'content';
28
22
 
@@ -295,7 +289,12 @@ declare class EditorClass<TClassDisplayMode extends DisplayMode | undefined = un
295
289
  registerTab(config: TabConfig): void;
296
290
  createPanel(config: PanelConfig): void;
297
291
  createViewer(config: ViewerConfig): void;
298
- createWidget(config: WidgetConfig): void;
292
+ createWidget<const S extends Record<string, unknown>>(config: {
293
+ schema: S;
294
+ mount: WidgetMountFn<InferSchemaType<S>>;
295
+ render: WidgetRenderFn<InferSchemaType<S>>;
296
+ }): void;
297
+ createWidget<Value = unknown>(config: WidgetConfig<Value>): void;
299
298
  }
300
299
 
301
300
  declare class Embed extends EditorClass {
@@ -359,7 +358,7 @@ export type OptionGroupEmbeddedConfig<Values extends ValueMap = ValueMap> = {
359
358
  export type OptionGroupConfig<Values extends ValueMap = ValueMap> = {
360
359
  rightLabel?: string;
361
360
  title: string | null;
362
- dynamicTitle?: (state: RootState) => string | undefined;
361
+ dynamicTitle?: (state: Record<string, any>) => string | undefined;
363
362
  icon?: string | string[];
364
363
  position?: number;
365
364
  supportedDesignModes?: DesignMode[];
@@ -471,11 +470,6 @@ export interface ViewerConfig {
471
470
  render: ViewerRenderFn;
472
471
  }
473
472
 
474
- export type WidgetMountFn = (node: HTMLDivElement | null, value: unknown, updateValue: unknown, data: unknown) => void;
475
-
476
- export type WidgetRenderFn = (value: unknown, updateValue: unknown, data: unknown) => string;
477
-
478
- export interface WidgetConfig {
479
- mount: WidgetMountFn;
480
- render: WidgetRenderFn;
481
- }
473
+ type WidgetComponentClass = any & {
474
+ schema?: Record<string, unknown> | null;
475
+ };
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type ButtonValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -80,7 +80,6 @@ import type { ColumnValues } from '../containers/column';
80
80
  import type { ContentValues } from '../containers/content';
81
81
  import type { RowValues } from '../containers/row';
82
82
  import type { MergeTagsValues } from '../editor/merge-tags';
83
- import type { ExporterConfig } from '../editor/types';
84
83
 
85
84
  type ButtonExporter = (
86
85
  renderValues: ContentValues & ButtonValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type CarouselValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -22,7 +22,6 @@ import type { ColumnValues } from '../containers/column';
22
22
  import type { ContentValues } from '../containers/content';
23
23
  import type { RowValues } from '../containers/row';
24
24
  import type { MergeTagsValues } from '../editor/merge-tags';
25
- import type { ExporterConfig } from '../editor/types';
26
25
 
27
26
  type CarouselExporter = (
28
27
  renderValues: ContentValues & CarouselValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type DividerValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -24,7 +24,6 @@ import type { ColumnValues } from '../containers/column';
24
24
  import type { ContentValues } from '../containers/content';
25
25
  import type { RowValues } from '../containers/row';
26
26
  import type { MergeTagsValues } from '../editor/merge-tags';
27
- import type { ExporterConfig } from '../editor/types';
28
27
 
29
28
  type DividerExporter = (
30
29
  renderValues: ContentValues & DividerValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type FormValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -128,7 +128,6 @@ import type { ColumnValues } from '../containers/column';
128
128
  import type { ContentValues } from '../containers/content';
129
129
  import type { RowValues } from '../containers/row';
130
130
  import type { MergeTagsValues } from '../editor/merge-tags';
131
- import type { ExporterConfig } from '../editor/types';
132
131
 
133
132
  type FormExporter = (
134
133
  renderValues: ContentValues & FormValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type HeadingValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -49,7 +49,6 @@ import type { ColumnValues } from '../containers/column';
49
49
  import type { ContentValues } from '../containers/content';
50
50
  import type { RowValues } from '../containers/row';
51
51
  import type { MergeTagsValues } from '../editor/merge-tags';
52
- import type { ExporterConfig } from '../editor/types';
53
52
 
54
53
  type HeadingExporter = (
55
54
  renderValues: ContentValues & HeadingValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type HtmlValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -18,7 +18,6 @@ import type { ColumnValues } from '../containers/column';
18
18
  import type { ContentValues } from '../containers/content';
19
19
  import type { RowValues } from '../containers/row';
20
20
  import type { MergeTagsValues } from '../editor/merge-tags';
21
- import type { ExporterConfig } from '../editor/types';
22
21
 
23
22
  type HtmlExporter = (
24
23
  renderValues: ContentValues & HtmlValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type ImageValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -45,7 +45,6 @@ import type { ColumnValues } from '../containers/column';
45
45
  import type { ContentValues } from '../containers/content';
46
46
  import type { RowValues } from '../containers/row';
47
47
  import type { MergeTagsValues } from '../editor/merge-tags';
48
- import type { ExporterConfig } from '../editor/types';
49
48
 
50
49
  type ImageExporter = (
51
50
  renderValues: ContentValues & ImageValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type MenuValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -61,7 +61,6 @@ import type { ColumnValues } from '../containers/column';
61
61
  import type { ContentValues } from '../containers/content';
62
62
  import type { RowValues } from '../containers/row';
63
63
  import type { MergeTagsValues } from '../editor/merge-tags';
64
- import type { ExporterConfig } from '../editor/types';
65
64
 
66
65
  type MenuExporter = (
67
66
  renderValues: ContentValues & MenuValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type PageBreakValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -27,7 +27,6 @@ import type { ColumnValues } from '../containers/column';
27
27
  import type { ContentValues } from '../containers/content';
28
28
  import type { RowValues } from '../containers/row';
29
29
  import type { MergeTagsValues } from '../editor/merge-tags';
30
- import type { ExporterConfig } from '../editor/types';
31
30
 
32
31
  type PageBreakExporter = (
33
32
  renderValues: ContentValues & PageBreakValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type ParagraphValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -46,7 +46,6 @@ import type { ColumnValues } from '../containers/column';
46
46
  import type { ContentValues } from '../containers/content';
47
47
  import type { RowValues } from '../containers/row';
48
48
  import type { MergeTagsValues } from '../editor/merge-tags';
49
- import type { ExporterConfig } from '../editor/types';
50
49
 
51
50
  type ParagraphExporter = (
52
51
  renderValues: ContentValues & ParagraphValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type SocialValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -28,7 +28,6 @@ import type { ColumnValues } from '../containers/column';
28
28
  import type { ContentValues } from '../containers/content';
29
29
  import type { RowValues } from '../containers/row';
30
30
  import type { MergeTagsValues } from '../editor/merge-tags';
31
- import type { ExporterConfig } from '../editor/types';
32
31
 
33
32
  type SocialExporter = (
34
33
  renderValues: ContentValues & SocialValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type TableValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -148,7 +148,6 @@ import type { ColumnValues } from '../containers/column';
148
148
  import type { ContentValues } from '../containers/content';
149
149
  import type { RowValues } from '../containers/row';
150
150
  import type { MergeTagsValues } from '../editor/merge-tags';
151
- import type { ExporterConfig } from '../editor/types';
152
151
 
153
152
  type TableExporter = (
154
153
  renderValues: ContentValues & TableValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type TextValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -46,7 +46,6 @@ import type { ColumnValues } from '../containers/column';
46
46
  import type { ContentValues } from '../containers/content';
47
47
  import type { RowValues } from '../containers/row';
48
48
  import type { MergeTagsValues } from '../editor/merge-tags';
49
- import type { ExporterConfig } from '../editor/types';
50
49
 
51
50
  type TextExporter = (
52
51
  renderValues: ContentValues & TextValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type TimerValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -57,7 +57,6 @@ import type { ColumnValues } from '../containers/column';
57
57
  import type { ContentValues } from '../containers/content';
58
58
  import type { RowValues } from '../containers/row';
59
59
  import type { MergeTagsValues } from '../editor/merge-tags';
60
- import type { ExporterConfig } from '../editor/types';
61
60
 
62
61
  type TimerExporter = (
63
62
  renderValues: ContentValues & TimerValues,
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by build-values-types.js. Do not edit manually.
2
2
 
3
- import type { DisplayMode, ExporterName } from '../editor/types';
3
+ import type { DisplayMode, ExporterConfig, ExporterName } from '../editor/types';
4
4
 
5
5
  export type VideoValues<
6
6
  TDisplayMode extends DisplayMode | undefined = undefined,
@@ -42,7 +42,6 @@ import type { ColumnValues } from '../containers/column';
42
42
  import type { ContentValues } from '../containers/content';
43
43
  import type { RowValues } from '../containers/row';
44
44
  import type { MergeTagsValues } from '../editor/merge-tags';
45
- import type { ExporterConfig } from '../editor/types';
46
45
 
47
46
  type VideoExporter = (
48
47
  renderValues: ContentValues & VideoValues,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unlayer/types",
3
- "version": "1.397.0",
3
+ "version": "1.399.0",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "types": "./dist/index.d.ts",