Skip to content

Commit

Permalink
fixing merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
privatemaker committed Jan 23, 2024
2 parents 20ac1a3 + 4411cc0 commit 704e641
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 80 deletions.
79 changes: 0 additions & 79 deletions website/content/docs/beta-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,32 +93,12 @@ sections:
- images/image06.png
```

## Custom Mount Element

Decap CMS always creates its own DOM element for mounting the application, which means it always takes over the entire page, and is generally inflexible if you're trying to do something creative, like injecting it into a shared context.

You can now provide your own element for Decap CMS to mount in by setting the target element's ID as `nc-root`. If Decap CMS finds an element with this ID during initialization, it will mount within that element instead of creating its own.





## Image widget file size limit

You can set a limit to as what the maximum file size of a file is that users can upload directly into a image field.

Example config:

```yaml
- label: 'Featured Image'
name: 'thumbnail'
widget: 'image'
default: '/uploads/chocolate-dogecoin.jpg'
media_library:
config:
max_file_size: 512000 # in bytes, only for default media library
```

## Summary string template transformations

You can apply transformations on fields in a summary string template using filter notation syntax.
Expand All @@ -139,62 +119,3 @@ collections:

The above config will transform the title field to uppercase and format the date field using `YYYY-MM-DD` format.
Available transformations are `upper`, `lower`, `date('<format>')`, `default('defaultValue')`, `ternary('valueForTrue','valueForFalse')` and `truncate(<number>)`/`truncate(<number>, '<string>')`

## Registering to CMS Events

You can execute a function when a specific CMS event occurs.

Example usage:

```javascript
CMS.registerEventListener({
name: 'prePublish',
handler: ({ author, entry }) => console.log(JSON.stringify({ author, data: entry.get('data') })),
});
```

Supported events are `prePublish`, `postPublish`, `preUnpublish`, `postUnpublish`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so:

```javascript
CMS.registerEventListener({
name: 'preSave',
handler: ({ entry }) => {
return entry.get('data').set('title', 'new title');
},
});
```

## Dynamic Default Values

When linking to `/admin/#/collections/posts/new` you can pass URL parameters to pre-populate an entry.

For example given the configuration:

```yaml
collections:
- name: posts
label: Posts
folder: content/posts
create: true
fields:
- label: Title
name: title
widget: string
- label: Object
name: object
widget: object
fields:
- label: Title
name: title
widget: string
- label: body
name: body
widget: markdown
```

clicking the following link: `/#/collections/posts/new?title=first&object.title=second&body=%23%20content`

will open the editor for a new post with the `title` field populated with `first`, the nested `object.title` field
with `second` and the markdown `body` field with `# content`.

**Note:** URL Encoding might be required for certain values (e.g. in the previous example the value for `body` is URL encoded).
17 changes: 17 additions & 0 deletions website/content/docs/custom-mounting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Custom Mount Element
weight: 90
group: Customization
---

Decap CMS always creates its own DOM element for mounting the application, which means it always takes over the entire page, and is generally inflexible if you're trying to do something creative, like injecting it into a shared context.

You can now provide your own element for Decap CMS to mount in by setting the target element's ID as `id="nc-root"`. If Decap CMS finds an element with this ID during initialization, it will mount within that element instead of creating its own.

This is useful if you want to create a wrapper around the CMS, like a custom header, footer, or sidebar.

**Example**

Adding the following div to `admin/index.html` will cause the CMS to load within it:

<div id="nc-root"></div>
38 changes: 38 additions & 0 deletions website/content/docs/dynamic-default-values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Dynamic Default Values
group: Fields
weight: 30
---

When linking to `/admin/#/collections/posts/new` you can pass URL parameters to pre-populate an entry.

For example given the configuration:

```yaml
collections:
- name: posts
label: Posts
folder: content/posts
create: true
fields:
- label: Title
name: title
widget: string
- label: Object
name: object
widget: object
fields:
- label: Title
name: title
widget: string
- label: body
name: body
widget: markdown
```
clicking the following link: `/#/collections/posts/new?title=first&object.title=second&body=%23%20content`

will open the editor for a new post with the `title` field populated with `first`, the nested `object.title` field
with `second` and the markdown `body` field with `# content`.

**Note:** URL Encoding might be required for certain values (e.g. in the previous example the value for `body` is URL encoded).
27 changes: 27 additions & 0 deletions website/content/docs/registering-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Registering to CMS Events
weight: 80
group: Customization
---

You can execute a function when a specific CMS event occurs.

Example usage:

```javascript
CMS.registerEventListener({
name: 'prePublish',
handler: ({ author, entry }) => console.log(JSON.stringify({ author, data: entry.get('data') })),
});
```

Supported events are `prePublish`, `postPublish`, `preUnpublish`, `postUnpublish`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so:

```javascript
CMS.registerEventListener({
name: 'preSave',
handler: ({ entry }) => {
return entry.get('data').set('title', 'new title');
},
});
```
12 changes: 12 additions & 0 deletions website/content/docs/widgets/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ The file widget allows editors to upload a file or select an existing one from t
config:
multiple: true
```
### File Size Limit
You can set a limit to as what the maximum file size of a file is that users can upload directly into a file field.
**Example**
```yaml
media_library:
config:
max_file_size: 1024000 # in bytes, only for default media library
```
14 changes: 13 additions & 1 deletion website/content/docs/widgets/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ The image widget allows editors to upload an image or select an existing one fro
media_library:
config:
multiple: true
```
```
### Image Size Limit
You can set a limit to as what the maximum file size of a file is that users can upload directly into a image field.
**Example**
```yaml
media_library:
config:
max_file_size: 512000 # in bytes, only for default media library
```

0 comments on commit 704e641

Please sign in to comment.