Skip to content

Class: TPPBroker

This is a subset of the TPP_SNAP implementation. This will be provided via the PREVIEW_INITIALIZED hook.

SNAPConnect

Implements

Constructors

constructor

new TPPBroker()

Methods

execute

execute(identifier, params?, result?): Promise\<any>

Executes a project script or an executable.

Parameters

Name Type Description
identifier string script ("script:script_uid") or executable ("class:full.qualified.executable.ClassName")
params? object parameters (e.g.
result? boolean should wait for an result.

Returns

Promise\<any>

Promise: the result

See

See also WE_API.Common.execute.

Example

TPP_BROKER.execute('class:EditMenu', { node: 43 })
 .then(() => location.reload());

Implementation of

SNAPConnect.execute


getElementStatus

getElementStatus(previewId): Promise\<SNAPStatus>

Fetches the SNAPStatus of the given PreviewId.

Parameters

Name Type
previewId string

Returns

Promise\<SNAPStatus>

Since

snap 1.2.0

Implementation of

SNAPConnect.getElementStatus


getPreviewElement

getPreviewElement(): Promise\<string>

Returns the PreviewId of the ContentCreator scope.

Returns

Promise\<string>

Promise: the PreviewId

Since

snap 1.2.0

Implementation of

SNAPConnect.getPreviewElement


moveSection

moveSection(source, target, options?): boolean

Move a Section before or after another Section. Triggers SNAP.onRerenderView.

Parameters

Name Type Description
source string the PreviewId of the source section.
target string the PreviewId of the target section, body or page with a single body.
options? SNAPMoveSectionOptions

Returns

boolean

boolean true, if the operation was successful, false otherwise.

Since

snap 1.2.4

Implementation of

SNAPConnect.moveSection


processWorkflow

processWorkflow(previewId, transition): Promise\<SNAPStatus>

Processes a Workflow transition.

Parameters

Name Type Description
previewId string The associated PreviewId.
transition string A transition uid, can be found in SNAPStatus.

Returns

Promise\<SNAPStatus>

Since

snap 1.2.0

Implementation of

SNAPConnect.processWorkflow


registerButton

registerButton(button, index): void

Define a custom button on the element decoration.

Parameters

Name Type Description
button SNAPButton
index number The button index, used as rendering order; -1 means at the end.

Returns

void

Example

// register a debug button, as the first button, on any decorated element
TPP_BROKER.registerButton({
  css: 'tpp-icon-debug',
  execute: async (scope) => console.log(scope),
}, 0);

Since

snap 1.2.0

Implementation of

SNAPConnect.registerButton


renderElement

renderElement(previewId?): Promise\<string | object>

Renders the given PreviewId.

Parameters

Name Type Description
previewId? null | string The associated PreviewId; If not set, the StartNode will be rendered.

Returns

Promise\<string | object>

Promise: The rendering result of the FirstSpirit template; if the result is a JSON, the JSON will automatically be parsed. For FirstSpirit projects based on CaaS v3 the standard FirstSpirit json format is returned.

Since

snap 1.2.0

Implementation of

SNAPConnect.renderElement


showEditDialog

showEditDialog(previewId): void

Opens the "Edit Dialog" of a FirstSpirit StoreElement associated with the PreviewId. Triggers CONTENT_CHANGED.

Parameters

Name Type Description
previewId string The associated PreviewId.

Returns

void

Since

snap 1.2.0

Implementation of

SNAPConnect.showEditDialog


showMessage

showMessage(message, kind, title?): void

Shows a message in the ContentCreator, either an info or an error dialog.

Parameters

Name Type Description
message string The message to be displayed.
kind string The type of the message; either "info" or "error".
title? string The title of the dialog.

Returns

void

Since

snap 1.2.24

Implementation of

SNAPConnect.showMessage


showMetaDataDialog

showMetaDataDialog(previewId): void

Opens the Metadata Dialog of an FirstSpirit StoreElement associated with the PreviewId. MetaData providing elements must be allowed in the ContentCreator settings, see Content Creator Documentation . Triggers CONTENT_CHANGED

Parameters

Name Type Description
previewId string The associated PreviewId.

Returns

void

Example

// display the default button
TPP_BROKER.overrideDefaultButton('metadata', {
  isVisible: ({ status }) => !status.custom && (['PageRef', 'Page', 'Section', 'Media'].includes(status.elementType))
})

Implementation of

SNAPConnect.showMetaDataDialog


showQuestion

showQuestion(message, title?): Promise\<boolean>

Shows a question dialog in the ContentCreator, providing the answers Yes or No.

Parameters

Name Type Description
message string The question to be displayed.
title? string The title of the question dialog.

Returns

Promise\<boolean>

Since

snap 1.2.24

Implementation of

SNAPConnect.showQuestion


startWorkflow

startWorkflow(previewId, workflow): Promise\<unknown>

Starts a FirstSpirit Workflow on the given PreviewId.

Parameters

Name Type Description
previewId string The associated PreviewId.
workflow string A workflow uid, can be found in SNAPStatus.

Returns

Promise\<unknown>

Since

snap 1.2.0

Implementation of

SNAPConnect.startWorkflow


triggerChange

triggerChange(previewId, content): void

Triggers onContentChange Handler. Can be used if a Custom Button changes the content.

Parameters

Name Type Description
previewId string The target PreviewId.
content string | object The updated content, if null renderElement is called.

Returns

void

Implementation of

SNAPConnect.triggerChange


getInstance

Static getInstance(): TPPBroker

Returns

TPPBroker


Last update: December 20, 2024