@patternfly/react-code-editor 6.0.0-alpha.7 → 6.0.0-alpha.71
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 +810 -0
- package/README.md +37 -40
- package/dist/esm/components/CodeEditor/CodeEditor.d.ts +8 -2
- package/dist/esm/components/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/dist/esm/components/CodeEditor/CodeEditor.js +47 -41
- package/dist/esm/components/CodeEditor/CodeEditor.js.map +1 -1
- package/dist/esm/components/CodeEditor/CodeEditorControl.js +1 -1
- package/dist/esm/components/CodeEditor/CodeEditorControl.js.map +1 -1
- package/dist/js/components/CodeEditor/CodeEditor.d.ts +8 -2
- package/dist/js/components/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/dist/js/components/CodeEditor/CodeEditor.js +47 -41
- package/dist/js/components/CodeEditor/CodeEditor.js.map +1 -1
- package/dist/js/components/CodeEditor/CodeEditorControl.js +1 -1
- package/dist/js/components/CodeEditor/CodeEditorControl.js.map +1 -1
- package/package.json +9 -10
- package/src/components/CodeEditor/CodeEditor.tsx +77 -65
- package/src/components/CodeEditor/CodeEditorControl.tsx +1 -1
- package/src/components/CodeEditor/__test__/CodeEditor.test.tsx +69 -39
- package/src/components/CodeEditor/__test__/CodeEditorControl.test.tsx +18 -0
- package/src/components/CodeEditor/__test__/__snapshots__/CodeEditor.test.tsx.snap +104 -536
- package/src/components/CodeEditor/__test__/__snapshots__/CodeEditorControl.test.tsx.snap +22 -0
- package/src/components/CodeEditor/examples/CodeEditor.md +5 -0
- package/src/components/CodeEditor/examples/CodeEditorCustomControl.tsx +2 -1
- package/src/components/CodeEditor/examples/CodeEditorShortcutMainHeader.tsx +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Matches snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
style="display: contents;"
|
|
7
|
+
>
|
|
8
|
+
<button
|
|
9
|
+
aria-disabled="false"
|
|
10
|
+
class="pf-v6-c-button pf-m-plain"
|
|
11
|
+
data-ouia-component-id="OUIA-Generated-Button-plain-1"
|
|
12
|
+
data-ouia-component-type="PF6/Button"
|
|
13
|
+
data-ouia-safe="true"
|
|
14
|
+
type="button"
|
|
15
|
+
>
|
|
16
|
+
<div>
|
|
17
|
+
icon
|
|
18
|
+
</div>
|
|
19
|
+
</button>
|
|
20
|
+
</div>
|
|
21
|
+
</DocumentFragment>
|
|
22
|
+
`;
|
|
@@ -15,11 +15,13 @@ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
|
|
|
15
15
|
### Basic
|
|
16
16
|
|
|
17
17
|
```ts file="./CodeEditorBasic.tsx"
|
|
18
|
+
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
### With sizeToFit height, height will grow/shrink with content
|
|
21
22
|
|
|
22
23
|
```ts file="./CodeEditorSizeToFit.tsx"
|
|
24
|
+
|
|
23
25
|
```
|
|
24
26
|
|
|
25
27
|
### With shortcut menu and main header content
|
|
@@ -27,14 +29,17 @@ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
|
|
|
27
29
|
These examples below are the shortcuts that we recommend describing in the popover since they are monaco features.
|
|
28
30
|
|
|
29
31
|
```ts file="./CodeEditorShortcutMainHeader.tsx"
|
|
32
|
+
|
|
30
33
|
```
|
|
31
34
|
|
|
32
35
|
### With actions
|
|
33
36
|
|
|
34
37
|
```ts file="./CodeEditorWithActions.tsx"
|
|
38
|
+
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
### With custom control
|
|
38
42
|
|
|
39
43
|
```ts file="CodeEditorCustomControl.tsx"
|
|
44
|
+
|
|
40
45
|
```
|
|
@@ -3,7 +3,7 @@ import { CodeEditor, CodeEditorControl } from '@patternfly/react-code-editor';
|
|
|
3
3
|
import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
|
|
4
4
|
|
|
5
5
|
export const CodeEditorCustomControl: React.FunctionComponent = () => {
|
|
6
|
-
const [code, setCode] = React.useState('');
|
|
6
|
+
const [code, setCode] = React.useState('Some example content');
|
|
7
7
|
|
|
8
8
|
const onChange = (code) => {
|
|
9
9
|
setCode(code);
|
|
@@ -32,6 +32,7 @@ export const CodeEditorCustomControl: React.FunctionComponent = () => {
|
|
|
32
32
|
customControls={customControl}
|
|
33
33
|
code={code}
|
|
34
34
|
onChange={onChange}
|
|
35
|
+
isHeaderPlain={code === ''}
|
|
35
36
|
/>
|
|
36
37
|
);
|
|
37
38
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CodeEditor, Language } from '@patternfly/react-code-editor';
|
|
3
|
-
import { Grid, GridItem,
|
|
3
|
+
import { Grid, GridItem, Label } from '@patternfly/react-core';
|
|
4
4
|
|
|
5
5
|
export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
|
|
6
6
|
const onEditorDidMount = (editor, monaco) => {
|
|
@@ -40,9 +40,9 @@ export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
|
|
|
40
40
|
<GridItem style={{ textAlign: 'right', marginRight: '1em' }}>
|
|
41
41
|
{shortcut.keys
|
|
42
42
|
.map((key) => (
|
|
43
|
-
<
|
|
43
|
+
<Label variant="outline" key={key}>
|
|
44
44
|
{key}
|
|
45
|
-
</
|
|
45
|
+
</Label>
|
|
46
46
|
))
|
|
47
47
|
.reduce((prev, curr) => (
|
|
48
48
|
<>{[prev, ' + ', curr]}</>
|