diff --git a/src/index.d.ts b/src/index.d.ts
index 2d984be..ea9ef3d 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -1,8 +1,12 @@
import type {
Cascade,
FileInput,
+ Input,
+ InputType,
RichTextInput,
SnippetConfig,
+ Structure,
+ StructureValue,
UrlInput,
} from '@cloudcannon/configuration-types';
@@ -210,7 +214,7 @@ export interface EditOptions {
/** Optional style information */
style?: string | null;
/** The mouse event that triggered the edit */
- e: MouseEvent;
+ e?: MouseEvent;
}
/**
@@ -235,7 +239,7 @@ export interface AddArrayItemOptions extends ArrayOptions {
/** The value to insert */
value: any;
/** The mouse event that triggered the addition */
- e: MouseEvent;
+ e?: MouseEvent;
}
/**
@@ -256,6 +260,10 @@ export interface RemoveArrayItemOptions extends ArrayOptions {
index: number;
}
+export interface GetInputConfigOptions {
+ slug: string;
+}
+
/**
* Options for getting the current value in the v2 API
*/
@@ -495,15 +503,17 @@ export interface CloudCannonJavaScriptV1APIFile {
releaseLock(): Promise<{ readOnly: boolean }>;
addEventListener(
- event: 'change' | 'delete' | 'create',
+ event: 'change' | 'delete',
listener: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void;
removeEventListener(
- event: 'change' | 'delete' | 'create',
+ event: 'change' | 'delete',
listener: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void;
+
+ getInputConfig(options: GetInputConfigOptions): Promise;
}
export interface CloudCannonJavaScriptV1APICollection {
@@ -528,17 +538,45 @@ export interface CloudCannonJavaScriptV1APICollection {
// add(options: any): Promise;
addEventListener(
- event: 'change' | 'delete' | 'create',
+ event: 'change' | 'delete',
listener: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void;
removeEventListener(
- event: 'change' | 'delete' | 'create',
+ event: 'change' | 'delete',
listener: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void;
}
+export interface CloudCannonJavaScriptV1APIDataset {
+ /**
+ * The key of the dataset
+ */
+ datasetKey: string;
+
+ /**
+ * Gets the items in a dataset
+ * @returns Promise that resolves with the items in the collection
+ */
+ items(): Promise;
+
+ addEventListener(
+ event: 'change' | 'delete',
+ listener: EventListenerOrEventListenerObject | null,
+ options?: EventListenerOptions | boolean
+ ): void;
+ removeEventListener(
+ event: 'change' | 'delete',
+ listener: EventListenerOrEventListenerObject | null,
+ options?: EventListenerOptions | boolean
+ ): void;
+}
+
+export interface CloudCannonJavaScriptV1APITextEditableRegion {
+ setContent: (content?: string | null) => void;
+}
+
export interface CloudCannonJavaScriptV1API {
/**
* Gets prefetched files
@@ -573,7 +611,7 @@ export interface CloudCannonJavaScriptV1API {
* @param inputConfig - Optional configuration for the input
* @returns Promise that resolves with the path of the uploaded file
*/
- upload(
+ uploadFile(
file: File,
inputConfig: RichTextInput | UrlInput | FileInput | undefined
): Promise;
@@ -581,19 +619,36 @@ export interface CloudCannonJavaScriptV1API {
currentFile(): CloudCannonJavaScriptV1APIFile;
file(path: string): CloudCannonJavaScriptV1APIFile;
collection(key: string): CloudCannonJavaScriptV1APICollection;
+ dataset(key: string): CloudCannonJavaScriptV1APIDataset;
files(): Promise;
collections(): Promise;
addEventListener(
- event: 'change' | 'delete' | 'create',
+ event: 'change' | 'delete',
listener: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void;
removeEventListener(
- event: 'change' | 'delete' | 'create',
+ event: 'change' | 'delete',
listener: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean
): void;
+
+ isAPIFile(obj: unknown): obj is CloudCannonJavaScriptV1APIFile;
+ isAPICollection(obj: unknown): obj is CloudCannonJavaScriptV1APICollection;
+ isAPIDataset(obj: unknown): obj is CloudCannonJavaScriptV1APIDataset;
+ findStructure(structure: Structure, value: any): StructureValue | undefined;
+ getInputType(key: string | undefined, value?: unknown, inputConfig?: Input): InputType;
+
+ createTextEditableRegion(
+ element: HTMLElement,
+ onChange: (content?: string | null) => void,
+ options?: {
+ elementType?: string;
+ editableType?: string;
+ inputConfig?: RichTextInput;
+ }
+ ): Promise;
}
export type CloudCannonJavaScriptAPIVersions = 'v0' | 'v1';