@dotcms/uve 0.0.1-beta.20 → 0.0.1-beta.22

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/index.cjs2.js CHANGED
@@ -470,9 +470,10 @@ function registerUVEEvents() {
470
470
  * This is typically called after all UVE event handlers and DOM listeners
471
471
  * have been set up successfully.
472
472
  */
473
- function setClientIsReady() {
473
+ function setClientIsReady(config) {
474
474
  sendMessageToUVE({
475
- action: types.DotCMSUVEAction.CLIENT_READY
475
+ action: types.DotCMSUVEAction.CLIENT_READY,
476
+ payload: config
476
477
  });
477
478
  }
478
479
  /**
@@ -620,9 +621,9 @@ function initInlineEditing(type, data) {
620
621
  * destroyUVESubscriptions();
621
622
  * ```
622
623
  */
623
- function initUVE() {
624
+ function initUVE(config = {}) {
624
625
  addClassToEmptyContentlets();
625
- setClientIsReady();
626
+ setClientIsReady(config);
626
627
  const {
627
628
  subscriptions
628
629
  } = registerUVEEvents();
package/index.esm2.js CHANGED
@@ -468,9 +468,10 @@ function registerUVEEvents() {
468
468
  * This is typically called after all UVE event handlers and DOM listeners
469
469
  * have been set up successfully.
470
470
  */
471
- function setClientIsReady() {
471
+ function setClientIsReady(config) {
472
472
  sendMessageToUVE({
473
- action: DotCMSUVEAction.CLIENT_READY
473
+ action: DotCMSUVEAction.CLIENT_READY,
474
+ payload: config
474
475
  });
475
476
  }
476
477
  /**
@@ -618,9 +619,9 @@ function initInlineEditing(type, data) {
618
619
  * destroyUVESubscriptions();
619
620
  * ```
620
621
  */
621
- function initUVE() {
622
+ function initUVE(config = {}) {
622
623
  addClassToEmptyContentlets();
623
- setClientIsReady();
624
+ setClientIsReady(config);
624
625
  const {
625
626
  subscriptions
626
627
  } = registerUVEEvents();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/uve",
3
- "version": "0.0.1-beta.20",
3
+ "version": "0.0.1-beta.22",
4
4
  "description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  import { DotCMSReorderMenuConfig, DotCMSUVEMessage } from '../types/editor/internal';
2
- import { Contentlet } from '../types/editor/public';
2
+ import { Contentlet, DotCMSUVEConfig } from '../types/editor/public';
3
3
  import { DotCMSInlineEditingPayload, DotCMSInlineEditingType } from '../types/events/public';
4
4
  /**
5
5
  * Post message to dotcms page editor
@@ -57,6 +57,6 @@ export declare function initInlineEditing(type: DotCMSInlineEditingType, data?:
57
57
  * destroyUVESubscriptions();
58
58
  * ```
59
59
  */
60
- export declare function initUVE(): {
60
+ export declare function initUVE(config?: DotCMSUVEConfig): {
61
61
  destroyUVESubscriptions: () => void;
62
62
  };
@@ -1,5 +1,6 @@
1
1
  import { ContentTypeMainFields, DotCMSContainerBound } from './internal';
2
2
  import { DEVELOPMENT_MODE, PRODUCTION_MODE } from '../../../internal';
3
+ import { DotCMSBasicGraphQLPage, DotCMSPageAsset } from '../page/public';
3
4
  /**
4
5
  * Represents the state of the Universal Visual Editor (UVE)
5
6
  * @interface
@@ -179,7 +180,7 @@ export declare enum UVEEventType {
179
180
  * Type definitions for each event's payload
180
181
  */
181
182
  export type UVEEventPayloadMap = {
182
- [UVEEventType.CONTENT_CHANGES]: unknown;
183
+ [UVEEventType.CONTENT_CHANGES]: DotCMSEditablePage;
183
184
  [UVEEventType.PAGE_RELOAD]: undefined;
184
185
  [UVEEventType.REQUEST_BOUNDS]: DotCMSContainerBound[];
185
186
  [UVEEventType.IFRAME_SCROLL]: 'up' | 'down';
@@ -223,3 +224,48 @@ export interface DotContentletAttributes {
223
224
  'data-dot-container': string;
224
225
  'data-dot-on-number-of-pages': string;
225
226
  }
227
+ /**
228
+ * Represents a GraphQL error
229
+ * @interface DotCMSGraphQLError
230
+ */
231
+ export interface DotCMSGraphQLError {
232
+ message: string;
233
+ locations: {
234
+ line: number;
235
+ column: number;
236
+ }[];
237
+ extensions: {
238
+ classification: string;
239
+ };
240
+ }
241
+ /**
242
+ * Represents the complete response from a GraphQL page query
243
+ *
244
+ * @template TContent - The type of the content data
245
+ * @template TNav - The type of the navigation data
246
+ */
247
+ export interface DotCMSGraphQLPageResponse<TContent = Record<string, any>> {
248
+ page: DotCMSBasicGraphQLPage;
249
+ content?: TContent;
250
+ errors?: DotCMSGraphQLError;
251
+ graphql: {
252
+ query: string;
253
+ variables: Record<string, unknown>;
254
+ };
255
+ }
256
+ /**
257
+ * Payload for initializing the UVE
258
+ * @interface DotCMSEditablePage
259
+ */
260
+ export type DotCMSEditablePage = DotCMSGraphQLPageResponse | DotCMSPageAsset;
261
+ /**
262
+ * Configuration for the UVE
263
+ * @interface DotCMSUVEConfig
264
+ */
265
+ export interface DotCMSUVEConfig {
266
+ graphql?: {
267
+ query: string;
268
+ variables: Record<string, unknown>;
269
+ };
270
+ params?: Record<string, unknown>;
271
+ }
@@ -9,6 +9,7 @@ export interface DotCMSPageAsset {
9
9
  template: DotCMSTemplate;
10
10
  viewAs?: DotCMSViewAs;
11
11
  vanityUrl?: DotCMSVanityUrl;
12
+ params?: Record<string, unknown>;
12
13
  }
13
14
  export interface DotPageAssetLayoutRow {
14
15
  identifier: number;
@@ -418,4 +419,67 @@ interface DotCMSSiteField {
418
419
  versionId: string;
419
420
  versionType: string;
420
421
  }
422
+ /**
423
+ * Represents a basic page structure returned from GraphQL queries
424
+ */
425
+ export interface DotCMSBasicGraphQLPage {
426
+ publishDate: string;
427
+ type: string;
428
+ httpsRequired: boolean;
429
+ inode: string;
430
+ path: string;
431
+ identifier: string;
432
+ hasTitleImage: boolean;
433
+ sortOrder: number;
434
+ extension: string;
435
+ canRead: boolean;
436
+ pageURI: string;
437
+ canEdit: boolean;
438
+ archived: boolean;
439
+ friendlyName: string;
440
+ workingInode: string;
441
+ url: string;
442
+ hasLiveVersion: boolean;
443
+ deleted: boolean;
444
+ pageUrl: string;
445
+ shortyWorking: string;
446
+ mimeType: string;
447
+ locked: boolean;
448
+ stInode: string;
449
+ contentType: string;
450
+ creationDate: string;
451
+ liveInode: string;
452
+ name: string;
453
+ shortyLive: string;
454
+ modDate: string;
455
+ title: string;
456
+ baseType: string;
457
+ working: boolean;
458
+ canLock: boolean;
459
+ live: boolean;
460
+ isContentlet: boolean;
461
+ statusIcons: string;
462
+ conLanguage: {
463
+ id: number;
464
+ language: string;
465
+ languageCode: string;
466
+ };
467
+ template: {
468
+ drawed: boolean;
469
+ };
470
+ containers: {
471
+ path?: string;
472
+ identifier: string;
473
+ maxContentlets?: number;
474
+ containerStructures?: {
475
+ contentTypeVar: string;
476
+ }[];
477
+ containerContentlets?: {
478
+ uuid: string;
479
+ contentlets: DotCMSContentlet[];
480
+ }[];
481
+ };
482
+ layout: DotCMSLayout;
483
+ viewAs: DotCMSViewAs;
484
+ }
421
485
  export {};
@@ -1,3 +1,4 @@
1
+ import { DotCMSUVEConfig } from '../lib/types/editor/public';
1
2
  /**
2
3
  * Sets up scroll event handlers for the window to notify the editor about scroll events.
3
4
  * Adds listeners for both 'scroll' and 'scrollend' events, sending appropriate messages
@@ -43,7 +44,7 @@ export declare function registerUVEEvents(): {
43
44
  * This is typically called after all UVE event handlers and DOM listeners
44
45
  * have been set up successfully.
45
46
  */
46
- export declare function setClientIsReady(): void;
47
+ export declare function setClientIsReady(config?: DotCMSUVEConfig): void;
47
48
  /**
48
49
  * Listen for block editor inline event.
49
50
  */