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.

See

See also WE_API.Common.execute.

Example

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

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

Implementation of

SNAPConnect.execute


getElementStatus

getElementStatus(previewId): Promise<SNAPStatus>

Fetches the SNAPStatus of the given PreviewId.

Since

snap 1.2.0

Parameters

Name Type
previewId string

Returns

Promise<SNAPStatus>

Implementation of

SNAPConnect.getElementStatus


getPreviewElement

getPreviewElement(): Promise<string>

Returns the PreviewId of the ContentCreator scope.

Since

snap 1.2.0

Returns

Promise<string>

Promise: the PreviewId

Implementation of

SNAPConnect.getPreviewElement


moveSection

moveSection(source, target, options?): boolean

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

Since

snap 1.2.4

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.

Implementation of

SNAPConnect.moveSection


overrideDefaultButton

overrideDefaultButton(defaultButtonName, buttonOverrides): void

Override a default button on the element decoration.

Parameters

Name Type Description
defaultButtonName string Available button names: edit , metadata , add-sibling-section , add-child-section , add-child-section-body , workflows , delete , crop , translate , move , and bookmark.
buttonOverrides null | SNAPButton Overrides given methods, null removes the default button.

Returns

void

Implementation of

SNAPConnect.overrideDefaultButton


processWorkflow

processWorkflow(previewId, transition): Promise<SNAPStatus>

Processes a Workflow transition.

Since

snap 1.2.0

Parameters

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

Returns

Promise<SNAPStatus>

Implementation of

SNAPConnect.processWorkflow


registerButton

registerButton(button, index): void

Define a custom button on the element decoration.

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

Parameters

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

Returns

void

Implementation of

SNAPConnect.registerButton


renderElement

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

Renders the given PreviewId.

Since

snap 1.2.0

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.

Implementation of

SNAPConnect.renderElement


showEditDialog

showEditDialog(previewId): void

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

Since

snap 1.2.0

Parameters

Name Type Description
previewId string The associated PreviewId.

Returns

void

Implementation of

SNAPConnect.showEditDialog


showMessage

showMessage(message, kind, title?): void

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

Since

snap 1.2.24

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

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

Example

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

Parameters

Name Type Description
previewId string The associated PreviewId.

Returns

void

Implementation of

SNAPConnect.showMetaDataDialog


showQuestion

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

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

Since

snap 1.2.24

Parameters

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

Returns

Promise<boolean>

Implementation of

SNAPConnect.showQuestion


startWorkflow

startWorkflow(previewId, workflow): Promise<unknown>

Starts a FirstSpirit Workflow on the given PreviewId.

Since

snap 1.2.0

Parameters

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

Returns

Promise<unknown>

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 1, 2023