Intégrer
Intégrer est un moyen simple d’inclure l’application dans votre site Web. Ajoute le code suivant à ton site web :
<iframe src="https://web.butterfly.linwood.dev/embed" width="100%" height="500px" allowtransparency="true"></iframe>| Option | Type de texte | Par défaut | Libellé |
|---|---|---|---|
| enregistrer | Booléen (true, false) | true | Activer la sauvegarde. Si désactivé, seul un bouton de sortie sera affiché |
| editable | Booléen (true, false) | true | Activer l’édition. Si désactivé, le document sera en lecture seule |
| langue | Chaîne de caractères (…, système, utilisateur) | system | Langue du document. Si le système, la langue sera détectée à partir du navigateur. Si l’utilisateur, la langue sera définie à la préférence des utilisateurs |
Évènements
Section intitulée « Évènements »Exemples d’utilisation :
const embedElement = document.querySelector('#butterfly');embedElement.addEventListener('message', (data) => { if(data.detail.type === 'save') { console.log('Saving...', data.detail.message); }});enregistrer
Section intitulée « enregistrer »The
saveevent is emitted when the user clicks the save button.
Paramètres:
data(TypeList<int>): The data of the document.
The
exitevent is emitted when the user clicks the exit button.
Paramètres:
data(TypeList<int>): The data of the document.
The
changeevent is emitted when the user changes the document.
Paramètres:
data(TypeList<int>): The data of the document.
Méthodes
Section intitulée « Méthodes »Exemple d’utilisation :
const embedElement = document.querySelector('#butterfly');embedElement.pushMessage('getData', {});embedElement.addEventListener('message', (data) => { if(data.detail.type === 'getData') { console.log(data.detail.message); }});The
getDatamethod returns the data of the document.
Aucun paramètre.
Returns: List<int>
The
setDatamethod sets the data of the document.
Paramètres:
data(TypeList<int>): The data of the document.
The
rendermethod renders the document to a png image.
Paramètres:
width(TypeNumber): The width of the image.height(TypeNumber): The height of the image.scale(TypeNumber): The scale of the image.renderBackground(TypeBoolean): If true, the background will be rendered.
Returns: String (Base64 encoded image)
renderSVG
Section intitulée « renderSVG »The
renderSVGmethod renders the document to a svg image.
Paramètres:
width(TypeNumber): The width of the image.height(TypeNumber): The height of the image.renderBackground(TypeBoolean): If true, the background will be rendered.
Returns: String (SVG)