Skip to content
Permalink
Browse files

Updates

* Simple Devices: new device type (HTML)
* Simple Devices: optimizing
* Blockly: html-editor fix
* 3rdparty: CodeMirror update
  • Loading branch information...
sergejey committed Apr 25, 2019
1 parent d24b2bb commit 52f1bfef634cc56df0984fb838ef198373615603
Showing with 11,349 additions and 8,578 deletions.
  1. +29 −16 3rdparty/codemirror/addon/comment/comment.js
  2. +15 −22 3rdparty/codemirror/addon/comment/continuecomment.js
  3. +5 −1 3rdparty/codemirror/addon/dialog/dialog.js
  4. +1 −1 3rdparty/codemirror/addon/display/autorefresh.js
  5. +1 −1 3rdparty/codemirror/addon/display/fullscreen.js
  6. +19 −4 3rdparty/codemirror/addon/display/panel.js
  7. +4 −1 3rdparty/codemirror/addon/display/placeholder.js
  8. +14 −26 3rdparty/codemirror/addon/display/rulers.js
  9. +29 −33 3rdparty/codemirror/addon/edit/closebrackets.js
  10. +20 −6 3rdparty/codemirror/addon/edit/closetag.js
  11. +57 −9 3rdparty/codemirror/addon/edit/continuelist.js
  12. +44 −14 3rdparty/codemirror/addon/edit/matchbrackets.js
  13. +1 −1 3rdparty/codemirror/addon/edit/matchtags.js
  14. +1 −1 3rdparty/codemirror/addon/edit/trailingspace.js
  15. +10 −10 3rdparty/codemirror/addon/fold/brace-fold.js
  16. +2 −2 3rdparty/codemirror/addon/fold/comment-fold.js
  17. +6 −3 3rdparty/codemirror/addon/fold/foldcode.js
  18. +2 −2 3rdparty/codemirror/addon/fold/foldgutter.js
  19. +20 −16 3rdparty/codemirror/addon/fold/indent-fold.js
  20. +1 −1 3rdparty/codemirror/addon/fold/markdown-fold.js
  21. +12 −10 3rdparty/codemirror/addon/fold/xml-fold.js
  22. +1 −1 3rdparty/codemirror/addon/hint/anyword-hint.js
  23. +1 −1 3rdparty/codemirror/addon/hint/css-hint.js
  24. +3 −1 3rdparty/codemirror/addon/hint/html-hint.js
  25. +16 −5 3rdparty/codemirror/addon/hint/javascript-hint.js
  26. +0 −2 3rdparty/codemirror/addon/hint/show-hint.css
  27. +66 −58 3rdparty/codemirror/addon/hint/show-hint.js
  28. +117 −67 3rdparty/codemirror/addon/hint/sql-hint.js
  29. +16 −6 3rdparty/codemirror/addon/hint/xml-hint.js
  30. +7 −1 3rdparty/codemirror/addon/lint/coffeescript-lint.js
  31. +9 −4 3rdparty/codemirror/addon/lint/css-lint.js
  32. +17 −4 3rdparty/codemirror/addon/lint/html-lint.js
  33. +22 −95 3rdparty/codemirror/addon/lint/javascript-lint.js
  34. +10 −1 3rdparty/codemirror/addon/lint/json-lint.js
  35. +2 −2 3rdparty/codemirror/addon/lint/lint.css
  36. +30 −9 3rdparty/codemirror/addon/lint/lint.js
  37. +17 −4 3rdparty/codemirror/addon/lint/yaml-lint.js
  38. +6 −0 3rdparty/codemirror/addon/merge/merge.css
  39. +314 −85 3rdparty/codemirror/addon/merge/merge.js
  40. +1 −1 3rdparty/codemirror/addon/mode/loadmode.js
  41. +13 −5 3rdparty/codemirror/addon/mode/multiplex.js
  42. +1 −1 3rdparty/codemirror/addon/mode/multiplex_test.js
  43. +10 −5 3rdparty/codemirror/addon/mode/overlay.js
  44. +9 −6 3rdparty/codemirror/addon/mode/simple.js
  45. +1 −1 3rdparty/codemirror/addon/runmode/colorize.js
  46. +3 −2 3rdparty/codemirror/addon/runmode/runmode-standalone.js
  47. +1 −1 3rdparty/codemirror/addon/runmode/runmode.js
  48. +23 −5 3rdparty/codemirror/addon/runmode/runmode.node.js
  49. +6 −2 3rdparty/codemirror/addon/scroll/annotatescrollbar.js
  50. +3 −1 3rdparty/codemirror/addon/scroll/scrollpastend.js
  51. +17 −12 3rdparty/codemirror/addon/scroll/simplescrollbars.js
  52. +5 −4 3rdparty/codemirror/addon/search/jump-to-line.js
  53. +48 −32 3rdparty/codemirror/addon/search/match-highlighter.js
  54. +2 −2 3rdparty/codemirror/addon/search/matchesonscrollbar.js
  55. +51 −21 3rdparty/codemirror/addon/search/search.js
  56. +257 −153 3rdparty/codemirror/addon/search/searchcursor.js
  57. +12 −14 3rdparty/codemirror/addon/selection/active-line.js
  58. +5 −4 3rdparty/codemirror/addon/selection/mark-selection.js
  59. +1 −1 3rdparty/codemirror/addon/selection/selection-pointer.js
  60. +32 −15 3rdparty/codemirror/addon/tern/tern.js
  61. +1 −1 3rdparty/codemirror/addon/tern/worker.js
  62. +5 −2 3rdparty/codemirror/addon/wrap/hardwrap.js
  63. +31 −20 3rdparty/codemirror/lib/codemirror.css
  64. +8,119 −7,256 3rdparty/codemirror/lib/codemirror.js
  65. +195 −92 3rdparty/codemirror/mode/clike/clike.js
  66. +27 −7 3rdparty/codemirror/mode/clike/index.html
  67. +1 −1 3rdparty/codemirror/mode/clike/scala.html
  68. +95 −7 3rdparty/codemirror/mode/clike/test.js
  69. +47 −41 3rdparty/codemirror/mode/css/css.js
  70. +3 −2 3rdparty/codemirror/mode/css/gss.html
  71. +1 −1 3rdparty/codemirror/mode/css/gss_test.js
  72. +2 −2 3rdparty/codemirror/mode/css/index.html
  73. +3 −3 3rdparty/codemirror/mode/css/less.html
  74. +5 −5 3rdparty/codemirror/mode/css/less_test.js
  75. +2 −1 3rdparty/codemirror/mode/css/scss.html
  76. +6 −6 3rdparty/codemirror/mode/css/scss_test.js
  77. +38 −21 3rdparty/codemirror/mode/css/test.js
  78. +8 −8 3rdparty/codemirror/mode/htmlmixed/htmlmixed.js
  79. +22 −11 3rdparty/codemirror/mode/htmlmixed/index.html
  80. +165 −0 3rdparty/codemirror/mode/index.html
  81. +2 −2 3rdparty/codemirror/mode/javascript/index.html
  82. +344 −166 3rdparty/codemirror/mode/javascript/javascript.js
  83. +2 −2 3rdparty/codemirror/mode/javascript/json-ld.html
  84. +292 −8 3rdparty/codemirror/mode/javascript/test.js
  85. +11 −10 3rdparty/codemirror/mode/javascript/typescript.html
  86. +217 −0 3rdparty/codemirror/mode/meta.js
  87. +2 −2 3rdparty/codemirror/mode/php/index.html
  88. +7 −7 3rdparty/codemirror/mode/php/php.js
  89. +1 −1 3rdparty/codemirror/mode/php/test.js
  90. +10 −6 3rdparty/codemirror/mode/sql/index.html
  91. +147 −58 3rdparty/codemirror/mode/sql/sql.js
  92. +2 −2 3rdparty/codemirror/mode/xml/index.html
  93. +1 −1 3rdparty/codemirror/mode/xml/test.js
  94. +10 −2 3rdparty/codemirror/mode/xml/xml.js
  95. +1 −1 modules/blockly_code/blockly_code.class.php
  96. +11 −0 modules/devices/addons/html_structure.php
  97. +22 −0 modules/devices/devices.class.php
  98. +11 −2 modules/devices/devices_edit.inc.php
  99. +3 −2 templates/blockly_code/blockly_code.html
  100. +12 −3 templates/devices/action_usual.html
  101. +11 −2 templates/devices/devices_edit.html
  102. +6 −0 templates/devices/devices_edit_settings.html
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -44,9 +44,22 @@
}
});

// Rough heuristic to try and detect lines that are part of multi-line string
function probablyInsideString(cm, pos, line) {
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"\`]/.test(line)
}

function getMode(cm, pos) {
var mode = cm.getMode()
return mode.useInnerComments === false || !mode.innerMode ? mode : cm.getModeAt(pos)
}

CodeMirror.defineExtension("lineComment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = self.getModeAt(from);
var self = this, mode = getMode(self, from);
var firstLine = self.getLine(from.line);
if (firstLine == null || probablyInsideString(self, from, firstLine)) return;

var commentString = options.lineComment || mode.lineComment;
if (!commentString) {
if (options.blockCommentStart || mode.blockCommentStart) {
@@ -55,8 +68,7 @@
}
return;
}
var firstLine = self.getLine(from.line);
if (firstLine == null) return;

var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
var pad = options.padding == null ? " " : options.padding;
var blankLines = options.commentBlankLines || from.line == to.line;
@@ -88,14 +100,15 @@

CodeMirror.defineExtension("blockComment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = self.getModeAt(from);
var self = this, mode = getMode(self, from);
var startString = options.blockCommentStart || mode.blockCommentStart;
var endString = options.blockCommentEnd || mode.blockCommentEnd;
if (!startString || !endString) {
if ((options.lineComment || mode.lineComment) && options.fullLines != false)
self.lineComment(from, to, options);
return;
}
if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return

var end = Math.min(to.line, self.lastLine());
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
@@ -121,7 +134,7 @@

CodeMirror.defineExtension("uncomment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = self.getModeAt(from);
var self = this, mode = getMode(self, from);
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);

// Try finding line comments
@@ -133,7 +146,7 @@
var line = self.getLine(i);
var found = line.indexOf(lineString);
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
if (found == -1 && nonWS.test(line)) break lineComment;
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
lines.push(line);
}
@@ -155,15 +168,15 @@
var endString = options.blockCommentEnd || mode.blockCommentEnd;
if (!startString || !endString) return false;
var lead = options.blockCommentLead || mode.blockCommentLead;
var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
if (close == -1 && start != end) {
endLine = self.getLine(--end);
close = endLine.lastIndexOf(endString);
}
if (open == -1 || close == -1 ||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
var startLine = self.getLine(start), open = startLine.indexOf(startString)
if (open == -1) return false
var endLine = end == start ? startLine : self.getLine(end)
var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1)
if (close == -1 ||
!/comment/.test(self.getTokenTypeAt(insideStart)) ||
!/comment/.test(self.getTokenTypeAt(insideEnd)) ||
self.getRange(insideStart, insideEnd, "\n").indexOf(endString) > -1)
return false;

// Avoid killing block comments completely outside the selection.
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -9,39 +9,32 @@
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
var modes = ["clike", "css", "javascript"];

for (var i = 0; i < modes.length; ++i)
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});

function continueComment(cm) {
if (cm.getOption("disableInput")) return CodeMirror.Pass;
var ranges = cm.listSelections(), mode, inserts = [];
for (var i = 0; i < ranges.length; i++) {
var pos = ranges[i].head, token = cm.getTokenAt(pos);
if (token.type != "comment") return CodeMirror.Pass;
var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode;
var pos = ranges[i].head
if (!/\bcomment\b/.test(cm.getTokenTypeAt(pos))) return CodeMirror.Pass;
var modeHere = cm.getModeAt(pos)
if (!mode) mode = modeHere;
else if (mode != modeHere) return CodeMirror.Pass;

var insert = null;
if (mode.blockCommentStart && mode.blockCommentContinue) {
var end = token.string.indexOf(mode.blockCommentEnd);
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) {
var line = cm.getLine(pos.line).slice(0, pos.ch)
var end = line.lastIndexOf(mode.blockCommentEnd), found
if (end != -1 && end == pos.ch - mode.blockCommentEnd.length) {
// Comment ended, don't continue it
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
insert = full.slice(0, token.start);
if (!/^\s*$/.test(insert)) {
insert = "";
for (var j = 0; j < token.start; ++j) insert += " ";
} else if ((found = line.lastIndexOf(mode.blockCommentStart)) > -1 && found > end) {
insert = line.slice(0, found)
if (/\S/.test(insert)) {
insert = ""
for (var j = 0; j < found; ++j) insert += " "
}
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
found + mode.blockCommentContinue.length > token.start &&
/^\s*$/.test(full.slice(0, found))) {
insert = full.slice(0, found);
} else if ((found = line.indexOf(mode.blockCommentContinue)) > -1 && !/\S/.test(line.slice(0, found))) {
insert = line.slice(0, found)
}
if (insert != null) insert += mode.blockCommentContinue;
if (insert != null) insert += mode.blockCommentContinue
}
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

// Open simple dialogs on top of an editor. Relies on dialog.css.

@@ -25,6 +25,7 @@
} else { // Assuming it's a detached DOM element.
dialog.appendChild(template);
}
CodeMirror.addClass(wrap, 'dialog-opened');
return dialog;
}

@@ -47,6 +48,7 @@
} else {
if (closed) return;
closed = true;
CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
dialog.parentNode.removeChild(dialog);
me.focus();

@@ -102,6 +104,7 @@
function close() {
if (closed) return;
closed = true;
CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
dialog.parentNode.removeChild(dialog);
me.focus();
}
@@ -141,6 +144,7 @@
if (closed) return;
closed = true;
clearTimeout(doneTimer);
CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
dialog.parentNode.removeChild(dialog);
}

@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -17,13 +17,15 @@
var info = this.state.panels;
var wrapper = info.wrapper;
var cmWrapper = this.getWrapperElement();
var replace = options.replace instanceof Panel && !options.replace.cleared;

if (options.after instanceof Panel && !options.after.cleared) {
wrapper.insertBefore(node, options.before.node.nextSibling);
} else if (options.before instanceof Panel && !options.before.cleared) {
wrapper.insertBefore(node, options.before.node);
} else if (options.replace instanceof Panel && !options.replace.cleared) {
} else if (replace) {
wrapper.insertBefore(node, options.replace.node);
info.panels++;
options.replace.clear();
} else if (options.position == "bottom") {
wrapper.appendChild(node);
@@ -37,7 +39,12 @@

var height = (options && options.height) || node.offsetHeight;
this._setSize(null, info.heightLeft -= height);
info.panels++;
if (!replace) {
info.panels++;
}
if (options.stable && isAtTop(this, node))
this.scrollTo(null, this.getScrollInfo().top + height)

return new Panel(this, node, options, height);
});

@@ -54,14 +61,16 @@
this.cleared = true;
var info = this.cm.state.panels;
this.cm._setSize(null, info.heightLeft += this.height);
if (this.options.stable && isAtTop(this.cm, this.node))
this.cm.scrollTo(null, this.cm.getScrollInfo().top - this.height)
info.wrapper.removeChild(this.node);
if (--info.panels == 0) removePanels(this.cm);
};

Panel.prototype.changed = function(height) {
var newHeight = height == null ? this.node.offsetHeight : height;
var info = this.cm.state.panels;
this.cm._setSize(null, info.height += (newHeight - this.height));
this.cm._setSize(null, info.heightLeft -= (newHeight - this.height));
this.height = newHeight;
};

@@ -109,4 +118,10 @@
cm.setSize = cm._setSize;
cm.setSize();
}

function isAtTop(cm, dom) {
for (var sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling)
if (sibling == cm.getWrapperElement()) return true
return false
}
});
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -14,10 +14,12 @@
if (val && !prev) {
cm.on("blur", onBlur);
cm.on("change", onChange);
cm.on("swapDoc", onChange);
onChange(cm);
} else if (!val && prev) {
cm.off("blur", onBlur);
cm.off("change", onChange);
cm.off("swapDoc", onChange);
clearPlaceholder(cm);
var wrapper = cm.getWrapperElement();
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
@@ -36,6 +38,7 @@
clearPlaceholder(cm);
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.style.direction = cm.getOption("direction");
elt.className = "CodeMirror-placeholder";
var placeHolder = cm.getOption("placeholder")
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -11,30 +11,26 @@
})(function(CodeMirror) {
"use strict";

CodeMirror.defineOption("rulers", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
clearRulers(cm);
cm.off("refresh", refreshRulers);
CodeMirror.defineOption("rulers", false, function(cm, val) {
if (cm.state.rulerDiv) {
cm.state.rulerDiv.parentElement.removeChild(cm.state.rulerDiv)
cm.state.rulerDiv = null
cm.off("refresh", drawRulers)
}
if (val && val.length) {
setRulers(cm);
cm.on("refresh", refreshRulers);
cm.state.rulerDiv = cm.display.lineSpace.parentElement.insertBefore(document.createElement("div"), cm.display.lineSpace)
cm.state.rulerDiv.className = "CodeMirror-rulers"
drawRulers(cm)
cm.on("refresh", drawRulers)
}
});

function clearRulers(cm) {
for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) {
var node = cm.display.lineSpace.childNodes[i];
if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
node.parentNode.removeChild(node);
}
}

function setRulers(cm) {
function drawRulers(cm) {
cm.state.rulerDiv.textContent = ""
var val = cm.getOption("rulers");
var cw = cm.defaultCharWidth();
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
var minH = cm.display.scroller.offsetHeight + 30;
cm.state.rulerDiv.style.minHeight = (cm.display.scroller.offsetHeight + 30) + "px";
for (var i = 0; i < val.length; i++) {
var elt = document.createElement("div");
elt.className = "CodeMirror-ruler";
@@ -49,15 +45,7 @@
if (conf.width) elt.style.borderLeftWidth = conf.width;
}
elt.style.left = (left + col * cw) + "px";
elt.style.top = "-50px";
elt.style.bottom = "-20px";
elt.style.minHeight = minH + "px";
cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
cm.state.rulerDiv.appendChild(elt)
}
}

function refreshRulers(cm) {
clearRulers(cm);
setRulers(cm);
}
});
Oops, something went wrong.

0 comments on commit 52f1bfe

Please sign in to comment.
You can’t perform that action at this time.