Skip to content

feat(uve): expose window.dotUVE.createContentlet to create contentlets without adding them to the page#35282

Merged
rjvelazco merged 7 commits intomainfrom
issue-33415-task-uve-provide-windowcreatecontentlet-to-create-contentlets-v2
Apr 10, 2026
Merged

feat(uve): expose window.dotUVE.createContentlet to create contentlets without adding them to the page#35282
rjvelazco merged 7 commits intomainfrom
issue-33415-task-uve-provide-windowcreatecontentlet-to-create-contentlets-v2

Conversation

@rjvelazco
Copy link
Copy Markdown
Member

@rjvelazco rjvelazco commented Apr 10, 2026

Summary

Implements #33415 — restoring the ability to create a contentlet from within the UVE without automatically dropping it onto the page layout.

In dotCMS v2, customers used window.parent.addContentlet for this. That API broke in v24. This PR introduces window.dotUVE.createContentlet(contentTypeVariable) as the supported replacement.

What changed

  • Added CREATE_CONTENTLET = 'create-contentlet' to the DotCMSUVEAction enum (@dotcms/types)
  • Added createContentlet(contentType: string) to the UVE public API (@dotcms/uve)
  • Exposed createContentlet on the window.dotUVE global object (sdk-editor.ts)
  • Handled the CREATE_CONTENTLET postMessage action in the UVE editor — opens the creation dialog via createContentletFromPalette without an actionPayload, so the contentlet is saved to the system but not inserted into the page
  • Added unit tests for the new function

How to use

Traditional (VTL / JSP pages)

In any VTL template or widget running inside the UVE iframe, call:

window.dotUVE.createContentlet('calendarEvent');

This opens the creation dialog for the calendarEvent content type. When the user saves, the contentlet is created in dotCMS and the page reloads — the contentlet is not added to the current page layout.

Example use case: A widget that renders all events for the current month. The editor wants to create a new event without dropping it on the page — the widget will pull it in automatically on the next render.

## dotUVE_widget.vtl
<button onclick="window.dotUVE.createContentlet('$contentTypeVariable')">
  Create new $contentTypeName
</button>

Headless (Next.js / React / Angular SDK)

Import createContentlet from @dotcms/uve and call it wherever needed:

import { createContentlet } from '@dotcms/uve';

// Opens the creation dialog for the 'Event' content type
// The new contentlet will NOT be added to the page layout
createContentlet('calendarEvent');

Example — React component:

import { createContentlet } from '@dotcms/uve';
import { getUVEState } from '@dotcms/uve';

export function CreateEventButton() {
  const isInEditor = !!getUVEState();

  if (!isInEditor) return null;

  return (
    <button onClick={() => createContentlet('calendarEvent')}>
      Create Event
    </button>
  );
}

The createContentlet call sends a postMessage to the UVE parent frame, which opens the standard dotCMS content creation dialog. On save, the page refreshes to reflect the new content — but the contentlet is never inserted into the page containers.


Video

video.mov

This PR fixes: #33415

This PR fixes: #33415

@github-actions github-actions bot added Area : Backend PR changes Java/Maven backend code Area : Frontend PR changes Angular/TypeScript frontend code Area : SDK PR changes SDK libraries labels Apr 10, 2026
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 10, 2026

Claude finished @rjvelazco's task in 3m 7s —— View job


Claude finished @rjvelazco's task in 1m 7s —— View job


I'll analyze this and get back to you.

@rjvelazco rjvelazco changed the title feat(edit-ema): add create contentlet functionality to editor feat(uve): expose window.dotUVE.createContentlet to create contentlets without adding them to the page Apr 10, 2026
@rjvelazco rjvelazco changed the title feat(uve): expose window.dotUVE.createContentlet to create contentlets without adding them to the page feat(uve): expose window.dotUVE.createContentlet to create contentlets without adding them to the page Apr 10, 2026
@nollymar nollymar enabled auto-merge April 10, 2026 15:44
@rjvelazco rjvelazco disabled auto-merge April 10, 2026 15:53
…create-contentlets-v2' of https://github.com/dotCMS/core into issue-33415-task-uve-provide-windowcreatecontentlet-to-create-contentlets-v2
@rjvelazco rjvelazco enabled auto-merge April 10, 2026 15:57
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 10, 2026

Rollback Safety Analysis

All changes in this PR are pure frontend (TypeScript/JavaScript SDK and Angular components). No database migrations, no Elasticsearch mapping changes, no Java backend code, and no REST API contract changes.

Checked against all rollback-unsafe categories (C-1 through C-4, H-1 through H-7, M-1 through M-4): none match.

This PR is safe to rollback.

@rjvelazco rjvelazco added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 9a50881 Apr 10, 2026
50 checks passed
@rjvelazco rjvelazco deleted the issue-33415-task-uve-provide-windowcreatecontentlet-to-create-contentlets-v2 branch April 10, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code Area : Frontend PR changes Angular/TypeScript frontend code Area : SDK PR changes SDK libraries

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[TASK] UVE: Provide window.createContentlet to Create Contentlets

3 participants