@dotcms/uve 0.0.1-beta.3 → 0.0.1-beta.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/README.md +321 -4
- package/index.cjs.js +13 -54
- package/index.esm.js +3 -56
- package/internal.cjs.d.ts +1 -0
- package/internal.cjs.default.js +1 -0
- package/internal.cjs.js +103 -0
- package/internal.cjs.mjs +2 -0
- package/internal.esm.d.ts +1 -0
- package/internal.esm.js +75 -0
- package/package.json +11 -8
- package/public.cjs.js +1127 -0
- package/public.esm.js +1093 -0
- package/src/index.d.ts +2 -2
- package/src/internal/constants.d.ts +76 -0
- package/src/internal/events.d.ts +66 -0
- package/src/internal/index.d.ts +2 -0
- package/src/internal/tinymce.config.d.ts +45 -0
- package/src/internal.d.ts +3 -0
- package/src/lib/{utils.d.ts → core/core.utils.d.ts} +20 -1
- package/src/lib/dom/dom.utils.d.ts +205 -0
- package/src/lib/editor/internal.d.ts +23 -0
- package/src/lib/editor/public.d.ts +86 -0
- package/src/script/sdk-editor.d.ts +6 -0
- package/src/script/utils.d.ts +53 -0
- package/src/lib/types.d.ts +0 -33
- package/src/types.d.ts +0 -2
- package/types.cjs.d.ts +0 -1
- package/types.cjs.default.js +0 -1
- package/types.cjs.js +0 -18
- package/types.cjs.mjs +0 -2
- package/types.esm.d.ts +0 -1
- package/types.esm.js +0 -18
package/README.md
CHANGED
|
@@ -1,7 +1,324 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DotCMS UVE SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A JavaScript library to connect your dotCMS pages with the Universal Visual Editor (UVE) and enable content authors to edit pages in real time.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **BETA VERSION NOTICE:** This SDK is currently in beta. APIs, functionality, and documentation may change significantly in the stable release.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Entry Points](#entry-points)
|
|
11
|
+
- [Getting Started](#getting-started)
|
|
12
|
+
- [API Reference](#api-reference)
|
|
13
|
+
- [Editor State](#editor-state)
|
|
14
|
+
- [Event Subscriptions](#event-subscriptions)
|
|
15
|
+
- [Content Editing](#content-editing)
|
|
16
|
+
- [Navigation & UI](#navigation--ui)
|
|
17
|
+
- [Messaging](#messaging)
|
|
18
|
+
- [Types Reference](#types-reference)
|
|
19
|
+
- [Examples](#examples)
|
|
20
|
+
- [Contributing](#contributing)
|
|
21
|
+
- [License](#license)
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
The UVE SDK is automatically included in DotCMS installations. For external usage:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Using npm
|
|
29
|
+
npm install @dotcms/uve-sdk
|
|
30
|
+
|
|
31
|
+
# Using yarn
|
|
32
|
+
yarn add @dotcms/uve-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Entry Points
|
|
36
|
+
|
|
37
|
+
The library exposes three main entry points:
|
|
38
|
+
|
|
39
|
+
- **`@dotcms/uve`**: Provides everything developers need to communicate with UVE.
|
|
40
|
+
|
|
41
|
+
- **`@dotcms/uve/types`**: Offers TypeScript types, interfaces, and other structures to help users organize their code properly.
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
To use the UVE SDK in your project, import the necessary functions:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { getUVEState, createUVESubscription, editContentlet } from '@dotcms/uve';
|
|
49
|
+
import { UVEEventType, UVE_MODE } from '@dotcms/uve/types';
|
|
50
|
+
|
|
51
|
+
// Check if we're in the editor
|
|
52
|
+
const uveState = getUVEState();
|
|
53
|
+
if (uveState?.mode === UVE_MODE.EDIT) {
|
|
54
|
+
console.log('Running in edit mode!');
|
|
55
|
+
|
|
56
|
+
// Subscribe to content changes
|
|
57
|
+
const subscription = createUVESubscription(UVEEventType.CONTENT_CHANGES, (changes) => {
|
|
58
|
+
console.log('Content updated:', changes);
|
|
59
|
+
// Update your UI with the new content
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Later, when no longer needed
|
|
63
|
+
subscription.unsubscribe();
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API Reference
|
|
68
|
+
|
|
69
|
+
### Editor State
|
|
70
|
+
|
|
71
|
+
#### `getUVEState`
|
|
72
|
+
|
|
73
|
+
Retrieves the current UVE state.
|
|
74
|
+
|
|
75
|
+
**Returns:**
|
|
76
|
+
- A `UVEState` object if running inside the editor, or `undefined` otherwise.
|
|
77
|
+
|
|
78
|
+
The state includes:
|
|
79
|
+
- `mode`: The current editor mode (preview, edit, live).
|
|
80
|
+
- `languageId`: The language ID of the current page set in the UVE.
|
|
81
|
+
- `persona`: The persona of the current page set in the UVE.
|
|
82
|
+
- `variantName`: The name of the current variant.
|
|
83
|
+
- `experimentId`: The ID of the current experiment.
|
|
84
|
+
- `publishDate`: The publish date of the current page set in the UVE.
|
|
85
|
+
|
|
86
|
+
> **Note:** If any of these properties are absent, it means the value is the default one.
|
|
87
|
+
|
|
88
|
+
**Example:**
|
|
89
|
+
```typescript
|
|
90
|
+
const editorState = getUVEState();
|
|
91
|
+
if (editorState?.mode === 'edit') {
|
|
92
|
+
// Enable editing features
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Event Subscriptions
|
|
97
|
+
|
|
98
|
+
#### `createUVESubscription`
|
|
99
|
+
|
|
100
|
+
Subscribe to page changes and other UVE events. Receive a callback that will be called with the updated content of the page.
|
|
101
|
+
|
|
102
|
+
**Parameters:**
|
|
103
|
+
- `eventType` - The type of event to subscribe to.
|
|
104
|
+
- `callback` - The callback function that will be called when the event occurs.
|
|
105
|
+
|
|
106
|
+
**Returns:**
|
|
107
|
+
- An event subscription that can be used to unsubscribe.
|
|
108
|
+
|
|
109
|
+
**Example:**
|
|
110
|
+
```typescript
|
|
111
|
+
// Subscribe to page changes
|
|
112
|
+
const subscription = createUVESubscription(UVEEventType.CONTENT_CHANGES, (changes) => {
|
|
113
|
+
console.log('Content changes:', changes);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Later, unsubscribe when no longer needed
|
|
117
|
+
subscription.unsubscribe();
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Content Editing
|
|
121
|
+
|
|
122
|
+
#### `editContentlet`
|
|
123
|
+
|
|
124
|
+
Allows you to edit a contentlet in the editor.
|
|
125
|
+
|
|
126
|
+
Calling this function within the editor prompts the UVE to open a dialog to edit the specified contentlet.
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
- `contentlet<T>` - The contentlet to edit.
|
|
130
|
+
|
|
131
|
+
**Example:**
|
|
132
|
+
```typescript
|
|
133
|
+
// Edit a contentlet
|
|
134
|
+
editContentlet(myContentlet);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### `initInlineEditing`
|
|
138
|
+
|
|
139
|
+
Initializes inline editing in the editor.
|
|
140
|
+
|
|
141
|
+
**Parameters:**
|
|
142
|
+
- `type` - The type of inline editing ('BLOCK_EDITOR' or 'WYSIWYG').
|
|
143
|
+
- `data` - (Optional) Data for the inline editing session.
|
|
144
|
+
|
|
145
|
+
**Example:**
|
|
146
|
+
```typescript
|
|
147
|
+
// Initialize block editor
|
|
148
|
+
initInlineEditing('BLOCK_EDITOR', {
|
|
149
|
+
inode: 'abc123',
|
|
150
|
+
language: 1,
|
|
151
|
+
contentType: 'Blog',
|
|
152
|
+
fieldName: 'body',
|
|
153
|
+
content: { /* content data */ }
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Navigation & UI
|
|
158
|
+
|
|
159
|
+
#### `reorderMenu`
|
|
160
|
+
|
|
161
|
+
Reorders the menu based on the provided configuration.
|
|
162
|
+
|
|
163
|
+
**Parameters:**
|
|
164
|
+
- `config` (optional): Configuration for reordering the menu.
|
|
165
|
+
- `startLevel` (default: `1`): The starting level of the menu to reorder.
|
|
166
|
+
- `depth` (default: `2`): The depth of the menu to reorder.
|
|
167
|
+
|
|
168
|
+
This function constructs a URL for the reorder menu page with the specified `startLevel` and `depth`, then sends a message to the editor to perform the reorder action.
|
|
169
|
+
|
|
170
|
+
**Example:**
|
|
171
|
+
```typescript
|
|
172
|
+
// Reorder menu starting from level 2 with depth of 3
|
|
173
|
+
reorderMenu({ startLevel: 2, depth: 3 });
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Messaging
|
|
177
|
+
|
|
178
|
+
#### `sendMessageToUVE`
|
|
179
|
+
|
|
180
|
+
The `sendMessageToUVE` function allows you to send messages to the dotCMS page editor. This is useful for triggering specific actions or updating the editor's state.
|
|
181
|
+
|
|
182
|
+
This function is primarily used within other library functions but can be helpful if you need to trigger specific behavior by sending a message to the UVE.
|
|
183
|
+
|
|
184
|
+
**Example:**
|
|
185
|
+
```typescript
|
|
186
|
+
sendMessageToUVE({
|
|
187
|
+
action: DotCMSUVEAction.CUSTOM_MESSAGE,
|
|
188
|
+
payload: { key: 'value' }
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Available Message Types (DotCMSUVEAction)
|
|
193
|
+
|
|
194
|
+
| **Type** | **Description** |
|
|
195
|
+
|--------------------------------------|---------------------------------------------------------------------------------------------------|
|
|
196
|
+
| `NAVIGATION_UPDATE` | Notifies the dotCMS editor that the page has changed. |
|
|
197
|
+
| `SET_BOUNDS` | Sends the position of rows, columns, containers, and contentlets to the editor. |
|
|
198
|
+
| `SET_CONTENTLET` | Sends information about the currently hovered contentlet. |
|
|
199
|
+
| `IFRAME_SCROLL` | Informs the editor that the page is being scrolled. |
|
|
200
|
+
| `IFRAME_SCROLL_END` | Notifies the editor that scrolling has stopped. |
|
|
201
|
+
| `PING_EDITOR` | Pings the editor to check if the page is inside the editor. |
|
|
202
|
+
| `INIT_INLINE_EDITING` | Initializes the inline editing mode in the editor. |
|
|
203
|
+
| `COPY_CONTENTLET_INLINE_EDITING` | Opens the "Copy Contentlet" dialog to duplicate and edit a contentlet inline. |
|
|
204
|
+
| `UPDATE_CONTENTLET_INLINE_EDITING` | Triggers the save action for inline-edited contentlets. |
|
|
205
|
+
| `REORDER_MENU` | Triggers the menu reorder action with a specified configuration. |
|
|
206
|
+
| `GET_PAGE_DATA` | Requests the current page information from the editor. |
|
|
207
|
+
| `CLIENT_READY` | Indicates that the client has completed initialization. |
|
|
208
|
+
| `EDIT_CONTENTLET` | Opens the contentlet editing dialog in the editor. |
|
|
209
|
+
|
|
210
|
+
## Types Reference
|
|
211
|
+
|
|
212
|
+
The SDK provides TypeScript types to assist in development:
|
|
213
|
+
|
|
214
|
+
### UVE State and Modes
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
// UVE State Interface
|
|
218
|
+
interface UVEState {
|
|
219
|
+
mode: UVE_MODE;
|
|
220
|
+
persona: string | null;
|
|
221
|
+
variantName: string | null;
|
|
222
|
+
experimentId: string | null;
|
|
223
|
+
publishDate: string | null;
|
|
224
|
+
languageId: string | null;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// UVE Mode Enum
|
|
228
|
+
enum UVE_MODE {
|
|
229
|
+
EDIT = 'EDIT_MODE',
|
|
230
|
+
PREVIEW = 'PREVIEW_MODE',
|
|
231
|
+
LIVE = 'LIVE',
|
|
232
|
+
UNKNOWN = 'UNKNOWN'
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### UVE Events
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
// Event Types Enum
|
|
240
|
+
enum UVEEventType {
|
|
241
|
+
CONTENT_CHANGES = 'changes',
|
|
242
|
+
PAGE_RELOAD = 'page-reload',
|
|
243
|
+
REQUEST_BOUNDS = 'request-bounds',
|
|
244
|
+
IFRAME_SCROLL = 'iframe-scroll',
|
|
245
|
+
CONTENTLET_HOVERED = 'contentlet-hovered'
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Event Subscription Interface
|
|
249
|
+
interface UVEEventSubscription {
|
|
250
|
+
unsubscribe: () => void;
|
|
251
|
+
event: string;
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Examples
|
|
256
|
+
|
|
257
|
+
### Basic Usage
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
import { getUVEState, createUVESubscription } from '@dotcms/uve';
|
|
261
|
+
import { UVEEventType, UVE_MODE } from '@dotcms/uve/types';
|
|
262
|
+
|
|
263
|
+
// Check if we're in the editor
|
|
264
|
+
const uveState = getUVEState();
|
|
265
|
+
if (uveState) {
|
|
266
|
+
console.log(`Running in ${uveState.mode} mode`);
|
|
267
|
+
|
|
268
|
+
// Initialize components based on editor state
|
|
269
|
+
if (uveState.mode === UVE_MODE.EDIT) {
|
|
270
|
+
enableEditFeatures();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Content Updates
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
import { createUVESubscription } from '@dotcms/uve';
|
|
279
|
+
import { UVEEventType } from '@dotcms/uve/types';
|
|
280
|
+
|
|
281
|
+
// Subscribe to content changes
|
|
282
|
+
const subscription = createUVESubscription(UVEEventType.CONTENT_CHANGES, (changes) => {
|
|
283
|
+
// Update your UI with the new content
|
|
284
|
+
updateUI(changes);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Clean up when component unmounts
|
|
288
|
+
function cleanup() {
|
|
289
|
+
subscription.unsubscribe();
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Inline Editing Integration
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
import { initInlineEditing } from '@dotcms/uve';
|
|
297
|
+
|
|
298
|
+
// Integrate with a block editor component
|
|
299
|
+
function setupBlockEditor(element, contentData) {
|
|
300
|
+
element.addEventListener('click', () => {
|
|
301
|
+
initInlineEditing('BLOCK_EDITOR', {
|
|
302
|
+
inode: contentData.inode,
|
|
303
|
+
language: contentData.languageId,
|
|
304
|
+
contentType: contentData.contentType,
|
|
305
|
+
fieldName: 'body',
|
|
306
|
+
content: contentData.content
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Contributing
|
|
313
|
+
|
|
314
|
+
We welcome contributions to the UVE SDK! Please follow these steps:
|
|
315
|
+
|
|
316
|
+
1. Fork the repository
|
|
317
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
318
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
319
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
320
|
+
5. Open a Pull Request
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
package/index.cjs.js
CHANGED
|
@@ -1,58 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _public = require('./public.cjs.js');
|
|
4
|
+
require('@dotcms/types');
|
|
5
|
+
require('@dotcms/types/internal');
|
|
4
6
|
|
|
5
|
-
/**
|
|
6
|
-
* Gets the current state of the Universal Visual Editor (UVE).
|
|
7
|
-
*
|
|
8
|
-
* This function checks if the code is running inside the DotCMS Universal Visual Editor
|
|
9
|
-
* and returns information about its current state, including the editor mode.
|
|
10
|
-
*
|
|
11
|
-
* @export
|
|
12
|
-
* @return {UVEState | undefined} Returns the UVE state object if running inside the editor,
|
|
13
|
-
* undefined otherwise.
|
|
14
|
-
*
|
|
15
|
-
* The state includes:
|
|
16
|
-
* - mode: The current editor mode (preview, edit, live)
|
|
17
|
-
* - languageId: The language ID of the current page setted on the UVE
|
|
18
|
-
* - persona: The persona of the current page setted on the UVE
|
|
19
|
-
* - variantName: The name of the current variant
|
|
20
|
-
* - experimentId: The ID of the current experiment
|
|
21
|
-
* - publishDate: The publish date of the current page setted on the UVE
|
|
22
|
-
*
|
|
23
|
-
* @note The absence of any of these properties means that the value is the default one.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* const editorState = getUVEState();
|
|
28
|
-
* if (editorState?.mode === 'edit') {
|
|
29
|
-
* // Enable editing features
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
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
|
-
};
|
|
56
|
-
}
|
|
57
7
|
|
|
58
|
-
|
|
8
|
+
|
|
9
|
+
exports.createUVESubscription = _public.createUVESubscription;
|
|
10
|
+
exports.editContentlet = _public.editContentlet;
|
|
11
|
+
exports.enableBlockEditorInline = _public.enableBlockEditorInline;
|
|
12
|
+
exports.getUVEState = _public.getUVEState;
|
|
13
|
+
exports.initInlineEditing = _public.initInlineEditing;
|
|
14
|
+
exports.initUVE = _public.initUVE;
|
|
15
|
+
exports.reorderMenu = _public.reorderMenu;
|
|
16
|
+
exports.sendMessageToUVE = _public.sendMessageToUVE;
|
|
17
|
+
exports.updateNavigation = _public.updateNavigation;
|
package/index.esm.js
CHANGED
|
@@ -1,56 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Gets the current state of the Universal Visual Editor (UVE).
|
|
5
|
-
*
|
|
6
|
-
* This function checks if the code is running inside the DotCMS Universal Visual Editor
|
|
7
|
-
* and returns information about its current state, including the editor mode.
|
|
8
|
-
*
|
|
9
|
-
* @export
|
|
10
|
-
* @return {UVEState | undefined} Returns the UVE state object if running inside the editor,
|
|
11
|
-
* undefined otherwise.
|
|
12
|
-
*
|
|
13
|
-
* The state includes:
|
|
14
|
-
* - mode: The current editor mode (preview, edit, live)
|
|
15
|
-
* - languageId: The language ID of the current page setted on the UVE
|
|
16
|
-
* - persona: The persona of the current page setted on the UVE
|
|
17
|
-
* - variantName: The name of the current variant
|
|
18
|
-
* - experimentId: The ID of the current experiment
|
|
19
|
-
* - publishDate: The publish date of the current page setted on the UVE
|
|
20
|
-
*
|
|
21
|
-
* @note The absence of any of these properties means that the value is the default one.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const editorState = getUVEState();
|
|
26
|
-
* if (editorState?.mode === 'edit') {
|
|
27
|
-
* // Enable editing features
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
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
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { getUVEState };
|
|
1
|
+
export { c as createUVESubscription, e as editContentlet, a as enableBlockEditorInline, g as getUVEState, i as initInlineEditing, b as initUVE, r as reorderMenu, s as sendMessageToUVE, u as updateNavigation } from './public.esm.js';
|
|
2
|
+
import '@dotcms/types';
|
|
3
|
+
import '@dotcms/types/internal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/internal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./internal.cjs.js').default;
|
package/internal.cjs.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _public = require('./public.cjs.js');
|
|
4
|
+
require('@dotcms/types');
|
|
5
|
+
require('@dotcms/types/internal');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TinyMCE default config across all versions
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
const __DEFAULT_TINYMCE_CONFIG__ = {
|
|
13
|
+
menubar: false,
|
|
14
|
+
inline: true,
|
|
15
|
+
valid_styles: {
|
|
16
|
+
'*': 'font-size,font-family,color,text-decoration,text-align'
|
|
17
|
+
},
|
|
18
|
+
powerpaste_word_import: 'clean',
|
|
19
|
+
powerpaste_html_import: 'clean',
|
|
20
|
+
suffix: '.min' // Suffix to use when loading resources
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* TinyMCE config to use per mode
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
const __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = {
|
|
28
|
+
full: {
|
|
29
|
+
plugins: 'link lists autolink charmap',
|
|
30
|
+
toolbar: ['styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'],
|
|
31
|
+
style_formats: [{
|
|
32
|
+
title: 'Paragraph',
|
|
33
|
+
format: 'p'
|
|
34
|
+
}, {
|
|
35
|
+
title: 'Header 1',
|
|
36
|
+
format: 'h1'
|
|
37
|
+
}, {
|
|
38
|
+
title: 'Header 2',
|
|
39
|
+
format: 'h2'
|
|
40
|
+
}, {
|
|
41
|
+
title: 'Header 3',
|
|
42
|
+
format: 'h3'
|
|
43
|
+
}, {
|
|
44
|
+
title: 'Header 4',
|
|
45
|
+
format: 'h4'
|
|
46
|
+
}, {
|
|
47
|
+
title: 'Header 5',
|
|
48
|
+
format: 'h5'
|
|
49
|
+
}, {
|
|
50
|
+
title: 'Header 6',
|
|
51
|
+
format: 'h6'
|
|
52
|
+
}, {
|
|
53
|
+
title: 'Pre',
|
|
54
|
+
format: 'pre'
|
|
55
|
+
}, {
|
|
56
|
+
title: 'Code',
|
|
57
|
+
format: 'code'
|
|
58
|
+
}]
|
|
59
|
+
},
|
|
60
|
+
plain: {
|
|
61
|
+
plugins: '',
|
|
62
|
+
toolbar: ''
|
|
63
|
+
},
|
|
64
|
+
minimal: {
|
|
65
|
+
plugins: 'link autolink',
|
|
66
|
+
toolbar: 'bold italic underline | link',
|
|
67
|
+
valid_elements: 'strong,em,span[style],a[href]'
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* TinyMCE path
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
const __TINYMCE_PATH_ON_DOTCMS__ = '/ext/tinymcev7/tinymce.min.js';
|
|
76
|
+
|
|
77
|
+
exports.CUSTOM_NO_COMPONENT = _public.CUSTOM_NO_COMPONENT;
|
|
78
|
+
exports.DEVELOPMENT_MODE = _public.DEVELOPMENT_MODE;
|
|
79
|
+
exports.EMPTY_CONTAINER_STYLE_ANGULAR = _public.EMPTY_CONTAINER_STYLE_ANGULAR;
|
|
80
|
+
exports.EMPTY_CONTAINER_STYLE_REACT = _public.EMPTY_CONTAINER_STYLE_REACT;
|
|
81
|
+
exports.END_CLASS = _public.END_CLASS;
|
|
82
|
+
exports.PRODUCTION_MODE = _public.PRODUCTION_MODE;
|
|
83
|
+
exports.START_CLASS = _public.START_CLASS;
|
|
84
|
+
exports.__UVE_EVENTS__ = _public.__UVE_EVENTS__;
|
|
85
|
+
exports.__UVE_EVENT_ERROR_FALLBACK__ = _public.__UVE_EVENT_ERROR_FALLBACK__;
|
|
86
|
+
exports.combineClasses = _public.combineClasses;
|
|
87
|
+
exports.computeScrollIsInBottom = _public.computeScrollIsInBottom;
|
|
88
|
+
exports.findDotCMSElement = _public.findDotCMSElement;
|
|
89
|
+
exports.findDotCMSVTLData = _public.findDotCMSVTLData;
|
|
90
|
+
exports.getClosestDotCMSContainerData = _public.getClosestDotCMSContainerData;
|
|
91
|
+
exports.getColumnPositionClasses = _public.getColumnPositionClasses;
|
|
92
|
+
exports.getContainersData = _public.getContainersData;
|
|
93
|
+
exports.getContentletsInContainer = _public.getContentletsInContainer;
|
|
94
|
+
exports.getDotCMSContainerData = _public.getDotCMSContainerData;
|
|
95
|
+
exports.getDotCMSContentletsBound = _public.getDotCMSContentletsBound;
|
|
96
|
+
exports.getDotCMSPageBounds = _public.getDotCMSPageBounds;
|
|
97
|
+
exports.getDotContainerAttributes = _public.getDotContainerAttributes;
|
|
98
|
+
exports.getDotContentletAttributes = _public.getDotContentletAttributes;
|
|
99
|
+
exports.isValidBlocks = _public.isValidBlocks;
|
|
100
|
+
exports.setBounds = _public.setBounds;
|
|
101
|
+
exports.__BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__;
|
|
102
|
+
exports.__DEFAULT_TINYMCE_CONFIG__ = __DEFAULT_TINYMCE_CONFIG__;
|
|
103
|
+
exports.__TINYMCE_PATH_ON_DOTCMS__ = __TINYMCE_PATH_ON_DOTCMS__;
|
package/internal.cjs.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/internal";
|
package/internal.esm.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export { C as CUSTOM_NO_COMPONENT, D as DEVELOPMENT_MODE, h as EMPTY_CONTAINER_STYLE_ANGULAR, f as EMPTY_CONTAINER_STYLE_REACT, E as END_CLASS, P as PRODUCTION_MODE, S as START_CLASS, _ as __UVE_EVENTS__, d as __UVE_EVENT_ERROR_FALLBACK__, q as combineClasses, p as computeScrollIsInBottom, n as findDotCMSElement, o as findDotCMSVTLData, m as getClosestDotCMSContainerData, t as getColumnPositionClasses, w as getContainersData, x as getContentletsInContainer, l as getDotCMSContainerData, k as getDotCMSContentletsBound, j as getDotCMSPageBounds, y as getDotContainerAttributes, v as getDotContentletAttributes, A as isValidBlocks, z as setBounds } from './public.esm.js';
|
|
2
|
+
import '@dotcms/types';
|
|
3
|
+
import '@dotcms/types/internal';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TinyMCE default config across all versions
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const __DEFAULT_TINYMCE_CONFIG__ = {
|
|
11
|
+
menubar: false,
|
|
12
|
+
inline: true,
|
|
13
|
+
valid_styles: {
|
|
14
|
+
'*': 'font-size,font-family,color,text-decoration,text-align'
|
|
15
|
+
},
|
|
16
|
+
powerpaste_word_import: 'clean',
|
|
17
|
+
powerpaste_html_import: 'clean',
|
|
18
|
+
suffix: '.min' // Suffix to use when loading resources
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* TinyMCE config to use per mode
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
const __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = {
|
|
26
|
+
full: {
|
|
27
|
+
plugins: 'link lists autolink charmap',
|
|
28
|
+
toolbar: ['styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'],
|
|
29
|
+
style_formats: [{
|
|
30
|
+
title: 'Paragraph',
|
|
31
|
+
format: 'p'
|
|
32
|
+
}, {
|
|
33
|
+
title: 'Header 1',
|
|
34
|
+
format: 'h1'
|
|
35
|
+
}, {
|
|
36
|
+
title: 'Header 2',
|
|
37
|
+
format: 'h2'
|
|
38
|
+
}, {
|
|
39
|
+
title: 'Header 3',
|
|
40
|
+
format: 'h3'
|
|
41
|
+
}, {
|
|
42
|
+
title: 'Header 4',
|
|
43
|
+
format: 'h4'
|
|
44
|
+
}, {
|
|
45
|
+
title: 'Header 5',
|
|
46
|
+
format: 'h5'
|
|
47
|
+
}, {
|
|
48
|
+
title: 'Header 6',
|
|
49
|
+
format: 'h6'
|
|
50
|
+
}, {
|
|
51
|
+
title: 'Pre',
|
|
52
|
+
format: 'pre'
|
|
53
|
+
}, {
|
|
54
|
+
title: 'Code',
|
|
55
|
+
format: 'code'
|
|
56
|
+
}]
|
|
57
|
+
},
|
|
58
|
+
plain: {
|
|
59
|
+
plugins: '',
|
|
60
|
+
toolbar: ''
|
|
61
|
+
},
|
|
62
|
+
minimal: {
|
|
63
|
+
plugins: 'link autolink',
|
|
64
|
+
toolbar: 'bold italic underline | link',
|
|
65
|
+
valid_elements: 'strong,em,span[style],a[href]'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* TinyMCE path
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
const __TINYMCE_PATH_ON_DOTCMS__ = '/ext/tinymcev7/tinymce.min.js';
|
|
74
|
+
|
|
75
|
+
export { __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__, __DEFAULT_TINYMCE_CONFIG__, __TINYMCE_PATH_ON_DOTCMS__ };
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/uve",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.31",
|
|
4
4
|
"description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/dotCMS/core.git#main"
|
|
8
8
|
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@dotcms/types": "next"
|
|
11
|
+
},
|
|
9
12
|
"keywords": [
|
|
10
13
|
"dotCMS",
|
|
11
14
|
"CMS",
|
|
@@ -21,11 +24,11 @@
|
|
|
21
24
|
"import": "./index.cjs.mjs",
|
|
22
25
|
"default": "./index.cjs.js"
|
|
23
26
|
},
|
|
24
|
-
"./
|
|
25
|
-
"module": "./
|
|
26
|
-
"types": "./
|
|
27
|
-
"import": "./
|
|
28
|
-
"default": "./
|
|
27
|
+
"./internal": {
|
|
28
|
+
"module": "./internal.esm.js",
|
|
29
|
+
"types": "./internal.esm.d.ts",
|
|
30
|
+
"import": "./internal.cjs.mjs",
|
|
31
|
+
"default": "./internal.cjs.js"
|
|
29
32
|
}
|
|
30
33
|
},
|
|
31
34
|
"typesVersions": {
|
|
@@ -33,8 +36,8 @@
|
|
|
33
36
|
".": [
|
|
34
37
|
"./src/index.d.ts"
|
|
35
38
|
],
|
|
36
|
-
"
|
|
37
|
-
"./src/
|
|
39
|
+
"internal": [
|
|
40
|
+
"./src/internal.d.ts"
|
|
38
41
|
]
|
|
39
42
|
}
|
|
40
43
|
},
|