mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Add test-blocks into the basic playground (#4333)
* Use local node_modules files instead of unkpkg for advanced playground, get test blocks in the basic playground from npm * Also move theme-modern * Update package-lock
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
<script src="../blocks/procedures.js"></script>
|
||||
<script src="themes/test_themes.js"></script>
|
||||
<script src="./playgrounds/screenshot.js"></script>
|
||||
<script src="../node_modules/@blockly/block-test/dist/index.js"></script>
|
||||
|
||||
<script>
|
||||
// Custom requires for the playground.
|
||||
@@ -126,6 +127,7 @@ function start() {
|
||||
scaleSpeed: 1.1
|
||||
}
|
||||
});
|
||||
initToolbox(workspace);
|
||||
workspace.configureContextMenu = configureContextMenu;
|
||||
// Restore previously displayed text.
|
||||
if (sessionStorage) {
|
||||
@@ -164,9 +166,18 @@ function getToolboxSuffix() {
|
||||
}
|
||||
|
||||
function getToolboxElement() {
|
||||
var toolboxSuffix = getToolboxSuffix();
|
||||
if (toolboxSuffix == 'test-blocks') {
|
||||
if (typeof window.toolboxTestBlocks !== 'undefined') {
|
||||
return toolboxTestBlocks;
|
||||
} else {
|
||||
alert('You need to run \'npm install\' in order to use the test blocks.');
|
||||
toolboxSuffix = 'categories';
|
||||
}
|
||||
}
|
||||
// The three possible values are: "simple", "categories",
|
||||
// "categories-typed-variables".
|
||||
return document.getElementById('toolbox-' + getToolboxSuffix());
|
||||
return document.getElementById('toolbox-' + toolboxSuffix);
|
||||
}
|
||||
|
||||
function setToolboxDropdown() {
|
||||
@@ -174,12 +185,21 @@ function setToolboxDropdown() {
|
||||
'toolbox-categories',
|
||||
'toolbox-categories-typed-variables',
|
||||
'toolbox-simple',
|
||||
'toolbox-test-blocks'
|
||||
];
|
||||
var toolboxSuffix = getToolboxSuffix();
|
||||
document.forms.options.elements.toolbox.selectedIndex =
|
||||
toolboxNames.indexOf('toolbox-' + toolboxSuffix);
|
||||
}
|
||||
|
||||
function initToolbox(workspace) {
|
||||
var toolboxSuffix = getToolboxSuffix();
|
||||
if (toolboxSuffix == 'test-blocks' &&
|
||||
typeof window.toolboxTestBlocksInit !== 'undefined') {
|
||||
toolboxTestBlocksInit(workspace);
|
||||
}
|
||||
}
|
||||
|
||||
function toXml() {
|
||||
var output = document.getElementById('importExport');
|
||||
var xml = Blockly.Xml.workspaceToDom(workspace);
|
||||
@@ -395,6 +415,7 @@ var spaghettiXml = [
|
||||
<option value="categories">Categories (untyped variables)</option>
|
||||
<option value="categories-typed-variables">Categories (typed variables)</option>
|
||||
<option value="simple">Simple</option>
|
||||
<option value="test-blocks">Test Blocks</option>
|
||||
</select>
|
||||
</form>
|
||||
<p>
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
<script src="../../blocks/procedures.js"></script>
|
||||
<script src="../themes/test_themes.js"></script>
|
||||
<script src="./screenshot.js"></script>
|
||||
<script src="https://unpkg.com/@blockly/dev-tools@2.0.0/dist/index.js"></script>
|
||||
<script src="https://unpkg.com/@blockly/theme-modern/dist/index.js"></script>
|
||||
<script src="../../node_modules/@blockly/dev-tools/dist/index.js"></script>
|
||||
<script src="../../node_modules/@blockly/theme-modern/dist/index.js"></script>
|
||||
|
||||
<script>
|
||||
// Custom requires for the playground.
|
||||
@@ -113,6 +113,10 @@ function configurePlayground(playground) {
|
||||
}
|
||||
|
||||
function initPlayground() {
|
||||
if (typeof window.createPlayground === 'undefined') {
|
||||
alert('You need to run \'npm install\' in order to use this playground.');
|
||||
return;
|
||||
}
|
||||
var defaultOptions = {
|
||||
comments: true,
|
||||
collapse: true,
|
||||
|
||||
Reference in New Issue
Block a user