diff --git a/packages/decap-cms-locales/src/zh_Hans/index.js b/packages/decap-cms-locales/src/zh_Hans/index.js index a4b951828670..d188cb02c6dd 100644 --- a/packages/decap-cms-locales/src/zh_Hans/index.js +++ b/packages/decap-cms-locales/src/zh_Hans/index.js @@ -93,6 +93,8 @@ const zh_Hans = { }, i18n: { writingInLocale: '正在使用%{locale}撰写', + copyFromLocale: '用其他语言进行填充', + copyFromLocaleConfirm: '你确定要用“%{locale}”进行填充吗?\n这将会覆盖所有现有的内容。', }, }, editor: { diff --git a/packages/decap-cms-locales/src/zh_Hant/index.js b/packages/decap-cms-locales/src/zh_Hant/index.js index df602068336e..0c59e47c5935 100644 --- a/packages/decap-cms-locales/src/zh_Hant/index.js +++ b/packages/decap-cms-locales/src/zh_Hant/index.js @@ -87,6 +87,8 @@ const zh_Hant = { }, i18n: { writingInLocale: '以 %{locale} 書寫', + copyFromLocale: '用其他語言進行填充', + copyFromLocaleConfirm: '你確定要用“%{locale}”進行填充嗎?\n這將會覆蓋所有現有的內容。', }, }, editor: { diff --git a/website/content/docs/beta-features.md b/website/content/docs/beta-features.md index 4cc55d3f8cbd..265934ebfc42 100644 --- a/website/content/docs/beta-features.md +++ b/website/content/docs/beta-features.md @@ -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 diff --git a/website/content/docs/custom-mounting.md b/website/content/docs/custom-mounting.md new file mode 100644 index 000000000000..fd8c5c5552ad --- /dev/null +++ b/website/content/docs/custom-mounting.md @@ -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: + +
diff --git a/website/content/docs/dynamic-default-values.md b/website/content/docs/dynamic-default-values.md new file mode 100644 index 000000000000..775886150ca8 --- /dev/null +++ b/website/content/docs/dynamic-default-values.md @@ -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). diff --git a/website/content/docs/registering-events.md b/website/content/docs/registering-events.md new file mode 100644 index 000000000000..34556b49be7c --- /dev/null +++ b/website/content/docs/registering-events.md @@ -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'); + }, +}); +``` diff --git a/website/content/docs/widgets/file.md b/website/content/docs/widgets/file.md index 3df31c7de762..4987407064b5 100644 --- a/website/content/docs/widgets/file.md +++ b/website/content/docs/widgets/file.md @@ -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 +``` diff --git a/website/content/docs/widgets/image.md b/website/content/docs/widgets/image.md index 5236c0b2ed13..5151412061e5 100644 --- a/website/content/docs/widgets/image.md +++ b/website/content/docs/widgets/image.md @@ -28,4 +28,16 @@ The image widget allows editors to upload an image or select an existing one fro media_library: config: multiple: true -``` \ No newline at end of file +``` + +### 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 +```