Skip to content

Commit b379001

Browse files
Merge pull request #1802 from payloadcms/chore/code-field-props
chore: moves editorProps into admin property for code and json field types
2 parents fe1dfa3 + d97c9fd commit b379001

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

docs/fields/code.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ This field uses the `monaco-react` editor syntax highlighting.
3333
| **`required`** | Require this field to have a value. |
3434
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
3535

36-
*\* An asterisk denotes that a property is required.*
36+
_\* An asterisk denotes that a property is required._
3737

38-
### Admin config
38+
### Admin Config
3939

40-
In addition to the default [field admin config](/docs/fields/overview#admin-config), the Code field type also allows for the customization of a `language` property.
40+
In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following properties:
4141

42-
The [monaco-react](https://github.com/suren-atoyan/monaco-react) editor supports all of the languages supported by the [monaco-editor](https://github.com/microsoft/monaco-editor). The `language` property can be set to any of the languages listed [here](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages).
42+
| Option | Description |
43+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
44+
| **`language`** | This property can be set to any language listed [here](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages). |
45+
| **`editorOptions`** | Options that can be passed to the monaco editor, [view the full list](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IDiffEditorConstructionOptions.html). |
4346

4447
### Example
4548

docs/fields/json.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,17 @@ This field uses the `monaco-react` editor syntax highlighting.
2929
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
3030
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
3131
| **`required`** | Require this field to have a value. |
32-
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
32+
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
3333

34-
*\* An asterisk denotes that a property is required.*
34+
_\* An asterisk denotes that a property is required._
35+
36+
### Admin Config
37+
38+
In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following properties:
39+
40+
| Option | Description |
41+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42+
| **`editorOptions`** | Options that can be passed to the monaco editor, [view the full list](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IDiffEditorConstructionOptions.html). |
3543

3644
### Example
3745

src/admin/components/forms/field-types/Code/Code.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const Code: React.FC<Props> = (props) => {
3232
language,
3333
description,
3434
condition,
35+
editorOptions,
3536
} = {},
3637
label,
37-
editorOptions,
3838
} = props;
3939

4040
const path = pathFromProps || name;

src/admin/components/forms/field-types/JSON/JSON.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ const JSONField: React.FC<Props> = (props) => {
2626
width,
2727
description,
2828
condition,
29+
editorOptions,
2930
} = {},
3031
label,
31-
editorOptions,
3232
} = props;
3333

3434
const path = pathFromProps || name;

src/fields/config/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,23 @@ export type UploadField = FieldBase & {
251251

252252
type CodeAdmin = Admin & {
253253
language?: string;
254+
editorOptions?: EditorProps['options'];
254255
}
255256

256257
export type CodeField = Omit<FieldBase, 'admin'> & {
257258
admin?: CodeAdmin
258259
minLength?: number
259260
maxLength?: number
260261
type: 'code';
262+
}
263+
264+
type JSONAdmin = Admin & {
261265
editorOptions?: EditorProps['options'];
262266
}
263267

264268
export type JSONField = Omit<FieldBase, 'admin'> & {
265-
admin?: Admin
269+
admin?: JSONAdmin
266270
type: 'json';
267-
editorOptions?: EditorProps['options'];
268271
}
269272

270273
export type SelectField = FieldBase & {

0 commit comments

Comments
 (0)