@citisen/litearea 0.2.0 → 0.2.1
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/types/dom/editor.d.ts +8 -3
- package/dist/types/dom/editor.d.ts.map +1 -1
- package/docs/completion.md +10 -2
- package/package.json +1 -1
- package/src/dom/editor.ts +14 -4
|
@@ -31,9 +31,14 @@ export interface LiteAreaCompletion {
|
|
|
31
31
|
/**
|
|
32
32
|
* Characters that open the list in addition to word characters.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Empty by default, because a separator is the wrong moment to interrupt: it is
|
|
35
|
+
* where the next token starts, which is the argument FOR opening there, and it
|
|
36
|
+
* loses to the habit every reader already has — the editor this is modelled on
|
|
37
|
+
* offers nothing on a space and waits for a letter or for `Ctrl+Space`. Nothing
|
|
38
|
+
* is stranded by that. The list stays open once it is open, so a value typed
|
|
39
|
+
* after a name is still filtered in place, and `Ctrl+Space` opens it on demand.
|
|
40
|
+
* Set it to `' '` or `','` for a language where a separator really is where the
|
|
41
|
+
* next token becomes guessable.
|
|
37
42
|
*/
|
|
38
43
|
triggerCharacters?: string;
|
|
39
44
|
/** The most rows to offer. Default 100. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/dom/editor.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,KAAK,EACL,QAAQ,EAET,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAM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CAAC,0BAA0B;IAkBlC,4DAA4D;IAC5D,OAAO,CAAC,cAAc;IAOtB,uCAAuC;IACvC,OAAO,CAAC,wBAAwB;IAUhC,yDAAyD;IACzD,OAAO,CAAC,UAAU;IAalB,kCAAkC;IAClC,OAAO,CAAC,SAAS;IAkBjB,qDAAqD;IACrD,OAAO,CAAC,WAAW;IAYnB,6BAA6B;IAC7B,OAAO,CAAC,IAAI;IAeZ,6BAA6B;IAC7B,OAAO,CAAC,MAAM;IAed,OAAO,CAAC,QAAQ,CAAC,OAAO,CAWvB;IAED,OAAO,CAAC,QAAQ,CAAC,SAAS,CAsDzB;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAUvB,2DAA2D;IAC3D,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAIxB;IAED,OAAO,CAAC,QAAQ,CAAC,YAAY,CAG5B;IAED,OAAO,CAAC,QAAQ,CAAC,OAAO,CAOvB;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAGjC;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAKtB;IAED,OAAO,CAAC,QAAQ,CAAC,WAAW,CAY3B;IAED,OAAO,CAAC,QAAQ,CAAC,YAAY,CAG5B;IAED,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAGlC;IAED,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAGhC;CACF;AA4CD,wFAAwF;AACxF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAA;AAErC,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,KAAK,CAAA;AAE/B,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAA"}
|
package/docs/completion.md
CHANGED
|
@@ -34,7 +34,7 @@ two bugs that make a completer feel broken have somewhere to live:
|
|
|
34
34
|
| Event | What happens |
|
|
35
35
|
| --- | --- |
|
|
36
36
|
| A word character is typed | The list opens, in `'auto'` mode. The predicate is the grammar's `wordChars` |
|
|
37
|
-
| A character typed through `triggerCharacters` |
|
|
37
|
+
| A character typed through `triggerCharacters` | Also opens it, in `'auto'` mode. **Empty by default**, so a separator does not open the list — see below |
|
|
38
38
|
| More characters are typed while the list is open | Re-resolved: the same source answers again if it is still eligible, the range is recomputed from the caret, and the rows are re-filtered |
|
|
39
39
|
| A character is deleted while the list is open | Re-filtered. A backspace with no list open opens nothing, because a deletion is not a request for suggestions |
|
|
40
40
|
| `Ctrl+Space` / `Cmd+Space` | Opens with no needle (`'explicit'`), or closes the list when it is already open |
|
|
@@ -45,6 +45,14 @@ two bugs that make a completer feel broken have somewhere to live:
|
|
|
45
45
|
| The editor itself is writing | Nothing re-opens: the editor knows its own edit from the user's |
|
|
46
46
|
| Any `input` event while `readOnly` | Nothing |
|
|
47
47
|
|
|
48
|
+
`triggerCharacters` is empty by default, so a separator does not open the list. A
|
|
49
|
+
space is where the next token starts, which is the argument for opening there,
|
|
50
|
+
and it loses to the habit a reader already has: the editor this is modelled on
|
|
51
|
+
offers nothing on a space and waits for a letter or for `Ctrl+Space`. Nothing is
|
|
52
|
+
stranded by it — the list stays open while the next token is typed, so a value
|
|
53
|
+
after a name is still suggested in place — and a language whose separator really
|
|
54
|
+
is the moment the next token becomes guessable names it explicitly.
|
|
55
|
+
|
|
48
56
|
`auto: false` (or `completion: false` on the editor) switches off every row above
|
|
49
57
|
except `Ctrl+Space`, `Escape`, and the arrows; `showCompletions()` and
|
|
50
58
|
`hideCompletions()` drive the same open and close by hand, and `currentCompletion`
|
|
@@ -276,7 +284,7 @@ default would be guessing about every other language.
|
|
|
276
284
|
|
|
277
285
|
| VSCode | litearea |
|
|
278
286
|
| --- | --- |
|
|
279
|
-
| Typing triggers suggestions | A word character or one of `triggerCharacters` (
|
|
287
|
+
| Typing triggers suggestions | A word character or one of `triggerCharacters` (empty by default) opens the list; `auto: false` turns it off |
|
|
280
288
|
| `Ctrl+Space` | `Ctrl+Space`/`Cmd+Space` opens on demand, and closes when the list is already open |
|
|
281
289
|
| Typing filters the list | The needle is the text between the source's current range start and the caret, matched fuzzily |
|
|
282
290
|
| `Enter` accepts | `Enter` accepts the active row |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citisen/litearea",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A lightweight textarea-based code editor: native undo/redo, fully custom syntax highlighting, VSCode-style completion, diagnostics, and hover tooltips. No CodeMirror, no Monaco.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/dom/editor.ts
CHANGED
|
@@ -94,9 +94,14 @@ export interface LiteAreaCompletion {
|
|
|
94
94
|
/**
|
|
95
95
|
* Characters that open the list in addition to word characters.
|
|
96
96
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
97
|
+
* Empty by default, because a separator is the wrong moment to interrupt: it is
|
|
98
|
+
* where the next token starts, which is the argument FOR opening there, and it
|
|
99
|
+
* loses to the habit every reader already has — the editor this is modelled on
|
|
100
|
+
* offers nothing on a space and waits for a letter or for `Ctrl+Space`. Nothing
|
|
101
|
+
* is stranded by that. The list stays open once it is open, so a value typed
|
|
102
|
+
* after a name is still filtered in place, and `Ctrl+Space` opens it on demand.
|
|
103
|
+
* Set it to `' '` or `','` for a language where a separator really is where the
|
|
104
|
+
* next token becomes guessable.
|
|
100
105
|
*/
|
|
101
106
|
triggerCharacters?: string
|
|
102
107
|
/** The most rows to offer. Default 100. */
|
|
@@ -289,11 +294,16 @@ export class LiteArea<State = unknown> {
|
|
|
289
294
|
{ autoGrow: true, minRows: 1 },
|
|
290
295
|
options.sizing as Partial<ResolvedSizing> | undefined,
|
|
291
296
|
)
|
|
297
|
+
// A word character opens the list; a separator does not, unless the grammar's
|
|
298
|
+
// host asks for one by name. The list does not need a separator to be helpful
|
|
299
|
+
// — it is already open while the next token is typed, and it re-filters in
|
|
300
|
+
// place — and opening on a space spends the one keystroke a reader is least
|
|
301
|
+
// willing to have interrupted.
|
|
292
302
|
this.completion =
|
|
293
303
|
options.completion === false
|
|
294
304
|
? undefined
|
|
295
305
|
: withDefaults<ResolvedCompletion>(
|
|
296
|
-
{ auto: true, triggerCharacters: '
|
|
306
|
+
{ auto: true, triggerCharacters: '', limit: 100, showDocumentation: true },
|
|
297
307
|
options.completion,
|
|
298
308
|
)
|
|
299
309
|
this.hover =
|