@instructure/ui-source-code-editor 8.53.3-snapshot-16 → 8.53.3-snapshot-20
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.
- package/CHANGELOG.md +6 -2
- package/es/SourceCodeEditor/SearchPanel.js +17 -14
- package/lib/SourceCodeEditor/SearchPanel.js +20 -16
- package/package.json +18 -18
- package/src/SourceCodeEditor/README.md +3 -1
- package/src/SourceCodeEditor/SearchPanel.tsx +19 -11
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/SourceCodeEditor/SearchPanel.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [8.53.3-snapshot-
|
|
6
|
+
## [8.53.3-snapshot-20](https://github.com/instructure/instructure-ui/compare/v8.53.2...v8.53.3-snapshot-20) (2024-03-20)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-source-code-editor:** make search panel work with older react versions ([76cdaac](https://github.com/instructure/instructure-ui/commit/76cdaac296d8bdcbcf337ef1d95eb8d2e538b993))
|
|
12
|
+
* **ui-source-code-editor:** remove warning and fix focus for search panel ([def33a3](https://github.com/instructure/instructure-ui/commit/def33a34e28373b2d6b2455afbae638a3c98685a))
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
|
|
@@ -29,12 +29,7 @@ import { setSearchQuery, search, findNext, findPrevious, SearchQuery, closeSearc
|
|
|
29
29
|
import { TextInput } from '@instructure/ui-text-input';
|
|
30
30
|
import { IconButton } from '@instructure/ui-buttons';
|
|
31
31
|
import { IconArrowOpenDownLine, IconArrowOpenUpLine, IconSearchLine } from '@instructure/ui-icons';
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
reactdom = require('react-dom/client');
|
|
35
|
-
} catch {
|
|
36
|
-
reactdom = require('react-dom');
|
|
37
|
-
}
|
|
32
|
+
import ReactDOM from 'react-dom';
|
|
38
33
|
function SearchPanel({
|
|
39
34
|
view,
|
|
40
35
|
searchConfig
|
|
@@ -71,7 +66,10 @@ function SearchPanel({
|
|
|
71
66
|
findPrevious(view);
|
|
72
67
|
};
|
|
73
68
|
return /*#__PURE__*/React.createElement(TextInput, {
|
|
74
|
-
|
|
69
|
+
renderLabel: "",
|
|
70
|
+
inputRef: r => {
|
|
71
|
+
setTimeout(() => r === null || r === void 0 ? void 0 : r.focus(), 0);
|
|
72
|
+
},
|
|
75
73
|
size: "small",
|
|
76
74
|
display: "inline-block",
|
|
77
75
|
width: "20rem",
|
|
@@ -100,16 +98,21 @@ function SearchPanel({
|
|
|
100
98
|
export default function customSearch(searchConfig) {
|
|
101
99
|
return searchConfig ? search({
|
|
102
100
|
createPanel: view => {
|
|
101
|
+
var _SearchPanel;
|
|
103
102
|
const dom = document.createElement('div');
|
|
104
103
|
dom.style.padding = '8px';
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
const reactVersionMajor = Number(React.version.split('.')[0]);
|
|
105
|
+
if (reactVersionMajor >= 18) {
|
|
106
|
+
// webpack tries to evaluate imports compile time which would lead to an error on older react versions
|
|
107
|
+
import( /* webpackIgnore: true */'react-dom/client').then(r => {
|
|
108
|
+
const root = r.createRoot(dom);
|
|
109
|
+
root.render(_SearchPanel || (_SearchPanel = /*#__PURE__*/React.createElement(SearchPanel, {
|
|
110
|
+
view: view,
|
|
111
|
+
searchConfig: searchConfig
|
|
112
|
+
})));
|
|
113
|
+
}).catch(e => {});
|
|
111
114
|
} else {
|
|
112
|
-
|
|
115
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(SearchPanel, {
|
|
113
116
|
view: view,
|
|
114
117
|
searchConfig: searchConfig
|
|
115
118
|
}), dom);
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var
|
|
4
|
+
var _interopRequireWildcard3 = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = customSearch;
|
|
9
|
+
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _react =
|
|
11
|
+
var _react = _interopRequireWildcard3(require("react"));
|
|
11
12
|
var _search = require("@codemirror/search");
|
|
12
13
|
var _TextInput = require("@instructure/ui-text-input/lib/TextInput");
|
|
13
14
|
var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
|
|
14
15
|
var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/IconArrowOpenDownLine.js");
|
|
15
16
|
var _IconArrowOpenUpLine2 = require("@instructure/ui-icons/lib/IconArrowOpenUpLine.js");
|
|
16
17
|
var _IconSearchLine2 = require("@instructure/ui-icons/lib/IconSearchLine.js");
|
|
18
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
17
19
|
var _IconSearchLine, _IconArrowOpenDownLin, _IconArrowOpenUpLine;
|
|
18
20
|
/*
|
|
19
21
|
* The MIT License (MIT)
|
|
@@ -38,12 +40,6 @@ var _IconSearchLine, _IconArrowOpenDownLin, _IconArrowOpenUpLine;
|
|
|
38
40
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
41
|
* SOFTWARE.
|
|
40
42
|
*/
|
|
41
|
-
let reactdom;
|
|
42
|
-
try {
|
|
43
|
-
reactdom = require('react-dom/client');
|
|
44
|
-
} catch {
|
|
45
|
-
reactdom = require('react-dom');
|
|
46
|
-
}
|
|
47
43
|
function SearchPanel({
|
|
48
44
|
view,
|
|
49
45
|
searchConfig
|
|
@@ -80,7 +76,10 @@ function SearchPanel({
|
|
|
80
76
|
(0, _search.findPrevious)(view);
|
|
81
77
|
};
|
|
82
78
|
return /*#__PURE__*/_react.default.createElement(_TextInput.TextInput, {
|
|
83
|
-
|
|
79
|
+
renderLabel: "",
|
|
80
|
+
inputRef: r => {
|
|
81
|
+
setTimeout(() => r === null || r === void 0 ? void 0 : r.focus(), 0);
|
|
82
|
+
},
|
|
84
83
|
size: "small",
|
|
85
84
|
display: "inline-block",
|
|
86
85
|
width: "20rem",
|
|
@@ -109,16 +108,21 @@ function SearchPanel({
|
|
|
109
108
|
function customSearch(searchConfig) {
|
|
110
109
|
return searchConfig ? (0, _search.search)({
|
|
111
110
|
createPanel: view => {
|
|
111
|
+
var _SearchPanel;
|
|
112
112
|
const dom = document.createElement('div');
|
|
113
113
|
dom.style.padding = '8px';
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
const reactVersionMajor = Number(_react.default.version.split('.')[0]);
|
|
115
|
+
if (reactVersionMajor >= 18) {
|
|
116
|
+
// webpack tries to evaluate imports compile time which would lead to an error on older react versions
|
|
117
|
+
Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require( /* webpackIgnore: true */'react-dom/client'))).then(r => {
|
|
118
|
+
const root = r.createRoot(dom);
|
|
119
|
+
root.render(_SearchPanel || (_SearchPanel = /*#__PURE__*/_react.default.createElement(SearchPanel, {
|
|
120
|
+
view: view,
|
|
121
|
+
searchConfig: searchConfig
|
|
122
|
+
})));
|
|
123
|
+
}).catch(e => {});
|
|
120
124
|
} else {
|
|
121
|
-
|
|
125
|
+
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(SearchPanel, {
|
|
122
126
|
view: view,
|
|
123
127
|
searchConfig: searchConfig
|
|
124
128
|
}), dom);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-source-code-editor",
|
|
3
|
-
"version": "8.53.3-snapshot-
|
|
3
|
+
"version": "8.53.3-snapshot-20",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.53.3-snapshot-
|
|
27
|
-
"@instructure/ui-test-queries": "8.53.3-snapshot-
|
|
28
|
-
"@instructure/ui-test-utils": "8.53.3-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "8.53.3-snapshot-20",
|
|
27
|
+
"@instructure/ui-test-queries": "8.53.3-snapshot-20",
|
|
28
|
+
"@instructure/ui-test-utils": "8.53.3-snapshot-20",
|
|
29
29
|
"@testing-library/jest-dom": "^6.1.4",
|
|
30
30
|
"@testing-library/react": "^14.1.2"
|
|
31
31
|
},
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"@codemirror/search": "^6.5.4",
|
|
45
45
|
"@codemirror/state": "^6.3.0",
|
|
46
46
|
"@codemirror/view": "^6.21.3",
|
|
47
|
-
"@instructure/emotion": "8.53.3-snapshot-
|
|
48
|
-
"@instructure/shared-types": "8.53.3-snapshot-
|
|
49
|
-
"@instructure/ui-a11y-content": "8.53.3-snapshot-
|
|
50
|
-
"@instructure/ui-buttons": "8.53.3-snapshot-
|
|
51
|
-
"@instructure/ui-dom-utils": "8.53.3-snapshot-
|
|
52
|
-
"@instructure/ui-i18n": "8.53.3-snapshot-
|
|
53
|
-
"@instructure/ui-icons": "8.53.3-snapshot-
|
|
54
|
-
"@instructure/ui-prop-types": "8.53.3-snapshot-
|
|
55
|
-
"@instructure/ui-react-utils": "8.53.3-snapshot-
|
|
56
|
-
"@instructure/ui-test-locator": "8.53.3-snapshot-
|
|
57
|
-
"@instructure/ui-testable": "8.53.3-snapshot-
|
|
58
|
-
"@instructure/ui-text-input": "8.53.3-snapshot-
|
|
59
|
-
"@instructure/ui-themes": "8.53.3-snapshot-
|
|
60
|
-
"@instructure/ui-utils": "8.53.3-snapshot-
|
|
47
|
+
"@instructure/emotion": "8.53.3-snapshot-20",
|
|
48
|
+
"@instructure/shared-types": "8.53.3-snapshot-20",
|
|
49
|
+
"@instructure/ui-a11y-content": "8.53.3-snapshot-20",
|
|
50
|
+
"@instructure/ui-buttons": "8.53.3-snapshot-20",
|
|
51
|
+
"@instructure/ui-dom-utils": "8.53.3-snapshot-20",
|
|
52
|
+
"@instructure/ui-i18n": "8.53.3-snapshot-20",
|
|
53
|
+
"@instructure/ui-icons": "8.53.3-snapshot-20",
|
|
54
|
+
"@instructure/ui-prop-types": "8.53.3-snapshot-20",
|
|
55
|
+
"@instructure/ui-react-utils": "8.53.3-snapshot-20",
|
|
56
|
+
"@instructure/ui-test-locator": "8.53.3-snapshot-20",
|
|
57
|
+
"@instructure/ui-testable": "8.53.3-snapshot-20",
|
|
58
|
+
"@instructure/ui-text-input": "8.53.3-snapshot-20",
|
|
59
|
+
"@instructure/ui-themes": "8.53.3-snapshot-20",
|
|
60
|
+
"@instructure/ui-utils": "8.53.3-snapshot-20",
|
|
61
61
|
"@lezer/highlight": "1.1.6",
|
|
62
62
|
"prop-types": "^15.8.1"
|
|
63
63
|
},
|
|
@@ -790,10 +790,12 @@ render(<AttachmentExample />)
|
|
|
790
790
|
|
|
791
791
|
To enable the search panel use the `searchConfig` prop.
|
|
792
792
|
|
|
793
|
-
You can open the search panel in the code editor by pressing `cmd/ctrl+f` when
|
|
793
|
+
You can open the search panel in the code editor by pressing `cmd/ctrl+f` when the editor is in focus (otherwise the browser's search will open). The reason you would use this instead of the browser native search is because it will miss results that are far out of view in the text rendered by the editor. This is the limitation of the underlying CodeMirror component.
|
|
794
794
|
|
|
795
795
|
Hitting `Enter` jumps to the next result and `Shift+Enter` to the previous. Alternatively you can use the up and down buttons to the right of the input field.
|
|
796
796
|
|
|
797
|
+
Placement: the search panel will open at the bottom of the editor. This cannot be changed unfortunately due to a limitation in CodeMirror.
|
|
798
|
+
|
|
797
799
|
```js
|
|
798
800
|
---
|
|
799
801
|
type: example
|
|
@@ -40,12 +40,7 @@ import {
|
|
|
40
40
|
IconSearchLine
|
|
41
41
|
} from '@instructure/ui-icons'
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
reactdom = require('react-dom/client')
|
|
46
|
-
} catch {
|
|
47
|
-
reactdom = require('react-dom')
|
|
48
|
-
}
|
|
43
|
+
import ReactDOM from 'react-dom'
|
|
49
44
|
|
|
50
45
|
export type SearchConfig = {
|
|
51
46
|
placeholder: string
|
|
@@ -103,7 +98,10 @@ function SearchPanel({
|
|
|
103
98
|
|
|
104
99
|
return (
|
|
105
100
|
<TextInput
|
|
106
|
-
|
|
101
|
+
renderLabel=""
|
|
102
|
+
inputRef={(r) => {
|
|
103
|
+
setTimeout(() => r?.focus(), 0)
|
|
104
|
+
}}
|
|
107
105
|
size="small"
|
|
108
106
|
display="inline-block"
|
|
109
107
|
width="20rem"
|
|
@@ -144,11 +142,21 @@ export default function customSearch(searchConfig: SearchConfig | undefined) {
|
|
|
144
142
|
createPanel: (view) => {
|
|
145
143
|
const dom = document.createElement('div')
|
|
146
144
|
dom.style.padding = '8px'
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
const reactVersionMajor = Number(React.version.split('.')[0])
|
|
146
|
+
if (reactVersionMajor >= 18) {
|
|
147
|
+
// webpack tries to evaluate imports compile time which would lead to an error on older react versions
|
|
148
|
+
import(/* webpackIgnore: true */ 'react-dom/client')
|
|
149
|
+
.then((r) => {
|
|
150
|
+
const root = r.createRoot(dom)
|
|
151
|
+
root.render(
|
|
152
|
+
<SearchPanel view={view} searchConfig={searchConfig} />
|
|
153
|
+
)
|
|
154
|
+
})
|
|
155
|
+
.catch((e) => {
|
|
156
|
+
console.error(e)
|
|
157
|
+
})
|
|
150
158
|
} else {
|
|
151
|
-
|
|
159
|
+
ReactDOM.render(
|
|
152
160
|
<SearchPanel view={view} searchConfig={searchConfig} />,
|
|
153
161
|
dom
|
|
154
162
|
)
|