Ionchorprú Sínitheoir Legalesign i do Láithreán Gréasáin
Tá ghné an Sínitheora daonna ag teastáil. Déan teagmháil leis an tacaíocht chun é a chumasú do do fhoireann.
Leagan reatha: v1.1.9 — log athruithe
Is comhpháirt gréasáin neodrach ó thaobh hardáin de é an Sínitheoir Legalesign a sholáthraíonn taithí sínithe doiciméad iomlán agus réidh ón taobh istigh den aip féin. Oibríonn sé le HTML amh, React, Vue, Angular, nó aon fhráma gréasáin.
Cuimhnigh an chomhpháirt seo áit ar bith a bhfuil gá ag do úsáideoirí le doiciméid a shíniú — laistigh de CRM, tairseach chustaiméara, nó aon aip inmheánach a dhéanann HTML a léiriú.
Suiteáil
Lódáil go díreach ón CDN (ní gá suiteáil):
<script type="module" src="https://cdn.legalesign.io/signer/latest/ls-signer.esm.js"></script>
Suiteáil React
Suiteáil trí bhainisteoir pacáiste:
npm install legalesign-signer
# or
pnpm add legalesign-signer
Comhtháthú Bunúsach
HTML & JavaScript
<ls-signer
recipient-id="abc123"
private-key="key"
session-id="session"
></ls-signer>
<script>
const signer = document.querySelector('ls-signer');
signer.addEventListener('signingSuccess', (e) => console.log('Signed:', e.detail.eventType, e.detail.documentId));
signer.addEventListener('signingFail', (e) => console.error('Failed:', e.detail.failureReason, e.detail.error));
signer.addEventListener('fieldChange', (e) => console.log('Field event:', e.detail.eventType));
</script>
React
import { useEffect, useState } from 'react';
import { LsSigner } from 'legalesign-signer/react';
import 'legalesign-signer/react.css';
function SigningPage() {
const [signerData, setSignerData] = useState(null);
useEffect(() => {
fetch('/your-backend/to-get-token')
.then(res => res.json())
.then(setSignerData);
}, []);
if (!signerData) return <p>Loading...</p>;
return (
<LsSigner
recipientId={signerData.recipientId}
privateKey={signerData.token}
sessionId={signerData.sessionId}
onSuccess={({ eventType, documentId }) => console.log(eventType, documentId)}
onFail={({ eventType, failureReason, error }) => console.error(eventType, failureReason, error)}
onChange={({ eventType, uuid, saved, field, document }) => console.log('Event:', eventType)}
/>
);
}
Éilíonn React react agus react-dom (v18 nó v19) mar shpleácha comhtháite.
Vue
<template>
<ls-signer
ref="signer"
:recipient-id="recipientId"
:private-key="privateKey"
:session-id="sessionId"
/>
</template>
<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue';
const signer = ref(null);
function handleSuccess(e) {
console.log('Signed:', e.detail);
}
function handleFail(e) {
console.error('Failed:', e.detail);
}
onMounted(() => {
signer.value.addEventListener('signingSuccess', handleSuccess);
signer.value.addEventListener('signingFail', handleFail);
});
onBeforeUnmount(() => {
signer.value?.removeEventListener('signingSuccess', handleSuccess);
signer.value?.removeEventListener('signingFail', handleFail);
});
</script>
Má úsáidtear Vue le Vite, cuir isCustomElement: (tag) => tag.startsWith('ls-') le do chumraíocht breiseáin Vue chun foláirimh faoi eilimintí anaithnid a sheachaint.
I Vue 3, íoslaghdaítear ainmneacha imeachtaí ar eilimintí saincheaptha, mar sin ní oibreoidh @signingSuccess. Bain úsáid as addEventListener ar an gcruthúnas eilimint mar a léirítear thuas.
Croch <ls-signer> i <ClientOnly> chun earráidí SSR a sheachaint. Cuir an chumraíocht eilimint shaincheaptha i nuxt.config.ts:
export default defineNuxtConfig({
vue: {
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('ls-'),
},
},
});
Fíordheimhniú
Teastaíonn ticéad gearrshaoil ón taobh thall den fhreastalaí don chomhpháirt sínitheora. Tá dhá rogha ann:
- GraphQL
generateComponentToken— Glaoigh leis lecomponent: LS_SIGNERagus nórecipientIdnósessionIdsa scóip sínitheora (soláthraigh ceann amháin, ní beirt). - REST API — Glaoigh
GET /signer/{signerId}/component-token/le do eochair API.
Tugann an beirt seo an token agus sessionId atá ag teastáil ón gcomhpháirt. Féach ar Údarú Widget don sreabhadh iomlán ticéad ar an taobh freastalaí.
Rogha 1: GraphQL (Node.js)
Agus ag baint úsáide as recipientId (an ceann is coitianta — úsáid nuair atá a fhios agat cé hé an faighteoir ach nach bhfuil aon seisiún agat fós):
const response = await fetch('https://graphql.uk.legalesign.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.LEGALESIGN_API_KEY}`,
},
body: JSON.stringify({
query: `mutation MintSignerToken($input: GenerateComponentTokenInput!) {
generateComponentToken(input: $input) {
token
tokenType
sessionId
expiresIn
expiresAt
}
}`,
variables: {
input: {
component: 'LS_SIGNER',
signer: { recipientId: '<recipient-id>' }
}
}
})
});
const { data } = await response.json();
const { token, sessionId } = data.generateComponentToken;
Ar an lámh eile, má tá sessionId agat cheana ó ghlao roimhe seo:
variables: {
input: {
component: 'LS_SIGNER',
signer: { sessionId: '<session-id>' }
}
}
Rogha 2: REST API
const response = await fetch(
`https://eu-api.legalesign.com/api/v1/signer/${signerId}/component-token/`,
{
headers: {
Authorization: `Bearer ${process.env.LEGALESIGN_API_KEY}`,
},
}
);
const { token, sessionId } = await response.json();
Pasáil token mar private-key agus sessionId mar session-id chuig an gcomhpháirt.
Tréithe Riachtanacha
| Tréith | Cineál | Cur Síos |
|---|---|---|
recipient-id | string | Aitheantóir faighteora (base64, tosaíocht rec, nó UUID) |
private-key | string | Ticéad ar ais ón generateComponentToken |
session-id | string | Aitheantóir seisiúin ar ais ón generateComponentToken |
Tréithe Roghnach
| Tréith | Cineál | Réamhshocraithe | Cur Síos |
|---|---|---|---|
colour | string | blue | Ainm dath téama (féach Téamáil) |
style | string | `` | Athruithe stíle (féach CSS Custaiméara) |
branding | boolean | true | Léirigh mbranda Legalesign. Socraigh mar false chun é a bhaint. |
language | string | — | Dírigh a bhaint as teanga ar leith agus cuir cosc ar an lasc teanga (féach Idirnáisiúnú) |
Imeachtaí
| Airí React | Imeacht comhpháirt gréasáin | eventType | Cathain |
|---|---|---|---|
onSuccess | signingSuccess | "success" | Doiciméad sínithe go rathúil |
onFail | signingFail | "failure" | Teip ar shíniú an doiciméid, diúltaíodh dó, éagtha, cealaithe, scriosta, bainte, nó críochnaithe cheana i gcineál eile |
onChange | fieldChange | "ready" | Doiciméad agus íomhánna leathanach luchtaithe go hiomlán |
onChange | fieldChange | "save" | Luach réimse sábháilte |
onChange | fieldChange | "select" | Roghnaíodh nó díríodh réimse |
onSuccess / signingSuccess
Scaoiltear nuair a shíneann an faighteoir an doiciméad go rathúil.
{
eventType: 'success';
documentId: string; // UUID of the signed document
recipientId: string; // UUID of the recipient
}
React:
<LsSigner
onSuccess={({ eventType, documentId, recipientId }) => {
console.log(eventType); // "success"
console.log(documentId);
console.log(recipientId);
}}
/>
Comhpháirt Gréasáin:
signer.addEventListener('signingSuccess', (e) => {
console.log(e.detail.eventType); // "success"
console.log(e.detail.documentId);
console.log(e.detail.recipientId);
});
onFail / signingFail
Scaoiltear nuair a theipeann ar an síniú — mar gheall ar dhiúltaigh doiciméad nó earráid i rith an tsíniú (m.sh. earráid líonra, seisiún éagtha, coinbhleacht staid doiciméid).
{
eventType: 'failure';
failureReason: FailureReason;
error: string; // Human-readable error message
documentId?: string; // UUID of the document (if available)
recipientId: string; // UUID of the recipient
}
failureReason | Cúis |
|---|---|
documentExpired | Stádas doiciméid "expired" nó dáta expires san am atá caite |
sessionExpired | Rinne API freagra 401 nó 403 nuair a bhí an doiciméad á luchtú |
cancelled | Stádas doiciméid "cancelled" |
deleted | Brat is_deleted an doiciméid ina lánmhír |
rejected | Díoltar an doiciméad ag an bhfaighteoir (is_rejected ina fíor) |
removed | Fuair API 404 — níl an doiciméad ann níos mó |
documentCompleted | D'fhill an API sínithe le completed — bhí an doiciméad sínithe cheana, is dóichí i mbrabhsálaí nó gléas eile. Taispeánann an comhpháirt teachtaireacht faisnéise don fhaighteoir seachas earráid. |
signingError | Aon earráid eile le linn luchtaithe nó sínithe |
React:
<LsSigner
onFail={({ eventType, failureReason, error, documentId, recipientId }) => {
console.log(eventType); // "failure"
console.log(failureReason); // e.g. "documentExpired"
console.log(error);
}}
/>
Comhpháirt Gréasáin:
signer.addEventListener('signingFail', (e) => {
console.log(e.detail.eventType); // "failure"
console.log(e.detail.failureReason); // e.g. "documentExpired"
console.log(e.detail.error);
});
onChange / fieldChange
Roinnt gach de na luachanna eventType an t-imeacht céanna. Bain úsáid as eventType chun idirdhealú a dhéanamh.
eventType: "ready"
Scaoiltear uair amháin nuair atá an doiciméad agus gach íomhá leathanach luchtaithe go hiomlán agus tá an comhéadan sínithe réidh le húsáid.
{
eventType: 'ready';
document: {
documentId: string; // UUID of the document
name: string; // Document name
state: string; // Document state (e.g. "signing")
recipientId: string; // UUID of the recipient
recipientRole?: string; // Role of the recipient (e.g. "witness")
pageCount: number; // Number of pages
expires?: string; // Expiry date (ISO string, if set)
isApprover: boolean; // Whether the recipient is an approver
isWitness: boolean; // Whether the recipient is a witness
canReassign: boolean; // Whether the recipient can reassign
doOfferReject: boolean; // Whether the reject option is shown
};
}
React:
<LsSigner
onChange={({ eventType, document }) => {
if (eventType === 'ready') {
console.log('Ready to sign:', document.documentId, document.name);
console.log('Pages:', document.pageCount);
console.log('Expires:', document.expires);
}
}}
/>
Comhpháirt Gréasáin:
signer.addEventListener('fieldChange', (e) => {
if (e.detail.eventType === 'ready') {
console.log('Ready to sign:', e.detail.document.documentId, e.detail.document.name);
}
});
eventType: "save"
Scaoiltear tar éis luach réimse a shábháil ar an bhfreastalaí.
{
eventType: 'save';
uuid: string; // UUID of the field
saved: boolean; // Whether the save was successful
field: Record<string, any>; // Full field object (see Field Properties below)
}
React:
<LsSigner
onChange={({ eventType, uuid, saved, field }) => {
if (eventType === 'save') {
console.log(uuid, saved, field.value);
}
}}
/>
Comhpháirt Gréasáin:
signer.addEventListener('fieldChange', (e) => {
if (e.detail.eventType === 'save') {
console.log(e.detail.uuid, e.detail.saved, e.detail.field.value);
}
});
eventType: "select"
Scaoiltear nuair a roghnaítear nó a dhírítear ar réimse — spreagtha ag cliceáil úsáideora, nascleanúint méarchláir, aiséascadh uathoibríoch, nó idirghníomhú taobhraon.
{
eventType: 'select';
uuid: string; // UUID of the selected field
field: Record<string, any>; // Full field object (see Field Properties below)
}
React:
<LsSigner
onChange={({ eventType, uuid, field }) => {
if (eventType === 'select') {
console.log('selected', uuid, field.fieldtype);
}
}}
/>
Comhpháirt Gréasáin:
signer.addEventListener('fieldChange', (e) => {
if (e.detail.eventType === 'select') {
console.log('selected', e.detail.uuid, e.detail.field.fieldtype);
}
});
Airíonna Réimse
Cuimsíonn an réad field san imeachtaí save agus select na hairíonna seo a leanas:
| Airí | Cineál | Cur Síos |
|---|---|---|
uuid | string | Aitheantóir réimse uathúil |
fieldtype | string | Cineál réimse (m.sh. "text", "signature", "date", "checkbox") |
value | string | Luach reatha an réimse |
state | boolean | An bhfuil an réimse sábháilte go rathúil |
optional | boolean | An bhfuil an réimse roghnach |
page | number | Uimhir an leathanaigh ina bhfuil an réimse |
label | string | Lipéad an réimse (más socraithe) |
validation | number | Cód cineál bailíochtaithe |
logicaction | string | Cineál gnímh loighic ("1" = raidió, "2" = suim, "3" = coinníollach) |
logicgroup | string | Aitheantóir grúpa loighic |
mapto | string | Grúpa sprioc do loighic (réimsí rialaithe) |
auto | boolean | An bhfuil an réimse líonta go huathoibríoch |
dirty | boolean | An bhfuil athruithe áitiúla neamhshábháilte ar an réimse |
Airí React
Úsáideann an comhpháirt React airí camelCase agus airí glaonna ar ais in áit imeachtaí DOM:
| Airí | Cineál | Riachtanach | Cur Síos |
|---|---|---|---|
recipientId | string | ✅ | Aitheantóir faighteora |
privateKey | string | ✅ | Eochair phríobháideach ón míniúchán generateComponentToken |
sessionId | string | ✅ | Aitheantóir seisiúin |
colour | LsSignerColour | ❌ | Dath téama |
branding | boolean | ❌ | Léirigh mbranda Legalesign. Réamhshocraithe ar true. |
language | string | ❌ | Dírigh ar theanga ar leith (féach Idirnáisiúnú) |
onSuccess | (data: { eventType: 'success'; documentId: string; recipientId: string }) => void | ❌ | Glaoitear ar shíniú rathúil |
onFail | (data: { eventType: 'failure'; failureReason: FailureReason; error: string; documentId?: string; recipientId: string }) => void | ❌ | Glaoitear ar theip ar shíniú |
onChange | (data: { eventType: 'ready' | 'save' | 'select'; document?: DocumentSummary; uuid?: string; saved?: boolean; field?: Record<string, any> }) => void | ❌ | Glaoitear ar imeachtaí réimse agus doiciméad réidh |
Láimhseálaí catch-all (le haghaidh dífhabhtaithe & protótipíochta)
Ós rud é go bhfuil eventType ag gach imeacht, is féidir feidhm amháin a nascadh le gach imeacht:
React:
const handleSignerEvent = (e) => {
switch (e.eventType) {
case 'success': console.log('Signed:', e.documentId); break;
case 'failure': console.log('Failed:', e.failureReason, e.error); break;
case 'ready': console.log('Ready:', e.document?.name); break;
case 'save': console.log('Saved field:', e.uuid, e.saved); break;
case 'select': console.log('Selected field:', e.uuid); break;
}
};
<LsSigner
onSuccess={handleSignerEvent}
onFail={handleSignerEvent}
onChange={handleSignerEvent}
/>
Comhpháirt Gréasáin:
const handleSignerEvent = (e) => {
switch (e.detail.eventType) {
case 'success': console.log('Signed:', e.detail.documentId); break;
case 'failure': console.log('Failed:', e.detail.failureReason, e.detail.error); break;
case 'ready': console.log('Ready:', e.detail.document?.name); break;
case 'save': console.log('Saved field:', e.detail.uuid, e.detail.saved); break;
case 'select': console.log('Selected field:', e.detail.uuid); break;
}
};
signer.addEventListener('signingSuccess', handleSignerEvent);
signer.addEventListener('signingFail', handleSignerEvent);
signer.addEventListener('fieldChange', handleSignerEvent);
Téamáil
Socraigh téama dath leis an airí colour. Déantar gach toin a dhíorthaítear go huathoibríoch.
Dathanna Ar Fáil
pink · blue · purple · indigo · teal · green · lightblue · burnt · aubergine · red · yellow · cyan · lime · trueGreen
Fág an airí gan a shonrú chun an gorm réamhshocraithe a fháil.
<ls-signer colour="pink" ...></ls-signer>
<LsSigner colour="pink" ... />
Cuireann an airí colour tréith data-ls-theme ar bhunús na comhpháirte. Sainmhíníonn sainairíonna saincheaptha CSS scála toin 10–100 do gach dath:
| Toíneach | Úsáid |
|---|---|
| 10 | Cúlraí éadroma, líonta mín |
| 20 | Scáileanna mín |
| 30 | Fáinní fócasacha |
| 60 | Dath príomhúil (cnaipeanna, naisc, stáit gníomhacha) |
| 70 | Staid léimneach |
| 80 | Béim dhorcha/láidir |
CSS Custaiméara
Cuireann an comhpháirt sainairíonna saincheaptha CSS ar fáil a bhféadfar iad a shárú chun cuma a shaincheapadh thar ceann an téama dath. Tá an tacar seo d’airíonna teoranta faoi láthair, déan teagmháil linn más mian leat níos mó sonraí.
<ls-signer
style="--ls-font-family: 'Inter', sans-serif; --ls-color-primary-60: #e91e63;"
recipient-id="abc123"
private-key="key"
session-id="session"
></ls-signer>
Airíonna Ar Fáil
| Airí | Réamhshocraithe | Cur Síos |
|---|---|---|
--ls-font-family | 'IBM Plex Sans', sans-serif | Príomhtheaghlach cló |
--ls-color-primary-10 go --ls-color-primary-100 | — | Scála dath príomhúil iomlán (ag sárú téama) |
--ls-color-error | #f64a44 | Dath stáit earráide |
--ls-color-error-light | #fff0f0 | Cúlra earráide |
--ls-color-success | #46dbaa | Dath stáit rath |
--ls-color-success-light | #effff9 | Cúlra rath |
--ls-color-warning | #fad232 | Dath stáit rabhaidh |
--ls-color-warning-light | #fffcef | Cúlra rabhaidh |
--ls-color-border | #d8d9dc | Dath scáile réamhshocraithe |
--ls-color-border-subtle | #e0e2e5 | Dath scáile mín |
--ls-color-bg-subtle | #f7f8fa | Dath cúlra mín |
Nóta: Chun insliú lánchuspóireach CSS (ag díriú ar eilimintí inmheánacha go díreach, ag sárú méideanna cló, raon scáileáin, spásáil, srl.), tá gné beartaithe sa todhchaí. Déan teagmháil linn má tá suim agat (déan teagmháil).
Idirnáisiúnú
Tacaíonn an comhpháirt le 17 teanga le haistriúcháin uilechuimsitheacha san fhoinse. Braitear teanga go huathoibríoch ón mbrabhsálaí. Cuireann lasc teanga ionsuite sa UI sínithe cead don fhaighteoir an teanga a athrú aon uair is mian leis.
Socraigh an tréith language chun teanga ar leith a fhorsú. Nuair a sholáthraítear é seo, cuirtear an lasc teanga ionsuite i bhfolach agus seachnaítear braiteacht bhrabhsálaí.
<ls-signer language="fr" recipient-id="abc123" private-key="key" session-id="session"></ls-signer>
<LsSigner language="fr" recipientId="abc123" privateKey="key" sessionId="session" />
Ord tosaíochta: airí language → teanga an bhrabhsálaí → Béarla mar shocrú ar fhillteán.
| Cód | Teanga | Cód | Teanga |
|---|---|---|---|
en | Béarla | nl | Ollainnis |
fr | Fraincis | fi | Fionlainnis |
bg | Bulgáiris | it | Iodáilis |
es | Spáinnis | he | Eabhrais |
de | Gearmáinis | sv | Sualainnis |
gs | Gàidhlig na h-Alba | cy | Bhreatnais |
ar | Araibis | is | Íoslainnis |
el | Gréigis | iw | Eabhrais (dána) |
pt | Portaingéilis | ||
ro | Rómáinis |
Leaganú CDN
Tacaíonn URL an CDN le leathanaigh nuashonraithe agus leaganacha sgrommuillithe araon:
<!-- Always get the most recent version (recommended) -->
<script type="module" src="https://cdn.legalesign.io/signer/latest/ls-signer.esm.js"></script>
<!-- Pin to a specific version -->
<script type="module" src="https://cdn.legalesign.io/signer/v1.1.9/ls-signer.esm.js"></script>
Molaimid úsáid a bhaint as latest — cinntíonn sé seo go bhfaigheann do chomhtháthú deisiúcháin fabhtanna, paistí slándála, agus gnéithe nua go huathoibríoch. Úsáid leagan sgrommuillithe má tá sé riachtanach greamaigh leagan a bhfuil cloí iomlán leis le linn fuarú QA nó scaoileadh rialaithe. Féach ar an stair iomlán leaganacha ar npm do na leaganacha atá ar fáil.
Sampla Iomlán
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document Signing</title>
<script type="module" src="https://cdn.legalesign.io/signer/latest/ls-signer.esm.js"></script>
</head>
<body>
<ls-signer
recipient-id="abc123"
private-key="key"
session-id="session"
colour="teal"
></ls-signer>
<script>
const signer = document.querySelector('ls-signer');
signer.addEventListener('signingSuccess', (event) => {
console.log('Document signed:', event.detail.documentId);
window.location.href = '/thank-you';
});
signer.addEventListener('signingFail', (event) => {
console.error('Signing failed:', event.detail.failureReason, event.detail.error);
});
signer.addEventListener('fieldChange', (event) => {
if (event.detail.eventType === 'ready') {
console.log('Ready to sign:', event.detail.document.name);
}
});
</script>
</body>
</html>
Tacaíocht Brabhsálaí
- Chrome/Edge (leagan is déanaí)
- Firefox (leagan is déanaí)
- Safari (leagan is déanaí)
- Brabhsálaithe soghluaiste (iOS Safari, Chrome Mobile)
Log Athruithe
| Leagan | Dáta | Achoimre |
|---|---|---|
| v1.1.9 | 3 Samh 2026 | Feabhsuithe ar láimhseáil earráide agus bailíochtú isteach nuair a shábhálann faighteoir sonraí fianaise |
| v1.1.8 | 2 Samh 2026 | Nuashonruithe aistriúcháin do na 17 theanga tacaíochta go léir |
| v1.1.7 | 20 Deireadh Fómhair 2026 | Cúis theip documentCompleted; feabhsuithe sábhála réimse; ceartúcháin suímh; feabhsuithe ghabháil imeachtaí teipe |
| v1.1.0 | 22 Iúil 2026 | Imeacht onChange / fieldChange; airí language; réimsí coinníollacha; léim uathoibríoch; QES |
| v1.0.12 | 20 Iúil 2026 | Imeacht onChange / fieldChange le ready, save, select; luachanna failureReason; bailíochtú astuairisce |
| v1.0.11 | 15 Iúil 2026 | Airí language; réimsí coinníollacha, titim síos, bosca seiceála; ionchur gutháin; ordú réimsí |
| v1.0.6 | 9 Meitheamh 2026 | Airí branding curtha leis |
| v1.0.3 | 15 Bealtaine 2026 | Airí colour; sainairíonna saincheaptha CSS; deisiúcháin fabhtanna |
| v1.0.0 | 11 Bealtaine 2026 | Scaoileadh cobhsaí tosaigh |