ZUI

Search documentation

Find a page or a heading.

SMS Editor

A plain-text editor for one SMS body with {{name}} variables and a meter of the segments it will cost.

tsx

Installation

bash

Installing it also installs the email editor's files, since the variable pills and the problem markers are shared between the two.

Usage

tsx
tsx

The body is plain text with no block and no mark; the only structure in it is a {{name}} variable. The meter under it counts the units the body uses of a segment in its encoding (GSM-7 or UCS-2), reading each variable as its literal {{name}} text, and turns to the sms-segment-exceeded problem when the body needs more segments than maxSegments allows (one by default).

API reference

SmsEditor

label is the editable surface's accessible name. readOnly shows the body, its problems and its cost with nothing that changes it: typing is refused and the variable menu is not drawn.

messages words every string the editor draws, as the email editor does; a key it leaves out stays English. Build it once per locale, outside the render or in a memo, since a new object rebuilds the menus' words. The meter reads smsMeter, which takes the units, the limit, the encoding (gsm7 or ucs2), the segments and the profile's maxSegments:

tsx

smsProfile takes variables and maxSegments.

Variables

Declare each variable once, in the profile, with a name of word characters, a type of string, duration, url or email, and optionally a label, a sampleValue and required. Typing {{ at any position opens the variable menu and picking one inserts a pill; a pill that is not declared is marked. A required variable that the body does not print is a problem.

When the declarations change, hand the editor a new profile and it redraws its pills itself. A host that edits the declarations in place calls refreshVariables(editor), from @/components/editor/profiles/variables/variable, so every pill reads its label again.

Validation

onValidate receives the problems on mount and whenever the list changes, and the server reads the same list with validate from @zeroxsolutions/editor-core/profiles/index.

A message about a variable names it. F8 moves the caret to the next problem and Shift+F8 to the previous one; Escape on a problem's marker goes back to its text.

Markup

The body has no formatting, so **, _ and [label](...) are the characters they are. The one markup is {{name}}. Pasting several lines keeps each as a line.

Hosting the value

value is the body the editor shows. Hand back what onChange gave you; pass a different value only to open another body, since one that differs from the editor's replaces it and drops the edits made since.

Travel

Travel sends the sign-in code and the departure reminder by SMS from a body written here, one per locale. The OTP body declares code and stays within one segment, because a second segment is a second message billed to the traveller's carrier.