@instructure/ui-source-code-editor 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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,28 +1,30 @@
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
- const allowedProps = ['label', 'language', 'readOnly', 'editable', 'lineNumbers', 'foldGutter', 'highlightActiveLineGutter', 'highlightActiveLine', 'lineWrapping', 'autofocus', 'spellcheck', 'direction', 'rtlMoveVisually', 'indentOnLoad', 'indentWithTab', 'indentUnit', 'defaultValue', 'value', 'onChange', 'onFocus', 'onBlur', 'attachment', 'height', 'width',
26
- // 'darkTheme',
27
- 'elementRef', 'containerRef', 'searchConfig'];
28
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'label',
3
+ 'language',
4
+ 'readOnly',
5
+ 'editable',
6
+ 'lineNumbers',
7
+ 'foldGutter',
8
+ 'highlightActiveLineGutter',
9
+ 'highlightActiveLine',
10
+ 'lineWrapping',
11
+ 'autofocus',
12
+ 'spellcheck',
13
+ 'direction',
14
+ 'rtlMoveVisually',
15
+ 'indentOnLoad',
16
+ 'indentWithTab',
17
+ 'indentUnit',
18
+ 'defaultValue',
19
+ 'value',
20
+ 'onChange',
21
+ 'onFocus',
22
+ 'onBlur',
23
+ 'attachment',
24
+ 'height',
25
+ 'width',
26
+ 'elementRef',
27
+ 'containerRef',
28
+ 'searchConfig'
29
+ ];
30
+ export { allowedProps };
@@ -1,234 +1,210 @@
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
1
  import { tags } from '@lezer/highlight';
26
- /**
27
- * ---
28
- * private: true
29
- * ---
30
- * Generates the style object from the theme and provided additional information
31
- * @param {Object} componentTheme The theme variable object.
32
- * @param {Object} props the props of the component, the style is applied to
33
- * @return {Object} The final style object, which will be used in the component
34
- */
35
- const generateStyle = (componentTheme, props, sharedTokens) => {
36
- const {
37
- attachment,
38
- height,
39
- width
40
- } = props;
41
- const attachmentBorderRadius = {
42
- top: {
43
- borderBottomLeftRadius: 0,
44
- borderBottomRightRadius: 0
45
- },
46
- bottom: {
47
- borderTopLeftRadius: 0,
48
- borderTopRightRadius: 0
49
- }
50
- };
51
- const attachmentVariants = {
52
- top: {
53
- marginBottom: 0,
54
- marginTop: '0.25rem'
55
- },
56
- bottom: {
57
- borderTopLeftRadius: 0,
58
- borderTopRightRadius: 0,
59
- marginBottom: '0.25rem'
60
- }
61
- };
62
- const lineHeight = 1.4375;
63
- return {
64
- codeEditor: {
65
- label: 'codeEditor',
66
- position: 'relative',
67
- boxSizing: 'border-box',
68
- height: height || 'auto',
69
- width
70
- },
71
- label: {
72
- label: 'label',
73
- height: '100%',
74
- width: '100%'
75
- },
76
- codeEditorContainer: {
77
- label: 'codeEditorContainer',
78
- height: '100%',
79
- width: '100%',
80
- borderColor: componentTheme?.borderColor,
81
- borderStyle: 'solid',
82
- borderWidth: componentTheme?.borderWidth,
83
- borderRadius: componentTheme.borderRadius,
84
- marginBottom: '1rem',
85
- ...(attachment && {
86
- ...attachmentVariants[attachment],
87
- ...attachmentBorderRadius[attachment]
88
- })
89
- },
90
- theme: {
91
- '&': {
92
- overflow: 'hidden',
93
- background: componentTheme.background,
94
- fontFamily: componentTheme.fontFamily,
95
- fontSize: componentTheme.fontSize,
96
- color: componentTheme.color,
97
- border: 0,
98
- height: '100%',
99
- width: '100%',
100
- minHeight: `${lineHeight}rem`,
101
- lineHeight,
102
- borderRadius: componentTheme.borderRadius,
103
- ...(attachment && {
104
- ...attachmentBorderRadius[attachment]
105
- })
106
- },
107
- '&.cm-editor.cm-focused': {
108
- // Provide a simple default outline to make sure a focused
109
- // editor is visually distinct. Can't leave the default behavior
110
- // because that will apply to the content element, which is
111
- // inside the scrollable container and doesn't include the
112
- // gutters. We also can't use an 'auto' outline, since those
113
- // are, for some reason, drawn behind the element content, which
114
- // will cause things like the active line background to cover
115
- // the outline (#297).
116
- outline: `${componentTheme?.borderWidth} solid ${sharedTokens.focusOutline.infoColor}`
117
- },
118
- '.cm-content': {
119
- padding: `${componentTheme.verticalPadding} 0`
120
- },
121
- '.cm-scroller': {
122
- fontFamily: componentTheme.fontFamily,
123
- lineHeight: 1.4375
124
- },
125
- '.cm-gutters': {
126
- background: componentTheme.gutterBackground,
127
- borderColor: componentTheme.borderColor
128
- },
129
- '.cm-line': {
130
- padding: `0 ${componentTheme.horizontalPadding}`
131
- },
132
- '.cm-activeLine': {
133
- backgroundColor: componentTheme.activeLineColor
134
- },
135
- '&.cm-focused .cm-cursor': {
136
- borderLeftColor: componentTheme.color
137
- },
138
- '.cm-selectionBackground': {
139
- background: 'transparent'
140
- },
141
- '.cm-selectionBackground, .cm-editor::selection': {
142
- backgroundColor: componentTheme.focusedSelectionBackgroundColor + ' !important'
143
- },
144
- '.cm-placeholder': {
145
- // for better contrast
146
- color: componentTheme.placeholderBackgroundColor
147
- },
148
- '.cm-panels': {
149
- backgroundColor: componentTheme.background,
150
- color: componentTheme.color
151
- }
152
- },
153
- highlightStyle: [
154
- /**
155
- * Copy of `defaultHighlightStyle` from '@codemirror/language'
156
- */
157
- // { tag: tags.meta, color: '#7a757a' },
158
- {
159
- tag: tags.link,
160
- textDecoration: 'underline'
161
- }, {
162
- tag: tags.heading,
163
- textDecoration: 'underline',
164
- fontWeight: 'bold'
165
- }, {
166
- tag: tags.emphasis,
167
- fontStyle: 'italic'
168
- }, {
169
- tag: tags.strong,
170
- fontWeight: 'bold'
171
- }, {
172
- tag: tags.strikethrough,
173
- textDecoration: 'line-through'
174
- }, {
175
- tag: tags.keyword,
176
- color: componentTheme.tagKeywordColor
177
- }, {
178
- tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
179
- color: componentTheme.tagAtomColor
180
- }, {
181
- tag: [tags.literal, tags.inserted],
182
- color: componentTheme.tagLiteralColor
183
- }, {
184
- tag: [tags.string, tags.deleted],
185
- color: componentTheme.tagStringColor
186
- },
187
- // {
188
- // tag: [tags.regexp, tags.escape, tags.special(tags.string)],
189
- // color: '#e40'
190
- // },
191
- {
192
- tag: tags.definition(tags.variableName),
193
- color: componentTheme.tagDefinitionVariableNameColor
194
- }, {
195
- tag: tags.local(tags.variableName),
196
- color: componentTheme.tagLocalVariableNameColor
197
- },
198
- // { tag: [tags.typeName, tags.namespace], color: '#085' },
199
- {
200
- tag: tags.className,
201
- color: componentTheme.tagClassNameColor
202
- }, {
203
- tag: [tags.special(tags.variableName), tags.macroName],
204
- color: componentTheme.tagSpecialVariableNameColor
205
- }, {
206
- tag: tags.definition(tags.propertyName),
207
- color: componentTheme.tagDefinitionPropertyNameColor
208
- }, {
209
- tag: tags.comment,
210
- color: componentTheme.tagCommentColor
211
- },
212
- // { tag: tags.invalid, color: '#f00' },
213
-
214
- /**
215
- * Custom highlighting overrides
216
- * (where original colors don't have enough contrast against #fff
217
- * or active highlight background)
218
- */
219
- {
220
- tag: tags.meta,
221
- color: componentTheme.tagMetaColor
222
- }, {
223
- tag: [tags.regexp, tags.escape, tags.special(tags.string)],
224
- color: componentTheme.tagRegExpColor
225
- }, {
226
- tag: [tags.typeName, tags.namespace],
227
- color: componentTheme.tagTypeNameColor
228
- }, {
229
- tag: tags.invalid,
230
- color: componentTheme.tagInvalidColor
231
- }]
232
- };
2
+ const generateStyle = (componentTheme, props, sharedTokens)=>{
3
+ const { attachment, height, width } = props;
4
+ const attachmentBorderRadius = {
5
+ top: {
6
+ borderBottomLeftRadius: 0,
7
+ borderBottomRightRadius: 0
8
+ },
9
+ bottom: {
10
+ borderTopLeftRadius: 0,
11
+ borderTopRightRadius: 0
12
+ }
13
+ };
14
+ const attachmentVariants = {
15
+ top: {
16
+ marginBottom: 0,
17
+ marginTop: '0.25rem'
18
+ },
19
+ bottom: {
20
+ borderTopLeftRadius: 0,
21
+ borderTopRightRadius: 0,
22
+ marginBottom: '0.25rem'
23
+ }
24
+ };
25
+ const lineHeight = 1.4375;
26
+ return {
27
+ codeEditor: {
28
+ label: 'codeEditor',
29
+ position: 'relative',
30
+ boxSizing: 'border-box',
31
+ height: height || 'auto',
32
+ width
33
+ },
34
+ label: {
35
+ label: 'label',
36
+ height: '100%',
37
+ width: '100%'
38
+ },
39
+ codeEditorContainer: {
40
+ label: 'codeEditorContainer',
41
+ height: '100%',
42
+ width: '100%',
43
+ borderColor: componentTheme?.borderColor,
44
+ borderStyle: 'solid',
45
+ borderWidth: componentTheme?.borderWidth,
46
+ borderRadius: componentTheme.borderRadius,
47
+ marginBottom: '1rem',
48
+ ...attachment && {
49
+ ...attachmentVariants[attachment],
50
+ ...attachmentBorderRadius[attachment]
51
+ }
52
+ },
53
+ theme: {
54
+ '&': {
55
+ overflow: 'hidden',
56
+ background: componentTheme.background,
57
+ fontFamily: componentTheme.fontFamily,
58
+ fontSize: componentTheme.fontSize,
59
+ color: componentTheme.color,
60
+ border: 0,
61
+ height: '100%',
62
+ width: '100%',
63
+ minHeight: `${lineHeight}rem`,
64
+ lineHeight,
65
+ borderRadius: componentTheme.borderRadius,
66
+ ...attachment && {
67
+ ...attachmentBorderRadius[attachment]
68
+ }
69
+ },
70
+ '&.cm-editor.cm-focused': {
71
+ outline: `${componentTheme?.borderWidth} solid ${sharedTokens.focusOutline.infoColor}`
72
+ },
73
+ '.cm-content': {
74
+ padding: `${componentTheme.verticalPadding} 0`
75
+ },
76
+ '.cm-scroller': {
77
+ fontFamily: componentTheme.fontFamily,
78
+ lineHeight: 1.4375
79
+ },
80
+ '.cm-gutters': {
81
+ background: componentTheme.gutterBackground,
82
+ borderColor: componentTheme.borderColor
83
+ },
84
+ '.cm-line': {
85
+ padding: `0 ${componentTheme.horizontalPadding}`
86
+ },
87
+ '.cm-activeLine': {
88
+ backgroundColor: componentTheme.activeLineColor
89
+ },
90
+ '&.cm-focused .cm-cursor': {
91
+ borderLeftColor: componentTheme.color
92
+ },
93
+ '.cm-selectionBackground': {
94
+ background: 'transparent'
95
+ },
96
+ '.cm-selectionBackground, .cm-editor::selection': {
97
+ backgroundColor: componentTheme.focusedSelectionBackgroundColor + ' !important'
98
+ },
99
+ '.cm-placeholder': {
100
+ color: componentTheme.placeholderBackgroundColor
101
+ },
102
+ '.cm-panels': {
103
+ backgroundColor: componentTheme.background,
104
+ color: componentTheme.color
105
+ }
106
+ },
107
+ highlightStyle: [
108
+ {
109
+ tag: tags.link,
110
+ textDecoration: 'underline'
111
+ },
112
+ {
113
+ tag: tags.heading,
114
+ textDecoration: 'underline',
115
+ fontWeight: 'bold'
116
+ },
117
+ {
118
+ tag: tags.emphasis,
119
+ fontStyle: 'italic'
120
+ },
121
+ {
122
+ tag: tags.strong,
123
+ fontWeight: 'bold'
124
+ },
125
+ {
126
+ tag: tags.strikethrough,
127
+ textDecoration: 'line-through'
128
+ },
129
+ {
130
+ tag: tags.keyword,
131
+ color: componentTheme.tagKeywordColor
132
+ },
133
+ {
134
+ tag: [
135
+ tags.atom,
136
+ tags.bool,
137
+ tags.url,
138
+ tags.contentSeparator,
139
+ tags.labelName
140
+ ],
141
+ color: componentTheme.tagAtomColor
142
+ },
143
+ {
144
+ tag: [
145
+ tags.literal,
146
+ tags.inserted
147
+ ],
148
+ color: componentTheme.tagLiteralColor
149
+ },
150
+ {
151
+ tag: [
152
+ tags.string,
153
+ tags.deleted
154
+ ],
155
+ color: componentTheme.tagStringColor
156
+ },
157
+ {
158
+ tag: tags.definition(tags.variableName),
159
+ color: componentTheme.tagDefinitionVariableNameColor
160
+ },
161
+ {
162
+ tag: tags.local(tags.variableName),
163
+ color: componentTheme.tagLocalVariableNameColor
164
+ },
165
+ {
166
+ tag: tags.className,
167
+ color: componentTheme.tagClassNameColor
168
+ },
169
+ {
170
+ tag: [
171
+ tags.special(tags.variableName),
172
+ tags.macroName
173
+ ],
174
+ color: componentTheme.tagSpecialVariableNameColor
175
+ },
176
+ {
177
+ tag: tags.definition(tags.propertyName),
178
+ color: componentTheme.tagDefinitionPropertyNameColor
179
+ },
180
+ {
181
+ tag: tags.comment,
182
+ color: componentTheme.tagCommentColor
183
+ },
184
+ {
185
+ tag: tags.meta,
186
+ color: componentTheme.tagMetaColor
187
+ },
188
+ {
189
+ tag: [
190
+ tags.regexp,
191
+ tags.escape,
192
+ tags.special(tags.string)
193
+ ],
194
+ color: componentTheme.tagRegExpColor
195
+ },
196
+ {
197
+ tag: [
198
+ tags.typeName,
199
+ tags.namespace
200
+ ],
201
+ color: componentTheme.tagTypeNameColor
202
+ },
203
+ {
204
+ tag: tags.invalid,
205
+ color: componentTheme.tagInvalidColor
206
+ }
207
+ ]
208
+ };
233
209
  };
234
- export default generateStyle;
210
+ export default generateStyle;
package/es/exports/a.js CHANGED
@@ -1,24 +1 @@
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/index.js';
1
+ export { SourceCodeEditor } from '../SourceCodeEditor/v1/index.js';
package/es/exports/b.js CHANGED
@@ -1,24 +1 @@
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/index.js';
1
+ export { SourceCodeEditor } from '../SourceCodeEditor/v2/index.js';