@codemirror/autocomplete 0.19.7 → 0.19.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/index.cjs +10 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.19.8 (2021-11-17)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Give the completion tooltip a minimal width, and show ellipsis when completions overflow the tooltip width.
|
|
6
|
+
|
|
7
|
+
### New features
|
|
8
|
+
|
|
9
|
+
`autocompletion` now accepts an `aboveCursor` option to make the completion tooltip show up above the cursor.
|
|
10
|
+
|
|
1
11
|
## 0.19.7 (2021-11-16)
|
|
2
12
|
|
|
3
13
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -309,6 +309,7 @@ const completionConfig = state.Facet.define({
|
|
|
309
309
|
maxRenderedOptions: 100,
|
|
310
310
|
defaultKeymap: true,
|
|
311
311
|
optionClass: () => "",
|
|
312
|
+
aboveCursor: false,
|
|
312
313
|
icons: true,
|
|
313
314
|
addToOptions: []
|
|
314
315
|
}, {
|
|
@@ -591,7 +592,7 @@ class CompletionDialog {
|
|
|
591
592
|
return selected == this.selected || selected >= this.options.length ? this
|
|
592
593
|
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected);
|
|
593
594
|
}
|
|
594
|
-
static build(active, state, id, prev) {
|
|
595
|
+
static build(active, state, id, prev, conf) {
|
|
595
596
|
let options = sortOptions(active, state);
|
|
596
597
|
if (!options.length)
|
|
597
598
|
return null;
|
|
@@ -605,7 +606,8 @@ class CompletionDialog {
|
|
|
605
606
|
}
|
|
606
607
|
return new CompletionDialog(options, makeAttrs(id, selected), {
|
|
607
608
|
pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
|
|
608
|
-
create: completionTooltip(completionState)
|
|
609
|
+
create: completionTooltip(completionState),
|
|
610
|
+
above: conf.aboveCursor,
|
|
609
611
|
}, prev ? prev.timestamp : Date.now(), selected);
|
|
610
612
|
}
|
|
611
613
|
map(changes) {
|
|
@@ -633,7 +635,7 @@ class CompletionState {
|
|
|
633
635
|
if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
|
|
634
636
|
active = this.active;
|
|
635
637
|
let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
|
|
636
|
-
!sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open)
|
|
638
|
+
!sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open, conf)
|
|
637
639
|
: this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
|
|
638
640
|
if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
|
|
639
641
|
active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* Inactive */) : a);
|
|
@@ -969,16 +971,19 @@ const baseTheme = view.EditorView.baseTheme({
|
|
|
969
971
|
"& > ul": {
|
|
970
972
|
fontFamily: "monospace",
|
|
971
973
|
whiteSpace: "nowrap",
|
|
972
|
-
overflow: "auto",
|
|
974
|
+
overflow: "hidden auto",
|
|
973
975
|
maxWidth_fallback: "700px",
|
|
974
976
|
maxWidth: "min(700px, 95vw)",
|
|
977
|
+
minWidth: "250px",
|
|
975
978
|
maxHeight: "10em",
|
|
976
979
|
listStyle: "none",
|
|
977
980
|
margin: 0,
|
|
978
981
|
padding: 0,
|
|
979
982
|
"& > li": {
|
|
983
|
+
overflowX: "hidden",
|
|
984
|
+
textOverflow: "ellipsis",
|
|
980
985
|
cursor: "pointer",
|
|
981
|
-
padding: "1px
|
|
986
|
+
padding: "1px 3px",
|
|
982
987
|
lineHeight: 1.2
|
|
983
988
|
},
|
|
984
989
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ interface CompletionConfig {
|
|
|
30
30
|
*/
|
|
31
31
|
defaultKeymap?: boolean;
|
|
32
32
|
/**
|
|
33
|
+
By default, completions are shown below the cursor when there is
|
|
34
|
+
space. Setting this to true will make the extension put the
|
|
35
|
+
completions above the cursor when possible.
|
|
36
|
+
*/
|
|
37
|
+
aboveCursor?: boolean;
|
|
38
|
+
/**
|
|
33
39
|
This can be used to add additional CSS classes to completion
|
|
34
40
|
options.
|
|
35
41
|
*/
|
package/dist/index.js
CHANGED
|
@@ -305,6 +305,7 @@ const completionConfig = /*@__PURE__*/Facet.define({
|
|
|
305
305
|
maxRenderedOptions: 100,
|
|
306
306
|
defaultKeymap: true,
|
|
307
307
|
optionClass: () => "",
|
|
308
|
+
aboveCursor: false,
|
|
308
309
|
icons: true,
|
|
309
310
|
addToOptions: []
|
|
310
311
|
}, {
|
|
@@ -587,7 +588,7 @@ class CompletionDialog {
|
|
|
587
588
|
return selected == this.selected || selected >= this.options.length ? this
|
|
588
589
|
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected);
|
|
589
590
|
}
|
|
590
|
-
static build(active, state, id, prev) {
|
|
591
|
+
static build(active, state, id, prev, conf) {
|
|
591
592
|
let options = sortOptions(active, state);
|
|
592
593
|
if (!options.length)
|
|
593
594
|
return null;
|
|
@@ -601,7 +602,8 @@ class CompletionDialog {
|
|
|
601
602
|
}
|
|
602
603
|
return new CompletionDialog(options, makeAttrs(id, selected), {
|
|
603
604
|
pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
|
|
604
|
-
create: completionTooltip(completionState)
|
|
605
|
+
create: completionTooltip(completionState),
|
|
606
|
+
above: conf.aboveCursor,
|
|
605
607
|
}, prev ? prev.timestamp : Date.now(), selected);
|
|
606
608
|
}
|
|
607
609
|
map(changes) {
|
|
@@ -629,7 +631,7 @@ class CompletionState {
|
|
|
629
631
|
if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
|
|
630
632
|
active = this.active;
|
|
631
633
|
let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
|
|
632
|
-
!sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open)
|
|
634
|
+
!sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open, conf)
|
|
633
635
|
: this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
|
|
634
636
|
if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
|
|
635
637
|
active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* Inactive */) : a);
|
|
@@ -965,16 +967,19 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
965
967
|
"& > ul": {
|
|
966
968
|
fontFamily: "monospace",
|
|
967
969
|
whiteSpace: "nowrap",
|
|
968
|
-
overflow: "auto",
|
|
970
|
+
overflow: "hidden auto",
|
|
969
971
|
maxWidth_fallback: "700px",
|
|
970
972
|
maxWidth: "min(700px, 95vw)",
|
|
973
|
+
minWidth: "250px",
|
|
971
974
|
maxHeight: "10em",
|
|
972
975
|
listStyle: "none",
|
|
973
976
|
margin: 0,
|
|
974
977
|
padding: 0,
|
|
975
978
|
"& > li": {
|
|
979
|
+
overflowX: "hidden",
|
|
980
|
+
textOverflow: "ellipsis",
|
|
976
981
|
cursor: "pointer",
|
|
977
|
-
padding: "1px
|
|
982
|
+
padding: "1px 3px",
|
|
978
983
|
lineHeight: 1.2
|
|
979
984
|
},
|
|
980
985
|
}
|