更新blockly到最新;修复复制粘贴问题
This commit is contained in:
parent
0a14502d94
commit
176e5a9798
@ -202,13 +202,6 @@ textarea[disabled] {
|
|||||||
|
|
||||||
/** ======== blockly 相关 ======== */
|
/** ======== blockly 相关 ======== */
|
||||||
|
|
||||||
/**
|
|
||||||
blockly图块的的黑暗程度,用opacity表示,0到1之间;
|
|
||||||
0表示表示纯亮色,1表示纯黑色
|
|
||||||
*/
|
|
||||||
#blocklyDarkScale {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
/*魔改*/
|
/*魔改*/
|
||||||
|
|
||||||
.blocklyTreeLabel {
|
.blocklyTreeLabel {
|
||||||
|
|||||||
@ -166,8 +166,8 @@ select {
|
|||||||
background-color: #33333c;
|
background-color: #33333c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gameCanvas, img {
|
.gameCanvas, img, svg {
|
||||||
filter: brightness(0.75);
|
filter: brightness(0.65);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 搜索事件块的输入框 */
|
/** 搜索事件块的输入框 */
|
||||||
@ -298,11 +298,6 @@ blockly图块的的黑暗程度,用opacity表示,0到1之间;
|
|||||||
0表示表示纯亮色,1表示纯黑色
|
0表示表示纯亮色,1表示纯黑色
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#blocklyDarkScale {
|
|
||||||
opacity: 0.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 如果需要blockly深色模式,请有选择性视情况取消注释下面几条;具体功能自行研究 */
|
/** 如果需要blockly深色模式,请有选择性视情况取消注释下面几条;具体功能自行研究 */
|
||||||
|
|
||||||
/*somethingSOMETHING*/
|
/*somethingSOMETHING*/
|
||||||
@ -372,7 +367,6 @@ input.blocklyHtmlInput {
|
|||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** ======== Blockly中自动补全相关 ======== */
|
/** ======== Blockly中自动补全相关 ======== */
|
||||||
.awesomplete > ul {
|
.awesomplete > ul {
|
||||||
background: #33333c;
|
background: #33333c;
|
||||||
|
|||||||
@ -689,99 +689,121 @@ editor_blockly = function () {
|
|||||||
|
|
||||||
editor_blockly.completeItems = [];
|
editor_blockly.completeItems = [];
|
||||||
|
|
||||||
Blockly.BlockSvg.prototype.updateColour_origin = Blockly.BlockSvg.prototype.updateColour;
|
editor_blockly.onTextFieldCreate = function (self, htmlInput) {
|
||||||
Blockly.BlockSvg.prototype.setShadowColour__origin = Blockly.BlockSvg.prototype.setShadowColour_;
|
var pb=self.sourceBlock_
|
||||||
Blockly.BlockSvg.prototype.setBorderColour__origin = Blockly.BlockSvg.prototype.setBorderColour_;
|
var args = MotaActionBlocks[pb.type].args
|
||||||
|
var targetf=args[args.indexOf(self.name)+1]
|
||||||
|
|
||||||
editor_blockly.setDarkScale=function () {
|
// ------ colour
|
||||||
var computedStyle = window.getComputedStyle(document.getElementById('blocklyDarkScale')) || {};
|
|
||||||
var globalScale = parseFloat(computedStyle.opacity) || 0;
|
|
||||||
|
|
||||||
if (globalScale > 0) {
|
if(targetf && targetf.slice(0,7)==='Colour_'){
|
||||||
// todo: fix to suit the new blockly version
|
var inputDom = htmlInput;
|
||||||
// ref https://github.com/google/blockly/tree/52b818ed67c5bfa7fd73edf2b067649b8b1f447b
|
// var getValue=function(){ // 获得自己的字符串
|
||||||
Blockly.BlockSvg.prototype.updateColour = function() {
|
// return pb.getFieldValue(self.name);
|
||||||
if (this.disabled) {
|
// }
|
||||||
// Disabled blocks don't have colour.
|
var setValue = function(newValue){ // 设置右边颜色块的css颜色
|
||||||
return;
|
pb.setFieldValue(newValue, targetf)
|
||||||
|
}
|
||||||
|
// 给inputDom绑事件
|
||||||
|
inputDom.oninput=function(){
|
||||||
|
var value=inputDom.value
|
||||||
|
if(/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)){
|
||||||
|
setValue('rgba('+value+')')
|
||||||
}
|
}
|
||||||
var hexColour = this.getColour();
|
}
|
||||||
var colourSecondary = this.getColourSecondary();
|
}
|
||||||
var colourTertiary = this.getColourTertiary();
|
else {
|
||||||
var rgb = goog.color.darken(goog.color.hexToRgb(hexColour),globalScale);
|
|
||||||
hexColour = goog.color.rgbArrayToHex(rgb);
|
htmlInput.onkeydown = function (e) {
|
||||||
|
if (e.keyCode == 13 && awesomplete.opened && awesomplete.selected) {
|
||||||
if (this.isShadow()) {
|
e.stopPropagation();
|
||||||
hexColour = this.setShadowColour_(rgb, colourSecondary);
|
e.stopImmediatePropagation();
|
||||||
} else {
|
e.preventDefault();
|
||||||
this.setBorderColour_(rgb, colourTertiary);
|
awesomplete.select();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
this.svgPath_.setAttribute('fill', hexColour);
|
}
|
||||||
|
|
||||||
var icons = this.getIcons();
|
// --- awesomplete
|
||||||
for (var i = 0; i < icons.length; i++) {
|
var awesomplete = new Awesomplete(htmlInput, {
|
||||||
icons[i].updateColour();
|
minChars: 1,
|
||||||
|
maxItems: 12,
|
||||||
|
autoFirst: true,
|
||||||
|
replace: function (text) {
|
||||||
|
text = text.toString();
|
||||||
|
var index = text.indexOf("(");
|
||||||
|
if (index >= 0) text = text.substring(0, index);
|
||||||
|
var value = this.input.value, index = this.input.selectionEnd;
|
||||||
|
if (index == null) index = value.length;
|
||||||
|
if (index < awesomplete.prefix.length) index = awesomplete.prefix.length;
|
||||||
|
var str = value.substring(0, index - awesomplete.prefix.length) + text + value.substring(index);
|
||||||
|
this.input.value = str;
|
||||||
|
pb.setFieldValue(str, self.name);
|
||||||
|
self.forceRerender();
|
||||||
|
self.resizeEditor_();
|
||||||
|
index += text.length - awesomplete.prefix.length;
|
||||||
|
this.input.setSelectionRange(index, index);
|
||||||
|
|
||||||
|
editor_blockly.completeItems = editor_blockly.completeItems.filter(function (x) {
|
||||||
|
return x != text;
|
||||||
|
});
|
||||||
|
editor_blockly.completeItems.unshift(text);
|
||||||
|
},
|
||||||
|
filter: function () {return true;},
|
||||||
|
item: function (text, input) {
|
||||||
|
var li = document.createElement("li");
|
||||||
|
li.setAttribute("role", "option");
|
||||||
|
li.setAttribute("aria-selected", "false");
|
||||||
|
input = awesomplete.prefix.trim();
|
||||||
|
if (input != "") text = text.replace(new RegExp("^"+input, "i"), "<mark>$&</mark>");
|
||||||
|
li.innerHTML = text;
|
||||||
|
return li;
|
||||||
|
},
|
||||||
|
sort: function (a, b) {
|
||||||
|
a = a.toString(); b = b.toString();
|
||||||
|
var ia = editor_blockly.completeItems.indexOf(a), ib = editor_blockly.completeItems.indexOf(b);
|
||||||
|
if (ia < 0) ia = editor_blockly.completeItems.length;
|
||||||
|
if (ib < 0) ib = editor_blockly.completeItems.length;
|
||||||
|
if (ia != ib) return ia - ib;
|
||||||
|
if (a.length != b.length) return a.length - b.length;
|
||||||
|
return a < b ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// Bump every dropdown to change its colour.
|
|
||||||
// TODO (#1456)
|
htmlInput.oninput = function () {
|
||||||
for (var x = 0, input; input = this.inputList[x]; x++) {
|
var value = htmlInput.value, index = htmlInput.selectionEnd;
|
||||||
for (var y = 0, field; field = input.fieldRow[y]; y++) {
|
if (index == null) index = value.length;
|
||||||
field.forceRerender();
|
value = value.substring(0, index);
|
||||||
|
// cal prefix
|
||||||
|
awesomplete.prefix = value;
|
||||||
|
for (var i = index - 1; i>=0; i--) {
|
||||||
|
var c = value.charAt(i);
|
||||||
|
if (!/^[a-zA-Z0-9_\u4E00-\u9FCC]$/.test(c)) {
|
||||||
|
awesomplete.prefix = value.substring(i+1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var list = editor_blockly.getAutoCompletions(value, pb.type, self.name);
|
||||||
|
|
||||||
|
awesomplete.list = list;
|
||||||
|
awesomplete.ul.style.marginLeft = getCaretCoordinates(htmlInput, htmlInput.selectionStart).left -
|
||||||
|
htmlInput.scrollLeft - 20 + "px";
|
||||||
|
awesomplete.evaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: fix to suit the new blockly version
|
awesomplete.container.style.width = "100%";
|
||||||
// ref https://github.com/google/blockly/tree/52b818ed67c5bfa7fd73edf2b067649b8b1f447b
|
|
||||||
Blockly.BlockSvg.prototype.setShadowColour_ = function(a, b) {
|
window.awesomplete = awesomplete;
|
||||||
if (b) {
|
|
||||||
this.svgPathLight_.style.display = "none";
|
|
||||||
this.svgPathDark_.style.display = "none";
|
|
||||||
this.svgPath_.setAttribute("fill", b);
|
|
||||||
var c = b
|
|
||||||
} else
|
|
||||||
a = goog.color.darken(a, .4),
|
|
||||||
c = goog.color.rgbArrayToHex(a),
|
|
||||||
this.svgPathLight_.style.display = "none",
|
|
||||||
this.svgPathDark_.setAttribute("fill", c);
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: fix to suit the new blockly version
|
|
||||||
// ref https://github.com/google/blockly/tree/52b818ed67c5bfa7fd73edf2b067649b8b1f447b
|
|
||||||
Blockly.BlockSvg.prototype.setBorderColour_ = function(a, b) {
|
|
||||||
if (b)
|
|
||||||
this.svgPathLight_.setAttribute("stroke", "none"),
|
|
||||||
this.svgPathDark_.setAttribute("fill", "none"),
|
|
||||||
this.svgPath_.setAttribute("stroke", b);
|
|
||||||
else {
|
|
||||||
this.svgPathLight_.style.display = "";
|
|
||||||
var c = goog.color.rgbArrayToHex(goog.color.darken(a, .2))
|
|
||||||
, d = goog.color.rgbArrayToHex(goog.color.lighten(a, .3));
|
|
||||||
this.svgPathLight_.setAttribute("stroke", c);
|
|
||||||
this.svgPathDark_.setAttribute("fill", d);
|
|
||||||
this.svgPath_.setAttribute("stroke", "none")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Blockly.BlockSvg.prototype.updateColour = Blockly.BlockSvg.prototype.updateColour_origin;
|
|
||||||
Blockly.BlockSvg.prototype.setShadowColour_ = Blockly.BlockSvg.prototype.setShadowColour__origin;
|
|
||||||
Blockly.BlockSvg.prototype.setBorderColour_ = Blockly.BlockSvg.prototype.setBorderColour__origin;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_blockly.setDarkScale();
|
|
||||||
|
|
||||||
return editor_blockly;
|
return editor_blockly;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- modify Blockly
|
// --- modify Blockly
|
||||||
|
|
||||||
// todo: fix to suit the new blockly version
|
Blockly.FieldColour.prototype.showEditor_ = function() {
|
||||||
// ref https://github.com/google/blockly/tree/52b818ed67c5bfa7fd73edf2b067649b8b1f447b
|
|
||||||
Blockly.FieldColour.prototype.createWidget_ = function() {
|
|
||||||
Blockly.WidgetDiv.hide();
|
Blockly.WidgetDiv.hide();
|
||||||
|
|
||||||
// console.log('here')
|
// console.log('here')
|
||||||
@ -802,189 +824,90 @@ Blockly.FieldColour.prototype.createWidget_ = function() {
|
|||||||
|
|
||||||
var setValue=function(newValue){ // css颜色
|
var setValue=function(newValue){ // css颜色
|
||||||
self.setValue(newValue)
|
self.setValue(newValue)
|
||||||
var c=new Colors();
|
pb.setFieldValue(newValue.replace("rgba(","").replace(")",""), targetf) // 放在颜色块左边的域中
|
||||||
c.setColor(newValue)
|
|
||||||
var rgbatext = [c.colors.webSmart.r,c.colors.webSmart.g,c.colors.webSmart.b,c.colors.alpha].join(",");
|
|
||||||
pb.setFieldValue(rgbatext, targetf) // 放在颜色块左边的域中
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
document.getElementById("colorPicker").value = getValue();
|
document.getElementById("colorPicker").value = getValue();
|
||||||
// 设置位置
|
// 设置位置
|
||||||
openColorPicker(Blockly.WidgetDiv.DIV.style.left.replace(/[^\d.]/g, ''), Blockly.WidgetDiv.DIV.style.top.replace(/[^\d.]/g, ''), setValue);
|
var scaledBBox = self.getScaledBBox();
|
||||||
|
openColorPicker(scaledBBox.left, scaledBBox.bottom, setValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
return document.createElement('table');
|
return document.createElement('table');
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo: fix to suit the new blockly version
|
Blockly.FieldColour.prototype.setValue = function (colour) {
|
||||||
// ref https://github.com/google/blockly/tree/52b818ed67c5bfa7fd73edf2b067649b8b1f447b
|
this.doValueUpdate_(colour);
|
||||||
|
}
|
||||||
|
|
||||||
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
|
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
|
||||||
Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_());
|
Blockly.WidgetDiv.show(
|
||||||
var div = Blockly.WidgetDiv.DIV;
|
this, this.sourceBlock_.RTL, this.widgetDispose_.bind(this));
|
||||||
// Create the input.
|
this.htmlInput_ = this.widgetCreate_();
|
||||||
var htmlInput =
|
this.isBeingEdited_ = true;
|
||||||
goog.dom.createDom(goog.dom.TagName.INPUT, 'blocklyHtmlInput');
|
|
||||||
htmlInput.setAttribute('spellcheck', this.spellcheck_);
|
|
||||||
var fontSize =
|
|
||||||
(Blockly.FieldTextInput.FONTSIZE * this.workspace_.scale) + 'pt';
|
|
||||||
div.style.fontSize = fontSize;
|
|
||||||
htmlInput.style.fontSize = fontSize;
|
|
||||||
|
|
||||||
Blockly.FieldTextInput.htmlInput_ = htmlInput;
|
|
||||||
div.appendChild(htmlInput);
|
|
||||||
|
|
||||||
htmlInput.value = htmlInput.defaultValue = this.text_;
|
|
||||||
htmlInput.oldValue_ = null;
|
|
||||||
|
|
||||||
// console.log('here')
|
|
||||||
var self=this;
|
|
||||||
var pb=self.sourceBlock_
|
|
||||||
var args = MotaActionBlocks[pb.type].args
|
|
||||||
var targetf=args[args.indexOf(self.name)+1]
|
|
||||||
|
|
||||||
// ------ colour
|
|
||||||
|
|
||||||
if(targetf && targetf.slice(0,7)==='Colour_'){
|
|
||||||
var inputDom = htmlInput;
|
|
||||||
// var getValue=function(){ // 获得自己的字符串
|
|
||||||
// return pb.getFieldValue(self.name);
|
|
||||||
// }
|
|
||||||
var setValue = function(newValue){ // 设置右边颜色块的css颜色
|
|
||||||
pb.setFieldValue(newValue, targetf)
|
|
||||||
}
|
|
||||||
// 给inputDom绑事件
|
|
||||||
inputDom.oninput=function(){
|
|
||||||
var value=inputDom.value
|
|
||||||
if(/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)){
|
|
||||||
setValue('rgba('+value+')')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
htmlInput.onkeydown = function (e) {
|
|
||||||
if (e.keyCode == 13 && awesomplete.opened && awesomplete.selected) {
|
|
||||||
e.stopPropagation();
|
|
||||||
e.stopImmediatePropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
awesomplete.select();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- awesomplete
|
|
||||||
var awesomplete = new Awesomplete(htmlInput, {
|
|
||||||
minChars: 1,
|
|
||||||
maxItems: 12,
|
|
||||||
autoFirst: true,
|
|
||||||
replace: function (text) {
|
|
||||||
text = text.toString();
|
|
||||||
var index = text.indexOf("(");
|
|
||||||
if (index >= 0) text = text.substring(0, index);
|
|
||||||
var value = this.input.value, index = this.input.selectionEnd;
|
|
||||||
if (index == null) index = value.length;
|
|
||||||
if (index < awesomplete.prefix.length) index = awesomplete.prefix.length;
|
|
||||||
var str = value.substring(0, index - awesomplete.prefix.length) + text + value.substring(index);
|
|
||||||
this.input.value = str;
|
|
||||||
pb.setFieldValue(str, self.name);
|
|
||||||
index += text.length - awesomplete.prefix.length;
|
|
||||||
this.input.setSelectionRange(index, index);
|
|
||||||
|
|
||||||
editor_blockly.completeItems = editor_blockly.completeItems.filter(function (x) {
|
|
||||||
return x != text;
|
|
||||||
});
|
|
||||||
editor_blockly.completeItems.unshift(text);
|
|
||||||
},
|
|
||||||
filter: function () {return true;},
|
|
||||||
item: function (text, input) {
|
|
||||||
var li = document.createElement("li");
|
|
||||||
li.setAttribute("role", "option");
|
|
||||||
li.setAttribute("aria-selected", "false");
|
|
||||||
input = awesomplete.prefix.trim();
|
|
||||||
if (input != "") text = text.replace(new RegExp("^"+input, "i"), "<mark>$&</mark>");
|
|
||||||
li.innerHTML = text;
|
|
||||||
return li;
|
|
||||||
},
|
|
||||||
sort: function (a, b) {
|
|
||||||
a = a.toString(); b = b.toString();
|
|
||||||
var ia = editor_blockly.completeItems.indexOf(a), ib = editor_blockly.completeItems.indexOf(b);
|
|
||||||
if (ia < 0) ia = editor_blockly.completeItems.length;
|
|
||||||
if (ib < 0) ib = editor_blockly.completeItems.length;
|
|
||||||
if (ia != ib) return ia - ib;
|
|
||||||
if (a.length != b.length) return a.length - b.length;
|
|
||||||
return a < b ? -1 : 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
htmlInput.oninput = function () {
|
|
||||||
var value = htmlInput.value, index = htmlInput.selectionEnd;
|
|
||||||
if (index == null) index = value.length;
|
|
||||||
value = value.substring(0, index);
|
|
||||||
// cal prefix
|
|
||||||
awesomplete.prefix = value;
|
|
||||||
for (var i = index - 1; i>=0; i--) {
|
|
||||||
var c = value.charAt(i);
|
|
||||||
if (!/^[a-zA-Z0-9_\u4E00-\u9FCC]$/.test(c)) {
|
|
||||||
awesomplete.prefix = value.substring(i+1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var list = editor_blockly.getAutoCompletions(value, pb.type, self.name);
|
|
||||||
|
|
||||||
awesomplete.list = list;
|
|
||||||
awesomplete.ul.style.marginLeft = getCaretCoordinates(htmlInput, htmlInput.selectionStart).left -
|
|
||||||
htmlInput.scrollLeft - 20 + "px";
|
|
||||||
awesomplete.evaluate();
|
|
||||||
}
|
|
||||||
|
|
||||||
awesomplete.container.style.width = "100%";
|
|
||||||
|
|
||||||
window.awesomplete = awesomplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
editor_blockly.onTextFieldCreate(this, this.htmlInput_);
|
||||||
|
|
||||||
if (!quietInput) {
|
if (!quietInput) {
|
||||||
htmlInput.focus();
|
this.htmlInput_.focus({preventScroll:true});
|
||||||
htmlInput.select();
|
this.htmlInput_.select();
|
||||||
}
|
}
|
||||||
this.validate_();
|
};
|
||||||
this.resizeEditor_();
|
|
||||||
|
|
||||||
this.bindEvents_(htmlInput);
|
Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_ = function(e) {
|
||||||
|
if (e.keyCode == Blockly.utils.KeyCodes.ENTER && !(window.awesomplete && window.awesomplete.opened)) {
|
||||||
|
Blockly.WidgetDiv.hide();
|
||||||
|
Blockly.DropDownDiv.hideWithoutAnimation();
|
||||||
|
} else if (e.keyCode == Blockly.utils.KeyCodes.ESC) {
|
||||||
|
this.htmlInput_.value = this.htmlInput_.defaultValue;
|
||||||
|
Blockly.WidgetDiv.hide();
|
||||||
|
Blockly.DropDownDiv.hideWithoutAnimation();
|
||||||
|
} else if (e.keyCode == Blockly.utils.KeyCodes.TAB) {
|
||||||
|
Blockly.WidgetDiv.hide();
|
||||||
|
Blockly.DropDownDiv.hideWithoutAnimation();
|
||||||
|
this.sourceBlock_.tab(this, !e.shiftKey);
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.copy_ = function(toCopy) {
|
Blockly.copy_ = function(toCopy) {
|
||||||
if (toCopy.isComment) {
|
if (toCopy.isComment) {
|
||||||
var xml = toCopy.toXmlWithXY();
|
var xml = toCopy.toXmlWithXY();
|
||||||
} else {
|
} else {
|
||||||
var xml = Blockly.Xml.blockToDom(toCopy, true);
|
var xml = Blockly.Xml.blockToDom(toCopy, true);
|
||||||
// Copy only the selected block and internal blocks.
|
// Copy only the selected block and internal blocks.
|
||||||
Blockly.Xml.deleteNext(xml);
|
Blockly.Xml.deleteNext(xml);
|
||||||
// Encode start position in XML.
|
// Encode start position in XML.
|
||||||
var xy = toCopy.getRelativeToSurfaceXY();
|
var xy = toCopy.getRelativeToSurfaceXY();
|
||||||
xml.setAttribute('x', toCopy.RTL ? -xy.x : xy.x);
|
xml.setAttribute('x', toCopy.RTL ? -xy.x : xy.x);
|
||||||
xml.setAttribute('y', xy.y);
|
xml.setAttribute('oy', xy.y);
|
||||||
|
xml.setAttribute('sy', toCopy.workspace.scrollY);
|
||||||
}
|
}
|
||||||
Blockly.clipboardXml_ = xml;
|
Blockly.clipboardXml_ = xml;
|
||||||
Blockly.clipboardSource_ = toCopy.workspace;
|
Blockly.clipboardSource_ = toCopy.workspace;
|
||||||
Blockly.clipboardTypeCounts_ = toCopy.isComment ? null :
|
Blockly.clipboardTypeCounts_ = toCopy.isComment ? null :
|
||||||
Blockly.utils.getBlockTypeCounts(toCopy, true);
|
Blockly.utils.getBlockTypeCounts(toCopy, true);
|
||||||
setTimeout(function(){Blockly.clipboardSource_.paste(Blockly.clipboardXml_)});
|
};
|
||||||
};
|
|
||||||
|
/**
|
||||||
Blockly.duplicate = function(toDuplicate) {
|
* Paste the provided block onto the workspace.
|
||||||
// Save the clipboard.
|
* @param {!Element} xmlBlock XML block element.
|
||||||
var clipboardXml = Blockly.clipboardXml_;
|
*/
|
||||||
var clipboardSource = Blockly.clipboardSource_;
|
Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) {
|
||||||
|
if (!this.rendered || xmlBlock.getElementsByTagName('block').length >=
|
||||||
// Create a duplicate via a copy/paste operation.
|
this.remainingCapacity()) {
|
||||||
Blockly.copy_(toDuplicate);
|
return;
|
||||||
|
}
|
||||||
|
if (this.currentGesture_) {
|
||||||
// Restore the clipboard.
|
this.currentGesture_.cancel(); // Dragging while pasting? No.
|
||||||
Blockly.clipboardXml_ = clipboardXml;
|
}
|
||||||
Blockly.clipboardSource_ = clipboardSource;
|
if (xmlBlock.tagName.toLowerCase() == 'comment') {
|
||||||
};
|
this.pasteWorkspaceComment_(xmlBlock);
|
||||||
|
} else {
|
||||||
Blockly.utils.KeyCodes.V=99999
|
if (xmlBlock.hasAttribute('oy') && xmlBlock.hasAttribute('sy')) {
|
||||||
|
xmlBlock.setAttribute('y', parseFloat(xmlBlock.getAttribute('oy')) + parseFloat(xmlBlock.getAttribute('sy')) - this.scrollY);
|
||||||
|
}
|
||||||
|
this.pasteBlock_(xmlBlock);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@ -422,7 +422,7 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
if(event.type==='create'){
|
if(event.type==='create'){
|
||||||
editor_blockly.addIntoLastUsedType(event.blockId);
|
editor_blockly.addIntoLastUsedType(event.blockId);
|
||||||
}
|
}
|
||||||
if(event.type==='ui'){
|
if(event.type==='ui' && event.element == 'click'){
|
||||||
var newClick = [new Date().getTime(),event.blockId];
|
var newClick = [new Date().getTime(),event.blockId];
|
||||||
var lastClick = doubleClickCheck.shift();
|
var lastClick = doubleClickCheck.shift();
|
||||||
doubleClickCheck.push(newClick);
|
doubleClickCheck.push(newClick);
|
||||||
@ -432,6 +432,8 @@ function omitedcheckUpdateFunction(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Only handle these events
|
||||||
|
if (["create", "move", "change", "delete"].indexOf(event.type) < 0) return;
|
||||||
if(editor_blockly.workspace.topBlocks_.length>=2){
|
if(editor_blockly.workspace.topBlocks_.length>=2){
|
||||||
editor_blockly.setValue('入口方块只能有一个');
|
editor_blockly.setValue('入口方块只能有一个');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -396,10 +396,6 @@ editor_mappanel_wrapper = function (editor) {
|
|||||||
var theme = editor.dom.editorTheme.value;
|
var theme = editor.dom.editorTheme.value;
|
||||||
editor.config.set('theme', theme);
|
editor.config.set('theme', theme);
|
||||||
document.getElementById('color_css').href = '_server/css/' + theme + '.css';
|
document.getElementById('color_css').href = '_server/css/' + theme + '.css';
|
||||||
// 等新的css加载完毕再设置blockly亮度
|
|
||||||
setTimeout(function () {
|
|
||||||
editor_blockly.setDarkScale();
|
|
||||||
}, 1500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -225,7 +225,6 @@
|
|||||||
</xml>
|
</xml>
|
||||||
</h3>
|
</h3>
|
||||||
<div style="position: relative;height: 100%">
|
<div style="position: relative;height: 100%">
|
||||||
<div id="blocklyDarkScale" style="display: none;"></div>
|
|
||||||
<div id="blocklyArea">
|
<div id="blocklyArea">
|
||||||
<div id="blocklyDiv"></div>
|
<div id="blocklyDiv"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -221,7 +221,6 @@
|
|||||||
</xml>
|
</xml>
|
||||||
</h3>
|
</h3>
|
||||||
<div style="position: relative;height: 100%">
|
<div style="position: relative;height: 100%">
|
||||||
<div id="blocklyDarkScale" style="display: none;"></div>
|
|
||||||
<div id="blocklyArea">
|
<div id="blocklyArea">
|
||||||
<div id="blocklyDiv"></div>
|
<div id="blocklyDiv"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -93,19 +93,20 @@ main.floors.sample3=
|
|||||||
"\t[杰克,thief]没错,我就是这一切的背后主谋。",
|
"\t[杰克,thief]没错,我就是这一切的背后主谋。",
|
||||||
{
|
{
|
||||||
"type": "move",
|
"type": "move",
|
||||||
|
"time": 1000,
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
"up",
|
||||||
"direction": "up",
|
"up",
|
||||||
"value": 3
|
"up"
|
||||||
}
|
]
|
||||||
],
|
|
||||||
"time": 1000
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "show",
|
"type": "show",
|
||||||
"loc": [
|
"loc": [
|
||||||
6,
|
[
|
||||||
4
|
6,
|
||||||
|
4
|
||||||
|
]
|
||||||
],
|
],
|
||||||
"time": 1000
|
"time": 1000
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user