Survei Riset: Ceritakan pengalaman Anda dengan Blockly
Mulai survei
Menggunakan blok prosedur bawaan
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menggunakan plugin
Untuk menggunakan blok prosedur, sebaiknya gunakan
Plugin @blockly/block-shareable-procedures.
Untuk perbedaan antara blok plugin dan blok bawaan, lihat
ringkasan.
Penginstalan
Benang:
shell
yarn add @blockly/block-shareable-procedures
NPM:
shell
npm install @blockly/block-shareable-procedures
Penggunaan
import Blockly from 'blockly';
import {blocks, unregisterProcedureBlocks} '@blockly/block-shareable-procedures';
unregisterProcedureBlocks();
Blockly.common.defineBlocks(blocks);
Ini akan menentukan blok prosedur yang memiliki nama yang sama dengan kode lama
blok prosedur bawaan. Jadi, jika Anda memuat JSON atau XML yang disimpan
dengan blok prosedur lama, mereka akan terus dimuat dengan benar.
Setelah Anda menentukan blok Anda (baik blok plugin, maupun blok
yang sudah ada), Anda harus menyediakannya
untuk pengguna Anda. Hal ini memerlukan
menggunakan {i>toolbox<i} gaya kategori, karena kategori prosedur diisi
secara dinamis, yang tidak didukung oleh toolbox flyout.
Anda dapat menambahkan kategori dinamis ke {i>toolbox<i} Anda seperti berikut:
JSON
{
"kind": "categoryToolbox",
"contents": [
{
"kind": "category",
"name": "Functions",
"custom": "PROCEDURE"
}
]
};
XML
<xml id="toolbox" style="display: none">
<category name="Functions" custom="PROCEDURE">
</xml>
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-04-14 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-04-14 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"]]