Search
This commit is contained in:
parent
efacefbc58
commit
71f03ffbfe
@ -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');
|
||||
}
|
||||
@ -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 = '<xml>' +
|
||||
MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() +
|
||||
MotaActionBlocks[labels[i]].xmlText() +
|
||||
'</xml>';
|
||||
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();
|
||||
@ -178,6 +178,10 @@
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.parse()">解析</button>
|
||||
<button onclick="editor_blockly.cancel()">取消</button>
|
||||
<div style="position: relative; display: inline-block; margin-left: 10px">
|
||||
<div class="searchLogo"></div>
|
||||
<input type="text" id="blockSearch" placeholder="搜索图块"/>
|
||||
</div>
|
||||
<xml id="toolbox" style="display:none">
|
||||
</xml>
|
||||
</h3>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user