แบบสำรวจการวิจัย: บอกให้เราทราบเกี่ยวกับประสบการณ์การใช้งาน Blockly
เริ่มแบบสำรวจ
การใช้บล็อกขั้นตอน
การใช้ปลั๊กอิน
ในการใช้การบล็อกกระบวนการ เราขอแนะนำให้ใช้
ปลั๊กอิน @blockly/block-shareable-procedures
สำหรับความแตกต่างระหว่างบล็อกปลั๊กอินและบล็อกในตัว โปรดดูส่วน
ภาพรวม
การติดตั้ง
เส้นด้าย:
shell
yarn add @blockly/block-shareable-procedures
NPM
shell
npm install @blockly/block-shareable-procedures
การใช้งาน
import Blockly from 'blockly';
import {blocks, unregisterProcedureBlocks} '@blockly/block-shareable-procedures';
unregisterProcedureBlocks();
Blockly.common.defineBlocks(blocks);
การดำเนินการนี้จะกำหนดการบล็อกกระบวนการที่มีชื่อเดียวกันกับไฟล์เดิม
บล็อกขั้นตอนในตัว ดังนั้นหากคุณกำลังโหลด JSON หรือ XML ที่บันทึกไว้
ด้วยการบล็อกขั้นตอนเดิม แท็กเหล่านั้นจะยังคงโหลดได้อย่างถูกต้อง
หลังจากที่คุณกำหนดการบล็อก (ประเภทปลั๊กอินหรือบล็อกเดิม) แล้ว
แบบบิวท์อิน) คุณจะต้องทำให้ผู้ใช้ของคุณใช้งานได้ ขั้นตอนนี้ต้องใช้
ให้ใช้กล่องเครื่องมือรูปแบบหมวดหมู่ เพราะระบบจะใส่หมวดหมู่ขั้นตอน
แบบไดนามิก ซึ่งกล่องเครื่องมือ Flyout ไม่รองรับ
คุณสามารถเพิ่มหมวดหมู่แบบไดนามิกลงในกล่องเครื่องมือได้ดังนี้
{
"kind": "categoryToolbox",
"contents": [
{
"kind": "category",
"name": "Functions",
"custom": "PROCEDURE"
}
]
};
<xml id="toolbox" style="display: none">
<category name="Functions" custom="PROCEDURE">
</xml>
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-09-09 UTC
[null,null,["อัปเดตล่าสุด 2024-09-09 UTC"],[[["Leverage the `@blockly/block-shareable-procedures` plugin for utilizing procedure blocks within Blockly, ensuring compatibility and enhanced functionality."],["Install the plugin effortlessly using either Yarn (`yarn add @blockly/block-shareable-procedures`) or NPM (`npm install @blockly/block-shareable-procedures`) based on your preference."],["Integrate the plugin into your project by importing necessary modules, unregistering existing procedure blocks, and defining new ones with shared functionalities, maintaining backward compatibility with older saved files."],["Incorporate the procedure blocks into your toolbox by utilizing a category style toolbox with a dynamic \"Functions\" category, allowing users easy access to these essential blocks."]]],["The `@blockly/block-shareable-procedures` plugin is recommended for using procedure blocks. Installation is done via Yarn or NPM. Usage involves importing `Blockly` and the plugin's `blocks`, then using the `unregisterProcedureBlocks()` and `Blockly.common.defineBlocks(blocks)` methods. This defines procedure blocks that maintain compatibility with legacy blocks. To make the blocks accessible, add a \"Functions\" category with the custom attribute \"PROCEDURE\" to your category-style toolbox, which is compatible with the dynamic procedure category.\n"]]