Skip to content

Commit

Permalink
feat: Add new event triggered on DOM updates
Browse files Browse the repository at this point in the history
A new event is introduced that triggers when changes are made in the Storyblok Visual Editor.
This is particularly helpful for generating CSS dynamically, as outlined in issue #864.
  • Loading branch information
dipankarmaikap committed Dec 24, 2024
1 parent 480071d commit 6843041
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/live-preview/handleStoryblokMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export async function handleStoryblokMessage(event: {
// Get current focused element in Storyblok
const focusedElem = document.querySelector('[data-blok-focused="true"]');
updateDOMWithNewBody(currentBody, newBody, focusedElem);
// Dispatch a custom event after the body update
document.dispatchEvent(new Event('storyblok-live-preview-updated'));
};
const debounceDelay = 500; // Adjust the delay as needed
clearTimeout(timeout);
Expand Down

0 comments on commit 6843041

Please sign in to comment.