unlayer-types 1.398.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.
- package/embed.d.ts +65 -64
- package/package.json +1 -1
package/embed.d.ts
CHANGED
|
@@ -1737,8 +1737,7 @@ declare module "packages/editor/src/state/types/types" {
|
|
|
1737
1737
|
[id: string]: unknown;
|
|
1738
1738
|
};
|
|
1739
1739
|
}, placeholder: string) => (dispatch: AppDispatch, getState: () => RootState) => Promise<void>;
|
|
1740
|
-
export
|
|
1741
|
-
}
|
|
1740
|
+
export type { JSONSchema } from '@libs/schemas/types/types';
|
|
1742
1741
|
export interface SuggestedSelection {
|
|
1743
1742
|
parent?: Location | null;
|
|
1744
1743
|
location: Location | null;
|
|
@@ -2337,6 +2336,7 @@ declare module "packages/editor/src/editor/helpers/sortArrayByPosition" {
|
|
|
2337
2336
|
}>(arr: T[]): T[];
|
|
2338
2337
|
}
|
|
2339
2338
|
declare module "packages/editor/src/engine/config/tools" {
|
|
2339
|
+
import type { JSONSchema } from "packages/editor/src/state/types/types";
|
|
2340
2340
|
import Mustache from 'mustache';
|
|
2341
2341
|
import { Entitlements } from '@libs/entitlements';
|
|
2342
2342
|
import type { PropertyEditorJSONSchemas, PropertyEditorZodSchemas } from '@libs/schemas/types/property_editor';
|
|
@@ -2638,6 +2638,14 @@ declare module "packages/editor/src/engine/config/tools" {
|
|
|
2638
2638
|
};
|
|
2639
2639
|
export function isRowToolEnabled(): boolean;
|
|
2640
2640
|
export function getTool(toolItem: ToolItem): ToolConfig<ValueMap, Validator>;
|
|
2641
|
+
/**
|
|
2642
|
+
* Returns true if a custom tool has schemas for all its custom widget options.
|
|
2643
|
+
* Built-in widgets are always supported. Custom widgets need an explicit schema
|
|
2644
|
+
* (via createWidget, registerPropertyEditor, or the option itself).
|
|
2645
|
+
*/
|
|
2646
|
+
export function hasAISchemas(tool: ToolConfig, { displayMode }?: {
|
|
2647
|
+
displayMode?: DisplayMode;
|
|
2648
|
+
}): boolean;
|
|
2641
2649
|
export function getAllTools(): any[];
|
|
2642
2650
|
export function getTools(collection?: Collection): any[];
|
|
2643
2651
|
export function getCustomToolsCount(): number;
|
|
@@ -2654,7 +2662,10 @@ declare module "packages/editor/src/engine/config/tools" {
|
|
|
2654
2662
|
export function registerOptions(config: OptionConfig & {
|
|
2655
2663
|
category?: string;
|
|
2656
2664
|
}): void;
|
|
2657
|
-
export function registerPropertyEditor<Props extends EditorProps<any>>(config: PropertyEditorConfig<Props>
|
|
2665
|
+
export function registerPropertyEditor<Props extends EditorProps<any>>(config: PropertyEditorConfig<Props> & {
|
|
2666
|
+
/** Shorthand for `schemas.value`. Prefer setting `schema` on `createWidget()` instead. */
|
|
2667
|
+
schema?: JSONSchema;
|
|
2668
|
+
}): void;
|
|
2658
2669
|
export function getPropertyEditor(config: {
|
|
2659
2670
|
id: PropertyEditorConfig['id'];
|
|
2660
2671
|
name?: PropertyEditorConfig['name'];
|
|
@@ -2903,68 +2914,53 @@ declare module "packages/editor/src/engine/config/createViewer" {
|
|
|
2903
2914
|
}
|
|
2904
2915
|
declare module "packages/editor/src/engine/config/createWidget" {
|
|
2905
2916
|
import React from 'react';
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
export
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
export interface
|
|
2913
|
-
|
|
2914
|
-
|
|
2917
|
+
import type { InferSchemaType } from '@libs/schemas/types/common';
|
|
2918
|
+
import type { JSONSchema } from "packages/editor/src/state/types/types";
|
|
2919
|
+
export type { InferSchemaType };
|
|
2920
|
+
export type UpdateValueFn<Value = unknown> = (newValue: Value | undefined, data?: object) => void;
|
|
2921
|
+
export type WidgetMountFn<Value = unknown> = (node: HTMLDivElement | null, value: Value | undefined, updateValue: UpdateValueFn<Value>, data: unknown) => void;
|
|
2922
|
+
export type WidgetRenderFn<Value = unknown> = (value: Value | undefined, updateValue: UpdateValueFn<Value>, data: unknown) => string;
|
|
2923
|
+
export interface WidgetConfig<Value = unknown> {
|
|
2924
|
+
mount: WidgetMountFn<Value>;
|
|
2925
|
+
render: WidgetRenderFn<Value>;
|
|
2926
|
+
/**
|
|
2927
|
+
* JSON Schema describing the value shape produced by this widget.
|
|
2928
|
+
* Used by the AI Copilot to understand what fields this custom property editor supports.
|
|
2929
|
+
*
|
|
2930
|
+
* @example
|
|
2931
|
+
* ```js
|
|
2932
|
+
* unlayer.registerPropertyEditor({
|
|
2933
|
+
* name: 'qr_generator',
|
|
2934
|
+
* Widget: unlayer.createWidget({
|
|
2935
|
+
* schema: {
|
|
2936
|
+
* type: 'object',
|
|
2937
|
+
* properties: {
|
|
2938
|
+
* qrCode: { type: 'string', description: 'Base64-encoded QR image' },
|
|
2939
|
+
* srcUrl: { type: 'string', description: 'URL encoded in the QR code' },
|
|
2940
|
+
* },
|
|
2941
|
+
* },
|
|
2942
|
+
* render(value) { ... },
|
|
2943
|
+
* mount(node, value, updateValue) { ... },
|
|
2944
|
+
* }),
|
|
2945
|
+
* });
|
|
2946
|
+
* ```
|
|
2947
|
+
*/
|
|
2948
|
+
schema?: JSONSchema | null;
|
|
2949
|
+
}
|
|
2950
|
+
export interface WidgetProps<Value = unknown> {
|
|
2951
|
+
value: Value | undefined;
|
|
2952
|
+
updateValue: UpdateValueFn<Value>;
|
|
2915
2953
|
data: unknown;
|
|
2916
2954
|
}
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
ref: HTMLDivElement | null;
|
|
2920
|
-
componentDidMount(): void;
|
|
2921
|
-
shouldComponentUpdate(nextProps: WidgetProps): boolean;
|
|
2922
|
-
componentDidUpdate(prevProps: WidgetProps): void;
|
|
2923
|
-
render(): React.JSX.Element;
|
|
2924
|
-
context: unknown;
|
|
2925
|
-
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<WidgetProps>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
|
|
2926
|
-
forceUpdate(callback?: () => void): void;
|
|
2927
|
-
readonly props: Readonly<WidgetProps>;
|
|
2928
|
-
state: Readonly<{}>;
|
|
2929
|
-
refs: {
|
|
2930
|
-
[key: string]: React.ReactInstance;
|
|
2931
|
-
};
|
|
2932
|
-
componentWillUnmount?(): void;
|
|
2933
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
2934
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<WidgetProps>, prevState: Readonly<{}>): any;
|
|
2935
|
-
componentWillMount?(): void;
|
|
2936
|
-
UNSAFE_componentWillMount?(): void;
|
|
2937
|
-
componentWillReceiveProps?(nextProps: Readonly<WidgetProps>, nextContext: any): void;
|
|
2938
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<WidgetProps>, nextContext: any): void;
|
|
2939
|
-
componentWillUpdate?(nextProps: Readonly<WidgetProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
2940
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<WidgetProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
2941
|
-
};
|
|
2942
|
-
new (props: WidgetProps, context: any): {
|
|
2943
|
-
ref: HTMLDivElement | null;
|
|
2944
|
-
componentDidMount(): void;
|
|
2945
|
-
shouldComponentUpdate(nextProps: WidgetProps): boolean;
|
|
2946
|
-
componentDidUpdate(prevProps: WidgetProps): void;
|
|
2947
|
-
render(): React.JSX.Element;
|
|
2948
|
-
context: unknown;
|
|
2949
|
-
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<WidgetProps>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
|
|
2950
|
-
forceUpdate(callback?: () => void): void;
|
|
2951
|
-
readonly props: Readonly<WidgetProps>;
|
|
2952
|
-
state: Readonly<{}>;
|
|
2953
|
-
refs: {
|
|
2954
|
-
[key: string]: React.ReactInstance;
|
|
2955
|
-
};
|
|
2956
|
-
componentWillUnmount?(): void;
|
|
2957
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
2958
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<WidgetProps>, prevState: Readonly<{}>): any;
|
|
2959
|
-
componentWillMount?(): void;
|
|
2960
|
-
UNSAFE_componentWillMount?(): void;
|
|
2961
|
-
componentWillReceiveProps?(nextProps: Readonly<WidgetProps>, nextContext: any): void;
|
|
2962
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<WidgetProps>, nextContext: any): void;
|
|
2963
|
-
componentWillUpdate?(nextProps: Readonly<WidgetProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
2964
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<WidgetProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
2965
|
-
};
|
|
2966
|
-
contextType?: React.Context<any> | undefined;
|
|
2955
|
+
type WidgetComponentClass = React.ComponentClass<WidgetProps> & {
|
|
2956
|
+
schema?: Record<string, unknown> | null;
|
|
2967
2957
|
};
|
|
2958
|
+
export function createWidget<const S extends Record<string, unknown>>(config: {
|
|
2959
|
+
schema: S;
|
|
2960
|
+
mount: WidgetMountFn<InferSchemaType<S>>;
|
|
2961
|
+
render: WidgetRenderFn<InferSchemaType<S>>;
|
|
2962
|
+
}): WidgetComponentClass;
|
|
2963
|
+
export function createWidget<Value = unknown>(config: WidgetConfig<Value>): WidgetComponentClass;
|
|
2968
2964
|
}
|
|
2969
2965
|
declare module "packages/editor/src/engine/options/bodies" {
|
|
2970
2966
|
export type { BodyValues } from '@libs/schemas/options/containers/bodies';
|
|
@@ -3170,7 +3166,7 @@ declare module "packages/editor/src/embed/Editor" {
|
|
|
3170
3166
|
import type { TabConfig } from "packages/editor/src/engine/config/tabs";
|
|
3171
3167
|
import type { PanelConfig } from "packages/editor/src/engine/config/createPanel";
|
|
3172
3168
|
import type { ViewerConfig } from "packages/editor/src/engine/config/createViewer";
|
|
3173
|
-
import type { WidgetConfig } from "packages/editor/src/engine/config/createWidget";
|
|
3169
|
+
import type { InferSchemaType, WidgetConfig, WidgetMountFn, WidgetRenderFn } from "packages/editor/src/engine/config/createWidget";
|
|
3174
3170
|
import type { AppearanceConfig, Audit, DesignMode, DesignTagsConfig, Device, DisplayConditions, DisplayMode, JSONTemplate, Language, LinkTypes, LinkTypesSharedConfig, MergeTags, MergeTagsConfig, SpecialLink, StyleGuideConfig, Tabs, Translations, User, Validator, Container, BodyContainerExporter, RowContainerExporter, ColumnContainerExporter, ContentContainerExporter, ItemExporter } from "packages/editor/src/state/types/types";
|
|
3175
3171
|
import type { BodyValues } from "packages/editor/src/engine/options/bodies";
|
|
3176
3172
|
import type { Locale, TextDirection } from "packages/editor/src/engine/config/intl";
|
|
@@ -3263,7 +3259,12 @@ declare module "packages/editor/src/embed/Editor" {
|
|
|
3263
3259
|
registerTab(_config: TabConfig): void;
|
|
3264
3260
|
createPanel(_config: PanelConfig): void;
|
|
3265
3261
|
createViewer(_config: ViewerConfig): void;
|
|
3266
|
-
createWidget(_config:
|
|
3262
|
+
createWidget<const S extends Record<string, unknown>>(_config: {
|
|
3263
|
+
schema: S;
|
|
3264
|
+
mount: WidgetMountFn<InferSchemaType<S>>;
|
|
3265
|
+
render: WidgetRenderFn<InferSchemaType<S>>;
|
|
3266
|
+
}): void;
|
|
3267
|
+
createWidget<Value = unknown>(_config: WidgetConfig<Value>): void;
|
|
3267
3268
|
}
|
|
3268
3269
|
}
|
|
3269
3270
|
declare module "packages/editor/src/embed/index" {
|
package/package.json
CHANGED