Index
Types
CreateLinkOptions
Type declaration
-
include
Params: string[]
OpenPolicyOptions
Type declaration
-
template
Href: string An optional template for the link to use when the policy is not set to
SAME_FRAME
, that will have any${[param]}
substrings interpolated using the current set of URL parameters.If
${[param]}
is included in the path of the URL, it will be replaced by the current URL parameter's value or undefined (${m}/show
:abc123/show
).If
${[param]}
is included in the search parameters of the URL, it and it's value wil be appended ot the URL (${m}
:m=abc123
).URL parameters that are unset will be appended without a value. (
${unset}
:unset
)Note:
${m}
or `${model} are special cases in model links. Instead of the current window's "model" param, the model ID from the link will be used instead.As an example, the string
"https://my.domain.com/${m}/show.html?${play}&${unset}"
interpolated at the URLhttps://my.domain.com/show/?m=abc123&play=1
will result in a URL like"https://my.domain.com/abc123/show.html?play=1&unset&m=abc123"
.
Methods
createDeepLink
-
Create a deep link to the current location of the current Showcase player.
const deepLink = await sdk.Link.createDeepLink();
Returns Promise<string>
createLink
-
Create a shareable link to the current Showcase player.
const link = await sdk.Link.createLink();
Returns Promise<string>
setExternalLinkPolicy
-
Change the behavior of clicking a link to a different origin.
sdk.Link.setExternalLinkPolicy(false); // clicking an external link will now navigate the current page (not the Showcase iframe) to the link
Parameters
-
openInNewWindow: boolean
Open the link in a new tab or window; otherwise, replace the embedder's window. true is the default behavior.
Returns Promise<void>
-
setModelLinkPolicy
-
Change the behavior of clicking a link to another model.
sdk.Link.setModelLinkPolicy(sdk.Link.OpenPolicy.NEW_WINDOW); // clicking a link to another model will now open a new window
Parameters
-
policy: Link.OpenPolicy
-
Optional options: Partial<Link.OpenPolicyOptions>
Returns Promise<void>
-
-
Parameters
-
policy: Link.OpenPolicy
-
destination: Link.DestinationPolicy
Returns Promise<void>
-
setNavigationLinkPolicy
-
Change the behavior of clicking a link to a location within the current model.
// when clicking a link with a location within the current model, open a new window with the model at the location // instead of navigating the current model to the new location sdk.Link.setNavigationLinkPolicy(sdk.Link.OpenPolicy.NEW_WINDOW, { templateHref: 'https://example.com/${m}/show.html?', }); // revert the navigation link behavior to the default sdk.Link.setNavigationLinkPolicy(sdk.Link.OpenPolicy.DEFAULT);
Parameters
-
policy: Link.OpenPolicy
-
Optional options: Partial<Link.OpenPolicyOptions>
Returns Promise<void>
-
setSameOriginLinkPolicy
-
Change the behavior of clicking a link to a page from the same origin as the one hosting Showcase.
sdk.Link.setSameOriginLinkPolicy(sdk.Link.OpenPolicy.CURRENT_WINDOW); // clicking a link with the same origin as Showcase's embedder will now navigate the embedding page sdk.Link.setSameOriginLinkPolicy(sdk.Link.OpenPolicy.SAME_FRAME); // clicking a link with the same origin as Showcase's embedder will now navigate Showcase's iframe to that page
Parameters
-
policy: Link.OpenPolicy
Returns Promise<void>
-
setShareLinkPolicy
-
Change how the link the share dialog and the createLink and createDeepLink links are created.
await sdk.Link.setShareLinkPolicy(sdk.Link.CreationPolicy.REFERRER); const link = await sdk.Link.createLink(); console.log(link); // should log a link to your page that embeds Showcase
Parameters
-
policy: Link.CreationPolicy
-
Optional options: Partial<Link.CreateLinkOptions>
Returns Promise<void>
-
The list of URL parameters to include in the share link