1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

update changelog

This commit is contained in:
Ian Storm Taylor 2018-07-27 15:40:07 -07:00
parent 49ee734241
commit 2092981e0c

View File

@ -42,6 +42,7 @@ Additionally, schema rules can now be defined using a `schema.rules` array of ob
// Match all blocks, regardless of type!
match: { object: 'block' },
text: /.../g,
normalize: () => { ... },
}]
}
}
@ -49,6 +50,36 @@ Additionally, schema rules can now be defined using a `schema.rules` array of ob
All of the shorthands like `schema.blocks` and `schema.inlines` are still available, and are simply rewritten to the more flexible `rules` syntax under the covers. These changes are just a small way of making Slate more flexible for advanced use cases when you run into them.
**Schema rule `normalize` functions now receive `SlateError` objects.** Previously they would be called with a signature of `(change, violation, context)`. They are now called with `(change, error)`. This new error is a `SlateError` object with an `error.code` and all of the same context properties.
A normalizer that previously looked like:
```js
{
normalize: (change, violation, context) {
if (violation === 'child_type_invalid') {
const type = index === 0 ? 'title' : 'paragraph'
return change.setNodeByKey(context.child.key, type)
}
}
}
```
Would now look like:
```js
{
normalize: (change, error) {
if (error.code === 'child_type_invalid') {
const type = index === 0 ? 'title' : 'paragraph'
return change.setNodeByKey(error.child.key, type)
}
}
}
```
This is just an attempt to make dealing with normalization errors slightly more idiomatic with how errors are represented in most libraries, in order to not reinvent the wheel unnecessarily.
---
### `0.35.0` — July 27, 2018