@stubber/form-fields 1.4.4 → 1.4.5

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.
@@ -1,4 +1,10 @@
1
- <script>import { acceptCompletion, CompletionContext } from "@codemirror/autocomplete";
1
+ <script>import {
2
+ acceptCompletion,
3
+ autocompletion,
4
+ CompletionContext,
5
+ completionKeymap,
6
+ startCompletion
7
+ } from "@codemirror/autocomplete";
2
8
  import { javascript, javascriptLanguage } from "@codemirror/lang-javascript";
3
9
  import { EditorState } from "@codemirror/state";
4
10
  import { EditorView, keymap } from "@codemirror/view";
@@ -12,10 +18,21 @@ $: label = $field.spec?.title;
12
18
  $: hide_label = $field.spec?.hide_label;
13
19
  $: isValid = !$field.state?.validation || $field.state?.validation?.valid;
14
20
  $: validationMessage = $field.state?.validation?.message;
15
- const tab_accept_completion = keymap.of([
21
+ const custom_completion_keymap = completionKeymap.filter((binding) => binding.key != "Enter").concat([
22
+ {
23
+ key: "Enter",
24
+ run: () => {
25
+ return false;
26
+ }
27
+ },
16
28
  {
17
29
  key: "Tab",
18
30
  run: acceptCompletion
31
+ },
32
+ {
33
+ key: "Ctrl-Space",
34
+ run: startCompletion,
35
+ stopPropagation: true
19
36
  }
20
37
  ]);
21
38
  function keysFor(obj) {
@@ -61,7 +78,8 @@ function bind_codemirror(el) {
61
78
  basicSetup,
62
79
  javascript(),
63
80
  stubber_completions,
64
- tab_accept_completion,
81
+ autocompletion({ defaultKeymap: false }),
82
+ keymap.of(custom_completion_keymap),
65
83
  min_height_editor,
66
84
  update_listener
67
85
  ]
@@ -1,27 +1,26 @@
1
1
  <script>
2
2
  import { syncStoreToStore } from "../../utils/syncing";
3
- import { deepEqual } from "fast-equals";
4
- import _ from "lodash-es";
5
- import { onMount, onDestroy } from "svelte";
6
- import { writable } from "svelte/store";
7
- import {
8
- EditorView,
9
- placeholder,
10
- MatchDecorator,
11
- Decoration,
12
- ViewPlugin,
13
- keymap,
14
- } from "@codemirror/view";
15
- import { EditorState, StateField } from "@codemirror/state";
16
- import { history, defaultKeymap, historyKeymap } from "@codemirror/commands";
17
3
  import {
18
4
  acceptCompletion,
19
5
  autocompletion,
20
6
  completionKeymap,
21
7
  startCompletion,
22
8
  } from "@codemirror/autocomplete";
9
+ import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
10
+ import { EditorState, StateField } from "@codemirror/state";
11
+ import {
12
+ Decoration,
13
+ EditorView,
14
+ MatchDecorator,
15
+ ViewPlugin,
16
+ keymap,
17
+ placeholder,
18
+ } from "@codemirror/view";
19
+ import { deepEqual } from "fast-equals";
20
+ import _ from "lodash-es";
21
+ import { onDestroy, onMount } from "svelte";
22
+ import { writable } from "svelte/store";
23
23
 
24
- import { Input } from "@stubber/ui/input";
25
24
  import { Label } from "@stubber/ui/label";
26
25
 
27
26
  export let field;
@@ -232,9 +231,7 @@
232
231
  },
233
232
  {
234
233
  key: "Ctrl-Space",
235
- run: (view) => {
236
- startCompletion(view);
237
- },
234
+ run: startCompletion,
238
235
  stopPropagation: true,
239
236
  },
240
237
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stubber/form-fields",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "An automatic form builder based on field specifications",
5
5
  "keywords": [
6
6
  "components",