diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-beautify.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-beautify.js new file mode 100644 index 0000000..c5e04dc --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-beautify.js @@ -0,0 +1,331 @@ +define("ace/ext/beautify",["require","exports","module","ace/token_iterator"], function(require, exports, module){// [WIP] +"use strict"; +var TokenIterator = require("../token_iterator").TokenIterator; +function is(token, type) { + return token.type.lastIndexOf(type + ".xml") > -1; +} +exports.singletonTags = ["area", "base", "br", "col", "command", "embed", "hr", "html", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]; +exports.blockTags = ["article", "aside", "blockquote", "body", "div", "dl", "fieldset", "footer", "form", "head", "header", "html", "nav", "ol", "p", "script", "section", "style", "table", "tbody", "tfoot", "thead", "ul"]; +exports.formatOptions = { + lineBreaksAfterCommasInCurlyBlock: true +}; +exports.beautify = function (session) { + var iterator = new TokenIterator(session, 0, 0); + var token = iterator.getCurrentToken(); + var tabString = session.getTabString(); + var singletonTags = exports.singletonTags; + var blockTags = exports.blockTags; + var formatOptions = exports.formatOptions || {}; + var nextToken; + var breakBefore = false; + var spaceBefore = false; + var spaceAfter = false; + var code = ""; + var value = ""; + var tagName = ""; + var depth = 0; + var lastDepth = 0; + var lastIndent = 0; + var indent = 0; + var unindent = 0; + var roundDepth = 0; + var curlyDepth = 0; + var row; + var curRow = 0; + var rowsToAdd = 0; + var rowTokens = []; + var abort = false; + var i; + var indentNextLine = false; + var inTag = false; + var inCSS = false; + var inBlock = false; + var levels = { 0: 0 }; + var parents = []; + var caseBody = false; + var trimNext = function () { + if (nextToken && nextToken.value && nextToken.type !== 'string.regexp') + nextToken.value = nextToken.value.replace(/^\s*/, ""); + }; + var trimLine = function () { + var end = code.length - 1; + while (true) { + if (end == 0) + break; + if (code[end] !== " ") + break; + end = end - 1; + } + code = code.slice(0, end + 1); + }; + var trimCode = function () { + code = code.trimRight(); + breakBefore = false; + }; + while (token !== null) { + curRow = iterator.getCurrentTokenRow(); + rowTokens = iterator.$rowTokens; + nextToken = iterator.stepForward(); + if (typeof token !== "undefined") { + value = token.value; + unindent = 0; + inCSS = (tagName === "style" || session.$modeId === "ace/mode/css"); + if (is(token, "tag-open")) { + inTag = true; + if (nextToken) + inBlock = (blockTags.indexOf(nextToken.value) !== -1); + if (value === " 0; rowsToAdd--) + code += "\n"; + breakBefore = true; + if (!is(token, "comment") && !token.type.match(/^(comment|string)$/)) + value = value.trimLeft(); + } + if (value) { + if (token.type === "keyword" && value.match(/^(if|else|elseif|for|foreach|while|switch)$/)) { + parents[depth] = value; + trimNext(); + spaceAfter = true; + if (value.match(/^(else|elseif)$/)) { + if (code.match(/\}[\s]*$/)) { + trimCode(); + spaceBefore = true; + } + } + } + else if (token.type === "paren.lparen") { + trimNext(); + if (value.substr(-1) === "{") { + spaceAfter = true; + indentNextLine = false; + if (!inTag) + rowsToAdd = 1; + } + if (value.substr(0, 1) === "{") { + spaceBefore = true; + if (code.substr(-1) !== '[' && code.trimRight().substr(-1) === '[') { + trimCode(); + spaceBefore = false; + } + else if (code.trimRight().substr(-1) === ')') { + trimCode(); + } + else { + trimLine(); + } + } + } + else if (token.type === "paren.rparen") { + unindent = 1; + if (value.substr(0, 1) === "}") { + if (parents[depth - 1] === 'case') + unindent++; + if (code.trimRight().substr(-1) === '{') { + trimCode(); + } + else { + spaceBefore = true; + if (inCSS) + rowsToAdd += 2; + } + } + if (value.substr(0, 1) === "]") { + if (code.substr(-1) !== '}' && code.trimRight().substr(-1) === '}') { + spaceBefore = false; + indent++; + trimCode(); + } + } + if (value.substr(0, 1) === ")") { + if (code.substr(-1) !== '(' && code.trimRight().substr(-1) === '(') { + spaceBefore = false; + indent++; + trimCode(); + } + } + trimLine(); + } + else if ((token.type === "keyword.operator" || token.type === "keyword") && value.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)) { + trimCode(); + trimNext(); + spaceBefore = true; + spaceAfter = true; + } + else if (token.type === "punctuation.operator" && value === ';') { + trimCode(); + trimNext(); + spaceAfter = true; + if (inCSS) + rowsToAdd++; + } + else if (token.type === "punctuation.operator" && value.match(/^(:|,)$/)) { + trimCode(); + trimNext(); + if (value.match(/^(,)$/) && curlyDepth > 0 && roundDepth === 0 && formatOptions.lineBreaksAfterCommasInCurlyBlock) { + rowsToAdd++; + } + else { + spaceAfter = true; + breakBefore = false; + } + } + else if (token.type === "support.php_tag" && value === "?>" && !breakBefore) { + trimCode(); + spaceBefore = true; + } + else if (is(token, "attribute-name") && code.substr(-1).match(/^\s$/)) { + spaceBefore = true; + } + else if (is(token, "attribute-equals")) { + trimLine(); + trimNext(); + } + else if (is(token, "tag-close")) { + trimLine(); + if (value === "/>") + spaceBefore = true; + } + else if (token.type === "keyword" && value.match(/^(case|default)$/)) { + if (caseBody) + unindent = 1; + } + if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['"@]$/))) { + indent = lastIndent; + if (depth > lastDepth) { + indent++; + for (i = depth; i > lastDepth; i--) + levels[i] = indent; + } + else if (depth < lastDepth) + indent = levels[depth]; + lastDepth = depth; + lastIndent = indent; + if (unindent) + indent -= unindent; + if (indentNextLine && !roundDepth) { + indent++; + indentNextLine = false; + } + for (i = 0; i < indent; i++) + code += tabString; + } + if (token.type === "keyword" && value.match(/^(case|default)$/)) { + if (caseBody === false) { + parents[depth] = value; + depth++; + caseBody = true; + } + } + else if (token.type === "keyword" && value.match(/^(break)$/)) { + if (parents[depth - 1] && parents[depth - 1].match(/^(case|default)$/)) { + depth--; + caseBody = false; + } + } + if (token.type === "paren.lparen") { + roundDepth += (value.match(/\(/g) || []).length; + curlyDepth += (value.match(/\{/g) || []).length; + depth += value.length; + } + if (token.type === "keyword" && value.match(/^(if|else|elseif|for|while)$/)) { + indentNextLine = true; + roundDepth = 0; + } + else if (!roundDepth && value.trim() && token.type !== "comment") + indentNextLine = false; + if (token.type === "paren.rparen") { + roundDepth -= (value.match(/\)/g) || []).length; + curlyDepth -= (value.match(/\}/g) || []).length; + for (i = 0; i < value.length; i++) { + depth--; + if (value.substr(i, 1) === '}' && parents[depth] === 'case') { + depth--; + } + } + } + if (token.type == "text") + value = value.replace(/\s+$/, " "); + if (spaceBefore && !breakBefore) { + trimLine(); + if (code.substr(-1) !== "\n") + code += " "; + } + code += value; + if (spaceAfter) + code += " "; + breakBefore = false; + spaceBefore = false; + spaceAfter = false; + if ((is(token, "tag-close") && (inBlock || blockTags.indexOf(tagName) !== -1)) || (is(token, "doctype") && value === ">")) { + if (inBlock && nextToken && nextToken.value === "") { + depth--; + } + } + if (is(token, "tag-name")) { + tagName = value; + } + row = curRow; + } + } + token = nextToken; + } + code = code.trim(); + session.doc.setValue(code); +}; +exports.commands = [{ + name: "beautify", + description: "Format selection (Beautify)", + exec: function (editor) { + exports.beautify(editor.session); + }, + bindKey: "Ctrl-Shift-B" + }]; + +}); + (function() { + window.require(["ace/ext/beautify"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-code_lens.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-code_lens.js new file mode 100644 index 0000000..22f9955 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-code_lens.js @@ -0,0 +1,203 @@ +define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var LineWidgets = require("../line_widgets").LineWidgets; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); +function clearLensElements(renderer) { + var textLayer = renderer.$textLayer; + var lensElements = textLayer.$lenses; + if (lensElements) + lensElements.forEach(function (el) { el.remove(); }); + textLayer.$lenses = null; +} +function renderWidgets(changes, renderer) { + var changed = changes & renderer.CHANGE_LINES + || changes & renderer.CHANGE_FULL + || changes & renderer.CHANGE_SCROLL + || changes & renderer.CHANGE_TEXT; + if (!changed) + return; + var session = renderer.session; + var lineWidgets = renderer.session.lineWidgets; + var textLayer = renderer.$textLayer; + var lensElements = textLayer.$lenses; + if (!lineWidgets) { + if (lensElements) + clearLensElements(renderer); + return; + } + var textCells = renderer.$textLayer.$lines.cells; + var config = renderer.layerConfig; + var padding = renderer.$padding; + if (!lensElements) + lensElements = textLayer.$lenses = []; + var index = 0; + for (var i = 0; i < textCells.length; i++) { + var row = textCells[i].row; + var widget = lineWidgets[row]; + var lenses = widget && widget.lenses; + if (!lenses || !lenses.length) + continue; + var lensContainer = lensElements[index]; + if (!lensContainer) { + lensContainer = lensElements[index] + = dom.buildDom(["div", { class: "ace_codeLens" }], renderer.container); + } + lensContainer.style.height = config.lineHeight + "px"; + index++; + for (var j = 0; j < lenses.length; j++) { + var el = lensContainer.childNodes[2 * j]; + if (!el) { + if (j != 0) + lensContainer.appendChild(dom.createTextNode("\xa0|\xa0")); + el = dom.buildDom(["a"], lensContainer); + } + el.textContent = lenses[j].title; + el.lensCommand = lenses[j]; + } + while (lensContainer.childNodes.length > 2 * j - 1) + lensContainer.lastChild.remove(); + var top = renderer.$cursorLayer.getPixelPosition({ + row: row, + column: 0 + }, true).top - config.lineHeight * widget.rowsAbove - config.offset; + lensContainer.style.top = top + "px"; + var left = renderer.gutterWidth; + var indent = session.getLine(row).search(/\S|$/); + if (indent == -1) + indent = 0; + left += indent * config.characterWidth; + lensContainer.style.paddingLeft = padding + left + "px"; + } + while (index < lensElements.length) + lensElements.pop().remove(); +} +function clearCodeLensWidgets(session) { + if (!session.lineWidgets) + return; + var widgetManager = session.widgetManager; + session.lineWidgets.forEach(function (widget) { + if (widget && widget.lenses) + widgetManager.removeLineWidget(widget); + }); +} +exports.setLenses = function (session, lenses) { + var firstRow = Number.MAX_VALUE; + clearCodeLensWidgets(session); + lenses && lenses.forEach(function (lens) { + var row = lens.start.row; + var column = lens.start.column; + var widget = session.lineWidgets && session.lineWidgets[row]; + if (!widget || !widget.lenses) { + widget = session.widgetManager.$registerLineWidget({ + rowCount: 1, + rowsAbove: 1, + row: row, + column: column, + lenses: [] + }); + } + widget.lenses.push(lens.command); + if (row < firstRow) + firstRow = row; + }); + session._emit("changeFold", { data: { start: { row: firstRow } } }); + return firstRow; +}; +function attachToEditor(editor) { + editor.codeLensProviders = []; + editor.renderer.on("afterRender", renderWidgets); + if (!editor.$codeLensClickHandler) { + editor.$codeLensClickHandler = function (e) { + var command = e.target.lensCommand; + if (!command) + return; + editor.execCommand(command.id, command.arguments); + editor._emit("codeLensClick", e); + }; + event.addListener(editor.container, "click", editor.$codeLensClickHandler, editor); + } + editor.$updateLenses = function () { + var session = editor.session; + if (!session) + return; + if (!session.widgetManager) { + session.widgetManager = new LineWidgets(session); + session.widgetManager.attach(editor); + } + var providersToWaitNum = editor.codeLensProviders.length; + var lenses = []; + editor.codeLensProviders.forEach(function (provider) { + provider.provideCodeLenses(session, function (err, payload) { + if (err) + return; + payload.forEach(function (lens) { + lenses.push(lens); + }); + providersToWaitNum--; + if (providersToWaitNum == 0) { + applyLenses(); + } + }); + }); + function applyLenses() { + var cursor = session.selection.cursor; + var oldRow = session.documentToScreenRow(cursor); + var scrollTop = session.getScrollTop(); + var firstRow = exports.setLenses(session, lenses); + var lastDelta = session.$undoManager && session.$undoManager.$lastDelta; + if (lastDelta && lastDelta.action == "remove" && lastDelta.lines.length > 1) + return; + var row = session.documentToScreenRow(cursor); + var lineHeight = editor.renderer.layerConfig.lineHeight; + var top = session.getScrollTop() + (row - oldRow) * lineHeight; + if (firstRow == 0 && scrollTop < lineHeight / 4 && scrollTop > -lineHeight / 4) { + top = -lineHeight; + } + session.setScrollTop(top); + } + }; + var updateLenses = lang.delayedCall(editor.$updateLenses); + editor.$updateLensesOnInput = function () { + updateLenses.delay(250); + }; + editor.on("input", editor.$updateLensesOnInput); +} +function detachFromEditor(editor) { + editor.off("input", editor.$updateLensesOnInput); + editor.renderer.off("afterRender", renderWidgets); + if (editor.$codeLensClickHandler) + editor.container.removeEventListener("click", editor.$codeLensClickHandler); +} +exports.registerCodeLensProvider = function (editor, codeLensProvider) { + editor.setOption("enableCodeLens", true); + editor.codeLensProviders.push(codeLensProvider); + editor.$updateLensesOnInput(); +}; +exports.clear = function (session) { + exports.setLenses(session, null); +}; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableCodeLens: { + set: function (val) { + if (val) { + attachToEditor(this); + } + else { + detachFromEditor(this); + } + } + } +}); +dom.importCssString("\n.ace_codeLens {\n position: absolute;\n color: #aaa;\n font-size: 88%;\n background: inherit;\n width: 100%;\n display: flex;\n align-items: flex-end;\n pointer-events: none;\n}\n.ace_codeLens > a {\n cursor: pointer;\n pointer-events: auto;\n}\n.ace_codeLens > a:hover {\n color: #0000ff;\n text-decoration: underline;\n}\n.ace_dark > .ace_codeLens > a:hover {\n color: #4e94ce;\n}\n", "codelense.css", false); + +}); + (function() { + window.require(["ace/ext/code_lens"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-elastic_tabstops_lite.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-elastic_tabstops_lite.js new file mode 100644 index 0000000..a9e4e84 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-elastic_tabstops_lite.js @@ -0,0 +1,227 @@ +define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var ElasticTabstopsLite = function (editor) { + this.$editor = editor; + var self = this; + var changedRows = []; + var recordChanges = false; + this.onAfterExec = function () { + recordChanges = false; + self.processRows(changedRows); + changedRows = []; + }; + this.onExec = function () { + recordChanges = true; + }; + this.onChange = function (delta) { + if (recordChanges) { + if (changedRows.indexOf(delta.start.row) == -1) + changedRows.push(delta.start.row); + if (delta.end.row != delta.start.row) + changedRows.push(delta.end.row); + } + }; +}; +(function () { + this.processRows = function (rows) { + this.$inChange = true; + var checkedRows = []; + for (var r = 0, rowCount = rows.length; r < rowCount; r++) { + var row = rows[r]; + if (checkedRows.indexOf(row) > -1) + continue; + var cellWidthObj = this.$findCellWidthsForBlock(row); + var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths); + var rowIndex = cellWidthObj.firstRow; + for (var w = 0, l = cellWidths.length; w < l; w++) { + var widths = cellWidths[w]; + checkedRows.push(rowIndex); + this.$adjustRow(rowIndex, widths); + rowIndex++; + } + } + this.$inChange = false; + }; + this.$findCellWidthsForBlock = function (row) { + var cellWidths = [], widths; + var rowIter = row; + while (rowIter >= 0) { + widths = this.$cellWidthsForRow(rowIter); + if (widths.length == 0) + break; + cellWidths.unshift(widths); + rowIter--; + } + var firstRow = rowIter + 1; + rowIter = row; + var numRows = this.$editor.session.getLength(); + while (rowIter < numRows - 1) { + rowIter++; + widths = this.$cellWidthsForRow(rowIter); + if (widths.length == 0) + break; + cellWidths.push(widths); + } + return { cellWidths: cellWidths, firstRow: firstRow }; + }; + this.$cellWidthsForRow = function (row) { + var selectionColumns = this.$selectionColumnsForRow(row); + var tabs = [-1].concat(this.$tabsForRow(row)); + var widths = tabs.map(function (el) { return 0; }).slice(1); + var line = this.$editor.session.getLine(row); + for (var i = 0, len = tabs.length - 1; i < len; i++) { + var leftEdge = tabs[i] + 1; + var rightEdge = tabs[i + 1]; + var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge); + var cell = line.substring(leftEdge, rightEdge); + widths[i] = Math.max(cell.replace(/\s+$/g, '').length, rightmostSelection - leftEdge); + } + return widths; + }; + this.$selectionColumnsForRow = function (row) { + var selections = [], cursor = this.$editor.getCursorPosition(); + if (this.$editor.session.getSelection().isEmpty()) { + if (row == cursor.row) + selections.push(cursor.column); + } + return selections; + }; + this.$setBlockCellWidthsToMax = function (cellWidths) { + var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth; + var columnInfo = this.$izip_longest(cellWidths); + for (var c = 0, l = columnInfo.length; c < l; c++) { + var column = columnInfo[c]; + if (!column.push) { + console.error(column); + continue; + } + column.push(NaN); + for (var r = 0, s = column.length; r < s; r++) { + var width = column[r]; + if (startingNewBlock) { + blockStartRow = r; + maxWidth = 0; + startingNewBlock = false; + } + if (isNaN(width)) { + blockEndRow = r; + for (var j = blockStartRow; j < blockEndRow; j++) { + cellWidths[j][c] = maxWidth; + } + startingNewBlock = true; + } + maxWidth = Math.max(maxWidth, width); + } + } + return cellWidths; + }; + this.$rightmostSelectionInCell = function (selectionColumns, cellRightEdge) { + var rightmost = 0; + if (selectionColumns.length) { + var lengths = []; + for (var s = 0, length = selectionColumns.length; s < length; s++) { + if (selectionColumns[s] <= cellRightEdge) + lengths.push(s); + else + lengths.push(0); + } + rightmost = Math.max.apply(Math, lengths); + } + return rightmost; + }; + this.$tabsForRow = function (row) { + var rowTabs = [], line = this.$editor.session.getLine(row), re = /\t/g, match; + while ((match = re.exec(line)) != null) { + rowTabs.push(match.index); + } + return rowTabs; + }; + this.$adjustRow = function (row, widths) { + var rowTabs = this.$tabsForRow(row); + if (rowTabs.length == 0) + return; + var bias = 0, location = -1; + var expandedSet = this.$izip(widths, rowTabs); + for (var i = 0, l = expandedSet.length; i < l; i++) { + var w = expandedSet[i][0], it = expandedSet[i][1]; + location += 1 + w; + it += bias; + var difference = location - it; + if (difference == 0) + continue; + var partialLine = this.$editor.session.getLine(row).substr(0, it); + var strippedPartialLine = partialLine.replace(/\s*$/g, ""); + var ispaces = partialLine.length - strippedPartialLine.length; + if (difference > 0) { + this.$editor.session.getDocument().insertInLine({ row: row, column: it + 1 }, Array(difference + 1).join(" ") + "\t"); + this.$editor.session.getDocument().removeInLine(row, it, it + 1); + bias += difference; + } + if (difference < 0 && ispaces >= -difference) { + this.$editor.session.getDocument().removeInLine(row, it + difference, it); + bias += difference; + } + } + }; + this.$izip_longest = function (iterables) { + if (!iterables[0]) + return []; + var longest = iterables[0].length; + var iterablesLength = iterables.length; + for (var i = 1; i < iterablesLength; i++) { + var iLength = iterables[i].length; + if (iLength > longest) + longest = iLength; + } + var expandedSet = []; + for (var l = 0; l < longest; l++) { + var set = []; + for (var i = 0; i < iterablesLength; i++) { + if (iterables[i][l] === "") + set.push(NaN); + else + set.push(iterables[i][l]); + } + expandedSet.push(set); + } + return expandedSet; + }; + this.$izip = function (widths, tabs) { + var size = widths.length >= tabs.length ? tabs.length : widths.length; + var expandedSet = []; + for (var i = 0; i < size; i++) { + var set = [widths[i], tabs[i]]; + expandedSet.push(set); + } + return expandedSet; + }; +}).call(ElasticTabstopsLite.prototype); +exports.ElasticTabstopsLite = ElasticTabstopsLite; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + useElasticTabstops: { + set: function (val) { + if (val) { + if (!this.elasticTabstops) + this.elasticTabstops = new ElasticTabstopsLite(this); + this.commands.on("afterExec", this.elasticTabstops.onAfterExec); + this.commands.on("exec", this.elasticTabstops.onExec); + this.on("change", this.elasticTabstops.onChange); + } + else if (this.elasticTabstops) { + this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec); + this.commands.removeListener("exec", this.elasticTabstops.onExec); + this.removeListener("change", this.elasticTabstops.onChange); + } + } + } +}); + +}); + (function() { + window.require(["ace/ext/elastic_tabstops_lite"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-emmet.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-emmet.js new file mode 100644 index 0000000..5e694af --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-emmet.js @@ -0,0 +1,1257 @@ +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict"; +var dom = require("./lib/dom"); +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var lang = require("./lib/lang"); +var Range = require("./range").Range; +var RangeList = require("./range_list").RangeList; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var Tokenizer = require("./tokenizer").Tokenizer; +var clipboard = require("./clipboard"); +var VARIABLES = { + CURRENT_WORD: function (editor) { + return editor.session.getTextRange(editor.session.getWordRange()); + }, + SELECTION: function (editor, name, indentation) { + var text = editor.session.getTextRange(); + if (indentation) + return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1"); + return text; + }, + CURRENT_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row); + }, + PREV_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row - 1); + }, + LINE_INDEX: function (editor) { + return editor.getCursorPosition().row; + }, + LINE_NUMBER: function (editor) { + return editor.getCursorPosition().row + 1; + }, + SOFT_TABS: function (editor) { + return editor.session.getUseSoftTabs() ? "YES" : "NO"; + }, + TAB_SIZE: function (editor) { + return editor.session.getTabSize(); + }, + CLIPBOARD: function (editor) { + return clipboard.getText && clipboard.getText(); + }, + FILENAME: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0]; + }, + FILENAME_BASE: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, ""); + }, + DIRECTORY: function (editor) { + return this.FILEPATH(editor).replace(/[^/\\]*$/, ""); + }, + FILEPATH: function (editor) { return "/not implemented.txt"; }, + WORKSPACE_NAME: function () { return "Unknown"; }, + FULLNAME: function () { return "Unknown"; }, + BLOCK_COMMENT_START: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.start || ""; + }, + BLOCK_COMMENT_END: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.end || ""; + }, + LINE_COMMENT: function (editor) { + var mode = editor.session.$mode || {}; + return mode.lineCommentStart || ""; + }, + CURRENT_YEAR: date.bind(null, { year: "numeric" }), + CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }), + CURRENT_MONTH: date.bind(null, { month: "numeric" }), + CURRENT_MONTH_NAME: date.bind(null, { month: "long" }), + CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }), + CURRENT_DATE: date.bind(null, { day: "2-digit" }), + CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }), + CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }), + CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }), + CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }), + CURRENT_SECOND: date.bind(null, { second: "2-digit" }) +}; +VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION; +function date(dateFormat) { + var str = new Date().toLocaleString("en-us", dateFormat); + return str.length == 1 ? "0" + str : str; +} +var SnippetManager = function () { + this.snippetMap = {}; + this.snippetNameMap = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.getTokenizer = function () { + return SnippetManager.$tokenizer || this.createTokenizer(); + }; + this.createTokenizer = function () { + function TabstopToken(str) { + str = str.substr(1); + if (/^\d+$/.test(str)) + return [{ tabstopId: parseInt(str, 10) }]; + return [{ text: str }]; + } + function escape(ch) { + return "(?:[^\\\\" + ch + "]|\\\\.)"; + } + var formatMatcher = { + regex: "/(" + escape("/") + "+)/", + onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.fmtString = true; + ts.guard = val.slice(1, -1); + ts.flag = ""; + return ""; + }, + next: "formatString" + }; + SnippetManager.$tokenizer = new Tokenizer({ + start: [ + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) { + val = ch; + } + else if ("`$\\".indexOf(ch) != -1) { + val = ch; + } + return [val]; + } }, + { regex: /}/, onMatch: function (val, state, stack) { + return [stack.length ? stack.shift() : val]; + } }, + { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken }, + { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) { + var t = TabstopToken(str.substr(1)); + stack.unshift(t[0]); + return t; + }, next: "snippetVar" }, + { regex: /\n/, token: "newline", merge: false } + ], + snippetVar: [ + { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) { + var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) { + return operator.length == 2 ? operator[1] : "\x00"; + }).split("\x00").map(function (value) { + return { value: value }; + }); + stack[0].choices = choices; + return [choices[0]]; + }, next: "start" }, + formatMatcher, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" } + ], + formatString: [ + { regex: /:/, onMatch: function (val, state, stack) { + if (stack.length && stack[0].expectElse) { + stack[0].expectElse = false; + stack[0].ifEnd = { elseEnd: stack[0] }; + return [stack[0].ifEnd]; + } + return ":"; + } }, + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) + val = ch; + else if ("`$\\".indexOf(ch) != -1) + val = ch; + else if (ch == "n") + val = "\n"; + else if (ch == "t") + val = "\t"; + else if ("ulULE".indexOf(ch) != -1) + val = { changeCase: ch, local: ch > "a" }; + return [val]; + } }, + { regex: "/\\w*}", onMatch: function (val, state, stack) { + var next = stack.shift(); + if (next) + next.flag = val.slice(1, -1); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" }, + { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) { + return [{ text: val.slice(1) }]; + } }, + { regex: /\${\w+/, onMatch: function (val, state, stack) { + var token = { text: val.slice(2) }; + stack.unshift(token); + return [token]; + }, next: "formatStringVar" }, + { regex: /\n/, token: "newline", merge: false }, + { regex: /}/, onMatch: function (val, state, stack) { + var next = stack.shift(); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" } + ], + formatStringVar: [ + { regex: /:\/\w+}/, onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.formatFunction = val.slice(2, -1); + return [stack.shift()]; + }, next: "formatString" }, + formatMatcher, + { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) { + if (val[1] == "+") + stack[0].ifEnd = stack[0]; + if (val[1] == "?") + stack[0].expectElse = true; + }, next: "formatString" }, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" } + ] + }); + return SnippetManager.$tokenizer; + }; + this.tokenizeTmSnippet = function (str, startState) { + return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) { + return x.value || x; + }); + }; + this.getVariableValue = function (editor, name, indentation) { + if (/^\d+$/.test(name)) + return (this.variables.__ || {})[name] || ""; + if (/^[A-Z]\d+$/.test(name)) + return (this.variables[name[0] + "__"] || {})[name.substr(1)] || ""; + name = name.replace(/^TM_/, ""); + if (!this.variables.hasOwnProperty(name)) + return ""; + var value = this.variables[name]; + if (typeof value == "function") + value = this.variables[name](editor, name, indentation); + return value == null ? "" : value; + }; + this.variables = VARIABLES; + this.tmStrFormat = function (str, ch, editor) { + if (!ch.fmt) + return str; + var flag = ch.flag || ""; + var re = ch.guard; + re = new RegExp(re, flag.replace(/[^gim]/g, "")); + var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt; + var _self = this; + var formatted = str.replace(re, function () { + var oldArgs = _self.variables.__; + _self.variables.__ = [].slice.call(arguments); + var fmtParts = _self.resolveVariables(fmtTokens, editor); + var gChangeCase = "E"; + for (var i = 0; i < fmtParts.length; i++) { + var ch = fmtParts[i]; + if (typeof ch == "object") { + fmtParts[i] = ""; + if (ch.changeCase && ch.local) { + var next = fmtParts[i + 1]; + if (next && typeof next == "string") { + if (ch.changeCase == "u") + fmtParts[i] = next[0].toUpperCase(); + else + fmtParts[i] = next[0].toLowerCase(); + fmtParts[i + 1] = next.substr(1); + } + } + else if (ch.changeCase) { + gChangeCase = ch.changeCase; + } + } + else if (gChangeCase == "U") { + fmtParts[i] = ch.toUpperCase(); + } + else if (gChangeCase == "L") { + fmtParts[i] = ch.toLowerCase(); + } + } + _self.variables.__ = oldArgs; + return fmtParts.join(""); + }); + return formatted; + }; + this.tmFormatFunction = function (str, ch, editor) { + if (ch.formatFunction == "upcase") + return str.toUpperCase(); + if (ch.formatFunction == "downcase") + return str.toLowerCase(); + return str; + }; + this.resolveVariables = function (snippet, editor) { + var result = []; + var indentation = ""; + var afterNewLine = true; + for (var i = 0; i < snippet.length; i++) { + var ch = snippet[i]; + if (typeof ch == "string") { + result.push(ch); + if (ch == "\n") { + afterNewLine = true; + indentation = ""; + } + else if (afterNewLine) { + indentation = /^\t*/.exec(ch)[0]; + afterNewLine = /\S/.test(ch); + } + continue; + } + if (!ch) + continue; + afterNewLine = false; + if (ch.fmtString) { + var j = snippet.indexOf(ch, i + 1); + if (j == -1) + j = snippet.length; + ch.fmt = snippet.slice(i + 1, j); + i = j; + } + if (ch.text) { + var value = this.getVariableValue(editor, ch.text, indentation) + ""; + if (ch.fmtString) + value = this.tmStrFormat(value, ch, editor); + if (ch.formatFunction) + value = this.tmFormatFunction(value, ch, editor); + if (value && !ch.ifEnd) { + result.push(value); + gotoNext(ch); + } + else if (!value && ch.ifEnd) { + gotoNext(ch.ifEnd); + } + } + else if (ch.elseEnd) { + gotoNext(ch.elseEnd); + } + else if (ch.tabstopId != null) { + result.push(ch); + } + else if (ch.changeCase != null) { + result.push(ch); + } + } + function gotoNext(ch) { + var i1 = snippet.indexOf(ch, i + 1); + if (i1 != -1) + i = i1; + } + return result; + }; + this.insertSnippetForSelection = function (editor, snippetText) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var tabString = editor.session.getTabString(); + var indentString = line.match(/^\s*/)[0]; + if (cursor.column < indentString.length) + indentString = indentString.slice(0, cursor.column); + snippetText = snippetText.replace(/\r/g, ""); + var tokens = this.tokenizeTmSnippet(snippetText); + tokens = this.resolveVariables(tokens, editor); + tokens = tokens.map(function (x) { + if (x == "\n") + return x + indentString; + if (typeof x == "string") + return x.replace(/\t/g, tabString); + return x; + }); + var tabstops = []; + tokens.forEach(function (p, i) { + if (typeof p != "object") + return; + var id = p.tabstopId; + var ts = tabstops[id]; + if (!ts) { + ts = tabstops[id] = []; + ts.index = id; + ts.value = ""; + ts.parents = {}; + } + if (ts.indexOf(p) !== -1) + return; + if (p.choices && !ts.choices) + ts.choices = p.choices; + ts.push(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 === -1) + return; + var value = tokens.slice(i + 1, i1); + var isNested = value.some(function (t) { return typeof t === "object"; }); + if (isNested && !ts.value) { + ts.value = value; + } + else if (value.length && (!ts.value || typeof ts.value !== "string")) { + ts.value = value.join(""); + } + }); + tabstops.forEach(function (ts) { ts.length = 0; }); + var expanding = {}; + function copyValue(val) { + var copy = []; + for (var i = 0; i < val.length; i++) { + var p = val[i]; + if (typeof p == "object") { + if (expanding[p.tabstopId]) + continue; + var j = val.lastIndexOf(p, i - 1); + p = copy[j] || { tabstopId: p.tabstopId }; + } + copy[i] = p; + } + return copy; + } + for (var i = 0; i < tokens.length; i++) { + var p = tokens[i]; + if (typeof p != "object") + continue; + var id = p.tabstopId; + var ts = tabstops[id]; + var i1 = tokens.indexOf(p, i + 1); + if (expanding[id]) { + if (expanding[id] === p) { + delete expanding[id]; + Object.keys(expanding).forEach(function (parentId) { + ts.parents[parentId] = true; + }); + } + continue; + } + expanding[id] = p; + var value = ts.value; + if (typeof value !== "string") + value = copyValue(value); + else if (p.fmt) + value = this.tmStrFormat(value, p, editor); + tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p)); + if (ts.indexOf(p) === -1) + ts.push(p); + } + var row = 0, column = 0; + var text = ""; + tokens.forEach(function (t) { + if (typeof t === "string") { + var lines = t.split("\n"); + if (lines.length > 1) { + column = lines[lines.length - 1].length; + row += lines.length - 1; + } + else + column += t.length; + text += t; + } + else if (t) { + if (!t.start) + t.start = { row: row, column: column }; + else + t.end = { row: row, column: column }; + } + }); + var range = editor.getSelectionRange(); + var end = editor.session.replace(range, text); + var tabstopManager = new TabstopManager(editor); + var selectionId = editor.inVirtualSelectionMode && editor.selection.index; + tabstopManager.addTabstops(tabstops, range.start, end, selectionId); + }; + this.insertSnippet = function (editor, snippetText) { + var self = this; + if (editor.inVirtualSelectionMode) + return self.insertSnippetForSelection(editor, snippetText); + editor.forEachSelection(function () { + self.insertSnippetForSelection(editor, snippetText); + }, null, { keepOrder: true }); + if (editor.tabstopManager) + editor.tabstopManager.tabNext(); + }; + this.$getScope = function (editor) { + var scope = editor.session.$mode.$id || ""; + scope = scope.split("/").pop(); + if (scope === "html" || scope === "php") { + if (scope === "php" && !editor.session.$mode.inlinePhp) + scope = "html"; + var c = editor.getCursorPosition(); + var state = editor.session.getState(c.row); + if (typeof state === "object") { + state = state[0]; + } + if (state.substring) { + if (state.substring(0, 3) == "js-") + scope = "javascript"; + else if (state.substring(0, 4) == "css-") + scope = "css"; + else if (state.substring(0, 4) == "php-") + scope = "php"; + } + } + return scope; + }; + this.getActiveScopes = function (editor) { + var scope = this.$getScope(editor); + var scopes = [scope]; + var snippetMap = this.snippetMap; + if (snippetMap[scope] && snippetMap[scope].includeScopes) { + scopes.push.apply(scopes, snippetMap[scope].includeScopes); + } + scopes.push("_"); + return scopes; + }; + this.expandWithTab = function (editor, options) { + var self = this; + var result = editor.forEachSelection(function () { + return self.expandSnippetForSelection(editor, options); + }, null, { keepOrder: true }); + if (result && editor.tabstopManager) + editor.tabstopManager.tabNext(); + return result; + }; + this.expandSnippetForSelection = function (editor, options) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var before = line.substring(0, cursor.column); + var after = line.substr(cursor.column); + var snippetMap = this.snippetMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = this.findMatchingSnippet(snippets, before, after); + return !!snippet; + }, this); + if (!snippet) + return false; + if (options && options.dryRun) + return true; + editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length); + this.variables.M__ = snippet.matchBefore; + this.variables.T__ = snippet.matchAfter; + this.insertSnippetForSelection(editor, snippet.content); + this.variables.M__ = this.variables.T__ = null; + return true; + }; + this.findMatchingSnippet = function (snippetList, before, after) { + for (var i = snippetList.length; i--;) { + var s = snippetList[i]; + if (s.startRe && !s.startRe.test(before)) + continue; + if (s.endRe && !s.endRe.test(after)) + continue; + if (!s.startRe && !s.endRe) + continue; + s.matchBefore = s.startRe ? s.startRe.exec(before) : [""]; + s.matchAfter = s.endRe ? s.endRe.exec(after) : [""]; + s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : ""; + s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : ""; + return s; + } + }; + this.snippetMap = {}; + this.snippetNameMap = {}; + this.register = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + var self = this; + if (!snippets) + snippets = []; + function wrapRegexp(src) { + if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) + src = "(?:" + src + ")"; + return src || ""; + } + function guardedRegexp(re, guard, opening) { + re = wrapRegexp(re); + guard = wrapRegexp(guard); + if (opening) { + re = guard + re; + if (re && re[re.length - 1] != "$") + re = re + "$"; + } + else { + re = re + guard; + if (re && re[0] != "^") + re = "^" + re; + } + return new RegExp(re); + } + function addSnippet(s) { + if (!s.scope) + s.scope = scope || "_"; + scope = s.scope; + if (!snippetMap[scope]) { + snippetMap[scope] = []; + snippetNameMap[scope] = {}; + } + var map = snippetNameMap[scope]; + if (s.name) { + var old = map[s.name]; + if (old) + self.unregister(old); + map[s.name] = s; + } + snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { + if (!s.guard && /^\w/.test(s.tabTrigger)) + s.guard = "\\b"; + s.trigger = lang.escapeRegExp(s.tabTrigger); + } + if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard) + return; + s.startRe = guardedRegexp(s.trigger, s.guard, true); + s.triggerRe = new RegExp(s.trigger); + s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); + s.endTriggerRe = new RegExp(s.endTrigger); + } + if (Array.isArray(snippets)) { + snippets.forEach(addSnippet); + } + else { + Object.keys(snippets).forEach(function (key) { + addSnippet(snippets[key]); + }); + } + this._signal("registerSnippets", { scope: scope }); + }; + this.unregister = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + function removeSnippet(s) { + var nameMap = snippetNameMap[s.scope || scope]; + if (nameMap && nameMap[s.name]) { + delete nameMap[s.name]; + var map = snippetMap[s.scope || scope]; + var i = map && map.indexOf(s); + if (i >= 0) + map.splice(i, 1); + } + } + if (snippets.content) + removeSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(removeSnippet); + }; + this.parseSnippetFile = function (str) { + str = str.replace(/\r/g, ""); + var list = [], snippet = {}; + var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm; + var m; + while (m = re.exec(str)) { + if (m[1]) { + try { + snippet = JSON.parse(m[1]); + list.push(snippet); + } + catch (e) { } + } + if (m[4]) { + snippet.content = m[4].replace(/^\t/gm, ""); + list.push(snippet); + snippet = {}; + } + else { + var key = m[2], val = m[3]; + if (key == "regex") { + var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g; + snippet.guard = guardRe.exec(val)[1]; + snippet.trigger = guardRe.exec(val)[1]; + snippet.endTrigger = guardRe.exec(val)[1]; + snippet.endGuard = guardRe.exec(val)[1]; + } + else if (key == "snippet") { + snippet.tabTrigger = val.match(/^\S*/)[0]; + if (!snippet.name) + snippet.name = val; + } + else if (key) { + snippet[key] = val; + } + } + } + return list; + }; + this.getSnippetByName = function (name, editor) { + var snippetMap = this.snippetNameMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = snippets[name]; + return !!snippet; + }, this); + return snippet; + }; +}).call(SnippetManager.prototype); +var TabstopManager = function (editor) { + if (editor.tabstopManager) + return editor.tabstopManager; + editor.tabstopManager = this; + this.$onChange = this.onChange.bind(this); + this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule; + this.$onChangeSession = this.onChangeSession.bind(this); + this.$onAfterExec = this.onAfterExec.bind(this); + this.attach(editor); +}; +(function () { + this.attach = function (editor) { + this.index = 0; + this.ranges = []; + this.tabstops = []; + this.$openTabstops = null; + this.selectedTabstop = null; + this.editor = editor; + this.editor.on("change", this.$onChange); + this.editor.on("changeSelection", this.$onChangeSelection); + this.editor.on("changeSession", this.$onChangeSession); + this.editor.commands.on("afterExec", this.$onAfterExec); + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.detach = function () { + this.tabstops.forEach(this.removeTabstopMarkers, this); + this.ranges = null; + this.tabstops = null; + this.selectedTabstop = null; + this.editor.removeListener("change", this.$onChange); + this.editor.removeListener("changeSelection", this.$onChangeSelection); + this.editor.removeListener("changeSession", this.$onChangeSession); + this.editor.commands.removeListener("afterExec", this.$onAfterExec); + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.tabstopManager = null; + this.editor = null; + }; + this.onChange = function (delta) { + var isRemove = delta.action[0] == "r"; + var selectedTabstop = this.selectedTabstop || {}; + var parents = selectedTabstop.parents || {}; + var tabstops = (this.tabstops || []).slice(); + for (var i = 0; i < tabstops.length; i++) { + var ts = tabstops[i]; + var active = ts == selectedTabstop || parents[ts.index]; + ts.rangeList.$bias = active ? 0 : 1; + if (delta.action == "remove" && ts !== selectedTabstop) { + var parentActive = ts.parents && ts.parents[selectedTabstop.index]; + var startIndex = ts.rangeList.pointIndex(delta.start, parentActive); + startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1; + var endIndex = ts.rangeList.pointIndex(delta.end, parentActive); + endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1; + var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex); + for (var j = 0; j < toRemove.length; j++) + this.removeRange(toRemove[j]); + } + ts.rangeList.$onChange(delta); + } + var session = this.editor.session; + if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue()) + this.detach(); + }; + this.updateLinkedFields = function () { + var ts = this.selectedTabstop; + if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked) + return; + this.$inChange = true; + var session = this.editor.session; + var text = session.getTextRange(ts.firstNonLinked); + for (var i = 0; i < ts.length; i++) { + var range = ts[i]; + if (!range.linked) + continue; + var original = range.original; + var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor); + session.replace(range, fmt); + } + this.$inChange = false; + }; + this.onAfterExec = function (e) { + if (e.command && !e.command.readOnly) + this.updateLinkedFields(); + }; + this.onChangeSelection = function () { + if (!this.editor) + return; + var lead = this.editor.selection.lead; + var anchor = this.editor.selection.anchor; + var isEmpty = this.editor.selection.isEmpty(); + for (var i = 0; i < this.ranges.length; i++) { + if (this.ranges[i].linked) + continue; + var containsLead = this.ranges[i].contains(lead.row, lead.column); + var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column); + if (containsLead && containsAnchor) + return; + } + this.detach(); + }; + this.onChangeSession = function () { + this.detach(); + }; + this.tabNext = function (dir) { + var max = this.tabstops.length; + var index = this.index + (dir || 1); + index = Math.min(Math.max(index, 1), max); + if (index == max) + index = 0; + this.selectTabstop(index); + if (index === 0) + this.detach(); + }; + this.selectTabstop = function (index) { + this.$openTabstops = null; + var ts = this.tabstops[this.index]; + if (ts) + this.addTabstopMarkers(ts); + this.index = index; + ts = this.tabstops[this.index]; + if (!ts || !ts.length) + return; + this.selectedTabstop = ts; + var range = ts.firstNonLinked || ts; + if (ts.choices) + range.cursor = range.start; + if (!this.editor.inVirtualSelectionMode) { + var sel = this.editor.multiSelect; + sel.toSingleRange(range); + for (var i = 0; i < ts.length; i++) { + if (ts.hasLinkedRanges && ts[i].linked) + continue; + sel.addRange(ts[i].clone(), true); + } + } + else { + this.editor.selection.fromOrientedRange(range); + } + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + if (this.selectedTabstop && this.selectedTabstop.choices) + this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices }); + }; + this.addTabstops = function (tabstops, start, end) { + var useLink = this.useLink || !this.editor.getOption("enableMultiselect"); + if (!this.$openTabstops) + this.$openTabstops = []; + if (!tabstops[0]) { + var p = Range.fromPoints(end, end); + moveRelative(p.start, start); + moveRelative(p.end, start); + tabstops[0] = [p]; + tabstops[0].index = 0; + } + var i = this.index; + var arg = [i + 1, 0]; + var ranges = this.ranges; + tabstops.forEach(function (ts, index) { + var dest = this.$openTabstops[index] || ts; + for (var i = 0; i < ts.length; i++) { + var p = ts[i]; + var range = Range.fromPoints(p.start, p.end || p.start); + movePoint(range.start, start); + movePoint(range.end, start); + range.original = p; + range.tabstop = dest; + ranges.push(range); + if (dest != ts) + dest.unshift(range); + else + dest[i] = range; + if (p.fmtString || (dest.firstNonLinked && useLink)) { + range.linked = true; + dest.hasLinkedRanges = true; + } + else if (!dest.firstNonLinked) + dest.firstNonLinked = range; + } + if (!dest.firstNonLinked) + dest.hasLinkedRanges = false; + if (dest === ts) { + arg.push(dest); + this.$openTabstops[index] = dest; + } + this.addTabstopMarkers(dest); + dest.rangeList = dest.rangeList || new RangeList(); + dest.rangeList.$bias = 0; + dest.rangeList.addList(dest); + }, this); + if (arg.length > 2) { + if (this.tabstops.length) + arg.push(arg.splice(2, 1)[0]); + this.tabstops.splice.apply(this.tabstops, arg); + } + }; + this.addTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + if (!range.markerId) + range.markerId = session.addMarker(range, "ace_snippet-marker", "text"); + }); + }; + this.removeTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + session.removeMarker(range.markerId); + range.markerId = null; + }); + }; + this.removeRange = function (range) { + var i = range.tabstop.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + i = this.ranges.indexOf(range); + if (i != -1) + this.ranges.splice(i, 1); + i = range.tabstop.rangeList.ranges.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + this.editor.session.removeMarker(range.markerId); + if (!range.tabstop.length) { + i = this.tabstops.indexOf(range.tabstop); + if (i != -1) + this.tabstops.splice(i, 1); + if (!this.tabstops.length) + this.detach(); + } + }; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys({ + "Tab": function (editor) { + if (exports.snippetManager && exports.snippetManager.expandWithTab(editor)) + return; + editor.tabstopManager.tabNext(1); + editor.renderer.scrollCursorIntoView(); + }, + "Shift-Tab": function (editor) { + editor.tabstopManager.tabNext(-1); + editor.renderer.scrollCursorIntoView(); + }, + "Esc": function (editor) { + editor.tabstopManager.detach(); + } + }); +}).call(TabstopManager.prototype); +var movePoint = function (point, diff) { + if (point.row == 0) + point.column += diff.column; + point.row += diff.row; +}; +var moveRelative = function (point, start) { + if (point.row == start.row) + point.column -= start.column; + point.row -= start.row; +}; +dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false); +exports.snippetManager = new SnippetManager(); +var Editor = require("./editor").Editor; +(function () { + this.insertSnippet = function (content, options) { + return exports.snippetManager.insertSnippet(this, content, options); + }; + this.expandSnippet = function (options) { + return exports.snippetManager.expandWithTab(this, options); + }; +}).call(Editor.prototype); + +}); + +define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","ace/config","resources","resources","tabStops","resources","utils","actions"], function(require, exports, module){"use strict"; +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var Editor = require("../editor").Editor; +var snippetManager = require("../snippets").snippetManager; +var Range = require("../range").Range; +var config = require("../config"); +var emmet, emmetPath; +function AceEmmetEditor() { } +AceEmmetEditor.prototype = { + setupContext: function (editor) { + this.ace = editor; + this.indentation = editor.session.getTabString(); + if (!emmet) + emmet = window.emmet; + var resources = emmet.resources || emmet.require("resources"); + resources.setVariable("indentation", this.indentation); + this.$syntax = null; + this.$syntax = this.getSyntax(); + }, + getSelectionRange: function () { + var range = this.ace.getSelectionRange(); + var doc = this.ace.session.doc; + return { + start: doc.positionToIndex(range.start), + end: doc.positionToIndex(range.end) + }; + }, + createSelection: function (start, end) { + var doc = this.ace.session.doc; + this.ace.selection.setRange({ + start: doc.indexToPosition(start), + end: doc.indexToPosition(end) + }); + }, + getCurrentLineRange: function () { + var ace = this.ace; + var row = ace.getCursorPosition().row; + var lineLength = ace.session.getLine(row).length; + var index = ace.session.doc.positionToIndex({ row: row, column: 0 }); + return { + start: index, + end: index + lineLength + }; + }, + getCaretPos: function () { + var pos = this.ace.getCursorPosition(); + return this.ace.session.doc.positionToIndex(pos); + }, + setCaretPos: function (index) { + var pos = this.ace.session.doc.indexToPosition(index); + this.ace.selection.moveToPosition(pos); + }, + getCurrentLine: function () { + var row = this.ace.getCursorPosition().row; + return this.ace.session.getLine(row); + }, + replaceContent: function (value, start, end, noIndent) { + if (end == null) + end = start == null ? this.getContent().length : start; + if (start == null) + start = 0; + var editor = this.ace; + var doc = editor.session.doc; + var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end)); + editor.session.remove(range); + range.end = range.start; + value = this.$updateTabstops(value); + snippetManager.insertSnippet(editor, value); + }, + getContent: function () { + return this.ace.getValue(); + }, + getSyntax: function () { + if (this.$syntax) + return this.$syntax; + var syntax = this.ace.session.$modeId.split("/").pop(); + if (syntax == "html" || syntax == "php") { + var cursor = this.ace.getCursorPosition(); + var state = this.ace.session.getState(cursor.row); + if (typeof state != "string") + state = state[0]; + if (state) { + state = state.split("-"); + if (state.length > 1) + syntax = state[0]; + else if (syntax == "php") + syntax = "html"; + } + } + return syntax; + }, + getProfileName: function () { + var resources = emmet.resources || emmet.require("resources"); + switch (this.getSyntax()) { + case "css": return "css"; + case "xml": + case "xsl": + return "xml"; + case "html": + var profile = resources.getVariable("profile"); + if (!profile) + profile = this.ace.session.getLines(0, 2).join("").search(/]+XHTML/i) != -1 ? "xhtml" : "html"; + return profile; + default: + var mode = this.ace.session.$mode; + return mode.emmetConfig && mode.emmetConfig.profile || "xhtml"; + } + }, + prompt: function (title) { + return prompt(title); // eslint-disable-line no-alert + }, + getSelection: function () { + return this.ace.session.getTextRange(); + }, + getFilePath: function () { + return ""; + }, + $updateTabstops: function (value) { + var base = 1000; + var zeroBase = 0; + var lastZero = null; + var ts = emmet.tabStops || emmet.require('tabStops'); + var resources = emmet.resources || emmet.require("resources"); + var settings = resources.getVocabulary("user"); + var tabstopOptions = { + tabstop: function (data) { + var group = parseInt(data.group, 10); + var isZero = group === 0; + if (isZero) + group = ++zeroBase; + else + group += base; + var placeholder = data.placeholder; + if (placeholder) { + placeholder = ts.processText(placeholder, tabstopOptions); + } + var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}'; + if (isZero) { + lastZero = [data.start, result]; + } + return result; + }, + escape: function (ch) { + if (ch == '$') + return '\\$'; + if (ch == '\\') + return '\\\\'; + return ch; + } + }; + value = ts.processText(value, tabstopOptions); + if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) { + value += '${0}'; + } + else if (lastZero) { + var common = emmet.utils ? emmet.utils.common : emmet.require('utils'); + value = common.replaceSubstring(value, '${0}', lastZero[0], lastZero[1]); + } + return value; + } +}; +var keymap = { + expand_abbreviation: { "mac": "ctrl+alt+e", "win": "alt+e" }, + match_pair_outward: { "mac": "ctrl+d", "win": "ctrl+," }, + match_pair_inward: { "mac": "ctrl+j", "win": "ctrl+shift+0" }, + matching_pair: { "mac": "ctrl+alt+j", "win": "alt+j" }, + next_edit_point: "alt+right", + prev_edit_point: "alt+left", + toggle_comment: { "mac": "command+/", "win": "ctrl+/" }, + split_join_tag: { "mac": "shift+command+'", "win": "shift+ctrl+`" }, + remove_tag: { "mac": "command+'", "win": "shift+ctrl+;" }, + evaluate_math_expression: { "mac": "shift+command+y", "win": "shift+ctrl+y" }, + increment_number_by_1: "ctrl+up", + decrement_number_by_1: "ctrl+down", + increment_number_by_01: "alt+up", + decrement_number_by_01: "alt+down", + increment_number_by_10: { "mac": "alt+command+up", "win": "shift+alt+up" }, + decrement_number_by_10: { "mac": "alt+command+down", "win": "shift+alt+down" }, + select_next_item: { "mac": "shift+command+.", "win": "shift+ctrl+." }, + select_previous_item: { "mac": "shift+command+,", "win": "shift+ctrl+," }, + reflect_css_value: { "mac": "shift+command+r", "win": "shift+ctrl+r" }, + encode_decode_data_url: { "mac": "shift+ctrl+d", "win": "ctrl+'" }, + expand_abbreviation_with_tab: "Tab", + wrap_with_abbreviation: { "mac": "shift+ctrl+a", "win": "shift+ctrl+a" } +}; +var editorProxy = new AceEmmetEditor(); +exports.commands = new HashHandler(); +exports.runEmmetCommand = function runEmmetCommand(editor) { + if (this.action == "expand_abbreviation_with_tab") { + if (!editor.selection.isEmpty()) + return false; + var pos = editor.selection.lead; + var token = editor.session.getTokenAt(pos.row, pos.column); + if (token && /\btag\b/.test(token.type)) + return false; + } + try { + editorProxy.setupContext(editor); + var actions = emmet.actions || emmet.require("actions"); + if (this.action == "wrap_with_abbreviation") { + return setTimeout(function () { + actions.run("wrap_with_abbreviation", editorProxy); + }, 0); + } + var result = actions.run(this.action, editorProxy); + } + catch (e) { + if (!emmet) { + var loading = exports.load(runEmmetCommand.bind(this, editor)); + if (this.action == "expand_abbreviation_with_tab") + return false; + return loading; + } + editor._signal("changeStatus", typeof e == "string" ? e : e.message); + config.warn(e); + result = false; + } + return result; +}; +for (var command in keymap) { + exports.commands.addCommand({ + name: "emmet:" + command, + action: command, + bindKey: keymap[command], + exec: exports.runEmmetCommand, + multiSelectAction: "forEach" + }); +} +exports.updateCommands = function (editor, enabled) { + if (enabled) { + editor.keyBinding.addKeyboardHandler(exports.commands); + } + else { + editor.keyBinding.removeKeyboardHandler(exports.commands); + } +}; +exports.isSupportedMode = function (mode) { + if (!mode) + return false; + if (mode.emmetConfig) + return true; + var id = mode.$id || mode; + return /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(id); +}; +exports.isAvailable = function (editor, command) { + if (/(evaluate_math_expression|expand_abbreviation)$/.test(command)) + return true; + var mode = editor.session.$mode; + var isSupported = exports.isSupportedMode(mode); + if (isSupported && mode.$modes) { + try { + editorProxy.setupContext(editor); + if (/js|php/.test(editorProxy.getSyntax())) + isSupported = false; + } + catch (e) { } + } + return isSupported; +}; +var onChangeMode = function (e, target) { + var editor = target; + if (!editor) + return; + var enabled = exports.isSupportedMode(editor.session.$mode); + if (e.enableEmmet === false) + enabled = false; + if (enabled) + exports.load(); + exports.updateCommands(editor, enabled); +}; +exports.load = function (cb) { + if (typeof emmetPath !== "string") { + config.warn("script for emmet-core is not loaded"); + return false; + } + config.loadModule(emmetPath, function () { + emmetPath = null; + cb && cb(); + }); + return true; +}; +exports.AceEmmetEditor = AceEmmetEditor; +config.defineOptions(Editor.prototype, "editor", { + enableEmmet: { + set: function (val) { + this[val ? "on" : "removeListener"]("changeMode", onChangeMode); + onChangeMode({ enableEmmet: !!val }, this); + }, + value: true + } +}); +exports.setCore = function (e) { + if (typeof e == "string") + emmetPath = e; + else + emmet = e; +}; + +}); + (function() { + window.require(["ace/ext/emmet"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-error_marker.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-error_marker.js new file mode 100644 index 0000000..f7c24d5 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-error_marker.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/ext/error_marker"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-hardwrap.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-hardwrap.js new file mode 100644 index 0000000..0279a89 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-hardwrap.js @@ -0,0 +1,117 @@ +define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var Range = require("../range").Range; +function hardWrap(editor, options) { + var max = options.column || editor.getOption("printMarginColumn"); + var allowMerge = options.allowMerge != false; + var row = Math.min(options.startRow, options.endRow); + var endRow = Math.max(options.startRow, options.endRow); + var session = editor.session; + while (row <= endRow) { + var line = session.getLine(row); + if (line.length > max) { + var space = findSpace(line, max, 5); + if (space) { + var indentation = /^\s*/.exec(line)[0]; + session.replace(new Range(row, space.start, row, space.end), "\n" + indentation); + } + endRow++; + } + else if (allowMerge && /\S/.test(line) && row != endRow) { + var nextLine = session.getLine(row + 1); + if (nextLine && /\S/.test(nextLine)) { + var trimmedLine = line.replace(/\s+$/, ""); + var trimmedNextLine = nextLine.replace(/^\s+/, ""); + var mergedLine = trimmedLine + " " + trimmedNextLine; + var space = findSpace(mergedLine, max, 5); + if (space && space.start > trimmedLine.length || mergedLine.length < max) { + var replaceRange = new Range(row, trimmedLine.length, row + 1, nextLine.length - trimmedNextLine.length); + session.replace(replaceRange, " "); + row--; + endRow--; + } + else if (trimmedLine.length < line.length) { + session.remove(new Range(row, trimmedLine.length, row, line.length)); + } + } + } + row++; + } + function findSpace(line, max, min) { + if (line.length < max) + return; + var before = line.slice(0, max); + var after = line.slice(max); + var spaceAfter = /^(?:(\s+)|(\S+)(\s+))/.exec(after); + var spaceBefore = /(?:(\s+)|(\s+)(\S+))$/.exec(before); + var start = 0; + var end = 0; + if (spaceBefore && !spaceBefore[2]) { + start = max - spaceBefore[1].length; + end = max; + } + if (spaceAfter && !spaceAfter[2]) { + if (!start) + start = max; + end = max + spaceAfter[1].length; + } + if (start) { + return { + start: start, + end: end + }; + } + if (spaceBefore && spaceBefore[2] && spaceBefore.index > min) { + return { + start: spaceBefore.index, + end: spaceBefore.index + spaceBefore[2].length + }; + } + if (spaceAfter && spaceAfter[2]) { + start = max + spaceAfter[2].length; + return { + start: start, + end: start + spaceAfter[3].length + }; + } + } +} +function wrapAfterInput(e) { + if (e.command.name == "insertstring" && /\S/.test(e.args)) { + var editor = e.editor; + var cursor = editor.selection.cursor; + if (cursor.column <= editor.renderer.$printMarginColumn) + return; + var lastDelta = editor.session.$undoManager.$lastDelta; + hardWrap(editor, { + startRow: cursor.row, endRow: cursor.row, + allowMerge: false + }); + if (lastDelta != editor.session.$undoManager.$lastDelta) + editor.session.markUndoGroup(); + } +} +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + hardWrap: { + set: function (val) { + if (val) { + this.commands.on("afterExec", wrapAfterInput); + } + else { + this.commands.off("afterExec", wrapAfterInput); + } + }, + value: false + } +}); +exports.hardWrap = hardWrap; + +}); + (function() { + window.require(["ace/ext/hardwrap"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-keybinding_menu.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-keybinding_menu.js new file mode 100644 index 0000000..faf0036 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-keybinding_menu.js @@ -0,0 +1,134 @@ +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var keys = require("../../lib/keys"); +module.exports.getEditorKeybordShortcuts = function (editor) { + var KEY_MODS = keys.KEY_MODS; + var keybindings = []; + var commandMap = {}; + editor.keyBinding.$handlers.forEach(function (handler) { + var ckb = handler.commandKeyBinding; + for (var i in ckb) { + var key = i.replace(/(^|-)\w/g, function (x) { return x.toUpperCase(); }); + var commands = ckb[i]; + if (!Array.isArray(commands)) + commands = [commands]; + commands.forEach(function (command) { + if (typeof command != "string") + command = command.name; + if (commandMap[command]) { + commandMap[command].key += "|" + key; + } + else { + commandMap[command] = { key: key, command: command }; + keybindings.push(commandMap[command]); + } + }); + } + }); + return keybindings; +}; + +}); + +define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var Editor = require("../editor").Editor; +function showKeyboardShortcuts(editor) { + if (!document.getElementById('kbshortcutmenu')) { + var overlayPage = require('./menu_tools/overlay_page').overlayPage; + var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts; + var kb = getEditorKeybordShortcuts(editor); + var el = document.createElement('div'); + var commands = kb.reduce(function (previous, current) { + return previous + '
' + + current.command + ' : ' + + '' + current.key + '
'; + }, ''); + el.id = 'kbshortcutmenu'; + el.innerHTML = '

Keyboard Shortcuts

' + commands + ''; + overlayPage(editor, el); + } +} +module.exports.init = function (editor) { + Editor.prototype.showKeyboardShortcuts = function () { + showKeyboardShortcuts(this); + }; + editor.commands.addCommands([{ + name: "showKeyboardShortcuts", + bindKey: { win: "Ctrl-Alt-h", mac: "Command-Alt-h" }, + exec: function (editor, line) { + editor.showKeyboardShortcuts(); + } + }]); +}; + +}); + (function() { + window.require(["ace/ext/keybinding_menu"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-language_tools.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-language_tools.js new file mode 100644 index 0000000..27db509 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-language_tools.js @@ -0,0 +1,1964 @@ +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict"; +var dom = require("./lib/dom"); +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var lang = require("./lib/lang"); +var Range = require("./range").Range; +var RangeList = require("./range_list").RangeList; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var Tokenizer = require("./tokenizer").Tokenizer; +var clipboard = require("./clipboard"); +var VARIABLES = { + CURRENT_WORD: function (editor) { + return editor.session.getTextRange(editor.session.getWordRange()); + }, + SELECTION: function (editor, name, indentation) { + var text = editor.session.getTextRange(); + if (indentation) + return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1"); + return text; + }, + CURRENT_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row); + }, + PREV_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row - 1); + }, + LINE_INDEX: function (editor) { + return editor.getCursorPosition().row; + }, + LINE_NUMBER: function (editor) { + return editor.getCursorPosition().row + 1; + }, + SOFT_TABS: function (editor) { + return editor.session.getUseSoftTabs() ? "YES" : "NO"; + }, + TAB_SIZE: function (editor) { + return editor.session.getTabSize(); + }, + CLIPBOARD: function (editor) { + return clipboard.getText && clipboard.getText(); + }, + FILENAME: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0]; + }, + FILENAME_BASE: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, ""); + }, + DIRECTORY: function (editor) { + return this.FILEPATH(editor).replace(/[^/\\]*$/, ""); + }, + FILEPATH: function (editor) { return "/not implemented.txt"; }, + WORKSPACE_NAME: function () { return "Unknown"; }, + FULLNAME: function () { return "Unknown"; }, + BLOCK_COMMENT_START: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.start || ""; + }, + BLOCK_COMMENT_END: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.end || ""; + }, + LINE_COMMENT: function (editor) { + var mode = editor.session.$mode || {}; + return mode.lineCommentStart || ""; + }, + CURRENT_YEAR: date.bind(null, { year: "numeric" }), + CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }), + CURRENT_MONTH: date.bind(null, { month: "numeric" }), + CURRENT_MONTH_NAME: date.bind(null, { month: "long" }), + CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }), + CURRENT_DATE: date.bind(null, { day: "2-digit" }), + CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }), + CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }), + CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }), + CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }), + CURRENT_SECOND: date.bind(null, { second: "2-digit" }) +}; +VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION; +function date(dateFormat) { + var str = new Date().toLocaleString("en-us", dateFormat); + return str.length == 1 ? "0" + str : str; +} +var SnippetManager = function () { + this.snippetMap = {}; + this.snippetNameMap = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.getTokenizer = function () { + return SnippetManager.$tokenizer || this.createTokenizer(); + }; + this.createTokenizer = function () { + function TabstopToken(str) { + str = str.substr(1); + if (/^\d+$/.test(str)) + return [{ tabstopId: parseInt(str, 10) }]; + return [{ text: str }]; + } + function escape(ch) { + return "(?:[^\\\\" + ch + "]|\\\\.)"; + } + var formatMatcher = { + regex: "/(" + escape("/") + "+)/", + onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.fmtString = true; + ts.guard = val.slice(1, -1); + ts.flag = ""; + return ""; + }, + next: "formatString" + }; + SnippetManager.$tokenizer = new Tokenizer({ + start: [ + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) { + val = ch; + } + else if ("`$\\".indexOf(ch) != -1) { + val = ch; + } + return [val]; + } }, + { regex: /}/, onMatch: function (val, state, stack) { + return [stack.length ? stack.shift() : val]; + } }, + { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken }, + { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) { + var t = TabstopToken(str.substr(1)); + stack.unshift(t[0]); + return t; + }, next: "snippetVar" }, + { regex: /\n/, token: "newline", merge: false } + ], + snippetVar: [ + { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) { + var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) { + return operator.length == 2 ? operator[1] : "\x00"; + }).split("\x00").map(function (value) { + return { value: value }; + }); + stack[0].choices = choices; + return [choices[0]]; + }, next: "start" }, + formatMatcher, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" } + ], + formatString: [ + { regex: /:/, onMatch: function (val, state, stack) { + if (stack.length && stack[0].expectElse) { + stack[0].expectElse = false; + stack[0].ifEnd = { elseEnd: stack[0] }; + return [stack[0].ifEnd]; + } + return ":"; + } }, + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) + val = ch; + else if ("`$\\".indexOf(ch) != -1) + val = ch; + else if (ch == "n") + val = "\n"; + else if (ch == "t") + val = "\t"; + else if ("ulULE".indexOf(ch) != -1) + val = { changeCase: ch, local: ch > "a" }; + return [val]; + } }, + { regex: "/\\w*}", onMatch: function (val, state, stack) { + var next = stack.shift(); + if (next) + next.flag = val.slice(1, -1); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" }, + { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) { + return [{ text: val.slice(1) }]; + } }, + { regex: /\${\w+/, onMatch: function (val, state, stack) { + var token = { text: val.slice(2) }; + stack.unshift(token); + return [token]; + }, next: "formatStringVar" }, + { regex: /\n/, token: "newline", merge: false }, + { regex: /}/, onMatch: function (val, state, stack) { + var next = stack.shift(); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" } + ], + formatStringVar: [ + { regex: /:\/\w+}/, onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.formatFunction = val.slice(2, -1); + return [stack.shift()]; + }, next: "formatString" }, + formatMatcher, + { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) { + if (val[1] == "+") + stack[0].ifEnd = stack[0]; + if (val[1] == "?") + stack[0].expectElse = true; + }, next: "formatString" }, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" } + ] + }); + return SnippetManager.$tokenizer; + }; + this.tokenizeTmSnippet = function (str, startState) { + return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) { + return x.value || x; + }); + }; + this.getVariableValue = function (editor, name, indentation) { + if (/^\d+$/.test(name)) + return (this.variables.__ || {})[name] || ""; + if (/^[A-Z]\d+$/.test(name)) + return (this.variables[name[0] + "__"] || {})[name.substr(1)] || ""; + name = name.replace(/^TM_/, ""); + if (!this.variables.hasOwnProperty(name)) + return ""; + var value = this.variables[name]; + if (typeof value == "function") + value = this.variables[name](editor, name, indentation); + return value == null ? "" : value; + }; + this.variables = VARIABLES; + this.tmStrFormat = function (str, ch, editor) { + if (!ch.fmt) + return str; + var flag = ch.flag || ""; + var re = ch.guard; + re = new RegExp(re, flag.replace(/[^gim]/g, "")); + var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt; + var _self = this; + var formatted = str.replace(re, function () { + var oldArgs = _self.variables.__; + _self.variables.__ = [].slice.call(arguments); + var fmtParts = _self.resolveVariables(fmtTokens, editor); + var gChangeCase = "E"; + for (var i = 0; i < fmtParts.length; i++) { + var ch = fmtParts[i]; + if (typeof ch == "object") { + fmtParts[i] = ""; + if (ch.changeCase && ch.local) { + var next = fmtParts[i + 1]; + if (next && typeof next == "string") { + if (ch.changeCase == "u") + fmtParts[i] = next[0].toUpperCase(); + else + fmtParts[i] = next[0].toLowerCase(); + fmtParts[i + 1] = next.substr(1); + } + } + else if (ch.changeCase) { + gChangeCase = ch.changeCase; + } + } + else if (gChangeCase == "U") { + fmtParts[i] = ch.toUpperCase(); + } + else if (gChangeCase == "L") { + fmtParts[i] = ch.toLowerCase(); + } + } + _self.variables.__ = oldArgs; + return fmtParts.join(""); + }); + return formatted; + }; + this.tmFormatFunction = function (str, ch, editor) { + if (ch.formatFunction == "upcase") + return str.toUpperCase(); + if (ch.formatFunction == "downcase") + return str.toLowerCase(); + return str; + }; + this.resolveVariables = function (snippet, editor) { + var result = []; + var indentation = ""; + var afterNewLine = true; + for (var i = 0; i < snippet.length; i++) { + var ch = snippet[i]; + if (typeof ch == "string") { + result.push(ch); + if (ch == "\n") { + afterNewLine = true; + indentation = ""; + } + else if (afterNewLine) { + indentation = /^\t*/.exec(ch)[0]; + afterNewLine = /\S/.test(ch); + } + continue; + } + if (!ch) + continue; + afterNewLine = false; + if (ch.fmtString) { + var j = snippet.indexOf(ch, i + 1); + if (j == -1) + j = snippet.length; + ch.fmt = snippet.slice(i + 1, j); + i = j; + } + if (ch.text) { + var value = this.getVariableValue(editor, ch.text, indentation) + ""; + if (ch.fmtString) + value = this.tmStrFormat(value, ch, editor); + if (ch.formatFunction) + value = this.tmFormatFunction(value, ch, editor); + if (value && !ch.ifEnd) { + result.push(value); + gotoNext(ch); + } + else if (!value && ch.ifEnd) { + gotoNext(ch.ifEnd); + } + } + else if (ch.elseEnd) { + gotoNext(ch.elseEnd); + } + else if (ch.tabstopId != null) { + result.push(ch); + } + else if (ch.changeCase != null) { + result.push(ch); + } + } + function gotoNext(ch) { + var i1 = snippet.indexOf(ch, i + 1); + if (i1 != -1) + i = i1; + } + return result; + }; + this.insertSnippetForSelection = function (editor, snippetText) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var tabString = editor.session.getTabString(); + var indentString = line.match(/^\s*/)[0]; + if (cursor.column < indentString.length) + indentString = indentString.slice(0, cursor.column); + snippetText = snippetText.replace(/\r/g, ""); + var tokens = this.tokenizeTmSnippet(snippetText); + tokens = this.resolveVariables(tokens, editor); + tokens = tokens.map(function (x) { + if (x == "\n") + return x + indentString; + if (typeof x == "string") + return x.replace(/\t/g, tabString); + return x; + }); + var tabstops = []; + tokens.forEach(function (p, i) { + if (typeof p != "object") + return; + var id = p.tabstopId; + var ts = tabstops[id]; + if (!ts) { + ts = tabstops[id] = []; + ts.index = id; + ts.value = ""; + ts.parents = {}; + } + if (ts.indexOf(p) !== -1) + return; + if (p.choices && !ts.choices) + ts.choices = p.choices; + ts.push(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 === -1) + return; + var value = tokens.slice(i + 1, i1); + var isNested = value.some(function (t) { return typeof t === "object"; }); + if (isNested && !ts.value) { + ts.value = value; + } + else if (value.length && (!ts.value || typeof ts.value !== "string")) { + ts.value = value.join(""); + } + }); + tabstops.forEach(function (ts) { ts.length = 0; }); + var expanding = {}; + function copyValue(val) { + var copy = []; + for (var i = 0; i < val.length; i++) { + var p = val[i]; + if (typeof p == "object") { + if (expanding[p.tabstopId]) + continue; + var j = val.lastIndexOf(p, i - 1); + p = copy[j] || { tabstopId: p.tabstopId }; + } + copy[i] = p; + } + return copy; + } + for (var i = 0; i < tokens.length; i++) { + var p = tokens[i]; + if (typeof p != "object") + continue; + var id = p.tabstopId; + var ts = tabstops[id]; + var i1 = tokens.indexOf(p, i + 1); + if (expanding[id]) { + if (expanding[id] === p) { + delete expanding[id]; + Object.keys(expanding).forEach(function (parentId) { + ts.parents[parentId] = true; + }); + } + continue; + } + expanding[id] = p; + var value = ts.value; + if (typeof value !== "string") + value = copyValue(value); + else if (p.fmt) + value = this.tmStrFormat(value, p, editor); + tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p)); + if (ts.indexOf(p) === -1) + ts.push(p); + } + var row = 0, column = 0; + var text = ""; + tokens.forEach(function (t) { + if (typeof t === "string") { + var lines = t.split("\n"); + if (lines.length > 1) { + column = lines[lines.length - 1].length; + row += lines.length - 1; + } + else + column += t.length; + text += t; + } + else if (t) { + if (!t.start) + t.start = { row: row, column: column }; + else + t.end = { row: row, column: column }; + } + }); + var range = editor.getSelectionRange(); + var end = editor.session.replace(range, text); + var tabstopManager = new TabstopManager(editor); + var selectionId = editor.inVirtualSelectionMode && editor.selection.index; + tabstopManager.addTabstops(tabstops, range.start, end, selectionId); + }; + this.insertSnippet = function (editor, snippetText) { + var self = this; + if (editor.inVirtualSelectionMode) + return self.insertSnippetForSelection(editor, snippetText); + editor.forEachSelection(function () { + self.insertSnippetForSelection(editor, snippetText); + }, null, { keepOrder: true }); + if (editor.tabstopManager) + editor.tabstopManager.tabNext(); + }; + this.$getScope = function (editor) { + var scope = editor.session.$mode.$id || ""; + scope = scope.split("/").pop(); + if (scope === "html" || scope === "php") { + if (scope === "php" && !editor.session.$mode.inlinePhp) + scope = "html"; + var c = editor.getCursorPosition(); + var state = editor.session.getState(c.row); + if (typeof state === "object") { + state = state[0]; + } + if (state.substring) { + if (state.substring(0, 3) == "js-") + scope = "javascript"; + else if (state.substring(0, 4) == "css-") + scope = "css"; + else if (state.substring(0, 4) == "php-") + scope = "php"; + } + } + return scope; + }; + this.getActiveScopes = function (editor) { + var scope = this.$getScope(editor); + var scopes = [scope]; + var snippetMap = this.snippetMap; + if (snippetMap[scope] && snippetMap[scope].includeScopes) { + scopes.push.apply(scopes, snippetMap[scope].includeScopes); + } + scopes.push("_"); + return scopes; + }; + this.expandWithTab = function (editor, options) { + var self = this; + var result = editor.forEachSelection(function () { + return self.expandSnippetForSelection(editor, options); + }, null, { keepOrder: true }); + if (result && editor.tabstopManager) + editor.tabstopManager.tabNext(); + return result; + }; + this.expandSnippetForSelection = function (editor, options) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var before = line.substring(0, cursor.column); + var after = line.substr(cursor.column); + var snippetMap = this.snippetMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = this.findMatchingSnippet(snippets, before, after); + return !!snippet; + }, this); + if (!snippet) + return false; + if (options && options.dryRun) + return true; + editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length); + this.variables.M__ = snippet.matchBefore; + this.variables.T__ = snippet.matchAfter; + this.insertSnippetForSelection(editor, snippet.content); + this.variables.M__ = this.variables.T__ = null; + return true; + }; + this.findMatchingSnippet = function (snippetList, before, after) { + for (var i = snippetList.length; i--;) { + var s = snippetList[i]; + if (s.startRe && !s.startRe.test(before)) + continue; + if (s.endRe && !s.endRe.test(after)) + continue; + if (!s.startRe && !s.endRe) + continue; + s.matchBefore = s.startRe ? s.startRe.exec(before) : [""]; + s.matchAfter = s.endRe ? s.endRe.exec(after) : [""]; + s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : ""; + s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : ""; + return s; + } + }; + this.snippetMap = {}; + this.snippetNameMap = {}; + this.register = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + var self = this; + if (!snippets) + snippets = []; + function wrapRegexp(src) { + if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) + src = "(?:" + src + ")"; + return src || ""; + } + function guardedRegexp(re, guard, opening) { + re = wrapRegexp(re); + guard = wrapRegexp(guard); + if (opening) { + re = guard + re; + if (re && re[re.length - 1] != "$") + re = re + "$"; + } + else { + re = re + guard; + if (re && re[0] != "^") + re = "^" + re; + } + return new RegExp(re); + } + function addSnippet(s) { + if (!s.scope) + s.scope = scope || "_"; + scope = s.scope; + if (!snippetMap[scope]) { + snippetMap[scope] = []; + snippetNameMap[scope] = {}; + } + var map = snippetNameMap[scope]; + if (s.name) { + var old = map[s.name]; + if (old) + self.unregister(old); + map[s.name] = s; + } + snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { + if (!s.guard && /^\w/.test(s.tabTrigger)) + s.guard = "\\b"; + s.trigger = lang.escapeRegExp(s.tabTrigger); + } + if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard) + return; + s.startRe = guardedRegexp(s.trigger, s.guard, true); + s.triggerRe = new RegExp(s.trigger); + s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); + s.endTriggerRe = new RegExp(s.endTrigger); + } + if (Array.isArray(snippets)) { + snippets.forEach(addSnippet); + } + else { + Object.keys(snippets).forEach(function (key) { + addSnippet(snippets[key]); + }); + } + this._signal("registerSnippets", { scope: scope }); + }; + this.unregister = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + function removeSnippet(s) { + var nameMap = snippetNameMap[s.scope || scope]; + if (nameMap && nameMap[s.name]) { + delete nameMap[s.name]; + var map = snippetMap[s.scope || scope]; + var i = map && map.indexOf(s); + if (i >= 0) + map.splice(i, 1); + } + } + if (snippets.content) + removeSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(removeSnippet); + }; + this.parseSnippetFile = function (str) { + str = str.replace(/\r/g, ""); + var list = [], snippet = {}; + var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm; + var m; + while (m = re.exec(str)) { + if (m[1]) { + try { + snippet = JSON.parse(m[1]); + list.push(snippet); + } + catch (e) { } + } + if (m[4]) { + snippet.content = m[4].replace(/^\t/gm, ""); + list.push(snippet); + snippet = {}; + } + else { + var key = m[2], val = m[3]; + if (key == "regex") { + var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g; + snippet.guard = guardRe.exec(val)[1]; + snippet.trigger = guardRe.exec(val)[1]; + snippet.endTrigger = guardRe.exec(val)[1]; + snippet.endGuard = guardRe.exec(val)[1]; + } + else if (key == "snippet") { + snippet.tabTrigger = val.match(/^\S*/)[0]; + if (!snippet.name) + snippet.name = val; + } + else if (key) { + snippet[key] = val; + } + } + } + return list; + }; + this.getSnippetByName = function (name, editor) { + var snippetMap = this.snippetNameMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = snippets[name]; + return !!snippet; + }, this); + return snippet; + }; +}).call(SnippetManager.prototype); +var TabstopManager = function (editor) { + if (editor.tabstopManager) + return editor.tabstopManager; + editor.tabstopManager = this; + this.$onChange = this.onChange.bind(this); + this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule; + this.$onChangeSession = this.onChangeSession.bind(this); + this.$onAfterExec = this.onAfterExec.bind(this); + this.attach(editor); +}; +(function () { + this.attach = function (editor) { + this.index = 0; + this.ranges = []; + this.tabstops = []; + this.$openTabstops = null; + this.selectedTabstop = null; + this.editor = editor; + this.editor.on("change", this.$onChange); + this.editor.on("changeSelection", this.$onChangeSelection); + this.editor.on("changeSession", this.$onChangeSession); + this.editor.commands.on("afterExec", this.$onAfterExec); + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.detach = function () { + this.tabstops.forEach(this.removeTabstopMarkers, this); + this.ranges = null; + this.tabstops = null; + this.selectedTabstop = null; + this.editor.removeListener("change", this.$onChange); + this.editor.removeListener("changeSelection", this.$onChangeSelection); + this.editor.removeListener("changeSession", this.$onChangeSession); + this.editor.commands.removeListener("afterExec", this.$onAfterExec); + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.tabstopManager = null; + this.editor = null; + }; + this.onChange = function (delta) { + var isRemove = delta.action[0] == "r"; + var selectedTabstop = this.selectedTabstop || {}; + var parents = selectedTabstop.parents || {}; + var tabstops = (this.tabstops || []).slice(); + for (var i = 0; i < tabstops.length; i++) { + var ts = tabstops[i]; + var active = ts == selectedTabstop || parents[ts.index]; + ts.rangeList.$bias = active ? 0 : 1; + if (delta.action == "remove" && ts !== selectedTabstop) { + var parentActive = ts.parents && ts.parents[selectedTabstop.index]; + var startIndex = ts.rangeList.pointIndex(delta.start, parentActive); + startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1; + var endIndex = ts.rangeList.pointIndex(delta.end, parentActive); + endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1; + var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex); + for (var j = 0; j < toRemove.length; j++) + this.removeRange(toRemove[j]); + } + ts.rangeList.$onChange(delta); + } + var session = this.editor.session; + if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue()) + this.detach(); + }; + this.updateLinkedFields = function () { + var ts = this.selectedTabstop; + if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked) + return; + this.$inChange = true; + var session = this.editor.session; + var text = session.getTextRange(ts.firstNonLinked); + for (var i = 0; i < ts.length; i++) { + var range = ts[i]; + if (!range.linked) + continue; + var original = range.original; + var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor); + session.replace(range, fmt); + } + this.$inChange = false; + }; + this.onAfterExec = function (e) { + if (e.command && !e.command.readOnly) + this.updateLinkedFields(); + }; + this.onChangeSelection = function () { + if (!this.editor) + return; + var lead = this.editor.selection.lead; + var anchor = this.editor.selection.anchor; + var isEmpty = this.editor.selection.isEmpty(); + for (var i = 0; i < this.ranges.length; i++) { + if (this.ranges[i].linked) + continue; + var containsLead = this.ranges[i].contains(lead.row, lead.column); + var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column); + if (containsLead && containsAnchor) + return; + } + this.detach(); + }; + this.onChangeSession = function () { + this.detach(); + }; + this.tabNext = function (dir) { + var max = this.tabstops.length; + var index = this.index + (dir || 1); + index = Math.min(Math.max(index, 1), max); + if (index == max) + index = 0; + this.selectTabstop(index); + if (index === 0) + this.detach(); + }; + this.selectTabstop = function (index) { + this.$openTabstops = null; + var ts = this.tabstops[this.index]; + if (ts) + this.addTabstopMarkers(ts); + this.index = index; + ts = this.tabstops[this.index]; + if (!ts || !ts.length) + return; + this.selectedTabstop = ts; + var range = ts.firstNonLinked || ts; + if (ts.choices) + range.cursor = range.start; + if (!this.editor.inVirtualSelectionMode) { + var sel = this.editor.multiSelect; + sel.toSingleRange(range); + for (var i = 0; i < ts.length; i++) { + if (ts.hasLinkedRanges && ts[i].linked) + continue; + sel.addRange(ts[i].clone(), true); + } + } + else { + this.editor.selection.fromOrientedRange(range); + } + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + if (this.selectedTabstop && this.selectedTabstop.choices) + this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices }); + }; + this.addTabstops = function (tabstops, start, end) { + var useLink = this.useLink || !this.editor.getOption("enableMultiselect"); + if (!this.$openTabstops) + this.$openTabstops = []; + if (!tabstops[0]) { + var p = Range.fromPoints(end, end); + moveRelative(p.start, start); + moveRelative(p.end, start); + tabstops[0] = [p]; + tabstops[0].index = 0; + } + var i = this.index; + var arg = [i + 1, 0]; + var ranges = this.ranges; + tabstops.forEach(function (ts, index) { + var dest = this.$openTabstops[index] || ts; + for (var i = 0; i < ts.length; i++) { + var p = ts[i]; + var range = Range.fromPoints(p.start, p.end || p.start); + movePoint(range.start, start); + movePoint(range.end, start); + range.original = p; + range.tabstop = dest; + ranges.push(range); + if (dest != ts) + dest.unshift(range); + else + dest[i] = range; + if (p.fmtString || (dest.firstNonLinked && useLink)) { + range.linked = true; + dest.hasLinkedRanges = true; + } + else if (!dest.firstNonLinked) + dest.firstNonLinked = range; + } + if (!dest.firstNonLinked) + dest.hasLinkedRanges = false; + if (dest === ts) { + arg.push(dest); + this.$openTabstops[index] = dest; + } + this.addTabstopMarkers(dest); + dest.rangeList = dest.rangeList || new RangeList(); + dest.rangeList.$bias = 0; + dest.rangeList.addList(dest); + }, this); + if (arg.length > 2) { + if (this.tabstops.length) + arg.push(arg.splice(2, 1)[0]); + this.tabstops.splice.apply(this.tabstops, arg); + } + }; + this.addTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + if (!range.markerId) + range.markerId = session.addMarker(range, "ace_snippet-marker", "text"); + }); + }; + this.removeTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + session.removeMarker(range.markerId); + range.markerId = null; + }); + }; + this.removeRange = function (range) { + var i = range.tabstop.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + i = this.ranges.indexOf(range); + if (i != -1) + this.ranges.splice(i, 1); + i = range.tabstop.rangeList.ranges.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + this.editor.session.removeMarker(range.markerId); + if (!range.tabstop.length) { + i = this.tabstops.indexOf(range.tabstop); + if (i != -1) + this.tabstops.splice(i, 1); + if (!this.tabstops.length) + this.detach(); + } + }; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys({ + "Tab": function (editor) { + if (exports.snippetManager && exports.snippetManager.expandWithTab(editor)) + return; + editor.tabstopManager.tabNext(1); + editor.renderer.scrollCursorIntoView(); + }, + "Shift-Tab": function (editor) { + editor.tabstopManager.tabNext(-1); + editor.renderer.scrollCursorIntoView(); + }, + "Esc": function (editor) { + editor.tabstopManager.detach(); + } + }); +}).call(TabstopManager.prototype); +var movePoint = function (point, diff) { + if (point.row == 0) + point.column += diff.column; + point.row += diff.row; +}; +var moveRelative = function (point, start) { + if (point.row == start.row) + point.column -= start.column; + point.row -= start.row; +}; +dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false); +exports.snippetManager = new SnippetManager(); +var Editor = require("./editor").Editor; +(function () { + this.insertSnippet = function (content, options) { + return exports.snippetManager.insertSnippet(this, content, options); + }; + this.expandSnippet = function (options) { + return exports.snippetManager.expandWithTab(this, options); + }; +}).call(Editor.prototype); + +}); + +define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"], function(require, exports, module){"use strict"; +var Renderer = require("../virtual_renderer").VirtualRenderer; +var Editor = require("../editor").Editor; +var Range = require("../range").Range; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); +var $singleLineEditor = function (el) { + var renderer = new Renderer(el); + renderer.$maxLines = 4; + var editor = new Editor(renderer); + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.renderer.setShowGutter(false); + editor.renderer.setHighlightGutterLine(false); + editor.$mouseHandler.$focusTimeout = 0; + editor.$highlightTagPending = true; + return editor; +}; +var AcePopup = function (parentNode) { + var el = dom.createElement("div"); + var popup = new $singleLineEditor(el); + if (parentNode) + parentNode.appendChild(el); + el.style.display = "none"; + popup.renderer.content.style.cursor = "default"; + popup.renderer.setStyle("ace_autocomplete"); + popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); + var noop = function () { }; + popup.focus = noop; + popup.$isFocused = true; + popup.renderer.$cursorLayer.restartTimer = noop; + popup.renderer.$cursorLayer.element.style.opacity = 0; + popup.renderer.$maxLines = 8; + popup.renderer.$keepTextAreaAtCursor = false; + popup.setHighlightActiveLine(false); + popup.session.highlight(""); + popup.session.$searchHighlight.clazz = "ace_highlight-marker"; + popup.on("mousedown", function (e) { + var pos = e.getDocumentPosition(); + popup.selection.moveToPosition(pos); + selectionMarker.start.row = selectionMarker.end.row = pos.row; + e.stop(); + }); + var lastMouseEvent; + var hoverMarker = new Range(-1, 0, -1, Infinity); + var selectionMarker = new Range(-1, 0, -1, Infinity); + selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine"); + popup.setSelectOnHover = function (val) { + if (!val) { + hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine"); + } + else if (hoverMarker.id) { + popup.session.removeMarker(hoverMarker.id); + hoverMarker.id = null; + } + }; + popup.setSelectOnHover(false); + popup.on("mousemove", function (e) { + if (!lastMouseEvent) { + lastMouseEvent = e; + return; + } + if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) { + return; + } + lastMouseEvent = e; + lastMouseEvent.scrollTop = popup.renderer.scrollTop; + var row = lastMouseEvent.getDocumentPosition().row; + if (hoverMarker.start.row != row) { + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row); + } + }); + popup.renderer.on("beforeRender", function () { + if (lastMouseEvent && hoverMarker.start.row != -1) { + lastMouseEvent.$pos = null; + var row = lastMouseEvent.getDocumentPosition().row; + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row, true); + } + }); + popup.renderer.on("afterRender", function () { + var row = popup.getRow(); + var t = popup.renderer.$textLayer; + var selected = t.element.childNodes[row - t.config.firstRow]; + if (selected !== t.selectedNode && t.selectedNode) + dom.removeCssClass(t.selectedNode, "ace_selected"); + t.selectedNode = selected; + if (selected) + dom.addCssClass(selected, "ace_selected"); + }); + var hideHoverMarker = function () { setHoverMarker(-1); }; + var setHoverMarker = function (row, suppressRedraw) { + if (row !== hoverMarker.start.row) { + hoverMarker.start.row = hoverMarker.end.row = row; + if (!suppressRedraw) + popup.session._emit("changeBackMarker"); + popup._emit("changeHoverMarker"); + } + }; + popup.getHoveredRow = function () { + return hoverMarker.start.row; + }; + event.addListener(popup.container, "mouseout", hideHoverMarker); + popup.on("hide", hideHoverMarker); + popup.on("changeSelection", hideHoverMarker); + popup.session.doc.getLength = function () { + return popup.data.length; + }; + popup.session.doc.getLine = function (i) { + var data = popup.data[i]; + if (typeof data == "string") + return data; + return (data && data.value) || ""; + }; + var bgTokenizer = popup.session.bgTokenizer; + bgTokenizer.$tokenizeRow = function (row) { + var data = popup.data[row]; + var tokens = []; + if (!data) + return tokens; + if (typeof data == "string") + data = { value: data }; + var caption = data.caption || data.value || data.name; + function addToken(value, className) { + value && tokens.push({ + type: (data.className || "") + (className || ""), + value: value + }); + } + var lower = caption.toLowerCase(); + var filterText = (popup.filterText || "").toLowerCase(); + var lastIndex = 0; + var lastI = 0; + for (var i = 0; i <= filterText.length; i++) { + if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) { + var sub = filterText.slice(lastI, i); + lastI = i; + var index = lower.indexOf(sub, lastIndex); + if (index == -1) + continue; + addToken(caption.slice(lastIndex, index), ""); + lastIndex = index + sub.length; + addToken(caption.slice(index, lastIndex), "completion-highlight"); + } + } + addToken(caption.slice(lastIndex, caption.length), ""); + if (data.meta) + tokens.push({ type: "completion-meta", value: data.meta }); + if (data.message) + tokens.push({ type: "completion-message", value: data.message }); + return tokens; + }; + bgTokenizer.$updateOnChange = noop; + bgTokenizer.start = noop; + popup.session.$computeWidth = function () { + return this.screenWidth = 0; + }; + popup.isOpen = false; + popup.isTopdown = false; + popup.autoSelect = true; + popup.filterText = ""; + popup.data = []; + popup.setData = function (list, filterText) { + popup.filterText = filterText || ""; + popup.setValue(lang.stringRepeat("\n", list.length), -1); + popup.data = list || []; + popup.setRow(0); + }; + popup.getData = function (row) { + return popup.data[row]; + }; + popup.getRow = function () { + return selectionMarker.start.row; + }; + popup.setRow = function (line) { + line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line)); + if (selectionMarker.start.row != line) { + popup.selection.clearSelection(); + selectionMarker.start.row = selectionMarker.end.row = line || 0; + popup.session._emit("changeBackMarker"); + popup.moveCursorTo(line || 0, 0); + if (popup.isOpen) + popup._signal("select"); + } + }; + popup.on("changeSelection", function () { + if (popup.isOpen) + popup.setRow(popup.selection.lead.row); + popup.renderer.scrollCursorIntoView(); + }); + popup.hide = function () { + this.container.style.display = "none"; + this._signal("hide"); + popup.isOpen = false; + }; + popup.show = function (pos, lineHeight, topdownOnly) { + var el = this.container; + var screenHeight = window.innerHeight; + var screenWidth = window.innerWidth; + var renderer = this.renderer; + var maxH = renderer.$maxLines * lineHeight * 1.4; + var top = pos.top + this.$borderSize; + var allowTopdown = top > screenHeight / 2 && !topdownOnly; + if (allowTopdown && top + lineHeight + maxH > screenHeight) { + renderer.$maxPixelHeight = top - 2 * this.$borderSize; + el.style.top = ""; + el.style.bottom = screenHeight - top + "px"; + popup.isTopdown = false; + } + else { + top += lineHeight; + renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight; + el.style.top = top + "px"; + el.style.bottom = ""; + popup.isTopdown = true; + } + el.style.display = ""; + var left = pos.left; + if (left + el.offsetWidth > screenWidth) + left = screenWidth - el.offsetWidth; + el.style.left = left + "px"; + this._signal("show"); + lastMouseEvent = null; + popup.isOpen = true; + }; + popup.goTo = function (where) { + var row = this.getRow(); + var max = this.session.getLength() - 1; + switch (where) { + case "up": + row = row <= 0 ? max : row - 1; + break; + case "down": + row = row >= max ? -1 : row + 1; + break; + case "start": + row = 0; + break; + case "end": + row = max; + break; + } + this.setRow(row); + }; + popup.getTextLeftOffset = function () { + return this.$borderSize + this.renderer.$padding + this.$imageSize; + }; + popup.$imageSize = 0; + popup.$borderSize = 1; + return popup; +}; +dom.importCssString("\n.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #CAD6FA;\n z-index: 1;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #3a674e;\n}\n.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid #abbffe;\n margin-top: -1px;\n background: rgba(233,233,253,0.4);\n position: absolute;\n z-index: 2;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid rgba(109, 150, 13, 0.8);\n background: rgba(58, 103, 78, 0.62);\n}\n.ace_completion-meta {\n opacity: 0.5;\n margin: 0.9em;\n}\n.ace_completion-message {\n color: blue;\n}\n.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #2d69c7;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #93ca12;\n}\n.ace_editor.ace_autocomplete {\n width: 300px;\n z-index: 200000;\n border: 1px lightgray solid;\n position: fixed;\n box-shadow: 2px 3px 5px rgba(0,0,0,.2);\n line-height: 1.4;\n background: #fefefe;\n color: #111;\n}\n.ace_dark.ace_editor.ace_autocomplete {\n border: 1px #484747 solid;\n box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\n line-height: 1.4;\n background: #25282c;\n color: #c1c1c1;\n}", "autocompletion.css", false); +exports.AcePopup = AcePopup; +exports.$singleLineEditor = $singleLineEditor; + +}); + +define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module){"use strict"; +exports.parForEach = function (array, fn, callback) { + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function (result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } +}; +var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/; +exports.retrievePrecedingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos - 1; i >= 0; i--) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf.reverse().join(""); +}; +exports.retrieveFollowingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf; +}; +exports.getCompletionPrefix = function (editor) { + var pos = editor.getCursorPosition(); + var line = editor.session.getLine(pos.row); + var prefix; + editor.completers.forEach(function (completer) { + if (completer.identifierRegexps) { + completer.identifierRegexps.forEach(function (identifierRegex) { + if (!prefix && identifierRegex) + prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex); + }.bind(this)); + } + }.bind(this)); + return prefix || this.retrievePrecedingIdentifier(line, pos.column); +}; + +}); + +define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config"], function(require, exports, module){"use strict"; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var AcePopup = require("./autocomplete/popup").AcePopup; +var util = require("./autocomplete/util"); +var lang = require("./lib/lang"); +var dom = require("./lib/dom"); +var snippetManager = require("./snippets").snippetManager; +var config = require("./config"); +var Autocomplete = function () { + this.autoInsert = false; + this.autoSelect = true; + this.exactMatch = false; + this.gatherCompletionsId = 0; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys(this.commands); + this.blurListener = this.blurListener.bind(this); + this.changeListener = this.changeListener.bind(this); + this.mousedownListener = this.mousedownListener.bind(this); + this.mousewheelListener = this.mousewheelListener.bind(this); + this.changeTimer = lang.delayedCall(function () { + this.updateCompletions(true); + }.bind(this)); + this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50); +}; +(function () { + this.$init = function () { + this.popup = new AcePopup(document.body || document.documentElement); + this.popup.on("click", function (e) { + this.insertMatch(); + e.stop(); + }.bind(this)); + this.popup.focus = this.editor.focus.bind(this.editor); + this.popup.on("show", this.tooltipTimer.bind(null, null)); + this.popup.on("select", this.tooltipTimer.bind(null, null)); + this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null)); + return this.popup; + }; + this.getPopup = function () { + return this.popup || this.$init(); + }; + this.openPopup = function (editor, prefix, keepPopupPosition) { + if (!this.popup) + this.$init(); + this.popup.autoSelect = this.autoSelect; + this.popup.setData(this.completions.filtered, this.completions.filterText); + editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + var renderer = editor.renderer; + this.popup.setRow(this.autoSelect ? 0 : -1); + if (!keepPopupPosition) { + this.popup.setTheme(editor.getTheme()); + this.popup.setFontSize(editor.getFontSize()); + var lineHeight = renderer.layerConfig.lineHeight; + var pos = renderer.$cursorLayer.getPixelPosition(this.base, true); + pos.left -= this.popup.getTextLeftOffset(); + var rect = editor.container.getBoundingClientRect(); + pos.top += rect.top - renderer.layerConfig.offset; + pos.left += rect.left - editor.renderer.scrollLeft; + pos.left += renderer.gutterWidth; + this.popup.show(pos, lineHeight); + } + else if (keepPopupPosition && !prefix) { + this.detach(); + } + this.changeTimer.cancel(); + }; + this.detach = function () { + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.off("changeSelection", this.changeListener); + this.editor.off("blur", this.blurListener); + this.editor.off("mousedown", this.mousedownListener); + this.editor.off("mousewheel", this.mousewheelListener); + this.changeTimer.cancel(); + this.hideDocTooltip(); + this.gatherCompletionsId += 1; + if (this.popup && this.popup.isOpen) + this.popup.hide(); + if (this.base) + this.base.detach(); + this.activated = false; + this.completions = this.base = null; + }; + this.changeListener = function (e) { + var cursor = this.editor.selection.lead; + if (cursor.row != this.base.row || cursor.column < this.base.column) { + this.detach(); + } + if (this.activated) + this.changeTimer.schedule(); + else + this.detach(); + }; + this.blurListener = function (e) { + var el = document.activeElement; + var text = this.editor.textInput.getElement(); + var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget); + var container = this.popup && this.popup.container; + if (el != text && el.parentNode != container && !fromTooltip + && el != this.tooltipNode && e.relatedTarget != text) { + this.detach(); + } + }; + this.mousedownListener = function (e) { + this.detach(); + }; + this.mousewheelListener = function (e) { + this.detach(); + }; + this.goTo = function (where) { + this.popup.goTo(where); + }; + this.insertMatch = function (data, options) { + if (!data) + data = this.popup.getData(this.popup.getRow()); + if (!data) + return false; + var completions = this.completions; + this.editor.startOperation({ command: { name: "insertMatch" } }); + if (data.completer && data.completer.insertMatch) { + data.completer.insertMatch(this.editor, data); + } + else { + if (!completions) + return false; + if (completions.filterText) { + var ranges = this.editor.selection.getAllRanges(); + for (var i = 0, range; range = ranges[i]; i++) { + range.start.column -= completions.filterText.length; + this.editor.session.remove(range); + } + } + if (data.snippet) + snippetManager.insertSnippet(this.editor, data.snippet); + else + this.editor.execCommand("insertstring", data.value || data); + } + if (this.completions == completions) + this.detach(); + this.editor.endOperation(); + }; + this.commands = { + "Up": function (editor) { editor.completer.goTo("up"); }, + "Down": function (editor) { editor.completer.goTo("down"); }, + "Ctrl-Up|Ctrl-Home": function (editor) { editor.completer.goTo("start"); }, + "Ctrl-Down|Ctrl-End": function (editor) { editor.completer.goTo("end"); }, + "Esc": function (editor) { editor.completer.detach(); }, + "Return": function (editor) { return editor.completer.insertMatch(); }, + "Shift-Return": function (editor) { editor.completer.insertMatch(null, { deleteSuffix: true }); }, + "Tab": function (editor) { + var result = editor.completer.insertMatch(); + if (!result && !editor.tabstopManager) + editor.completer.goTo("down"); + else + return result; + }, + "PageUp": function (editor) { editor.completer.popup.gotoPageUp(); }, + "PageDown": function (editor) { editor.completer.popup.gotoPageDown(); } + }; + this.gatherCompletions = function (editor, callback) { + var session = editor.getSession(); + var pos = editor.getCursorPosition(); + var prefix = util.getCompletionPrefix(editor); + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); + this.base.$insertRight = true; + var matches = []; + var total = editor.completers.length; + editor.completers.forEach(function (completer, i) { + completer.getCompletions(editor, session, pos, prefix, function (err, results) { + if (!err && results) + matches = matches.concat(results); + callback(null, { + prefix: util.getCompletionPrefix(editor), + matches: matches, + finished: (--total === 0) + }); + }); + }); + return true; + }; + this.showPopup = function (editor, options) { + if (this.editor) + this.detach(); + this.activated = true; + this.editor = editor; + if (editor.completer != this) { + if (editor.completer) + editor.completer.detach(); + editor.completer = this; + } + editor.on("changeSelection", this.changeListener); + editor.on("blur", this.blurListener); + editor.on("mousedown", this.mousedownListener); + editor.on("mousewheel", this.mousewheelListener); + this.updateCompletions(false, options); + }; + this.updateCompletions = function (keepPopupPosition, options) { + if (keepPopupPosition && this.base && this.completions) { + var pos = this.editor.getCursorPosition(); + var prefix = this.editor.session.getTextRange({ start: this.base, end: pos }); + if (prefix == this.completions.filterText) + return; + this.completions.setFilter(prefix); + if (!this.completions.filtered.length) + return this.detach(); + if (this.completions.filtered.length == 1 + && this.completions.filtered[0].value == prefix + && !this.completions.filtered[0].snippet) + return this.detach(); + this.openPopup(this.editor, prefix, keepPopupPosition); + return; + } + if (options && options.matches) { + var pos = this.editor.getSelectionRange().start; + this.base = this.editor.session.doc.createAnchor(pos.row, pos.column); + this.base.$insertRight = true; + this.completions = new FilteredList(options.matches); + return this.openPopup(this.editor, "", keepPopupPosition); + } + var _id = this.gatherCompletionsId; + var detachIfFinished = function (results) { + if (!results.finished) + return; + return this.detach(); + }.bind(this); + var processResults = function (results) { + var prefix = results.prefix; + var matches = results.matches; + this.completions = new FilteredList(matches); + if (this.exactMatch) + this.completions.exactMatch = true; + this.completions.setFilter(prefix); + var filtered = this.completions.filtered; + if (!filtered.length) + return detachIfFinished(results); + if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) + return detachIfFinished(results); + if (this.autoInsert && filtered.length == 1 && results.finished) + return this.insertMatch(filtered[0]); + this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this); + var isImmediate = true; + var immediateResults = null; + this.gatherCompletions(this.editor, function (err, results) { + var prefix = results.prefix; + var matches = results && results.matches; + if (!matches || !matches.length) + return detachIfFinished(results); + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + if (isImmediate) { + immediateResults = results; + return; + } + processResults(results); + }.bind(this)); + isImmediate = false; + if (immediateResults) { + var results = immediateResults; + immediateResults = null; + processResults(results); + } + }; + this.cancelContextMenu = function () { + this.editor.$mouseHandler.cancelContextMenu(); + }; + this.updateDocTooltip = function () { + var popup = this.popup; + var all = popup.data; + var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]); + var doc = null; + if (!selected || !this.editor || !this.popup.isOpen) + return this.hideDocTooltip(); + this.editor.completers.some(function (completer) { + if (completer.getDocTooltip) + doc = completer.getDocTooltip(selected); + return doc; + }); + if (!doc && typeof selected != "string") + doc = selected; + if (typeof doc == "string") + doc = { docText: doc }; + if (!doc || !(doc.docHTML || doc.docText)) + return this.hideDocTooltip(); + this.showDocTooltip(doc); + }; + this.showDocTooltip = function (item) { + if (!this.tooltipNode) { + this.tooltipNode = dom.createElement("div"); + this.tooltipNode.className = "ace_tooltip ace_doc-tooltip"; + this.tooltipNode.style.margin = 0; + this.tooltipNode.style.pointerEvents = "auto"; + this.tooltipNode.tabIndex = -1; + this.tooltipNode.onblur = this.blurListener.bind(this); + this.tooltipNode.onclick = this.onTooltipClick.bind(this); + } + var tooltipNode = this.tooltipNode; + if (item.docHTML) { + tooltipNode.innerHTML = item.docHTML; + } + else if (item.docText) { + tooltipNode.textContent = item.docText; + } + if (!tooltipNode.parentNode) + document.body.appendChild(tooltipNode); + var popup = this.popup; + var rect = popup.container.getBoundingClientRect(); + tooltipNode.style.top = popup.container.style.top; + tooltipNode.style.bottom = popup.container.style.bottom; + tooltipNode.style.display = "block"; + if (window.innerWidth - rect.right < 320) { + if (rect.left < 320) { + if (popup.isTopdown) { + tooltipNode.style.top = rect.bottom + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + else { + tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + } + else { + tooltipNode.style.right = window.innerWidth - rect.left + "px"; + tooltipNode.style.left = ""; + } + } + else { + tooltipNode.style.left = (rect.right + 1) + "px"; + tooltipNode.style.right = ""; + } + }; + this.hideDocTooltip = function () { + this.tooltipTimer.cancel(); + if (!this.tooltipNode) + return; + var el = this.tooltipNode; + if (!this.editor.isFocused() && document.activeElement == el) + this.editor.focus(); + this.tooltipNode = null; + if (el.parentNode) + el.parentNode.removeChild(el); + }; + this.onTooltipClick = function (e) { + var a = e.target; + while (a && a != this.tooltipNode) { + if (a.nodeName == "A" && a.href) { + a.rel = "noreferrer"; + a.target = "_blank"; + break; + } + a = a.parentNode; + } + }; + this.destroy = function () { + this.detach(); + if (this.popup) { + this.popup.destroy(); + var el = this.popup.container; + if (el && el.parentNode) + el.parentNode.removeChild(el); + } + if (this.editor && this.editor.completer == this) + this.editor.completer == null; + this.popup = null; + }; +}).call(Autocomplete.prototype); +Autocomplete.for = function (editor) { + if (editor.completer) { + return editor.completer; + } + if (config.get("sharedPopups")) { + if (!Autocomplete.$shared) + Autocomplete.$sharedInstance = new Autocomplete(); + editor.completer = Autocomplete.$sharedInstance; + } + else { + editor.completer = new Autocomplete(); + editor.once("destroy", function (e, editor) { + editor.completer.destroy(); + }); + } + return editor.completer; +}; +Autocomplete.startCommand = { + name: "startAutocomplete", + exec: function (editor, options) { + var completer = Autocomplete.for(editor); + completer.autoInsert = false; + completer.autoSelect = true; + completer.showPopup(editor, options); + completer.cancelContextMenu(); + }, + bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" +}; +var FilteredList = function (array, filterText) { + this.all = array; + this.filtered = array; + this.filterText = filterText || ""; + this.exactMatch = false; +}; +(function () { + this.setFilter = function (str) { + if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0) + var matches = this.filtered; + else + var matches = this.all; + this.filterText = str; + matches = this.filterCompletions(matches, this.filterText); + matches = matches.sort(function (a, b) { + return b.exactMatch - a.exactMatch || b.$score - a.$score + || (a.caption || a.value).localeCompare(b.caption || b.value); + }); + var prev = null; + matches = matches.filter(function (item) { + var caption = item.snippet || item.caption || item.value; + if (caption === prev) + return false; + prev = caption; + return true; + }); + this.filtered = matches; + }; + this.filterCompletions = function (items, needle) { + var results = []; + var upper = needle.toUpperCase(); + var lower = needle.toLowerCase(); + loop: for (var i = 0, item; item = items[i]; i++) { + var caption = item.caption || item.value || item.snippet; + if (!caption) + continue; + var lastIndex = -1; + var matchMask = 0; + var penalty = 0; + var index, distance; + if (this.exactMatch) { + if (needle !== caption.substr(0, needle.length)) + continue loop; + } + else { + var fullMatchIndex = caption.toLowerCase().indexOf(lower); + if (fullMatchIndex > -1) { + penalty = fullMatchIndex; + } + else { + for (var j = 0; j < needle.length; j++) { + var i1 = caption.indexOf(lower[j], lastIndex + 1); + var i2 = caption.indexOf(upper[j], lastIndex + 1); + index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2; + if (index < 0) + continue loop; + distance = index - lastIndex - 1; + if (distance > 0) { + if (lastIndex === -1) + penalty += 10; + penalty += distance; + matchMask = matchMask | (1 << j); + } + lastIndex = index; + } + } + } + item.matchMask = matchMask; + item.exactMatch = penalty ? 0 : 1; + item.$score = (item.score || 0) - penalty; + results.push(item); + } + return results; + }; +}).call(FilteredList.prototype); +exports.Autocomplete = Autocomplete; +exports.FilteredList = FilteredList; + +}); + +define("ace/autocomplete/text_completer",["require","exports","module","ace/range"], function(require, exports, module){var Range = require("../range").Range; +var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/; +function getWordIndex(doc, pos) { + var textBefore = doc.getTextRange(Range.fromPoints({ row: 0, column: 0 }, pos)); + return textBefore.split(splitRegex).length - 1; +} +function wordDistance(doc, pos) { + var prefixPos = getWordIndex(doc, pos); + var words = doc.getValue().split(splitRegex); + var wordScores = Object.create(null); + var currentWord = words[prefixPos]; + words.forEach(function (word, idx) { + if (!word || word === currentWord) + return; + var distance = Math.abs(prefixPos - idx); + var score = words.length - distance; + if (wordScores[word]) { + wordScores[word] = Math.max(score, wordScores[word]); + } + else { + wordScores[word] = score; + } + }); + return wordScores; +} +exports.getCompletions = function (editor, session, pos, prefix, callback) { + var wordScore = wordDistance(session, pos); + var wordList = Object.keys(wordScore); + callback(null, wordList.map(function (word) { + return { + caption: word, + value: word, + score: wordScore[word], + meta: "local" + }; + })); +}; + +}); + +define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/lib/lang","ace/autocomplete/util","ace/autocomplete/text_completer","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var snippetManager = require("../snippets").snippetManager; +var Autocomplete = require("../autocomplete").Autocomplete; +var config = require("../config"); +var lang = require("../lib/lang"); +var util = require("../autocomplete/util"); +var textCompleter = require("../autocomplete/text_completer"); +var keyWordCompleter = { + getCompletions: function (editor, session, pos, prefix, callback) { + if (session.$mode.completer) { + return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback); + } + var state = editor.session.getState(pos.row); + var completions = session.$mode.getCompletions(state, session, pos, prefix); + callback(null, completions); + } +}; +var transformSnippetTooltip = function (str) { + var record = {}; + return str.replace(/\${(\d+)(:(.*?))?}/g, function (_, p1, p2, p3) { + return (record[p1] = p3 || ''); + }).replace(/\$(\d+?)/g, function (_, p1) { + return record[p1]; + }); +}; +var snippetCompleter = { + getCompletions: function (editor, session, pos, prefix, callback) { + var scopes = []; + var token = session.getTokenAt(pos.row, pos.column); + if (token && token.type.match(/(tag-name|tag-open|tag-whitespace|attribute-name|attribute-value)\.xml$/)) + scopes.push('html-tag'); + else + scopes = snippetManager.getActiveScopes(editor); + var snippetMap = snippetManager.snippetMap; + var completions = []; + scopes.forEach(function (scope) { + var snippets = snippetMap[scope] || []; + for (var i = snippets.length; i--;) { + var s = snippets[i]; + var caption = s.name || s.tabTrigger; + if (!caption) + continue; + completions.push({ + caption: caption, + snippet: s.content, + meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet", + type: "snippet" + }); + } + }, this); + callback(null, completions); + }, + getDocTooltip: function (item) { + if (item.type == "snippet" && !item.docHTML) { + item.docHTML = [ + "", lang.escapeHTML(item.caption), "", "
", + lang.escapeHTML(transformSnippetTooltip(item.snippet)) + ].join(""); + } + } +}; +var completers = [snippetCompleter, textCompleter, keyWordCompleter]; +exports.setCompleters = function (val) { + completers.length = 0; + if (val) + completers.push.apply(completers, val); +}; +exports.addCompleter = function (completer) { + completers.push(completer); +}; +exports.textCompleter = textCompleter; +exports.keyWordCompleter = keyWordCompleter; +exports.snippetCompleter = snippetCompleter; +var expandSnippet = { + name: "expandSnippet", + exec: function (editor) { + return snippetManager.expandWithTab(editor); + }, + bindKey: "Tab" +}; +var onChangeMode = function (e, editor) { + loadSnippetsForMode(editor.session.$mode); +}; +var loadSnippetsForMode = function (mode) { + if (typeof mode == "string") + mode = config.$modes[mode]; + if (!mode) + return; + if (!snippetManager.files) + snippetManager.files = {}; + loadSnippetFile(mode.$id, mode.snippetFileId); + if (mode.modes) + mode.modes.forEach(loadSnippetsForMode); +}; +var loadSnippetFile = function (id, snippetFilePath) { + if (!snippetFilePath || !id || snippetManager.files[id]) + return; + snippetManager.files[id] = {}; + config.loadModule(snippetFilePath, function (m) { + if (!m) + return; + snippetManager.files[id] = m; + if (!m.snippets && m.snippetText) + m.snippets = snippetManager.parseSnippetFile(m.snippetText); + snippetManager.register(m.snippets || [], m.scope); + if (m.includeScopes) { + snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes; + m.includeScopes.forEach(function (x) { + loadSnippetsForMode("ace/mode/" + x); + }); + } + }); +}; +var doLiveAutocomplete = function (e) { + var editor = e.editor; + var hasCompleter = editor.completer && editor.completer.activated; + if (e.command.name === "backspace") { + if (hasCompleter && !util.getCompletionPrefix(editor)) + editor.completer.detach(); + } + else if (e.command.name === "insertstring") { + var prefix = util.getCompletionPrefix(editor); + if (prefix && !hasCompleter) { + var completer = Autocomplete.for(editor); + completer.autoInsert = false; + completer.showPopup(editor); + } + } +}; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableBasicAutocompletion: { + set: function (val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val) ? val : completers; + this.commands.addCommand(Autocomplete.startCommand); + } + else { + this.commands.removeCommand(Autocomplete.startCommand); + } + }, + value: false + }, + enableLiveAutocompletion: { + set: function (val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val) ? val : completers; + this.commands.on('afterExec', doLiveAutocomplete); + } + else { + this.commands.removeListener('afterExec', doLiveAutocomplete); + } + }, + value: false + }, + enableSnippets: { + set: function (val) { + if (val) { + this.commands.addCommand(expandSnippet); + this.on("changeMode", onChangeMode); + onChangeMode(null, this); + } + else { + this.commands.removeCommand(expandSnippet); + this.off("changeMode", onChangeMode); + } + }, + value: false + } +}); + +}); + (function() { + window.require(["ace/ext/language_tools"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-linking.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-linking.js new file mode 100644 index 0000000..09cd3e8 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-linking.js @@ -0,0 +1,57 @@ +define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableLinking: { + set: function (val) { + if (val) { + this.on("click", onClick); + this.on("mousemove", onMouseMove); + } + else { + this.off("click", onClick); + this.off("mousemove", onMouseMove); + } + }, + value: false + } +}); +exports.previousLinkingHover = false; +function onMouseMove(e) { + var editor = e.editor; + var ctrl = e.getAccelKey(); + if (ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + if (exports.previousLinkingHover && exports.previousLinkingHover != token) { + editor._emit("linkHoverOut"); + } + editor._emit("linkHover", { position: docPos, token: token }); + exports.previousLinkingHover = token; + } + else if (exports.previousLinkingHover) { + editor._emit("linkHoverOut"); + exports.previousLinkingHover = false; + } +} +function onClick(e) { + var ctrl = e.getAccelKey(); + var button = e.getButton(); + if (button == 0 && ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + editor._emit("linkClick", { position: docPos, token: token }); + } +} + +}); + (function() { + window.require(["ace/ext/linking"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-modelist.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-modelist.js new file mode 100644 index 0000000..b9c32d0 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-modelist.js @@ -0,0 +1,247 @@ +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + (function() { + window.require(["ace/ext/modelist"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-options.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-options.js new file mode 100644 index 0000000..7111140 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-options.js @@ -0,0 +1,732 @@ +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + +define("ace/ext/themelist",["require","exports","module"], function(require, exports, module){/** + * Generates a list of themes available when ace was built. + * @fileOverview Generates a list of themes available when ace was built. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ +"use strict"; +var themeData = [ + ["Chrome"], + ["Clouds"], + ["Crimson Editor"], + ["Dawn"], + ["Dreamweaver"], + ["Eclipse"], + ["GitHub"], + ["IPlastic"], + ["Solarized Light"], + ["TextMate"], + ["Tomorrow"], + ["XCode"], + ["Kuroir"], + ["KatzenMilch"], + ["SQL Server", "sqlserver", "light"], + ["Ambiance", "ambiance", "dark"], + ["Chaos", "chaos", "dark"], + ["Clouds Midnight", "clouds_midnight", "dark"], + ["Dracula", "", "dark"], + ["Cobalt", "cobalt", "dark"], + ["Gruvbox", "gruvbox", "dark"], + ["Green on Black", "gob", "dark"], + ["idle Fingers", "idle_fingers", "dark"], + ["krTheme", "kr_theme", "dark"], + ["Merbivore", "merbivore", "dark"], + ["Merbivore Soft", "merbivore_soft", "dark"], + ["Mono Industrial", "mono_industrial", "dark"], + ["Monokai", "monokai", "dark"], + ["Nord Dark", "nord_dark", "dark"], + ["One Dark", "one_dark", "dark"], + ["Pastel on dark", "pastel_on_dark", "dark"], + ["Solarized Dark", "solarized_dark", "dark"], + ["Terminal", "terminal", "dark"], + ["Tomorrow Night", "tomorrow_night", "dark"], + ["Tomorrow Night Blue", "tomorrow_night_blue", "dark"], + ["Tomorrow Night Bright", "tomorrow_night_bright", "dark"], + ["Tomorrow Night 80s", "tomorrow_night_eighties", "dark"], + ["Twilight", "twilight", "dark"], + ["Vibrant Ink", "vibrant_ink", "dark"] +]; +exports.themesByName = {}; +exports.themes = themeData.map(function (data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; +}); + +}); + +define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module){"use strict"; +require("./menu_tools/overlay_page"); +var dom = require("../lib/dom"); +var oop = require("../lib/oop"); +var config = require("../config"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; +var buildDom = dom.buildDom; +var modelist = require("./modelist"); +var themelist = require("./themelist"); +var themes = { Bright: [], Dark: [] }; +themelist.themes.forEach(function (x) { + themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme }); +}); +var modes = modelist.modes.map(function (x) { + return { caption: x.caption, value: x.mode }; +}); +var optionGroups = { + Main: { + Mode: { + path: "mode", + type: "select", + items: modes + }, + Theme: { + path: "theme", + type: "select", + items: themes + }, + "Keybinding": { + type: "buttonBar", + path: "keyboardHandler", + items: [ + { caption: "Ace", value: null }, + { caption: "Vim", value: "ace/keyboard/vim" }, + { caption: "Emacs", value: "ace/keyboard/emacs" }, + { caption: "Sublime", value: "ace/keyboard/sublime" }, + { caption: "VSCode", value: "ace/keyboard/vscode" } + ] + }, + "Font Size": { + path: "fontSize", + type: "number", + defaultValue: 12, + defaults: [ + { caption: "12px", value: 12 }, + { caption: "24px", value: 24 } + ] + }, + "Soft Wrap": { + type: "buttonBar", + path: "wrap", + items: [ + { caption: "Off", value: "off" }, + { caption: "View", value: "free" }, + { caption: "margin", value: "printMargin" }, + { caption: "40", value: "40" } + ] + }, + "Cursor Style": { + path: "cursorStyle", + items: [ + { caption: "Ace", value: "ace" }, + { caption: "Slim", value: "slim" }, + { caption: "Smooth", value: "smooth" }, + { caption: "Smooth And Slim", value: "smooth slim" }, + { caption: "Wide", value: "wide" } + ] + }, + "Folding": { + path: "foldStyle", + items: [ + { caption: "Manual", value: "manual" }, + { caption: "Mark begin", value: "markbegin" }, + { caption: "Mark begin and end", value: "markbeginend" } + ] + }, + "Soft Tabs": [{ + path: "useSoftTabs" + }, { + ariaLabel: "Tab Size", + path: "tabSize", + type: "number", + values: [2, 3, 4, 8, 16] + }], + "Overscroll": { + type: "buttonBar", + path: "scrollPastEnd", + items: [ + { caption: "None", value: 0 }, + { caption: "Half", value: 0.5 }, + { caption: "Full", value: 1 } + ] + } + }, + More: { + "Atomic soft tabs": { + path: "navigateWithinSoftTabs" + }, + "Enable Behaviours": { + path: "behavioursEnabled" + }, + "Wrap with quotes": { + path: "wrapBehavioursEnabled" + }, + "Enable Auto Indent": { + path: "enableAutoIndent" + }, + "Full Line Selection": { + type: "checkbox", + values: "text|line", + path: "selectionStyle" + }, + "Highlight Active Line": { + path: "highlightActiveLine" + }, + "Show Invisibles": { + path: "showInvisibles" + }, + "Show Indent Guides": { + path: "displayIndentGuides" + }, + "Highlight Indent Guides": { + path: "highlightIndentGuides" + }, + "Persistent HScrollbar": { + path: "hScrollBarAlwaysVisible" + }, + "Persistent VScrollbar": { + path: "vScrollBarAlwaysVisible" + }, + "Animate scrolling": { + path: "animatedScroll" + }, + "Show Gutter": { + path: "showGutter" + }, + "Show Line Numbers": { + path: "showLineNumbers" + }, + "Relative Line Numbers": { + path: "relativeLineNumbers" + }, + "Fixed Gutter Width": { + path: "fixedWidthGutter" + }, + "Show Print Margin": [{ + path: "showPrintMargin" + }, { + ariaLabel: "Print Margin", + type: "number", + path: "printMarginColumn" + }], + "Indented Soft Wrap": { + path: "indentedSoftWrap" + }, + "Highlight selected word": { + path: "highlightSelectedWord" + }, + "Fade Fold Widgets": { + path: "fadeFoldWidgets" + }, + "Use textarea for IME": { + path: "useTextareaForIME" + }, + "Merge Undo Deltas": { + path: "mergeUndoDeltas", + items: [ + { caption: "Always", value: "always" }, + { caption: "Never", value: "false" }, + { caption: "Timed", value: "true" } + ] + }, + "Elastic Tabstops": { + path: "useElasticTabstops" + }, + "Incremental Search": { + path: "useIncrementalSearch" + }, + "Read-only": { + path: "readOnly" + }, + "Copy without selection": { + path: "copyWithEmptySelection" + }, + "Live Autocompletion": { + path: "enableLiveAutocompletion" + }, + "Custom scrollbar": { + path: "customScrollbar" + } + } +}; +var OptionPanel = function (editor, element) { + this.editor = editor; + this.container = element || document.createElement("div"); + this.groups = []; + this.options = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.add = function (config) { + if (config.Main) + oop.mixin(optionGroups.Main, config.Main); + if (config.More) + oop.mixin(optionGroups.More, config.More); + }; + this.render = function () { + this.container.innerHTML = ""; + buildDom(["table", { role: "presentation", id: "controls" }, + this.renderOptionGroup(optionGroups.Main), + ["tr", null, ["td", { colspan: 2 }, + ["table", { role: "presentation", id: "more-controls" }, + this.renderOptionGroup(optionGroups.More) + ] + ]], + ["tr", null, ["td", { colspan: 2 }, "version " + config.version]] + ], this.container); + }; + this.renderOptionGroup = function (group) { + return Object.keys(group).map(function (key, i) { + var item = group[key]; + if (!item.position) + item.position = i / 10000; + if (!item.label) + item.label = key; + return item; + }).sort(function (a, b) { + return a.position - b.position; + }).map(function (item) { + return this.renderOption(item.label, item); + }, this); + }; + this.renderOptionControl = function (key, option) { + var self = this; + if (Array.isArray(option)) { + return option.map(function (x) { + return self.renderOptionControl(key, x); + }); + } + var control; + var value = self.getOption(option); + if (option.values && option.type != "checkbox") { + if (typeof option.values == "string") + option.values = option.values.split("|"); + option.items = option.values.map(function (v) { + return { value: v, name: v }; + }); + } + if (option.type == "buttonBar") { + control = ["div", { role: "group", "aria-labelledby": option.path + "-label" }, option.items.map(function (item) { + return ["button", { + value: item.value, + ace_selected_button: value == item.value, + 'aria-pressed': value == item.value, + onclick: function () { + self.setOption(option, item.value); + var nodes = this.parentNode.querySelectorAll("[ace_selected_button]"); + for (var i = 0; i < nodes.length; i++) { + nodes[i].removeAttribute("ace_selected_button"); + nodes[i].setAttribute("aria-pressed", false); + } + this.setAttribute("ace_selected_button", true); + this.setAttribute("aria-pressed", true); + } + }, item.desc || item.caption || item.name]; + })]; + } + else if (option.type == "number") { + control = ["input", { type: "number", value: value || option.defaultValue, style: "width:3em", oninput: function () { + self.setOption(option, parseInt(this.value)); + } }]; + if (option.ariaLabel) { + control[1]["aria-label"] = option.ariaLabel; + } + else { + control[1].id = key; + } + if (option.defaults) { + control = [control, option.defaults.map(function (item) { + return ["button", { onclick: function () { + var input = this.parentNode.firstChild; + input.value = item.value; + input.oninput(); + } }, item.caption]; + })]; + } + } + else if (option.items) { + var buildItems = function (items) { + return items.map(function (item) { + return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name]; + }); + }; + var items = Array.isArray(option.items) + ? buildItems(option.items) + : Object.keys(option.items).map(function (key) { + return ["optgroup", { "label": key }, buildItems(option.items[key])]; + }); + control = ["select", { id: key, value: value, onchange: function () { + self.setOption(option, this.value); + } }, items]; + } + else { + if (typeof option.values == "string") + option.values = option.values.split("|"); + if (option.values) + value = value == option.values[1]; + control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function () { + var value = this.checked; + if (option.values) + value = option.values[value ? 1 : 0]; + self.setOption(option, value); + } }]; + if (option.type == "checkedNumber") { + control = [control, []]; + } + } + return control; + }; + this.renderOption = function (key, option) { + if (option.path && !option.onchange && !this.editor.$options[option.path]) + return; + var path = Array.isArray(option) ? option[0].path : option.path; + this.options[path] = option; + var safeKey = "-" + path; + var safeId = path + "-label"; + var control = this.renderOptionControl(safeKey, option); + return ["tr", { class: "ace_optionsMenuEntry" }, ["td", + ["label", { for: safeKey, id: safeId }, key] + ], ["td", control]]; + }; + this.setOption = function (option, value) { + if (typeof option == "string") + option = this.options[option]; + if (value == "false") + value = false; + if (value == "true") + value = true; + if (value == "null") + value = null; + if (value == "undefined") + value = undefined; + if (typeof value == "string" && parseFloat(value).toString() == value) + value = parseFloat(value); + if (option.onchange) + option.onchange(value); + else if (option.path) + this.editor.setOption(option.path, value); + this._signal("setOption", { name: option.path, value: value }); + }; + this.getOption = function (option) { + if (option.getValue) + return option.getValue(); + return this.editor.getOption(option.path); + }; +}).call(OptionPanel.prototype); +exports.OptionPanel = OptionPanel; + +}); + (function() { + window.require(["ace/ext/options"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-prompt.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-prompt.js new file mode 100644 index 0000000..9643869 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-prompt.js @@ -0,0 +1,2517 @@ +define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var keys = require("../../lib/keys"); +module.exports.getEditorKeybordShortcuts = function (editor) { + var KEY_MODS = keys.KEY_MODS; + var keybindings = []; + var commandMap = {}; + editor.keyBinding.$handlers.forEach(function (handler) { + var ckb = handler.commandKeyBinding; + for (var i in ckb) { + var key = i.replace(/(^|-)\w/g, function (x) { return x.toUpperCase(); }); + var commands = ckb[i]; + if (!Array.isArray(commands)) + commands = [commands]; + commands.forEach(function (command) { + if (typeof command != "string") + command = command.name; + if (commandMap[command]) { + commandMap[command].key += "|" + key; + } + else { + commandMap[command] = { key: key, command: command }; + keybindings.push(commandMap[command]); + } + }); + } + }); + return keybindings; +}; + +}); + +define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"], function(require, exports, module){"use strict"; +var Renderer = require("../virtual_renderer").VirtualRenderer; +var Editor = require("../editor").Editor; +var Range = require("../range").Range; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); +var $singleLineEditor = function (el) { + var renderer = new Renderer(el); + renderer.$maxLines = 4; + var editor = new Editor(renderer); + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.renderer.setShowGutter(false); + editor.renderer.setHighlightGutterLine(false); + editor.$mouseHandler.$focusTimeout = 0; + editor.$highlightTagPending = true; + return editor; +}; +var AcePopup = function (parentNode) { + var el = dom.createElement("div"); + var popup = new $singleLineEditor(el); + if (parentNode) + parentNode.appendChild(el); + el.style.display = "none"; + popup.renderer.content.style.cursor = "default"; + popup.renderer.setStyle("ace_autocomplete"); + popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); + var noop = function () { }; + popup.focus = noop; + popup.$isFocused = true; + popup.renderer.$cursorLayer.restartTimer = noop; + popup.renderer.$cursorLayer.element.style.opacity = 0; + popup.renderer.$maxLines = 8; + popup.renderer.$keepTextAreaAtCursor = false; + popup.setHighlightActiveLine(false); + popup.session.highlight(""); + popup.session.$searchHighlight.clazz = "ace_highlight-marker"; + popup.on("mousedown", function (e) { + var pos = e.getDocumentPosition(); + popup.selection.moveToPosition(pos); + selectionMarker.start.row = selectionMarker.end.row = pos.row; + e.stop(); + }); + var lastMouseEvent; + var hoverMarker = new Range(-1, 0, -1, Infinity); + var selectionMarker = new Range(-1, 0, -1, Infinity); + selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine"); + popup.setSelectOnHover = function (val) { + if (!val) { + hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine"); + } + else if (hoverMarker.id) { + popup.session.removeMarker(hoverMarker.id); + hoverMarker.id = null; + } + }; + popup.setSelectOnHover(false); + popup.on("mousemove", function (e) { + if (!lastMouseEvent) { + lastMouseEvent = e; + return; + } + if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) { + return; + } + lastMouseEvent = e; + lastMouseEvent.scrollTop = popup.renderer.scrollTop; + var row = lastMouseEvent.getDocumentPosition().row; + if (hoverMarker.start.row != row) { + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row); + } + }); + popup.renderer.on("beforeRender", function () { + if (lastMouseEvent && hoverMarker.start.row != -1) { + lastMouseEvent.$pos = null; + var row = lastMouseEvent.getDocumentPosition().row; + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row, true); + } + }); + popup.renderer.on("afterRender", function () { + var row = popup.getRow(); + var t = popup.renderer.$textLayer; + var selected = t.element.childNodes[row - t.config.firstRow]; + if (selected !== t.selectedNode && t.selectedNode) + dom.removeCssClass(t.selectedNode, "ace_selected"); + t.selectedNode = selected; + if (selected) + dom.addCssClass(selected, "ace_selected"); + }); + var hideHoverMarker = function () { setHoverMarker(-1); }; + var setHoverMarker = function (row, suppressRedraw) { + if (row !== hoverMarker.start.row) { + hoverMarker.start.row = hoverMarker.end.row = row; + if (!suppressRedraw) + popup.session._emit("changeBackMarker"); + popup._emit("changeHoverMarker"); + } + }; + popup.getHoveredRow = function () { + return hoverMarker.start.row; + }; + event.addListener(popup.container, "mouseout", hideHoverMarker); + popup.on("hide", hideHoverMarker); + popup.on("changeSelection", hideHoverMarker); + popup.session.doc.getLength = function () { + return popup.data.length; + }; + popup.session.doc.getLine = function (i) { + var data = popup.data[i]; + if (typeof data == "string") + return data; + return (data && data.value) || ""; + }; + var bgTokenizer = popup.session.bgTokenizer; + bgTokenizer.$tokenizeRow = function (row) { + var data = popup.data[row]; + var tokens = []; + if (!data) + return tokens; + if (typeof data == "string") + data = { value: data }; + var caption = data.caption || data.value || data.name; + function addToken(value, className) { + value && tokens.push({ + type: (data.className || "") + (className || ""), + value: value + }); + } + var lower = caption.toLowerCase(); + var filterText = (popup.filterText || "").toLowerCase(); + var lastIndex = 0; + var lastI = 0; + for (var i = 0; i <= filterText.length; i++) { + if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) { + var sub = filterText.slice(lastI, i); + lastI = i; + var index = lower.indexOf(sub, lastIndex); + if (index == -1) + continue; + addToken(caption.slice(lastIndex, index), ""); + lastIndex = index + sub.length; + addToken(caption.slice(index, lastIndex), "completion-highlight"); + } + } + addToken(caption.slice(lastIndex, caption.length), ""); + if (data.meta) + tokens.push({ type: "completion-meta", value: data.meta }); + if (data.message) + tokens.push({ type: "completion-message", value: data.message }); + return tokens; + }; + bgTokenizer.$updateOnChange = noop; + bgTokenizer.start = noop; + popup.session.$computeWidth = function () { + return this.screenWidth = 0; + }; + popup.isOpen = false; + popup.isTopdown = false; + popup.autoSelect = true; + popup.filterText = ""; + popup.data = []; + popup.setData = function (list, filterText) { + popup.filterText = filterText || ""; + popup.setValue(lang.stringRepeat("\n", list.length), -1); + popup.data = list || []; + popup.setRow(0); + }; + popup.getData = function (row) { + return popup.data[row]; + }; + popup.getRow = function () { + return selectionMarker.start.row; + }; + popup.setRow = function (line) { + line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line)); + if (selectionMarker.start.row != line) { + popup.selection.clearSelection(); + selectionMarker.start.row = selectionMarker.end.row = line || 0; + popup.session._emit("changeBackMarker"); + popup.moveCursorTo(line || 0, 0); + if (popup.isOpen) + popup._signal("select"); + } + }; + popup.on("changeSelection", function () { + if (popup.isOpen) + popup.setRow(popup.selection.lead.row); + popup.renderer.scrollCursorIntoView(); + }); + popup.hide = function () { + this.container.style.display = "none"; + this._signal("hide"); + popup.isOpen = false; + }; + popup.show = function (pos, lineHeight, topdownOnly) { + var el = this.container; + var screenHeight = window.innerHeight; + var screenWidth = window.innerWidth; + var renderer = this.renderer; + var maxH = renderer.$maxLines * lineHeight * 1.4; + var top = pos.top + this.$borderSize; + var allowTopdown = top > screenHeight / 2 && !topdownOnly; + if (allowTopdown && top + lineHeight + maxH > screenHeight) { + renderer.$maxPixelHeight = top - 2 * this.$borderSize; + el.style.top = ""; + el.style.bottom = screenHeight - top + "px"; + popup.isTopdown = false; + } + else { + top += lineHeight; + renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight; + el.style.top = top + "px"; + el.style.bottom = ""; + popup.isTopdown = true; + } + el.style.display = ""; + var left = pos.left; + if (left + el.offsetWidth > screenWidth) + left = screenWidth - el.offsetWidth; + el.style.left = left + "px"; + this._signal("show"); + lastMouseEvent = null; + popup.isOpen = true; + }; + popup.goTo = function (where) { + var row = this.getRow(); + var max = this.session.getLength() - 1; + switch (where) { + case "up": + row = row <= 0 ? max : row - 1; + break; + case "down": + row = row >= max ? -1 : row + 1; + break; + case "start": + row = 0; + break; + case "end": + row = max; + break; + } + this.setRow(row); + }; + popup.getTextLeftOffset = function () { + return this.$borderSize + this.renderer.$padding + this.$imageSize; + }; + popup.$imageSize = 0; + popup.$borderSize = 1; + return popup; +}; +dom.importCssString("\n.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #CAD6FA;\n z-index: 1;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #3a674e;\n}\n.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid #abbffe;\n margin-top: -1px;\n background: rgba(233,233,253,0.4);\n position: absolute;\n z-index: 2;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid rgba(109, 150, 13, 0.8);\n background: rgba(58, 103, 78, 0.62);\n}\n.ace_completion-meta {\n opacity: 0.5;\n margin: 0.9em;\n}\n.ace_completion-message {\n color: blue;\n}\n.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #2d69c7;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #93ca12;\n}\n.ace_editor.ace_autocomplete {\n width: 300px;\n z-index: 200000;\n border: 1px lightgray solid;\n position: fixed;\n box-shadow: 2px 3px 5px rgba(0,0,0,.2);\n line-height: 1.4;\n background: #fefefe;\n color: #111;\n}\n.ace_dark.ace_editor.ace_autocomplete {\n border: 1px #484747 solid;\n box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\n line-height: 1.4;\n background: #25282c;\n color: #c1c1c1;\n}", "autocompletion.css", false); +exports.AcePopup = AcePopup; +exports.$singleLineEditor = $singleLineEditor; + +}); + +define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module){"use strict"; +exports.parForEach = function (array, fn, callback) { + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function (result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } +}; +var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/; +exports.retrievePrecedingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos - 1; i >= 0; i--) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf.reverse().join(""); +}; +exports.retrieveFollowingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf; +}; +exports.getCompletionPrefix = function (editor) { + var pos = editor.getCursorPosition(); + var line = editor.session.getLine(pos.row); + var prefix; + editor.completers.forEach(function (completer) { + if (completer.identifierRegexps) { + completer.identifierRegexps.forEach(function (identifierRegex) { + if (!prefix && identifierRegex) + prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex); + }.bind(this)); + } + }.bind(this)); + return prefix || this.retrievePrecedingIdentifier(line, pos.column); +}; + +}); + +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict"; +var dom = require("./lib/dom"); +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var lang = require("./lib/lang"); +var Range = require("./range").Range; +var RangeList = require("./range_list").RangeList; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var Tokenizer = require("./tokenizer").Tokenizer; +var clipboard = require("./clipboard"); +var VARIABLES = { + CURRENT_WORD: function (editor) { + return editor.session.getTextRange(editor.session.getWordRange()); + }, + SELECTION: function (editor, name, indentation) { + var text = editor.session.getTextRange(); + if (indentation) + return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1"); + return text; + }, + CURRENT_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row); + }, + PREV_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row - 1); + }, + LINE_INDEX: function (editor) { + return editor.getCursorPosition().row; + }, + LINE_NUMBER: function (editor) { + return editor.getCursorPosition().row + 1; + }, + SOFT_TABS: function (editor) { + return editor.session.getUseSoftTabs() ? "YES" : "NO"; + }, + TAB_SIZE: function (editor) { + return editor.session.getTabSize(); + }, + CLIPBOARD: function (editor) { + return clipboard.getText && clipboard.getText(); + }, + FILENAME: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0]; + }, + FILENAME_BASE: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, ""); + }, + DIRECTORY: function (editor) { + return this.FILEPATH(editor).replace(/[^/\\]*$/, ""); + }, + FILEPATH: function (editor) { return "/not implemented.txt"; }, + WORKSPACE_NAME: function () { return "Unknown"; }, + FULLNAME: function () { return "Unknown"; }, + BLOCK_COMMENT_START: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.start || ""; + }, + BLOCK_COMMENT_END: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.end || ""; + }, + LINE_COMMENT: function (editor) { + var mode = editor.session.$mode || {}; + return mode.lineCommentStart || ""; + }, + CURRENT_YEAR: date.bind(null, { year: "numeric" }), + CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }), + CURRENT_MONTH: date.bind(null, { month: "numeric" }), + CURRENT_MONTH_NAME: date.bind(null, { month: "long" }), + CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }), + CURRENT_DATE: date.bind(null, { day: "2-digit" }), + CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }), + CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }), + CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }), + CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }), + CURRENT_SECOND: date.bind(null, { second: "2-digit" }) +}; +VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION; +function date(dateFormat) { + var str = new Date().toLocaleString("en-us", dateFormat); + return str.length == 1 ? "0" + str : str; +} +var SnippetManager = function () { + this.snippetMap = {}; + this.snippetNameMap = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.getTokenizer = function () { + return SnippetManager.$tokenizer || this.createTokenizer(); + }; + this.createTokenizer = function () { + function TabstopToken(str) { + str = str.substr(1); + if (/^\d+$/.test(str)) + return [{ tabstopId: parseInt(str, 10) }]; + return [{ text: str }]; + } + function escape(ch) { + return "(?:[^\\\\" + ch + "]|\\\\.)"; + } + var formatMatcher = { + regex: "/(" + escape("/") + "+)/", + onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.fmtString = true; + ts.guard = val.slice(1, -1); + ts.flag = ""; + return ""; + }, + next: "formatString" + }; + SnippetManager.$tokenizer = new Tokenizer({ + start: [ + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) { + val = ch; + } + else if ("`$\\".indexOf(ch) != -1) { + val = ch; + } + return [val]; + } }, + { regex: /}/, onMatch: function (val, state, stack) { + return [stack.length ? stack.shift() : val]; + } }, + { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken }, + { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) { + var t = TabstopToken(str.substr(1)); + stack.unshift(t[0]); + return t; + }, next: "snippetVar" }, + { regex: /\n/, token: "newline", merge: false } + ], + snippetVar: [ + { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) { + var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) { + return operator.length == 2 ? operator[1] : "\x00"; + }).split("\x00").map(function (value) { + return { value: value }; + }); + stack[0].choices = choices; + return [choices[0]]; + }, next: "start" }, + formatMatcher, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" } + ], + formatString: [ + { regex: /:/, onMatch: function (val, state, stack) { + if (stack.length && stack[0].expectElse) { + stack[0].expectElse = false; + stack[0].ifEnd = { elseEnd: stack[0] }; + return [stack[0].ifEnd]; + } + return ":"; + } }, + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) + val = ch; + else if ("`$\\".indexOf(ch) != -1) + val = ch; + else if (ch == "n") + val = "\n"; + else if (ch == "t") + val = "\t"; + else if ("ulULE".indexOf(ch) != -1) + val = { changeCase: ch, local: ch > "a" }; + return [val]; + } }, + { regex: "/\\w*}", onMatch: function (val, state, stack) { + var next = stack.shift(); + if (next) + next.flag = val.slice(1, -1); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" }, + { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) { + return [{ text: val.slice(1) }]; + } }, + { regex: /\${\w+/, onMatch: function (val, state, stack) { + var token = { text: val.slice(2) }; + stack.unshift(token); + return [token]; + }, next: "formatStringVar" }, + { regex: /\n/, token: "newline", merge: false }, + { regex: /}/, onMatch: function (val, state, stack) { + var next = stack.shift(); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" } + ], + formatStringVar: [ + { regex: /:\/\w+}/, onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.formatFunction = val.slice(2, -1); + return [stack.shift()]; + }, next: "formatString" }, + formatMatcher, + { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) { + if (val[1] == "+") + stack[0].ifEnd = stack[0]; + if (val[1] == "?") + stack[0].expectElse = true; + }, next: "formatString" }, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" } + ] + }); + return SnippetManager.$tokenizer; + }; + this.tokenizeTmSnippet = function (str, startState) { + return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) { + return x.value || x; + }); + }; + this.getVariableValue = function (editor, name, indentation) { + if (/^\d+$/.test(name)) + return (this.variables.__ || {})[name] || ""; + if (/^[A-Z]\d+$/.test(name)) + return (this.variables[name[0] + "__"] || {})[name.substr(1)] || ""; + name = name.replace(/^TM_/, ""); + if (!this.variables.hasOwnProperty(name)) + return ""; + var value = this.variables[name]; + if (typeof value == "function") + value = this.variables[name](editor, name, indentation); + return value == null ? "" : value; + }; + this.variables = VARIABLES; + this.tmStrFormat = function (str, ch, editor) { + if (!ch.fmt) + return str; + var flag = ch.flag || ""; + var re = ch.guard; + re = new RegExp(re, flag.replace(/[^gim]/g, "")); + var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt; + var _self = this; + var formatted = str.replace(re, function () { + var oldArgs = _self.variables.__; + _self.variables.__ = [].slice.call(arguments); + var fmtParts = _self.resolveVariables(fmtTokens, editor); + var gChangeCase = "E"; + for (var i = 0; i < fmtParts.length; i++) { + var ch = fmtParts[i]; + if (typeof ch == "object") { + fmtParts[i] = ""; + if (ch.changeCase && ch.local) { + var next = fmtParts[i + 1]; + if (next && typeof next == "string") { + if (ch.changeCase == "u") + fmtParts[i] = next[0].toUpperCase(); + else + fmtParts[i] = next[0].toLowerCase(); + fmtParts[i + 1] = next.substr(1); + } + } + else if (ch.changeCase) { + gChangeCase = ch.changeCase; + } + } + else if (gChangeCase == "U") { + fmtParts[i] = ch.toUpperCase(); + } + else if (gChangeCase == "L") { + fmtParts[i] = ch.toLowerCase(); + } + } + _self.variables.__ = oldArgs; + return fmtParts.join(""); + }); + return formatted; + }; + this.tmFormatFunction = function (str, ch, editor) { + if (ch.formatFunction == "upcase") + return str.toUpperCase(); + if (ch.formatFunction == "downcase") + return str.toLowerCase(); + return str; + }; + this.resolveVariables = function (snippet, editor) { + var result = []; + var indentation = ""; + var afterNewLine = true; + for (var i = 0; i < snippet.length; i++) { + var ch = snippet[i]; + if (typeof ch == "string") { + result.push(ch); + if (ch == "\n") { + afterNewLine = true; + indentation = ""; + } + else if (afterNewLine) { + indentation = /^\t*/.exec(ch)[0]; + afterNewLine = /\S/.test(ch); + } + continue; + } + if (!ch) + continue; + afterNewLine = false; + if (ch.fmtString) { + var j = snippet.indexOf(ch, i + 1); + if (j == -1) + j = snippet.length; + ch.fmt = snippet.slice(i + 1, j); + i = j; + } + if (ch.text) { + var value = this.getVariableValue(editor, ch.text, indentation) + ""; + if (ch.fmtString) + value = this.tmStrFormat(value, ch, editor); + if (ch.formatFunction) + value = this.tmFormatFunction(value, ch, editor); + if (value && !ch.ifEnd) { + result.push(value); + gotoNext(ch); + } + else if (!value && ch.ifEnd) { + gotoNext(ch.ifEnd); + } + } + else if (ch.elseEnd) { + gotoNext(ch.elseEnd); + } + else if (ch.tabstopId != null) { + result.push(ch); + } + else if (ch.changeCase != null) { + result.push(ch); + } + } + function gotoNext(ch) { + var i1 = snippet.indexOf(ch, i + 1); + if (i1 != -1) + i = i1; + } + return result; + }; + this.insertSnippetForSelection = function (editor, snippetText) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var tabString = editor.session.getTabString(); + var indentString = line.match(/^\s*/)[0]; + if (cursor.column < indentString.length) + indentString = indentString.slice(0, cursor.column); + snippetText = snippetText.replace(/\r/g, ""); + var tokens = this.tokenizeTmSnippet(snippetText); + tokens = this.resolveVariables(tokens, editor); + tokens = tokens.map(function (x) { + if (x == "\n") + return x + indentString; + if (typeof x == "string") + return x.replace(/\t/g, tabString); + return x; + }); + var tabstops = []; + tokens.forEach(function (p, i) { + if (typeof p != "object") + return; + var id = p.tabstopId; + var ts = tabstops[id]; + if (!ts) { + ts = tabstops[id] = []; + ts.index = id; + ts.value = ""; + ts.parents = {}; + } + if (ts.indexOf(p) !== -1) + return; + if (p.choices && !ts.choices) + ts.choices = p.choices; + ts.push(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 === -1) + return; + var value = tokens.slice(i + 1, i1); + var isNested = value.some(function (t) { return typeof t === "object"; }); + if (isNested && !ts.value) { + ts.value = value; + } + else if (value.length && (!ts.value || typeof ts.value !== "string")) { + ts.value = value.join(""); + } + }); + tabstops.forEach(function (ts) { ts.length = 0; }); + var expanding = {}; + function copyValue(val) { + var copy = []; + for (var i = 0; i < val.length; i++) { + var p = val[i]; + if (typeof p == "object") { + if (expanding[p.tabstopId]) + continue; + var j = val.lastIndexOf(p, i - 1); + p = copy[j] || { tabstopId: p.tabstopId }; + } + copy[i] = p; + } + return copy; + } + for (var i = 0; i < tokens.length; i++) { + var p = tokens[i]; + if (typeof p != "object") + continue; + var id = p.tabstopId; + var ts = tabstops[id]; + var i1 = tokens.indexOf(p, i + 1); + if (expanding[id]) { + if (expanding[id] === p) { + delete expanding[id]; + Object.keys(expanding).forEach(function (parentId) { + ts.parents[parentId] = true; + }); + } + continue; + } + expanding[id] = p; + var value = ts.value; + if (typeof value !== "string") + value = copyValue(value); + else if (p.fmt) + value = this.tmStrFormat(value, p, editor); + tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p)); + if (ts.indexOf(p) === -1) + ts.push(p); + } + var row = 0, column = 0; + var text = ""; + tokens.forEach(function (t) { + if (typeof t === "string") { + var lines = t.split("\n"); + if (lines.length > 1) { + column = lines[lines.length - 1].length; + row += lines.length - 1; + } + else + column += t.length; + text += t; + } + else if (t) { + if (!t.start) + t.start = { row: row, column: column }; + else + t.end = { row: row, column: column }; + } + }); + var range = editor.getSelectionRange(); + var end = editor.session.replace(range, text); + var tabstopManager = new TabstopManager(editor); + var selectionId = editor.inVirtualSelectionMode && editor.selection.index; + tabstopManager.addTabstops(tabstops, range.start, end, selectionId); + }; + this.insertSnippet = function (editor, snippetText) { + var self = this; + if (editor.inVirtualSelectionMode) + return self.insertSnippetForSelection(editor, snippetText); + editor.forEachSelection(function () { + self.insertSnippetForSelection(editor, snippetText); + }, null, { keepOrder: true }); + if (editor.tabstopManager) + editor.tabstopManager.tabNext(); + }; + this.$getScope = function (editor) { + var scope = editor.session.$mode.$id || ""; + scope = scope.split("/").pop(); + if (scope === "html" || scope === "php") { + if (scope === "php" && !editor.session.$mode.inlinePhp) + scope = "html"; + var c = editor.getCursorPosition(); + var state = editor.session.getState(c.row); + if (typeof state === "object") { + state = state[0]; + } + if (state.substring) { + if (state.substring(0, 3) == "js-") + scope = "javascript"; + else if (state.substring(0, 4) == "css-") + scope = "css"; + else if (state.substring(0, 4) == "php-") + scope = "php"; + } + } + return scope; + }; + this.getActiveScopes = function (editor) { + var scope = this.$getScope(editor); + var scopes = [scope]; + var snippetMap = this.snippetMap; + if (snippetMap[scope] && snippetMap[scope].includeScopes) { + scopes.push.apply(scopes, snippetMap[scope].includeScopes); + } + scopes.push("_"); + return scopes; + }; + this.expandWithTab = function (editor, options) { + var self = this; + var result = editor.forEachSelection(function () { + return self.expandSnippetForSelection(editor, options); + }, null, { keepOrder: true }); + if (result && editor.tabstopManager) + editor.tabstopManager.tabNext(); + return result; + }; + this.expandSnippetForSelection = function (editor, options) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var before = line.substring(0, cursor.column); + var after = line.substr(cursor.column); + var snippetMap = this.snippetMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = this.findMatchingSnippet(snippets, before, after); + return !!snippet; + }, this); + if (!snippet) + return false; + if (options && options.dryRun) + return true; + editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length); + this.variables.M__ = snippet.matchBefore; + this.variables.T__ = snippet.matchAfter; + this.insertSnippetForSelection(editor, snippet.content); + this.variables.M__ = this.variables.T__ = null; + return true; + }; + this.findMatchingSnippet = function (snippetList, before, after) { + for (var i = snippetList.length; i--;) { + var s = snippetList[i]; + if (s.startRe && !s.startRe.test(before)) + continue; + if (s.endRe && !s.endRe.test(after)) + continue; + if (!s.startRe && !s.endRe) + continue; + s.matchBefore = s.startRe ? s.startRe.exec(before) : [""]; + s.matchAfter = s.endRe ? s.endRe.exec(after) : [""]; + s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : ""; + s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : ""; + return s; + } + }; + this.snippetMap = {}; + this.snippetNameMap = {}; + this.register = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + var self = this; + if (!snippets) + snippets = []; + function wrapRegexp(src) { + if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) + src = "(?:" + src + ")"; + return src || ""; + } + function guardedRegexp(re, guard, opening) { + re = wrapRegexp(re); + guard = wrapRegexp(guard); + if (opening) { + re = guard + re; + if (re && re[re.length - 1] != "$") + re = re + "$"; + } + else { + re = re + guard; + if (re && re[0] != "^") + re = "^" + re; + } + return new RegExp(re); + } + function addSnippet(s) { + if (!s.scope) + s.scope = scope || "_"; + scope = s.scope; + if (!snippetMap[scope]) { + snippetMap[scope] = []; + snippetNameMap[scope] = {}; + } + var map = snippetNameMap[scope]; + if (s.name) { + var old = map[s.name]; + if (old) + self.unregister(old); + map[s.name] = s; + } + snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { + if (!s.guard && /^\w/.test(s.tabTrigger)) + s.guard = "\\b"; + s.trigger = lang.escapeRegExp(s.tabTrigger); + } + if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard) + return; + s.startRe = guardedRegexp(s.trigger, s.guard, true); + s.triggerRe = new RegExp(s.trigger); + s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); + s.endTriggerRe = new RegExp(s.endTrigger); + } + if (Array.isArray(snippets)) { + snippets.forEach(addSnippet); + } + else { + Object.keys(snippets).forEach(function (key) { + addSnippet(snippets[key]); + }); + } + this._signal("registerSnippets", { scope: scope }); + }; + this.unregister = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + function removeSnippet(s) { + var nameMap = snippetNameMap[s.scope || scope]; + if (nameMap && nameMap[s.name]) { + delete nameMap[s.name]; + var map = snippetMap[s.scope || scope]; + var i = map && map.indexOf(s); + if (i >= 0) + map.splice(i, 1); + } + } + if (snippets.content) + removeSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(removeSnippet); + }; + this.parseSnippetFile = function (str) { + str = str.replace(/\r/g, ""); + var list = [], snippet = {}; + var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm; + var m; + while (m = re.exec(str)) { + if (m[1]) { + try { + snippet = JSON.parse(m[1]); + list.push(snippet); + } + catch (e) { } + } + if (m[4]) { + snippet.content = m[4].replace(/^\t/gm, ""); + list.push(snippet); + snippet = {}; + } + else { + var key = m[2], val = m[3]; + if (key == "regex") { + var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g; + snippet.guard = guardRe.exec(val)[1]; + snippet.trigger = guardRe.exec(val)[1]; + snippet.endTrigger = guardRe.exec(val)[1]; + snippet.endGuard = guardRe.exec(val)[1]; + } + else if (key == "snippet") { + snippet.tabTrigger = val.match(/^\S*/)[0]; + if (!snippet.name) + snippet.name = val; + } + else if (key) { + snippet[key] = val; + } + } + } + return list; + }; + this.getSnippetByName = function (name, editor) { + var snippetMap = this.snippetNameMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = snippets[name]; + return !!snippet; + }, this); + return snippet; + }; +}).call(SnippetManager.prototype); +var TabstopManager = function (editor) { + if (editor.tabstopManager) + return editor.tabstopManager; + editor.tabstopManager = this; + this.$onChange = this.onChange.bind(this); + this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule; + this.$onChangeSession = this.onChangeSession.bind(this); + this.$onAfterExec = this.onAfterExec.bind(this); + this.attach(editor); +}; +(function () { + this.attach = function (editor) { + this.index = 0; + this.ranges = []; + this.tabstops = []; + this.$openTabstops = null; + this.selectedTabstop = null; + this.editor = editor; + this.editor.on("change", this.$onChange); + this.editor.on("changeSelection", this.$onChangeSelection); + this.editor.on("changeSession", this.$onChangeSession); + this.editor.commands.on("afterExec", this.$onAfterExec); + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.detach = function () { + this.tabstops.forEach(this.removeTabstopMarkers, this); + this.ranges = null; + this.tabstops = null; + this.selectedTabstop = null; + this.editor.removeListener("change", this.$onChange); + this.editor.removeListener("changeSelection", this.$onChangeSelection); + this.editor.removeListener("changeSession", this.$onChangeSession); + this.editor.commands.removeListener("afterExec", this.$onAfterExec); + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.tabstopManager = null; + this.editor = null; + }; + this.onChange = function (delta) { + var isRemove = delta.action[0] == "r"; + var selectedTabstop = this.selectedTabstop || {}; + var parents = selectedTabstop.parents || {}; + var tabstops = (this.tabstops || []).slice(); + for (var i = 0; i < tabstops.length; i++) { + var ts = tabstops[i]; + var active = ts == selectedTabstop || parents[ts.index]; + ts.rangeList.$bias = active ? 0 : 1; + if (delta.action == "remove" && ts !== selectedTabstop) { + var parentActive = ts.parents && ts.parents[selectedTabstop.index]; + var startIndex = ts.rangeList.pointIndex(delta.start, parentActive); + startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1; + var endIndex = ts.rangeList.pointIndex(delta.end, parentActive); + endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1; + var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex); + for (var j = 0; j < toRemove.length; j++) + this.removeRange(toRemove[j]); + } + ts.rangeList.$onChange(delta); + } + var session = this.editor.session; + if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue()) + this.detach(); + }; + this.updateLinkedFields = function () { + var ts = this.selectedTabstop; + if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked) + return; + this.$inChange = true; + var session = this.editor.session; + var text = session.getTextRange(ts.firstNonLinked); + for (var i = 0; i < ts.length; i++) { + var range = ts[i]; + if (!range.linked) + continue; + var original = range.original; + var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor); + session.replace(range, fmt); + } + this.$inChange = false; + }; + this.onAfterExec = function (e) { + if (e.command && !e.command.readOnly) + this.updateLinkedFields(); + }; + this.onChangeSelection = function () { + if (!this.editor) + return; + var lead = this.editor.selection.lead; + var anchor = this.editor.selection.anchor; + var isEmpty = this.editor.selection.isEmpty(); + for (var i = 0; i < this.ranges.length; i++) { + if (this.ranges[i].linked) + continue; + var containsLead = this.ranges[i].contains(lead.row, lead.column); + var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column); + if (containsLead && containsAnchor) + return; + } + this.detach(); + }; + this.onChangeSession = function () { + this.detach(); + }; + this.tabNext = function (dir) { + var max = this.tabstops.length; + var index = this.index + (dir || 1); + index = Math.min(Math.max(index, 1), max); + if (index == max) + index = 0; + this.selectTabstop(index); + if (index === 0) + this.detach(); + }; + this.selectTabstop = function (index) { + this.$openTabstops = null; + var ts = this.tabstops[this.index]; + if (ts) + this.addTabstopMarkers(ts); + this.index = index; + ts = this.tabstops[this.index]; + if (!ts || !ts.length) + return; + this.selectedTabstop = ts; + var range = ts.firstNonLinked || ts; + if (ts.choices) + range.cursor = range.start; + if (!this.editor.inVirtualSelectionMode) { + var sel = this.editor.multiSelect; + sel.toSingleRange(range); + for (var i = 0; i < ts.length; i++) { + if (ts.hasLinkedRanges && ts[i].linked) + continue; + sel.addRange(ts[i].clone(), true); + } + } + else { + this.editor.selection.fromOrientedRange(range); + } + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + if (this.selectedTabstop && this.selectedTabstop.choices) + this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices }); + }; + this.addTabstops = function (tabstops, start, end) { + var useLink = this.useLink || !this.editor.getOption("enableMultiselect"); + if (!this.$openTabstops) + this.$openTabstops = []; + if (!tabstops[0]) { + var p = Range.fromPoints(end, end); + moveRelative(p.start, start); + moveRelative(p.end, start); + tabstops[0] = [p]; + tabstops[0].index = 0; + } + var i = this.index; + var arg = [i + 1, 0]; + var ranges = this.ranges; + tabstops.forEach(function (ts, index) { + var dest = this.$openTabstops[index] || ts; + for (var i = 0; i < ts.length; i++) { + var p = ts[i]; + var range = Range.fromPoints(p.start, p.end || p.start); + movePoint(range.start, start); + movePoint(range.end, start); + range.original = p; + range.tabstop = dest; + ranges.push(range); + if (dest != ts) + dest.unshift(range); + else + dest[i] = range; + if (p.fmtString || (dest.firstNonLinked && useLink)) { + range.linked = true; + dest.hasLinkedRanges = true; + } + else if (!dest.firstNonLinked) + dest.firstNonLinked = range; + } + if (!dest.firstNonLinked) + dest.hasLinkedRanges = false; + if (dest === ts) { + arg.push(dest); + this.$openTabstops[index] = dest; + } + this.addTabstopMarkers(dest); + dest.rangeList = dest.rangeList || new RangeList(); + dest.rangeList.$bias = 0; + dest.rangeList.addList(dest); + }, this); + if (arg.length > 2) { + if (this.tabstops.length) + arg.push(arg.splice(2, 1)[0]); + this.tabstops.splice.apply(this.tabstops, arg); + } + }; + this.addTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + if (!range.markerId) + range.markerId = session.addMarker(range, "ace_snippet-marker", "text"); + }); + }; + this.removeTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + session.removeMarker(range.markerId); + range.markerId = null; + }); + }; + this.removeRange = function (range) { + var i = range.tabstop.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + i = this.ranges.indexOf(range); + if (i != -1) + this.ranges.splice(i, 1); + i = range.tabstop.rangeList.ranges.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + this.editor.session.removeMarker(range.markerId); + if (!range.tabstop.length) { + i = this.tabstops.indexOf(range.tabstop); + if (i != -1) + this.tabstops.splice(i, 1); + if (!this.tabstops.length) + this.detach(); + } + }; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys({ + "Tab": function (editor) { + if (exports.snippetManager && exports.snippetManager.expandWithTab(editor)) + return; + editor.tabstopManager.tabNext(1); + editor.renderer.scrollCursorIntoView(); + }, + "Shift-Tab": function (editor) { + editor.tabstopManager.tabNext(-1); + editor.renderer.scrollCursorIntoView(); + }, + "Esc": function (editor) { + editor.tabstopManager.detach(); + } + }); +}).call(TabstopManager.prototype); +var movePoint = function (point, diff) { + if (point.row == 0) + point.column += diff.column; + point.row += diff.row; +}; +var moveRelative = function (point, start) { + if (point.row == start.row) + point.column -= start.column; + point.row -= start.row; +}; +dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false); +exports.snippetManager = new SnippetManager(); +var Editor = require("./editor").Editor; +(function () { + this.insertSnippet = function (content, options) { + return exports.snippetManager.insertSnippet(this, content, options); + }; + this.expandSnippet = function (options) { + return exports.snippetManager.expandWithTab(this, options); + }; +}).call(Editor.prototype); + +}); + +define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config"], function(require, exports, module){"use strict"; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var AcePopup = require("./autocomplete/popup").AcePopup; +var util = require("./autocomplete/util"); +var lang = require("./lib/lang"); +var dom = require("./lib/dom"); +var snippetManager = require("./snippets").snippetManager; +var config = require("./config"); +var Autocomplete = function () { + this.autoInsert = false; + this.autoSelect = true; + this.exactMatch = false; + this.gatherCompletionsId = 0; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys(this.commands); + this.blurListener = this.blurListener.bind(this); + this.changeListener = this.changeListener.bind(this); + this.mousedownListener = this.mousedownListener.bind(this); + this.mousewheelListener = this.mousewheelListener.bind(this); + this.changeTimer = lang.delayedCall(function () { + this.updateCompletions(true); + }.bind(this)); + this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50); +}; +(function () { + this.$init = function () { + this.popup = new AcePopup(document.body || document.documentElement); + this.popup.on("click", function (e) { + this.insertMatch(); + e.stop(); + }.bind(this)); + this.popup.focus = this.editor.focus.bind(this.editor); + this.popup.on("show", this.tooltipTimer.bind(null, null)); + this.popup.on("select", this.tooltipTimer.bind(null, null)); + this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null)); + return this.popup; + }; + this.getPopup = function () { + return this.popup || this.$init(); + }; + this.openPopup = function (editor, prefix, keepPopupPosition) { + if (!this.popup) + this.$init(); + this.popup.autoSelect = this.autoSelect; + this.popup.setData(this.completions.filtered, this.completions.filterText); + editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + var renderer = editor.renderer; + this.popup.setRow(this.autoSelect ? 0 : -1); + if (!keepPopupPosition) { + this.popup.setTheme(editor.getTheme()); + this.popup.setFontSize(editor.getFontSize()); + var lineHeight = renderer.layerConfig.lineHeight; + var pos = renderer.$cursorLayer.getPixelPosition(this.base, true); + pos.left -= this.popup.getTextLeftOffset(); + var rect = editor.container.getBoundingClientRect(); + pos.top += rect.top - renderer.layerConfig.offset; + pos.left += rect.left - editor.renderer.scrollLeft; + pos.left += renderer.gutterWidth; + this.popup.show(pos, lineHeight); + } + else if (keepPopupPosition && !prefix) { + this.detach(); + } + this.changeTimer.cancel(); + }; + this.detach = function () { + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.off("changeSelection", this.changeListener); + this.editor.off("blur", this.blurListener); + this.editor.off("mousedown", this.mousedownListener); + this.editor.off("mousewheel", this.mousewheelListener); + this.changeTimer.cancel(); + this.hideDocTooltip(); + this.gatherCompletionsId += 1; + if (this.popup && this.popup.isOpen) + this.popup.hide(); + if (this.base) + this.base.detach(); + this.activated = false; + this.completions = this.base = null; + }; + this.changeListener = function (e) { + var cursor = this.editor.selection.lead; + if (cursor.row != this.base.row || cursor.column < this.base.column) { + this.detach(); + } + if (this.activated) + this.changeTimer.schedule(); + else + this.detach(); + }; + this.blurListener = function (e) { + var el = document.activeElement; + var text = this.editor.textInput.getElement(); + var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget); + var container = this.popup && this.popup.container; + if (el != text && el.parentNode != container && !fromTooltip + && el != this.tooltipNode && e.relatedTarget != text) { + this.detach(); + } + }; + this.mousedownListener = function (e) { + this.detach(); + }; + this.mousewheelListener = function (e) { + this.detach(); + }; + this.goTo = function (where) { + this.popup.goTo(where); + }; + this.insertMatch = function (data, options) { + if (!data) + data = this.popup.getData(this.popup.getRow()); + if (!data) + return false; + var completions = this.completions; + this.editor.startOperation({ command: { name: "insertMatch" } }); + if (data.completer && data.completer.insertMatch) { + data.completer.insertMatch(this.editor, data); + } + else { + if (!completions) + return false; + if (completions.filterText) { + var ranges = this.editor.selection.getAllRanges(); + for (var i = 0, range; range = ranges[i]; i++) { + range.start.column -= completions.filterText.length; + this.editor.session.remove(range); + } + } + if (data.snippet) + snippetManager.insertSnippet(this.editor, data.snippet); + else + this.editor.execCommand("insertstring", data.value || data); + } + if (this.completions == completions) + this.detach(); + this.editor.endOperation(); + }; + this.commands = { + "Up": function (editor) { editor.completer.goTo("up"); }, + "Down": function (editor) { editor.completer.goTo("down"); }, + "Ctrl-Up|Ctrl-Home": function (editor) { editor.completer.goTo("start"); }, + "Ctrl-Down|Ctrl-End": function (editor) { editor.completer.goTo("end"); }, + "Esc": function (editor) { editor.completer.detach(); }, + "Return": function (editor) { return editor.completer.insertMatch(); }, + "Shift-Return": function (editor) { editor.completer.insertMatch(null, { deleteSuffix: true }); }, + "Tab": function (editor) { + var result = editor.completer.insertMatch(); + if (!result && !editor.tabstopManager) + editor.completer.goTo("down"); + else + return result; + }, + "PageUp": function (editor) { editor.completer.popup.gotoPageUp(); }, + "PageDown": function (editor) { editor.completer.popup.gotoPageDown(); } + }; + this.gatherCompletions = function (editor, callback) { + var session = editor.getSession(); + var pos = editor.getCursorPosition(); + var prefix = util.getCompletionPrefix(editor); + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); + this.base.$insertRight = true; + var matches = []; + var total = editor.completers.length; + editor.completers.forEach(function (completer, i) { + completer.getCompletions(editor, session, pos, prefix, function (err, results) { + if (!err && results) + matches = matches.concat(results); + callback(null, { + prefix: util.getCompletionPrefix(editor), + matches: matches, + finished: (--total === 0) + }); + }); + }); + return true; + }; + this.showPopup = function (editor, options) { + if (this.editor) + this.detach(); + this.activated = true; + this.editor = editor; + if (editor.completer != this) { + if (editor.completer) + editor.completer.detach(); + editor.completer = this; + } + editor.on("changeSelection", this.changeListener); + editor.on("blur", this.blurListener); + editor.on("mousedown", this.mousedownListener); + editor.on("mousewheel", this.mousewheelListener); + this.updateCompletions(false, options); + }; + this.updateCompletions = function (keepPopupPosition, options) { + if (keepPopupPosition && this.base && this.completions) { + var pos = this.editor.getCursorPosition(); + var prefix = this.editor.session.getTextRange({ start: this.base, end: pos }); + if (prefix == this.completions.filterText) + return; + this.completions.setFilter(prefix); + if (!this.completions.filtered.length) + return this.detach(); + if (this.completions.filtered.length == 1 + && this.completions.filtered[0].value == prefix + && !this.completions.filtered[0].snippet) + return this.detach(); + this.openPopup(this.editor, prefix, keepPopupPosition); + return; + } + if (options && options.matches) { + var pos = this.editor.getSelectionRange().start; + this.base = this.editor.session.doc.createAnchor(pos.row, pos.column); + this.base.$insertRight = true; + this.completions = new FilteredList(options.matches); + return this.openPopup(this.editor, "", keepPopupPosition); + } + var _id = this.gatherCompletionsId; + var detachIfFinished = function (results) { + if (!results.finished) + return; + return this.detach(); + }.bind(this); + var processResults = function (results) { + var prefix = results.prefix; + var matches = results.matches; + this.completions = new FilteredList(matches); + if (this.exactMatch) + this.completions.exactMatch = true; + this.completions.setFilter(prefix); + var filtered = this.completions.filtered; + if (!filtered.length) + return detachIfFinished(results); + if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) + return detachIfFinished(results); + if (this.autoInsert && filtered.length == 1 && results.finished) + return this.insertMatch(filtered[0]); + this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this); + var isImmediate = true; + var immediateResults = null; + this.gatherCompletions(this.editor, function (err, results) { + var prefix = results.prefix; + var matches = results && results.matches; + if (!matches || !matches.length) + return detachIfFinished(results); + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + if (isImmediate) { + immediateResults = results; + return; + } + processResults(results); + }.bind(this)); + isImmediate = false; + if (immediateResults) { + var results = immediateResults; + immediateResults = null; + processResults(results); + } + }; + this.cancelContextMenu = function () { + this.editor.$mouseHandler.cancelContextMenu(); + }; + this.updateDocTooltip = function () { + var popup = this.popup; + var all = popup.data; + var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]); + var doc = null; + if (!selected || !this.editor || !this.popup.isOpen) + return this.hideDocTooltip(); + this.editor.completers.some(function (completer) { + if (completer.getDocTooltip) + doc = completer.getDocTooltip(selected); + return doc; + }); + if (!doc && typeof selected != "string") + doc = selected; + if (typeof doc == "string") + doc = { docText: doc }; + if (!doc || !(doc.docHTML || doc.docText)) + return this.hideDocTooltip(); + this.showDocTooltip(doc); + }; + this.showDocTooltip = function (item) { + if (!this.tooltipNode) { + this.tooltipNode = dom.createElement("div"); + this.tooltipNode.className = "ace_tooltip ace_doc-tooltip"; + this.tooltipNode.style.margin = 0; + this.tooltipNode.style.pointerEvents = "auto"; + this.tooltipNode.tabIndex = -1; + this.tooltipNode.onblur = this.blurListener.bind(this); + this.tooltipNode.onclick = this.onTooltipClick.bind(this); + } + var tooltipNode = this.tooltipNode; + if (item.docHTML) { + tooltipNode.innerHTML = item.docHTML; + } + else if (item.docText) { + tooltipNode.textContent = item.docText; + } + if (!tooltipNode.parentNode) + document.body.appendChild(tooltipNode); + var popup = this.popup; + var rect = popup.container.getBoundingClientRect(); + tooltipNode.style.top = popup.container.style.top; + tooltipNode.style.bottom = popup.container.style.bottom; + tooltipNode.style.display = "block"; + if (window.innerWidth - rect.right < 320) { + if (rect.left < 320) { + if (popup.isTopdown) { + tooltipNode.style.top = rect.bottom + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + else { + tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + } + else { + tooltipNode.style.right = window.innerWidth - rect.left + "px"; + tooltipNode.style.left = ""; + } + } + else { + tooltipNode.style.left = (rect.right + 1) + "px"; + tooltipNode.style.right = ""; + } + }; + this.hideDocTooltip = function () { + this.tooltipTimer.cancel(); + if (!this.tooltipNode) + return; + var el = this.tooltipNode; + if (!this.editor.isFocused() && document.activeElement == el) + this.editor.focus(); + this.tooltipNode = null; + if (el.parentNode) + el.parentNode.removeChild(el); + }; + this.onTooltipClick = function (e) { + var a = e.target; + while (a && a != this.tooltipNode) { + if (a.nodeName == "A" && a.href) { + a.rel = "noreferrer"; + a.target = "_blank"; + break; + } + a = a.parentNode; + } + }; + this.destroy = function () { + this.detach(); + if (this.popup) { + this.popup.destroy(); + var el = this.popup.container; + if (el && el.parentNode) + el.parentNode.removeChild(el); + } + if (this.editor && this.editor.completer == this) + this.editor.completer == null; + this.popup = null; + }; +}).call(Autocomplete.prototype); +Autocomplete.for = function (editor) { + if (editor.completer) { + return editor.completer; + } + if (config.get("sharedPopups")) { + if (!Autocomplete.$shared) + Autocomplete.$sharedInstance = new Autocomplete(); + editor.completer = Autocomplete.$sharedInstance; + } + else { + editor.completer = new Autocomplete(); + editor.once("destroy", function (e, editor) { + editor.completer.destroy(); + }); + } + return editor.completer; +}; +Autocomplete.startCommand = { + name: "startAutocomplete", + exec: function (editor, options) { + var completer = Autocomplete.for(editor); + completer.autoInsert = false; + completer.autoSelect = true; + completer.showPopup(editor, options); + completer.cancelContextMenu(); + }, + bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" +}; +var FilteredList = function (array, filterText) { + this.all = array; + this.filtered = array; + this.filterText = filterText || ""; + this.exactMatch = false; +}; +(function () { + this.setFilter = function (str) { + if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0) + var matches = this.filtered; + else + var matches = this.all; + this.filterText = str; + matches = this.filterCompletions(matches, this.filterText); + matches = matches.sort(function (a, b) { + return b.exactMatch - a.exactMatch || b.$score - a.$score + || (a.caption || a.value).localeCompare(b.caption || b.value); + }); + var prev = null; + matches = matches.filter(function (item) { + var caption = item.snippet || item.caption || item.value; + if (caption === prev) + return false; + prev = caption; + return true; + }); + this.filtered = matches; + }; + this.filterCompletions = function (items, needle) { + var results = []; + var upper = needle.toUpperCase(); + var lower = needle.toLowerCase(); + loop: for (var i = 0, item; item = items[i]; i++) { + var caption = item.caption || item.value || item.snippet; + if (!caption) + continue; + var lastIndex = -1; + var matchMask = 0; + var penalty = 0; + var index, distance; + if (this.exactMatch) { + if (needle !== caption.substr(0, needle.length)) + continue loop; + } + else { + var fullMatchIndex = caption.toLowerCase().indexOf(lower); + if (fullMatchIndex > -1) { + penalty = fullMatchIndex; + } + else { + for (var j = 0; j < needle.length; j++) { + var i1 = caption.indexOf(lower[j], lastIndex + 1); + var i2 = caption.indexOf(upper[j], lastIndex + 1); + index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2; + if (index < 0) + continue loop; + distance = index - lastIndex - 1; + if (distance > 0) { + if (lastIndex === -1) + penalty += 10; + penalty += distance; + matchMask = matchMask | (1 << j); + } + lastIndex = index; + } + } + } + item.matchMask = matchMask; + item.exactMatch = penalty ? 0 : 1; + item.$score = (item.score || 0) - penalty; + results.push(item); + } + return results; + }; +}).call(FilteredList.prototype); +exports.Autocomplete = Autocomplete; +exports.FilteredList = FilteredList; + +}); + +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + +define("ace/ext/prompt",["require","exports","module","ace/range","ace/lib/dom","ace/ext/menu_tools/get_editor_keyboard_shortcuts","ace/autocomplete","ace/autocomplete/popup","ace/autocomplete/popup","ace/undomanager","ace/tokenizer","ace/ext/menu_tools/overlay_page","ace/ext/modelist"], function(require, exports, module){/** + * Prompt plugin is used for getting input from user. + * + * @param {Object} editor Ouside editor related to this prompt. Will be blurred when prompt is open. + * @param {String} message Predefined value of prompt input box. + * @param {Object} options Cusomizable options for this prompt. + * @param {String} options.name Prompt name. + * @param {String} options.$type Use prompt of specific type (gotoLine|commands|modes or default if empty). + * @param {[start, end]} options.selection Defines which part of the predefined value should be highlited. + * @param {Boolean} options.hasDescription Set to true if prompt has description below input box. + * @param {String} options.prompt Description below input box. + * @param {String} options.placeholder Placeholder for value. + * @param {Object} options.$rules Specific rules for input like password or regexp. + * @param {Boolean} options.ignoreFocusOut Set to true to keep the prompt open when focus moves to another part of the editor. + * @param {Function} options.getCompletions Function for defining list of options for value. + * @param {Function} options.getPrefix Function for defining current value prefix. + * @param {Function} options.onAccept Function called when Enter is pressed. + * @param {Function} options.onInput Function called when input is added to prompt input box. + * @param {Function} options.onCancel Function called when Esc|Shift-Esc is pressed. + * @param {Function} callback Function called after done. + * */ +"use strict"; +var Range = require("../range").Range; +var dom = require("../lib/dom"); +var shortcuts = require("../ext/menu_tools/get_editor_keyboard_shortcuts"); +var FilteredList = require("../autocomplete").FilteredList; +var AcePopup = require('../autocomplete/popup').AcePopup; +var $singleLineEditor = require('../autocomplete/popup').$singleLineEditor; +var UndoManager = require("../undomanager").UndoManager; +var Tokenizer = require("../tokenizer").Tokenizer; +var overlayPage = require("./menu_tools/overlay_page").overlayPage; +var modelist = require("./modelist"); +var openPrompt; +function prompt(editor, message, options, callback) { + if (typeof message == "object") { + return prompt(editor, "", message, options); + } + if (openPrompt) { + var lastPrompt = openPrompt; + editor = lastPrompt.editor; + lastPrompt.close(); + if (lastPrompt.name && lastPrompt.name == options.name) + return; + } + if (options.$type) + return prompt[options.$type](editor, callback); + var cmdLine = $singleLineEditor(); + cmdLine.session.setUndoManager(new UndoManager()); + var el = dom.buildDom(["div", { class: "ace_prompt_container" + (options.hasDescription ? " input-box-with-description" : "") }]); + var overlay = overlayPage(editor, el, done); + el.appendChild(cmdLine.container); + if (editor) { + editor.cmdLine = cmdLine; + cmdLine.setOption("fontSize", editor.getOption("fontSize")); + } + if (message) { + cmdLine.setValue(message, 1); + } + if (options.selection) { + cmdLine.selection.setRange({ + start: cmdLine.session.doc.indexToPosition(options.selection[0]), + end: cmdLine.session.doc.indexToPosition(options.selection[1]) + }); + } + if (options.getCompletions) { + var popup = new AcePopup(); + popup.renderer.setStyle("ace_autocomplete_inline"); + popup.container.style.display = "block"; + popup.container.style.maxWidth = "600px"; + popup.container.style.width = "100%"; + popup.container.style.marginTop = "3px"; + popup.renderer.setScrollMargin(2, 2, 0, 0); + popup.autoSelect = false; + popup.renderer.$maxLines = 15; + popup.setRow(-1); + popup.on("click", function (e) { + var data = popup.getData(popup.getRow()); + if (!data.error) { + cmdLine.setValue(data.value || data.name || data); + accept(); + e.stop(); + } + }); + el.appendChild(popup.container); + updateCompletions(); + } + if (options.$rules) { + var tokenizer = new Tokenizer(options.$rules); + cmdLine.session.bgTokenizer.setTokenizer(tokenizer); + } + if (options.placeholder) { + cmdLine.setOption("placeholder", options.placeholder); + } + if (options.hasDescription) { + var promptTextContainer = dom.buildDom(["div", { class: "ace_prompt_text_container" }]); + dom.buildDom(options.prompt || "Press 'Enter' to confirm or 'Escape' to cancel", promptTextContainer); + el.appendChild(promptTextContainer); + } + overlay.setIgnoreFocusOut(options.ignoreFocusOut); + function accept() { + var val; + if (popup && popup.getCursorPosition().row > 0) { + val = valueFromRecentList(); + } + else { + val = cmdLine.getValue(); + } + var curData = popup ? popup.getData(popup.getRow()) : val; + if (curData && !curData.error) { + done(); + options.onAccept && options.onAccept({ + value: val, + item: curData + }, cmdLine); + } + } + var keys = { + "Enter": accept, + "Esc|Shift-Esc": function () { + options.onCancel && options.onCancel(cmdLine.getValue(), cmdLine); + done(); + } + }; + if (popup) { + Object.assign(keys, { + "Up": function (editor) { popup.goTo("up"); valueFromRecentList(); }, + "Down": function (editor) { popup.goTo("down"); valueFromRecentList(); }, + "Ctrl-Up|Ctrl-Home": function (editor) { popup.goTo("start"); valueFromRecentList(); }, + "Ctrl-Down|Ctrl-End": function (editor) { popup.goTo("end"); valueFromRecentList(); }, + "Tab": function (editor) { + popup.goTo("down"); + valueFromRecentList(); + }, + "PageUp": function (editor) { popup.gotoPageUp(); valueFromRecentList(); }, + "PageDown": function (editor) { popup.gotoPageDown(); valueFromRecentList(); } + }); + } + cmdLine.commands.bindKeys(keys); + function done() { + overlay.close(); + callback && callback(); + openPrompt = null; + } + cmdLine.on("input", function () { + options.onInput && options.onInput(); + updateCompletions(); + }); + function updateCompletions() { + if (options.getCompletions) { + var prefix; + if (options.getPrefix) { + prefix = options.getPrefix(cmdLine); + } + var completions = options.getCompletions(cmdLine); + popup.setData(completions, prefix); + popup.resize(true); + } + } + function valueFromRecentList() { + var current = popup.getData(popup.getRow()); + if (current && !current.error) + return current.value || current.caption || current; + } + cmdLine.resize(true); + if (popup) { + popup.resize(true); + } + cmdLine.focus(); + openPrompt = { + close: done, + name: options.name, + editor: editor + }; +} +prompt.gotoLine = function (editor, callback) { + function stringifySelection(selection) { + if (!Array.isArray(selection)) + selection = [selection]; + return selection.map(function (r) { + var cursor = r.isBackwards ? r.start : r.end; + var anchor = r.isBackwards ? r.end : r.start; + var row = anchor.row; + var s = (row + 1) + ":" + anchor.column; + if (anchor.row == cursor.row) { + if (anchor.column != cursor.column) + s += ">" + ":" + cursor.column; + } + else { + s += ">" + (cursor.row + 1) + ":" + cursor.column; + } + return s; + }).reverse().join(", "); + } + prompt(editor, ":" + stringifySelection(editor.selection.toJSON()), { + name: "gotoLine", + selection: [1, Number.MAX_VALUE], + onAccept: function (data) { + var value = data.value; + var _history = prompt.gotoLine._history; + if (!_history) + prompt.gotoLine._history = _history = []; + if (_history.indexOf(value) != -1) + _history.splice(_history.indexOf(value), 1); + _history.unshift(value); + if (_history.length > 20) + _history.length = 20; + var pos = editor.getCursorPosition(); + var ranges = []; + value.replace(/^:/, "").split(/,/).map(function (str) { + var parts = str.split(/([<>:+-]|c?\d+)|[^c\d<>:+-]+/).filter(Boolean); + var i = 0; + function readPosition() { + var c = parts[i++]; + if (!c) + return; + if (c[0] == "c") { + var index = parseInt(c.slice(1)) || 0; + return editor.session.doc.indexToPosition(index); + } + var row = pos.row; + var column = 0; + if (/\d/.test(c)) { + row = parseInt(c) - 1; + c = parts[i++]; + } + if (c == ":") { + c = parts[i++]; + if (/\d/.test(c)) { + column = parseInt(c) || 0; + } + } + return { row: row, column: column }; + } + pos = readPosition(); + var range = Range.fromPoints(pos, pos); + if (parts[i] == ">") { + i++; + range.end = readPosition(); + } + else if (parts[i] == "<") { + i++; + range.start = readPosition(); + } + ranges.unshift(range); + }); + editor.selection.fromJSON(ranges); + var scrollTop = editor.renderer.scrollTop; + editor.renderer.scrollSelectionIntoView(editor.selection.anchor, editor.selection.cursor, 0.5); + editor.renderer.animateScrolling(scrollTop); + }, + history: function () { + var undoManager = editor.session.getUndoManager(); + if (!prompt.gotoLine._history) + return []; + return prompt.gotoLine._history; + }, + getCompletions: function (cmdLine) { + var value = cmdLine.getValue(); + var m = value.replace(/^:/, "").split(":"); + var row = Math.min(parseInt(m[0]) || 1, editor.session.getLength()) - 1; + var line = editor.session.getLine(row); + var current = value + " " + line; + return [current].concat(this.history()); + }, + $rules: { + start: [{ + regex: /\d+/, + token: "string" + }, { + regex: /[:,><+\-c]/, + token: "keyword" + }] + } + }); +}; +prompt.commands = function (editor, callback) { + function normalizeName(name) { + return (name || "").replace(/^./, function (x) { + return x.toUpperCase(x); + }).replace(/[a-z][A-Z]/g, function (x) { + return x[0] + " " + x[1].toLowerCase(x); + }); + } + function getEditorCommandsByName(excludeCommands) { + var commandsByName = []; + var commandMap = {}; + editor.keyBinding.$handlers.forEach(function (handler) { + var platform = handler.platform; + var cbn = handler.byName; + for (var i in cbn) { + var key = cbn[i].bindKey; + if (typeof key !== "string") { + key = key && key[platform] || ""; + } + var commands = cbn[i]; + var description = commands.description || normalizeName(commands.name); + if (!Array.isArray(commands)) + commands = [commands]; + commands.forEach(function (command) { + if (typeof command != "string") + command = command.name; + var needle = excludeCommands.find(function (el) { + return el === command; + }); + if (!needle) { + if (commandMap[command]) { + commandMap[command].key += "|" + key; + } + else { + commandMap[command] = { key: key, command: command, description: description }; + commandsByName.push(commandMap[command]); + } + } + }); + } + }); + return commandsByName; + } + var excludeCommandsList = ["insertstring", "inserttext", "setIndentation", "paste"]; + var shortcutsArray = getEditorCommandsByName(excludeCommandsList); + shortcutsArray = shortcutsArray.map(function (item) { + return { value: item.description, meta: item.key, command: item.command }; + }); + prompt(editor, "", { + name: "commands", + selection: [0, Number.MAX_VALUE], + maxHistoryCount: 5, + onAccept: function (data) { + if (data.item) { + var commandName = data.item.command; + this.addToHistory(data.item); + editor.execCommand(commandName); + } + }, + addToHistory: function (item) { + var history = this.history(); + history.unshift(item); + delete item.message; + for (var i = 1; i < history.length; i++) { + if (history[i]["command"] == item.command) { + history.splice(i, 1); + break; + } + } + if (this.maxHistoryCount > 0 && history.length > this.maxHistoryCount) { + history.splice(history.length - 1, 1); + } + prompt.commands.history = history; + }, + history: function () { + return prompt.commands.history || []; + }, + getPrefix: function (cmdLine) { + var currentPos = cmdLine.getCursorPosition(); + var filterValue = cmdLine.getValue(); + return filterValue.substring(0, currentPos.column); + }, + getCompletions: function (cmdLine) { + function getFilteredCompletions(commands, prefix) { + var resultCommands = JSON.parse(JSON.stringify(commands)); + var filtered = new FilteredList(resultCommands); + return filtered.filterCompletions(resultCommands, prefix); + } + function getUniqueCommandList(commands, usedCommands) { + if (!usedCommands || !usedCommands.length) { + return commands; + } + var excludeCommands = []; + usedCommands.forEach(function (item) { + excludeCommands.push(item.command); + }); + var resultCommands = []; + commands.forEach(function (item) { + if (excludeCommands.indexOf(item.command) === -1) { + resultCommands.push(item); + } + }); + return resultCommands; + } + var prefix = this.getPrefix(cmdLine); + var recentlyUsedCommands = getFilteredCompletions(this.history(), prefix); + var otherCommands = getUniqueCommandList(shortcutsArray, recentlyUsedCommands); + otherCommands = getFilteredCompletions(otherCommands, prefix); + if (recentlyUsedCommands.length && otherCommands.length) { + recentlyUsedCommands[0]["message"] = " Recently used"; + otherCommands[0]["message"] = " Other commands"; + } + var completions = recentlyUsedCommands.concat(otherCommands); + return completions.length > 0 ? completions : [{ + value: "No matching commands", + error: 1 + }]; + } + }); +}; +prompt.modes = function (editor, callback) { + var modesArray = modelist.modes; + modesArray = modesArray.map(function (item) { + return { value: item.caption, mode: item.name }; + }); + prompt(editor, "", { + name: "modes", + selection: [0, Number.MAX_VALUE], + onAccept: function (data) { + if (data.item) { + var modeName = "ace/mode/" + data.item.mode; + editor.session.setMode(modeName); + } + }, + getPrefix: function (cmdLine) { + var currentPos = cmdLine.getCursorPosition(); + var filterValue = cmdLine.getValue(); + return filterValue.substring(0, currentPos.column); + }, + getCompletions: function (cmdLine) { + function getFilteredCompletions(modes, prefix) { + var resultCommands = JSON.parse(JSON.stringify(modes)); + var filtered = new FilteredList(resultCommands); + return filtered.filterCompletions(resultCommands, prefix); + } + var prefix = this.getPrefix(cmdLine); + var completions = getFilteredCompletions(modesArray, prefix); + return completions.length > 0 ? completions : [{ + "caption": "No mode matching", + "value": "No mode matching", + "error": 1 + }]; + } + }); +}; +dom.importCssString(".ace_prompt_container {\n max-width: 600px;\n width: 100%;\n margin: 20px auto;\n padding: 3px;\n background: white;\n border-radius: 2px;\n box-shadow: 0px 2px 3px 0px #555;\n}", "promtp.css", false); +exports.prompt = prompt; + +}); + (function() { + window.require(["ace/ext/prompt"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-rtl.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-rtl.js new file mode 100644 index 0000000..56c7337 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-rtl.js @@ -0,0 +1,121 @@ +define("ace/ext/rtl",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var commands = [{ + name: "leftToRight", + bindKey: { win: "Ctrl-Alt-Shift-L", mac: "Command-Alt-Shift-L" }, + exec: function (editor) { + editor.session.$bidiHandler.setRtlDirection(editor, false); + }, + readOnly: true + }, { + name: "rightToLeft", + bindKey: { win: "Ctrl-Alt-Shift-R", mac: "Command-Alt-Shift-R" }, + exec: function (editor) { + editor.session.$bidiHandler.setRtlDirection(editor, true); + }, + readOnly: true + }]; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + rtlText: { + set: function (val) { + if (val) { + this.on("change", onChange); + this.on("changeSelection", onChangeSelection); + this.renderer.on("afterRender", updateLineDirection); + this.commands.on("exec", onCommandEmitted); + this.commands.addCommands(commands); + } + else { + this.off("change", onChange); + this.off("changeSelection", onChangeSelection); + this.renderer.off("afterRender", updateLineDirection); + this.commands.off("exec", onCommandEmitted); + this.commands.removeCommands(commands); + clearTextLayer(this.renderer); + } + this.renderer.updateFull(); + } + }, + rtl: { + set: function (val) { + this.session.$bidiHandler.$isRtl = val; + if (val) { + this.setOption("rtlText", false); + this.renderer.on("afterRender", updateLineDirection); + this.session.$bidiHandler.seenBidi = true; + } + else { + this.renderer.off("afterRender", updateLineDirection); + clearTextLayer(this.renderer); + } + this.renderer.updateFull(); + } + } +}); +function onChangeSelection(e, editor) { + var lead = editor.getSelection().lead; + if (editor.session.$bidiHandler.isRtlLine(lead.row)) { + if (lead.column === 0) { + if (editor.session.$bidiHandler.isMoveLeftOperation && lead.row > 0) { + editor.getSelection().moveCursorTo(lead.row - 1, editor.session.getLine(lead.row - 1).length); + } + else { + if (editor.getSelection().isEmpty()) + lead.column += 1; + else + lead.setPosition(lead.row, lead.column + 1); + } + } + } +} +function onCommandEmitted(commadEvent) { + commadEvent.editor.session.$bidiHandler.isMoveLeftOperation = /gotoleft|selectleft|backspace|removewordleft/.test(commadEvent.command.name); +} +function onChange(delta, editor) { + var session = editor.session; + session.$bidiHandler.currentRow = null; + if (session.$bidiHandler.isRtlLine(delta.start.row) && delta.action === 'insert' && delta.lines.length > 1) { + for (var row = delta.start.row; row < delta.end.row; row++) { + if (session.getLine(row + 1).charAt(0) !== session.$bidiHandler.RLE) + session.doc.$lines[row + 1] = session.$bidiHandler.RLE + session.getLine(row + 1); + } + } +} +function updateLineDirection(e, renderer) { + var session = renderer.session; + var $bidiHandler = session.$bidiHandler; + var cells = renderer.$textLayer.$lines.cells; + var width = renderer.layerConfig.width - renderer.layerConfig.padding + "px"; + cells.forEach(function (cell) { + var style = cell.element.style; + if ($bidiHandler && $bidiHandler.isRtlLine(cell.row)) { + style.direction = "rtl"; + style.textAlign = "right"; + style.width = width; + } + else { + style.direction = ""; + style.textAlign = ""; + style.width = ""; + } + }); +} +function clearTextLayer(renderer) { + var lines = renderer.$textLayer.$lines; + lines.cells.forEach(clear); + lines.cellCache.forEach(clear); + function clear(cell) { + var style = cell.element.style; + style.direction = style.textAlign = style.width = ""; + } +} + +}); + (function() { + window.require(["ace/ext/rtl"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-searchbox.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-searchbox.js new file mode 100644 index 0000000..0af4ab1 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-searchbox.js @@ -0,0 +1,339 @@ +define("ace/ext/searchbox.css",["require","exports","module"], function(require, exports, module){module.exports = "\n\n/* ------------------------------------------------------------------------------------------\n * Editor Search Form\n * --------------------------------------------------------------------------------------- */\n.ace_search {\n background-color: #ddd;\n color: #666;\n border: 1px solid #cbcbcb;\n border-top: 0 none;\n overflow: hidden;\n margin: 0;\n padding: 4px 6px 0 4px;\n position: absolute;\n top: 0;\n z-index: 99;\n white-space: normal;\n}\n.ace_search.left {\n border-left: 0 none;\n border-radius: 0px 0px 5px 0px;\n left: 0;\n}\n.ace_search.right {\n border-radius: 0px 0px 0px 5px;\n border-right: 0 none;\n right: 0;\n}\n\n.ace_search_form, .ace_replace_form {\n margin: 0 20px 4px 0;\n overflow: hidden;\n line-height: 1.9;\n}\n.ace_replace_form {\n margin-right: 0;\n}\n.ace_search_form.ace_nomatch {\n outline: 1px solid red;\n}\n\n.ace_search_field {\n border-radius: 3px 0 0 3px;\n background-color: white;\n color: black;\n border: 1px solid #cbcbcb;\n border-right: 0 none;\n outline: 0;\n padding: 0;\n font-size: inherit;\n margin: 0;\n line-height: inherit;\n padding: 0 6px;\n min-width: 17em;\n vertical-align: top;\n min-height: 1.8em;\n box-sizing: content-box;\n}\n.ace_searchbtn {\n border: 1px solid #cbcbcb;\n line-height: inherit;\n display: inline-block;\n padding: 0 6px;\n background: #fff;\n border-right: 0 none;\n border-left: 1px solid #dcdcdc;\n cursor: pointer;\n margin: 0;\n position: relative;\n color: #666;\n}\n.ace_searchbtn:last-child {\n border-radius: 0 3px 3px 0;\n border-right: 1px solid #cbcbcb;\n}\n.ace_searchbtn:disabled {\n background: none;\n cursor: default;\n}\n.ace_searchbtn:hover {\n background-color: #eef1f6;\n}\n.ace_searchbtn.prev, .ace_searchbtn.next {\n padding: 0px 0.7em\n}\n.ace_searchbtn.prev:after, .ace_searchbtn.next:after {\n content: \"\";\n border: solid 2px #888;\n width: 0.5em;\n height: 0.5em;\n border-width: 2px 0 0 2px;\n display:inline-block;\n transform: rotate(-45deg);\n}\n.ace_searchbtn.next:after {\n border-width: 0 2px 2px 0 ;\n}\n.ace_searchbtn_close {\n background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\n border-radius: 50%;\n border: 0 none;\n color: #656565;\n cursor: pointer;\n font: 16px/16px Arial;\n padding: 0;\n height: 14px;\n width: 14px;\n top: 9px;\n right: 7px;\n position: absolute;\n}\n.ace_searchbtn_close:hover {\n background-color: #656565;\n background-position: 50% 100%;\n color: white;\n}\n\n.ace_button {\n margin-left: 2px;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n -ms-user-select: none;\n user-select: none;\n overflow: hidden;\n opacity: 0.7;\n border: 1px solid rgba(100,100,100,0.23);\n padding: 1px;\n box-sizing: border-box!important;\n color: black;\n}\n\n.ace_button:hover {\n background-color: #eee;\n opacity:1;\n}\n.ace_button:active {\n background-color: #ddd;\n}\n\n.ace_button.checked {\n border-color: #3399ff;\n opacity:1;\n}\n\n.ace_search_options{\n margin-bottom: 3px;\n text-align: right;\n -webkit-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n -ms-user-select: none;\n user-select: none;\n clear: both;\n}\n\n.ace_search_counter {\n float: left;\n font-family: arial;\n padding: 0 8px;\n}"; + +}); + +define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/ext/searchbox.css","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module){"use strict"; +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var event = require("../lib/event"); +var searchboxCss = require("./searchbox.css"); +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var keyUtil = require("../lib/keys"); +var MAX_COUNT = 999; +dom.importCssString(searchboxCss, "ace_searchbox", false); +var SearchBox = function (editor, range, showReplaceForm) { + var div = dom.createElement("div"); + dom.buildDom(["div", { class: "ace_search right" }, + ["span", { action: "hide", class: "ace_searchbtn_close" }], + ["div", { class: "ace_search_form" }, + ["input", { class: "ace_search_field", placeholder: "Search for", spellcheck: "false" }], + ["span", { action: "findPrev", class: "ace_searchbtn prev" }, "\u200b"], + ["span", { action: "findNext", class: "ace_searchbtn next" }, "\u200b"], + ["span", { action: "findAll", class: "ace_searchbtn", title: "Alt-Enter" }, "All"] + ], + ["div", { class: "ace_replace_form" }, + ["input", { class: "ace_search_field", placeholder: "Replace with", spellcheck: "false" }], + ["span", { action: "replaceAndFindNext", class: "ace_searchbtn" }, "Replace"], + ["span", { action: "replaceAll", class: "ace_searchbtn" }, "All"] + ], + ["div", { class: "ace_search_options" }, + ["span", { action: "toggleReplace", class: "ace_button", title: "Toggle Replace mode", + style: "float:left;margin-top:-2px;padding:0 5px;" }, "+"], + ["span", { class: "ace_search_counter" }], + ["span", { action: "toggleRegexpMode", class: "ace_button", title: "RegExp Search" }, ".*"], + ["span", { action: "toggleCaseSensitive", class: "ace_button", title: "CaseSensitive Search" }, "Aa"], + ["span", { action: "toggleWholeWords", class: "ace_button", title: "Whole Word Search" }, "\\b"], + ["span", { action: "searchInSelection", class: "ace_button", title: "Search In Selection" }, "S"] + ] + ], div); + this.element = div.firstChild; + this.setSession = this.setSession.bind(this); + this.$init(); + this.setEditor(editor); + dom.importCssString(searchboxCss, "ace_searchbox", editor.container); +}; +(function () { + this.setEditor = function (editor) { + editor.searchBox = this; + editor.renderer.scroller.appendChild(this.element); + this.editor = editor; + }; + this.setSession = function (e) { + this.searchRange = null; + this.$syncOptions(true); + }; + this.$initElements = function (sb) { + this.searchBox = sb.querySelector(".ace_search_form"); + this.replaceBox = sb.querySelector(".ace_replace_form"); + this.searchOption = sb.querySelector("[action=searchInSelection]"); + this.replaceOption = sb.querySelector("[action=toggleReplace]"); + this.regExpOption = sb.querySelector("[action=toggleRegexpMode]"); + this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]"); + this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]"); + this.searchInput = this.searchBox.querySelector(".ace_search_field"); + this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); + this.searchCounter = sb.querySelector(".ace_search_counter"); + }; + this.$init = function () { + var sb = this.element; + this.$initElements(sb); + var _this = this; + event.addListener(sb, "mousedown", function (e) { + setTimeout(function () { + _this.activeInput.focus(); + }, 0); + event.stopPropagation(e); + }); + event.addListener(sb, "click", function (e) { + var t = e.target || e.srcElement; + var action = t.getAttribute("action"); + if (action && _this[action]) + _this[action](); + else if (_this.$searchBarKb.commands[action]) + _this.$searchBarKb.commands[action].exec(_this); + event.stopPropagation(e); + }); + event.addCommandKeyListener(sb, function (e, hashId, keyCode) { + var keyString = keyUtil.keyCodeToString(keyCode); + var command = _this.$searchBarKb.findKeyCommand(hashId, keyString); + if (command && command.exec) { + command.exec(_this); + event.stopEvent(e); + } + }); + this.$onChange = lang.delayedCall(function () { + _this.find(false, false); + }); + event.addListener(this.searchInput, "input", function () { + _this.$onChange.schedule(20); + }); + event.addListener(this.searchInput, "focus", function () { + _this.activeInput = _this.searchInput; + _this.searchInput.value && _this.highlight(); + }); + event.addListener(this.replaceInput, "focus", function () { + _this.activeInput = _this.replaceInput; + _this.searchInput.value && _this.highlight(); + }); + }; + this.$closeSearchBarKb = new HashHandler([{ + bindKey: "Esc", + name: "closeSearchBar", + exec: function (editor) { + editor.searchBox.hide(); + } + }]); + this.$searchBarKb = new HashHandler(); + this.$searchBarKb.bindKeys({ + "Ctrl-f|Command-f": function (sb) { + var isReplace = sb.isReplace = !sb.isReplace; + sb.replaceBox.style.display = isReplace ? "" : "none"; + sb.replaceOption.checked = false; + sb.$syncOptions(); + sb.searchInput.focus(); + }, + "Ctrl-H|Command-Option-F": function (sb) { + if (sb.editor.getReadOnly()) + return; + sb.replaceOption.checked = true; + sb.$syncOptions(); + sb.replaceInput.focus(); + }, + "Ctrl-G|Command-G": function (sb) { + sb.findNext(); + }, + "Ctrl-Shift-G|Command-Shift-G": function (sb) { + sb.findPrev(); + }, + "esc": function (sb) { + setTimeout(function () { sb.hide(); }); + }, + "Return": function (sb) { + if (sb.activeInput == sb.replaceInput) + sb.replace(); + sb.findNext(); + }, + "Shift-Return": function (sb) { + if (sb.activeInput == sb.replaceInput) + sb.replace(); + sb.findPrev(); + }, + "Alt-Return": function (sb) { + if (sb.activeInput == sb.replaceInput) + sb.replaceAll(); + sb.findAll(); + }, + "Tab": function (sb) { + (sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus(); + } + }); + this.$searchBarKb.addCommands([{ + name: "toggleRegexpMode", + bindKey: { win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/" }, + exec: function (sb) { + sb.regExpOption.checked = !sb.regExpOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleCaseSensitive", + bindKey: { win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I" }, + exec: function (sb) { + sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleWholeWords", + bindKey: { win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W" }, + exec: function (sb) { + sb.wholeWordOption.checked = !sb.wholeWordOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleReplace", + exec: function (sb) { + sb.replaceOption.checked = !sb.replaceOption.checked; + sb.$syncOptions(); + } + }, { + name: "searchInSelection", + exec: function (sb) { + sb.searchOption.checked = !sb.searchRange; + sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange()); + sb.$syncOptions(); + } + }]); + this.setSearchRange = function (range) { + this.searchRange = range; + if (range) { + this.searchRangeMarker = this.editor.session.addMarker(range, "ace_active-line"); + } + else if (this.searchRangeMarker) { + this.editor.session.removeMarker(this.searchRangeMarker); + this.searchRangeMarker = null; + } + }; + this.$syncOptions = function (preventScroll) { + dom.setCssClass(this.replaceOption, "checked", this.searchRange); + dom.setCssClass(this.searchOption, "checked", this.searchOption.checked); + this.replaceOption.textContent = this.replaceOption.checked ? "-" : "+"; + dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked); + dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked); + dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked); + var readOnly = this.editor.getReadOnly(); + this.replaceOption.style.display = readOnly ? "none" : ""; + this.replaceBox.style.display = this.replaceOption.checked && !readOnly ? "" : "none"; + this.find(false, false, preventScroll); + }; + this.highlight = function (re) { + this.editor.session.highlight(re || this.editor.$search.$options.re); + this.editor.renderer.updateBackMarkers(); + }; + this.find = function (skipCurrent, backwards, preventScroll) { + var range = this.editor.find(this.searchInput.value, { + skipCurrent: skipCurrent, + backwards: backwards, + wrap: true, + regExp: this.regExpOption.checked, + caseSensitive: this.caseSensitiveOption.checked, + wholeWord: this.wholeWordOption.checked, + preventScroll: preventScroll, + range: this.searchRange + }); + var noMatch = !range && this.searchInput.value; + dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); + this.editor._emit("findSearchBox", { match: !noMatch }); + this.highlight(); + this.updateCounter(); + }; + this.updateCounter = function () { + var editor = this.editor; + var regex = editor.$search.$options.re; + var all = 0; + var before = 0; + if (regex) { + var value = this.searchRange + ? editor.session.getTextRange(this.searchRange) + : editor.getValue(); + var offset = editor.session.doc.positionToIndex(editor.selection.anchor); + if (this.searchRange) + offset -= editor.session.doc.positionToIndex(this.searchRange.start); + var last = regex.lastIndex = 0; + var m; + while ((m = regex.exec(value))) { + all++; + last = m.index; + if (last <= offset) + before++; + if (all > MAX_COUNT) + break; + if (!m[0]) { + regex.lastIndex = last += 1; + if (last >= value.length) + break; + } + } + } + this.searchCounter.textContent = before + " of " + (all > MAX_COUNT ? MAX_COUNT + "+" : all); + }; + this.findNext = function () { + this.find(true, false); + }; + this.findPrev = function () { + this.find(true, true); + }; + this.findAll = function () { + var range = this.editor.findAll(this.searchInput.value, { + regExp: this.regExpOption.checked, + caseSensitive: this.caseSensitiveOption.checked, + wholeWord: this.wholeWordOption.checked + }); + var noMatch = !range && this.searchInput.value; + dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); + this.editor._emit("findSearchBox", { match: !noMatch }); + this.highlight(); + this.hide(); + }; + this.replace = function () { + if (!this.editor.getReadOnly()) + this.editor.replace(this.replaceInput.value); + }; + this.replaceAndFindNext = function () { + if (!this.editor.getReadOnly()) { + this.editor.replace(this.replaceInput.value); + this.findNext(); + } + }; + this.replaceAll = function () { + if (!this.editor.getReadOnly()) + this.editor.replaceAll(this.replaceInput.value); + }; + this.hide = function () { + this.active = false; + this.setSearchRange(null); + this.editor.off("changeSession", this.setSession); + this.element.style.display = "none"; + this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb); + this.editor.focus(); + }; + this.show = function (value, isReplace) { + this.active = true; + this.editor.on("changeSession", this.setSession); + this.element.style.display = ""; + this.replaceOption.checked = isReplace; + if (value) + this.searchInput.value = value; + this.searchInput.focus(); + this.searchInput.select(); + this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb); + this.$syncOptions(true); + }; + this.isFocused = function () { + var el = document.activeElement; + return el == this.searchInput || el == this.replaceInput; + }; +}).call(SearchBox.prototype); +exports.SearchBox = SearchBox; +exports.Search = function (editor, isReplace) { + var sb = editor.searchBox || new SearchBox(editor); + sb.show(editor.session.getTextRange(), isReplace); +}; + +}); + (function() { + window.require(["ace/ext/searchbox"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-settings_menu.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-settings_menu.js new file mode 100644 index 0000000..627787f --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-settings_menu.js @@ -0,0 +1,754 @@ +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + +define("ace/ext/themelist",["require","exports","module"], function(require, exports, module){/** + * Generates a list of themes available when ace was built. + * @fileOverview Generates a list of themes available when ace was built. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ +"use strict"; +var themeData = [ + ["Chrome"], + ["Clouds"], + ["Crimson Editor"], + ["Dawn"], + ["Dreamweaver"], + ["Eclipse"], + ["GitHub"], + ["IPlastic"], + ["Solarized Light"], + ["TextMate"], + ["Tomorrow"], + ["XCode"], + ["Kuroir"], + ["KatzenMilch"], + ["SQL Server", "sqlserver", "light"], + ["Ambiance", "ambiance", "dark"], + ["Chaos", "chaos", "dark"], + ["Clouds Midnight", "clouds_midnight", "dark"], + ["Dracula", "", "dark"], + ["Cobalt", "cobalt", "dark"], + ["Gruvbox", "gruvbox", "dark"], + ["Green on Black", "gob", "dark"], + ["idle Fingers", "idle_fingers", "dark"], + ["krTheme", "kr_theme", "dark"], + ["Merbivore", "merbivore", "dark"], + ["Merbivore Soft", "merbivore_soft", "dark"], + ["Mono Industrial", "mono_industrial", "dark"], + ["Monokai", "monokai", "dark"], + ["Nord Dark", "nord_dark", "dark"], + ["One Dark", "one_dark", "dark"], + ["Pastel on dark", "pastel_on_dark", "dark"], + ["Solarized Dark", "solarized_dark", "dark"], + ["Terminal", "terminal", "dark"], + ["Tomorrow Night", "tomorrow_night", "dark"], + ["Tomorrow Night Blue", "tomorrow_night_blue", "dark"], + ["Tomorrow Night Bright", "tomorrow_night_bright", "dark"], + ["Tomorrow Night 80s", "tomorrow_night_eighties", "dark"], + ["Twilight", "twilight", "dark"], + ["Vibrant Ink", "vibrant_ink", "dark"] +]; +exports.themesByName = {}; +exports.themes = themeData.map(function (data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; +}); + +}); + +define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module){"use strict"; +require("./menu_tools/overlay_page"); +var dom = require("../lib/dom"); +var oop = require("../lib/oop"); +var config = require("../config"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; +var buildDom = dom.buildDom; +var modelist = require("./modelist"); +var themelist = require("./themelist"); +var themes = { Bright: [], Dark: [] }; +themelist.themes.forEach(function (x) { + themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme }); +}); +var modes = modelist.modes.map(function (x) { + return { caption: x.caption, value: x.mode }; +}); +var optionGroups = { + Main: { + Mode: { + path: "mode", + type: "select", + items: modes + }, + Theme: { + path: "theme", + type: "select", + items: themes + }, + "Keybinding": { + type: "buttonBar", + path: "keyboardHandler", + items: [ + { caption: "Ace", value: null }, + { caption: "Vim", value: "ace/keyboard/vim" }, + { caption: "Emacs", value: "ace/keyboard/emacs" }, + { caption: "Sublime", value: "ace/keyboard/sublime" }, + { caption: "VSCode", value: "ace/keyboard/vscode" } + ] + }, + "Font Size": { + path: "fontSize", + type: "number", + defaultValue: 12, + defaults: [ + { caption: "12px", value: 12 }, + { caption: "24px", value: 24 } + ] + }, + "Soft Wrap": { + type: "buttonBar", + path: "wrap", + items: [ + { caption: "Off", value: "off" }, + { caption: "View", value: "free" }, + { caption: "margin", value: "printMargin" }, + { caption: "40", value: "40" } + ] + }, + "Cursor Style": { + path: "cursorStyle", + items: [ + { caption: "Ace", value: "ace" }, + { caption: "Slim", value: "slim" }, + { caption: "Smooth", value: "smooth" }, + { caption: "Smooth And Slim", value: "smooth slim" }, + { caption: "Wide", value: "wide" } + ] + }, + "Folding": { + path: "foldStyle", + items: [ + { caption: "Manual", value: "manual" }, + { caption: "Mark begin", value: "markbegin" }, + { caption: "Mark begin and end", value: "markbeginend" } + ] + }, + "Soft Tabs": [{ + path: "useSoftTabs" + }, { + ariaLabel: "Tab Size", + path: "tabSize", + type: "number", + values: [2, 3, 4, 8, 16] + }], + "Overscroll": { + type: "buttonBar", + path: "scrollPastEnd", + items: [ + { caption: "None", value: 0 }, + { caption: "Half", value: 0.5 }, + { caption: "Full", value: 1 } + ] + } + }, + More: { + "Atomic soft tabs": { + path: "navigateWithinSoftTabs" + }, + "Enable Behaviours": { + path: "behavioursEnabled" + }, + "Wrap with quotes": { + path: "wrapBehavioursEnabled" + }, + "Enable Auto Indent": { + path: "enableAutoIndent" + }, + "Full Line Selection": { + type: "checkbox", + values: "text|line", + path: "selectionStyle" + }, + "Highlight Active Line": { + path: "highlightActiveLine" + }, + "Show Invisibles": { + path: "showInvisibles" + }, + "Show Indent Guides": { + path: "displayIndentGuides" + }, + "Highlight Indent Guides": { + path: "highlightIndentGuides" + }, + "Persistent HScrollbar": { + path: "hScrollBarAlwaysVisible" + }, + "Persistent VScrollbar": { + path: "vScrollBarAlwaysVisible" + }, + "Animate scrolling": { + path: "animatedScroll" + }, + "Show Gutter": { + path: "showGutter" + }, + "Show Line Numbers": { + path: "showLineNumbers" + }, + "Relative Line Numbers": { + path: "relativeLineNumbers" + }, + "Fixed Gutter Width": { + path: "fixedWidthGutter" + }, + "Show Print Margin": [{ + path: "showPrintMargin" + }, { + ariaLabel: "Print Margin", + type: "number", + path: "printMarginColumn" + }], + "Indented Soft Wrap": { + path: "indentedSoftWrap" + }, + "Highlight selected word": { + path: "highlightSelectedWord" + }, + "Fade Fold Widgets": { + path: "fadeFoldWidgets" + }, + "Use textarea for IME": { + path: "useTextareaForIME" + }, + "Merge Undo Deltas": { + path: "mergeUndoDeltas", + items: [ + { caption: "Always", value: "always" }, + { caption: "Never", value: "false" }, + { caption: "Timed", value: "true" } + ] + }, + "Elastic Tabstops": { + path: "useElasticTabstops" + }, + "Incremental Search": { + path: "useIncrementalSearch" + }, + "Read-only": { + path: "readOnly" + }, + "Copy without selection": { + path: "copyWithEmptySelection" + }, + "Live Autocompletion": { + path: "enableLiveAutocompletion" + }, + "Custom scrollbar": { + path: "customScrollbar" + } + } +}; +var OptionPanel = function (editor, element) { + this.editor = editor; + this.container = element || document.createElement("div"); + this.groups = []; + this.options = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.add = function (config) { + if (config.Main) + oop.mixin(optionGroups.Main, config.Main); + if (config.More) + oop.mixin(optionGroups.More, config.More); + }; + this.render = function () { + this.container.innerHTML = ""; + buildDom(["table", { role: "presentation", id: "controls" }, + this.renderOptionGroup(optionGroups.Main), + ["tr", null, ["td", { colspan: 2 }, + ["table", { role: "presentation", id: "more-controls" }, + this.renderOptionGroup(optionGroups.More) + ] + ]], + ["tr", null, ["td", { colspan: 2 }, "version " + config.version]] + ], this.container); + }; + this.renderOptionGroup = function (group) { + return Object.keys(group).map(function (key, i) { + var item = group[key]; + if (!item.position) + item.position = i / 10000; + if (!item.label) + item.label = key; + return item; + }).sort(function (a, b) { + return a.position - b.position; + }).map(function (item) { + return this.renderOption(item.label, item); + }, this); + }; + this.renderOptionControl = function (key, option) { + var self = this; + if (Array.isArray(option)) { + return option.map(function (x) { + return self.renderOptionControl(key, x); + }); + } + var control; + var value = self.getOption(option); + if (option.values && option.type != "checkbox") { + if (typeof option.values == "string") + option.values = option.values.split("|"); + option.items = option.values.map(function (v) { + return { value: v, name: v }; + }); + } + if (option.type == "buttonBar") { + control = ["div", { role: "group", "aria-labelledby": option.path + "-label" }, option.items.map(function (item) { + return ["button", { + value: item.value, + ace_selected_button: value == item.value, + 'aria-pressed': value == item.value, + onclick: function () { + self.setOption(option, item.value); + var nodes = this.parentNode.querySelectorAll("[ace_selected_button]"); + for (var i = 0; i < nodes.length; i++) { + nodes[i].removeAttribute("ace_selected_button"); + nodes[i].setAttribute("aria-pressed", false); + } + this.setAttribute("ace_selected_button", true); + this.setAttribute("aria-pressed", true); + } + }, item.desc || item.caption || item.name]; + })]; + } + else if (option.type == "number") { + control = ["input", { type: "number", value: value || option.defaultValue, style: "width:3em", oninput: function () { + self.setOption(option, parseInt(this.value)); + } }]; + if (option.ariaLabel) { + control[1]["aria-label"] = option.ariaLabel; + } + else { + control[1].id = key; + } + if (option.defaults) { + control = [control, option.defaults.map(function (item) { + return ["button", { onclick: function () { + var input = this.parentNode.firstChild; + input.value = item.value; + input.oninput(); + } }, item.caption]; + })]; + } + } + else if (option.items) { + var buildItems = function (items) { + return items.map(function (item) { + return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name]; + }); + }; + var items = Array.isArray(option.items) + ? buildItems(option.items) + : Object.keys(option.items).map(function (key) { + return ["optgroup", { "label": key }, buildItems(option.items[key])]; + }); + control = ["select", { id: key, value: value, onchange: function () { + self.setOption(option, this.value); + } }, items]; + } + else { + if (typeof option.values == "string") + option.values = option.values.split("|"); + if (option.values) + value = value == option.values[1]; + control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function () { + var value = this.checked; + if (option.values) + value = option.values[value ? 1 : 0]; + self.setOption(option, value); + } }]; + if (option.type == "checkedNumber") { + control = [control, []]; + } + } + return control; + }; + this.renderOption = function (key, option) { + if (option.path && !option.onchange && !this.editor.$options[option.path]) + return; + var path = Array.isArray(option) ? option[0].path : option.path; + this.options[path] = option; + var safeKey = "-" + path; + var safeId = path + "-label"; + var control = this.renderOptionControl(safeKey, option); + return ["tr", { class: "ace_optionsMenuEntry" }, ["td", + ["label", { for: safeKey, id: safeId }, key] + ], ["td", control]]; + }; + this.setOption = function (option, value) { + if (typeof option == "string") + option = this.options[option]; + if (value == "false") + value = false; + if (value == "true") + value = true; + if (value == "null") + value = null; + if (value == "undefined") + value = undefined; + if (typeof value == "string" && parseFloat(value).toString() == value) + value = parseFloat(value); + if (option.onchange) + option.onchange(value); + else if (option.path) + this.editor.setOption(option.path, value); + this._signal("setOption", { name: option.path, value: value }); + }; + this.getOption = function (option) { + if (option.getValue) + return option.getValue(); + return this.editor.getOption(option.path); + }; +}).call(OptionPanel.prototype); +exports.OptionPanel = OptionPanel; + +}); + +define("ace/ext/settings_menu",["require","exports","module","ace/ext/options","ace/ext/menu_tools/overlay_page","ace/editor"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var OptionPanel = require("./options").OptionPanel; +var overlayPage = require('./menu_tools/overlay_page').overlayPage; +function showSettingsMenu(editor) { + if (!document.getElementById('ace_settingsmenu')) { + var options = new OptionPanel(editor); + options.render(); + options.container.id = "ace_settingsmenu"; + overlayPage(editor, options.container); + options.container.querySelector("select,input,button,checkbox").focus(); + } +} +module.exports.init = function () { + var Editor = require("../editor").Editor; + Editor.prototype.showSettingsMenu = function () { + showSettingsMenu(this); + }; +}; + +}); + (function() { + window.require(["ace/ext/settings_menu"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-spellcheck.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-spellcheck.js new file mode 100644 index 0000000..8faef50 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-spellcheck.js @@ -0,0 +1,68 @@ +define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var event = require("../lib/event"); +exports.contextMenuHandler = function (e) { + var host = e.target; + var text = host.textInput.getElement(); + if (!host.selection.isEmpty()) + return; + var c = host.getCursorPosition(); + var r = host.session.getWordRange(c.row, c.column); + var w = host.session.getTextRange(r); + host.session.tokenRe.lastIndex = 0; + if (!host.session.tokenRe.test(w)) + return; + var PLACEHOLDER = "\x01\x01"; + var value = w + " " + PLACEHOLDER; + text.value = value; + text.setSelectionRange(w.length, w.length + 1); + text.setSelectionRange(0, 0); + text.setSelectionRange(0, w.length); + var afterKeydown = false; + event.addListener(text, "keydown", function onKeydown() { + event.removeListener(text, "keydown", onKeydown); + afterKeydown = true; + }); + host.textInput.setInputHandler(function (newVal) { + if (newVal == value) + return ''; + if (newVal.lastIndexOf(value, 0) === 0) + return newVal.slice(value.length); + if (newVal.substr(text.selectionEnd) == value) + return newVal.slice(0, -value.length); + if (newVal.slice(-2) == PLACEHOLDER) { + var val = newVal.slice(0, -2); + if (val.slice(-1) == " ") { + if (afterKeydown) + return val.substring(0, text.selectionEnd); + val = val.slice(0, -1); + host.session.replace(r, val); + return ""; + } + } + return newVal; + }); +}; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + spellcheck: { + set: function (val) { + var text = this.textInput.getElement(); + text.spellcheck = !!val; + if (!val) + this.removeListener("nativecontextmenu", exports.contextMenuHandler); + else + this.on("nativecontextmenu", exports.contextMenuHandler); + }, + value: true + } +}); + +}); + (function() { + window.require(["ace/ext/spellcheck"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-split.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-split.js new file mode 100644 index 0000000..e4571d5 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-split.js @@ -0,0 +1,186 @@ +define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"], function(require, exports, module){"use strict"; +var oop = require("./lib/oop"); +var lang = require("./lib/lang"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var Editor = require("./editor").Editor; +var Renderer = require("./virtual_renderer").VirtualRenderer; +var EditSession = require("./edit_session").EditSession; +var Split = function (container, theme, splits) { + this.BELOW = 1; + this.BESIDE = 0; + this.$container = container; + this.$theme = theme; + this.$splits = 0; + this.$editorCSS = ""; + this.$editors = []; + this.$orientation = this.BESIDE; + this.setSplits(splits || 1); + this.$cEditor = this.$editors[0]; + this.on("focus", function (editor) { + this.$cEditor = editor; + }.bind(this)); +}; +(function () { + oop.implement(this, EventEmitter); + this.$createEditor = function () { + var el = document.createElement("div"); + el.className = this.$editorCSS; + el.style.cssText = "position: absolute; top:0px; bottom:0px"; + this.$container.appendChild(el); + var editor = new Editor(new Renderer(el, this.$theme)); + editor.on("focus", function () { + this._emit("focus", editor); + }.bind(this)); + this.$editors.push(editor); + editor.setFontSize(this.$fontSize); + return editor; + }; + this.setSplits = function (splits) { + var editor; + if (splits < 1) { + throw "The number of splits have to be > 0!"; + } + if (splits == this.$splits) { + return; + } + else if (splits > this.$splits) { + while (this.$splits < this.$editors.length && this.$splits < splits) { + editor = this.$editors[this.$splits]; + this.$container.appendChild(editor.container); + editor.setFontSize(this.$fontSize); + this.$splits++; + } + while (this.$splits < splits) { + this.$createEditor(); + this.$splits++; + } + } + else { + while (this.$splits > splits) { + editor = this.$editors[this.$splits - 1]; + this.$container.removeChild(editor.container); + this.$splits--; + } + } + this.resize(); + }; + this.getSplits = function () { + return this.$splits; + }; + this.getEditor = function (idx) { + return this.$editors[idx]; + }; + this.getCurrentEditor = function () { + return this.$cEditor; + }; + this.focus = function () { + this.$cEditor.focus(); + }; + this.blur = function () { + this.$cEditor.blur(); + }; + this.setTheme = function (theme) { + this.$editors.forEach(function (editor) { + editor.setTheme(theme); + }); + }; + this.setKeyboardHandler = function (keybinding) { + this.$editors.forEach(function (editor) { + editor.setKeyboardHandler(keybinding); + }); + }; + this.forEach = function (callback, scope) { + this.$editors.forEach(callback, scope); + }; + this.$fontSize = ""; + this.setFontSize = function (size) { + this.$fontSize = size; + this.forEach(function (editor) { + editor.setFontSize(size); + }); + }; + this.$cloneSession = function (session) { + var s = new EditSession(session.getDocument(), session.getMode()); + var undoManager = session.getUndoManager(); + s.setUndoManager(undoManager); + s.setTabSize(session.getTabSize()); + s.setUseSoftTabs(session.getUseSoftTabs()); + s.setOverwrite(session.getOverwrite()); + s.setBreakpoints(session.getBreakpoints()); + s.setUseWrapMode(session.getUseWrapMode()); + s.setUseWorker(session.getUseWorker()); + s.setWrapLimitRange(session.$wrapLimitRange.min, session.$wrapLimitRange.max); + s.$foldData = session.$cloneFoldData(); + return s; + }; + this.setSession = function (session, idx) { + var editor; + if (idx == null) { + editor = this.$cEditor; + } + else { + editor = this.$editors[idx]; + } + var isUsed = this.$editors.some(function (editor) { + return editor.session === session; + }); + if (isUsed) { + session = this.$cloneSession(session); + } + editor.setSession(session); + return session; + }; + this.getOrientation = function () { + return this.$orientation; + }; + this.setOrientation = function (orientation) { + if (this.$orientation == orientation) { + return; + } + this.$orientation = orientation; + this.resize(); + }; + this.resize = function () { + var width = this.$container.clientWidth; + var height = this.$container.clientHeight; + var editor; + if (this.$orientation == this.BESIDE) { + var editorWidth = width / this.$splits; + for (var i = 0; i < this.$splits; i++) { + editor = this.$editors[i]; + editor.container.style.width = editorWidth + "px"; + editor.container.style.top = "0px"; + editor.container.style.left = i * editorWidth + "px"; + editor.container.style.height = height + "px"; + editor.resize(); + } + } + else { + var editorHeight = height / this.$splits; + for (var i = 0; i < this.$splits; i++) { + editor = this.$editors[i]; + editor.container.style.width = width + "px"; + editor.container.style.top = i * editorHeight + "px"; + editor.container.style.left = "0px"; + editor.container.style.height = editorHeight + "px"; + editor.resize(); + } + } + }; +}).call(Split.prototype); +exports.Split = Split; + +}); + +define("ace/ext/split",["require","exports","module","ace/split"], function(require, exports, module){"use strict"; +module.exports = require("../split"); + +}); + (function() { + window.require(["ace/ext/split"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-static_highlight.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-static_highlight.js new file mode 100644 index 0000000..d9be541 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-static_highlight.js @@ -0,0 +1,182 @@ +define("ace/ext/static.css",["require","exports","module"], function(require, exports, module){module.exports = ".ace_static_highlight {\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;\n font-size: 12px;\n white-space: pre-wrap\n}\n\n.ace_static_highlight .ace_gutter {\n width: 2em;\n text-align: right;\n padding: 0 3px 0 0;\n margin-right: 3px;\n contain: none;\n}\n\n.ace_static_highlight.ace_show_gutter .ace_line {\n padding-left: 2.6em;\n}\n\n.ace_static_highlight .ace_line { position: relative; }\n\n.ace_static_highlight .ace_gutter-cell {\n -moz-user-select: -moz-none;\n -khtml-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n top: 0;\n bottom: 0;\n left: 0;\n position: absolute;\n}\n\n\n.ace_static_highlight .ace_gutter-cell:before {\n content: counter(ace_line, decimal);\n counter-increment: ace_line;\n}\n.ace_static_highlight {\n counter-reset: ace_line;\n}\n"; + +}); + +define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/ext/static.css","ace/config","ace/lib/dom","ace/lib/lang"], function(require, exports, module){"use strict"; +var EditSession = require("../edit_session").EditSession; +var TextLayer = require("../layer/text").Text; +var baseStyles = require("./static.css"); +var config = require("../config"); +var dom = require("../lib/dom"); +var escapeHTML = require("../lib/lang").escapeHTML; +function Element(type) { + this.type = type; + this.style = {}; + this.textContent = ""; +} +Element.prototype.cloneNode = function () { + return this; +}; +Element.prototype.appendChild = function (child) { + this.textContent += child.toString(); +}; +Element.prototype.toString = function () { + var stringBuilder = []; + if (this.type != "fragment") { + stringBuilder.push("<", this.type); + if (this.className) + stringBuilder.push(" class='", this.className, "'"); + var styleStr = []; + for (var key in this.style) { + styleStr.push(key, ":", this.style[key]); + } + if (styleStr.length) + stringBuilder.push(" style='", styleStr.join(""), "'"); + stringBuilder.push(">"); + } + if (this.textContent) { + stringBuilder.push(this.textContent); + } + if (this.type != "fragment") { + stringBuilder.push(""); + } + return stringBuilder.join(""); +}; +var simpleDom = { + createTextNode: function (textContent, element) { + return escapeHTML(textContent); + }, + createElement: function (type) { + return new Element(type); + }, + createFragment: function () { + return new Element("fragment"); + } +}; +var SimpleTextLayer = function () { + this.config = {}; + this.dom = simpleDom; +}; +SimpleTextLayer.prototype = TextLayer.prototype; +var highlight = function (el, opts, callback) { + var m = el.className.match(/lang-(\w+)/); + var mode = opts.mode || m && ("ace/mode/" + m[1]); + if (!mode) + return false; + var theme = opts.theme || "ace/theme/textmate"; + var data = ""; + var nodes = []; + if (el.firstElementChild) { + var textLen = 0; + for (var i = 0; i < el.childNodes.length; i++) { + var ch = el.childNodes[i]; + if (ch.nodeType == 3) { + textLen += ch.data.length; + data += ch.data; + } + else { + nodes.push(textLen, ch); + } + } + } + else { + data = el.textContent; + if (opts.trim) + data = data.trim(); + } + highlight.render(data, mode, theme, opts.firstLineNumber, !opts.showGutter, function (highlighted) { + dom.importCssString(highlighted.css, "ace_highlight"); + el.innerHTML = highlighted.html; + var container = el.firstChild.firstChild; + for (var i = 0; i < nodes.length; i += 2) { + var pos = highlighted.session.doc.indexToPosition(nodes[i]); + var node = nodes[i + 1]; + var lineEl = container.children[pos.row]; + lineEl && lineEl.appendChild(node); + } + callback && callback(); + }); +}; +highlight.render = function (input, mode, theme, lineStart, disableGutter, callback) { + var waiting = 1; + var modeCache = EditSession.prototype.$modes; + if (typeof theme == "string") { + waiting++; + config.loadModule(['theme', theme], function (m) { + theme = m; + --waiting || done(); + }); + } + var modeOptions; + if (mode && typeof mode === "object" && !mode.getTokenizer) { + modeOptions = mode; + mode = modeOptions.path; + } + if (typeof mode == "string") { + waiting++; + config.loadModule(['mode', mode], function (m) { + if (!modeCache[mode] || modeOptions) + modeCache[mode] = new m.Mode(modeOptions); + mode = modeCache[mode]; + --waiting || done(); + }); + } + function done() { + var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter); + return callback ? callback(result) : result; + } + return --waiting || done(); +}; +highlight.renderSync = function (input, mode, theme, lineStart, disableGutter) { + lineStart = parseInt(lineStart || 1, 10); + var session = new EditSession(""); + session.setUseWorker(false); + session.setMode(mode); + var textLayer = new SimpleTextLayer(); + textLayer.setSession(session); + Object.keys(textLayer.$tabStrings).forEach(function (k) { + if (typeof textLayer.$tabStrings[k] == "string") { + var el = simpleDom.createFragment(); + el.textContent = textLayer.$tabStrings[k]; + textLayer.$tabStrings[k] = el; + } + }); + session.setValue(input); + var length = session.getLength(); + var outerEl = simpleDom.createElement("div"); + outerEl.className = theme.cssClass; + var innerEl = simpleDom.createElement("div"); + innerEl.className = "ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter"); + innerEl.style["counter-reset"] = "ace_line " + (lineStart - 1); + for (var ix = 0; ix < length; ix++) { + var lineEl = simpleDom.createElement("div"); + lineEl.className = "ace_line"; + if (!disableGutter) { + var gutterEl = simpleDom.createElement("span"); + gutterEl.className = "ace_gutter ace_gutter-cell"; + gutterEl.textContent = ""; + lineEl.appendChild(gutterEl); + } + textLayer.$renderLine(lineEl, ix, false); + lineEl.textContent += "\n"; + innerEl.appendChild(lineEl); + } + outerEl.appendChild(innerEl); + return { + css: baseStyles + theme.cssText, + html: outerEl.toString(), + session: session + }; +}; +module.exports = highlight; +module.exports.highlight = highlight; + +}); + (function() { + window.require(["ace/ext/static_highlight"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-statusbar.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-statusbar.js new file mode 100644 index 0000000..35e0bc3 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-statusbar.js @@ -0,0 +1,48 @@ +define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"], function(require, exports, module){"use strict"; +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var StatusBar = function (editor, parentNode) { + this.element = dom.createElement("div"); + this.element.className = "ace_status-indicator"; + this.element.style.cssText = "display: inline-block;"; + parentNode.appendChild(this.element); + var statusUpdate = lang.delayedCall(function () { + this.updateStatus(editor); + }.bind(this)).schedule.bind(null, 100); + editor.on("changeStatus", statusUpdate); + editor.on("changeSelection", statusUpdate); + editor.on("keyboardActivity", statusUpdate); +}; +(function () { + this.updateStatus = function (editor) { + var status = []; + function add(str, separator) { + str && status.push(str, separator || "|"); + } + add(editor.keyBinding.getStatusText(editor)); + if (editor.commands.recording) + add("REC"); + var sel = editor.selection; + var c = sel.lead; + if (!sel.isEmpty()) { + var r = editor.getSelectionRange(); + add("(" + (r.end.row - r.start.row) + ":" + (r.end.column - r.start.column) + ")", " "); + } + add(c.row + ":" + c.column, " "); + if (sel.rangeCount) + add("[" + sel.rangeCount + "]", " "); + status.pop(); + this.element.textContent = status.join(""); + }; +}).call(StatusBar.prototype); +exports.StatusBar = StatusBar; + +}); + (function() { + window.require(["ace/ext/statusbar"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-textarea.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-textarea.js new file mode 100644 index 0000000..5b52867 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-textarea.js @@ -0,0 +1,389 @@ +define("ace/ext/textarea",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/net","ace/ace"], function(require, exports, module){"use strict"; +var event = require("../lib/event"); +var UA = require("../lib/useragent"); +var net = require("../lib/net"); +var ace = require("../ace"); +module.exports = exports = ace; +var getCSSProperty = function (element, container, property) { + var ret = element.style[property]; + if (!ret) { + if (window.getComputedStyle) { + ret = window.getComputedStyle(element, '').getPropertyValue(property); + } + else { + ret = element.currentStyle[property]; + } + } + if (!ret || ret == 'auto' || ret == 'intrinsic') { + ret = container.style[property]; + } + return ret; +}; +function applyStyles(elm, styles) { + for (var style in styles) { + elm.style[style] = styles[style]; + } +} +function setupContainer(element, getValue) { + if (element.type != 'textarea') { + throw new Error("Textarea required!"); + } + var parentNode = element.parentNode; + var container = document.createElement('div'); + var resizeEvent = function () { + var style = 'position:relative;'; + [ + 'margin-top', 'margin-left', 'margin-right', 'margin-bottom' + ].forEach(function (item) { + style += item + ':' + + getCSSProperty(element, container, item) + ';'; + }); + var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px"); + var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px"); + style += 'height:' + height + ';width:' + width + ';'; + style += 'display:inline-block;'; + container.setAttribute('style', style); + }; + event.addListener(window, 'resize', resizeEvent); + resizeEvent(); + parentNode.insertBefore(container, element.nextSibling); + while (parentNode !== document) { + if (parentNode.tagName.toUpperCase() === 'FORM') { + var oldSumit = parentNode.onsubmit; + parentNode.onsubmit = function (evt) { + element.value = getValue(); + if (oldSumit) { + oldSumit.call(this, evt); + } + }; + break; + } + parentNode = parentNode.parentNode; + } + return container; +} +exports.transformTextarea = function (element, options) { + var isFocused = element.autofocus || document.activeElement == element; + var session; + var container = setupContainer(element, function () { + return session.getValue(); + }); + element.style.display = 'none'; + container.style.background = 'white'; + var editorDiv = document.createElement("div"); + applyStyles(editorDiv, { + top: "0px", + left: "0px", + right: "0px", + bottom: "0px", + border: "1px solid gray", + position: "absolute" + }); + container.appendChild(editorDiv); + var settingOpener = document.createElement("div"); + applyStyles(settingOpener, { + position: "absolute", + right: "0px", + bottom: "0px", + cursor: "nw-resize", + border: "solid 9px", + borderColor: "lightblue gray gray #ceade6", + zIndex: 101 + }); + var settingDiv = document.createElement("div"); + var settingDivStyles = { + top: "0px", + left: "20%", + right: "0px", + bottom: "0px", + position: "absolute", + padding: "5px", + zIndex: 100, + color: "white", + display: "none", + overflow: "auto", + fontSize: "14px", + boxShadow: "-5px 2px 3px gray" + }; + if (!UA.isOldIE) { + settingDivStyles.backgroundColor = "rgba(0, 0, 0, 0.6)"; + } + else { + settingDivStyles.backgroundColor = "#333"; + } + applyStyles(settingDiv, settingDivStyles); + container.appendChild(settingDiv); + options = options || exports.defaultOptions; + var editor = ace.edit(editorDiv); + session = editor.getSession(); + session.setValue(element.value || element.innerHTML); + if (isFocused) + editor.focus(); + container.appendChild(settingOpener); + setupApi(editor, editorDiv, settingDiv, ace, options); + setupSettingPanel(settingDiv, settingOpener, editor); + var state = ""; + event.addListener(settingOpener, "mousemove", function (e) { + var rect = this.getBoundingClientRect(); + var x = e.clientX - rect.left, y = e.clientY - rect.top; + if (x + y < (rect.width + rect.height) / 2) { + this.style.cursor = "pointer"; + state = "toggle"; + } + else { + state = "resize"; + this.style.cursor = "nw-resize"; + } + }); + event.addListener(settingOpener, "mousedown", function (e) { + e.preventDefault(); + if (state == "toggle") { + editor.setDisplaySettings(); + return; + } + container.style.zIndex = 100000; + var rect = container.getBoundingClientRect(); + var startX = rect.width + rect.left - e.clientX; + var startY = rect.height + rect.top - e.clientY; + event.capture(settingOpener, function (e) { + container.style.width = e.clientX - rect.left + startX + "px"; + container.style.height = e.clientY - rect.top + startY + "px"; + editor.resize(); + }, function () { }); + }); + return editor; +}; +function load(url, module, callback) { + net.loadScript(url, function () { + require([module], callback); + }); +} +function setupApi(editor, editorDiv, settingDiv, ace, options) { + var session = editor.getSession(); + var renderer = editor.renderer; + function toBool(value) { + return value === "true" || value == true; + } + editor.setDisplaySettings = function (display) { + if (display == null) + display = settingDiv.style.display == "none"; + if (display) { + settingDiv.style.display = "block"; + settingDiv.hideButton.focus(); + editor.on("focus", function onFocus() { + editor.removeListener("focus", onFocus); + settingDiv.style.display = "none"; + }); + } + else { + editor.focus(); + } + }; + editor.$setOption = editor.setOption; + editor.$getOption = editor.getOption; + editor.setOption = function (key, value) { + switch (key) { + case "mode": + editor.$setOption("mode", "ace/mode/" + value); + break; + case "theme": + editor.$setOption("theme", "ace/theme/" + value); + break; + case "keybindings": + switch (value) { + case "vim": + editor.setKeyboardHandler("ace/keyboard/vim"); + break; + case "emacs": + editor.setKeyboardHandler("ace/keyboard/emacs"); + break; + default: + editor.setKeyboardHandler(null); + } + break; + case "wrap": + case "fontSize": + editor.$setOption(key, value); + break; + default: + editor.$setOption(key, toBool(value)); + } + }; + editor.getOption = function (key) { + switch (key) { + case "mode": + return editor.$getOption("mode").substr("ace/mode/".length); + break; + case "theme": + return editor.$getOption("theme").substr("ace/theme/".length); + break; + case "keybindings": + var value = editor.getKeyboardHandler(); + switch (value && value.$id) { + case "ace/keyboard/vim": + return "vim"; + case "ace/keyboard/emacs": + return "emacs"; + default: + return "ace"; + } + break; + default: + return editor.$getOption(key); + } + }; + editor.setOptions(options); + return editor; +} +function setupSettingPanel(settingDiv, settingOpener, editor) { + var BOOL = null; + var desc = { + mode: "Mode:", + wrap: "Soft Wrap:", + theme: "Theme:", + fontSize: "Font Size:", + showGutter: "Display Gutter:", + keybindings: "Keyboard", + showPrintMargin: "Show Print Margin:", + useSoftTabs: "Use Soft Tabs:", + showInvisibles: "Show Invisibles" + }; + var optionValues = { + mode: { + text: "Plain", + javascript: "JavaScript", + xml: "XML", + html: "HTML", + css: "CSS", + scss: "SCSS", + python: "Python", + php: "PHP", + java: "Java", + ruby: "Ruby", + c_cpp: "C/C++", + coffee: "CoffeeScript", + json: "json", + perl: "Perl", + clojure: "Clojure", + ocaml: "OCaml", + csharp: "C#", + haxe: "haXe", + svg: "SVG", + textile: "Textile", + groovy: "Groovy", + liquid: "Liquid", + Scala: "Scala" + }, + theme: { + clouds: "Clouds", + clouds_midnight: "Clouds Midnight", + cobalt: "Cobalt", + crimson_editor: "Crimson Editor", + dawn: "Dawn", + gob: "Green on Black", + eclipse: "Eclipse", + idle_fingers: "Idle Fingers", + kr_theme: "Kr Theme", + merbivore: "Merbivore", + merbivore_soft: "Merbivore Soft", + mono_industrial: "Mono Industrial", + monokai: "Monokai", + pastel_on_dark: "Pastel On Dark", + solarized_dark: "Solarized Dark", + solarized_light: "Solarized Light", + textmate: "Textmate", + twilight: "Twilight", + vibrant_ink: "Vibrant Ink" + }, + showGutter: BOOL, + fontSize: { + "10px": "10px", + "11px": "11px", + "12px": "12px", + "14px": "14px", + "16px": "16px" + }, + wrap: { + off: "Off", + 40: "40", + 80: "80", + free: "Free" + }, + keybindings: { + ace: "ace", + vim: "vim", + emacs: "emacs" + }, + showPrintMargin: BOOL, + useSoftTabs: BOOL, + showInvisibles: BOOL + }; + var table = []; + table.push(""); + function renderOption(builder, option, obj, cValue) { + if (!obj) { + builder.push(""); + return; + } + builder.push(""); + } + for (var option in exports.defaultOptions) { + table.push(""); + table.push(""); + } + table.push("
SettingValue
", desc[option], ""); + renderOption(table, option, optionValues[option], editor.getOption(option)); + table.push("
"); + settingDiv.innerHTML = table.join(""); + var onChange = function (e) { + var select = e.currentTarget; + editor.setOption(select.title, select.value); + }; + var onClick = function (e) { + var cb = e.currentTarget; + editor.setOption(cb.title, cb.checked); + }; + var selects = settingDiv.getElementsByTagName("select"); + for (var i = 0; i < selects.length; i++) + selects[i].onchange = onChange; + var cbs = settingDiv.getElementsByTagName("input"); + for (var i = 0; i < cbs.length; i++) + cbs[i].onclick = onClick; + var button = document.createElement("input"); + button.type = "button"; + button.value = "Hide"; + event.addListener(button, "click", function () { + editor.setDisplaySettings(false); + }); + settingDiv.appendChild(button); + settingDiv.hideButton = button; +} +exports.defaultOptions = { + mode: "javascript", + theme: "textmate", + wrap: "off", + fontSize: "12px", + showGutter: "false", + keybindings: "ace", + showPrintMargin: "false", + useSoftTabs: "true", + showInvisibles: "false" +}; + +}); + (function() { + window.require(["ace/ext/textarea"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-themelist.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-themelist.js new file mode 100644 index 0000000..4cf752d --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-themelist.js @@ -0,0 +1,71 @@ +define("ace/ext/themelist",["require","exports","module"], function(require, exports, module){/** + * Generates a list of themes available when ace was built. + * @fileOverview Generates a list of themes available when ace was built. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ +"use strict"; +var themeData = [ + ["Chrome"], + ["Clouds"], + ["Crimson Editor"], + ["Dawn"], + ["Dreamweaver"], + ["Eclipse"], + ["GitHub"], + ["IPlastic"], + ["Solarized Light"], + ["TextMate"], + ["Tomorrow"], + ["XCode"], + ["Kuroir"], + ["KatzenMilch"], + ["SQL Server", "sqlserver", "light"], + ["Ambiance", "ambiance", "dark"], + ["Chaos", "chaos", "dark"], + ["Clouds Midnight", "clouds_midnight", "dark"], + ["Dracula", "", "dark"], + ["Cobalt", "cobalt", "dark"], + ["Gruvbox", "gruvbox", "dark"], + ["Green on Black", "gob", "dark"], + ["idle Fingers", "idle_fingers", "dark"], + ["krTheme", "kr_theme", "dark"], + ["Merbivore", "merbivore", "dark"], + ["Merbivore Soft", "merbivore_soft", "dark"], + ["Mono Industrial", "mono_industrial", "dark"], + ["Monokai", "monokai", "dark"], + ["Nord Dark", "nord_dark", "dark"], + ["One Dark", "one_dark", "dark"], + ["Pastel on dark", "pastel_on_dark", "dark"], + ["Solarized Dark", "solarized_dark", "dark"], + ["Terminal", "terminal", "dark"], + ["Tomorrow Night", "tomorrow_night", "dark"], + ["Tomorrow Night Blue", "tomorrow_night_blue", "dark"], + ["Tomorrow Night Bright", "tomorrow_night_bright", "dark"], + ["Tomorrow Night 80s", "tomorrow_night_eighties", "dark"], + ["Twilight", "twilight", "dark"], + ["Vibrant Ink", "vibrant_ink", "dark"] +]; +exports.themesByName = {}; +exports.themes = themeData.map(function (data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; +}); + +}); + (function() { + window.require(["ace/ext/themelist"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/ext-whitespace.js b/src/main/resources/static/assets/js/vendor/template/build/src/ext-whitespace.js new file mode 100644 index 0000000..af3b0c5 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/ext-whitespace.js @@ -0,0 +1,193 @@ +define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"], function(require, exports, module){"use strict"; +var lang = require("../lib/lang"); +exports.$detectIndentation = function (lines, fallback) { + var stats = []; + var changes = []; + var tabIndents = 0; + var prevSpaces = 0; + var max = Math.min(lines.length, 1000); + for (var i = 0; i < max; i++) { + var line = lines[i]; + if (!/^\s*[^*+\-\s]/.test(line)) + continue; + if (line[0] == "\t") { + tabIndents++; + prevSpaces = -Number.MAX_VALUE; + } + else { + var spaces = line.match(/^ */)[0].length; + if (spaces && line[spaces] != "\t") { + var diff = spaces - prevSpaces; + if (diff > 0 && !(prevSpaces % diff) && !(spaces % diff)) + changes[diff] = (changes[diff] || 0) + 1; + stats[spaces] = (stats[spaces] || 0) + 1; + } + prevSpaces = spaces; + } + while (i < max && line[line.length - 1] == "\\") + line = lines[i++]; + } + function getScore(indent) { + var score = 0; + for (var i = indent; i < stats.length; i += indent) + score += stats[i] || 0; + return score; + } + var changesTotal = changes.reduce(function (a, b) { return a + b; }, 0); + var first = { score: 0, length: 0 }; + var spaceIndents = 0; + for (var i = 1; i < 12; i++) { + var score = getScore(i); + if (i == 1) { + spaceIndents = score; + score = stats[1] ? 0.9 : 0.8; + if (!stats.length) + score = 0; + } + else + score /= spaceIndents; + if (changes[i]) + score += changes[i] / changesTotal; + if (score > first.score) + first = { score: score, length: i }; + } + if (first.score && first.score > 1.4) + var tabLength = first.length; + if (tabIndents > spaceIndents + 1) { + if (tabLength == 1 || spaceIndents < tabIndents / 4 || first.score < 1.8) + tabLength = undefined; + return { ch: "\t", length: tabLength }; + } + if (spaceIndents > tabIndents + 1) + return { ch: " ", length: tabLength }; +}; +exports.detectIndentation = function (session) { + var lines = session.getLines(0, 1000); + var indent = exports.$detectIndentation(lines) || {}; + if (indent.ch) + session.setUseSoftTabs(indent.ch == " "); + if (indent.length) + session.setTabSize(indent.length); + return indent; +}; +exports.trimTrailingSpace = function (session, options) { + var doc = session.getDocument(); + var lines = doc.getAllLines(); + var min = options && options.trimEmpty ? -1 : 0; + var cursors = [], ci = -1; + if (options && options.keepCursorPosition) { + if (session.selection.rangeCount) { + session.selection.rangeList.ranges.forEach(function (x, i, ranges) { + var next = ranges[i + 1]; + if (next && next.cursor.row == x.cursor.row) + return; + cursors.push(x.cursor); + }); + } + else { + cursors.push(session.selection.getCursor()); + } + ci = 0; + } + var cursorRow = cursors[ci] && cursors[ci].row; + for (var i = 0, l = lines.length; i < l; i++) { + var line = lines[i]; + var index = line.search(/\s+$/); + if (i == cursorRow) { + if (index < cursors[ci].column && index > min) + index = cursors[ci].column; + ci++; + cursorRow = cursors[ci] ? cursors[ci].row : -1; + } + if (index > min) + doc.removeInLine(i, index, line.length); + } +}; +exports.convertIndentation = function (session, ch, len) { + var oldCh = session.getTabString()[0]; + var oldLen = session.getTabSize(); + if (!len) + len = oldLen; + if (!ch) + ch = oldCh; + var tab = ch == "\t" ? ch : lang.stringRepeat(ch, len); + var doc = session.doc; + var lines = doc.getAllLines(); + var cache = {}; + var spaceCache = {}; + for (var i = 0, l = lines.length; i < l; i++) { + var line = lines[i]; + var match = line.match(/^\s*/)[0]; + if (match) { + var w = session.$getStringScreenWidth(match)[0]; + var tabCount = Math.floor(w / oldLen); + var reminder = w % oldLen; + var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount)); + toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(" ", reminder)); + if (toInsert != match) { + doc.removeInLine(i, 0, match.length); + doc.insertInLine({ row: i, column: 0 }, toInsert); + } + } + } + session.setTabSize(len); + session.setUseSoftTabs(ch == " "); +}; +exports.$parseStringArg = function (text) { + var indent = {}; + if (/t/.test(text)) + indent.ch = "\t"; + else if (/s/.test(text)) + indent.ch = " "; + var m = text.match(/\d+/); + if (m) + indent.length = parseInt(m[0], 10); + return indent; +}; +exports.$parseArg = function (arg) { + if (!arg) + return {}; + if (typeof arg == "string") + return exports.$parseStringArg(arg); + if (typeof arg.text == "string") + return exports.$parseStringArg(arg.text); + return arg; +}; +exports.commands = [{ + name: "detectIndentation", + description: "Detect indentation from content", + exec: function (editor) { + exports.detectIndentation(editor.session); + } + }, { + name: "trimTrailingSpace", + description: "Trim trailing whitespace", + exec: function (editor, args) { + exports.trimTrailingSpace(editor.session, args); + } + }, { + name: "convertIndentation", + description: "Convert indentation to ...", + exec: function (editor, arg) { + var indent = exports.$parseArg(arg); + exports.convertIndentation(editor.session, indent.ch, indent.length); + } + }, { + name: "setIndentation", + description: "Set indentation", + exec: function (editor, arg) { + var indent = exports.$parseArg(arg); + indent.length && editor.session.setTabSize(indent.length); + indent.ch && editor.session.setUseSoftTabs(indent.ch == " "); + } + }]; + +}); + (function() { + window.require(["ace/ext/whitespace"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/edifact.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/edifact.js new file mode 100644 index 0000000..56740a7 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/edifact.js @@ -0,0 +1,17 @@ +define("ace/snippets/edifact.snippets",["require","exports","module"], function(require, exports, module){module.exports = "## Access Modifiers\nsnippet u\n\tUN\nsnippet un\n\tUNB\nsnippet pr\n\tprivate\n##\n## Annotations\nsnippet before\n\t@Before\n\tstatic void ${1:intercept}(${2:args}) { ${3} }\nsnippet mm\n\t@ManyToMany\n\t${1}\nsnippet mo\n\t@ManyToOne\n\t${1}\nsnippet om\n\t@OneToMany${1:(cascade=CascadeType.ALL)}\n\t${2}\nsnippet oo\n\t@OneToOne\n\t${1}\n##\n## Basic Java packages and import\nsnippet im\n\timport\nsnippet j.b\n\tjava.beans.\nsnippet j.i\n\tjava.io.\nsnippet j.m\n\tjava.math.\nsnippet j.n\n\tjava.net.\nsnippet j.u\n\tjava.util.\n##\n## Class\nsnippet cl\n\tclass ${1:`Filename(\"\", \"untitled\")`} ${2}\nsnippet in\n\tinterface ${1:`Filename(\"\", \"untitled\")`} ${2:extends Parent}${3}\nsnippet tc\n\tpublic class ${1:`Filename()`} extends ${2:TestCase}\n##\n## Class Enhancements\nsnippet ext\n\textends \nsnippet imp\n\timplements\n##\n## Comments\nsnippet /*\n\t/*\n\t * ${1}\n\t */\n##\n## Constants\nsnippet co\n\tstatic public final ${1:String} ${2:var} = ${3};${4}\nsnippet cos\n\tstatic public final String ${1:var} = \"${2}\";${3}\n##\n## Control Statements\nsnippet case\n\tcase ${1}:\n\t\t${2}\nsnippet def\n\tdefault:\n\t\t${2}\nsnippet el\n\telse\nsnippet elif\n\telse if (${1}) ${2}\nsnippet if\n\tif (${1}) ${2}\nsnippet sw\n\tswitch (${1}) {\n\t\t${2}\n\t}\n##\n## Create a Method\nsnippet m\n\t${1:void} ${2:method}(${3}) ${4:throws }${5}\n##\n## Create a Variable\nsnippet v\n\t${1:String} ${2:var}${3: = null}${4};${5}\n##\n## Enhancements to Methods, variables, classes, etc.\nsnippet ab\n\tabstract\nsnippet fi\n\tfinal\nsnippet st\n\tstatic\nsnippet sy\n\tsynchronized\n##\n## Error Methods\nsnippet err\n\tSystem.err.print(\"${1:Message}\");\nsnippet errf\n\tSystem.err.printf(\"${1:Message}\", ${2:exception});\nsnippet errln\n\tSystem.err.println(\"${1:Message}\");\n##\n## Exception Handling\nsnippet as\n\tassert ${1:test} : \"${2:Failure message}\";${3}\nsnippet ca\n\tcatch(${1:Exception} ${2:e}) ${3}\nsnippet thr\n\tthrow\nsnippet ths\n\tthrows\nsnippet try\n\ttry {\n\t\t${3}\n\t} catch(${1:Exception} ${2:e}) {\n\t}\nsnippet tryf\n\ttry {\n\t\t${3}\n\t} catch(${1:Exception} ${2:e}) {\n\t} finally {\n\t}\n##\n## Find Methods\nsnippet findall\n\tList<${1:listName}> ${2:items} = ${1}.findAll();${3}\nsnippet findbyid\n\t${1:var} ${2:item} = ${1}.findById(${3});${4}\n##\n## Javadocs\nsnippet /**\n\t/**\n\t * ${1}\n\t */\nsnippet @au\n\t@author `system(\"grep \\`id -un\\` /etc/passwd | cut -d \\\":\\\" -f5 | cut -d \\\",\\\" -f1\")`\nsnippet @br\n\t@brief ${1:Description}\nsnippet @fi\n\t@file ${1:`Filename()`}.java\nsnippet @pa\n\t@param ${1:param}\nsnippet @re\n\t@return ${1:param}\n##\n## Logger Methods\nsnippet debug\n\tLogger.debug(${1:param});${2}\nsnippet error\n\tLogger.error(${1:param});${2}\nsnippet info\n\tLogger.info(${1:param});${2}\nsnippet warn\n\tLogger.warn(${1:param});${2}\n##\n## Loops\nsnippet enfor\n\tfor (${1} : ${2}) ${3}\nsnippet for\n\tfor (${1}; ${2}; ${3}) ${4}\nsnippet wh\n\twhile (${1}) ${2}\n##\n## Main method\nsnippet main\n\tpublic static void main (String[] args) {\n\t\t${1:/* code */}\n\t}\n##\n## Print Methods\nsnippet print\n\tSystem.out.print(\"${1:Message}\");\nsnippet printf\n\tSystem.out.printf(\"${1:Message}\", ${2:args});\nsnippet println\n\tSystem.out.println(${1});\n##\n## Render Methods\nsnippet ren\n\trender(${1:param});${2}\nsnippet rena\n\trenderArgs.put(\"${1}\", ${2});${3}\nsnippet renb\n\trenderBinary(${1:param});${2}\nsnippet renj\n\trenderJSON(${1:param});${2}\nsnippet renx\n\trenderXml(${1:param});${2}\n##\n## Setter and Getter Methods\nsnippet set\n\t${1:public} void set${3:}(${2:String} ${4:}){\n\t\tthis.$4 = $4;\n\t}\nsnippet get\n\t${1:public} ${2:String} get${3:}(){\n\t\treturn this.${4:};\n\t}\n##\n## Terminate Methods or Loops\nsnippet re\n\treturn\nsnippet br\n\tbreak;\n##\n## Test Methods\nsnippet t\n\tpublic void test${1:Name}() throws Exception {\n\t\t${2}\n\t}\nsnippet test\n\t@Test\n\tpublic void test${1:Name}() throws Exception {\n\t\t${2}\n\t}\n##\n## Utils\nsnippet Sc\n\tScanner\n##\n## Miscellaneous\nsnippet action\n\tpublic static void ${1:index}(${2:args}) { ${3} }\nsnippet rnf\n\tnotFound(${1:param});${2}\nsnippet rnfin\n\tnotFoundIfNull(${1:param});${2}\nsnippet rr\n\tredirect(${1:param});${2}\nsnippet ru\n\tunauthorized(${1:param});${2}\nsnippet unless\n\t(unless=${1:param});${2}\n"; + +}); + +define("ace/snippets/edifact",["require","exports","module","ace/snippets/edifact.snippets"], function(require, exports, module){"use strict"; +exports.snippetText = require("./edifact.snippets"); +exports.scope = "edifact"; + +}); + (function() { + window.require(["ace/snippets/edifact"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/eiffel.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/eiffel.js new file mode 100644 index 0000000..0376642 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/eiffel.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/eiffel"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/ejs.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/ejs.js new file mode 100644 index 0000000..d733c66 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/ejs.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/ejs"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/elixir.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/elixir.js new file mode 100644 index 0000000..4d92731 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/elixir.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/elixir"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/elm.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/elm.js new file mode 100644 index 0000000..147f472 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/elm.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/elm"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/erlang.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/erlang.js new file mode 100644 index 0000000..cc2e59a --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/erlang.js @@ -0,0 +1,17 @@ +define("ace/snippets/erlang.snippets",["require","exports","module"], function(require, exports, module){module.exports = "# module and export all\nsnippet mod\n\t-module(${1:`Filename('', 'my')`}).\n\t\n\t-compile([export_all]).\n\t\n\tstart() ->\n\t ${2}\n\t\n\tstop() ->\n\t ok.\n# define directive\nsnippet def\n\t-define(${1:macro}, ${2:body}).${3}\n# export directive\nsnippet exp\n\t-export([${1:function}/${2:arity}]).\n# include directive\nsnippet inc\n\t-include(\"${1:file}\").${2}\n# behavior directive\nsnippet beh\n\t-behaviour(${1:behaviour}).${2}\n# if expression\nsnippet if\n\tif\n\t ${1:guard} ->\n\t ${2:body}\n\tend\n# case expression\nsnippet case\n\tcase ${1:expression} of\n\t ${2:pattern} ->\n\t ${3:body};\n\tend\n# anonymous function\nsnippet fun\n\tfun (${1:Parameters}) -> ${2:body} end${3}\n# try...catch\nsnippet try\n\ttry\n\t ${1}\n\tcatch\n\t ${2:_:_} -> ${3:got_some_exception}\n\tend\n# record directive\nsnippet rec\n\t-record(${1:record}, {\n\t ${2:field}=${3:value}}).${4}\n# todo comment\nsnippet todo\n\t%% TODO: ${1}\n## Snippets below (starting with '%') are in EDoc format.\n## See http://www.erlang.org/doc/apps/edoc/chapter.html#id56887 for more details\n# doc comment\nsnippet %d\n\t%% @doc ${1}\n# end of doc comment\nsnippet %e\n\t%% @end\n# specification comment\nsnippet %s\n\t%% @spec ${1}\n# private function marker\nsnippet %p\n\t%% @private\n# OTP application\nsnippet application\n\t-module(${1:`Filename('', 'my')`}).\n\n\t-behaviour(application).\n\n\t-export([start/2, stop/1]).\n\n\tstart(_Type, _StartArgs) ->\n\t case ${2:root_supervisor}:start_link() of\n\t {ok, Pid} ->\n\t {ok, Pid};\n\t Other ->\n\t\t {error, Other}\n\t end.\n\n\tstop(_State) ->\n\t ok.\t\n# OTP supervisor\nsnippet supervisor\n\t-module(${1:`Filename('', 'my')`}).\n\n\t-behaviour(supervisor).\n\n\t%% API\n\t-export([start_link/0]).\n\n\t%% Supervisor callbacks\n\t-export([init/1]).\n\n\t-define(SERVER, ?MODULE).\n\n\tstart_link() ->\n\t supervisor:start_link({local, ?SERVER}, ?MODULE, []).\n\n\tinit([]) ->\n\t Server = {${2:my_server}, {$2, start_link, []},\n\t permanent, 2000, worker, [$2]},\n\t Children = [Server],\n\t RestartStrategy = {one_for_one, 0, 1},\n\t {ok, {RestartStrategy, Children}}.\n# OTP gen_server\nsnippet gen_server\n\t-module(${1:`Filename('', 'my')`}).\n\n\t-behaviour(gen_server).\n\n\t%% API\n\t-export([\n\t start_link/0\n\t ]).\n\n\t%% gen_server callbacks\n\t-export([init/1, handle_call/3, handle_cast/2, handle_info/2,\n\t terminate/2, code_change/3]).\n\n\t-define(SERVER, ?MODULE).\n\n\t-record(state, {}).\n\n\t%%%===================================================================\n\t%%% API\n\t%%%===================================================================\n\n\tstart_link() ->\n\t gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).\n\n\t%%%===================================================================\n\t%%% gen_server callbacks\n\t%%%===================================================================\n\n\tinit([]) ->\n\t {ok, #state{}}.\n\n\thandle_call(_Request, _From, State) ->\n\t Reply = ok,\n\t {reply, Reply, State}.\n\n\thandle_cast(_Msg, State) ->\n\t {noreply, State}.\n\n\thandle_info(_Info, State) ->\n\t {noreply, State}.\n\n\tterminate(_Reason, _State) ->\n\t ok.\n\n\tcode_change(_OldVsn, State, _Extra) ->\n\t {ok, State}.\n\n\t%%%===================================================================\n\t%%% Internal functions\n\t%%%===================================================================\n\n"; + +}); + +define("ace/snippets/erlang",["require","exports","module","ace/snippets/erlang.snippets"], function(require, exports, module){"use strict"; +exports.snippetText = require("./erlang.snippets"); +exports.scope = "erlang"; + +}); + (function() { + window.require(["ace/snippets/erlang"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/forth.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/forth.js new file mode 100644 index 0000000..861cdda --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/forth.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/forth"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fortran.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fortran.js new file mode 100644 index 0000000..4ad332b --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fortran.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/fortran"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fsharp.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fsharp.js new file mode 100644 index 0000000..e79909e --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fsharp.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/fsharp"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fsl.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fsl.js new file mode 100644 index 0000000..26abaab --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/fsl.js @@ -0,0 +1,17 @@ +define("ace/snippets/fsl.snippets",["require","exports","module"], function(require, exports, module){module.exports = "snippet header\n\tmachine_name : \"\";\n\tmachine_author : \"\";\n\tmachine_license : MIT;\n\tmachine_comment : \"\";\n\tmachine_language : en;\n\tmachine_version : 1.0.0;\n\tfsl_version : 1.0.0;\n\tstart_states : [];\n"; + +}); + +define("ace/snippets/fsl",["require","exports","module","ace/snippets/fsl.snippets"], function(require, exports, module){"use strict"; +exports.snippetText = require("./fsl.snippets"); +exports.scope = "fsl"; + +}); + (function() { + window.require(["ace/snippets/fsl"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/ftl.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/ftl.js new file mode 100644 index 0000000..1146c3b --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/ftl.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/ftl"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/gcode.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/gcode.js new file mode 100644 index 0000000..516ff7b --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/gcode.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/gcode"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/build/src/snippets/gherkin.js b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/gherkin.js new file mode 100644 index 0000000..106a05e --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/build/src/snippets/gherkin.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/gherkin"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-beautify.js b/src/main/resources/static/assets/js/vendor/template/src/ext-beautify.js new file mode 100644 index 0000000..c5e04dc --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-beautify.js @@ -0,0 +1,331 @@ +define("ace/ext/beautify",["require","exports","module","ace/token_iterator"], function(require, exports, module){// [WIP] +"use strict"; +var TokenIterator = require("../token_iterator").TokenIterator; +function is(token, type) { + return token.type.lastIndexOf(type + ".xml") > -1; +} +exports.singletonTags = ["area", "base", "br", "col", "command", "embed", "hr", "html", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]; +exports.blockTags = ["article", "aside", "blockquote", "body", "div", "dl", "fieldset", "footer", "form", "head", "header", "html", "nav", "ol", "p", "script", "section", "style", "table", "tbody", "tfoot", "thead", "ul"]; +exports.formatOptions = { + lineBreaksAfterCommasInCurlyBlock: true +}; +exports.beautify = function (session) { + var iterator = new TokenIterator(session, 0, 0); + var token = iterator.getCurrentToken(); + var tabString = session.getTabString(); + var singletonTags = exports.singletonTags; + var blockTags = exports.blockTags; + var formatOptions = exports.formatOptions || {}; + var nextToken; + var breakBefore = false; + var spaceBefore = false; + var spaceAfter = false; + var code = ""; + var value = ""; + var tagName = ""; + var depth = 0; + var lastDepth = 0; + var lastIndent = 0; + var indent = 0; + var unindent = 0; + var roundDepth = 0; + var curlyDepth = 0; + var row; + var curRow = 0; + var rowsToAdd = 0; + var rowTokens = []; + var abort = false; + var i; + var indentNextLine = false; + var inTag = false; + var inCSS = false; + var inBlock = false; + var levels = { 0: 0 }; + var parents = []; + var caseBody = false; + var trimNext = function () { + if (nextToken && nextToken.value && nextToken.type !== 'string.regexp') + nextToken.value = nextToken.value.replace(/^\s*/, ""); + }; + var trimLine = function () { + var end = code.length - 1; + while (true) { + if (end == 0) + break; + if (code[end] !== " ") + break; + end = end - 1; + } + code = code.slice(0, end + 1); + }; + var trimCode = function () { + code = code.trimRight(); + breakBefore = false; + }; + while (token !== null) { + curRow = iterator.getCurrentTokenRow(); + rowTokens = iterator.$rowTokens; + nextToken = iterator.stepForward(); + if (typeof token !== "undefined") { + value = token.value; + unindent = 0; + inCSS = (tagName === "style" || session.$modeId === "ace/mode/css"); + if (is(token, "tag-open")) { + inTag = true; + if (nextToken) + inBlock = (blockTags.indexOf(nextToken.value) !== -1); + if (value === " 0; rowsToAdd--) + code += "\n"; + breakBefore = true; + if (!is(token, "comment") && !token.type.match(/^(comment|string)$/)) + value = value.trimLeft(); + } + if (value) { + if (token.type === "keyword" && value.match(/^(if|else|elseif|for|foreach|while|switch)$/)) { + parents[depth] = value; + trimNext(); + spaceAfter = true; + if (value.match(/^(else|elseif)$/)) { + if (code.match(/\}[\s]*$/)) { + trimCode(); + spaceBefore = true; + } + } + } + else if (token.type === "paren.lparen") { + trimNext(); + if (value.substr(-1) === "{") { + spaceAfter = true; + indentNextLine = false; + if (!inTag) + rowsToAdd = 1; + } + if (value.substr(0, 1) === "{") { + spaceBefore = true; + if (code.substr(-1) !== '[' && code.trimRight().substr(-1) === '[') { + trimCode(); + spaceBefore = false; + } + else if (code.trimRight().substr(-1) === ')') { + trimCode(); + } + else { + trimLine(); + } + } + } + else if (token.type === "paren.rparen") { + unindent = 1; + if (value.substr(0, 1) === "}") { + if (parents[depth - 1] === 'case') + unindent++; + if (code.trimRight().substr(-1) === '{') { + trimCode(); + } + else { + spaceBefore = true; + if (inCSS) + rowsToAdd += 2; + } + } + if (value.substr(0, 1) === "]") { + if (code.substr(-1) !== '}' && code.trimRight().substr(-1) === '}') { + spaceBefore = false; + indent++; + trimCode(); + } + } + if (value.substr(0, 1) === ")") { + if (code.substr(-1) !== '(' && code.trimRight().substr(-1) === '(') { + spaceBefore = false; + indent++; + trimCode(); + } + } + trimLine(); + } + else if ((token.type === "keyword.operator" || token.type === "keyword") && value.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)) { + trimCode(); + trimNext(); + spaceBefore = true; + spaceAfter = true; + } + else if (token.type === "punctuation.operator" && value === ';') { + trimCode(); + trimNext(); + spaceAfter = true; + if (inCSS) + rowsToAdd++; + } + else if (token.type === "punctuation.operator" && value.match(/^(:|,)$/)) { + trimCode(); + trimNext(); + if (value.match(/^(,)$/) && curlyDepth > 0 && roundDepth === 0 && formatOptions.lineBreaksAfterCommasInCurlyBlock) { + rowsToAdd++; + } + else { + spaceAfter = true; + breakBefore = false; + } + } + else if (token.type === "support.php_tag" && value === "?>" && !breakBefore) { + trimCode(); + spaceBefore = true; + } + else if (is(token, "attribute-name") && code.substr(-1).match(/^\s$/)) { + spaceBefore = true; + } + else if (is(token, "attribute-equals")) { + trimLine(); + trimNext(); + } + else if (is(token, "tag-close")) { + trimLine(); + if (value === "/>") + spaceBefore = true; + } + else if (token.type === "keyword" && value.match(/^(case|default)$/)) { + if (caseBody) + unindent = 1; + } + if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['"@]$/))) { + indent = lastIndent; + if (depth > lastDepth) { + indent++; + for (i = depth; i > lastDepth; i--) + levels[i] = indent; + } + else if (depth < lastDepth) + indent = levels[depth]; + lastDepth = depth; + lastIndent = indent; + if (unindent) + indent -= unindent; + if (indentNextLine && !roundDepth) { + indent++; + indentNextLine = false; + } + for (i = 0; i < indent; i++) + code += tabString; + } + if (token.type === "keyword" && value.match(/^(case|default)$/)) { + if (caseBody === false) { + parents[depth] = value; + depth++; + caseBody = true; + } + } + else if (token.type === "keyword" && value.match(/^(break)$/)) { + if (parents[depth - 1] && parents[depth - 1].match(/^(case|default)$/)) { + depth--; + caseBody = false; + } + } + if (token.type === "paren.lparen") { + roundDepth += (value.match(/\(/g) || []).length; + curlyDepth += (value.match(/\{/g) || []).length; + depth += value.length; + } + if (token.type === "keyword" && value.match(/^(if|else|elseif|for|while)$/)) { + indentNextLine = true; + roundDepth = 0; + } + else if (!roundDepth && value.trim() && token.type !== "comment") + indentNextLine = false; + if (token.type === "paren.rparen") { + roundDepth -= (value.match(/\)/g) || []).length; + curlyDepth -= (value.match(/\}/g) || []).length; + for (i = 0; i < value.length; i++) { + depth--; + if (value.substr(i, 1) === '}' && parents[depth] === 'case') { + depth--; + } + } + } + if (token.type == "text") + value = value.replace(/\s+$/, " "); + if (spaceBefore && !breakBefore) { + trimLine(); + if (code.substr(-1) !== "\n") + code += " "; + } + code += value; + if (spaceAfter) + code += " "; + breakBefore = false; + spaceBefore = false; + spaceAfter = false; + if ((is(token, "tag-close") && (inBlock || blockTags.indexOf(tagName) !== -1)) || (is(token, "doctype") && value === ">")) { + if (inBlock && nextToken && nextToken.value === "") { + depth--; + } + } + if (is(token, "tag-name")) { + tagName = value; + } + row = curRow; + } + } + token = nextToken; + } + code = code.trim(); + session.doc.setValue(code); +}; +exports.commands = [{ + name: "beautify", + description: "Format selection (Beautify)", + exec: function (editor) { + exports.beautify(editor.session); + }, + bindKey: "Ctrl-Shift-B" + }]; + +}); + (function() { + window.require(["ace/ext/beautify"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-code_lens.js b/src/main/resources/static/assets/js/vendor/template/src/ext-code_lens.js new file mode 100644 index 0000000..22f9955 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-code_lens.js @@ -0,0 +1,203 @@ +define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var LineWidgets = require("../line_widgets").LineWidgets; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); +function clearLensElements(renderer) { + var textLayer = renderer.$textLayer; + var lensElements = textLayer.$lenses; + if (lensElements) + lensElements.forEach(function (el) { el.remove(); }); + textLayer.$lenses = null; +} +function renderWidgets(changes, renderer) { + var changed = changes & renderer.CHANGE_LINES + || changes & renderer.CHANGE_FULL + || changes & renderer.CHANGE_SCROLL + || changes & renderer.CHANGE_TEXT; + if (!changed) + return; + var session = renderer.session; + var lineWidgets = renderer.session.lineWidgets; + var textLayer = renderer.$textLayer; + var lensElements = textLayer.$lenses; + if (!lineWidgets) { + if (lensElements) + clearLensElements(renderer); + return; + } + var textCells = renderer.$textLayer.$lines.cells; + var config = renderer.layerConfig; + var padding = renderer.$padding; + if (!lensElements) + lensElements = textLayer.$lenses = []; + var index = 0; + for (var i = 0; i < textCells.length; i++) { + var row = textCells[i].row; + var widget = lineWidgets[row]; + var lenses = widget && widget.lenses; + if (!lenses || !lenses.length) + continue; + var lensContainer = lensElements[index]; + if (!lensContainer) { + lensContainer = lensElements[index] + = dom.buildDom(["div", { class: "ace_codeLens" }], renderer.container); + } + lensContainer.style.height = config.lineHeight + "px"; + index++; + for (var j = 0; j < lenses.length; j++) { + var el = lensContainer.childNodes[2 * j]; + if (!el) { + if (j != 0) + lensContainer.appendChild(dom.createTextNode("\xa0|\xa0")); + el = dom.buildDom(["a"], lensContainer); + } + el.textContent = lenses[j].title; + el.lensCommand = lenses[j]; + } + while (lensContainer.childNodes.length > 2 * j - 1) + lensContainer.lastChild.remove(); + var top = renderer.$cursorLayer.getPixelPosition({ + row: row, + column: 0 + }, true).top - config.lineHeight * widget.rowsAbove - config.offset; + lensContainer.style.top = top + "px"; + var left = renderer.gutterWidth; + var indent = session.getLine(row).search(/\S|$/); + if (indent == -1) + indent = 0; + left += indent * config.characterWidth; + lensContainer.style.paddingLeft = padding + left + "px"; + } + while (index < lensElements.length) + lensElements.pop().remove(); +} +function clearCodeLensWidgets(session) { + if (!session.lineWidgets) + return; + var widgetManager = session.widgetManager; + session.lineWidgets.forEach(function (widget) { + if (widget && widget.lenses) + widgetManager.removeLineWidget(widget); + }); +} +exports.setLenses = function (session, lenses) { + var firstRow = Number.MAX_VALUE; + clearCodeLensWidgets(session); + lenses && lenses.forEach(function (lens) { + var row = lens.start.row; + var column = lens.start.column; + var widget = session.lineWidgets && session.lineWidgets[row]; + if (!widget || !widget.lenses) { + widget = session.widgetManager.$registerLineWidget({ + rowCount: 1, + rowsAbove: 1, + row: row, + column: column, + lenses: [] + }); + } + widget.lenses.push(lens.command); + if (row < firstRow) + firstRow = row; + }); + session._emit("changeFold", { data: { start: { row: firstRow } } }); + return firstRow; +}; +function attachToEditor(editor) { + editor.codeLensProviders = []; + editor.renderer.on("afterRender", renderWidgets); + if (!editor.$codeLensClickHandler) { + editor.$codeLensClickHandler = function (e) { + var command = e.target.lensCommand; + if (!command) + return; + editor.execCommand(command.id, command.arguments); + editor._emit("codeLensClick", e); + }; + event.addListener(editor.container, "click", editor.$codeLensClickHandler, editor); + } + editor.$updateLenses = function () { + var session = editor.session; + if (!session) + return; + if (!session.widgetManager) { + session.widgetManager = new LineWidgets(session); + session.widgetManager.attach(editor); + } + var providersToWaitNum = editor.codeLensProviders.length; + var lenses = []; + editor.codeLensProviders.forEach(function (provider) { + provider.provideCodeLenses(session, function (err, payload) { + if (err) + return; + payload.forEach(function (lens) { + lenses.push(lens); + }); + providersToWaitNum--; + if (providersToWaitNum == 0) { + applyLenses(); + } + }); + }); + function applyLenses() { + var cursor = session.selection.cursor; + var oldRow = session.documentToScreenRow(cursor); + var scrollTop = session.getScrollTop(); + var firstRow = exports.setLenses(session, lenses); + var lastDelta = session.$undoManager && session.$undoManager.$lastDelta; + if (lastDelta && lastDelta.action == "remove" && lastDelta.lines.length > 1) + return; + var row = session.documentToScreenRow(cursor); + var lineHeight = editor.renderer.layerConfig.lineHeight; + var top = session.getScrollTop() + (row - oldRow) * lineHeight; + if (firstRow == 0 && scrollTop < lineHeight / 4 && scrollTop > -lineHeight / 4) { + top = -lineHeight; + } + session.setScrollTop(top); + } + }; + var updateLenses = lang.delayedCall(editor.$updateLenses); + editor.$updateLensesOnInput = function () { + updateLenses.delay(250); + }; + editor.on("input", editor.$updateLensesOnInput); +} +function detachFromEditor(editor) { + editor.off("input", editor.$updateLensesOnInput); + editor.renderer.off("afterRender", renderWidgets); + if (editor.$codeLensClickHandler) + editor.container.removeEventListener("click", editor.$codeLensClickHandler); +} +exports.registerCodeLensProvider = function (editor, codeLensProvider) { + editor.setOption("enableCodeLens", true); + editor.codeLensProviders.push(codeLensProvider); + editor.$updateLensesOnInput(); +}; +exports.clear = function (session) { + exports.setLenses(session, null); +}; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableCodeLens: { + set: function (val) { + if (val) { + attachToEditor(this); + } + else { + detachFromEditor(this); + } + } + } +}); +dom.importCssString("\n.ace_codeLens {\n position: absolute;\n color: #aaa;\n font-size: 88%;\n background: inherit;\n width: 100%;\n display: flex;\n align-items: flex-end;\n pointer-events: none;\n}\n.ace_codeLens > a {\n cursor: pointer;\n pointer-events: auto;\n}\n.ace_codeLens > a:hover {\n color: #0000ff;\n text-decoration: underline;\n}\n.ace_dark > .ace_codeLens > a:hover {\n color: #4e94ce;\n}\n", "codelense.css", false); + +}); + (function() { + window.require(["ace/ext/code_lens"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-elastic_tabstops_lite.js b/src/main/resources/static/assets/js/vendor/template/src/ext-elastic_tabstops_lite.js new file mode 100644 index 0000000..a9e4e84 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-elastic_tabstops_lite.js @@ -0,0 +1,227 @@ +define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var ElasticTabstopsLite = function (editor) { + this.$editor = editor; + var self = this; + var changedRows = []; + var recordChanges = false; + this.onAfterExec = function () { + recordChanges = false; + self.processRows(changedRows); + changedRows = []; + }; + this.onExec = function () { + recordChanges = true; + }; + this.onChange = function (delta) { + if (recordChanges) { + if (changedRows.indexOf(delta.start.row) == -1) + changedRows.push(delta.start.row); + if (delta.end.row != delta.start.row) + changedRows.push(delta.end.row); + } + }; +}; +(function () { + this.processRows = function (rows) { + this.$inChange = true; + var checkedRows = []; + for (var r = 0, rowCount = rows.length; r < rowCount; r++) { + var row = rows[r]; + if (checkedRows.indexOf(row) > -1) + continue; + var cellWidthObj = this.$findCellWidthsForBlock(row); + var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths); + var rowIndex = cellWidthObj.firstRow; + for (var w = 0, l = cellWidths.length; w < l; w++) { + var widths = cellWidths[w]; + checkedRows.push(rowIndex); + this.$adjustRow(rowIndex, widths); + rowIndex++; + } + } + this.$inChange = false; + }; + this.$findCellWidthsForBlock = function (row) { + var cellWidths = [], widths; + var rowIter = row; + while (rowIter >= 0) { + widths = this.$cellWidthsForRow(rowIter); + if (widths.length == 0) + break; + cellWidths.unshift(widths); + rowIter--; + } + var firstRow = rowIter + 1; + rowIter = row; + var numRows = this.$editor.session.getLength(); + while (rowIter < numRows - 1) { + rowIter++; + widths = this.$cellWidthsForRow(rowIter); + if (widths.length == 0) + break; + cellWidths.push(widths); + } + return { cellWidths: cellWidths, firstRow: firstRow }; + }; + this.$cellWidthsForRow = function (row) { + var selectionColumns = this.$selectionColumnsForRow(row); + var tabs = [-1].concat(this.$tabsForRow(row)); + var widths = tabs.map(function (el) { return 0; }).slice(1); + var line = this.$editor.session.getLine(row); + for (var i = 0, len = tabs.length - 1; i < len; i++) { + var leftEdge = tabs[i] + 1; + var rightEdge = tabs[i + 1]; + var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge); + var cell = line.substring(leftEdge, rightEdge); + widths[i] = Math.max(cell.replace(/\s+$/g, '').length, rightmostSelection - leftEdge); + } + return widths; + }; + this.$selectionColumnsForRow = function (row) { + var selections = [], cursor = this.$editor.getCursorPosition(); + if (this.$editor.session.getSelection().isEmpty()) { + if (row == cursor.row) + selections.push(cursor.column); + } + return selections; + }; + this.$setBlockCellWidthsToMax = function (cellWidths) { + var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth; + var columnInfo = this.$izip_longest(cellWidths); + for (var c = 0, l = columnInfo.length; c < l; c++) { + var column = columnInfo[c]; + if (!column.push) { + console.error(column); + continue; + } + column.push(NaN); + for (var r = 0, s = column.length; r < s; r++) { + var width = column[r]; + if (startingNewBlock) { + blockStartRow = r; + maxWidth = 0; + startingNewBlock = false; + } + if (isNaN(width)) { + blockEndRow = r; + for (var j = blockStartRow; j < blockEndRow; j++) { + cellWidths[j][c] = maxWidth; + } + startingNewBlock = true; + } + maxWidth = Math.max(maxWidth, width); + } + } + return cellWidths; + }; + this.$rightmostSelectionInCell = function (selectionColumns, cellRightEdge) { + var rightmost = 0; + if (selectionColumns.length) { + var lengths = []; + for (var s = 0, length = selectionColumns.length; s < length; s++) { + if (selectionColumns[s] <= cellRightEdge) + lengths.push(s); + else + lengths.push(0); + } + rightmost = Math.max.apply(Math, lengths); + } + return rightmost; + }; + this.$tabsForRow = function (row) { + var rowTabs = [], line = this.$editor.session.getLine(row), re = /\t/g, match; + while ((match = re.exec(line)) != null) { + rowTabs.push(match.index); + } + return rowTabs; + }; + this.$adjustRow = function (row, widths) { + var rowTabs = this.$tabsForRow(row); + if (rowTabs.length == 0) + return; + var bias = 0, location = -1; + var expandedSet = this.$izip(widths, rowTabs); + for (var i = 0, l = expandedSet.length; i < l; i++) { + var w = expandedSet[i][0], it = expandedSet[i][1]; + location += 1 + w; + it += bias; + var difference = location - it; + if (difference == 0) + continue; + var partialLine = this.$editor.session.getLine(row).substr(0, it); + var strippedPartialLine = partialLine.replace(/\s*$/g, ""); + var ispaces = partialLine.length - strippedPartialLine.length; + if (difference > 0) { + this.$editor.session.getDocument().insertInLine({ row: row, column: it + 1 }, Array(difference + 1).join(" ") + "\t"); + this.$editor.session.getDocument().removeInLine(row, it, it + 1); + bias += difference; + } + if (difference < 0 && ispaces >= -difference) { + this.$editor.session.getDocument().removeInLine(row, it + difference, it); + bias += difference; + } + } + }; + this.$izip_longest = function (iterables) { + if (!iterables[0]) + return []; + var longest = iterables[0].length; + var iterablesLength = iterables.length; + for (var i = 1; i < iterablesLength; i++) { + var iLength = iterables[i].length; + if (iLength > longest) + longest = iLength; + } + var expandedSet = []; + for (var l = 0; l < longest; l++) { + var set = []; + for (var i = 0; i < iterablesLength; i++) { + if (iterables[i][l] === "") + set.push(NaN); + else + set.push(iterables[i][l]); + } + expandedSet.push(set); + } + return expandedSet; + }; + this.$izip = function (widths, tabs) { + var size = widths.length >= tabs.length ? tabs.length : widths.length; + var expandedSet = []; + for (var i = 0; i < size; i++) { + var set = [widths[i], tabs[i]]; + expandedSet.push(set); + } + return expandedSet; + }; +}).call(ElasticTabstopsLite.prototype); +exports.ElasticTabstopsLite = ElasticTabstopsLite; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + useElasticTabstops: { + set: function (val) { + if (val) { + if (!this.elasticTabstops) + this.elasticTabstops = new ElasticTabstopsLite(this); + this.commands.on("afterExec", this.elasticTabstops.onAfterExec); + this.commands.on("exec", this.elasticTabstops.onExec); + this.on("change", this.elasticTabstops.onChange); + } + else if (this.elasticTabstops) { + this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec); + this.commands.removeListener("exec", this.elasticTabstops.onExec); + this.removeListener("change", this.elasticTabstops.onChange); + } + } + } +}); + +}); + (function() { + window.require(["ace/ext/elastic_tabstops_lite"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-emmet.js b/src/main/resources/static/assets/js/vendor/template/src/ext-emmet.js new file mode 100644 index 0000000..5e694af --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-emmet.js @@ -0,0 +1,1257 @@ +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict"; +var dom = require("./lib/dom"); +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var lang = require("./lib/lang"); +var Range = require("./range").Range; +var RangeList = require("./range_list").RangeList; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var Tokenizer = require("./tokenizer").Tokenizer; +var clipboard = require("./clipboard"); +var VARIABLES = { + CURRENT_WORD: function (editor) { + return editor.session.getTextRange(editor.session.getWordRange()); + }, + SELECTION: function (editor, name, indentation) { + var text = editor.session.getTextRange(); + if (indentation) + return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1"); + return text; + }, + CURRENT_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row); + }, + PREV_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row - 1); + }, + LINE_INDEX: function (editor) { + return editor.getCursorPosition().row; + }, + LINE_NUMBER: function (editor) { + return editor.getCursorPosition().row + 1; + }, + SOFT_TABS: function (editor) { + return editor.session.getUseSoftTabs() ? "YES" : "NO"; + }, + TAB_SIZE: function (editor) { + return editor.session.getTabSize(); + }, + CLIPBOARD: function (editor) { + return clipboard.getText && clipboard.getText(); + }, + FILENAME: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0]; + }, + FILENAME_BASE: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, ""); + }, + DIRECTORY: function (editor) { + return this.FILEPATH(editor).replace(/[^/\\]*$/, ""); + }, + FILEPATH: function (editor) { return "/not implemented.txt"; }, + WORKSPACE_NAME: function () { return "Unknown"; }, + FULLNAME: function () { return "Unknown"; }, + BLOCK_COMMENT_START: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.start || ""; + }, + BLOCK_COMMENT_END: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.end || ""; + }, + LINE_COMMENT: function (editor) { + var mode = editor.session.$mode || {}; + return mode.lineCommentStart || ""; + }, + CURRENT_YEAR: date.bind(null, { year: "numeric" }), + CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }), + CURRENT_MONTH: date.bind(null, { month: "numeric" }), + CURRENT_MONTH_NAME: date.bind(null, { month: "long" }), + CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }), + CURRENT_DATE: date.bind(null, { day: "2-digit" }), + CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }), + CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }), + CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }), + CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }), + CURRENT_SECOND: date.bind(null, { second: "2-digit" }) +}; +VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION; +function date(dateFormat) { + var str = new Date().toLocaleString("en-us", dateFormat); + return str.length == 1 ? "0" + str : str; +} +var SnippetManager = function () { + this.snippetMap = {}; + this.snippetNameMap = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.getTokenizer = function () { + return SnippetManager.$tokenizer || this.createTokenizer(); + }; + this.createTokenizer = function () { + function TabstopToken(str) { + str = str.substr(1); + if (/^\d+$/.test(str)) + return [{ tabstopId: parseInt(str, 10) }]; + return [{ text: str }]; + } + function escape(ch) { + return "(?:[^\\\\" + ch + "]|\\\\.)"; + } + var formatMatcher = { + regex: "/(" + escape("/") + "+)/", + onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.fmtString = true; + ts.guard = val.slice(1, -1); + ts.flag = ""; + return ""; + }, + next: "formatString" + }; + SnippetManager.$tokenizer = new Tokenizer({ + start: [ + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) { + val = ch; + } + else if ("`$\\".indexOf(ch) != -1) { + val = ch; + } + return [val]; + } }, + { regex: /}/, onMatch: function (val, state, stack) { + return [stack.length ? stack.shift() : val]; + } }, + { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken }, + { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) { + var t = TabstopToken(str.substr(1)); + stack.unshift(t[0]); + return t; + }, next: "snippetVar" }, + { regex: /\n/, token: "newline", merge: false } + ], + snippetVar: [ + { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) { + var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) { + return operator.length == 2 ? operator[1] : "\x00"; + }).split("\x00").map(function (value) { + return { value: value }; + }); + stack[0].choices = choices; + return [choices[0]]; + }, next: "start" }, + formatMatcher, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" } + ], + formatString: [ + { regex: /:/, onMatch: function (val, state, stack) { + if (stack.length && stack[0].expectElse) { + stack[0].expectElse = false; + stack[0].ifEnd = { elseEnd: stack[0] }; + return [stack[0].ifEnd]; + } + return ":"; + } }, + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) + val = ch; + else if ("`$\\".indexOf(ch) != -1) + val = ch; + else if (ch == "n") + val = "\n"; + else if (ch == "t") + val = "\t"; + else if ("ulULE".indexOf(ch) != -1) + val = { changeCase: ch, local: ch > "a" }; + return [val]; + } }, + { regex: "/\\w*}", onMatch: function (val, state, stack) { + var next = stack.shift(); + if (next) + next.flag = val.slice(1, -1); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" }, + { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) { + return [{ text: val.slice(1) }]; + } }, + { regex: /\${\w+/, onMatch: function (val, state, stack) { + var token = { text: val.slice(2) }; + stack.unshift(token); + return [token]; + }, next: "formatStringVar" }, + { regex: /\n/, token: "newline", merge: false }, + { regex: /}/, onMatch: function (val, state, stack) { + var next = stack.shift(); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" } + ], + formatStringVar: [ + { regex: /:\/\w+}/, onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.formatFunction = val.slice(2, -1); + return [stack.shift()]; + }, next: "formatString" }, + formatMatcher, + { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) { + if (val[1] == "+") + stack[0].ifEnd = stack[0]; + if (val[1] == "?") + stack[0].expectElse = true; + }, next: "formatString" }, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" } + ] + }); + return SnippetManager.$tokenizer; + }; + this.tokenizeTmSnippet = function (str, startState) { + return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) { + return x.value || x; + }); + }; + this.getVariableValue = function (editor, name, indentation) { + if (/^\d+$/.test(name)) + return (this.variables.__ || {})[name] || ""; + if (/^[A-Z]\d+$/.test(name)) + return (this.variables[name[0] + "__"] || {})[name.substr(1)] || ""; + name = name.replace(/^TM_/, ""); + if (!this.variables.hasOwnProperty(name)) + return ""; + var value = this.variables[name]; + if (typeof value == "function") + value = this.variables[name](editor, name, indentation); + return value == null ? "" : value; + }; + this.variables = VARIABLES; + this.tmStrFormat = function (str, ch, editor) { + if (!ch.fmt) + return str; + var flag = ch.flag || ""; + var re = ch.guard; + re = new RegExp(re, flag.replace(/[^gim]/g, "")); + var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt; + var _self = this; + var formatted = str.replace(re, function () { + var oldArgs = _self.variables.__; + _self.variables.__ = [].slice.call(arguments); + var fmtParts = _self.resolveVariables(fmtTokens, editor); + var gChangeCase = "E"; + for (var i = 0; i < fmtParts.length; i++) { + var ch = fmtParts[i]; + if (typeof ch == "object") { + fmtParts[i] = ""; + if (ch.changeCase && ch.local) { + var next = fmtParts[i + 1]; + if (next && typeof next == "string") { + if (ch.changeCase == "u") + fmtParts[i] = next[0].toUpperCase(); + else + fmtParts[i] = next[0].toLowerCase(); + fmtParts[i + 1] = next.substr(1); + } + } + else if (ch.changeCase) { + gChangeCase = ch.changeCase; + } + } + else if (gChangeCase == "U") { + fmtParts[i] = ch.toUpperCase(); + } + else if (gChangeCase == "L") { + fmtParts[i] = ch.toLowerCase(); + } + } + _self.variables.__ = oldArgs; + return fmtParts.join(""); + }); + return formatted; + }; + this.tmFormatFunction = function (str, ch, editor) { + if (ch.formatFunction == "upcase") + return str.toUpperCase(); + if (ch.formatFunction == "downcase") + return str.toLowerCase(); + return str; + }; + this.resolveVariables = function (snippet, editor) { + var result = []; + var indentation = ""; + var afterNewLine = true; + for (var i = 0; i < snippet.length; i++) { + var ch = snippet[i]; + if (typeof ch == "string") { + result.push(ch); + if (ch == "\n") { + afterNewLine = true; + indentation = ""; + } + else if (afterNewLine) { + indentation = /^\t*/.exec(ch)[0]; + afterNewLine = /\S/.test(ch); + } + continue; + } + if (!ch) + continue; + afterNewLine = false; + if (ch.fmtString) { + var j = snippet.indexOf(ch, i + 1); + if (j == -1) + j = snippet.length; + ch.fmt = snippet.slice(i + 1, j); + i = j; + } + if (ch.text) { + var value = this.getVariableValue(editor, ch.text, indentation) + ""; + if (ch.fmtString) + value = this.tmStrFormat(value, ch, editor); + if (ch.formatFunction) + value = this.tmFormatFunction(value, ch, editor); + if (value && !ch.ifEnd) { + result.push(value); + gotoNext(ch); + } + else if (!value && ch.ifEnd) { + gotoNext(ch.ifEnd); + } + } + else if (ch.elseEnd) { + gotoNext(ch.elseEnd); + } + else if (ch.tabstopId != null) { + result.push(ch); + } + else if (ch.changeCase != null) { + result.push(ch); + } + } + function gotoNext(ch) { + var i1 = snippet.indexOf(ch, i + 1); + if (i1 != -1) + i = i1; + } + return result; + }; + this.insertSnippetForSelection = function (editor, snippetText) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var tabString = editor.session.getTabString(); + var indentString = line.match(/^\s*/)[0]; + if (cursor.column < indentString.length) + indentString = indentString.slice(0, cursor.column); + snippetText = snippetText.replace(/\r/g, ""); + var tokens = this.tokenizeTmSnippet(snippetText); + tokens = this.resolveVariables(tokens, editor); + tokens = tokens.map(function (x) { + if (x == "\n") + return x + indentString; + if (typeof x == "string") + return x.replace(/\t/g, tabString); + return x; + }); + var tabstops = []; + tokens.forEach(function (p, i) { + if (typeof p != "object") + return; + var id = p.tabstopId; + var ts = tabstops[id]; + if (!ts) { + ts = tabstops[id] = []; + ts.index = id; + ts.value = ""; + ts.parents = {}; + } + if (ts.indexOf(p) !== -1) + return; + if (p.choices && !ts.choices) + ts.choices = p.choices; + ts.push(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 === -1) + return; + var value = tokens.slice(i + 1, i1); + var isNested = value.some(function (t) { return typeof t === "object"; }); + if (isNested && !ts.value) { + ts.value = value; + } + else if (value.length && (!ts.value || typeof ts.value !== "string")) { + ts.value = value.join(""); + } + }); + tabstops.forEach(function (ts) { ts.length = 0; }); + var expanding = {}; + function copyValue(val) { + var copy = []; + for (var i = 0; i < val.length; i++) { + var p = val[i]; + if (typeof p == "object") { + if (expanding[p.tabstopId]) + continue; + var j = val.lastIndexOf(p, i - 1); + p = copy[j] || { tabstopId: p.tabstopId }; + } + copy[i] = p; + } + return copy; + } + for (var i = 0; i < tokens.length; i++) { + var p = tokens[i]; + if (typeof p != "object") + continue; + var id = p.tabstopId; + var ts = tabstops[id]; + var i1 = tokens.indexOf(p, i + 1); + if (expanding[id]) { + if (expanding[id] === p) { + delete expanding[id]; + Object.keys(expanding).forEach(function (parentId) { + ts.parents[parentId] = true; + }); + } + continue; + } + expanding[id] = p; + var value = ts.value; + if (typeof value !== "string") + value = copyValue(value); + else if (p.fmt) + value = this.tmStrFormat(value, p, editor); + tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p)); + if (ts.indexOf(p) === -1) + ts.push(p); + } + var row = 0, column = 0; + var text = ""; + tokens.forEach(function (t) { + if (typeof t === "string") { + var lines = t.split("\n"); + if (lines.length > 1) { + column = lines[lines.length - 1].length; + row += lines.length - 1; + } + else + column += t.length; + text += t; + } + else if (t) { + if (!t.start) + t.start = { row: row, column: column }; + else + t.end = { row: row, column: column }; + } + }); + var range = editor.getSelectionRange(); + var end = editor.session.replace(range, text); + var tabstopManager = new TabstopManager(editor); + var selectionId = editor.inVirtualSelectionMode && editor.selection.index; + tabstopManager.addTabstops(tabstops, range.start, end, selectionId); + }; + this.insertSnippet = function (editor, snippetText) { + var self = this; + if (editor.inVirtualSelectionMode) + return self.insertSnippetForSelection(editor, snippetText); + editor.forEachSelection(function () { + self.insertSnippetForSelection(editor, snippetText); + }, null, { keepOrder: true }); + if (editor.tabstopManager) + editor.tabstopManager.tabNext(); + }; + this.$getScope = function (editor) { + var scope = editor.session.$mode.$id || ""; + scope = scope.split("/").pop(); + if (scope === "html" || scope === "php") { + if (scope === "php" && !editor.session.$mode.inlinePhp) + scope = "html"; + var c = editor.getCursorPosition(); + var state = editor.session.getState(c.row); + if (typeof state === "object") { + state = state[0]; + } + if (state.substring) { + if (state.substring(0, 3) == "js-") + scope = "javascript"; + else if (state.substring(0, 4) == "css-") + scope = "css"; + else if (state.substring(0, 4) == "php-") + scope = "php"; + } + } + return scope; + }; + this.getActiveScopes = function (editor) { + var scope = this.$getScope(editor); + var scopes = [scope]; + var snippetMap = this.snippetMap; + if (snippetMap[scope] && snippetMap[scope].includeScopes) { + scopes.push.apply(scopes, snippetMap[scope].includeScopes); + } + scopes.push("_"); + return scopes; + }; + this.expandWithTab = function (editor, options) { + var self = this; + var result = editor.forEachSelection(function () { + return self.expandSnippetForSelection(editor, options); + }, null, { keepOrder: true }); + if (result && editor.tabstopManager) + editor.tabstopManager.tabNext(); + return result; + }; + this.expandSnippetForSelection = function (editor, options) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var before = line.substring(0, cursor.column); + var after = line.substr(cursor.column); + var snippetMap = this.snippetMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = this.findMatchingSnippet(snippets, before, after); + return !!snippet; + }, this); + if (!snippet) + return false; + if (options && options.dryRun) + return true; + editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length); + this.variables.M__ = snippet.matchBefore; + this.variables.T__ = snippet.matchAfter; + this.insertSnippetForSelection(editor, snippet.content); + this.variables.M__ = this.variables.T__ = null; + return true; + }; + this.findMatchingSnippet = function (snippetList, before, after) { + for (var i = snippetList.length; i--;) { + var s = snippetList[i]; + if (s.startRe && !s.startRe.test(before)) + continue; + if (s.endRe && !s.endRe.test(after)) + continue; + if (!s.startRe && !s.endRe) + continue; + s.matchBefore = s.startRe ? s.startRe.exec(before) : [""]; + s.matchAfter = s.endRe ? s.endRe.exec(after) : [""]; + s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : ""; + s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : ""; + return s; + } + }; + this.snippetMap = {}; + this.snippetNameMap = {}; + this.register = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + var self = this; + if (!snippets) + snippets = []; + function wrapRegexp(src) { + if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) + src = "(?:" + src + ")"; + return src || ""; + } + function guardedRegexp(re, guard, opening) { + re = wrapRegexp(re); + guard = wrapRegexp(guard); + if (opening) { + re = guard + re; + if (re && re[re.length - 1] != "$") + re = re + "$"; + } + else { + re = re + guard; + if (re && re[0] != "^") + re = "^" + re; + } + return new RegExp(re); + } + function addSnippet(s) { + if (!s.scope) + s.scope = scope || "_"; + scope = s.scope; + if (!snippetMap[scope]) { + snippetMap[scope] = []; + snippetNameMap[scope] = {}; + } + var map = snippetNameMap[scope]; + if (s.name) { + var old = map[s.name]; + if (old) + self.unregister(old); + map[s.name] = s; + } + snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { + if (!s.guard && /^\w/.test(s.tabTrigger)) + s.guard = "\\b"; + s.trigger = lang.escapeRegExp(s.tabTrigger); + } + if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard) + return; + s.startRe = guardedRegexp(s.trigger, s.guard, true); + s.triggerRe = new RegExp(s.trigger); + s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); + s.endTriggerRe = new RegExp(s.endTrigger); + } + if (Array.isArray(snippets)) { + snippets.forEach(addSnippet); + } + else { + Object.keys(snippets).forEach(function (key) { + addSnippet(snippets[key]); + }); + } + this._signal("registerSnippets", { scope: scope }); + }; + this.unregister = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + function removeSnippet(s) { + var nameMap = snippetNameMap[s.scope || scope]; + if (nameMap && nameMap[s.name]) { + delete nameMap[s.name]; + var map = snippetMap[s.scope || scope]; + var i = map && map.indexOf(s); + if (i >= 0) + map.splice(i, 1); + } + } + if (snippets.content) + removeSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(removeSnippet); + }; + this.parseSnippetFile = function (str) { + str = str.replace(/\r/g, ""); + var list = [], snippet = {}; + var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm; + var m; + while (m = re.exec(str)) { + if (m[1]) { + try { + snippet = JSON.parse(m[1]); + list.push(snippet); + } + catch (e) { } + } + if (m[4]) { + snippet.content = m[4].replace(/^\t/gm, ""); + list.push(snippet); + snippet = {}; + } + else { + var key = m[2], val = m[3]; + if (key == "regex") { + var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g; + snippet.guard = guardRe.exec(val)[1]; + snippet.trigger = guardRe.exec(val)[1]; + snippet.endTrigger = guardRe.exec(val)[1]; + snippet.endGuard = guardRe.exec(val)[1]; + } + else if (key == "snippet") { + snippet.tabTrigger = val.match(/^\S*/)[0]; + if (!snippet.name) + snippet.name = val; + } + else if (key) { + snippet[key] = val; + } + } + } + return list; + }; + this.getSnippetByName = function (name, editor) { + var snippetMap = this.snippetNameMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = snippets[name]; + return !!snippet; + }, this); + return snippet; + }; +}).call(SnippetManager.prototype); +var TabstopManager = function (editor) { + if (editor.tabstopManager) + return editor.tabstopManager; + editor.tabstopManager = this; + this.$onChange = this.onChange.bind(this); + this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule; + this.$onChangeSession = this.onChangeSession.bind(this); + this.$onAfterExec = this.onAfterExec.bind(this); + this.attach(editor); +}; +(function () { + this.attach = function (editor) { + this.index = 0; + this.ranges = []; + this.tabstops = []; + this.$openTabstops = null; + this.selectedTabstop = null; + this.editor = editor; + this.editor.on("change", this.$onChange); + this.editor.on("changeSelection", this.$onChangeSelection); + this.editor.on("changeSession", this.$onChangeSession); + this.editor.commands.on("afterExec", this.$onAfterExec); + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.detach = function () { + this.tabstops.forEach(this.removeTabstopMarkers, this); + this.ranges = null; + this.tabstops = null; + this.selectedTabstop = null; + this.editor.removeListener("change", this.$onChange); + this.editor.removeListener("changeSelection", this.$onChangeSelection); + this.editor.removeListener("changeSession", this.$onChangeSession); + this.editor.commands.removeListener("afterExec", this.$onAfterExec); + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.tabstopManager = null; + this.editor = null; + }; + this.onChange = function (delta) { + var isRemove = delta.action[0] == "r"; + var selectedTabstop = this.selectedTabstop || {}; + var parents = selectedTabstop.parents || {}; + var tabstops = (this.tabstops || []).slice(); + for (var i = 0; i < tabstops.length; i++) { + var ts = tabstops[i]; + var active = ts == selectedTabstop || parents[ts.index]; + ts.rangeList.$bias = active ? 0 : 1; + if (delta.action == "remove" && ts !== selectedTabstop) { + var parentActive = ts.parents && ts.parents[selectedTabstop.index]; + var startIndex = ts.rangeList.pointIndex(delta.start, parentActive); + startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1; + var endIndex = ts.rangeList.pointIndex(delta.end, parentActive); + endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1; + var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex); + for (var j = 0; j < toRemove.length; j++) + this.removeRange(toRemove[j]); + } + ts.rangeList.$onChange(delta); + } + var session = this.editor.session; + if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue()) + this.detach(); + }; + this.updateLinkedFields = function () { + var ts = this.selectedTabstop; + if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked) + return; + this.$inChange = true; + var session = this.editor.session; + var text = session.getTextRange(ts.firstNonLinked); + for (var i = 0; i < ts.length; i++) { + var range = ts[i]; + if (!range.linked) + continue; + var original = range.original; + var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor); + session.replace(range, fmt); + } + this.$inChange = false; + }; + this.onAfterExec = function (e) { + if (e.command && !e.command.readOnly) + this.updateLinkedFields(); + }; + this.onChangeSelection = function () { + if (!this.editor) + return; + var lead = this.editor.selection.lead; + var anchor = this.editor.selection.anchor; + var isEmpty = this.editor.selection.isEmpty(); + for (var i = 0; i < this.ranges.length; i++) { + if (this.ranges[i].linked) + continue; + var containsLead = this.ranges[i].contains(lead.row, lead.column); + var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column); + if (containsLead && containsAnchor) + return; + } + this.detach(); + }; + this.onChangeSession = function () { + this.detach(); + }; + this.tabNext = function (dir) { + var max = this.tabstops.length; + var index = this.index + (dir || 1); + index = Math.min(Math.max(index, 1), max); + if (index == max) + index = 0; + this.selectTabstop(index); + if (index === 0) + this.detach(); + }; + this.selectTabstop = function (index) { + this.$openTabstops = null; + var ts = this.tabstops[this.index]; + if (ts) + this.addTabstopMarkers(ts); + this.index = index; + ts = this.tabstops[this.index]; + if (!ts || !ts.length) + return; + this.selectedTabstop = ts; + var range = ts.firstNonLinked || ts; + if (ts.choices) + range.cursor = range.start; + if (!this.editor.inVirtualSelectionMode) { + var sel = this.editor.multiSelect; + sel.toSingleRange(range); + for (var i = 0; i < ts.length; i++) { + if (ts.hasLinkedRanges && ts[i].linked) + continue; + sel.addRange(ts[i].clone(), true); + } + } + else { + this.editor.selection.fromOrientedRange(range); + } + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + if (this.selectedTabstop && this.selectedTabstop.choices) + this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices }); + }; + this.addTabstops = function (tabstops, start, end) { + var useLink = this.useLink || !this.editor.getOption("enableMultiselect"); + if (!this.$openTabstops) + this.$openTabstops = []; + if (!tabstops[0]) { + var p = Range.fromPoints(end, end); + moveRelative(p.start, start); + moveRelative(p.end, start); + tabstops[0] = [p]; + tabstops[0].index = 0; + } + var i = this.index; + var arg = [i + 1, 0]; + var ranges = this.ranges; + tabstops.forEach(function (ts, index) { + var dest = this.$openTabstops[index] || ts; + for (var i = 0; i < ts.length; i++) { + var p = ts[i]; + var range = Range.fromPoints(p.start, p.end || p.start); + movePoint(range.start, start); + movePoint(range.end, start); + range.original = p; + range.tabstop = dest; + ranges.push(range); + if (dest != ts) + dest.unshift(range); + else + dest[i] = range; + if (p.fmtString || (dest.firstNonLinked && useLink)) { + range.linked = true; + dest.hasLinkedRanges = true; + } + else if (!dest.firstNonLinked) + dest.firstNonLinked = range; + } + if (!dest.firstNonLinked) + dest.hasLinkedRanges = false; + if (dest === ts) { + arg.push(dest); + this.$openTabstops[index] = dest; + } + this.addTabstopMarkers(dest); + dest.rangeList = dest.rangeList || new RangeList(); + dest.rangeList.$bias = 0; + dest.rangeList.addList(dest); + }, this); + if (arg.length > 2) { + if (this.tabstops.length) + arg.push(arg.splice(2, 1)[0]); + this.tabstops.splice.apply(this.tabstops, arg); + } + }; + this.addTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + if (!range.markerId) + range.markerId = session.addMarker(range, "ace_snippet-marker", "text"); + }); + }; + this.removeTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + session.removeMarker(range.markerId); + range.markerId = null; + }); + }; + this.removeRange = function (range) { + var i = range.tabstop.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + i = this.ranges.indexOf(range); + if (i != -1) + this.ranges.splice(i, 1); + i = range.tabstop.rangeList.ranges.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + this.editor.session.removeMarker(range.markerId); + if (!range.tabstop.length) { + i = this.tabstops.indexOf(range.tabstop); + if (i != -1) + this.tabstops.splice(i, 1); + if (!this.tabstops.length) + this.detach(); + } + }; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys({ + "Tab": function (editor) { + if (exports.snippetManager && exports.snippetManager.expandWithTab(editor)) + return; + editor.tabstopManager.tabNext(1); + editor.renderer.scrollCursorIntoView(); + }, + "Shift-Tab": function (editor) { + editor.tabstopManager.tabNext(-1); + editor.renderer.scrollCursorIntoView(); + }, + "Esc": function (editor) { + editor.tabstopManager.detach(); + } + }); +}).call(TabstopManager.prototype); +var movePoint = function (point, diff) { + if (point.row == 0) + point.column += diff.column; + point.row += diff.row; +}; +var moveRelative = function (point, start) { + if (point.row == start.row) + point.column -= start.column; + point.row -= start.row; +}; +dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false); +exports.snippetManager = new SnippetManager(); +var Editor = require("./editor").Editor; +(function () { + this.insertSnippet = function (content, options) { + return exports.snippetManager.insertSnippet(this, content, options); + }; + this.expandSnippet = function (options) { + return exports.snippetManager.expandWithTab(this, options); + }; +}).call(Editor.prototype); + +}); + +define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","ace/config","resources","resources","tabStops","resources","utils","actions"], function(require, exports, module){"use strict"; +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var Editor = require("../editor").Editor; +var snippetManager = require("../snippets").snippetManager; +var Range = require("../range").Range; +var config = require("../config"); +var emmet, emmetPath; +function AceEmmetEditor() { } +AceEmmetEditor.prototype = { + setupContext: function (editor) { + this.ace = editor; + this.indentation = editor.session.getTabString(); + if (!emmet) + emmet = window.emmet; + var resources = emmet.resources || emmet.require("resources"); + resources.setVariable("indentation", this.indentation); + this.$syntax = null; + this.$syntax = this.getSyntax(); + }, + getSelectionRange: function () { + var range = this.ace.getSelectionRange(); + var doc = this.ace.session.doc; + return { + start: doc.positionToIndex(range.start), + end: doc.positionToIndex(range.end) + }; + }, + createSelection: function (start, end) { + var doc = this.ace.session.doc; + this.ace.selection.setRange({ + start: doc.indexToPosition(start), + end: doc.indexToPosition(end) + }); + }, + getCurrentLineRange: function () { + var ace = this.ace; + var row = ace.getCursorPosition().row; + var lineLength = ace.session.getLine(row).length; + var index = ace.session.doc.positionToIndex({ row: row, column: 0 }); + return { + start: index, + end: index + lineLength + }; + }, + getCaretPos: function () { + var pos = this.ace.getCursorPosition(); + return this.ace.session.doc.positionToIndex(pos); + }, + setCaretPos: function (index) { + var pos = this.ace.session.doc.indexToPosition(index); + this.ace.selection.moveToPosition(pos); + }, + getCurrentLine: function () { + var row = this.ace.getCursorPosition().row; + return this.ace.session.getLine(row); + }, + replaceContent: function (value, start, end, noIndent) { + if (end == null) + end = start == null ? this.getContent().length : start; + if (start == null) + start = 0; + var editor = this.ace; + var doc = editor.session.doc; + var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end)); + editor.session.remove(range); + range.end = range.start; + value = this.$updateTabstops(value); + snippetManager.insertSnippet(editor, value); + }, + getContent: function () { + return this.ace.getValue(); + }, + getSyntax: function () { + if (this.$syntax) + return this.$syntax; + var syntax = this.ace.session.$modeId.split("/").pop(); + if (syntax == "html" || syntax == "php") { + var cursor = this.ace.getCursorPosition(); + var state = this.ace.session.getState(cursor.row); + if (typeof state != "string") + state = state[0]; + if (state) { + state = state.split("-"); + if (state.length > 1) + syntax = state[0]; + else if (syntax == "php") + syntax = "html"; + } + } + return syntax; + }, + getProfileName: function () { + var resources = emmet.resources || emmet.require("resources"); + switch (this.getSyntax()) { + case "css": return "css"; + case "xml": + case "xsl": + return "xml"; + case "html": + var profile = resources.getVariable("profile"); + if (!profile) + profile = this.ace.session.getLines(0, 2).join("").search(/]+XHTML/i) != -1 ? "xhtml" : "html"; + return profile; + default: + var mode = this.ace.session.$mode; + return mode.emmetConfig && mode.emmetConfig.profile || "xhtml"; + } + }, + prompt: function (title) { + return prompt(title); // eslint-disable-line no-alert + }, + getSelection: function () { + return this.ace.session.getTextRange(); + }, + getFilePath: function () { + return ""; + }, + $updateTabstops: function (value) { + var base = 1000; + var zeroBase = 0; + var lastZero = null; + var ts = emmet.tabStops || emmet.require('tabStops'); + var resources = emmet.resources || emmet.require("resources"); + var settings = resources.getVocabulary("user"); + var tabstopOptions = { + tabstop: function (data) { + var group = parseInt(data.group, 10); + var isZero = group === 0; + if (isZero) + group = ++zeroBase; + else + group += base; + var placeholder = data.placeholder; + if (placeholder) { + placeholder = ts.processText(placeholder, tabstopOptions); + } + var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}'; + if (isZero) { + lastZero = [data.start, result]; + } + return result; + }, + escape: function (ch) { + if (ch == '$') + return '\\$'; + if (ch == '\\') + return '\\\\'; + return ch; + } + }; + value = ts.processText(value, tabstopOptions); + if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) { + value += '${0}'; + } + else if (lastZero) { + var common = emmet.utils ? emmet.utils.common : emmet.require('utils'); + value = common.replaceSubstring(value, '${0}', lastZero[0], lastZero[1]); + } + return value; + } +}; +var keymap = { + expand_abbreviation: { "mac": "ctrl+alt+e", "win": "alt+e" }, + match_pair_outward: { "mac": "ctrl+d", "win": "ctrl+," }, + match_pair_inward: { "mac": "ctrl+j", "win": "ctrl+shift+0" }, + matching_pair: { "mac": "ctrl+alt+j", "win": "alt+j" }, + next_edit_point: "alt+right", + prev_edit_point: "alt+left", + toggle_comment: { "mac": "command+/", "win": "ctrl+/" }, + split_join_tag: { "mac": "shift+command+'", "win": "shift+ctrl+`" }, + remove_tag: { "mac": "command+'", "win": "shift+ctrl+;" }, + evaluate_math_expression: { "mac": "shift+command+y", "win": "shift+ctrl+y" }, + increment_number_by_1: "ctrl+up", + decrement_number_by_1: "ctrl+down", + increment_number_by_01: "alt+up", + decrement_number_by_01: "alt+down", + increment_number_by_10: { "mac": "alt+command+up", "win": "shift+alt+up" }, + decrement_number_by_10: { "mac": "alt+command+down", "win": "shift+alt+down" }, + select_next_item: { "mac": "shift+command+.", "win": "shift+ctrl+." }, + select_previous_item: { "mac": "shift+command+,", "win": "shift+ctrl+," }, + reflect_css_value: { "mac": "shift+command+r", "win": "shift+ctrl+r" }, + encode_decode_data_url: { "mac": "shift+ctrl+d", "win": "ctrl+'" }, + expand_abbreviation_with_tab: "Tab", + wrap_with_abbreviation: { "mac": "shift+ctrl+a", "win": "shift+ctrl+a" } +}; +var editorProxy = new AceEmmetEditor(); +exports.commands = new HashHandler(); +exports.runEmmetCommand = function runEmmetCommand(editor) { + if (this.action == "expand_abbreviation_with_tab") { + if (!editor.selection.isEmpty()) + return false; + var pos = editor.selection.lead; + var token = editor.session.getTokenAt(pos.row, pos.column); + if (token && /\btag\b/.test(token.type)) + return false; + } + try { + editorProxy.setupContext(editor); + var actions = emmet.actions || emmet.require("actions"); + if (this.action == "wrap_with_abbreviation") { + return setTimeout(function () { + actions.run("wrap_with_abbreviation", editorProxy); + }, 0); + } + var result = actions.run(this.action, editorProxy); + } + catch (e) { + if (!emmet) { + var loading = exports.load(runEmmetCommand.bind(this, editor)); + if (this.action == "expand_abbreviation_with_tab") + return false; + return loading; + } + editor._signal("changeStatus", typeof e == "string" ? e : e.message); + config.warn(e); + result = false; + } + return result; +}; +for (var command in keymap) { + exports.commands.addCommand({ + name: "emmet:" + command, + action: command, + bindKey: keymap[command], + exec: exports.runEmmetCommand, + multiSelectAction: "forEach" + }); +} +exports.updateCommands = function (editor, enabled) { + if (enabled) { + editor.keyBinding.addKeyboardHandler(exports.commands); + } + else { + editor.keyBinding.removeKeyboardHandler(exports.commands); + } +}; +exports.isSupportedMode = function (mode) { + if (!mode) + return false; + if (mode.emmetConfig) + return true; + var id = mode.$id || mode; + return /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(id); +}; +exports.isAvailable = function (editor, command) { + if (/(evaluate_math_expression|expand_abbreviation)$/.test(command)) + return true; + var mode = editor.session.$mode; + var isSupported = exports.isSupportedMode(mode); + if (isSupported && mode.$modes) { + try { + editorProxy.setupContext(editor); + if (/js|php/.test(editorProxy.getSyntax())) + isSupported = false; + } + catch (e) { } + } + return isSupported; +}; +var onChangeMode = function (e, target) { + var editor = target; + if (!editor) + return; + var enabled = exports.isSupportedMode(editor.session.$mode); + if (e.enableEmmet === false) + enabled = false; + if (enabled) + exports.load(); + exports.updateCommands(editor, enabled); +}; +exports.load = function (cb) { + if (typeof emmetPath !== "string") { + config.warn("script for emmet-core is not loaded"); + return false; + } + config.loadModule(emmetPath, function () { + emmetPath = null; + cb && cb(); + }); + return true; +}; +exports.AceEmmetEditor = AceEmmetEditor; +config.defineOptions(Editor.prototype, "editor", { + enableEmmet: { + set: function (val) { + this[val ? "on" : "removeListener"]("changeMode", onChangeMode); + onChangeMode({ enableEmmet: !!val }, this); + }, + value: true + } +}); +exports.setCore = function (e) { + if (typeof e == "string") + emmetPath = e; + else + emmet = e; +}; + +}); + (function() { + window.require(["ace/ext/emmet"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-error_marker.js b/src/main/resources/static/assets/js/vendor/template/src/ext-error_marker.js new file mode 100644 index 0000000..f7c24d5 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-error_marker.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/ext/error_marker"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-hardwrap.js b/src/main/resources/static/assets/js/vendor/template/src/ext-hardwrap.js new file mode 100644 index 0000000..0279a89 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-hardwrap.js @@ -0,0 +1,117 @@ +define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var Range = require("../range").Range; +function hardWrap(editor, options) { + var max = options.column || editor.getOption("printMarginColumn"); + var allowMerge = options.allowMerge != false; + var row = Math.min(options.startRow, options.endRow); + var endRow = Math.max(options.startRow, options.endRow); + var session = editor.session; + while (row <= endRow) { + var line = session.getLine(row); + if (line.length > max) { + var space = findSpace(line, max, 5); + if (space) { + var indentation = /^\s*/.exec(line)[0]; + session.replace(new Range(row, space.start, row, space.end), "\n" + indentation); + } + endRow++; + } + else if (allowMerge && /\S/.test(line) && row != endRow) { + var nextLine = session.getLine(row + 1); + if (nextLine && /\S/.test(nextLine)) { + var trimmedLine = line.replace(/\s+$/, ""); + var trimmedNextLine = nextLine.replace(/^\s+/, ""); + var mergedLine = trimmedLine + " " + trimmedNextLine; + var space = findSpace(mergedLine, max, 5); + if (space && space.start > trimmedLine.length || mergedLine.length < max) { + var replaceRange = new Range(row, trimmedLine.length, row + 1, nextLine.length - trimmedNextLine.length); + session.replace(replaceRange, " "); + row--; + endRow--; + } + else if (trimmedLine.length < line.length) { + session.remove(new Range(row, trimmedLine.length, row, line.length)); + } + } + } + row++; + } + function findSpace(line, max, min) { + if (line.length < max) + return; + var before = line.slice(0, max); + var after = line.slice(max); + var spaceAfter = /^(?:(\s+)|(\S+)(\s+))/.exec(after); + var spaceBefore = /(?:(\s+)|(\s+)(\S+))$/.exec(before); + var start = 0; + var end = 0; + if (spaceBefore && !spaceBefore[2]) { + start = max - spaceBefore[1].length; + end = max; + } + if (spaceAfter && !spaceAfter[2]) { + if (!start) + start = max; + end = max + spaceAfter[1].length; + } + if (start) { + return { + start: start, + end: end + }; + } + if (spaceBefore && spaceBefore[2] && spaceBefore.index > min) { + return { + start: spaceBefore.index, + end: spaceBefore.index + spaceBefore[2].length + }; + } + if (spaceAfter && spaceAfter[2]) { + start = max + spaceAfter[2].length; + return { + start: start, + end: start + spaceAfter[3].length + }; + } + } +} +function wrapAfterInput(e) { + if (e.command.name == "insertstring" && /\S/.test(e.args)) { + var editor = e.editor; + var cursor = editor.selection.cursor; + if (cursor.column <= editor.renderer.$printMarginColumn) + return; + var lastDelta = editor.session.$undoManager.$lastDelta; + hardWrap(editor, { + startRow: cursor.row, endRow: cursor.row, + allowMerge: false + }); + if (lastDelta != editor.session.$undoManager.$lastDelta) + editor.session.markUndoGroup(); + } +} +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + hardWrap: { + set: function (val) { + if (val) { + this.commands.on("afterExec", wrapAfterInput); + } + else { + this.commands.off("afterExec", wrapAfterInput); + } + }, + value: false + } +}); +exports.hardWrap = hardWrap; + +}); + (function() { + window.require(["ace/ext/hardwrap"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-keybinding_menu.js b/src/main/resources/static/assets/js/vendor/template/src/ext-keybinding_menu.js new file mode 100644 index 0000000..faf0036 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-keybinding_menu.js @@ -0,0 +1,134 @@ +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var keys = require("../../lib/keys"); +module.exports.getEditorKeybordShortcuts = function (editor) { + var KEY_MODS = keys.KEY_MODS; + var keybindings = []; + var commandMap = {}; + editor.keyBinding.$handlers.forEach(function (handler) { + var ckb = handler.commandKeyBinding; + for (var i in ckb) { + var key = i.replace(/(^|-)\w/g, function (x) { return x.toUpperCase(); }); + var commands = ckb[i]; + if (!Array.isArray(commands)) + commands = [commands]; + commands.forEach(function (command) { + if (typeof command != "string") + command = command.name; + if (commandMap[command]) { + commandMap[command].key += "|" + key; + } + else { + commandMap[command] = { key: key, command: command }; + keybindings.push(commandMap[command]); + } + }); + } + }); + return keybindings; +}; + +}); + +define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var Editor = require("../editor").Editor; +function showKeyboardShortcuts(editor) { + if (!document.getElementById('kbshortcutmenu')) { + var overlayPage = require('./menu_tools/overlay_page').overlayPage; + var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts; + var kb = getEditorKeybordShortcuts(editor); + var el = document.createElement('div'); + var commands = kb.reduce(function (previous, current) { + return previous + '
' + + current.command + ' : ' + + '' + current.key + '
'; + }, ''); + el.id = 'kbshortcutmenu'; + el.innerHTML = '

Keyboard Shortcuts

' + commands + ''; + overlayPage(editor, el); + } +} +module.exports.init = function (editor) { + Editor.prototype.showKeyboardShortcuts = function () { + showKeyboardShortcuts(this); + }; + editor.commands.addCommands([{ + name: "showKeyboardShortcuts", + bindKey: { win: "Ctrl-Alt-h", mac: "Command-Alt-h" }, + exec: function (editor, line) { + editor.showKeyboardShortcuts(); + } + }]); +}; + +}); + (function() { + window.require(["ace/ext/keybinding_menu"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-language_tools.js b/src/main/resources/static/assets/js/vendor/template/src/ext-language_tools.js new file mode 100644 index 0000000..27db509 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-language_tools.js @@ -0,0 +1,1964 @@ +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict"; +var dom = require("./lib/dom"); +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var lang = require("./lib/lang"); +var Range = require("./range").Range; +var RangeList = require("./range_list").RangeList; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var Tokenizer = require("./tokenizer").Tokenizer; +var clipboard = require("./clipboard"); +var VARIABLES = { + CURRENT_WORD: function (editor) { + return editor.session.getTextRange(editor.session.getWordRange()); + }, + SELECTION: function (editor, name, indentation) { + var text = editor.session.getTextRange(); + if (indentation) + return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1"); + return text; + }, + CURRENT_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row); + }, + PREV_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row - 1); + }, + LINE_INDEX: function (editor) { + return editor.getCursorPosition().row; + }, + LINE_NUMBER: function (editor) { + return editor.getCursorPosition().row + 1; + }, + SOFT_TABS: function (editor) { + return editor.session.getUseSoftTabs() ? "YES" : "NO"; + }, + TAB_SIZE: function (editor) { + return editor.session.getTabSize(); + }, + CLIPBOARD: function (editor) { + return clipboard.getText && clipboard.getText(); + }, + FILENAME: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0]; + }, + FILENAME_BASE: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, ""); + }, + DIRECTORY: function (editor) { + return this.FILEPATH(editor).replace(/[^/\\]*$/, ""); + }, + FILEPATH: function (editor) { return "/not implemented.txt"; }, + WORKSPACE_NAME: function () { return "Unknown"; }, + FULLNAME: function () { return "Unknown"; }, + BLOCK_COMMENT_START: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.start || ""; + }, + BLOCK_COMMENT_END: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.end || ""; + }, + LINE_COMMENT: function (editor) { + var mode = editor.session.$mode || {}; + return mode.lineCommentStart || ""; + }, + CURRENT_YEAR: date.bind(null, { year: "numeric" }), + CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }), + CURRENT_MONTH: date.bind(null, { month: "numeric" }), + CURRENT_MONTH_NAME: date.bind(null, { month: "long" }), + CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }), + CURRENT_DATE: date.bind(null, { day: "2-digit" }), + CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }), + CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }), + CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }), + CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }), + CURRENT_SECOND: date.bind(null, { second: "2-digit" }) +}; +VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION; +function date(dateFormat) { + var str = new Date().toLocaleString("en-us", dateFormat); + return str.length == 1 ? "0" + str : str; +} +var SnippetManager = function () { + this.snippetMap = {}; + this.snippetNameMap = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.getTokenizer = function () { + return SnippetManager.$tokenizer || this.createTokenizer(); + }; + this.createTokenizer = function () { + function TabstopToken(str) { + str = str.substr(1); + if (/^\d+$/.test(str)) + return [{ tabstopId: parseInt(str, 10) }]; + return [{ text: str }]; + } + function escape(ch) { + return "(?:[^\\\\" + ch + "]|\\\\.)"; + } + var formatMatcher = { + regex: "/(" + escape("/") + "+)/", + onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.fmtString = true; + ts.guard = val.slice(1, -1); + ts.flag = ""; + return ""; + }, + next: "formatString" + }; + SnippetManager.$tokenizer = new Tokenizer({ + start: [ + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) { + val = ch; + } + else if ("`$\\".indexOf(ch) != -1) { + val = ch; + } + return [val]; + } }, + { regex: /}/, onMatch: function (val, state, stack) { + return [stack.length ? stack.shift() : val]; + } }, + { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken }, + { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) { + var t = TabstopToken(str.substr(1)); + stack.unshift(t[0]); + return t; + }, next: "snippetVar" }, + { regex: /\n/, token: "newline", merge: false } + ], + snippetVar: [ + { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) { + var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) { + return operator.length == 2 ? operator[1] : "\x00"; + }).split("\x00").map(function (value) { + return { value: value }; + }); + stack[0].choices = choices; + return [choices[0]]; + }, next: "start" }, + formatMatcher, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" } + ], + formatString: [ + { regex: /:/, onMatch: function (val, state, stack) { + if (stack.length && stack[0].expectElse) { + stack[0].expectElse = false; + stack[0].ifEnd = { elseEnd: stack[0] }; + return [stack[0].ifEnd]; + } + return ":"; + } }, + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) + val = ch; + else if ("`$\\".indexOf(ch) != -1) + val = ch; + else if (ch == "n") + val = "\n"; + else if (ch == "t") + val = "\t"; + else if ("ulULE".indexOf(ch) != -1) + val = { changeCase: ch, local: ch > "a" }; + return [val]; + } }, + { regex: "/\\w*}", onMatch: function (val, state, stack) { + var next = stack.shift(); + if (next) + next.flag = val.slice(1, -1); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" }, + { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) { + return [{ text: val.slice(1) }]; + } }, + { regex: /\${\w+/, onMatch: function (val, state, stack) { + var token = { text: val.slice(2) }; + stack.unshift(token); + return [token]; + }, next: "formatStringVar" }, + { regex: /\n/, token: "newline", merge: false }, + { regex: /}/, onMatch: function (val, state, stack) { + var next = stack.shift(); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" } + ], + formatStringVar: [ + { regex: /:\/\w+}/, onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.formatFunction = val.slice(2, -1); + return [stack.shift()]; + }, next: "formatString" }, + formatMatcher, + { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) { + if (val[1] == "+") + stack[0].ifEnd = stack[0]; + if (val[1] == "?") + stack[0].expectElse = true; + }, next: "formatString" }, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" } + ] + }); + return SnippetManager.$tokenizer; + }; + this.tokenizeTmSnippet = function (str, startState) { + return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) { + return x.value || x; + }); + }; + this.getVariableValue = function (editor, name, indentation) { + if (/^\d+$/.test(name)) + return (this.variables.__ || {})[name] || ""; + if (/^[A-Z]\d+$/.test(name)) + return (this.variables[name[0] + "__"] || {})[name.substr(1)] || ""; + name = name.replace(/^TM_/, ""); + if (!this.variables.hasOwnProperty(name)) + return ""; + var value = this.variables[name]; + if (typeof value == "function") + value = this.variables[name](editor, name, indentation); + return value == null ? "" : value; + }; + this.variables = VARIABLES; + this.tmStrFormat = function (str, ch, editor) { + if (!ch.fmt) + return str; + var flag = ch.flag || ""; + var re = ch.guard; + re = new RegExp(re, flag.replace(/[^gim]/g, "")); + var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt; + var _self = this; + var formatted = str.replace(re, function () { + var oldArgs = _self.variables.__; + _self.variables.__ = [].slice.call(arguments); + var fmtParts = _self.resolveVariables(fmtTokens, editor); + var gChangeCase = "E"; + for (var i = 0; i < fmtParts.length; i++) { + var ch = fmtParts[i]; + if (typeof ch == "object") { + fmtParts[i] = ""; + if (ch.changeCase && ch.local) { + var next = fmtParts[i + 1]; + if (next && typeof next == "string") { + if (ch.changeCase == "u") + fmtParts[i] = next[0].toUpperCase(); + else + fmtParts[i] = next[0].toLowerCase(); + fmtParts[i + 1] = next.substr(1); + } + } + else if (ch.changeCase) { + gChangeCase = ch.changeCase; + } + } + else if (gChangeCase == "U") { + fmtParts[i] = ch.toUpperCase(); + } + else if (gChangeCase == "L") { + fmtParts[i] = ch.toLowerCase(); + } + } + _self.variables.__ = oldArgs; + return fmtParts.join(""); + }); + return formatted; + }; + this.tmFormatFunction = function (str, ch, editor) { + if (ch.formatFunction == "upcase") + return str.toUpperCase(); + if (ch.formatFunction == "downcase") + return str.toLowerCase(); + return str; + }; + this.resolveVariables = function (snippet, editor) { + var result = []; + var indentation = ""; + var afterNewLine = true; + for (var i = 0; i < snippet.length; i++) { + var ch = snippet[i]; + if (typeof ch == "string") { + result.push(ch); + if (ch == "\n") { + afterNewLine = true; + indentation = ""; + } + else if (afterNewLine) { + indentation = /^\t*/.exec(ch)[0]; + afterNewLine = /\S/.test(ch); + } + continue; + } + if (!ch) + continue; + afterNewLine = false; + if (ch.fmtString) { + var j = snippet.indexOf(ch, i + 1); + if (j == -1) + j = snippet.length; + ch.fmt = snippet.slice(i + 1, j); + i = j; + } + if (ch.text) { + var value = this.getVariableValue(editor, ch.text, indentation) + ""; + if (ch.fmtString) + value = this.tmStrFormat(value, ch, editor); + if (ch.formatFunction) + value = this.tmFormatFunction(value, ch, editor); + if (value && !ch.ifEnd) { + result.push(value); + gotoNext(ch); + } + else if (!value && ch.ifEnd) { + gotoNext(ch.ifEnd); + } + } + else if (ch.elseEnd) { + gotoNext(ch.elseEnd); + } + else if (ch.tabstopId != null) { + result.push(ch); + } + else if (ch.changeCase != null) { + result.push(ch); + } + } + function gotoNext(ch) { + var i1 = snippet.indexOf(ch, i + 1); + if (i1 != -1) + i = i1; + } + return result; + }; + this.insertSnippetForSelection = function (editor, snippetText) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var tabString = editor.session.getTabString(); + var indentString = line.match(/^\s*/)[0]; + if (cursor.column < indentString.length) + indentString = indentString.slice(0, cursor.column); + snippetText = snippetText.replace(/\r/g, ""); + var tokens = this.tokenizeTmSnippet(snippetText); + tokens = this.resolveVariables(tokens, editor); + tokens = tokens.map(function (x) { + if (x == "\n") + return x + indentString; + if (typeof x == "string") + return x.replace(/\t/g, tabString); + return x; + }); + var tabstops = []; + tokens.forEach(function (p, i) { + if (typeof p != "object") + return; + var id = p.tabstopId; + var ts = tabstops[id]; + if (!ts) { + ts = tabstops[id] = []; + ts.index = id; + ts.value = ""; + ts.parents = {}; + } + if (ts.indexOf(p) !== -1) + return; + if (p.choices && !ts.choices) + ts.choices = p.choices; + ts.push(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 === -1) + return; + var value = tokens.slice(i + 1, i1); + var isNested = value.some(function (t) { return typeof t === "object"; }); + if (isNested && !ts.value) { + ts.value = value; + } + else if (value.length && (!ts.value || typeof ts.value !== "string")) { + ts.value = value.join(""); + } + }); + tabstops.forEach(function (ts) { ts.length = 0; }); + var expanding = {}; + function copyValue(val) { + var copy = []; + for (var i = 0; i < val.length; i++) { + var p = val[i]; + if (typeof p == "object") { + if (expanding[p.tabstopId]) + continue; + var j = val.lastIndexOf(p, i - 1); + p = copy[j] || { tabstopId: p.tabstopId }; + } + copy[i] = p; + } + return copy; + } + for (var i = 0; i < tokens.length; i++) { + var p = tokens[i]; + if (typeof p != "object") + continue; + var id = p.tabstopId; + var ts = tabstops[id]; + var i1 = tokens.indexOf(p, i + 1); + if (expanding[id]) { + if (expanding[id] === p) { + delete expanding[id]; + Object.keys(expanding).forEach(function (parentId) { + ts.parents[parentId] = true; + }); + } + continue; + } + expanding[id] = p; + var value = ts.value; + if (typeof value !== "string") + value = copyValue(value); + else if (p.fmt) + value = this.tmStrFormat(value, p, editor); + tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p)); + if (ts.indexOf(p) === -1) + ts.push(p); + } + var row = 0, column = 0; + var text = ""; + tokens.forEach(function (t) { + if (typeof t === "string") { + var lines = t.split("\n"); + if (lines.length > 1) { + column = lines[lines.length - 1].length; + row += lines.length - 1; + } + else + column += t.length; + text += t; + } + else if (t) { + if (!t.start) + t.start = { row: row, column: column }; + else + t.end = { row: row, column: column }; + } + }); + var range = editor.getSelectionRange(); + var end = editor.session.replace(range, text); + var tabstopManager = new TabstopManager(editor); + var selectionId = editor.inVirtualSelectionMode && editor.selection.index; + tabstopManager.addTabstops(tabstops, range.start, end, selectionId); + }; + this.insertSnippet = function (editor, snippetText) { + var self = this; + if (editor.inVirtualSelectionMode) + return self.insertSnippetForSelection(editor, snippetText); + editor.forEachSelection(function () { + self.insertSnippetForSelection(editor, snippetText); + }, null, { keepOrder: true }); + if (editor.tabstopManager) + editor.tabstopManager.tabNext(); + }; + this.$getScope = function (editor) { + var scope = editor.session.$mode.$id || ""; + scope = scope.split("/").pop(); + if (scope === "html" || scope === "php") { + if (scope === "php" && !editor.session.$mode.inlinePhp) + scope = "html"; + var c = editor.getCursorPosition(); + var state = editor.session.getState(c.row); + if (typeof state === "object") { + state = state[0]; + } + if (state.substring) { + if (state.substring(0, 3) == "js-") + scope = "javascript"; + else if (state.substring(0, 4) == "css-") + scope = "css"; + else if (state.substring(0, 4) == "php-") + scope = "php"; + } + } + return scope; + }; + this.getActiveScopes = function (editor) { + var scope = this.$getScope(editor); + var scopes = [scope]; + var snippetMap = this.snippetMap; + if (snippetMap[scope] && snippetMap[scope].includeScopes) { + scopes.push.apply(scopes, snippetMap[scope].includeScopes); + } + scopes.push("_"); + return scopes; + }; + this.expandWithTab = function (editor, options) { + var self = this; + var result = editor.forEachSelection(function () { + return self.expandSnippetForSelection(editor, options); + }, null, { keepOrder: true }); + if (result && editor.tabstopManager) + editor.tabstopManager.tabNext(); + return result; + }; + this.expandSnippetForSelection = function (editor, options) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var before = line.substring(0, cursor.column); + var after = line.substr(cursor.column); + var snippetMap = this.snippetMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = this.findMatchingSnippet(snippets, before, after); + return !!snippet; + }, this); + if (!snippet) + return false; + if (options && options.dryRun) + return true; + editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length); + this.variables.M__ = snippet.matchBefore; + this.variables.T__ = snippet.matchAfter; + this.insertSnippetForSelection(editor, snippet.content); + this.variables.M__ = this.variables.T__ = null; + return true; + }; + this.findMatchingSnippet = function (snippetList, before, after) { + for (var i = snippetList.length; i--;) { + var s = snippetList[i]; + if (s.startRe && !s.startRe.test(before)) + continue; + if (s.endRe && !s.endRe.test(after)) + continue; + if (!s.startRe && !s.endRe) + continue; + s.matchBefore = s.startRe ? s.startRe.exec(before) : [""]; + s.matchAfter = s.endRe ? s.endRe.exec(after) : [""]; + s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : ""; + s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : ""; + return s; + } + }; + this.snippetMap = {}; + this.snippetNameMap = {}; + this.register = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + var self = this; + if (!snippets) + snippets = []; + function wrapRegexp(src) { + if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) + src = "(?:" + src + ")"; + return src || ""; + } + function guardedRegexp(re, guard, opening) { + re = wrapRegexp(re); + guard = wrapRegexp(guard); + if (opening) { + re = guard + re; + if (re && re[re.length - 1] != "$") + re = re + "$"; + } + else { + re = re + guard; + if (re && re[0] != "^") + re = "^" + re; + } + return new RegExp(re); + } + function addSnippet(s) { + if (!s.scope) + s.scope = scope || "_"; + scope = s.scope; + if (!snippetMap[scope]) { + snippetMap[scope] = []; + snippetNameMap[scope] = {}; + } + var map = snippetNameMap[scope]; + if (s.name) { + var old = map[s.name]; + if (old) + self.unregister(old); + map[s.name] = s; + } + snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { + if (!s.guard && /^\w/.test(s.tabTrigger)) + s.guard = "\\b"; + s.trigger = lang.escapeRegExp(s.tabTrigger); + } + if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard) + return; + s.startRe = guardedRegexp(s.trigger, s.guard, true); + s.triggerRe = new RegExp(s.trigger); + s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); + s.endTriggerRe = new RegExp(s.endTrigger); + } + if (Array.isArray(snippets)) { + snippets.forEach(addSnippet); + } + else { + Object.keys(snippets).forEach(function (key) { + addSnippet(snippets[key]); + }); + } + this._signal("registerSnippets", { scope: scope }); + }; + this.unregister = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + function removeSnippet(s) { + var nameMap = snippetNameMap[s.scope || scope]; + if (nameMap && nameMap[s.name]) { + delete nameMap[s.name]; + var map = snippetMap[s.scope || scope]; + var i = map && map.indexOf(s); + if (i >= 0) + map.splice(i, 1); + } + } + if (snippets.content) + removeSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(removeSnippet); + }; + this.parseSnippetFile = function (str) { + str = str.replace(/\r/g, ""); + var list = [], snippet = {}; + var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm; + var m; + while (m = re.exec(str)) { + if (m[1]) { + try { + snippet = JSON.parse(m[1]); + list.push(snippet); + } + catch (e) { } + } + if (m[4]) { + snippet.content = m[4].replace(/^\t/gm, ""); + list.push(snippet); + snippet = {}; + } + else { + var key = m[2], val = m[3]; + if (key == "regex") { + var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g; + snippet.guard = guardRe.exec(val)[1]; + snippet.trigger = guardRe.exec(val)[1]; + snippet.endTrigger = guardRe.exec(val)[1]; + snippet.endGuard = guardRe.exec(val)[1]; + } + else if (key == "snippet") { + snippet.tabTrigger = val.match(/^\S*/)[0]; + if (!snippet.name) + snippet.name = val; + } + else if (key) { + snippet[key] = val; + } + } + } + return list; + }; + this.getSnippetByName = function (name, editor) { + var snippetMap = this.snippetNameMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = snippets[name]; + return !!snippet; + }, this); + return snippet; + }; +}).call(SnippetManager.prototype); +var TabstopManager = function (editor) { + if (editor.tabstopManager) + return editor.tabstopManager; + editor.tabstopManager = this; + this.$onChange = this.onChange.bind(this); + this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule; + this.$onChangeSession = this.onChangeSession.bind(this); + this.$onAfterExec = this.onAfterExec.bind(this); + this.attach(editor); +}; +(function () { + this.attach = function (editor) { + this.index = 0; + this.ranges = []; + this.tabstops = []; + this.$openTabstops = null; + this.selectedTabstop = null; + this.editor = editor; + this.editor.on("change", this.$onChange); + this.editor.on("changeSelection", this.$onChangeSelection); + this.editor.on("changeSession", this.$onChangeSession); + this.editor.commands.on("afterExec", this.$onAfterExec); + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.detach = function () { + this.tabstops.forEach(this.removeTabstopMarkers, this); + this.ranges = null; + this.tabstops = null; + this.selectedTabstop = null; + this.editor.removeListener("change", this.$onChange); + this.editor.removeListener("changeSelection", this.$onChangeSelection); + this.editor.removeListener("changeSession", this.$onChangeSession); + this.editor.commands.removeListener("afterExec", this.$onAfterExec); + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.tabstopManager = null; + this.editor = null; + }; + this.onChange = function (delta) { + var isRemove = delta.action[0] == "r"; + var selectedTabstop = this.selectedTabstop || {}; + var parents = selectedTabstop.parents || {}; + var tabstops = (this.tabstops || []).slice(); + for (var i = 0; i < tabstops.length; i++) { + var ts = tabstops[i]; + var active = ts == selectedTabstop || parents[ts.index]; + ts.rangeList.$bias = active ? 0 : 1; + if (delta.action == "remove" && ts !== selectedTabstop) { + var parentActive = ts.parents && ts.parents[selectedTabstop.index]; + var startIndex = ts.rangeList.pointIndex(delta.start, parentActive); + startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1; + var endIndex = ts.rangeList.pointIndex(delta.end, parentActive); + endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1; + var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex); + for (var j = 0; j < toRemove.length; j++) + this.removeRange(toRemove[j]); + } + ts.rangeList.$onChange(delta); + } + var session = this.editor.session; + if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue()) + this.detach(); + }; + this.updateLinkedFields = function () { + var ts = this.selectedTabstop; + if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked) + return; + this.$inChange = true; + var session = this.editor.session; + var text = session.getTextRange(ts.firstNonLinked); + for (var i = 0; i < ts.length; i++) { + var range = ts[i]; + if (!range.linked) + continue; + var original = range.original; + var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor); + session.replace(range, fmt); + } + this.$inChange = false; + }; + this.onAfterExec = function (e) { + if (e.command && !e.command.readOnly) + this.updateLinkedFields(); + }; + this.onChangeSelection = function () { + if (!this.editor) + return; + var lead = this.editor.selection.lead; + var anchor = this.editor.selection.anchor; + var isEmpty = this.editor.selection.isEmpty(); + for (var i = 0; i < this.ranges.length; i++) { + if (this.ranges[i].linked) + continue; + var containsLead = this.ranges[i].contains(lead.row, lead.column); + var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column); + if (containsLead && containsAnchor) + return; + } + this.detach(); + }; + this.onChangeSession = function () { + this.detach(); + }; + this.tabNext = function (dir) { + var max = this.tabstops.length; + var index = this.index + (dir || 1); + index = Math.min(Math.max(index, 1), max); + if (index == max) + index = 0; + this.selectTabstop(index); + if (index === 0) + this.detach(); + }; + this.selectTabstop = function (index) { + this.$openTabstops = null; + var ts = this.tabstops[this.index]; + if (ts) + this.addTabstopMarkers(ts); + this.index = index; + ts = this.tabstops[this.index]; + if (!ts || !ts.length) + return; + this.selectedTabstop = ts; + var range = ts.firstNonLinked || ts; + if (ts.choices) + range.cursor = range.start; + if (!this.editor.inVirtualSelectionMode) { + var sel = this.editor.multiSelect; + sel.toSingleRange(range); + for (var i = 0; i < ts.length; i++) { + if (ts.hasLinkedRanges && ts[i].linked) + continue; + sel.addRange(ts[i].clone(), true); + } + } + else { + this.editor.selection.fromOrientedRange(range); + } + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + if (this.selectedTabstop && this.selectedTabstop.choices) + this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices }); + }; + this.addTabstops = function (tabstops, start, end) { + var useLink = this.useLink || !this.editor.getOption("enableMultiselect"); + if (!this.$openTabstops) + this.$openTabstops = []; + if (!tabstops[0]) { + var p = Range.fromPoints(end, end); + moveRelative(p.start, start); + moveRelative(p.end, start); + tabstops[0] = [p]; + tabstops[0].index = 0; + } + var i = this.index; + var arg = [i + 1, 0]; + var ranges = this.ranges; + tabstops.forEach(function (ts, index) { + var dest = this.$openTabstops[index] || ts; + for (var i = 0; i < ts.length; i++) { + var p = ts[i]; + var range = Range.fromPoints(p.start, p.end || p.start); + movePoint(range.start, start); + movePoint(range.end, start); + range.original = p; + range.tabstop = dest; + ranges.push(range); + if (dest != ts) + dest.unshift(range); + else + dest[i] = range; + if (p.fmtString || (dest.firstNonLinked && useLink)) { + range.linked = true; + dest.hasLinkedRanges = true; + } + else if (!dest.firstNonLinked) + dest.firstNonLinked = range; + } + if (!dest.firstNonLinked) + dest.hasLinkedRanges = false; + if (dest === ts) { + arg.push(dest); + this.$openTabstops[index] = dest; + } + this.addTabstopMarkers(dest); + dest.rangeList = dest.rangeList || new RangeList(); + dest.rangeList.$bias = 0; + dest.rangeList.addList(dest); + }, this); + if (arg.length > 2) { + if (this.tabstops.length) + arg.push(arg.splice(2, 1)[0]); + this.tabstops.splice.apply(this.tabstops, arg); + } + }; + this.addTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + if (!range.markerId) + range.markerId = session.addMarker(range, "ace_snippet-marker", "text"); + }); + }; + this.removeTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + session.removeMarker(range.markerId); + range.markerId = null; + }); + }; + this.removeRange = function (range) { + var i = range.tabstop.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + i = this.ranges.indexOf(range); + if (i != -1) + this.ranges.splice(i, 1); + i = range.tabstop.rangeList.ranges.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + this.editor.session.removeMarker(range.markerId); + if (!range.tabstop.length) { + i = this.tabstops.indexOf(range.tabstop); + if (i != -1) + this.tabstops.splice(i, 1); + if (!this.tabstops.length) + this.detach(); + } + }; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys({ + "Tab": function (editor) { + if (exports.snippetManager && exports.snippetManager.expandWithTab(editor)) + return; + editor.tabstopManager.tabNext(1); + editor.renderer.scrollCursorIntoView(); + }, + "Shift-Tab": function (editor) { + editor.tabstopManager.tabNext(-1); + editor.renderer.scrollCursorIntoView(); + }, + "Esc": function (editor) { + editor.tabstopManager.detach(); + } + }); +}).call(TabstopManager.prototype); +var movePoint = function (point, diff) { + if (point.row == 0) + point.column += diff.column; + point.row += diff.row; +}; +var moveRelative = function (point, start) { + if (point.row == start.row) + point.column -= start.column; + point.row -= start.row; +}; +dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false); +exports.snippetManager = new SnippetManager(); +var Editor = require("./editor").Editor; +(function () { + this.insertSnippet = function (content, options) { + return exports.snippetManager.insertSnippet(this, content, options); + }; + this.expandSnippet = function (options) { + return exports.snippetManager.expandWithTab(this, options); + }; +}).call(Editor.prototype); + +}); + +define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"], function(require, exports, module){"use strict"; +var Renderer = require("../virtual_renderer").VirtualRenderer; +var Editor = require("../editor").Editor; +var Range = require("../range").Range; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); +var $singleLineEditor = function (el) { + var renderer = new Renderer(el); + renderer.$maxLines = 4; + var editor = new Editor(renderer); + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.renderer.setShowGutter(false); + editor.renderer.setHighlightGutterLine(false); + editor.$mouseHandler.$focusTimeout = 0; + editor.$highlightTagPending = true; + return editor; +}; +var AcePopup = function (parentNode) { + var el = dom.createElement("div"); + var popup = new $singleLineEditor(el); + if (parentNode) + parentNode.appendChild(el); + el.style.display = "none"; + popup.renderer.content.style.cursor = "default"; + popup.renderer.setStyle("ace_autocomplete"); + popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); + var noop = function () { }; + popup.focus = noop; + popup.$isFocused = true; + popup.renderer.$cursorLayer.restartTimer = noop; + popup.renderer.$cursorLayer.element.style.opacity = 0; + popup.renderer.$maxLines = 8; + popup.renderer.$keepTextAreaAtCursor = false; + popup.setHighlightActiveLine(false); + popup.session.highlight(""); + popup.session.$searchHighlight.clazz = "ace_highlight-marker"; + popup.on("mousedown", function (e) { + var pos = e.getDocumentPosition(); + popup.selection.moveToPosition(pos); + selectionMarker.start.row = selectionMarker.end.row = pos.row; + e.stop(); + }); + var lastMouseEvent; + var hoverMarker = new Range(-1, 0, -1, Infinity); + var selectionMarker = new Range(-1, 0, -1, Infinity); + selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine"); + popup.setSelectOnHover = function (val) { + if (!val) { + hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine"); + } + else if (hoverMarker.id) { + popup.session.removeMarker(hoverMarker.id); + hoverMarker.id = null; + } + }; + popup.setSelectOnHover(false); + popup.on("mousemove", function (e) { + if (!lastMouseEvent) { + lastMouseEvent = e; + return; + } + if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) { + return; + } + lastMouseEvent = e; + lastMouseEvent.scrollTop = popup.renderer.scrollTop; + var row = lastMouseEvent.getDocumentPosition().row; + if (hoverMarker.start.row != row) { + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row); + } + }); + popup.renderer.on("beforeRender", function () { + if (lastMouseEvent && hoverMarker.start.row != -1) { + lastMouseEvent.$pos = null; + var row = lastMouseEvent.getDocumentPosition().row; + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row, true); + } + }); + popup.renderer.on("afterRender", function () { + var row = popup.getRow(); + var t = popup.renderer.$textLayer; + var selected = t.element.childNodes[row - t.config.firstRow]; + if (selected !== t.selectedNode && t.selectedNode) + dom.removeCssClass(t.selectedNode, "ace_selected"); + t.selectedNode = selected; + if (selected) + dom.addCssClass(selected, "ace_selected"); + }); + var hideHoverMarker = function () { setHoverMarker(-1); }; + var setHoverMarker = function (row, suppressRedraw) { + if (row !== hoverMarker.start.row) { + hoverMarker.start.row = hoverMarker.end.row = row; + if (!suppressRedraw) + popup.session._emit("changeBackMarker"); + popup._emit("changeHoverMarker"); + } + }; + popup.getHoveredRow = function () { + return hoverMarker.start.row; + }; + event.addListener(popup.container, "mouseout", hideHoverMarker); + popup.on("hide", hideHoverMarker); + popup.on("changeSelection", hideHoverMarker); + popup.session.doc.getLength = function () { + return popup.data.length; + }; + popup.session.doc.getLine = function (i) { + var data = popup.data[i]; + if (typeof data == "string") + return data; + return (data && data.value) || ""; + }; + var bgTokenizer = popup.session.bgTokenizer; + bgTokenizer.$tokenizeRow = function (row) { + var data = popup.data[row]; + var tokens = []; + if (!data) + return tokens; + if (typeof data == "string") + data = { value: data }; + var caption = data.caption || data.value || data.name; + function addToken(value, className) { + value && tokens.push({ + type: (data.className || "") + (className || ""), + value: value + }); + } + var lower = caption.toLowerCase(); + var filterText = (popup.filterText || "").toLowerCase(); + var lastIndex = 0; + var lastI = 0; + for (var i = 0; i <= filterText.length; i++) { + if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) { + var sub = filterText.slice(lastI, i); + lastI = i; + var index = lower.indexOf(sub, lastIndex); + if (index == -1) + continue; + addToken(caption.slice(lastIndex, index), ""); + lastIndex = index + sub.length; + addToken(caption.slice(index, lastIndex), "completion-highlight"); + } + } + addToken(caption.slice(lastIndex, caption.length), ""); + if (data.meta) + tokens.push({ type: "completion-meta", value: data.meta }); + if (data.message) + tokens.push({ type: "completion-message", value: data.message }); + return tokens; + }; + bgTokenizer.$updateOnChange = noop; + bgTokenizer.start = noop; + popup.session.$computeWidth = function () { + return this.screenWidth = 0; + }; + popup.isOpen = false; + popup.isTopdown = false; + popup.autoSelect = true; + popup.filterText = ""; + popup.data = []; + popup.setData = function (list, filterText) { + popup.filterText = filterText || ""; + popup.setValue(lang.stringRepeat("\n", list.length), -1); + popup.data = list || []; + popup.setRow(0); + }; + popup.getData = function (row) { + return popup.data[row]; + }; + popup.getRow = function () { + return selectionMarker.start.row; + }; + popup.setRow = function (line) { + line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line)); + if (selectionMarker.start.row != line) { + popup.selection.clearSelection(); + selectionMarker.start.row = selectionMarker.end.row = line || 0; + popup.session._emit("changeBackMarker"); + popup.moveCursorTo(line || 0, 0); + if (popup.isOpen) + popup._signal("select"); + } + }; + popup.on("changeSelection", function () { + if (popup.isOpen) + popup.setRow(popup.selection.lead.row); + popup.renderer.scrollCursorIntoView(); + }); + popup.hide = function () { + this.container.style.display = "none"; + this._signal("hide"); + popup.isOpen = false; + }; + popup.show = function (pos, lineHeight, topdownOnly) { + var el = this.container; + var screenHeight = window.innerHeight; + var screenWidth = window.innerWidth; + var renderer = this.renderer; + var maxH = renderer.$maxLines * lineHeight * 1.4; + var top = pos.top + this.$borderSize; + var allowTopdown = top > screenHeight / 2 && !topdownOnly; + if (allowTopdown && top + lineHeight + maxH > screenHeight) { + renderer.$maxPixelHeight = top - 2 * this.$borderSize; + el.style.top = ""; + el.style.bottom = screenHeight - top + "px"; + popup.isTopdown = false; + } + else { + top += lineHeight; + renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight; + el.style.top = top + "px"; + el.style.bottom = ""; + popup.isTopdown = true; + } + el.style.display = ""; + var left = pos.left; + if (left + el.offsetWidth > screenWidth) + left = screenWidth - el.offsetWidth; + el.style.left = left + "px"; + this._signal("show"); + lastMouseEvent = null; + popup.isOpen = true; + }; + popup.goTo = function (where) { + var row = this.getRow(); + var max = this.session.getLength() - 1; + switch (where) { + case "up": + row = row <= 0 ? max : row - 1; + break; + case "down": + row = row >= max ? -1 : row + 1; + break; + case "start": + row = 0; + break; + case "end": + row = max; + break; + } + this.setRow(row); + }; + popup.getTextLeftOffset = function () { + return this.$borderSize + this.renderer.$padding + this.$imageSize; + }; + popup.$imageSize = 0; + popup.$borderSize = 1; + return popup; +}; +dom.importCssString("\n.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #CAD6FA;\n z-index: 1;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #3a674e;\n}\n.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid #abbffe;\n margin-top: -1px;\n background: rgba(233,233,253,0.4);\n position: absolute;\n z-index: 2;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid rgba(109, 150, 13, 0.8);\n background: rgba(58, 103, 78, 0.62);\n}\n.ace_completion-meta {\n opacity: 0.5;\n margin: 0.9em;\n}\n.ace_completion-message {\n color: blue;\n}\n.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #2d69c7;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #93ca12;\n}\n.ace_editor.ace_autocomplete {\n width: 300px;\n z-index: 200000;\n border: 1px lightgray solid;\n position: fixed;\n box-shadow: 2px 3px 5px rgba(0,0,0,.2);\n line-height: 1.4;\n background: #fefefe;\n color: #111;\n}\n.ace_dark.ace_editor.ace_autocomplete {\n border: 1px #484747 solid;\n box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\n line-height: 1.4;\n background: #25282c;\n color: #c1c1c1;\n}", "autocompletion.css", false); +exports.AcePopup = AcePopup; +exports.$singleLineEditor = $singleLineEditor; + +}); + +define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module){"use strict"; +exports.parForEach = function (array, fn, callback) { + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function (result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } +}; +var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/; +exports.retrievePrecedingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos - 1; i >= 0; i--) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf.reverse().join(""); +}; +exports.retrieveFollowingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf; +}; +exports.getCompletionPrefix = function (editor) { + var pos = editor.getCursorPosition(); + var line = editor.session.getLine(pos.row); + var prefix; + editor.completers.forEach(function (completer) { + if (completer.identifierRegexps) { + completer.identifierRegexps.forEach(function (identifierRegex) { + if (!prefix && identifierRegex) + prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex); + }.bind(this)); + } + }.bind(this)); + return prefix || this.retrievePrecedingIdentifier(line, pos.column); +}; + +}); + +define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config"], function(require, exports, module){"use strict"; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var AcePopup = require("./autocomplete/popup").AcePopup; +var util = require("./autocomplete/util"); +var lang = require("./lib/lang"); +var dom = require("./lib/dom"); +var snippetManager = require("./snippets").snippetManager; +var config = require("./config"); +var Autocomplete = function () { + this.autoInsert = false; + this.autoSelect = true; + this.exactMatch = false; + this.gatherCompletionsId = 0; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys(this.commands); + this.blurListener = this.blurListener.bind(this); + this.changeListener = this.changeListener.bind(this); + this.mousedownListener = this.mousedownListener.bind(this); + this.mousewheelListener = this.mousewheelListener.bind(this); + this.changeTimer = lang.delayedCall(function () { + this.updateCompletions(true); + }.bind(this)); + this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50); +}; +(function () { + this.$init = function () { + this.popup = new AcePopup(document.body || document.documentElement); + this.popup.on("click", function (e) { + this.insertMatch(); + e.stop(); + }.bind(this)); + this.popup.focus = this.editor.focus.bind(this.editor); + this.popup.on("show", this.tooltipTimer.bind(null, null)); + this.popup.on("select", this.tooltipTimer.bind(null, null)); + this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null)); + return this.popup; + }; + this.getPopup = function () { + return this.popup || this.$init(); + }; + this.openPopup = function (editor, prefix, keepPopupPosition) { + if (!this.popup) + this.$init(); + this.popup.autoSelect = this.autoSelect; + this.popup.setData(this.completions.filtered, this.completions.filterText); + editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + var renderer = editor.renderer; + this.popup.setRow(this.autoSelect ? 0 : -1); + if (!keepPopupPosition) { + this.popup.setTheme(editor.getTheme()); + this.popup.setFontSize(editor.getFontSize()); + var lineHeight = renderer.layerConfig.lineHeight; + var pos = renderer.$cursorLayer.getPixelPosition(this.base, true); + pos.left -= this.popup.getTextLeftOffset(); + var rect = editor.container.getBoundingClientRect(); + pos.top += rect.top - renderer.layerConfig.offset; + pos.left += rect.left - editor.renderer.scrollLeft; + pos.left += renderer.gutterWidth; + this.popup.show(pos, lineHeight); + } + else if (keepPopupPosition && !prefix) { + this.detach(); + } + this.changeTimer.cancel(); + }; + this.detach = function () { + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.off("changeSelection", this.changeListener); + this.editor.off("blur", this.blurListener); + this.editor.off("mousedown", this.mousedownListener); + this.editor.off("mousewheel", this.mousewheelListener); + this.changeTimer.cancel(); + this.hideDocTooltip(); + this.gatherCompletionsId += 1; + if (this.popup && this.popup.isOpen) + this.popup.hide(); + if (this.base) + this.base.detach(); + this.activated = false; + this.completions = this.base = null; + }; + this.changeListener = function (e) { + var cursor = this.editor.selection.lead; + if (cursor.row != this.base.row || cursor.column < this.base.column) { + this.detach(); + } + if (this.activated) + this.changeTimer.schedule(); + else + this.detach(); + }; + this.blurListener = function (e) { + var el = document.activeElement; + var text = this.editor.textInput.getElement(); + var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget); + var container = this.popup && this.popup.container; + if (el != text && el.parentNode != container && !fromTooltip + && el != this.tooltipNode && e.relatedTarget != text) { + this.detach(); + } + }; + this.mousedownListener = function (e) { + this.detach(); + }; + this.mousewheelListener = function (e) { + this.detach(); + }; + this.goTo = function (where) { + this.popup.goTo(where); + }; + this.insertMatch = function (data, options) { + if (!data) + data = this.popup.getData(this.popup.getRow()); + if (!data) + return false; + var completions = this.completions; + this.editor.startOperation({ command: { name: "insertMatch" } }); + if (data.completer && data.completer.insertMatch) { + data.completer.insertMatch(this.editor, data); + } + else { + if (!completions) + return false; + if (completions.filterText) { + var ranges = this.editor.selection.getAllRanges(); + for (var i = 0, range; range = ranges[i]; i++) { + range.start.column -= completions.filterText.length; + this.editor.session.remove(range); + } + } + if (data.snippet) + snippetManager.insertSnippet(this.editor, data.snippet); + else + this.editor.execCommand("insertstring", data.value || data); + } + if (this.completions == completions) + this.detach(); + this.editor.endOperation(); + }; + this.commands = { + "Up": function (editor) { editor.completer.goTo("up"); }, + "Down": function (editor) { editor.completer.goTo("down"); }, + "Ctrl-Up|Ctrl-Home": function (editor) { editor.completer.goTo("start"); }, + "Ctrl-Down|Ctrl-End": function (editor) { editor.completer.goTo("end"); }, + "Esc": function (editor) { editor.completer.detach(); }, + "Return": function (editor) { return editor.completer.insertMatch(); }, + "Shift-Return": function (editor) { editor.completer.insertMatch(null, { deleteSuffix: true }); }, + "Tab": function (editor) { + var result = editor.completer.insertMatch(); + if (!result && !editor.tabstopManager) + editor.completer.goTo("down"); + else + return result; + }, + "PageUp": function (editor) { editor.completer.popup.gotoPageUp(); }, + "PageDown": function (editor) { editor.completer.popup.gotoPageDown(); } + }; + this.gatherCompletions = function (editor, callback) { + var session = editor.getSession(); + var pos = editor.getCursorPosition(); + var prefix = util.getCompletionPrefix(editor); + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); + this.base.$insertRight = true; + var matches = []; + var total = editor.completers.length; + editor.completers.forEach(function (completer, i) { + completer.getCompletions(editor, session, pos, prefix, function (err, results) { + if (!err && results) + matches = matches.concat(results); + callback(null, { + prefix: util.getCompletionPrefix(editor), + matches: matches, + finished: (--total === 0) + }); + }); + }); + return true; + }; + this.showPopup = function (editor, options) { + if (this.editor) + this.detach(); + this.activated = true; + this.editor = editor; + if (editor.completer != this) { + if (editor.completer) + editor.completer.detach(); + editor.completer = this; + } + editor.on("changeSelection", this.changeListener); + editor.on("blur", this.blurListener); + editor.on("mousedown", this.mousedownListener); + editor.on("mousewheel", this.mousewheelListener); + this.updateCompletions(false, options); + }; + this.updateCompletions = function (keepPopupPosition, options) { + if (keepPopupPosition && this.base && this.completions) { + var pos = this.editor.getCursorPosition(); + var prefix = this.editor.session.getTextRange({ start: this.base, end: pos }); + if (prefix == this.completions.filterText) + return; + this.completions.setFilter(prefix); + if (!this.completions.filtered.length) + return this.detach(); + if (this.completions.filtered.length == 1 + && this.completions.filtered[0].value == prefix + && !this.completions.filtered[0].snippet) + return this.detach(); + this.openPopup(this.editor, prefix, keepPopupPosition); + return; + } + if (options && options.matches) { + var pos = this.editor.getSelectionRange().start; + this.base = this.editor.session.doc.createAnchor(pos.row, pos.column); + this.base.$insertRight = true; + this.completions = new FilteredList(options.matches); + return this.openPopup(this.editor, "", keepPopupPosition); + } + var _id = this.gatherCompletionsId; + var detachIfFinished = function (results) { + if (!results.finished) + return; + return this.detach(); + }.bind(this); + var processResults = function (results) { + var prefix = results.prefix; + var matches = results.matches; + this.completions = new FilteredList(matches); + if (this.exactMatch) + this.completions.exactMatch = true; + this.completions.setFilter(prefix); + var filtered = this.completions.filtered; + if (!filtered.length) + return detachIfFinished(results); + if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) + return detachIfFinished(results); + if (this.autoInsert && filtered.length == 1 && results.finished) + return this.insertMatch(filtered[0]); + this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this); + var isImmediate = true; + var immediateResults = null; + this.gatherCompletions(this.editor, function (err, results) { + var prefix = results.prefix; + var matches = results && results.matches; + if (!matches || !matches.length) + return detachIfFinished(results); + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + if (isImmediate) { + immediateResults = results; + return; + } + processResults(results); + }.bind(this)); + isImmediate = false; + if (immediateResults) { + var results = immediateResults; + immediateResults = null; + processResults(results); + } + }; + this.cancelContextMenu = function () { + this.editor.$mouseHandler.cancelContextMenu(); + }; + this.updateDocTooltip = function () { + var popup = this.popup; + var all = popup.data; + var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]); + var doc = null; + if (!selected || !this.editor || !this.popup.isOpen) + return this.hideDocTooltip(); + this.editor.completers.some(function (completer) { + if (completer.getDocTooltip) + doc = completer.getDocTooltip(selected); + return doc; + }); + if (!doc && typeof selected != "string") + doc = selected; + if (typeof doc == "string") + doc = { docText: doc }; + if (!doc || !(doc.docHTML || doc.docText)) + return this.hideDocTooltip(); + this.showDocTooltip(doc); + }; + this.showDocTooltip = function (item) { + if (!this.tooltipNode) { + this.tooltipNode = dom.createElement("div"); + this.tooltipNode.className = "ace_tooltip ace_doc-tooltip"; + this.tooltipNode.style.margin = 0; + this.tooltipNode.style.pointerEvents = "auto"; + this.tooltipNode.tabIndex = -1; + this.tooltipNode.onblur = this.blurListener.bind(this); + this.tooltipNode.onclick = this.onTooltipClick.bind(this); + } + var tooltipNode = this.tooltipNode; + if (item.docHTML) { + tooltipNode.innerHTML = item.docHTML; + } + else if (item.docText) { + tooltipNode.textContent = item.docText; + } + if (!tooltipNode.parentNode) + document.body.appendChild(tooltipNode); + var popup = this.popup; + var rect = popup.container.getBoundingClientRect(); + tooltipNode.style.top = popup.container.style.top; + tooltipNode.style.bottom = popup.container.style.bottom; + tooltipNode.style.display = "block"; + if (window.innerWidth - rect.right < 320) { + if (rect.left < 320) { + if (popup.isTopdown) { + tooltipNode.style.top = rect.bottom + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + else { + tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + } + else { + tooltipNode.style.right = window.innerWidth - rect.left + "px"; + tooltipNode.style.left = ""; + } + } + else { + tooltipNode.style.left = (rect.right + 1) + "px"; + tooltipNode.style.right = ""; + } + }; + this.hideDocTooltip = function () { + this.tooltipTimer.cancel(); + if (!this.tooltipNode) + return; + var el = this.tooltipNode; + if (!this.editor.isFocused() && document.activeElement == el) + this.editor.focus(); + this.tooltipNode = null; + if (el.parentNode) + el.parentNode.removeChild(el); + }; + this.onTooltipClick = function (e) { + var a = e.target; + while (a && a != this.tooltipNode) { + if (a.nodeName == "A" && a.href) { + a.rel = "noreferrer"; + a.target = "_blank"; + break; + } + a = a.parentNode; + } + }; + this.destroy = function () { + this.detach(); + if (this.popup) { + this.popup.destroy(); + var el = this.popup.container; + if (el && el.parentNode) + el.parentNode.removeChild(el); + } + if (this.editor && this.editor.completer == this) + this.editor.completer == null; + this.popup = null; + }; +}).call(Autocomplete.prototype); +Autocomplete.for = function (editor) { + if (editor.completer) { + return editor.completer; + } + if (config.get("sharedPopups")) { + if (!Autocomplete.$shared) + Autocomplete.$sharedInstance = new Autocomplete(); + editor.completer = Autocomplete.$sharedInstance; + } + else { + editor.completer = new Autocomplete(); + editor.once("destroy", function (e, editor) { + editor.completer.destroy(); + }); + } + return editor.completer; +}; +Autocomplete.startCommand = { + name: "startAutocomplete", + exec: function (editor, options) { + var completer = Autocomplete.for(editor); + completer.autoInsert = false; + completer.autoSelect = true; + completer.showPopup(editor, options); + completer.cancelContextMenu(); + }, + bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" +}; +var FilteredList = function (array, filterText) { + this.all = array; + this.filtered = array; + this.filterText = filterText || ""; + this.exactMatch = false; +}; +(function () { + this.setFilter = function (str) { + if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0) + var matches = this.filtered; + else + var matches = this.all; + this.filterText = str; + matches = this.filterCompletions(matches, this.filterText); + matches = matches.sort(function (a, b) { + return b.exactMatch - a.exactMatch || b.$score - a.$score + || (a.caption || a.value).localeCompare(b.caption || b.value); + }); + var prev = null; + matches = matches.filter(function (item) { + var caption = item.snippet || item.caption || item.value; + if (caption === prev) + return false; + prev = caption; + return true; + }); + this.filtered = matches; + }; + this.filterCompletions = function (items, needle) { + var results = []; + var upper = needle.toUpperCase(); + var lower = needle.toLowerCase(); + loop: for (var i = 0, item; item = items[i]; i++) { + var caption = item.caption || item.value || item.snippet; + if (!caption) + continue; + var lastIndex = -1; + var matchMask = 0; + var penalty = 0; + var index, distance; + if (this.exactMatch) { + if (needle !== caption.substr(0, needle.length)) + continue loop; + } + else { + var fullMatchIndex = caption.toLowerCase().indexOf(lower); + if (fullMatchIndex > -1) { + penalty = fullMatchIndex; + } + else { + for (var j = 0; j < needle.length; j++) { + var i1 = caption.indexOf(lower[j], lastIndex + 1); + var i2 = caption.indexOf(upper[j], lastIndex + 1); + index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2; + if (index < 0) + continue loop; + distance = index - lastIndex - 1; + if (distance > 0) { + if (lastIndex === -1) + penalty += 10; + penalty += distance; + matchMask = matchMask | (1 << j); + } + lastIndex = index; + } + } + } + item.matchMask = matchMask; + item.exactMatch = penalty ? 0 : 1; + item.$score = (item.score || 0) - penalty; + results.push(item); + } + return results; + }; +}).call(FilteredList.prototype); +exports.Autocomplete = Autocomplete; +exports.FilteredList = FilteredList; + +}); + +define("ace/autocomplete/text_completer",["require","exports","module","ace/range"], function(require, exports, module){var Range = require("../range").Range; +var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/; +function getWordIndex(doc, pos) { + var textBefore = doc.getTextRange(Range.fromPoints({ row: 0, column: 0 }, pos)); + return textBefore.split(splitRegex).length - 1; +} +function wordDistance(doc, pos) { + var prefixPos = getWordIndex(doc, pos); + var words = doc.getValue().split(splitRegex); + var wordScores = Object.create(null); + var currentWord = words[prefixPos]; + words.forEach(function (word, idx) { + if (!word || word === currentWord) + return; + var distance = Math.abs(prefixPos - idx); + var score = words.length - distance; + if (wordScores[word]) { + wordScores[word] = Math.max(score, wordScores[word]); + } + else { + wordScores[word] = score; + } + }); + return wordScores; +} +exports.getCompletions = function (editor, session, pos, prefix, callback) { + var wordScore = wordDistance(session, pos); + var wordList = Object.keys(wordScore); + callback(null, wordList.map(function (word) { + return { + caption: word, + value: word, + score: wordScore[word], + meta: "local" + }; + })); +}; + +}); + +define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/lib/lang","ace/autocomplete/util","ace/autocomplete/text_completer","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var snippetManager = require("../snippets").snippetManager; +var Autocomplete = require("../autocomplete").Autocomplete; +var config = require("../config"); +var lang = require("../lib/lang"); +var util = require("../autocomplete/util"); +var textCompleter = require("../autocomplete/text_completer"); +var keyWordCompleter = { + getCompletions: function (editor, session, pos, prefix, callback) { + if (session.$mode.completer) { + return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback); + } + var state = editor.session.getState(pos.row); + var completions = session.$mode.getCompletions(state, session, pos, prefix); + callback(null, completions); + } +}; +var transformSnippetTooltip = function (str) { + var record = {}; + return str.replace(/\${(\d+)(:(.*?))?}/g, function (_, p1, p2, p3) { + return (record[p1] = p3 || ''); + }).replace(/\$(\d+?)/g, function (_, p1) { + return record[p1]; + }); +}; +var snippetCompleter = { + getCompletions: function (editor, session, pos, prefix, callback) { + var scopes = []; + var token = session.getTokenAt(pos.row, pos.column); + if (token && token.type.match(/(tag-name|tag-open|tag-whitespace|attribute-name|attribute-value)\.xml$/)) + scopes.push('html-tag'); + else + scopes = snippetManager.getActiveScopes(editor); + var snippetMap = snippetManager.snippetMap; + var completions = []; + scopes.forEach(function (scope) { + var snippets = snippetMap[scope] || []; + for (var i = snippets.length; i--;) { + var s = snippets[i]; + var caption = s.name || s.tabTrigger; + if (!caption) + continue; + completions.push({ + caption: caption, + snippet: s.content, + meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet", + type: "snippet" + }); + } + }, this); + callback(null, completions); + }, + getDocTooltip: function (item) { + if (item.type == "snippet" && !item.docHTML) { + item.docHTML = [ + "", lang.escapeHTML(item.caption), "", "
", + lang.escapeHTML(transformSnippetTooltip(item.snippet)) + ].join(""); + } + } +}; +var completers = [snippetCompleter, textCompleter, keyWordCompleter]; +exports.setCompleters = function (val) { + completers.length = 0; + if (val) + completers.push.apply(completers, val); +}; +exports.addCompleter = function (completer) { + completers.push(completer); +}; +exports.textCompleter = textCompleter; +exports.keyWordCompleter = keyWordCompleter; +exports.snippetCompleter = snippetCompleter; +var expandSnippet = { + name: "expandSnippet", + exec: function (editor) { + return snippetManager.expandWithTab(editor); + }, + bindKey: "Tab" +}; +var onChangeMode = function (e, editor) { + loadSnippetsForMode(editor.session.$mode); +}; +var loadSnippetsForMode = function (mode) { + if (typeof mode == "string") + mode = config.$modes[mode]; + if (!mode) + return; + if (!snippetManager.files) + snippetManager.files = {}; + loadSnippetFile(mode.$id, mode.snippetFileId); + if (mode.modes) + mode.modes.forEach(loadSnippetsForMode); +}; +var loadSnippetFile = function (id, snippetFilePath) { + if (!snippetFilePath || !id || snippetManager.files[id]) + return; + snippetManager.files[id] = {}; + config.loadModule(snippetFilePath, function (m) { + if (!m) + return; + snippetManager.files[id] = m; + if (!m.snippets && m.snippetText) + m.snippets = snippetManager.parseSnippetFile(m.snippetText); + snippetManager.register(m.snippets || [], m.scope); + if (m.includeScopes) { + snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes; + m.includeScopes.forEach(function (x) { + loadSnippetsForMode("ace/mode/" + x); + }); + } + }); +}; +var doLiveAutocomplete = function (e) { + var editor = e.editor; + var hasCompleter = editor.completer && editor.completer.activated; + if (e.command.name === "backspace") { + if (hasCompleter && !util.getCompletionPrefix(editor)) + editor.completer.detach(); + } + else if (e.command.name === "insertstring") { + var prefix = util.getCompletionPrefix(editor); + if (prefix && !hasCompleter) { + var completer = Autocomplete.for(editor); + completer.autoInsert = false; + completer.showPopup(editor); + } + } +}; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableBasicAutocompletion: { + set: function (val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val) ? val : completers; + this.commands.addCommand(Autocomplete.startCommand); + } + else { + this.commands.removeCommand(Autocomplete.startCommand); + } + }, + value: false + }, + enableLiveAutocompletion: { + set: function (val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val) ? val : completers; + this.commands.on('afterExec', doLiveAutocomplete); + } + else { + this.commands.removeListener('afterExec', doLiveAutocomplete); + } + }, + value: false + }, + enableSnippets: { + set: function (val) { + if (val) { + this.commands.addCommand(expandSnippet); + this.on("changeMode", onChangeMode); + onChangeMode(null, this); + } + else { + this.commands.removeCommand(expandSnippet); + this.off("changeMode", onChangeMode); + } + }, + value: false + } +}); + +}); + (function() { + window.require(["ace/ext/language_tools"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-linking.js b/src/main/resources/static/assets/js/vendor/template/src/ext-linking.js new file mode 100644 index 0000000..09cd3e8 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-linking.js @@ -0,0 +1,57 @@ +define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableLinking: { + set: function (val) { + if (val) { + this.on("click", onClick); + this.on("mousemove", onMouseMove); + } + else { + this.off("click", onClick); + this.off("mousemove", onMouseMove); + } + }, + value: false + } +}); +exports.previousLinkingHover = false; +function onMouseMove(e) { + var editor = e.editor; + var ctrl = e.getAccelKey(); + if (ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + if (exports.previousLinkingHover && exports.previousLinkingHover != token) { + editor._emit("linkHoverOut"); + } + editor._emit("linkHover", { position: docPos, token: token }); + exports.previousLinkingHover = token; + } + else if (exports.previousLinkingHover) { + editor._emit("linkHoverOut"); + exports.previousLinkingHover = false; + } +} +function onClick(e) { + var ctrl = e.getAccelKey(); + var button = e.getButton(); + if (button == 0 && ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + editor._emit("linkClick", { position: docPos, token: token }); + } +} + +}); + (function() { + window.require(["ace/ext/linking"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-modelist.js b/src/main/resources/static/assets/js/vendor/template/src/ext-modelist.js new file mode 100644 index 0000000..b9c32d0 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-modelist.js @@ -0,0 +1,247 @@ +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + (function() { + window.require(["ace/ext/modelist"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-options.js b/src/main/resources/static/assets/js/vendor/template/src/ext-options.js new file mode 100644 index 0000000..7111140 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-options.js @@ -0,0 +1,732 @@ +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + +define("ace/ext/themelist",["require","exports","module"], function(require, exports, module){/** + * Generates a list of themes available when ace was built. + * @fileOverview Generates a list of themes available when ace was built. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ +"use strict"; +var themeData = [ + ["Chrome"], + ["Clouds"], + ["Crimson Editor"], + ["Dawn"], + ["Dreamweaver"], + ["Eclipse"], + ["GitHub"], + ["IPlastic"], + ["Solarized Light"], + ["TextMate"], + ["Tomorrow"], + ["XCode"], + ["Kuroir"], + ["KatzenMilch"], + ["SQL Server", "sqlserver", "light"], + ["Ambiance", "ambiance", "dark"], + ["Chaos", "chaos", "dark"], + ["Clouds Midnight", "clouds_midnight", "dark"], + ["Dracula", "", "dark"], + ["Cobalt", "cobalt", "dark"], + ["Gruvbox", "gruvbox", "dark"], + ["Green on Black", "gob", "dark"], + ["idle Fingers", "idle_fingers", "dark"], + ["krTheme", "kr_theme", "dark"], + ["Merbivore", "merbivore", "dark"], + ["Merbivore Soft", "merbivore_soft", "dark"], + ["Mono Industrial", "mono_industrial", "dark"], + ["Monokai", "monokai", "dark"], + ["Nord Dark", "nord_dark", "dark"], + ["One Dark", "one_dark", "dark"], + ["Pastel on dark", "pastel_on_dark", "dark"], + ["Solarized Dark", "solarized_dark", "dark"], + ["Terminal", "terminal", "dark"], + ["Tomorrow Night", "tomorrow_night", "dark"], + ["Tomorrow Night Blue", "tomorrow_night_blue", "dark"], + ["Tomorrow Night Bright", "tomorrow_night_bright", "dark"], + ["Tomorrow Night 80s", "tomorrow_night_eighties", "dark"], + ["Twilight", "twilight", "dark"], + ["Vibrant Ink", "vibrant_ink", "dark"] +]; +exports.themesByName = {}; +exports.themes = themeData.map(function (data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; +}); + +}); + +define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module){"use strict"; +require("./menu_tools/overlay_page"); +var dom = require("../lib/dom"); +var oop = require("../lib/oop"); +var config = require("../config"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; +var buildDom = dom.buildDom; +var modelist = require("./modelist"); +var themelist = require("./themelist"); +var themes = { Bright: [], Dark: [] }; +themelist.themes.forEach(function (x) { + themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme }); +}); +var modes = modelist.modes.map(function (x) { + return { caption: x.caption, value: x.mode }; +}); +var optionGroups = { + Main: { + Mode: { + path: "mode", + type: "select", + items: modes + }, + Theme: { + path: "theme", + type: "select", + items: themes + }, + "Keybinding": { + type: "buttonBar", + path: "keyboardHandler", + items: [ + { caption: "Ace", value: null }, + { caption: "Vim", value: "ace/keyboard/vim" }, + { caption: "Emacs", value: "ace/keyboard/emacs" }, + { caption: "Sublime", value: "ace/keyboard/sublime" }, + { caption: "VSCode", value: "ace/keyboard/vscode" } + ] + }, + "Font Size": { + path: "fontSize", + type: "number", + defaultValue: 12, + defaults: [ + { caption: "12px", value: 12 }, + { caption: "24px", value: 24 } + ] + }, + "Soft Wrap": { + type: "buttonBar", + path: "wrap", + items: [ + { caption: "Off", value: "off" }, + { caption: "View", value: "free" }, + { caption: "margin", value: "printMargin" }, + { caption: "40", value: "40" } + ] + }, + "Cursor Style": { + path: "cursorStyle", + items: [ + { caption: "Ace", value: "ace" }, + { caption: "Slim", value: "slim" }, + { caption: "Smooth", value: "smooth" }, + { caption: "Smooth And Slim", value: "smooth slim" }, + { caption: "Wide", value: "wide" } + ] + }, + "Folding": { + path: "foldStyle", + items: [ + { caption: "Manual", value: "manual" }, + { caption: "Mark begin", value: "markbegin" }, + { caption: "Mark begin and end", value: "markbeginend" } + ] + }, + "Soft Tabs": [{ + path: "useSoftTabs" + }, { + ariaLabel: "Tab Size", + path: "tabSize", + type: "number", + values: [2, 3, 4, 8, 16] + }], + "Overscroll": { + type: "buttonBar", + path: "scrollPastEnd", + items: [ + { caption: "None", value: 0 }, + { caption: "Half", value: 0.5 }, + { caption: "Full", value: 1 } + ] + } + }, + More: { + "Atomic soft tabs": { + path: "navigateWithinSoftTabs" + }, + "Enable Behaviours": { + path: "behavioursEnabled" + }, + "Wrap with quotes": { + path: "wrapBehavioursEnabled" + }, + "Enable Auto Indent": { + path: "enableAutoIndent" + }, + "Full Line Selection": { + type: "checkbox", + values: "text|line", + path: "selectionStyle" + }, + "Highlight Active Line": { + path: "highlightActiveLine" + }, + "Show Invisibles": { + path: "showInvisibles" + }, + "Show Indent Guides": { + path: "displayIndentGuides" + }, + "Highlight Indent Guides": { + path: "highlightIndentGuides" + }, + "Persistent HScrollbar": { + path: "hScrollBarAlwaysVisible" + }, + "Persistent VScrollbar": { + path: "vScrollBarAlwaysVisible" + }, + "Animate scrolling": { + path: "animatedScroll" + }, + "Show Gutter": { + path: "showGutter" + }, + "Show Line Numbers": { + path: "showLineNumbers" + }, + "Relative Line Numbers": { + path: "relativeLineNumbers" + }, + "Fixed Gutter Width": { + path: "fixedWidthGutter" + }, + "Show Print Margin": [{ + path: "showPrintMargin" + }, { + ariaLabel: "Print Margin", + type: "number", + path: "printMarginColumn" + }], + "Indented Soft Wrap": { + path: "indentedSoftWrap" + }, + "Highlight selected word": { + path: "highlightSelectedWord" + }, + "Fade Fold Widgets": { + path: "fadeFoldWidgets" + }, + "Use textarea for IME": { + path: "useTextareaForIME" + }, + "Merge Undo Deltas": { + path: "mergeUndoDeltas", + items: [ + { caption: "Always", value: "always" }, + { caption: "Never", value: "false" }, + { caption: "Timed", value: "true" } + ] + }, + "Elastic Tabstops": { + path: "useElasticTabstops" + }, + "Incremental Search": { + path: "useIncrementalSearch" + }, + "Read-only": { + path: "readOnly" + }, + "Copy without selection": { + path: "copyWithEmptySelection" + }, + "Live Autocompletion": { + path: "enableLiveAutocompletion" + }, + "Custom scrollbar": { + path: "customScrollbar" + } + } +}; +var OptionPanel = function (editor, element) { + this.editor = editor; + this.container = element || document.createElement("div"); + this.groups = []; + this.options = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.add = function (config) { + if (config.Main) + oop.mixin(optionGroups.Main, config.Main); + if (config.More) + oop.mixin(optionGroups.More, config.More); + }; + this.render = function () { + this.container.innerHTML = ""; + buildDom(["table", { role: "presentation", id: "controls" }, + this.renderOptionGroup(optionGroups.Main), + ["tr", null, ["td", { colspan: 2 }, + ["table", { role: "presentation", id: "more-controls" }, + this.renderOptionGroup(optionGroups.More) + ] + ]], + ["tr", null, ["td", { colspan: 2 }, "version " + config.version]] + ], this.container); + }; + this.renderOptionGroup = function (group) { + return Object.keys(group).map(function (key, i) { + var item = group[key]; + if (!item.position) + item.position = i / 10000; + if (!item.label) + item.label = key; + return item; + }).sort(function (a, b) { + return a.position - b.position; + }).map(function (item) { + return this.renderOption(item.label, item); + }, this); + }; + this.renderOptionControl = function (key, option) { + var self = this; + if (Array.isArray(option)) { + return option.map(function (x) { + return self.renderOptionControl(key, x); + }); + } + var control; + var value = self.getOption(option); + if (option.values && option.type != "checkbox") { + if (typeof option.values == "string") + option.values = option.values.split("|"); + option.items = option.values.map(function (v) { + return { value: v, name: v }; + }); + } + if (option.type == "buttonBar") { + control = ["div", { role: "group", "aria-labelledby": option.path + "-label" }, option.items.map(function (item) { + return ["button", { + value: item.value, + ace_selected_button: value == item.value, + 'aria-pressed': value == item.value, + onclick: function () { + self.setOption(option, item.value); + var nodes = this.parentNode.querySelectorAll("[ace_selected_button]"); + for (var i = 0; i < nodes.length; i++) { + nodes[i].removeAttribute("ace_selected_button"); + nodes[i].setAttribute("aria-pressed", false); + } + this.setAttribute("ace_selected_button", true); + this.setAttribute("aria-pressed", true); + } + }, item.desc || item.caption || item.name]; + })]; + } + else if (option.type == "number") { + control = ["input", { type: "number", value: value || option.defaultValue, style: "width:3em", oninput: function () { + self.setOption(option, parseInt(this.value)); + } }]; + if (option.ariaLabel) { + control[1]["aria-label"] = option.ariaLabel; + } + else { + control[1].id = key; + } + if (option.defaults) { + control = [control, option.defaults.map(function (item) { + return ["button", { onclick: function () { + var input = this.parentNode.firstChild; + input.value = item.value; + input.oninput(); + } }, item.caption]; + })]; + } + } + else if (option.items) { + var buildItems = function (items) { + return items.map(function (item) { + return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name]; + }); + }; + var items = Array.isArray(option.items) + ? buildItems(option.items) + : Object.keys(option.items).map(function (key) { + return ["optgroup", { "label": key }, buildItems(option.items[key])]; + }); + control = ["select", { id: key, value: value, onchange: function () { + self.setOption(option, this.value); + } }, items]; + } + else { + if (typeof option.values == "string") + option.values = option.values.split("|"); + if (option.values) + value = value == option.values[1]; + control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function () { + var value = this.checked; + if (option.values) + value = option.values[value ? 1 : 0]; + self.setOption(option, value); + } }]; + if (option.type == "checkedNumber") { + control = [control, []]; + } + } + return control; + }; + this.renderOption = function (key, option) { + if (option.path && !option.onchange && !this.editor.$options[option.path]) + return; + var path = Array.isArray(option) ? option[0].path : option.path; + this.options[path] = option; + var safeKey = "-" + path; + var safeId = path + "-label"; + var control = this.renderOptionControl(safeKey, option); + return ["tr", { class: "ace_optionsMenuEntry" }, ["td", + ["label", { for: safeKey, id: safeId }, key] + ], ["td", control]]; + }; + this.setOption = function (option, value) { + if (typeof option == "string") + option = this.options[option]; + if (value == "false") + value = false; + if (value == "true") + value = true; + if (value == "null") + value = null; + if (value == "undefined") + value = undefined; + if (typeof value == "string" && parseFloat(value).toString() == value) + value = parseFloat(value); + if (option.onchange) + option.onchange(value); + else if (option.path) + this.editor.setOption(option.path, value); + this._signal("setOption", { name: option.path, value: value }); + }; + this.getOption = function (option) { + if (option.getValue) + return option.getValue(); + return this.editor.getOption(option.path); + }; +}).call(OptionPanel.prototype); +exports.OptionPanel = OptionPanel; + +}); + (function() { + window.require(["ace/ext/options"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-prompt.js b/src/main/resources/static/assets/js/vendor/template/src/ext-prompt.js new file mode 100644 index 0000000..9643869 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-prompt.js @@ -0,0 +1,2517 @@ +define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var keys = require("../../lib/keys"); +module.exports.getEditorKeybordShortcuts = function (editor) { + var KEY_MODS = keys.KEY_MODS; + var keybindings = []; + var commandMap = {}; + editor.keyBinding.$handlers.forEach(function (handler) { + var ckb = handler.commandKeyBinding; + for (var i in ckb) { + var key = i.replace(/(^|-)\w/g, function (x) { return x.toUpperCase(); }); + var commands = ckb[i]; + if (!Array.isArray(commands)) + commands = [commands]; + commands.forEach(function (command) { + if (typeof command != "string") + command = command.name; + if (commandMap[command]) { + commandMap[command].key += "|" + key; + } + else { + commandMap[command] = { key: key, command: command }; + keybindings.push(commandMap[command]); + } + }); + } + }); + return keybindings; +}; + +}); + +define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"], function(require, exports, module){"use strict"; +var Renderer = require("../virtual_renderer").VirtualRenderer; +var Editor = require("../editor").Editor; +var Range = require("../range").Range; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); +var $singleLineEditor = function (el) { + var renderer = new Renderer(el); + renderer.$maxLines = 4; + var editor = new Editor(renderer); + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.renderer.setShowGutter(false); + editor.renderer.setHighlightGutterLine(false); + editor.$mouseHandler.$focusTimeout = 0; + editor.$highlightTagPending = true; + return editor; +}; +var AcePopup = function (parentNode) { + var el = dom.createElement("div"); + var popup = new $singleLineEditor(el); + if (parentNode) + parentNode.appendChild(el); + el.style.display = "none"; + popup.renderer.content.style.cursor = "default"; + popup.renderer.setStyle("ace_autocomplete"); + popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); + var noop = function () { }; + popup.focus = noop; + popup.$isFocused = true; + popup.renderer.$cursorLayer.restartTimer = noop; + popup.renderer.$cursorLayer.element.style.opacity = 0; + popup.renderer.$maxLines = 8; + popup.renderer.$keepTextAreaAtCursor = false; + popup.setHighlightActiveLine(false); + popup.session.highlight(""); + popup.session.$searchHighlight.clazz = "ace_highlight-marker"; + popup.on("mousedown", function (e) { + var pos = e.getDocumentPosition(); + popup.selection.moveToPosition(pos); + selectionMarker.start.row = selectionMarker.end.row = pos.row; + e.stop(); + }); + var lastMouseEvent; + var hoverMarker = new Range(-1, 0, -1, Infinity); + var selectionMarker = new Range(-1, 0, -1, Infinity); + selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine"); + popup.setSelectOnHover = function (val) { + if (!val) { + hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine"); + } + else if (hoverMarker.id) { + popup.session.removeMarker(hoverMarker.id); + hoverMarker.id = null; + } + }; + popup.setSelectOnHover(false); + popup.on("mousemove", function (e) { + if (!lastMouseEvent) { + lastMouseEvent = e; + return; + } + if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) { + return; + } + lastMouseEvent = e; + lastMouseEvent.scrollTop = popup.renderer.scrollTop; + var row = lastMouseEvent.getDocumentPosition().row; + if (hoverMarker.start.row != row) { + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row); + } + }); + popup.renderer.on("beforeRender", function () { + if (lastMouseEvent && hoverMarker.start.row != -1) { + lastMouseEvent.$pos = null; + var row = lastMouseEvent.getDocumentPosition().row; + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row, true); + } + }); + popup.renderer.on("afterRender", function () { + var row = popup.getRow(); + var t = popup.renderer.$textLayer; + var selected = t.element.childNodes[row - t.config.firstRow]; + if (selected !== t.selectedNode && t.selectedNode) + dom.removeCssClass(t.selectedNode, "ace_selected"); + t.selectedNode = selected; + if (selected) + dom.addCssClass(selected, "ace_selected"); + }); + var hideHoverMarker = function () { setHoverMarker(-1); }; + var setHoverMarker = function (row, suppressRedraw) { + if (row !== hoverMarker.start.row) { + hoverMarker.start.row = hoverMarker.end.row = row; + if (!suppressRedraw) + popup.session._emit("changeBackMarker"); + popup._emit("changeHoverMarker"); + } + }; + popup.getHoveredRow = function () { + return hoverMarker.start.row; + }; + event.addListener(popup.container, "mouseout", hideHoverMarker); + popup.on("hide", hideHoverMarker); + popup.on("changeSelection", hideHoverMarker); + popup.session.doc.getLength = function () { + return popup.data.length; + }; + popup.session.doc.getLine = function (i) { + var data = popup.data[i]; + if (typeof data == "string") + return data; + return (data && data.value) || ""; + }; + var bgTokenizer = popup.session.bgTokenizer; + bgTokenizer.$tokenizeRow = function (row) { + var data = popup.data[row]; + var tokens = []; + if (!data) + return tokens; + if (typeof data == "string") + data = { value: data }; + var caption = data.caption || data.value || data.name; + function addToken(value, className) { + value && tokens.push({ + type: (data.className || "") + (className || ""), + value: value + }); + } + var lower = caption.toLowerCase(); + var filterText = (popup.filterText || "").toLowerCase(); + var lastIndex = 0; + var lastI = 0; + for (var i = 0; i <= filterText.length; i++) { + if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) { + var sub = filterText.slice(lastI, i); + lastI = i; + var index = lower.indexOf(sub, lastIndex); + if (index == -1) + continue; + addToken(caption.slice(lastIndex, index), ""); + lastIndex = index + sub.length; + addToken(caption.slice(index, lastIndex), "completion-highlight"); + } + } + addToken(caption.slice(lastIndex, caption.length), ""); + if (data.meta) + tokens.push({ type: "completion-meta", value: data.meta }); + if (data.message) + tokens.push({ type: "completion-message", value: data.message }); + return tokens; + }; + bgTokenizer.$updateOnChange = noop; + bgTokenizer.start = noop; + popup.session.$computeWidth = function () { + return this.screenWidth = 0; + }; + popup.isOpen = false; + popup.isTopdown = false; + popup.autoSelect = true; + popup.filterText = ""; + popup.data = []; + popup.setData = function (list, filterText) { + popup.filterText = filterText || ""; + popup.setValue(lang.stringRepeat("\n", list.length), -1); + popup.data = list || []; + popup.setRow(0); + }; + popup.getData = function (row) { + return popup.data[row]; + }; + popup.getRow = function () { + return selectionMarker.start.row; + }; + popup.setRow = function (line) { + line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line)); + if (selectionMarker.start.row != line) { + popup.selection.clearSelection(); + selectionMarker.start.row = selectionMarker.end.row = line || 0; + popup.session._emit("changeBackMarker"); + popup.moveCursorTo(line || 0, 0); + if (popup.isOpen) + popup._signal("select"); + } + }; + popup.on("changeSelection", function () { + if (popup.isOpen) + popup.setRow(popup.selection.lead.row); + popup.renderer.scrollCursorIntoView(); + }); + popup.hide = function () { + this.container.style.display = "none"; + this._signal("hide"); + popup.isOpen = false; + }; + popup.show = function (pos, lineHeight, topdownOnly) { + var el = this.container; + var screenHeight = window.innerHeight; + var screenWidth = window.innerWidth; + var renderer = this.renderer; + var maxH = renderer.$maxLines * lineHeight * 1.4; + var top = pos.top + this.$borderSize; + var allowTopdown = top > screenHeight / 2 && !topdownOnly; + if (allowTopdown && top + lineHeight + maxH > screenHeight) { + renderer.$maxPixelHeight = top - 2 * this.$borderSize; + el.style.top = ""; + el.style.bottom = screenHeight - top + "px"; + popup.isTopdown = false; + } + else { + top += lineHeight; + renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight; + el.style.top = top + "px"; + el.style.bottom = ""; + popup.isTopdown = true; + } + el.style.display = ""; + var left = pos.left; + if (left + el.offsetWidth > screenWidth) + left = screenWidth - el.offsetWidth; + el.style.left = left + "px"; + this._signal("show"); + lastMouseEvent = null; + popup.isOpen = true; + }; + popup.goTo = function (where) { + var row = this.getRow(); + var max = this.session.getLength() - 1; + switch (where) { + case "up": + row = row <= 0 ? max : row - 1; + break; + case "down": + row = row >= max ? -1 : row + 1; + break; + case "start": + row = 0; + break; + case "end": + row = max; + break; + } + this.setRow(row); + }; + popup.getTextLeftOffset = function () { + return this.$borderSize + this.renderer.$padding + this.$imageSize; + }; + popup.$imageSize = 0; + popup.$borderSize = 1; + return popup; +}; +dom.importCssString("\n.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #CAD6FA;\n z-index: 1;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #3a674e;\n}\n.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid #abbffe;\n margin-top: -1px;\n background: rgba(233,233,253,0.4);\n position: absolute;\n z-index: 2;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid rgba(109, 150, 13, 0.8);\n background: rgba(58, 103, 78, 0.62);\n}\n.ace_completion-meta {\n opacity: 0.5;\n margin: 0.9em;\n}\n.ace_completion-message {\n color: blue;\n}\n.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #2d69c7;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #93ca12;\n}\n.ace_editor.ace_autocomplete {\n width: 300px;\n z-index: 200000;\n border: 1px lightgray solid;\n position: fixed;\n box-shadow: 2px 3px 5px rgba(0,0,0,.2);\n line-height: 1.4;\n background: #fefefe;\n color: #111;\n}\n.ace_dark.ace_editor.ace_autocomplete {\n border: 1px #484747 solid;\n box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\n line-height: 1.4;\n background: #25282c;\n color: #c1c1c1;\n}", "autocompletion.css", false); +exports.AcePopup = AcePopup; +exports.$singleLineEditor = $singleLineEditor; + +}); + +define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module){"use strict"; +exports.parForEach = function (array, fn, callback) { + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function (result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } +}; +var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/; +exports.retrievePrecedingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos - 1; i >= 0; i--) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf.reverse().join(""); +}; +exports.retrieveFollowingIdentifier = function (text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf; +}; +exports.getCompletionPrefix = function (editor) { + var pos = editor.getCursorPosition(); + var line = editor.session.getLine(pos.row); + var prefix; + editor.completers.forEach(function (completer) { + if (completer.identifierRegexps) { + completer.identifierRegexps.forEach(function (identifierRegex) { + if (!prefix && identifierRegex) + prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex); + }.bind(this)); + } + }.bind(this)); + return prefix || this.retrievePrecedingIdentifier(line, pos.column); +}; + +}); + +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict"; +var dom = require("./lib/dom"); +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var lang = require("./lib/lang"); +var Range = require("./range").Range; +var RangeList = require("./range_list").RangeList; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var Tokenizer = require("./tokenizer").Tokenizer; +var clipboard = require("./clipboard"); +var VARIABLES = { + CURRENT_WORD: function (editor) { + return editor.session.getTextRange(editor.session.getWordRange()); + }, + SELECTION: function (editor, name, indentation) { + var text = editor.session.getTextRange(); + if (indentation) + return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1"); + return text; + }, + CURRENT_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row); + }, + PREV_LINE: function (editor) { + return editor.session.getLine(editor.getCursorPosition().row - 1); + }, + LINE_INDEX: function (editor) { + return editor.getCursorPosition().row; + }, + LINE_NUMBER: function (editor) { + return editor.getCursorPosition().row + 1; + }, + SOFT_TABS: function (editor) { + return editor.session.getUseSoftTabs() ? "YES" : "NO"; + }, + TAB_SIZE: function (editor) { + return editor.session.getTabSize(); + }, + CLIPBOARD: function (editor) { + return clipboard.getText && clipboard.getText(); + }, + FILENAME: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0]; + }, + FILENAME_BASE: function (editor) { + return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, ""); + }, + DIRECTORY: function (editor) { + return this.FILEPATH(editor).replace(/[^/\\]*$/, ""); + }, + FILEPATH: function (editor) { return "/not implemented.txt"; }, + WORKSPACE_NAME: function () { return "Unknown"; }, + FULLNAME: function () { return "Unknown"; }, + BLOCK_COMMENT_START: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.start || ""; + }, + BLOCK_COMMENT_END: function (editor) { + var mode = editor.session.$mode || {}; + return mode.blockComment && mode.blockComment.end || ""; + }, + LINE_COMMENT: function (editor) { + var mode = editor.session.$mode || {}; + return mode.lineCommentStart || ""; + }, + CURRENT_YEAR: date.bind(null, { year: "numeric" }), + CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }), + CURRENT_MONTH: date.bind(null, { month: "numeric" }), + CURRENT_MONTH_NAME: date.bind(null, { month: "long" }), + CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }), + CURRENT_DATE: date.bind(null, { day: "2-digit" }), + CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }), + CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }), + CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }), + CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }), + CURRENT_SECOND: date.bind(null, { second: "2-digit" }) +}; +VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION; +function date(dateFormat) { + var str = new Date().toLocaleString("en-us", dateFormat); + return str.length == 1 ? "0" + str : str; +} +var SnippetManager = function () { + this.snippetMap = {}; + this.snippetNameMap = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.getTokenizer = function () { + return SnippetManager.$tokenizer || this.createTokenizer(); + }; + this.createTokenizer = function () { + function TabstopToken(str) { + str = str.substr(1); + if (/^\d+$/.test(str)) + return [{ tabstopId: parseInt(str, 10) }]; + return [{ text: str }]; + } + function escape(ch) { + return "(?:[^\\\\" + ch + "]|\\\\.)"; + } + var formatMatcher = { + regex: "/(" + escape("/") + "+)/", + onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.fmtString = true; + ts.guard = val.slice(1, -1); + ts.flag = ""; + return ""; + }, + next: "formatString" + }; + SnippetManager.$tokenizer = new Tokenizer({ + start: [ + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) { + val = ch; + } + else if ("`$\\".indexOf(ch) != -1) { + val = ch; + } + return [val]; + } }, + { regex: /}/, onMatch: function (val, state, stack) { + return [stack.length ? stack.shift() : val]; + } }, + { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken }, + { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) { + var t = TabstopToken(str.substr(1)); + stack.unshift(t[0]); + return t; + }, next: "snippetVar" }, + { regex: /\n/, token: "newline", merge: false } + ], + snippetVar: [ + { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) { + var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) { + return operator.length == 2 ? operator[1] : "\x00"; + }).split("\x00").map(function (value) { + return { value: value }; + }); + stack[0].choices = choices; + return [choices[0]]; + }, next: "start" }, + formatMatcher, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" } + ], + formatString: [ + { regex: /:/, onMatch: function (val, state, stack) { + if (stack.length && stack[0].expectElse) { + stack[0].expectElse = false; + stack[0].ifEnd = { elseEnd: stack[0] }; + return [stack[0].ifEnd]; + } + return ":"; + } }, + { regex: /\\./, onMatch: function (val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) + val = ch; + else if ("`$\\".indexOf(ch) != -1) + val = ch; + else if (ch == "n") + val = "\n"; + else if (ch == "t") + val = "\t"; + else if ("ulULE".indexOf(ch) != -1) + val = { changeCase: ch, local: ch > "a" }; + return [val]; + } }, + { regex: "/\\w*}", onMatch: function (val, state, stack) { + var next = stack.shift(); + if (next) + next.flag = val.slice(1, -1); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" }, + { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) { + return [{ text: val.slice(1) }]; + } }, + { regex: /\${\w+/, onMatch: function (val, state, stack) { + var token = { text: val.slice(2) }; + stack.unshift(token); + return [token]; + }, next: "formatStringVar" }, + { regex: /\n/, token: "newline", merge: false }, + { regex: /}/, onMatch: function (val, state, stack) { + var next = stack.shift(); + this.next = next && next.tabstopId ? "start" : ""; + return [next || val]; + }, next: "start" } + ], + formatStringVar: [ + { regex: /:\/\w+}/, onMatch: function (val, state, stack) { + var ts = stack[0]; + ts.formatFunction = val.slice(2, -1); + return [stack.shift()]; + }, next: "formatString" }, + formatMatcher, + { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) { + if (val[1] == "+") + stack[0].ifEnd = stack[0]; + if (val[1] == "?") + stack[0].expectElse = true; + }, next: "formatString" }, + { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" } + ] + }); + return SnippetManager.$tokenizer; + }; + this.tokenizeTmSnippet = function (str, startState) { + return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) { + return x.value || x; + }); + }; + this.getVariableValue = function (editor, name, indentation) { + if (/^\d+$/.test(name)) + return (this.variables.__ || {})[name] || ""; + if (/^[A-Z]\d+$/.test(name)) + return (this.variables[name[0] + "__"] || {})[name.substr(1)] || ""; + name = name.replace(/^TM_/, ""); + if (!this.variables.hasOwnProperty(name)) + return ""; + var value = this.variables[name]; + if (typeof value == "function") + value = this.variables[name](editor, name, indentation); + return value == null ? "" : value; + }; + this.variables = VARIABLES; + this.tmStrFormat = function (str, ch, editor) { + if (!ch.fmt) + return str; + var flag = ch.flag || ""; + var re = ch.guard; + re = new RegExp(re, flag.replace(/[^gim]/g, "")); + var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt; + var _self = this; + var formatted = str.replace(re, function () { + var oldArgs = _self.variables.__; + _self.variables.__ = [].slice.call(arguments); + var fmtParts = _self.resolveVariables(fmtTokens, editor); + var gChangeCase = "E"; + for (var i = 0; i < fmtParts.length; i++) { + var ch = fmtParts[i]; + if (typeof ch == "object") { + fmtParts[i] = ""; + if (ch.changeCase && ch.local) { + var next = fmtParts[i + 1]; + if (next && typeof next == "string") { + if (ch.changeCase == "u") + fmtParts[i] = next[0].toUpperCase(); + else + fmtParts[i] = next[0].toLowerCase(); + fmtParts[i + 1] = next.substr(1); + } + } + else if (ch.changeCase) { + gChangeCase = ch.changeCase; + } + } + else if (gChangeCase == "U") { + fmtParts[i] = ch.toUpperCase(); + } + else if (gChangeCase == "L") { + fmtParts[i] = ch.toLowerCase(); + } + } + _self.variables.__ = oldArgs; + return fmtParts.join(""); + }); + return formatted; + }; + this.tmFormatFunction = function (str, ch, editor) { + if (ch.formatFunction == "upcase") + return str.toUpperCase(); + if (ch.formatFunction == "downcase") + return str.toLowerCase(); + return str; + }; + this.resolveVariables = function (snippet, editor) { + var result = []; + var indentation = ""; + var afterNewLine = true; + for (var i = 0; i < snippet.length; i++) { + var ch = snippet[i]; + if (typeof ch == "string") { + result.push(ch); + if (ch == "\n") { + afterNewLine = true; + indentation = ""; + } + else if (afterNewLine) { + indentation = /^\t*/.exec(ch)[0]; + afterNewLine = /\S/.test(ch); + } + continue; + } + if (!ch) + continue; + afterNewLine = false; + if (ch.fmtString) { + var j = snippet.indexOf(ch, i + 1); + if (j == -1) + j = snippet.length; + ch.fmt = snippet.slice(i + 1, j); + i = j; + } + if (ch.text) { + var value = this.getVariableValue(editor, ch.text, indentation) + ""; + if (ch.fmtString) + value = this.tmStrFormat(value, ch, editor); + if (ch.formatFunction) + value = this.tmFormatFunction(value, ch, editor); + if (value && !ch.ifEnd) { + result.push(value); + gotoNext(ch); + } + else if (!value && ch.ifEnd) { + gotoNext(ch.ifEnd); + } + } + else if (ch.elseEnd) { + gotoNext(ch.elseEnd); + } + else if (ch.tabstopId != null) { + result.push(ch); + } + else if (ch.changeCase != null) { + result.push(ch); + } + } + function gotoNext(ch) { + var i1 = snippet.indexOf(ch, i + 1); + if (i1 != -1) + i = i1; + } + return result; + }; + this.insertSnippetForSelection = function (editor, snippetText) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var tabString = editor.session.getTabString(); + var indentString = line.match(/^\s*/)[0]; + if (cursor.column < indentString.length) + indentString = indentString.slice(0, cursor.column); + snippetText = snippetText.replace(/\r/g, ""); + var tokens = this.tokenizeTmSnippet(snippetText); + tokens = this.resolveVariables(tokens, editor); + tokens = tokens.map(function (x) { + if (x == "\n") + return x + indentString; + if (typeof x == "string") + return x.replace(/\t/g, tabString); + return x; + }); + var tabstops = []; + tokens.forEach(function (p, i) { + if (typeof p != "object") + return; + var id = p.tabstopId; + var ts = tabstops[id]; + if (!ts) { + ts = tabstops[id] = []; + ts.index = id; + ts.value = ""; + ts.parents = {}; + } + if (ts.indexOf(p) !== -1) + return; + if (p.choices && !ts.choices) + ts.choices = p.choices; + ts.push(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 === -1) + return; + var value = tokens.slice(i + 1, i1); + var isNested = value.some(function (t) { return typeof t === "object"; }); + if (isNested && !ts.value) { + ts.value = value; + } + else if (value.length && (!ts.value || typeof ts.value !== "string")) { + ts.value = value.join(""); + } + }); + tabstops.forEach(function (ts) { ts.length = 0; }); + var expanding = {}; + function copyValue(val) { + var copy = []; + for (var i = 0; i < val.length; i++) { + var p = val[i]; + if (typeof p == "object") { + if (expanding[p.tabstopId]) + continue; + var j = val.lastIndexOf(p, i - 1); + p = copy[j] || { tabstopId: p.tabstopId }; + } + copy[i] = p; + } + return copy; + } + for (var i = 0; i < tokens.length; i++) { + var p = tokens[i]; + if (typeof p != "object") + continue; + var id = p.tabstopId; + var ts = tabstops[id]; + var i1 = tokens.indexOf(p, i + 1); + if (expanding[id]) { + if (expanding[id] === p) { + delete expanding[id]; + Object.keys(expanding).forEach(function (parentId) { + ts.parents[parentId] = true; + }); + } + continue; + } + expanding[id] = p; + var value = ts.value; + if (typeof value !== "string") + value = copyValue(value); + else if (p.fmt) + value = this.tmStrFormat(value, p, editor); + tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p)); + if (ts.indexOf(p) === -1) + ts.push(p); + } + var row = 0, column = 0; + var text = ""; + tokens.forEach(function (t) { + if (typeof t === "string") { + var lines = t.split("\n"); + if (lines.length > 1) { + column = lines[lines.length - 1].length; + row += lines.length - 1; + } + else + column += t.length; + text += t; + } + else if (t) { + if (!t.start) + t.start = { row: row, column: column }; + else + t.end = { row: row, column: column }; + } + }); + var range = editor.getSelectionRange(); + var end = editor.session.replace(range, text); + var tabstopManager = new TabstopManager(editor); + var selectionId = editor.inVirtualSelectionMode && editor.selection.index; + tabstopManager.addTabstops(tabstops, range.start, end, selectionId); + }; + this.insertSnippet = function (editor, snippetText) { + var self = this; + if (editor.inVirtualSelectionMode) + return self.insertSnippetForSelection(editor, snippetText); + editor.forEachSelection(function () { + self.insertSnippetForSelection(editor, snippetText); + }, null, { keepOrder: true }); + if (editor.tabstopManager) + editor.tabstopManager.tabNext(); + }; + this.$getScope = function (editor) { + var scope = editor.session.$mode.$id || ""; + scope = scope.split("/").pop(); + if (scope === "html" || scope === "php") { + if (scope === "php" && !editor.session.$mode.inlinePhp) + scope = "html"; + var c = editor.getCursorPosition(); + var state = editor.session.getState(c.row); + if (typeof state === "object") { + state = state[0]; + } + if (state.substring) { + if (state.substring(0, 3) == "js-") + scope = "javascript"; + else if (state.substring(0, 4) == "css-") + scope = "css"; + else if (state.substring(0, 4) == "php-") + scope = "php"; + } + } + return scope; + }; + this.getActiveScopes = function (editor) { + var scope = this.$getScope(editor); + var scopes = [scope]; + var snippetMap = this.snippetMap; + if (snippetMap[scope] && snippetMap[scope].includeScopes) { + scopes.push.apply(scopes, snippetMap[scope].includeScopes); + } + scopes.push("_"); + return scopes; + }; + this.expandWithTab = function (editor, options) { + var self = this; + var result = editor.forEachSelection(function () { + return self.expandSnippetForSelection(editor, options); + }, null, { keepOrder: true }); + if (result && editor.tabstopManager) + editor.tabstopManager.tabNext(); + return result; + }; + this.expandSnippetForSelection = function (editor, options) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var before = line.substring(0, cursor.column); + var after = line.substr(cursor.column); + var snippetMap = this.snippetMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = this.findMatchingSnippet(snippets, before, after); + return !!snippet; + }, this); + if (!snippet) + return false; + if (options && options.dryRun) + return true; + editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length); + this.variables.M__ = snippet.matchBefore; + this.variables.T__ = snippet.matchAfter; + this.insertSnippetForSelection(editor, snippet.content); + this.variables.M__ = this.variables.T__ = null; + return true; + }; + this.findMatchingSnippet = function (snippetList, before, after) { + for (var i = snippetList.length; i--;) { + var s = snippetList[i]; + if (s.startRe && !s.startRe.test(before)) + continue; + if (s.endRe && !s.endRe.test(after)) + continue; + if (!s.startRe && !s.endRe) + continue; + s.matchBefore = s.startRe ? s.startRe.exec(before) : [""]; + s.matchAfter = s.endRe ? s.endRe.exec(after) : [""]; + s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : ""; + s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : ""; + return s; + } + }; + this.snippetMap = {}; + this.snippetNameMap = {}; + this.register = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + var self = this; + if (!snippets) + snippets = []; + function wrapRegexp(src) { + if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) + src = "(?:" + src + ")"; + return src || ""; + } + function guardedRegexp(re, guard, opening) { + re = wrapRegexp(re); + guard = wrapRegexp(guard); + if (opening) { + re = guard + re; + if (re && re[re.length - 1] != "$") + re = re + "$"; + } + else { + re = re + guard; + if (re && re[0] != "^") + re = "^" + re; + } + return new RegExp(re); + } + function addSnippet(s) { + if (!s.scope) + s.scope = scope || "_"; + scope = s.scope; + if (!snippetMap[scope]) { + snippetMap[scope] = []; + snippetNameMap[scope] = {}; + } + var map = snippetNameMap[scope]; + if (s.name) { + var old = map[s.name]; + if (old) + self.unregister(old); + map[s.name] = s; + } + snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { + if (!s.guard && /^\w/.test(s.tabTrigger)) + s.guard = "\\b"; + s.trigger = lang.escapeRegExp(s.tabTrigger); + } + if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard) + return; + s.startRe = guardedRegexp(s.trigger, s.guard, true); + s.triggerRe = new RegExp(s.trigger); + s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); + s.endTriggerRe = new RegExp(s.endTrigger); + } + if (Array.isArray(snippets)) { + snippets.forEach(addSnippet); + } + else { + Object.keys(snippets).forEach(function (key) { + addSnippet(snippets[key]); + }); + } + this._signal("registerSnippets", { scope: scope }); + }; + this.unregister = function (snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + function removeSnippet(s) { + var nameMap = snippetNameMap[s.scope || scope]; + if (nameMap && nameMap[s.name]) { + delete nameMap[s.name]; + var map = snippetMap[s.scope || scope]; + var i = map && map.indexOf(s); + if (i >= 0) + map.splice(i, 1); + } + } + if (snippets.content) + removeSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(removeSnippet); + }; + this.parseSnippetFile = function (str) { + str = str.replace(/\r/g, ""); + var list = [], snippet = {}; + var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm; + var m; + while (m = re.exec(str)) { + if (m[1]) { + try { + snippet = JSON.parse(m[1]); + list.push(snippet); + } + catch (e) { } + } + if (m[4]) { + snippet.content = m[4].replace(/^\t/gm, ""); + list.push(snippet); + snippet = {}; + } + else { + var key = m[2], val = m[3]; + if (key == "regex") { + var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g; + snippet.guard = guardRe.exec(val)[1]; + snippet.trigger = guardRe.exec(val)[1]; + snippet.endTrigger = guardRe.exec(val)[1]; + snippet.endGuard = guardRe.exec(val)[1]; + } + else if (key == "snippet") { + snippet.tabTrigger = val.match(/^\S*/)[0]; + if (!snippet.name) + snippet.name = val; + } + else if (key) { + snippet[key] = val; + } + } + } + return list; + }; + this.getSnippetByName = function (name, editor) { + var snippetMap = this.snippetNameMap; + var snippet; + this.getActiveScopes(editor).some(function (scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = snippets[name]; + return !!snippet; + }, this); + return snippet; + }; +}).call(SnippetManager.prototype); +var TabstopManager = function (editor) { + if (editor.tabstopManager) + return editor.tabstopManager; + editor.tabstopManager = this; + this.$onChange = this.onChange.bind(this); + this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule; + this.$onChangeSession = this.onChangeSession.bind(this); + this.$onAfterExec = this.onAfterExec.bind(this); + this.attach(editor); +}; +(function () { + this.attach = function (editor) { + this.index = 0; + this.ranges = []; + this.tabstops = []; + this.$openTabstops = null; + this.selectedTabstop = null; + this.editor = editor; + this.editor.on("change", this.$onChange); + this.editor.on("changeSelection", this.$onChangeSelection); + this.editor.on("changeSession", this.$onChangeSession); + this.editor.commands.on("afterExec", this.$onAfterExec); + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.detach = function () { + this.tabstops.forEach(this.removeTabstopMarkers, this); + this.ranges = null; + this.tabstops = null; + this.selectedTabstop = null; + this.editor.removeListener("change", this.$onChange); + this.editor.removeListener("changeSelection", this.$onChangeSelection); + this.editor.removeListener("changeSession", this.$onChangeSession); + this.editor.commands.removeListener("afterExec", this.$onAfterExec); + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.tabstopManager = null; + this.editor = null; + }; + this.onChange = function (delta) { + var isRemove = delta.action[0] == "r"; + var selectedTabstop = this.selectedTabstop || {}; + var parents = selectedTabstop.parents || {}; + var tabstops = (this.tabstops || []).slice(); + for (var i = 0; i < tabstops.length; i++) { + var ts = tabstops[i]; + var active = ts == selectedTabstop || parents[ts.index]; + ts.rangeList.$bias = active ? 0 : 1; + if (delta.action == "remove" && ts !== selectedTabstop) { + var parentActive = ts.parents && ts.parents[selectedTabstop.index]; + var startIndex = ts.rangeList.pointIndex(delta.start, parentActive); + startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1; + var endIndex = ts.rangeList.pointIndex(delta.end, parentActive); + endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1; + var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex); + for (var j = 0; j < toRemove.length; j++) + this.removeRange(toRemove[j]); + } + ts.rangeList.$onChange(delta); + } + var session = this.editor.session; + if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue()) + this.detach(); + }; + this.updateLinkedFields = function () { + var ts = this.selectedTabstop; + if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked) + return; + this.$inChange = true; + var session = this.editor.session; + var text = session.getTextRange(ts.firstNonLinked); + for (var i = 0; i < ts.length; i++) { + var range = ts[i]; + if (!range.linked) + continue; + var original = range.original; + var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor); + session.replace(range, fmt); + } + this.$inChange = false; + }; + this.onAfterExec = function (e) { + if (e.command && !e.command.readOnly) + this.updateLinkedFields(); + }; + this.onChangeSelection = function () { + if (!this.editor) + return; + var lead = this.editor.selection.lead; + var anchor = this.editor.selection.anchor; + var isEmpty = this.editor.selection.isEmpty(); + for (var i = 0; i < this.ranges.length; i++) { + if (this.ranges[i].linked) + continue; + var containsLead = this.ranges[i].contains(lead.row, lead.column); + var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column); + if (containsLead && containsAnchor) + return; + } + this.detach(); + }; + this.onChangeSession = function () { + this.detach(); + }; + this.tabNext = function (dir) { + var max = this.tabstops.length; + var index = this.index + (dir || 1); + index = Math.min(Math.max(index, 1), max); + if (index == max) + index = 0; + this.selectTabstop(index); + if (index === 0) + this.detach(); + }; + this.selectTabstop = function (index) { + this.$openTabstops = null; + var ts = this.tabstops[this.index]; + if (ts) + this.addTabstopMarkers(ts); + this.index = index; + ts = this.tabstops[this.index]; + if (!ts || !ts.length) + return; + this.selectedTabstop = ts; + var range = ts.firstNonLinked || ts; + if (ts.choices) + range.cursor = range.start; + if (!this.editor.inVirtualSelectionMode) { + var sel = this.editor.multiSelect; + sel.toSingleRange(range); + for (var i = 0; i < ts.length; i++) { + if (ts.hasLinkedRanges && ts[i].linked) + continue; + sel.addRange(ts[i].clone(), true); + } + } + else { + this.editor.selection.fromOrientedRange(range); + } + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + if (this.selectedTabstop && this.selectedTabstop.choices) + this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices }); + }; + this.addTabstops = function (tabstops, start, end) { + var useLink = this.useLink || !this.editor.getOption("enableMultiselect"); + if (!this.$openTabstops) + this.$openTabstops = []; + if (!tabstops[0]) { + var p = Range.fromPoints(end, end); + moveRelative(p.start, start); + moveRelative(p.end, start); + tabstops[0] = [p]; + tabstops[0].index = 0; + } + var i = this.index; + var arg = [i + 1, 0]; + var ranges = this.ranges; + tabstops.forEach(function (ts, index) { + var dest = this.$openTabstops[index] || ts; + for (var i = 0; i < ts.length; i++) { + var p = ts[i]; + var range = Range.fromPoints(p.start, p.end || p.start); + movePoint(range.start, start); + movePoint(range.end, start); + range.original = p; + range.tabstop = dest; + ranges.push(range); + if (dest != ts) + dest.unshift(range); + else + dest[i] = range; + if (p.fmtString || (dest.firstNonLinked && useLink)) { + range.linked = true; + dest.hasLinkedRanges = true; + } + else if (!dest.firstNonLinked) + dest.firstNonLinked = range; + } + if (!dest.firstNonLinked) + dest.hasLinkedRanges = false; + if (dest === ts) { + arg.push(dest); + this.$openTabstops[index] = dest; + } + this.addTabstopMarkers(dest); + dest.rangeList = dest.rangeList || new RangeList(); + dest.rangeList.$bias = 0; + dest.rangeList.addList(dest); + }, this); + if (arg.length > 2) { + if (this.tabstops.length) + arg.push(arg.splice(2, 1)[0]); + this.tabstops.splice.apply(this.tabstops, arg); + } + }; + this.addTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + if (!range.markerId) + range.markerId = session.addMarker(range, "ace_snippet-marker", "text"); + }); + }; + this.removeTabstopMarkers = function (ts) { + var session = this.editor.session; + ts.forEach(function (range) { + session.removeMarker(range.markerId); + range.markerId = null; + }); + }; + this.removeRange = function (range) { + var i = range.tabstop.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + i = this.ranges.indexOf(range); + if (i != -1) + this.ranges.splice(i, 1); + i = range.tabstop.rangeList.ranges.indexOf(range); + if (i != -1) + range.tabstop.splice(i, 1); + this.editor.session.removeMarker(range.markerId); + if (!range.tabstop.length) { + i = this.tabstops.indexOf(range.tabstop); + if (i != -1) + this.tabstops.splice(i, 1); + if (!this.tabstops.length) + this.detach(); + } + }; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys({ + "Tab": function (editor) { + if (exports.snippetManager && exports.snippetManager.expandWithTab(editor)) + return; + editor.tabstopManager.tabNext(1); + editor.renderer.scrollCursorIntoView(); + }, + "Shift-Tab": function (editor) { + editor.tabstopManager.tabNext(-1); + editor.renderer.scrollCursorIntoView(); + }, + "Esc": function (editor) { + editor.tabstopManager.detach(); + } + }); +}).call(TabstopManager.prototype); +var movePoint = function (point, diff) { + if (point.row == 0) + point.column += diff.column; + point.row += diff.row; +}; +var moveRelative = function (point, start) { + if (point.row == start.row) + point.column -= start.column; + point.row -= start.row; +}; +dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false); +exports.snippetManager = new SnippetManager(); +var Editor = require("./editor").Editor; +(function () { + this.insertSnippet = function (content, options) { + return exports.snippetManager.insertSnippet(this, content, options); + }; + this.expandSnippet = function (options) { + return exports.snippetManager.expandWithTab(this, options); + }; +}).call(Editor.prototype); + +}); + +define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config"], function(require, exports, module){"use strict"; +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var AcePopup = require("./autocomplete/popup").AcePopup; +var util = require("./autocomplete/util"); +var lang = require("./lib/lang"); +var dom = require("./lib/dom"); +var snippetManager = require("./snippets").snippetManager; +var config = require("./config"); +var Autocomplete = function () { + this.autoInsert = false; + this.autoSelect = true; + this.exactMatch = false; + this.gatherCompletionsId = 0; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys(this.commands); + this.blurListener = this.blurListener.bind(this); + this.changeListener = this.changeListener.bind(this); + this.mousedownListener = this.mousedownListener.bind(this); + this.mousewheelListener = this.mousewheelListener.bind(this); + this.changeTimer = lang.delayedCall(function () { + this.updateCompletions(true); + }.bind(this)); + this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50); +}; +(function () { + this.$init = function () { + this.popup = new AcePopup(document.body || document.documentElement); + this.popup.on("click", function (e) { + this.insertMatch(); + e.stop(); + }.bind(this)); + this.popup.focus = this.editor.focus.bind(this.editor); + this.popup.on("show", this.tooltipTimer.bind(null, null)); + this.popup.on("select", this.tooltipTimer.bind(null, null)); + this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null)); + return this.popup; + }; + this.getPopup = function () { + return this.popup || this.$init(); + }; + this.openPopup = function (editor, prefix, keepPopupPosition) { + if (!this.popup) + this.$init(); + this.popup.autoSelect = this.autoSelect; + this.popup.setData(this.completions.filtered, this.completions.filterText); + editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + var renderer = editor.renderer; + this.popup.setRow(this.autoSelect ? 0 : -1); + if (!keepPopupPosition) { + this.popup.setTheme(editor.getTheme()); + this.popup.setFontSize(editor.getFontSize()); + var lineHeight = renderer.layerConfig.lineHeight; + var pos = renderer.$cursorLayer.getPixelPosition(this.base, true); + pos.left -= this.popup.getTextLeftOffset(); + var rect = editor.container.getBoundingClientRect(); + pos.top += rect.top - renderer.layerConfig.offset; + pos.left += rect.left - editor.renderer.scrollLeft; + pos.left += renderer.gutterWidth; + this.popup.show(pos, lineHeight); + } + else if (keepPopupPosition && !prefix) { + this.detach(); + } + this.changeTimer.cancel(); + }; + this.detach = function () { + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.off("changeSelection", this.changeListener); + this.editor.off("blur", this.blurListener); + this.editor.off("mousedown", this.mousedownListener); + this.editor.off("mousewheel", this.mousewheelListener); + this.changeTimer.cancel(); + this.hideDocTooltip(); + this.gatherCompletionsId += 1; + if (this.popup && this.popup.isOpen) + this.popup.hide(); + if (this.base) + this.base.detach(); + this.activated = false; + this.completions = this.base = null; + }; + this.changeListener = function (e) { + var cursor = this.editor.selection.lead; + if (cursor.row != this.base.row || cursor.column < this.base.column) { + this.detach(); + } + if (this.activated) + this.changeTimer.schedule(); + else + this.detach(); + }; + this.blurListener = function (e) { + var el = document.activeElement; + var text = this.editor.textInput.getElement(); + var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget); + var container = this.popup && this.popup.container; + if (el != text && el.parentNode != container && !fromTooltip + && el != this.tooltipNode && e.relatedTarget != text) { + this.detach(); + } + }; + this.mousedownListener = function (e) { + this.detach(); + }; + this.mousewheelListener = function (e) { + this.detach(); + }; + this.goTo = function (where) { + this.popup.goTo(where); + }; + this.insertMatch = function (data, options) { + if (!data) + data = this.popup.getData(this.popup.getRow()); + if (!data) + return false; + var completions = this.completions; + this.editor.startOperation({ command: { name: "insertMatch" } }); + if (data.completer && data.completer.insertMatch) { + data.completer.insertMatch(this.editor, data); + } + else { + if (!completions) + return false; + if (completions.filterText) { + var ranges = this.editor.selection.getAllRanges(); + for (var i = 0, range; range = ranges[i]; i++) { + range.start.column -= completions.filterText.length; + this.editor.session.remove(range); + } + } + if (data.snippet) + snippetManager.insertSnippet(this.editor, data.snippet); + else + this.editor.execCommand("insertstring", data.value || data); + } + if (this.completions == completions) + this.detach(); + this.editor.endOperation(); + }; + this.commands = { + "Up": function (editor) { editor.completer.goTo("up"); }, + "Down": function (editor) { editor.completer.goTo("down"); }, + "Ctrl-Up|Ctrl-Home": function (editor) { editor.completer.goTo("start"); }, + "Ctrl-Down|Ctrl-End": function (editor) { editor.completer.goTo("end"); }, + "Esc": function (editor) { editor.completer.detach(); }, + "Return": function (editor) { return editor.completer.insertMatch(); }, + "Shift-Return": function (editor) { editor.completer.insertMatch(null, { deleteSuffix: true }); }, + "Tab": function (editor) { + var result = editor.completer.insertMatch(); + if (!result && !editor.tabstopManager) + editor.completer.goTo("down"); + else + return result; + }, + "PageUp": function (editor) { editor.completer.popup.gotoPageUp(); }, + "PageDown": function (editor) { editor.completer.popup.gotoPageDown(); } + }; + this.gatherCompletions = function (editor, callback) { + var session = editor.getSession(); + var pos = editor.getCursorPosition(); + var prefix = util.getCompletionPrefix(editor); + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); + this.base.$insertRight = true; + var matches = []; + var total = editor.completers.length; + editor.completers.forEach(function (completer, i) { + completer.getCompletions(editor, session, pos, prefix, function (err, results) { + if (!err && results) + matches = matches.concat(results); + callback(null, { + prefix: util.getCompletionPrefix(editor), + matches: matches, + finished: (--total === 0) + }); + }); + }); + return true; + }; + this.showPopup = function (editor, options) { + if (this.editor) + this.detach(); + this.activated = true; + this.editor = editor; + if (editor.completer != this) { + if (editor.completer) + editor.completer.detach(); + editor.completer = this; + } + editor.on("changeSelection", this.changeListener); + editor.on("blur", this.blurListener); + editor.on("mousedown", this.mousedownListener); + editor.on("mousewheel", this.mousewheelListener); + this.updateCompletions(false, options); + }; + this.updateCompletions = function (keepPopupPosition, options) { + if (keepPopupPosition && this.base && this.completions) { + var pos = this.editor.getCursorPosition(); + var prefix = this.editor.session.getTextRange({ start: this.base, end: pos }); + if (prefix == this.completions.filterText) + return; + this.completions.setFilter(prefix); + if (!this.completions.filtered.length) + return this.detach(); + if (this.completions.filtered.length == 1 + && this.completions.filtered[0].value == prefix + && !this.completions.filtered[0].snippet) + return this.detach(); + this.openPopup(this.editor, prefix, keepPopupPosition); + return; + } + if (options && options.matches) { + var pos = this.editor.getSelectionRange().start; + this.base = this.editor.session.doc.createAnchor(pos.row, pos.column); + this.base.$insertRight = true; + this.completions = new FilteredList(options.matches); + return this.openPopup(this.editor, "", keepPopupPosition); + } + var _id = this.gatherCompletionsId; + var detachIfFinished = function (results) { + if (!results.finished) + return; + return this.detach(); + }.bind(this); + var processResults = function (results) { + var prefix = results.prefix; + var matches = results.matches; + this.completions = new FilteredList(matches); + if (this.exactMatch) + this.completions.exactMatch = true; + this.completions.setFilter(prefix); + var filtered = this.completions.filtered; + if (!filtered.length) + return detachIfFinished(results); + if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) + return detachIfFinished(results); + if (this.autoInsert && filtered.length == 1 && results.finished) + return this.insertMatch(filtered[0]); + this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this); + var isImmediate = true; + var immediateResults = null; + this.gatherCompletions(this.editor, function (err, results) { + var prefix = results.prefix; + var matches = results && results.matches; + if (!matches || !matches.length) + return detachIfFinished(results); + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + if (isImmediate) { + immediateResults = results; + return; + } + processResults(results); + }.bind(this)); + isImmediate = false; + if (immediateResults) { + var results = immediateResults; + immediateResults = null; + processResults(results); + } + }; + this.cancelContextMenu = function () { + this.editor.$mouseHandler.cancelContextMenu(); + }; + this.updateDocTooltip = function () { + var popup = this.popup; + var all = popup.data; + var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]); + var doc = null; + if (!selected || !this.editor || !this.popup.isOpen) + return this.hideDocTooltip(); + this.editor.completers.some(function (completer) { + if (completer.getDocTooltip) + doc = completer.getDocTooltip(selected); + return doc; + }); + if (!doc && typeof selected != "string") + doc = selected; + if (typeof doc == "string") + doc = { docText: doc }; + if (!doc || !(doc.docHTML || doc.docText)) + return this.hideDocTooltip(); + this.showDocTooltip(doc); + }; + this.showDocTooltip = function (item) { + if (!this.tooltipNode) { + this.tooltipNode = dom.createElement("div"); + this.tooltipNode.className = "ace_tooltip ace_doc-tooltip"; + this.tooltipNode.style.margin = 0; + this.tooltipNode.style.pointerEvents = "auto"; + this.tooltipNode.tabIndex = -1; + this.tooltipNode.onblur = this.blurListener.bind(this); + this.tooltipNode.onclick = this.onTooltipClick.bind(this); + } + var tooltipNode = this.tooltipNode; + if (item.docHTML) { + tooltipNode.innerHTML = item.docHTML; + } + else if (item.docText) { + tooltipNode.textContent = item.docText; + } + if (!tooltipNode.parentNode) + document.body.appendChild(tooltipNode); + var popup = this.popup; + var rect = popup.container.getBoundingClientRect(); + tooltipNode.style.top = popup.container.style.top; + tooltipNode.style.bottom = popup.container.style.bottom; + tooltipNode.style.display = "block"; + if (window.innerWidth - rect.right < 320) { + if (rect.left < 320) { + if (popup.isTopdown) { + tooltipNode.style.top = rect.bottom + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + else { + tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px"; + tooltipNode.style.left = rect.left + "px"; + tooltipNode.style.right = ""; + tooltipNode.style.bottom = ""; + } + } + else { + tooltipNode.style.right = window.innerWidth - rect.left + "px"; + tooltipNode.style.left = ""; + } + } + else { + tooltipNode.style.left = (rect.right + 1) + "px"; + tooltipNode.style.right = ""; + } + }; + this.hideDocTooltip = function () { + this.tooltipTimer.cancel(); + if (!this.tooltipNode) + return; + var el = this.tooltipNode; + if (!this.editor.isFocused() && document.activeElement == el) + this.editor.focus(); + this.tooltipNode = null; + if (el.parentNode) + el.parentNode.removeChild(el); + }; + this.onTooltipClick = function (e) { + var a = e.target; + while (a && a != this.tooltipNode) { + if (a.nodeName == "A" && a.href) { + a.rel = "noreferrer"; + a.target = "_blank"; + break; + } + a = a.parentNode; + } + }; + this.destroy = function () { + this.detach(); + if (this.popup) { + this.popup.destroy(); + var el = this.popup.container; + if (el && el.parentNode) + el.parentNode.removeChild(el); + } + if (this.editor && this.editor.completer == this) + this.editor.completer == null; + this.popup = null; + }; +}).call(Autocomplete.prototype); +Autocomplete.for = function (editor) { + if (editor.completer) { + return editor.completer; + } + if (config.get("sharedPopups")) { + if (!Autocomplete.$shared) + Autocomplete.$sharedInstance = new Autocomplete(); + editor.completer = Autocomplete.$sharedInstance; + } + else { + editor.completer = new Autocomplete(); + editor.once("destroy", function (e, editor) { + editor.completer.destroy(); + }); + } + return editor.completer; +}; +Autocomplete.startCommand = { + name: "startAutocomplete", + exec: function (editor, options) { + var completer = Autocomplete.for(editor); + completer.autoInsert = false; + completer.autoSelect = true; + completer.showPopup(editor, options); + completer.cancelContextMenu(); + }, + bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" +}; +var FilteredList = function (array, filterText) { + this.all = array; + this.filtered = array; + this.filterText = filterText || ""; + this.exactMatch = false; +}; +(function () { + this.setFilter = function (str) { + if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0) + var matches = this.filtered; + else + var matches = this.all; + this.filterText = str; + matches = this.filterCompletions(matches, this.filterText); + matches = matches.sort(function (a, b) { + return b.exactMatch - a.exactMatch || b.$score - a.$score + || (a.caption || a.value).localeCompare(b.caption || b.value); + }); + var prev = null; + matches = matches.filter(function (item) { + var caption = item.snippet || item.caption || item.value; + if (caption === prev) + return false; + prev = caption; + return true; + }); + this.filtered = matches; + }; + this.filterCompletions = function (items, needle) { + var results = []; + var upper = needle.toUpperCase(); + var lower = needle.toLowerCase(); + loop: for (var i = 0, item; item = items[i]; i++) { + var caption = item.caption || item.value || item.snippet; + if (!caption) + continue; + var lastIndex = -1; + var matchMask = 0; + var penalty = 0; + var index, distance; + if (this.exactMatch) { + if (needle !== caption.substr(0, needle.length)) + continue loop; + } + else { + var fullMatchIndex = caption.toLowerCase().indexOf(lower); + if (fullMatchIndex > -1) { + penalty = fullMatchIndex; + } + else { + for (var j = 0; j < needle.length; j++) { + var i1 = caption.indexOf(lower[j], lastIndex + 1); + var i2 = caption.indexOf(upper[j], lastIndex + 1); + index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2; + if (index < 0) + continue loop; + distance = index - lastIndex - 1; + if (distance > 0) { + if (lastIndex === -1) + penalty += 10; + penalty += distance; + matchMask = matchMask | (1 << j); + } + lastIndex = index; + } + } + } + item.matchMask = matchMask; + item.exactMatch = penalty ? 0 : 1; + item.$score = (item.score || 0) - penalty; + results.push(item); + } + return results; + }; +}).call(FilteredList.prototype); +exports.Autocomplete = Autocomplete; +exports.FilteredList = FilteredList; + +}); + +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + +define("ace/ext/prompt",["require","exports","module","ace/range","ace/lib/dom","ace/ext/menu_tools/get_editor_keyboard_shortcuts","ace/autocomplete","ace/autocomplete/popup","ace/autocomplete/popup","ace/undomanager","ace/tokenizer","ace/ext/menu_tools/overlay_page","ace/ext/modelist"], function(require, exports, module){/** + * Prompt plugin is used for getting input from user. + * + * @param {Object} editor Ouside editor related to this prompt. Will be blurred when prompt is open. + * @param {String} message Predefined value of prompt input box. + * @param {Object} options Cusomizable options for this prompt. + * @param {String} options.name Prompt name. + * @param {String} options.$type Use prompt of specific type (gotoLine|commands|modes or default if empty). + * @param {[start, end]} options.selection Defines which part of the predefined value should be highlited. + * @param {Boolean} options.hasDescription Set to true if prompt has description below input box. + * @param {String} options.prompt Description below input box. + * @param {String} options.placeholder Placeholder for value. + * @param {Object} options.$rules Specific rules for input like password or regexp. + * @param {Boolean} options.ignoreFocusOut Set to true to keep the prompt open when focus moves to another part of the editor. + * @param {Function} options.getCompletions Function for defining list of options for value. + * @param {Function} options.getPrefix Function for defining current value prefix. + * @param {Function} options.onAccept Function called when Enter is pressed. + * @param {Function} options.onInput Function called when input is added to prompt input box. + * @param {Function} options.onCancel Function called when Esc|Shift-Esc is pressed. + * @param {Function} callback Function called after done. + * */ +"use strict"; +var Range = require("../range").Range; +var dom = require("../lib/dom"); +var shortcuts = require("../ext/menu_tools/get_editor_keyboard_shortcuts"); +var FilteredList = require("../autocomplete").FilteredList; +var AcePopup = require('../autocomplete/popup').AcePopup; +var $singleLineEditor = require('../autocomplete/popup').$singleLineEditor; +var UndoManager = require("../undomanager").UndoManager; +var Tokenizer = require("../tokenizer").Tokenizer; +var overlayPage = require("./menu_tools/overlay_page").overlayPage; +var modelist = require("./modelist"); +var openPrompt; +function prompt(editor, message, options, callback) { + if (typeof message == "object") { + return prompt(editor, "", message, options); + } + if (openPrompt) { + var lastPrompt = openPrompt; + editor = lastPrompt.editor; + lastPrompt.close(); + if (lastPrompt.name && lastPrompt.name == options.name) + return; + } + if (options.$type) + return prompt[options.$type](editor, callback); + var cmdLine = $singleLineEditor(); + cmdLine.session.setUndoManager(new UndoManager()); + var el = dom.buildDom(["div", { class: "ace_prompt_container" + (options.hasDescription ? " input-box-with-description" : "") }]); + var overlay = overlayPage(editor, el, done); + el.appendChild(cmdLine.container); + if (editor) { + editor.cmdLine = cmdLine; + cmdLine.setOption("fontSize", editor.getOption("fontSize")); + } + if (message) { + cmdLine.setValue(message, 1); + } + if (options.selection) { + cmdLine.selection.setRange({ + start: cmdLine.session.doc.indexToPosition(options.selection[0]), + end: cmdLine.session.doc.indexToPosition(options.selection[1]) + }); + } + if (options.getCompletions) { + var popup = new AcePopup(); + popup.renderer.setStyle("ace_autocomplete_inline"); + popup.container.style.display = "block"; + popup.container.style.maxWidth = "600px"; + popup.container.style.width = "100%"; + popup.container.style.marginTop = "3px"; + popup.renderer.setScrollMargin(2, 2, 0, 0); + popup.autoSelect = false; + popup.renderer.$maxLines = 15; + popup.setRow(-1); + popup.on("click", function (e) { + var data = popup.getData(popup.getRow()); + if (!data.error) { + cmdLine.setValue(data.value || data.name || data); + accept(); + e.stop(); + } + }); + el.appendChild(popup.container); + updateCompletions(); + } + if (options.$rules) { + var tokenizer = new Tokenizer(options.$rules); + cmdLine.session.bgTokenizer.setTokenizer(tokenizer); + } + if (options.placeholder) { + cmdLine.setOption("placeholder", options.placeholder); + } + if (options.hasDescription) { + var promptTextContainer = dom.buildDom(["div", { class: "ace_prompt_text_container" }]); + dom.buildDom(options.prompt || "Press 'Enter' to confirm or 'Escape' to cancel", promptTextContainer); + el.appendChild(promptTextContainer); + } + overlay.setIgnoreFocusOut(options.ignoreFocusOut); + function accept() { + var val; + if (popup && popup.getCursorPosition().row > 0) { + val = valueFromRecentList(); + } + else { + val = cmdLine.getValue(); + } + var curData = popup ? popup.getData(popup.getRow()) : val; + if (curData && !curData.error) { + done(); + options.onAccept && options.onAccept({ + value: val, + item: curData + }, cmdLine); + } + } + var keys = { + "Enter": accept, + "Esc|Shift-Esc": function () { + options.onCancel && options.onCancel(cmdLine.getValue(), cmdLine); + done(); + } + }; + if (popup) { + Object.assign(keys, { + "Up": function (editor) { popup.goTo("up"); valueFromRecentList(); }, + "Down": function (editor) { popup.goTo("down"); valueFromRecentList(); }, + "Ctrl-Up|Ctrl-Home": function (editor) { popup.goTo("start"); valueFromRecentList(); }, + "Ctrl-Down|Ctrl-End": function (editor) { popup.goTo("end"); valueFromRecentList(); }, + "Tab": function (editor) { + popup.goTo("down"); + valueFromRecentList(); + }, + "PageUp": function (editor) { popup.gotoPageUp(); valueFromRecentList(); }, + "PageDown": function (editor) { popup.gotoPageDown(); valueFromRecentList(); } + }); + } + cmdLine.commands.bindKeys(keys); + function done() { + overlay.close(); + callback && callback(); + openPrompt = null; + } + cmdLine.on("input", function () { + options.onInput && options.onInput(); + updateCompletions(); + }); + function updateCompletions() { + if (options.getCompletions) { + var prefix; + if (options.getPrefix) { + prefix = options.getPrefix(cmdLine); + } + var completions = options.getCompletions(cmdLine); + popup.setData(completions, prefix); + popup.resize(true); + } + } + function valueFromRecentList() { + var current = popup.getData(popup.getRow()); + if (current && !current.error) + return current.value || current.caption || current; + } + cmdLine.resize(true); + if (popup) { + popup.resize(true); + } + cmdLine.focus(); + openPrompt = { + close: done, + name: options.name, + editor: editor + }; +} +prompt.gotoLine = function (editor, callback) { + function stringifySelection(selection) { + if (!Array.isArray(selection)) + selection = [selection]; + return selection.map(function (r) { + var cursor = r.isBackwards ? r.start : r.end; + var anchor = r.isBackwards ? r.end : r.start; + var row = anchor.row; + var s = (row + 1) + ":" + anchor.column; + if (anchor.row == cursor.row) { + if (anchor.column != cursor.column) + s += ">" + ":" + cursor.column; + } + else { + s += ">" + (cursor.row + 1) + ":" + cursor.column; + } + return s; + }).reverse().join(", "); + } + prompt(editor, ":" + stringifySelection(editor.selection.toJSON()), { + name: "gotoLine", + selection: [1, Number.MAX_VALUE], + onAccept: function (data) { + var value = data.value; + var _history = prompt.gotoLine._history; + if (!_history) + prompt.gotoLine._history = _history = []; + if (_history.indexOf(value) != -1) + _history.splice(_history.indexOf(value), 1); + _history.unshift(value); + if (_history.length > 20) + _history.length = 20; + var pos = editor.getCursorPosition(); + var ranges = []; + value.replace(/^:/, "").split(/,/).map(function (str) { + var parts = str.split(/([<>:+-]|c?\d+)|[^c\d<>:+-]+/).filter(Boolean); + var i = 0; + function readPosition() { + var c = parts[i++]; + if (!c) + return; + if (c[0] == "c") { + var index = parseInt(c.slice(1)) || 0; + return editor.session.doc.indexToPosition(index); + } + var row = pos.row; + var column = 0; + if (/\d/.test(c)) { + row = parseInt(c) - 1; + c = parts[i++]; + } + if (c == ":") { + c = parts[i++]; + if (/\d/.test(c)) { + column = parseInt(c) || 0; + } + } + return { row: row, column: column }; + } + pos = readPosition(); + var range = Range.fromPoints(pos, pos); + if (parts[i] == ">") { + i++; + range.end = readPosition(); + } + else if (parts[i] == "<") { + i++; + range.start = readPosition(); + } + ranges.unshift(range); + }); + editor.selection.fromJSON(ranges); + var scrollTop = editor.renderer.scrollTop; + editor.renderer.scrollSelectionIntoView(editor.selection.anchor, editor.selection.cursor, 0.5); + editor.renderer.animateScrolling(scrollTop); + }, + history: function () { + var undoManager = editor.session.getUndoManager(); + if (!prompt.gotoLine._history) + return []; + return prompt.gotoLine._history; + }, + getCompletions: function (cmdLine) { + var value = cmdLine.getValue(); + var m = value.replace(/^:/, "").split(":"); + var row = Math.min(parseInt(m[0]) || 1, editor.session.getLength()) - 1; + var line = editor.session.getLine(row); + var current = value + " " + line; + return [current].concat(this.history()); + }, + $rules: { + start: [{ + regex: /\d+/, + token: "string" + }, { + regex: /[:,><+\-c]/, + token: "keyword" + }] + } + }); +}; +prompt.commands = function (editor, callback) { + function normalizeName(name) { + return (name || "").replace(/^./, function (x) { + return x.toUpperCase(x); + }).replace(/[a-z][A-Z]/g, function (x) { + return x[0] + " " + x[1].toLowerCase(x); + }); + } + function getEditorCommandsByName(excludeCommands) { + var commandsByName = []; + var commandMap = {}; + editor.keyBinding.$handlers.forEach(function (handler) { + var platform = handler.platform; + var cbn = handler.byName; + for (var i in cbn) { + var key = cbn[i].bindKey; + if (typeof key !== "string") { + key = key && key[platform] || ""; + } + var commands = cbn[i]; + var description = commands.description || normalizeName(commands.name); + if (!Array.isArray(commands)) + commands = [commands]; + commands.forEach(function (command) { + if (typeof command != "string") + command = command.name; + var needle = excludeCommands.find(function (el) { + return el === command; + }); + if (!needle) { + if (commandMap[command]) { + commandMap[command].key += "|" + key; + } + else { + commandMap[command] = { key: key, command: command, description: description }; + commandsByName.push(commandMap[command]); + } + } + }); + } + }); + return commandsByName; + } + var excludeCommandsList = ["insertstring", "inserttext", "setIndentation", "paste"]; + var shortcutsArray = getEditorCommandsByName(excludeCommandsList); + shortcutsArray = shortcutsArray.map(function (item) { + return { value: item.description, meta: item.key, command: item.command }; + }); + prompt(editor, "", { + name: "commands", + selection: [0, Number.MAX_VALUE], + maxHistoryCount: 5, + onAccept: function (data) { + if (data.item) { + var commandName = data.item.command; + this.addToHistory(data.item); + editor.execCommand(commandName); + } + }, + addToHistory: function (item) { + var history = this.history(); + history.unshift(item); + delete item.message; + for (var i = 1; i < history.length; i++) { + if (history[i]["command"] == item.command) { + history.splice(i, 1); + break; + } + } + if (this.maxHistoryCount > 0 && history.length > this.maxHistoryCount) { + history.splice(history.length - 1, 1); + } + prompt.commands.history = history; + }, + history: function () { + return prompt.commands.history || []; + }, + getPrefix: function (cmdLine) { + var currentPos = cmdLine.getCursorPosition(); + var filterValue = cmdLine.getValue(); + return filterValue.substring(0, currentPos.column); + }, + getCompletions: function (cmdLine) { + function getFilteredCompletions(commands, prefix) { + var resultCommands = JSON.parse(JSON.stringify(commands)); + var filtered = new FilteredList(resultCommands); + return filtered.filterCompletions(resultCommands, prefix); + } + function getUniqueCommandList(commands, usedCommands) { + if (!usedCommands || !usedCommands.length) { + return commands; + } + var excludeCommands = []; + usedCommands.forEach(function (item) { + excludeCommands.push(item.command); + }); + var resultCommands = []; + commands.forEach(function (item) { + if (excludeCommands.indexOf(item.command) === -1) { + resultCommands.push(item); + } + }); + return resultCommands; + } + var prefix = this.getPrefix(cmdLine); + var recentlyUsedCommands = getFilteredCompletions(this.history(), prefix); + var otherCommands = getUniqueCommandList(shortcutsArray, recentlyUsedCommands); + otherCommands = getFilteredCompletions(otherCommands, prefix); + if (recentlyUsedCommands.length && otherCommands.length) { + recentlyUsedCommands[0]["message"] = " Recently used"; + otherCommands[0]["message"] = " Other commands"; + } + var completions = recentlyUsedCommands.concat(otherCommands); + return completions.length > 0 ? completions : [{ + value: "No matching commands", + error: 1 + }]; + } + }); +}; +prompt.modes = function (editor, callback) { + var modesArray = modelist.modes; + modesArray = modesArray.map(function (item) { + return { value: item.caption, mode: item.name }; + }); + prompt(editor, "", { + name: "modes", + selection: [0, Number.MAX_VALUE], + onAccept: function (data) { + if (data.item) { + var modeName = "ace/mode/" + data.item.mode; + editor.session.setMode(modeName); + } + }, + getPrefix: function (cmdLine) { + var currentPos = cmdLine.getCursorPosition(); + var filterValue = cmdLine.getValue(); + return filterValue.substring(0, currentPos.column); + }, + getCompletions: function (cmdLine) { + function getFilteredCompletions(modes, prefix) { + var resultCommands = JSON.parse(JSON.stringify(modes)); + var filtered = new FilteredList(resultCommands); + return filtered.filterCompletions(resultCommands, prefix); + } + var prefix = this.getPrefix(cmdLine); + var completions = getFilteredCompletions(modesArray, prefix); + return completions.length > 0 ? completions : [{ + "caption": "No mode matching", + "value": "No mode matching", + "error": 1 + }]; + } + }); +}; +dom.importCssString(".ace_prompt_container {\n max-width: 600px;\n width: 100%;\n margin: 20px auto;\n padding: 3px;\n background: white;\n border-radius: 2px;\n box-shadow: 0px 2px 3px 0px #555;\n}", "promtp.css", false); +exports.prompt = prompt; + +}); + (function() { + window.require(["ace/ext/prompt"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-rtl.js b/src/main/resources/static/assets/js/vendor/template/src/ext-rtl.js new file mode 100644 index 0000000..56c7337 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-rtl.js @@ -0,0 +1,121 @@ +define("ace/ext/rtl",["require","exports","module","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var commands = [{ + name: "leftToRight", + bindKey: { win: "Ctrl-Alt-Shift-L", mac: "Command-Alt-Shift-L" }, + exec: function (editor) { + editor.session.$bidiHandler.setRtlDirection(editor, false); + }, + readOnly: true + }, { + name: "rightToLeft", + bindKey: { win: "Ctrl-Alt-Shift-R", mac: "Command-Alt-Shift-R" }, + exec: function (editor) { + editor.session.$bidiHandler.setRtlDirection(editor, true); + }, + readOnly: true + }]; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + rtlText: { + set: function (val) { + if (val) { + this.on("change", onChange); + this.on("changeSelection", onChangeSelection); + this.renderer.on("afterRender", updateLineDirection); + this.commands.on("exec", onCommandEmitted); + this.commands.addCommands(commands); + } + else { + this.off("change", onChange); + this.off("changeSelection", onChangeSelection); + this.renderer.off("afterRender", updateLineDirection); + this.commands.off("exec", onCommandEmitted); + this.commands.removeCommands(commands); + clearTextLayer(this.renderer); + } + this.renderer.updateFull(); + } + }, + rtl: { + set: function (val) { + this.session.$bidiHandler.$isRtl = val; + if (val) { + this.setOption("rtlText", false); + this.renderer.on("afterRender", updateLineDirection); + this.session.$bidiHandler.seenBidi = true; + } + else { + this.renderer.off("afterRender", updateLineDirection); + clearTextLayer(this.renderer); + } + this.renderer.updateFull(); + } + } +}); +function onChangeSelection(e, editor) { + var lead = editor.getSelection().lead; + if (editor.session.$bidiHandler.isRtlLine(lead.row)) { + if (lead.column === 0) { + if (editor.session.$bidiHandler.isMoveLeftOperation && lead.row > 0) { + editor.getSelection().moveCursorTo(lead.row - 1, editor.session.getLine(lead.row - 1).length); + } + else { + if (editor.getSelection().isEmpty()) + lead.column += 1; + else + lead.setPosition(lead.row, lead.column + 1); + } + } + } +} +function onCommandEmitted(commadEvent) { + commadEvent.editor.session.$bidiHandler.isMoveLeftOperation = /gotoleft|selectleft|backspace|removewordleft/.test(commadEvent.command.name); +} +function onChange(delta, editor) { + var session = editor.session; + session.$bidiHandler.currentRow = null; + if (session.$bidiHandler.isRtlLine(delta.start.row) && delta.action === 'insert' && delta.lines.length > 1) { + for (var row = delta.start.row; row < delta.end.row; row++) { + if (session.getLine(row + 1).charAt(0) !== session.$bidiHandler.RLE) + session.doc.$lines[row + 1] = session.$bidiHandler.RLE + session.getLine(row + 1); + } + } +} +function updateLineDirection(e, renderer) { + var session = renderer.session; + var $bidiHandler = session.$bidiHandler; + var cells = renderer.$textLayer.$lines.cells; + var width = renderer.layerConfig.width - renderer.layerConfig.padding + "px"; + cells.forEach(function (cell) { + var style = cell.element.style; + if ($bidiHandler && $bidiHandler.isRtlLine(cell.row)) { + style.direction = "rtl"; + style.textAlign = "right"; + style.width = width; + } + else { + style.direction = ""; + style.textAlign = ""; + style.width = ""; + } + }); +} +function clearTextLayer(renderer) { + var lines = renderer.$textLayer.$lines; + lines.cells.forEach(clear); + lines.cellCache.forEach(clear); + function clear(cell) { + var style = cell.element.style; + style.direction = style.textAlign = style.width = ""; + } +} + +}); + (function() { + window.require(["ace/ext/rtl"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-searchbox.js b/src/main/resources/static/assets/js/vendor/template/src/ext-searchbox.js new file mode 100644 index 0000000..0af4ab1 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-searchbox.js @@ -0,0 +1,339 @@ +define("ace/ext/searchbox.css",["require","exports","module"], function(require, exports, module){module.exports = "\n\n/* ------------------------------------------------------------------------------------------\n * Editor Search Form\n * --------------------------------------------------------------------------------------- */\n.ace_search {\n background-color: #ddd;\n color: #666;\n border: 1px solid #cbcbcb;\n border-top: 0 none;\n overflow: hidden;\n margin: 0;\n padding: 4px 6px 0 4px;\n position: absolute;\n top: 0;\n z-index: 99;\n white-space: normal;\n}\n.ace_search.left {\n border-left: 0 none;\n border-radius: 0px 0px 5px 0px;\n left: 0;\n}\n.ace_search.right {\n border-radius: 0px 0px 0px 5px;\n border-right: 0 none;\n right: 0;\n}\n\n.ace_search_form, .ace_replace_form {\n margin: 0 20px 4px 0;\n overflow: hidden;\n line-height: 1.9;\n}\n.ace_replace_form {\n margin-right: 0;\n}\n.ace_search_form.ace_nomatch {\n outline: 1px solid red;\n}\n\n.ace_search_field {\n border-radius: 3px 0 0 3px;\n background-color: white;\n color: black;\n border: 1px solid #cbcbcb;\n border-right: 0 none;\n outline: 0;\n padding: 0;\n font-size: inherit;\n margin: 0;\n line-height: inherit;\n padding: 0 6px;\n min-width: 17em;\n vertical-align: top;\n min-height: 1.8em;\n box-sizing: content-box;\n}\n.ace_searchbtn {\n border: 1px solid #cbcbcb;\n line-height: inherit;\n display: inline-block;\n padding: 0 6px;\n background: #fff;\n border-right: 0 none;\n border-left: 1px solid #dcdcdc;\n cursor: pointer;\n margin: 0;\n position: relative;\n color: #666;\n}\n.ace_searchbtn:last-child {\n border-radius: 0 3px 3px 0;\n border-right: 1px solid #cbcbcb;\n}\n.ace_searchbtn:disabled {\n background: none;\n cursor: default;\n}\n.ace_searchbtn:hover {\n background-color: #eef1f6;\n}\n.ace_searchbtn.prev, .ace_searchbtn.next {\n padding: 0px 0.7em\n}\n.ace_searchbtn.prev:after, .ace_searchbtn.next:after {\n content: \"\";\n border: solid 2px #888;\n width: 0.5em;\n height: 0.5em;\n border-width: 2px 0 0 2px;\n display:inline-block;\n transform: rotate(-45deg);\n}\n.ace_searchbtn.next:after {\n border-width: 0 2px 2px 0 ;\n}\n.ace_searchbtn_close {\n background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\n border-radius: 50%;\n border: 0 none;\n color: #656565;\n cursor: pointer;\n font: 16px/16px Arial;\n padding: 0;\n height: 14px;\n width: 14px;\n top: 9px;\n right: 7px;\n position: absolute;\n}\n.ace_searchbtn_close:hover {\n background-color: #656565;\n background-position: 50% 100%;\n color: white;\n}\n\n.ace_button {\n margin-left: 2px;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n -ms-user-select: none;\n user-select: none;\n overflow: hidden;\n opacity: 0.7;\n border: 1px solid rgba(100,100,100,0.23);\n padding: 1px;\n box-sizing: border-box!important;\n color: black;\n}\n\n.ace_button:hover {\n background-color: #eee;\n opacity:1;\n}\n.ace_button:active {\n background-color: #ddd;\n}\n\n.ace_button.checked {\n border-color: #3399ff;\n opacity:1;\n}\n\n.ace_search_options{\n margin-bottom: 3px;\n text-align: right;\n -webkit-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n -ms-user-select: none;\n user-select: none;\n clear: both;\n}\n\n.ace_search_counter {\n float: left;\n font-family: arial;\n padding: 0 8px;\n}"; + +}); + +define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/ext/searchbox.css","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module){"use strict"; +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var event = require("../lib/event"); +var searchboxCss = require("./searchbox.css"); +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var keyUtil = require("../lib/keys"); +var MAX_COUNT = 999; +dom.importCssString(searchboxCss, "ace_searchbox", false); +var SearchBox = function (editor, range, showReplaceForm) { + var div = dom.createElement("div"); + dom.buildDom(["div", { class: "ace_search right" }, + ["span", { action: "hide", class: "ace_searchbtn_close" }], + ["div", { class: "ace_search_form" }, + ["input", { class: "ace_search_field", placeholder: "Search for", spellcheck: "false" }], + ["span", { action: "findPrev", class: "ace_searchbtn prev" }, "\u200b"], + ["span", { action: "findNext", class: "ace_searchbtn next" }, "\u200b"], + ["span", { action: "findAll", class: "ace_searchbtn", title: "Alt-Enter" }, "All"] + ], + ["div", { class: "ace_replace_form" }, + ["input", { class: "ace_search_field", placeholder: "Replace with", spellcheck: "false" }], + ["span", { action: "replaceAndFindNext", class: "ace_searchbtn" }, "Replace"], + ["span", { action: "replaceAll", class: "ace_searchbtn" }, "All"] + ], + ["div", { class: "ace_search_options" }, + ["span", { action: "toggleReplace", class: "ace_button", title: "Toggle Replace mode", + style: "float:left;margin-top:-2px;padding:0 5px;" }, "+"], + ["span", { class: "ace_search_counter" }], + ["span", { action: "toggleRegexpMode", class: "ace_button", title: "RegExp Search" }, ".*"], + ["span", { action: "toggleCaseSensitive", class: "ace_button", title: "CaseSensitive Search" }, "Aa"], + ["span", { action: "toggleWholeWords", class: "ace_button", title: "Whole Word Search" }, "\\b"], + ["span", { action: "searchInSelection", class: "ace_button", title: "Search In Selection" }, "S"] + ] + ], div); + this.element = div.firstChild; + this.setSession = this.setSession.bind(this); + this.$init(); + this.setEditor(editor); + dom.importCssString(searchboxCss, "ace_searchbox", editor.container); +}; +(function () { + this.setEditor = function (editor) { + editor.searchBox = this; + editor.renderer.scroller.appendChild(this.element); + this.editor = editor; + }; + this.setSession = function (e) { + this.searchRange = null; + this.$syncOptions(true); + }; + this.$initElements = function (sb) { + this.searchBox = sb.querySelector(".ace_search_form"); + this.replaceBox = sb.querySelector(".ace_replace_form"); + this.searchOption = sb.querySelector("[action=searchInSelection]"); + this.replaceOption = sb.querySelector("[action=toggleReplace]"); + this.regExpOption = sb.querySelector("[action=toggleRegexpMode]"); + this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]"); + this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]"); + this.searchInput = this.searchBox.querySelector(".ace_search_field"); + this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); + this.searchCounter = sb.querySelector(".ace_search_counter"); + }; + this.$init = function () { + var sb = this.element; + this.$initElements(sb); + var _this = this; + event.addListener(sb, "mousedown", function (e) { + setTimeout(function () { + _this.activeInput.focus(); + }, 0); + event.stopPropagation(e); + }); + event.addListener(sb, "click", function (e) { + var t = e.target || e.srcElement; + var action = t.getAttribute("action"); + if (action && _this[action]) + _this[action](); + else if (_this.$searchBarKb.commands[action]) + _this.$searchBarKb.commands[action].exec(_this); + event.stopPropagation(e); + }); + event.addCommandKeyListener(sb, function (e, hashId, keyCode) { + var keyString = keyUtil.keyCodeToString(keyCode); + var command = _this.$searchBarKb.findKeyCommand(hashId, keyString); + if (command && command.exec) { + command.exec(_this); + event.stopEvent(e); + } + }); + this.$onChange = lang.delayedCall(function () { + _this.find(false, false); + }); + event.addListener(this.searchInput, "input", function () { + _this.$onChange.schedule(20); + }); + event.addListener(this.searchInput, "focus", function () { + _this.activeInput = _this.searchInput; + _this.searchInput.value && _this.highlight(); + }); + event.addListener(this.replaceInput, "focus", function () { + _this.activeInput = _this.replaceInput; + _this.searchInput.value && _this.highlight(); + }); + }; + this.$closeSearchBarKb = new HashHandler([{ + bindKey: "Esc", + name: "closeSearchBar", + exec: function (editor) { + editor.searchBox.hide(); + } + }]); + this.$searchBarKb = new HashHandler(); + this.$searchBarKb.bindKeys({ + "Ctrl-f|Command-f": function (sb) { + var isReplace = sb.isReplace = !sb.isReplace; + sb.replaceBox.style.display = isReplace ? "" : "none"; + sb.replaceOption.checked = false; + sb.$syncOptions(); + sb.searchInput.focus(); + }, + "Ctrl-H|Command-Option-F": function (sb) { + if (sb.editor.getReadOnly()) + return; + sb.replaceOption.checked = true; + sb.$syncOptions(); + sb.replaceInput.focus(); + }, + "Ctrl-G|Command-G": function (sb) { + sb.findNext(); + }, + "Ctrl-Shift-G|Command-Shift-G": function (sb) { + sb.findPrev(); + }, + "esc": function (sb) { + setTimeout(function () { sb.hide(); }); + }, + "Return": function (sb) { + if (sb.activeInput == sb.replaceInput) + sb.replace(); + sb.findNext(); + }, + "Shift-Return": function (sb) { + if (sb.activeInput == sb.replaceInput) + sb.replace(); + sb.findPrev(); + }, + "Alt-Return": function (sb) { + if (sb.activeInput == sb.replaceInput) + sb.replaceAll(); + sb.findAll(); + }, + "Tab": function (sb) { + (sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus(); + } + }); + this.$searchBarKb.addCommands([{ + name: "toggleRegexpMode", + bindKey: { win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/" }, + exec: function (sb) { + sb.regExpOption.checked = !sb.regExpOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleCaseSensitive", + bindKey: { win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I" }, + exec: function (sb) { + sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleWholeWords", + bindKey: { win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W" }, + exec: function (sb) { + sb.wholeWordOption.checked = !sb.wholeWordOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleReplace", + exec: function (sb) { + sb.replaceOption.checked = !sb.replaceOption.checked; + sb.$syncOptions(); + } + }, { + name: "searchInSelection", + exec: function (sb) { + sb.searchOption.checked = !sb.searchRange; + sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange()); + sb.$syncOptions(); + } + }]); + this.setSearchRange = function (range) { + this.searchRange = range; + if (range) { + this.searchRangeMarker = this.editor.session.addMarker(range, "ace_active-line"); + } + else if (this.searchRangeMarker) { + this.editor.session.removeMarker(this.searchRangeMarker); + this.searchRangeMarker = null; + } + }; + this.$syncOptions = function (preventScroll) { + dom.setCssClass(this.replaceOption, "checked", this.searchRange); + dom.setCssClass(this.searchOption, "checked", this.searchOption.checked); + this.replaceOption.textContent = this.replaceOption.checked ? "-" : "+"; + dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked); + dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked); + dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked); + var readOnly = this.editor.getReadOnly(); + this.replaceOption.style.display = readOnly ? "none" : ""; + this.replaceBox.style.display = this.replaceOption.checked && !readOnly ? "" : "none"; + this.find(false, false, preventScroll); + }; + this.highlight = function (re) { + this.editor.session.highlight(re || this.editor.$search.$options.re); + this.editor.renderer.updateBackMarkers(); + }; + this.find = function (skipCurrent, backwards, preventScroll) { + var range = this.editor.find(this.searchInput.value, { + skipCurrent: skipCurrent, + backwards: backwards, + wrap: true, + regExp: this.regExpOption.checked, + caseSensitive: this.caseSensitiveOption.checked, + wholeWord: this.wholeWordOption.checked, + preventScroll: preventScroll, + range: this.searchRange + }); + var noMatch = !range && this.searchInput.value; + dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); + this.editor._emit("findSearchBox", { match: !noMatch }); + this.highlight(); + this.updateCounter(); + }; + this.updateCounter = function () { + var editor = this.editor; + var regex = editor.$search.$options.re; + var all = 0; + var before = 0; + if (regex) { + var value = this.searchRange + ? editor.session.getTextRange(this.searchRange) + : editor.getValue(); + var offset = editor.session.doc.positionToIndex(editor.selection.anchor); + if (this.searchRange) + offset -= editor.session.doc.positionToIndex(this.searchRange.start); + var last = regex.lastIndex = 0; + var m; + while ((m = regex.exec(value))) { + all++; + last = m.index; + if (last <= offset) + before++; + if (all > MAX_COUNT) + break; + if (!m[0]) { + regex.lastIndex = last += 1; + if (last >= value.length) + break; + } + } + } + this.searchCounter.textContent = before + " of " + (all > MAX_COUNT ? MAX_COUNT + "+" : all); + }; + this.findNext = function () { + this.find(true, false); + }; + this.findPrev = function () { + this.find(true, true); + }; + this.findAll = function () { + var range = this.editor.findAll(this.searchInput.value, { + regExp: this.regExpOption.checked, + caseSensitive: this.caseSensitiveOption.checked, + wholeWord: this.wholeWordOption.checked + }); + var noMatch = !range && this.searchInput.value; + dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); + this.editor._emit("findSearchBox", { match: !noMatch }); + this.highlight(); + this.hide(); + }; + this.replace = function () { + if (!this.editor.getReadOnly()) + this.editor.replace(this.replaceInput.value); + }; + this.replaceAndFindNext = function () { + if (!this.editor.getReadOnly()) { + this.editor.replace(this.replaceInput.value); + this.findNext(); + } + }; + this.replaceAll = function () { + if (!this.editor.getReadOnly()) + this.editor.replaceAll(this.replaceInput.value); + }; + this.hide = function () { + this.active = false; + this.setSearchRange(null); + this.editor.off("changeSession", this.setSession); + this.element.style.display = "none"; + this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb); + this.editor.focus(); + }; + this.show = function (value, isReplace) { + this.active = true; + this.editor.on("changeSession", this.setSession); + this.element.style.display = ""; + this.replaceOption.checked = isReplace; + if (value) + this.searchInput.value = value; + this.searchInput.focus(); + this.searchInput.select(); + this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb); + this.$syncOptions(true); + }; + this.isFocused = function () { + var el = document.activeElement; + return el == this.searchInput || el == this.replaceInput; + }; +}).call(SearchBox.prototype); +exports.SearchBox = SearchBox; +exports.Search = function (editor, isReplace) { + var sb = editor.searchBox || new SearchBox(editor); + sb.show(editor.session.getTextRange(), isReplace); +}; + +}); + (function() { + window.require(["ace/ext/searchbox"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-settings_menu.js b/src/main/resources/static/assets/js/vendor/template/src/ext-settings_menu.js new file mode 100644 index 0000000..627787f --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-settings_menu.js @@ -0,0 +1,754 @@ +define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"; + +}); + +define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("./settings_menu.css"); +dom.importCssString(cssText, "settings_menu.css", false); +module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { + var closer = document.createElement('div'); + var ignoreFocusOut = false; + function documentEscListener(e) { + if (e.keyCode === 27) { + close(); + } + } + function close() { + if (!closer) + return; + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + if (editor) { + editor.focus(); + } + closer = null; + callback && callback(); + } + function setIgnoreFocusOut(ignore) { + ignoreFocusOut = ignore; + if (ignore) { + closer.style.pointerEvents = "none"; + contentElement.style.pointerEvents = "auto"; + } + } + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : ''); + closer.addEventListener('click', function (e) { + if (!ignoreFocusOut) { + close(); + } + }); + document.addEventListener('keydown', documentEscListener); + contentElement.addEventListener('click', function (e) { + e.stopPropagation(); + }); + closer.appendChild(contentElement); + document.body.appendChild(closer); + if (editor) { + editor.blur(); + } + return { + close: close, + setIgnoreFocusOut: setIgnoreFocusOut + }; +}; + +}); + +define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict"; +var modes = []; +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} +var Mode = function (name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function (a, b) { + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } + else { + re = "^.*\\.(" + extensions + ")$"; + } + this.extRe = new RegExp(re, "gi"); +}; +Mode.prototype.supportsFile = function (filename) { + return filename.match(this.extRe); +}; +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript: ["as"], + ADA: ["ada|adb"], + Alda: ["alda"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + Apex: ["apex|cls|trigger|tgr"], + AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86: ["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + Crystal: ["cr"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Edifact: ["edi"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FSharp: ["fsi|fs|ml|mli|fsx|fsscript"], + FSL: ["fsl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Ion: ["ion"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx|cjs|mjs"], + JSON: ["json"], + JSON5: ["json5"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + Log: ["log"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], + MEL: ["mel"], + MIPS: ["s|asm"], + MIXAL: ["mixal"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nginx: ["nginx|conf"], + Nim: ["nim"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + Nunjucks: ["nunjucks|nunjs|nj|njk"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + PartiQL: ["partiql|pql"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP_Laravel_blade: ["blade.php"], + PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Puppet: ["epp|pp"], + Python: ["py"], + QML: ["qml"], + R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + Robot: ["robot|resource"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SaC: ["sac"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala|sbt"], + Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Slim: ["slim|skim"], + Smarty: ["smarty|tpl"], + Smithy: ["smithy"], + snippets: ["snippets"], + Soy_Template: ["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Terraform: ["tf", "tfvars", "terragrunt"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Visualforce: ["vfp|component|page"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + YAML: ["yaml|yml"], + Zeek: ["zeek|bro"], + Django: ["html"] +}; +var nameOverrides = { + ObjectiveC: "Objective-C", + CSharp: "C#", + golang: "Go", + C_Cpp: "C and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker", + PHP_Laravel_blade: "PHP (Blade Template)", + Perl6: "Perl 6", + AutoHotKey: "AutoHotkey / AutoIt" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); + +define("ace/ext/themelist",["require","exports","module"], function(require, exports, module){/** + * Generates a list of themes available when ace was built. + * @fileOverview Generates a list of themes available when ace was built. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ +"use strict"; +var themeData = [ + ["Chrome"], + ["Clouds"], + ["Crimson Editor"], + ["Dawn"], + ["Dreamweaver"], + ["Eclipse"], + ["GitHub"], + ["IPlastic"], + ["Solarized Light"], + ["TextMate"], + ["Tomorrow"], + ["XCode"], + ["Kuroir"], + ["KatzenMilch"], + ["SQL Server", "sqlserver", "light"], + ["Ambiance", "ambiance", "dark"], + ["Chaos", "chaos", "dark"], + ["Clouds Midnight", "clouds_midnight", "dark"], + ["Dracula", "", "dark"], + ["Cobalt", "cobalt", "dark"], + ["Gruvbox", "gruvbox", "dark"], + ["Green on Black", "gob", "dark"], + ["idle Fingers", "idle_fingers", "dark"], + ["krTheme", "kr_theme", "dark"], + ["Merbivore", "merbivore", "dark"], + ["Merbivore Soft", "merbivore_soft", "dark"], + ["Mono Industrial", "mono_industrial", "dark"], + ["Monokai", "monokai", "dark"], + ["Nord Dark", "nord_dark", "dark"], + ["One Dark", "one_dark", "dark"], + ["Pastel on dark", "pastel_on_dark", "dark"], + ["Solarized Dark", "solarized_dark", "dark"], + ["Terminal", "terminal", "dark"], + ["Tomorrow Night", "tomorrow_night", "dark"], + ["Tomorrow Night Blue", "tomorrow_night_blue", "dark"], + ["Tomorrow Night Bright", "tomorrow_night_bright", "dark"], + ["Tomorrow Night 80s", "tomorrow_night_eighties", "dark"], + ["Twilight", "twilight", "dark"], + ["Vibrant Ink", "vibrant_ink", "dark"] +]; +exports.themesByName = {}; +exports.themes = themeData.map(function (data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; +}); + +}); + +define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module){"use strict"; +require("./menu_tools/overlay_page"); +var dom = require("../lib/dom"); +var oop = require("../lib/oop"); +var config = require("../config"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; +var buildDom = dom.buildDom; +var modelist = require("./modelist"); +var themelist = require("./themelist"); +var themes = { Bright: [], Dark: [] }; +themelist.themes.forEach(function (x) { + themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme }); +}); +var modes = modelist.modes.map(function (x) { + return { caption: x.caption, value: x.mode }; +}); +var optionGroups = { + Main: { + Mode: { + path: "mode", + type: "select", + items: modes + }, + Theme: { + path: "theme", + type: "select", + items: themes + }, + "Keybinding": { + type: "buttonBar", + path: "keyboardHandler", + items: [ + { caption: "Ace", value: null }, + { caption: "Vim", value: "ace/keyboard/vim" }, + { caption: "Emacs", value: "ace/keyboard/emacs" }, + { caption: "Sublime", value: "ace/keyboard/sublime" }, + { caption: "VSCode", value: "ace/keyboard/vscode" } + ] + }, + "Font Size": { + path: "fontSize", + type: "number", + defaultValue: 12, + defaults: [ + { caption: "12px", value: 12 }, + { caption: "24px", value: 24 } + ] + }, + "Soft Wrap": { + type: "buttonBar", + path: "wrap", + items: [ + { caption: "Off", value: "off" }, + { caption: "View", value: "free" }, + { caption: "margin", value: "printMargin" }, + { caption: "40", value: "40" } + ] + }, + "Cursor Style": { + path: "cursorStyle", + items: [ + { caption: "Ace", value: "ace" }, + { caption: "Slim", value: "slim" }, + { caption: "Smooth", value: "smooth" }, + { caption: "Smooth And Slim", value: "smooth slim" }, + { caption: "Wide", value: "wide" } + ] + }, + "Folding": { + path: "foldStyle", + items: [ + { caption: "Manual", value: "manual" }, + { caption: "Mark begin", value: "markbegin" }, + { caption: "Mark begin and end", value: "markbeginend" } + ] + }, + "Soft Tabs": [{ + path: "useSoftTabs" + }, { + ariaLabel: "Tab Size", + path: "tabSize", + type: "number", + values: [2, 3, 4, 8, 16] + }], + "Overscroll": { + type: "buttonBar", + path: "scrollPastEnd", + items: [ + { caption: "None", value: 0 }, + { caption: "Half", value: 0.5 }, + { caption: "Full", value: 1 } + ] + } + }, + More: { + "Atomic soft tabs": { + path: "navigateWithinSoftTabs" + }, + "Enable Behaviours": { + path: "behavioursEnabled" + }, + "Wrap with quotes": { + path: "wrapBehavioursEnabled" + }, + "Enable Auto Indent": { + path: "enableAutoIndent" + }, + "Full Line Selection": { + type: "checkbox", + values: "text|line", + path: "selectionStyle" + }, + "Highlight Active Line": { + path: "highlightActiveLine" + }, + "Show Invisibles": { + path: "showInvisibles" + }, + "Show Indent Guides": { + path: "displayIndentGuides" + }, + "Highlight Indent Guides": { + path: "highlightIndentGuides" + }, + "Persistent HScrollbar": { + path: "hScrollBarAlwaysVisible" + }, + "Persistent VScrollbar": { + path: "vScrollBarAlwaysVisible" + }, + "Animate scrolling": { + path: "animatedScroll" + }, + "Show Gutter": { + path: "showGutter" + }, + "Show Line Numbers": { + path: "showLineNumbers" + }, + "Relative Line Numbers": { + path: "relativeLineNumbers" + }, + "Fixed Gutter Width": { + path: "fixedWidthGutter" + }, + "Show Print Margin": [{ + path: "showPrintMargin" + }, { + ariaLabel: "Print Margin", + type: "number", + path: "printMarginColumn" + }], + "Indented Soft Wrap": { + path: "indentedSoftWrap" + }, + "Highlight selected word": { + path: "highlightSelectedWord" + }, + "Fade Fold Widgets": { + path: "fadeFoldWidgets" + }, + "Use textarea for IME": { + path: "useTextareaForIME" + }, + "Merge Undo Deltas": { + path: "mergeUndoDeltas", + items: [ + { caption: "Always", value: "always" }, + { caption: "Never", value: "false" }, + { caption: "Timed", value: "true" } + ] + }, + "Elastic Tabstops": { + path: "useElasticTabstops" + }, + "Incremental Search": { + path: "useIncrementalSearch" + }, + "Read-only": { + path: "readOnly" + }, + "Copy without selection": { + path: "copyWithEmptySelection" + }, + "Live Autocompletion": { + path: "enableLiveAutocompletion" + }, + "Custom scrollbar": { + path: "customScrollbar" + } + } +}; +var OptionPanel = function (editor, element) { + this.editor = editor; + this.container = element || document.createElement("div"); + this.groups = []; + this.options = {}; +}; +(function () { + oop.implement(this, EventEmitter); + this.add = function (config) { + if (config.Main) + oop.mixin(optionGroups.Main, config.Main); + if (config.More) + oop.mixin(optionGroups.More, config.More); + }; + this.render = function () { + this.container.innerHTML = ""; + buildDom(["table", { role: "presentation", id: "controls" }, + this.renderOptionGroup(optionGroups.Main), + ["tr", null, ["td", { colspan: 2 }, + ["table", { role: "presentation", id: "more-controls" }, + this.renderOptionGroup(optionGroups.More) + ] + ]], + ["tr", null, ["td", { colspan: 2 }, "version " + config.version]] + ], this.container); + }; + this.renderOptionGroup = function (group) { + return Object.keys(group).map(function (key, i) { + var item = group[key]; + if (!item.position) + item.position = i / 10000; + if (!item.label) + item.label = key; + return item; + }).sort(function (a, b) { + return a.position - b.position; + }).map(function (item) { + return this.renderOption(item.label, item); + }, this); + }; + this.renderOptionControl = function (key, option) { + var self = this; + if (Array.isArray(option)) { + return option.map(function (x) { + return self.renderOptionControl(key, x); + }); + } + var control; + var value = self.getOption(option); + if (option.values && option.type != "checkbox") { + if (typeof option.values == "string") + option.values = option.values.split("|"); + option.items = option.values.map(function (v) { + return { value: v, name: v }; + }); + } + if (option.type == "buttonBar") { + control = ["div", { role: "group", "aria-labelledby": option.path + "-label" }, option.items.map(function (item) { + return ["button", { + value: item.value, + ace_selected_button: value == item.value, + 'aria-pressed': value == item.value, + onclick: function () { + self.setOption(option, item.value); + var nodes = this.parentNode.querySelectorAll("[ace_selected_button]"); + for (var i = 0; i < nodes.length; i++) { + nodes[i].removeAttribute("ace_selected_button"); + nodes[i].setAttribute("aria-pressed", false); + } + this.setAttribute("ace_selected_button", true); + this.setAttribute("aria-pressed", true); + } + }, item.desc || item.caption || item.name]; + })]; + } + else if (option.type == "number") { + control = ["input", { type: "number", value: value || option.defaultValue, style: "width:3em", oninput: function () { + self.setOption(option, parseInt(this.value)); + } }]; + if (option.ariaLabel) { + control[1]["aria-label"] = option.ariaLabel; + } + else { + control[1].id = key; + } + if (option.defaults) { + control = [control, option.defaults.map(function (item) { + return ["button", { onclick: function () { + var input = this.parentNode.firstChild; + input.value = item.value; + input.oninput(); + } }, item.caption]; + })]; + } + } + else if (option.items) { + var buildItems = function (items) { + return items.map(function (item) { + return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name]; + }); + }; + var items = Array.isArray(option.items) + ? buildItems(option.items) + : Object.keys(option.items).map(function (key) { + return ["optgroup", { "label": key }, buildItems(option.items[key])]; + }); + control = ["select", { id: key, value: value, onchange: function () { + self.setOption(option, this.value); + } }, items]; + } + else { + if (typeof option.values == "string") + option.values = option.values.split("|"); + if (option.values) + value = value == option.values[1]; + control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function () { + var value = this.checked; + if (option.values) + value = option.values[value ? 1 : 0]; + self.setOption(option, value); + } }]; + if (option.type == "checkedNumber") { + control = [control, []]; + } + } + return control; + }; + this.renderOption = function (key, option) { + if (option.path && !option.onchange && !this.editor.$options[option.path]) + return; + var path = Array.isArray(option) ? option[0].path : option.path; + this.options[path] = option; + var safeKey = "-" + path; + var safeId = path + "-label"; + var control = this.renderOptionControl(safeKey, option); + return ["tr", { class: "ace_optionsMenuEntry" }, ["td", + ["label", { for: safeKey, id: safeId }, key] + ], ["td", control]]; + }; + this.setOption = function (option, value) { + if (typeof option == "string") + option = this.options[option]; + if (value == "false") + value = false; + if (value == "true") + value = true; + if (value == "null") + value = null; + if (value == "undefined") + value = undefined; + if (typeof value == "string" && parseFloat(value).toString() == value) + value = parseFloat(value); + if (option.onchange) + option.onchange(value); + else if (option.path) + this.editor.setOption(option.path, value); + this._signal("setOption", { name: option.path, value: value }); + }; + this.getOption = function (option) { + if (option.getValue) + return option.getValue(); + return this.editor.getOption(option.path); + }; +}).call(OptionPanel.prototype); +exports.OptionPanel = OptionPanel; + +}); + +define("ace/ext/settings_menu",["require","exports","module","ace/ext/options","ace/ext/menu_tools/overlay_page","ace/editor"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +"use strict"; +var OptionPanel = require("./options").OptionPanel; +var overlayPage = require('./menu_tools/overlay_page').overlayPage; +function showSettingsMenu(editor) { + if (!document.getElementById('ace_settingsmenu')) { + var options = new OptionPanel(editor); + options.render(); + options.container.id = "ace_settingsmenu"; + overlayPage(editor, options.container); + options.container.querySelector("select,input,button,checkbox").focus(); + } +} +module.exports.init = function () { + var Editor = require("../editor").Editor; + Editor.prototype.showSettingsMenu = function () { + showSettingsMenu(this); + }; +}; + +}); + (function() { + window.require(["ace/ext/settings_menu"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-spellcheck.js b/src/main/resources/static/assets/js/vendor/template/src/ext-spellcheck.js new file mode 100644 index 0000000..8faef50 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-spellcheck.js @@ -0,0 +1,68 @@ +define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"], function(require, exports, module){"use strict"; +var event = require("../lib/event"); +exports.contextMenuHandler = function (e) { + var host = e.target; + var text = host.textInput.getElement(); + if (!host.selection.isEmpty()) + return; + var c = host.getCursorPosition(); + var r = host.session.getWordRange(c.row, c.column); + var w = host.session.getTextRange(r); + host.session.tokenRe.lastIndex = 0; + if (!host.session.tokenRe.test(w)) + return; + var PLACEHOLDER = "\x01\x01"; + var value = w + " " + PLACEHOLDER; + text.value = value; + text.setSelectionRange(w.length, w.length + 1); + text.setSelectionRange(0, 0); + text.setSelectionRange(0, w.length); + var afterKeydown = false; + event.addListener(text, "keydown", function onKeydown() { + event.removeListener(text, "keydown", onKeydown); + afterKeydown = true; + }); + host.textInput.setInputHandler(function (newVal) { + if (newVal == value) + return ''; + if (newVal.lastIndexOf(value, 0) === 0) + return newVal.slice(value.length); + if (newVal.substr(text.selectionEnd) == value) + return newVal.slice(0, -value.length); + if (newVal.slice(-2) == PLACEHOLDER) { + var val = newVal.slice(0, -2); + if (val.slice(-1) == " ") { + if (afterKeydown) + return val.substring(0, text.selectionEnd); + val = val.slice(0, -1); + host.session.replace(r, val); + return ""; + } + } + return newVal; + }); +}; +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + spellcheck: { + set: function (val) { + var text = this.textInput.getElement(); + text.spellcheck = !!val; + if (!val) + this.removeListener("nativecontextmenu", exports.contextMenuHandler); + else + this.on("nativecontextmenu", exports.contextMenuHandler); + }, + value: true + } +}); + +}); + (function() { + window.require(["ace/ext/spellcheck"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-split.js b/src/main/resources/static/assets/js/vendor/template/src/ext-split.js new file mode 100644 index 0000000..e4571d5 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-split.js @@ -0,0 +1,186 @@ +define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"], function(require, exports, module){"use strict"; +var oop = require("./lib/oop"); +var lang = require("./lib/lang"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var Editor = require("./editor").Editor; +var Renderer = require("./virtual_renderer").VirtualRenderer; +var EditSession = require("./edit_session").EditSession; +var Split = function (container, theme, splits) { + this.BELOW = 1; + this.BESIDE = 0; + this.$container = container; + this.$theme = theme; + this.$splits = 0; + this.$editorCSS = ""; + this.$editors = []; + this.$orientation = this.BESIDE; + this.setSplits(splits || 1); + this.$cEditor = this.$editors[0]; + this.on("focus", function (editor) { + this.$cEditor = editor; + }.bind(this)); +}; +(function () { + oop.implement(this, EventEmitter); + this.$createEditor = function () { + var el = document.createElement("div"); + el.className = this.$editorCSS; + el.style.cssText = "position: absolute; top:0px; bottom:0px"; + this.$container.appendChild(el); + var editor = new Editor(new Renderer(el, this.$theme)); + editor.on("focus", function () { + this._emit("focus", editor); + }.bind(this)); + this.$editors.push(editor); + editor.setFontSize(this.$fontSize); + return editor; + }; + this.setSplits = function (splits) { + var editor; + if (splits < 1) { + throw "The number of splits have to be > 0!"; + } + if (splits == this.$splits) { + return; + } + else if (splits > this.$splits) { + while (this.$splits < this.$editors.length && this.$splits < splits) { + editor = this.$editors[this.$splits]; + this.$container.appendChild(editor.container); + editor.setFontSize(this.$fontSize); + this.$splits++; + } + while (this.$splits < splits) { + this.$createEditor(); + this.$splits++; + } + } + else { + while (this.$splits > splits) { + editor = this.$editors[this.$splits - 1]; + this.$container.removeChild(editor.container); + this.$splits--; + } + } + this.resize(); + }; + this.getSplits = function () { + return this.$splits; + }; + this.getEditor = function (idx) { + return this.$editors[idx]; + }; + this.getCurrentEditor = function () { + return this.$cEditor; + }; + this.focus = function () { + this.$cEditor.focus(); + }; + this.blur = function () { + this.$cEditor.blur(); + }; + this.setTheme = function (theme) { + this.$editors.forEach(function (editor) { + editor.setTheme(theme); + }); + }; + this.setKeyboardHandler = function (keybinding) { + this.$editors.forEach(function (editor) { + editor.setKeyboardHandler(keybinding); + }); + }; + this.forEach = function (callback, scope) { + this.$editors.forEach(callback, scope); + }; + this.$fontSize = ""; + this.setFontSize = function (size) { + this.$fontSize = size; + this.forEach(function (editor) { + editor.setFontSize(size); + }); + }; + this.$cloneSession = function (session) { + var s = new EditSession(session.getDocument(), session.getMode()); + var undoManager = session.getUndoManager(); + s.setUndoManager(undoManager); + s.setTabSize(session.getTabSize()); + s.setUseSoftTabs(session.getUseSoftTabs()); + s.setOverwrite(session.getOverwrite()); + s.setBreakpoints(session.getBreakpoints()); + s.setUseWrapMode(session.getUseWrapMode()); + s.setUseWorker(session.getUseWorker()); + s.setWrapLimitRange(session.$wrapLimitRange.min, session.$wrapLimitRange.max); + s.$foldData = session.$cloneFoldData(); + return s; + }; + this.setSession = function (session, idx) { + var editor; + if (idx == null) { + editor = this.$cEditor; + } + else { + editor = this.$editors[idx]; + } + var isUsed = this.$editors.some(function (editor) { + return editor.session === session; + }); + if (isUsed) { + session = this.$cloneSession(session); + } + editor.setSession(session); + return session; + }; + this.getOrientation = function () { + return this.$orientation; + }; + this.setOrientation = function (orientation) { + if (this.$orientation == orientation) { + return; + } + this.$orientation = orientation; + this.resize(); + }; + this.resize = function () { + var width = this.$container.clientWidth; + var height = this.$container.clientHeight; + var editor; + if (this.$orientation == this.BESIDE) { + var editorWidth = width / this.$splits; + for (var i = 0; i < this.$splits; i++) { + editor = this.$editors[i]; + editor.container.style.width = editorWidth + "px"; + editor.container.style.top = "0px"; + editor.container.style.left = i * editorWidth + "px"; + editor.container.style.height = height + "px"; + editor.resize(); + } + } + else { + var editorHeight = height / this.$splits; + for (var i = 0; i < this.$splits; i++) { + editor = this.$editors[i]; + editor.container.style.width = width + "px"; + editor.container.style.top = i * editorHeight + "px"; + editor.container.style.left = "0px"; + editor.container.style.height = editorHeight + "px"; + editor.resize(); + } + } + }; +}).call(Split.prototype); +exports.Split = Split; + +}); + +define("ace/ext/split",["require","exports","module","ace/split"], function(require, exports, module){"use strict"; +module.exports = require("../split"); + +}); + (function() { + window.require(["ace/ext/split"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-static_highlight.js b/src/main/resources/static/assets/js/vendor/template/src/ext-static_highlight.js new file mode 100644 index 0000000..d9be541 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-static_highlight.js @@ -0,0 +1,182 @@ +define("ace/ext/static.css",["require","exports","module"], function(require, exports, module){module.exports = ".ace_static_highlight {\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;\n font-size: 12px;\n white-space: pre-wrap\n}\n\n.ace_static_highlight .ace_gutter {\n width: 2em;\n text-align: right;\n padding: 0 3px 0 0;\n margin-right: 3px;\n contain: none;\n}\n\n.ace_static_highlight.ace_show_gutter .ace_line {\n padding-left: 2.6em;\n}\n\n.ace_static_highlight .ace_line { position: relative; }\n\n.ace_static_highlight .ace_gutter-cell {\n -moz-user-select: -moz-none;\n -khtml-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n top: 0;\n bottom: 0;\n left: 0;\n position: absolute;\n}\n\n\n.ace_static_highlight .ace_gutter-cell:before {\n content: counter(ace_line, decimal);\n counter-increment: ace_line;\n}\n.ace_static_highlight {\n counter-reset: ace_line;\n}\n"; + +}); + +define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/ext/static.css","ace/config","ace/lib/dom","ace/lib/lang"], function(require, exports, module){"use strict"; +var EditSession = require("../edit_session").EditSession; +var TextLayer = require("../layer/text").Text; +var baseStyles = require("./static.css"); +var config = require("../config"); +var dom = require("../lib/dom"); +var escapeHTML = require("../lib/lang").escapeHTML; +function Element(type) { + this.type = type; + this.style = {}; + this.textContent = ""; +} +Element.prototype.cloneNode = function () { + return this; +}; +Element.prototype.appendChild = function (child) { + this.textContent += child.toString(); +}; +Element.prototype.toString = function () { + var stringBuilder = []; + if (this.type != "fragment") { + stringBuilder.push("<", this.type); + if (this.className) + stringBuilder.push(" class='", this.className, "'"); + var styleStr = []; + for (var key in this.style) { + styleStr.push(key, ":", this.style[key]); + } + if (styleStr.length) + stringBuilder.push(" style='", styleStr.join(""), "'"); + stringBuilder.push(">"); + } + if (this.textContent) { + stringBuilder.push(this.textContent); + } + if (this.type != "fragment") { + stringBuilder.push(""); + } + return stringBuilder.join(""); +}; +var simpleDom = { + createTextNode: function (textContent, element) { + return escapeHTML(textContent); + }, + createElement: function (type) { + return new Element(type); + }, + createFragment: function () { + return new Element("fragment"); + } +}; +var SimpleTextLayer = function () { + this.config = {}; + this.dom = simpleDom; +}; +SimpleTextLayer.prototype = TextLayer.prototype; +var highlight = function (el, opts, callback) { + var m = el.className.match(/lang-(\w+)/); + var mode = opts.mode || m && ("ace/mode/" + m[1]); + if (!mode) + return false; + var theme = opts.theme || "ace/theme/textmate"; + var data = ""; + var nodes = []; + if (el.firstElementChild) { + var textLen = 0; + for (var i = 0; i < el.childNodes.length; i++) { + var ch = el.childNodes[i]; + if (ch.nodeType == 3) { + textLen += ch.data.length; + data += ch.data; + } + else { + nodes.push(textLen, ch); + } + } + } + else { + data = el.textContent; + if (opts.trim) + data = data.trim(); + } + highlight.render(data, mode, theme, opts.firstLineNumber, !opts.showGutter, function (highlighted) { + dom.importCssString(highlighted.css, "ace_highlight"); + el.innerHTML = highlighted.html; + var container = el.firstChild.firstChild; + for (var i = 0; i < nodes.length; i += 2) { + var pos = highlighted.session.doc.indexToPosition(nodes[i]); + var node = nodes[i + 1]; + var lineEl = container.children[pos.row]; + lineEl && lineEl.appendChild(node); + } + callback && callback(); + }); +}; +highlight.render = function (input, mode, theme, lineStart, disableGutter, callback) { + var waiting = 1; + var modeCache = EditSession.prototype.$modes; + if (typeof theme == "string") { + waiting++; + config.loadModule(['theme', theme], function (m) { + theme = m; + --waiting || done(); + }); + } + var modeOptions; + if (mode && typeof mode === "object" && !mode.getTokenizer) { + modeOptions = mode; + mode = modeOptions.path; + } + if (typeof mode == "string") { + waiting++; + config.loadModule(['mode', mode], function (m) { + if (!modeCache[mode] || modeOptions) + modeCache[mode] = new m.Mode(modeOptions); + mode = modeCache[mode]; + --waiting || done(); + }); + } + function done() { + var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter); + return callback ? callback(result) : result; + } + return --waiting || done(); +}; +highlight.renderSync = function (input, mode, theme, lineStart, disableGutter) { + lineStart = parseInt(lineStart || 1, 10); + var session = new EditSession(""); + session.setUseWorker(false); + session.setMode(mode); + var textLayer = new SimpleTextLayer(); + textLayer.setSession(session); + Object.keys(textLayer.$tabStrings).forEach(function (k) { + if (typeof textLayer.$tabStrings[k] == "string") { + var el = simpleDom.createFragment(); + el.textContent = textLayer.$tabStrings[k]; + textLayer.$tabStrings[k] = el; + } + }); + session.setValue(input); + var length = session.getLength(); + var outerEl = simpleDom.createElement("div"); + outerEl.className = theme.cssClass; + var innerEl = simpleDom.createElement("div"); + innerEl.className = "ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter"); + innerEl.style["counter-reset"] = "ace_line " + (lineStart - 1); + for (var ix = 0; ix < length; ix++) { + var lineEl = simpleDom.createElement("div"); + lineEl.className = "ace_line"; + if (!disableGutter) { + var gutterEl = simpleDom.createElement("span"); + gutterEl.className = "ace_gutter ace_gutter-cell"; + gutterEl.textContent = ""; + lineEl.appendChild(gutterEl); + } + textLayer.$renderLine(lineEl, ix, false); + lineEl.textContent += "\n"; + innerEl.appendChild(lineEl); + } + outerEl.appendChild(innerEl); + return { + css: baseStyles + theme.cssText, + html: outerEl.toString(), + session: session + }; +}; +module.exports = highlight; +module.exports.highlight = highlight; + +}); + (function() { + window.require(["ace/ext/static_highlight"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-statusbar.js b/src/main/resources/static/assets/js/vendor/template/src/ext-statusbar.js new file mode 100644 index 0000000..35e0bc3 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-statusbar.js @@ -0,0 +1,48 @@ +define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"], function(require, exports, module){"use strict"; +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var StatusBar = function (editor, parentNode) { + this.element = dom.createElement("div"); + this.element.className = "ace_status-indicator"; + this.element.style.cssText = "display: inline-block;"; + parentNode.appendChild(this.element); + var statusUpdate = lang.delayedCall(function () { + this.updateStatus(editor); + }.bind(this)).schedule.bind(null, 100); + editor.on("changeStatus", statusUpdate); + editor.on("changeSelection", statusUpdate); + editor.on("keyboardActivity", statusUpdate); +}; +(function () { + this.updateStatus = function (editor) { + var status = []; + function add(str, separator) { + str && status.push(str, separator || "|"); + } + add(editor.keyBinding.getStatusText(editor)); + if (editor.commands.recording) + add("REC"); + var sel = editor.selection; + var c = sel.lead; + if (!sel.isEmpty()) { + var r = editor.getSelectionRange(); + add("(" + (r.end.row - r.start.row) + ":" + (r.end.column - r.start.column) + ")", " "); + } + add(c.row + ":" + c.column, " "); + if (sel.rangeCount) + add("[" + sel.rangeCount + "]", " "); + status.pop(); + this.element.textContent = status.join(""); + }; +}).call(StatusBar.prototype); +exports.StatusBar = StatusBar; + +}); + (function() { + window.require(["ace/ext/statusbar"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-textarea.js b/src/main/resources/static/assets/js/vendor/template/src/ext-textarea.js new file mode 100644 index 0000000..5b52867 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-textarea.js @@ -0,0 +1,389 @@ +define("ace/ext/textarea",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/net","ace/ace"], function(require, exports, module){"use strict"; +var event = require("../lib/event"); +var UA = require("../lib/useragent"); +var net = require("../lib/net"); +var ace = require("../ace"); +module.exports = exports = ace; +var getCSSProperty = function (element, container, property) { + var ret = element.style[property]; + if (!ret) { + if (window.getComputedStyle) { + ret = window.getComputedStyle(element, '').getPropertyValue(property); + } + else { + ret = element.currentStyle[property]; + } + } + if (!ret || ret == 'auto' || ret == 'intrinsic') { + ret = container.style[property]; + } + return ret; +}; +function applyStyles(elm, styles) { + for (var style in styles) { + elm.style[style] = styles[style]; + } +} +function setupContainer(element, getValue) { + if (element.type != 'textarea') { + throw new Error("Textarea required!"); + } + var parentNode = element.parentNode; + var container = document.createElement('div'); + var resizeEvent = function () { + var style = 'position:relative;'; + [ + 'margin-top', 'margin-left', 'margin-right', 'margin-bottom' + ].forEach(function (item) { + style += item + ':' + + getCSSProperty(element, container, item) + ';'; + }); + var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px"); + var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px"); + style += 'height:' + height + ';width:' + width + ';'; + style += 'display:inline-block;'; + container.setAttribute('style', style); + }; + event.addListener(window, 'resize', resizeEvent); + resizeEvent(); + parentNode.insertBefore(container, element.nextSibling); + while (parentNode !== document) { + if (parentNode.tagName.toUpperCase() === 'FORM') { + var oldSumit = parentNode.onsubmit; + parentNode.onsubmit = function (evt) { + element.value = getValue(); + if (oldSumit) { + oldSumit.call(this, evt); + } + }; + break; + } + parentNode = parentNode.parentNode; + } + return container; +} +exports.transformTextarea = function (element, options) { + var isFocused = element.autofocus || document.activeElement == element; + var session; + var container = setupContainer(element, function () { + return session.getValue(); + }); + element.style.display = 'none'; + container.style.background = 'white'; + var editorDiv = document.createElement("div"); + applyStyles(editorDiv, { + top: "0px", + left: "0px", + right: "0px", + bottom: "0px", + border: "1px solid gray", + position: "absolute" + }); + container.appendChild(editorDiv); + var settingOpener = document.createElement("div"); + applyStyles(settingOpener, { + position: "absolute", + right: "0px", + bottom: "0px", + cursor: "nw-resize", + border: "solid 9px", + borderColor: "lightblue gray gray #ceade6", + zIndex: 101 + }); + var settingDiv = document.createElement("div"); + var settingDivStyles = { + top: "0px", + left: "20%", + right: "0px", + bottom: "0px", + position: "absolute", + padding: "5px", + zIndex: 100, + color: "white", + display: "none", + overflow: "auto", + fontSize: "14px", + boxShadow: "-5px 2px 3px gray" + }; + if (!UA.isOldIE) { + settingDivStyles.backgroundColor = "rgba(0, 0, 0, 0.6)"; + } + else { + settingDivStyles.backgroundColor = "#333"; + } + applyStyles(settingDiv, settingDivStyles); + container.appendChild(settingDiv); + options = options || exports.defaultOptions; + var editor = ace.edit(editorDiv); + session = editor.getSession(); + session.setValue(element.value || element.innerHTML); + if (isFocused) + editor.focus(); + container.appendChild(settingOpener); + setupApi(editor, editorDiv, settingDiv, ace, options); + setupSettingPanel(settingDiv, settingOpener, editor); + var state = ""; + event.addListener(settingOpener, "mousemove", function (e) { + var rect = this.getBoundingClientRect(); + var x = e.clientX - rect.left, y = e.clientY - rect.top; + if (x + y < (rect.width + rect.height) / 2) { + this.style.cursor = "pointer"; + state = "toggle"; + } + else { + state = "resize"; + this.style.cursor = "nw-resize"; + } + }); + event.addListener(settingOpener, "mousedown", function (e) { + e.preventDefault(); + if (state == "toggle") { + editor.setDisplaySettings(); + return; + } + container.style.zIndex = 100000; + var rect = container.getBoundingClientRect(); + var startX = rect.width + rect.left - e.clientX; + var startY = rect.height + rect.top - e.clientY; + event.capture(settingOpener, function (e) { + container.style.width = e.clientX - rect.left + startX + "px"; + container.style.height = e.clientY - rect.top + startY + "px"; + editor.resize(); + }, function () { }); + }); + return editor; +}; +function load(url, module, callback) { + net.loadScript(url, function () { + require([module], callback); + }); +} +function setupApi(editor, editorDiv, settingDiv, ace, options) { + var session = editor.getSession(); + var renderer = editor.renderer; + function toBool(value) { + return value === "true" || value == true; + } + editor.setDisplaySettings = function (display) { + if (display == null) + display = settingDiv.style.display == "none"; + if (display) { + settingDiv.style.display = "block"; + settingDiv.hideButton.focus(); + editor.on("focus", function onFocus() { + editor.removeListener("focus", onFocus); + settingDiv.style.display = "none"; + }); + } + else { + editor.focus(); + } + }; + editor.$setOption = editor.setOption; + editor.$getOption = editor.getOption; + editor.setOption = function (key, value) { + switch (key) { + case "mode": + editor.$setOption("mode", "ace/mode/" + value); + break; + case "theme": + editor.$setOption("theme", "ace/theme/" + value); + break; + case "keybindings": + switch (value) { + case "vim": + editor.setKeyboardHandler("ace/keyboard/vim"); + break; + case "emacs": + editor.setKeyboardHandler("ace/keyboard/emacs"); + break; + default: + editor.setKeyboardHandler(null); + } + break; + case "wrap": + case "fontSize": + editor.$setOption(key, value); + break; + default: + editor.$setOption(key, toBool(value)); + } + }; + editor.getOption = function (key) { + switch (key) { + case "mode": + return editor.$getOption("mode").substr("ace/mode/".length); + break; + case "theme": + return editor.$getOption("theme").substr("ace/theme/".length); + break; + case "keybindings": + var value = editor.getKeyboardHandler(); + switch (value && value.$id) { + case "ace/keyboard/vim": + return "vim"; + case "ace/keyboard/emacs": + return "emacs"; + default: + return "ace"; + } + break; + default: + return editor.$getOption(key); + } + }; + editor.setOptions(options); + return editor; +} +function setupSettingPanel(settingDiv, settingOpener, editor) { + var BOOL = null; + var desc = { + mode: "Mode:", + wrap: "Soft Wrap:", + theme: "Theme:", + fontSize: "Font Size:", + showGutter: "Display Gutter:", + keybindings: "Keyboard", + showPrintMargin: "Show Print Margin:", + useSoftTabs: "Use Soft Tabs:", + showInvisibles: "Show Invisibles" + }; + var optionValues = { + mode: { + text: "Plain", + javascript: "JavaScript", + xml: "XML", + html: "HTML", + css: "CSS", + scss: "SCSS", + python: "Python", + php: "PHP", + java: "Java", + ruby: "Ruby", + c_cpp: "C/C++", + coffee: "CoffeeScript", + json: "json", + perl: "Perl", + clojure: "Clojure", + ocaml: "OCaml", + csharp: "C#", + haxe: "haXe", + svg: "SVG", + textile: "Textile", + groovy: "Groovy", + liquid: "Liquid", + Scala: "Scala" + }, + theme: { + clouds: "Clouds", + clouds_midnight: "Clouds Midnight", + cobalt: "Cobalt", + crimson_editor: "Crimson Editor", + dawn: "Dawn", + gob: "Green on Black", + eclipse: "Eclipse", + idle_fingers: "Idle Fingers", + kr_theme: "Kr Theme", + merbivore: "Merbivore", + merbivore_soft: "Merbivore Soft", + mono_industrial: "Mono Industrial", + monokai: "Monokai", + pastel_on_dark: "Pastel On Dark", + solarized_dark: "Solarized Dark", + solarized_light: "Solarized Light", + textmate: "Textmate", + twilight: "Twilight", + vibrant_ink: "Vibrant Ink" + }, + showGutter: BOOL, + fontSize: { + "10px": "10px", + "11px": "11px", + "12px": "12px", + "14px": "14px", + "16px": "16px" + }, + wrap: { + off: "Off", + 40: "40", + 80: "80", + free: "Free" + }, + keybindings: { + ace: "ace", + vim: "vim", + emacs: "emacs" + }, + showPrintMargin: BOOL, + useSoftTabs: BOOL, + showInvisibles: BOOL + }; + var table = []; + table.push(""); + function renderOption(builder, option, obj, cValue) { + if (!obj) { + builder.push(""); + return; + } + builder.push(""); + } + for (var option in exports.defaultOptions) { + table.push(""); + table.push(""); + } + table.push("
SettingValue
", desc[option], ""); + renderOption(table, option, optionValues[option], editor.getOption(option)); + table.push("
"); + settingDiv.innerHTML = table.join(""); + var onChange = function (e) { + var select = e.currentTarget; + editor.setOption(select.title, select.value); + }; + var onClick = function (e) { + var cb = e.currentTarget; + editor.setOption(cb.title, cb.checked); + }; + var selects = settingDiv.getElementsByTagName("select"); + for (var i = 0; i < selects.length; i++) + selects[i].onchange = onChange; + var cbs = settingDiv.getElementsByTagName("input"); + for (var i = 0; i < cbs.length; i++) + cbs[i].onclick = onClick; + var button = document.createElement("input"); + button.type = "button"; + button.value = "Hide"; + event.addListener(button, "click", function () { + editor.setDisplaySettings(false); + }); + settingDiv.appendChild(button); + settingDiv.hideButton = button; +} +exports.defaultOptions = { + mode: "javascript", + theme: "textmate", + wrap: "off", + fontSize: "12px", + showGutter: "false", + keybindings: "ace", + showPrintMargin: "false", + useSoftTabs: "true", + showInvisibles: "false" +}; + +}); + (function() { + window.require(["ace/ext/textarea"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-themelist.js b/src/main/resources/static/assets/js/vendor/template/src/ext-themelist.js new file mode 100644 index 0000000..4cf752d --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-themelist.js @@ -0,0 +1,71 @@ +define("ace/ext/themelist",["require","exports","module"], function(require, exports, module){/** + * Generates a list of themes available when ace was built. + * @fileOverview Generates a list of themes available when ace was built. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ +"use strict"; +var themeData = [ + ["Chrome"], + ["Clouds"], + ["Crimson Editor"], + ["Dawn"], + ["Dreamweaver"], + ["Eclipse"], + ["GitHub"], + ["IPlastic"], + ["Solarized Light"], + ["TextMate"], + ["Tomorrow"], + ["XCode"], + ["Kuroir"], + ["KatzenMilch"], + ["SQL Server", "sqlserver", "light"], + ["Ambiance", "ambiance", "dark"], + ["Chaos", "chaos", "dark"], + ["Clouds Midnight", "clouds_midnight", "dark"], + ["Dracula", "", "dark"], + ["Cobalt", "cobalt", "dark"], + ["Gruvbox", "gruvbox", "dark"], + ["Green on Black", "gob", "dark"], + ["idle Fingers", "idle_fingers", "dark"], + ["krTheme", "kr_theme", "dark"], + ["Merbivore", "merbivore", "dark"], + ["Merbivore Soft", "merbivore_soft", "dark"], + ["Mono Industrial", "mono_industrial", "dark"], + ["Monokai", "monokai", "dark"], + ["Nord Dark", "nord_dark", "dark"], + ["One Dark", "one_dark", "dark"], + ["Pastel on dark", "pastel_on_dark", "dark"], + ["Solarized Dark", "solarized_dark", "dark"], + ["Terminal", "terminal", "dark"], + ["Tomorrow Night", "tomorrow_night", "dark"], + ["Tomorrow Night Blue", "tomorrow_night_blue", "dark"], + ["Tomorrow Night Bright", "tomorrow_night_bright", "dark"], + ["Tomorrow Night 80s", "tomorrow_night_eighties", "dark"], + ["Twilight", "twilight", "dark"], + ["Vibrant Ink", "vibrant_ink", "dark"] +]; +exports.themesByName = {}; +exports.themes = themeData.map(function (data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; +}); + +}); + (function() { + window.require(["ace/ext/themelist"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/ext-whitespace.js b/src/main/resources/static/assets/js/vendor/template/src/ext-whitespace.js new file mode 100644 index 0000000..af3b0c5 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/ext-whitespace.js @@ -0,0 +1,193 @@ +define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"], function(require, exports, module){"use strict"; +var lang = require("../lib/lang"); +exports.$detectIndentation = function (lines, fallback) { + var stats = []; + var changes = []; + var tabIndents = 0; + var prevSpaces = 0; + var max = Math.min(lines.length, 1000); + for (var i = 0; i < max; i++) { + var line = lines[i]; + if (!/^\s*[^*+\-\s]/.test(line)) + continue; + if (line[0] == "\t") { + tabIndents++; + prevSpaces = -Number.MAX_VALUE; + } + else { + var spaces = line.match(/^ */)[0].length; + if (spaces && line[spaces] != "\t") { + var diff = spaces - prevSpaces; + if (diff > 0 && !(prevSpaces % diff) && !(spaces % diff)) + changes[diff] = (changes[diff] || 0) + 1; + stats[spaces] = (stats[spaces] || 0) + 1; + } + prevSpaces = spaces; + } + while (i < max && line[line.length - 1] == "\\") + line = lines[i++]; + } + function getScore(indent) { + var score = 0; + for (var i = indent; i < stats.length; i += indent) + score += stats[i] || 0; + return score; + } + var changesTotal = changes.reduce(function (a, b) { return a + b; }, 0); + var first = { score: 0, length: 0 }; + var spaceIndents = 0; + for (var i = 1; i < 12; i++) { + var score = getScore(i); + if (i == 1) { + spaceIndents = score; + score = stats[1] ? 0.9 : 0.8; + if (!stats.length) + score = 0; + } + else + score /= spaceIndents; + if (changes[i]) + score += changes[i] / changesTotal; + if (score > first.score) + first = { score: score, length: i }; + } + if (first.score && first.score > 1.4) + var tabLength = first.length; + if (tabIndents > spaceIndents + 1) { + if (tabLength == 1 || spaceIndents < tabIndents / 4 || first.score < 1.8) + tabLength = undefined; + return { ch: "\t", length: tabLength }; + } + if (spaceIndents > tabIndents + 1) + return { ch: " ", length: tabLength }; +}; +exports.detectIndentation = function (session) { + var lines = session.getLines(0, 1000); + var indent = exports.$detectIndentation(lines) || {}; + if (indent.ch) + session.setUseSoftTabs(indent.ch == " "); + if (indent.length) + session.setTabSize(indent.length); + return indent; +}; +exports.trimTrailingSpace = function (session, options) { + var doc = session.getDocument(); + var lines = doc.getAllLines(); + var min = options && options.trimEmpty ? -1 : 0; + var cursors = [], ci = -1; + if (options && options.keepCursorPosition) { + if (session.selection.rangeCount) { + session.selection.rangeList.ranges.forEach(function (x, i, ranges) { + var next = ranges[i + 1]; + if (next && next.cursor.row == x.cursor.row) + return; + cursors.push(x.cursor); + }); + } + else { + cursors.push(session.selection.getCursor()); + } + ci = 0; + } + var cursorRow = cursors[ci] && cursors[ci].row; + for (var i = 0, l = lines.length; i < l; i++) { + var line = lines[i]; + var index = line.search(/\s+$/); + if (i == cursorRow) { + if (index < cursors[ci].column && index > min) + index = cursors[ci].column; + ci++; + cursorRow = cursors[ci] ? cursors[ci].row : -1; + } + if (index > min) + doc.removeInLine(i, index, line.length); + } +}; +exports.convertIndentation = function (session, ch, len) { + var oldCh = session.getTabString()[0]; + var oldLen = session.getTabSize(); + if (!len) + len = oldLen; + if (!ch) + ch = oldCh; + var tab = ch == "\t" ? ch : lang.stringRepeat(ch, len); + var doc = session.doc; + var lines = doc.getAllLines(); + var cache = {}; + var spaceCache = {}; + for (var i = 0, l = lines.length; i < l; i++) { + var line = lines[i]; + var match = line.match(/^\s*/)[0]; + if (match) { + var w = session.$getStringScreenWidth(match)[0]; + var tabCount = Math.floor(w / oldLen); + var reminder = w % oldLen; + var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount)); + toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(" ", reminder)); + if (toInsert != match) { + doc.removeInLine(i, 0, match.length); + doc.insertInLine({ row: i, column: 0 }, toInsert); + } + } + } + session.setTabSize(len); + session.setUseSoftTabs(ch == " "); +}; +exports.$parseStringArg = function (text) { + var indent = {}; + if (/t/.test(text)) + indent.ch = "\t"; + else if (/s/.test(text)) + indent.ch = " "; + var m = text.match(/\d+/); + if (m) + indent.length = parseInt(m[0], 10); + return indent; +}; +exports.$parseArg = function (arg) { + if (!arg) + return {}; + if (typeof arg == "string") + return exports.$parseStringArg(arg); + if (typeof arg.text == "string") + return exports.$parseStringArg(arg.text); + return arg; +}; +exports.commands = [{ + name: "detectIndentation", + description: "Detect indentation from content", + exec: function (editor) { + exports.detectIndentation(editor.session); + } + }, { + name: "trimTrailingSpace", + description: "Trim trailing whitespace", + exec: function (editor, args) { + exports.trimTrailingSpace(editor.session, args); + } + }, { + name: "convertIndentation", + description: "Convert indentation to ...", + exec: function (editor, arg) { + var indent = exports.$parseArg(arg); + exports.convertIndentation(editor.session, indent.ch, indent.length); + } + }, { + name: "setIndentation", + description: "Set indentation", + exec: function (editor, arg) { + var indent = exports.$parseArg(arg); + indent.length && editor.session.setTabSize(indent.length); + indent.ch && editor.session.setUseSoftTabs(indent.ch == " "); + } + }]; + +}); + (function() { + window.require(["ace/ext/whitespace"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/edifact.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/edifact.js new file mode 100644 index 0000000..56740a7 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/edifact.js @@ -0,0 +1,17 @@ +define("ace/snippets/edifact.snippets",["require","exports","module"], function(require, exports, module){module.exports = "## Access Modifiers\nsnippet u\n\tUN\nsnippet un\n\tUNB\nsnippet pr\n\tprivate\n##\n## Annotations\nsnippet before\n\t@Before\n\tstatic void ${1:intercept}(${2:args}) { ${3} }\nsnippet mm\n\t@ManyToMany\n\t${1}\nsnippet mo\n\t@ManyToOne\n\t${1}\nsnippet om\n\t@OneToMany${1:(cascade=CascadeType.ALL)}\n\t${2}\nsnippet oo\n\t@OneToOne\n\t${1}\n##\n## Basic Java packages and import\nsnippet im\n\timport\nsnippet j.b\n\tjava.beans.\nsnippet j.i\n\tjava.io.\nsnippet j.m\n\tjava.math.\nsnippet j.n\n\tjava.net.\nsnippet j.u\n\tjava.util.\n##\n## Class\nsnippet cl\n\tclass ${1:`Filename(\"\", \"untitled\")`} ${2}\nsnippet in\n\tinterface ${1:`Filename(\"\", \"untitled\")`} ${2:extends Parent}${3}\nsnippet tc\n\tpublic class ${1:`Filename()`} extends ${2:TestCase}\n##\n## Class Enhancements\nsnippet ext\n\textends \nsnippet imp\n\timplements\n##\n## Comments\nsnippet /*\n\t/*\n\t * ${1}\n\t */\n##\n## Constants\nsnippet co\n\tstatic public final ${1:String} ${2:var} = ${3};${4}\nsnippet cos\n\tstatic public final String ${1:var} = \"${2}\";${3}\n##\n## Control Statements\nsnippet case\n\tcase ${1}:\n\t\t${2}\nsnippet def\n\tdefault:\n\t\t${2}\nsnippet el\n\telse\nsnippet elif\n\telse if (${1}) ${2}\nsnippet if\n\tif (${1}) ${2}\nsnippet sw\n\tswitch (${1}) {\n\t\t${2}\n\t}\n##\n## Create a Method\nsnippet m\n\t${1:void} ${2:method}(${3}) ${4:throws }${5}\n##\n## Create a Variable\nsnippet v\n\t${1:String} ${2:var}${3: = null}${4};${5}\n##\n## Enhancements to Methods, variables, classes, etc.\nsnippet ab\n\tabstract\nsnippet fi\n\tfinal\nsnippet st\n\tstatic\nsnippet sy\n\tsynchronized\n##\n## Error Methods\nsnippet err\n\tSystem.err.print(\"${1:Message}\");\nsnippet errf\n\tSystem.err.printf(\"${1:Message}\", ${2:exception});\nsnippet errln\n\tSystem.err.println(\"${1:Message}\");\n##\n## Exception Handling\nsnippet as\n\tassert ${1:test} : \"${2:Failure message}\";${3}\nsnippet ca\n\tcatch(${1:Exception} ${2:e}) ${3}\nsnippet thr\n\tthrow\nsnippet ths\n\tthrows\nsnippet try\n\ttry {\n\t\t${3}\n\t} catch(${1:Exception} ${2:e}) {\n\t}\nsnippet tryf\n\ttry {\n\t\t${3}\n\t} catch(${1:Exception} ${2:e}) {\n\t} finally {\n\t}\n##\n## Find Methods\nsnippet findall\n\tList<${1:listName}> ${2:items} = ${1}.findAll();${3}\nsnippet findbyid\n\t${1:var} ${2:item} = ${1}.findById(${3});${4}\n##\n## Javadocs\nsnippet /**\n\t/**\n\t * ${1}\n\t */\nsnippet @au\n\t@author `system(\"grep \\`id -un\\` /etc/passwd | cut -d \\\":\\\" -f5 | cut -d \\\",\\\" -f1\")`\nsnippet @br\n\t@brief ${1:Description}\nsnippet @fi\n\t@file ${1:`Filename()`}.java\nsnippet @pa\n\t@param ${1:param}\nsnippet @re\n\t@return ${1:param}\n##\n## Logger Methods\nsnippet debug\n\tLogger.debug(${1:param});${2}\nsnippet error\n\tLogger.error(${1:param});${2}\nsnippet info\n\tLogger.info(${1:param});${2}\nsnippet warn\n\tLogger.warn(${1:param});${2}\n##\n## Loops\nsnippet enfor\n\tfor (${1} : ${2}) ${3}\nsnippet for\n\tfor (${1}; ${2}; ${3}) ${4}\nsnippet wh\n\twhile (${1}) ${2}\n##\n## Main method\nsnippet main\n\tpublic static void main (String[] args) {\n\t\t${1:/* code */}\n\t}\n##\n## Print Methods\nsnippet print\n\tSystem.out.print(\"${1:Message}\");\nsnippet printf\n\tSystem.out.printf(\"${1:Message}\", ${2:args});\nsnippet println\n\tSystem.out.println(${1});\n##\n## Render Methods\nsnippet ren\n\trender(${1:param});${2}\nsnippet rena\n\trenderArgs.put(\"${1}\", ${2});${3}\nsnippet renb\n\trenderBinary(${1:param});${2}\nsnippet renj\n\trenderJSON(${1:param});${2}\nsnippet renx\n\trenderXml(${1:param});${2}\n##\n## Setter and Getter Methods\nsnippet set\n\t${1:public} void set${3:}(${2:String} ${4:}){\n\t\tthis.$4 = $4;\n\t}\nsnippet get\n\t${1:public} ${2:String} get${3:}(){\n\t\treturn this.${4:};\n\t}\n##\n## Terminate Methods or Loops\nsnippet re\n\treturn\nsnippet br\n\tbreak;\n##\n## Test Methods\nsnippet t\n\tpublic void test${1:Name}() throws Exception {\n\t\t${2}\n\t}\nsnippet test\n\t@Test\n\tpublic void test${1:Name}() throws Exception {\n\t\t${2}\n\t}\n##\n## Utils\nsnippet Sc\n\tScanner\n##\n## Miscellaneous\nsnippet action\n\tpublic static void ${1:index}(${2:args}) { ${3} }\nsnippet rnf\n\tnotFound(${1:param});${2}\nsnippet rnfin\n\tnotFoundIfNull(${1:param});${2}\nsnippet rr\n\tredirect(${1:param});${2}\nsnippet ru\n\tunauthorized(${1:param});${2}\nsnippet unless\n\t(unless=${1:param});${2}\n"; + +}); + +define("ace/snippets/edifact",["require","exports","module","ace/snippets/edifact.snippets"], function(require, exports, module){"use strict"; +exports.snippetText = require("./edifact.snippets"); +exports.scope = "edifact"; + +}); + (function() { + window.require(["ace/snippets/edifact"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/eiffel.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/eiffel.js new file mode 100644 index 0000000..0376642 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/eiffel.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/eiffel"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/ejs.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/ejs.js new file mode 100644 index 0000000..d733c66 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/ejs.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/ejs"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/elixir.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/elixir.js new file mode 100644 index 0000000..4d92731 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/elixir.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/elixir"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/elm.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/elm.js new file mode 100644 index 0000000..147f472 --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/elm.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/elm"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/erlang.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/erlang.js new file mode 100644 index 0000000..cc2e59a --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/erlang.js @@ -0,0 +1,17 @@ +define("ace/snippets/erlang.snippets",["require","exports","module"], function(require, exports, module){module.exports = "# module and export all\nsnippet mod\n\t-module(${1:`Filename('', 'my')`}).\n\t\n\t-compile([export_all]).\n\t\n\tstart() ->\n\t ${2}\n\t\n\tstop() ->\n\t ok.\n# define directive\nsnippet def\n\t-define(${1:macro}, ${2:body}).${3}\n# export directive\nsnippet exp\n\t-export([${1:function}/${2:arity}]).\n# include directive\nsnippet inc\n\t-include(\"${1:file}\").${2}\n# behavior directive\nsnippet beh\n\t-behaviour(${1:behaviour}).${2}\n# if expression\nsnippet if\n\tif\n\t ${1:guard} ->\n\t ${2:body}\n\tend\n# case expression\nsnippet case\n\tcase ${1:expression} of\n\t ${2:pattern} ->\n\t ${3:body};\n\tend\n# anonymous function\nsnippet fun\n\tfun (${1:Parameters}) -> ${2:body} end${3}\n# try...catch\nsnippet try\n\ttry\n\t ${1}\n\tcatch\n\t ${2:_:_} -> ${3:got_some_exception}\n\tend\n# record directive\nsnippet rec\n\t-record(${1:record}, {\n\t ${2:field}=${3:value}}).${4}\n# todo comment\nsnippet todo\n\t%% TODO: ${1}\n## Snippets below (starting with '%') are in EDoc format.\n## See http://www.erlang.org/doc/apps/edoc/chapter.html#id56887 for more details\n# doc comment\nsnippet %d\n\t%% @doc ${1}\n# end of doc comment\nsnippet %e\n\t%% @end\n# specification comment\nsnippet %s\n\t%% @spec ${1}\n# private function marker\nsnippet %p\n\t%% @private\n# OTP application\nsnippet application\n\t-module(${1:`Filename('', 'my')`}).\n\n\t-behaviour(application).\n\n\t-export([start/2, stop/1]).\n\n\tstart(_Type, _StartArgs) ->\n\t case ${2:root_supervisor}:start_link() of\n\t {ok, Pid} ->\n\t {ok, Pid};\n\t Other ->\n\t\t {error, Other}\n\t end.\n\n\tstop(_State) ->\n\t ok.\t\n# OTP supervisor\nsnippet supervisor\n\t-module(${1:`Filename('', 'my')`}).\n\n\t-behaviour(supervisor).\n\n\t%% API\n\t-export([start_link/0]).\n\n\t%% Supervisor callbacks\n\t-export([init/1]).\n\n\t-define(SERVER, ?MODULE).\n\n\tstart_link() ->\n\t supervisor:start_link({local, ?SERVER}, ?MODULE, []).\n\n\tinit([]) ->\n\t Server = {${2:my_server}, {$2, start_link, []},\n\t permanent, 2000, worker, [$2]},\n\t Children = [Server],\n\t RestartStrategy = {one_for_one, 0, 1},\n\t {ok, {RestartStrategy, Children}}.\n# OTP gen_server\nsnippet gen_server\n\t-module(${1:`Filename('', 'my')`}).\n\n\t-behaviour(gen_server).\n\n\t%% API\n\t-export([\n\t start_link/0\n\t ]).\n\n\t%% gen_server callbacks\n\t-export([init/1, handle_call/3, handle_cast/2, handle_info/2,\n\t terminate/2, code_change/3]).\n\n\t-define(SERVER, ?MODULE).\n\n\t-record(state, {}).\n\n\t%%%===================================================================\n\t%%% API\n\t%%%===================================================================\n\n\tstart_link() ->\n\t gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).\n\n\t%%%===================================================================\n\t%%% gen_server callbacks\n\t%%%===================================================================\n\n\tinit([]) ->\n\t {ok, #state{}}.\n\n\thandle_call(_Request, _From, State) ->\n\t Reply = ok,\n\t {reply, Reply, State}.\n\n\thandle_cast(_Msg, State) ->\n\t {noreply, State}.\n\n\thandle_info(_Info, State) ->\n\t {noreply, State}.\n\n\tterminate(_Reason, _State) ->\n\t ok.\n\n\tcode_change(_OldVsn, State, _Extra) ->\n\t {ok, State}.\n\n\t%%%===================================================================\n\t%%% Internal functions\n\t%%%===================================================================\n\n"; + +}); + +define("ace/snippets/erlang",["require","exports","module","ace/snippets/erlang.snippets"], function(require, exports, module){"use strict"; +exports.snippetText = require("./erlang.snippets"); +exports.scope = "erlang"; + +}); + (function() { + window.require(["ace/snippets/erlang"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/forth.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/forth.js new file mode 100644 index 0000000..861cdda --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/forth.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/forth"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/fortran.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/fortran.js new file mode 100644 index 0000000..4ad332b --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/fortran.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/fortran"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/fsharp.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/fsharp.js new file mode 100644 index 0000000..e79909e --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/fsharp.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/fsharp"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/fsl.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/fsl.js new file mode 100644 index 0000000..26abaab --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/fsl.js @@ -0,0 +1,17 @@ +define("ace/snippets/fsl.snippets",["require","exports","module"], function(require, exports, module){module.exports = "snippet header\n\tmachine_name : \"\";\n\tmachine_author : \"\";\n\tmachine_license : MIT;\n\tmachine_comment : \"\";\n\tmachine_language : en;\n\tmachine_version : 1.0.0;\n\tfsl_version : 1.0.0;\n\tstart_states : [];\n"; + +}); + +define("ace/snippets/fsl",["require","exports","module","ace/snippets/fsl.snippets"], function(require, exports, module){"use strict"; +exports.snippetText = require("./fsl.snippets"); +exports.scope = "fsl"; + +}); + (function() { + window.require(["ace/snippets/fsl"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/ftl.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/ftl.js new file mode 100644 index 0000000..1146c3b --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/ftl.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/ftl"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/gcode.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/gcode.js new file mode 100644 index 0000000..516ff7b --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/gcode.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/gcode"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/src/main/resources/static/assets/js/vendor/template/src/snippets/gherkin.js b/src/main/resources/static/assets/js/vendor/template/src/snippets/gherkin.js new file mode 100644 index 0000000..106a05e --- /dev/null +++ b/src/main/resources/static/assets/js/vendor/template/src/snippets/gherkin.js @@ -0,0 +1,10 @@ + +; + (function() { + window.require(["ace/snippets/gherkin"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file