payload 1.0.34 → 1.1.0
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/.eslintrc.js +1 -0
- package/components/elements.ts +1 -1
- package/components/index.js +2 -2
- package/dist/admin/components/elements/DeleteDocument/index.js +6 -6
- package/dist/admin/components/elements/DuplicateDocument/index.js +4 -4
- package/dist/admin/components/elements/GenerateConfirmation/index.js +7 -5
- package/dist/admin/components/elements/ListControls/index.js +3 -2
- package/dist/admin/components/elements/Nav/index.js +43 -24
- package/dist/admin/components/elements/Nav/index.scss +22 -26
- package/dist/admin/components/elements/NavGroup/index.d.ts +8 -0
- package/dist/admin/components/elements/NavGroup/index.js +52 -0
- package/dist/admin/components/elements/NavGroup/index.scss +53 -0
- package/dist/admin/components/elements/Popup/index.js +14 -13
- package/dist/admin/components/elements/SearchFilter/index.js +45 -16
- package/dist/admin/components/elements/SearchFilter/types.d.ts +2 -0
- package/dist/admin/components/elements/Status/index.js +14 -9
- package/dist/admin/components/elements/WhereBuilder/index.js +14 -1
- package/dist/admin/components/forms/Error/index.scss +2 -1
- package/dist/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.js +3 -3
- package/dist/admin/components/forms/Label/index.scss +3 -1
- package/dist/admin/components/forms/field-types/Array/index.js +14 -9
- package/dist/admin/components/forms/field-types/Blocks/index.js +12 -7
- package/dist/admin/components/forms/field-types/Collapsible/index.js +7 -7
- package/dist/admin/components/forms/field-types/RichText/RichText.d.ts +2 -2
- package/dist/admin/components/forms/field-types/RichText/RichText.js +3 -6
- package/dist/admin/components/forms/field-types/RichText/elements/indent/index.js +0 -3
- package/dist/admin/components/forms/field-types/RichText/elements/index.d.ts +6 -3
- package/dist/admin/components/forms/field-types/RichText/elements/link/Button.d.ts +4 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Button.js +105 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Element.d.ts +9 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Element.js +120 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/baseFields.d.ts +3 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/baseFields.js +56 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/index.d.ts +4 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/index.js +22 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/index.scss +29 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/types.d.ts +9 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/types.js +1 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/index.d.ts +6 -5
- package/dist/admin/components/forms/field-types/RichText/elements/link/index.js +4 -67
- package/dist/admin/components/forms/field-types/RichText/elements/link/index.scss +36 -63
- package/dist/admin/components/forms/field-types/RichText/elements/link/shared.d.ts +1 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/shared.js +1 -0
- package/dist/admin/components/forms/field-types/RichText/elements/link/utilities.d.ts +1 -1
- package/dist/admin/components/forms/field-types/RichText/elements/link/utilities.js +13 -23
- package/dist/admin/components/forms/field-types/RichText/elements/relationship/Button/index.js +6 -10
- package/dist/admin/components/forms/field-types/RichText/elements/toggle.js +0 -3
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Button/index.js +8 -12
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/EditModal/index.js +2 -3
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/index.js +6 -6
- package/dist/admin/components/forms/field-types/RichText/types.d.ts +0 -4
- package/dist/admin/components/forms/field-types/Tabs/index.js +4 -4
- package/dist/admin/components/forms/field-types/Text/Input.d.ts +2 -0
- package/dist/admin/components/forms/field-types/Text/Input.js +2 -3
- package/dist/admin/components/forms/field-types/Text/index.js +2 -2
- package/dist/admin/components/forms/field-types/Text/types.d.ts +3 -0
- package/dist/admin/components/forms/field-types/Upload/Add/index.js +4 -4
- package/dist/admin/components/forms/field-types/Upload/Input.js +3 -3
- package/dist/admin/components/forms/field-types/Upload/SelectExisting/index.js +6 -6
- package/dist/admin/components/forms/field-types/rowReducer.d.ts +1 -0
- package/dist/admin/components/forms/field-types/rowReducer.js +2 -2
- package/dist/admin/components/graphics/Account/Gravatar.d.ts +3 -0
- package/dist/admin/components/graphics/Account/Gravatar.js +15 -0
- package/dist/admin/components/graphics/Account/index.d.ts +2 -2
- package/dist/admin/components/graphics/Account/index.js +24 -1
- package/dist/admin/components/modals/StayLoggedIn/index.js +4 -3
- package/dist/admin/components/utilities/Auth/index.js +1 -1
- package/dist/admin/components/views/Account/index.js +1 -1
- package/dist/admin/components/views/Dashboard/Default.js +44 -12
- package/dist/admin/components/views/Dashboard/index.scss +1 -1
- package/dist/admin/components/views/Version/Restore/index.js +3 -3
- package/dist/admin/components/views/collections/List/RelationshipProvider/index.js +1 -1
- package/dist/admin/components/views/collections/List/getInitialColumns.js +2 -2
- package/dist/admin/hooks/useThrottledEffect.js +15 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/scss/vars.scss +2 -2
- package/dist/admin/utilities/groupNavItems.d.ts +19 -0
- package/dist/admin/utilities/groupNavItems.js +36 -0
- package/dist/auth/types.d.ts +1 -1
- package/dist/bin/generateTypes.js +20 -4
- package/dist/collections/config/schema.js +18 -2
- package/dist/collections/config/types.d.ts +9 -0
- package/dist/collections/operations/create.js +3 -1
- package/dist/collections/operations/local/create.d.ts +2 -2
- package/dist/collections/operations/local/create.js +3 -3
- package/dist/collections/operations/local/update.js +2 -2
- package/dist/collections/operations/restoreVersion.js +11 -1
- package/dist/collections/operations/update.js +3 -1
- package/dist/config/defaults.js +2 -1
- package/dist/config/schema.js +3 -1
- package/dist/config/types.d.ts +1 -0
- package/dist/fields/config/schema.js +14 -6
- package/dist/fields/config/types.d.ts +45 -9
- package/dist/fields/config/types.js +10 -2
- package/dist/fields/hooks/afterChange/index.d.ts +2 -1
- package/dist/fields/hooks/afterChange/index.js +4 -2
- package/dist/fields/hooks/afterChange/promise.d.ts +5 -3
- package/dist/fields/hooks/afterChange/promise.js +49 -18
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +5 -3
- package/dist/fields/hooks/afterChange/traverseFields.js +4 -2
- package/dist/fields/hooks/afterRead/promise.d.ts +2 -2
- package/dist/fields/hooks/afterRead/promise.js +50 -22
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/promise.js +51 -20
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/promise.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/promise.js +35 -15
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +2 -2
- package/dist/fields/richText/recurseNestedFields.js +3 -3
- package/dist/fields/richText/{relationshipPromise.d.ts → richTextRelationshipPromise.d.ts} +0 -0
- package/dist/fields/richText/richTextRelationshipPromise.js +104 -0
- package/dist/globals/config/schema.js +2 -1
- package/dist/globals/config/types.d.ts +2 -0
- package/dist/globals/operations/restoreVersion.js +10 -1
- package/dist/globals/operations/update.js +4 -1
- package/dist/graphql/schema/buildMutationInputType.js +27 -13
- package/dist/graphql/schema/buildObjectType.js +18 -3
- package/dist/graphql/schema/withNullableType.d.ts +2 -2
- package/dist/graphql/schema/withNullableType.js +1 -1
- package/dist/mongoose/buildQuery.js +4 -2
- package/dist/mongoose/buildSchema.js +25 -14
- package/dist/types/index.d.ts +1 -1
- package/dist/uploads/getBaseFields.js +3 -3
- package/dist/uploads/getFileByPath.d.ts +1 -1
- package/dist/uploads/getFileByPath.js +5 -5
- package/dist/uploads/getSafeFilename.js +3 -4
- package/dist/uploads/imageResizer.d.ts +1 -9
- package/dist/uploads/imageResizer.js +18 -18
- package/dist/uploads/types.d.ts +18 -3
- package/dist/uploads/uploadFile.js +29 -8
- package/dist/utilities/flattenTopLevelFields.js +2 -2
- package/dist/utilities/groupOrTabHasRequiredSubfield.d.ts +2 -0
- package/dist/utilities/groupOrTabHasRequiredSubfield.js +17 -0
- package/dist/utilities/logger.js +2 -3
- package/dist/utilities/wordBoundariesRegex.js +2 -2
- package/docs/admin/overview.mdx +2 -1
- package/docs/configuration/collections.mdx +14 -1
- package/docs/fields/array.mdx +10 -1
- package/docs/fields/blocks.mdx +9 -1
- package/docs/fields/collapsible.mdx +13 -5
- package/docs/fields/rich-text.mdx +7 -0
- package/docs/fields/tabs.mdx +4 -2
- package/docs/hooks/collections.mdx +3 -2
- package/docs/hooks/fields.mdx +11 -9
- package/docs/hooks/globals.mdx +1 -0
- package/docs/upload/overview.mdx +5 -3
- package/package.json +4 -4
- package/CHANGELOG.md +0 -1870
- package/dist/fields/richText/relationshipPromise.js +0 -71
|
@@ -61,6 +61,7 @@ You can customize the way that the Admin panel behaves on a collection-by-collec
|
|
|
61
61
|
|
|
62
62
|
| Option | Description |
|
|
63
63
|
| ---------------------------- | -------------|
|
|
64
|
+
| `group` | Text used as a label for grouping collection links together in the navigation. |
|
|
64
65
|
| `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin panel. If no field is defined, the ID of the document is used as the title. |
|
|
65
66
|
| `description` | Text or React component to display below the Collection label in the List view to give editors more information. |
|
|
66
67
|
| `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
|
|
@@ -68,6 +69,7 @@ You can customize the way that the Admin panel behaves on a collection-by-collec
|
|
|
68
69
|
| `enableRichTextRelationship` | The [Rich Text](/docs/fields/rich-text) field features a `Relationship` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. |
|
|
69
70
|
| `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
|
|
70
71
|
| `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
|
|
72
|
+
| `listSearchableFields ` | Specify which fields should be searched in the List search view. [More](/docs/configuration/collections#list-searchable-fields) |
|
|
71
73
|
|
|
72
74
|
### Preview
|
|
73
75
|
|
|
@@ -78,7 +80,7 @@ If the function is specified, a Preview button will automatically appear in the
|
|
|
78
80
|
**The preview function accepts two arguments:**
|
|
79
81
|
|
|
80
82
|
1. The document being edited
|
|
81
|
-
1. An `options` object, containing `locale` and `token` properties. The `token` is the currently logged
|
|
83
|
+
1. An `options` object, containing `locale` and `token` properties. The `token` is the currently logged-in user's JWT.
|
|
82
84
|
|
|
83
85
|
**Example collection with preview function:**
|
|
84
86
|
|
|
@@ -118,6 +120,17 @@ Hooks are a powerful way to extend collection functionality and execute your own
|
|
|
118
120
|
|
|
119
121
|
Collections support all field types that Payload has to offer—including simple fields like text and checkboxes all the way to more complicated layout-building field groups like Blocks. [Click here](/docs/fields/overview) to learn more about field types.
|
|
120
122
|
|
|
123
|
+
#### List Searchable Fields
|
|
124
|
+
|
|
125
|
+
In the List view, there is a "search" box that allows you to quickly find a document with a search. By default, it searches on the ID field. If you have `admin.useAsTitle` defined, the list search will use that field. However, you can define more than one field to search to make it easier on your admin editors to find the data they need.
|
|
126
|
+
|
|
127
|
+
For example, let's say you have a Posts collection with `title`, `metaDescription`, and `tags` fields - and you want all three of those fields to be searchable in the List view. You can simply add `admin.listSearchableFields: ['title', 'metaDescription', 'tags']` - and the admin UI will automatically search on those three fields plus the ID field.
|
|
128
|
+
|
|
129
|
+
<Banner type="warning">
|
|
130
|
+
<strong>Note:</strong><br/>
|
|
131
|
+
If you are adding <strong>listSearchableFields</strong>, make sure you index each of these fields so your admin queries can remain performant.
|
|
132
|
+
</Banner>
|
|
133
|
+
|
|
121
134
|
### TypeScript
|
|
122
135
|
|
|
123
136
|
You can import collection types as follows:
|
package/docs/fields/array.mdx
CHANGED
|
@@ -35,10 +35,19 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
|
|
|
35
35
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Array will be kept, so there is no need to specify each nested field as `localized`. |
|
|
36
36
|
| **`required`** | Require this field to have a value. |
|
|
37
37
|
| **`labels`** | Customize the row labels appearing in the Admin dashboard. |
|
|
38
|
-
| **`admin`**
|
|
38
|
+
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
39
39
|
|
|
40
40
|
*\* An asterisk denotes that a property is required.*
|
|
41
41
|
|
|
42
|
+
### Admin Config
|
|
43
|
+
|
|
44
|
+
In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following properties:
|
|
45
|
+
|
|
46
|
+
| Option | Description |
|
|
47
|
+
| ---------------------- | ------------------------------- |
|
|
48
|
+
| **`initCollapsed`** | Set the initial collapsed state |
|
|
49
|
+
|
|
50
|
+
|
|
42
51
|
### Example
|
|
43
52
|
|
|
44
53
|
`collections/ExampleCollection.ts`
|
package/docs/fields/blocks.mdx
CHANGED
|
@@ -36,10 +36,18 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme
|
|
|
36
36
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. || **`required`** | Require this field to have a value. |
|
|
37
37
|
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
|
|
38
38
|
| **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
|
|
39
|
-
| **`admin`**
|
|
39
|
+
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
40
40
|
|
|
41
41
|
*\* An asterisk denotes that a property is required.*
|
|
42
42
|
|
|
43
|
+
### Admin Config
|
|
44
|
+
|
|
45
|
+
In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following properties:
|
|
46
|
+
|
|
47
|
+
| Option | Description |
|
|
48
|
+
| ---------------------- | ------------------------------- |
|
|
49
|
+
| **`initCollapsed`** | Set the initial collapsed state |
|
|
50
|
+
|
|
43
51
|
### Block configs
|
|
44
52
|
|
|
45
53
|
Blocks are defined as separate configs of their own.
|
|
@@ -12,14 +12,22 @@ keywords: row, fields, config, configuration, documentation, Content Management
|
|
|
12
12
|
|
|
13
13
|
### Config
|
|
14
14
|
|
|
15
|
-
| Option
|
|
16
|
-
|
|
|
17
|
-
| **`label`** *
|
|
18
|
-
| **`fields`** *
|
|
19
|
-
| **`admin`**
|
|
15
|
+
| Option | Description |
|
|
16
|
+
| -------------- | ------------------------------------------------------------------------- |
|
|
17
|
+
| **`label`** * | A label to render within the header of the collapsible component. |
|
|
18
|
+
| **`fields`** * | Array of field types to nest within this Collapsible. |
|
|
19
|
+
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
20
20
|
|
|
21
21
|
*\* An asterisk denotes that a property is required.*
|
|
22
22
|
|
|
23
|
+
### Admin Config
|
|
24
|
+
|
|
25
|
+
In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following properties:
|
|
26
|
+
|
|
27
|
+
| Option | Description |
|
|
28
|
+
| ---------------------- | ------------------------------- |
|
|
29
|
+
| **`initCollapsed`** | Set the initial collapsed state |
|
|
30
|
+
|
|
23
31
|
### Example
|
|
24
32
|
|
|
25
33
|
`collections/ExampleCollection.ts`
|
|
@@ -77,6 +77,13 @@ The default `leaves` available in Payload are:
|
|
|
77
77
|
|
|
78
78
|
Set this property to `true` to hide this field's gutter within the admin panel. The field gutter is rendered as a vertical line and padding, but often if this field is nested within a Group, Block, or Array, you may want to hide the gutter.
|
|
79
79
|
|
|
80
|
+
**`link.fields`**
|
|
81
|
+
|
|
82
|
+
This allows [fields](/docs/fields/overview) to be saved as extra fields on a link inside the Rich Text Editor. When this is present, the fields will render inside a modal that can be opened by clicking the "edit" button on the link element.
|
|
83
|
+
|
|
84
|
+

|
|
85
|
+
*RichText link with custom fields*
|
|
86
|
+
|
|
80
87
|
**`upload.collections[collection-name].fields`**
|
|
81
88
|
|
|
82
89
|
This allows [fields](/docs/fields/overview) to be saved as meta data on an upload field inside the Rich Text Editor. When this is present, the fields will render inside a modal that can be opened by clicking the "edit" button on the upload element.
|
package/docs/fields/tabs.mdx
CHANGED
|
@@ -7,7 +7,7 @@ keywords: tabs, fields, config, configuration, documentation, Content Management
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
<Banner >
|
|
10
|
-
The Tabs field is presentational-only and only affects the Admin panel. By using it, you can place fields within a nice layout component that separates certain sub-fields by a tabbed interface.
|
|
10
|
+
The Tabs field is presentational-only and only affects the Admin panel (unless a tab is named). By using it, you can place fields within a nice layout component that separates certain sub-fields by a tabbed interface.
|
|
11
11
|
</Banner>
|
|
12
12
|
|
|
13
13
|

|
|
@@ -26,6 +26,7 @@ Each tab has its own required `label` and `fields` array. You can also optionall
|
|
|
26
26
|
|
|
27
27
|
| Option | Description |
|
|
28
28
|
| ----------------- | ----------- |
|
|
29
|
+
| **`name`** | An optional property name to be used when stored and retrieved from the database, similar to a [Group](/docs/fields/group). |
|
|
29
30
|
| **`label`** * | The label to render on the tab itself. |
|
|
30
31
|
| **`fields`** * | The fields to render within this tab. |
|
|
31
32
|
| **`description`** | Optionally render a description within this tab to describe the contents of the tab itself. |
|
|
@@ -56,10 +57,11 @@ const ExampleCollection: CollectionConfig = {
|
|
|
56
57
|
],
|
|
57
58
|
},
|
|
58
59
|
{
|
|
60
|
+
name: 'tabTwo',
|
|
59
61
|
label: 'Tab Two Label', // required
|
|
60
62
|
fields: [ // required
|
|
61
63
|
{
|
|
62
|
-
name: 'numberField',
|
|
64
|
+
name: 'numberField', // accessible via tabTwo.numberField
|
|
63
65
|
type: 'number',
|
|
64
66
|
required: true,
|
|
65
67
|
},
|
|
@@ -38,7 +38,7 @@ const ExampleHooks: CollectionConfig = {
|
|
|
38
38
|
slug: 'example-hooks',
|
|
39
39
|
fields: [
|
|
40
40
|
{ name: 'name', type: 'text'},
|
|
41
|
-
]
|
|
41
|
+
],
|
|
42
42
|
hooks: {
|
|
43
43
|
beforeOperation: [(args) => {...}],
|
|
44
44
|
beforeValidate: [(args) => {...}],
|
|
@@ -56,7 +56,7 @@ const ExampleHooks: CollectionConfig = {
|
|
|
56
56
|
afterRefresh: [(args) => {...}],
|
|
57
57
|
afterMe: [(args) => {...}],
|
|
58
58
|
afterForgotPassword: [(args) => {...}],
|
|
59
|
-
}
|
|
59
|
+
},
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
@@ -121,6 +121,7 @@ import { CollectionAfterChangeHook } from 'payload/types';
|
|
|
121
121
|
const afterChangeHook: CollectionAfterChangeHook = async ({
|
|
122
122
|
doc, // full document data
|
|
123
123
|
req, // full express request
|
|
124
|
+
previousDoc, // document data before updating the collection
|
|
124
125
|
operation, // name of the operation ie. 'create', 'update'
|
|
125
126
|
}) => {
|
|
126
127
|
return doc;
|
package/docs/hooks/fields.mdx
CHANGED
|
@@ -56,15 +56,17 @@ All field-level hooks are formatted to accept the same arguments, although some
|
|
|
56
56
|
|
|
57
57
|
Field Hooks receive one `args` argument that contains the following properties:
|
|
58
58
|
|
|
59
|
-
| Option
|
|
60
|
-
|
|
61
|
-
| **`data`**
|
|
62
|
-
| **`
|
|
63
|
-
| **`
|
|
64
|
-
| **`
|
|
65
|
-
| **`
|
|
66
|
-
| **`
|
|
67
|
-
| **`
|
|
59
|
+
| Option | Description |
|
|
60
|
+
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
61
|
+
| **`data`** | The data passed to update the document within `create` and `update` operations, and the full document itself in the `afterRead` hook. |
|
|
62
|
+
| **`siblingData`** | The sibling data passed to a field that the hook is running against. |
|
|
63
|
+
| **`findMany`** | Boolean to denote if this hook is running against finding one, or finding many within the `afterRead` hook. |
|
|
64
|
+
| **`operation`** | A string relating to which operation the field type is currently executing within. Useful within `beforeValidate`, `beforeChange`, and `afterChange` hooks to differentiate between `create` and `update` operations. |
|
|
65
|
+
| **`originalDoc`** | The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. |
|
|
66
|
+
| **`previousDoc`** | The document before changes were applied, only in `afterChange` hooks. |
|
|
67
|
+
| **`previousSiblingDoc`** | The sibling data from the previous document in `afterChange` hook. |
|
|
68
|
+
| **`req`** | The Express `request` object. It is mocked for Local API operations. |
|
|
69
|
+
| **`value`** | The value of the field. |
|
|
68
70
|
|
|
69
71
|
#### Return value
|
|
70
72
|
|
package/docs/hooks/globals.mdx
CHANGED
|
@@ -78,6 +78,7 @@ import { GlobalAfterChangeHook } from 'payload/types'
|
|
|
78
78
|
|
|
79
79
|
const afterChangeHook: GlobalAfterChangeHook = async ({
|
|
80
80
|
doc, // full document data
|
|
81
|
+
previousDoc, // document data before updating the collection
|
|
81
82
|
req, // full express request
|
|
82
83
|
}) => {
|
|
83
84
|
return data;
|
package/docs/upload/overview.mdx
CHANGED
|
@@ -45,6 +45,8 @@ Every Payload Collection can opt-in to supporting Uploads by specifying the `upl
|
|
|
45
45
|
| **`staticURL`** \* | The base URL path to use to access your uploads. Example: `/media` |
|
|
46
46
|
| **`staticDir`** \* | The folder directory to use to store media in. Can be either an absolute path or relative to the directory that contains your config. |
|
|
47
47
|
| **`imageSizes`** | If specified, image uploads will be automatically resized in accordance to these image sizes. [More](#image-sizes) |
|
|
48
|
+
| **`formatOptions`** | An object with `format` and `options` that are used with the Sharp image library to format the upload file. [More](https://sharp.pixelplumbing.com/api-output#toformat) |
|
|
49
|
+
| **`resizeOptions`** | An object passed to the the Sharp image library to resize the uploaded file. [More](https://sharp.pixelplumbing.com/api-resize) |
|
|
48
50
|
| **`adminThumbnail`** | Set the way that the Admin panel will display thumbnails for this Collection. [More](#admin-thumbnails) |
|
|
49
51
|
| **`mimeTypes`** | Restrict mimeTypes in the file picker. Array of valid mimetypes or mimetype wildcards [More](#mimetypes) |
|
|
50
52
|
| **`disableLocalStorage`** | Completely disable uploading files to disk locally. [More](#disabling-local-upload-storage) |
|
|
@@ -68,13 +70,13 @@ const Media: CollectionConfig = {
|
|
|
68
70
|
name: 'thumbnail',
|
|
69
71
|
width: 400,
|
|
70
72
|
height: 300,
|
|
71
|
-
|
|
73
|
+
position: 'centre',
|
|
72
74
|
},
|
|
73
75
|
{
|
|
74
76
|
name: 'card',
|
|
75
77
|
width: 768,
|
|
76
78
|
height: 1024,
|
|
77
|
-
|
|
79
|
+
position: 'centre',
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
82
|
name: 'tablet',
|
|
@@ -84,7 +86,7 @@ const Media: CollectionConfig = {
|
|
|
84
86
|
// but it will retain its original aspect ratio
|
|
85
87
|
// and calculate a height automatically.
|
|
86
88
|
height: null,
|
|
87
|
-
|
|
89
|
+
position: 'centre',
|
|
88
90
|
},
|
|
89
91
|
],
|
|
90
92
|
adminThumbnail: 'thumbnail',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Node, React and MongoDB Headless CMS and Application Framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@babel/preset-typescript": "^7.12.1",
|
|
86
86
|
"@babel/register": "^7.11.5",
|
|
87
87
|
"@date-io/date-fns": "^2.10.6",
|
|
88
|
-
"@faceless-ui/modal": "
|
|
88
|
+
"@faceless-ui/modal": "^2.0.0-alpha.4",
|
|
89
89
|
"@faceless-ui/scroll-info": "^1.2.3",
|
|
90
90
|
"@faceless-ui/window-info": "^2.0.2",
|
|
91
91
|
"@types/is-plain-object": "^2.0.4",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"express-fileupload": "1.4.0",
|
|
108
108
|
"express-graphql": "0.12.0",
|
|
109
109
|
"express-rate-limit": "^5.1.3",
|
|
110
|
-
"falsey": "^1.0.0",
|
|
111
110
|
"file-loader": "^6.2.0",
|
|
111
|
+
"file-type": "16.5.4",
|
|
112
112
|
"find-up": "4.1.0",
|
|
113
113
|
"flatley": "^5.2.0",
|
|
114
114
|
"fs-extra": "^10.0.0",
|
|
@@ -127,9 +127,9 @@
|
|
|
127
127
|
"json-schema-to-typescript": "^11.0.2",
|
|
128
128
|
"jsonwebtoken": "^8.5.1",
|
|
129
129
|
"jwt-decode": "^3.1.2",
|
|
130
|
+
"md5": "^2.3.0",
|
|
130
131
|
"method-override": "^3.0.0",
|
|
131
132
|
"micro-memoize": "^4.0.9",
|
|
132
|
-
"mime": "^2.5.0",
|
|
133
133
|
"mini-css-extract-plugin": "1.3.3",
|
|
134
134
|
"minimist": "^1.2.0",
|
|
135
135
|
"mkdirp": "^1.0.4",
|