@dotcms/uve 0.0.1-beta.0 → 0.0.1-beta.10

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.cjs.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./src/public/index";
1
+ export * from "./src/index";
package/index.cjs.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var types = require('./types.cjs.js');
4
+ var internal = require('./internal.cjs.js');
4
5
 
5
6
  /**
6
7
  * Gets the current state of the Universal Visual Editor (UVE).
@@ -31,28 +32,55 @@ var types = require('./types.cjs.js');
31
32
  * ```
32
33
  */
33
34
  function getUVEState() {
34
- if (typeof window === 'undefined' || window.parent === window || !window.location) {
35
- return;
36
- }
37
- const url = new URL(window.location.href);
38
- const possibleModes = Object.values(types.UVE_MODE);
39
- let mode = url.searchParams.get('mode') ?? types.UVE_MODE.EDIT;
40
- const languageId = url.searchParams.get('language_id');
41
- const persona = url.searchParams.get('personaId');
42
- const variantName = url.searchParams.get('variantName');
43
- const experimentId = url.searchParams.get('experimentId');
44
- const publishDate = url.searchParams.get('publishDate');
45
- if (!possibleModes.includes(mode)) {
46
- mode = types.UVE_MODE.EDIT;
47
- }
48
- return {
49
- mode,
50
- languageId,
51
- persona,
52
- variantName,
53
- experimentId,
54
- publishDate
55
- };
35
+ if (typeof window === 'undefined' || window.parent === window || !window.location) {
36
+ return;
37
+ }
38
+ const url = new URL(window.location.href);
39
+ const possibleModes = Object.values(types.UVE_MODE);
40
+ let mode = url.searchParams.get('mode') ?? types.UVE_MODE.EDIT;
41
+ const languageId = url.searchParams.get('language_id');
42
+ const persona = url.searchParams.get('personaId');
43
+ const variantName = url.searchParams.get('variantName');
44
+ const experimentId = url.searchParams.get('experimentId');
45
+ const publishDate = url.searchParams.get('publishDate');
46
+ if (!possibleModes.includes(mode)) {
47
+ mode = types.UVE_MODE.EDIT;
48
+ }
49
+ return {
50
+ mode,
51
+ languageId,
52
+ persona,
53
+ variantName,
54
+ experimentId,
55
+ publishDate
56
+ };
57
+ }
58
+ /**
59
+ * Creates a subscription to a UVE event.
60
+ *
61
+ * @param {string} event - The event to subscribe to.
62
+ * @param {UVECallback} callback - The callback to call when the event is triggered.
63
+ * @return {UnsubscribeUVE | undefined} The unsubscribe function if the event is valid, undefined otherwise.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const unsubscribeChanges = createUVESubscription('changes', (payload) => {
68
+ * console.log(payload);
69
+ * });
70
+ * ```
71
+ */
72
+ function createUVESubscription(event, callback) {
73
+ if (!getUVEState()) {
74
+ console.warn('UVE Subscription: Not running inside UVE');
75
+ return internal.__UVE_EVENT_ERROR_FALLBACK__(event);
76
+ }
77
+ const eventCallback = internal.__UVE_EVENTS__[event];
78
+ if (!eventCallback) {
79
+ console.error(`UVE Subscription: Event ${event} not found`);
80
+ return internal.__UVE_EVENT_ERROR_FALLBACK__(event);
81
+ }
82
+ return eventCallback(callback);
56
83
  }
57
84
 
85
+ exports.createUVESubscription = createUVESubscription;
58
86
  exports.getUVEState = getUVEState;
package/index.esm.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./src/public/index";
1
+ export * from "./src/index";
package/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { UVE_MODE } from './types.esm.js';
2
+ import { __UVE_EVENT_ERROR_FALLBACK__, __UVE_EVENTS__ } from './internal.esm.js';
2
3
 
3
4
  /**
4
5
  * Gets the current state of the Universal Visual Editor (UVE).
@@ -29,28 +30,54 @@ import { UVE_MODE } from './types.esm.js';
29
30
  * ```
30
31
  */
31
32
  function getUVEState() {
32
- if (typeof window === 'undefined' || window.parent === window || !window.location) {
33
- return;
34
- }
35
- const url = new URL(window.location.href);
36
- const possibleModes = Object.values(UVE_MODE);
37
- let mode = url.searchParams.get('mode') ?? UVE_MODE.EDIT;
38
- const languageId = url.searchParams.get('language_id');
39
- const persona = url.searchParams.get('personaId');
40
- const variantName = url.searchParams.get('variantName');
41
- const experimentId = url.searchParams.get('experimentId');
42
- const publishDate = url.searchParams.get('publishDate');
43
- if (!possibleModes.includes(mode)) {
44
- mode = UVE_MODE.EDIT;
45
- }
46
- return {
47
- mode,
48
- languageId,
49
- persona,
50
- variantName,
51
- experimentId,
52
- publishDate
53
- };
33
+ if (typeof window === 'undefined' || window.parent === window || !window.location) {
34
+ return;
35
+ }
36
+ const url = new URL(window.location.href);
37
+ const possibleModes = Object.values(UVE_MODE);
38
+ let mode = url.searchParams.get('mode') ?? UVE_MODE.EDIT;
39
+ const languageId = url.searchParams.get('language_id');
40
+ const persona = url.searchParams.get('personaId');
41
+ const variantName = url.searchParams.get('variantName');
42
+ const experimentId = url.searchParams.get('experimentId');
43
+ const publishDate = url.searchParams.get('publishDate');
44
+ if (!possibleModes.includes(mode)) {
45
+ mode = UVE_MODE.EDIT;
46
+ }
47
+ return {
48
+ mode,
49
+ languageId,
50
+ persona,
51
+ variantName,
52
+ experimentId,
53
+ publishDate
54
+ };
55
+ }
56
+ /**
57
+ * Creates a subscription to a UVE event.
58
+ *
59
+ * @param {string} event - The event to subscribe to.
60
+ * @param {UVECallback} callback - The callback to call when the event is triggered.
61
+ * @return {UnsubscribeUVE | undefined} The unsubscribe function if the event is valid, undefined otherwise.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const unsubscribeChanges = createUVESubscription('changes', (payload) => {
66
+ * console.log(payload);
67
+ * });
68
+ * ```
69
+ */
70
+ function createUVESubscription(event, callback) {
71
+ if (!getUVEState()) {
72
+ console.warn('UVE Subscription: Not running inside UVE');
73
+ return __UVE_EVENT_ERROR_FALLBACK__(event);
74
+ }
75
+ const eventCallback = __UVE_EVENTS__[event];
76
+ if (!eventCallback) {
77
+ console.error(`UVE Subscription: Event ${event} not found`);
78
+ return __UVE_EVENT_ERROR_FALLBACK__(event);
79
+ }
80
+ return eventCallback(callback);
54
81
  }
55
82
 
56
- export { getUVEState };
83
+ export { createUVESubscription, getUVEState };
@@ -0,0 +1 @@
1
+ export * from "./src/internal";
@@ -0,0 +1 @@
1
+ exports._default = require('./internal.cjs.js').default;
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Actions received from the dotcms editor
5
+ *
6
+ * @export
7
+ * @enum {number}
8
+ */
9
+ exports.__DOTCMS_UVE_EVENT__ = void 0;
10
+ (function (__DOTCMS_UVE_EVENT__) {
11
+ /**
12
+ * Request to page to reload
13
+ */
14
+ __DOTCMS_UVE_EVENT__["UVE_RELOAD_PAGE"] = "uve-reload-page";
15
+ /**
16
+ * Request the bounds for the elements
17
+ */
18
+ __DOTCMS_UVE_EVENT__["UVE_REQUEST_BOUNDS"] = "uve-request-bounds";
19
+ /**
20
+ * Received pong from the editor
21
+ */
22
+ __DOTCMS_UVE_EVENT__["UVE_EDITOR_PONG"] = "uve-editor-pong";
23
+ /**
24
+ * Received scroll event trigger from the editor
25
+ */
26
+ __DOTCMS_UVE_EVENT__["UVE_SCROLL_INSIDE_IFRAME"] = "uve-scroll-inside-iframe";
27
+ /**
28
+ * Set the page data
29
+ */
30
+ __DOTCMS_UVE_EVENT__["UVE_SET_PAGE_DATA"] = "uve-set-page-data";
31
+ /**
32
+ * Copy contentlet inline editing success
33
+ */
34
+ __DOTCMS_UVE_EVENT__["UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS"] = "uve-copy-contentlet-inline-editing-success";
35
+ })(exports.__DOTCMS_UVE_EVENT__ || (exports.__DOTCMS_UVE_EVENT__ = {}));
36
+
37
+ // TODO: WE NEED TO LOOK FOR ALL THE NOTIFY_CLIENT EVENTS AND ADD THEM TO THE UVE_EVENTS CONSTANT WHEN WE MIGRATE THE EDITOR TO THE NEW UVE LIBRARY
38
+ /**
39
+ * Events that can be subscribed to in the UVE
40
+ *
41
+ * @internal
42
+ * @type {Record<string, UVEEvent>}
43
+ */
44
+ const __UVE_EVENTS__ = {
45
+ changes: callback => {
46
+ const messageCallback = event => {
47
+ if (event.data.name === exports.__DOTCMS_UVE_EVENT__.UVE_SET_PAGE_DATA) {
48
+ callback(event.data.payload);
49
+ }
50
+ };
51
+ window.addEventListener('message', messageCallback);
52
+ return {
53
+ unsubscribe: () => {
54
+ window.removeEventListener('message', messageCallback);
55
+ },
56
+ event: 'changes'
57
+ };
58
+ }
59
+ };
60
+ /**
61
+ * Default UVE event
62
+ *
63
+ * @param {string} event - The event to subscribe to.
64
+ * @internal
65
+ */
66
+ const __UVE_EVENT_ERROR_FALLBACK__ = event => {
67
+ return {
68
+ unsubscribe: () => {
69
+ /* do nothing */
70
+ },
71
+ event
72
+ };
73
+ };
74
+
75
+ exports.__UVE_EVENTS__ = __UVE_EVENTS__;
76
+ exports.__UVE_EVENT_ERROR_FALLBACK__ = __UVE_EVENT_ERROR_FALLBACK__;
@@ -0,0 +1,2 @@
1
+ export * from './internal.cjs.js';
2
+ export { _default as default } from './internal.cjs.default.js';
@@ -0,0 +1 @@
1
+ export * from "./src/internal";
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Actions received from the dotcms editor
3
+ *
4
+ * @export
5
+ * @enum {number}
6
+ */
7
+ var __DOTCMS_UVE_EVENT__;
8
+ (function (__DOTCMS_UVE_EVENT__) {
9
+ /**
10
+ * Request to page to reload
11
+ */
12
+ __DOTCMS_UVE_EVENT__["UVE_RELOAD_PAGE"] = "uve-reload-page";
13
+ /**
14
+ * Request the bounds for the elements
15
+ */
16
+ __DOTCMS_UVE_EVENT__["UVE_REQUEST_BOUNDS"] = "uve-request-bounds";
17
+ /**
18
+ * Received pong from the editor
19
+ */
20
+ __DOTCMS_UVE_EVENT__["UVE_EDITOR_PONG"] = "uve-editor-pong";
21
+ /**
22
+ * Received scroll event trigger from the editor
23
+ */
24
+ __DOTCMS_UVE_EVENT__["UVE_SCROLL_INSIDE_IFRAME"] = "uve-scroll-inside-iframe";
25
+ /**
26
+ * Set the page data
27
+ */
28
+ __DOTCMS_UVE_EVENT__["UVE_SET_PAGE_DATA"] = "uve-set-page-data";
29
+ /**
30
+ * Copy contentlet inline editing success
31
+ */
32
+ __DOTCMS_UVE_EVENT__["UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS"] = "uve-copy-contentlet-inline-editing-success";
33
+ })(__DOTCMS_UVE_EVENT__ || (__DOTCMS_UVE_EVENT__ = {}));
34
+
35
+ // TODO: WE NEED TO LOOK FOR ALL THE NOTIFY_CLIENT EVENTS AND ADD THEM TO THE UVE_EVENTS CONSTANT WHEN WE MIGRATE THE EDITOR TO THE NEW UVE LIBRARY
36
+ /**
37
+ * Events that can be subscribed to in the UVE
38
+ *
39
+ * @internal
40
+ * @type {Record<string, UVEEvent>}
41
+ */
42
+ const __UVE_EVENTS__ = {
43
+ changes: callback => {
44
+ const messageCallback = event => {
45
+ if (event.data.name === __DOTCMS_UVE_EVENT__.UVE_SET_PAGE_DATA) {
46
+ callback(event.data.payload);
47
+ }
48
+ };
49
+ window.addEventListener('message', messageCallback);
50
+ return {
51
+ unsubscribe: () => {
52
+ window.removeEventListener('message', messageCallback);
53
+ },
54
+ event: 'changes'
55
+ };
56
+ }
57
+ };
58
+ /**
59
+ * Default UVE event
60
+ *
61
+ * @param {string} event - The event to subscribe to.
62
+ * @internal
63
+ */
64
+ const __UVE_EVENT_ERROR_FALLBACK__ = event => {
65
+ return {
66
+ unsubscribe: () => {
67
+ /* do nothing */
68
+ },
69
+ event
70
+ };
71
+ };
72
+
73
+ export { __DOTCMS_UVE_EVENT__, __UVE_EVENTS__, __UVE_EVENT_ERROR_FALLBACK__ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/uve",
3
- "version": "0.0.1-beta.0",
3
+ "version": "0.0.1-beta.10",
4
4
  "description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,12 +13,6 @@
13
13
  "UVE",
14
14
  "Universal Visual Editor"
15
15
  ],
16
- "author": "dotcms <dev@dotcms.com>",
17
- "license": "MIT",
18
- "bugs": {
19
- "url": "https://github.com/dotCMS/core/issues"
20
- },
21
- "homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/client/README.md",
22
16
  "exports": {
23
17
  "./package.json": "./package.json",
24
18
  ".": {
@@ -32,9 +26,34 @@
32
26
  "types": "./types.esm.d.ts",
33
27
  "import": "./types.cjs.mjs",
34
28
  "default": "./types.cjs.js"
29
+ },
30
+ "./internal": {
31
+ "module": "./internal.esm.js",
32
+ "types": "./internal.esm.d.ts",
33
+ "import": "./internal.cjs.mjs",
34
+ "default": "./internal.cjs.js"
35
35
  }
36
36
  },
37
+ "typesVersions": {
38
+ "*": {
39
+ ".": [
40
+ "./src/index.d.ts"
41
+ ],
42
+ "types": [
43
+ "./src/types.d.ts"
44
+ ],
45
+ "internal": [
46
+ "./src/internal.d.ts"
47
+ ]
48
+ }
49
+ },
50
+ "author": "dotcms <dev@dotcms.com>",
51
+ "license": "MIT",
52
+ "bugs": {
53
+ "url": "https://github.com/dotCMS/core/issues"
54
+ },
55
+ "homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/uve/README.md",
37
56
  "module": "./index.esm.js",
38
57
  "main": "./index.cjs.js",
39
58
  "types": "./index.esm.d.ts"
40
- }
59
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/utils';
@@ -0,0 +1,18 @@
1
+ import { UVEEvent } from '../lib/types/editor/public';
2
+ /**
3
+ * Events that can be subscribed to in the UVE
4
+ *
5
+ * @internal
6
+ * @type {Record<string, UVEEvent>}
7
+ */
8
+ export declare const __UVE_EVENTS__: Record<string, UVEEvent>;
9
+ /**
10
+ * Default UVE event
11
+ *
12
+ * @param {string} event - The event to subscribe to.
13
+ * @internal
14
+ */
15
+ export declare const __UVE_EVENT_ERROR_FALLBACK__: (event: string) => {
16
+ unsubscribe: () => void;
17
+ event: string;
18
+ };
@@ -0,0 +1 @@
1
+ export * from './constants';
@@ -0,0 +1,3 @@
1
+ export * from './internal/index';
2
+ export * from './lib/types/editor/internal';
3
+ export * from './lib/types/events/internal';
@@ -0,0 +1,44 @@
1
+ import { DotCMSUVEAction } from './public';
2
+ /**
3
+ * @description Custom client parameters for fetching data.
4
+ */
5
+ export type DotCMSCustomerParams = {
6
+ depth: string;
7
+ };
8
+ /**
9
+ * Configuration for reordering a menu.
10
+ */
11
+ export interface DotCMSReorderMenuConfig {
12
+ /**
13
+ * The starting level of the menu to be reordered.
14
+ */
15
+ startLevel: number;
16
+ /**
17
+ * The depth of the menu levels to be reordered.
18
+ */
19
+ depth: number;
20
+ }
21
+ declare global {
22
+ interface Window {
23
+ dotCMSUVE: DotCMSUVE;
24
+ }
25
+ }
26
+ /**
27
+ * Post message props
28
+ *
29
+ * @export
30
+ * @template T
31
+ * @interface DotCMSUVEMessage
32
+ */
33
+ export type DotCMSUVEMessage<T> = {
34
+ action: DotCMSUVEAction;
35
+ payload?: T;
36
+ };
37
+ type DotCMSUVEFunction = (...args: any[]) => void;
38
+ export interface DotCMSUVE {
39
+ editContentlet: DotCMSUVEFunction;
40
+ initInlineEditing: DotCMSUVEFunction;
41
+ reorderMenu: DotCMSUVEFunction;
42
+ lastScrollYPosition: number;
43
+ }
44
+ export {};
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Represents the state of the Universal Visual Editor (UVE)
3
+ * @interface
4
+ * @property {UVE_MODE} mode - The current mode of operation for UVE (EDIT, PREVIEW, LIVE, or UNKNOWN)
5
+ * @property {string | null} persona - The selected persona for content personalization
6
+ * @property {string | null} variantName - The name of the current content variant
7
+ * @property {string | null} experimentId - The identifier for the current A/B testing experiment
8
+ * @property {string | null} publishDate - The scheduled publish date for content
9
+ * @property {string | null} languageId - The identifier for the current language selection
10
+ */
11
+ export interface UVEState {
12
+ mode: UVE_MODE;
13
+ persona: string | null;
14
+ variantName: string | null;
15
+ experimentId: string | null;
16
+ publishDate: string | null;
17
+ languageId: string | null;
18
+ }
19
+ /**
20
+ * Possible modes of UVE (Universal Visual Editor)
21
+ * @enum {string}
22
+ *
23
+ * @property {string} LIVE - Shows published and future content
24
+ * @property {string} PREVIEW - Shows published and working content
25
+ * @property {string} EDIT - Enables content editing functionality in UVE
26
+ * @property {string} UNKNOWN - Error state, UVE should not remain in this mode
27
+ */
28
+ export declare enum UVE_MODE {
29
+ EDIT = "EDIT_MODE",
30
+ PREVIEW = "PREVIEW_MODE",
31
+ LIVE = "LIVE",
32
+ UNKNOWN = "UNKNOWN"
33
+ }
34
+ /**
35
+ * Callback function for UVE events
36
+ * @callback UVECallback
37
+ * @param {unknown} payload - The payload of the event
38
+ */
39
+ export type UVECallback = (payload: unknown) => void;
40
+ /**
41
+ * Unsubscribe function for UVE events
42
+ * @callback UnsubscribeUVE
43
+ */
44
+ export type UnsubscribeUVE = () => void;
45
+ /**
46
+ * UVESubscription type
47
+ * @typedef {Object} UVESubscription
48
+ * @property {UnsubscribeUVE} unsubscribe - The unsubscribe function for the UVE event
49
+ * @property {string} event - The event name
50
+ */
51
+ export type UVESubscription = {
52
+ unsubscribe: UnsubscribeUVE;
53
+ event: string;
54
+ };
55
+ /**
56
+ * UVE event type
57
+ * @typedef {function} UVEEvent
58
+ */
59
+ export type UVEEvent = (callback: UVECallback) => UVESubscription;
60
+ /**
61
+ * Configuration type for DotCMS Editor
62
+ * @typedef {Object} DotCMSEditoConfig
63
+ * @property {Object} [params] - Parameters for Page API configuration
64
+ * @property {number} [params.depth] - The depth level for fetching page data
65
+ * @property {string} [query] - GraphQL query string for data fetching
66
+ */
67
+ export type DotCMSEditorConfig = {
68
+ params: {
69
+ depth: number;
70
+ };
71
+ } | {
72
+ query: string;
73
+ };
74
+ /**
75
+ * Actions send to the dotcms editor
76
+ *
77
+ * @export
78
+ * @enum {number}
79
+ */
80
+ export declare enum DotCMSUVEAction {
81
+ /**
82
+ * Tell the dotcms editor that page change
83
+ */
84
+ NAVIGATION_UPDATE = "set-url",
85
+ /**
86
+ * Send the element position of the rows, columnsm containers and contentlets
87
+ */
88
+ SET_BOUNDS = "set-bounds",
89
+ /**
90
+ * Send the information of the hovered contentlet
91
+ */
92
+ SET_CONTENTLET = "set-contentlet",
93
+ /**
94
+ * Tell the editor that the page is being scrolled
95
+ */
96
+ IFRAME_SCROLL = "scroll",
97
+ /**
98
+ * Tell the editor that the page has stopped scrolling
99
+ */
100
+ IFRAME_SCROLL_END = "scroll-end",
101
+ /**
102
+ * Ping the editor to see if the page is inside the editor
103
+ */
104
+ PING_EDITOR = "ping-editor",
105
+ /**
106
+ * Tell the editor to init the inline editing editor.
107
+ */
108
+ INIT_INLINE_EDITING = "init-inline-editing",
109
+ /**
110
+ * Tell the editor to open the Copy-contentlet dialog
111
+ * To copy a content and then edit it inline.
112
+ */
113
+ COPY_CONTENTLET_INLINE_EDITING = "copy-contentlet-inline-editing",
114
+ /**
115
+ * Tell the editor to save inline edited contentlet
116
+ */
117
+ UPDATE_CONTENTLET_INLINE_EDITING = "update-contentlet-inline-editing",
118
+ /**
119
+ * Tell the editor to trigger a menu reorder
120
+ */
121
+ REORDER_MENU = "reorder-menu",
122
+ /**
123
+ * Tell the editor to send the page info to iframe
124
+ */
125
+ GET_PAGE_DATA = "get-page-data",
126
+ /**
127
+ * Tell the editor an user send a graphql query
128
+ */
129
+ CLIENT_READY = "client-ready",
130
+ /**
131
+ * Tell the editor to edit a contentlet
132
+ */
133
+ EDIT_CONTENTLET = "edit-contentlet",
134
+ /**
135
+ * Tell the editor to do nothing
136
+ */
137
+ NOOP = "noop"
138
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Actions received from the dotcms editor
3
+ *
4
+ * @export
5
+ * @enum {number}
6
+ */
7
+ export declare enum __DOTCMS_UVE_EVENT__ {
8
+ /**
9
+ * Request to page to reload
10
+ */
11
+ UVE_RELOAD_PAGE = "uve-reload-page",
12
+ /**
13
+ * Request the bounds for the elements
14
+ */
15
+ UVE_REQUEST_BOUNDS = "uve-request-bounds",
16
+ /**
17
+ * Received pong from the editor
18
+ */
19
+ UVE_EDITOR_PONG = "uve-editor-pong",
20
+ /**
21
+ * Received scroll event trigger from the editor
22
+ */
23
+ UVE_SCROLL_INSIDE_IFRAME = "uve-scroll-inside-iframe",
24
+ /**
25
+ * Set the page data
26
+ */
27
+ UVE_SET_PAGE_DATA = "uve-set-page-data",
28
+ /**
29
+ * Copy contentlet inline editing success
30
+ */
31
+ UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS = "uve-copy-contentlet-inline-editing-success"
32
+ }
@@ -0,0 +1,18 @@
1
+ export type DotCMSInlineEditingType = 'BLOCK_EDITOR' | 'WYSIWYG';
2
+ /**
3
+ * Interface representing the data needed for inline editing in DotCMS
4
+ *
5
+ * @interface DotCMSInlineEditorData
6
+ * @property {string} inode - The inode identifier of the content being edited
7
+ * @property {number} language - The language ID of the content
8
+ * @property {string} contentType - The content type identifier
9
+ * @property {string} fieldName - The name of the field being edited
10
+ * @property {Record<string, unknown>} content - The content data as key-value pairs
11
+ */
12
+ export interface DotCMSInlineEditingPayload {
13
+ inode: string;
14
+ language: number;
15
+ contentType: string;
16
+ fieldName: string;
17
+ content: Record<string, unknown>;
18
+ }
@@ -1,4 +1,4 @@
1
- import { UVEState } from './types';
1
+ import { UVECallback, UVEState, UVESubscription } from './types/editor/public';
2
2
  /**
3
3
  * Gets the current state of the Universal Visual Editor (UVE).
4
4
  *
@@ -28,3 +28,18 @@ import { UVEState } from './types';
28
28
  * ```
29
29
  */
30
30
  export declare function getUVEState(): UVEState | undefined;
31
+ /**
32
+ * Creates a subscription to a UVE event.
33
+ *
34
+ * @param {string} event - The event to subscribe to.
35
+ * @param {UVECallback} callback - The callback to call when the event is triggered.
36
+ * @return {UnsubscribeUVE | undefined} The unsubscribe function if the event is valid, undefined otherwise.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const unsubscribeChanges = createUVESubscription('changes', (payload) => {
41
+ * console.log(payload);
42
+ * });
43
+ * ```
44
+ */
45
+ export declare function createUVESubscription(event: string, callback: UVECallback): UVESubscription;
package/src/types.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/types/editor/public';
2
+ export * from './lib/types/events/public';
package/types.cjs.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./src/public/types";
1
+ export * from "./src/types";
package/types.cjs.js CHANGED
@@ -11,8 +11,74 @@
11
11
  */
12
12
  exports.UVE_MODE = void 0;
13
13
  (function (UVE_MODE) {
14
- UVE_MODE["EDIT"] = "EDIT_MODE";
15
- UVE_MODE["PREVIEW"] = "PREVIEW_MODE";
16
- UVE_MODE["LIVE"] = "LIVE";
17
- UVE_MODE["UNKNOWN"] = "UNKNOWN";
14
+ UVE_MODE["EDIT"] = "EDIT_MODE";
15
+ UVE_MODE["PREVIEW"] = "PREVIEW_MODE";
16
+ UVE_MODE["LIVE"] = "LIVE";
17
+ UVE_MODE["UNKNOWN"] = "UNKNOWN";
18
18
  })(exports.UVE_MODE || (exports.UVE_MODE = {}));
19
+ /**
20
+ * Actions send to the dotcms editor
21
+ *
22
+ * @export
23
+ * @enum {number}
24
+ */
25
+ exports.DotCMSUVEAction = void 0;
26
+ (function (DotCMSUVEAction) {
27
+ /**
28
+ * Tell the dotcms editor that page change
29
+ */
30
+ DotCMSUVEAction["NAVIGATION_UPDATE"] = "set-url";
31
+ /**
32
+ * Send the element position of the rows, columnsm containers and contentlets
33
+ */
34
+ DotCMSUVEAction["SET_BOUNDS"] = "set-bounds";
35
+ /**
36
+ * Send the information of the hovered contentlet
37
+ */
38
+ DotCMSUVEAction["SET_CONTENTLET"] = "set-contentlet";
39
+ /**
40
+ * Tell the editor that the page is being scrolled
41
+ */
42
+ DotCMSUVEAction["IFRAME_SCROLL"] = "scroll";
43
+ /**
44
+ * Tell the editor that the page has stopped scrolling
45
+ */
46
+ DotCMSUVEAction["IFRAME_SCROLL_END"] = "scroll-end";
47
+ /**
48
+ * Ping the editor to see if the page is inside the editor
49
+ */
50
+ DotCMSUVEAction["PING_EDITOR"] = "ping-editor";
51
+ /**
52
+ * Tell the editor to init the inline editing editor.
53
+ */
54
+ DotCMSUVEAction["INIT_INLINE_EDITING"] = "init-inline-editing";
55
+ /**
56
+ * Tell the editor to open the Copy-contentlet dialog
57
+ * To copy a content and then edit it inline.
58
+ */
59
+ DotCMSUVEAction["COPY_CONTENTLET_INLINE_EDITING"] = "copy-contentlet-inline-editing";
60
+ /**
61
+ * Tell the editor to save inline edited contentlet
62
+ */
63
+ DotCMSUVEAction["UPDATE_CONTENTLET_INLINE_EDITING"] = "update-contentlet-inline-editing";
64
+ /**
65
+ * Tell the editor to trigger a menu reorder
66
+ */
67
+ DotCMSUVEAction["REORDER_MENU"] = "reorder-menu";
68
+ /**
69
+ * Tell the editor to send the page info to iframe
70
+ */
71
+ DotCMSUVEAction["GET_PAGE_DATA"] = "get-page-data";
72
+ /**
73
+ * Tell the editor an user send a graphql query
74
+ */
75
+ DotCMSUVEAction["CLIENT_READY"] = "client-ready";
76
+ /**
77
+ * Tell the editor to edit a contentlet
78
+ */
79
+ DotCMSUVEAction["EDIT_CONTENTLET"] = "edit-contentlet";
80
+ /**
81
+ * Tell the editor to do nothing
82
+ */
83
+ DotCMSUVEAction["NOOP"] = "noop";
84
+ })(exports.DotCMSUVEAction || (exports.DotCMSUVEAction = {}));
package/types.esm.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./src/public/types";
1
+ export * from "./src/types";
package/types.esm.js CHANGED
@@ -9,10 +9,76 @@
9
9
  */
10
10
  var UVE_MODE;
11
11
  (function (UVE_MODE) {
12
- UVE_MODE["EDIT"] = "EDIT_MODE";
13
- UVE_MODE["PREVIEW"] = "PREVIEW_MODE";
14
- UVE_MODE["LIVE"] = "LIVE";
15
- UVE_MODE["UNKNOWN"] = "UNKNOWN";
12
+ UVE_MODE["EDIT"] = "EDIT_MODE";
13
+ UVE_MODE["PREVIEW"] = "PREVIEW_MODE";
14
+ UVE_MODE["LIVE"] = "LIVE";
15
+ UVE_MODE["UNKNOWN"] = "UNKNOWN";
16
16
  })(UVE_MODE || (UVE_MODE = {}));
17
+ /**
18
+ * Actions send to the dotcms editor
19
+ *
20
+ * @export
21
+ * @enum {number}
22
+ */
23
+ var DotCMSUVEAction;
24
+ (function (DotCMSUVEAction) {
25
+ /**
26
+ * Tell the dotcms editor that page change
27
+ */
28
+ DotCMSUVEAction["NAVIGATION_UPDATE"] = "set-url";
29
+ /**
30
+ * Send the element position of the rows, columnsm containers and contentlets
31
+ */
32
+ DotCMSUVEAction["SET_BOUNDS"] = "set-bounds";
33
+ /**
34
+ * Send the information of the hovered contentlet
35
+ */
36
+ DotCMSUVEAction["SET_CONTENTLET"] = "set-contentlet";
37
+ /**
38
+ * Tell the editor that the page is being scrolled
39
+ */
40
+ DotCMSUVEAction["IFRAME_SCROLL"] = "scroll";
41
+ /**
42
+ * Tell the editor that the page has stopped scrolling
43
+ */
44
+ DotCMSUVEAction["IFRAME_SCROLL_END"] = "scroll-end";
45
+ /**
46
+ * Ping the editor to see if the page is inside the editor
47
+ */
48
+ DotCMSUVEAction["PING_EDITOR"] = "ping-editor";
49
+ /**
50
+ * Tell the editor to init the inline editing editor.
51
+ */
52
+ DotCMSUVEAction["INIT_INLINE_EDITING"] = "init-inline-editing";
53
+ /**
54
+ * Tell the editor to open the Copy-contentlet dialog
55
+ * To copy a content and then edit it inline.
56
+ */
57
+ DotCMSUVEAction["COPY_CONTENTLET_INLINE_EDITING"] = "copy-contentlet-inline-editing";
58
+ /**
59
+ * Tell the editor to save inline edited contentlet
60
+ */
61
+ DotCMSUVEAction["UPDATE_CONTENTLET_INLINE_EDITING"] = "update-contentlet-inline-editing";
62
+ /**
63
+ * Tell the editor to trigger a menu reorder
64
+ */
65
+ DotCMSUVEAction["REORDER_MENU"] = "reorder-menu";
66
+ /**
67
+ * Tell the editor to send the page info to iframe
68
+ */
69
+ DotCMSUVEAction["GET_PAGE_DATA"] = "get-page-data";
70
+ /**
71
+ * Tell the editor an user send a graphql query
72
+ */
73
+ DotCMSUVEAction["CLIENT_READY"] = "client-ready";
74
+ /**
75
+ * Tell the editor to edit a contentlet
76
+ */
77
+ DotCMSUVEAction["EDIT_CONTENTLET"] = "edit-contentlet";
78
+ /**
79
+ * Tell the editor to do nothing
80
+ */
81
+ DotCMSUVEAction["NOOP"] = "noop";
82
+ })(DotCMSUVEAction || (DotCMSUVEAction = {}));
17
83
 
18
- export { UVE_MODE };
84
+ export { DotCMSUVEAction, UVE_MODE };
@@ -1,33 +0,0 @@
1
- /**
2
- * Represents the state of the Universal Visual Editor (UVE)
3
- * @interface
4
- * @property {UVE_MODE} mode - The current mode of operation for UVE (EDIT, PREVIEW, LIVE, or UNKNOWN)
5
- * @property {string | null} persona - The selected persona for content personalization
6
- * @property {string | null} variantName - The name of the current content variant
7
- * @property {string | null} experimentId - The identifier for the current A/B testing experiment
8
- * @property {string | null} publishDate - The scheduled publish date for content
9
- * @property {string | null} languageId - The identifier for the current language selection
10
- */
11
- export interface UVEState {
12
- mode: UVE_MODE;
13
- persona: string | null;
14
- variantName: string | null;
15
- experimentId: string | null;
16
- publishDate: string | null;
17
- languageId: string | null;
18
- }
19
- /**
20
- * Possible modes of UVE (Universal Visual Editor)
21
- * @enum {string}
22
- *
23
- * @property {string} LIVE - Shows published and future content
24
- * @property {string} PREVIEW - Shows published and working content
25
- * @property {string} EDIT - Enables content editing functionality in UVE
26
- * @property {string} UNKNOWN - Error state, UVE should not remain in this mode
27
- */
28
- export declare enum UVE_MODE {
29
- EDIT = "EDIT_MODE",
30
- PREVIEW = "PREVIEW_MODE",
31
- LIVE = "LIVE",
32
- UNKNOWN = "UNKNOWN"
33
- }
@@ -1,2 +0,0 @@
1
- import { getUVEState } from '../lib/utils';
2
- export { getUVEState };
@@ -1,2 +0,0 @@
1
- import { UVE_MODE, UVEState } from '../lib/types';
2
- export { UVE_MODE, UVEState };