blockly auto complete
This commit is contained in:
parent
b138d0a157
commit
a0487a3e5c
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Peter Dematté
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@ -627,7 +627,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
if (obj.length > 0 && b.type.startsWith(obj[0].type)) {
|
||||
if (b.type == 'previewUI_s')
|
||||
uievent.previewUI(obj[0].action);
|
||||
else uievent.previewUI(obj);
|
||||
else uievent.previewUI([obj[0]]);
|
||||
}
|
||||
} catch (e) {main.log(e);}
|
||||
return true;
|
||||
@ -637,7 +637,6 @@ function omitedcheckUpdateFunction(event) {
|
||||
|
||||
editor_blockly.doubleClickBlock = function (blockId) {
|
||||
var b = editor_blockly.workspace.getBlockById(blockId);
|
||||
console.log(Blockly.JavaScript.blockToCode(b));
|
||||
|
||||
if (previewBlock(b)) return;
|
||||
|
||||
@ -853,4 +852,148 @@ function omitedcheckUpdateFunction(event) {
|
||||
|
||||
return editor_blockly;
|
||||
}
|
||||
//editor_blockly=editor_blockly();
|
||||
|
||||
// --- modify Blockly
|
||||
|
||||
Blockly.FieldColour.prototype.createWidget_ = function() {
|
||||
Blockly.WidgetDiv.hide();
|
||||
|
||||
// console.log('here')
|
||||
var self=this;
|
||||
var pb=self.sourceBlock_
|
||||
var args = MotaActionBlocks[pb.type].args
|
||||
var targetf=args[args.indexOf(self.name)-1]
|
||||
|
||||
var getValue=function(){
|
||||
// return self.getValue() // css颜色
|
||||
var f = pb.getFieldValue(targetf);
|
||||
if (/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/.test(f)) {
|
||||
return f;
|
||||
}
|
||||
return "";
|
||||
// 也可以用 pb.getFieldValue(targetf) 获得颜色块左边的域的内容
|
||||
}
|
||||
|
||||
var setValue=function(newValue){ // css颜色
|
||||
self.setValue(newValue)
|
||||
var c=new Colors();
|
||||
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 () {
|
||||
document.getElementById("colorPicker").value = getValue();
|
||||
window.jsColorPicker.confirm = setValue;
|
||||
// 设置位置
|
||||
triggerColorPicker(Blockly.WidgetDiv.DIV.style.left, Blockly.WidgetDiv.DIV.style.top);
|
||||
});
|
||||
|
||||
return document.createElement('table');
|
||||
};
|
||||
|
||||
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
|
||||
Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_());
|
||||
var div = Blockly.WidgetDiv.DIV;
|
||||
// Create the input.
|
||||
var htmlInput =
|
||||
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 {
|
||||
// --- awesomplete
|
||||
var awesomplete = new Awesomplete(htmlInput, {
|
||||
minChars: 4,
|
||||
maxItems: 12,
|
||||
replace: function (text) {
|
||||
var value = this.input.value, index = this.input.selectionEnd;
|
||||
if (index == null) index = value.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);
|
||||
},
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
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 = "";
|
||||
for (var i = index - 1; i>=0; i--) {
|
||||
var c = value.charAt(i);
|
||||
if (!/^\w$/.test(c)) {
|
||||
awesomplete.prefix = value.substring(i+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var list = editor_blockly.getAutoCompletions(value);
|
||||
awesomplete.list = list;
|
||||
var coordinates = getCaretCoordinates(htmlInput, htmlInput.selectionStart, {debug: true});
|
||||
// console.log(coordinates);
|
||||
awesomplete.ul.style.marginLeft = coordinates.left -
|
||||
htmlInput.scrollLeft - 20 + "px";
|
||||
awesomplete.evaluate();
|
||||
}
|
||||
|
||||
awesomplete.container.style.width = "100%";
|
||||
|
||||
window.awesomplete = awesomplete;
|
||||
}
|
||||
|
||||
if (!quietInput) {
|
||||
htmlInput.focus();
|
||||
htmlInput.select();
|
||||
}
|
||||
this.validate_();
|
||||
this.resizeEditor_();
|
||||
|
||||
this.bindEvents_(htmlInput);
|
||||
};
|
||||
60
_server/thirdparty/LICENSE.md
vendored
Normal file
60
_server/thirdparty/LICENSE.md
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/* jsColor */
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Peter Dematté
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
/* awesomplete */
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Lea Verou
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
/* caret-position */
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jonathan Ong me@jongleberry.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
103
_server/thirdparty/awesomplete.css
vendored
Normal file
103
_server/thirdparty/awesomplete.css
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
.awesomplete [hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.awesomplete .visually-hidden {
|
||||
position: absolute;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.awesomplete {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.awesomplete > input {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.awesomplete > ul {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
box-sizing: border-box;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.awesomplete > ul:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.awesomplete > ul {
|
||||
border-radius: .3em;
|
||||
margin: .8em 0 0;
|
||||
background: hsla(0,0%,100%,.9);
|
||||
background: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8));
|
||||
border: 1px solid rgba(0,0,0,.3);
|
||||
box-shadow: .05em .2em .6em rgba(0,0,0,.2);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
@supports (transform: scale(0)) {
|
||||
.awesomplete > ul {
|
||||
transition: .3s cubic-bezier(.4,.2,.5,1.4);
|
||||
transform-origin: 1.43em -.43em;
|
||||
}
|
||||
|
||||
.awesomplete > ul[hidden],
|
||||
.awesomplete > ul:empty {
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
display: block;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pointer */
|
||||
.awesomplete > ul:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -.43em;
|
||||
left: 1em;
|
||||
width: 0; height: 0;
|
||||
padding: .4em;
|
||||
background: white;
|
||||
border: inherit;
|
||||
border-right: 0;
|
||||
border-bottom: 0;
|
||||
-webkit-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.awesomplete > ul > li {
|
||||
position: relative;
|
||||
padding: .2em .5em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.awesomplete > ul > li:hover {
|
||||
background: hsl(200, 40%, 80%);
|
||||
color: black;
|
||||
}
|
||||
|
||||
.awesomplete > ul > li[aria-selected="true"] {
|
||||
background: hsl(205, 40%, 40%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.awesomplete mark {
|
||||
background: hsl(65, 100%, 50%);
|
||||
}
|
||||
|
||||
.awesomplete li:hover mark {
|
||||
background: hsl(68, 100%, 41%);
|
||||
}
|
||||
|
||||
.awesomplete li[aria-selected="true"] mark {
|
||||
background: hsl(86, 100%, 21%);
|
||||
color: inherit;
|
||||
}
|
||||
/*# sourceMappingURL=awesomplete.css.map */
|
||||
3
_server/thirdparty/awesomplete.min.js
vendored
Normal file
3
_server/thirdparty/awesomplete.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
155
_server/thirdparty/caret-position.js
vendored
Normal file
155
_server/thirdparty/caret-position.js
vendored
Normal file
@ -0,0 +1,155 @@
|
||||
/* jshint browser: true */
|
||||
|
||||
(function () {
|
||||
|
||||
// We'll copy the properties below into the mirror div.
|
||||
// Note that some browsers, such as Firefox, do not concatenate properties
|
||||
// into their shorthand (e.g. padding-top, padding-bottom etc. -> padding),
|
||||
// so we have to list every single property explicitly.
|
||||
var properties = [
|
||||
'direction', // RTL support
|
||||
'boxSizing',
|
||||
'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does
|
||||
'height',
|
||||
'overflowX',
|
||||
'overflowY', // copy the scrollbar for IE
|
||||
|
||||
'borderTopWidth',
|
||||
'borderRightWidth',
|
||||
'borderBottomWidth',
|
||||
'borderLeftWidth',
|
||||
'borderStyle',
|
||||
|
||||
'paddingTop',
|
||||
'paddingRight',
|
||||
'paddingBottom',
|
||||
'paddingLeft',
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/font
|
||||
'fontStyle',
|
||||
'fontVariant',
|
||||
'fontWeight',
|
||||
'fontStretch',
|
||||
'fontSize',
|
||||
'fontSizeAdjust',
|
||||
'lineHeight',
|
||||
'fontFamily',
|
||||
|
||||
'textAlign',
|
||||
'textTransform',
|
||||
'textIndent',
|
||||
'textDecoration', // might not make a difference, but better be safe
|
||||
|
||||
'letterSpacing',
|
||||
'wordSpacing',
|
||||
|
||||
'tabSize',
|
||||
'MozTabSize'
|
||||
|
||||
];
|
||||
|
||||
var isBrowser = (typeof window !== 'undefined');
|
||||
var isFirefox = (isBrowser && window.mozInnerScreenX != null);
|
||||
|
||||
function getCaretCoordinates(element, position, options) {
|
||||
if (!isBrowser) {
|
||||
throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');
|
||||
}
|
||||
|
||||
var debug = options && options.debug || false;
|
||||
if (debug) {
|
||||
var el = document.querySelector('#input-textarea-caret-position-mirror-div');
|
||||
if (el) el.parentNode.removeChild(el);
|
||||
}
|
||||
|
||||
// The mirror div will replicate the textarea's style
|
||||
var div = document.createElement('div');
|
||||
div.id = 'input-textarea-caret-position-mirror-div';
|
||||
document.body.appendChild(div);
|
||||
|
||||
var style = div.style;
|
||||
var computed = window.getComputedStyle ? window.getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9
|
||||
var isInput = element.nodeName === 'INPUT';
|
||||
|
||||
// Default textarea styles
|
||||
style.whiteSpace = 'nowrap';
|
||||
if (!isInput)
|
||||
style.wordWrap = 'break-word'; // only for textarea-s
|
||||
|
||||
// Position off-screen
|
||||
style.position = 'absolute'; // required to return coordinates properly
|
||||
if (!debug)
|
||||
style.visibility = 'hidden'; // not 'display: none' because we want rendering
|
||||
|
||||
// Transfer the element's properties to the div
|
||||
properties.forEach(function (prop) {
|
||||
if (isInput && prop === 'lineHeight') {
|
||||
// Special case for <input>s because text is rendered centered and line height may be != height
|
||||
if (computed.boxSizing === "border-box") {
|
||||
var height = parseInt(computed.height);
|
||||
var outerHeight =
|
||||
parseInt(computed.paddingTop) +
|
||||
parseInt(computed.paddingBottom) +
|
||||
parseInt(computed.borderTopWidth) +
|
||||
parseInt(computed.borderBottomWidth);
|
||||
var targetHeight = outerHeight + parseInt(computed.lineHeight);
|
||||
if (height > targetHeight) {
|
||||
style.lineHeight = height - outerHeight + "px";
|
||||
} else if (height === targetHeight) {
|
||||
style.lineHeight = computed.lineHeight;
|
||||
} else {
|
||||
style.lineHeight = 0;
|
||||
}
|
||||
} else {
|
||||
style.lineHeight = computed.height;
|
||||
}
|
||||
} else {
|
||||
style[prop] = computed[prop];
|
||||
}
|
||||
});
|
||||
|
||||
if (isFirefox) {
|
||||
// Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275
|
||||
if (element.scrollHeight > parseInt(computed.height))
|
||||
style.overflowY = 'scroll';
|
||||
} else {
|
||||
style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'
|
||||
}
|
||||
|
||||
div.textContent = element.value.substring(0, position);
|
||||
// The second special handling for input type="text" vs textarea:
|
||||
// spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037
|
||||
if (isInput)
|
||||
div.textContent = div.textContent.replace(/\s/g, '\u00a0');
|
||||
|
||||
var span = document.createElement('span');
|
||||
// Wrapping must be replicated *exactly*, including when a long word gets
|
||||
// onto the next line, with whitespace at the end of the line before (#7).
|
||||
// The *only* reliable way to do that is to copy the *entire* rest of the
|
||||
// textarea's content into the <span> created at the caret position.
|
||||
// For inputs, just '.' would be enough, but no need to bother.
|
||||
span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all
|
||||
div.appendChild(span);
|
||||
|
||||
var coordinates = {
|
||||
top: span.offsetTop + parseInt(computed['borderTopWidth']),
|
||||
left: span.offsetLeft + parseInt(computed['borderLeftWidth']),
|
||||
height: parseInt(computed['lineHeight'])
|
||||
};
|
||||
|
||||
if (debug) {
|
||||
span.style.backgroundColor = '#aaa';
|
||||
} else {
|
||||
document.body.removeChild(div);
|
||||
}
|
||||
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
if (typeof module != 'undefined' && typeof module.exports != 'undefined') {
|
||||
module.exports = getCaretCoordinates;
|
||||
} else if(isBrowser) {
|
||||
window.getCaretCoordinates = getCaretCoordinates;
|
||||
}
|
||||
|
||||
}());
|
||||
@ -1,3 +1,5 @@
|
||||
// ------ ColorPicker ------ //
|
||||
|
||||
(function (window) {
|
||||
window.jsColorPicker = function(selectors, config) {
|
||||
var renderCallback = function(colors, mode) {
|
||||
@ -254,7 +256,7 @@
|
||||
})(this);
|
||||
|
||||
// Added
|
||||
var colors = jsColorPicker('input.color', {
|
||||
jsColorPicker('input.color', {
|
||||
customBG: '#222',
|
||||
readOnly: false,
|
||||
// patch: false,
|
||||
@ -303,89 +305,5 @@ function triggerColorPicker(left, top) {
|
||||
}
|
||||
}
|
||||
|
||||
Blockly.FieldColour.prototype.createWidget_ = function() {
|
||||
Blockly.WidgetDiv.hide();
|
||||
// ------ AutoCompletion ------
|
||||
|
||||
// console.log('here')
|
||||
var self=this;
|
||||
var pb=self.sourceBlock_
|
||||
var args = MotaActionBlocks[pb.type].args
|
||||
var targetf=args[args.indexOf(self.name)-1]
|
||||
|
||||
var getValue=function(){
|
||||
// return self.getValue() // css颜色
|
||||
var f = pb.getFieldValue(targetf);
|
||||
if (/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/.test(f)) {
|
||||
return f;
|
||||
}
|
||||
return "";
|
||||
// 也可以用 pb.getFieldValue(targetf) 获得颜色块左边的域的内容
|
||||
}
|
||||
|
||||
var setValue=function(newValue){ // css颜色
|
||||
self.setValue(newValue)
|
||||
var c=new Colors();
|
||||
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 () {
|
||||
document.getElementById("colorPicker").value = getValue();
|
||||
window.jsColorPicker.confirm = setValue;
|
||||
// 设置位置
|
||||
triggerColorPicker(Blockly.WidgetDiv.DIV.style.left, Blockly.WidgetDiv.DIV.style.top);
|
||||
});
|
||||
|
||||
return document.createElement('table');
|
||||
};
|
||||
|
||||
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
|
||||
Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_());
|
||||
var div = Blockly.WidgetDiv.DIV;
|
||||
// Create the input.
|
||||
var htmlInput =
|
||||
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;
|
||||
this.validate_();
|
||||
this.resizeEditor_();
|
||||
if (!quietInput) {
|
||||
htmlInput.focus();
|
||||
htmlInput.select();
|
||||
}
|
||||
|
||||
// console.log('here')
|
||||
var self=this;
|
||||
var pb=self.sourceBlock_
|
||||
var args = MotaActionBlocks[pb.type].args
|
||||
var targetf=args[args.indexOf(self.name)+1]
|
||||
|
||||
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+')')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.bindEvents_(htmlInput);
|
||||
};
|
||||
1
_server/vendor/polyfill.min.js
vendored
1
_server/vendor/polyfill.min.js
vendored
@ -1 +0,0 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(){}function n(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,f._immediateFn(function(){var i=1===e._state?n.onFulfilled:n.onRejected;if(null!==i){var r;try{r=i(e._value)}catch(e){return void o(n.promise,e)}t(n.promise,r)}else(1===e._state?t:o)(n.promise,e._value)})):e._deferreds.push(n)}function t(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof f)return e._state=3,e._value=n,void i(e);if("function"==typeof t)return void r(function(e,n){return function(){e.apply(n,arguments)}}(t,n),e)}e._state=1,e._value=n,i(e)}catch(n){o(e,n)}}function o(e,n){e._state=2,e._value=n,i(e)}function i(e){2===e._state&&0===e._deferreds.length&&f._immediateFn(function(){e._handled||f._unhandledRejectionFn(e._value)});for(var t=0,o=e._deferreds.length;o>t;t++)n(e,e._deferreds[t]);e._deferreds=null}function r(e,n){var i=!1;try{e(function(e){i||(i=!0,t(n,e))},function(e){i||(i=!0,o(n,e))})}catch(e){if(i)return;i=!0,o(n,e)}}function f(e){if(!(this instanceof f))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],r(e,this)}var u=setTimeout,c=f.prototype;c.catch=function(e){return this.then(null,e)},c.then=function(t,o){var i=new this.constructor(e);return n(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(t,o,i)),i},f.all=function(e){return new f(function(n,t){function o(e,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(n){o(e,n)},t)}i[e]=f,0==--r&&n(i)}catch(e){t(e)}}if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var i=Array.prototype.slice.call(e);if(0===i.length)return n([]);for(var r=i.length,f=0;i.length>f;f++)o(f,i[f])})},f.resolve=function(e){return e&&"object"==typeof e&&e.constructor===f?e:new f(function(n){n(e)})},f.reject=function(e){return new f(function(n,t){t(e)})},f.race=function(e){return new f(function(n,t){for(var o=0,i=e.length;i>o;o++)e[o].then(n,t)})},f._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){u(e,0)},f._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==a)return a;throw Error("unable to locate global object")}();a.Promise||(a.Promise=f)});
|
||||
6
_server/vendor/vue.min.js
vendored
6
_server/vendor/vue.min.js
vendored
File diff suppressed because one or more lines are too long
@ -5,6 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1,initial-scale=1,user-scalable=no" />
|
||||
<link href="_server/css/editor_mobile.css" rel="stylesheet">
|
||||
<link href="_server/CodeMirror/codemirror.css" rel="stylesheet">
|
||||
<link href="_server/thirdparty/awesomplete.css" rel="stylesheet">
|
||||
<link href="_server/css/editor_mode_mobile.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
@ -598,9 +599,11 @@
|
||||
<script src="_server/CodeMirror/jshint.min.js"></script>
|
||||
<script src="_server/CodeMirror/beautify.min.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
|
||||
<!-- colorPicker -->
|
||||
<script type="text/javascript" src="_server/colorPicker/color.all.min.js"></script>
|
||||
<script type="text/javascript" src="_server/colorPicker/jsColor.js"></script>
|
||||
<!-- thirdparty -->
|
||||
<script src="_server/thirdparty/color.all.min.js"></script>
|
||||
<script src="_server/thirdparty/awesomplete.min.js"></script>
|
||||
<script src="_server/thirdparty/caret-position.js"></script>
|
||||
<script src="_server/thirdparty/jsColor.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<link href="_server/css/editor.css" rel="stylesheet">
|
||||
<link href="_server/CodeMirror/codemirror.css" rel="stylesheet">
|
||||
<link href="_server/thirdparty/awesomplete.css" rel="stylesheet">
|
||||
<link href="_server/css/editor_mode.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
@ -582,9 +583,11 @@
|
||||
<script src="_server/CodeMirror/jshint.min.js"></script>
|
||||
<script src="_server/CodeMirror/beautify.min.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
|
||||
<!-- colorPicker -->
|
||||
<script type="text/javascript" src="_server/colorPicker/color.all.min.js"></script>
|
||||
<script type="text/javascript" src="_server/colorPicker/jsColor.js"></script>
|
||||
<!-- thirdparty -->
|
||||
<script src="_server/thirdparty/color.all.min.js"></script>
|
||||
<script src="_server/thirdparty/awesomplete.min.js"></script>
|
||||
<script src="_server/thirdparty/caret-position.js"></script>
|
||||
<script src="_server/thirdparty/jsColor.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user