@operato/input 1.5.53 → 1.7.2
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 +9 -0
- package/dist/src/ox-input-code.d.ts +1 -0
- package/dist/src/ox-input-code.js +20 -1
- package/dist/src/ox-input-code.js.map +1 -1
- package/dist/stories/ox-input-code.stories.d.ts +5 -0
- package/dist/stories/ox-input-code.stories.js +6 -3
- package/dist/stories/ox-input-code.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/src/ox-input-code.ts +19 -2
- package/stories/ox-input-code.stories.ts +7 -3
- package/yarn-error.log +17084 -0
- package/dist/src/ox-input-graphql.d.ts +0 -29
- package/dist/src/ox-input-graphql.js +0 -108
- package/dist/src/ox-input-graphql.js.map +0 -1
- package/src/ox-input-graphql.ts +0 -99
package/src/ox-input-code.ts
CHANGED
@@ -9,10 +9,12 @@ import { history, historyKeymap, indentWithTab } from '@codemirror/commands'
|
|
9
9
|
import { EditorView, highlightActiveLine, keymap } from '@codemirror/view'
|
10
10
|
import { EditorState } from '@codemirror/state'
|
11
11
|
import { autocompletion, closeBrackets } from '@codemirror/autocomplete'
|
12
|
-
import { bracketMatching, syntaxHighlighting } from '@codemirror/language'
|
12
|
+
import { bracketMatching, LanguageSupport, syntaxHighlighting } from '@codemirror/language'
|
13
13
|
import { oneDarkHighlightStyle, oneDark } from '@codemirror/theme-one-dark'
|
14
14
|
|
15
15
|
import { javascript } from '@codemirror/lang-javascript'
|
16
|
+
import { sql } from '@codemirror/lang-sql'
|
17
|
+
import { json } from '@codemirror/lang-json'
|
16
18
|
|
17
19
|
import { ScrollbarStyles } from '@operato/styles'
|
18
20
|
import { togglefullscreen } from '@operato/utils'
|
@@ -53,6 +55,7 @@ export class OxInputCode extends OxFormField {
|
|
53
55
|
@property({ type: String }) mode?: string
|
54
56
|
@property({ type: Number, attribute: 'tab-size' }) tabSize: number = 2
|
55
57
|
@property({ type: Boolean, attribute: 'tab-as-space' }) tabAsSpace: boolean = true
|
58
|
+
@property({ type: String }) language?: 'javascript' | 'sql' | 'json' = 'javascript'
|
56
59
|
|
57
60
|
private _self_changing: boolean = false
|
58
61
|
private _editor?: EditorView
|
@@ -68,9 +71,24 @@ export class OxInputCode extends OxFormField {
|
|
68
71
|
|
69
72
|
get editor() {
|
70
73
|
if (!this._editor) {
|
74
|
+
let language: LanguageSupport
|
75
|
+
switch (this.language) {
|
76
|
+
case 'sql':
|
77
|
+
language = sql()
|
78
|
+
break
|
79
|
+
case 'json':
|
80
|
+
language = json()
|
81
|
+
break
|
82
|
+
case 'javascript':
|
83
|
+
default:
|
84
|
+
language = javascript()
|
85
|
+
break
|
86
|
+
}
|
87
|
+
|
71
88
|
this._editor = new EditorView({
|
72
89
|
doc: this.value,
|
73
90
|
extensions: [
|
91
|
+
language,
|
74
92
|
bracketMatching(),
|
75
93
|
closeBrackets(),
|
76
94
|
history(),
|
@@ -78,7 +96,6 @@ export class OxInputCode extends OxFormField {
|
|
78
96
|
oneDark,
|
79
97
|
syntaxHighlighting(oneDarkHighlightStyle),
|
80
98
|
highlightActiveLine(),
|
81
|
-
javascript(),
|
82
99
|
keymap.of([
|
83
100
|
...historyKeymap,
|
84
101
|
indentWithTab,
|
@@ -7,7 +7,8 @@ export default {
|
|
7
7
|
component: 'ox-input-code',
|
8
8
|
argTypes: {
|
9
9
|
value: { control: 'text' },
|
10
|
-
name: { control: 'text' }
|
10
|
+
name: { control: 'text' },
|
11
|
+
language: { control: 'select', options: ['javascript', 'sql', 'json'] }
|
11
12
|
}
|
12
13
|
}
|
13
14
|
|
@@ -20,9 +21,10 @@ interface Story<T> {
|
|
20
21
|
interface ArgTypes {
|
21
22
|
name?: string
|
22
23
|
value?: string
|
24
|
+
language: 'javascript' | 'sql' | 'json'
|
23
25
|
}
|
24
26
|
|
25
|
-
const Template: Story<ArgTypes> = ({ name = 'code', value = '' }: ArgTypes) => html`
|
27
|
+
const Template: Story<ArgTypes> = ({ name = 'code', language = 'javascript', value = '' }: ArgTypes) => html`
|
26
28
|
<link href="/themes/app-theme.css" rel="stylesheet" />
|
27
29
|
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
28
30
|
<style>
|
@@ -38,6 +40,7 @@ const Template: Story<ArgTypes> = ({ name = 'code', value = '' }: ArgTypes) => h
|
|
38
40
|
console.log((e.target as HTMLInputElement).value)
|
39
41
|
}}
|
40
42
|
name=${name}
|
43
|
+
language=${language}
|
41
44
|
.value=${value}
|
42
45
|
>
|
43
46
|
</ox-input-code>
|
@@ -46,5 +49,6 @@ const Template: Story<ArgTypes> = ({ name = 'code', value = '' }: ArgTypes) => h
|
|
46
49
|
export const Regular = Template.bind({})
|
47
50
|
Regular.args = {
|
48
51
|
name: 'code',
|
49
|
-
value: ''
|
52
|
+
value: '',
|
53
|
+
language: 'javascript'
|
50
54
|
}
|