Embed
التضمين طريقة بسيطة لإدراج التطبيق في موقع الويب الخاص بك. أضف التعليمة البرمجية التالية إلى موقع الويب الخاص بك:
<iframe src="https://web.butterfly.linwood.dev/embed" width="100%" height="500px" allowtransparency="true"></iframe>خيارات
Section titled “خيارات”| خيار | نوع | الافتراضي | الوصف |
|---|---|---|---|
| حفظ | Boolean (true, false) | true | تمكين الحفظ. في حالة التعطيل، سيتم عرض زر الخروج فقط |
| editable | Boolean (true, false) | true | تمكين التحرير. في حالة التعطيل، سيكون المستند للقراءة فقط |
| اللغة | سلسلة (…، النظام، المستخدم) | system | () لغة الوثيقة. إذا كان النظام، سيتم اكتشاف اللغة من المتصفح. إذا كان المستخدم، سيتم تعيين اللغة إلى تفضيل المستخدمين |
الأحداث
Section titled “الأحداث”أمثلة على كيفية استخدامها:
const embedElement = document.querySelector('#butterfly');embedElement.addEventListener('message', (data) => { if(data.detail.type === 'save') { console.log('Saving...', data.detail.message); }});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.
لا توجد معلمات.
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)