Fix typos in architecture doc (#387)
This commit is contained in:
parent
6d7bf3b186
commit
6cac49f430
@ -4,7 +4,7 @@ Netlify CMS is a React Application, using Redux for state management with immuta
|
||||
|
||||
The core abstractions for content editing are `collections`, `entries` and `widgets`.
|
||||
|
||||
Each `collection` represents a collection of entries. This can either be a collection of similar entries with the same structure, or a set of entries that each of their own structure.
|
||||
Each `collection` represents a collection of entries. This can either be a collection of similar entries with the same structure, or a set of entries where each has their own structure.
|
||||
|
||||
The structure of an entry is defined as a series of fields, each with a `name`, a `label` and a `widget` .
|
||||
|
||||
@ -17,7 +17,7 @@ Entries are loaded and persisted through a `backend` that will typically represe
|
||||
|
||||
**Config:** Holds the environment configuration (backend type, available collections & fields).
|
||||
|
||||
**Collections** List of available collections, its fields and metadata information.
|
||||
**Collections** List of available collections, their fields and metadata information.
|
||||
|
||||
**Entries:** Entries for each field.
|
||||
|
||||
@ -32,12 +32,12 @@ Selectors are functions defined within reducers used to compute derived data fro
|
||||
|
||||
**selectEntries:** Selects all entries for a given collection.
|
||||
|
||||
**getAsset:** Selects a single AssetProxy object for the given URI:
|
||||
**getAsset:** Selects a single AssetProxy object for the given URI.
|
||||
|
||||
## Value Objects:
|
||||
**AssetProxy:** AssetProxy is a Value Object that holds information regarding an asset file (such as an image, for example), whether it's persisted online or hold locally in cache.
|
||||
**AssetProxy:** AssetProxy is a Value Object that holds information regarding an asset file (such as an image, for example), whether it's persisted online or held locally in cache.
|
||||
|
||||
For files persisted online, the AssetProxy only keeps information about it's URI. For local files, the AssetProxy will keep a reference to the actual File object while generating the expected final URIs and on-demand blobs for local preview.
|
||||
For a file persisted online, the AssetProxy only keeps information about its URI. For local files, the AssetProxy will keep a reference to the actual File object while generating the expected final URIs and on-demand blobs for local preview.
|
||||
|
||||
The AssetProxy object can be used directly inside a media tag (such as `<img>`), as it will always return something that can be used by the media tag to render correctly (either the URI for the online file or a single-use blob).
|
||||
|
||||
@ -47,15 +47,15 @@ Components are separated into two main categories: Container components and pres
|
||||
|
||||
### Entry Editing:
|
||||
For either updating an existing entry or creating a new one, the `EntryEditor` is used and the flow is the same:
|
||||
- When mounted, the `EntryPage` container component dispatches the `createDraft` action, setting the `entryDraft` state to a blank state (in case of a new entry) or to a copy of the selected entry (in case of an edit).
|
||||
- The `EntryPage` will also render widgets for each field type in the given entry.
|
||||
- Widgets are used for editing entry fields. There are different widgets for different field types, and they are always defined in a pair containing a `control` and a `preview` components. The control component is responsible for presenting the user with the appropriate interface for manipulating the current field value, while the preview component is responsible for displaying value with the appropriate styling.
|
||||
* When mounted, the `EntryPage` container component dispatches the `createDraft` action, setting the `entryDraft` state to a blank state (in case of a new entry) or to a copy of the selected entry (in case of an edit).
|
||||
* The `EntryPage` will also render widgets for each field type in the given entry.
|
||||
* Widgets are used for editing entry fields. There are different widgets for different field types, and they are always defined in a pair containing a `control` and a `preview` component. The control component is responsible for presenting the user with the appropriate interface for manipulating the current field value, while the preview component is responsible for displaying the value with the appropriate styling.
|
||||
|
||||
#### Widget components implementation:
|
||||
The control component receives 3 callbacks as props: onChange, onAddAsset & onRemoveAsset.
|
||||
- onChange (Required): Should be called when the users changes the current value. It will ultimately end up updating the EntryDraft object in the Redux Store, thus updating the preview component.
|
||||
- onAddAsset & onRemoveAsset (optionals): If the field accepts file uploads for media (images, for example), these callbacks should be invoked with a `AssetProxy` value object. `onAddAsset` will get the current media stored in the Redux state tree while `onRemoveAsset` will remove it. AssetProxy objects are stored in the `Medias` object and referenced in the `EntryDraft` object on the state tree.
|
||||
The control component receives 3 callbacks as props: `onChange`, `onAddAsset` & `onRemoveAsset`.
|
||||
* onChange (Required): Should be called when the users changes the current value. It will ultimately end up updating the EntryDraft object in the Redux Store, thus updating the preview component.
|
||||
* onAddAsset & onRemoveAsset (optionals): If the field accepts file uploads for media (images, for example), these callbacks should be invoked with a `AssetProxy` value object. `onAddAsset` will get the current media stored in the Redux state tree while `onRemoveAsset` will remove it. AssetProxy objects are stored in the `Medias` object and referenced in the `EntryDraft` object on the state tree.
|
||||
|
||||
Both control and preview widgets receive a `getAsset` selector via props. Displaying the media (or its uri) for the user should always be done via `getAsset`, as it returns a AssetProxy that can return the correct value for both medias already persisted on server and cached media not yet uploaded.
|
||||
Both control and preview widgets receive a `getAsset` selector via props. Displaying the media (or its URI) for the user should always be done via `getAsset`, as it returns an AssetProxy that can return the correct value for both medias already persisted on the server and cached media not yet uploaded.
|
||||
|
||||
The actual persistence of the content and medias inserted into the control component are delegated to the backend implementation. The backend will be called with the updated values and a a list of assetProxy objects for each field of the entry, and should return a promise that can resolve into the persisted entry object and the list of the persisted media URIs.
|
||||
|
Loading…
x
Reference in New Issue
Block a user