@codemirror/lang-html
Advanced tools
Comparing version 0.18.0 to 0.18.1
@@ -0,1 +1,13 @@ | ||
## 0.18.1 (2021-05-05) | ||
### Bug fixes | ||
Fix an issue where the completer would sometimes try to complete an opening tag to its own close tag. | ||
Fix a bug that would sometimes produce the wrong indentation in HTML elements. | ||
Fix a bug that broke tag-specific attribute completion in tags like `<input>` or `<script>`. | ||
Move a new version of lezer-html which solves some issues with autocompletion. | ||
## 0.18.0 (2021-03-03) | ||
@@ -2,0 +14,0 @@ |
@@ -1,8 +0,23 @@ | ||
import { Extension } from '@codemirror/state'; | ||
import * as _codemirror_state from '@codemirror/state'; | ||
import { LezerLanguage, LanguageSupport } from '@codemirror/language'; | ||
/** | ||
A language provider based on the [Lezer HTML | ||
parser](https://github.com/lezer-parser/html), wired up with the | ||
JavaScript and CSS parsers to parse the content of `<script>` and | ||
`<style>` tags. | ||
*/ | ||
declare const htmlLanguage: LezerLanguage; | ||
declare const htmlCompletion: Extension; | ||
/** | ||
HTML tag completion. Opens and closes tags and attributes in a | ||
context-aware way. | ||
*/ | ||
declare const htmlCompletion: _codemirror_state.Extension; | ||
/** | ||
Language support for HTML, including | ||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and | ||
CSS support extensions. | ||
*/ | ||
declare function html(): LanguageSupport; | ||
export { html, htmlCompletion, htmlLanguage }; |
@@ -321,3 +321,3 @@ import { parser, configureNesting } from 'lezer-html'; | ||
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"], | ||
role: "alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "), | ||
role: /*@__PURE__*/"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "), | ||
"aria-activedescendant": null, | ||
@@ -358,9 +358,7 @@ "aria-atomic": Bool, | ||
}; | ||
const AllTags = Object.keys(Tags); | ||
const GlobalAttrNames = Object.keys(GlobalAttrs); | ||
const AllTags = /*@__PURE__*/Object.keys(Tags); | ||
const GlobalAttrNames = /*@__PURE__*/Object.keys(GlobalAttrs); | ||
function elementName(doc, tree) { | ||
let tag = tree.firstChild; | ||
if (!tag || tag.name != "OpenTag") | ||
return ""; | ||
let name = tag.getChild("TagName"); | ||
let name = tag && tag.getChild("TagName"); | ||
return name ? doc.sliceString(name.from, name.to) : ""; | ||
@@ -389,3 +387,3 @@ } | ||
break; | ||
if (tagName && open.indexOf(tagName) < 0) | ||
if (tagName && open.indexOf(tagName) < 0 && (tree.name == "EndTag" || tree.from >= parent.firstChild.to)) | ||
open.push(tagName); | ||
@@ -478,10 +476,12 @@ } | ||
/// A language provider based on the [Lezer HTML | ||
/// parser](https://github.com/lezer-parser/html), wired up with the | ||
/// JavaScript and CSS parsers to parse the content of `<script>` and | ||
/// `<style>` tags. | ||
const htmlLanguage = LezerLanguage.define({ | ||
parser: parser.configure({ | ||
/** | ||
A language provider based on the [Lezer HTML | ||
parser](https://github.com/lezer-parser/html), wired up with the | ||
JavaScript and CSS parsers to parse the content of `<script>` and | ||
`<style>` tags. | ||
*/ | ||
const htmlLanguage = /*@__PURE__*/LezerLanguage.define({ | ||
parser: /*@__PURE__*/parser.configure({ | ||
props: [ | ||
indentNodeProp.add({ | ||
/*@__PURE__*/indentNodeProp.add({ | ||
Element(context) { | ||
@@ -491,3 +491,3 @@ let after = /^(\s*)(<\/)?/.exec(context.textAfter); | ||
return context.continue(); | ||
return context.lineIndent(context.state.doc.lineAt(context.node.from)) + (after[1] ? 0 : context.unit); | ||
return context.lineIndent(context.state.doc.lineAt(context.node.from)) + (after[2] ? 0 : context.unit); | ||
}, | ||
@@ -512,3 +512,3 @@ "OpenTag CloseTag SelfClosingTag"(context) { | ||
}), | ||
foldNodeProp.add({ | ||
/*@__PURE__*/foldNodeProp.add({ | ||
Element(node) { | ||
@@ -521,3 +521,3 @@ let first = node.firstChild, last = node.lastChild; | ||
}), | ||
styleTags({ | ||
/*@__PURE__*/styleTags({ | ||
AttributeValue: tags.string, | ||
@@ -537,3 +537,3 @@ "Text RawText": tags.content, | ||
], | ||
nested: configureNesting([ | ||
nested: /*@__PURE__*/configureNesting([ | ||
{ tag: "script", | ||
@@ -556,8 +556,12 @@ attrs(attrs) { | ||
}); | ||
/// HTML tag completion. Opens and closes tags and attributes in a | ||
/// context-aware way. | ||
const htmlCompletion = htmlLanguage.data.of({ autocomplete: completeHTML }); | ||
/// Language support for HTML, including | ||
/// [`htmlCompletion`](#lang-html.htmlCompletion) and JavaScript and | ||
/// CSS support extensions. | ||
/** | ||
HTML tag completion. Opens and closes tags and attributes in a | ||
context-aware way. | ||
*/ | ||
const htmlCompletion = /*@__PURE__*/htmlLanguage.data.of({ autocomplete: completeHTML }); | ||
/** | ||
Language support for HTML, including | ||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and | ||
CSS support extensions. | ||
*/ | ||
function html() { | ||
@@ -564,0 +568,0 @@ return new LanguageSupport(htmlLanguage, [htmlCompletion, javascript().support, css().support]); |
{ | ||
"name": "@codemirror/lang-html", | ||
"version": "0.18.0", | ||
"version": "0.18.1", | ||
"description": "HTML language support for the CodeMirror code editor", | ||
"scripts": { | ||
"test": "mocha test/test-*.js", | ||
"prepare": "tsc -p tsconfig.local.json && rollup -c" | ||
"test": "cm-runtests", | ||
"prepare": "cm-buildhelper src/html.ts" | ||
}, | ||
@@ -35,12 +35,7 @@ "keywords": [ | ||
"@codemirror/state": "^0.18.0", | ||
"lezer-html": "^0.13.0", | ||
"lezer-html": "^0.13.5", | ||
"lezer-tree": "^0.13.0" | ||
}, | ||
"devDependencies": { | ||
"rollup": "^2.35.1", | ||
"rollup-plugin-dts": "^2.0.1", | ||
"typescript": "^4.1.3", | ||
"@types/mocha": "^5.2.0", | ||
"ist": "^1.1.6", | ||
"mocha": "^7.1.1" | ||
"@codemirror/buildhelper": "^0.1.5" | ||
}, | ||
@@ -47,0 +42,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
1143
48152
8
Updatedlezer-html@^0.13.5