@cloudcannon/configuration-types 0.0.28 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/inputs.d.ts CHANGED
@@ -154,14 +154,14 @@ export interface TextInput extends BaseInput {
154
154
  * Sets an input type, which controls how this input appears and behaves.
155
155
  */
156
156
  type:
157
- | 'text'
158
- | 'email'
159
- | 'disabled'
160
- | 'pinterest'
161
- | 'facebook'
162
- | 'twitter'
163
- | 'github'
164
- | 'instagram';
157
+ | 'text'
158
+ | 'email'
159
+ | 'disabled'
160
+ | 'pinterest'
161
+ | 'facebook'
162
+ | 'twitter'
163
+ | 'github'
164
+ | 'instagram';
165
165
 
166
166
  /**
167
167
  * Options that are specific to this `type` of input.
@@ -314,40 +314,6 @@ export interface RangeInput extends BaseInput {
314
314
  options?: RangeInputOptions;
315
315
  }
316
316
 
317
- export interface UrlInputOptions extends WithEmptyTypeText, WithPaths {
318
- /**
319
- * Hides the option to link to a file. This does not prevent typing a file path in the input.
320
- *
321
- * @default false
322
- */
323
- hide_link_to_file?: boolean;
324
- /**
325
- * Hides the option to link to a page. This does not prevent typing a file's output URL in the
326
- * input.
327
- *
328
- * @default false
329
- */
330
- hide_link_to_page?: boolean;
331
- /**
332
- * Hides the option to link to an email address. This does not prevent typing a `mailto:` link in
333
- * the input.
334
- *
335
- * @default false
336
- */
337
- hide_link_to_email_address?: boolean;
338
- }
339
-
340
- export interface UrlInput extends BaseInput {
341
- /**
342
- * Sets an input type, which controls how this input appears and behaves.
343
- */
344
- type: 'url';
345
- /**
346
- * Options that are specific to this `type` of input.
347
- */
348
- options?: UrlInputOptions;
349
- }
350
-
351
317
  export interface RichTextInputOptions extends WithEmptyTypeText, ImageResizeable, BlockEditable {
352
318
  /**
353
319
  * Shows or hides the resize handler to vertically resize the input.
@@ -406,7 +372,7 @@ export interface TimeInput extends BaseInput {
406
372
  options?: WithEmptyTypeText;
407
373
  }
408
374
 
409
- export interface FileInputOptions extends WithEmptyTypeText, WithPaths {
375
+ export interface FileInputOptions extends WithEmptyTypeText, WithPaths, ImageResizeable {
410
376
  /**
411
377
  * Restricts which file types are available to select or upload to this input. Accepted format is
412
378
  * an array or comma-separated string of MIME types. The special value '*' means any type is
@@ -418,30 +384,71 @@ export interface FileInputOptions extends WithEmptyTypeText, WithPaths {
418
384
  * sources can be uploaded to and selected from.
419
385
  */
420
386
  allowed_sources?: string[];
387
+ /**
388
+ * Disables the context menu option and the drop area for uploading files.
389
+ *
390
+ * @default false
391
+ */
392
+ disable_upload_file?: boolean;
393
+ /**
394
+ * Prevents typing into the text input, while still allowing context menu options to change the
395
+ * value.
396
+ *
397
+ * @default false
398
+ */
399
+ disable_direct_input?: boolean;
400
+ /**
401
+ * Prevents file uploads inside the "Select existing file/image" file browser modal window.
402
+ *
403
+ * @default false
404
+ */
405
+ disable_upload_file_in_file_browser?: boolean;
421
406
  }
422
407
 
423
408
  export interface FileInput extends BaseInput {
424
409
  /**
425
410
  * Sets an input type, which controls how this input appears and behaves.
426
411
  */
427
- type: 'file' | 'document';
412
+ type: 'file' | 'document' | 'image';
428
413
  /**
429
- * Options that are specific to File inputs.
414
+ * Options that are specific to File, Image and Document inputs.
430
415
  */
431
416
  options?: FileInputOptions;
432
417
  }
433
418
 
434
- export type ImageInputOptions = FileInputOptions & ImageResizeable;
419
+ export interface UrlInputOptions extends FileInputOptions {
420
+ /**
421
+ * Hides the options to link to an existing file, and upload a new file. This does not prevent
422
+ * typing a file path in the input.
423
+ *
424
+ * @default false
425
+ */
426
+ hide_link_to_file?: boolean;
427
+ /**
428
+ * Hides the option to link to a page. This does not prevent typing a file's output URL in the
429
+ * input.
430
+ *
431
+ * @default false
432
+ */
433
+ hide_link_to_page?: boolean;
434
+ /**
435
+ * Hides the option to link to an email address. This does not prevent typing a `mailto:` link in
436
+ * the input.
437
+ *
438
+ * @default false
439
+ */
440
+ hide_link_to_email_address?: boolean;
441
+ }
435
442
 
436
- export interface ImageInput extends BaseInput {
443
+ export interface UrlInput extends BaseInput {
437
444
  /**
438
445
  * Sets an input type, which controls how this input appears and behaves.
439
446
  */
440
- type: 'image';
447
+ type: 'url';
441
448
  /**
442
- * Options that are specific to Image inputs.
449
+ * Options that are specific to URL inputs.
443
450
  */
444
- options?: ImageInputOptions;
451
+ options?: UrlInputOptions;
445
452
  }
446
453
 
447
454
  export interface SelectInputOptions extends WithPreview, WithPickerPreview {
@@ -501,7 +508,7 @@ export interface MultiselectInput extends BaseInput {
501
508
  options?: SelectInputOptions & WithEmptyTypeArray;
502
509
  }
503
510
 
504
- export interface ChoiceInputOptions extends Omit<SelectInputOptions, 'allow_create'> {}
511
+ export interface ChoiceInputOptions extends Omit<SelectInputOptions, 'allow_create'> { }
505
512
 
506
513
  export interface ChoiceInput extends BaseInput {
507
514
  /**
@@ -667,12 +674,11 @@ export type KnownInput =
667
674
  | BooleanInput
668
675
  | NumberInput
669
676
  | RangeInput
670
- | UrlInput
671
677
  | RichTextInput
672
678
  | DateInput
673
679
  | TimeInput
674
680
  | FileInput
675
- | ImageInput
681
+ | UrlInput
676
682
  | SelectInput
677
683
  | MultiselectInput
678
684
  | ChoiceInput
@@ -1,6 +1,6 @@
1
1
  import type { Cascade } from './cascade';
2
2
  import type { SnippetConfig } from './snippets';
3
- import type { FileInput, ImageInput, RichTextInput } from './inputs';
3
+ import type { FileInput, UrlInput, RichTextInput } from './inputs';
4
4
 
5
5
  export interface CloseCustomDataPanelOptions {
6
6
  parentId: string;
@@ -17,12 +17,17 @@ export interface OpenCustomDataPanelOptions extends CloseCustomDataPanelOptions
17
17
 
18
18
  /**
19
19
  * 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.
21
22
  */
22
23
  export interface CloudCannonJavaScriptAPI {
23
- /** Whether event handling is currently enabled */
24
+ /**
25
+ * Whether event handling is currently enabled
26
+ */
24
27
  eventsEnabled: boolean;
25
- /** Whether the API should be installed globally */
28
+ /**
29
+ * Whether the API should be installed globally
30
+ */
26
31
  installGlobally: boolean;
27
32
 
28
33
  /**
@@ -31,8 +36,7 @@ export interface CloudCannonJavaScriptAPI {
31
36
  disableGlobalInstall(): void;
32
37
 
33
38
  /**
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
36
40
  */
37
41
  enableEvents(): void;
38
42
 
@@ -42,19 +46,21 @@ export interface CloudCannonJavaScriptAPI {
42
46
  disableEvents(): void;
43
47
 
44
48
  /**
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
47
51
  */
48
52
  refreshInterface(): void;
49
53
 
50
54
  /**
51
55
  * Triggers an update event for a specific file
56
+ *
52
57
  * @param sourcePath - The path of the file to update
53
58
  */
54
59
  triggerUpdateEvent(sourcePath: string): void;
55
60
 
56
61
  /**
57
62
  * Sets the loading state of the editor
63
+ *
58
64
  * @param loadingData - Optional loading state message
59
65
  * @returns Promise that resolves when loading state is updated
60
66
  */
@@ -62,6 +68,7 @@ export interface CloudCannonJavaScriptAPI {
62
68
 
63
69
  /**
64
70
  * Sets data for a specific field
71
+ *
65
72
  * @param slug - The identifier of the field to set
66
73
  * @param value - The value to set
67
74
  * @returns Promise that resolves when the data is set
@@ -70,6 +77,7 @@ export interface CloudCannonJavaScriptAPI {
70
77
 
71
78
  /**
72
79
  * Initiates editing of a specific field
80
+ *
73
81
  * @param slug - The identifier of the field to edit
74
82
  * @param style - Optional style information
75
83
  * @param e - The mouse event that triggered the edit
@@ -78,6 +86,7 @@ export interface CloudCannonJavaScriptAPI {
78
86
 
79
87
  /**
80
88
  * Opens a custom data panel for editing
89
+ *
81
90
  * @param options - Configuration options for the panel
82
91
  * @returns Promise that resolves when the panel is opened
83
92
  */
@@ -85,6 +94,7 @@ export interface CloudCannonJavaScriptAPI {
85
94
 
86
95
  /**
87
96
  * Closes a custom data panel
97
+ *
88
98
  * @param options - Configuration options for the panel to close
89
99
  * @returns Promise that resolves when the panel is closed
90
100
  */
@@ -92,14 +102,19 @@ export interface CloudCannonJavaScriptAPI {
92
102
 
93
103
  /**
94
104
  * Uploads a file to the editor
105
+ *
95
106
  * @param file - The file to upload
96
107
  * @param inputConfig - Optional configuration for the input
97
108
  * @returns Promise that resolves with the path of the uploaded file
98
109
  */
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>;
100
114
 
101
115
  /**
102
116
  * Adds an item to an array field
117
+ *
103
118
  * @param slug - The identifier of the array field
104
119
  * @param index - The position to insert at (null for end)
105
120
  * @param value - The value to insert
@@ -110,6 +125,7 @@ export interface CloudCannonJavaScriptAPI {
110
125
 
111
126
  /**
112
127
  * Adds an item before a specific index in an array field
128
+ *
113
129
  * @param slug - The identifier of the array field
114
130
  * @param index - The index to insert before
115
131
  * @param value - The value to insert
@@ -120,6 +136,7 @@ export interface CloudCannonJavaScriptAPI {
120
136
 
121
137
  /**
122
138
  * Adds an item after a specific index in an array field
139
+ *
123
140
  * @param slug - The identifier of the array field
124
141
  * @param index - The index to insert after
125
142
  * @param value - The value to insert
@@ -130,6 +147,7 @@ export interface CloudCannonJavaScriptAPI {
130
147
 
131
148
  /**
132
149
  * Removes an item from an array field
150
+ *
133
151
  * @param slug - The identifier of the array field
134
152
  * @param index - The index of the item to remove
135
153
  * @returns Promise that resolves when the item is removed
@@ -138,6 +156,7 @@ export interface CloudCannonJavaScriptAPI {
138
156
 
139
157
  /**
140
158
  * Moves an item within an array field
159
+ *
141
160
  * @param slug - The identifier of the array field
142
161
  * @param index - The current index of the item
143
162
  * @param toIndex - The target index for the item
@@ -147,6 +166,7 @@ export interface CloudCannonJavaScriptAPI {
147
166
 
148
167
  /**
149
168
  * Gets the current value of the editor
169
+ *
150
170
  * @param options - Optional configuration for the value retrieval
151
171
  * @returns Promise that resolves with the current value
152
172
  */
@@ -154,6 +174,7 @@ export interface CloudCannonJavaScriptAPI {
154
174
 
155
175
  /**
156
176
  * Claims a lock on a file
177
+ *
157
178
  * @param sourcePath - Optional path of the file to lock
158
179
  * @returns Promise that resolves with the lock status
159
180
  */
@@ -161,6 +182,7 @@ export interface CloudCannonJavaScriptAPI {
161
182
 
162
183
  /**
163
184
  * Releases a lock on a file
185
+ *
164
186
  * @param sourcePath - Optional path of the file to unlock
165
187
  * @returns Promise that resolves with the lock status
166
188
  */
@@ -168,13 +190,15 @@ export interface CloudCannonJavaScriptAPI {
168
190
 
169
191
  /**
170
192
  * Gets prefetched files
193
+ *
171
194
  * @returns Promise that resolves with a record of file blobs
172
195
  */
173
196
  prefetchedFiles(): Promise<Record<string, Blob>>;
174
197
 
175
198
  /**
176
199
  * Loads legacy Bookshop information
200
+ *
177
201
  * @returns Promise that resolves with the Bookshop data
178
202
  */
179
203
  loadLegacyBookshopInfo(): Promise<any>;
180
- }
204
+ }