@instructure/ui-source-code-editor 11.7.10 → 11.7.11-pr-snapshot-1794841957152

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/es/SourceCodeEditor/v1/SearchPanel.js +81 -104
  3. package/es/SourceCodeEditor/v1/customKeybinding.js +85 -98
  4. package/es/SourceCodeEditor/v1/index.js +463 -507
  5. package/es/SourceCodeEditor/v1/props.js +30 -28
  6. package/es/SourceCodeEditor/v1/styles.js +198 -222
  7. package/es/SourceCodeEditor/v1/theme.js +19 -53
  8. package/es/SourceCodeEditor/v2/SearchPanel.js +81 -109
  9. package/es/SourceCodeEditor/v2/customKeybinding.js +85 -98
  10. package/es/SourceCodeEditor/v2/index.js +519 -545
  11. package/es/SourceCodeEditor/v2/props.js +30 -28
  12. package/es/SourceCodeEditor/v2/styles.js +208 -232
  13. package/es/exports/a.js +1 -24
  14. package/es/exports/b.js +1 -24
  15. package/package.json +16 -22
  16. package/src/SourceCodeEditor/v1/index.tsx +10 -5
  17. package/src/SourceCodeEditor/v2/index.tsx +47 -12
  18. package/tsconfig.build.json +0 -1
  19. package/tsconfig.build.tsbuildinfo +1 -1
  20. package/types/SourceCodeEditor/v1/index.d.ts +3 -1
  21. package/types/SourceCodeEditor/v1/index.d.ts.map +1 -1
  22. package/types/SourceCodeEditor/v2/index.d.ts +6 -1
  23. package/types/SourceCodeEditor/v2/index.d.ts.map +1 -1
  24. package/lib/SourceCodeEditor/v1/SearchPanel.js +0 -119
  25. package/lib/SourceCodeEditor/v1/customKeybinding.js +0 -105
  26. package/lib/SourceCodeEditor/v1/index.js +0 -550
  27. package/lib/SourceCodeEditor/v1/props.js +0 -33
  28. package/lib/SourceCodeEditor/v1/styles.js +0 -230
  29. package/lib/SourceCodeEditor/v1/theme.js +0 -60
  30. package/lib/SourceCodeEditor/v2/SearchPanel.js +0 -125
  31. package/lib/SourceCodeEditor/v2/customKeybinding.js +0 -105
  32. package/lib/SourceCodeEditor/v2/index.js +0 -591
  33. package/lib/SourceCodeEditor/v2/props.js +0 -33
  34. package/lib/SourceCodeEditor/v2/styles.js +0 -240
  35. package/lib/exports/a.js +0 -12
  36. package/lib/exports/b.js +0 -12
  37. package/lib/package.json +0 -1
@@ -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,224 +1,200 @@
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) => {
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 ${componentTheme?.focusBorderColor}`
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-selectionBackground': {
133
- background: 'transparent'
134
- },
135
- '.cm-focused .cm-selectionBackground': {
136
- background: '#d7d4f0'
137
- },
138
- '.cm-placeholder': {
139
- // for better contrast
140
- color: '#707070'
141
- }
142
- },
143
- highlightStyle: [
144
- /**
145
- * Copy of `defaultHighlightStyle` from '@codemirror/language'
146
- */
147
- // { tag: tags.meta, color: '#7a757a' },
148
- {
149
- tag: tags.link,
150
- textDecoration: 'underline'
151
- }, {
152
- tag: tags.heading,
153
- textDecoration: 'underline',
154
- fontWeight: 'bold'
155
- }, {
156
- tag: tags.emphasis,
157
- fontStyle: 'italic'
158
- }, {
159
- tag: tags.strong,
160
- fontWeight: 'bold'
161
- }, {
162
- tag: tags.strikethrough,
163
- textDecoration: 'line-through'
164
- }, {
165
- tag: tags.keyword,
166
- color: '#708'
167
- }, {
168
- tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
169
- color: '#219'
170
- }, {
171
- tag: [tags.literal, tags.inserted],
172
- color: '#164'
173
- }, {
174
- tag: [tags.string, tags.deleted],
175
- color: '#a11'
176
- },
177
- // {
178
- // tag: [tags.regexp, tags.escape, tags.special(tags.string)],
179
- // color: '#e40'
180
- // },
181
- {
182
- tag: tags.definition(tags.variableName),
183
- color: '#00f'
184
- }, {
185
- tag: tags.local(tags.variableName),
186
- color: '#30a'
187
- },
188
- // { tag: [tags.typeName, tags.namespace], color: '#085' },
189
- {
190
- tag: tags.className,
191
- color: '#167'
192
- }, {
193
- tag: [tags.special(tags.variableName), tags.macroName],
194
- color: '#256'
195
- }, {
196
- tag: tags.definition(tags.propertyName),
197
- color: '#00c'
198
- }, {
199
- tag: tags.comment,
200
- color: '#940'
201
- },
202
- // { tag: tags.invalid, color: '#f00' },
203
-
204
- /**
205
- * Custom highlighting overrides
206
- * (where original colors don't have enough contrast against #fff
207
- * or active highlight background)
208
- */
209
- {
210
- tag: tags.meta,
211
- color: '#757075'
212
- }, {
213
- tag: [tags.regexp, tags.escape, tags.special(tags.string)],
214
- color: '#d13b00'
215
- }, {
216
- tag: [tags.typeName, tags.namespace],
217
- color: '#008051'
218
- }, {
219
- tag: tags.invalid,
220
- color: '#e60000'
221
- }]
222
- };
2
+ const generateStyle = (componentTheme, props)=>{
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 ${componentTheme?.focusBorderColor}`
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-selectionBackground': {
88
+ background: 'transparent'
89
+ },
90
+ '.cm-focused .cm-selectionBackground': {
91
+ background: '#d7d4f0'
92
+ },
93
+ '.cm-placeholder': {
94
+ color: '#707070'
95
+ }
96
+ },
97
+ highlightStyle: [
98
+ {
99
+ tag: tags.link,
100
+ textDecoration: 'underline'
101
+ },
102
+ {
103
+ tag: tags.heading,
104
+ textDecoration: 'underline',
105
+ fontWeight: 'bold'
106
+ },
107
+ {
108
+ tag: tags.emphasis,
109
+ fontStyle: 'italic'
110
+ },
111
+ {
112
+ tag: tags.strong,
113
+ fontWeight: 'bold'
114
+ },
115
+ {
116
+ tag: tags.strikethrough,
117
+ textDecoration: 'line-through'
118
+ },
119
+ {
120
+ tag: tags.keyword,
121
+ color: '#708'
122
+ },
123
+ {
124
+ tag: [
125
+ tags.atom,
126
+ tags.bool,
127
+ tags.url,
128
+ tags.contentSeparator,
129
+ tags.labelName
130
+ ],
131
+ color: '#219'
132
+ },
133
+ {
134
+ tag: [
135
+ tags.literal,
136
+ tags.inserted
137
+ ],
138
+ color: '#164'
139
+ },
140
+ {
141
+ tag: [
142
+ tags.string,
143
+ tags.deleted
144
+ ],
145
+ color: '#a11'
146
+ },
147
+ {
148
+ tag: tags.definition(tags.variableName),
149
+ color: '#00f'
150
+ },
151
+ {
152
+ tag: tags.local(tags.variableName),
153
+ color: '#30a'
154
+ },
155
+ {
156
+ tag: tags.className,
157
+ color: '#167'
158
+ },
159
+ {
160
+ tag: [
161
+ tags.special(tags.variableName),
162
+ tags.macroName
163
+ ],
164
+ color: '#256'
165
+ },
166
+ {
167
+ tag: tags.definition(tags.propertyName),
168
+ color: '#00c'
169
+ },
170
+ {
171
+ tag: tags.comment,
172
+ color: '#940'
173
+ },
174
+ {
175
+ tag: tags.meta,
176
+ color: '#757075'
177
+ },
178
+ {
179
+ tag: [
180
+ tags.regexp,
181
+ tags.escape,
182
+ tags.special(tags.string)
183
+ ],
184
+ color: '#d13b00'
185
+ },
186
+ {
187
+ tag: [
188
+ tags.typeName,
189
+ tags.namespace
190
+ ],
191
+ color: '#008051'
192
+ },
193
+ {
194
+ tag: tags.invalid,
195
+ color: '#e60000'
196
+ }
197
+ ]
198
+ };
223
199
  };
224
- export default generateStyle;
200
+ export default generateStyle;
@@ -1,54 +1,20 @@
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
- /**
26
- * Generates the theme object for the component from the theme and provided additional information
27
- * @param {Object} theme The actual theme object.
28
- * @return {Object} The final theme object with the overrides and component variables
29
- */
30
- const generateComponentTheme = theme => {
31
- const {
32
- colors,
33
- borders,
34
- typography,
35
- spacing
36
- } = theme;
37
- const componentVariables = {
38
- fontFamily: typography?.fontFamilyMonospace,
39
- fontSize: typography?.fontSizeSmall,
40
- background: colors?.contrasts?.white1010,
41
- color: colors?.contrasts?.grey125125,
42
- gutterBackground: colors?.contrasts?.grey1111,
43
- borderWidth: borders?.widthSmall,
44
- borderColor: colors?.contrasts?.grey3045,
45
- borderRadius: borders?.radiusMedium,
46
- focusBorderColor: colors?.contrasts?.blue4570,
47
- horizontalPadding: spacing?.xSmall,
48
- verticalPadding: spacing?.xxSmall
49
- };
50
- return {
51
- ...componentVariables
52
- };
1
+ const generateComponentTheme = (theme)=>{
2
+ const { colors, borders, typography, spacing } = theme;
3
+ const componentVariables = {
4
+ fontFamily: typography?.fontFamilyMonospace,
5
+ fontSize: typography?.fontSizeSmall,
6
+ background: colors?.contrasts?.white1010,
7
+ color: colors?.contrasts?.grey125125,
8
+ gutterBackground: colors?.contrasts?.grey1111,
9
+ borderWidth: borders?.widthSmall,
10
+ borderColor: colors?.contrasts?.grey3045,
11
+ borderRadius: borders?.radiusMedium,
12
+ focusBorderColor: colors?.contrasts?.blue4570,
13
+ horizontalPadding: spacing?.xSmall,
14
+ verticalPadding: spacing?.xxSmall
15
+ };
16
+ return {
17
+ ...componentVariables
18
+ };
53
19
  };
54
- export default generateComponentTheme;
20
+ export default generateComponentTheme;