Skip to content

Commit

Permalink
Merge branch 'master' into docs/beta-features/widget-variable-types
Browse files Browse the repository at this point in the history
  • Loading branch information
privatemaker committed Jan 29, 2024
2 parents 3f9e426 + dffeaea commit cc5e107
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 87 deletions.
2 changes: 2 additions & 0 deletions packages/decap-cms-locales/src/zh_Hans/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const zh_Hans = {
},
i18n: {
writingInLocale: '正在使用%{locale}撰写',
copyFromLocale: '用其他语言进行填充',
copyFromLocaleConfirm: '你确定要用“%{locale}”进行填充吗?\n这将会覆盖所有现有的内容。',
},
},
editor: {
Expand Down
2 changes: 2 additions & 0 deletions packages/decap-cms-locales/src/zh_Hant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const zh_Hant = {
},
i18n: {
writingInLocale: '以 %{locale} 書寫',
copyFromLocale: '用其他語言進行填充',
copyFromLocaleConfirm: '你確定要用“%{locale}”進行填充嗎?\n這將會覆蓋所有現有的內容。',
},
},
editor: {
Expand Down
86 changes: 0 additions & 86 deletions website/content/docs/beta-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,6 @@ We run new functionality in an open beta format from time to time. That means th






## 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 @@ -59,64 +30,7 @@ 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).


## Remark plugins
Expand Down
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 cc5e107

Please sign in to comment.