Stay organized with collections
Save and categorize content based on your preferences.
blockly > common
common namespace
Functions
Variables
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003ecommon\u003c/code\u003e namespace provides functions for managing workspaces, defining blocks, and handling UI elements within Blockly.\u003c/p\u003e\n"],["\u003cp\u003eIt includes functions to find, register, and unregister workspaces, as well as to manipulate the main workspace.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use this namespace to define blocks programmatically from JSON definitions or add them to the Blockly.Blocks dictionary.\u003c/p\u003e\n"],["\u003cp\u003eFunctions are available for interacting with selected objects, resizing the SVG workspace, and managing drag-and-drop connections.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecommon\u003c/code\u003e namespace also exposes variables for tracking dragging connections and for testing purposes.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [common](./blockly.common_namespace.md)\n\ncommon namespace\n----------------\n\nFunctions\n---------\n\n| Function | Description |\n|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [createBlockDefinitionsFromJsonArray(jsonArray)](./blockly.common_namespace.createblockdefinitionsfromjsonarray_1_function.md) | Define blocks from an array of JSON block definitions, as might be generated by the Blockly Developer Tools. |\n| [defineBlocks(blocks)](./blockly.common_namespace.defineblocks_1_function.md) | Add the specified block definitions to the block definitions dictionary (Blockly.Blocks). |\n| [defineBlocksWithJsonArray(jsonArray)](./blockly.common_namespace.defineblockswithjsonarray_1_function.md) | Define blocks from an array of JSON block definitions, as might be generated by the Blockly Developer Tools. |\n| [getAllWorkspaces()](./blockly.common_namespace.getallworkspaces_1_function.md) | Find all workspaces. |\n| [getBlockTypeCounts(block, opt_stripFollowing)](./blockly.common_namespace.getblocktypecounts_1_function.md) | Get a map of all the block's descendants mapping their type to the number of children with that type. |\n| [getMainWorkspace()](./blockly.common_namespace.getmainworkspace_1_function.md) | Returns the last used top level workspace (based on focus). Try not to use this function, particularly if there are multiple Blockly instances on a page. |\n| [getParentContainer()](./blockly.common_namespace.getparentcontainer_1_function.md) | Get the container element in which to render the WidgetDiv, DropDownDiv and Tooltip. |\n| [getSelected()](./blockly.common_namespace.getselected_1_function.md) | Returns the current selection. |\n| [getWorkspaceById(id)](./blockly.common_namespace.getworkspacebyid_1_function.md) | Find the workspace with the specified ID. |\n| [registerWorkspace(workspace)](./blockly.common_namespace.registerworkspace_1_function.md) | Register a workspace in the workspace db. |\n| [setMainWorkspace(workspace)](./blockly.common_namespace.setmainworkspace_1_function.md) | Sets last used main workspace. |\n| [setParentContainer(newParent)](./blockly.common_namespace.setparentcontainer_1_function.md) | Set the parent container. This is the container element that the WidgetDiv, DropDownDiv, and Tooltip are rendered into the first time `Blockly.inject` is called. This method is a NOP if called after the first `Blockly.inject`. |\n| [svgResize(workspace)](./blockly.common_namespace.svgresize_1_function.md) | Size the SVG image to completely fill its container. Call this when the view actually changes sizes (e.g. on a window resize/device orientation change). See workspace.resizeContents to resize the workspace when the contents change (e.g. when a block is added or removed). Record the height/width of the SVG image. |\n| [unregisterWorkpace(workspace)](./blockly.common_namespace.unregisterworkpace_1_function.md) | Unregister a workspace from the workspace db. |\n\nVariables\n---------\n\n| Variable | Description |\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------|\n| [draggingConnections](./blockly.common_namespace.draggingconnections_variable.md) | All of the connections on blocks that are currently being dragged. |\n| [TEST_ONLY](./blockly.common_namespace.test_only_variable.md) | |"]]