@patternfly/react-code-editor 6.5.0-prerelease.3 → 6.5.0-prerelease.30

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,102 @@
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.5.0-prerelease.30](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.29...@patternfly/react-code-editor@6.5.0-prerelease.30) (2026-01-12)
7
+
8
+ **Note:** Version bump only for package @patternfly/react-code-editor
9
+
10
+ # [6.5.0-prerelease.29](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.28...@patternfly/react-code-editor@6.5.0-prerelease.29) (2026-01-09)
11
+
12
+ **Note:** Version bump only for package @patternfly/react-code-editor
13
+
14
+ # [6.5.0-prerelease.28](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.27...@patternfly/react-code-editor@6.5.0-prerelease.28) (2026-01-09)
15
+
16
+ **Note:** Version bump only for package @patternfly/react-code-editor
17
+
18
+ # [6.5.0-prerelease.27](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.26...@patternfly/react-code-editor@6.5.0-prerelease.27) (2025-12-17)
19
+
20
+ **Note:** Version bump only for package @patternfly/react-code-editor
21
+
22
+ # [6.5.0-prerelease.26](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.22...@patternfly/react-code-editor@6.5.0-prerelease.26) (2025-12-16)
23
+
24
+ **Note:** Version bump only for package @patternfly/react-code-editor
25
+
26
+ # [6.5.0-prerelease.22](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.21...@patternfly/react-code-editor@6.5.0-prerelease.22) (2025-12-03)
27
+
28
+ **Note:** Version bump only for package @patternfly/react-code-editor
29
+
30
+ # [6.5.0-prerelease.21](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.20...@patternfly/react-code-editor@6.5.0-prerelease.21) (2025-12-03)
31
+
32
+ **Note:** Version bump only for package @patternfly/react-code-editor
33
+
34
+ # [6.5.0-prerelease.20](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.19...@patternfly/react-code-editor@6.5.0-prerelease.20) (2025-12-01)
35
+
36
+ **Note:** Version bump only for package @patternfly/react-code-editor
37
+
38
+ # [6.5.0-prerelease.19](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.18...@patternfly/react-code-editor@6.5.0-prerelease.19) (2025-11-21)
39
+
40
+ **Note:** Version bump only for package @patternfly/react-code-editor
41
+
42
+ # [6.5.0-prerelease.18](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.17...@patternfly/react-code-editor@6.5.0-prerelease.18) (2025-11-21)
43
+
44
+ **Note:** Version bump only for package @patternfly/react-code-editor
45
+
46
+ # [6.5.0-prerelease.17](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.16...@patternfly/react-code-editor@6.5.0-prerelease.17) (2025-11-20)
47
+
48
+ **Note:** Version bump only for package @patternfly/react-code-editor
49
+
50
+ # [6.5.0-prerelease.16](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.15...@patternfly/react-code-editor@6.5.0-prerelease.16) (2025-11-20)
51
+
52
+ **Note:** Version bump only for package @patternfly/react-code-editor
53
+
54
+ # [6.5.0-prerelease.15](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.14...@patternfly/react-code-editor@6.5.0-prerelease.15) (2025-11-19)
55
+
56
+ **Note:** Version bump only for package @patternfly/react-code-editor
57
+
58
+ # [6.5.0-prerelease.14](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.13...@patternfly/react-code-editor@6.5.0-prerelease.14) (2025-11-17)
59
+
60
+ **Note:** Version bump only for package @patternfly/react-code-editor
61
+
62
+ # [6.5.0-prerelease.13](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.12...@patternfly/react-code-editor@6.5.0-prerelease.13) (2025-11-14)
63
+
64
+ **Note:** Version bump only for package @patternfly/react-code-editor
65
+
66
+ # [6.5.0-prerelease.12](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.11...@patternfly/react-code-editor@6.5.0-prerelease.12) (2025-11-12)
67
+
68
+ **Note:** Version bump only for package @patternfly/react-code-editor
69
+
70
+ # [6.5.0-prerelease.11](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.10...@patternfly/react-code-editor@6.5.0-prerelease.11) (2025-11-10)
71
+
72
+ **Note:** Version bump only for package @patternfly/react-code-editor
73
+
74
+ # [6.5.0-prerelease.10](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.9...@patternfly/react-code-editor@6.5.0-prerelease.10) (2025-11-10)
75
+
76
+ **Note:** Version bump only for package @patternfly/react-code-editor
77
+
78
+ # [6.5.0-prerelease.9](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.8...@patternfly/react-code-editor@6.5.0-prerelease.9) (2025-11-06)
79
+
80
+ **Note:** Version bump only for package @patternfly/react-code-editor
81
+
82
+ # [6.5.0-prerelease.8](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.7...@patternfly/react-code-editor@6.5.0-prerelease.8) (2025-11-06)
83
+
84
+ **Note:** Version bump only for package @patternfly/react-code-editor
85
+
86
+ # [6.5.0-prerelease.7](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.6...@patternfly/react-code-editor@6.5.0-prerelease.7) (2025-11-05)
87
+
88
+ **Note:** Version bump only for package @patternfly/react-code-editor
89
+
90
+ # [6.5.0-prerelease.6](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.5...@patternfly/react-code-editor@6.5.0-prerelease.6) (2025-11-05)
91
+
92
+ **Note:** Version bump only for package @patternfly/react-code-editor
93
+
94
+ # [6.5.0-prerelease.5](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.4...@patternfly/react-code-editor@6.5.0-prerelease.5) (2025-11-05)
95
+
96
+ **Note:** Version bump only for package @patternfly/react-code-editor
97
+
98
+ # [6.5.0-prerelease.4](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.3...@patternfly/react-code-editor@6.5.0-prerelease.4) (2025-11-03)
99
+
100
+ **Note:** Version bump only for package @patternfly/react-code-editor
101
+
6
102
  # [6.5.0-prerelease.3](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@6.5.0-prerelease.2...@patternfly/react-code-editor@6.5.0-prerelease.3) (2025-11-03)
7
103
 
8
104
  **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.5.0-prerelease.3",
3
+ "version": "6.5.0-prerelease.30",
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.7.0",
34
- "@patternfly/react-core": "^6.5.0-prerelease.3",
35
- "@patternfly/react-icons": "^6.5.0-prerelease.2",
36
- "@patternfly/react-styles": "^6.5.0-prerelease.2",
34
+ "@patternfly/react-core": "^6.5.0-prerelease.28",
35
+ "@patternfly/react-icons": "^6.5.0-prerelease.12",
36
+ "@patternfly/react-styles": "^6.5.0-prerelease.10",
37
37
  "react-dropzone": "14.3.5",
38
38
  "tslib": "^2.8.1"
39
39
  },
@@ -42,7 +42,7 @@
42
42
  "react-dom": "^17 || ^18 || ^19"
43
43
  },
44
44
  "devDependencies": {
45
- "monaco-editor": "^0.52.2"
45
+ "monaco-editor": "^0.55.1"
46
46
  },
47
- "gitHead": "40a5015cf1eb4730bda9c5c15e328f6d544bc857"
47
+ "gitHead": "884ad17d2ec8d71239e2f4f86b5fbc4fd4cc8196"
48
48
  }
@@ -14,6 +14,7 @@ import HashtagIcon from '@patternfly/react-icons/dist/esm/icons/hashtag-icon';
14
14
  import MapIcon from '@patternfly/react-icons/dist/esm/icons/map-icon';
15
15
  import MoonIcon from '@patternfly/react-icons/dist/esm/icons/moon-icon';
16
16
  import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
17
+ import FontIcon from '@patternfly/react-icons/dist/esm/icons/font-icon';
17
18
 
18
19
  ## Examples
19
20
 
@@ -2,8 +2,19 @@ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
2
2
  import MapIcon from '@patternfly/react-icons/dist/esm/icons/map-icon';
3
3
  import MoonIcon from '@patternfly/react-icons/dist/esm/icons/moon-icon';
4
4
  import HashtagIcon from '@patternfly/react-icons/dist/esm/icons/hashtag-icon';
5
+ import FontIcon from '@patternfly/react-icons/dist/esm/icons/font-icon';
5
6
  import { CodeEditor, CodeEditorControl } from '@patternfly/react-code-editor';
6
- import { Flex, FlexItem, Icon, Modal, ModalBody, ModalHeader, Switch, SwitchProps } from '@patternfly/react-core';
7
+ import {
8
+ Flex,
9
+ FlexItem,
10
+ Icon,
11
+ Modal,
12
+ ModalBody,
13
+ ModalHeader,
14
+ NumberInput,
15
+ Switch,
16
+ SwitchProps
17
+ } from '@patternfly/react-core';
7
18
  import { useState } from 'react';
8
19
 
9
20
  interface ConfigModalItemProps {
@@ -11,76 +22,105 @@ interface ConfigModalItemProps {
11
22
  icon?: React.ReactNode;
12
23
  /** Description of the configuration option. */
13
24
  description: string;
14
- /** Flag indicating whether the option is enabled or disabled. */
15
- isChecked?: SwitchProps['isChecked'];
16
- /** onChange handler for the switch. */
17
- onChange?: SwitchProps['onChange'];
18
25
  /** Title of the configuration option. We assume that titles are unique. */
19
26
  title: string;
20
- /** Labels for the enabled and disabled states of the switch. */
21
- labels?: {
22
- enabled: string;
23
- disabled: string;
24
- };
25
- /** Optional OUIA ID of the configuration option. Also used as a prefix for the ids of inner elements. */
26
- ouiaId?: string;
27
+ /**
28
+ * Optional ID of the configuration option. Also used as a prefix for the following elements:
29
+ * - `${id}-title` for the element which contains the title
30
+ * - `${id}-description` for the element which contains the description
31
+ */
32
+ id?: string;
33
+ /**
34
+ * Slot to render inside the configuration modal. Remember to add `aria-labelledby` and `aria-describedby` props
35
+ * to the control inside the slot, pointing to the title and description ids respectively.
36
+ */
37
+ slot?: React.ReactNode;
27
38
  }
28
39
 
29
40
  const ConfigModalItem: React.FunctionComponent<ConfigModalItemProps> = ({
30
41
  icon = <CogIcon />,
31
42
  description,
32
- isChecked = false,
33
- labels = { enabled: undefined, disabled: undefined },
34
- onChange,
35
43
  title,
36
- ouiaId
44
+ id = `ConfigModalItem-${title.replace(/\s+/g, '-').toLowerCase()}`,
45
+ slot
37
46
  }) => (
38
47
  <Flex
39
48
  alignItems={{ default: 'alignItemsCenter' }}
40
49
  justifyContent={{ default: 'justifyContentSpaceBetween' }}
41
50
  spaceItems={{ default: 'spaceItemsMd' }}
51
+ id={id}
42
52
  >
43
53
  <FlexItem flex={{ default: 'flex_1' }}>
44
54
  <Flex spaceItems={{ default: 'spaceItemsSm' }}>
45
55
  <Icon isInline>{icon}</Icon>
46
- <strong id={`${ouiaId}-title`} className="pf-v6-u-font-weight-bold">
56
+ <strong id={`${id}-title`} className="pf-v6-u-font-weight-bold">
47
57
  {title}
48
58
  </strong>
49
59
  </Flex>
50
60
 
51
- <div id={`${ouiaId}-description`}>{description}</div>
61
+ <div id={`${id}-description`}>{description}</div>
52
62
  </FlexItem>
53
- <FlexItem alignSelf={{ default: 'alignSelfCenter' }}>
63
+ <FlexItem alignSelf={{ default: 'alignSelfCenter' }}>{slot}</FlexItem>
64
+ </Flex>
65
+ );
66
+
67
+ interface ConfigModalSwitchProps extends Omit<ConfigModalItemProps, 'slot'> {
68
+ /** Flag indicating whether the option is enabled or disabled. */
69
+ isChecked?: SwitchProps['isChecked'];
70
+ /** onChange handler for the switch. */
71
+ onChange?: SwitchProps['onChange'];
72
+ /** Labels for the enabled and disabled states of the switch. */
73
+ labels?: {
74
+ enabled: string;
75
+ disabled: string;
76
+ };
77
+ }
78
+
79
+ const ConfigModalSwitch: React.FunctionComponent<ConfigModalSwitchProps> = ({
80
+ icon = <CogIcon />,
81
+ description,
82
+ title,
83
+ id = `ConfigModalSwitch-${title.replace(/\s+/g, '-').toLowerCase()}`,
84
+ isChecked = false,
85
+ onChange,
86
+ labels = { enabled: undefined, disabled: undefined }
87
+ }) => (
88
+ <ConfigModalItem
89
+ icon={icon}
90
+ description={description}
91
+ title={title}
92
+ id={id}
93
+ slot={
54
94
  <Switch
55
- aria-labelledby={`${ouiaId}-title`}
56
- aria-describedby={`${ouiaId}-description`}
57
- ouiaId={`${ouiaId}-switch`}
95
+ aria-labelledby={`${id}-title`}
96
+ aria-describedby={`${id}-description`}
97
+ ouiaId={`${id}-switch`}
58
98
  isChecked={isChecked}
59
99
  isReversed
60
100
  label={isChecked ? labels.enabled : labels.disabled}
61
101
  onChange={onChange}
62
102
  />
63
- </FlexItem>
64
- </Flex>
103
+ }
104
+ />
65
105
  );
66
106
 
67
107
  interface ConfigModalControlProps {
68
- /** Array of configuration controls to be rendered inside the modal. */
69
- controls: ConfigModalItemProps[];
108
+ /** Controls to be rendered inside the configuration modal. */
109
+ children: React.ReactNode;
70
110
  /** Title of the configuration modal. */
71
111
  title?: string;
72
112
  /** Description of the configuration modal. */
73
113
  description?: string;
74
- /** Optional OUIA ID of the configuration modal. Also used as a prefix for the ids of inner elements. */
114
+ /** Optional ID of the configuration modal. Also used as a prefix for the ids of inner elements and the OUIA id. */
75
115
  ouiaId?: string;
76
116
  }
77
117
 
78
118
  const ConfigModalControl: React.FunctionComponent<ConfigModalControlProps> = ({
79
- controls,
119
+ children,
80
120
  title = 'Editor settings',
81
- description = 'Settings will be applied immediately',
121
+ description = 'Changes apply immediately',
82
122
  ouiaId = 'CodeEditorConfigurationModal'
83
- }) => {
123
+ }: ConfigModalControlProps) => {
84
124
  const [isModalOpen, setIsModalOpen] = useState(false);
85
125
 
86
126
  return (
@@ -89,27 +129,21 @@ const ConfigModalControl: React.FunctionComponent<ConfigModalControlProps> = ({
89
129
  aria-describedby={`${ouiaId}-body`}
90
130
  aria-labelledby={`${ouiaId}-title`}
91
131
  isOpen={isModalOpen}
92
- onClose={() => setIsModalOpen(!isModalOpen)}
132
+ onClose={() => setIsModalOpen(false)}
93
133
  ouiaId={ouiaId}
94
134
  variant="small"
95
135
  >
96
136
  <ModalHeader title={title} description={description} labelId={`${ouiaId}-title`} />
97
137
  <ModalBody id={`${ouiaId}-body`}>
98
138
  <Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsMd' }}>
99
- {controls.map((control) => (
100
- <ConfigModalItem
101
- key={control.title}
102
- ouiaId={`${ouiaId}-${control.title.replace(/\s+/g, '-').toLowerCase()}`}
103
- {...control}
104
- />
105
- ))}
139
+ {children}
106
140
  </Flex>
107
141
  </ModalBody>
108
142
  </Modal>
109
143
  <CodeEditorControl
110
144
  aria-label={title}
111
145
  aria-haspopup="dialog"
112
- icon={<CogIcon />}
146
+ isSettings
113
147
  onClick={() => setIsModalOpen(true)}
114
148
  tooltipProps={{ content: title, ariaLive: 'off' }}
115
149
  />
@@ -123,37 +157,62 @@ export const CodeEditorConfigurationModal: React.FunctionComponent = () => {
123
157
  const [isMinimapVisible, setIsMinimapVisible] = useState(true);
124
158
  const [isDarkTheme, setIsDarkTheme] = useState(false);
125
159
  const [isLineNumbersVisible, setIsLineNumbersVisible] = useState(true);
160
+ const [fontSize, setFontSize] = useState(14);
126
161
 
127
162
  const onChange = (code: string) => {
128
163
  setCode(code);
129
164
  };
130
165
 
131
166
  const customControl = (
132
- <ConfigModalControl
133
- controls={[
134
- {
135
- title: 'Minimap',
136
- description: 'Show a preview of the full code on the side of the editor',
137
- isChecked: isMinimapVisible,
138
- onChange: (_e, checked) => setIsMinimapVisible(checked),
139
- icon: <MapIcon />
140
- },
141
- {
142
- title: 'Dark theme',
143
- description: 'Switch the editor to a dark color theme',
144
- isChecked: isDarkTheme,
145
- onChange: (_e, checked) => setIsDarkTheme(checked),
146
- icon: <MoonIcon />
147
- },
148
- {
149
- title: 'Line numbers',
150
- description: 'Show line numbers to the left of each line of code',
151
- isChecked: isLineNumbersVisible,
152
- onChange: (_e, checked) => setIsLineNumbersVisible(checked),
153
- icon: <HashtagIcon />
167
+ <ConfigModalControl>
168
+ <ConfigModalSwitch
169
+ key="minimap-switch"
170
+ title="Minimap"
171
+ description="Show a preview of the full code on the side of the editor"
172
+ isChecked={isMinimapVisible}
173
+ onChange={(_e, checked) => setIsMinimapVisible(checked)}
174
+ icon={<MapIcon />}
175
+ />
176
+ <ConfigModalSwitch
177
+ key="dark-theme-switch"
178
+ title="Dark theme"
179
+ description="Switch the editor to a dark color theme"
180
+ isChecked={isDarkTheme}
181
+ onChange={(_e, checked) => setIsDarkTheme(checked)}
182
+ icon={<MoonIcon />}
183
+ />
184
+ <ConfigModalSwitch
185
+ key="line-numbers-switch"
186
+ title="Line numbers"
187
+ description="Show line numbers to the left of each line of code"
188
+ isChecked={isLineNumbersVisible}
189
+ onChange={(_e, checked) => setIsLineNumbersVisible(checked)}
190
+ icon={<HashtagIcon />}
191
+ />
192
+ <ConfigModalItem
193
+ key="font-size"
194
+ title="Font size"
195
+ description="Adjust the font size of the code editor"
196
+ ouia-id="ConfigModalItem-font-size"
197
+ icon={<FontIcon />}
198
+ slot={
199
+ <NumberInput
200
+ aria-labelledby="ConfigModalItem-font-size-title"
201
+ aria-describedby="ConfigModalItem-font-size-description"
202
+ inputAriaLabel="Enter a font size"
203
+ minusBtnAriaLabel="Decrease font size"
204
+ plusBtnAriaLabel="Increase font size"
205
+ role="group" // For screen readers to group the input and buttons as one widget
206
+ value={fontSize}
207
+ min={5}
208
+ onMinus={() => setFontSize((size) => Math.max(5, size - 1))}
209
+ onChange={(event) => setFontSize(Number((event.target as HTMLInputElement).value))}
210
+ onPlus={() => setFontSize((size) => size + 1)}
211
+ widthChars={2}
212
+ />
154
213
  }
155
- ]}
156
- />
214
+ />
215
+ </ConfigModalControl>
157
216
  );
158
217
 
159
218
  return (
@@ -165,6 +224,7 @@ export const CodeEditorConfigurationModal: React.FunctionComponent = () => {
165
224
  isLineNumbersVisible={isLineNumbersVisible}
166
225
  isMinimapVisible={isMinimapVisible}
167
226
  onChange={onChange}
227
+ options={{ fontSize }}
168
228
  />
169
229
  );
170
230
  };