@instructure/ui-source-code-editor 8.25.1-snapshot-19

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 (43) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +48 -0
  3. package/es/SourceCodeEditor/SourceCodeEditorLocator.js +81 -0
  4. package/es/SourceCodeEditor/customKeybinding.js +96 -0
  5. package/es/SourceCodeEditor/index.js +587 -0
  6. package/es/SourceCodeEditor/props.js +55 -0
  7. package/es/SourceCodeEditor/styles.js +204 -0
  8. package/es/SourceCodeEditor/theme.js +52 -0
  9. package/es/index.js +24 -0
  10. package/lib/SourceCodeEditor/SourceCodeEditorLocator.js +92 -0
  11. package/lib/SourceCodeEditor/customKeybinding.js +104 -0
  12. package/lib/SourceCodeEditor/index.js +601 -0
  13. package/lib/SourceCodeEditor/props.js +67 -0
  14. package/lib/SourceCodeEditor/styles.js +213 -0
  15. package/lib/SourceCodeEditor/theme.js +60 -0
  16. package/lib/index.js +13 -0
  17. package/lib/package.json +1 -0
  18. package/package.json +68 -0
  19. package/src/SourceCodeEditor/README.md +794 -0
  20. package/src/SourceCodeEditor/SourceCodeEditorLocator.ts +56 -0
  21. package/src/SourceCodeEditor/customKeybinding.ts +121 -0
  22. package/src/SourceCodeEditor/index.tsx +659 -0
  23. package/src/SourceCodeEditor/props.ts +291 -0
  24. package/src/SourceCodeEditor/styles.ts +200 -0
  25. package/src/SourceCodeEditor/theme.ts +55 -0
  26. package/src/index.ts +25 -0
  27. package/tsconfig.build.json +25 -0
  28. package/tsconfig.build.tsbuildinfo +1 -0
  29. package/tsconfig.json +4 -0
  30. package/types/SourceCodeEditor/SourceCodeEditorLocator.d.ts +607 -0
  31. package/types/SourceCodeEditor/SourceCodeEditorLocator.d.ts.map +1 -0
  32. package/types/SourceCodeEditor/customKeybinding.d.ts +4 -0
  33. package/types/SourceCodeEditor/customKeybinding.d.ts.map +1 -0
  34. package/types/SourceCodeEditor/index.d.ts +126 -0
  35. package/types/SourceCodeEditor/index.d.ts.map +1 -0
  36. package/types/SourceCodeEditor/props.d.ts +130 -0
  37. package/types/SourceCodeEditor/props.d.ts.map +1 -0
  38. package/types/SourceCodeEditor/styles.d.ts +14 -0
  39. package/types/SourceCodeEditor/styles.d.ts.map +1 -0
  40. package/types/SourceCodeEditor/theme.d.ts +10 -0
  41. package/types/SourceCodeEditor/theme.d.ts.map +1 -0
  42. package/types/index.d.ts +3 -0
  43. package/types/index.d.ts.map +1 -0
@@ -0,0 +1,56 @@
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 { locator } from '@instructure/ui-test-locator'
26
+ import { find, findAll } from '@instructure/ui-test-queries'
27
+
28
+ import { SourceCodeEditor } from './index'
29
+
30
+ // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
31
+ export const SourceCodeEditorLocator = locator(SourceCodeEditor.selector, {
32
+ findContainer: async (...args: any[]) => {
33
+ return await find('[class$=-codeEditorContainer]', ...args)
34
+ },
35
+ findLabel: async (...args: any[]) => {
36
+ return await find('[class$=-screenReaderContent]', ...args)
37
+ },
38
+ findInput: async (...args: any[]) => {
39
+ return await find('[role="textbox"]', ...args)
40
+ },
41
+ findGutter: async (...args: any[]) => {
42
+ return await find('.cm-gutter', ...args)
43
+ },
44
+ findScroller: async (...args: any[]) => {
45
+ return await find('.cm-scroller', ...args)
46
+ },
47
+ findAllLines: async (...args: any[]) => {
48
+ return await findAll('.cm-line', ...args)
49
+ },
50
+ findAllGutterElements: async (...args: any[]) => {
51
+ const allGutterElements = await findAll('.cm-gutterElement', ...args)
52
+ // first gutter element is always a placeholder
53
+ allGutterElements.shift()
54
+ return allGutterElements
55
+ }
56
+ })
@@ -0,0 +1,121 @@
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 {
26
+ cursorCharLeft,
27
+ cursorCharRight,
28
+ cursorGroupLeft,
29
+ cursorGroupRight,
30
+ cursorLineBoundaryBackward,
31
+ cursorLineBoundaryForward,
32
+ cursorSyntaxLeft,
33
+ cursorSyntaxRight,
34
+ deleteCharBackward,
35
+ deleteCharForward,
36
+ deleteGroupBackward,
37
+ deleteGroupForward,
38
+ deleteToLineEnd,
39
+ deleteToLineStart,
40
+ selectCharLeft,
41
+ selectCharRight,
42
+ selectGroupLeft,
43
+ selectGroupRight,
44
+ selectLineBoundaryBackward,
45
+ selectLineBoundaryForward,
46
+ selectSyntaxLeft,
47
+ selectSyntaxRight
48
+ } from '@codemirror/commands'
49
+ import type { KeyBinding } from '@codemirror/view'
50
+
51
+ const rtlHorizontalArrowKeymap: KeyBinding[] = [
52
+ // Left/Start/Forward
53
+ {
54
+ key: 'ArrowLeft',
55
+ run: cursorCharRight,
56
+ shift: selectCharRight,
57
+ preventDefault: true
58
+ },
59
+ {
60
+ key: 'Mod-ArrowLeft',
61
+ mac: 'Alt-ArrowLeft',
62
+ run: cursorGroupRight,
63
+ shift: selectGroupRight
64
+ },
65
+ {
66
+ key: 'Alt-ArrowLeft',
67
+ mac: 'Ctrl-ArrowLeft',
68
+ run: cursorSyntaxRight,
69
+ shift: selectSyntaxRight
70
+ },
71
+ {
72
+ mac: 'Cmd-ArrowLeft',
73
+ run: cursorLineBoundaryForward,
74
+ shift: selectLineBoundaryForward
75
+ },
76
+ {
77
+ key: 'Home',
78
+ run: cursorLineBoundaryForward,
79
+ shift: selectLineBoundaryForward
80
+ },
81
+
82
+ // Right/End/Backward
83
+ {
84
+ key: 'ArrowRight',
85
+ run: cursorCharLeft,
86
+ shift: selectCharLeft,
87
+ preventDefault: true
88
+ },
89
+ {
90
+ key: 'Mod-ArrowRight',
91
+ mac: 'Alt-ArrowRight',
92
+ run: cursorGroupLeft,
93
+ shift: selectGroupLeft
94
+ },
95
+ {
96
+ key: 'Alt-ArrowRight',
97
+ mac: 'Ctrl-ArrowRight',
98
+ run: cursorSyntaxLeft,
99
+ shift: selectSyntaxLeft
100
+ },
101
+ {
102
+ mac: 'Cmd-ArrowRight',
103
+ run: cursorLineBoundaryBackward,
104
+ shift: selectLineBoundaryBackward
105
+ },
106
+ {
107
+ key: 'End',
108
+ run: cursorLineBoundaryBackward,
109
+ shift: selectLineBoundaryBackward
110
+ },
111
+
112
+ // Delete/Backspace
113
+ { key: 'Delete', run: deleteCharBackward },
114
+ { key: 'Mod-Delete', mac: 'Alt-Delete', run: deleteGroupBackward },
115
+ { key: 'Backspace', run: deleteCharForward, shift: deleteCharForward },
116
+ { key: 'Mod-Backspace', mac: 'Alt-Backspace', run: deleteGroupForward },
117
+ { mac: 'Mod-Delete', run: deleteToLineStart },
118
+ { mac: 'Mod-Backspace', run: deleteToLineEnd }
119
+ ]
120
+
121
+ export { rtlHorizontalArrowKeymap }