From ecdd8057ebf550ace7f2afdb0c5cc71094de79fe Mon Sep 17 00:00:00 2001 From: Tobias Lopez Date: Tue, 18 Nov 2025 15:28:47 +0100 Subject: [PATCH] feat: raise event on when displaying block preview --- .../blockEditor/block-grid-preview.custom-view.element.ts | 7 +++++++ .../blockEditor/block-list-preview.custom-view.element.ts | 6 ++++++ .../blockEditor/rich-text-preview.custom-view.element.ts | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-grid-preview.custom-view.element.ts b/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-grid-preview.custom-view.element.ts index 49bdb90d..5dbe3991 100644 --- a/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-grid-preview.custom-view.element.ts +++ b/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-grid-preview.custom-view.element.ts @@ -332,6 +332,13 @@ export class BlockGridPreviewCustomView if (data) { this._htmlMarkup = data ?? ''; this._isLoading = false; + + document.body.dispatchEvent(new CustomEvent('umb-block-preview-rendered', { + detail: { + host: this, + html: this._htmlMarkup + } + })); } else if (UmbApiError.isUmbApiError(error)) { this._error = error.message; diff --git a/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-list-preview.custom-view.element.ts b/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-list-preview.custom-view.element.ts index 6306a56f..962eae1c 100644 --- a/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-list-preview.custom-view.element.ts +++ b/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-list-preview.custom-view.element.ts @@ -300,6 +300,12 @@ export class BlockListPreviewCustomView if (data) { this._htmlMarkup = data ?? ''; this._isLoading = false; + document.body.dispatchEvent(new CustomEvent('umb-block-list-preview-rendered', { + detail: { + host: this, + html: this._htmlMarkup + } + })); } else if (UmbApiError.isUmbApiError(error)) { this._error = error.message; diff --git a/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/rich-text-preview.custom-view.element.ts b/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/rich-text-preview.custom-view.element.ts index 737b6bfd..2c4ba89d 100644 --- a/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/rich-text-preview.custom-view.element.ts +++ b/src/Umbraco.Community.BlockPreview.UI/src/blockEditor/rich-text-preview.custom-view.element.ts @@ -255,6 +255,12 @@ export class RichTextPreviewCustomView if (data) { this._htmlMarkup = data ?? ''; this._isLoading = false; + document.body.dispatchEvent(new CustomEvent('umb-block-rte-preview-rendered', { + detail: { + host: this, + html: this._htmlMarkup + } + })); } else if (UmbApiError.isUmbApiError(error)) { this._error = error.message;