@dotcms/uve 0.0.1-beta.14 → 0.0.1-beta.16
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/constants.cjs.js +767 -0
- package/constants.esm.js +740 -0
- package/index.cjs.js +8 -81
- package/index.esm.js +4 -76
- package/internal.cjs.js +109 -393
- package/internal.esm.js +80 -386
- package/package.json +1 -1
- package/src/internal/constants.d.ts +58 -0
- package/src/internal.d.ts +2 -0
- package/src/lib/dom/dom.utils.d.ts +95 -0
- package/src/lib/editor/internal.d.ts +16 -1
- package/src/lib/types/block-editor-renderer/internal.d.ts +46 -0
- package/src/lib/types/block-editor-renderer/public.d.ts +38 -0
- package/src/lib/types/editor/public.d.ts +44 -0
- package/src/lib/types/page/public.d.ts +421 -0
- package/src/types.d.ts +2 -0
package/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var constants = require('./constants.cjs.js');
|
|
4
4
|
var types = require('./types.cjs.js');
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -76,92 +76,19 @@ function getUVEState() {
|
|
|
76
76
|
function createUVESubscription(eventType, callback) {
|
|
77
77
|
if (!getUVEState()) {
|
|
78
78
|
console.warn('UVE Subscription: Not running inside UVE');
|
|
79
|
-
return
|
|
79
|
+
return constants.__UVE_EVENT_ERROR_FALLBACK__(eventType);
|
|
80
80
|
}
|
|
81
|
-
const eventCallback =
|
|
81
|
+
const eventCallback = constants.__UVE_EVENTS__[eventType];
|
|
82
82
|
if (!eventCallback) {
|
|
83
83
|
console.error(`UVE Subscription: Event ${eventType} not found`);
|
|
84
|
-
return
|
|
84
|
+
return constants.__UVE_EVENT_ERROR_FALLBACK__(eventType);
|
|
85
85
|
}
|
|
86
86
|
return eventCallback(callback);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* @template T
|
|
94
|
-
* @param {DotCMSUVEMessage<T>} message
|
|
95
|
-
*/
|
|
96
|
-
function sendMessageToUVE(message) {
|
|
97
|
-
window.parent.postMessage(message, '*');
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* You can use this function to edit a contentlet in the editor.
|
|
101
|
-
*
|
|
102
|
-
* Calling this function inside the editor, will prompt the UVE to open a dialog to edit the contentlet.
|
|
103
|
-
*
|
|
104
|
-
* @export
|
|
105
|
-
* @template T
|
|
106
|
-
* @param {Contentlet<T>} contentlet - The contentlet to edit.
|
|
107
|
-
*/
|
|
108
|
-
function editContentlet(contentlet) {
|
|
109
|
-
sendMessageToUVE({
|
|
110
|
-
action: types.DotCMSUVEAction.EDIT_CONTENTLET,
|
|
111
|
-
payload: contentlet
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/*
|
|
115
|
-
* Reorders the menu based on the provided configuration.
|
|
116
|
-
*
|
|
117
|
-
* @param {ReorderMenuConfig} [config] - Optional configuration for reordering the menu.
|
|
118
|
-
* @param {number} [config.startLevel=1] - The starting level of the menu to reorder.
|
|
119
|
-
* @param {number} [config.depth=2] - The depth of the menu to reorder.
|
|
120
|
-
*
|
|
121
|
-
* This function constructs a URL for the reorder menu page with the specified
|
|
122
|
-
* start level and depth, and sends a message to the editor to perform the reorder action.
|
|
123
|
-
*/
|
|
124
|
-
function reorderMenu(config) {
|
|
125
|
-
const {
|
|
126
|
-
startLevel = 1,
|
|
127
|
-
depth = 2
|
|
128
|
-
} = config || {};
|
|
129
|
-
sendMessageToUVE({
|
|
130
|
-
action: types.DotCMSUVEAction.REORDER_MENU,
|
|
131
|
-
payload: {
|
|
132
|
-
startLevel,
|
|
133
|
-
depth
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Initializes the inline editing in the editor.
|
|
139
|
-
*
|
|
140
|
-
* @export
|
|
141
|
-
* @param {INLINE_EDITING_EVENT_KEY} type
|
|
142
|
-
* @param {InlineEditEventData} eventData
|
|
143
|
-
* @return {*}
|
|
144
|
-
*
|
|
145
|
-
* * @example
|
|
146
|
-
* ```html
|
|
147
|
-
* <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
|
|
148
|
-
* ${My Content}
|
|
149
|
-
* </div>
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
function initInlineEditing(type, data) {
|
|
153
|
-
sendMessageToUVE({
|
|
154
|
-
action: types.DotCMSUVEAction.INIT_INLINE_EDITING,
|
|
155
|
-
payload: {
|
|
156
|
-
type,
|
|
157
|
-
data
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
89
|
+
exports.editContentlet = constants.editContentlet;
|
|
90
|
+
exports.initInlineEditing = constants.initInlineEditing;
|
|
91
|
+
exports.reorderMenu = constants.reorderMenu;
|
|
92
|
+
exports.sendMessageToUVE = constants.sendMessageToUVE;
|
|
162
93
|
exports.createUVESubscription = createUVESubscription;
|
|
163
|
-
exports.editContentlet = editContentlet;
|
|
164
94
|
exports.getUVEState = getUVEState;
|
|
165
|
-
exports.initInlineEditing = initInlineEditing;
|
|
166
|
-
exports.reorderMenu = reorderMenu;
|
|
167
|
-
exports.sendMessageToUVE = sendMessageToUVE;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { __UVE_EVENT_ERROR_FALLBACK__, __UVE_EVENTS__ } from './
|
|
2
|
-
|
|
1
|
+
import { _ as __UVE_EVENT_ERROR_FALLBACK__, a as __UVE_EVENTS__ } from './constants.esm.js';
|
|
2
|
+
export { e as editContentlet, i as initInlineEditing, r as reorderMenu, s as sendMessageToUVE } from './constants.esm.js';
|
|
3
|
+
import { UVE_MODE } from './types.esm.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Gets the current state of the Universal Visual Editor (UVE).
|
|
@@ -84,77 +85,4 @@ function createUVESubscription(eventType, callback) {
|
|
|
84
85
|
return eventCallback(callback);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
* Post message to dotcms page editor
|
|
89
|
-
*
|
|
90
|
-
* @export
|
|
91
|
-
* @template T
|
|
92
|
-
* @param {DotCMSUVEMessage<T>} message
|
|
93
|
-
*/
|
|
94
|
-
function sendMessageToUVE(message) {
|
|
95
|
-
window.parent.postMessage(message, '*');
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* You can use this function to edit a contentlet in the editor.
|
|
99
|
-
*
|
|
100
|
-
* Calling this function inside the editor, will prompt the UVE to open a dialog to edit the contentlet.
|
|
101
|
-
*
|
|
102
|
-
* @export
|
|
103
|
-
* @template T
|
|
104
|
-
* @param {Contentlet<T>} contentlet - The contentlet to edit.
|
|
105
|
-
*/
|
|
106
|
-
function editContentlet(contentlet) {
|
|
107
|
-
sendMessageToUVE({
|
|
108
|
-
action: DotCMSUVEAction.EDIT_CONTENTLET,
|
|
109
|
-
payload: contentlet
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
/*
|
|
113
|
-
* Reorders the menu based on the provided configuration.
|
|
114
|
-
*
|
|
115
|
-
* @param {ReorderMenuConfig} [config] - Optional configuration for reordering the menu.
|
|
116
|
-
* @param {number} [config.startLevel=1] - The starting level of the menu to reorder.
|
|
117
|
-
* @param {number} [config.depth=2] - The depth of the menu to reorder.
|
|
118
|
-
*
|
|
119
|
-
* This function constructs a URL for the reorder menu page with the specified
|
|
120
|
-
* start level and depth, and sends a message to the editor to perform the reorder action.
|
|
121
|
-
*/
|
|
122
|
-
function reorderMenu(config) {
|
|
123
|
-
const {
|
|
124
|
-
startLevel = 1,
|
|
125
|
-
depth = 2
|
|
126
|
-
} = config || {};
|
|
127
|
-
sendMessageToUVE({
|
|
128
|
-
action: DotCMSUVEAction.REORDER_MENU,
|
|
129
|
-
payload: {
|
|
130
|
-
startLevel,
|
|
131
|
-
depth
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Initializes the inline editing in the editor.
|
|
137
|
-
*
|
|
138
|
-
* @export
|
|
139
|
-
* @param {INLINE_EDITING_EVENT_KEY} type
|
|
140
|
-
* @param {InlineEditEventData} eventData
|
|
141
|
-
* @return {*}
|
|
142
|
-
*
|
|
143
|
-
* * @example
|
|
144
|
-
* ```html
|
|
145
|
-
* <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
|
|
146
|
-
* ${My Content}
|
|
147
|
-
* </div>
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
function initInlineEditing(type, data) {
|
|
151
|
-
sendMessageToUVE({
|
|
152
|
-
action: DotCMSUVEAction.INIT_INLINE_EDITING,
|
|
153
|
-
payload: {
|
|
154
|
-
type,
|
|
155
|
-
data
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export { createUVESubscription, editContentlet, getUVEState, initInlineEditing, reorderMenu, sendMessageToUVE };
|
|
88
|
+
export { createUVESubscription, getUVEState };
|