Skip to content

Commit 4abd899

Browse files
committed
feat(UVE): Integrate Universal Visual Editor (UVE) package
- Added @dotcms/uve as a dependency in package.json and package-lock.json. - Updated README.md with instructions for enabling UVE and initializing it in app.js. - Refactored app.js to use createUVESubscription for real-time updates on content changes.
1 parent f2a5964 commit 4abd899

4 files changed

Lines changed: 48 additions & 6 deletions

File tree

examples/dotcms-laravel/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,42 @@ This command starts Laravel's built-in development server on port 8000, providin
488488

489489
2. Visit `http://localhost:8000` in your browser. The application will fetch and render pages from your DotCMS instance.
490490

491+
## Enable Universal Visual Editor (UVE)
492+
493+
To enable the Universal Visual Editor (UVE) for in-context editing:
494+
495+
1. Install the UVE package:
496+
497+
```bash
498+
npm install @dotcms/uve
499+
```
500+
501+
2. Update your `resources/js/app.js` to initialize UVE:
502+
503+
```javascript
504+
import {createUVESubscription} from '@dotcms/uve';
505+
506+
import './bootstrap';
507+
508+
try {
509+
createUVESubscription('changes', (changes) => {
510+
window.location.reload();
511+
});
512+
} catch (error) {
513+
console.warn('dotUVE is not available, you might experience issues with the the Universal Visual Editor', error);
514+
}
515+
```
516+
517+
This setup enables real-time updates when content is edited through the Universal Visual Editor.
518+
491519
## How It Works
492520

493521
1. When a user visits a URL, the catch-all route directs the request to `AppController::index()`.
494522
2. The controller uses the `DotCMSClient` to fetch the page from DotCMS.
495523
3. The page data is passed to the Blade templates for rendering.
496524
4. DotCMS-specific helper functions assist with rendering containers and content.
497525
5. Content-type specific templates render each content type appropriately.
526+
6. The `createUVESubscription` is to subscribe to the pages changes that the user performs inside the UVE.
498527

499528
```mermaid
500529
sequenceDiagram

examples/dotcms-laravel/package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/dotcms-laravel/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
"laravel-vite-plugin": "^1.2.0",
1313
"tailwindcss": "^4.0.0",
1414
"vite": "^6.0.11"
15+
},
16+
"dependencies": {
17+
"@dotcms/uve": "^0.0.1-beta.29"
1518
}
1619
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import {createUVESubscription} from '@dotcms/uve';
2+
13
import './bootstrap';
24

3-
// dotUVE is a global variable that is set by the dotCMS UVE JavaScript API
4-
if (window.dotUVE) {
5-
window.dotUVE.createSubscription('changes', (changes) => {
5+
try {
6+
createUVESubscription('changes', (changes) => {
67
window.location.reload();
7-
})
8-
} else {
9-
console.warn('dotUVE is not available, you might experience issues with the the Universal Visual Editor');
8+
});
9+
} catch (error) {
10+
console.warn('dotUVE is not available, you might experience issues with the the Universal Visual Editor', error);
1011
}

0 commit comments

Comments
 (0)