Premier commit déjà bien avancé

This commit is contained in:
2025-11-10 18:33:24 +01:00
commit db4f0508cb
652 changed files with 440521 additions and 0 deletions

View File

@ -0,0 +1,16 @@
name: Trigger CI
on: push
jobs:
build:
name: Dispatch to main repo
runs-on: ubuntu-latest
steps:
- name: Emit repository_dispatch
uses: mvasigh/dispatch-action@main
with:
# You should create a personal access token and store it in your repository
token: ${{ secrets.DISPATCH_AUTH }}
repo: dev
owner: codemirror
event_type: push

106
frontend/node_modules/@codemirror/lang-css/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,106 @@
## 6.3.1 (2024-11-26)
### Bug fixes
When completing a property name, insert a colon and space after the name.
## 6.3.0 (2024-09-07)
### New features
CSS autocompletion now completes `@`-keywords.
## 6.2.1 (2023-08-04)
### Bug fixes
Allow keyframe blocks to be code-folded.
## 6.2.0 (2023-04-26)
### Bug fixes
Explicitly list @lezer/common as a package dependency.
### New features
Export `defineCSSCompletionSource`, which allows one to define a CSS-style completion source for dialects with their own variable syntax.
## 6.1.1 (2023-03-08)
### Bug fixes
Provide better completions when completing directly in a `Styles` top node.
## 6.1.0 (2023-03-06)
### New features
CSS completion can now complete variable names.
## 6.0.2 (2023-01-28)
### Bug fixes
Fetch the available CSS property names in a way that works on Chrome.
## 6.0.1 (2022-10-24)
### Bug fixes
CSS completion now supports a number of additional recent and semi-standardized pseudo-class names.
## 6.0.0 (2022-06-08)
### Breaking changes
Update dependencies to 6.0.0
## 0.20.0 (2022-04-20)
### Breaking changes
Update dependencies to 0.20.0
## 0.19.3 (2021-09-24)
### Bug fixes
Use more appropriate highlighting tags for attribute names, tag names, and CSS variables.
## 0.19.2 (2021-09-22)
### New features
The package now exports a completion source function, rather than a prebuilt completion extension.
## 0.19.1 (2021-08-11)
### Bug fixes
Fix incorrect versions for @lezer dependencies.
## 0.19.0 (2021-08-11)
### Breaking changes
Update dependencies to 0.19.0
## 0.18.0 (2021-03-03)
### Breaking changes
Update dependencies to 0.18.
## 0.17.1 (2021-01-06)
### New features
The package now also exports a CommonJS module.
## 0.17.0 (2020-12-29)
### Breaking changes
First numbered release.

21
frontend/node_modules/@codemirror/lang-css/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

50
frontend/node_modules/@codemirror/lang-css/README.md generated vendored Normal file
View File

@ -0,0 +1,50 @@
<!-- NOTE: README.md is generated from src/README.md -->
# @codemirror/lang-css [![NPM version](https://img.shields.io/npm/v/@codemirror/lang-css.svg)](https://www.npmjs.org/package/@codemirror/lang-css)
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-css/blob/main/CHANGELOG.md) ]
This package implements CSS language support for the
[CodeMirror](https://codemirror.net/) code editor.
The [project page](https://codemirror.net/) has more information, a
number of [examples](https://codemirror.net/examples/) and the
[documentation](https://codemirror.net/docs/).
This code is released under an
[MIT license](https://github.com/codemirror/lang-css/tree/main/LICENSE).
We aim to be an inclusive, welcoming community. To make that explicit,
we have a [code of
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
to communication around the project.
## API Reference
<dl>
<dt id="user-content-css">
<code><strong><a href="#user-content-css">css</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
<dd><p>Language support for CSS.</p>
</dd>
<dt id="user-content-csslanguage">
<code><strong><a href="#user-content-csslanguage">cssLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
<dd><p>A language provider based on the <a href="https://github.com/lezer-parser/css">Lezer CSS
parser</a>, extended with
highlighting and indentation information.</p>
</dd>
<dt id="user-content-csscompletionsource">
<code><strong><a href="#user-content-csscompletionsource">cssCompletionSource</a></strong>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
<dd><p>CSS property, variable, and value keyword completion source.</p>
</dd>
<dt id="user-content-definecsscompletionsource">
<code><strong><a href="#user-content-definecsscompletionsource">defineCSSCompletionSource</a></strong>(<a id="user-content-definecsscompletionsource^isvariable" href="#user-content-definecsscompletionsource^isvariable">isVariable</a>: fn(<a id="user-content-definecsscompletionsource^isvariable^node" href="#user-content-definecsscompletionsource^isvariable^node">node</a>: <a href="https://lezer.codemirror.net/docs/ref/#common.SyntaxNodeRef">SyntaxNodeRef</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
<dd><p>Create a completion source for a CSS dialect, providing a
predicate for determining what kind of syntax node can act as a
completable variable. This is used by language modes like Sass and
Less to reuse this package's completion logic.</p>
</dd>
</dl>

View File

@ -0,0 +1,269 @@
'use strict';
var css$1 = require('@lezer/css');
var language = require('@codemirror/language');
var common = require('@lezer/common');
let _properties = null;
function properties() {
if (!_properties && typeof document == "object" && document.body) {
let { style } = document.body, names = [], seen = new Set;
for (let prop in style)
if (prop != "cssText" && prop != "cssFloat") {
if (typeof style[prop] == "string") {
if (/[A-Z]/.test(prop))
prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase());
if (!seen.has(prop)) {
names.push(prop);
seen.add(prop);
}
}
}
_properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " }));
}
return _properties || [];
}
const pseudoClasses = [
"active", "after", "any-link", "autofill", "backdrop", "before",
"checked", "cue", "default", "defined", "disabled", "empty",
"enabled", "file-selector-button", "first", "first-child",
"first-letter", "first-line", "first-of-type", "focus",
"focus-visible", "focus-within", "fullscreen", "has", "host",
"host-context", "hover", "in-range", "indeterminate", "invalid",
"is", "lang", "last-child", "last-of-type", "left", "link", "marker",
"modal", "not", "nth-child", "nth-last-child", "nth-last-of-type",
"nth-of-type", "only-child", "only-of-type", "optional", "out-of-range",
"part", "placeholder", "placeholder-shown", "read-only", "read-write",
"required", "right", "root", "scope", "selection", "slotted", "target",
"target-text", "valid", "visited", "where"
].map(name => ({ type: "class", label: name }));
const values = [
"above", "absolute", "activeborder", "additive", "activecaption", "after-white-space",
"ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always",
"antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column",
"avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below",
"bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize",
"caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle",
"cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn",
"color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content",
"contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover",
"crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in",
"destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed",
"disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize",
"ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end",
"ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion",
"expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box",
"fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from",
"geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide",
"higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext",
"inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid",
"inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all",
"landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear",
"linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower",
"lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation",
"match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic",
"mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower",
"ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none",
"normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize",
"oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside",
"outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused",
"perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait",
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio",
"read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat",
"repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round",
"row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation",
"scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position",
"se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show",
"single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps",
"small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out",
"source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start",
"static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks",
"super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell",
"table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row",
"table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin",
"threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top",
"transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent",
"ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin",
"uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill",
"visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe",
"windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small"
].map(name => ({ type: "keyword", label: name })).concat([
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
"whitesmoke", "yellow", "yellowgreen"
].map(name => ({ type: "constant", label: name })));
const tags = [
"a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body",
"br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del",
"details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer",
"form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe",
"img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output",
"p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary",
"sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul"
].map(name => ({ type: "type", label: name }));
const atRules = [
"@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values",
"@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page",
"@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition"
].map(label => ({ type: "keyword", label }));
const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/;
function isVarArg(node, doc) {
var _a;
if (node.name == "(" || node.type.isError)
node = node.parent || node;
if (node.name != "ArgList")
return false;
let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild;
if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee")
return false;
return doc.sliceString(callee.from, callee.to) == "var";
}
const VariablesByNode = new common.NodeWeakMap();
const declSelector = ["Declaration"];
function astTop(node) {
for (let cur = node;;) {
if (cur.type.isTop)
return cur;
if (!(cur = cur.parent))
return node;
}
}
function variableNames(doc, node, isVariable) {
if (node.to - node.from > 4096) {
let known = VariablesByNode.get(node);
if (known)
return known;
let result = [], seen = new Set, cursor = node.cursor(common.IterMode.IncludeAnonymous);
if (cursor.firstChild())
do {
for (let option of variableNames(doc, cursor.node, isVariable))
if (!seen.has(option.label)) {
seen.add(option.label);
result.push(option);
}
} while (cursor.nextSibling());
VariablesByNode.set(node, result);
return result;
}
else {
let result = [], seen = new Set;
node.cursor().iterate(node => {
var _a;
if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") {
let name = doc.sliceString(node.from, node.to);
if (!seen.has(name)) {
seen.add(name);
result.push({ label: name, type: "variable" });
}
}
});
return result;
}
}
/**
Create a completion source for a CSS dialect, providing a
predicate for determining what kind of syntax node can act as a
completable variable. This is used by language modes like Sass and
Less to reuse this package's completion logic.
*/
const defineCSSCompletionSource = (isVariable) => context => {
let { state, pos } = context, node = language.syntaxTree(state).resolveInner(pos, -1);
let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-";
if (node.name == "PropertyName" ||
(isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name))
return { from: node.from, options: properties(), validFor: identifier };
if (node.name == "ValueName")
return { from: node.from, options: values, validFor: identifier };
if (node.name == "PseudoClassName")
return { from: node.from, options: pseudoClasses, validFor: identifier };
if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc))
return { from: isVariable(node) || isDash ? node.from : pos,
options: variableNames(state.doc, astTop(node), isVariable),
validFor: variable };
if (node.name == "TagName") {
for (let { parent } = node; parent; parent = parent.parent)
if (parent.name == "Block")
return { from: node.from, options: properties(), validFor: identifier };
return { from: node.from, options: tags, validFor: identifier };
}
if (node.name == "AtKeyword")
return { from: node.from, options: atRules, validFor: identifier };
if (!context.explicit)
return null;
let above = node.resolve(pos), before = above.childBefore(pos);
if (before && before.name == ":" && above.name == "PseudoClassSelector")
return { from: pos, options: pseudoClasses, validFor: identifier };
if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList")
return { from: pos, options: values, validFor: identifier };
if (above.name == "Block" || above.name == "Styles")
return { from: pos, options: properties(), validFor: identifier };
return null;
};
/**
CSS property, variable, and value keyword completion source.
*/
const cssCompletionSource = defineCSSCompletionSource(n => n.name == "VariableName");
/**
A language provider based on the [Lezer CSS
parser](https://github.com/lezer-parser/css), extended with
highlighting and indentation information.
*/
const cssLanguage = language.LRLanguage.define({
name: "css",
parser: css$1.parser.configure({
props: [
language.indentNodeProp.add({
Declaration: language.continuedIndent()
}),
language.foldNodeProp.add({
"Block KeyframeList": language.foldInside
})
]
}),
languageData: {
commentTokens: { block: { open: "/*", close: "*/" } },
indentOnInput: /^\s*\}$/,
wordChars: "-"
}
});
/**
Language support for CSS.
*/
function css() {
return new language.LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource }));
}
exports.css = css;
exports.cssCompletionSource = cssCompletionSource;
exports.cssLanguage = cssLanguage;
exports.defineCSSCompletionSource = defineCSSCompletionSource;

View File

@ -0,0 +1,28 @@
import { LRLanguage, LanguageSupport } from '@codemirror/language';
import { CompletionSource } from '@codemirror/autocomplete';
import { SyntaxNodeRef } from '@lezer/common';
/**
Create a completion source for a CSS dialect, providing a
predicate for determining what kind of syntax node can act as a
completable variable. This is used by language modes like Sass and
Less to reuse this package's completion logic.
*/
declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource;
/**
CSS property, variable, and value keyword completion source.
*/
declare const cssCompletionSource: CompletionSource;
/**
A language provider based on the [Lezer CSS
parser](https://github.com/lezer-parser/css), extended with
highlighting and indentation information.
*/
declare const cssLanguage: LRLanguage;
/**
Language support for CSS.
*/
declare function css(): LanguageSupport;
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource };

View File

@ -0,0 +1,28 @@
import { LRLanguage, LanguageSupport } from '@codemirror/language';
import { CompletionSource } from '@codemirror/autocomplete';
import { SyntaxNodeRef } from '@lezer/common';
/**
Create a completion source for a CSS dialect, providing a
predicate for determining what kind of syntax node can act as a
completable variable. This is used by language modes like Sass and
Less to reuse this package's completion logic.
*/
declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource;
/**
CSS property, variable, and value keyword completion source.
*/
declare const cssCompletionSource: CompletionSource;
/**
A language provider based on the [Lezer CSS
parser](https://github.com/lezer-parser/css), extended with
highlighting and indentation information.
*/
declare const cssLanguage: LRLanguage;
/**
Language support for CSS.
*/
declare function css(): LanguageSupport;
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource };

View File

@ -0,0 +1,264 @@
import { parser } from '@lezer/css';
import { syntaxTree, LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
import { NodeWeakMap, IterMode } from '@lezer/common';
let _properties = null;
function properties() {
if (!_properties && typeof document == "object" && document.body) {
let { style } = document.body, names = [], seen = new Set;
for (let prop in style)
if (prop != "cssText" && prop != "cssFloat") {
if (typeof style[prop] == "string") {
if (/[A-Z]/.test(prop))
prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase());
if (!seen.has(prop)) {
names.push(prop);
seen.add(prop);
}
}
}
_properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " }));
}
return _properties || [];
}
const pseudoClasses = /*@__PURE__*/[
"active", "after", "any-link", "autofill", "backdrop", "before",
"checked", "cue", "default", "defined", "disabled", "empty",
"enabled", "file-selector-button", "first", "first-child",
"first-letter", "first-line", "first-of-type", "focus",
"focus-visible", "focus-within", "fullscreen", "has", "host",
"host-context", "hover", "in-range", "indeterminate", "invalid",
"is", "lang", "last-child", "last-of-type", "left", "link", "marker",
"modal", "not", "nth-child", "nth-last-child", "nth-last-of-type",
"nth-of-type", "only-child", "only-of-type", "optional", "out-of-range",
"part", "placeholder", "placeholder-shown", "read-only", "read-write",
"required", "right", "root", "scope", "selection", "slotted", "target",
"target-text", "valid", "visited", "where"
].map(name => ({ type: "class", label: name }));
const values = /*@__PURE__*/[
"above", "absolute", "activeborder", "additive", "activecaption", "after-white-space",
"ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always",
"antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column",
"avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below",
"bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize",
"caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle",
"cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn",
"color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content",
"contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover",
"crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in",
"destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed",
"disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize",
"ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end",
"ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion",
"expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box",
"fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from",
"geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide",
"higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext",
"inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid",
"inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all",
"landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear",
"linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower",
"lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation",
"match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic",
"mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower",
"ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none",
"normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize",
"oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside",
"outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused",
"perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait",
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio",
"read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat",
"repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round",
"row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation",
"scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position",
"se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show",
"single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps",
"small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out",
"source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start",
"static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks",
"super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell",
"table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row",
"table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin",
"threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top",
"transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent",
"ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin",
"uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill",
"visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe",
"windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small"
].map(name => ({ type: "keyword", label: name })).concat(/*@__PURE__*/[
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
"whitesmoke", "yellow", "yellowgreen"
].map(name => ({ type: "constant", label: name })));
const tags = /*@__PURE__*/[
"a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body",
"br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del",
"details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer",
"form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe",
"img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output",
"p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary",
"sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul"
].map(name => ({ type: "type", label: name }));
const atRules = /*@__PURE__*/[
"@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values",
"@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page",
"@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition"
].map(label => ({ type: "keyword", label }));
const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/;
function isVarArg(node, doc) {
var _a;
if (node.name == "(" || node.type.isError)
node = node.parent || node;
if (node.name != "ArgList")
return false;
let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild;
if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee")
return false;
return doc.sliceString(callee.from, callee.to) == "var";
}
const VariablesByNode = /*@__PURE__*/new NodeWeakMap();
const declSelector = ["Declaration"];
function astTop(node) {
for (let cur = node;;) {
if (cur.type.isTop)
return cur;
if (!(cur = cur.parent))
return node;
}
}
function variableNames(doc, node, isVariable) {
if (node.to - node.from > 4096) {
let known = VariablesByNode.get(node);
if (known)
return known;
let result = [], seen = new Set, cursor = node.cursor(IterMode.IncludeAnonymous);
if (cursor.firstChild())
do {
for (let option of variableNames(doc, cursor.node, isVariable))
if (!seen.has(option.label)) {
seen.add(option.label);
result.push(option);
}
} while (cursor.nextSibling());
VariablesByNode.set(node, result);
return result;
}
else {
let result = [], seen = new Set;
node.cursor().iterate(node => {
var _a;
if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") {
let name = doc.sliceString(node.from, node.to);
if (!seen.has(name)) {
seen.add(name);
result.push({ label: name, type: "variable" });
}
}
});
return result;
}
}
/**
Create a completion source for a CSS dialect, providing a
predicate for determining what kind of syntax node can act as a
completable variable. This is used by language modes like Sass and
Less to reuse this package's completion logic.
*/
const defineCSSCompletionSource = (isVariable) => context => {
let { state, pos } = context, node = syntaxTree(state).resolveInner(pos, -1);
let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-";
if (node.name == "PropertyName" ||
(isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name))
return { from: node.from, options: properties(), validFor: identifier };
if (node.name == "ValueName")
return { from: node.from, options: values, validFor: identifier };
if (node.name == "PseudoClassName")
return { from: node.from, options: pseudoClasses, validFor: identifier };
if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc))
return { from: isVariable(node) || isDash ? node.from : pos,
options: variableNames(state.doc, astTop(node), isVariable),
validFor: variable };
if (node.name == "TagName") {
for (let { parent } = node; parent; parent = parent.parent)
if (parent.name == "Block")
return { from: node.from, options: properties(), validFor: identifier };
return { from: node.from, options: tags, validFor: identifier };
}
if (node.name == "AtKeyword")
return { from: node.from, options: atRules, validFor: identifier };
if (!context.explicit)
return null;
let above = node.resolve(pos), before = above.childBefore(pos);
if (before && before.name == ":" && above.name == "PseudoClassSelector")
return { from: pos, options: pseudoClasses, validFor: identifier };
if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList")
return { from: pos, options: values, validFor: identifier };
if (above.name == "Block" || above.name == "Styles")
return { from: pos, options: properties(), validFor: identifier };
return null;
};
/**
CSS property, variable, and value keyword completion source.
*/
const cssCompletionSource = /*@__PURE__*/defineCSSCompletionSource(n => n.name == "VariableName");
/**
A language provider based on the [Lezer CSS
parser](https://github.com/lezer-parser/css), extended with
highlighting and indentation information.
*/
const cssLanguage = /*@__PURE__*/LRLanguage.define({
name: "css",
parser: /*@__PURE__*/parser.configure({
props: [
/*@__PURE__*/indentNodeProp.add({
Declaration: /*@__PURE__*/continuedIndent()
}),
/*@__PURE__*/foldNodeProp.add({
"Block KeyframeList": foldInside
})
]
}),
languageData: {
commentTokens: { block: { open: "/*", close: "*/" } },
indentOnInput: /^\s*\}$/,
wordChars: "-"
}
});
/**
Language support for CSS.
*/
function css() {
return new LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource }));
}
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource };

View File

@ -0,0 +1,42 @@
{
"name": "@codemirror/lang-css",
"version": "6.3.1",
"description": "CSS language support for the CodeMirror code editor",
"scripts": {
"test": "cm-runtests",
"prepare": "cm-buildhelper src/css.ts"
},
"keywords": [
"editor",
"code"
],
"author": {
"name": "Marijn Haverbeke",
"email": "marijn@haverbeke.berlin",
"url": "http://marijnhaverbeke.nl"
},
"type": "module",
"main": "dist/index.cjs",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"types": "dist/index.d.ts",
"module": "dist/index.js",
"sideEffects": false,
"license": "MIT",
"dependencies": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@lezer/common": "^1.0.2",
"@lezer/css": "^1.1.7"
},
"devDependencies": {
"@codemirror/buildhelper": "^1.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/codemirror/lang-css.git"
}
}