Skip to content

Commit

Permalink
Merge branch 'master' into docs/beta-features/summary-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjagodic authored Jan 29, 2024
2 parents b4a9478 + dffeaea commit de14674
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 78 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
77 changes: 0 additions & 77 deletions website/content/docs/beta-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,91 +93,14 @@ 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
```


## 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 de14674

Please sign in to comment.