@dotcms/uve 0.0.1-beta.14 → 0.0.1-beta.15

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/internal.cjs.js CHANGED
@@ -210,6 +210,167 @@ function computeScrollIsInBottom() {
210
210
  const scrollY = window.scrollY;
211
211
  return scrollY + viewportHeight >= documentHeight;
212
212
  }
213
+ /**
214
+ *
215
+ *
216
+ * Combine classes into a single string.
217
+ *
218
+ * @param {string[]} classes
219
+ * @returns {string} Combined classes
220
+ */
221
+ const combineClasses = classes => classes.filter(Boolean).join(' ');
222
+ /**
223
+ *
224
+ *
225
+ * Calculates and returns the CSS Grid positioning classes for a column based on its configuration.
226
+ * Uses a 12-column grid system where columns are positioned using grid-column-start and grid-column-end.
227
+ *
228
+ * @example
229
+ * ```typescript
230
+ * const classes = getColumnPositionClasses({
231
+ * leftOffset: 1, // Starts at the first column
232
+ * width: 6 // Spans 6 columns
233
+ * });
234
+ * // Returns: { startClass: 'col-start-1', endClass: 'col-end-7' }
235
+ * ```
236
+ *
237
+ * @param {DotPageAssetLayoutColumn} column - Column configuration object
238
+ * @param {number} column.leftOffset - Starting position (0-based) in the grid
239
+ * @param {number} column.width - Number of columns to span
240
+ * @returns {{ startClass: string, endClass: string }} Object containing CSS class names for grid positioning
241
+ */
242
+ const getColumnPositionClasses = column => {
243
+ const {
244
+ leftOffset,
245
+ width
246
+ } = column;
247
+ const startClass = `${START_CLASS}${leftOffset}`;
248
+ const endClass = `${END_CLASS}${leftOffset + width}`;
249
+ return {
250
+ startClass,
251
+ endClass
252
+ };
253
+ };
254
+ /**
255
+ *
256
+ *
257
+ * Helper function that returns an object containing the dotCMS data attributes.
258
+ * @param {DotCMSContentlet} contentlet - The contentlet to get the attributes for
259
+ * @param {string} container - The container to get the attributes for
260
+ * @returns {DotContentletAttributes} The dotCMS data attributes
261
+ */
262
+ function getDotContentletAttributes(contentlet, container) {
263
+ return {
264
+ 'data-dot-identifier': contentlet?.identifier,
265
+ 'data-dot-basetype': contentlet?.baseType,
266
+ 'data-dot-title': contentlet?.['widgetTitle'] || contentlet?.title,
267
+ 'data-dot-inode': contentlet?.inode,
268
+ 'data-dot-type': contentlet?.contentType,
269
+ 'data-dot-container': container,
270
+ 'data-dot-on-number-of-pages': contentlet?.['onNumberOfPages']
271
+ };
272
+ }
273
+ /**
274
+ *
275
+ *
276
+ * Retrieves container data from a DotCMS page asset using the container reference.
277
+ * This function processes the container information and returns a standardized format
278
+ * for container editing.
279
+ *
280
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
281
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
282
+ * @throws {Error} When page asset is invalid or container is not found
283
+ * @returns {EditableContainerData} Formatted container data for editing
284
+ *
285
+ * @example
286
+ * const containerData = getContainersData(pageAsset, containerRef);
287
+ * // Returns: { uuid: '123', identifier: 'cont1', acceptTypes: 'type1,type2', maxContentlets: 5 }
288
+ */
289
+ const getContainersData = (dotCMSPageAsset, columContainer) => {
290
+ const {
291
+ identifier,
292
+ uuid
293
+ } = columContainer;
294
+ const dotContainer = dotCMSPageAsset.containers[identifier];
295
+ if (!dotContainer) {
296
+ return null;
297
+ }
298
+ const {
299
+ containerStructures,
300
+ container
301
+ } = dotContainer;
302
+ const acceptTypes = containerStructures?.map(structure => structure.contentTypeVar).join(',') ?? '';
303
+ const variantId = container?.parentPermissionable?.variantId;
304
+ const maxContentlets = container?.maxContentlets ?? 0;
305
+ const path = container?.path;
306
+ return {
307
+ uuid,
308
+ variantId,
309
+ acceptTypes,
310
+ maxContentlets,
311
+ identifier: path ?? identifier
312
+ };
313
+ };
314
+ /**
315
+ *
316
+ *
317
+ * Retrieves the contentlets (content items) associated with a specific container.
318
+ * Handles different UUID formats and provides warning for missing contentlets.
319
+ *
320
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
321
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
322
+ * @returns {DotCMSContentlet[]} Array of contentlets in the container
323
+ *
324
+ * @example
325
+ * const contentlets = getContentletsInContainer(pageAsset, containerRef);
326
+ * // Returns: [{ identifier: 'cont1', ... }, { identifier: 'cont2', ... }]
327
+ */
328
+ const getContentletsInContainer = (dotCMSPageAsset, columContainer) => {
329
+ const {
330
+ identifier,
331
+ uuid
332
+ } = columContainer;
333
+ const {
334
+ contentlets
335
+ } = dotCMSPageAsset.containers[identifier];
336
+ const contentletsInContainer = contentlets[`uuid-${uuid}`] || contentlets[`uuid-dotParser_${uuid}`] || [];
337
+ if (!contentletsInContainer) {
338
+ console.warn(`We couldn't find the contentlets for the container with the identifier ${identifier} and the uuid ${uuid} becareful by adding content to this container.\nWe recommend to change the container in the layout and add the content again.`);
339
+ }
340
+ return contentletsInContainer;
341
+ };
342
+ /**
343
+ *
344
+ *
345
+ * Generates the required DotCMS data attributes for a container element.
346
+ * These attributes are used by DotCMS for container identification and functionality.
347
+ *
348
+ * @param {EditableContainerData} params - Container data including uuid, identifier, acceptTypes, and maxContentlets
349
+ * @returns {DotContainerAttributes} Object containing all necessary data attributes
350
+ *
351
+ * @example
352
+ * const attributes = getDotContainerAttributes({
353
+ * uuid: '123',
354
+ * identifier: 'cont1',
355
+ * acceptTypes: 'type1,type2',
356
+ * maxContentlets: 5
357
+ * });
358
+ * // Returns: { 'data-dot-object': 'container', 'data-dot-identifier': 'cont1', ... }
359
+ */
360
+ function getDotContainerAttributes({
361
+ uuid,
362
+ identifier,
363
+ acceptTypes,
364
+ maxContentlets
365
+ }) {
366
+ return {
367
+ 'data-dot-object': 'container',
368
+ 'data-dot-accept-types': acceptTypes,
369
+ 'data-dot-identifier': identifier,
370
+ 'data-max-contentlets': maxContentlets.toString(),
371
+ 'data-dot-uuid': uuid
372
+ };
373
+ }
213
374
 
214
375
  /**
215
376
  * Subscribes to content changes in the UVE editor
@@ -408,13 +569,84 @@ const __UVE_EVENT_ERROR_FALLBACK__ = event => {
408
569
  event
409
570
  };
410
571
  };
572
+ /**
573
+ * Development mode
574
+ *
575
+ * @internal
576
+ */
577
+ const DEVELOPMENT_MODE = 'development';
578
+ /**
579
+ * Production mode
580
+ *
581
+ * @internal
582
+ */
583
+ const PRODUCTION_MODE = 'production';
584
+ /**
585
+ * End class
586
+ *
587
+ * @internal
588
+ */
589
+ const END_CLASS = 'col-end-';
590
+ /**
591
+ * Start class
592
+ *
593
+ * @internal
594
+ */
595
+ const START_CLASS = 'col-start-';
596
+ /**
597
+ * Empty container style for React
598
+ *
599
+ * @internal
600
+ */
601
+ const EMPTY_CONTAINER_STYLE_REACT = {
602
+ width: '100%',
603
+ backgroundColor: '#ECF0FD',
604
+ display: 'flex',
605
+ justifyContent: 'center',
606
+ alignItems: 'center',
607
+ color: '#030E32',
608
+ height: '10rem'
609
+ };
610
+ /**
611
+ * Empty container style for Angular
612
+ *
613
+ * @internal
614
+ */
615
+ const EMPTY_CONTAINER_STYLE_ANGULAR = {
616
+ width: '100%',
617
+ 'background-color': '#ECF0FD',
618
+ display: 'flex',
619
+ 'justify-content': 'center',
620
+ 'align-items': 'center',
621
+ color: '#030E32',
622
+ height: '10rem'
623
+ };
624
+ /**
625
+ * Custom no component
626
+ *
627
+ * @internal
628
+ */
629
+ const CUSTOM_NO_COMPONENT = 'CustomNoComponent';
411
630
 
631
+ exports.CUSTOM_NO_COMPONENT = CUSTOM_NO_COMPONENT;
632
+ exports.DEVELOPMENT_MODE = DEVELOPMENT_MODE;
633
+ exports.EMPTY_CONTAINER_STYLE_ANGULAR = EMPTY_CONTAINER_STYLE_ANGULAR;
634
+ exports.EMPTY_CONTAINER_STYLE_REACT = EMPTY_CONTAINER_STYLE_REACT;
635
+ exports.END_CLASS = END_CLASS;
636
+ exports.PRODUCTION_MODE = PRODUCTION_MODE;
637
+ exports.START_CLASS = START_CLASS;
412
638
  exports.__UVE_EVENTS__ = __UVE_EVENTS__;
413
639
  exports.__UVE_EVENT_ERROR_FALLBACK__ = __UVE_EVENT_ERROR_FALLBACK__;
640
+ exports.combineClasses = combineClasses;
414
641
  exports.computeScrollIsInBottom = computeScrollIsInBottom;
415
642
  exports.findDotCMSElement = findDotCMSElement;
416
643
  exports.findDotCMSVTLData = findDotCMSVTLData;
417
644
  exports.getClosestDotCMSContainerData = getClosestDotCMSContainerData;
645
+ exports.getColumnPositionClasses = getColumnPositionClasses;
646
+ exports.getContainersData = getContainersData;
647
+ exports.getContentletsInContainer = getContentletsInContainer;
418
648
  exports.getDotCMSContainerData = getDotCMSContainerData;
419
649
  exports.getDotCMSContentletsBound = getDotCMSContentletsBound;
420
650
  exports.getDotCMSPageBounds = getDotCMSPageBounds;
651
+ exports.getDotContainerAttributes = getDotContainerAttributes;
652
+ exports.getDotContentletAttributes = getDotContentletAttributes;
package/internal.esm.js CHANGED
@@ -208,6 +208,167 @@ function computeScrollIsInBottom() {
208
208
  const scrollY = window.scrollY;
209
209
  return scrollY + viewportHeight >= documentHeight;
210
210
  }
211
+ /**
212
+ *
213
+ *
214
+ * Combine classes into a single string.
215
+ *
216
+ * @param {string[]} classes
217
+ * @returns {string} Combined classes
218
+ */
219
+ const combineClasses = classes => classes.filter(Boolean).join(' ');
220
+ /**
221
+ *
222
+ *
223
+ * Calculates and returns the CSS Grid positioning classes for a column based on its configuration.
224
+ * Uses a 12-column grid system where columns are positioned using grid-column-start and grid-column-end.
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * const classes = getColumnPositionClasses({
229
+ * leftOffset: 1, // Starts at the first column
230
+ * width: 6 // Spans 6 columns
231
+ * });
232
+ * // Returns: { startClass: 'col-start-1', endClass: 'col-end-7' }
233
+ * ```
234
+ *
235
+ * @param {DotPageAssetLayoutColumn} column - Column configuration object
236
+ * @param {number} column.leftOffset - Starting position (0-based) in the grid
237
+ * @param {number} column.width - Number of columns to span
238
+ * @returns {{ startClass: string, endClass: string }} Object containing CSS class names for grid positioning
239
+ */
240
+ const getColumnPositionClasses = column => {
241
+ const {
242
+ leftOffset,
243
+ width
244
+ } = column;
245
+ const startClass = `${START_CLASS}${leftOffset}`;
246
+ const endClass = `${END_CLASS}${leftOffset + width}`;
247
+ return {
248
+ startClass,
249
+ endClass
250
+ };
251
+ };
252
+ /**
253
+ *
254
+ *
255
+ * Helper function that returns an object containing the dotCMS data attributes.
256
+ * @param {DotCMSContentlet} contentlet - The contentlet to get the attributes for
257
+ * @param {string} container - The container to get the attributes for
258
+ * @returns {DotContentletAttributes} The dotCMS data attributes
259
+ */
260
+ function getDotContentletAttributes(contentlet, container) {
261
+ return {
262
+ 'data-dot-identifier': contentlet?.identifier,
263
+ 'data-dot-basetype': contentlet?.baseType,
264
+ 'data-dot-title': contentlet?.['widgetTitle'] || contentlet?.title,
265
+ 'data-dot-inode': contentlet?.inode,
266
+ 'data-dot-type': contentlet?.contentType,
267
+ 'data-dot-container': container,
268
+ 'data-dot-on-number-of-pages': contentlet?.['onNumberOfPages']
269
+ };
270
+ }
271
+ /**
272
+ *
273
+ *
274
+ * Retrieves container data from a DotCMS page asset using the container reference.
275
+ * This function processes the container information and returns a standardized format
276
+ * for container editing.
277
+ *
278
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
279
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
280
+ * @throws {Error} When page asset is invalid or container is not found
281
+ * @returns {EditableContainerData} Formatted container data for editing
282
+ *
283
+ * @example
284
+ * const containerData = getContainersData(pageAsset, containerRef);
285
+ * // Returns: { uuid: '123', identifier: 'cont1', acceptTypes: 'type1,type2', maxContentlets: 5 }
286
+ */
287
+ const getContainersData = (dotCMSPageAsset, columContainer) => {
288
+ const {
289
+ identifier,
290
+ uuid
291
+ } = columContainer;
292
+ const dotContainer = dotCMSPageAsset.containers[identifier];
293
+ if (!dotContainer) {
294
+ return null;
295
+ }
296
+ const {
297
+ containerStructures,
298
+ container
299
+ } = dotContainer;
300
+ const acceptTypes = containerStructures?.map(structure => structure.contentTypeVar).join(',') ?? '';
301
+ const variantId = container?.parentPermissionable?.variantId;
302
+ const maxContentlets = container?.maxContentlets ?? 0;
303
+ const path = container?.path;
304
+ return {
305
+ uuid,
306
+ variantId,
307
+ acceptTypes,
308
+ maxContentlets,
309
+ identifier: path ?? identifier
310
+ };
311
+ };
312
+ /**
313
+ *
314
+ *
315
+ * Retrieves the contentlets (content items) associated with a specific container.
316
+ * Handles different UUID formats and provides warning for missing contentlets.
317
+ *
318
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
319
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
320
+ * @returns {DotCMSContentlet[]} Array of contentlets in the container
321
+ *
322
+ * @example
323
+ * const contentlets = getContentletsInContainer(pageAsset, containerRef);
324
+ * // Returns: [{ identifier: 'cont1', ... }, { identifier: 'cont2', ... }]
325
+ */
326
+ const getContentletsInContainer = (dotCMSPageAsset, columContainer) => {
327
+ const {
328
+ identifier,
329
+ uuid
330
+ } = columContainer;
331
+ const {
332
+ contentlets
333
+ } = dotCMSPageAsset.containers[identifier];
334
+ const contentletsInContainer = contentlets[`uuid-${uuid}`] || contentlets[`uuid-dotParser_${uuid}`] || [];
335
+ if (!contentletsInContainer) {
336
+ console.warn(`We couldn't find the contentlets for the container with the identifier ${identifier} and the uuid ${uuid} becareful by adding content to this container.\nWe recommend to change the container in the layout and add the content again.`);
337
+ }
338
+ return contentletsInContainer;
339
+ };
340
+ /**
341
+ *
342
+ *
343
+ * Generates the required DotCMS data attributes for a container element.
344
+ * These attributes are used by DotCMS for container identification and functionality.
345
+ *
346
+ * @param {EditableContainerData} params - Container data including uuid, identifier, acceptTypes, and maxContentlets
347
+ * @returns {DotContainerAttributes} Object containing all necessary data attributes
348
+ *
349
+ * @example
350
+ * const attributes = getDotContainerAttributes({
351
+ * uuid: '123',
352
+ * identifier: 'cont1',
353
+ * acceptTypes: 'type1,type2',
354
+ * maxContentlets: 5
355
+ * });
356
+ * // Returns: { 'data-dot-object': 'container', 'data-dot-identifier': 'cont1', ... }
357
+ */
358
+ function getDotContainerAttributes({
359
+ uuid,
360
+ identifier,
361
+ acceptTypes,
362
+ maxContentlets
363
+ }) {
364
+ return {
365
+ 'data-dot-object': 'container',
366
+ 'data-dot-accept-types': acceptTypes,
367
+ 'data-dot-identifier': identifier,
368
+ 'data-max-contentlets': maxContentlets.toString(),
369
+ 'data-dot-uuid': uuid
370
+ };
371
+ }
211
372
 
212
373
  /**
213
374
  * Subscribes to content changes in the UVE editor
@@ -406,5 +567,63 @@ const __UVE_EVENT_ERROR_FALLBACK__ = event => {
406
567
  event
407
568
  };
408
569
  };
570
+ /**
571
+ * Development mode
572
+ *
573
+ * @internal
574
+ */
575
+ const DEVELOPMENT_MODE = 'development';
576
+ /**
577
+ * Production mode
578
+ *
579
+ * @internal
580
+ */
581
+ const PRODUCTION_MODE = 'production';
582
+ /**
583
+ * End class
584
+ *
585
+ * @internal
586
+ */
587
+ const END_CLASS = 'col-end-';
588
+ /**
589
+ * Start class
590
+ *
591
+ * @internal
592
+ */
593
+ const START_CLASS = 'col-start-';
594
+ /**
595
+ * Empty container style for React
596
+ *
597
+ * @internal
598
+ */
599
+ const EMPTY_CONTAINER_STYLE_REACT = {
600
+ width: '100%',
601
+ backgroundColor: '#ECF0FD',
602
+ display: 'flex',
603
+ justifyContent: 'center',
604
+ alignItems: 'center',
605
+ color: '#030E32',
606
+ height: '10rem'
607
+ };
608
+ /**
609
+ * Empty container style for Angular
610
+ *
611
+ * @internal
612
+ */
613
+ const EMPTY_CONTAINER_STYLE_ANGULAR = {
614
+ width: '100%',
615
+ 'background-color': '#ECF0FD',
616
+ display: 'flex',
617
+ 'justify-content': 'center',
618
+ 'align-items': 'center',
619
+ color: '#030E32',
620
+ height: '10rem'
621
+ };
622
+ /**
623
+ * Custom no component
624
+ *
625
+ * @internal
626
+ */
627
+ const CUSTOM_NO_COMPONENT = 'CustomNoComponent';
409
628
 
410
- export { __DOTCMS_UVE_EVENT__, __UVE_EVENTS__, __UVE_EVENT_ERROR_FALLBACK__, computeScrollIsInBottom, findDotCMSElement, findDotCMSVTLData, getClosestDotCMSContainerData, getDotCMSContainerData, getDotCMSContentletsBound, getDotCMSPageBounds };
629
+ export { CUSTOM_NO_COMPONENT, DEVELOPMENT_MODE, EMPTY_CONTAINER_STYLE_ANGULAR, EMPTY_CONTAINER_STYLE_REACT, END_CLASS, PRODUCTION_MODE, START_CLASS, __DOTCMS_UVE_EVENT__, __UVE_EVENTS__, __UVE_EVENT_ERROR_FALLBACK__, combineClasses, computeScrollIsInBottom, findDotCMSElement, findDotCMSVTLData, getClosestDotCMSContainerData, getColumnPositionClasses, getContainersData, getContentletsInContainer, getDotCMSContainerData, getDotCMSContentletsBound, getDotCMSPageBounds, getDotContainerAttributes, getDotContentletAttributes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/uve",
3
- "version": "0.0.1-beta.14",
3
+ "version": "0.0.1-beta.15",
4
4
  "description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,3 +16,61 @@ export declare const __UVE_EVENT_ERROR_FALLBACK__: (event: string) => {
16
16
  unsubscribe: () => void;
17
17
  event: string;
18
18
  };
19
+ /**
20
+ * Development mode
21
+ *
22
+ * @internal
23
+ */
24
+ export declare const DEVELOPMENT_MODE = "development";
25
+ /**
26
+ * Production mode
27
+ *
28
+ * @internal
29
+ */
30
+ export declare const PRODUCTION_MODE = "production";
31
+ /**
32
+ * End class
33
+ *
34
+ * @internal
35
+ */
36
+ export declare const END_CLASS = "col-end-";
37
+ /**
38
+ * Start class
39
+ *
40
+ * @internal
41
+ */
42
+ export declare const START_CLASS = "col-start-";
43
+ /**
44
+ * Empty container style for React
45
+ *
46
+ * @internal
47
+ */
48
+ export declare const EMPTY_CONTAINER_STYLE_REACT: {
49
+ width: string;
50
+ backgroundColor: string;
51
+ display: string;
52
+ justifyContent: string;
53
+ alignItems: string;
54
+ color: string;
55
+ height: string;
56
+ };
57
+ /**
58
+ * Empty container style for Angular
59
+ *
60
+ * @internal
61
+ */
62
+ export declare const EMPTY_CONTAINER_STYLE_ANGULAR: {
63
+ width: string;
64
+ 'background-color': string;
65
+ display: string;
66
+ 'justify-content': string;
67
+ 'align-items': string;
68
+ color: string;
69
+ height: string;
70
+ };
71
+ /**
72
+ * Custom no component
73
+ *
74
+ * @internal
75
+ */
76
+ export declare const CUSTOM_NO_COMPONENT = "CustomNoComponent";
@@ -1,4 +1,6 @@
1
1
  import { DotCMSContainerBound, DotCMSContentletBound } from '../types/editor/internal';
2
+ import { DotContainerAttributes, DotContentletAttributes, EditableContainerData } from '../types/editor/public';
3
+ import { DotCMSColumnContainer, DotCMSContentlet, DotCMSPageAsset, DotPageAssetLayoutColumn } from '../types/page/public';
2
4
  /**
3
5
  * Calculates the bounding information for each page element within the given containers.
4
6
  *
@@ -109,3 +111,96 @@ export declare function findDotCMSVTLData(target: HTMLElement): {
109
111
  * ```
110
112
  */
111
113
  export declare function computeScrollIsInBottom(): boolean;
114
+ /**
115
+ *
116
+ *
117
+ * Combine classes into a single string.
118
+ *
119
+ * @param {string[]} classes
120
+ * @returns {string} Combined classes
121
+ */
122
+ export declare const combineClasses: (classes: string[]) => string;
123
+ /**
124
+ *
125
+ *
126
+ * Calculates and returns the CSS Grid positioning classes for a column based on its configuration.
127
+ * Uses a 12-column grid system where columns are positioned using grid-column-start and grid-column-end.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const classes = getColumnPositionClasses({
132
+ * leftOffset: 1, // Starts at the first column
133
+ * width: 6 // Spans 6 columns
134
+ * });
135
+ * // Returns: { startClass: 'col-start-1', endClass: 'col-end-7' }
136
+ * ```
137
+ *
138
+ * @param {DotPageAssetLayoutColumn} column - Column configuration object
139
+ * @param {number} column.leftOffset - Starting position (0-based) in the grid
140
+ * @param {number} column.width - Number of columns to span
141
+ * @returns {{ startClass: string, endClass: string }} Object containing CSS class names for grid positioning
142
+ */
143
+ export declare const getColumnPositionClasses: (column: DotPageAssetLayoutColumn) => {
144
+ startClass: string;
145
+ endClass: string;
146
+ };
147
+ /**
148
+ *
149
+ *
150
+ * Helper function that returns an object containing the dotCMS data attributes.
151
+ * @param {DotCMSContentlet} contentlet - The contentlet to get the attributes for
152
+ * @param {string} container - The container to get the attributes for
153
+ * @returns {DotContentletAttributes} The dotCMS data attributes
154
+ */
155
+ export declare function getDotContentletAttributes(contentlet: DotCMSContentlet, container: string): DotContentletAttributes;
156
+ /**
157
+ *
158
+ *
159
+ * Retrieves container data from a DotCMS page asset using the container reference.
160
+ * This function processes the container information and returns a standardized format
161
+ * for container editing.
162
+ *
163
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
164
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
165
+ * @throws {Error} When page asset is invalid or container is not found
166
+ * @returns {EditableContainerData} Formatted container data for editing
167
+ *
168
+ * @example
169
+ * const containerData = getContainersData(pageAsset, containerRef);
170
+ * // Returns: { uuid: '123', identifier: 'cont1', acceptTypes: 'type1,type2', maxContentlets: 5 }
171
+ */
172
+ export declare const getContainersData: (dotCMSPageAsset: DotCMSPageAsset, columContainer: DotCMSColumnContainer) => EditableContainerData | null;
173
+ /**
174
+ *
175
+ *
176
+ * Retrieves the contentlets (content items) associated with a specific container.
177
+ * Handles different UUID formats and provides warning for missing contentlets.
178
+ *
179
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
180
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
181
+ * @returns {DotCMSContentlet[]} Array of contentlets in the container
182
+ *
183
+ * @example
184
+ * const contentlets = getContentletsInContainer(pageAsset, containerRef);
185
+ * // Returns: [{ identifier: 'cont1', ... }, { identifier: 'cont2', ... }]
186
+ */
187
+ export declare const getContentletsInContainer: (dotCMSPageAsset: DotCMSPageAsset, columContainer: DotCMSColumnContainer) => DotCMSContentlet[];
188
+ /**
189
+ *
190
+ *
191
+ * Generates the required DotCMS data attributes for a container element.
192
+ * These attributes are used by DotCMS for container identification and functionality.
193
+ *
194
+ * @param {EditableContainerData} params - Container data including uuid, identifier, acceptTypes, and maxContentlets
195
+ * @returns {DotContainerAttributes} Object containing all necessary data attributes
196
+ *
197
+ * @example
198
+ * const attributes = getDotContainerAttributes({
199
+ * uuid: '123',
200
+ * identifier: 'cont1',
201
+ * acceptTypes: 'type1,type2',
202
+ * maxContentlets: 5
203
+ * });
204
+ * // Returns: { 'data-dot-object': 'container', 'data-dot-identifier': 'cont1', ... }
205
+ */
206
+ export declare function getDotContainerAttributes({ uuid, identifier, acceptTypes, maxContentlets }: EditableContainerData): DotContainerAttributes;
@@ -1,4 +1,5 @@
1
1
  import { ContentTypeMainFields, DotCMSContainerBound } from './internal';
2
+ import { DEVELOPMENT_MODE, PRODUCTION_MODE } from '../../../internal';
2
3
  /**
3
4
  * Represents the state of the Universal Visual Editor (UVE)
4
5
  * @interface
@@ -17,6 +18,11 @@ export interface UVEState {
17
18
  publishDate: string | null;
18
19
  languageId: string | null;
19
20
  }
21
+ /**
22
+ * The mode of the page renderer component
23
+ * @enum {string}
24
+ */
25
+ export type DotCMSPageRendererMode = typeof PRODUCTION_MODE | typeof DEVELOPMENT_MODE;
20
26
  /**
21
27
  * Possible modes of UVE (Universal Visual Editor)
22
28
  * @enum {string}
@@ -179,3 +185,41 @@ export type UVEEventPayloadMap = {
179
185
  [UVEEventType.IFRAME_SCROLL]: 'up' | 'down';
180
186
  [UVEEventType.CONTENTLET_HOVERED]: unknown;
181
187
  };
188
+ /**
189
+ *
190
+ * Interface representing the data needed for container editing
191
+ * @interface EditableContainerData
192
+ */
193
+ export interface EditableContainerData {
194
+ uuid: string;
195
+ identifier: string;
196
+ acceptTypes: string;
197
+ maxContentlets: number;
198
+ variantId?: string;
199
+ }
200
+ /**
201
+ *
202
+ * Interface representing the data attributes of a DotCMS container.
203
+ * @interface DotContainerAttributes
204
+ */
205
+ export interface DotContainerAttributes {
206
+ 'data-dot-object': string;
207
+ 'data-dot-accept-types': string;
208
+ 'data-dot-identifier': string;
209
+ 'data-max-contentlets': string;
210
+ 'data-dot-uuid': string;
211
+ }
212
+ /**
213
+ *
214
+ * Interface representing the data attributes of a DotCMS contentlet.
215
+ * @interface DotContentletAttributes
216
+ */
217
+ export interface DotContentletAttributes {
218
+ 'data-dot-identifier': string;
219
+ 'data-dot-basetype': string;
220
+ 'data-dot-title': string;
221
+ 'data-dot-inode': string;
222
+ 'data-dot-type': string;
223
+ 'data-dot-container': string;
224
+ 'data-dot-on-number-of-pages': string;
225
+ }
@@ -0,0 +1,421 @@
1
+ export interface DotCMSPageAsset {
2
+ canCreateTemplate?: boolean;
3
+ containers: {
4
+ [key: string]: DotCMSPageAssetContainer;
5
+ };
6
+ layout: DotCMSLayout;
7
+ page: DotCMSPage;
8
+ site: DotCMSSite;
9
+ template: DotCMSTemplate;
10
+ viewAs?: DotCMSViewAs;
11
+ vanityUrl?: DotCMSVanityUrl;
12
+ }
13
+ export interface DotPageAssetLayoutRow {
14
+ identifier: number;
15
+ value?: string;
16
+ id?: string;
17
+ columns: DotPageAssetLayoutColumn[];
18
+ styleClass?: string;
19
+ }
20
+ export interface DotCMSVanityUrl {
21
+ pattern: string;
22
+ vanityUrlId: string;
23
+ url: string;
24
+ siteId: string;
25
+ languageId: number;
26
+ forwardTo: string;
27
+ response: number;
28
+ order: number;
29
+ temporaryRedirect: boolean;
30
+ permanentRedirect: boolean;
31
+ forward: boolean;
32
+ }
33
+ export interface DotPageAssetLayoutColumn {
34
+ preview: boolean;
35
+ containers: DotCMSColumnContainer[];
36
+ widthPercent: number;
37
+ width: number;
38
+ leftOffset: number;
39
+ left: number;
40
+ styleClass?: string;
41
+ }
42
+ export interface DotCMSColumnContainer {
43
+ identifier: string;
44
+ uuid: string;
45
+ historyUUIDs: string[];
46
+ }
47
+ export interface DotCMSPageAssetContainer {
48
+ container: DotCMSContainer;
49
+ containerStructures: DotCMSContainerStructure[];
50
+ contentlets: {
51
+ [key: string]: DotCMSContentlet[];
52
+ };
53
+ }
54
+ export interface DotCMSContainer {
55
+ identifier: string;
56
+ uuid: string;
57
+ iDate: number;
58
+ type: string;
59
+ owner?: string;
60
+ inode: string;
61
+ source: string;
62
+ title: string;
63
+ friendlyName: string;
64
+ modDate: number;
65
+ modUser: string;
66
+ sortOrder: number;
67
+ showOnMenu: boolean;
68
+ code?: string;
69
+ maxContentlets: number;
70
+ useDiv: boolean;
71
+ sortContentletsBy?: string;
72
+ preLoop: string;
73
+ postLoop: string;
74
+ staticify: boolean;
75
+ luceneQuery?: string;
76
+ notes: string;
77
+ languageId?: number;
78
+ path?: string;
79
+ live: boolean;
80
+ locked: boolean;
81
+ working: boolean;
82
+ deleted: boolean;
83
+ name: string;
84
+ archived: boolean;
85
+ permissionId: string;
86
+ versionId: string;
87
+ versionType: string;
88
+ permissionType: string;
89
+ categoryId: string;
90
+ idate: number;
91
+ new: boolean;
92
+ acceptTypes: string;
93
+ contentlets: DotCMSContentlet[];
94
+ parentPermissionable: DotCMSSiteParentPermissionable;
95
+ }
96
+ export interface DotCMSContentlet {
97
+ archived: boolean;
98
+ baseType: string;
99
+ deleted?: boolean;
100
+ binary?: string;
101
+ binaryContentAsset?: string;
102
+ binaryVersion?: string;
103
+ contentType: string;
104
+ file?: string;
105
+ folder: string;
106
+ hasLiveVersion?: boolean;
107
+ hasTitleImage: boolean;
108
+ host: string;
109
+ hostName: string;
110
+ identifier: string;
111
+ inode: string;
112
+ image?: any;
113
+ languageId: number;
114
+ language?: string;
115
+ live: boolean;
116
+ locked: boolean;
117
+ mimeType?: string;
118
+ modDate: string;
119
+ modUser: string;
120
+ modUserName: string;
121
+ owner: string;
122
+ sortOrder: number;
123
+ stInode: string;
124
+ title: string;
125
+ titleImage: string;
126
+ text?: string;
127
+ url: string;
128
+ working: boolean;
129
+ body?: string;
130
+ contentTypeIcon?: string;
131
+ variant?: string;
132
+ __icon__?: string;
133
+ [key: string]: any;
134
+ }
135
+ export interface DotcmsNavigationItem {
136
+ code?: any;
137
+ folder: string;
138
+ children?: DotcmsNavigationItem[];
139
+ host: string;
140
+ languageId: number;
141
+ href: string;
142
+ title: string;
143
+ type: string;
144
+ hash: number;
145
+ target: string;
146
+ order: number;
147
+ }
148
+ interface DotCMSTemplate {
149
+ iDate: number;
150
+ type: string;
151
+ owner: string;
152
+ inode: string;
153
+ identifier: string;
154
+ source: string;
155
+ title: string;
156
+ friendlyName: string;
157
+ modDate: number;
158
+ modUser: string;
159
+ sortOrder: number;
160
+ showOnMenu: boolean;
161
+ image: string;
162
+ drawed: boolean;
163
+ drawedBody: string;
164
+ theme: string;
165
+ anonymous: boolean;
166
+ template: boolean;
167
+ name: string;
168
+ live: boolean;
169
+ archived: boolean;
170
+ locked: boolean;
171
+ working: boolean;
172
+ permissionId: string;
173
+ versionId: string;
174
+ versionType: string;
175
+ deleted: boolean;
176
+ permissionType: string;
177
+ categoryId: string;
178
+ idate: number;
179
+ new: boolean;
180
+ canEdit: boolean;
181
+ }
182
+ interface DotCMSPage {
183
+ template: string;
184
+ modDate: number;
185
+ metadata: string;
186
+ cachettl: string;
187
+ pageURI: string;
188
+ title: string;
189
+ type: string;
190
+ showOnMenu: string;
191
+ httpsRequired: boolean;
192
+ inode: string;
193
+ disabledWYSIWYG: any[];
194
+ seokeywords: string;
195
+ host: string;
196
+ lastReview: number;
197
+ working: boolean;
198
+ locked: boolean;
199
+ stInode: string;
200
+ friendlyName: string;
201
+ live: boolean;
202
+ owner: string;
203
+ identifier: string;
204
+ nullProperties: any[];
205
+ friendlyname: string;
206
+ pagemetadata: string;
207
+ languageId: number;
208
+ url: string;
209
+ seodescription: string;
210
+ modUserName: string;
211
+ folder: string;
212
+ deleted: boolean;
213
+ sortOrder: number;
214
+ modUser: string;
215
+ pageUrl: string;
216
+ workingInode: string;
217
+ shortyWorking: string;
218
+ canEdit: boolean;
219
+ canRead: boolean;
220
+ canLock: boolean;
221
+ lockedOn: number;
222
+ lockedBy: string;
223
+ lockedByName: string;
224
+ liveInode: string;
225
+ shortyLive: string;
226
+ }
227
+ interface DotCMSViewAs {
228
+ language: {
229
+ id: number;
230
+ languageCode: string;
231
+ countryCode: string;
232
+ language: string;
233
+ country: string;
234
+ };
235
+ mode: string;
236
+ }
237
+ interface DotCMSLayout {
238
+ pageWidth: string;
239
+ width: string;
240
+ layout: string;
241
+ title: string;
242
+ header: boolean;
243
+ footer: boolean;
244
+ body: DotPageAssetLayoutBody;
245
+ sidebar: DotPageAssetLayoutSidebar;
246
+ }
247
+ interface DotCMSContainerStructure {
248
+ id: string;
249
+ structureId: string;
250
+ containerInode: string;
251
+ containerId: string;
252
+ code: string;
253
+ contentTypeVar: string;
254
+ }
255
+ interface DotPageAssetLayoutSidebar {
256
+ preview: boolean;
257
+ containers: DotCMSContainer[];
258
+ location: string;
259
+ widthPercent: number;
260
+ width: string;
261
+ }
262
+ interface DotPageAssetLayoutBody {
263
+ rows: DotPageAssetLayoutRow[];
264
+ }
265
+ interface DotCMSSite {
266
+ lowIndexPriority: boolean;
267
+ name: string;
268
+ default: boolean;
269
+ aliases: string;
270
+ parent: boolean;
271
+ tagStorage: string;
272
+ systemHost: boolean;
273
+ inode: string;
274
+ versionType: string;
275
+ structureInode: string;
276
+ hostname: string;
277
+ hostThumbnail?: any;
278
+ owner: string;
279
+ permissionId: string;
280
+ permissionType: string;
281
+ type: string;
282
+ identifier: string;
283
+ modDate: number;
284
+ host: string;
285
+ live: boolean;
286
+ indexPolicy: string;
287
+ categoryId: string;
288
+ actionId?: any;
289
+ new: boolean;
290
+ archived: boolean;
291
+ locked: boolean;
292
+ disabledWysiwyg: any[];
293
+ modUser: string;
294
+ working: boolean;
295
+ titleImage: {
296
+ present: boolean;
297
+ };
298
+ folder: string;
299
+ htmlpage: boolean;
300
+ fileAsset: boolean;
301
+ vanityUrl: boolean;
302
+ keyValue: boolean;
303
+ structure?: DotCMSSiteStructure;
304
+ title: string;
305
+ languageId: number;
306
+ indexPolicyDependencies: string;
307
+ contentTypeId: string;
308
+ versionId: string;
309
+ lastReview: number;
310
+ nextReview?: any;
311
+ reviewInterval?: any;
312
+ sortOrder: number;
313
+ contentType: DotCMSSiteContentType;
314
+ }
315
+ interface DotCMSSiteContentType {
316
+ owner?: any;
317
+ parentPermissionable: DotCMSSiteParentPermissionable;
318
+ permissionId: string;
319
+ permissionType: string;
320
+ }
321
+ export interface DotCMSSiteParentPermissionable {
322
+ Inode: string;
323
+ Identifier: string;
324
+ permissionByIdentifier: boolean;
325
+ type: string;
326
+ owner?: any;
327
+ identifier: string;
328
+ permissionId: string;
329
+ parentPermissionable?: any;
330
+ permissionType: string;
331
+ inode: string;
332
+ childrenPermissionable?: any;
333
+ variantId?: string;
334
+ }
335
+ interface DotCMSSiteStructure {
336
+ iDate: number;
337
+ type: string;
338
+ owner?: any;
339
+ inode: string;
340
+ identifier: string;
341
+ name: string;
342
+ description: string;
343
+ defaultStructure: boolean;
344
+ reviewInterval?: any;
345
+ reviewerRole?: any;
346
+ pagedetail?: any;
347
+ structureType: number;
348
+ fixed: boolean;
349
+ system: boolean;
350
+ velocityVarName: string;
351
+ urlMapPattern?: any;
352
+ host: string;
353
+ folder: string;
354
+ publishDateVar?: any;
355
+ expireDateVar?: any;
356
+ modDate: number;
357
+ fields: DotCMSSiteField[];
358
+ widget: boolean;
359
+ detailPage?: any;
360
+ fieldsBySortOrder: DotCMSSiteField[];
361
+ form: boolean;
362
+ htmlpageAsset: boolean;
363
+ content: boolean;
364
+ fileAsset: boolean;
365
+ persona: boolean;
366
+ permissionId: string;
367
+ permissionType: string;
368
+ live: boolean;
369
+ categoryId: string;
370
+ idate: number;
371
+ new: boolean;
372
+ archived: boolean;
373
+ locked: boolean;
374
+ modUser: string;
375
+ working: boolean;
376
+ title: string;
377
+ versionId: string;
378
+ versionType: string;
379
+ }
380
+ interface DotCMSSiteField {
381
+ iDate: number;
382
+ type: string;
383
+ owner?: any;
384
+ inode: string;
385
+ identifier: string;
386
+ structureInode: string;
387
+ fieldName: string;
388
+ fieldType: string;
389
+ fieldRelationType?: any;
390
+ fieldContentlet: string;
391
+ required: boolean;
392
+ velocityVarName: string;
393
+ sortOrder: number;
394
+ values?: any;
395
+ regexCheck?: any;
396
+ hint?: any;
397
+ defaultValue?: any;
398
+ indexed: boolean;
399
+ listed: boolean;
400
+ fixed: boolean;
401
+ readOnly: boolean;
402
+ searchable: boolean;
403
+ unique: boolean;
404
+ modDate: number;
405
+ dataType: string;
406
+ live: boolean;
407
+ categoryId: string;
408
+ idate: number;
409
+ new: boolean;
410
+ archived: boolean;
411
+ locked: boolean;
412
+ modUser: string;
413
+ working: boolean;
414
+ permissionId: string;
415
+ parentPermissionable?: any;
416
+ permissionType: string;
417
+ title: string;
418
+ versionId: string;
419
+ versionType: string;
420
+ }
421
+ export {};
package/src/types.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './lib/types/editor/public';
2
2
  export * from './lib/types/events/public';
3
+ export * from './lib/types/page/public';