11import type { Cascade } from './cascade' ;
22import type { SnippetConfig } from './snippets' ;
3- import type { FileInput , ImageInput , RichTextInput } from './inputs' ;
3+ import type { FileInput , UrlInput , RichTextInput } from './inputs' ;
44
55export interface CloseCustomDataPanelOptions {
66 parentId : string ;
@@ -17,12 +17,17 @@ export interface OpenCustomDataPanelOptions extends CloseCustomDataPanelOptions
1717
1818/**
1919 * Interface defining the public JavaScript API for interacting with CloudCannon's Visual Editor.
20- * This API provides methods for managing content, handling file operations, and controlling the editor's state.
20+ * This API provides methods for managing content, handling file operations, and controlling the
21+ * editor's state.
2122 */
2223export interface CloudCannonJavaScriptAPI {
23- /** Whether event handling is currently enabled */
24+ /**
25+ * Whether event handling is currently enabled
26+ */
2427 eventsEnabled : boolean ;
25- /** Whether the API should be installed globally */
28+ /**
29+ * Whether the API should be installed globally
30+ */
2631 installGlobally : boolean ;
2732
2833 /**
@@ -31,8 +36,7 @@ export interface CloudCannonJavaScriptAPI {
3136 disableGlobalInstall ( ) : void ;
3237
3338 /**
34- * Enables event handling for the API
35- * This will also ensure the commit model is created
39+ * Enables event handling for the API This will also ensure the commit model is created
3640 */
3741 enableEvents ( ) : void ;
3842
@@ -42,26 +46,29 @@ export interface CloudCannonJavaScriptAPI {
4246 disableEvents ( ) : void ;
4347
4448 /**
45- * Refreshes the editor interface
46- * Note: This has been replaced with a MutationObserver in editor-overlays-view
49+ * Refreshes the editor interface Note: This has been replaced with a MutationObserver in
50+ * editor-overlays-view
4751 */
4852 refreshInterface ( ) : void ;
4953
5054 /**
5155 * Triggers an update event for a specific file
56+ *
5257 * @param sourcePath - The path of the file to update
5358 */
5459 triggerUpdateEvent ( sourcePath : string ) : void ;
5560
5661 /**
5762 * Sets the loading state of the editor
63+ *
5864 * @param loadingData - Optional loading state message
5965 * @returns Promise that resolves when loading state is updated
6066 */
6167 setLoading ( loadingData : string | undefined ) : Promise < any > ;
6268
6369 /**
6470 * Sets data for a specific field
71+ *
6572 * @param slug - The identifier of the field to set
6673 * @param value - The value to set
6774 * @returns Promise that resolves when the data is set
@@ -70,6 +77,7 @@ export interface CloudCannonJavaScriptAPI {
7077
7178 /**
7279 * Initiates editing of a specific field
80+ *
7381 * @param slug - The identifier of the field to edit
7482 * @param style - Optional style information
7583 * @param e - The mouse event that triggered the edit
@@ -78,28 +86,35 @@ export interface CloudCannonJavaScriptAPI {
7886
7987 /**
8088 * Opens a custom data panel for editing
89+ *
8190 * @param options - Configuration options for the panel
8291 * @returns Promise that resolves when the panel is opened
8392 */
8493 openCustomDataPanel ( options : OpenCustomDataPanelOptions ) : Promise < void > ;
8594
8695 /**
8796 * Closes a custom data panel
97+ *
8898 * @param options - Configuration options for the panel to close
8999 * @returns Promise that resolves when the panel is closed
90100 */
91101 closeCustomDataPanel ( options : CloseCustomDataPanelOptions ) : Promise < void > ;
92102
93103 /**
94104 * Uploads a file to the editor
105+ *
95106 * @param file - The file to upload
96107 * @param inputConfig - Optional configuration for the input
97108 * @returns Promise that resolves with the path of the uploaded file
98109 */
99- uploadFile ( file : File , inputConfig : RichTextInput | ImageInput | FileInput | undefined ) : Promise < string | undefined > ;
110+ uploadFile (
111+ file : File ,
112+ inputConfig : RichTextInput | UrlInput | FileInput | undefined ,
113+ ) : Promise < string | undefined > ;
100114
101115 /**
102116 * Adds an item to an array field
117+ *
103118 * @param slug - The identifier of the array field
104119 * @param index - The position to insert at (null for end)
105120 * @param value - The value to insert
@@ -110,6 +125,7 @@ export interface CloudCannonJavaScriptAPI {
110125
111126 /**
112127 * Adds an item before a specific index in an array field
128+ *
113129 * @param slug - The identifier of the array field
114130 * @param index - The index to insert before
115131 * @param value - The value to insert
@@ -120,6 +136,7 @@ export interface CloudCannonJavaScriptAPI {
120136
121137 /**
122138 * Adds an item after a specific index in an array field
139+ *
123140 * @param slug - The identifier of the array field
124141 * @param index - The index to insert after
125142 * @param value - The value to insert
@@ -130,6 +147,7 @@ export interface CloudCannonJavaScriptAPI {
130147
131148 /**
132149 * Removes an item from an array field
150+ *
133151 * @param slug - The identifier of the array field
134152 * @param index - The index of the item to remove
135153 * @returns Promise that resolves when the item is removed
@@ -138,6 +156,7 @@ export interface CloudCannonJavaScriptAPI {
138156
139157 /**
140158 * Moves an item within an array field
159+ *
141160 * @param slug - The identifier of the array field
142161 * @param index - The current index of the item
143162 * @param toIndex - The target index for the item
@@ -147,34 +166,39 @@ export interface CloudCannonJavaScriptAPI {
147166
148167 /**
149168 * Gets the current value of the editor
169+ *
150170 * @param options - Optional configuration for the value retrieval
151171 * @returns Promise that resolves with the current value
152172 */
153173 value ( options ?: { keepMarkdownAsHTML ?: boolean } ) : Promise < string > ;
154174
155175 /**
156176 * Claims a lock on a file
177+ *
157178 * @param sourcePath - Optional path of the file to lock
158179 * @returns Promise that resolves with the lock status
159180 */
160181 claimLock ( sourcePath ?: string ) : Promise < { readOnly : boolean } > ;
161182
162183 /**
163184 * Releases a lock on a file
185+ *
164186 * @param sourcePath - Optional path of the file to unlock
165187 * @returns Promise that resolves with the lock status
166188 */
167189 releaseLock ( sourcePath ?: string ) : Promise < { readOnly : boolean } > ;
168190
169191 /**
170192 * Gets prefetched files
193+ *
171194 * @returns Promise that resolves with a record of file blobs
172195 */
173196 prefetchedFiles ( ) : Promise < Record < string , Blob > > ;
174197
175198 /**
176199 * Loads legacy Bookshop information
200+ *
177201 * @returns Promise that resolves with the Bookshop data
178202 */
179203 loadLegacyBookshopInfo ( ) : Promise < any > ;
180- }
204+ }
0 commit comments