@stesura/esign
E-signature fields: an inline esign_field node that marks where a signer signs or fills
in, a manifest of the fields for the PDF or DOCX you send, and adapters that turn the
manifest into DocuSign, Acrobat Sign and Dropbox Sign field definitions. Framework-free;
the editor UI is in @stesura/esign-react. See the
package list for how it fits with the other packages.
Schema
Add the node with stesuraSchema(withEsign()); it composes with other with* helpers.
withEsign
Merges the esign node and grant into stesuraSchema props; composes with
other with* helpers: stesuraSchema(withEsign(withAutomation())).
| Name | Type | Default |
|---|---|---|
props | SchemaProps |
{ nodes: { [x: string]: StesuraNodeSpec; }; globalAttributes: { nodes: { hidden: { esign_field: true; }; }; definitions?: Record<string, GlobalAttributeDefinition>; }; marks?: Record<...>; }ESIGN_KINDS
const ESIGN_KINDS: readonly ["signature", "initials", "date", "name", "title", "company", "text", "checkbox"]The field kinds every supported provider has.
isEsignKind
Whether value is one of ESIGN_KINDS.
| Name | Type | Default |
|---|---|---|
value | unknown |
readEsignField
The field’s attrs, validated: attrs are unvalidated on the JSON/collab path, so every reader goes through here. A missing or invalid size falls back to the kind’s default.
| Name | Type | Default |
|---|---|---|
node | Node |
EsignKind
type EsignKind = "signature" | "initials" | "date" | "name" | "title" | "company" | "text" | "checkbox";A field kind: one of ESIGN_KINDS.
EsignFieldAttrs
A field’s attrs, validated: what readEsignField returns.
EsignStyle
type EsignStyle = "line" | "box" | "none";What prints for a field: a bottom border (line), a full border (box), or nothing.
EsignResize
type EsignResize = "both" | "width" | "none";Which sides a field’s box can be dragged on.
Commands
insertEsignField
Inserts a field at the cursor, sized by the kind’s defaults unless overridden. Refused in code blocks and where inline content can’t go.
| Name | Type | Default |
|---|---|---|
__0 | InsertEsignFieldOptions |
InsertEsignFieldOptions
Options of insertEsignField: the kind, and optionally the signer, size and style.
| Name | Type | Default |
|---|---|---|
kind | "date" | "name" | "title" | "text" | "checkbox" | "signature" | "initials" | "company" | |
signer | string | |
height | numberpt | |
required | boolean | |
width | numberpt | |
style | "none" | "line" | "box" |
updateEsignField
Updates field id. A kind change without a size takes the new kind’s
default size. Undoable; false when the field is missing or nothing changes
(compared against the validated attrs, so unset sizes don’t count as a change).
| Name | Type | Default |
|---|---|---|
id | string | |
update | Partial<Omit<EsignFieldAttrs, "id">> |
EsignFieldUpdate
The attrs updateEsignField changes; every attr but id.
resizeEsignField
What the resize frame commits: the field at pos resized within its kind’s
policy (one-line kinds keep their height, checkboxes never resize).
| Name | Type | Default |
|---|---|---|
pos | number | |
size | Size |
renameSigner
Reassigns every field of role from to to in one undoable transaction.
False when no field changes or to is already a role: a rename never
merges two roles (updateEsignField reassigns a single field).
| Name | Type | Default |
|---|---|---|
from | string | |
to | string |
findEsignField
The field with id id and its position.
| Name | Type | Default |
|---|---|---|
doc | Node | |
id | string |
signerRoles
Roles already in doc, normalised.
| Name | Type | Default |
|---|---|---|
doc | Node |
Reading and validating
collectEsignFields
Every field in document order, with its validated attrs.
| Name | Type | Default |
|---|---|---|
doc | Node |
EsignFieldInfo
A field as collectEsignFields returns it: validated attrs, position and visibility.
collectSigners
Visible fields by signer role, roles in order of first appearance (a stable index for colouring). Unassigned fields are left out.
| Name | Type | Default |
|---|---|---|
fields | readonly EsignFieldInfo[] |
esignDiagnostics
Problems that would block or weaken a send. Visible fields only; not stored.
| Name | Type | Default |
|---|---|---|
fields | readonly EsignFieldInfo[] |
EsignDiagnostic
One problem esignDiagnostics found, about a field (id) or a role (signer).
| Name | Type | Default |
|---|---|---|
code | EsignDiagnosticCode | |
severity | "error" | "warning" | |
id | string | nullThe field it is about; null for a role-level diagnostic. | |
signer | string | null | |
message | string |
EsignDiagnosticCode
type EsignDiagnosticCode =
| "unassigned-signer"
| "missing-id"
| "duplicate-id"
| "signer-without-signature";What esignDiagnostics found: a field without a signer, without an id, sharing an id, or a signer with no signature field (a warning).
Manifest
Build the manifest from the document you rendered, with the field boxes the PDF export measured.
buildManifest
Joins the document’s fields with what the PDF render measured, by id.
Build fields from the document that was rendered (for an automation
document, the materialized one): hidden content never gets a box, so ids
from the editor document would not match. Hidden, unassigned and id-less
fields are left out; a field the render did not place keeps its anchor and
is reported. Without measured (DOCX output) every field is anchor-only.
| Name | Type | Default |
|---|---|---|
fields | readonly EsignFieldInfo[] | |
measured | PdfFieldPlacements |
EsignManifest
The fields to send to a provider, built by buildManifest. Units are pt,
origin each page’s top-left corner.
EsignManifestField
One field of the EsignManifest: its role, size and anchor, and its box when measured.
EsignPlacement
A field’s box: pt, origin its page’s top-left corner, page 1-based.
| Name | Type | Default |
|---|---|---|
page | number | |
x | number | |
y | number | |
width | number | |
height | number |
EsignManifestWarning
One buildManifest warning; id is null for a field without one.
| Name | Type | Default |
|---|---|---|
code | EsignManifestWarningCode | |
id | string | null | |
message | string |
EsignManifestWarningCode
type EsignManifestWarningCode =
| "unassigned-signer"
| "missing-id"
| "duplicate-id"
| "unplaced-field";Why buildManifest warned: a field left out, or one the render did not place.
Provider adapters
docusignEnvelopeTabs
The manifest as DocuSign tabs, per signer: set each signers[].tabs of the
envelope definition to its entry. Fields whose role has no recipient are
skipped.
| Name | Type | Default |
|---|---|---|
manifest | EsignManifest | |
options | DocusignOptions |
DocusignOptions
Options of docusignEnvelopeTabs.
DocusignTabs
A DocuSign recipient’s tabs, one collection per tab type.
DocusignTab
One DocuSign tab (eSignature REST v2.1). Every value is a string, as the API types them; positions are whole points from the page’s top-left.
adobeSignFormFields
The manifest as the body of PUT /agreements/{id}/formFields ({ fields }),
for an agreement created in AUTHORING state. Coordinates only: fields
without a placement are skipped (see adobeSignFormFieldGenerators).
top is taken as the field’s top edge measured up from the page bottom.
The API reference does not say which edge: check one real agreement first.
| Name | Type | Default |
|---|---|---|
manifest | EsignManifest | |
__1 | { participantSetIds: Readonly<Record<string, string>>; } |
adobeSignFormFieldGenerators
The manifest as formFieldGenerators for POST /agreements: every field
placed by its anchor text, so it works for PDF and DOCX uploads alike.
| Name | Type | Default |
|---|---|---|
manifest | EsignManifest | |
__1 | { participantSetNames: Readonly<Record<string, string>>; } |
AdobeSignFormField
Acrobat Sign REST v6 FormField. Locations are points with a bottom-left origin.
AdobeSignFormFieldGenerator
Acrobat Sign REST v6 FormFieldGenerator placing one field by its anchor text.
AdobeSignInputType
type AdobeSignInputType = "SIGNATURE" | "TEXT_FIELD" | "CHECKBOX";An Acrobat Sign form field’s inputType.
AdobeSignContentType
type AdobeSignContentType =
| "SIGNATURE"
| "SIGNER_INITIALS"
| "SIGNATURE_DATE"
| "SIGNER_NAME"
| "SIGNER_TITLE"
| "SIGNER_COMPANY"
| "DATA";An Acrobat Sign form field’s contentType.
dropboxSignFormFields
The manifest as form_fields_per_document. Coordinates only (Dropbox Sign
has no anchor-string placement): fields without a placement are skipped.
Values are whole points (72 dpi, top-left), as the API reference states. The help centre describes sizes in an 80 dpi system and pages rescaled to US Letter: verify against one real request, A4 especially.
| Name | Type | Default |
|---|---|---|
manifest | EsignManifest | |
__1 | { signers: Readonly<Record<string, number>>; documentIndex?: number; } |
DropboxSignFormField
Dropbox Sign API v3 form_fields_per_document entry, page coordinate system.
DropboxSignFieldType
type DropboxSignFieldType = "signature" | "initials" | "date_signed" | "text" | "checkbox";A Dropbox Sign form field’s type.
AdapterSkip
A manifest field an adapter could not express.
| Name | Type | Default |
|---|---|---|
id | string | |
reason | "no-recipient" | "no-placement"
|
Export
esignDocx
DOCX export of the field: a bordered (or underlined) box sized like the
field, preceded by its anchor token as 1pt white text. One-way: importing the
file gives plain text. With automationDocx, spread both nodes and keep
its transformDoc.
esignMarkdown
Markdown serialization of the field as {{esign|kind|signer}} text.
One-way: parsing gives the text back, not a field.
| Name | Type | Default |
|---|---|---|
fenceHandlers | Readonly<Record<string, FenceHandler>> | |
nodeHandlers | Readonly<Record<string, PmNodeHandler>> |