@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [8.25.1-snapshot-19](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-19) (2022-06-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **ui-source-code-editor,ui-code-editor,ui:** add new `SourceCodeEditor` component ([b5064f5](https://github.com/instructure/instructure-ui/commit/b5064f5c767eb2d5c5a6d7f5bb6d05bd689418b5))
12
+
13
+
14
+
15
+
16
+
17
+ See the instructure-ui mono-repo [change log](#CHANGELOG) for past changes.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ ---
2
+ category: packages
3
+ ---
4
+
5
+ ## ui-source-code-editor
6
+
7
+ [![npm][npm]][npm-url] 
8
+ [![MIT License][license-badge]][license] 
9
+ [![Code of Conduct][coc-badge]][coc]
10
+
11
+ A code editor component.
12
+
13
+ ### Components
14
+
15
+ The `ui-source-code-editor` package contains the following:
16
+
17
+ - [SourceCodeEditor](#SourceCodeEditor)
18
+
19
+ ### Installation
20
+
21
+ ```sh
22
+ yarn add @instructure/ui-source-code-editor
23
+ ```
24
+
25
+ ### Usage
26
+
27
+ ```js
28
+ import React from 'react'
29
+ import { SourceCodeEditor } from '@instructure/ui-source-code-editor'
30
+
31
+ const MyCodeEditor = () => {
32
+ return (
33
+ <SourceCodeEditor
34
+ label="code editor"
35
+ defaultValue='{"foo": "bar"}'
36
+ language="javascript"
37
+ readOnly
38
+ />
39
+ )
40
+ }
41
+ ```
42
+
43
+ [npm]: https://img.shields.io/npm/v/@instructure/ui-source-code-editor.svg
44
+ [npm-url]: https://npmjs.com/package/@instructure/ui-source-code-editor
45
+ [license-badge]: https://img.shields.io/npm/l/instructure-ui.svg?style=flat-square
46
+ [license]: https://github.com/instructure/instructure-ui/blob/master/LICENSE
47
+ [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
48
+ [coc]: https://github.com/instructure/instructure-ui/blob/master/CODE_OF_CONDUCT.md
@@ -0,0 +1,81 @@
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
+ import { locator } from '@instructure/ui-test-locator';
25
+ import { find, findAll } from '@instructure/ui-test-queries';
26
+ import { SourceCodeEditor } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
27
+
28
+ export const SourceCodeEditorLocator = locator(SourceCodeEditor.selector, {
29
+ findContainer: async function () {
30
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31
+ args[_key] = arguments[_key];
32
+ }
33
+
34
+ return await find('[class$=-codeEditorContainer]', ...args);
35
+ },
36
+ findLabel: async function () {
37
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
38
+ args[_key2] = arguments[_key2];
39
+ }
40
+
41
+ return await find('[class$=-screenReaderContent]', ...args);
42
+ },
43
+ findInput: async function () {
44
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
45
+ args[_key3] = arguments[_key3];
46
+ }
47
+
48
+ return await find('[role="textbox"]', ...args);
49
+ },
50
+ findGutter: async function () {
51
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
52
+ args[_key4] = arguments[_key4];
53
+ }
54
+
55
+ return await find('.cm-gutter', ...args);
56
+ },
57
+ findScroller: async function () {
58
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
59
+ args[_key5] = arguments[_key5];
60
+ }
61
+
62
+ return await find('.cm-scroller', ...args);
63
+ },
64
+ findAllLines: async function () {
65
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
66
+ args[_key6] = arguments[_key6];
67
+ }
68
+
69
+ return await findAll('.cm-line', ...args);
70
+ },
71
+ findAllGutterElements: async function () {
72
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
73
+ args[_key7] = arguments[_key7];
74
+ }
75
+
76
+ const allGutterElements = await findAll('.cm-gutterElement', ...args); // first gutter element is always a placeholder
77
+
78
+ allGutterElements.shift();
79
+ return allGutterElements;
80
+ }
81
+ });
@@ -0,0 +1,96 @@
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
+ import { cursorCharLeft, cursorCharRight, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorSyntaxLeft, cursorSyntaxRight, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteToLineEnd, deleteToLineStart, selectCharLeft, selectCharRight, selectGroupLeft, selectGroupRight, selectLineBoundaryBackward, selectLineBoundaryForward, selectSyntaxLeft, selectSyntaxRight } from '@codemirror/commands';
25
+ const rtlHorizontalArrowKeymap = [// Left/Start/Forward
26
+ {
27
+ key: 'ArrowLeft',
28
+ run: cursorCharRight,
29
+ shift: selectCharRight,
30
+ preventDefault: true
31
+ }, {
32
+ key: 'Mod-ArrowLeft',
33
+ mac: 'Alt-ArrowLeft',
34
+ run: cursorGroupRight,
35
+ shift: selectGroupRight
36
+ }, {
37
+ key: 'Alt-ArrowLeft',
38
+ mac: 'Ctrl-ArrowLeft',
39
+ run: cursorSyntaxRight,
40
+ shift: selectSyntaxRight
41
+ }, {
42
+ mac: 'Cmd-ArrowLeft',
43
+ run: cursorLineBoundaryForward,
44
+ shift: selectLineBoundaryForward
45
+ }, {
46
+ key: 'Home',
47
+ run: cursorLineBoundaryForward,
48
+ shift: selectLineBoundaryForward
49
+ }, // Right/End/Backward
50
+ {
51
+ key: 'ArrowRight',
52
+ run: cursorCharLeft,
53
+ shift: selectCharLeft,
54
+ preventDefault: true
55
+ }, {
56
+ key: 'Mod-ArrowRight',
57
+ mac: 'Alt-ArrowRight',
58
+ run: cursorGroupLeft,
59
+ shift: selectGroupLeft
60
+ }, {
61
+ key: 'Alt-ArrowRight',
62
+ mac: 'Ctrl-ArrowRight',
63
+ run: cursorSyntaxLeft,
64
+ shift: selectSyntaxLeft
65
+ }, {
66
+ mac: 'Cmd-ArrowRight',
67
+ run: cursorLineBoundaryBackward,
68
+ shift: selectLineBoundaryBackward
69
+ }, {
70
+ key: 'End',
71
+ run: cursorLineBoundaryBackward,
72
+ shift: selectLineBoundaryBackward
73
+ }, // Delete/Backspace
74
+ {
75
+ key: 'Delete',
76
+ run: deleteCharBackward
77
+ }, {
78
+ key: 'Mod-Delete',
79
+ mac: 'Alt-Delete',
80
+ run: deleteGroupBackward
81
+ }, {
82
+ key: 'Backspace',
83
+ run: deleteCharForward,
84
+ shift: deleteCharForward
85
+ }, {
86
+ key: 'Mod-Backspace',
87
+ mac: 'Alt-Backspace',
88
+ run: deleteGroupForward
89
+ }, {
90
+ mac: 'Mod-Delete',
91
+ run: deleteToLineStart
92
+ }, {
93
+ mac: 'Mod-Backspace',
94
+ run: deleteToLineEnd
95
+ }];
96
+ export { rtlHorizontalArrowKeymap };