@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,118 +1,90 @@
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
-
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
25
2
  import { useState } from 'react';
26
3
  import { setSearchQuery, search, findNext, findPrevious, SearchQuery, closeSearchPanel } from '@codemirror/search';
27
4
  import { TextInput } from '@instructure/ui-text-input/latest';
28
5
  import { IconButton } from '@instructure/ui-buttons/latest';
29
6
  import { IconArrowOpenDownLine, IconArrowOpenUpLine, IconSearchLine } from '@instructure/ui-icons';
30
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
31
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- */
36
- export function SearchPanel({
37
- view,
38
- searchConfig
39
- }) {
40
- const [searchQueryStr, setSearchQueryStr] = useState('');
41
- const handleChange = (_e, value) => {
42
- setSearchQueryStr(value);
43
- handleHighlightSearch(value);
44
- };
45
- const handleHighlightSearch = searchStr => {
46
- view.dispatch({
47
- effects: setSearchQuery.of(new SearchQuery({
48
- search: searchStr
49
- }))
50
- });
51
- };
52
- const handleKeyDown = e => {
53
- if (e.key !== 'Enter') return;
54
- if (!e.shiftKey) handleFindNext();else handleFindPrev();
55
- };
56
- const handleKeyUp = e => {
57
- if (e.key !== 'Escape') return;
58
- closeSearchPanel(view);
59
- };
60
- const handleFindNext = () => {
61
- handleHighlightSearch(searchQueryStr);
62
- findNext(view);
63
- };
64
- const handleFindPrev = () => {
65
- handleHighlightSearch(searchQueryStr);
66
- findPrevious(view);
67
- };
68
- return _jsx(TextInput, {
69
- renderLabel: "",
70
- inputRef: r => {
71
- setTimeout(() => r?.focus(), 0);
72
- },
73
- size: "small",
74
- display: "inline-block",
75
- width: "20rem",
76
- placeholder: searchConfig.placeholder,
77
- onChange: handleChange,
78
- onKeyDown: handleKeyDown,
79
- onKeyUp: handleKeyUp,
80
- renderBeforeInput: _jsx(IconSearchLine, {
81
- size: "x-small"
82
- }),
83
- renderAfterInput: _jsxs("span", {
84
- children: [_jsx(IconButton, {
85
- size: "small",
86
- withBorder: false,
87
- withBackground: false,
88
- onClick: handleFindNext,
89
- screenReaderLabel: searchConfig.nextResultLabel,
90
- children: _jsx(IconArrowOpenDownLine, {})
91
- }), _jsx(IconButton, {
7
+ export function SearchPanel({ view, searchConfig }) {
8
+ const [searchQueryStr, setSearchQueryStr] = useState('');
9
+ const handleChange = (_e, value)=>{
10
+ setSearchQueryStr(value);
11
+ handleHighlightSearch(value);
12
+ };
13
+ const handleHighlightSearch = (searchStr)=>{
14
+ view.dispatch({
15
+ effects: setSearchQuery.of(new SearchQuery({
16
+ search: searchStr
17
+ }))
18
+ });
19
+ };
20
+ const handleKeyDown = (e)=>{
21
+ if (e.key !== 'Enter') return;
22
+ if (!e.shiftKey) handleFindNext();
23
+ else handleFindPrev();
24
+ };
25
+ const handleKeyUp = (e)=>{
26
+ if (e.key !== 'Escape') return;
27
+ closeSearchPanel(view);
28
+ };
29
+ const handleFindNext = ()=>{
30
+ handleHighlightSearch(searchQueryStr);
31
+ findNext(view);
32
+ };
33
+ const handleFindPrev = ()=>{
34
+ handleHighlightSearch(searchQueryStr);
35
+ findPrevious(view);
36
+ };
37
+ return /*#__PURE__*/ _jsx(TextInput, {
38
+ renderLabel: "",
39
+ inputRef: (r)=>{
40
+ setTimeout(()=>r?.focus(), 0);
41
+ },
92
42
  size: "small",
93
- withBorder: false,
94
- withBackground: false,
95
- onClick: handleFindPrev,
96
- screenReaderLabel: searchConfig.prevResultLabel,
97
- children: _jsx(IconArrowOpenUpLine, {})
98
- })]
99
- })
100
- });
43
+ display: "inline-block",
44
+ width: "20rem",
45
+ placeholder: searchConfig.placeholder,
46
+ onChange: handleChange,
47
+ onKeyDown: handleKeyDown,
48
+ onKeyUp: handleKeyUp,
49
+ renderBeforeInput: /*#__PURE__*/ _jsx(IconSearchLine, {
50
+ size: "x-small"
51
+ }),
52
+ renderAfterInput: /*#__PURE__*/ _jsxs("span", {
53
+ children: [
54
+ /*#__PURE__*/ _jsx(IconButton, {
55
+ size: "small",
56
+ withBorder: false,
57
+ withBackground: false,
58
+ onClick: handleFindNext,
59
+ screenReaderLabel: searchConfig.nextResultLabel,
60
+ children: /*#__PURE__*/ _jsx(IconArrowOpenDownLine, {})
61
+ }),
62
+ /*#__PURE__*/ _jsx(IconButton, {
63
+ size: "small",
64
+ withBorder: false,
65
+ withBackground: false,
66
+ onClick: handleFindPrev,
67
+ screenReaderLabel: searchConfig.prevResultLabel,
68
+ children: /*#__PURE__*/ _jsx(IconArrowOpenUpLine, {})
69
+ })
70
+ ]
71
+ })
72
+ });
101
73
  }
102
74
  export default function customSearch(searchConfig, handlers) {
103
- return searchConfig ? search({
104
- createPanel: view => {
105
- const dom = document.createElement('div');
106
- dom.style.padding = '8px';
107
- return {
108
- dom,
109
- mount() {
110
- handlers.onMount(dom, view);
111
- },
112
- destroy() {
113
- handlers.onDestroy(dom);
75
+ return searchConfig ? search({
76
+ createPanel: (view)=>{
77
+ const dom = document.createElement('div');
78
+ dom.style.padding = '8px';
79
+ return {
80
+ dom,
81
+ mount () {
82
+ handlers.onMount(dom, view);
83
+ },
84
+ destroy () {
85
+ handlers.onDestroy(dom);
86
+ }
87
+ };
114
88
  }
115
- };
116
- }
117
- }) : [];
118
- }
89
+ }) : [];
90
+ }
@@ -1,100 +1,87 @@
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 { cursorCharLeft, cursorCharRight, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorSyntaxLeft, cursorSyntaxRight, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteToLineEnd, deleteToLineStart, selectCharLeft, selectCharRight, selectGroupLeft, selectGroupRight, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineBoundaryBackward, selectLineBoundaryForward, selectSyntaxLeft, selectSyntaxRight } from '@codemirror/commands';
26
2
  const rtlHorizontalArrowKeymap = [
27
- // Left/Start/Forward
28
- {
29
- key: 'ArrowLeft',
30
- run: cursorCharRight,
31
- shift: selectCharRight,
32
- preventDefault: true
33
- }, {
34
- key: 'Mod-ArrowLeft',
35
- mac: 'Alt-ArrowLeft',
36
- run: cursorGroupRight,
37
- shift: selectGroupRight
38
- }, {
39
- key: 'Alt-ArrowLeft',
40
- mac: 'Ctrl-ArrowLeft',
41
- run: cursorSyntaxRight,
42
- shift: selectSyntaxRight
43
- }, {
44
- mac: 'Cmd-ArrowLeft',
45
- run: cursorLineBoundaryRight,
46
- shift: selectLineBoundaryRight
47
- }, {
48
- key: 'Home',
49
- run: cursorLineBoundaryForward,
50
- shift: selectLineBoundaryForward
51
- },
52
- // Right/End/Backward
53
- {
54
- key: 'ArrowRight',
55
- run: cursorCharLeft,
56
- shift: selectCharLeft,
57
- preventDefault: true
58
- }, {
59
- key: 'Mod-ArrowRight',
60
- mac: 'Alt-ArrowRight',
61
- run: cursorGroupLeft,
62
- shift: selectGroupLeft
63
- }, {
64
- key: 'Alt-ArrowRight',
65
- mac: 'Ctrl-ArrowRight',
66
- run: cursorSyntaxLeft,
67
- shift: selectSyntaxLeft
68
- }, {
69
- mac: 'Cmd-ArrowRight',
70
- run: cursorLineBoundaryLeft,
71
- shift: selectLineBoundaryLeft
72
- }, {
73
- key: 'End',
74
- run: cursorLineBoundaryBackward,
75
- shift: selectLineBoundaryBackward
76
- },
77
- // Delete/Backspace
78
- {
79
- key: 'Delete',
80
- run: deleteCharBackward
81
- }, {
82
- key: 'Mod-Delete',
83
- mac: 'Alt-Delete',
84
- run: deleteGroupBackward
85
- }, {
86
- key: 'Backspace',
87
- run: deleteCharForward,
88
- shift: deleteCharForward
89
- }, {
90
- key: 'Mod-Backspace',
91
- mac: 'Alt-Backspace',
92
- run: deleteGroupForward
93
- }, {
94
- mac: 'Mod-Delete',
95
- run: deleteToLineStart
96
- }, {
97
- mac: 'Mod-Backspace',
98
- run: deleteToLineEnd
99
- }];
100
- export { rtlHorizontalArrowKeymap };
3
+ {
4
+ key: 'ArrowLeft',
5
+ run: cursorCharRight,
6
+ shift: selectCharRight,
7
+ preventDefault: true
8
+ },
9
+ {
10
+ key: 'Mod-ArrowLeft',
11
+ mac: 'Alt-ArrowLeft',
12
+ run: cursorGroupRight,
13
+ shift: selectGroupRight
14
+ },
15
+ {
16
+ key: 'Alt-ArrowLeft',
17
+ mac: 'Ctrl-ArrowLeft',
18
+ run: cursorSyntaxRight,
19
+ shift: selectSyntaxRight
20
+ },
21
+ {
22
+ mac: 'Cmd-ArrowLeft',
23
+ run: cursorLineBoundaryRight,
24
+ shift: selectLineBoundaryRight
25
+ },
26
+ {
27
+ key: 'Home',
28
+ run: cursorLineBoundaryForward,
29
+ shift: selectLineBoundaryForward
30
+ },
31
+ {
32
+ key: 'ArrowRight',
33
+ run: cursorCharLeft,
34
+ shift: selectCharLeft,
35
+ preventDefault: true
36
+ },
37
+ {
38
+ key: 'Mod-ArrowRight',
39
+ mac: 'Alt-ArrowRight',
40
+ run: cursorGroupLeft,
41
+ shift: selectGroupLeft
42
+ },
43
+ {
44
+ key: 'Alt-ArrowRight',
45
+ mac: 'Ctrl-ArrowRight',
46
+ run: cursorSyntaxLeft,
47
+ shift: selectSyntaxLeft
48
+ },
49
+ {
50
+ mac: 'Cmd-ArrowRight',
51
+ run: cursorLineBoundaryLeft,
52
+ shift: selectLineBoundaryLeft
53
+ },
54
+ {
55
+ key: 'End',
56
+ run: cursorLineBoundaryBackward,
57
+ shift: selectLineBoundaryBackward
58
+ },
59
+ {
60
+ key: 'Delete',
61
+ run: deleteCharBackward
62
+ },
63
+ {
64
+ key: 'Mod-Delete',
65
+ mac: 'Alt-Delete',
66
+ run: deleteGroupBackward
67
+ },
68
+ {
69
+ key: 'Backspace',
70
+ run: deleteCharForward,
71
+ shift: deleteCharForward
72
+ },
73
+ {
74
+ key: 'Mod-Backspace',
75
+ mac: 'Alt-Backspace',
76
+ run: deleteGroupForward
77
+ },
78
+ {
79
+ mac: 'Mod-Delete',
80
+ run: deleteToLineStart
81
+ },
82
+ {
83
+ mac: 'Mod-Backspace',
84
+ run: deleteToLineEnd
85
+ }
86
+ ];
87
+ export { rtlHorizontalArrowKeymap };