@codemirror/lang-html
Advanced tools
Comparing version 6.4.3 to 6.4.4
@@ -0,1 +1,7 @@ | ||
## 6.4.4 (2023-06-05) | ||
### Bug fixes | ||
Fix a bug where the completed tag names didn't take into account the parent node's declared children in the schema in some circumstances. | ||
## 6.4.3 (2023-03-27) | ||
@@ -2,0 +8,0 @@ |
@@ -367,8 +367,8 @@ import { parser, configureNesting } from '@lezer/html'; | ||
function findParentElement(tree, skip = false) { | ||
for (let cur = tree.parent; cur; cur = cur.parent) | ||
if (cur.name == "Element") { | ||
for (; tree; tree = tree.parent) | ||
if (tree.name == "Element") { | ||
if (skip) | ||
skip = false; | ||
else | ||
return cur; | ||
return tree; | ||
} | ||
@@ -378,3 +378,3 @@ return null; | ||
function allowedChildren(doc, tree, schema) { | ||
let parentInfo = schema.tags[elementName(doc, findParentElement(tree, true))]; | ||
let parentInfo = schema.tags[elementName(doc, findParentElement(tree))]; | ||
return (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.children) || schema.allTags; | ||
@@ -384,3 +384,3 @@ } | ||
let open = []; | ||
for (let parent = tree; parent = findParentElement(parent);) { | ||
for (let parent = findParentElement(tree); parent && !parent.type.isTop; parent = findParentElement(parent.parent)) { | ||
let tagName = elementName(doc, parent); | ||
@@ -397,4 +397,5 @@ if (tagName && parent.lastChild.name == "CloseTag") | ||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">"; | ||
let parent = findParentElement(tree, true); | ||
return { from, to, | ||
options: allowedChildren(state.doc, tree, schema).map(tagName => ({ label: tagName, type: "type" })).concat(openTags(state.doc, tree).map((tag, i) => ({ label: "/" + tag, apply: "/" + tag + end, | ||
options: allowedChildren(state.doc, parent, schema).map(tagName => ({ label: tagName, type: "type" })).concat(openTags(state.doc, tree).map((tag, i) => ({ label: "/" + tag, apply: "/" + tag + end, | ||
type: "type", boost: 99 - i }))), | ||
@@ -401,0 +402,0 @@ validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/ }; |
{ | ||
"name": "@codemirror/lang-html", | ||
"version": "6.4.3", | ||
"version": "6.4.4", | ||
"description": "HTML language support for the CodeMirror code editor", | ||
@@ -40,3 +40,3 @@ "scripts": { | ||
"devDependencies": { | ||
"@codemirror/buildhelper": "^0.1.5" | ||
"@codemirror/buildhelper": "^1.0.0" | ||
}, | ||
@@ -43,0 +43,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
77052
9
1423