@patternfly/react-docs 7.6.0-prerelease.7 → 7.6.0-prerelease.8
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/package.json +12 -13
- package/patternfly-docs/generated/components/about-modal/react.js +149 -0
- package/patternfly-docs/generated/components/accordion/react.js +262 -0
- package/patternfly-docs/generated/components/action-list/react.js +144 -0
- package/patternfly-docs/generated/components/alert/react-demos.js +56 -0
- package/patternfly-docs/generated/components/alert/react.js +1433 -0
- package/patternfly-docs/generated/components/avatar/react.js +166 -0
- package/patternfly-docs/generated/components/back-to-top/react-demos.js +60 -0
- package/patternfly-docs/generated/components/back-to-top/react.js +77 -0
- package/patternfly-docs/generated/components/backdrop/react.js +64 -0
- package/patternfly-docs/generated/components/background-image/react.js +62 -0
- package/patternfly-docs/generated/components/badge/react.js +97 -0
- package/patternfly-docs/generated/components/banner/react-demos.js +57 -0
- package/patternfly-docs/generated/components/banner/react.js +148 -0
- package/patternfly-docs/generated/components/brand/react.js +142 -0
- package/patternfly-docs/generated/components/breadcrumb/react.js +206 -0
- package/patternfly-docs/generated/components/button/react-demos.js +57 -0
- package/patternfly-docs/generated/components/button/react.js +826 -0
- package/patternfly-docs/generated/components/card/react-demos.js +201 -0
- package/patternfly-docs/generated/components/card/react.js +1015 -0
- package/patternfly-docs/generated/components/charts/area-chart/-Victory.js +1350 -0
- package/patternfly-docs/generated/components/charts/bar-chart/-Victory.js +1334 -0
- package/patternfly-docs/generated/components/charts/box-plot-chart/-Victory.js +1282 -0
- package/patternfly-docs/generated/components/charts/bullet-chart/-Victory.js +848 -0
- package/patternfly-docs/generated/components/charts/colors-for-charts/-Victory.js +192 -0
- package/patternfly-docs/generated/components/charts/donut-chart/-Victory.js +426 -0
- package/patternfly-docs/generated/components/charts/donut-utilization-chart/-Victory.js +804 -0
- package/patternfly-docs/generated/components/charts/legends/-Victory.js +3230 -0
- package/patternfly-docs/generated/components/charts/line-chart/-Victory.js +1178 -0
- package/patternfly-docs/generated/components/charts/line-chart/ECharts.js +525 -0
- package/patternfly-docs/generated/components/charts/patterns/-Victory.js +3382 -0
- package/patternfly-docs/generated/components/charts/pie-chart/-Victory.js +377 -0
- package/patternfly-docs/generated/components/charts/resize-observer/-Victory.js +2475 -0
- package/patternfly-docs/generated/components/charts/sankey-chart/ECharts.js +538 -0
- package/patternfly-docs/generated/components/charts/scatter-chart/-Victory.js +1551 -0
- package/patternfly-docs/generated/components/charts/skeletons/-Victory.js +4115 -0
- package/patternfly-docs/generated/components/charts/sparkline-chart/-Victory.js +955 -0
- package/patternfly-docs/generated/components/charts/stack-chart/-Victory.js +1173 -0
- package/patternfly-docs/generated/components/charts/threshold-chart/-Victory.js +1166 -0
- package/patternfly-docs/generated/components/charts/tooltips/-Victory.js +413 -0
- package/patternfly-docs/generated/components/chip/react-deprecated.js +323 -0
- package/patternfly-docs/generated/components/clipboard-copy/react.js +373 -0
- package/patternfly-docs/generated/components/code-block/react.js +148 -0
- package/patternfly-docs/generated/components/code-editor/react.js +659 -0
- package/patternfly-docs/generated/components/compass/react-demos.js +147 -0
- package/patternfly-docs/generated/components/compass/react.js +440 -0
- package/patternfly-docs/generated/components/content/react.js +248 -0
- package/patternfly-docs/generated/components/data-list/react-demos.js +90 -0
- package/patternfly-docs/generated/components/data-list/react.js +709 -0
- package/patternfly-docs/generated/components/date-and-time/calendar-month/react.js +283 -0
- package/patternfly-docs/generated/components/date-and-time/date-and-time-picker/react-demos.js +64 -0
- package/patternfly-docs/generated/components/date-and-time/date-picker/react-demos.js +83 -0
- package/patternfly-docs/generated/components/date-and-time/date-picker/react.js +395 -0
- package/patternfly-docs/generated/components/date-and-time/time-picker/react.js +241 -0
- package/patternfly-docs/generated/components/description-list/react-demos.js +58 -0
- package/patternfly-docs/generated/components/description-list/react.js +743 -0
- package/patternfly-docs/generated/components/divider/react.js +126 -0
- package/patternfly-docs/generated/components/drag-and-drop/react-demos.js +351 -0
- package/patternfly-docs/generated/components/drag-and-drop/react-deprecated.js +184 -0
- package/patternfly-docs/generated/components/drag-and-drop/react.js +137 -0
- package/patternfly-docs/generated/components/drawer/react.js +598 -0
- package/patternfly-docs/generated/components/dual-list-selector/react-deprecated.js +772 -0
- package/patternfly-docs/generated/components/dual-list-selector/react.js +594 -0
- package/patternfly-docs/generated/components/empty-state/react.js +199 -0
- package/patternfly-docs/generated/components/expandable-section/react-demos.js +65 -0
- package/patternfly-docs/generated/components/expandable-section/react.js +408 -0
- package/patternfly-docs/generated/components/file-upload/multiple-file-upload/react-demos.js +52 -0
- package/patternfly-docs/generated/components/file-upload/multiple-file-upload/react.js +398 -0
- package/patternfly-docs/generated/components/file-upload/simple-file-upload/react.js +749 -0
- package/patternfly-docs/generated/components/forms/checkbox/react.js +222 -0
- package/patternfly-docs/generated/components/forms/form/react.js +1106 -0
- package/patternfly-docs/generated/components/forms/form-select/react.js +208 -0
- package/patternfly-docs/generated/components/forms/radio/react.js +212 -0
- package/patternfly-docs/generated/components/forms/text-area/react.js +160 -0
- package/patternfly-docs/generated/components/forms/text-input/react.js +216 -0
- package/patternfly-docs/generated/components/helper-text/react-demos.js +180 -0
- package/patternfly-docs/generated/components/helper-text/react.js +164 -0
- package/patternfly-docs/generated/components/hero/react.js +88 -0
- package/patternfly-docs/generated/components/hint/react.js +169 -0
- package/patternfly-docs/generated/components/icon/react.js +215 -0
- package/patternfly-docs/generated/components/input-group/react.js +182 -0
- package/patternfly-docs/generated/components/jump-links/react-demos.js +154 -0
- package/patternfly-docs/generated/components/jump-links/react.js +212 -0
- package/patternfly-docs/generated/components/label/react-demos.js +57 -0
- package/patternfly-docs/generated/components/label/react.js +417 -0
- package/patternfly-docs/generated/components/list/react.js +175 -0
- package/patternfly-docs/generated/components/login-page/react.js +587 -0
- package/patternfly-docs/generated/components/masthead/react-demos.js +79 -0
- package/patternfly-docs/generated/components/masthead/react.js +291 -0
- package/patternfly-docs/generated/components/menus/application-launcher/react-demos.js +769 -0
- package/patternfly-docs/generated/components/menus/context-selector/react-demos.js +665 -0
- package/patternfly-docs/generated/components/menus/custom-menus/react-demos.js +187 -0
- package/patternfly-docs/generated/components/menus/dropdown/react-templates.js +163 -0
- package/patternfly-docs/generated/components/menus/dropdown/react.js +998 -0
- package/patternfly-docs/generated/components/menus/menu/react.js +1540 -0
- package/patternfly-docs/generated/components/menus/menu-toggle/react.js +747 -0
- package/patternfly-docs/generated/components/menus/options-menu/react-demos.js +508 -0
- package/patternfly-docs/generated/components/menus/select/react-templates.js +257 -0
- package/patternfly-docs/generated/components/menus/select/react.js +998 -0
- package/patternfly-docs/generated/components/modal/react-deprecated.js +554 -0
- package/patternfly-docs/generated/components/modal/react.js +597 -0
- package/patternfly-docs/generated/components/navigation/react-demos.js +356 -0
- package/patternfly-docs/generated/components/navigation/react.js +409 -0
- package/patternfly-docs/generated/components/notification-badge/react.js +196 -0
- package/patternfly-docs/generated/components/notification-drawer/react-demos.js +107 -0
- package/patternfly-docs/generated/components/notification-drawer/react.js +394 -0
- package/patternfly-docs/generated/components/number-input/react.js +210 -0
- package/patternfly-docs/generated/components/overflow-menu/react.js +274 -0
- package/patternfly-docs/generated/components/page/react-demos.js +149 -0
- package/patternfly-docs/generated/components/page/react.js +1352 -0
- package/patternfly-docs/generated/components/pagination/react.js +492 -0
- package/patternfly-docs/generated/components/panel/react.js +236 -0
- package/patternfly-docs/generated/components/popover/react.js +390 -0
- package/patternfly-docs/generated/components/progress/react-demos.js +59 -0
- package/patternfly-docs/generated/components/progress/react.js +283 -0
- package/patternfly-docs/generated/components/progress-stepper/react-demos.js +45 -0
- package/patternfly-docs/generated/components/progress-stepper/react.js +219 -0
- package/patternfly-docs/generated/components/search-input/react-demos.js +113 -0
- package/patternfly-docs/generated/components/search-input/react.js +263 -0
- package/patternfly-docs/generated/components/sidebar/react.js +236 -0
- package/patternfly-docs/generated/components/simple-list/react.js +200 -0
- package/patternfly-docs/generated/components/skeleton/react-demos.js +44 -0
- package/patternfly-docs/generated/components/skeleton/react.js +122 -0
- package/patternfly-docs/generated/components/skip-to-content/react.js +73 -0
- package/patternfly-docs/generated/components/slider/react.js +309 -0
- package/patternfly-docs/generated/components/spinner/react.js +111 -0
- package/patternfly-docs/generated/components/switch/react.js +163 -0
- package/patternfly-docs/generated/components/table/react-demos.js +355 -0
- package/patternfly-docs/generated/components/table/react-deprecated.js +1350 -0
- package/patternfly-docs/generated/components/table/react.js +3241 -0
- package/patternfly-docs/generated/components/tabs/react-demos.js +108 -0
- package/patternfly-docs/generated/components/tabs/react.js +1359 -0
- package/patternfly-docs/generated/components/text-input-group/react-demos.js +152 -0
- package/patternfly-docs/generated/components/text-input-group/react.js +278 -0
- package/patternfly-docs/generated/components/tile/react-deprecated.js +242 -0
- package/patternfly-docs/generated/components/timestamp/react.js +283 -0
- package/patternfly-docs/generated/components/title/react.js +94 -0
- package/patternfly-docs/generated/components/toggle-group/react.js +299 -0
- package/patternfly-docs/generated/components/toolbar/react-demos.js +66 -0
- package/patternfly-docs/generated/components/toolbar/react.js +932 -0
- package/patternfly-docs/generated/components/tooltip/react.js +241 -0
- package/patternfly-docs/generated/components/tree-view/react.js +429 -0
- package/patternfly-docs/generated/components/truncate/react.js +211 -0
- package/patternfly-docs/generated/components/wizard/react-demos.js +87 -0
- package/patternfly-docs/generated/components/wizard/react-deprecated.js +788 -0
- package/patternfly-docs/generated/components/wizard/react.js +986 -0
- package/patternfly-docs/generated/developer-guides/open-ui-automation/react.js +285 -0
- package/patternfly-docs/generated/foundations-and-styles/layouts/bullseye/react.js +70 -0
- package/patternfly-docs/generated/foundations-and-styles/layouts/flex/react.js +506 -0
- package/patternfly-docs/generated/foundations-and-styles/layouts/gallery/react.js +94 -0
- package/patternfly-docs/generated/foundations-and-styles/layouts/grid/react.js +272 -0
- package/patternfly-docs/generated/foundations-and-styles/layouts/level/react.js +87 -0
- package/patternfly-docs/generated/foundations-and-styles/layouts/split/react.js +124 -0
- package/patternfly-docs/generated/foundations-and-styles/layouts/stack/react.js +112 -0
- package/patternfly-docs/generated/index.js +1769 -0
- package/patternfly-docs/generated/patterns/card-view/react-demos.js +78 -0
- package/patternfly-docs/generated/patterns/filters/react-demos.js +141 -0
- package/patternfly-docs/generated/patterns/password-generator/react-demos.js +51 -0
- package/patternfly-docs/generated/patterns/password-strength/react-demos.js +61 -0
- package/patternfly-docs/generated/patterns/primary-detail/react-demos.js +124 -0
- package/patternfly-docs/generated/patterns/right-to-left/react-demos.js +81 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AutoLinkHeader, Example, Link as PatternflyThemeLink } from '@patternfly/documentation-framework/components';
|
|
3
|
+
import { Fragment, useState } from 'react';
|
|
4
|
+
import { CodeEditor, CodeEditorControl, Language } from '@patternfly/react-code-editor';
|
|
5
|
+
import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon';
|
|
6
|
+
import HashtagIcon from '@patternfly/react-icons/dist/esm/icons/hashtag-icon';
|
|
7
|
+
import MapIcon from '@patternfly/react-icons/dist/esm/icons/map-icon';
|
|
8
|
+
import RhUiDarkModeFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-dark-mode-fill-icon';
|
|
9
|
+
import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
|
|
10
|
+
import FontIcon from '@patternfly/react-icons/dist/esm/icons/font-icon';
|
|
11
|
+
import AdjustIcon from '@patternfly/react-icons/dist/esm/icons/adjust-icon';
|
|
12
|
+
const pageData = {
|
|
13
|
+
"id": "Code editor",
|
|
14
|
+
"section": "components",
|
|
15
|
+
"subsection": "",
|
|
16
|
+
"deprecated": false,
|
|
17
|
+
"template": false,
|
|
18
|
+
"beta": false,
|
|
19
|
+
"demo": false,
|
|
20
|
+
"newImplementationLink": false,
|
|
21
|
+
"source": "react",
|
|
22
|
+
"tabName": null,
|
|
23
|
+
"slug": "/components/code-editor/react",
|
|
24
|
+
"sourceLink": "https://github.com/patternfly/patternfly-react/blob/main/packages/react-code-editor/src/components/CodeEditor/examples/CodeEditor.md",
|
|
25
|
+
"relPath": "packages/react-code-editor/src/components/CodeEditor/examples/CodeEditor.md",
|
|
26
|
+
"propComponents": [
|
|
27
|
+
{
|
|
28
|
+
"name": "CodeEditor",
|
|
29
|
+
"description": "The main code editor component.",
|
|
30
|
+
"props": [
|
|
31
|
+
{
|
|
32
|
+
"name": "className",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Additional classes added to the code editor.",
|
|
35
|
+
"defaultValue": "''"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "code",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Code displayed in code editor.",
|
|
41
|
+
"defaultValue": "''"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "copyButtonAriaLabel",
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Accessible label for the copy button.",
|
|
47
|
+
"defaultValue": "'Copy code to clipboard'"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "copyButtonSuccessTooltipText",
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "Text to display in the tooltip on the copy button after code is copied to clipboard.",
|
|
53
|
+
"defaultValue": "'Content added to clipboard'"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "copyButtonToolTipText",
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "Text to display in the tooltip on the copy button before code is copied.",
|
|
59
|
+
"defaultValue": "'Copy to clipboard'"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "customControls",
|
|
63
|
+
"type": "ReactNode | ReactNode[]",
|
|
64
|
+
"description": "A single node or array of nodes - ideally the code editor controls component - to display\nabove code editor.",
|
|
65
|
+
"defaultValue": "null"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "downloadButtonAriaLabel",
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "Accessible label for the download button.",
|
|
71
|
+
"defaultValue": "'Download code'"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "downloadButtonToolTipText",
|
|
75
|
+
"type": "string",
|
|
76
|
+
"description": "Text to display in the tooltip on the download button.",
|
|
77
|
+
"defaultValue": "'Download'"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "downloadFileName",
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "Name of the file if user downloads code to local file.",
|
|
83
|
+
"defaultValue": "Date.now().toString()"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "editorProps",
|
|
87
|
+
"type": "EditorProps",
|
|
88
|
+
"description": "Additional props to pass to the monaco editor."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "emptyState",
|
|
92
|
+
"type": "ReactNode",
|
|
93
|
+
"description": "Content to display in space of the code editor when there is no code to display.",
|
|
94
|
+
"defaultValue": "''"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "emptyStateBody",
|
|
98
|
+
"type": "ReactNode",
|
|
99
|
+
"description": "Override default empty state body text.",
|
|
100
|
+
"defaultValue": "'Drag and drop a file or upload one.'"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "emptyStateButton",
|
|
104
|
+
"type": "ReactNode",
|
|
105
|
+
"description": "Override default empty state button text.",
|
|
106
|
+
"defaultValue": "'Browse'"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "emptyStateLink",
|
|
110
|
+
"type": "ReactNode",
|
|
111
|
+
"description": "Override default empty state link text.",
|
|
112
|
+
"defaultValue": "'Start from scratch'"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "emptyStateTitle",
|
|
116
|
+
"type": "ReactNode",
|
|
117
|
+
"description": "Override default empty state title text.",
|
|
118
|
+
"defaultValue": "'Start editing'"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "headerMainContent",
|
|
122
|
+
"type": "string",
|
|
123
|
+
"description": "Editor header main content title.",
|
|
124
|
+
"defaultValue": "''"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "height",
|
|
128
|
+
"type": "string | 'sizeToFit'",
|
|
129
|
+
"description": "Height of code editor. 'sizeToFit' will automatically change the height\nto the height of the content."
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "isCopyEnabled",
|
|
133
|
+
"type": "boolean",
|
|
134
|
+
"description": "Flag to add copy button to code editor actions.",
|
|
135
|
+
"defaultValue": "false"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "isDarkTheme",
|
|
139
|
+
"type": "boolean",
|
|
140
|
+
"description": "Flag indicating the editor is styled using monaco's dark theme.",
|
|
141
|
+
"defaultValue": "false"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "isDownloadEnabled",
|
|
145
|
+
"type": "boolean",
|
|
146
|
+
"description": "Flag to add download button to code editor actions.",
|
|
147
|
+
"defaultValue": "false"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "isFullHeight",
|
|
151
|
+
"type": "boolean",
|
|
152
|
+
"description": "Flag that enables component to consume the available height of its container. If `height` prop is set to 100%, this will also become enabled.",
|
|
153
|
+
"defaultValue": "false"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "isHeaderPlain",
|
|
157
|
+
"type": "boolean",
|
|
158
|
+
"description": "Flag indicating the editor has a plain header.",
|
|
159
|
+
"defaultValue": "false"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "isHighContrastTheme",
|
|
163
|
+
"type": "boolean",
|
|
164
|
+
"description": "Flag indicating the editor is styled using monaco's high contrast themes.",
|
|
165
|
+
"defaultValue": "false"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "isLanguageLabelVisible",
|
|
169
|
+
"type": "boolean",
|
|
170
|
+
"description": "Flag to include a label indicating the currently configured editor language.",
|
|
171
|
+
"defaultValue": "false"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "isLineNumbersVisible",
|
|
175
|
+
"type": "boolean",
|
|
176
|
+
"description": "Flag indicating the editor is displaying line numbers.",
|
|
177
|
+
"defaultValue": "true"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "isMinimapVisible",
|
|
181
|
+
"type": "boolean",
|
|
182
|
+
"description": "Flag to add the minimap to the code editor.",
|
|
183
|
+
"defaultValue": "false"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "isReadOnly",
|
|
187
|
+
"type": "boolean",
|
|
188
|
+
"description": "Flag indicating the editor is read only.",
|
|
189
|
+
"defaultValue": "false"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "isUploadEnabled",
|
|
193
|
+
"type": "boolean",
|
|
194
|
+
"description": "Flag to add upload button to code editor actions. Also makes the code editor accept a\nfile using drag and drop.",
|
|
195
|
+
"defaultValue": "false"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"name": "language",
|
|
199
|
+
"type": "Language",
|
|
200
|
+
"description": "Language displayed in the editor.",
|
|
201
|
+
"defaultValue": "Language.plaintext"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"name": "loading",
|
|
205
|
+
"type": "ReactNode",
|
|
206
|
+
"description": "The loading screen before the editor will be loaded. Defaults to 'loading...'.",
|
|
207
|
+
"defaultValue": "''"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "onChange",
|
|
211
|
+
"type": "(value: string, event: editor.IModelContentChangedEvent) => void",
|
|
212
|
+
"description": "Function which fires each time the content of the code editor is manually changed. Does\nnot fire when a file is uploaded.",
|
|
213
|
+
"defaultValue": "() => {}"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "onCodeChange",
|
|
217
|
+
"type": "(value: string) => void",
|
|
218
|
+
"description": "Function which fires each time the code changes in the code editor.",
|
|
219
|
+
"defaultValue": "() => {}"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "onDownload",
|
|
223
|
+
"type": "(value: string, fileName: string) => void",
|
|
224
|
+
"description": "Function which fires when the code is downloaded. Defaults to a function that\ndownloads the current editor content.",
|
|
225
|
+
"defaultValue": "(value: string, fileName: string) => {\n const link = document.createElement('a');\n link.href = URL.createObjectURL(new Blob([value], { type: 'text' }));\n link.download = fileName;\n link.click();\n}"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"name": "onEditorDidMount",
|
|
229
|
+
"type": "(editor: editor.IStandaloneCodeEditor, monaco: Monaco) => void",
|
|
230
|
+
"description": "Callback which fires after the code editor is mounted containing a reference to the\nmonaco editor and the monaco instance.",
|
|
231
|
+
"defaultValue": "() => {}"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"name": "options",
|
|
235
|
+
"type": "editor.IStandaloneEditorConstructionOptions",
|
|
236
|
+
"description": "Refer to Monaco interface {monaco.editor.IStandaloneEditorConstructionOptions}.",
|
|
237
|
+
"defaultValue": "{}"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"name": "overrideServices",
|
|
241
|
+
"type": "editor.IEditorOverrideServices",
|
|
242
|
+
"description": "Refer to Monaco interface {monaco.editor.IEditorOverrideServices}.",
|
|
243
|
+
"defaultValue": "{}"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"name": "shortcutsPopoverButtonText",
|
|
247
|
+
"type": "string",
|
|
248
|
+
"description": "Text to show in the button to open the shortcut popover.",
|
|
249
|
+
"defaultValue": "'View Shortcuts'"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"name": "shortcutsPopoverProps",
|
|
253
|
+
"type": "PopoverProps",
|
|
254
|
+
"description": "Properties for the shortcut popover.",
|
|
255
|
+
"defaultValue": "{ bodyContent: '', 'aria-label': 'Keyboard Shortcuts' }"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"name": "showEditor",
|
|
259
|
+
"type": "boolean",
|
|
260
|
+
"description": "Flag to show the editor.",
|
|
261
|
+
"defaultValue": "true"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "toolTipCopyExitDelay",
|
|
265
|
+
"type": "number",
|
|
266
|
+
"description": "The delay before tooltip fades after code copied.",
|
|
267
|
+
"defaultValue": "1600"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"name": "toolTipDelay",
|
|
271
|
+
"type": "number",
|
|
272
|
+
"description": "The entry and exit delay for all tooltips.",
|
|
273
|
+
"defaultValue": "300"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "toolTipMaxWidth",
|
|
277
|
+
"type": "string",
|
|
278
|
+
"description": "The max width of the tooltips on all button.",
|
|
279
|
+
"defaultValue": "'100px'"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"name": "toolTipPosition",
|
|
283
|
+
"type": "| TooltipPosition\n| 'auto'\n| 'top'\n| 'bottom'\n| 'left'\n| 'right'\n| 'top-start'\n| 'top-end'\n| 'bottom-start'\n| 'bottom-end'\n| 'left-start'\n| 'left-end'\n| 'right-start'\n| 'right-end'",
|
|
284
|
+
"description": "The position of tooltips on all buttons.",
|
|
285
|
+
"defaultValue": "'top'"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"name": "uploadButtonAriaLabel",
|
|
289
|
+
"type": "string",
|
|
290
|
+
"description": "Accessible label for the upload button.",
|
|
291
|
+
"defaultValue": "'Upload code'"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"name": "uploadButtonToolTipText",
|
|
295
|
+
"type": "string",
|
|
296
|
+
"description": "Text to display in the tooltip on the upload button.",
|
|
297
|
+
"defaultValue": "'Upload'"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"name": "width",
|
|
301
|
+
"type": "string",
|
|
302
|
+
"description": "Width of code editor. Defaults to 100%.",
|
|
303
|
+
"defaultValue": "''"
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"name": "CodeEditorControl",
|
|
309
|
+
"description": "Allows customizing the code editor controls by passing this sub-component into the\ncode editor's customControl property.",
|
|
310
|
+
"props": [
|
|
311
|
+
{
|
|
312
|
+
"name": "aria-label",
|
|
313
|
+
"type": "string",
|
|
314
|
+
"description": "Accessible label for the code editor control"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"name": "className",
|
|
318
|
+
"type": "string",
|
|
319
|
+
"description": "Additional classes added to the code editor control."
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"name": "icon",
|
|
323
|
+
"type": "React.ReactNode",
|
|
324
|
+
"description": "Icon rendered inside the code editor control."
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"name": "isVisible",
|
|
328
|
+
"type": "boolean",
|
|
329
|
+
"description": "Flag indicating that the button is visible above the code editor.",
|
|
330
|
+
"defaultValue": "true"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"name": "onClick",
|
|
334
|
+
"type": "(code: string, event?: any) => void",
|
|
335
|
+
"description": "Event handler for the click of the button",
|
|
336
|
+
"defaultValue": "() => {}"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"name": "tooltipProps",
|
|
340
|
+
"type": "any",
|
|
341
|
+
"description": "Additional tooltip props forwarded to the Tooltip component",
|
|
342
|
+
"defaultValue": "{}"
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"name": "Popover",
|
|
348
|
+
"description": "The main popover component. The following properties can also be passed into another component\nthat has a property specifically for passing in popover properties.",
|
|
349
|
+
"props": [
|
|
350
|
+
{
|
|
351
|
+
"name": "alertSeverityScreenReaderText",
|
|
352
|
+
"type": "string",
|
|
353
|
+
"description": "Text announced by screen reader when alert severity variant is set to indicate\nseverity level."
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"name": "alertSeverityVariant",
|
|
357
|
+
"type": "'custom' | 'info' | 'warning' | 'success' | 'danger'",
|
|
358
|
+
"description": "Severity variants for an alert popover. This modifies the color of the header to\nmatch the severity."
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"name": "animationDuration",
|
|
362
|
+
"type": "number",
|
|
363
|
+
"description": "The duration of the CSS fade transition animation.",
|
|
364
|
+
"defaultValue": "300"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"name": "appendTo",
|
|
368
|
+
"type": "HTMLElement | ((ref?: HTMLElement) => HTMLElement) | 'inline'",
|
|
369
|
+
"description": "The element to append the popover to. Defaults to \"inline\".",
|
|
370
|
+
"defaultValue": "() => document.body"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"name": "aria-label",
|
|
374
|
+
"type": "string",
|
|
375
|
+
"description": "Accessible label for the popover, required when header is not present.",
|
|
376
|
+
"defaultValue": "''"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"name": "bodyContent",
|
|
380
|
+
"type": "React.ReactNode | ((hide: () => void) => React.ReactNode)",
|
|
381
|
+
"description": "Body content of the popover. If you want to close the popover after an action within the\nbody content, you can use the isVisible prop for manual control, or you can provide a\nfunction which will receive a callback as an argument to hide the popover, i.e.\nbodyContent={hide => <Button onClick={() => hide()}>Close</Button>}",
|
|
382
|
+
"required": true
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"name": "children",
|
|
386
|
+
"type": "ReactElement<any>",
|
|
387
|
+
"description": "The trigger reference element to which the popover is relatively placed to. If you cannot wrap\nthe element with the Popover, you can use the triggerRef prop instead.\nUsage: <Popover><Button>Reference</Button></Popover>"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"name": "className",
|
|
391
|
+
"type": "string",
|
|
392
|
+
"description": "Additional classes added to the popover.",
|
|
393
|
+
"defaultValue": "''"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"name": "closeBtnAriaLabel",
|
|
397
|
+
"type": "string",
|
|
398
|
+
"description": "Accessible label for the close button.",
|
|
399
|
+
"defaultValue": "'Close'"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"name": "distance",
|
|
403
|
+
"type": "number",
|
|
404
|
+
"description": "Distance of the popover to its target. Defaults to 25.",
|
|
405
|
+
"defaultValue": "25"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"name": "elementToFocus",
|
|
409
|
+
"type": "HTMLElement | SVGElement | string",
|
|
410
|
+
"description": "The element to focus when the popover becomes visible. By default the first\nfocusable element will receive focus."
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "enableFlip",
|
|
414
|
+
"type": "boolean",
|
|
415
|
+
"description": "If true, tries to keep the popover in view by flipping it if necessary.\nIf the position is set to 'auto', this prop is ignored.",
|
|
416
|
+
"defaultValue": "true"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"name": "flipBehavior",
|
|
420
|
+
"type": "| 'flip'\n| (\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'top-start'\n | 'top-end'\n | 'bottom-start'\n | 'bottom-end'\n | 'left-start'\n | 'left-end'\n | 'right-start'\n | 'right-end'\n )[]",
|
|
421
|
+
"description": "The desired position to flip the popover to if the initial position is not possible.\nBy setting this prop to 'flip' it attempts to flip the popover to the opposite side if\nthere is no space.\nYou can also pass an array of positions that determines the flip order. It should contain\nthe initial position followed by alternative positions if that position is unavailable.\nExample: Initial position is 'top'. Button with popover is in the top right corner.\n'flipBehavior' is set to ['top', 'right', 'left']. Since there is no space to the top, it\nchecks if right is available. There's also no space to the right, so it finally shows the\npopover on the left.",
|
|
422
|
+
"defaultValue": "[\n 'top',\n 'bottom',\n 'left',\n 'right',\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'left-start',\n 'left-end',\n 'right-start',\n 'right-end'\n]"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"name": "footerContent",
|
|
426
|
+
"type": "React.ReactNode | ((hide: () => void) => React.ReactNode)",
|
|
427
|
+
"description": "Footer content of the popover. If you want to close the popover after an action within the\nfooter content, you can use the isVisible prop for manual control, or you can provide a\nfunction which will receive a callback as an argument to hide the popover, i.e.\nfooterContent={hide => <Button onClick={() => hide()}>Close</Button>}",
|
|
428
|
+
"defaultValue": "null"
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
"name": "hasAutoWidth",
|
|
432
|
+
"type": "boolean",
|
|
433
|
+
"description": "Removes fixed-width and allows width to be defined by contents.",
|
|
434
|
+
"defaultValue": "false"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"name": "hasNoPadding",
|
|
438
|
+
"type": "boolean",
|
|
439
|
+
"description": "Allows content to touch edges of popover container.",
|
|
440
|
+
"defaultValue": "false"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"name": "headerComponent",
|
|
444
|
+
"type": "'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'",
|
|
445
|
+
"description": "Sets the heading level to use for the popover header. Defaults to h6.",
|
|
446
|
+
"defaultValue": "'h6'"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"name": "headerContent",
|
|
450
|
+
"type": "React.ReactNode | ((hide: () => void) => React.ReactNode)",
|
|
451
|
+
"description": "Simple header content to be placed within a title. If you want to close the popover after\nan action within the header content, you can use the isVisible prop for manual control,\nor you can provide a function which will receive a callback as an argument to hide the\npopover, i.e. headerContent={hide => <Button onClick={() => hide()}>Close</Button>}",
|
|
452
|
+
"defaultValue": "null"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"name": "headerIcon",
|
|
456
|
+
"type": "React.ReactNode",
|
|
457
|
+
"description": "Icon to be displayed in the popover header. *",
|
|
458
|
+
"defaultValue": "null"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"name": "hideOnOutsideClick",
|
|
462
|
+
"type": "boolean",
|
|
463
|
+
"description": "Hides the popover when a click occurs outside (only works if isVisible is not controlled\nby the user).",
|
|
464
|
+
"defaultValue": "true"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
"name": "id",
|
|
468
|
+
"type": "string",
|
|
469
|
+
"description": "Id used as part of the various popover elements (popover-${id}-header/body/footer)."
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"name": "isVisible",
|
|
473
|
+
"type": "boolean",
|
|
474
|
+
"description": "True to show the popover programmatically. Used in conjunction with the shouldClose prop.\nBy default, the popover child element handles click events automatically. If you want to\ncontrol this programmatically, the popover will not auto-close if the close button is\nclicked, the escape key is used, or if a click occurs outside the popover. Instead, the\nconsumer is responsible for closing the popover themselves by adding a callback listener\nfor the shouldClose prop.",
|
|
475
|
+
"defaultValue": "null"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"name": "maxWidth",
|
|
479
|
+
"type": "string",
|
|
480
|
+
"description": "Maximum width of the popover (default 18.75rem).",
|
|
481
|
+
"defaultValue": "popoverMaxWidth && popoverMaxWidth.value"
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
"name": "minWidth",
|
|
485
|
+
"type": "string",
|
|
486
|
+
"description": "Minimum width of the popover (default 6.25rem).",
|
|
487
|
+
"defaultValue": "popoverMinWidth && popoverMinWidth.value"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
"name": "onHidden",
|
|
491
|
+
"type": "() => void",
|
|
492
|
+
"description": "Lifecycle function invoked when the popover has fully transitioned out.",
|
|
493
|
+
"defaultValue": "(): void => null"
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
"name": "onHide",
|
|
497
|
+
"type": "(event: MouseEvent | KeyboardEvent) => void",
|
|
498
|
+
"description": "Lifecycle function invoked when the popover begins to transition out.",
|
|
499
|
+
"defaultValue": "(): void => null"
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"name": "onMount",
|
|
503
|
+
"type": "() => void",
|
|
504
|
+
"description": "Lifecycle function invoked when the popover has been mounted to the DOM.",
|
|
505
|
+
"defaultValue": "(): void => null"
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
"name": "onShow",
|
|
509
|
+
"type": "(event: MouseEvent | KeyboardEvent) => void",
|
|
510
|
+
"description": "Lifecycle function invoked when the popover begins to transition in.",
|
|
511
|
+
"defaultValue": "(): void => null"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
"name": "onShown",
|
|
515
|
+
"type": "() => void",
|
|
516
|
+
"description": "Lifecycle function invoked when the popover has fully transitioned in.",
|
|
517
|
+
"defaultValue": "(): void => null"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"name": "position",
|
|
521
|
+
"type": "| PopoverPosition\n| 'auto'\n| 'top'\n| 'bottom'\n| 'left'\n| 'right'\n| 'top-start'\n| 'top-end'\n| 'bottom-start'\n| 'bottom-end'\n| 'left-start'\n| 'left-end'\n| 'right-start'\n| 'right-end'",
|
|
522
|
+
"description": "Popover position. Note: With the enableFlip property set to true, it will change the\nposition if there is not enough space for the starting position. The behavior of where it\nflips to can be controlled through the flipBehavior property.",
|
|
523
|
+
"defaultValue": "'top'"
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"name": "shouldClose",
|
|
527
|
+
"type": "(event: MouseEvent | KeyboardEvent, hideFunction?: () => void) => void",
|
|
528
|
+
"description": "Callback function that is only invoked when isVisible is also controlled. Called when the\npopover close button is clicked, the enter key was used on it, or the escape key is used.",
|
|
529
|
+
"defaultValue": "(): void => null"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"name": "shouldOpen",
|
|
533
|
+
"type": "(event: MouseEvent | KeyboardEvent, showFunction?: () => void) => void",
|
|
534
|
+
"description": "Callback function that is only invoked when isVisible is also controlled. Called when the\nenter key is used on the focused trigger.",
|
|
535
|
+
"defaultValue": "(): void => null"
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"name": "showClose",
|
|
539
|
+
"type": "boolean",
|
|
540
|
+
"description": "Flag indicating whether the close button should be shown.",
|
|
541
|
+
"defaultValue": "true"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"name": "triggerAction",
|
|
545
|
+
"type": "'click' | 'hover'",
|
|
546
|
+
"description": "Sets an interaction to open popover, defaults to \"click\"",
|
|
547
|
+
"defaultValue": "'click'"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"name": "triggerRef",
|
|
551
|
+
"type": "HTMLElement | (() => HTMLElement) | React.RefObject<any>",
|
|
552
|
+
"description": "The trigger reference element to which the popover is relatively placed to. If you can wrap the\nelement with the popover, you can use the children prop instead, or both props together.\nWhen passed along with the trigger prop, the div element that wraps the trigger will be removed.\nUsage: <Popover triggerRef={() => document.getElementById('reference-element')} />"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"name": "withFocusTrap",
|
|
556
|
+
"type": "boolean",
|
|
557
|
+
"description": "Whether to trap focus in the popover."
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
"name": "zIndex",
|
|
561
|
+
"type": "number",
|
|
562
|
+
"description": "The z-index of the popover.",
|
|
563
|
+
"defaultValue": "9999"
|
|
564
|
+
}
|
|
565
|
+
]
|
|
566
|
+
}
|
|
567
|
+
],
|
|
568
|
+
"cssPrefix": [
|
|
569
|
+
"pf-v6-c-code-editor"
|
|
570
|
+
],
|
|
571
|
+
"examples": [
|
|
572
|
+
"Basic",
|
|
573
|
+
"With sizeToFit height, height will grow/shrink with content",
|
|
574
|
+
"With isFullHeight height, height will match the size of the parent",
|
|
575
|
+
"With shortcut menu and main header content",
|
|
576
|
+
"With actions",
|
|
577
|
+
"With custom control",
|
|
578
|
+
"With configuration modal"
|
|
579
|
+
]
|
|
580
|
+
};
|
|
581
|
+
pageData.liveContext = {
|
|
582
|
+
Fragment,
|
|
583
|
+
useState,
|
|
584
|
+
CodeEditor,
|
|
585
|
+
CodeEditorControl,
|
|
586
|
+
Language,
|
|
587
|
+
RhUiSettingsFillIcon,
|
|
588
|
+
HashtagIcon,
|
|
589
|
+
MapIcon,
|
|
590
|
+
RhUiDarkModeFillIcon,
|
|
591
|
+
PlayIcon,
|
|
592
|
+
FontIcon,
|
|
593
|
+
AdjustIcon
|
|
594
|
+
};
|
|
595
|
+
pageData.examples = {
|
|
596
|
+
'Basic': props =>
|
|
597
|
+
<Example {...pageData} {...props} {...{"code":"import { useState } from 'react';\nimport { CodeEditor, Language } from '@patternfly/react-code-editor';\nimport { Checkbox } from '@patternfly/react-core';\n\nexport const CodeEditorBasic: React.FunctionComponent = () => {\n const [isDarkTheme, setIsDarkTheme] = useState(false);\n const [isHighContrastTheme, setIsHighContrastTheme] = useState(false);\n const [isLineNumbersVisible, setIsLineNumbersVisible] = useState(true);\n const [isReadOnly, setIsReadOnly] = useState(false);\n const [isMinimapVisible, setIsMinimapVisible] = useState(false);\n\n const toggleDarkTheme = (checked) => {\n setIsDarkTheme(checked);\n };\n\n const toggleHighContrastTheme = (checked) => {\n setIsHighContrastTheme(checked);\n };\n\n const toggleLineNumbers = (checked) => {\n setIsLineNumbersVisible(checked);\n };\n const toggleReadOnly = (checked) => {\n setIsReadOnly(checked);\n };\n const toggleMinimap = (checked) => {\n setIsMinimapVisible(checked);\n };\n\n const onEditorDidMount = (editor, monaco) => {\n editor.layout();\n editor.focus();\n monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });\n };\n\n const onChange = (value) => {\n // eslint-disable-next-line no-console\n console.log(value);\n };\n\n return (\n <>\n <Checkbox\n label=\"Dark theme\"\n isChecked={isDarkTheme}\n onChange={(_event, checked) => toggleDarkTheme(checked)}\n aria-label=\"dark theme checkbox\"\n id=\"toggle-theme\"\n name=\"toggle-theme\"\n />\n <Checkbox\n label=\"High contrast theme\"\n isChecked={isHighContrastTheme}\n onChange={(_event, checked) => toggleHighContrastTheme(checked)}\n aria-label=\"high contrast theme checkbox\"\n id=\"toggle-high-contrast-theme\"\n name=\"toggle-high-contrast-theme\"\n />\n <Checkbox\n label=\"Line numbers\"\n isChecked={isLineNumbersVisible}\n onChange={(_event, checked) => toggleLineNumbers(checked)}\n aria-label=\"line numbers checkbox\"\n id=\"toggle-line-numbers\"\n name=\"toggle-line-numbers\"\n />\n <Checkbox\n label=\"Read only\"\n isChecked={isReadOnly}\n onChange={(_event, checked) => toggleReadOnly(checked)}\n aria-label=\"read only checkbox\"\n id=\"toggle-read-only\"\n name=\"toggle-read-only\"\n />\n <Checkbox\n label=\"Minimap\"\n isChecked={isMinimapVisible}\n onChange={(_event, checked) => toggleMinimap(checked)}\n aria-label=\"display minimap checkbox\"\n id=\"toggle-minimap\"\n name=\"toggle-minimap\"\n />\n <CodeEditor\n isDarkTheme={isDarkTheme}\n isHighContrastTheme={isHighContrastTheme}\n isLineNumbersVisible={isLineNumbersVisible}\n isReadOnly={isReadOnly}\n isMinimapVisible={isMinimapVisible}\n isLanguageLabelVisible\n code=\"Some example content\"\n onChange={onChange}\n language={Language.javascript}\n onEditorDidMount={onEditorDidMount}\n height=\"400px\"\n />\n </>\n );\n};\n","title":"Basic","lang":"ts","className":""}}>
|
|
598
|
+
|
|
599
|
+
</Example>,
|
|
600
|
+
'With sizeToFit height, height will grow/shrink with content': props =>
|
|
601
|
+
<Example {...pageData} {...props} {...{"code":"import { CodeEditor, Language } from '@patternfly/react-code-editor';\n\nexport const CodeEditorSizeToFit: React.FunctionComponent = () => {\n const onEditorDidMount = (editor, monaco) => {\n editor.layout();\n editor.focus();\n monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });\n };\n\n const onChange = (value) => {\n // eslint-disable-next-line no-console\n console.log(value);\n };\n\n return (\n <CodeEditor\n code=\"Some example content\"\n onChange={onChange}\n language={Language.javascript}\n onEditorDidMount={onEditorDidMount}\n height=\"sizeToFit\"\n />\n );\n};\n","title":"With sizeToFit height, height will grow/shrink with content","lang":"ts","className":""}}>
|
|
602
|
+
|
|
603
|
+
</Example>,
|
|
604
|
+
'With isFullHeight height, height will match the size of the parent': props =>
|
|
605
|
+
<Example {...pageData} {...props} {...{"code":"import { CodeEditor, Language } from '@patternfly/react-code-editor';\n\nexport const CodeEditorFullHeight: React.FunctionComponent = () => {\n const onEditorDidMount = (editor, monaco) => {\n editor.layout();\n editor.focus();\n monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });\n };\n\n const onChange = (value) => {\n // eslint-disable-next-line no-console\n console.log(value);\n };\n\n return (\n <div style={{ height: '400px' }}>\n <CodeEditor\n code=\"Some example content\"\n onChange={onChange}\n language={Language.javascript}\n onEditorDidMount={onEditorDidMount}\n isFullHeight\n />\n </div>\n );\n};\n","title":"With isFullHeight height, height will match the size of the parent","lang":"ts","className":""}}>
|
|
606
|
+
|
|
607
|
+
</Example>,
|
|
608
|
+
'With shortcut menu and main header content': props =>
|
|
609
|
+
<Example {...pageData} {...props} {...{"code":"import { Fragment, useState } from 'react';\nimport { CodeEditor, Language } from '@patternfly/react-code-editor';\nimport { Grid, GridItem, Label, Radio } from '@patternfly/react-core';\n\nexport const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {\n type ShortcutMode = 'PC' | 'Mac';\n\n const [currentShortcutMode, setCurrentShortcutMode] = useState<ShortcutMode>('PC');\n\n const onEditorDidMount = (editor, monaco) => {\n editor.layout();\n editor.focus();\n monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });\n };\n\n const onChange = (value: string) => {\n // eslint-disable-next-line no-console\n console.log(value);\n };\n\n const onShortcutModeChange = (event: React.FormEvent<HTMLInputElement>, checked: boolean) => {\n if (checked) {\n const newMode = event.currentTarget.value as ShortcutMode;\n setCurrentShortcutMode(newMode);\n }\n };\n\n const shortcuts = [\n {\n PC: ['Alt', 'F1'],\n Mac: ['Opt', 'F1'],\n description: 'Accessibility helps'\n },\n {\n PC: ['F1'],\n Mac: ['F1'],\n description: 'View all editor shortcuts'\n },\n {\n PC: ['Ctrl', 'Space'],\n Mac: ['Opt', 'Esc'],\n description: 'Activate auto complete'\n },\n {\n PC: ['Ctrl', 'S'],\n Mac: ['Cmd', 'S'],\n description: 'Save'\n }\n ];\n const shortcutsPopoverProps = {\n bodyContent: (\n <Grid span={6} hasGutter key=\"grid\">\n {shortcuts.map((shortcut, index) => (\n <Fragment key={index}>\n <GridItem style={{ textAlign: 'right', marginRight: '1em' }}>\n {shortcut[currentShortcutMode]\n .map((key) => (\n <Label variant=\"outline\" key={key}>\n {key}\n </Label>\n ))\n .reduce((prev, curr) => (\n <>{[prev, ' + ', curr]}</>\n ))}\n </GridItem>\n <GridItem>{shortcut.description}</GridItem>\n </Fragment>\n ))}\n </Grid>\n ),\n 'aria-label': 'Shortcuts'\n };\n\n return (\n <>\n <Radio\n checked={currentShortcutMode === 'PC'}\n onChange={onShortcutModeChange}\n label=\"PC shortcuts\"\n name=\"shortcut-radio\"\n id=\"pc-shortcuts\"\n value=\"PC\"\n />\n <Radio\n checked={currentShortcutMode === 'Mac'}\n onChange={onShortcutModeChange}\n label=\"Mac shortcuts\"\n name=\"shortcut-radio\"\n id=\"mac-shortcuts\"\n value=\"Mac\"\n />\n <CodeEditor\n headerMainContent=\"Header main content\"\n shortcutsPopoverProps={shortcutsPopoverProps}\n isLanguageLabelVisible\n code=\"Some example content\"\n onChange={onChange}\n language={Language.javascript}\n onEditorDidMount={onEditorDidMount}\n height=\"400px\"\n />\n </>\n );\n};\n","title":"With shortcut menu and main header content","lang":"ts","className":""}}>
|
|
610
|
+
|
|
611
|
+
<p {...{"className":"pf-v6-c-content--p pf-m-editorial ws-p "}}>
|
|
612
|
+
{`These examples below are the shortcuts that we recommend describing in the popover since they are monaco features.`}
|
|
613
|
+
</p>
|
|
614
|
+
</Example>,
|
|
615
|
+
'With actions': props =>
|
|
616
|
+
<Example {...pageData} {...props} {...{"code":"import { CodeEditor } from '@patternfly/react-code-editor';\n\nexport const CodeEditorWithActions: React.FunctionComponent = () => (\n <CodeEditor isUploadEnabled isDownloadEnabled isCopyEnabled isLanguageLabelVisible height=\"400px\" />\n);\n","title":"With actions","lang":"ts","className":""}}>
|
|
617
|
+
|
|
618
|
+
</Example>,
|
|
619
|
+
'With custom control': props =>
|
|
620
|
+
<Example {...pageData} {...props} {...{"code":"import { useState } from 'react';\nimport { CodeEditor, CodeEditorControl } from '@patternfly/react-code-editor';\nimport PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';\n\nexport const CodeEditorCustomControl: React.FunctionComponent = () => {\n const [code, setCode] = useState('Some example content');\n\n const onChange = (code) => {\n setCode(code);\n };\n\n const onExecuteCode = (code) => {\n // eslint-disable-next-line no-console\n console.log(code);\n };\n\n const customControl = (\n <CodeEditorControl\n icon={<PlayIcon />}\n aria-label=\"Execute code\"\n tooltipProps={{ content: 'Execute code' }}\n onClick={onExecuteCode}\n isVisible={code !== ''}\n />\n );\n\n return (\n <CodeEditor\n isDownloadEnabled\n isCopyEnabled\n height=\"400px\"\n customControls={customControl}\n code={code}\n onChange={onChange}\n isHeaderPlain={code === ''}\n />\n );\n};\n","title":"With custom control","lang":"ts","className":""}}>
|
|
621
|
+
|
|
622
|
+
</Example>,
|
|
623
|
+
'With configuration modal': props =>
|
|
624
|
+
<Example {...pageData} {...props} {...{"code":"import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon';\nimport MapIcon from '@patternfly/react-icons/dist/esm/icons/map-icon';\nimport RhUiDarkModeFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-dark-mode-fill-icon';\nimport HashtagIcon from '@patternfly/react-icons/dist/esm/icons/hashtag-icon';\nimport FontIcon from '@patternfly/react-icons/dist/esm/icons/font-icon';\nimport AdjustIcon from '@patternfly/react-icons/dist/esm/icons/adjust-icon';\nimport { CodeEditor, CodeEditorControl } from '@patternfly/react-code-editor';\nimport {\n Flex,\n FlexItem,\n Icon,\n Modal,\n ModalBody,\n ModalHeader,\n NumberInput,\n Switch,\n SwitchProps\n} from '@patternfly/react-core';\nimport { useState } from 'react';\n\ninterface ConfigModalItemProps {\n /** Icon rendered inside the configuration modal. */\n icon?: React.ReactNode;\n /** Description of the configuration option. */\n description: string;\n /** Title of the configuration option. We assume that titles are unique. */\n title: string;\n /**\n * Optional ID of the configuration option. Also used as a prefix for the following elements:\n * - `${id}-title` for the element which contains the title\n * - `${id}-description` for the element which contains the description\n */\n id?: string;\n /**\n * Slot to render inside the configuration modal. Remember to add `aria-labelledby` and `aria-describedby` props\n * to the control inside the slot, pointing to the title and description ids respectively.\n */\n slot?: React.ReactNode;\n}\n\nconst ConfigModalItem: React.FunctionComponent<ConfigModalItemProps> = ({\n icon = <RhUiSettingsFillIcon />,\n description,\n title,\n id = `ConfigModalItem-${title.replace(/\\s+/g, '-').toLowerCase()}`,\n slot\n}) => (\n <Flex\n alignItems={{ default: 'alignItemsCenter' }}\n justifyContent={{ default: 'justifyContentSpaceBetween' }}\n spaceItems={{ default: 'spaceItemsMd' }}\n id={id}\n >\n <FlexItem flex={{ default: 'flex_1' }}>\n <Flex spaceItems={{ default: 'spaceItemsSm' }}>\n <Icon isInline>{icon}</Icon>\n <strong id={`${id}-title`} className=\"pf-v6-u-font-weight-bold\">\n {title}\n </strong>\n </Flex>\n\n <div id={`${id}-description`}>{description}</div>\n </FlexItem>\n <FlexItem alignSelf={{ default: 'alignSelfCenter' }}>{slot}</FlexItem>\n </Flex>\n);\n\ninterface ConfigModalSwitchProps extends Omit<ConfigModalItemProps, 'slot'> {\n /** Flag indicating whether the option is enabled or disabled. */\n isChecked?: SwitchProps['isChecked'];\n /** onChange handler for the switch. */\n onChange?: SwitchProps['onChange'];\n /** Labels for the enabled and disabled states of the switch. */\n labels?: {\n enabled: string;\n disabled: string;\n };\n}\n\nconst ConfigModalSwitch: React.FunctionComponent<ConfigModalSwitchProps> = ({\n icon = <RhUiSettingsFillIcon />,\n description,\n title,\n id = `ConfigModalSwitch-${title.replace(/\\s+/g, '-').toLowerCase()}`,\n isChecked = false,\n onChange,\n labels = { enabled: undefined, disabled: undefined }\n}) => (\n <ConfigModalItem\n icon={icon}\n description={description}\n title={title}\n id={id}\n slot={\n <Switch\n aria-labelledby={`${id}-title`}\n aria-describedby={`${id}-description`}\n ouiaId={`${id}-switch`}\n isChecked={isChecked}\n isReversed\n label={isChecked ? labels.enabled : labels.disabled}\n onChange={onChange}\n />\n }\n />\n);\n\ninterface ConfigModalControlProps {\n /** Controls to be rendered inside the configuration modal. */\n children: React.ReactNode;\n /** Title of the configuration modal. */\n title?: string;\n /** Description of the configuration modal. */\n description?: string;\n /** Optional ID of the configuration modal. Also used as a prefix for the ids of inner elements and the OUIA id. */\n ouiaId?: string;\n}\n\nconst ConfigModalControl: React.FunctionComponent<ConfigModalControlProps> = ({\n children,\n title = 'Editor settings',\n description = 'Changes apply immediately',\n ouiaId = 'CodeEditorConfigurationModal'\n}: ConfigModalControlProps) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n return (\n <>\n <Modal\n aria-describedby={`${ouiaId}-body`}\n aria-labelledby={`${ouiaId}-title`}\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n ouiaId={ouiaId}\n variant=\"small\"\n >\n <ModalHeader title={title} description={description} labelId={`${ouiaId}-title`} />\n <ModalBody id={`${ouiaId}-body`}>\n <Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsMd' }}>\n {children}\n </Flex>\n </ModalBody>\n </Modal>\n <CodeEditorControl\n aria-label={title}\n aria-haspopup=\"dialog\"\n isSettings\n onClick={() => setIsModalOpen(true)}\n tooltipProps={{ content: title, ariaLive: 'off' }}\n />\n </>\n );\n};\n\nexport const CodeEditorConfigurationModal: React.FunctionComponent = () => {\n const [code, setCode] = useState('Some example content');\n\n const [isMinimapVisible, setIsMinimapVisible] = useState(true);\n const [isDarkTheme, setIsDarkTheme] = useState(false);\n const [isHighContrastTheme, setIsHighContrastTheme] = useState(false);\n const [isLineNumbersVisible, setIsLineNumbersVisible] = useState(true);\n const [fontSize, setFontSize] = useState(14);\n\n const onChange = (code: string) => {\n setCode(code);\n };\n\n const customControl = (\n <ConfigModalControl>\n <ConfigModalSwitch\n key=\"minimap-switch\"\n title=\"Minimap\"\n description=\"Show a preview of the full code on the side of the editor\"\n isChecked={isMinimapVisible}\n onChange={(_e, checked) => setIsMinimapVisible(checked)}\n icon={<MapIcon />}\n />\n <ConfigModalSwitch\n key=\"dark-theme-switch\"\n title=\"Dark theme\"\n description=\"Switch the editor to a dark color theme\"\n isChecked={isDarkTheme}\n onChange={(_e, checked) => setIsDarkTheme(checked)}\n icon={<RhUiDarkModeFillIcon />}\n />\n <ConfigModalSwitch\n key=\"high-contrast-theme-switch\"\n title=\"High contrast theme\"\n description=\"Switch the editor to a high contrast color theme\"\n isChecked={isHighContrastTheme}\n onChange={(_e, checked) => setIsHighContrastTheme(checked)}\n icon={<AdjustIcon />}\n />\n <ConfigModalSwitch\n key=\"line-numbers-switch\"\n title=\"Line numbers\"\n description=\"Show line numbers to the left of each line of code\"\n isChecked={isLineNumbersVisible}\n onChange={(_e, checked) => setIsLineNumbersVisible(checked)}\n icon={<HashtagIcon />}\n />\n <ConfigModalItem\n key=\"font-size\"\n title=\"Font size\"\n description=\"Adjust the font size of the code editor\"\n ouia-id=\"ConfigModalItem-font-size\"\n icon={<FontIcon />}\n slot={\n <NumberInput\n aria-labelledby=\"ConfigModalItem-font-size-title\"\n aria-describedby=\"ConfigModalItem-font-size-description\"\n inputAriaLabel=\"Enter a font size\"\n minusBtnAriaLabel=\"Decrease font size\"\n plusBtnAriaLabel=\"Increase font size\"\n role=\"group\" // For screen readers to group the input and buttons as one widget\n value={fontSize}\n min={5}\n onMinus={() => setFontSize((size) => Math.max(5, size - 1))}\n onChange={(event) => setFontSize(Number((event.target as HTMLInputElement).value))}\n onPlus={() => setFontSize((size) => size + 1)}\n widthChars={2}\n />\n }\n />\n </ConfigModalControl>\n );\n\n return (\n <CodeEditor\n code={code}\n customControls={customControl}\n height=\"400px\"\n isDarkTheme={isDarkTheme}\n isHighContrastTheme={isHighContrastTheme}\n isLineNumbersVisible={isLineNumbersVisible}\n isMinimapVisible={isMinimapVisible}\n onChange={onChange}\n options={{ fontSize }}\n />\n );\n};\n","title":"With configuration modal","lang":"ts","className":""}}>
|
|
625
|
+
|
|
626
|
+
</Example>
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
const Component = () => (
|
|
630
|
+
<React.Fragment>
|
|
631
|
+
<p {...{"className":"pf-v6-c-content--p pf-m-editorial ws-p "}}>
|
|
632
|
+
{`Note: Code editor lives in its own package at `}
|
|
633
|
+
<PatternflyThemeLink {...{"to":"https://www.npmjs.com/package/@patternfly/react-code-editor","className":""}}>
|
|
634
|
+
{`@patternfly/react-code-editor`}
|
|
635
|
+
</PatternflyThemeLink>
|
|
636
|
+
{` and has `}
|
|
637
|
+
<PatternflyThemeLink {...{"to":"https://github.com/patternfly/patternfly-react/blob/main/packages/react-code-editor/package.json","className":""}}>
|
|
638
|
+
<strong {...{"className":""}}>
|
|
639
|
+
{`required peer deps`}
|
|
640
|
+
</strong>
|
|
641
|
+
</PatternflyThemeLink>
|
|
642
|
+
{`.`}
|
|
643
|
+
</p>
|
|
644
|
+
<AutoLinkHeader {...{"id":"examples","headingLevel":"h2","className":"ws-title ws-h2"}}>
|
|
645
|
+
{`Examples`}
|
|
646
|
+
</AutoLinkHeader>
|
|
647
|
+
{React.createElement(pageData.examples["Basic"])}
|
|
648
|
+
{React.createElement(pageData.examples["With sizeToFit height, height will grow/shrink with content"])}
|
|
649
|
+
{React.createElement(pageData.examples["With isFullHeight height, height will match the size of the parent"])}
|
|
650
|
+
{React.createElement(pageData.examples["With shortcut menu and main header content"])}
|
|
651
|
+
{React.createElement(pageData.examples["With actions"])}
|
|
652
|
+
{React.createElement(pageData.examples["With custom control"])}
|
|
653
|
+
{React.createElement(pageData.examples["With configuration modal"])}
|
|
654
|
+
</React.Fragment>
|
|
655
|
+
);
|
|
656
|
+
Component.displayName = 'ComponentsCodeEditorReactDocs';
|
|
657
|
+
Component.pageData = pageData;
|
|
658
|
+
|
|
659
|
+
export default Component;
|