@stubber/form-fields 1.4.3 → 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 {
|
|
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
|
|
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
|
-
|
|
81
|
+
autocompletion({ defaultKeymap: false }),
|
|
82
|
+
keymap.of(custom_completion_keymap),
|
|
65
83
|
min_height_editor,
|
|
66
84
|
update_listener
|
|
67
85
|
]
|
|
@@ -1,22 +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
3
|
import {
|
|
4
|
+
acceptCompletion,
|
|
5
|
+
autocompletion,
|
|
6
|
+
completionKeymap,
|
|
7
|
+
startCompletion,
|
|
8
|
+
} from "@codemirror/autocomplete";
|
|
9
|
+
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
10
|
+
import { EditorState, StateField } from "@codemirror/state";
|
|
11
|
+
import {
|
|
12
|
+
Decoration,
|
|
8
13
|
EditorView,
|
|
9
|
-
placeholder,
|
|
10
14
|
MatchDecorator,
|
|
11
|
-
Decoration,
|
|
12
15
|
ViewPlugin,
|
|
13
16
|
keymap,
|
|
17
|
+
placeholder,
|
|
14
18
|
} from "@codemirror/view";
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
19
|
+
import { deepEqual } from "fast-equals";
|
|
20
|
+
import _ from "lodash-es";
|
|
21
|
+
import { onDestroy, onMount } from "svelte";
|
|
22
|
+
import { writable } from "svelte/store";
|
|
18
23
|
|
|
19
|
-
import { Input } from "@stubber/ui/input";
|
|
20
24
|
import { Label } from "@stubber/ui/label";
|
|
21
25
|
|
|
22
26
|
export let field;
|
|
@@ -212,6 +216,26 @@
|
|
|
212
216
|
|
|
213
217
|
$: is_string = typeof $internal?.raw === "string";
|
|
214
218
|
|
|
219
|
+
const custom_completion_keymap = completionKeymap
|
|
220
|
+
.filter((binding) => binding.key != "Enter")
|
|
221
|
+
.concat([
|
|
222
|
+
{
|
|
223
|
+
key: "Enter",
|
|
224
|
+
run: () => {
|
|
225
|
+
return false;
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
key: "Tab",
|
|
230
|
+
run: acceptCompletion,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: "Ctrl-Space",
|
|
234
|
+
run: startCompletion,
|
|
235
|
+
stopPropagation: true,
|
|
236
|
+
},
|
|
237
|
+
]);
|
|
238
|
+
|
|
215
239
|
$: {
|
|
216
240
|
// check if internal.raw is not a string
|
|
217
241
|
if (is_string) {
|
|
@@ -220,12 +244,12 @@
|
|
|
220
244
|
history({ newGroupDelay: 150 }),
|
|
221
245
|
EditorView.lineWrapping,
|
|
222
246
|
contentField,
|
|
223
|
-
autocompletion({ override: [myCompletions] }),
|
|
247
|
+
autocompletion({ override: [myCompletions], defaultKeymap: false }),
|
|
224
248
|
placeholder(label),
|
|
225
249
|
EditorView.contentAttributes.of({
|
|
226
250
|
spellcheck: "true",
|
|
227
251
|
}),
|
|
228
|
-
keymap.of([...defaultKeymap, ...historyKeymap]),
|
|
252
|
+
keymap.of([...defaultKeymap, ...historyKeymap, ...custom_completion_keymap]),
|
|
229
253
|
];
|
|
230
254
|
|
|
231
255
|
if (code_language === "handlebars") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stubber/form-fields",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "An automatic form builder based on field specifications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
62
62
|
"@codemirror/state": "^6.5.2",
|
|
63
63
|
"@codemirror/view": "^6.38.4",
|
|
64
|
-
"@stubber/ui": "^1.
|
|
64
|
+
"@stubber/ui": "^1.13.1",
|
|
65
65
|
"ag-grid-community": "^31.0.2",
|
|
66
66
|
"ag-grid-enterprise": "^31.0.2",
|
|
67
67
|
"codemirror": "^6.0.2",
|