@patternfly/react-code-editor 6.0.0-alpha.71 → 6.0.0-alpha.73

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 CHANGED
@@ -3,6 +3,14 @@
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
+ # [6.0.0-alpha.73](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.0.0-alpha.72...@patternfly/react-code-editor@6.0.0-alpha.73) (2024-06-26)
7
+
8
+ **Note:** Version bump only for package @patternfly/react-code-editor
9
+
10
+ # [6.0.0-alpha.72](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.0.0-alpha.71...@patternfly/react-code-editor@6.0.0-alpha.72) (2024-06-25)
11
+
12
+ **Note:** Version bump only for package @patternfly/react-code-editor
13
+
6
14
  # [6.0.0-alpha.71](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.0.0-alpha.70...@patternfly/react-code-editor@6.0.0-alpha.71) (2024-06-25)
7
15
 
8
16
  **Note:** Version bump only for package @patternfly/react-code-editor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-code-editor",
3
- "version": "6.0.0-alpha.71",
3
+ "version": "6.0.0-alpha.73",
4
4
  "description": "This package provides a PatternFly wrapper for the Monaco code editor\n",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@monaco-editor/react": "^4.6.0",
34
- "@patternfly/react-core": "^6.0.0-alpha.71",
35
- "@patternfly/react-icons": "^6.0.0-alpha.25",
36
- "@patternfly/react-styles": "^6.0.0-alpha.24",
34
+ "@patternfly/react-core": "^6.0.0-alpha.73",
35
+ "@patternfly/react-icons": "^6.0.0-alpha.27",
36
+ "@patternfly/react-styles": "^6.0.0-alpha.26",
37
37
  "react-dropzone": "14.2.3",
38
38
  "tslib": "^2.6.2"
39
39
  },
@@ -44,5 +44,5 @@
44
44
  "devDependencies": {
45
45
  "monaco-editor": "^0.49.0"
46
46
  },
47
- "gitHead": "74b0b00a5b489551ae02aef64d22e6f3fb3557e0"
47
+ "gitHead": "5ce8c9748b3f0fafa36430e68d82d0725dff2f2e"
48
48
  }
@@ -1,34 +1,49 @@
1
1
  import React from 'react';
2
2
  import { CodeEditor, Language } from '@patternfly/react-code-editor';
3
- import { Grid, GridItem, Label } from '@patternfly/react-core';
3
+ import { Grid, GridItem, Label, Radio } from '@patternfly/react-core';
4
4
 
5
5
  export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
6
+ type ShortcutMode = 'PC' | 'Mac';
7
+
8
+ const [currentShortcutMode, setCurrentShortcutMode] = React.useState<ShortcutMode>('PC');
9
+
6
10
  const onEditorDidMount = (editor, monaco) => {
7
11
  editor.layout();
8
12
  editor.focus();
9
13
  monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });
10
14
  };
11
15
 
12
- const onChange = (value) => {
16
+ const onChange = (value: string) => {
13
17
  // eslint-disable-next-line no-console
14
18
  console.log(value);
15
19
  };
16
20
 
21
+ const onShortcutModeChange = (event: React.FormEvent<HTMLInputElement>, checked: boolean) => {
22
+ if (checked) {
23
+ const newMode = event.currentTarget.value as ShortcutMode;
24
+ setCurrentShortcutMode(newMode);
25
+ }
26
+ };
27
+
17
28
  const shortcuts = [
18
29
  {
19
- keys: ['Opt', 'F1'],
30
+ PC: ['Alt', 'F1'],
31
+ Mac: ['Opt', 'F1'],
20
32
  description: 'Accessibility helps'
21
33
  },
22
34
  {
23
- keys: ['F1'],
35
+ PC: ['F1'],
36
+ Mac: ['F1'],
24
37
  description: 'View all editor shortcuts'
25
38
  },
26
39
  {
27
- keys: ['Ctrl', 'Space'],
40
+ PC: ['Ctrl', 'Space'],
41
+ Mac: ['Opt', 'Esc'],
28
42
  description: 'Activate auto complete'
29
43
  },
30
44
  {
31
- keys: ['Cmd', 'S'],
45
+ PC: ['Ctrl', 'S'],
46
+ Mac: ['Cmd', 'S'],
32
47
  description: 'Save'
33
48
  }
34
49
  ];
@@ -38,7 +53,7 @@ export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
38
53
  {shortcuts.map((shortcut, index) => (
39
54
  <React.Fragment key={index}>
40
55
  <GridItem style={{ textAlign: 'right', marginRight: '1em' }}>
41
- {shortcut.keys
56
+ {shortcut[currentShortcutMode]
42
57
  .map((key) => (
43
58
  <Label variant="outline" key={key}>
44
59
  {key}
@@ -57,14 +72,32 @@ export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
57
72
  };
58
73
 
59
74
  return (
60
- <CodeEditor
61
- shortcutsPopoverProps={shortcutsPopoverProps}
62
- isLanguageLabelVisible
63
- code="Some example content"
64
- onChange={onChange}
65
- language={Language.javascript}
66
- onEditorDidMount={onEditorDidMount}
67
- height="400px"
68
- />
75
+ <>
76
+ <Radio
77
+ checked={currentShortcutMode === 'PC'}
78
+ onChange={onShortcutModeChange}
79
+ label="PC shortcuts"
80
+ name="shortcut-radio"
81
+ id="pc-shortcuts"
82
+ value="PC"
83
+ />
84
+ <Radio
85
+ checked={currentShortcutMode === 'Mac'}
86
+ onChange={onShortcutModeChange}
87
+ label="Mac shortcuts"
88
+ name="shortcut-radio"
89
+ id="mac-shortcuts"
90
+ value="Mac"
91
+ />
92
+ <CodeEditor
93
+ shortcutsPopoverProps={shortcutsPopoverProps}
94
+ isLanguageLabelVisible
95
+ code="Some example content"
96
+ onChange={onChange}
97
+ language={Language.javascript}
98
+ onEditorDidMount={onEditorDidMount}
99
+ height="400px"
100
+ />
101
+ </>
69
102
  );
70
103
  };