@@ -4,9 +4,9 @@ import { resolveMessageProperties } from "./gist-properties-manager";
44import { embedHTMLTemplate } from "../templates/embed" ;
55import { messageHTMLTemplate } from "../templates/message" ;
66import { positions } from "./page-component-manager" ;
7+ import { wideOverlayPositions } from "../utilities/message-utils" ;
78
89const delay = ms => new Promise ( res => setTimeout ( res , ms ) ) ;
9- const wideOverlayPositions = [ "x-gist-top" , "x-gist-bottom" , "x-gist-floating-top" , "x-gist-floating-bottom" ] ;
1010
1111export function isElementLoaded ( elementId ) {
1212 var element = safelyFetchElement ( elementId ) ;
@@ -17,7 +17,7 @@ export function isElementLoaded(elementId) {
1717 }
1818}
1919
20- export function loadEmbedComponent ( elementId , url , message , options ) {
20+ export function loadEmbedComponent ( elementId , url , message , options , stepName = null ) {
2121 var element = safelyFetchElement ( elementId ) ;
2222 if ( element ) {
2323 var messageElementId = getMessageElementId ( message . instanceId ) ;
@@ -35,7 +35,7 @@ export function loadEmbedComponent(elementId, url, message, options) {
3535 element . style . height = "0px" ;
3636 }
3737 element . innerHTML = embed ( url , message , messageProperties ) ;
38- attachIframeLoadEvent ( messageElementId , options ) ;
38+ attachIframeLoadEvent ( messageElementId , options , stepName ) ;
3939 } else {
4040 log ( `Message could not be embedded, elementId ${ elementId } not found.` ) ;
4141 }
@@ -52,7 +52,11 @@ export function hideEmbedComponent(elementId) {
5252 var element = safelyFetchElement ( elementId ) ;
5353 if ( element ) {
5454 element . classList . remove ( "gist-visible" ) ;
55+ // Remove all gist-* classes (instanceId classes)
56+ const classesToRemove = Array . from ( element . classList ) . filter ( cls => cls . startsWith ( 'gist-' ) ) ;
57+ classesToRemove . forEach ( cls => element . classList . remove ( cls ) ) ;
5558 element . style . removeProperty ( "height" ) ;
59+ element . style . removeProperty ( "width" ) ;
5660 element . innerHTML = "" ;
5761 }
5862}
@@ -85,24 +89,36 @@ export function resizeComponent(message, size) {
8589 }
8690}
8791
88- export function loadOverlayComponent ( url , message , options ) {
92+ export function loadOverlayComponent ( url , message , options , stepName = null ) {
8993 document . body . insertAdjacentHTML ( 'afterbegin' , component ( url , message ) ) ;
90- attachIframeLoadEvent ( getMessageElementId ( message . instanceId ) , options ) ;
94+ attachIframeLoadEvent ( getMessageElementId ( message . instanceId ) , options , stepName ) ;
9195}
9296
93- function attachIframeLoadEvent ( elementId , options ) {
97+ function attachIframeLoadEvent ( elementId , options , stepName = null ) {
9498 const iframe = document . getElementById ( elementId ) ;
9599 if ( iframe ) {
96100 iframe . onload = function ( ) {
97- sendOptionsToIframe ( elementId , options ) ; // Send the options when iframe loads
101+ sendOptionsToIframe ( elementId , options , stepName ) ; // Send the options when iframe loads
98102 } ;
99103 }
100104}
101105
102- function sendOptionsToIframe ( iframeId , options ) {
106+ // SDK capabilities that can be communicated to the renderer
107+ const SDK_CAPABILITIES = [
108+ 'MultiStepDisplayTypes'
109+ ] ;
110+
111+ export function sendOptionsToIframe ( iframeId , options , stepName = null ) {
103112 const iframe = document . getElementById ( iframeId ) ;
104113 if ( iframe && iframe . contentWindow ) {
105- iframe . contentWindow . postMessage ( { options : options } , '*' ) ;
114+ const message = {
115+ options : options ,
116+ capabilities : SDK_CAPABILITIES
117+ } ;
118+ if ( stepName ) {
119+ options . stepId = stepName ;
120+ }
121+ iframe . contentWindow . postMessage ( message , '*' ) ;
106122 }
107123}
108124
0 commit comments