codemirror_mode_htmlmixed_htmlmixed.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. import {
  2. require_css
  3. } from "./chunk-APHQCZPF.js";
  4. import {
  5. require_javascript
  6. } from "./chunk-6D4BEOWP.js";
  7. import {
  8. require_codemirror
  9. } from "./chunk-SPLH5WDX.js";
  10. import {
  11. __commonJS
  12. } from "./chunk-2LSFTFF7.js";
  13. // node_modules/.pnpm/codemirror@5.65.12/node_modules/codemirror/mode/xml/xml.js
  14. var require_xml = __commonJS({
  15. "node_modules/.pnpm/codemirror@5.65.12/node_modules/codemirror/mode/xml/xml.js"(exports, module) {
  16. (function(mod) {
  17. if (typeof exports == "object" && typeof module == "object")
  18. mod(require_codemirror());
  19. else if (typeof define == "function" && define.amd)
  20. define(["../../lib/codemirror"], mod);
  21. else
  22. mod(CodeMirror);
  23. })(function(CodeMirror2) {
  24. "use strict";
  25. var htmlConfig = {
  26. autoSelfClosers: {
  27. "area": true,
  28. "base": true,
  29. "br": true,
  30. "col": true,
  31. "command": true,
  32. "embed": true,
  33. "frame": true,
  34. "hr": true,
  35. "img": true,
  36. "input": true,
  37. "keygen": true,
  38. "link": true,
  39. "meta": true,
  40. "param": true,
  41. "source": true,
  42. "track": true,
  43. "wbr": true,
  44. "menuitem": true
  45. },
  46. implicitlyClosed: {
  47. "dd": true,
  48. "li": true,
  49. "optgroup": true,
  50. "option": true,
  51. "p": true,
  52. "rp": true,
  53. "rt": true,
  54. "tbody": true,
  55. "td": true,
  56. "tfoot": true,
  57. "th": true,
  58. "tr": true
  59. },
  60. contextGrabbers: {
  61. "dd": { "dd": true, "dt": true },
  62. "dt": { "dd": true, "dt": true },
  63. "li": { "li": true },
  64. "option": { "option": true, "optgroup": true },
  65. "optgroup": { "optgroup": true },
  66. "p": {
  67. "address": true,
  68. "article": true,
  69. "aside": true,
  70. "blockquote": true,
  71. "dir": true,
  72. "div": true,
  73. "dl": true,
  74. "fieldset": true,
  75. "footer": true,
  76. "form": true,
  77. "h1": true,
  78. "h2": true,
  79. "h3": true,
  80. "h4": true,
  81. "h5": true,
  82. "h6": true,
  83. "header": true,
  84. "hgroup": true,
  85. "hr": true,
  86. "menu": true,
  87. "nav": true,
  88. "ol": true,
  89. "p": true,
  90. "pre": true,
  91. "section": true,
  92. "table": true,
  93. "ul": true
  94. },
  95. "rp": { "rp": true, "rt": true },
  96. "rt": { "rp": true, "rt": true },
  97. "tbody": { "tbody": true, "tfoot": true },
  98. "td": { "td": true, "th": true },
  99. "tfoot": { "tbody": true },
  100. "th": { "td": true, "th": true },
  101. "thead": { "tbody": true, "tfoot": true },
  102. "tr": { "tr": true }
  103. },
  104. doNotIndent: { "pre": true },
  105. allowUnquoted: true,
  106. allowMissing: true,
  107. caseFold: true
  108. };
  109. var xmlConfig = {
  110. autoSelfClosers: {},
  111. implicitlyClosed: {},
  112. contextGrabbers: {},
  113. doNotIndent: {},
  114. allowUnquoted: false,
  115. allowMissing: false,
  116. allowMissingTagName: false,
  117. caseFold: false
  118. };
  119. CodeMirror2.defineMode("xml", function(editorConf, config_) {
  120. var indentUnit = editorConf.indentUnit;
  121. var config = {};
  122. var defaults = config_.htmlMode ? htmlConfig : xmlConfig;
  123. for (var prop in defaults)
  124. config[prop] = defaults[prop];
  125. for (var prop in config_)
  126. config[prop] = config_[prop];
  127. var type, setStyle;
  128. function inText(stream, state) {
  129. function chain(parser) {
  130. state.tokenize = parser;
  131. return parser(stream, state);
  132. }
  133. var ch = stream.next();
  134. if (ch == "<") {
  135. if (stream.eat("!")) {
  136. if (stream.eat("[")) {
  137. if (stream.match("CDATA["))
  138. return chain(inBlock("atom", "]]>"));
  139. else
  140. return null;
  141. } else if (stream.match("--")) {
  142. return chain(inBlock("comment", "-->"));
  143. } else if (stream.match("DOCTYPE", true, true)) {
  144. stream.eatWhile(/[\w\._\-]/);
  145. return chain(doctype(1));
  146. } else {
  147. return null;
  148. }
  149. } else if (stream.eat("?")) {
  150. stream.eatWhile(/[\w\._\-]/);
  151. state.tokenize = inBlock("meta", "?>");
  152. return "meta";
  153. } else {
  154. type = stream.eat("/") ? "closeTag" : "openTag";
  155. state.tokenize = inTag;
  156. return "tag bracket";
  157. }
  158. } else if (ch == "&") {
  159. var ok;
  160. if (stream.eat("#")) {
  161. if (stream.eat("x")) {
  162. ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
  163. } else {
  164. ok = stream.eatWhile(/[\d]/) && stream.eat(";");
  165. }
  166. } else {
  167. ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
  168. }
  169. return ok ? "atom" : "error";
  170. } else {
  171. stream.eatWhile(/[^&<]/);
  172. return null;
  173. }
  174. }
  175. inText.isInText = true;
  176. function inTag(stream, state) {
  177. var ch = stream.next();
  178. if (ch == ">" || ch == "/" && stream.eat(">")) {
  179. state.tokenize = inText;
  180. type = ch == ">" ? "endTag" : "selfcloseTag";
  181. return "tag bracket";
  182. } else if (ch == "=") {
  183. type = "equals";
  184. return null;
  185. } else if (ch == "<") {
  186. state.tokenize = inText;
  187. state.state = baseState;
  188. state.tagName = state.tagStart = null;
  189. var next = state.tokenize(stream, state);
  190. return next ? next + " tag error" : "tag error";
  191. } else if (/[\'\"]/.test(ch)) {
  192. state.tokenize = inAttribute(ch);
  193. state.stringStartCol = stream.column();
  194. return state.tokenize(stream, state);
  195. } else {
  196. stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
  197. return "word";
  198. }
  199. }
  200. function inAttribute(quote) {
  201. var closure = function(stream, state) {
  202. while (!stream.eol()) {
  203. if (stream.next() == quote) {
  204. state.tokenize = inTag;
  205. break;
  206. }
  207. }
  208. return "string";
  209. };
  210. closure.isInAttribute = true;
  211. return closure;
  212. }
  213. function inBlock(style, terminator) {
  214. return function(stream, state) {
  215. while (!stream.eol()) {
  216. if (stream.match(terminator)) {
  217. state.tokenize = inText;
  218. break;
  219. }
  220. stream.next();
  221. }
  222. return style;
  223. };
  224. }
  225. function doctype(depth) {
  226. return function(stream, state) {
  227. var ch;
  228. while ((ch = stream.next()) != null) {
  229. if (ch == "<") {
  230. state.tokenize = doctype(depth + 1);
  231. return state.tokenize(stream, state);
  232. } else if (ch == ">") {
  233. if (depth == 1) {
  234. state.tokenize = inText;
  235. break;
  236. } else {
  237. state.tokenize = doctype(depth - 1);
  238. return state.tokenize(stream, state);
  239. }
  240. }
  241. }
  242. return "meta";
  243. };
  244. }
  245. function lower(tagName) {
  246. return tagName && tagName.toLowerCase();
  247. }
  248. function Context(state, tagName, startOfLine) {
  249. this.prev = state.context;
  250. this.tagName = tagName || "";
  251. this.indent = state.indented;
  252. this.startOfLine = startOfLine;
  253. if (config.doNotIndent.hasOwnProperty(tagName) || state.context && state.context.noIndent)
  254. this.noIndent = true;
  255. }
  256. function popContext(state) {
  257. if (state.context)
  258. state.context = state.context.prev;
  259. }
  260. function maybePopContext(state, nextTagName) {
  261. var parentTagName;
  262. while (true) {
  263. if (!state.context) {
  264. return;
  265. }
  266. parentTagName = state.context.tagName;
  267. if (!config.contextGrabbers.hasOwnProperty(lower(parentTagName)) || !config.contextGrabbers[lower(parentTagName)].hasOwnProperty(lower(nextTagName))) {
  268. return;
  269. }
  270. popContext(state);
  271. }
  272. }
  273. function baseState(type2, stream, state) {
  274. if (type2 == "openTag") {
  275. state.tagStart = stream.column();
  276. return tagNameState;
  277. } else if (type2 == "closeTag") {
  278. return closeTagNameState;
  279. } else {
  280. return baseState;
  281. }
  282. }
  283. function tagNameState(type2, stream, state) {
  284. if (type2 == "word") {
  285. state.tagName = stream.current();
  286. setStyle = "tag";
  287. return attrState;
  288. } else if (config.allowMissingTagName && type2 == "endTag") {
  289. setStyle = "tag bracket";
  290. return attrState(type2, stream, state);
  291. } else {
  292. setStyle = "error";
  293. return tagNameState;
  294. }
  295. }
  296. function closeTagNameState(type2, stream, state) {
  297. if (type2 == "word") {
  298. var tagName = stream.current();
  299. if (state.context && state.context.tagName != tagName && config.implicitlyClosed.hasOwnProperty(lower(state.context.tagName)))
  300. popContext(state);
  301. if (state.context && state.context.tagName == tagName || config.matchClosing === false) {
  302. setStyle = "tag";
  303. return closeState;
  304. } else {
  305. setStyle = "tag error";
  306. return closeStateErr;
  307. }
  308. } else if (config.allowMissingTagName && type2 == "endTag") {
  309. setStyle = "tag bracket";
  310. return closeState(type2, stream, state);
  311. } else {
  312. setStyle = "error";
  313. return closeStateErr;
  314. }
  315. }
  316. function closeState(type2, _stream, state) {
  317. if (type2 != "endTag") {
  318. setStyle = "error";
  319. return closeState;
  320. }
  321. popContext(state);
  322. return baseState;
  323. }
  324. function closeStateErr(type2, stream, state) {
  325. setStyle = "error";
  326. return closeState(type2, stream, state);
  327. }
  328. function attrState(type2, _stream, state) {
  329. if (type2 == "word") {
  330. setStyle = "attribute";
  331. return attrEqState;
  332. } else if (type2 == "endTag" || type2 == "selfcloseTag") {
  333. var tagName = state.tagName, tagStart = state.tagStart;
  334. state.tagName = state.tagStart = null;
  335. if (type2 == "selfcloseTag" || config.autoSelfClosers.hasOwnProperty(lower(tagName))) {
  336. maybePopContext(state, tagName);
  337. } else {
  338. maybePopContext(state, tagName);
  339. state.context = new Context(state, tagName, tagStart == state.indented);
  340. }
  341. return baseState;
  342. }
  343. setStyle = "error";
  344. return attrState;
  345. }
  346. function attrEqState(type2, stream, state) {
  347. if (type2 == "equals")
  348. return attrValueState;
  349. if (!config.allowMissing)
  350. setStyle = "error";
  351. return attrState(type2, stream, state);
  352. }
  353. function attrValueState(type2, stream, state) {
  354. if (type2 == "string")
  355. return attrContinuedState;
  356. if (type2 == "word" && config.allowUnquoted) {
  357. setStyle = "string";
  358. return attrState;
  359. }
  360. setStyle = "error";
  361. return attrState(type2, stream, state);
  362. }
  363. function attrContinuedState(type2, stream, state) {
  364. if (type2 == "string")
  365. return attrContinuedState;
  366. return attrState(type2, stream, state);
  367. }
  368. return {
  369. startState: function(baseIndent) {
  370. var state = {
  371. tokenize: inText,
  372. state: baseState,
  373. indented: baseIndent || 0,
  374. tagName: null,
  375. tagStart: null,
  376. context: null
  377. };
  378. if (baseIndent != null)
  379. state.baseIndent = baseIndent;
  380. return state;
  381. },
  382. token: function(stream, state) {
  383. if (!state.tagName && stream.sol())
  384. state.indented = stream.indentation();
  385. if (stream.eatSpace())
  386. return null;
  387. type = null;
  388. var style = state.tokenize(stream, state);
  389. if ((style || type) && style != "comment") {
  390. setStyle = null;
  391. state.state = state.state(type || style, stream, state);
  392. if (setStyle)
  393. style = setStyle == "error" ? style + " error" : setStyle;
  394. }
  395. return style;
  396. },
  397. indent: function(state, textAfter, fullLine) {
  398. var context = state.context;
  399. if (state.tokenize.isInAttribute) {
  400. if (state.tagStart == state.indented)
  401. return state.stringStartCol + 1;
  402. else
  403. return state.indented + indentUnit;
  404. }
  405. if (context && context.noIndent)
  406. return CodeMirror2.Pass;
  407. if (state.tokenize != inTag && state.tokenize != inText)
  408. return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
  409. if (state.tagName) {
  410. if (config.multilineTagIndentPastTag !== false)
  411. return state.tagStart + state.tagName.length + 2;
  412. else
  413. return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
  414. }
  415. if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter))
  416. return 0;
  417. var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
  418. if (tagAfter && tagAfter[1]) {
  419. while (context) {
  420. if (context.tagName == tagAfter[2]) {
  421. context = context.prev;
  422. break;
  423. } else if (config.implicitlyClosed.hasOwnProperty(lower(context.tagName))) {
  424. context = context.prev;
  425. } else {
  426. break;
  427. }
  428. }
  429. } else if (tagAfter) {
  430. while (context) {
  431. var grabbers = config.contextGrabbers[lower(context.tagName)];
  432. if (grabbers && grabbers.hasOwnProperty(lower(tagAfter[2])))
  433. context = context.prev;
  434. else
  435. break;
  436. }
  437. }
  438. while (context && context.prev && !context.startOfLine)
  439. context = context.prev;
  440. if (context)
  441. return context.indent + indentUnit;
  442. else
  443. return state.baseIndent || 0;
  444. },
  445. electricInput: /<\/[\s\w:]+>$/,
  446. blockCommentStart: "<!--",
  447. blockCommentEnd: "-->",
  448. configuration: config.htmlMode ? "html" : "xml",
  449. helperType: config.htmlMode ? "html" : "xml",
  450. skipAttribute: function(state) {
  451. if (state.state == attrValueState)
  452. state.state = attrState;
  453. },
  454. xmlCurrentTag: function(state) {
  455. return state.tagName ? { name: state.tagName, close: state.type == "closeTag" } : null;
  456. },
  457. xmlCurrentContext: function(state) {
  458. var context = [];
  459. for (var cx = state.context; cx; cx = cx.prev)
  460. context.push(cx.tagName);
  461. return context.reverse();
  462. }
  463. };
  464. });
  465. CodeMirror2.defineMIME("text/xml", "xml");
  466. CodeMirror2.defineMIME("application/xml", "xml");
  467. if (!CodeMirror2.mimeModes.hasOwnProperty("text/html"))
  468. CodeMirror2.defineMIME("text/html", { name: "xml", htmlMode: true });
  469. });
  470. }
  471. });
  472. // node_modules/.pnpm/codemirror@5.65.12/node_modules/codemirror/mode/htmlmixed/htmlmixed.js
  473. var require_htmlmixed = __commonJS({
  474. "node_modules/.pnpm/codemirror@5.65.12/node_modules/codemirror/mode/htmlmixed/htmlmixed.js"(exports, module) {
  475. (function(mod) {
  476. if (typeof exports == "object" && typeof module == "object")
  477. mod(require_codemirror(), require_xml(), require_javascript(), require_css());
  478. else if (typeof define == "function" && define.amd)
  479. define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
  480. else
  481. mod(CodeMirror);
  482. })(function(CodeMirror2) {
  483. "use strict";
  484. var defaultTags = {
  485. script: [
  486. ["lang", /(javascript|babel)/i, "javascript"],
  487. ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"],
  488. ["type", /./, "text/plain"],
  489. [null, null, "javascript"]
  490. ],
  491. style: [
  492. ["lang", /^css$/i, "css"],
  493. ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
  494. ["type", /./, "text/plain"],
  495. [null, null, "css"]
  496. ]
  497. };
  498. function maybeBackup(stream, pat, style) {
  499. var cur = stream.current(), close = cur.search(pat);
  500. if (close > -1) {
  501. stream.backUp(cur.length - close);
  502. } else if (cur.match(/<\/?$/)) {
  503. stream.backUp(cur.length);
  504. if (!stream.match(pat, false))
  505. stream.match(cur);
  506. }
  507. return style;
  508. }
  509. var attrRegexpCache = {};
  510. function getAttrRegexp(attr) {
  511. var regexp = attrRegexpCache[attr];
  512. if (regexp)
  513. return regexp;
  514. return attrRegexpCache[attr] = new RegExp("\\s+" + attr + `\\s*=\\s*('|")?([^'"]+)('|")?\\s*`);
  515. }
  516. function getAttrValue(text, attr) {
  517. var match = text.match(getAttrRegexp(attr));
  518. return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "";
  519. }
  520. function getTagRegexp(tagName, anchored) {
  521. return new RegExp((anchored ? "^" : "") + "</\\s*" + tagName + "\\s*>", "i");
  522. }
  523. function addTags(from, to) {
  524. for (var tag in from) {
  525. var dest = to[tag] || (to[tag] = []);
  526. var source = from[tag];
  527. for (var i = source.length - 1; i >= 0; i--)
  528. dest.unshift(source[i]);
  529. }
  530. }
  531. function findMatchingMode(tagInfo, tagText) {
  532. for (var i = 0; i < tagInfo.length; i++) {
  533. var spec = tagInfo[i];
  534. if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0])))
  535. return spec[2];
  536. }
  537. }
  538. CodeMirror2.defineMode("htmlmixed", function(config, parserConfig) {
  539. var htmlMode = CodeMirror2.getMode(config, {
  540. name: "xml",
  541. htmlMode: true,
  542. multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
  543. multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag,
  544. allowMissingTagName: parserConfig.allowMissingTagName
  545. });
  546. var tags = {};
  547. var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
  548. addTags(defaultTags, tags);
  549. if (configTags)
  550. addTags(configTags, tags);
  551. if (configScript)
  552. for (var i = configScript.length - 1; i >= 0; i--)
  553. tags.script.unshift(["type", configScript[i].matches, configScript[i].mode]);
  554. function html(stream, state) {
  555. var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName;
  556. if (tag && !/[<>\s\/]/.test(stream.current()) && (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) && tags.hasOwnProperty(tagName)) {
  557. state.inTag = tagName + " ";
  558. } else if (state.inTag && tag && />$/.test(stream.current())) {
  559. var inTag = /^([\S]+) (.*)/.exec(state.inTag);
  560. state.inTag = null;
  561. var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2]);
  562. var mode = CodeMirror2.getMode(config, modeSpec);
  563. var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
  564. state.token = function(stream2, state2) {
  565. if (stream2.match(endTagA, false)) {
  566. state2.token = html;
  567. state2.localState = state2.localMode = null;
  568. return null;
  569. }
  570. return maybeBackup(stream2, endTag, state2.localMode.token(stream2, state2.localState));
  571. };
  572. state.localMode = mode;
  573. state.localState = CodeMirror2.startState(mode, htmlMode.indent(state.htmlState, "", ""));
  574. } else if (state.inTag) {
  575. state.inTag += stream.current();
  576. if (stream.eol())
  577. state.inTag += " ";
  578. }
  579. return style;
  580. }
  581. ;
  582. return {
  583. startState: function() {
  584. var state = CodeMirror2.startState(htmlMode);
  585. return { token: html, inTag: null, localMode: null, localState: null, htmlState: state };
  586. },
  587. copyState: function(state) {
  588. var local;
  589. if (state.localState) {
  590. local = CodeMirror2.copyState(state.localMode, state.localState);
  591. }
  592. return {
  593. token: state.token,
  594. inTag: state.inTag,
  595. localMode: state.localMode,
  596. localState: local,
  597. htmlState: CodeMirror2.copyState(htmlMode, state.htmlState)
  598. };
  599. },
  600. token: function(stream, state) {
  601. return state.token(stream, state);
  602. },
  603. indent: function(state, textAfter, line) {
  604. if (!state.localMode || /^\s*<\//.test(textAfter))
  605. return htmlMode.indent(state.htmlState, textAfter, line);
  606. else if (state.localMode.indent)
  607. return state.localMode.indent(state.localState, textAfter, line);
  608. else
  609. return CodeMirror2.Pass;
  610. },
  611. innerMode: function(state) {
  612. return { state: state.localState || state.htmlState, mode: state.localMode || htmlMode };
  613. }
  614. };
  615. }, "xml", "javascript", "css");
  616. CodeMirror2.defineMIME("text/html", "htmlmixed");
  617. });
  618. }
  619. });
  620. export default require_htmlmixed();
  621. //# sourceMappingURL=codemirror_mode_htmlmixed_htmlmixed.js.map