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
See
See also WE_API.Common.execute.
Example
Implementation of
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
getPreviewElement
▸ getPreviewElement(): Promise
\<string
>
Returns the PreviewId of the ContentCreator scope.
Returns
Promise
\<string
>
Promise
Since
snap 1.2.0
Implementation of
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
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
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
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
Since
snap 1.2.0
Implementation of
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
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
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
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
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
getInstance
▸ Static
getInstance(): TPPBroker