2023-01-16 22:26:34 +00:00
|
|
|
ace.define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
|
2012-07-05 06:37:09 +00:00
|
|
|
var oop = require("../lib/oop");
|
|
|
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
2023-01-16 22:26:34 +00:00
|
|
|
var XmlHighlightRules = function (normalize) {
|
2015-11-19 16:37:40 +00:00
|
|
|
var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
|
2012-07-05 06:37:09 +00:00
|
|
|
this.$rules = {
|
2023-01-16 22:26:34 +00:00
|
|
|
start: [
|
|
|
|
{ token: "string.cdata.xml", regex: "<\\!\\[CDATA\\[", next: "cdata" },
|
2013-12-30 15:00:16 +00:00
|
|
|
{
|
2023-01-16 22:26:34 +00:00
|
|
|
token: ["punctuation.instruction.xml", "keyword.instruction.xml"],
|
|
|
|
regex: "(<\\?)(" + tagRegex + ")", next: "processing_instruction"
|
2013-12-30 15:00:16 +00:00
|
|
|
},
|
2023-01-16 22:26:34 +00:00
|
|
|
{ token: "comment.start.xml", regex: "<\\!--", next: "comment" },
|
2013-12-30 15:00:16 +00:00
|
|
|
{
|
2023-01-16 22:26:34 +00:00
|
|
|
token: ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
|
|
|
|
regex: "(<\\!)(DOCTYPE)(?=[\\s])", next: "doctype", caseInsensitive: true
|
2013-12-30 15:00:16 +00:00
|
|
|
},
|
2023-01-16 22:26:34 +00:00
|
|
|
{ include: "tag" },
|
|
|
|
{ token: "text.end-tag-open.xml", regex: "</" },
|
|
|
|
{ token: "text.tag-open.xml", regex: "<" },
|
|
|
|
{ include: "reference" },
|
|
|
|
{ defaultToken: "text.xml" }
|
2013-12-30 15:00:16 +00:00
|
|
|
],
|
2023-01-16 22:26:34 +00:00
|
|
|
processing_instruction: [{
|
|
|
|
token: "entity.other.attribute-name.decl-attribute-name.xml",
|
|
|
|
regex: tagRegex
|
|
|
|
}, {
|
|
|
|
token: "keyword.operator.decl-attribute-equals.xml",
|
|
|
|
regex: "="
|
|
|
|
}, {
|
|
|
|
include: "whitespace"
|
|
|
|
}, {
|
|
|
|
include: "string"
|
|
|
|
}, {
|
|
|
|
token: "punctuation.xml-decl.xml",
|
|
|
|
regex: "\\?>",
|
|
|
|
next: "start"
|
|
|
|
}],
|
|
|
|
doctype: [
|
|
|
|
{ include: "whitespace" },
|
|
|
|
{ include: "string" },
|
|
|
|
{ token: "xml-pe.doctype.xml", regex: ">", next: "start" },
|
|
|
|
{ token: "xml-pe.xml", regex: "[-_a-zA-Z0-9:]+" },
|
|
|
|
{ token: "punctuation.int-subset", regex: "\\[", push: "int_subset" }
|
2013-12-30 15:00:16 +00:00
|
|
|
],
|
2023-01-16 22:26:34 +00:00
|
|
|
int_subset: [{
|
|
|
|
token: "text.xml",
|
|
|
|
regex: "\\s+"
|
|
|
|
}, {
|
|
|
|
token: "punctuation.int-subset.xml",
|
|
|
|
regex: "]",
|
|
|
|
next: "pop"
|
|
|
|
}, {
|
|
|
|
token: ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
|
|
|
|
regex: "(<\\!)(" + tagRegex + ")",
|
|
|
|
push: [{
|
|
|
|
token: "text",
|
|
|
|
regex: "\\s+"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
token: "punctuation.markup-decl.xml",
|
|
|
|
regex: ">",
|
|
|
|
next: "pop"
|
|
|
|
},
|
|
|
|
{ include: "string" }]
|
|
|
|
}],
|
|
|
|
cdata: [
|
|
|
|
{ token: "string.cdata.xml", regex: "\\]\\]>", next: "start" },
|
|
|
|
{ token: "text.xml", regex: "\\s+" },
|
|
|
|
{ token: "text.xml", regex: "(?:[^\\]]|\\](?!\\]>))+" }
|
2013-12-30 15:00:16 +00:00
|
|
|
],
|
2023-01-16 22:26:34 +00:00
|
|
|
comment: [
|
|
|
|
{ token: "comment.end.xml", regex: "-->", next: "start" },
|
|
|
|
{ defaultToken: "comment.xml" }
|
2013-12-30 15:00:16 +00:00
|
|
|
],
|
2023-01-16 22:26:34 +00:00
|
|
|
reference: [{
|
|
|
|
token: "constant.language.escape.reference.xml",
|
|
|
|
regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
|
|
|
}],
|
|
|
|
attr_reference: [{
|
|
|
|
token: "constant.language.escape.reference.attribute-value.xml",
|
|
|
|
regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
|
|
|
}],
|
|
|
|
tag: [{
|
|
|
|
token: ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
|
|
|
|
regex: "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
|
|
|
|
next: [
|
|
|
|
{ include: "attributes" },
|
|
|
|
{ token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: "start" }
|
|
|
|
]
|
|
|
|
}],
|
|
|
|
tag_whitespace: [
|
|
|
|
{ token: "text.tag-whitespace.xml", regex: "\\s+" }
|
2014-04-29 09:03:14 +00:00
|
|
|
],
|
2023-01-16 22:26:34 +00:00
|
|
|
whitespace: [
|
|
|
|
{ token: "text.whitespace.xml", regex: "\\s+" }
|
2013-12-30 15:00:16 +00:00
|
|
|
],
|
|
|
|
string: [{
|
2023-01-16 22:26:34 +00:00
|
|
|
token: "string.xml",
|
|
|
|
regex: "'",
|
|
|
|
push: [
|
|
|
|
{ token: "string.xml", regex: "'", next: "pop" },
|
|
|
|
{ defaultToken: "string.xml" }
|
|
|
|
]
|
|
|
|
}, {
|
|
|
|
token: "string.xml",
|
|
|
|
regex: '"',
|
|
|
|
push: [
|
|
|
|
{ token: "string.xml", regex: '"', next: "pop" },
|
|
|
|
{ defaultToken: "string.xml" }
|
|
|
|
]
|
|
|
|
}],
|
2013-12-30 15:00:16 +00:00
|
|
|
attributes: [{
|
2023-01-16 22:26:34 +00:00
|
|
|
token: "entity.other.attribute-name.xml",
|
|
|
|
regex: tagRegex
|
|
|
|
}, {
|
|
|
|
token: "keyword.operator.attribute-equals.xml",
|
|
|
|
regex: "="
|
|
|
|
}, {
|
|
|
|
include: "tag_whitespace"
|
|
|
|
}, {
|
|
|
|
include: "attribute_value"
|
|
|
|
}],
|
2014-04-29 09:03:14 +00:00
|
|
|
attribute_value: [{
|
2023-01-16 22:26:34 +00:00
|
|
|
token: "string.attribute-value.xml",
|
|
|
|
regex: "'",
|
|
|
|
push: [
|
|
|
|
{ token: "string.attribute-value.xml", regex: "'", next: "pop" },
|
|
|
|
{ include: "attr_reference" },
|
|
|
|
{ defaultToken: "string.attribute-value.xml" }
|
|
|
|
]
|
|
|
|
}, {
|
|
|
|
token: "string.attribute-value.xml",
|
|
|
|
regex: '"',
|
|
|
|
push: [
|
|
|
|
{ token: "string.attribute-value.xml", regex: '"', next: "pop" },
|
|
|
|
{ include: "attr_reference" },
|
|
|
|
{ defaultToken: "string.attribute-value.xml" }
|
|
|
|
]
|
|
|
|
}]
|
2012-07-05 06:37:09 +00:00
|
|
|
};
|
2013-12-30 15:00:16 +00:00
|
|
|
if (this.constructor === XmlHighlightRules)
|
|
|
|
this.normalizeRules();
|
2012-07-05 06:37:09 +00:00
|
|
|
};
|
2023-01-16 22:26:34 +00:00
|
|
|
(function () {
|
|
|
|
this.embedTagRules = function (HighlightRules, prefix, tag) {
|
2013-12-30 15:00:16 +00:00
|
|
|
this.$rules.tag.unshift({
|
2023-01-16 22:26:34 +00:00
|
|
|
token: ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
|
|
|
|
regex: "(<)(" + tag + "(?=\\s|>|$))",
|
2013-12-30 15:00:16 +00:00
|
|
|
next: [
|
2023-01-16 22:26:34 +00:00
|
|
|
{ include: "attributes" },
|
|
|
|
{ token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: prefix + "start" }
|
2013-12-30 15:00:16 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
this.$rules[tag + "-end"] = [
|
2023-01-16 22:26:34 +00:00
|
|
|
{ include: "attributes" },
|
|
|
|
{ token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: "start",
|
|
|
|
onMatch: function (value, currentState, stack) {
|
2013-12-30 15:00:16 +00:00
|
|
|
stack.splice(0);
|
|
|
|
return this.token;
|
2023-01-16 22:26:34 +00:00
|
|
|
} }
|
2020-04-14 12:14:48 +00:00
|
|
|
];
|
2013-12-30 15:00:16 +00:00
|
|
|
this.embedRules(HighlightRules, prefix, [{
|
2023-01-16 22:26:34 +00:00
|
|
|
token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
|
|
|
|
regex: "(</)(" + tag + "(?=\\s|>|$))",
|
|
|
|
next: tag + "-end"
|
|
|
|
}, {
|
|
|
|
token: "string.cdata.xml",
|
|
|
|
regex: "<\\!\\[CDATA\\["
|
|
|
|
}, {
|
|
|
|
token: "string.cdata.xml",
|
|
|
|
regex: "\\]\\]>"
|
|
|
|
}]);
|
2013-12-30 15:00:16 +00:00
|
|
|
};
|
|
|
|
}).call(TextHighlightRules.prototype);
|
2012-07-05 06:37:09 +00:00
|
|
|
oop.inherits(XmlHighlightRules, TextHighlightRules);
|
|
|
|
exports.XmlHighlightRules = XmlHighlightRules;
|
|
|
|
|
2023-01-16 22:26:34 +00:00
|
|
|
});
|
2012-07-05 06:37:09 +00:00
|
|
|
|
2023-01-16 22:26:34 +00:00
|
|
|
ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module){"use strict";
|
2012-07-05 06:37:09 +00:00
|
|
|
var oop = require("../../lib/oop");
|
|
|
|
var Behaviour = require("../behaviour").Behaviour;
|
|
|
|
var TokenIterator = require("../../token_iterator").TokenIterator;
|
2014-07-08 20:15:22 +00:00
|
|
|
var lang = require("../../lib/lang");
|
2014-04-29 09:03:14 +00:00
|
|
|
function is(token, type) {
|
2020-04-14 12:14:48 +00:00
|
|
|
return token && token.type.lastIndexOf(type + ".xml") > -1;
|
2012-07-05 06:37:09 +00:00
|
|
|
}
|
|
|
|
var XmlBehaviour = function () {
|
2014-04-29 09:03:14 +00:00
|
|
|
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
|
|
|
|
if (text == '"' || text == "'") {
|
|
|
|
var quote = text;
|
|
|
|
var selected = session.doc.getTextRange(editor.getSelectionRange());
|
|
|
|
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
|
2012-07-05 06:37:09 +00:00
|
|
|
return {
|
2014-04-29 09:03:14 +00:00
|
|
|
text: quote + selected + quote,
|
2012-07-05 06:37:09 +00:00
|
|
|
selection: false
|
|
|
|
};
|
2013-12-30 15:00:16 +00:00
|
|
|
}
|
2012-07-05 06:37:09 +00:00
|
|
|
var cursor = editor.getCursorPosition();
|
|
|
|
var line = session.doc.getLine(cursor.row);
|
|
|
|
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
2014-04-29 09:03:14 +00:00
|
|
|
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
|
|
|
var token = iterator.getCurrentToken();
|
|
|
|
if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
|
2013-12-30 15:00:16 +00:00
|
|
|
return {
|
2014-04-29 09:03:14 +00:00
|
|
|
text: "",
|
2013-12-30 15:00:16 +00:00
|
|
|
selection: [1, 1]
|
|
|
|
};
|
|
|
|
}
|
2014-04-29 09:03:14 +00:00
|
|
|
if (!token)
|
|
|
|
token = iterator.stepBackward();
|
|
|
|
if (!token)
|
|
|
|
return;
|
|
|
|
while (is(token, "tag-whitespace") || is(token, "whitespace")) {
|
|
|
|
token = iterator.stepBackward();
|
|
|
|
}
|
|
|
|
var rightSpace = !rightChar || rightChar.match(/\s/);
|
|
|
|
if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
|
2012-07-05 06:37:09 +00:00
|
|
|
return {
|
2014-04-29 09:03:14 +00:00
|
|
|
text: quote + quote,
|
|
|
|
selection: [1, 1]
|
2012-07-05 06:37:09 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2023-01-16 22:26:34 +00:00
|
|
|
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
|
2012-07-05 06:37:09 +00:00
|
|
|
var selected = session.doc.getTextRange(range);
|
|
|
|
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
|
|
|
|
var line = session.doc.getLine(range.start.row);
|
|
|
|
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
|
2013-12-30 15:00:16 +00:00
|
|
|
if (rightChar == selected) {
|
2012-07-05 06:37:09 +00:00
|
|
|
range.end.column++;
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-04-29 09:03:14 +00:00
|
|
|
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
|
|
|
|
if (text == '>') {
|
2017-02-05 20:05:00 +00:00
|
|
|
var position = editor.getSelectionRange().start;
|
2014-04-29 09:03:14 +00:00
|
|
|
var iterator = new TokenIterator(session, position.row, position.column);
|
|
|
|
var token = iterator.getCurrentToken() || iterator.stepBackward();
|
|
|
|
if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
|
|
|
|
return;
|
|
|
|
if (is(token, "reference.attribute-value"))
|
|
|
|
return;
|
|
|
|
if (is(token, "attribute-value")) {
|
2020-04-14 12:14:48 +00:00
|
|
|
var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
|
|
|
|
if (position.column < tokenEndColumn)
|
|
|
|
return;
|
|
|
|
if (position.column == tokenEndColumn) {
|
|
|
|
var nextToken = iterator.stepForward();
|
|
|
|
if (nextToken && is(nextToken, "attribute-value"))
|
2014-04-29 09:03:14 +00:00
|
|
|
return;
|
2020-04-14 12:14:48 +00:00
|
|
|
iterator.stepBackward();
|
2014-04-29 09:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-14 12:14:48 +00:00
|
|
|
if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
|
|
|
|
return;
|
2014-04-29 09:03:14 +00:00
|
|
|
while (!is(token, "tag-name")) {
|
|
|
|
token = iterator.stepBackward();
|
2017-02-05 20:05:00 +00:00
|
|
|
if (token.value == "<") {
|
|
|
|
token = iterator.stepForward();
|
|
|
|
break;
|
|
|
|
}
|
2014-04-29 09:03:14 +00:00
|
|
|
}
|
|
|
|
var tokenRow = iterator.getCurrentTokenRow();
|
|
|
|
var tokenColumn = iterator.getCurrentTokenColumn();
|
|
|
|
if (is(iterator.stepBackward(), "end-tag-open"))
|
|
|
|
return;
|
|
|
|
var element = token.value;
|
|
|
|
if (tokenRow == position.row)
|
|
|
|
element = element.substring(0, position.column - tokenColumn);
|
|
|
|
if (this.voidElements.hasOwnProperty(element.toLowerCase()))
|
2023-01-16 22:26:34 +00:00
|
|
|
return;
|
2014-04-29 09:03:14 +00:00
|
|
|
return {
|
2023-01-16 22:26:34 +00:00
|
|
|
text: ">" + "</" + element + ">",
|
|
|
|
selection: [1, 1]
|
2014-04-29 09:03:14 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2014-07-08 20:15:22 +00:00
|
|
|
this.add("autoindent", "insertion", function (state, action, editor, session, text) {
|
2014-04-29 09:03:14 +00:00
|
|
|
if (text == "\n") {
|
|
|
|
var cursor = editor.getCursorPosition();
|
|
|
|
var line = session.getLine(cursor.row);
|
2014-07-08 20:15:22 +00:00
|
|
|
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
|
|
|
var token = iterator.getCurrentToken();
|
|
|
|
if (token && token.type.indexOf("tag-close") !== -1) {
|
2015-11-19 16:37:40 +00:00
|
|
|
if (token.value == "/>")
|
|
|
|
return;
|
2014-07-08 20:15:22 +00:00
|
|
|
while (token && token.type.indexOf("tag-name") === -1) {
|
|
|
|
token = iterator.stepBackward();
|
|
|
|
}
|
|
|
|
if (!token) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var tag = token.value;
|
|
|
|
var row = iterator.getCurrentTokenRow();
|
|
|
|
token = iterator.stepBackward();
|
|
|
|
if (!token || token.type.indexOf("end-tag") !== -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.voidElements && !this.voidElements[tag]) {
|
2023-01-16 22:26:34 +00:00
|
|
|
var nextToken = session.getTokenAt(cursor.row, cursor.column + 1);
|
2014-07-08 20:15:22 +00:00
|
|
|
var line = session.getLine(row);
|
|
|
|
var nextIndent = this.$getIndent(line);
|
|
|
|
var indent = nextIndent + session.getTabString();
|
|
|
|
if (nextToken && nextToken.value === "</") {
|
|
|
|
return {
|
|
|
|
text: "\n" + indent + "\n" + nextIndent,
|
|
|
|
selection: [1, indent.length, 1, indent.length]
|
|
|
|
};
|
2023-01-16 22:26:34 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-07-08 20:15:22 +00:00
|
|
|
return {
|
|
|
|
text: "\n" + indent
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2014-04-29 09:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-03-16 18:05:39 +00:00
|
|
|
};
|
2014-04-29 09:03:14 +00:00
|
|
|
oop.inherits(XmlBehaviour, Behaviour);
|
|
|
|
exports.XmlBehaviour = XmlBehaviour;
|
2012-07-05 06:37:09 +00:00
|
|
|
|
2023-01-16 22:26:34 +00:00
|
|
|
});
|
2012-07-05 06:37:09 +00:00
|
|
|
|
2023-01-16 22:26:34 +00:00
|
|
|
ace.define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
|
2012-07-05 06:37:09 +00:00
|
|
|
var oop = require("../../lib/oop");
|
|
|
|
var Range = require("../../range").Range;
|
|
|
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
2023-01-16 22:26:34 +00:00
|
|
|
var FoldMode = exports.FoldMode = function (voidElements, optionalEndTags) {
|
2012-07-05 06:37:09 +00:00
|
|
|
BaseFoldMode.call(this);
|
2014-07-08 20:15:22 +00:00
|
|
|
this.voidElements = voidElements || {};
|
|
|
|
this.optionalEndTags = oop.mixin({}, this.voidElements);
|
|
|
|
if (optionalEndTags)
|
|
|
|
oop.mixin(this.optionalEndTags, optionalEndTags);
|
2012-07-05 06:37:09 +00:00
|
|
|
};
|
|
|
|
oop.inherits(FoldMode, BaseFoldMode);
|
2023-01-16 22:26:34 +00:00
|
|
|
var Tag = function () {
|
2014-04-29 09:03:14 +00:00
|
|
|
this.tagName = "";
|
|
|
|
this.closing = false;
|
|
|
|
this.selfClosing = false;
|
2023-01-16 22:26:34 +00:00
|
|
|
this.start = { row: 0, column: 0 };
|
|
|
|
this.end = { row: 0, column: 0 };
|
2014-04-29 09:03:14 +00:00
|
|
|
};
|
|
|
|
function is(token, type) {
|
|
|
|
return token.type.lastIndexOf(type + ".xml") > -1;
|
|
|
|
}
|
2023-01-16 22:26:34 +00:00
|
|
|
(function () {
|
|
|
|
this.getFoldWidget = function (session, foldStyle, row) {
|
2012-07-05 06:37:09 +00:00
|
|
|
var tag = this._getFirstTagInLine(session, row);
|
2014-04-29 09:03:14 +00:00
|
|
|
if (!tag)
|
2017-02-05 20:05:00 +00:00
|
|
|
return this.getCommentFoldWidget(session, row);
|
2014-04-29 09:03:14 +00:00
|
|
|
if (tag.closing || (!tag.tagName && tag.selfClosing))
|
2023-01-16 22:26:34 +00:00
|
|
|
return foldStyle === "markbeginend" ? "end" : "";
|
2014-04-29 09:03:14 +00:00
|
|
|
if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
|
2012-07-05 06:37:09 +00:00
|
|
|
return "";
|
2014-04-29 09:03:14 +00:00
|
|
|
if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
|
2012-07-05 06:37:09 +00:00
|
|
|
return "";
|
|
|
|
return "start";
|
|
|
|
};
|
2023-01-16 22:26:34 +00:00
|
|
|
this.getCommentFoldWidget = function (session, row) {
|
2017-02-05 20:05:00 +00:00
|
|
|
if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
|
|
|
|
return "start";
|
|
|
|
return "";
|
2020-04-14 12:14:48 +00:00
|
|
|
};
|
2023-01-16 22:26:34 +00:00
|
|
|
this._getFirstTagInLine = function (session, row) {
|
2012-07-05 06:37:09 +00:00
|
|
|
var tokens = session.getTokens(row);
|
2014-04-29 09:03:14 +00:00
|
|
|
var tag = new Tag();
|
2012-07-05 06:37:09 +00:00
|
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
|
|
var token = tokens[i];
|
2014-04-29 09:03:14 +00:00
|
|
|
if (is(token, "tag-open")) {
|
|
|
|
tag.end.column = tag.start.column + token.value.length;
|
|
|
|
tag.closing = is(token, "end-tag-open");
|
|
|
|
token = tokens[++i];
|
|
|
|
if (!token)
|
|
|
|
return null;
|
|
|
|
tag.tagName = token.value;
|
|
|
|
tag.end.column += token.value.length;
|
|
|
|
for (i++; i < tokens.length; i++) {
|
|
|
|
token = tokens[i];
|
|
|
|
tag.end.column += token.value.length;
|
|
|
|
if (is(token, "tag-close")) {
|
|
|
|
tag.selfClosing = token.value == '/>';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tag;
|
2023-01-16 22:26:34 +00:00
|
|
|
}
|
|
|
|
else if (is(token, "tag-close")) {
|
2014-04-29 09:03:14 +00:00
|
|
|
tag.selfClosing = token.value == '/>';
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
tag.start.column += token.value.length;
|
2012-07-05 06:37:09 +00:00
|
|
|
}
|
2014-04-29 09:03:14 +00:00
|
|
|
return null;
|
2012-07-05 06:37:09 +00:00
|
|
|
};
|
2023-01-16 22:26:34 +00:00
|
|
|
this._findEndTagInLine = function (session, row, tagName, startColumn) {
|
2014-04-29 09:03:14 +00:00
|
|
|
var tokens = session.getTokens(row);
|
2013-12-30 15:00:16 +00:00
|
|
|
var column = 0;
|
2014-04-29 09:03:14 +00:00
|
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
|
|
var token = tokens[i];
|
|
|
|
column += token.value.length;
|
|
|
|
if (column < startColumn)
|
|
|
|
continue;
|
|
|
|
if (is(token, "end-tag-open")) {
|
|
|
|
token = tokens[i + 1];
|
|
|
|
if (token && token.value == tagName)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2012-07-05 06:37:09 +00:00
|
|
|
};
|
2023-01-16 22:26:34 +00:00
|
|
|
this.getFoldWidgetRange = function (session, foldStyle, row) {
|
|
|
|
var tags = session.getMatchingTags({ row: row, column: 0 });
|
|
|
|
if (tags) {
|
|
|
|
return new Range(tags.openTag.end.row, tags.openTag.end.column, tags.closeTag.start.row, tags.closeTag.start.column);
|
2012-07-05 06:37:09 +00:00
|
|
|
}
|
2023-01-16 22:26:34 +00:00
|
|
|
else {
|
2017-02-05 20:05:00 +00:00
|
|
|
return this.getCommentFoldWidget(session, row)
|
|
|
|
&& session.getCommentFoldRange(row, session.getLine(row).length);
|
|
|
|
}
|
2012-07-05 06:37:09 +00:00
|
|
|
};
|
|
|
|
}).call(FoldMode.prototype);
|
|
|
|
|
|
|
|
});
|
2014-07-08 20:15:22 +00:00
|
|
|
|
2023-01-16 22:26:34 +00:00
|
|
|
ace.define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml","ace/worker/worker_client"], function(require, exports, module){"use strict";
|
2014-07-08 20:15:22 +00:00
|
|
|
var oop = require("../lib/oop");
|
|
|
|
var lang = require("../lib/lang");
|
|
|
|
var TextMode = require("./text").Mode;
|
|
|
|
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
|
|
|
|
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
|
|
|
|
var XmlFoldMode = require("./folding/xml").FoldMode;
|
|
|
|
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
2023-01-16 22:26:34 +00:00
|
|
|
var Mode = function () {
|
|
|
|
this.HighlightRules = XmlHighlightRules;
|
|
|
|
this.$behaviour = new XmlBehaviour();
|
|
|
|
this.foldingRules = new XmlFoldMode();
|
2014-07-08 20:15:22 +00:00
|
|
|
};
|
|
|
|
oop.inherits(Mode, TextMode);
|
2023-01-16 22:26:34 +00:00
|
|
|
(function () {
|
2014-07-08 20:15:22 +00:00
|
|
|
this.voidElements = lang.arrayToMap([]);
|
2023-01-16 22:26:34 +00:00
|
|
|
this.blockComment = { start: "<!--", end: "-->" };
|
|
|
|
this.createWorker = function (session) {
|
2014-07-08 20:15:22 +00:00
|
|
|
var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
|
|
|
|
worker.attachToDocument(session.getDocument());
|
2023-01-16 22:26:34 +00:00
|
|
|
worker.on("error", function (e) {
|
2014-07-08 20:15:22 +00:00
|
|
|
session.setAnnotations(e.data);
|
|
|
|
});
|
2023-01-16 22:26:34 +00:00
|
|
|
worker.on("terminate", function () {
|
2014-07-08 20:15:22 +00:00
|
|
|
session.clearAnnotations();
|
|
|
|
});
|
|
|
|
return worker;
|
|
|
|
};
|
|
|
|
this.$id = "ace/mode/xml";
|
|
|
|
}).call(Mode.prototype);
|
|
|
|
exports.Mode = Mode;
|
2023-01-16 22:26:34 +00:00
|
|
|
|
2020-04-14 12:14:48 +00:00
|
|
|
}); (function() {
|
|
|
|
ace.require(["ace/mode/xml"], function(m) {
|
|
|
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
|
|
module.exports = m;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
|
|
|
|