연구 설문조사: 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을 로드하면
이전 프러시저 블록이 있으면 계속 올바르게 로드됩니다.
차단 (플러그인 또는 레거시 차단)을 정의한 후
기본 제공되는 API)를 사용자가 사용할 수 있도록 해야 합니다. 이를 위해서는
프러시저 카테고리가 채워져 있으므로 카테고리 스타일 도구 상자를 사용할 수 있습니다.
이는 플라이아웃 툴박스에서 지원되지 않습니다.
다음과 같이 도구 상자에 동적 카테고리를 추가할 수 있습니다.
{
"kind": "categoryToolbox",
"contents": [
{
"kind": "category",
"name": "Functions",
"custom": "PROCEDURE"
}
]
};
<xml id="toolbox" style="display: none">
<category name="Functions" custom="PROCEDURE">
</xml>
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 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"]]