Blockly は 2025 年 11 月 10 日に Raspberry Pi Foundation に移行しました。ブログ投稿とよくある質問をご覧ください。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
ワークスペースの作成
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Blockly ワークスペースは、Blockly の最上位のコンポーネントです。ブロックを使用してプログラミングを行うための UI です。
ワークスペースとそのサブコンポーネントの詳細については、ビジュアル用語集をご覧ください。
Injection div
Blockly ワークスペースは、インジェクション div と呼ばれる <div> に挿入する必要があります。
インジェクション div のサイズは、静的または動的に設定できます。div 内の Blockly 要素は、ウィンドウのサイズ変更時にサイズを更新します。
次のコード スニペットは、静的にサイズ設定されたインジェクション div の HTML を示しています。
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
インジェクション
インジェクションは、ワークスペースの UI を構成するすべての HTML サブ要素を作成します。また、ワークスペースを使用できるようにするために必要な初期化もすべて行います。
インジェクション関数は、インジェクション div の ID またはインジェクション div 自体を受け取ることができます。
// Passes the ID.
const workspace = Blockly.inject('blocklyDiv', { /* config */ });
// Passes the injection div.
const workspace = Blockly.inject(
document.getElementById('blocklyDiv'), { /* config */ });
構成
ワークスペースは、挿入時に多数のオプション(レイアウトやスタイルなど)で構成できます。
構成オプションの詳細については、構成オプションをご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-11-07 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-11-07 UTC。"],[],["Blockly workspaces, the UI for block programming, are injected into a designated `\u003cdiv\u003e` element called the \"injection div.\" This div can have a fixed or dynamic size, with Blockly elements resizing accordingly. Injection initializes the workspace UI and readies it for use. The `Blockly.inject()` function, which creates the workspace, accepts either the injection div's ID or the div itself. Workspace configuration, including layout and style, is set during the injection process.\n"]]