From 0d29d5c38435b24d65f5ce055cd5108f50d6ca68 Mon Sep 17 00:00:00 2001 From: BryceLTaylor Date: Mon, 24 May 2021 10:01:04 -0400 Subject: [PATCH 1/2] add keyboard navigation module and buttons --- package.json | 5 +++-- public/index.html | 2 ++ src/index.js | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d39094a..babb858 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,9 @@ ], "dependencies": { "@blockly/continuous-toolbox": "^1.0.4", - "blockly": ">=5.20210325.0", - "@blockly/dev-tools": "latest" + "@blockly/dev-tools": "latest", + "@blockly/keyboard-navigation": "^0.1.7", + "blockly": ">=5.20210325.0" }, "devDependencies": { "copy-webpack-plugin": "^5.1.1", diff --git a/public/index.html b/public/index.html index 9392f67..d712926 100644 --- a/public/index.html +++ b/public/index.html @@ -41,6 +41,8 @@ + +
diff --git a/src/index.js b/src/index.js index 32db410..1e654f3 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,6 @@ import * as Blockly from 'blockly'; -// I haven't figured out how to import this file properly so the themes are here. -// TODO: move them back into separate files. -//import Theme from './src/default_theme'; + +import {NavigationController} from '@blockly/keyboard-navigation'; // TODO Fix up all the other blocks files. They need: // * to have their style set correclty. @@ -39,6 +38,8 @@ import openDyslexicTheme from './themes/openDyslexic_theme.js'; import toolboxXmlObject from './toolbox.js'; const toolboxXml = toolboxXmlObject.toolbox; +const navControl = new NavigationController(); + /** * Create a workspace. * @param {HTMLElement} blocklyDiv The blockly container div. @@ -63,6 +64,12 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById("openDyslexic").addEventListener("click", function() { workspace.setTheme(openDyslexicTheme); }); + document.getElementById("enableKeyboard").addEventListener("click", function() { + navControl.enable(workspace); + }); + document.getElementById("disableKeyboard").addEventListener("click", function() { + navControl.disable(workspace); + }); const defaultOptions = { move: { @@ -94,4 +101,8 @@ document.addEventListener('DOMContentLoaded', function() { workspace = Blockly.inject('root', defaultOptions); //createPlayground(document.getElementById('root'), createWorkspace, defaultOptions); + + navControl.init(); + navControl.addWorkspace(workspace); + //navControl.enable(workspace); }); From 843f750de54bf34c29523a688a13c19b2690c019 Mon Sep 17 00:00:00 2001 From: BryceLTaylor Date: Mon, 24 May 2021 10:01:20 -0400 Subject: [PATCH 2/2] adjust height so buttons appear --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index d712926..fd6342f 100644 --- a/public/index.html +++ b/public/index.html @@ -12,7 +12,7 @@ } #root { - height: 100%; + height: 90%; } .blocklyFlyout{ border-right: 1px solid hsla(0, 0%, 0%, 0.15);