Skip to main content

Feature class

📖 Description​

The Feature class defines a feature in a Features collection. Features are used in Tripetto to create panels for managing the properties of elements like blocks. Each feature can control a single Card.

tip

For some examples of built-in features, see the EditorOrchestrator class.

See the Block editor guide for more information about editor panels.


🆕 constructor​

Creates a new Feature instance.

Signature​
constructor(features: Features, properties: IFeature): Feature
Parameters​
NameTypeOptionalDescription
featuresFeaturesNoReference to the features collection.
propertiesIFeatureNoSpecifies the properties for the feature.
Return value​

Returns a reference to the new Feature instance.

🗃ī¸ Fields​


🏷ī¸ card​

Retrieves the card.

Type​

Card | undefined


🏷ī¸ element​

Retrieves a reference to the feature element.

Type​

Element | undefined


🏷ī¸ features​

Retrieves a reference to the Features collection.

Type​

Features


🏷ī¸ isActivated​

Sets or retrieves if the feature is activated.

Type​

boolean


🏷ī¸ isAwaiting​

Sets or retrieves if the feature validation is awaiting.

Type​

boolean


🏷ī¸ isDisabled​

Sets or retrieves if the feature is disabled.

Type​

boolean


🏷ī¸ isFailed​

Sets or retrieves if the feature validation has failed.

Type​

boolean


🏷ī¸ isInvalid​

Sets or retrieves if the feature validation is invalid.

Type​

boolean


🏷ī¸ isLocked​

Sets or retrieves if the feature is locked.

Type​

boolean


🏷ī¸ isPassed​

Sets or retrieves if the feature validation has passed.

Type​

boolean


🏷ī¸ isVisible​

Sets or retrieves if the feature is visible.

Type​

boolean


🏷ī¸ name​

Sets or retrieves the feature name.

Type​

string


🏷ī¸ type​

Retrieves the feature type.

Type​

"card" | "toggle" | "static"


🏷ī¸ validation​

Sets or retrieves the validation state of the feature.

Type​

"unknown" | "fail" | "invalid" | "pass" | "await"

â–ļī¸ Methods​


🔧 activate​

Activates the feature.

Signature​
activate(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 activated​

Sets the feature state.

Signature​
activated(activated?: boolean): this
Parameters​
NameTypeOptionalDescription
activatedbooleanYesSpecifies if the feature is activated (default is true).
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 deactivate​

Deactivate the feature.

Signature​
deactivate(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 disable​

Disables the feature.

Signature​
disable(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 disabled​

Sets the feature disabled state.

Signature​
disabled(disabled?: boolean): this
Parameters​
NameTypeOptionalDescription
disabledbooleanYesSpecifies if the feature is disabled (default is true).
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 enable​

Enables the feature.

Signature​
enable(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 focus​

Sets focus to the feature.

Signature​
focus(): boolean
Return value​

boolean


🔧 hide​

Hides the feature.

Signature​
hide(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 lock​

Locks the feature.

Signature​
lock(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 locked​

Sets the feature locking state.

Signature​
locked(locked?: boolean): this
Parameters​
NameTypeOptionalDescription
lockedbooleanYesSpecifies if the feature is locked (default is true).
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 onDisable​

Attaches an OnDisable function to the feature. This function is invoked when the disabled state of the feature changes.

Signature​
onDisable(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parameters​
NameTypeOptionalDescription
fn(feature: Feature) => voidNoSpecifies the callback function.
mode"synchronous" | "asynchronous"YesSpecifies the callback mode (default is synchronous).
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 onLock​

Attaches an OnLock function to the feature. This function is invoked when the lock state of the feature changes.

Signature​
onLock(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parameters​
NameTypeOptionalDescription
fn(feature: Feature) => voidNoSpecifies the callback function.
mode"synchronous" | "asynchronous"YesSpecifies the callback mode (default is synchronous).
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 onToggle​

Attaches an OnToggle function to the feature. This function is invoked when the toggle state of the feature changes.

Signature​
onToggle(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parameters​
NameTypeOptionalDescription
fn(feature: Feature) => voidNoSpecifies the callback function.
mode"synchronous" | "asynchronous"YesSpecifies the callback mode (default is synchronous).
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 onVisible​

Attaches an OnVisible function to the feature. This function is invoked when the visibility of the feature changes.

Signature​
onVisible(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parameters​
NameTypeOptionalDescription
fn(feature: Feature) => voidNoSpecifies the callback function.
mode"synchronous" | "asynchronous"YesSpecifies the callback mode (default is synchronous).
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 scrollIntoView​

Scrolls the feature into view.

Signature​
scrollIntoView(): void

🔧 show​

Shows the feature.

Signature​
show(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 style​

Applies styles to the feature.

Signature​
style(style: IStyles): this
Parameters​
NameTypeOptionalDescription
styleIStylesNoSpecifies the styles.
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 unlock​

Unlocks the feature.

Signature​
unlock(): this
Return value​

Returns a reference to the Feature instance to allow chaining.


🔧 visible​

Sets the feature visibility.

Signature​
visible(visible?: boolean): this
Parameters​
NameTypeOptionalDescription
visiblebooleanYesSpecifies if the feature is visible (default is true).
Return value​

Returns a reference to the Feature instance to allow chaining.

⛓ī¸ Interfaces​


🔗 IFeature​

Defines the feature properties.

Type declaration​
interface IFeature {
  type: "card" | "toggle" | "static";
  option: boolean;
  name: string;
  card?: Card;Optional
}
🖱ī¸ Hover with the mouse over a property name for a tooltip with the description of that property. Click it for more information.

🏷ī¸ card​

Reference to the Card that is controlled by the feature.

Type​

Card


🏷ī¸ name​

Specifies the feature name.

Type​

string


🏷ī¸ option​

Specifies if the feature is an option.

Type​

boolean


🏷ī¸ type​

Specifies the feature type.

Type​

"card" | "toggle" | "static"