LaravelTest
66 строк · 2.5 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"), require("../../mode/css/css"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror", "../../mode/css/css"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14var pseudoClasses = {"active":1, "after":1, "before":1, "checked":1, "default":1,15"disabled":1, "empty":1, "enabled":1, "first-child":1, "first-letter":1,16"first-line":1, "first-of-type":1, "focus":1, "hover":1, "in-range":1,17"indeterminate":1, "invalid":1, "lang":1, "last-child":1, "last-of-type":1,18"link":1, "not":1, "nth-child":1, "nth-last-child":1, "nth-last-of-type":1,19"nth-of-type":1, "only-of-type":1, "only-child":1, "optional":1, "out-of-range":1,20"placeholder":1, "read-only":1, "read-write":1, "required":1, "root":1,21"selection":1, "target":1, "valid":1, "visited":122};23
24CodeMirror.registerHelper("hint", "css", function(cm) {25var cur = cm.getCursor(), token = cm.getTokenAt(cur);26var inner = CodeMirror.innerMode(cm.getMode(), token.state);27if (inner.mode.name != "css") return;28
29if (token.type == "keyword" && "!important".indexOf(token.string) == 0)30return {list: ["!important"], from: CodeMirror.Pos(cur.line, token.start),31to: CodeMirror.Pos(cur.line, token.end)};32
33var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);34if (/[^\w$_-]/.test(word)) {35word = ""; start = end = cur.ch;36}37
38var spec = CodeMirror.resolveMode("text/css");39
40var result = [];41function add(keywords) {42for (var name in keywords)43if (!word || name.lastIndexOf(word, 0) == 0)44result.push(name);45}46
47var st = inner.state.state;48if (st == "pseudo" || token.type == "variable-3") {49add(pseudoClasses);50} else if (st == "block" || st == "maybeprop") {51add(spec.propertyKeywords);52} else if (st == "prop" || st == "parens" || st == "at" || st == "params") {53add(spec.valueKeywords);54add(spec.colorKeywords);55} else if (st == "media" || st == "media_parens") {56add(spec.mediaTypes);57add(spec.mediaFeatures);58}59
60if (result.length) return {61list: result,62from: CodeMirror.Pos(cur.line, start),63to: CodeMirror.Pos(cur.line, end)64};65});66});67