@codemirror/autocomplete
Advanced tools
Comparing version 0.17.4 to 0.18.0
@@ -0,1 +1,7 @@ | ||
## 0.18.0 (2021-03-03) | ||
### Bug fixes | ||
Only preserve selected option across updates when it isn't the first option. | ||
## 0.17.4 (2021-01-18) | ||
@@ -2,0 +8,0 @@ |
import { showTooltip, tooltips } from '@codemirror/tooltip'; | ||
import { Facet, combineConfig, StateEffect, StateField, Transaction, Text, EditorSelection, Prec, CharCategory } from '@codemirror/state'; | ||
import { EditorView, Direction, themeClass, ViewPlugin, logException, Decoration, WidgetType, keymap } from '@codemirror/view'; | ||
import { EditorView, Direction, ViewPlugin, logException, Decoration, WidgetType, keymap } from '@codemirror/view'; | ||
import { syntaxTree, indentUnit } from '@codemirror/language'; | ||
@@ -272,3 +272,3 @@ import { codePointAt, codePointSize, fromCodePoint } from '@codemirror/text'; | ||
const baseTheme = EditorView.baseTheme({ | ||
"$tooltip.autocomplete": { | ||
".cm-tooltip.cm-tooltip-autocomplete": { | ||
"& > ul": { | ||
@@ -295,3 +295,3 @@ fontFamily: "monospace", | ||
}, | ||
"$completionListIncompleteTop:before, $completionListIncompleteBottom:after": { | ||
".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": { | ||
content: '"···"', | ||
@@ -302,3 +302,3 @@ opacity: 0.5, | ||
}, | ||
"$tooltip.completionInfo": { | ||
".cm-tooltip.cm-completionInfo": { | ||
position: "absolute", | ||
@@ -309,7 +309,7 @@ padding: "3px 9px", | ||
}, | ||
"$tooltip.completionInfo.left": { right: "100%" }, | ||
"$tooltip.completionInfo.right": { left: "100%" }, | ||
"$$light $snippetField": { backgroundColor: "#00000022" }, | ||
"$$dark $snippetField": { backgroundColor: "#ffffff22" }, | ||
"$snippetFieldPosition": { | ||
".cm-completionInfo.cm-completionInfo-left": { right: "100%" }, | ||
".cm-completionInfo.cm-completionInfo-right": { left: "100%" }, | ||
"&light .cm-snippetField": { backgroundColor: "#00000022" }, | ||
"&dark .cm-snippetField": { backgroundColor: "#ffffff22" }, | ||
".cm-snippetFieldPosition": { | ||
verticalAlign: "text-top", | ||
@@ -321,10 +321,10 @@ width: 0, | ||
}, | ||
$completionMatchedText: { | ||
".cm-completionMatchedText": { | ||
textDecoration: "underline" | ||
}, | ||
$completionDetail: { | ||
".cm-completionDetail": { | ||
marginLeft: "0.5em", | ||
fontStyle: "italic" | ||
}, | ||
$completionIcon: { | ||
".cm-completionIcon": { | ||
fontSize: "90%", | ||
@@ -337,33 +337,33 @@ width: ".8em", | ||
}, | ||
"$completionIcon.function, $completionIcon.method": { | ||
".cm-completionIcon-function, .cm-completionIcon-method": { | ||
"&:after": { content: "'ƒ'" } | ||
}, | ||
"$completionIcon.class": { | ||
".cm-completionIcon-class": { | ||
"&:after": { content: "'○'" } | ||
}, | ||
"$completionIcon.interface": { | ||
".cm-completionIcon-interface": { | ||
"&:after": { content: "'◌'" } | ||
}, | ||
"$completionIcon.variable": { | ||
".cm-completionIcon-variable": { | ||
"&:after": { content: "'𝑥'" } | ||
}, | ||
"$completionIcon.constant": { | ||
".cm-completionIcon-constant": { | ||
"&:after": { content: "'𝐶'" } | ||
}, | ||
"$completionIcon.type": { | ||
".cm-completionIcon-type": { | ||
"&:after": { content: "'𝑡'" } | ||
}, | ||
"$completionIcon.enum": { | ||
".cm-completionIcon-enum": { | ||
"&:after": { content: "'∪'" } | ||
}, | ||
"$completionIcon.property": { | ||
".cm-completionIcon-property": { | ||
"&:after": { content: "'□'" } | ||
}, | ||
"$completionIcon.keyword": { | ||
".cm-completionIcon-keyword": { | ||
"&:after": { content: "'🔑\uFE0E'" } // Disable emoji rendering | ||
}, | ||
"$completionIcon.namespace": { | ||
".cm-completionIcon-namespace": { | ||
"&:after": { content: "'▢'" } | ||
}, | ||
"$completionIcon.text": { | ||
".cm-completionIcon-text": { | ||
"&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" } | ||
@@ -383,6 +383,8 @@ } | ||
let icon = li.appendChild(document.createElement("div")); | ||
icon.className = themeClass("completionIcon" + (completion.type ? "." + completion.type : "")); | ||
icon.classList.add("cm-completionIcon"); | ||
if (completion.type) | ||
icon.classList.add("cm-completionIcon-" + completion.type); | ||
icon.setAttribute("aria-hidden", "true"); | ||
let labelElt = li.appendChild(document.createElement("span")); | ||
labelElt.className = themeClass("completionLabel"); | ||
labelElt.className = "cm-completionLabel"; | ||
let { label, detail } = completion, off = 0; | ||
@@ -395,3 +397,3 @@ for (let j = 1; j < match.length;) { | ||
span.appendChild(document.createTextNode(label.slice(from, to))); | ||
span.className = themeClass("completionMatchedText"); | ||
span.className = "cm-completionMatchedText"; | ||
off = to; | ||
@@ -403,3 +405,3 @@ } | ||
let detailElt = li.appendChild(document.createElement("span")); | ||
detailElt.className = themeClass("completionDetail"); | ||
detailElt.className = "cm-completionDetail"; | ||
detailElt.textContent = detail; | ||
@@ -410,5 +412,5 @@ } | ||
if (range.from) | ||
ul.classList.add(themeClass("completionListIncompleteTop")); | ||
ul.classList.add("cm-completionListIncompleteTop"); | ||
if (range.to < options.length) | ||
ul.classList.add(themeClass("completionListIncompleteBottom")); | ||
ul.classList.add("cm-completionListIncompleteBottom"); | ||
return ul; | ||
@@ -418,3 +420,3 @@ } | ||
let dom = document.createElement("div"); | ||
dom.className = themeClass("tooltip.completionInfo"); | ||
dom.className = "cm-tooltip cm-completionInfo"; | ||
let { info } = option.completion; | ||
@@ -536,4 +538,4 @@ if (typeof info == "string") | ||
this.info.style.top = pos.top + "px"; | ||
this.info.classList.toggle("cm-tooltip-completionInfo-left", pos.left); | ||
this.info.classList.toggle("cm-tooltip-completionInfo-right", !pos.left); | ||
this.info.classList.toggle("cm-completionInfo-left", pos.left); | ||
this.info.classList.toggle("cm-completionInfo-right", !pos.left); | ||
} | ||
@@ -605,3 +607,3 @@ } | ||
let selected = 0; | ||
if (prev) { | ||
if (prev && prev.selected) { | ||
let selectedValue = prev.options[prev.selected].completion; | ||
@@ -615,3 +617,3 @@ for (let i = 0; i < options.length && !selected; i++) { | ||
pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8), | ||
style: "autocomplete", | ||
class: "cm-tooltip-autocomplete", | ||
create: completionTooltip(completionState) | ||
@@ -1021,3 +1023,3 @@ }], prev ? prev.timestamp : Date.now(), selected); | ||
let span = document.createElement("span"); | ||
span.className = themeClass("snippetFieldPosition"); | ||
span.className = "cm-snippetFieldPosition"; | ||
return span; | ||
@@ -1027,3 +1029,3 @@ } | ||
} }); | ||
let fieldRange = Decoration.mark({ class: themeClass("snippetField") }); | ||
let fieldRange = Decoration.mark({ class: "cm-snippetField" }); | ||
class ActiveSnippet { | ||
@@ -1097,5 +1099,5 @@ constructor(ranges, active) { | ||
if (ranges.length > 1) { | ||
spec.effects = setActive.of(new ActiveSnippet(ranges, 0)); | ||
let effects = spec.effects = [setActive.of(new ActiveSnippet(ranges, 0))]; | ||
if (editor.state.field(snippetState, false) === undefined) | ||
spec.reconfigure = { append: [snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme] }; | ||
effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme])); | ||
} | ||
@@ -1102,0 +1104,0 @@ editor.dispatch(editor.state.update(spec)); |
{ | ||
"name": "@codemirror/autocomplete", | ||
"version": "0.17.4", | ||
"version": "0.18.0", | ||
"description": "Autocompletion for the CodeMirror code editor", | ||
@@ -29,7 +29,7 @@ "scripts": { | ||
"dependencies": { | ||
"@codemirror/language": "^0.17.0", | ||
"@codemirror/state": "^0.17.0", | ||
"@codemirror/text": "^0.17.0", | ||
"@codemirror/tooltip": "^0.17.0", | ||
"@codemirror/view": "^0.17.0", | ||
"@codemirror/language": "^0.18.0", | ||
"@codemirror/state": "^0.18.0", | ||
"@codemirror/text": "^0.18.0", | ||
"@codemirror/tooltip": "^0.18.0", | ||
"@codemirror/view": "^0.18.0", | ||
"lezer-tree": "^0.13.0" | ||
@@ -36,0 +36,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
224113
2548
+ Added@codemirror/language@0.18.2(transitive)
+ Added@codemirror/rangeset@0.18.5(transitive)
+ Added@codemirror/state@0.18.7(transitive)
+ Added@codemirror/text@0.18.1(transitive)
+ Added@codemirror/tooltip@0.18.4(transitive)
+ Added@codemirror/view@0.18.19(transitive)
+ Addedstyle-mod@4.1.2(transitive)
- Removed@codemirror/language@0.17.5(transitive)
- Removed@codemirror/rangeset@0.17.1(transitive)
- Removed@codemirror/state@0.17.2(transitive)
- Removed@codemirror/text@0.17.2(transitive)
- Removed@codemirror/tooltip@0.17.2(transitive)
- Removed@codemirror/view@0.17.13(transitive)
- Removedstyle-mod@3.2.2(transitive)
Updated@codemirror/language@^0.18.0
Updated@codemirror/state@^0.18.0
Updated@codemirror/text@^0.18.0
Updated@codemirror/tooltip@^0.18.0
Updated@codemirror/view@^0.18.0