type FieldPluginSchema = { field_type: string; options: FieldPluginOption[]; translatable?: boolean; }; type FieldPluginOption = { name: string; value: string; }; declare const isFieldPluginOption: (it: unknown) => it is FieldPluginOption; declare const isFieldPluginSchema: (it: unknown) => it is FieldPluginSchema; type MessageToPlugin = { action: Action; uid: string; callbackId?: string; }; declare const isMessageToPlugin: (obj: unknown) => obj is MessageToPlugin; /** * The story object that is attached to "get-context", "loaded". */ type StoryData = { content: Record; } & Record; declare const isStoryData: (data: unknown) => data is StoryData; /** * Type that describes the complete state of a field type */ type FieldPluginData = { isModalOpen: boolean; content: Content; options: Record; spaceId: number | undefined; userId: number | undefined; interfaceLang: string; storyLang: string; story: StoryData; storyId: number | undefined; blockUid: string | undefined; token: string | undefined; uid: string; translatable: boolean; isAIEnabled: boolean; releases: Release[]; releaseId: number | undefined; }; type Release = { name: string; id: number; created_at: string; release_at: string; released: boolean; uuid: string; branches_to_deploy: number[]; timezone: string; description?: string; }; /** * The message that the field type wrapper (parent) sends to the * field type (child) via postMessage(). */ type LoadedMessage = MessageToPlugin<'loaded'> & { language: string; interfaceLanguage: string; spaceId: number | null; userId: number | undefined; story: StoryData; storyId: number | undefined; blockId: string | undefined; token: string | null; schema: FieldPluginSchema; model: unknown; isAIEnabled: boolean; isModalOpen: boolean; releases: Release[]; releaseId: number | undefined; }; declare const isLoadedMessage: (data: unknown) => data is LoadedMessage; type AssetWrapper = { filename: string; asset: Asset; }; type Asset = { id: number; fieldtype: 'asset'; filename: string; name: string; meta_data?: Record; title: string; copyright: string; focus: string; alt: string; source?: string; is_external_url?: boolean; is_private?: boolean; src?: string; updated_at?: string; }; declare const isAsset: (data: unknown) => data is AssetWrapper; declare const assetFromAssetSelectedMessage: (message: AssetSelectedMessage) => Asset; type AssetSelectedMessage = MessageToPlugin<'asset-selected'> & { field?: string; callbackId: string; } & AssetWrapper & Record; declare const isAssetSelectedMessage: (data: unknown) => data is AssetSelectedMessage; declare const hasField: (data: unknown) => boolean; type ContextRequestMessage = MessageToPlugin<'get-context'> & { story: StoryData; }; declare const isContextRequestMessage: (data: unknown) => data is ContextRequestMessage; /** * The user object that is attached to "get-user-context". */ type UserData = { isSpaceAdmin: boolean; permissions: Record | undefined; }; declare const isUserData: (data: unknown) => data is UserData; type UserContextRequestMessage = MessageToPlugin<'get-user-context'> & { user: UserData; }; declare const isUserContextRequestMessage: (data: unknown) => data is UserContextRequestMessage; /** * The message that the field type wrapper (parent) sends to the * field type (child) via postMessage(). */ type StateChangedMessage = MessageToPlugin<'state-changed'> & { language: string; interfaceLanguage: string; spaceId: number | null; userId: number | undefined; story: StoryData; storyId: number | undefined; blockId: string | undefined; token: string | null; schema: FieldPluginSchema; model: unknown; isAIEnabled: boolean; isModalOpen: boolean; releases: Release[]; releaseId: number | undefined; }; declare const isStateMessage: (data: unknown) => data is StateChangedMessage; /** * The object returned when calling the "prompt-ai" action. */ type PromptAIResponse = { ok: true; answer: string; } | { ok: false; error: string; }; type PromptAIResponseMessage = MessageToPlugin<'prompt-ai'> & { aiResponse: PromptAIResponse; }; declare const isPromptAIMessage: (data: unknown) => data is PromptAIResponseMessage; declare const getResponseFromPromptAIMessage: (message: PromptAIResponseMessage) => PromptAIResponse; type PreviewDimensionResponseMessage = MessageToPlugin<'preview-dimension'>; declare const isPreviewDimensionResponse: (data: unknown) => data is PreviewDimensionResponseMessage; /** * The plugin container's sends it's state to the plugin */ type OnMessage = (message: Message) => void; type OnStateChangeMessage = (message: StateChangedMessage) => void; type OnLoadedMessage = (message: LoadedMessage) => void; type OnAssetSelectMessage = (message: AssetSelectedMessage) => void; type OnPromptAIMessage = (message: PromptAIResponseMessage) => void; type OnPreviewDimensionMessage = (message: PreviewDimensionResponseMessage) => void; type OnContextRequestMessage = (message: ContextRequestMessage) => void; type OnUserContextRequestMessage = (message: UserContextRequestMessage) => void; type OnUnknownPluginMessage = (message: MessageToPlugin) => void; declare const recordFromFieldPluginOptions: (options: FieldPluginOption[]) => Record; type MessageToContainer = { action: 'plugin-changed' | 'prompt-ai'; uid: string; event: Event; callbackId?: string; }; declare const isMessageToContainer: (obj: unknown) => obj is MessageToContainer; type ValueChangeMessage = MessageToContainer<'update'> & { model: unknown; }; declare const isValueChangeMessage: (obj: unknown) => obj is ValueChangeMessage; declare const valueChangeMessage: (options: Pick) => ValueChangeMessage; type ModalSize = { width?: string; height?: string; }; type ModalChangeMessage = MessageToContainer<'toggleModal'> & { status: boolean; modalSize?: ModalSize; }; declare const isModalChangeMessage: (obj: unknown) => obj is ModalChangeMessage; declare const modalChangeMessage: (options: Pick) => ModalChangeMessage; type PluginLoadedMessage = MessageToContainer<'loaded'> & { fullHeight?: boolean; subscribeState?: boolean; enablePortalModal?: boolean; }; declare const isPluginLoadedMessage: (obj: unknown) => obj is PluginLoadedMessage; declare const pluginLoadedMessage: (options: Pick) => PluginLoadedMessage; type Dimension = { tag: 'desktop'; } | { tag: 'tablet'; } | { tag: 'mobile'; } | { tag: 'custom'; width: number; }; type PreviewDimensionChangeMessage = MessageToContainer<'previewDimension'> & { data: Dimension; }; declare const isPreviewDimensionChangeMessage: (data: unknown) => data is PreviewDimensionChangeMessage; declare const previewDimensionsChangeMessage: (options: Pick) => PreviewDimensionChangeMessage; type HeightChangeMessage = MessageToContainer<'heightChange'> & { height: number; }; declare const isHeightChangeMessage: (obj: unknown) => obj is HeightChangeMessage; declare const heightChangeMessage: (uid: string, height: number) => HeightChangeMessage; type GetContextMessage = MessageToContainer<'getContext'> & { debounce: false; }; declare const isGetContextMessage: (obj: unknown) => obj is GetContextMessage; declare const getContextMessage: (options: Pick) => GetContextMessage; type GetUserContextMessage = MessageToContainer<'getUserContext'>; declare const isGetUserContextMessage: (obj: unknown) => obj is GetUserContextMessage; declare const getUserContextMessage: (options: Pick) => GetUserContextMessage; type AssetModalChangeMessage = Omit, 'callbackId'> & { field?: string; callbackId: string; }; declare const isAssetModalChangeMessage: (obj: unknown) => obj is AssetModalChangeMessage; declare const assetModalChangeMessage: (options: Pick) => AssetModalChangeMessage; declare const promptAIActionsList: readonly ["prompt", "complete", "shorten", "extend", "rephrase", "summarize", "simplify", "translate", "tldr", "adjust-tone", "emojify", "fix_spelling_and_grammar"]; type PromptAIAction = (typeof promptAIActionsList)[number]; type PromptAIPayload = { action: PromptAIAction; text: string; basedOnCurrentStory?: boolean; language?: string; textLength?: string; tone?: string; textLengthUnit?: string; }; type PluginPromptAIMessage = Omit, 'action'> & { action: 'prompt-ai'; promptAIPayload: PromptAIPayload; }; declare const isPluginPromptAIMessage: (obj: unknown) => obj is PluginPromptAIMessage; declare const isPromptAIPayloadValid: (promptAIPayload: PromptAIPayload) => boolean; declare const getPluginPromptAIMessage: (message: PromptAIPayload, options: Pick) => PluginPromptAIMessage; /** * The parameters that are passed from the field type wrapper to the * custom field type via the URL query parameters */ type PluginUrlParams = { uid: string; secure: boolean; host: string; preview: boolean; }; declare const originFromPluginParams: (fieldTypeParams: PluginUrlParams) => string; declare const pluginUrlParamsFromUrl: (url: string) => PluginUrlParams | undefined; /** * Constructs a ULR search params string from a PluginUrlParams object, without a leading question mark. * @param pluginUrlParams */ declare const urlSearchParamsFromPluginUrlParams: (pluginUrlParams: PluginUrlParams) => string; type SetContent = (content: Content) => Promise>; type SetModalOpen = (isModalOpen: boolean, modalSize?: ModalSize) => Promise>; type RequestContext = () => Promise; type PromptAI = (payload: PromptAIPayload) => Promise; type RequestUserContext = () => Promise; type SelectAsset = () => Promise; type Initialize = () => Promise>; type SetPreviewWidth = (previewWidth: Dimension) => Promise; type FieldPluginActions = { setContent: SetContent; setModalOpen: SetModalOpen; requestContext: RequestContext; promptAI: PromptAI; requestUserContext: RequestUserContext; selectAsset: SelectAsset; setPreviewDimension: SetPreviewWidth; }; type ValidateContent = (content: unknown) => { content: Content; error?: string; }; type FieldPluginResponse = { type: 'loading'; error?: never; data?: never; actions?: never; } | { type: 'error'; error: Error; data?: never; actions?: never; } | { type: 'loaded'; error?: never; data: FieldPluginData; actions: FieldPluginActions; }; type CreateFieldPluginOptions = { onUpdateState: (state: FieldPluginResponse) => void; validateContent?: ValidateContent; targetOrigin?: string; enablePortalModal?: boolean; }; type CreateFieldPlugin = (options: CreateFieldPluginOptions) => () => void; /** * @returns cleanup function for side effects */ declare const createFieldPlugin: CreateFieldPlugin; export { type Asset, type AssetModalChangeMessage, type AssetSelectedMessage, type AssetWrapper, type ContextRequestMessage, type CreateFieldPlugin, type CreateFieldPluginOptions, type Dimension, type FieldPluginActions, type FieldPluginData, type FieldPluginOption, type FieldPluginResponse, type FieldPluginSchema, type GetContextMessage, type GetUserContextMessage, type HeightChangeMessage, type Initialize, type LoadedMessage, type MessageToContainer, type MessageToPlugin, type ModalChangeMessage, type ModalSize, type OnAssetSelectMessage, type OnContextRequestMessage, type OnLoadedMessage, type OnMessage, type OnPreviewDimensionMessage, type OnPromptAIMessage, type OnStateChangeMessage, type OnUnknownPluginMessage, type OnUserContextRequestMessage, type PluginLoadedMessage, type PluginPromptAIMessage, type PluginUrlParams, type PreviewDimensionChangeMessage, type PreviewDimensionResponseMessage, type PromptAI, type PromptAIAction, type PromptAIPayload, type PromptAIResponse, type PromptAIResponseMessage, type Release, type RequestContext, type RequestUserContext, type SelectAsset, type SetContent, type SetModalOpen, type SetPreviewWidth, type StateChangedMessage, type StoryData, type UserContextRequestMessage, type UserData, type ValueChangeMessage, assetFromAssetSelectedMessage, assetModalChangeMessage, createFieldPlugin, getContextMessage, getPluginPromptAIMessage, getResponseFromPromptAIMessage, getUserContextMessage, hasField, heightChangeMessage, isAsset, isAssetModalChangeMessage, isAssetSelectedMessage, isContextRequestMessage, isFieldPluginOption, isFieldPluginSchema, isGetContextMessage, isGetUserContextMessage, isHeightChangeMessage, isLoadedMessage, isMessageToContainer, isMessageToPlugin, isModalChangeMessage, isPluginLoadedMessage, isPluginPromptAIMessage, isPreviewDimensionChangeMessage, isPreviewDimensionResponse, isPromptAIMessage, isPromptAIPayloadValid, isStateMessage, isStoryData, isUserContextRequestMessage, isUserData, isValueChangeMessage, modalChangeMessage, originFromPluginParams, pluginLoadedMessage, pluginUrlParamsFromUrl, previewDimensionsChangeMessage, promptAIActionsList, recordFromFieldPluginOptions, urlSearchParamsFromPluginUrlParams, valueChangeMessage };