@codemirror/lang-css
Advanced tools
Comparing version 6.1.0 to 6.1.1
@@ -0,1 +1,7 @@ | ||
## 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) | ||
@@ -2,0 +8,0 @@ |
@@ -145,2 +145,10 @@ import { parser } from '@lezer/css'; | ||
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) { | ||
@@ -182,6 +190,6 @@ if (node.to - node.from > 4096) { | ||
const cssCompletionSource = context => { | ||
var _a; | ||
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 && ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.name) == "Block") | ||
if (node.name == "PropertyName" || | ||
(isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name)) | ||
return { from: node.from, options: properties(), validFor: identifier }; | ||
@@ -194,3 +202,3 @@ if (node.name == "ValueName") | ||
return { from: node.name == "VariableName" ? node.from : pos, | ||
options: variableNames(state.doc, syntaxTree(state).topNode), | ||
options: variableNames(state.doc, astTop(node)), | ||
validFor: variable }; | ||
@@ -210,3 +218,3 @@ if (node.name == "TagName") { | ||
return { from: pos, options: values, validFor: identifier }; | ||
if (above.name == "Block") | ||
if (above.name == "Block" || above.name == "Styles") | ||
return { from: pos, options: properties(), validFor: identifier }; | ||
@@ -213,0 +221,0 @@ return null; |
{ | ||
"name": "@codemirror/lang-css", | ||
"version": "6.1.0", | ||
"version": "6.1.1", | ||
"description": "CSS language support for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
36407
515