Passa al contenuto principale

WrUtils

webround-docs


webround-docs / WrUtils

Interface: WrUtils

Defined in: wr.d.ts:1273

Utility functions available in every custom component.

Available as wr.utils.

Methods

changeLanguage()

changeLanguage(lang): void

Defined in: wr.d.ts:1295

Switch the active language on a multilingual site.

Parameters

lang

string

Returns

void

Example

wr.utils.changeLanguage('it')

generateHref()

generateHref(path): string

Defined in: wr.d.ts:1282

Generate a localized href for SPA navigation. Handles anchor links, external URLs, and relative paths automatically.

Parameters

path

string

Returns

string

Example

<a href={wr.utils.generateHref('/shop')}>Shop</a>

getAltchaChallenge()

getAltchaChallenge(): Promise<string>

Defined in: wr.d.ts:1302

Fetch an Altcha CAPTCHA challenge token for form protection. Returns null when called from within the editor.

Returns

Promise<string>

Example

const proof = await wr.utils.getAltchaChallenge()

navigate(path, options?): void

Defined in: wr.d.ts:1289

Trigger a client-side navigation without a full page reload. For anchor links (#section), smoothly scrolls to the target element.

Parameters

path

string

options?

Record<string, any>

Returns

void

Example

wr.utils.navigate('/shop')

submitForm()

submitForm(fields, files?, proof?): Promise<boolean>

Defined in: wr.d.ts:1316

Submit a contact or lead-capture form. Returns true immediately when called from within the editor.

Parameters

fields

Record<string, any>

files?

File[]

proof?

string

Returns

Promise<boolean>

Example

const ok = await wr.utils.submitForm(
{ name: 'Alice', email: '[email protected]' },
[],
altchaProof
)