Ενσωμάτωση
Embedding is a simple way to include the app in your website. Add the following code to your website:
<iframe src="https://web.butterfly.linwood.dev/embed" width="100%" height="500px" allowtransparency="true"></iframe>Επιλογές
Section titled “Επιλογές”| Επιλογή | Τύπος | Προεπιλογή | Περιγραφή |
|---|---|---|---|
| αποθήκευση | Boolean (true, false) | true | Enable save. If disabled, only an exit button will be shown |
| editable | Boolean (true, false) | true | Enable editing. If disabled, the document will be read-only |
| γλώσσα | Συμβολοσειρά (…, σύστημα, χρήστης) | system | Language of the document. If system, the language will be detected from the browser. If user, the language will set to the users preference |
Συμβάντα
Section titled “Συμβάντα”Παραδείγματα πώς να το χρησιμοποιήσετε:
const embedElement = document.querySelector('#butterfly');embedElement.addEventListener('message', (data) => { if(data.detail.type === 'save') { console.log('Saving...', data.detail.message); }});αποθήκευση
Section titled “αποθήκευση”The
saveevent is emitted when the user clicks the save button.
Παράμετροι:
data(TypeList<int>): The data of the document.
έξοδος
Section titled “έξοδος”The
exitevent is emitted when the user clicks the exit button.
Παράμετροι:
data(TypeList<int>): The data of the document.
change
Section titled “change”The
changeevent is emitted when the user changes the document.
Παράμετροι:
data(TypeList<int>): The data of the document.
Μέθοδοι
Section titled “Μέθοδοι”Παράδειγμα πώς να το χρησιμοποιήσετε:
const embedElement = document.querySelector('#butterfly');embedElement.pushMessage('getData', {});embedElement.addEventListener('message', (data) => { if(data.detail.type === 'getData') { console.log(data.detail.message); }});getData
Section titled “getData”The
getDatamethod returns the data of the document.
No parameters.
Returns: List<int>
setData
Section titled “setData”The
setDatamethod sets the data of the document.
Παράμετροι:
data(TypeList<int>): The data of the document.
render
Section titled “render”The
rendermethod renders the document to a png image.
Παράμετροι:
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 titled “renderSVG”The
renderSVGmethod renders the document to a svg image.
Παράμετροι:
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)