@instructure/ui-source-code-editor 11.6.0 → 11.6.1-snapshot-129
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 +40 -293
- package/es/SourceCodeEditor/{SearchPanel.js → v1/SearchPanel.js} +2 -2
- package/es/SourceCodeEditor/{index.js → v1/index.js} +1 -1
- package/es/SourceCodeEditor/v2/SearchPanel.js +118 -0
- package/es/SourceCodeEditor/v2/customKeybinding.js +100 -0
- package/es/SourceCodeEditor/v2/index.js +535 -0
- package/es/SourceCodeEditor/v2/props.js +28 -0
- package/es/SourceCodeEditor/v2/styles.js +228 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -2
- package/lib/SourceCodeEditor/{SearchPanel.js → v1/SearchPanel.js} +8 -8
- package/lib/SourceCodeEditor/{index.js → v1/index.js} +1 -1
- package/lib/SourceCodeEditor/v2/SearchPanel.js +126 -0
- package/lib/SourceCodeEditor/v2/customKeybinding.js +105 -0
- package/lib/SourceCodeEditor/v2/index.js +541 -0
- package/lib/SourceCodeEditor/v2/props.js +33 -0
- package/lib/SourceCodeEditor/v2/styles.js +234 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +42 -20
- package/src/SourceCodeEditor/{SearchPanel.tsx → v1/SearchPanel.tsx} +2 -2
- package/src/SourceCodeEditor/{index.tsx → v1/index.tsx} +1 -1
- package/src/SourceCodeEditor/v2/README.md +799 -0
- package/src/SourceCodeEditor/v2/SearchPanel.tsx +150 -0
- package/src/SourceCodeEditor/v2/customKeybinding.ts +125 -0
- package/src/SourceCodeEditor/v2/index.tsx +685 -0
- package/src/SourceCodeEditor/v2/props.ts +263 -0
- package/src/SourceCodeEditor/v2/styles.ts +239 -0
- package/src/exports/a.ts +25 -0
- package/src/exports/b.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/SourceCodeEditor/v1/SearchPanel.d.ts.map +1 -0
- package/types/SourceCodeEditor/v1/customKeybinding.d.ts.map +1 -0
- package/types/SourceCodeEditor/v1/index.d.ts.map +1 -0
- package/types/SourceCodeEditor/v1/props.d.ts.map +1 -0
- package/types/SourceCodeEditor/v1/styles.d.ts.map +1 -0
- package/types/SourceCodeEditor/v1/theme.d.ts.map +1 -0
- package/types/SourceCodeEditor/v2/SearchPanel.d.ts +7 -0
- package/types/SourceCodeEditor/v2/SearchPanel.d.ts.map +1 -0
- package/types/SourceCodeEditor/v2/customKeybinding.d.ts +4 -0
- package/types/SourceCodeEditor/v2/customKeybinding.d.ts.map +1 -0
- package/types/SourceCodeEditor/v2/index.d.ts +103 -0
- package/types/SourceCodeEditor/v2/index.d.ts.map +1 -0
- package/types/SourceCodeEditor/v2/props.d.ts +142 -0
- package/types/SourceCodeEditor/v2/props.d.ts.map +1 -0
- package/types/SourceCodeEditor/v2/styles.d.ts +14 -0
- package/types/SourceCodeEditor/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/SourceCodeEditor/SearchPanel.d.ts.map +0 -1
- package/types/SourceCodeEditor/customKeybinding.d.ts.map +0 -1
- package/types/SourceCodeEditor/index.d.ts.map +0 -1
- package/types/SourceCodeEditor/props.d.ts.map +0 -1
- package/types/SourceCodeEditor/styles.d.ts.map +0 -1
- package/types/SourceCodeEditor/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/SourceCodeEditor/{customKeybinding.js → v1/customKeybinding.js} +0 -0
- /package/es/SourceCodeEditor/{props.js → v1/props.js} +0 -0
- /package/es/SourceCodeEditor/{styles.js → v1/styles.js} +0 -0
- /package/es/SourceCodeEditor/{theme.js → v1/theme.js} +0 -0
- /package/lib/SourceCodeEditor/{customKeybinding.js → v1/customKeybinding.js} +0 -0
- /package/lib/SourceCodeEditor/{props.js → v1/props.js} +0 -0
- /package/lib/SourceCodeEditor/{styles.js → v1/styles.js} +0 -0
- /package/lib/SourceCodeEditor/{theme.js → v1/theme.js} +0 -0
- /package/src/SourceCodeEditor/{README.md → v1/README.md} +0 -0
- /package/src/SourceCodeEditor/{customKeybinding.ts → v1/customKeybinding.ts} +0 -0
- /package/src/SourceCodeEditor/{props.ts → v1/props.ts} +0 -0
- /package/src/SourceCodeEditor/{styles.ts → v1/styles.ts} +0 -0
- /package/src/SourceCodeEditor/{theme.ts → v1/theme.ts} +0 -0
- /package/types/SourceCodeEditor/{SearchPanel.d.ts → v1/SearchPanel.d.ts} +0 -0
- /package/types/SourceCodeEditor/{customKeybinding.d.ts → v1/customKeybinding.d.ts} +0 -0
- /package/types/SourceCodeEditor/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/SourceCodeEditor/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/SourceCodeEditor/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/SourceCodeEditor/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { TagStyle } from '@codemirror/language'
|
|
26
|
+
|
|
27
|
+
import type {
|
|
28
|
+
CodeEditorTheme,
|
|
29
|
+
OtherHTMLAttributes
|
|
30
|
+
} from '@instructure/shared-types'
|
|
31
|
+
import type {
|
|
32
|
+
WithStyleProps,
|
|
33
|
+
StyleObject,
|
|
34
|
+
ComponentStyle
|
|
35
|
+
} from '@instructure/emotion'
|
|
36
|
+
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
37
|
+
import type { TextDirectionContextConsumerProps } from '@instructure/ui-i18n'
|
|
38
|
+
import type { SearchConfig } from './SearchPanel'
|
|
39
|
+
|
|
40
|
+
type SourceCodeEditorOwnProps = {
|
|
41
|
+
/**
|
|
42
|
+
* The label text that screen readers will read when this component gets
|
|
43
|
+
* focus.
|
|
44
|
+
*/
|
|
45
|
+
label: string
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The language to use (adds autocomplete and syntax highlighting).
|
|
49
|
+
*/
|
|
50
|
+
language?:
|
|
51
|
+
| 'sh'
|
|
52
|
+
| 'js'
|
|
53
|
+
| 'json'
|
|
54
|
+
| 'javascript'
|
|
55
|
+
| 'jsx'
|
|
56
|
+
| 'shell'
|
|
57
|
+
| 'css'
|
|
58
|
+
| 'html'
|
|
59
|
+
| 'markdown'
|
|
60
|
+
| 'yaml'
|
|
61
|
+
| 'yml'
|
|
62
|
+
| 'bash'
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* This disables editing of the editor content by the user and API calls.
|
|
66
|
+
*
|
|
67
|
+
* __Note:__ The editor is still focusable in readOnly mode. Read more at the [codemirror documentation](https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly).
|
|
68
|
+
*/
|
|
69
|
+
readOnly?: boolean
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Controls whether the editor content DOM is editable.
|
|
73
|
+
*
|
|
74
|
+
* __Note:__ When set to false, the editor is not focusable.
|
|
75
|
+
* (This doesn't affect API calls that change the editor content, e.g.: copy-paste,
|
|
76
|
+
* even when those are bound to keys or buttons.) Read more at the [codemirror documentation](https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable).
|
|
77
|
+
*/
|
|
78
|
+
editable?: boolean
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Whether to display the line numbers in the gutter
|
|
82
|
+
*/
|
|
83
|
+
lineNumbers?: boolean
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Whether to show a fold status indicator before foldable lines (which can be clicked to fold or unfold the line)
|
|
87
|
+
*/
|
|
88
|
+
foldGutter?: boolean
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Whether to highlight gutter elements on the active line (visible only when a gutter is visible)
|
|
92
|
+
*/
|
|
93
|
+
highlightActiveLineGutter?: boolean
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Highlights the lines that have a cursor on them
|
|
97
|
+
*/
|
|
98
|
+
highlightActiveLine?: boolean
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Whether it should scroll or wrap for long lines. Defaults to false (scroll)
|
|
102
|
+
*/
|
|
103
|
+
lineWrapping?: boolean
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Whether the editor should focus itself on initialization
|
|
107
|
+
*/
|
|
108
|
+
autofocus?: boolean
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Whether spellcheck will be enabled on the input
|
|
112
|
+
*/
|
|
113
|
+
spellcheck?: boolean
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Whether the editor should auto-indent the code on this initial load
|
|
117
|
+
* and when the `value` is changed
|
|
118
|
+
*/
|
|
119
|
+
indentOnLoad?: boolean
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* When this feature is on, Tab and Shift-Tab will indent the code. By default, it is turned off, and tabbing will focus the next element in the tab order.
|
|
123
|
+
*
|
|
124
|
+
* __Note__: Even if this feature is on, pressing Escape before tabbing will not handle indentation and will handle focus instead.
|
|
125
|
+
*/
|
|
126
|
+
indentWithTab?: boolean
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Overrides the unit by which indentation happens (defaults to 2 spaces).
|
|
130
|
+
* Should be a string consisting either entirely of spaces or entirely of tabs.
|
|
131
|
+
*/
|
|
132
|
+
indentUnit?: string
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Flips overall layout and selects base paragraph direction to be "LTR" or "RTL".
|
|
136
|
+
*/
|
|
137
|
+
direction?: 'ltr' | 'rtl'
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Whether horizontal cursor movement through "RTL" text is visual
|
|
141
|
+
* (pressing the left arrow moves the cursor left) or logical
|
|
142
|
+
* (pressing the left arrow moves to the next lower index in the string,
|
|
143
|
+
* which is visually right in "RTL" text)
|
|
144
|
+
*/
|
|
145
|
+
rtlMoveVisually?: boolean
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The default value of the editor (in uncontrolled mode)
|
|
149
|
+
*/
|
|
150
|
+
defaultValue?: string
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The selected value for the controlled version
|
|
154
|
+
* (needs an onChange handler to work)
|
|
155
|
+
*/
|
|
156
|
+
value?: string
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Called when the value of the component changes.
|
|
160
|
+
*/
|
|
161
|
+
onChange?: (value: string) => void
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Called when the editor receives focus
|
|
165
|
+
*/
|
|
166
|
+
onFocus?: () => void
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Called when the editor loses focus
|
|
170
|
+
*/
|
|
171
|
+
onBlur?: () => void
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets minor visual styles (border radius & top/bottom margin)
|
|
175
|
+
*/
|
|
176
|
+
attachment?: 'bottom' | 'top'
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The height of the editor.
|
|
180
|
+
*/
|
|
181
|
+
height?: string
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The width of the editor.
|
|
185
|
+
*/
|
|
186
|
+
width?: string
|
|
187
|
+
|
|
188
|
+
// TODO: discuss the future of the dark theme with the Design theme
|
|
189
|
+
// We decided not to use the dark theme yet, the colors need to be configured
|
|
190
|
+
// (e.g. color contrast)
|
|
191
|
+
// Also, probably a `theme` oneOf prop would be better with more options
|
|
192
|
+
// darkTheme?: boolean
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* provides a reference to the underlying html root element
|
|
196
|
+
*/
|
|
197
|
+
elementRef?: (element: HTMLDivElement | null) => void
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* provides a reference to the html element of the editor's container
|
|
201
|
+
*/
|
|
202
|
+
containerRef?: (element: HTMLDivElement | null) => void
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* enable search panel in editor when pressing ctrl/cmd+f
|
|
206
|
+
*/
|
|
207
|
+
searchConfig?: SearchConfig
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
type PropKeys = keyof SourceCodeEditorOwnProps
|
|
211
|
+
|
|
212
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
213
|
+
|
|
214
|
+
type SourceCodeEditorProps = SourceCodeEditorOwnProps &
|
|
215
|
+
WithStyleProps<
|
|
216
|
+
CodeEditorTheme,
|
|
217
|
+
// The highlightStyle is a unique one, not compatible with our style syntax,
|
|
218
|
+
// but isn't used for the css prop anyway
|
|
219
|
+
Record<keyof SourceCodeEditorStyle, any>
|
|
220
|
+
> &
|
|
221
|
+
TextDirectionContextConsumerProps &
|
|
222
|
+
OtherHTMLAttributes<SourceCodeEditorOwnProps> &
|
|
223
|
+
WithDeterministicIdProps
|
|
224
|
+
|
|
225
|
+
type SourceCodeEditorStyle = ComponentStyle<
|
|
226
|
+
'codeEditor' | 'label' | 'codeEditorContainer'
|
|
227
|
+
> & {
|
|
228
|
+
theme: StyleObject
|
|
229
|
+
highlightStyle: TagStyle[]
|
|
230
|
+
}
|
|
231
|
+
const allowedProps: AllowedPropKeys = [
|
|
232
|
+
'label',
|
|
233
|
+
'language',
|
|
234
|
+
'readOnly',
|
|
235
|
+
'editable',
|
|
236
|
+
'lineNumbers',
|
|
237
|
+
'foldGutter',
|
|
238
|
+
'highlightActiveLineGutter',
|
|
239
|
+
'highlightActiveLine',
|
|
240
|
+
'lineWrapping',
|
|
241
|
+
'autofocus',
|
|
242
|
+
'spellcheck',
|
|
243
|
+
'direction',
|
|
244
|
+
'rtlMoveVisually',
|
|
245
|
+
'indentOnLoad',
|
|
246
|
+
'indentWithTab',
|
|
247
|
+
'indentUnit',
|
|
248
|
+
'defaultValue',
|
|
249
|
+
'value',
|
|
250
|
+
'onChange',
|
|
251
|
+
'onFocus',
|
|
252
|
+
'onBlur',
|
|
253
|
+
'attachment',
|
|
254
|
+
'height',
|
|
255
|
+
'width',
|
|
256
|
+
// 'darkTheme',
|
|
257
|
+
'elementRef',
|
|
258
|
+
'containerRef',
|
|
259
|
+
'searchConfig'
|
|
260
|
+
]
|
|
261
|
+
|
|
262
|
+
export type { SourceCodeEditorProps, SourceCodeEditorStyle }
|
|
263
|
+
export { allowedProps }
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { tags } from '@lezer/highlight'
|
|
26
|
+
|
|
27
|
+
import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
28
|
+
import type { SourceCodeEditorProps, SourceCodeEditorStyle } from './props'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* ---
|
|
32
|
+
* private: true
|
|
33
|
+
* ---
|
|
34
|
+
* Generates the style object from the theme and provided additional information
|
|
35
|
+
* @param {Object} componentTheme The theme variable object.
|
|
36
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
37
|
+
* @return {Object} The final style object, which will be used in the component
|
|
38
|
+
*/
|
|
39
|
+
const generateStyle = (
|
|
40
|
+
componentTheme: NewComponentTypes['SourceCodeEditor'],
|
|
41
|
+
props: SourceCodeEditorProps,
|
|
42
|
+
sharedTokens: SharedTokens
|
|
43
|
+
): SourceCodeEditorStyle => {
|
|
44
|
+
const { attachment, height, width } = props
|
|
45
|
+
|
|
46
|
+
const attachmentBorderRadius = {
|
|
47
|
+
top: {
|
|
48
|
+
borderBottomLeftRadius: 0,
|
|
49
|
+
borderBottomRightRadius: 0
|
|
50
|
+
},
|
|
51
|
+
bottom: {
|
|
52
|
+
borderTopLeftRadius: 0,
|
|
53
|
+
borderTopRightRadius: 0
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const attachmentVariants = {
|
|
58
|
+
top: {
|
|
59
|
+
marginBottom: 0,
|
|
60
|
+
marginTop: '0.25rem'
|
|
61
|
+
},
|
|
62
|
+
bottom: {
|
|
63
|
+
borderTopLeftRadius: 0,
|
|
64
|
+
borderTopRightRadius: 0,
|
|
65
|
+
marginBottom: '0.25rem'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const lineHeight = 1.4375
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
codeEditor: {
|
|
73
|
+
label: 'codeEditor',
|
|
74
|
+
position: 'relative',
|
|
75
|
+
boxSizing: 'border-box',
|
|
76
|
+
height: height || 'auto',
|
|
77
|
+
width
|
|
78
|
+
},
|
|
79
|
+
label: {
|
|
80
|
+
label: 'label',
|
|
81
|
+
height: '100%',
|
|
82
|
+
width: '100%'
|
|
83
|
+
},
|
|
84
|
+
codeEditorContainer: {
|
|
85
|
+
label: 'codeEditorContainer',
|
|
86
|
+
height: '100%',
|
|
87
|
+
width: '100%',
|
|
88
|
+
borderColor: componentTheme?.borderColor,
|
|
89
|
+
borderStyle: 'solid',
|
|
90
|
+
borderWidth: componentTheme?.borderWidth,
|
|
91
|
+
borderRadius: componentTheme.borderRadius,
|
|
92
|
+
marginBottom: '1rem',
|
|
93
|
+
...(attachment && {
|
|
94
|
+
...attachmentVariants[attachment],
|
|
95
|
+
...attachmentBorderRadius[attachment]
|
|
96
|
+
})
|
|
97
|
+
},
|
|
98
|
+
theme: {
|
|
99
|
+
'&': {
|
|
100
|
+
overflow: 'hidden',
|
|
101
|
+
background: componentTheme.background,
|
|
102
|
+
fontFamily: componentTheme.fontFamily,
|
|
103
|
+
fontSize: componentTheme.fontSize,
|
|
104
|
+
color: componentTheme.color,
|
|
105
|
+
border: 0,
|
|
106
|
+
height: '100%',
|
|
107
|
+
width: '100%',
|
|
108
|
+
minHeight: `${lineHeight}rem`,
|
|
109
|
+
lineHeight,
|
|
110
|
+
borderRadius: componentTheme.borderRadius,
|
|
111
|
+
...(attachment && {
|
|
112
|
+
...attachmentBorderRadius[attachment]
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
'&.cm-editor.cm-focused': {
|
|
117
|
+
// Provide a simple default outline to make sure a focused
|
|
118
|
+
// editor is visually distinct. Can't leave the default behavior
|
|
119
|
+
// because that will apply to the content element, which is
|
|
120
|
+
// inside the scrollable container and doesn't include the
|
|
121
|
+
// gutters. We also can't use an 'auto' outline, since those
|
|
122
|
+
// are, for some reason, drawn behind the element content, which
|
|
123
|
+
// will cause things like the active line background to cover
|
|
124
|
+
// the outline (#297).
|
|
125
|
+
outline: `${componentTheme?.borderWidth} solid ${sharedTokens.focusOutline.infoColor}`
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
'.cm-content': {
|
|
129
|
+
padding: `${componentTheme.verticalPadding} 0`
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
'.cm-scroller': {
|
|
133
|
+
fontFamily: componentTheme.fontFamily,
|
|
134
|
+
lineHeight: 1.4375
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
'.cm-gutters': {
|
|
138
|
+
background: componentTheme.gutterBackground,
|
|
139
|
+
borderColor: componentTheme.borderColor
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
'.cm-line': {
|
|
143
|
+
padding: `0 ${componentTheme.horizontalPadding}`
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
'.cm-activeLine': {
|
|
147
|
+
backgroundColor: componentTheme.activeLineColor
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
'&.cm-focused .cm-cursor': { borderLeftColor: componentTheme.color },
|
|
151
|
+
|
|
152
|
+
'.cm-selectionBackground': {
|
|
153
|
+
background: 'transparent'
|
|
154
|
+
},
|
|
155
|
+
'.cm-selectionBackground, .cm-editor::selection': {
|
|
156
|
+
backgroundColor:
|
|
157
|
+
componentTheme.focusedSelectionBackgroundColor + ' !important'
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
'.cm-placeholder': {
|
|
161
|
+
// for better contrast
|
|
162
|
+
color: componentTheme.placeholderBackgroundColor
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
highlightStyle: [
|
|
167
|
+
/**
|
|
168
|
+
* Copy of `defaultHighlightStyle` from '@codemirror/language'
|
|
169
|
+
*/
|
|
170
|
+
// { tag: tags.meta, color: '#7a757a' },
|
|
171
|
+
{ tag: tags.link, textDecoration: 'underline' },
|
|
172
|
+
{ tag: tags.heading, textDecoration: 'underline', fontWeight: 'bold' },
|
|
173
|
+
{ tag: tags.emphasis, fontStyle: 'italic' },
|
|
174
|
+
{ tag: tags.strong, fontWeight: 'bold' },
|
|
175
|
+
{ tag: tags.strikethrough, textDecoration: 'line-through' },
|
|
176
|
+
{ tag: tags.keyword, color: componentTheme.tagKeywordColor },
|
|
177
|
+
{
|
|
178
|
+
tag: [
|
|
179
|
+
tags.atom,
|
|
180
|
+
tags.bool,
|
|
181
|
+
tags.url,
|
|
182
|
+
tags.contentSeparator,
|
|
183
|
+
tags.labelName
|
|
184
|
+
],
|
|
185
|
+
color: componentTheme.tagAtomColor
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
tag: [tags.literal, tags.inserted],
|
|
189
|
+
color: componentTheme.tagLiteralColor
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
tag: [tags.string, tags.deleted],
|
|
193
|
+
color: componentTheme.tagStringColor
|
|
194
|
+
},
|
|
195
|
+
// {
|
|
196
|
+
// tag: [tags.regexp, tags.escape, tags.special(tags.string)],
|
|
197
|
+
// color: '#e40'
|
|
198
|
+
// },
|
|
199
|
+
{
|
|
200
|
+
tag: tags.definition(tags.variableName),
|
|
201
|
+
color: componentTheme.tagDefinitionVariableNameColor
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
tag: tags.local(tags.variableName),
|
|
205
|
+
color: componentTheme.tagLocalVariableNameColor
|
|
206
|
+
},
|
|
207
|
+
// { tag: [tags.typeName, tags.namespace], color: '#085' },
|
|
208
|
+
{ tag: tags.className, color: componentTheme.tagClassNameColor },
|
|
209
|
+
{
|
|
210
|
+
tag: [tags.special(tags.variableName), tags.macroName],
|
|
211
|
+
color: componentTheme.tagSpecialVariableNameColor
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
tag: tags.definition(tags.propertyName),
|
|
215
|
+
color: componentTheme.tagDefinitionPropertyNameColor
|
|
216
|
+
},
|
|
217
|
+
{ tag: tags.comment, color: componentTheme.tagCommentColor },
|
|
218
|
+
// { tag: tags.invalid, color: '#f00' },
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Custom highlighting overrides
|
|
222
|
+
* (where original colors don't have enough contrast against #fff
|
|
223
|
+
* or active highlight background)
|
|
224
|
+
*/
|
|
225
|
+
{ tag: tags.meta, color: componentTheme.tagMetaColor },
|
|
226
|
+
{
|
|
227
|
+
tag: [tags.regexp, tags.escape, tags.special(tags.string)],
|
|
228
|
+
color: componentTheme.tagRegExpColor
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
tag: [tags.typeName, tags.namespace],
|
|
232
|
+
color: componentTheme.tagTypeNameColor
|
|
233
|
+
},
|
|
234
|
+
{ tag: tags.invalid, color: componentTheme.tagInvalidColor }
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export default generateStyle
|
package/src/exports/a.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export { SourceCodeEditor } from '../SourceCodeEditor/v1'
|
|
25
|
+
export type { SourceCodeEditorProps } from '../SourceCodeEditor/v1/props'
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export { SourceCodeEditor } from '../SourceCodeEditor/v2'
|
|
25
|
+
export type { SourceCodeEditorProps } from '../SourceCodeEditor/v2/props'
|