diff --git a/_server/css/editor.css b/_server/css/editor.css
index 928a0964..c5837379 100644
--- a/_server/css/editor.css
+++ b/_server/css/editor.css
@@ -392,3 +392,21 @@ table.row td {
[v-cloak] {
display: none !important;
}
+
+#blockSearch {
+ width: 100px;
+ background-color: #E9EBF2;
+ border-radius: 10px;
+ outline: none;
+ padding-left: 20px;
+ height: 14px;
+}
+
+.searchLogo {
+ width: 15px;
+ height: 15px;
+ position: absolute;
+ left: 6px;
+ top: 7px;
+ background-image:url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGJhc2VQcm9maWxlPSJmdWxsIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpldj0iaHR0cDovL3d3dy53My5vcmcvMjAwMS94bWwtZXZlbnRzIj4KPGc%2BCgk8cG9seWdvbiBmaWxsPSIjNjY2IiBwb2ludHM9IjkuMjA3LDYuMTI2IDcuNzkzLDcuNTQxIDExLjc5MywxMS41NDEgMTMuMjA3LDEwLjEyNiIgLz4KCTxwYXRoIGZpbGw9IiM2NjYiIGQ9Ik01LjkxNywyYzEuNjA4LDAsMi45MTcsMS4zMDgsMi45MTcsMi45MTdTNy41MjUsNy44MzMsNS45MTcsNy44MzNTMyw2LjUyNSwzLDQuOTE3UzQuMzA4LDIsNS45MTcsMgoJCSBNNS45MTcsMEMzLjIwMSwwLDEsMi4yMDEsMSw0LjkxN3MyLjIwMSw0LjkxNyw0LjkxNyw0LjkxN3M0LjkxNy0yLjIwMSw0LjkxNy00LjkxN0MxMC44MzMsMi4yMDEsOC42MzIsMCw1LjkxNywwTDUuOTE3LDB6IiAvPgo8L2c%2BCjwvc3ZnPgo%3D');
+}
\ No newline at end of file
diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js
index a966619f..1d12d9ad 100644
--- a/_server/editor_blockly.js
+++ b/_server/editor_blockly.js
@@ -277,9 +277,10 @@ var workspace = Blockly.inject(blocklyDiv,{
editor_blockly.searchBlockCategoryCallback = function(workspace) {
var xmlList = [];
- for (var i = 0; i < editor_blockly.lastUsedType.length; i++) {
+ var labels = editor_blockly.searchBlock();
+ for (var i = 0; i < labels.length; i++) {
var blockText = '' +
- MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() +
+ MotaActionBlocks[labels[i]].xmlText() +
'';
var block = Blockly.Xml.textToDom(blockText).firstChild;
block.setAttribute("gap", 5);
@@ -310,8 +311,8 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
workspace.setScale(workspace.scale);
}
- var doubleClickCheck=[[0,'abc']];
- function omitedcheckUpdateFunction(event) {
+var doubleClickCheck=[[0,'abc']];
+function omitedcheckUpdateFunction(event) {
if(event.type==='move'){
editor_blockly.addIntoLastUsedType(event.blockId);
}
@@ -565,6 +566,60 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
editor_blockly.lastUsedType.unshift(blockType);
}
+ // Index from 1 - 9
+ editor_blockly.openToolbox = function(index) {
+ var element = document.getElementById(':'+index);
+ if (element == null || element.getAttribute("aria-selected")=="true") return;
+ element.click();
+ }
+ editor_blockly.reopenToolbox = function(index) {
+ var element = document.getElementById(':'+index);
+ if (element == null) return;
+ if (element.getAttribute("aria-selected")=="true") element.click();
+ element.click();
+ }
+
+ editor_blockly.closeToolbox = function() {
+ for (var i=1; i<=10; i++) {
+ var element = document.getElementById(':'+i);
+ if (element && element.getAttribute("aria-selected")=="true") {
+ element.click();
+ return;
+ }
+ }
+ }
+
+ var searchInput = document.getElementById("blockSearch");
+ searchInput.onfocus = function () {
+ editor_blockly.reopenToolbox(9);
+ }
+
+ searchInput.oninput = function () {
+ editor_blockly.reopenToolbox(9);
+ }
+
+ editor_blockly.searchBlock = function (value) {
+ if (value == null) value = searchInput.value;
+ value = value.toLowerCase();
+ if (value == '') return editor_blockly.lastUsedType;
+ var results = [];
+ for (var name in MotaActionBlocks) {
+ if (typeof name !== 'string' || name.indexOf("_s") !== name.length-2) continue;
+ var block = MotaActionBlocks[name];
+ if(block && block.json) {
+ if ((block.json.type||"").toLowerCase().indexOf(value)>=0
+ || (block.json.message0||"").toLowerCase().indexOf(value)>=0
+ || (block.json.tooltip||"").toLowerCase().indexOf(value)>=0) {
+ results.push(name);
+ if (results.length>=editor_blockly.lastUsedTypeNum)
+ break;
+ }
+ }
+ }
+
+ return results.length == 0 ? editor_blockly.lastUsedType : results;
+ }
+
return editor_blockly;
}
//editor_blockly=editor_blockly();
\ No newline at end of file
diff --git a/editor.html b/editor.html
index 54cdb46e..ce6bf5c2 100644
--- a/editor.html
+++ b/editor.html
@@ -178,6 +178,10 @@
+