comparison .cms/lib/codemirror/mode/vue/vue.js @ 0:78edf6b517a0 draft

24.10
author Coffee CMS <info@coffee-cms.ru>
date Fri, 11 Oct 2024 22:40:23 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:78edf6b517a0
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: https://codemirror.net/5/LICENSE
3
4 (function (mod) {
5 "use strict";
6 if (typeof exports === "object" && typeof module === "object") {// CommonJS
7 mod(require("../../lib/codemirror"),
8 require("../../addon/mode/overlay"),
9 require("../xml/xml"),
10 require("../javascript/javascript"),
11 require("../coffeescript/coffeescript"),
12 require("../css/css"),
13 require("../sass/sass"),
14 require("../stylus/stylus"),
15 require("../pug/pug"),
16 require("../handlebars/handlebars"));
17 } else if (typeof define === "function" && define.amd) { // AMD
18 define(["../../lib/codemirror",
19 "../../addon/mode/overlay",
20 "../xml/xml",
21 "../javascript/javascript",
22 "../coffeescript/coffeescript",
23 "../css/css",
24 "../sass/sass",
25 "../stylus/stylus",
26 "../pug/pug",
27 "../handlebars/handlebars"], mod);
28 } else { // Plain browser env
29 mod(CodeMirror);
30 }
31 })(function (CodeMirror) {
32 var tagLanguages = {
33 script: [
34 ["lang", /coffee(script)?/, "coffeescript"],
35 ["type", /^(?:text|application)\/(?:x-)?coffee(?:script)?$/, "coffeescript"],
36 ["lang", /^babel$/, "javascript"],
37 ["type", /^text\/babel$/, "javascript"],
38 ["type", /^text\/ecmascript-\d+$/, "javascript"]
39 ],
40 style: [
41 ["lang", /^stylus$/i, "stylus"],
42 ["lang", /^sass$/i, "sass"],
43 ["lang", /^less$/i, "text/x-less"],
44 ["lang", /^scss$/i, "text/x-scss"],
45 ["type", /^(text\/)?(x-)?styl(us)?$/i, "stylus"],
46 ["type", /^text\/sass/i, "sass"],
47 ["type", /^(text\/)?(x-)?scss$/i, "text/x-scss"],
48 ["type", /^(text\/)?(x-)?less$/i, "text/x-less"]
49 ],
50 template: [
51 ["lang", /^vue-template$/i, "vue"],
52 ["lang", /^pug$/i, "pug"],
53 ["lang", /^handlebars$/i, "handlebars"],
54 ["type", /^(text\/)?(x-)?pug$/i, "pug"],
55 ["type", /^text\/x-handlebars-template$/i, "handlebars"],
56 [null, null, "vue-template"]
57 ]
58 };
59
60 CodeMirror.defineMode("vue-template", function (config, parserConfig) {
61 var mustacheOverlay = {
62 token: function (stream) {
63 if (stream.match(/^\{\{.*?\}\}/)) return "meta mustache";
64 while (stream.next() && !stream.match("{{", false)) {}
65 return null;
66 }
67 };
68 return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay);
69 });
70
71 CodeMirror.defineMode("vue", function (config) {
72 return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages});
73 }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars");
74
75 CodeMirror.defineMIME("script/x-vue", "vue");
76 CodeMirror.defineMIME("text/x-vue", "vue");
77 });