From 3b0927e9a6a87dff120c51943ed9b70b7a1a64fe Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Fri, 1 Sep 2023 23:45:25 +0200 Subject: [PATCH 1/7] Update blockly to 10.x --- package.json | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c253b1d..4aeb198 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,14 @@ "version" : "2.0.1", "description" : "A Node Red node for visual programming a function using Blockly", "dependencies": { - "blockly": "^6.20210701.0", - "@blockly/field-date": "^4.2.14", - "@blockly/plugin-workspace-search": "^4.0.2", - "@blockly/zoom-to-fit": "^2.0.2", - "@blockly/workspace-backpack": "^1.0.2" + "blockly": "^10.1.3", + "@blockly/field-date": "^8.0.3", + "@blockly/plugin-workspace-search": "^8.0.4", + "@blockly/zoom-to-fit": "^5.0.4", + "@blockly/workspace-backpack": "^5.2.0", + "@blockly/plugin-workspace-search": "^8.0.4", + "@blockly/toolbox-search": "^1.1.4", + "@blockly/workspace-minimap": "^0.1.0" }, "author": { "name": "Bart Butenaers" From bab6837174fa78b4bd0b3676612641844bc51998 Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Sun, 10 Sep 2023 23:30:58 +0200 Subject: [PATCH 2/7] Blockly 10.x migration & minimap & toolbox search --- blockly.html | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/blockly.html b/blockly.html index f8d9ab4..61470fc 100644 --- a/blockly.html +++ b/blockly.html @@ -46,7 +46,8 @@ "blockly-contrib/npm/@blockly___SEPARATOR___plugin-workspace-search/dist/index.js", "blockly-contrib/npm/@blockly___SEPARATOR___zoom-to-fit/dist/index.js", "blockly-contrib/npm/@blockly___SEPARATOR___workspace-backpack/dist/index.js", - "blockly-contrib/npm/@blockly___SEPARATOR___workspace-backpack/dist/index.js" + "blockly-contrib/npm/@blockly___SEPARATOR___toolbox-search/dist/index.js", + "blockly-contrib/npm/@blockly___SEPARATOR___workspace-minimap/dist/index.js" ] }); @@ -209,7 +210,17 @@ } }); }); - + + // Add a 'Search' category at the end, which is linked automatically by Blockly to the toolbox-search plugin. + const searchElement = document.createElementNS("http://www.w3.org/1999/xhtml", "category"); + searchElement.setAttribute("name", "Search"); + searchElement.setAttribute("kind", "search"); + // When the search input field is clicked, a blue background appears. + // I tried to apply as color the same color as the background color (grey), but it doesn't help. + // The same happens in the official plugin demo (https://google.github.io/blockly-samples/plugins/toolbox-search/test/index.html) + searchElement.setAttribute("colour", "#B2B2B"); // Same color as the background + node.toolboxXmlDocument.documentElement.appendChild(searchElement); + // Create the workspace as soon as the last script has been loaded. // This is possible because the scripts are loaded sequentially (via async = false) if (node.workspace) { @@ -231,6 +242,7 @@ var showTrashcan = true; var allowComments = true; var showZoomControl = true; + var showMiniMap = true; var horizontalLayout = false; var enableBackPack = false; var toolboxPosition = "start"; @@ -246,6 +258,7 @@ showTrashcan = configNode.showTrashcan; allowComments = configNode.allowComments; showZoomControl = configNode.showZoomControl; + showMiniMap = configNode.showMiniMap; renderer = configNode.renderer; enableBackPack = configNode.enableBackPack; configNodeId = configNode.id; @@ -354,7 +367,14 @@ node.zoomToFit = new ZoomToFitControl(node.workspace); node.zoomToFit.init(); } - + + // Only show the minimap when the (fullscreen) tray is open, because the minimap is too big to fit into the node's config screen. + if (showMiniMap && node.isTrayOpen) { + // Enable the mini map on the workspace (via the workspace-minimap plugin) + node.minimap = new PositionedMinimap(node.workspace); + node.minimap.init(); + } + if (enableBackPack) { // Enable the backpack icon on the workspace (via the workspace-backpack plugin) node.backpack = new Backpack(node.workspace); @@ -379,7 +399,7 @@ try { // Load the workspace content again from the specified XML string - var dom = Blockly.Xml.textToDom(workspaceXml); + var dom = Blockly.utils.xml.textToDom(workspaceXml); Blockly.Xml.domToWorkspace(dom, node.workspace); } catch(err) { @@ -439,7 +459,13 @@ node.zoomToFit.dispose(); node.zoomToFit = null; } - + + // When previously a workspace-minimap plugin has been activated, then clean it up + if (node.minimap) { + node.minimap.dispose(); + node.minimap = null; + } + // When previously a workspace-backpack plugin has been activated (for the previous workspace instance), then clean it up if (node.backpack) { node.backpack.dispose(); @@ -573,6 +599,7 @@ node.librariesLoaded = false; node.previousEnableBackPack = "none"; + node.isTrayOpen = false; $( "#node-input-outputs" ).spinner({ min:1, @@ -743,7 +770,7 @@ text: RED._("common.label.cancel"), click: function() { var loadedXml = node.loadedXml; - + node.isTrayOpen = false; //Jeff: re-create workspace after RED.tray.close finished RED.tray.close(() => createWorkspace(node, loadedXml)); } @@ -755,7 +782,7 @@ click: function() { var dom = Blockly.Xml.workspaceToDom(node.workspace); var loadedXml = Blockly.Xml.domToPrettyText(dom); - + node.isTrayOpen = false; RED.tray.close(() => createWorkspace(node, loadedXml)); } } @@ -797,6 +824,7 @@ } } + node.isTrayOpen = true; RED.tray.show(trayOptions); } } From ef040910b38d62e58c5c5ec7eb3aaa54e535b117 Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Sun, 10 Sep 2023 23:33:08 +0200 Subject: [PATCH 3/7] Blockly 10.x migration & minimap --- blockly_config.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/blockly_config.html b/blockly_config.html index 6633a11..be832df 100644 --- a/blockly_config.html +++ b/blockly_config.html @@ -52,7 +52,7 @@ // need to replace that separator by the string "___SEPARATOR___". Otherwise the NGinx webserver installed together // with HomeAssistant will cause the Express.js routes to be messed up. // See https://github.com/bartbutenaers/node-red-contrib-blockly/issues/101 - "blockly-contrib/npm/@blockly___SEPARATOR___field-date/dist/date_compressed.js", + "blockly-contrib/npm/@blockly___SEPARATOR___field-date/dist/index.js", "blockly-contrib/npm/node-red-contrib-blockly/lib/datetime/dateTimeBlocksCodeGen.js", "blockly-contrib/npm/node-red-contrib-blockly/lib/datetime/dateTimeBlocksDefs.js", "blockly-contrib/npm/node-red-contrib-blockly/lib/datetime/toolbox.xml", @@ -103,6 +103,7 @@ showTrashcan: {value: true}, allowComments: {value: true}, showZoomControl: {value: true}, + showMiniMap: {value: true}, enableBackPack: {value: false}, // The backpackContents will be set by the Blockly nodes, but need to be defined here (otherwise it won't be persisted by Node-RED) backpackContents: {value: []}, @@ -261,6 +262,11 @@ Show zoom control icons in workspace +
+ + + Show a mini map in (expanded) workspace +
@@ -353,6 +359,8 @@ If activated, comments can be added to a block (via the right-click context menu).

Show zoom control icons in workspace:
If activated, zoom control icons will be displayed in the Blockly workspace.

+

Show mini map in workspace:
+ If activated, a mini map will be displayed in the Blockly workspace (when extended to fullscreen).

Show backpack icon in workspace:
If activated, a backpack icon will be displayed in the Blockly workspace. Via this way you can manage your favorite blocks.

Categories:
@@ -369,4 +377,4 @@

  • Thrasos:
  • Zelos: A Scratch-like look and feel.
  • - \ No newline at end of file + From 5e2592b44d80572cff7baaa886bab2e416e8d95a Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Sun, 10 Sep 2023 23:34:20 +0200 Subject: [PATCH 4/7] Blockly 10.x migration --- lib/nodered/nodeRedBlocksDefs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nodered/nodeRedBlocksDefs.js b/lib/nodered/nodeRedBlocksDefs.js index aa6d7f8..7de063f 100644 --- a/lib/nodered/nodeRedBlocksDefs.js +++ b/lib/nodered/nodeRedBlocksDefs.js @@ -242,10 +242,10 @@ Blockly.Blocks['node_send'] = { var insideLoop = false; var block = this; - + // Check whether this node_send block is (nested) inside a loop, by searching up the hierarchy to the root block do { - if(Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.LOOP_TYPES.indexOf(block.type) != -1) { + if(Blockly.libraryBlocks.loops.loopTypes.has(block.type)) { insideLoop = true; break; } From 40b85d9f7a1871c00f29a984327f0515d91e0e6b Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Sun, 10 Sep 2023 23:53:57 +0200 Subject: [PATCH 5/7] Bump version 2.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4aeb198..bd824f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-contrib-blockly", - "version" : "2.0.1", + "version" : "2.2.0", "description" : "A Node Red node for visual programming a function using Blockly", "dependencies": { "blockly": "^10.1.3", From ea14a91472d406748522a252076d93aebf9ff0aa Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Sun, 15 Oct 2023 21:10:12 +0200 Subject: [PATCH 6/7] update plugin-workspace-search minimal version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd824f3..e89c748 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "dependencies": { "blockly": "^10.1.3", "@blockly/field-date": "^8.0.3", - "@blockly/plugin-workspace-search": "^8.0.4", + "@blockly/plugin-workspace-search": "^8.0.6", "@blockly/zoom-to-fit": "^5.0.4", "@blockly/workspace-backpack": "^5.2.0", "@blockly/plugin-workspace-search": "^8.0.4", From 55fcd8e6f46a947482ac7506f814fb7e06f2e095 Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Sun, 15 Oct 2023 21:20:40 +0200 Subject: [PATCH 7/7] Minimum toolbox-search version 1.1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e89c748..9d3b4ea 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@blockly/zoom-to-fit": "^5.0.4", "@blockly/workspace-backpack": "^5.2.0", "@blockly/plugin-workspace-search": "^8.0.4", - "@blockly/toolbox-search": "^1.1.4", + "@blockly/toolbox-search": "^1.1.6", "@blockly/workspace-minimap": "^0.1.0" }, "author": {