@instructure/ui-source-code-editor 11.7.3 → 11.7.4-pr-snapshot-1781695314229

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -0
  3. package/{lib/SourceCodeEditor/v2/props.js → babel.config.cjs} +12 -9
  4. package/es/SourceCodeEditor/v1/index.js +6 -6
  5. package/es/SourceCodeEditor/v2/index.js +5 -5
  6. package/es/exports/a.js +1 -1
  7. package/es/exports/b.js +1 -1
  8. package/package.json +15 -20
  9. package/src/SourceCodeEditor/v1/index.tsx +6 -5
  10. package/src/SourceCodeEditor/v2/index.tsx +5 -4
  11. package/src/exports/a.ts +1 -1
  12. package/src/exports/b.ts +1 -1
  13. package/tsconfig.build.tsbuildinfo +1 -1
  14. package/types/SourceCodeEditor/v1/index.d.ts +2 -1
  15. package/types/SourceCodeEditor/v1/index.d.ts.map +1 -1
  16. package/types/SourceCodeEditor/v2/index.d.ts +2 -1
  17. package/types/SourceCodeEditor/v2/index.d.ts.map +1 -1
  18. package/types/exports/a.d.ts +1 -1
  19. package/types/exports/a.d.ts.map +1 -1
  20. package/types/exports/b.d.ts +1 -1
  21. package/types/exports/b.d.ts.map +1 -1
  22. package/lib/SourceCodeEditor/v1/SearchPanel.js +0 -121
  23. package/lib/SourceCodeEditor/v1/customKeybinding.js +0 -105
  24. package/lib/SourceCodeEditor/v1/index.js +0 -552
  25. package/lib/SourceCodeEditor/v1/props.js +0 -33
  26. package/lib/SourceCodeEditor/v1/styles.js +0 -230
  27. package/lib/SourceCodeEditor/v1/theme.js +0 -60
  28. package/lib/SourceCodeEditor/v2/SearchPanel.js +0 -121
  29. package/lib/SourceCodeEditor/v2/customKeybinding.js +0 -105
  30. package/lib/SourceCodeEditor/v2/index.js +0 -559
  31. package/lib/SourceCodeEditor/v2/styles.js +0 -236
  32. package/lib/exports/a.js +0 -12
  33. package/lib/exports/b.js +0 -12
  34. package/lib/package.json +0 -1
@@ -1,230 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _highlight = require("@lezer/highlight");
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- /**
33
- * ---
34
- * private: true
35
- * ---
36
- * Generates the style object from the theme and provided additional information
37
- * @param {Object} componentTheme The theme variable object.
38
- * @param {Object} props the props of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, props) => {
42
- const {
43
- attachment,
44
- height,
45
- width
46
- } = props;
47
- const attachmentBorderRadius = {
48
- top: {
49
- borderBottomLeftRadius: 0,
50
- borderBottomRightRadius: 0
51
- },
52
- bottom: {
53
- borderTopLeftRadius: 0,
54
- borderTopRightRadius: 0
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
- const lineHeight = 1.4375;
69
- return {
70
- codeEditor: {
71
- label: 'codeEditor',
72
- position: 'relative',
73
- boxSizing: 'border-box',
74
- height: height || 'auto',
75
- width
76
- },
77
- label: {
78
- label: 'label',
79
- height: '100%',
80
- width: '100%'
81
- },
82
- codeEditorContainer: {
83
- label: 'codeEditorContainer',
84
- height: '100%',
85
- width: '100%',
86
- borderColor: componentTheme?.borderColor,
87
- borderStyle: 'solid',
88
- borderWidth: componentTheme?.borderWidth,
89
- borderRadius: componentTheme.borderRadius,
90
- marginBottom: '1rem',
91
- ...(attachment && {
92
- ...attachmentVariants[attachment],
93
- ...attachmentBorderRadius[attachment]
94
- })
95
- },
96
- theme: {
97
- '&': {
98
- overflow: 'hidden',
99
- background: componentTheme.background,
100
- fontFamily: componentTheme.fontFamily,
101
- fontSize: componentTheme.fontSize,
102
- color: componentTheme.color,
103
- border: 0,
104
- height: '100%',
105
- width: '100%',
106
- minHeight: `${lineHeight}rem`,
107
- lineHeight,
108
- borderRadius: componentTheme.borderRadius,
109
- ...(attachment && {
110
- ...attachmentBorderRadius[attachment]
111
- })
112
- },
113
- '&.cm-editor.cm-focused': {
114
- // Provide a simple default outline to make sure a focused
115
- // editor is visually distinct. Can't leave the default behavior
116
- // because that will apply to the content element, which is
117
- // inside the scrollable container and doesn't include the
118
- // gutters. We also can't use an 'auto' outline, since those
119
- // are, for some reason, drawn behind the element content, which
120
- // will cause things like the active line background to cover
121
- // the outline (#297).
122
- outline: `${componentTheme?.borderWidth} solid ${componentTheme?.focusBorderColor}`
123
- },
124
- '.cm-content': {
125
- padding: `${componentTheme.verticalPadding} 0`
126
- },
127
- '.cm-scroller': {
128
- fontFamily: componentTheme.fontFamily,
129
- lineHeight: 1.4375
130
- },
131
- '.cm-gutters': {
132
- background: componentTheme.gutterBackground,
133
- borderColor: componentTheme.borderColor
134
- },
135
- '.cm-line': {
136
- padding: `0 ${componentTheme.horizontalPadding}`
137
- },
138
- '.cm-selectionBackground': {
139
- background: 'transparent'
140
- },
141
- '.cm-focused .cm-selectionBackground': {
142
- background: '#d7d4f0'
143
- },
144
- '.cm-placeholder': {
145
- // for better contrast
146
- color: '#707070'
147
- }
148
- },
149
- highlightStyle: [
150
- /**
151
- * Copy of `defaultHighlightStyle` from '@codemirror/language'
152
- */
153
- // { tag: tags.meta, color: '#7a757a' },
154
- {
155
- tag: _highlight.tags.link,
156
- textDecoration: 'underline'
157
- }, {
158
- tag: _highlight.tags.heading,
159
- textDecoration: 'underline',
160
- fontWeight: 'bold'
161
- }, {
162
- tag: _highlight.tags.emphasis,
163
- fontStyle: 'italic'
164
- }, {
165
- tag: _highlight.tags.strong,
166
- fontWeight: 'bold'
167
- }, {
168
- tag: _highlight.tags.strikethrough,
169
- textDecoration: 'line-through'
170
- }, {
171
- tag: _highlight.tags.keyword,
172
- color: '#708'
173
- }, {
174
- tag: [_highlight.tags.atom, _highlight.tags.bool, _highlight.tags.url, _highlight.tags.contentSeparator, _highlight.tags.labelName],
175
- color: '#219'
176
- }, {
177
- tag: [_highlight.tags.literal, _highlight.tags.inserted],
178
- color: '#164'
179
- }, {
180
- tag: [_highlight.tags.string, _highlight.tags.deleted],
181
- color: '#a11'
182
- },
183
- // {
184
- // tag: [tags.regexp, tags.escape, tags.special(tags.string)],
185
- // color: '#e40'
186
- // },
187
- {
188
- tag: _highlight.tags.definition(_highlight.tags.variableName),
189
- color: '#00f'
190
- }, {
191
- tag: _highlight.tags.local(_highlight.tags.variableName),
192
- color: '#30a'
193
- },
194
- // { tag: [tags.typeName, tags.namespace], color: '#085' },
195
- {
196
- tag: _highlight.tags.className,
197
- color: '#167'
198
- }, {
199
- tag: [_highlight.tags.special(_highlight.tags.variableName), _highlight.tags.macroName],
200
- color: '#256'
201
- }, {
202
- tag: _highlight.tags.definition(_highlight.tags.propertyName),
203
- color: '#00c'
204
- }, {
205
- tag: _highlight.tags.comment,
206
- color: '#940'
207
- },
208
- // { tag: tags.invalid, color: '#f00' },
209
-
210
- /**
211
- * Custom highlighting overrides
212
- * (where original colors don't have enough contrast against #fff
213
- * or active highlight background)
214
- */
215
- {
216
- tag: _highlight.tags.meta,
217
- color: '#757075'
218
- }, {
219
- tag: [_highlight.tags.regexp, _highlight.tags.escape, _highlight.tags.special(_highlight.tags.string)],
220
- color: '#d13b00'
221
- }, {
222
- tag: [_highlight.tags.typeName, _highlight.tags.namespace],
223
- color: '#008051'
224
- }, {
225
- tag: _highlight.tags.invalid,
226
- color: '#e60000'
227
- }]
228
- };
229
- };
230
- var _default = exports.default = generateStyle;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- const {
38
- colors,
39
- borders,
40
- typography,
41
- spacing
42
- } = theme;
43
- const componentVariables = {
44
- fontFamily: typography?.fontFamilyMonospace,
45
- fontSize: typography?.fontSizeSmall,
46
- background: colors?.contrasts?.white1010,
47
- color: colors?.contrasts?.grey125125,
48
- gutterBackground: colors?.contrasts?.grey1111,
49
- borderWidth: borders?.widthSmall,
50
- borderColor: colors?.contrasts?.grey3045,
51
- borderRadius: borders?.radiusMedium,
52
- focusBorderColor: colors?.contrasts?.blue4570,
53
- horizontalPadding: spacing?.xSmall,
54
- verticalPadding: spacing?.xxSmall
55
- };
56
- return {
57
- ...componentVariables
58
- };
59
- };
60
- var _default = exports.default = generateComponentTheme;
@@ -1,121 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = customSearch;
7
- var _react = require("react");
8
- var _search = require("@codemirror/search");
9
- var _latest = require("@instructure/ui-text-input/latest");
10
- var _latest2 = require("@instructure/ui-buttons/latest");
11
- var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenDownLine.js");
12
- var _IconArrowOpenUpLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenUpLine.js");
13
- var _IconSearchLine = require("@instructure/ui-icons/lib/generated/IconSearchLine.js");
14
- var _client = require("react-dom/client");
15
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
- /*
17
- * The MIT License (MIT)
18
- *
19
- * Copyright (c) 2015 - present Instructure, Inc.
20
- *
21
- * Permission is hereby granted, free of charge, to any person obtaining a copy
22
- * of this software and associated documentation files (the "Software"), to deal
23
- * in the Software without restriction, including without limitation the rights
24
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
- * copies of the Software, and to permit persons to whom the Software is
26
- * furnished to do so, subject to the following conditions:
27
- *
28
- * The above copyright notice and this permission notice shall be included in all
29
- * copies or substantial portions of the Software.
30
- *
31
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
- * SOFTWARE.
38
- */
39
-
40
- function SearchPanel({
41
- view,
42
- searchConfig
43
- }) {
44
- const [searchQueryStr, setSearchQueryStr] = (0, _react.useState)('');
45
- const handleChange = (_e, value) => {
46
- setSearchQueryStr(value);
47
- handleHighlightSearch(value);
48
- };
49
- const handleHighlightSearch = searchStr => {
50
- view.dispatch({
51
- effects: _search.setSearchQuery.of(new _search.SearchQuery({
52
- search: searchStr
53
- }))
54
- });
55
- };
56
- const handleKeyDown = e => {
57
- if (e.key !== 'Enter') return;
58
- if (!e.shiftKey) handleFindNext();else handleFindPrev();
59
- };
60
- const handleKeyUp = e => {
61
- if (e.key !== 'Escape') return;
62
- (0, _search.closeSearchPanel)(view);
63
- };
64
- const handleFindNext = () => {
65
- handleHighlightSearch(searchQueryStr);
66
- (0, _search.findNext)(view);
67
- };
68
- const handleFindPrev = () => {
69
- handleHighlightSearch(searchQueryStr);
70
- (0, _search.findPrevious)(view);
71
- };
72
- return (0, _jsxRuntime.jsx)(_latest.TextInput, {
73
- renderLabel: "",
74
- inputRef: r => {
75
- setTimeout(() => r?.focus(), 0);
76
- },
77
- size: "small",
78
- display: "inline-block",
79
- width: "20rem",
80
- placeholder: searchConfig.placeholder,
81
- onChange: handleChange,
82
- onKeyDown: handleKeyDown,
83
- onKeyUp: handleKeyUp,
84
- renderBeforeInput: (0, _jsxRuntime.jsx)(_IconSearchLine.IconSearchLine, {
85
- size: "x-small"
86
- }),
87
- renderAfterInput: (0, _jsxRuntime.jsxs)("span", {
88
- children: [(0, _jsxRuntime.jsx)(_latest2.IconButton, {
89
- size: "small",
90
- withBorder: false,
91
- withBackground: false,
92
- onClick: handleFindNext,
93
- screenReaderLabel: searchConfig.nextResultLabel,
94
- children: (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {})
95
- }), (0, _jsxRuntime.jsx)(_latest2.IconButton, {
96
- size: "small",
97
- withBorder: false,
98
- withBackground: false,
99
- onClick: handleFindPrev,
100
- screenReaderLabel: searchConfig.prevResultLabel,
101
- children: (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine.IconArrowOpenUpLine, {})
102
- })]
103
- })
104
- });
105
- }
106
- function customSearch(searchConfig) {
107
- return searchConfig ? (0, _search.search)({
108
- createPanel: view => {
109
- const dom = document.createElement('div');
110
- dom.style.padding = '8px';
111
- const root = (0, _client.createRoot)(dom);
112
- root.render((0, _jsxRuntime.jsx)(SearchPanel, {
113
- view: view,
114
- searchConfig: searchConfig
115
- }));
116
- return {
117
- dom
118
- };
119
- }
120
- }) : [];
121
- }
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.rtlHorizontalArrowKeymap = void 0;
7
- var _commands = require("@codemirror/commands");
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- const rtlHorizontalArrowKeymap = exports.rtlHorizontalArrowKeymap = [
33
- // Left/Start/Forward
34
- {
35
- key: 'ArrowLeft',
36
- run: _commands.cursorCharRight,
37
- shift: _commands.selectCharRight,
38
- preventDefault: true
39
- }, {
40
- key: 'Mod-ArrowLeft',
41
- mac: 'Alt-ArrowLeft',
42
- run: _commands.cursorGroupRight,
43
- shift: _commands.selectGroupRight
44
- }, {
45
- key: 'Alt-ArrowLeft',
46
- mac: 'Ctrl-ArrowLeft',
47
- run: _commands.cursorSyntaxRight,
48
- shift: _commands.selectSyntaxRight
49
- }, {
50
- mac: 'Cmd-ArrowLeft',
51
- run: _commands.cursorLineBoundaryRight,
52
- shift: _commands.selectLineBoundaryRight
53
- }, {
54
- key: 'Home',
55
- run: _commands.cursorLineBoundaryForward,
56
- shift: _commands.selectLineBoundaryForward
57
- },
58
- // Right/End/Backward
59
- {
60
- key: 'ArrowRight',
61
- run: _commands.cursorCharLeft,
62
- shift: _commands.selectCharLeft,
63
- preventDefault: true
64
- }, {
65
- key: 'Mod-ArrowRight',
66
- mac: 'Alt-ArrowRight',
67
- run: _commands.cursorGroupLeft,
68
- shift: _commands.selectGroupLeft
69
- }, {
70
- key: 'Alt-ArrowRight',
71
- mac: 'Ctrl-ArrowRight',
72
- run: _commands.cursorSyntaxLeft,
73
- shift: _commands.selectSyntaxLeft
74
- }, {
75
- mac: 'Cmd-ArrowRight',
76
- run: _commands.cursorLineBoundaryLeft,
77
- shift: _commands.selectLineBoundaryLeft
78
- }, {
79
- key: 'End',
80
- run: _commands.cursorLineBoundaryBackward,
81
- shift: _commands.selectLineBoundaryBackward
82
- },
83
- // Delete/Backspace
84
- {
85
- key: 'Delete',
86
- run: _commands.deleteCharBackward
87
- }, {
88
- key: 'Mod-Delete',
89
- mac: 'Alt-Delete',
90
- run: _commands.deleteGroupBackward
91
- }, {
92
- key: 'Backspace',
93
- run: _commands.deleteCharForward,
94
- shift: _commands.deleteCharForward
95
- }, {
96
- key: 'Mod-Backspace',
97
- mac: 'Alt-Backspace',
98
- run: _commands.deleteGroupForward
99
- }, {
100
- mac: 'Mod-Delete',
101
- run: _commands.deleteToLineStart
102
- }, {
103
- mac: 'Mod-Backspace',
104
- run: _commands.deleteToLineEnd
105
- }];