From e2f901985076de4176c905d350d5eafeb0f58e0b Mon Sep 17 00:00:00 2001
From: Zoey Li <31378877+alicialics@users.noreply.github.com>
Date: Thu, 9 Nov 2023 22:59:20 +0000
Subject: [PATCH 01/21] chore: run eslint and prettier on some examples
---
eslint.config.js | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/eslint.config.js b/eslint.config.js
index 2a66a6996c..87a4dfa7ba 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -19,7 +19,24 @@ const compat = new FlatCompat();
module.exports = [
{
ignores: [
- 'examples/',
+ 'examples/backpack-demo',
+ 'examples/blockly-angular',
+ 'examples/blockly-react',
+ 'examples/blockly-rtc',
+ 'examples/blockly-vue3',
+ 'examples/context-menu-codelab',
+ 'examples/custom-dialogs-demo',
+ 'examples/custom-renderer-codelab',
+ 'examples/custom-toolbox-codelab',
+ 'examples/devsite-demo',
+ 'examples/devsite-landing-demo',
+ 'examples/getting-started-codelab',
+ 'examples/interpreter-demo',
+ 'examples/pitch-field-demo',
+ 'examples/sample-app-ts',
+ 'examples/theme-extension-codelab',
+ 'examples/turtle-field-demo',
+ 'examples/validation-and-warnings-codelab',
'codelabs/',
'gh-pages/',
'**/dist/',
From 7a5af586828384f4be8c7d331c9acc6b6b5ba9ed Mon Sep 17 00:00:00 2001
From: Zoey Li <31378877+alicialics@users.noreply.github.com>
Date: Fri, 10 Nov 2023 18:20:32 +0000
Subject: [PATCH 02/21] chore: run prettier
---
.prettierignore | 23 +-
examples/blockly-svelte/README.md | 3 +-
examples/blockly-svelte/public/global.css | 65 +-
examples/blockly-svelte/public/index.html | 21 +-
examples/blockly-svelte/rollup.config.js | 17 +-
examples/blockly-svelte/src/main.js | 2 +-
.../src/blocks/json.js | 78 +-
.../src/generators/json.js | 36 +-
.../custom-generator-codelab/src/index.css | 43 +-
.../custom-generator-codelab/src/index.html | 18 +-
.../custom-generator-codelab/src/index.js | 8 +-
.../src/serialization.js | 4 +-
examples/custom-tooltips-demo/README.md | 1 +
examples/custom-tooltips-demo/index.html | 39 +-
examples/custom-tooltips-demo/index.js | 14 +-
examples/fixed-demo/index.html | 147 +-
examples/generator-demo/index.html | 428 +++---
examples/graph-demo/index.html | 1052 +++++++-------
examples/headless-demo/index.html | 129 +-
.../src/blocks/text.js | 5 +-
.../src/cursors/custom.js | 14 +-
.../src/generators/javascript.js | 12 +-
.../keyboard-navigation-codelab/src/index.css | 43 +-
.../src/index.html | 18 +-
.../keyboard-navigation-codelab/src/index.js | 46 +-
.../src/markers/custom_marker_svg.js | 12 +-
.../src/serialization.js | 4 +-
examples/max-blocks-demo/index.html | 183 +--
examples/mirror-demo/index.html | 248 ++--
examples/resizable-demo/index.html | 99 +-
examples/resizable-demo/overlay.html | 197 +--
examples/rtl-demo/index.html | 847 +++++------
examples/sample-app/src/blocks/text.js | 5 +-
.../sample-app/src/generators/javascript.js | 6 +-
examples/sample-app/src/index.css | 43 +-
examples/sample-app/src/index.html | 18 +-
examples/sample-app/src/index.js | 8 +-
examples/sample-app/src/serialization.js | 4 +-
.../single-direction-scroll-demo/index.html | 161 +--
examples/toolbox-demo/index.html | 1286 +++++++++--------
40 files changed, 2773 insertions(+), 2614 deletions(-)
diff --git a/.prettierignore b/.prettierignore
index bf200a37bc..a6cc936f44 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1,5 +1,24 @@
-# All examples, codelabs, etc.
-examples/*
+# Examples, codelabs, etc.
+examples/backpack-demo
+examples/blockly-angular
+examples/blockly-react
+examples/blockly-rtc
+examples/blockly-vue3
+examples/context-menu-codelab
+examples/custom-dialogs-demo
+examples/custom-renderer-codelab
+examples/custom-toolbox-codelab
+examples/devsite-demo
+examples/devsite-landing-demo
+examples/getting-started-codelab
+examples/interpreter-demo
+examples/pitch-field-demo
+examples/sample-app-ts
+examples/theme-extension-codelab
+examples/turtle-field-demo
+examples/validation-and-warnings-codelab
+examples/lerna.json
+examples/README.md
node_modules/*
codelabs/*
gh-pages/*
diff --git a/examples/blockly-svelte/README.md b/examples/blockly-svelte/README.md
index 108fb051f4..16f6ea1003 100644
--- a/examples/blockly-svelte/README.md
+++ b/examples/blockly-svelte/README.md
@@ -15,10 +15,11 @@ npm install
### Running
start [Rollup](https://rollupjs.org) by:
+
```bash
npm run start
```
### Browse
-Navigate to [http://localhost:3000/](http://localhost:3000/)
+Navigate to [http://localhost:3000/](http://localhost:3000/)
diff --git a/examples/blockly-svelte/public/global.css b/examples/blockly-svelte/public/global.css
index deaa4cfcc3..2807b357f6 100644
--- a/examples/blockly-svelte/public/global.css
+++ b/examples/blockly-svelte/public/global.css
@@ -1,62 +1,67 @@
-html, body {
- position: relative;
- width: 100%;
- height: 100%;
+html,
+body {
+ position: relative;
+ width: 100%;
+ height: 100%;
}
body {
- color: #333;
- margin: 0;
- padding: 8px;
- box-sizing: border-box;
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
+ color: #333;
+ margin: 0;
+ padding: 8px;
+ box-sizing: border-box;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
+ Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}
a {
- color: rgb(0,100,200);
- text-decoration: none;
+ color: rgb(0, 100, 200);
+ text-decoration: none;
}
a:hover {
- text-decoration: underline;
+ text-decoration: underline;
}
a:visited {
- color: rgb(0,80,160);
+ color: rgb(0, 80, 160);
}
label {
- display: block;
+ display: block;
}
-input, button, select, textarea {
- font-family: inherit;
- font-size: inherit;
- padding: 0.4em;
- margin: 0 0 0.5em 0;
- box-sizing: border-box;
- border: 1px solid #ccc;
- border-radius: 2px;
+input,
+button,
+select,
+textarea {
+ font-family: inherit;
+ font-size: inherit;
+ padding: 0.4em;
+ margin: 0 0 0.5em 0;
+ box-sizing: border-box;
+ border: 1px solid #ccc;
+ border-radius: 2px;
}
input:disabled {
- color: #ccc;
+ color: #ccc;
}
-input[type="range"] {
- height: 0;
+input[type='range'] {
+ height: 0;
}
button {
- color: #333;
- background-color: #f4f4f4;
- outline: none;
+ color: #333;
+ background-color: #f4f4f4;
+ outline: none;
}
button:active {
- background-color: #ddd;
+ background-color: #ddd;
}
button:focus {
- border-color: #666;
+ border-color: #666;
}
diff --git a/examples/blockly-svelte/public/index.html b/examples/blockly-svelte/public/index.html
index de7354234c..e1e4730a53 100644
--- a/examples/blockly-svelte/public/index.html
+++ b/examples/blockly-svelte/public/index.html
@@ -1,18 +1,17 @@
-
-
-
+
+
+
- Svelte app
+ Svelte app
-
-
-
+
+
+
-
-
+
+
-
-
+
diff --git a/examples/blockly-svelte/rollup.config.js b/examples/blockly-svelte/rollup.config.js
index d6eb97bd34..2666c43866 100644
--- a/examples/blockly-svelte/rollup.config.js
+++ b/examples/blockly-svelte/rollup.config.js
@@ -26,7 +26,7 @@ import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
-import { terser } from 'rollup-plugin-terser';
+import {terser} from 'rollup-plugin-terser';
const production = !process.env.ROLLUP_WATCH;
@@ -36,7 +36,7 @@ export default {
sourcemap: true,
format: 'iife',
name: 'app',
- file: 'public/bundle.js'
+ file: 'public/bundle.js',
},
plugins: [
svelte({
@@ -44,9 +44,9 @@ export default {
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
- css: css => {
+ css: (css) => {
css.write('bundle.css');
- }
+ },
}),
// If you have external dependencies installed from
@@ -56,7 +56,8 @@ export default {
// https://github.com/rollup/rollup-plugin-commonjs
resolve({
browser: true,
- dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/')
+ dedupe: (importee) =>
+ importee === 'svelte' || importee.startsWith('svelte/'),
}),
commonjs(),
@@ -66,9 +67,9 @@ export default {
// If we're building for production (npm run build
// instead of npm run dev), minify
- production && terser()
+ production && terser(),
],
watch: {
- clearScreen: false
- }
+ clearScreen: false,
+ },
};
diff --git a/examples/blockly-svelte/src/main.js b/examples/blockly-svelte/src/main.js
index 3be4eb417d..e0d7434542 100644
--- a/examples/blockly-svelte/src/main.js
+++ b/examples/blockly-svelte/src/main.js
@@ -24,7 +24,7 @@
import App from './App.svelte';
const app = new App({
- target: document.body
+ target: document.body,
});
export default app;
diff --git a/examples/custom-generator-codelab/src/blocks/json.js b/examples/custom-generator-codelab/src/blocks/json.js
index 53a23198f0..8343fa779a 100644
--- a/examples/custom-generator-codelab/src/blocks/json.js
+++ b/examples/custom-generator-codelab/src/blocks/json.js
@@ -11,41 +11,43 @@
import * as Blockly from 'blockly';
-export const blocks = Blockly.common.createBlockDefinitionsFromJsonArray([{
- 'type': 'object',
- 'message0': '{ %1 %2 }',
- 'args0': [
- {
- 'type': 'input_dummy',
- },
- {
- 'type': 'input_statement',
- 'name': 'MEMBERS',
- },
- ],
- 'output': null,
- 'colour': 230,
-},
-{
- 'type': 'member',
- 'message0': '%1 %2 %3',
- 'args0': [
- {
- 'type': 'field_input',
- 'name': 'MEMBER_NAME',
- 'text': '',
- },
- {
- 'type': 'field_label',
- 'name': 'COLON',
- 'text': ':',
- },
- {
- 'type': 'input_value',
- 'name': 'MEMBER_VALUE',
- },
- ],
- 'previousStatement': null,
- 'nextStatement': null,
- 'colour': 230,
-}]);
+export const blocks = Blockly.common.createBlockDefinitionsFromJsonArray([
+ {
+ 'type': 'object',
+ 'message0': '{ %1 %2 }',
+ 'args0': [
+ {
+ 'type': 'input_dummy',
+ },
+ {
+ 'type': 'input_statement',
+ 'name': 'MEMBERS',
+ },
+ ],
+ 'output': null,
+ 'colour': 230,
+ },
+ {
+ 'type': 'member',
+ 'message0': '%1 %2 %3',
+ 'args0': [
+ {
+ 'type': 'field_input',
+ 'name': 'MEMBER_NAME',
+ 'text': '',
+ },
+ {
+ 'type': 'field_label',
+ 'name': 'COLON',
+ 'text': ':',
+ },
+ {
+ 'type': 'input_value',
+ 'name': 'MEMBER_VALUE',
+ },
+ ],
+ 'previousStatement': null,
+ 'nextStatement': null,
+ 'colour': 230,
+ },
+]);
diff --git a/examples/custom-generator-codelab/src/generators/json.js b/examples/custom-generator-codelab/src/generators/json.js
index 07151a4582..383e2c93fb 100644
--- a/examples/custom-generator-codelab/src/generators/json.js
+++ b/examples/custom-generator-codelab/src/generators/json.js
@@ -17,62 +17,60 @@ const Order = {
ATOMIC: 0,
};
-jsonGenerator.scrub_ = function(block, code, thisOnly) {
- const nextBlock =
- block.nextConnection && block.nextConnection.targetBlock();
+jsonGenerator.scrub_ = function (block, code, thisOnly) {
+ const nextBlock = block.nextConnection && block.nextConnection.targetBlock();
if (nextBlock && !thisOnly) {
return code + ',\n' + jsonGenerator.blockToCode(nextBlock);
}
return code;
};
-jsonGenerator.forBlock['logic_null'] = function(block) {
+jsonGenerator.forBlock['logic_null'] = function (block) {
return ['null', Order.ATOMIC];
};
-jsonGenerator.forBlock['text'] = function(block) {
+jsonGenerator.forBlock['text'] = function (block) {
const textValue = block.getFieldValue('TEXT');
const code = `"${textValue}"`;
return [code, Order.ATOMIC];
};
-jsonGenerator.forBlock['math_number'] = function(block) {
+jsonGenerator.forBlock['math_number'] = function (block) {
const code = String(block.getFieldValue('NUM'));
return [code, Order.ATOMIC];
};
-jsonGenerator.forBlock['logic_boolean'] = function(block) {
- const code = (block.getFieldValue('BOOL') == 'TRUE') ? 'true' : 'false';
+jsonGenerator.forBlock['logic_boolean'] = function (block) {
+ const code = block.getFieldValue('BOOL') == 'TRUE' ? 'true' : 'false';
return [code, Order.ATOMIC];
};
-jsonGenerator.forBlock['member'] = function(block, generator) {
+jsonGenerator.forBlock['member'] = function (block, generator) {
const name = block.getFieldValue('MEMBER_NAME');
- const value = generator.valueToCode(
- block, 'MEMBER_VALUE', Order.ATOMIC);
+ const value = generator.valueToCode(block, 'MEMBER_VALUE', Order.ATOMIC);
const code = `"${name}": ${value}`;
return code;
};
-jsonGenerator.forBlock['lists_create_with'] = function(block, generator) {
+jsonGenerator.forBlock['lists_create_with'] = function (block, generator) {
const values = [];
for (let i = 0; i < block.itemCount_; i++) {
- const valueCode = generator.valueToCode(block, 'ADD' + i,
- Order.ATOMIC);
+ const valueCode = generator.valueToCode(block, 'ADD' + i, Order.ATOMIC);
if (valueCode) {
values.push(valueCode);
}
}
const valueString = values.join(',\n');
- const indentedValueString =
- generator.prefixLines(valueString, generator.INDENT);
+ const indentedValueString = generator.prefixLines(
+ valueString,
+ generator.INDENT,
+ );
const codeString = '[\n' + indentedValueString + '\n]';
return [codeString, Order.ATOMIC];
};
-jsonGenerator.forBlock['object'] = function(block, generator) {
- const statementMembers =
- generator.statementToCode(block, 'MEMBERS');
+jsonGenerator.forBlock['object'] = function (block, generator) {
+ const statementMembers = generator.statementToCode(block, 'MEMBERS');
const code = '{\n' + statementMembers + '\n}';
return [code, Order.ATOMIC];
};
diff --git a/examples/custom-generator-codelab/src/index.css b/examples/custom-generator-codelab/src/index.css
index 4a05dbfd9f..f282700701 100644
--- a/examples/custom-generator-codelab/src/index.css
+++ b/examples/custom-generator-codelab/src/index.css
@@ -1,39 +1,40 @@
body {
- margin: 0;
- max-width: 100vw;
+ margin: 0;
+ max-width: 100vw;
}
-pre, code {
- overflow: auto;
+pre,
+code {
+ overflow: auto;
}
#pageContainer {
- display: flex;
- width: 100%;
- max-width: 100vw;
- height: 100vh;
+ display: flex;
+ width: 100%;
+ max-width: 100vw;
+ height: 100vh;
}
#blocklyDiv {
- flex-basis: 100%;
- height: 100%;
- min-width: 600px;
+ flex-basis: 100%;
+ height: 100%;
+ min-width: 600px;
}
#outputPane {
- display: flex;
- flex-direction: column;
- width: 400px;
- flex: 0 0 400px;
- overflow: auto;
- margin: 1rem;
+ display: flex;
+ flex-direction: column;
+ width: 400px;
+ flex: 0 0 400px;
+ overflow: auto;
+ margin: 1rem;
}
#generatedCode {
- height: 50%;
- background-color: rgb(247, 240, 228);
+ height: 50%;
+ background-color: rgb(247, 240, 228);
}
#output {
- height: 50%;
-}
\ No newline at end of file
+ height: 50%;
+}
diff --git a/examples/custom-generator-codelab/src/index.html b/examples/custom-generator-codelab/src/index.html
index 2f81d3c111..36d8eeacd9 100644
--- a/examples/custom-generator-codelab/src/index.html
+++ b/examples/custom-generator-codelab/src/index.html
@@ -1,10 +1,10 @@
-
-
-
-
- Blockly Sample App
-
-
+
+
+
+
+ Blockly Sample App
+
+
-
-
+
+
diff --git a/examples/custom-generator-codelab/src/index.js b/examples/custom-generator-codelab/src/index.js
index 7d45f63b29..175127a432 100644
--- a/examples/custom-generator-codelab/src/index.js
+++ b/examples/custom-generator-codelab/src/index.js
@@ -38,14 +38,16 @@ ws.addChangeListener((e) => {
save(ws);
});
-
// Whenever the workspace changes meaningfully, run the code again.
ws.addChangeListener((e) => {
// Don't run the code when the workspace finishes loading; we're
// already running it once when the application starts.
// Don't run the code during drags; we might have invalid state.
- if (e.isUiEvent || e.type == Blockly.Events.FINISHED_LOADING ||
- ws.isDragging()) {
+ if (
+ e.isUiEvent ||
+ e.type == Blockly.Events.FINISHED_LOADING ||
+ ws.isDragging()
+ ) {
return;
}
runCode();
diff --git a/examples/custom-generator-codelab/src/serialization.js b/examples/custom-generator-codelab/src/serialization.js
index b31c22b9fd..2ffda8b460 100644
--- a/examples/custom-generator-codelab/src/serialization.js
+++ b/examples/custom-generator-codelab/src/serialization.js
@@ -13,7 +13,7 @@ const storageKey = 'jsonGeneratorWorkspace';
* Saves the state of the workspace to browser's local storage.
* @param {Blockly.Workspace} workspace Blockly workspace to save.
*/
-export const save = function(workspace) {
+export const save = function (workspace) {
const data = Blockly.serialization.workspaces.save(workspace);
window.localStorage?.setItem(storageKey, JSON.stringify(data));
};
@@ -22,7 +22,7 @@ export const save = function(workspace) {
* Loads saved state from local storage into the given workspace.
* @param {Blockly.Workspace} workspace Blockly workspace to load into.
*/
-export const load = function(workspace) {
+export const load = function (workspace) {
const data = window.localStorage?.getItem(storageKey);
if (!data) return;
diff --git a/examples/custom-tooltips-demo/README.md b/examples/custom-tooltips-demo/README.md
index be269653b8..f2c6925e5e 100644
--- a/examples/custom-tooltips-demo/README.md
+++ b/examples/custom-tooltips-demo/README.md
@@ -7,4 +7,5 @@ This is a demo of the custom tooltip API. This isn't a plugin that can be instal
Create a function that takes two parameters. The first is the div element to render the tooltip DOM into. The second is the element being moused over. You can get the tooltip string for the element by calling `Blockly.Tooltip.getTooltipOfObject(element)`. Do any custom logic you like to render the tooltip into the given div. Register your function with Blockly by calling `Blockly.Tooltip.setCustomTooltip(yourFunction)`. Your function will be called instead of the default rendering logic whenever a tooltip should be shown.
## License
+
Apache 2.0
diff --git a/examples/custom-tooltips-demo/index.html b/examples/custom-tooltips-demo/index.html
index 918454f37e..021ca334a2 100644
--- a/examples/custom-tooltips-demo/index.html
+++ b/examples/custom-tooltips-demo/index.html
@@ -1,23 +1,22 @@
-
+
+
+
+ Blockly Custom Tooltip Example
+
+
+
+
+
+
+
-
-
- Blockly Custom Tooltip Example
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/examples/custom-tooltips-demo/index.js b/examples/custom-tooltips-demo/index.js
index 9eabacd540..b7c56fef53 100644
--- a/examples/custom-tooltips-demo/index.js
+++ b/examples/custom-tooltips-demo/index.js
@@ -8,7 +8,6 @@
* @fileoverview Test page for example plugin showing custom tooltip rendering.
*/
-
/**
* Create and register the custom tooltip rendering function.
* This could be extracted into a plugin if desired.
@@ -18,7 +17,7 @@ function initTooltips() {
// a tooltip is shown in Blockly. The first argument is the div to render
// the content into. The second argument is the element to show the tooltip
// for.
- const customTooltip = function(div, element) {
+ const customTooltip = function (div, element) {
if (element instanceof Blockly.BlockSvg) {
// You can access the block being moused over.
// Here we get the color of the block to set the background color.
@@ -58,9 +57,9 @@ function createWorkspace(blocklyDiv, options) {
return workspace;
}
-document.addEventListener('DOMContentLoaded', function() {
+document.addEventListener('DOMContentLoaded', function () {
Blockly.Blocks['custom_tooltip_1'] = {
- init: function() {
+ init: function () {
this.appendDummyInput().appendField('This is a test block.');
this.setColour(150);
this.setTooltip('This is a regular tooltip.');
@@ -68,7 +67,7 @@ document.addEventListener('DOMContentLoaded', function() {
},
};
Blockly.Blocks['custom_tooltip_2'] = {
- init: function() {
+ init: function () {
this.appendDummyInput().appendField('Mouse over me.');
this.setColour(150);
this.setTooltip('Tip: This tooltip has an image.');
@@ -90,5 +89,8 @@ document.addEventListener('DOMContentLoaded', function() {
// createPlayground is from @blockly/dev-tools.
// eslint-disable-next-line no-undef
createPlayground(
- document.getElementById('root'), createWorkspace, defaultOptions);
+ document.getElementById('root'),
+ createWorkspace,
+ defaultOptions,
+ );
});
diff --git a/examples/fixed-demo/index.html b/examples/fixed-demo/index.html
index 33db0c3737..11dd5aed25 100644
--- a/examples/fixed-demo/index.html
+++ b/examples/fixed-demo/index.html
@@ -1,76 +1,85 @@
-
+
-
-
- Blockly Demo: Fixed Blockly
-
-
-
+
+
+ Blockly Demo: Fixed Blockly
+
+
+
-
-
-
-
This is a simple demo of injecting Blockly into a fixed-sized 'div' element.
+ body {
+ background-color: #fff;
+ font-family: sans-serif;
+ }
+ h1 {
+ font-weight: normal;
+ font-size: 140%;
+ }
+ .demo {
+ padding: 1rem;
+ }
+
+
+
+
+
+
-
-
-
+ const demoWorkspace = Blockly.inject('blocklyDiv', {
+ media: './node_modules/blockly/media/',
+ toolbox: toolbox,
+ });
+
+
diff --git a/examples/generator-demo/index.html b/examples/generator-demo/index.html
index 0d3cf15da2..036e738614 100644
--- a/examples/generator-demo/index.html
+++ b/examples/generator-demo/index.html
@@ -1,257 +1,271 @@
-
+
-
-
- Blockly Demo: Generating JavaScript
-
-
-
-
+
+
+ Blockly Demo: Generating JavaScript
+
+
+
+
-
-
-
- This is a simple demo of generating code from blocks and running
- the code using eval.
+
+
+
+
+ This is a simple demo of generating code from blocks and running the code
+ using eval.
+
- → More info on Code Generators and Running JavaScript .
+
+ → More info on
+ Code Generators
+ and
+ Running JavaScript .
+
-
- Show JavaScript
- Run JavaScript
-
+
+ Show JavaScript
+ Run JavaScript
+
-
+
-
-
-
+
+
diff --git a/examples/graph-demo/index.html b/examples/graph-demo/index.html
index ec918dc772..74801176e0 100644
--- a/examples/graph-demo/index.html
+++ b/examples/graph-demo/index.html
@@ -1,542 +1,572 @@
-
+
-
-
- Blockly Demo: Graph
-
-
-
-
-
+
+
+ Blockly Demo: Graph
+
+
+
+
+
-
-
-
- This is a demo of giving instant feedback as blocks are changed.
+
+
+
+ This is a demo of giving instant feedback as blocks are changed.
- → More info on Realtime generation …
+
+ → More info on
+ Realtime generation …
+
-
+
-
-
- ...
-
+
+
+ ...
+
-
-
-
-
- POWER
-
-
-
- 1
-
-
-
-
- 2
-
-
- 1
-
-
-
-
-
-
+
+
+
+
+ POWER
+
+
+
+ 1
+
+
+
+
+ 2
+
+
+ 1
+
+
+
+
+
+
-
+ // When Blockly changes, update the graph.
+ Graph.workspace.addChangeListener(Graph.drawVisualization);
+ Graph.workspace.addChangeListener(Blockly.Events.disableOrphans);
+ Graph.resize();
+ };
-
+ window.addEventListener('load', Graph.init);
+ window.addEventListener('resize', Graph.resize);
+
+
diff --git a/examples/headless-demo/index.html b/examples/headless-demo/index.html
index 9eaa283248..855eec6e48 100644
--- a/examples/headless-demo/index.html
+++ b/examples/headless-demo/index.html
@@ -1,38 +1,40 @@
-
+
-
-
- Blockly Demo: Headless
-
-
-
-
-
-
-
- This is a simple demo of generating Python code from JSON with no graphics.
- This might be useful for server-side code generation.
+
+
+ Blockly Demo: Headless
+
+
+
+
+
+
+
+
+ This is a simple demo of generating Python code from JSON with no
+ graphics. This might be useful for server-side code generation.
+
-
-
- Generate Python ⤴
-
+
+ Generate Python ⤴
+
-
-
-
+
+
diff --git a/examples/keyboard-navigation-codelab/src/blocks/text.js b/examples/keyboard-navigation-codelab/src/blocks/text.js
index 30159e8df3..2b6a8c4e58 100644
--- a/examples/keyboard-navigation-codelab/src/blocks/text.js
+++ b/examples/keyboard-navigation-codelab/src/blocks/text.js
@@ -35,5 +35,6 @@ const addText = {
// Create the block definitions for the JSON-only blocks.
// This does not register their definitions with Blockly.
// This file has no side effects!
-export const blocks = Blockly.common.createBlockDefinitionsFromJsonArray(
- [addText]);
+export const blocks = Blockly.common.createBlockDefinitionsFromJsonArray([
+ addText,
+]);
diff --git a/examples/keyboard-navigation-codelab/src/cursors/custom.js b/examples/keyboard-navigation-codelab/src/cursors/custom.js
index 4599eedc84..4562da6adf 100644
--- a/examples/keyboard-navigation-codelab/src/cursors/custom.js
+++ b/examples/keyboard-navigation-codelab/src/cursors/custom.js
@@ -13,8 +13,11 @@ export class CustomCursor extends Blockly.Cursor {
let newNode = curNode.next();
// While the newNode exists and is either a previous or next type go to the
// next value.
- while (newNode && (newNode.getType() === Blockly.ASTNode.types.PREVIOUS ||
- newNode.getType() === Blockly.ASTNode.types.NEXT)) {
+ while (
+ newNode &&
+ (newNode.getType() === Blockly.ASTNode.types.PREVIOUS ||
+ newNode.getType() === Blockly.ASTNode.types.NEXT)
+ ) {
newNode = newNode.next();
}
if (newNode) {
@@ -48,8 +51,11 @@ export class CustomCursor extends Blockly.Cursor {
let newNode = curNode.prev();
// While the newNode exists and is either a previous or next connection go
// to the previous value.
- while (newNode && (newNode.getType() === Blockly.ASTNode.types.PREVIOUS ||
- newNode.getType() === Blockly.ASTNode.types.NEXT)) {
+ while (
+ newNode &&
+ (newNode.getType() === Blockly.ASTNode.types.PREVIOUS ||
+ newNode.getType() === Blockly.ASTNode.types.NEXT)
+ ) {
newNode = newNode.prev();
}
if (newNode) {
diff --git a/examples/keyboard-navigation-codelab/src/generators/javascript.js b/examples/keyboard-navigation-codelab/src/generators/javascript.js
index f2af8c19ac..1ee6bc2364 100644
--- a/examples/keyboard-navigation-codelab/src/generators/javascript.js
+++ b/examples/keyboard-navigation-codelab/src/generators/javascript.js
@@ -11,14 +11,14 @@ import {Order} from 'blockly/javascript';
// This file has no side effects!
export const forBlock = Object.create(null);
-forBlock['add_text'] = function(block, generator) {
- const text = generator.valueToCode(block, 'TEXT', Order.NONE) || '\'\'';
+forBlock['add_text'] = function (block, generator) {
+ const text = generator.valueToCode(block, 'TEXT', Order.NONE) || "''";
const color =
- generator.valueToCode(block, 'COLOR', Order.ATOMIC) || '\'#ffffff\'';
+ generator.valueToCode(block, 'COLOR', Order.ATOMIC) || "'#ffffff'";
const addText = generator.provideFunction_(
- 'addText',
- `function ${generator.FUNCTION_NAME_PLACEHOLDER_}(text, color) {
+ 'addText',
+ `function ${generator.FUNCTION_NAME_PLACEHOLDER_}(text, color) {
// Add text to the output area.
const outputDiv = document.getElementById('output');
@@ -26,7 +26,7 @@ forBlock['add_text'] = function(block, generator) {
textEl.innerText = text;
textEl.style.color = color;
outputDiv.appendChild(textEl);
-}`
+}`,
);
// Generate the function call for this block.
const code = `${addText}(${text}, ${color});\n`;
diff --git a/examples/keyboard-navigation-codelab/src/index.css b/examples/keyboard-navigation-codelab/src/index.css
index 4a05dbfd9f..f282700701 100644
--- a/examples/keyboard-navigation-codelab/src/index.css
+++ b/examples/keyboard-navigation-codelab/src/index.css
@@ -1,39 +1,40 @@
body {
- margin: 0;
- max-width: 100vw;
+ margin: 0;
+ max-width: 100vw;
}
-pre, code {
- overflow: auto;
+pre,
+code {
+ overflow: auto;
}
#pageContainer {
- display: flex;
- width: 100%;
- max-width: 100vw;
- height: 100vh;
+ display: flex;
+ width: 100%;
+ max-width: 100vw;
+ height: 100vh;
}
#blocklyDiv {
- flex-basis: 100%;
- height: 100%;
- min-width: 600px;
+ flex-basis: 100%;
+ height: 100%;
+ min-width: 600px;
}
#outputPane {
- display: flex;
- flex-direction: column;
- width: 400px;
- flex: 0 0 400px;
- overflow: auto;
- margin: 1rem;
+ display: flex;
+ flex-direction: column;
+ width: 400px;
+ flex: 0 0 400px;
+ overflow: auto;
+ margin: 1rem;
}
#generatedCode {
- height: 50%;
- background-color: rgb(247, 240, 228);
+ height: 50%;
+ background-color: rgb(247, 240, 228);
}
#output {
- height: 50%;
-}
\ No newline at end of file
+ height: 50%;
+}
diff --git a/examples/keyboard-navigation-codelab/src/index.html b/examples/keyboard-navigation-codelab/src/index.html
index 2f81d3c111..36d8eeacd9 100644
--- a/examples/keyboard-navigation-codelab/src/index.html
+++ b/examples/keyboard-navigation-codelab/src/index.html
@@ -1,10 +1,10 @@
-
-
-
-
- Blockly Sample App
-
-
+
+
+
+
+ Blockly Sample App
+
+
-
-
+
+
diff --git a/examples/keyboard-navigation-codelab/src/index.js b/examples/keyboard-navigation-codelab/src/index.js
index 8b584e5ca3..b09618ea3f 100644
--- a/examples/keyboard-navigation-codelab/src/index.js
+++ b/examples/keyboard-navigation-codelab/src/index.js
@@ -60,14 +60,16 @@ ws.addChangeListener((e) => {
save(ws);
});
-
// Whenever the workspace changes meaningfully, run the code again.
ws.addChangeListener((e) => {
// Don't run the code when the workspace finishes loading; we're
// already running it once when the application starts.
// Don't run the code during drags; we might have invalid state.
- if (e.isUiEvent || e.type == Blockly.Events.FINISHED_LOADING ||
- ws.isDragging()) {
+ if (
+ e.isUiEvent ||
+ e.type == Blockly.Events.FINISHED_LOADING ||
+ ws.isDragging()
+ ) {
return;
}
runCode();
@@ -75,15 +77,17 @@ ws.addChangeListener((e) => {
// Create a serialized key from the primary key and any modifiers.
const ctrlW = Blockly.ShortcutRegistry.registry.createSerializedKey(
- Blockly.utils.KeyCodes.W, [Blockly.ShortcutRegistry.modifierKeys.Control]);
+ Blockly.utils.KeyCodes.W,
+ [Blockly.ShortcutRegistry.modifierKeys.Control],
+);
const moveToStack = {
name: 'moveToStack',
keyCodes: [ctrlW], // The custom key mapping.
- preconditionFn: function(workspace) {
+ preconditionFn: function (workspace) {
return workspace.keyboardAccessibilityMode;
},
- callback: function(workspace) {
+ callback: function (workspace) {
const cursor = workspace.getCursor();
// Gets the current node.
const currentNode = cursor.getCurNode();
@@ -91,7 +95,7 @@ const moveToStack = {
const currentBlock = currentNode.getSourceBlock();
// If we are on a workspace node there will be no source block.
if (currentBlock) {
- // Gets the top block in the stack.
+ // Gets the top block in the stack.
const rootBlock = currentBlock.getRootBlock();
// Gets the top node on a block. This is either the previous connection,
// output connection, or the block itself.
@@ -106,21 +110,33 @@ const moveToStack = {
Blockly.ShortcutRegistry.registry.register(moveToStack);
Blockly.ShortcutRegistry.registry.removeAllKeyMappings(
- Constants.SHORTCUT_NAMES.OUT);
+ Constants.SHORTCUT_NAMES.OUT,
+);
Blockly.ShortcutRegistry.registry.addKeyMapping(
- Blockly.utils.KeyCodes.LEFT, Constants.SHORTCUT_NAMES.OUT);
+ Blockly.utils.KeyCodes.LEFT,
+ Constants.SHORTCUT_NAMES.OUT,
+);
Blockly.ShortcutRegistry.registry.removeAllKeyMappings(
- Constants.SHORTCUT_NAMES.IN);
+ Constants.SHORTCUT_NAMES.IN,
+);
Blockly.ShortcutRegistry.registry.addKeyMapping(
- Blockly.utils.KeyCodes.RIGHT, Constants.SHORTCUT_NAMES.IN);
+ Blockly.utils.KeyCodes.RIGHT,
+ Constants.SHORTCUT_NAMES.IN,
+);
Blockly.ShortcutRegistry.registry.removeAllKeyMappings(
- Constants.SHORTCUT_NAMES.PREVIOUS);
+ Constants.SHORTCUT_NAMES.PREVIOUS,
+);
Blockly.ShortcutRegistry.registry.addKeyMapping(
- Blockly.utils.KeyCodes.UP, Constants.SHORTCUT_NAMES.PREVIOUS);
+ Blockly.utils.KeyCodes.UP,
+ Constants.SHORTCUT_NAMES.PREVIOUS,
+);
Blockly.ShortcutRegistry.registry.removeAllKeyMappings(
- Constants.SHORTCUT_NAMES.NEXT);
+ Constants.SHORTCUT_NAMES.NEXT,
+);
Blockly.ShortcutRegistry.registry.addKeyMapping(
- Blockly.utils.KeyCodes.DOWN, Constants.SHORTCUT_NAMES.NEXT);
+ Blockly.utils.KeyCodes.DOWN,
+ Constants.SHORTCUT_NAMES.NEXT,
+);
diff --git a/examples/keyboard-navigation-codelab/src/markers/custom_marker_svg.js b/examples/keyboard-navigation-codelab/src/markers/custom_marker_svg.js
index 160e8101f3..f4f676b65b 100644
--- a/examples/keyboard-navigation-codelab/src/markers/custom_marker_svg.js
+++ b/examples/keyboard-navigation-codelab/src/markers/custom_marker_svg.js
@@ -14,13 +14,19 @@ class CustomMarkerSvg extends Blockly.blockRendering.MarkerSvg {
// Create the svg element for the marker when it is on a block and set the
// parent to markerSvg_.
this.blockPath_ = Blockly.utils.dom.createSvgElement(
- 'path', {}, this.markerSvg_);
+ 'path',
+ {},
+ this.markerSvg_,
+ );
// If this is a cursor make the cursor blink.
if (this.isCursor()) {
const blinkProperties = this.getBlinkProperties_();
- Blockly.utils.dom.createSvgElement('animate', blinkProperties,
- this.blockPath_);
+ Blockly.utils.dom.createSvgElement(
+ 'animate',
+ blinkProperties,
+ this.blockPath_,
+ );
}
}
diff --git a/examples/keyboard-navigation-codelab/src/serialization.js b/examples/keyboard-navigation-codelab/src/serialization.js
index 0cf9a6377f..685eaf2fd7 100644
--- a/examples/keyboard-navigation-codelab/src/serialization.js
+++ b/examples/keyboard-navigation-codelab/src/serialization.js
@@ -12,7 +12,7 @@ const storageKey = 'mainWorkspace';
* Saves the state of the workspace to browser's local storage.
* @param {Blockly.Workspace} workspace Blockly workspace to save.
*/
-export const save = function(workspace) {
+export const save = function (workspace) {
const data = Blockly.serialization.workspaces.save(workspace);
window.localStorage?.setItem(storageKey, JSON.stringify(data));
};
@@ -21,7 +21,7 @@ export const save = function(workspace) {
* Loads saved state from local storage into the given workspace.
* @param {Blockly.Workspace} workspace Blockly workspace to load into.
*/
-export const load = function(workspace) {
+export const load = function (workspace) {
const data = window.localStorage?.getItem(storageKey);
if (!data) return;
diff --git a/examples/max-blocks-demo/index.html b/examples/max-blocks-demo/index.html
index c1e7f1c533..9fd8f7c51c 100644
--- a/examples/max-blocks-demo/index.html
+++ b/examples/max-blocks-demo/index.html
@@ -1,97 +1,104 @@
-
+
-
-
- Blockly Demo: Maximum Block Limit
-
-
-
-
-
-
- This is a demo of Blockly which has been restricted to a maximum of
- five blocks.
+
+
+ Blockly Demo: Maximum Block Limit
+
+
+
+
+
+
+
+ This is a demo of Blockly which has been restricted to a maximum of five
+ blocks.
+
- You have block(s) left.
+
+ You have block(s) left.
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
- 10
-
-
-
-
-
- i
-
-
- 1
-
-
-
-
- 10
-
-
-
-
- 1
-
-
-
-
-
-
- 123
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ 10
+
+
+
+
+
+ i
+
+
+ 1
+
+
+
+
+ 10
+
+
+
+
+ 1
+
+
+
+
+
+
+ 123
+
+
+
+
+
+
+
+
+
+
-
-
-
+ demoWorkspace.addChangeListener(onchange);
+ onchange();
+
+
diff --git a/examples/mirror-demo/index.html b/examples/mirror-demo/index.html
index f13ca665c5..00ffe3fb6e 100644
--- a/examples/mirror-demo/index.html
+++ b/examples/mirror-demo/index.html
@@ -1,127 +1,137 @@
-
+
-
-
- Blockly Demo: Mirrored Blockly
-
-
-
-
-
-
- This is a simple demo of a primary Blockly instance that controls a secondary Blockly instance with events.
- Open the JavaScript console to see the event passing.
+
+
+ Blockly Demo: Mirrored Blockly
+
+
+
+
+
+
+
+ This is a simple demo of a primary Blockly instance that controls a
+ secondary Blockly instance with events. Open the JavaScript console to see
+ the event passing.
+
- → More info on events …
+
+ → More info on
+ events …
+
-
+
-
-
-
+
+
diff --git a/examples/resizable-demo/index.html b/examples/resizable-demo/index.html
index 5428ddc1e3..a028b0a56e 100644
--- a/examples/resizable-demo/index.html
+++ b/examples/resizable-demo/index.html
@@ -1,49 +1,56 @@
-
+
-
-
- Blockly Demo: Resizable Blockly (Part 1)
-
-
-
-
-
-
- The first step in creating a resizable Blockly workspace is to use
- CSS or tables to create an area for it.
- Next, inject Blockly over that area.
+
+
+ Blockly Demo: Resizable Blockly (Part 1)
+
+
+
+
+
+
+
+ The first step in creating a resizable Blockly workspace is to use
+ CSS or tables to create an area for it. Next,
+ inject Blockly over that area.
+
- → More info on injecting resizable Blockly …
-
-
-
-
- Blockly will be positioned here.
-
-
-
-
+
+ → More info on
+ injecting resizable Blockly …
+
+
+
+
+ Blockly will be positioned here.
+
+
+
diff --git a/examples/resizable-demo/overlay.html b/examples/resizable-demo/overlay.html
index be5ced33e3..25be274833 100644
--- a/examples/resizable-demo/overlay.html
+++ b/examples/resizable-demo/overlay.html
@@ -1,117 +1,124 @@
-
+
-
-
- Blockly Demo: Resizable Blockly (Part 2)
-
-
-
-
-
-
-
-
-
-
- Once an area is defined , Blockly can be
- injected and positioned over the area.
- A resize handler keeps it in position as the page changes.
-
+
+
+ Blockly Demo: Resizable Blockly (Part 2)
+
+
+
+
+
+
+
+
+
+
+ Once an area is defined , Blockly can be
+ injected and positioned over the area. A resize handler keeps it in
+ position as the page changes.
+
- → More info on injecting resizable Blockly …
-
-
-
-
-
-
-
+
+ → More info on
+ injecting resizable Blockly …
+
+
+
+
+
+
+
-
+
-
-
+ console.log('resize');
+ };
+ window.addEventListener('resize', onresize, false);
+ onresize();
+
+
diff --git a/examples/rtl-demo/index.html b/examples/rtl-demo/index.html
index 82143efed4..e2d6a0055b 100644
--- a/examples/rtl-demo/index.html
+++ b/examples/rtl-demo/index.html
@@ -1,430 +1,435 @@
-
+
-
-
-
- Blockly Demo: RTL
-
-
-
-
-
+
+
+
+
-
-
-
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_length',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_isEmpty',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_indexOf',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_charAt',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_changeCase',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_trim',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_print',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'text_prompt_ext',
+ 'inputs': {
+ 'TEXT': {
+ 'kind': 'block',
+ 'type': 'text',
+ },
+ },
+ },
+ ],
+ },
+ {
+ 'kind': 'category',
+ 'name': 'قوائم',
+ 'colour': '%{BKY_LISTS_HUE}',
+ 'contents': [
+ {
+ 'kind': 'block',
+ 'type': 'lists_create_empty',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'lists_create_with',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'lists_repeat',
+ 'inputs': {
+ 'NUM': {
+ 'block': {
+ 'type': 'math_number',
+ 'fields': {
+ 'NUM': 5,
+ },
+ },
+ },
+ },
+ },
+ {
+ 'kind': 'block',
+ 'type': 'lists_length',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'lists_isEmpty',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'lists_indexOf',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'lists_getIndex',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'lists_setIndex',
+ },
+ ],
+ },
+ {
+ 'kind': 'category',
+ 'name': 'لون',
+ 'colour': '%{BKY_COLOUR_HUE}',
+ 'contents': [
+ {
+ 'kind': 'block',
+ 'type': 'colour_picker',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'colour_rgb',
+ },
+ {
+ 'kind': 'block',
+ 'type': 'colour_blend',
+ },
+ ],
+ },
+ {
+ 'kind': 'sep',
+ },
+ {
+ 'kind': 'category',
+ 'name': 'متغيرات',
+ 'custom': 'VARIABLE',
+ 'colour': '%{BKY_VARIABLES_HUE}',
+ },
+ {
+ 'kind': 'category',
+ 'name': 'إجراءات',
+ 'custom': 'PROCEDURE',
+ 'colour': '%{BKY_PROCEDURES_HUE}',
+ },
+ ],
+ };
+ const workspace = Blockly.inject('blocklyDiv', {
+ media: './node_modules/blockly/media/',
+ rtl: true,
+ toolbox: toolbox,
+ });
+ Blockly.Xml.domToWorkspace(
+ document.getElementById('startBlocks'),
+ workspace,
+ );
+ // window.onbeforeunload = function() {
+ // return 'Leaving this page will result in the loss of your work.';
+ // };
+ }
+
+
+
+
-
-
-
-
- LT
-
-
- x
-
-
-
-
- 256
-
-
-
-
-
-
- x
-
-
- 0
-
-
-
-
-
-
- أكثر من لعبة
-
-
-
-
-
-
-
-
-
+
+
+
+
+ LT
+
+
+ x
+
+
+
+
+ 256
+
+
+
+
+
+
+ x
+
+
+ 0
+
+
+
+
+
+
+ أكثر من لعبة
+
+
+
+
+
+
+
+
+