diff --git a/src/index.d.ts b/src/index.d.ts index ea9ef3d..1ee596b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -10,17 +10,13 @@ import type { UrlInput, } from '@cloudcannon/configuration-types'; -export interface CloseCustomDataPanelOptions { - parentId: string; - id: string; -} - -export interface OpenCustomDataPanelOptions extends CloseCustomDataPanelOptions { - data: Record | any[] | undefined; - position?: DOMRect; +export interface CreateCustomDataPanelOptions { + id?: string; title: string; - inputConfig: Cascade & SnippetConfig; - allowFullDataCascade?: boolean; + onChange: (data?: Record | unknown[]) => void; + data?: Record | unknown[]; + config?: Cascade; + position?: DOMRect; } type EventListenerParameters = Parameters; @@ -89,20 +85,6 @@ export interface CloudCannonJavaScriptV0API { */ edit(slug: string, style: string | null, e: MouseEvent): void; - /** - * Opens a custom data panel for editing - * @param options - Configuration options for the panel - * @returns Promise that resolves when the panel is opened - */ - openCustomDataPanel(options: OpenCustomDataPanelOptions): Promise; - - /** - * Closes a custom data panel - * @param options - Configuration options for the panel to close - * @returns Promise that resolves when the panel is closed - */ - closeCustomDataPanel(options: CloseCustomDataPanelOptions): Promise; - /** * Uploads a file to the editor * @param file - The file to upload @@ -166,7 +148,7 @@ export interface CloudCannonJavaScriptV0API { * @param options - Optional configuration for the value retrieval * @returns Promise that resolves with the current value */ - value(options?: { keepMarkdownAsHTML?: boolean }): Promise; + value(options?: { rewriteURLs?: boolean }): Promise; /** * Claims a lock on a file @@ -231,11 +213,6 @@ export interface ArrayOptions { export interface AddArrayItemOptions extends ArrayOptions { /** The position to insert at (null for end) */ index: number | null; - /** - * The position to insert at (before or after) - * @default 'before' - */ - position?: 'before' | 'after'; /** The value to insert */ value: any; /** The mouse event that triggered the addition */ @@ -264,17 +241,6 @@ export interface GetInputConfigOptions { slug: string; } -/** - * Options for getting the current value in the v2 API - */ -export interface ValueOptions { - /** - * CloudCannon works with HTML by default. Markdown is converted to HTML and back again while editing. - * If true, any markdown inputs will be returned as an HTML string instead of Markdown. - */ - keepMarkdownAsHTML?: boolean; -} - export interface FileNotFoundError extends Error { message: 'File not found'; } @@ -291,12 +257,10 @@ export interface CloudCannonJavaScriptV1APIFileContent { * @throws {FileNotFoundError} If the file is not found * @example * ```javascript - * const value = await CloudCannon.content({ - * keepMarkdownAsHTML: true, - * }); + * const value = await CloudCannon.content(); * ``` */ - get(options?: ValueOptions): Promise; + get(): Promise; /** * Sets the body content of a file @@ -326,12 +290,12 @@ export interface CloudCannonJavaScriptV1APIFileData { * @returns Promise that resolves with the data of the file * @example * ```javascript - * const value = await CloudCannon.data({ - * keepMarkdownAsHTML: true, - * }); + * const value = await CloudCannon.data(); * ``` */ - get(options?: ValueOptions & { slug?: string }): Promise | any[] | undefined>; + get(options?: { slug?: string; rewriteUrls?: boolean }): Promise< + Record | any[] | undefined + >; /** * Sets data for a specific field @@ -591,20 +555,6 @@ export interface CloudCannonJavaScriptV1API { */ setLoading(loadingData: string | undefined): Promise; - /** - * Opens a custom data panel for editing - * @param options - Configuration options for the panel - * @returns Promise that resolves when the panel is opened - */ - openCustomDataPanel(options: OpenCustomDataPanelOptions): Promise; - - /** - * Closes a custom data panel - * @param options - Configuration options for the panel to close - * @returns Promise that resolves when the panel is closed - */ - closeCustomDataPanel(options: CloseCustomDataPanelOptions): Promise; - /** * Uploads a file to the editor * @param file - The file to upload @@ -649,6 +599,10 @@ export interface CloudCannonJavaScriptV1API { inputConfig?: RichTextInput; } ): Promise; + + createCustomDataPanel(options: CreateCustomDataPanelOptions): Promise; + + getPreviewUrl(originalUrl: string, inputConfig?: Input): Promise; } export type CloudCannonJavaScriptAPIVersions = 'v0' | 'v1';