From d63cad1493a017be4d7738dbe97f592b824b55a3 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 10 Sep 2025 17:13:12 +1200 Subject: [PATCH 1/4] Add a nicer user-facing custom panel API --- src/index.d.ts | 46 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index ea9ef3d..01b7733 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 @@ -591,20 +573,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 +617,8 @@ export interface CloudCannonJavaScriptV1API { inputConfig?: RichTextInput; } ): Promise; + + createCustomDataPanel(options: CreateCustomDataPanelOptions): Promise; } export type CloudCannonJavaScriptAPIVersions = 'v0' | 'v1'; From 90eb88e9245eccfd1ed60b23deb8c9b4bbb25701 Mon Sep 17 00:00:00 2001 From: Tate Date: Fri, 12 Sep 2025 14:49:16 +1200 Subject: [PATCH 2/4] Remove position from array add options --- src/index.d.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 01b7733..e49d064 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -213,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 */ From 5a2c1a261bb320a06f9ec12b15c38c7f195ce0bd Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 17 Sep 2025 13:48:06 +1200 Subject: [PATCH 3/4] Remove keepMarkdownAsHTML, add getPreviewUrl --- src/index.d.ts | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index e49d064..a5083aa 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -148,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 @@ -241,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'; } @@ -268,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 @@ -303,12 +290,10 @@ 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 }): Promise | any[] | undefined>; /** * Sets data for a specific field @@ -614,6 +599,8 @@ export interface CloudCannonJavaScriptV1API { ): Promise; createCustomDataPanel(options: CreateCustomDataPanelOptions): Promise; + + getPreviewUrl(originalUrl: string, inputConfig?: Input): Promise; } export type CloudCannonJavaScriptAPIVersions = 'v0' | 'v1'; From 2042e55133b16eaa74d174e13ee8f0205974d613 Mon Sep 17 00:00:00 2001 From: Tate Date: Thu, 18 Sep 2025 09:21:32 +1200 Subject: [PATCH 4/4] Add rewriteUrl option --- src/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index a5083aa..1ee596b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -293,7 +293,9 @@ export interface CloudCannonJavaScriptV1APIFileData { * const value = await CloudCannon.data(); * ``` */ - get(options?: { slug?: string }): Promise | any[] | undefined>; + get(options?: { slug?: string; rewriteUrls?: boolean }): Promise< + Record | any[] | undefined + >; /** * Sets data for a specific field