diff --git a/docs/Summary.md b/docs/Summary.md index 80a0cd247..165fa9274 100644 --- a/docs/Summary.md +++ b/docs/Summary.md @@ -47,6 +47,11 @@ - [Core](./reference/plugins/core.md) +## Utils Reference + +- [Utils](./reference/utils/utils.md) + + ## General - [FAQ](./general/faq.md) diff --git a/docs/reference/Readme.md b/docs/reference/Readme.md index 95d1f4cac..1a7e67f03 100644 --- a/docs/reference/Readme.md +++ b/docs/reference/Readme.md @@ -25,3 +25,5 @@ This is the full reference documentation for all of the pieces of Slate, broken - **Plugins** - [Plugins](./plugins/plugin.md) - [Core](./plugins/core.md) +- **Utils** + - [Utils](./utils/utils.md) diff --git a/docs/reference/models/node.md b/docs/reference/models/node.md index 5eceac228..ed5a52076 100644 --- a/docs/reference/models/node.md +++ b/docs/reference/models/node.md @@ -39,6 +39,15 @@ ## Properties +### `key` +`String` + +A short-lived, unique identifier for the node. + +By default, keys are not meant to be long-lived unique identifiers for nodes that you might store in a database, or elsewhere. They are meant purely to identify a node inside of a single Slate instance. For that reason, they are simply auto-incrementing strings. (eg. `'0'`, `'1'`, `'2'`, ...) + +If you want to make your keys uniqueness long-lived, you'll need to supply your own key generating function via the [`setKeyGenerator`](../utils/utils.md#setkeygenerator) util. + ### `nodes` `Immutable.List` diff --git a/docs/reference/utils/utils.md b/docs/reference/utils/utils.md new file mode 100644 index 000000000..f16ef9897 --- /dev/null +++ b/docs/reference/utils/utils.md @@ -0,0 +1,12 @@ + +# Utils + +These are extra utility functions that ship with Slate that may be useful for certain use cases. + + +## `setKeyGenerator` +`setKeyGenerator(generator: Function) => Void` + +Allows you to specify your own key generating function, instead of using Slate's built-in default generator which simply uses auto-incrementing number strings. (eg. `'0'`, `'1'`, `'2'`, ...) + +This will act globally on all uses of the Slate dependency.